index
int64
0
66.5k
func_name
stringlengths
2
5.36k
func_dep
stringlengths
16
2.19k
func
stringlengths
8
55.3k
test
stringlengths
0
7.07k
opt
stringclasses
4 values
language
stringclasses
2 values
asm
stringlengths
0
45.4k
ida_asm
stringlengths
0
44.7k
ida_pseudo
stringlengths
0
44.3k
ghidra_asm
stringlengths
0
49.1k
ghidra_pseudo
stringlengths
0
64.7k
3,882
func0
#include <iostream> #include <vector> #include <algorithm> #include <assert.h>
int func0(int n, int a, int b, int c) { std::vector<int> dp(n + 10, -1); dp[0] = 0; for (int i = 0; i < n; i++) { if (dp[i] != -1) { if (i + a <= n) { dp[i + a] = std::max(dp[i] + 1, dp[i + a]); } if (i + b <= n) { dp[i + b] = std::max(dp[i] + 1, dp[i + b]); } if (i + c <= n) { dp[i + c] = std::max(dp[i] + 1, dp[i + c]); } } } return dp[n]; }
int main() { assert(func0(7, 5, 2, 5) == 2); assert(func0(17, 2, 1, 3) == 17); assert(func0(18, 16, 3, 6) == 6); return 0; }
O2
cpp
func0(int, int, int, int): endbr64 movabs $0x1fffffffffffffff,%rax push %r14 lea 0xa(%rdi),%r14d movslq %r14d,%r14 push %r13 push %r12 push %rbp push %rbx cmp %rax,%r14 ja 141d <_Z5func0iiii+0x11d> test %r14,%r14 je 1410 <_Z5func0iiii+0x110> shl $0x2,%r14 mov %edi,%ebx mov %esi,%ebp mov %edx,%r12d mov %r14,%rdi mov %ecx,%r13d callq 10e0 <_Znwm@plt> mov %rax,%rdi lea (%rax,%r14,1),%rax mov %rdi,%r8 movl $0xffffffff,(%r8) add $0x4,%r8 cmp %rax,%r8 jne 1350 <_Z5func0iiii+0x50> movl $0x0,(%rdi) test %ebx,%ebx jle 13f3 <_Z5func0iiii+0xf3> lea -0x1(%rbx),%edx xor %r8d,%r8d xor %r10d,%r10d jmp 1387 <_Z5func0iiii+0x87> nopl 0x0(%rax) mov (%rdi,%rax,4),%r10d mov %rax,%r8 cmp $0xffffffff,%r10d je 13ea <_Z5func0iiii+0xea> lea 0x0(%rbp,%r8,1),%eax mov %r8d,%r9d cmp %eax,%ebx jl 13ad <_Z5func0iiii+0xad> cltq add $0x1,%r10d lea (%rdi,%rax,4),%rax cmp %r10d,(%rax) cmovge (%rax),%r10d mov %r10d,(%rax) lea (%r12,%r9,1),%eax cmp %eax,%ebx jl 13cb <_Z5func0iiii+0xcb> cltq lea (%rdi,%rax,4),%rcx mov (%rdi,%r8,4),%eax mov (%rcx),%esi add $0x1,%eax cmp %esi,%eax cmovl %esi,%eax mov %eax,(%rcx) add %r13d,%r9d cmp %ebx,%r9d jg 13ea <_Z5func0iiii+0xea> movslq %r9d,%r9 mov (%rdi,%r8,4),%eax lea (%rdi,%r9,4),%rcx mov (%rcx),%esi add $0x1,%eax cmp %esi,%eax cmovl %esi,%eax mov %eax,(%rcx) lea 0x1(%r8),%rax cmp %rdx,%r8 jne 1380 <_Z5func0iiii+0x80> mov -0x28(%rdi,%r14,1),%r12d callq 10d0 <_ZdlPv@plt> pop %rbx pop %rbp mov %r12d,%eax pop %r12 pop %r13 pop %r14 retq nopl 0x0(%rax) movl $0x0,0x0 ud2 lea 0xbe4(%rip),%rdi callq 10a0 <_ZSt20__throw_length_errorPKc@plt> nopl 0x0(%rax)
_Z5func0iiii: endbr64 push r15 push r14 push r13 push r12 lea r12d, [rdi+0Ah] push rbp movsxd r12, r12d push rbx mov rax, r12 sub rsp, 8 shr rax, 3Dh jnz loc_13BD test r12, r12 jz loc_13B0 shl r12, 2 mov ebp, edi mov r13d, esi mov r14d, edx mov rdi, r12; unsigned __int64 mov r15d, ecx call __Znwm; operator new(ulong) mov rdx, r12; n mov esi, 0FFh; c mov rbx, rax mov rdi, rax; s call _memset mov dword ptr [rbx], 0 mov rdi, rbx; void * test ebp, ebp jle loc_138E mov ecx, r15d mov edx, r14d lea r8, [rbx+r12-28h] mov eax, r13d nop dword ptr [rax+rax+00000000h] loc_1320: mov esi, [rbx] cmp esi, 0FFFFFFFFh jz short loc_137C cmp eax, ebp jg short loc_1342 movsxd r9, eax add esi, 1 lea r9, [rdi+r9*4] mov r10d, [r9] cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_1342: cmp edx, ebp jg short loc_135F movsxd rsi, edx lea r9, [rdi+rsi*4] mov esi, [rbx] mov r10d, [r9] add esi, 1 cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_135F: cmp ecx, ebp jg short loc_137C movsxd rsi, ecx lea r9, [rdi+rsi*4] mov esi, [rbx] mov r10d, [r9] add esi, 1 cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_137C: add rbx, 4 add ecx, 1 add edx, 1 add eax, 1 cmp r8, rbx jnz short loc_1320 loc_138E: mov ebx, [rdi+r12-28h] mov rsi, r12; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) add rsp, 8 mov eax, ebx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_13B0: mov ds:dword_0, 0 ud2 loc_13BD: lea rdi, aCannotCreateSt; "cannot create std::vector larger than m"... call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*)
long long func0(int a1, int a2, int a3, int a4) { unsigned long long v4; // r12 _DWORD *v8; // rbx char *v9; // rdi int v10; // ecx int v11; // edx long long v12; // r8 int v14; // esi int *v15; // r9 int *v16; // r9 int v17; // esi int *v18; // r9 int v19; // esi unsigned int v20; // ebx if ( (unsigned long long)(a1 + 10) >> 61 ) std::__throw_length_error("cannot create std::vector larger than max_size()"); if ( a1 == -10 ) { dword_0 = 0; BUG(); } v4 = 4LL * (a1 + 10); v8 = (_DWORD *)operator new(v4); memset(v8, 255, v4); *v8 = 0; v9 = (char *)v8; if ( a1 > 0 ) { v10 = a4; v11 = a3; v12 = (long long)&v8[v4 / 4 - 10]; do { if ( *v8 != -1 ) { if ( a2 <= a1 ) { v14 = *v8 + 1; v15 = (int *)&v9[4 * a2]; if ( v14 < *v15 ) v14 = *v15; *v15 = v14; } if ( v11 <= a1 ) { v16 = (int *)&v9[4 * v11]; v17 = *v8 + 1; if ( v17 < *v16 ) v17 = *v16; *v16 = v17; } if ( v10 <= a1 ) { v18 = (int *)&v9[4 * v10]; v19 = *v8 + 1; if ( v19 < *v18 ) v19 = *v18; *v18 = v19; } } ++v8; ++v10; ++v11; ++a2; } while ( (_DWORD *)v12 != v8 ); } v20 = *(_DWORD *)&v9[v4 - 40]; operator delete(v9, v4); return v20; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 LEA R12D,[RDI + 0xa] PUSH RBP MOVSXD R12,R12D PUSH RBX MOV RAX,R12 SUB RSP,0x8 SHR RAX,0x3d JNZ 0x001013bd TEST R12,R12 JZ 0x001013b0 SHL R12,0x2 MOV EBP,EDI MOV R13D,ESI MOV R14D,EDX MOV RDI,R12 MOV R15D,ECX CALL 0x001010c0 MOV RDX,R12 MOV ESI,0xff MOV RBX,RAX MOV RDI,RAX CALL 0x001010a0 MOV dword ptr [RBX],0x0 MOV RDI,RBX TEST EBP,EBP JLE 0x0010138e MOV ECX,R15D MOV EDX,R14D LEA R8,[RBX + R12*0x1 + -0x28] MOV EAX,R13D NOP dword ptr [RAX + RAX*0x1] LAB_00101320: MOV ESI,dword ptr [RBX] CMP ESI,-0x1 JZ 0x0010137c CMP EAX,EBP JG 0x00101342 MOVSXD R9,EAX ADD ESI,0x1 LEA R9,[RDI + R9*0x4] MOV R10D,dword ptr [R9] CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_00101342: CMP EDX,EBP JG 0x0010135f MOVSXD RSI,EDX LEA R9,[RDI + RSI*0x4] MOV ESI,dword ptr [RBX] MOV R10D,dword ptr [R9] ADD ESI,0x1 CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_0010135f: CMP ECX,EBP JG 0x0010137c MOVSXD RSI,ECX LEA R9,[RDI + RSI*0x4] MOV ESI,dword ptr [RBX] MOV R10D,dword ptr [R9] ADD ESI,0x1 CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_0010137c: ADD RBX,0x4 ADD ECX,0x1 ADD EDX,0x1 ADD EAX,0x1 CMP R8,RBX JNZ 0x00101320 LAB_0010138e: MOV EBX,dword ptr [RDI + R12*0x1 + -0x28] MOV RSI,R12 CALL 0x001010d0 ADD RSP,0x8 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001013b0: MOV dword ptr [0x00000000],0x0 UD2 LAB_001013bd: LEA RDI,[0x102008] CALL 0x00101090
/* WARNING: Control flow encountered bad instruction data */ /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(int, int, int, int) */ int func0(int param_1,int param_2,int param_3,int param_4) { int iVar1; code *pcVar2; int *__s; int *piVar3; int iVar4; ulong uVar5; ulong __n; uVar5 = (ulong)(param_1 + 10); if (uVar5 >> 0x3d != 0) { std::__throw_length_error("cannot create std::vector larger than max_size()"); /* WARNING: Bad instruction - Truncating control flow here */ halt_baddata(); } if (uVar5 != 0) { __n = uVar5 * 4; __s = (int *)operator_new(__n); memset(__s,0xff,__n); *__s = 0; if (0 < param_1) { piVar3 = __s; do { if (*piVar3 != -1) { if (param_2 <= param_1) { iVar4 = *piVar3 + 1; iVar1 = __s[param_2]; if (iVar4 < iVar1) { iVar4 = iVar1; } __s[param_2] = iVar4; } if (param_3 <= param_1) { iVar1 = __s[param_3]; iVar4 = *piVar3 + 1; if (*piVar3 + 1 < iVar1) { iVar4 = iVar1; } __s[param_3] = iVar4; } if (param_4 <= param_1) { iVar1 = __s[param_4]; iVar4 = *piVar3 + 1; if (*piVar3 + 1 < iVar1) { iVar4 = iVar1; } __s[param_4] = iVar4; } } piVar3 = piVar3 + 1; param_4 = param_4 + 1; param_3 = param_3 + 1; param_2 = param_2 + 1; } while (__s + (uVar5 - 10) != piVar3); } iVar1 = __s[uVar5 - 10]; operator_delete(__s,__n); return iVar1; } _DAT_00000000 = 0; /* WARNING: Does not return */ pcVar2 = (code *)invalidInstructionException(); (*pcVar2)(); }
3,883
func0
#include <iostream> #include <vector> #include <algorithm> #include <assert.h>
int func0(int n, int a, int b, int c) { std::vector<int> dp(n + 10, -1); dp[0] = 0; for (int i = 0; i < n; i++) { if (dp[i] != -1) { if (i + a <= n) { dp[i + a] = std::max(dp[i] + 1, dp[i + a]); } if (i + b <= n) { dp[i + b] = std::max(dp[i] + 1, dp[i + b]); } if (i + c <= n) { dp[i + c] = std::max(dp[i] + 1, dp[i + c]); } } } return dp[n]; }
int main() { assert(func0(7, 5, 2, 5) == 2); assert(func0(17, 2, 1, 3) == 17); assert(func0(18, 16, 3, 6) == 6); return 0; }
O3
cpp
func0(int, int, int, int): endbr64 movabs $0x1fffffffffffffff,%rax push %r14 lea 0xa(%rdi),%r14d movslq %r14d,%r14 push %r13 push %r12 push %rbp push %rbx cmp %rax,%r14 ja 1425 <_Z5func0iiii+0x105> test %r14,%r14 je 1418 <_Z5func0iiii+0xf8> shl $0x2,%r14 mov %edi,%ebx mov %esi,%ebp mov %edx,%r12d mov %r14,%rdi mov %ecx,%r13d callq 1100 <_Znwm@plt> mov %r14,%rdx mov $0xff,%esi mov %rax,%rdi callq 10c0 <memset@plt> movl $0x0,(%rax) mov %rax,%rdi test %ebx,%ebx jle 13fd <_Z5func0iiii+0xdd> lea -0x1(%rbx),%r8d xor %eax,%eax jmp 1393 <_Z5func0iiii+0x73> nopw 0x0(%rax,%rax,1) mov %rdx,%rax mov (%rdi,%rax,4),%esi cmp $0xffffffff,%esi je 13f4 <_Z5func0iiii+0xd4> lea 0x0(%rbp,%rax,1),%ecx mov %eax,%edx cmp %ebx,%ecx jg 13b6 <_Z5func0iiii+0x96> movslq %ecx,%rcx add $0x1,%esi lea (%rdi,%rcx,4),%rcx cmp %esi,(%rcx) cmovge (%rcx),%esi mov %esi,(%rcx) lea (%r12,%rdx,1),%ecx cmp %ecx,%ebx jl 13d7 <_Z5func0iiii+0xb7> movslq %ecx,%rcx lea (%rdi,%rcx,4),%rsi mov (%rdi,%rax,4),%ecx mov (%rsi),%r9d add $0x1,%ecx cmp %r9d,%ecx cmovl %r9d,%ecx mov %ecx,(%rsi) add %r13d,%edx cmp %ebx,%edx jg 13f4 <_Z5func0iiii+0xd4> mov (%rdi,%rax,4),%esi movslq %edx,%rdx lea (%rdi,%rdx,4),%rcx lea 0x1(%rsi),%edx mov (%rcx),%esi cmp %esi,%edx cmovl %esi,%edx mov %edx,(%rcx) lea 0x1(%rax),%rdx cmp %r8,%rax jne 1390 <_Z5func0iiii+0x70> mov -0x28(%rdi,%r14,1),%r12d callq 10f0 <_ZdlPv@plt> pop %rbx pop %rbp mov %r12d,%eax pop %r12 pop %r13 pop %r14 retq nopl 0x0(%rax,%rax,1) movl $0x0,0x0 ud2 lea 0xbdc(%rip),%rdi callq 10b0 <_ZSt20__throw_length_errorPKc@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
_Z5func0iiii: endbr64 push r15 push r14 push r13 push r12 lea r12d, [rdi+0Ah] push rbp movsxd r12, r12d push rbx mov rax, r12 sub rsp, 8 shr rax, 3Dh jnz loc_13BD test r12, r12 jz loc_13B0 shl r12, 2 mov ebp, edi mov r13d, esi mov r14d, edx mov rdi, r12; unsigned __int64 mov r15d, ecx call __Znwm; operator new(ulong) mov rdx, r12; n mov esi, 0FFh; c mov rbx, rax mov rdi, rax; s call _memset mov dword ptr [rbx], 0 mov rdi, rbx; void * test ebp, ebp jle loc_138E mov ecx, r15d mov edx, r14d lea r8, [rbx+r12-28h] mov eax, r13d nop dword ptr [rax+rax+00000000h] loc_1320: mov esi, [rbx] cmp esi, 0FFFFFFFFh jz short loc_137C cmp eax, ebp jg short loc_1342 movsxd r9, eax add esi, 1 lea r9, [rdi+r9*4] mov r10d, [r9] cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_1342: cmp edx, ebp jg short loc_135F movsxd rsi, edx lea r9, [rdi+rsi*4] mov esi, [rbx] mov r10d, [r9] add esi, 1 cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_135F: cmp ecx, ebp jg short loc_137C movsxd rsi, ecx lea r9, [rdi+rsi*4] mov esi, [rbx] mov r10d, [r9] add esi, 1 cmp esi, r10d cmovl esi, r10d mov [r9], esi loc_137C: add rbx, 4 add ecx, 1 add edx, 1 add eax, 1 cmp rbx, r8 jnz short loc_1320 loc_138E: mov ebx, [rdi+r12-28h] mov rsi, r12; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) add rsp, 8 mov eax, ebx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_13B0: mov ds:dword_0, 0 ud2 loc_13BD: lea rdi, aCannotCreateSt; "cannot create std::vector larger than m"... call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*)
long long func0(int a1, int a2, int a3, int a4) { unsigned long long v4; // r12 _DWORD *v8; // rbx char *v9; // rdi int v10; // ecx int v11; // edx long long v12; // r8 int v14; // esi int *v15; // r9 int *v16; // r9 int v17; // esi int *v18; // r9 int v19; // esi unsigned int v20; // ebx if ( (unsigned long long)(a1 + 10) >> 61 ) std::__throw_length_error("cannot create std::vector larger than max_size()"); if ( a1 == -10 ) { dword_0 = 0; BUG(); } v4 = 4LL * (a1 + 10); v8 = (_DWORD *)operator new(v4); memset(v8, 255, v4); *v8 = 0; v9 = (char *)v8; if ( a1 > 0 ) { v10 = a4; v11 = a3; v12 = (long long)&v8[v4 / 4 - 10]; do { if ( *v8 != -1 ) { if ( a2 <= a1 ) { v14 = *v8 + 1; v15 = (int *)&v9[4 * a2]; if ( v14 < *v15 ) v14 = *v15; *v15 = v14; } if ( v11 <= a1 ) { v16 = (int *)&v9[4 * v11]; v17 = *v8 + 1; if ( v17 < *v16 ) v17 = *v16; *v16 = v17; } if ( v10 <= a1 ) { v18 = (int *)&v9[4 * v10]; v19 = *v8 + 1; if ( v19 < *v18 ) v19 = *v18; *v18 = v19; } } ++v8; ++v10; ++v11; ++a2; } while ( v8 != (_DWORD *)v12 ); } v20 = *(_DWORD *)&v9[v4 - 40]; operator delete(v9, v4); return v20; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 LEA R12D,[RDI + 0xa] PUSH RBP MOVSXD R12,R12D PUSH RBX MOV RAX,R12 SUB RSP,0x8 SHR RAX,0x3d JNZ 0x001013bd TEST R12,R12 JZ 0x001013b0 SHL R12,0x2 MOV EBP,EDI MOV R13D,ESI MOV R14D,EDX MOV RDI,R12 MOV R15D,ECX CALL 0x001010c0 MOV RDX,R12 MOV ESI,0xff MOV RBX,RAX MOV RDI,RAX CALL 0x001010a0 MOV dword ptr [RBX],0x0 MOV RDI,RBX TEST EBP,EBP JLE 0x0010138e MOV ECX,R15D MOV EDX,R14D LEA R8,[RBX + R12*0x1 + -0x28] MOV EAX,R13D NOP dword ptr [RAX + RAX*0x1] LAB_00101320: MOV ESI,dword ptr [RBX] CMP ESI,-0x1 JZ 0x0010137c CMP EAX,EBP JG 0x00101342 MOVSXD R9,EAX ADD ESI,0x1 LEA R9,[RDI + R9*0x4] MOV R10D,dword ptr [R9] CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_00101342: CMP EDX,EBP JG 0x0010135f MOVSXD RSI,EDX LEA R9,[RDI + RSI*0x4] MOV ESI,dword ptr [RBX] MOV R10D,dword ptr [R9] ADD ESI,0x1 CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_0010135f: CMP ECX,EBP JG 0x0010137c MOVSXD RSI,ECX LEA R9,[RDI + RSI*0x4] MOV ESI,dword ptr [RBX] MOV R10D,dword ptr [R9] ADD ESI,0x1 CMP ESI,R10D CMOVL ESI,R10D MOV dword ptr [R9],ESI LAB_0010137c: ADD RBX,0x4 ADD ECX,0x1 ADD EDX,0x1 ADD EAX,0x1 CMP RBX,R8 JNZ 0x00101320 LAB_0010138e: MOV EBX,dword ptr [RDI + R12*0x1 + -0x28] MOV RSI,R12 CALL 0x001010d0 ADD RSP,0x8 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001013b0: MOV dword ptr [0x00000000],0x0 UD2 LAB_001013bd: LEA RDI,[0x102008] CALL 0x00101090
/* WARNING: Control flow encountered bad instruction data */ /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(int, int, int, int) */ int func0(int param_1,int param_2,int param_3,int param_4) { int iVar1; code *pcVar2; int *__s; int *piVar3; int iVar4; ulong uVar5; ulong __n; uVar5 = (ulong)(param_1 + 10); if (uVar5 >> 0x3d != 0) { std::__throw_length_error("cannot create std::vector larger than max_size()"); /* WARNING: Bad instruction - Truncating control flow here */ halt_baddata(); } if (uVar5 != 0) { __n = uVar5 * 4; __s = (int *)operator_new(__n); memset(__s,0xff,__n); *__s = 0; if (0 < param_1) { piVar3 = __s; do { if (*piVar3 != -1) { if (param_2 <= param_1) { iVar4 = *piVar3 + 1; iVar1 = __s[param_2]; if (iVar4 < iVar1) { iVar4 = iVar1; } __s[param_2] = iVar4; } if (param_3 <= param_1) { iVar1 = __s[param_3]; iVar4 = *piVar3 + 1; if (*piVar3 + 1 < iVar1) { iVar4 = iVar1; } __s[param_3] = iVar4; } if (param_4 <= param_1) { iVar1 = __s[param_4]; iVar4 = *piVar3 + 1; if (*piVar3 + 1 < iVar1) { iVar4 = iVar1; } __s[param_4] = iVar4; } } piVar3 = piVar3 + 1; param_4 = param_4 + 1; param_3 = param_3 + 1; param_2 = param_2 + 1; } while (piVar3 != __s + (uVar5 - 10)); } iVar1 = __s[uVar5 - 10]; operator_delete(__s,__n); return iVar1; } _DAT_00000000 = 0; /* WARNING: Does not return */ pcVar2 = (code *)invalidInstructionException(); (*pcVar2)(); }
3,884
func0
#include <vector> #include <cassert>
std::vector<int> func0(std::vector<int> test_tup1, std::vector<int> test_tup2) { std::vector<int> res = test_tup1; res.insert(res.end(), test_tup2.begin(), test_tup2.end()); return res; }
int main() { assert((func0({3, 4}, {5, 6}) == std::vector<int>{3, 4, 5, 6})); assert((func0({1, 2}, {3, 4}) == std::vector<int>{1, 2, 3, 4})); assert((func0({4, 5}, {6, 8}) == std::vector<int>{4, 5, 6, 8})); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >): endbr64 push %rbp mov %rsp,%rbp push %r12 push %rbx sub $0x40,%rsp mov %rdi,-0x38(%rbp) mov %rsi,-0x40(%rbp) mov %rdx,-0x48(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x40(%rbp),%rdx mov -0x38(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1ba0 <_ZNSt6vectorIiSaIiEEC1ERKS1_> mov -0x48(%rbp),%rax mov %rax,%rdi callq 1d08 <_ZNSt6vectorIiSaIiEE3endEv> mov %rax,%r12 mov -0x48(%rbp),%rax mov %rax,%rdi callq 1d58 <_ZNSt6vectorIiSaIiEE5beginEv> mov %rax,%rbx mov -0x38(%rbp),%rax mov %rax,%rdi callq 1d08 <_ZNSt6vectorIiSaIiEE3endEv> mov %rax,-0x28(%rbp) lea -0x28(%rbp),%rdx lea -0x20(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1da4 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEC1IPiEERKNS0_IT_NS_11__enable_ifIXsrSt10__are_sameIS9_S8_E7__valueES5_E6__typeEEE> mov -0x20(%rbp),%rsi mov -0x38(%rbp),%rax mov %r12,%rcx mov %rbx,%rdx mov %rax,%rdi callq 1dd2 <_ZNSt6vectorIiSaIiEE6insertIN9__gnu_cxx17__normal_iteratorIPiS1_EEvEES6_NS4_IPKiS1_EET_SA_> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 1372 <_Z5func0St6vectorIiSaIiEES1_+0xc9> jmp 136d <_Z5func0St6vectorIiSaIiEES1_+0xc4> endbr64 mov %rax,%rbx mov -0x38(%rbp),%rax mov %rax,%rdi callq 1cc0 <_ZNSt6vectorIiSaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 11b0 <_Unwind_Resume@plt> callq 1170 <__stack_chk_fail@plt> mov -0x38(%rbp),%rax add $0x40,%rsp pop %rbx pop %r12 pop %rbp retq
_Z5func0St6vectorIiSaIiEES1_: endbr64 push rbp mov rbp, rsp push r12 push rbx sub rsp, 40h mov [rbp+var_38], rdi mov [rbp+var_40], rsi mov [rbp+var_48], rdx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rdx, [rbp+var_40] mov rax, [rbp+var_38] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEC2ERKS1_; std::vector<int>::vector(std::vector<int> const&) mov rax, [rbp+var_48] mov rdi, rax call _ZNSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov r12, rax mov rax, [rbp+var_48] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rbx, rax mov rax, [rbp+var_38] mov rdi, rax call _ZNSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_28], rax lea rdx, [rbp+var_28] lea rax, [rbp+var_20] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEC2IPivEERKNS0_IT_S5_EE; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::__normal_iterator<int *,void>(__gnu_cxx::__normal_iterator<int *,std::vector<int>> const&) mov rsi, [rbp+var_20] mov rax, [rbp+var_38] mov rcx, r12 mov rdx, rbx mov rdi, rax call _ZNSt6vectorIiSaIiEE6insertIN9__gnu_cxx17__normal_iteratorIPiS1_EEvEES6_NS4_IPKiS1_EET_SA_; std::vector<int>::insert<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,void>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) nop mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_13A6 jmp short loc_13A1 endbr64 mov rbx, rax mov rax, [rbp+var_38] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1399 call ___stack_chk_fail loc_1399: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_13A1: call ___stack_chk_fail loc_13A6: mov rax, [rbp+var_38] add rsp, 40h pop rbx pop r12 pop rbp retn
long long func0(long long a1, long long a2, long long a3) { long long v3; // r12 long long v4; // rbx long long v7; // [rsp+28h] [rbp-28h] BYREF _QWORD v8[4]; // [rsp+30h] [rbp-20h] BYREF v8[1] = __readfsqword(0x28u); std::vector<int>::vector(a1, a2); v3 = std::vector<int>::end(a3); v4 = std::vector<int>::begin(a3); v7 = std::vector<int>::end(a1); __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::__normal_iterator<int *,void>(v8, &v7); std::vector<int>::insert<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,void>(a1, v8[0], v4, v3); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R12 PUSH RBX SUB RSP,0x40 MOV qword ptr [RBP + -0x38],RDI MOV qword ptr [RBP + -0x40],RSI MOV qword ptr [RBP + -0x48],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RDX,qword ptr [RBP + -0x40] MOV RAX,qword ptr [RBP + -0x38] MOV RSI,RDX MOV RDI,RAX LAB_00101301: CALL 0x00101c3e MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x00101e00 MOV R12,RAX MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x00101e50 MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x00101e00 MOV qword ptr [RBP + -0x28],RAX LEA RDX,[RBP + -0x28] LEA RAX,[RBP + -0x20] MOV RSI,RDX MOV RDI,RAX CALL 0x00101e9c MOV RSI,qword ptr [RBP + -0x20] MOV RAX,qword ptr [RBP + -0x38] MOV RCX,R12 MOV RDX,RBX MOV RDI,RAX LAB_00101358: CALL 0x00101eca NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001013a6 JMP 0x001013a1 LAB_001013a1: CALL 0x00101190 LAB_001013a6: MOV RAX,qword ptr [RBP + -0x38] ADD RSP,0x40 POP RBX POP R12 POP RBP RET
/* func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >) */ vector<int,std::allocator<int>> * func0(vector param_1,vector param_2) { int8 uVar1; int8 uVar2; vector<int,std::allocator<int>> *in_RDX; int4 in_register_00000034; int4 in_register_0000003c; vector<int,std::allocator<int>> *this; long in_FS_OFFSET; int8 local_30; int8 local_28; long local_20; this = (vector<int,std::allocator<int>> *)CONCAT44(in_register_0000003c,param_1); local_20 = *(long *)(in_FS_OFFSET + 0x28); std::vector<int,std::allocator<int>>::vector (this,(vector *)CONCAT44(in_register_00000034,param_2)); uVar1 = std::vector<int,std::allocator<int>>::end(in_RDX); uVar2 = std::vector<int,std::allocator<int>>::begin(in_RDX); local_30 = std::vector<int,std::allocator<int>>::end(this); __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::__normal_iterator<int*,void> ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_28, (__normal_iterator *)&local_30); /* try { // try from 00101358 to 0010135c has its CatchHandler @ 0010136f */ std::vector<int,std::allocator<int>>:: insert<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,void> (this,local_28,uVar2,uVar1); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return this; }
3,885
func0
#include <vector> #include <cassert>
std::vector<int> func0(std::vector<int> test_tup1, std::vector<int> test_tup2) { std::vector<int> res = test_tup1; res.insert(res.end(), test_tup2.begin(), test_tup2.end()); return res; }
int main() { assert((func0({3, 4}, {5, 6}) == std::vector<int>{3, 4, 5, 6})); assert((func0({1, 2}, {3, 4}) == std::vector<int>{1, 2, 3, 4})); assert((func0({4, 5}, {6, 8}) == std::vector<int>{4, 5, 6, 8})); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >): endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx mov %rdi,%rbx mov %rsi,%r14 mov %rdx,%r13 mov 0x8(%rsi),%r12 sub (%rsi),%r12 movq $0x0,(%rdi) movq $0x0,0x8(%rdi) movq $0x0,0x10(%rdi) mov %r12,%rax sar $0x2,%rax je 130a <_Z5func0St6vectorIiSaIiEES1_+0xa1> movabs $0x1fffffffffffffff,%rdx cmp %rdx,%rax ja 1305 <_Z5func0St6vectorIiSaIiEES1_+0x9c> mov %r12,%rdi callq 1140 <_Znwm@plt> mov %rax,%rbp mov %rbp,(%rbx) mov %rbp,0x8(%rbx) add %rbp,%r12 mov %r12,0x10(%rbx) mov 0x8(%r14),%rax mov (%r14),%rsi mov %rax,%r12 sub %rsi,%r12 cmp %rsi,%rax je 12ea <_Z5func0St6vectorIiSaIiEES1_+0x81> mov %r12,%rdx mov %rbp,%rdi callq 1120 <memcpy@plt> lea 0x0(%rbp,%r12,1),%rsi mov %rsi,0x8(%rbx) mov 0x8(%r13),%rcx mov 0x0(%r13),%rdx mov %rbx,%rdi callq 1900 <_ZNSt6vectorIiSaIiEE15_M_range_insertIN9__gnu_cxx17__normal_iteratorIPiS1_EEEEvS6_T_S7_St20forward_iterator_tag> jmp 132d <_Z5func0St6vectorIiSaIiEES1_+0xc4> callq 10e0 <_ZSt17__throw_bad_allocv@plt> mov $0x0,%ebp jmp 12bf <_Z5func0St6vectorIiSaIiEES1_+0x56> endbr64 mov %rax,%rbp mov (%rbx),%rdi test %rdi,%rdi je 1325 <_Z5func0St6vectorIiSaIiEES1_+0xbc> callq 1130 <_ZdlPv@plt> mov %rbp,%rdi callq 1170 <_Unwind_Resume@plt> mov %rbx,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq
_Z5func0St6vectorIiSaIiEES1_: endbr64 push r14 push r13 push r12 push rbp push rbx mov rbx, rdi mov r14, rsi mov r13, rdx mov r12, [rsi+8] sub r12, [rsi] mov qword ptr [rdi], 0 mov qword ptr [rdi+8], 0 mov qword ptr [rdi+10h], 0 jz short loc_1301 mov rax, 7FFFFFFFFFFFFFFCh cmp rax, r12 jb short loc_12FC mov rdi, r12; unsigned __int64 call __Znwm; operator new(ulong) mov rbp, rax loc_12B8: mov [rbx], rbp mov [rbx+8], rbp add r12, rbp mov [rbx+10h], r12 mov rsi, [r14]; src mov r12, [r14+8] sub r12, rsi cmp r12, 4 jle short loc_1308 mov rdx, r12; n mov rdi, rbp; dest call _memmove loc_12E1: lea rsi, [rbp+r12+0] mov [rbx+8], rsi mov rcx, [r13+8] mov rdx, [r13+0] mov rdi, rbx call _ZNSt6vectorIiSaIiEE15_M_range_insertIN9__gnu_cxx17__normal_iteratorIPiS1_EEEEvS6_T_S7_St20forward_iterator_tag; std::vector<int>::_M_range_insert<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,std::forward_iterator_tag) jmp short loc_1328 loc_12FC: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) loc_1301: mov ebp, 0 jmp short loc_12B8 loc_1308: jnz short loc_12E1 mov eax, [rsi] mov [rbp+0], eax jmp short loc_12E1 endbr64 mov rbp, rax mov rdi, rbx call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rdi, rbp; struct _Unwind_Exception * call __Unwind_Resume loc_1328: mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 retn
_QWORD * func0(_QWORD *a1, _QWORD *a2, _QWORD *a3) { unsigned long long v5; // r12 _DWORD *v6; // rbp _DWORD *v7; // rsi long long v8; // r12 v5 = a2[1] - *a2; *a1 = 0LL; a1[1] = 0LL; a1[2] = 0LL; if ( v5 ) { if ( v5 <= 0x7FFFFFFFFFFFFFFCLL ) { v6 = (_DWORD *)operator new(v5); goto LABEL_4; } std::__throw_bad_array_new_length(); } v6 = 0LL; LABEL_4: *a1 = v6; a1[1] = v6; a1[2] = (char *)v6 + v5; v7 = (_DWORD *)*a2; v8 = a2[1] - *a2; if ( v8 <= 4 ) { if ( v8 == 4 ) *v6 = *v7; } else { memmove(v6, v7, a2[1] - *a2); } a1[1] = (char *)v6 + v8; std::vector<int>::_M_range_insert<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>( a1, (char *)v6 + v8, *a3, a3[1]); return a1; }
func0: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV RBX,RDI MOV R14,RSI MOV R13,RDX MOV R12,qword ptr [RSI + 0x8] SUB R12,qword ptr [RSI] MOV qword ptr [RDI],0x0 MOV qword ptr [RDI + 0x8],0x0 MOV qword ptr [RDI + 0x10],0x0 JZ 0x00101301 MOV RAX,0x7ffffffffffffffc CMP RAX,R12 JC 0x001012fc MOV RDI,R12 LAB_001012b0: CALL 0x00101130 MOV RBP,RAX LAB_001012b8: MOV qword ptr [RBX],RBP MOV qword ptr [RBX + 0x8],RBP ADD R12,RBP MOV qword ptr [RBX + 0x10],R12 MOV RSI,qword ptr [R14] MOV R12,qword ptr [R14 + 0x8] SUB R12,RSI CMP R12,0x4 JLE 0x00101308 MOV RDX,R12 MOV RDI,RBP CALL 0x00101160 LAB_001012e1: LEA RSI,[RBP + R12*0x1] MOV qword ptr [RBX + 0x8],RSI MOV RCX,qword ptr [R13 + 0x8] MOV RDX,qword ptr [R13] MOV RDI,RBX LAB_001012f5: CALL 0x00101918 JMP 0x00101328 LAB_001012fc: CALL 0x00101110 LAB_00101301: MOV EBP,0x0 JMP 0x001012b8 LAB_00101308: JNZ 0x001012e1 MOV EAX,dword ptr [RSI] MOV dword ptr [RBP],EAX JMP 0x001012e1 LAB_00101328: MOV RAX,RBX POP RBX POP RBP POP R12 POP R13 POP R14 RET
/* func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >) */ int8 * func0(vector param_1,vector param_2) { int4 *__src; int4 *__dest; int8 *in_RDX; int4 in_register_00000034; long *plVar1; int4 in_register_0000003c; int8 *puVar2; ulong uVar3; size_t __n; puVar2 = (int8 *)CONCAT44(in_register_0000003c,param_1); plVar1 = (long *)CONCAT44(in_register_00000034,param_2); uVar3 = plVar1[1] - *plVar1; *puVar2 = 0; puVar2[1] = 0; puVar2[2] = 0; if (uVar3 != 0) { if (uVar3 < 0x7ffffffffffffffd) { __dest = (int4 *)operator_new(uVar3); goto LAB_001012b8; } std::__throw_bad_array_new_length(); } __dest = (int4 *)0x0; LAB_001012b8: *puVar2 = __dest; puVar2[1] = __dest; puVar2[2] = uVar3 + (long)__dest; __src = (int4 *)*plVar1; __n = plVar1[1] - (long)__src; if ((long)__n < 5) { if (__n == 4) { *__dest = *__src; } } else { memmove(__dest,__src,__n); } puVar2[1] = (long)__dest + __n; /* try { // try from 001012f5 to 001012f9 has its CatchHandler @ 00101311 */ std::vector<int,std::allocator<int>>:: _M_range_insert<__normal_iterator<int*,std::vector<int,std::allocator<int>>>> (param_1,(__normal_iterator)((long)__dest + __n),(__normal_iterator)*in_RDX, (forward_iterator_tag)in_RDX[1]); return puVar2; }
3,886
func0
#include <vector> #include <cassert>
std::vector<int> func0(std::vector<int> test_tup1, std::vector<int> test_tup2) { std::vector<int> res = test_tup1; res.insert(res.end(), test_tup2.begin(), test_tup2.end()); return res; }
int main() { assert((func0({3, 4}, {5, 6}) == std::vector<int>{3, 4, 5, 6})); assert((func0({1, 2}, {3, 4}) == std::vector<int>{1, 2, 3, 4})); assert((func0({4, 5}, {6, 8}) == std::vector<int>{4, 5, 6, 8})); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >): endbr64 push %r13 mov %rdx,%r13 push %r12 mov %rdi,%r12 push %rbp mov %rsi,%rbp push %rbx sub $0x8,%rsp mov 0x8(%rsi),%rbx sub (%rsi),%rbx movq $0x0,(%rdi) mov %rbx,%rax movq $0x0,0x8(%rdi) sar $0x2,%rax movq $0x0,0x10(%rdi) je 17c8 <_Z5func0St6vectorIiSaIiEES1_+0xb8> movabs $0x1fffffffffffffff,%rdx cmp %rdx,%rax ja 17cc <_Z5func0St6vectorIiSaIiEES1_+0xbc> mov %rbx,%rdi callq 1140 <_Znwm@plt> mov %rax,%rcx add %rcx,%rbx mov %rcx,(%r12) mov %rbx,0x10(%r12) mov %rcx,0x8(%r12) mov 0x8(%rbp),%rax mov 0x0(%rbp),%rsi mov %rax,%rbx sub %rsi,%rbx cmp %rsi,%rax je 179a <_Z5func0St6vectorIiSaIiEES1_+0x8a> mov %rcx,%rdi mov %rbx,%rdx callq 1120 <memcpy@plt> mov %rax,%rcx lea (%rcx,%rbx,1),%rsi mov %r12,%rdi mov %rsi,0x8(%r12) mov 0x8(%r13),%rcx mov 0x0(%r13),%rdx callq 18f0 <_ZNSt6vectorIiSaIiEE15_M_range_insertIN9__gnu_cxx17__normal_iteratorIPiS1_EEEEvS6_T_S7_St20forward_iterator_tag> add $0x8,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 retq nopl 0x0(%rax) xor %ecx,%ecx jmp 1768 <_Z5func0St6vectorIiSaIiEES1_+0x58> callq 10e0 <_ZSt17__throw_bad_allocv@plt> endbr64 mov %rax,%rbp jmpq 1180 <_Z5func0St6vectorIiSaIiEES1_.cold> nopl (%rax)
_Z5func0St6vectorIiSaIiEES1_: endbr64 push r15 pxor xmm0, xmm0 mov r15, rdx push r14 push r13 push r12 push rbp mov rbp, rsi push rbx mov rbx, rdi sub rsp, 18h mov rcx, [rsi+8] sub rcx, [rsi] movups xmmword ptr [rdi], xmm0 mov qword ptr [rdi+10h], 0 jz loc_17E0 mov rax, 7FFFFFFFFFFFFFFCh cmp rax, rcx jb loc_18C0 mov rdi, rcx; unsigned __int64 mov [rsp+48h+dest], rcx call __Znwm; operator new(ulong) mov rcx, [rsp+48h+dest] mov r12, rax loc_174D: movq xmm0, r12 lea rax, [r12+rcx] punpcklqdq xmm0, xmm0 mov [rbx+10h], rax movups xmmword ptr [rbx], xmm0 mov rsi, [rbp+0]; src mov rbp, [rbp+8] sub rbp, rsi cmp rbp, 4 jle loc_18A0 mov rdx, rbp; n mov rdi, r12; dest mov [rsp+48h+dest], rcx mov r14, rbp call _memmove mov rcx, [rsp+48h+dest] loc_178C: lea rdi, [r12+r14]; dest mov [rbx+8], rdi mov r13, [r15+8] mov r15, [r15] cmp r15, r13 jz short loc_17CA sub r13, r15 sub rcx, rbp cmp rcx, r13 jb short loc_17F0 cmp r13, 4 jle loc_18C8 mov rdx, r13; n mov rsi, r15; src call _memmove mov rdi, rax loc_17C3: add rdi, r13 mov [rbx+8], rdi loc_17CA: add rsp, 18h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_17E0: xor r12d, r12d jmp loc_174D loc_17F0: mov rcx, 1FFFFFFFFFFFFFFFh mov rax, rbp mov rdx, r13 sar rax, 2 sar rdx, 2 sub rcx, rax cmp rcx, rdx jb loc_1984 cmp r14, r13 cmovnb rdx, rax add rax, rdx jb loc_1990 test rax, rax jnz loc_1940 mov [rsp+48h+var_40], 0 mov [rsp+48h+dest], 0 cmp rbp, 4 jle loc_18E0 loc_1848: mov rbp, [rsp+48h+dest] mov rdx, r14; n mov rsi, r12; src mov rdi, rbp; dest add r14, rbp call _memcpy cmp r13, 4 jle loc_1930 loc_1867: mov rdi, r14; dest mov rdx, r13; n mov rsi, r15; src add r14, r13 call _memmove loc_1878: mov rsi, [rbx+10h] mov rdi, r12; void * sub rsi, r12; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1887: mov rax, [rsp+48h+dest] mov [rbx+8], r14 mov [rbx], rax mov rax, [rsp+48h+var_40] mov [rbx+10h], rax jmp loc_17CA loc_18A0: mov r14, rbp jnz loc_178C mov eax, [rsi] mov r14d, 4 mov [r12], eax jmp loc_178C loc_18C0: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) nop dword ptr [rax] loc_18C8: jnz loc_17C3 mov eax, [r15] mov [rdi], eax jmp loc_17C3 loc_18E0: jz short loc_1912 mov rax, [rsp+48h+dest] add r14, rax cmp r13, 4 jle loc_19A1 mov rdx, r13; n mov rsi, r15; src mov rdi, r14; dest call _memmove loc_1901: add r14, r13 test r12, r12 jz loc_1887 jmp loc_1878 loc_1912: mov rdx, [rsp+48h+dest] mov eax, [r12] add r14, rdx mov [rdx], eax cmp r13, 4 jg loc_1867 nop dword ptr [rax+00000000h] loc_1930: mov eax, [r15] add r14, 4 mov [r14-4], eax jmp loc_1878 loc_1940: mov rdx, 1FFFFFFFFFFFFFFFh cmp rax, rdx cmova rax, rdx shl rax, 2 mov [rsp+48h+var_40], rax loc_195A: mov rdi, [rsp+48h+var_40]; unsigned __int64 call __Znwm; operator new(ulong) mov rdx, [rsp+48h+var_40] mov [rsp+48h+dest], rax add rdx, rax mov [rsp+48h+var_40], rdx cmp rbp, 4 jg loc_1848 jmp loc_18E0 loc_1984: lea rdi, aVectorMRangeIn; "vector::_M_range_insert" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) loc_1990: mov rax, 7FFFFFFFFFFFFFFCh mov [rsp+48h+var_40], rax jmp short loc_195A loc_19A1: mov eax, [r15] mov [r14], eax jmp loc_1901 endbr64 mov rbp, rax jmp _Z5func0St6vectorIiSaIiEES1__cold; func0(std::vector<int>,std::vector<int>) [clone]
_QWORD * func0(char *a1, _QWORD *a2, char *a3) { signed long long v3; // r13 _QWORD *v6; // rbx unsigned long long v7; // rcx _DWORD *v8; // rax _DWORD *v9; // r12 _DWORD *v10; // rsi signed long long v11; // rbp unsigned long long v12; // r14 char *v13; // r13 bool v14; // zf long long v16; // rax long long v17; // rdx bool v18; // cf unsigned long long v19; // rax bool v20; // zf size_t v21; // rdx char *v22; // r14 char *v23; // rdi char *v24; // r14 _DWORD *v25; // r14 _DWORD *v26; // rax void *desta; // [rsp+0h] [rbp-48h] void *destb; // [rsp+0h] [rbp-48h] _DWORD *dest; // [rsp+0h] [rbp-48h] unsigned long long v30; // [rsp+8h] [rbp-40h] unsigned long long v31; // [rsp+8h] [rbp-40h] v6 = a1; v7 = a2[1] - *a2; *(_OWORD *)a1 = 0LL; *((_QWORD *)a1 + 2) = 0LL; if ( v7 ) { if ( v7 > 0x7FFFFFFFFFFFFFFCLL ) { std::__throw_bad_array_new_length(); goto LABEL_26; } desta = (void *)v7; v8 = (_DWORD *)operator new(v7); v7 = (unsigned long long)desta; v9 = v8; } else { v9 = 0LL; } *((_QWORD *)a1 + 2) = (char *)v9 + v7; *(__m128i *)a1 = _mm_unpacklo_epi64((__m128i)(unsigned long long)v9, (__m128i)(unsigned long long)v9); v10 = (_DWORD *)*a2; v11 = a2[1] - *a2; if ( v11 <= 4 ) { v12 = v11; if ( v11 == 4 ) { v12 = 4LL; *v9 = *v10; } } else { destb = (void *)v7; v12 = v11; memmove(v9, v10, v11); v7 = (unsigned long long)destb; } a1 = (char *)v9 + v12; v6[1] = (char *)v9 + v12; v13 = (char *)*((_QWORD *)a3 + 1); a3 = *(char **)a3; if ( a3 != v13 ) { v3 = v13 - a3; if ( v7 - v11 >= v3 ) { v14 = v3 == 4; if ( v3 > 4 ) { a1 = (char *)memmove(a1, a3, v3); LABEL_10: v6[1] = &a1[v3]; return v6; } LABEL_26: if ( v14 ) *(_DWORD *)a1 = *(_DWORD *)a3; goto LABEL_10; } v16 = v11 >> 2; v17 = v3 >> 2; if ( 0x1FFFFFFFFFFFFFFFLL - (v11 >> 2) < (unsigned long long)(v3 >> 2) ) std::__throw_length_error("vector::_M_range_insert"); if ( v12 >= v3 ) v17 = v11 >> 2; v18 = __CFADD__(v17, v16); v19 = v17 + v16; if ( v18 ) { v31 = 0x1FFFFFFFFFFFFFFFLL; v26 = (_DWORD *)operator new(0x7FFFFFFFFFFFFFFCuLL); } else { if ( !v19 ) { v30 = 0LL; dest = 0LL; v20 = v11 == 4; if ( v11 > 4 ) goto LABEL_19; goto LABEL_28; } if ( v19 > 0x1FFFFFFFFFFFFFFFLL ) v19 = 0x1FFFFFFFFFFFFFFFLL; v31 = v19; v26 = (_DWORD *)operator new(4 * v19); } dest = v26; v30 = (unsigned long long)&v26[v31]; v20 = v11 == 4; if ( v11 > 4 ) { LABEL_19: v21 = v12; v22 = (char *)dest + v12; memcpy(dest, v9, v21); if ( v3 > 4 ) { LABEL_20: v23 = v22; v24 = &v22[v3]; memmove(v23, a3, v3); LABEL_21: operator delete(v9, v6[2] - (_QWORD)v9); LABEL_22: v6[1] = v24; *v6 = dest; v6[2] = v30; return v6; } LABEL_34: v24 = v22 + 4; *((_DWORD *)v24 - 1) = *(_DWORD *)a3; goto LABEL_21; } LABEL_28: if ( !v20 ) { v25 = (_DWORD *)((char *)dest + v12); if ( v3 <= 4 ) *v25 = *(_DWORD *)a3; else memmove(v25, a3, v3); v24 = (char *)v25 + v3; if ( !v9 ) goto LABEL_22; goto LABEL_21; } v22 = (char *)dest + v12; *dest = *v9; if ( v3 > 4 ) goto LABEL_20; goto LABEL_34; } return v6; }
func0: MOV RDI,RBX CALL 0x001019c0 MOV RDI,RBP LAB_0010118b: CALL 0x00101170
/* func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >) [clone .cold] */ void func0(vector param_1,vector param_2) { vector<int,std::allocator<int>> *unaff_RBX; std::vector<int,std::allocator<int>>::~vector(unaff_RBX); /* WARNING: Subroutine does not return */ _Unwind_Resume(); }
3,887
func0
#include <vector> #include <cassert>
std::vector<int> func0(std::vector<int> test_tup1, std::vector<int> test_tup2) { std::vector<int> res = test_tup1; res.insert(res.end(), test_tup2.begin(), test_tup2.end()); return res; }
int main() { assert((func0({3, 4}, {5, 6}) == std::vector<int>{3, 4, 5, 6})); assert((func0({1, 2}, {3, 4}) == std::vector<int>{1, 2, 3, 4})); assert((func0({4, 5}, {6, 8}) == std::vector<int>{4, 5, 6, 8})); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >): endbr64 push %r15 pxor %xmm0,%xmm0 push %r14 mov %rdx,%r14 push %r13 push %r12 mov %rdi,%r12 push %rbp mov %rsi,%rbp push %rbx sub $0x28,%rsp mov 0x8(%rsi),%rbx sub (%rsi),%rbx movups %xmm0,(%rdi) mov %rbx,%rax movq $0x0,0x10(%rdi) sar $0x2,%rax je 1928 <_Z5func0St6vectorIiSaIiEES1_+0x1d8> movabs $0x1fffffffffffffff,%rdx cmp %rdx,%rax ja 19bd <_Z5func0St6vectorIiSaIiEES1_+0x26d> mov %rbx,%rdi callq 1140 <_Znwm@plt> mov %rax,%r8 movq %r8,%xmm0 lea (%r8,%rbx,1),%rax punpcklqdq %xmm0,%xmm0 mov %rax,0x10(%r12) movups %xmm0,(%r12) mov 0x8(%rbp),%rax mov 0x0(%rbp),%rsi mov %rax,%r15 sub %rsi,%r15 mov %r15,%r9 cmp %rsi,%rax je 17f1 <_Z5func0St6vectorIiSaIiEES1_+0xa1> mov %r8,%rdi mov %r15,%rdx mov %r15,0x8(%rsp) callq 1120 <memcpy@plt> mov 0x8(%rsp),%r9 mov %rax,%r8 lea (%r8,%r15,1),%rbp mov %rbp,0x8(%r12) mov 0x8(%r14),%r13 mov (%r14),%r14 cmp %r13,%r14 je 1832 <_Z5func0St6vectorIiSaIiEES1_+0xe2> sub %r14,%r13 sub %r15,%rbx mov %r13,%rax sar $0x2,%rbx sar $0x2,%rax cmp %rbx,%rax ja 1848 <_Z5func0St6vectorIiSaIiEES1_+0xf8> mov %r13,%rdx mov %r14,%rsi mov %rbp,%rdi add %rbp,%r13 callq 1120 <memcpy@plt> mov %r13,0x8(%r12) add $0x28,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax) movabs $0x1fffffffffffffff,%rdx sar $0x2,%r15 mov %rdx,%rcx sub %r15,%rcx cmp %rcx,%rax ja 19c2 <_Z5func0St6vectorIiSaIiEES1_+0x272> cmp %r15,%rax cmovb %r15,%rax add %r15,%rax jb 19ce <_Z5func0St6vectorIiSaIiEES1_+0x27e> xor %r15d,%r15d xor %ebx,%ebx test %rax,%rax jne 1970 <_Z5func0St6vectorIiSaIiEES1_+0x220> lea (%rbx,%r9,1),%r10 lea (%r10,%r13,1),%r11 cmp %rbp,%r8 je 1930 <_Z5func0St6vectorIiSaIiEES1_+0x1e0> mov %r8,%rsi mov %r9,%rdx mov %rbx,%rdi mov %r11,0x10(%rsp) mov %r8,0x8(%rsp) mov %r10,0x18(%rsp) callq 1160 <memmove@plt> mov 0x18(%rsp),%r10 mov %r13,%rdx mov %r14,%rsi mov %r10,%rdi callq 1120 <memcpy@plt> mov 0x8(%r12),%rax mov 0x10(%rsp),%r11 mov 0x8(%rsp),%r8 mov %rax,%rdx sub %rbp,%rdx cmp %rax,%rbp lea (%r11,%rdx,1),%r13 je 19b0 <_Z5func0St6vectorIiSaIiEES1_+0x260> mov %rbp,%rsi mov %r11,%rdi mov %r8,0x8(%rsp) callq 1120 <memcpy@plt> mov 0x8(%rsp),%r8 test %r8,%r8 jne 19b0 <_Z5func0St6vectorIiSaIiEES1_+0x260> movq %rbx,%xmm0 movq %r13,%xmm1 mov %r15,0x10(%r12) punpcklqdq %xmm1,%xmm0 movups %xmm0,(%r12) jmpq 1832 <_Z5func0St6vectorIiSaIiEES1_+0xe2> nopl 0x0(%rax) xor %r8d,%r8d jmpq 17ac <_Z5func0St6vectorIiSaIiEES1_+0x5c> mov %r13,%rdx mov %r14,%rsi mov %r10,%rdi mov %r11,0x10(%rsp) mov %r8,0x8(%rsp) callq 1120 <memcpy@plt> mov 0x8(%r12),%rax mov 0x8(%rsp),%r8 mov 0x10(%rsp),%r11 mov %rax,%rdx sub %r8,%rdx lea (%r11,%rdx,1),%r13 cmp %rax,%r8 jne 18e6 <_Z5func0St6vectorIiSaIiEES1_+0x196> jmp 18fb <_Z5func0St6vectorIiSaIiEES1_+0x1ab> nopl 0x0(%rax) cmp %rdx,%rax cmovbe %rax,%rdx mov %rdx,%r15 shl $0x2,%r15 mov %r15,%rdi callq 1140 <_Znwm@plt> mov (%r12),%r8 mov %rbp,%r9 mov %rax,%rbx add %rax,%r15 sub %r8,%r9 lea (%rbx,%r9,1),%r10 lea (%r10,%r13,1),%r11 cmp %rbp,%r8 jne 1894 <_Z5func0St6vectorIiSaIiEES1_+0x144> jmp 1930 <_Z5func0St6vectorIiSaIiEES1_+0x1e0> nopl 0x0(%rax) mov %r8,%rdi callq 1130 <_ZdlPv@plt> jmpq 1904 <_Z5func0St6vectorIiSaIiEES1_+0x1b4> callq 10e0 <_ZSt17__throw_bad_allocv@plt> lea 0x767(%rip),%rdi callq 1100 <_ZSt20__throw_length_errorPKc@plt> movabs $0x7ffffffffffffffc,%r15 jmp 197e <_Z5func0St6vectorIiSaIiEES1_+0x22e> endbr64 mov %rax,%rbp jmpq 1195 <_Z5func0St6vectorIiSaIiEES1_.cold> nopw %cs:0x0(%rax,%rax,1)
_Z5func0St6vectorIiSaIiEES1_: endbr64 push r15 pxor xmm0, xmm0 mov r15, rdx push r14 push r13 push r12 push rbp mov rbp, rsi push rbx mov rbx, rdi sub rsp, 18h mov rcx, [rsi+8] sub rcx, [rsi] movups xmmword ptr [rdi], xmm0 mov qword ptr [rdi+10h], 0 jz loc_17E0 mov rax, 7FFFFFFFFFFFFFFCh cmp rax, rcx jb loc_18C0 mov rdi, rcx; unsigned __int64 mov [rsp+48h+dest], rcx call __Znwm; operator new(ulong) mov rcx, [rsp+48h+dest] mov r12, rax loc_174D: movq xmm0, r12 lea rax, [r12+rcx] punpcklqdq xmm0, xmm0 mov [rbx+10h], rax movups xmmword ptr [rbx], xmm0 mov rsi, [rbp+0]; src mov rbp, [rbp+8] sub rbp, rsi cmp rbp, 4 jle loc_18A0 mov rdx, rbp; n mov rdi, r12; dest mov [rsp+48h+dest], rcx mov r14, rbp call _memmove mov rcx, [rsp+48h+dest] loc_178C: lea rdi, [r12+r14]; dest mov [rbx+8], rdi mov r13, [r15+8] mov r15, [r15] cmp r15, r13 jz short loc_17CA sub r13, r15 sub rcx, rbp cmp rcx, r13 jb short loc_17F0 cmp r13, 4 jle loc_18C8 mov rdx, r13; n mov rsi, r15; src call _memmove mov rdi, rax loc_17C3: add rdi, r13 mov [rbx+8], rdi loc_17CA: add rsp, 18h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_17E0: xor r12d, r12d jmp loc_174D loc_17F0: mov rcx, 1FFFFFFFFFFFFFFFh mov rax, rbp mov rdx, r13 sar rax, 2 sar rdx, 2 sub rcx, rax cmp rcx, rdx jb loc_1982 cmp r14, r13 cmovnb rdx, rax add rax, rdx jb loc_198E test rax, rax jnz loc_1940 mov [rsp+48h+var_40], 0 mov [rsp+48h+dest], 0 cmp rbp, 4 jle loc_18E0 loc_1848: mov rbp, [rsp+48h+dest] mov rdx, r14; n mov rsi, r12; src mov rdi, rbp; dest add r14, rbp call _memcpy cmp r13, 4 jle loc_1930 loc_1867: mov rdi, r14; dest mov rdx, r13; n mov rsi, r15; src add r14, r13 call _memmove loc_1878: mov rsi, [rbx+10h] mov rdi, r12; void * sub rsi, r12; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1887: mov rax, [rsp+48h+dest] mov [rbx+8], r14 mov [rbx], rax mov rax, [rsp+48h+var_40] mov [rbx+10h], rax jmp loc_17CA loc_18A0: mov r14, rbp jnz loc_178C mov eax, [rsi] mov r14d, 4 mov [r12], eax jmp loc_178C loc_18C0: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) nop dword ptr [rax] loc_18C8: jnz loc_17C3 mov eax, [r15] mov [rdi], eax jmp loc_17C3 loc_18E0: jz short loc_1912 mov rax, [rsp+48h+dest] add r14, rax cmp r13, 4 jle loc_19A2 mov rdx, r13; n mov rsi, r15; src mov rdi, r14; dest call _memmove loc_1901: add r14, r13 test r12, r12 jz loc_1887 jmp loc_1878 loc_1912: mov rdx, [rsp+48h+dest] mov eax, [r12] add r14, rdx mov [rdx], eax cmp r13, 4 jg loc_1867 nop dword ptr [rax+00000000h] loc_1930: mov eax, [r15] add r14, 4 mov [r14-4], eax jmp loc_1878 loc_1940: mov rdx, 1FFFFFFFFFFFFFFFh cmp rax, rdx cmova rax, rdx shl rax, 2 mov [rsp+48h+var_40], rax mov rdi, rax; unsigned __int64 loc_195D: call __Znwm; operator new(ulong) mov rdx, [rsp+48h+var_40] mov [rsp+48h+dest], rax add rdx, rax mov [rsp+48h+var_40], rdx cmp rbp, 4 jg loc_1848 jmp loc_18E0 loc_1982: lea rdi, aVectorMRangeIn; "vector::_M_range_insert" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) loc_198E: mov rax, 7FFFFFFFFFFFFFFCh mov [rsp+48h+var_40], rax mov rdi, rax jmp short loc_195D loc_19A2: mov eax, [r15] mov [r14], eax jmp loc_1901 endbr64 mov rbp, rax jmp _Z5func0St6vectorIiSaIiEES1__cold; func0(std::vector<int>,std::vector<int>) [clone]
_QWORD * func0(char *a1, _QWORD *a2, char *a3) { signed long long v3; // r13 _QWORD *v6; // rbx unsigned long long v7; // rcx _DWORD *v8; // rax _DWORD *v9; // r12 _DWORD *v10; // rsi signed long long v11; // rbp unsigned long long v12; // r14 char *v13; // r13 bool v14; // zf long long v16; // rax long long v17; // rdx bool v18; // cf unsigned long long v19; // rax bool v20; // zf size_t v21; // rdx char *v22; // r14 char *v23; // rdi char *v24; // r14 _DWORD *v25; // r14 unsigned long long v26; // rdi void *desta; // [rsp+0h] [rbp-48h] void *destb; // [rsp+0h] [rbp-48h] _DWORD *dest; // [rsp+0h] [rbp-48h] _DWORD *v30; // [rsp+8h] [rbp-40h] long long v31; // [rsp+8h] [rbp-40h] v6 = a1; v7 = a2[1] - *a2; *(_OWORD *)a1 = 0LL; *((_QWORD *)a1 + 2) = 0LL; if ( v7 ) { if ( v7 > 0x7FFFFFFFFFFFFFFCLL ) { std::__throw_bad_array_new_length(); goto LABEL_26; } desta = (void *)v7; v8 = (_DWORD *)operator new(v7); v7 = (unsigned long long)desta; v9 = v8; } else { v9 = 0LL; } *((_QWORD *)a1 + 2) = (char *)v9 + v7; *(__m128i *)a1 = _mm_unpacklo_epi64((__m128i)(unsigned long long)v9, (__m128i)(unsigned long long)v9); v10 = (_DWORD *)*a2; v11 = a2[1] - *a2; if ( v11 <= 4 ) { v12 = v11; if ( v11 == 4 ) { v12 = 4LL; *v9 = *v10; } } else { destb = (void *)v7; v12 = v11; memmove(v9, v10, v11); v7 = (unsigned long long)destb; } a1 = (char *)v9 + v12; v6[1] = (char *)v9 + v12; v13 = (char *)*((_QWORD *)a3 + 1); a3 = *(char **)a3; if ( a3 != v13 ) { v3 = v13 - a3; if ( v7 - v11 >= v3 ) { v14 = v3 == 4; if ( v3 > 4 ) { a1 = (char *)memmove(a1, a3, v3); LABEL_10: v6[1] = &a1[v3]; return v6; } LABEL_26: if ( v14 ) *(_DWORD *)a1 = *(_DWORD *)a3; goto LABEL_10; } v16 = v11 >> 2; v17 = v3 >> 2; if ( 0x1FFFFFFFFFFFFFFFLL - (v11 >> 2) < (unsigned long long)(v3 >> 2) ) std::__throw_length_error("vector::_M_range_insert"); if ( v12 >= v3 ) v17 = v11 >> 2; v18 = __CFADD__(v17, v16); v19 = v17 + v16; if ( v18 ) { v31 = 0x1FFFFFFFFFFFFFFFLL; v26 = 0x7FFFFFFFFFFFFFFCLL; } else { if ( !v19 ) { v30 = 0LL; dest = 0LL; v20 = v11 == 4; if ( v11 > 4 ) goto LABEL_19; goto LABEL_28; } if ( v19 > 0x1FFFFFFFFFFFFFFFLL ) v19 = 0x1FFFFFFFFFFFFFFFLL; v31 = v19; v26 = 4 * v19; } dest = (_DWORD *)operator new(v26); v30 = &dest[v31]; v20 = v11 == 4; if ( v11 > 4 ) { LABEL_19: v21 = v12; v22 = (char *)dest + v12; memcpy(dest, v9, v21); if ( v3 > 4 ) { LABEL_20: v23 = v22; v24 = &v22[v3]; memmove(v23, a3, v3); LABEL_21: operator delete(v9, v6[2] - (_QWORD)v9); LABEL_22: v6[1] = v24; *v6 = dest; v6[2] = v30; return v6; } LABEL_34: v24 = v22 + 4; *((_DWORD *)v24 - 1) = *(_DWORD *)a3; goto LABEL_21; } LABEL_28: if ( !v20 ) { v25 = (_DWORD *)((char *)dest + v12); if ( v3 <= 4 ) *v25 = *(_DWORD *)a3; else memmove(v25, a3, v3); v24 = (char *)v25 + v3; if ( !v9 ) goto LABEL_22; goto LABEL_21; } v22 = (char *)dest + v12; *dest = *v9; if ( v3 > 4 ) goto LABEL_20; goto LABEL_34; } return v6; }
func0: MOV RDI,RBX CALL 0x001019c0 MOV RDI,RBP LAB_0010118b: CALL 0x00101170
/* func0(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >) [clone .cold] */ void func0(vector param_1,vector param_2) { vector<int,std::allocator<int>> *unaff_RBX; std::vector<int,std::allocator<int>>::~vector(unaff_RBX); /* WARNING: Subroutine does not return */ _Unwind_Resume(); }
3,888
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string s, int d) { std::string tmp = s.substr(d) + s.substr(0, d); return tmp; }
int main() { assert(func0("python", 2) == "thonpy"); assert(func0("bigdata", 3) == "databig"); assert(func0("hadoop", 1) == "adooph"); return 0; }
O0
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x78,%rsp mov %rdi,-0x68(%rbp) mov %rsi,-0x70(%rbp) mov %edx,-0x74(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x74(%rbp),%eax movslq %eax,%rdx lea -0x40(%rbp),%rax mov -0x70(%rbp),%rsi mov %rdx,%rcx mov $0x0,%edx mov %rax,%rdi callq 22e0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@plt> mov -0x74(%rbp),%eax movslq %eax,%rdx lea -0x60(%rbp),%rax mov -0x70(%rbp),%rsi mov $0xffffffffffffffff,%rcx mov %rax,%rdi callq 22e0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@plt> mov -0x68(%rbp),%rax lea -0x40(%rbp),%rdx lea -0x60(%rbp),%rcx mov %rcx,%rsi mov %rax,%rdi callq 29b9 <_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEOS8_S9_> lea -0x60(%rbp),%rax mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> lea -0x40(%rbp),%rax mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 25a4 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xdb> jmp 259f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xd6> endbr64 mov %rax,%rbx lea -0x60(%rbp),%rax mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> jmp 2588 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xbf> endbr64 mov %rax,%rbx lea -0x40(%rbp),%rax mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 2390 <_Unwind_Resume@plt> callq 2330 <__stack_chk_fail@plt> mov -0x68(%rbp),%rax add $0x78,%rsp pop %rbx pop %rbp retq
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 78h mov [rbp+var_68], rdi mov [rbp+var_70], rsi mov [rbp+var_74], edx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov eax, [rbp+var_74] movsxd rdx, eax lea rax, [rbp+var_40] mov rsi, [rbp+var_70] mov rcx, rdx mov edx, 0 mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm; std::string::substr(ulong,ulong) mov eax, [rbp+var_74] movsxd rdx, eax lea rax, [rbp+var_60] mov rsi, [rbp+var_70] mov rcx, 0FFFFFFFFFFFFFFFFh mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm; std::string::substr(ulong,ulong) mov rax, [rbp+var_68] lea rdx, [rbp+var_40] lea rcx, [rbp+var_60] mov rsi, rcx mov rdi, rax call _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEOS8_S9_; std::operator+<char>(std::string&&,std::string&) lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() lea rax, [rbp+var_40] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() nop mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_24F8 jmp short loc_24F3 endbr64 mov rbx, rax lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() jmp short loc_24C8 endbr64 mov rbx, rax loc_24C8: lea rax, [rbp+var_40] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_24EB call ___stack_chk_fail loc_24EB: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_24F3: call ___stack_chk_fail loc_24F8: mov rax, [rbp+var_68] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, long long a2, int a3) { _BYTE v5[32]; // [rsp+20h] [rbp-60h] BYREF _BYTE v6[40]; // [rsp+40h] [rbp-40h] BYREF unsigned long long v7; // [rsp+68h] [rbp-18h] v7 = __readfsqword(0x28u); std::string::substr(v6, a2, 0LL, a3); std::string::substr(v5, a2, a3, -1LL); std::operator+<char>(a1, v5, v6); std::string::~string(v5); std::string::~string(v6); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x78 MOV qword ptr [RBP + -0x68],RDI MOV qword ptr [RBP + -0x70],RSI MOV dword ptr [RBP + -0x74],EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV EAX,dword ptr [RBP + -0x74] MOVSXD RDX,EAX LEA RAX,[RBP + -0x40] MOV RSI,qword ptr [RBP + -0x70] MOV RCX,RDX MOV EDX,0x0 MOV RDI,RAX LAB_00102449: CALL 0x00102260 MOV EAX,dword ptr [RBP + -0x74] MOVSXD RDX,EAX LEA RAX,[RBP + -0x60] MOV RSI,qword ptr [RBP + -0x70] MOV RCX,-0x1 MOV RDI,RAX LAB_00102466: CALL 0x00102260 MOV RAX,qword ptr [RBP + -0x68] LEA RDX,[RBP + -0x40] LEA RCX,[RBP + -0x60] MOV RSI,RCX MOV RDI,RAX LAB_0010247d: CALL 0x00102a0c LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x001021f0 LEA RAX,[RBP + -0x40] MOV RDI,RAX CALL 0x001021f0 NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001024f8 JMP 0x001024f3 LAB_001024f3: CALL 0x001022a0 LAB_001024f8: MOV RAX,qword ptr [RBP + -0x68] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::string, int) */ int8 func0(int8 param_1,ulong param_2) { long in_FS_OFFSET; string local_68 [32]; string local_48 [40]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); std::string::substr((ulong)local_48,param_2); /* try { // try from 00102466 to 0010246a has its CatchHandler @ 001024c1 */ std::string::substr((ulong)local_68,param_2); /* try { // try from 0010247d to 00102481 has its CatchHandler @ 001024ac */ std::operator+(param_1,local_68,local_48); std::string::~string(local_68); std::string::~string(local_48); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
3,889
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string s, int d) { std::string tmp = s.substr(d) + s.substr(0, d); return tmp; }
int main() { assert(func0("python", 2) == "thonpy"); assert(func0("bigdata", 3) == "databig"); assert(func0("hadoop", 1) == "adooph"); return 0; }
O1
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int): endbr64 push %r12 push %rbp push %rbx sub $0x50,%rsp mov %rdi,%rbx mov %rsi,%r12 mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax movslq %edx,%rbp mov 0x8(%rsi),%rdx lea 0x20(%rsp),%rdi lea 0x30(%rsp),%rax mov %rax,0x20(%rsp) mov (%rsi),%rsi cmp %rdx,%rbp cmovbe %rbp,%rdx add %rsi,%rdx callq 1702 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov 0x8(%r12),%rdx cmp %rdx,%rbp ja 133a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x71> mov %rsp,%rdi lea 0x10(%rsp),%rax mov %rax,(%rsp) mov (%r12),%rsi add %rsi,%rdx add %rbp,%rsi callq 1702 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> jmp 1364 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x9b> mov %rdx,%rcx mov %rbp,%rdx lea 0xceb(%rip),%rsi lea 0xd32(%rip),%rdi mov $0x0,%eax callq 1190 <_ZSt24__throw_out_of_range_fmtPKcz@plt> endbr64 mov %rax,%rbx jmpq 146e <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1a5> mov 0x8(%rsp),%r8 mov 0x28(%rsp),%rdx lea (%r8,%rdx,1),%rcx mov (%rsp),%rsi lea 0x10(%rsp),%rax cmp %rax,%rsi mov $0xf,%eax cmovne 0x10(%rsp),%rax cmp %rax,%rcx jbe 13a4 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xdb> lea 0x30(%rsp),%rax cmp %rax,0x20(%rsp) je 13b3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xea> mov 0x30(%rsp),%rax cmp %rax,%rcx jbe 13ba <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xf1> mov %rsp,%rdi mov 0x20(%rsp),%rsi callq 1120 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> jmp 13d1 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x108> mov $0xf,%eax jmp 139f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xd6> lea 0x20(%rsp),%rdi mov %rsi,%rcx mov $0x0,%edx mov $0x0,%esi callq 11b0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@plt> lea 0x10(%rbx),%rdx mov %rdx,(%rbx) mov (%rax),%rcx lea 0x10(%rax),%rdx cmp %rdx,%rcx je 1449 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x180> mov %rcx,(%rbx) mov 0x10(%rax),%rcx mov %rcx,0x10(%rbx) mov 0x8(%rax),%rcx mov %rcx,0x8(%rbx) mov %rdx,(%rax) movq $0x0,0x8(%rax) movb $0x0,0x10(%rax) mov (%rsp),%rdi lea 0x10(%rsp),%rax cmp %rax,%rdi je 1419 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x150> callq 1170 <_ZdlPv@plt> mov 0x20(%rsp),%rdi lea 0x30(%rsp),%rax cmp %rax,%rdi je 142d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x164> callq 1170 <_ZdlPv@plt> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 148a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1c1> mov %rbx,%rax add $0x50,%rsp pop %rbx pop %rbp pop %r12 retq movdqu 0x10(%rax),%xmm0 movups %xmm0,0x10(%rbx) jmp 13ef <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x126> endbr64 mov %rax,%rbx mov (%rsp),%rdi lea 0x10(%rsp),%rax cmp %rax,%rdi je 146e <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1a5> callq 1170 <_ZdlPv@plt> mov 0x20(%rsp),%rdi lea 0x30(%rsp),%rax cmp %rax,%rdi je 1482 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1b9> callq 1170 <_ZdlPv@plt> mov %rbx,%rdi callq 11c0 <_Unwind_Resume@plt> callq 1180 <__stack_chk_fail@plt>
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 push r12 push rbp push rbx sub rsp, 50h mov rbx, rdi mov r12, rsi mov rax, fs:28h mov [rsp+68h+var_20], rax xor eax, eax movsxd rbp, edx lea rdi, [rsp+68h+var_48] lea rax, [rsp+68h+var_38] mov [rsp+68h+var_48], rax mov rsi, [rsi] mov rdx, [r12+8] cmp rbp, rdx cmovbe rdx, rbp add rdx, rsi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) mov rdx, [r12+8] cmp rdx, rbp jb short loc_135B mov rdi, rsp lea rax, [rsp+68h+var_58] mov [rsp+68h+var_68], rax mov rsi, [r12] add rdx, rsi add rsi, rbp call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp short loc_139A loc_135B: mov rax, [rsp+68h+var_20] sub rax, fs:28h jnz short loc_1395 mov rcx, rdx mov rdx, rbp lea rsi, aBasicStringSub; "basic_string::substr" lea rdi, aSPosWhichIsZuT; "%s: __pos (which is %zu) > this->size()"... mov eax, 0 call __ZSt24__throw_out_of_range_fmtPKcz; std::__throw_out_of_range_fmt(char const*,...) endbr64 mov rbx, rax jmp loc_1519 loc_1395: call ___stack_chk_fail loc_139A: mov r8, [rsp+68h+var_60] mov rdx, [rsp+68h+var_40] lea rax, [r8+rdx] mov rcx, [rsp+68h+var_68] lea rsi, [rsp+68h+var_58] cmp rcx, rsi jz short loc_13FE mov rsi, [rsp+68h+var_58] loc_13BB: cmp rsi, rax jnb short loc_13D6 lea rsi, [rsp+68h+var_38] cmp [rsp+68h+var_48], rsi jz short loc_1405 mov rsi, [rsp+68h+var_38] loc_13D1: cmp rsi, rax jnb short loc_140C loc_13D6: mov rsi, [rsp+68h+var_48] mov rax, 3FFFFFFFFFFFFFFFh sub rax, r8 cmp rax, rdx jb loc_14EE mov rdi, rsp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) jmp loc_1541 loc_13FE: mov esi, 0Fh jmp short loc_13BB loc_1405: mov esi, 0Fh jmp short loc_13D1 loc_140C: lea rdi, [rsp+68h+var_48] mov edx, 0 mov esi, 0 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm; std::string::_M_replace(ulong,ulong,char const*,ulong) lea rcx, [rbx+10h] mov [rbx], rcx mov rdx, [rax] lea rsi, [rax+10h] cmp rdx, rsi jz short loc_145A mov [rbx], rdx mov rdx, [rax+10h] mov [rbx+10h], rdx loc_143E: mov rdx, [rax+8] mov [rbx+8], rdx mov [rax], rsi mov qword ptr [rax+8], 0 mov byte ptr [rax+10h], 0 jmp loc_1576 loc_145A: mov rdi, [rax+8] lea rdx, [rdi+1] cmp edx, 8 jnb short loc_149D test dl, 4 jnz short loc_148B test edx, edx jz short loc_143E movzx edi, byte ptr [rax+10h] mov [rbx+10h], dil test dl, 2 jz short loc_143E mov edx, edx movzx edi, word ptr [rsi+rdx-2] mov [rcx+rdx-2], di jmp short loc_143E loc_148B: mov edi, [rax+10h] mov [rbx+10h], edi mov edx, edx mov edi, [rsi+rdx-4] mov [rcx+rdx-4], edi jmp short loc_143E loc_149D: mov rdi, [rax+10h] mov [rbx+10h], rdi mov edi, edx mov r8, [rsi+rdi-8] mov [rcx+rdi-8], r8 lea r8, [rcx+8] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 mov r10, rsi sub r10, rcx add edx, ecx and edx, 0FFFFFFF8h cmp edx, 8 jb loc_143E and edx, 0FFFFFFF8h mov ecx, 0 loc_14D8: mov edi, ecx mov r9, [r10+rdi] mov [r8+rdi], r9 add ecx, 8 cmp ecx, edx jb short loc_14D8 jmp loc_143E loc_14EE: mov rax, [rsp+68h+var_20] sub rax, fs:28h jnz short loc_153C lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) endbr64 mov rbx, rax mov rdi, rsp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) loc_1519: lea rdi, [rsp+68h+var_48] call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) mov rax, [rsp+68h+var_20] sub rax, fs:28h jz loc_1671 call ___stack_chk_fail loc_153C: call ___stack_chk_fail loc_1541: lea rcx, [rbx+10h] mov [rbx], rcx mov rdx, [rax] lea rsi, [rax+10h] cmp rdx, rsi jz short loc_15CF mov [rbx], rdx mov rdx, [rax+10h] mov [rbx+10h], rdx loc_155F: mov rdx, [rax+8] mov [rbx+8], rdx mov [rax], rsi mov qword ptr [rax+8], 0 mov byte ptr [rax+10h], 0 loc_1576: mov rdi, [rsp+68h+var_68]; void * lea rax, [rsp+68h+var_58] cmp rdi, rax jz short loc_1592 mov rax, [rsp+68h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1592: mov rdi, [rsp+68h+var_48]; void * lea rax, [rsp+68h+var_38] cmp rdi, rax jz short loc_15AF mov rax, [rsp+68h+var_38] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_15AF: mov rax, [rsp+68h+var_20] sub rax, fs:28h jnz loc_1679 mov rax, rbx add rsp, 50h pop rbx pop rbp pop r12 retn loc_15CF: mov rdi, [rax+8] lea rdx, [rdi+1] cmp edx, 8 jnb short loc_1620 test dl, 4 jnz short loc_160B test edx, edx jz loc_155F movzx edi, byte ptr [rax+10h] mov [rbx+10h], dil test dl, 2 jz loc_155F mov edx, edx movzx edi, word ptr [rsi+rdx-2] mov [rcx+rdx-2], di jmp loc_155F loc_160B: mov edi, [rax+10h] mov [rbx+10h], edi mov edx, edx mov edi, [rsi+rdx-4] mov [rcx+rdx-4], edi jmp loc_155F loc_1620: mov rdi, [rax+10h] mov [rbx+10h], rdi mov edi, edx mov r8, [rsi+rdi-8] mov [rcx+rdi-8], r8 lea r8, [rcx+8] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 mov r10, rsi sub r10, rcx add edx, ecx and edx, 0FFFFFFF8h cmp edx, 8 jb loc_155F and edx, 0FFFFFFF8h mov ecx, 0 loc_165B: mov edi, ecx mov r9, [r10+rdi] mov [r8+rdi], r9 add ecx, 8 cmp ecx, edx jb short loc_165B jmp loc_155F loc_1671: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_1679: call ___stack_chk_fail
char ** func0(char **a1, long long *a2, int a3) { unsigned long long v4; // rbp long long v5; // rsi unsigned long long v6; // rdx unsigned long long v7; // rdx unsigned long long v8; // rax unsigned long long v9; // rsi unsigned long long v10; // rsi char **v11; // rax char **v12; // rax _QWORD *v13; // rcx char *v14; // rsi unsigned int v15; // edx unsigned long long v16; // r8 char *v17; // rcx char *v18; // r10 unsigned int v19; // edx unsigned int v20; // edx unsigned int v21; // ecx _QWORD *v22; // rcx char *v23; // rsi unsigned int v25; // edx unsigned long long v26; // r8 char *v27; // rcx char *v28; // r10 unsigned int v29; // edx unsigned int v30; // edx unsigned int v31; // ecx void *v32; // [rsp+0h] [rbp-68h] BYREF long long v33; // [rsp+8h] [rbp-60h] _QWORD v34[2]; // [rsp+10h] [rbp-58h] BYREF void *v35; // [rsp+20h] [rbp-48h] BYREF unsigned long long v36; // [rsp+28h] [rbp-40h] _QWORD v37[7]; // [rsp+30h] [rbp-38h] BYREF v37[3] = __readfsqword(0x28u); v4 = a3; v35 = v37; v5 = *a2; v6 = a2[1]; if ( v4 <= v6 ) v6 = v4; std::string::_M_construct<char const*>(&v35, v5, v5 + v6); v7 = a2[1]; if ( v7 < v4 ) std::__throw_out_of_range_fmt( "%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v4, a2[1]); v32 = v34; std::string::_M_construct<char const*>(&v32, v4 + *a2, *a2 + v7); v8 = v33 + v36; if ( v32 == v34 ) v9 = 15LL; else v9 = v34[0]; if ( v9 < v8 && (v35 == v37 ? (v10 = 15LL) : (v10 = v37[0]), v10 >= v8) ) { v12 = (char **)std::string::_M_replace(&v35, 0LL, 0LL); v13 = a1 + 2; *a1 = (char *)(a1 + 2); v14 = (char *)(v12 + 2); if ( *v12 == (char *)(v12 + 2) ) { v15 = (unsigned int)v12[1] + 1; if ( v15 >= 8 ) { a1[2] = v12[2]; *(_QWORD *)((char *)v13 + v15 - 8) = *(_QWORD *)&v14[v15 - 8]; v16 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v17 = (char *)v13 - v16; v18 = (char *)(v14 - v17); v19 = ((_DWORD)v17 + v15) & 0xFFFFFFF8; if ( v19 >= 8 ) { v20 = v19 & 0xFFFFFFF8; v21 = 0; do { *(_QWORD *)(v16 + v21) = *(_QWORD *)&v18[v21]; v21 += 8; } while ( v21 < v20 ); } } else if ( (v15 & 4) != 0 ) { *((_DWORD *)a1 + 4) = *((_DWORD *)v12 + 4); *(_DWORD *)((char *)v13 + v15 - 4) = *(_DWORD *)&v14[v15 - 4]; } else if ( (unsigned int)v12[1] != -1 ) { *((_BYTE *)a1 + 16) = *((_BYTE *)v12 + 16); if ( (v15 & 2) != 0 ) *(_WORD *)((char *)v13 + v15 - 2) = *(_WORD *)&v14[v15 - 2]; } } else { *a1 = *v12; a1[2] = v12[2]; } a1[1] = v12[1]; *v12 = v14; v12[1] = 0LL; *((_BYTE *)v12 + 16) = 0; } else { if ( 0x3FFFFFFFFFFFFFFFLL - v33 < v36 ) std::__throw_length_error("basic_string::append"); v11 = (char **)std::string::_M_append(&v32, v35); v22 = a1 + 2; *a1 = (char *)(a1 + 2); v23 = (char *)(v11 + 2); if ( *v11 == (char *)(v11 + 2) ) { v25 = (unsigned int)v11[1] + 1; if ( v25 >= 8 ) { a1[2] = v11[2]; *(_QWORD *)((char *)v22 + v25 - 8) = *(_QWORD *)&v23[v25 - 8]; v26 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v27 = (char *)v22 - v26; v28 = (char *)(v23 - v27); v29 = ((_DWORD)v27 + v25) & 0xFFFFFFF8; if ( v29 >= 8 ) { v30 = v29 & 0xFFFFFFF8; v31 = 0; do { *(_QWORD *)(v26 + v31) = *(_QWORD *)&v28[v31]; v31 += 8; } while ( v31 < v30 ); } } else if ( (v25 & 4) != 0 ) { *((_DWORD *)a1 + 4) = *((_DWORD *)v11 + 4); *(_DWORD *)((char *)v22 + v25 - 4) = *(_DWORD *)&v23[v25 - 4]; } else if ( (unsigned int)v11[1] != -1 ) { *((_BYTE *)a1 + 16) = *((_BYTE *)v11 + 16); if ( (v25 & 2) != 0 ) *(_WORD *)((char *)v22 + v25 - 2) = *(_WORD *)&v23[v25 - 2]; } } else { *a1 = *v11; a1[2] = v11[2]; } a1[1] = v11[1]; *v11 = v23; v11[1] = 0LL; *((_BYTE *)v11 + 16) = 0; } if ( v32 != v34 ) operator delete(v32, v34[0] + 1LL); if ( v35 != v37 ) operator delete(v35, v37[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x50 MOV RBX,RDI MOV R12,RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX MOVSXD RBP,EDX LEA RDI,[RSP + 0x20] LEA RAX,[RSP + 0x30] MOV qword ptr [RSP + 0x20],RAX MOV RSI,qword ptr [RSI] MOV RDX,qword ptr [R12 + 0x8] CMP RBP,RDX CMOVBE RDX,RBP ADD RDX,RSI LAB_0010132f: CALL 0x001018ea MOV RDX,qword ptr [R12 + 0x8] CMP RDX,RBP JC 0x0010135b MOV RDI,RSP LEA RAX,[RSP + 0x10] MOV qword ptr [RSP],RAX MOV RSI,qword ptr [R12] ADD RDX,RSI ADD RSI,RBP LAB_00101354: CALL 0x001018ea JMP 0x0010139a LAB_0010135b: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101395 MOV RCX,RDX MOV RDX,RBP LEA RSI,[0x1020ff] LEA RDI,[0x102040] MOV EAX,0x0 CALL 0x001011c0 LAB_00101389: ENDBR64 MOV RBX,RAX JMP 0x00101519 LAB_00101395: CALL 0x001011a0 LAB_0010139a: MOV R8,qword ptr [RSP + 0x8] MOV RDX,qword ptr [RSP + 0x28] LEA RAX,[R8 + RDX*0x1] MOV RCX,qword ptr [RSP] LEA RSI,[RSP + 0x10] CMP RCX,RSI JZ 0x001013fe MOV RSI,qword ptr [RSP + 0x10] LAB_001013bb: CMP RSI,RAX JNC 0x001013d6 LEA RSI,[RSP + 0x30] CMP qword ptr [RSP + 0x20],RSI JZ 0x00101405 MOV RSI,qword ptr [RSP + 0x30] LAB_001013d1: CMP RSI,RAX JNC 0x0010140c LAB_001013d6: MOV RSI,qword ptr [RSP + 0x20] MOV RAX,0x3fffffffffffffff SUB RAX,R8 CMP RAX,RDX JC 0x001014ee MOV RDI,RSP LAB_001013f4: CALL 0x00101120 JMP 0x00101541 LAB_001013fe: MOV ESI,0xf JMP 0x001013bb LAB_00101405: MOV ESI,0xf JMP 0x001013d1 LAB_0010140c: LEA RDI,[RSP + 0x20] MOV EDX,0x0 MOV ESI,0x0 CALL 0x001011d0 LEA RCX,[RBX + 0x10] MOV qword ptr [RBX],RCX MOV RDX,qword ptr [RAX] LEA RSI,[RAX + 0x10] CMP RDX,RSI JZ 0x0010145a MOV qword ptr [RBX],RDX MOV RDX,qword ptr [RAX + 0x10] MOV qword ptr [RBX + 0x10],RDX LAB_0010143e: MOV RDX,qword ptr [RAX + 0x8] MOV qword ptr [RBX + 0x8],RDX MOV qword ptr [RAX],RSI MOV qword ptr [RAX + 0x8],0x0 MOV byte ptr [RAX + 0x10],0x0 JMP 0x00101576 LAB_0010145a: MOV RDI,qword ptr [RAX + 0x8] LEA RDX,[RDI + 0x1] CMP EDX,0x8 JNC 0x0010149d TEST DL,0x4 JNZ 0x0010148b TEST EDX,EDX JZ 0x0010143e MOVZX EDI,byte ptr [RAX + 0x10] MOV byte ptr [RBX + 0x10],DIL TEST DL,0x2 JZ 0x0010143e MOV EDX,EDX MOVZX EDI,word ptr [RSI + RDX*0x1 + -0x2] MOV word ptr [RCX + RDX*0x1 + -0x2],DI JMP 0x0010143e LAB_0010148b: MOV EDI,dword ptr [RAX + 0x10] MOV dword ptr [RBX + 0x10],EDI MOV EDX,EDX MOV EDI,dword ptr [RSI + RDX*0x1 + -0x4] MOV dword ptr [RCX + RDX*0x1 + -0x4],EDI JMP 0x0010143e LAB_0010149d: MOV RDI,qword ptr [RAX + 0x10] MOV qword ptr [RBX + 0x10],RDI MOV EDI,EDX MOV R8,qword ptr [RSI + RDI*0x1 + -0x8] MOV qword ptr [RCX + RDI*0x1 + -0x8],R8 LEA R8,[RCX + 0x8] AND R8,-0x8 SUB RCX,R8 MOV R10,RSI SUB R10,RCX ADD EDX,ECX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x0010143e AND EDX,0xfffffff8 MOV ECX,0x0 LAB_001014d8: MOV EDI,ECX MOV R9,qword ptr [R10 + RDI*0x1] MOV qword ptr [R8 + RDI*0x1],R9 ADD ECX,0x8 CMP ECX,EDX JC 0x001014d8 JMP 0x0010143e LAB_001014ee: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010153c LEA RDI,[0x102114] CALL 0x00101150 LAB_0010150a: ENDBR64 MOV RBX,RAX MOV RDI,RSP CALL 0x001011b0 LAB_00101519: LEA RDI,[RSP + 0x20] CALL 0x001011b0 MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JZ 0x00101671 CALL 0x001011a0 LAB_0010153c: CALL 0x001011a0 LAB_00101541: LEA RCX,[RBX + 0x10] MOV qword ptr [RBX],RCX MOV RDX,qword ptr [RAX] LEA RSI,[RAX + 0x10] CMP RDX,RSI JZ 0x001015cf MOV qword ptr [RBX],RDX MOV RDX,qword ptr [RAX + 0x10] MOV qword ptr [RBX + 0x10],RDX LAB_0010155f: MOV RDX,qword ptr [RAX + 0x8] MOV qword ptr [RBX + 0x8],RDX MOV qword ptr [RAX],RSI MOV qword ptr [RAX + 0x8],0x0 MOV byte ptr [RAX + 0x10],0x0 LAB_00101576: MOV RDI,qword ptr [RSP] LEA RAX,[RSP + 0x10] CMP RDI,RAX JZ 0x00101592 MOV RAX,qword ptr [RSP + 0x10] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_00101592: MOV RDI,qword ptr [RSP + 0x20] LEA RAX,[RSP + 0x30] CMP RDI,RAX JZ 0x001015af MOV RAX,qword ptr [RSP + 0x30] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_001015af: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101679 MOV RAX,RBX ADD RSP,0x50 POP RBX POP RBP POP R12 RET LAB_001015cf: MOV RDI,qword ptr [RAX + 0x8] LEA RDX,[RDI + 0x1] CMP EDX,0x8 JNC 0x00101620 TEST DL,0x4 JNZ 0x0010160b TEST EDX,EDX JZ 0x0010155f MOVZX EDI,byte ptr [RAX + 0x10] MOV byte ptr [RBX + 0x10],DIL TEST DL,0x2 JZ 0x0010155f MOV EDX,EDX MOVZX EDI,word ptr [RSI + RDX*0x1 + -0x2] MOV word ptr [RCX + RDX*0x1 + -0x2],DI JMP 0x0010155f LAB_0010160b: MOV EDI,dword ptr [RAX + 0x10] MOV dword ptr [RBX + 0x10],EDI MOV EDX,EDX MOV EDI,dword ptr [RSI + RDX*0x1 + -0x4] MOV dword ptr [RCX + RDX*0x1 + -0x4],EDI JMP 0x0010155f LAB_00101620: MOV RDI,qword ptr [RAX + 0x10] MOV qword ptr [RBX + 0x10],RDI MOV EDI,EDX MOV R8,qword ptr [RSI + RDI*0x1 + -0x8] MOV qword ptr [RCX + RDI*0x1 + -0x8],R8 LEA R8,[RCX + 0x8] AND R8,-0x8 SUB RCX,R8 MOV R10,RSI SUB R10,RCX ADD EDX,ECX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x0010155f AND EDX,0xfffffff8 MOV ECX,0x0 LAB_0010165b: MOV EDI,ECX MOV R9,qword ptr [R10 + RDI*0x1] MOV qword ptr [R8 + RDI*0x1],R9 ADD ECX,0x8 CMP ECX,EDX JC 0x0010165b JMP 0x0010155f LAB_00101671: MOV RDI,RBX LAB_00101674: CALL 0x001011e0 LAB_00101679: CALL 0x001011a0
/* func0(std::string, int) */ long * func0(long *param_1,long *param_2,int param_3) { long *plVar1; long *plVar2; int8 uVar3; uint uVar4; long lVar5; uint uVar6; ulong uVar7; ulong uVar8; long in_FS_OFFSET; ulong *local_68; long local_60; ulong local_58 [2]; ulong *local_48; ulong local_40; ulong local_38 [3]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); uVar8 = (ulong)param_3; local_48 = local_38; uVar7 = param_2[1]; if (uVar8 <= (ulong)param_2[1]) { uVar7 = uVar8; } std::string::_M_construct<char_const*> ((char *)&local_48,(char *)*param_2,(int)uVar7 + (int)(char *)*param_2); uVar7 = param_2[1]; if (uVar7 < uVar8) { if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } uVar3 = std::__throw_out_of_range_fmt ("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr",uVar8,uVar7); /* catch() { ... } // from try @ 00101354 with catch @ 00101389 */ } else { local_68 = local_58; /* try { // try from 00101354 to 00101388 has its CatchHandler @ 00101389 */ std::string::_M_construct<char_const*> ((char *)&local_68,(char *)(*param_2 + uVar8),(int)uVar7 + (int)*param_2); uVar7 = local_58[0]; if (local_68 == local_58) { uVar7 = 0xf; } if (uVar7 < local_60 + local_40) { uVar7 = local_38[0]; if (local_48 == local_38) { uVar7 = 0xf; } if (local_60 + local_40 <= uVar7) { plVar2 = (long *)std::string::_M_replace((ulong)&local_48,0,(char *)0x0,(ulong)local_68); *param_1 = (long)(param_1 + 2); plVar1 = plVar2 + 2; if ((long *)*plVar2 == plVar1) { uVar7 = plVar2[1] + 1; uVar6 = (uint)uVar7; if (uVar6 < 8) { if ((uVar7 & 4) == 0) { if ((uVar6 != 0) && (*(int *)(param_1 + 2) = *(int *)(plVar2 + 2), (uVar7 & 2) != 0)) { *(int2 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xe) = *(int2 *)((long)plVar2 + (uVar7 & 0xffffffff) + 0xe); } } else { *(int4 *)(param_1 + 2) = *(int4 *)(plVar2 + 2); *(int4 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xc) = *(int4 *)((long)plVar2 + (uVar7 & 0xffffffff) + 0xc); } } else { param_1[2] = plVar2[2]; *(int8 *)((long)param_1 + (uVar7 & 0xffffffff) + 8) = *(int8 *)((long)plVar2 + (uVar7 & 0xffffffff) + 8); lVar5 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar6 = uVar6 + (int)lVar5 & 0xfffffff8; if (7 < uVar6) { uVar4 = 0; do { *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + (ulong)uVar4) = *(int8 *)((long)plVar1 + ((ulong)uVar4 - lVar5)); uVar4 = uVar4 + 8; } while (uVar4 < uVar6); } } } else { *param_1 = *plVar2; param_1[2] = plVar2[2]; } param_1[1] = plVar2[1]; *plVar2 = (long)plVar1; plVar2[1] = 0; *(int *)(plVar2 + 2) = 0; goto LAB_00101576; } } if (local_40 <= 0x3fffffffffffffffU - local_60) { /* try { // try from 001013f4 to 00101509 has its CatchHandler @ 0010150a */ plVar2 = (long *)std::string::_M_append((char *)&local_68,(ulong)local_48); *param_1 = (long)(param_1 + 2); plVar1 = plVar2 + 2; if ((long *)*plVar2 == plVar1) { uVar7 = plVar2[1] + 1; uVar6 = (uint)uVar7; if (uVar6 < 8) { if ((uVar7 & 4) == 0) { if ((uVar6 != 0) && (*(int *)(param_1 + 2) = *(int *)(plVar2 + 2), (uVar7 & 2) != 0)) { *(int2 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xe) = *(int2 *)((long)plVar2 + (uVar7 & 0xffffffff) + 0xe); } } else { *(int4 *)(param_1 + 2) = *(int4 *)(plVar2 + 2); *(int4 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xc) = *(int4 *)((long)plVar2 + (uVar7 & 0xffffffff) + 0xc); } } else { param_1[2] = plVar2[2]; *(int8 *)((long)param_1 + (uVar7 & 0xffffffff) + 8) = *(int8 *)((long)plVar2 + (uVar7 & 0xffffffff) + 8); lVar5 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar6 = uVar6 + (int)lVar5 & 0xfffffff8; if (7 < uVar6) { uVar4 = 0; do { *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + (ulong)uVar4) = *(int8 *)((long)plVar1 + ((ulong)uVar4 - lVar5)); uVar4 = uVar4 + 8; } while (uVar4 < uVar6); } } } else { *param_1 = *plVar2; param_1[2] = plVar2[2]; } param_1[1] = plVar2[1]; *plVar2 = (long)plVar1; plVar2[1] = 0; *(int *)(plVar2 + 2) = 0; LAB_00101576: if (local_68 != local_58) { operator_delete(local_68,local_58[0] + 1); } if (local_48 != local_38) { operator_delete(local_48,local_38[0] + 1); } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } uVar3 = std::__throw_length_error("basic_string::append"); /* catch() { ... } // from try @ 001013f4 with catch @ 0010150a */ std::string::_M_dispose(); } std::string::_M_dispose(); if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar3); } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,890
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string s, int d) { std::string tmp = s.substr(d) + s.substr(0, d); return tmp; }
int main() { assert(func0("python", 2) == "thonpy"); assert(func0("bigdata", 3) == "databig"); assert(func0("hadoop", 1) == "adooph"); return 0; }
O2
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int): endbr64 push %r15 mov %rsi,%rax push %r14 push %r13 movslq %edx,%r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x68,%rsp mov 0x8(%rsi),%rdx mov (%rsi),%rsi mov %fs:0x28,%rbx mov %rbx,0x58(%rsp) xor %ebx,%ebx lea 0x30(%rsp),%r14 lea 0x40(%rsp),%rbp mov %rax,0x8(%rsp) cmp %rdx,%r13 mov %r14,%rdi mov %rbp,0x30(%rsp) cmovbe %r13,%rdx add %rsi,%rdx callq 1710 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov 0x8(%rsp),%rax mov 0x8(%rax),%rdx cmp %rdx,%r13 ja 16d8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x178> mov (%rax),%rsi lea 0x10(%rsp),%r15 lea 0x20(%rsp),%rbx mov %r15,%rdi mov %rbx,0x10(%rsp) add %rsi,%rdx add %r13,%rsi callq 1710 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov 0x10(%rsp),%r9 mov 0x18(%rsp),%r8 mov $0xf,%eax mov 0x38(%rsp),%rdx mov %rax,%rdi mov 0x30(%rsp),%rsi cmp %rbx,%r9 cmovne 0x20(%rsp),%rdi lea (%r8,%rdx,1),%rcx cmp %rdi,%rcx jbe 162a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xca> cmp %rbp,%rsi cmovne 0x40(%rsp),%rax cmp %rax,%rcx jbe 16b0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x150> mov %r15,%rdi callq 1130 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> lea 0x10(%r12),%rdx mov %rdx,(%r12) mov (%rax),%rcx lea 0x10(%rax),%rdx cmp %rdx,%rcx je 16c8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x168> mov %rcx,(%r12) mov 0x10(%rax),%rcx mov %rcx,0x10(%r12) mov 0x8(%rax),%rcx mov %rdx,(%rax) mov 0x10(%rsp),%rdi movq $0x0,0x8(%rax) mov %rcx,0x8(%r12) movb $0x0,0x10(%rax) cmp %rbx,%rdi je 167f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x11f> callq 1190 <_ZdlPv@plt> mov 0x30(%rsp),%rdi cmp %rbp,%rdi je 168e <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x12e> callq 1190 <_ZdlPv@plt> mov 0x58(%rsp),%rax xor %fs:0x28,%rax jne 16f3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x193> add $0x68,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov %r9,%rcx xor %edx,%edx xor %esi,%esi mov %r14,%rdi callq 11d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@plt> jmpq 1632 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xd2> nopl 0x0(%rax) movdqu 0x10(%rax),%xmm0 movups %xmm0,0x10(%r12) jmpq 1658 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xf8> mov %rdx,%rcx lea 0x950(%rip),%rsi mov %r13,%rdx xor %eax,%eax lea 0x992(%rip),%rdi callq 11b0 <_ZSt24__throw_out_of_range_fmtPKcz@plt> callq 11a0 <__stack_chk_fail@plt> endbr64 mov %rax,%r12 jmpq 120f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi.cold+0xf> endbr64 mov %rax,%r12 jmpq 1200 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi.cold>
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 push r15 push r14 push r13 mov r13, rsi push r12 push rbp movsxd rbp, edx push rbx mov rbx, rdi sub rsp, 68h mov rdx, [r13+8] mov rsi, [rsi] mov rcx, fs:28h mov [rsp+98h+var_40], rcx xor ecx, ecx lea rdi, [rsp+98h+var_68] lea r12, [rsp+98h+var_58] cmp rbp, rdx mov [rsp+98h+var_90], rdi cmovbe rdx, rbp mov [rsp+98h+var_68], r12 add rdx, rsi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rdx, [r13+8] cmp rdx, rbp jb loc_1889 mov rsi, [r13+0] lea r15, [rsp+98h+var_88] lea r14, [rsp+98h+var_78] mov rdi, r15 mov [rsp+98h+var_88], r14 add rdx, rsi add rsi, rbp call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov r8, [rsp+98h+var_80] mov rdx, [rsp+98h+var_60] mov rcx, [rsp+98h+var_88] mov rsi, [rsp+98h+var_68] lea rax, [r8+rdx] cmp rcx, r14 jz loc_17C0 cmp [rsp+98h+var_78], rax jnb short loc_1672 cmp rsi, r12 jz loc_17B0 loc_1664: mov rdi, [rsp+98h+var_58] loc_1669: cmp rdi, rax jnb loc_1720 loc_1672: mov rax, 3FFFFFFFFFFFFFFFh sub rax, r8 cmp rax, rdx jb loc_18B4 mov rdi, r15 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) lea rcx, [rbx+10h] lea rdi, [rax+10h] mov rsi, [rax+8] mov [rbx], rcx mov rdx, [rax] cmp rdx, rdi jz loc_17E0 loc_16AB: mov [rbx], rdx mov rdx, [rax+10h] mov [rbx+10h], rdx loc_16B6: mov [rbx+8], rsi mov [rax], rdi mov byte ptr [rax+10h], 0 mov rdi, [rsp+98h+var_88]; void * mov qword ptr [rax+8], 0 cmp rdi, r14 jz short loc_16E1 mov rax, [rsp+98h+var_78] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_16E1: mov rdi, [rsp+98h+var_68]; void * cmp rdi, r12 jz short loc_16F9 mov rax, [rsp+98h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_16F9: mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz loc_1884 add rsp, 68h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1720: mov rdi, [rsp+98h+var_90] xor edx, edx xor esi, esi call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm; std::string::_M_replace(ulong,ulong,char const*,ulong) lea rcx, [rbx+10h] lea rdi, [rax+10h] mov rsi, [rax+8] mov [rbx], rcx mov rdx, [rax] cmp rdx, rdi jnz loc_16AB lea rdx, [rsi+1] cmp edx, 8 jb loc_1838 mov rsi, [rax+10h] mov r10, rdi mov [rbx+10h], rsi mov esi, edx mov r8, [rdi+rsi-8] mov [rcx+rsi-8], r8 lea r8, [rbx+18h] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 add edx, ecx sub r10, rcx and edx, 0FFFFFFF8h cmp edx, 8 jb short loc_17A0 and edx, 0FFFFFFF8h xor ecx, ecx loc_178A: mov esi, ecx add ecx, 8 mov r9, [r10+rsi] mov [r8+rsi], r9 cmp ecx, edx jb short loc_178A nop dword ptr [rax+rax+00h] loc_17A0: mov rsi, [rax+8] jmp loc_16B6 loc_17B0: mov edi, 0Fh jmp loc_1669 loc_17C0: cmp rax, 0Fh jbe loc_1672 cmp rsi, r12 jnz loc_1664 jmp loc_1672 loc_17E0: lea rdx, [rsi+1] cmp edx, 8 jb short loc_1838 mov rsi, [rax+10h] mov r10, rdi mov [rbx+10h], rsi mov esi, edx mov r8, [rdi+rsi-8] mov [rcx+rsi-8], r8 lea r8, [rbx+18h] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 add edx, ecx sub r10, rcx and edx, 0FFFFFFF8h cmp edx, 8 jb short loc_17A0 and edx, 0FFFFFFF8h xor ecx, ecx loc_181D: mov esi, ecx add ecx, 8 mov r9, [r10+rsi] mov [r8+rsi], r9 cmp ecx, edx jb short loc_181D jmp loc_17A0 loc_1838: test dl, 4 jnz short loc_186B test edx, edx jz loc_16B6 movzx esi, byte ptr [rax+10h] mov [rbx+10h], sil test dl, 2 jz loc_17A0 mov edx, edx movzx esi, word ptr [rdi+rdx-2] mov [rcx+rdx-2], si mov rsi, [rax+8] jmp loc_16B6 loc_186B: mov esi, [rax+10h] mov edx, edx mov [rbx+10h], esi mov esi, [rdi+rdx-4] mov [rcx+rdx-4], esi mov rsi, [rax+8] jmp loc_16B6 loc_1884: call ___stack_chk_fail loc_1889: mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1884 mov rcx, rdx lea rsi, aBasicStringSub; "basic_string::substr" mov rdx, rbp xor eax, eax lea rdi, aSPosWhichIsZuT; "%s: __pos (which is %zu) > this->size()"... call __ZSt24__throw_out_of_range_fmtPKcz; std::__throw_out_of_range_fmt(char const*,...) loc_18B4: mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1884 lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) endbr64 mov rbx, rax jmp loc_1208 endbr64 mov rbx, rax jmp _Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi_cold; func0(std::string,int) [clone]
char ** func0(char **a1, long long *a2, int a3) { unsigned long long v4; // rbp unsigned long long v6; // rdx long long v7; // rsi long long v8; // rcx unsigned long long v9; // rdx long long v10; // rsi unsigned long long v11; // rax unsigned long long v12; // rdi char **v13; // rax _QWORD *v14; // rcx char *v15; // rdi char *v16; // rsi char *v17; // rdx _QWORD *v18; // rdi unsigned int v20; // edx unsigned long long v21; // r8 char *v22; // rcx char *v23; // r10 unsigned int v24; // edx unsigned int v25; // edx unsigned int v26; // ecx long long v27; // rsi unsigned long long v28; // r8 char *v29; // rcx char *v30; // r10 unsigned int v31; // edx unsigned int v32; // edx unsigned int v33; // ecx long long v34; // rsi void *v35; // [rsp+10h] [rbp-88h] BYREF long long v36; // [rsp+18h] [rbp-80h] _QWORD v37[2]; // [rsp+20h] [rbp-78h] BYREF void *v38; // [rsp+30h] [rbp-68h] BYREF unsigned long long v39; // [rsp+38h] [rbp-60h] _QWORD v40[11]; // [rsp+40h] [rbp-58h] BYREF v4 = a3; v6 = a2[1]; v7 = *a2; v40[3] = __readfsqword(0x28u); if ( v4 <= v6 ) v6 = v4; v38 = v40; std::string::_M_construct<char const*>(&v38, v7, v7 + v6, 0LL); v9 = a2[1]; if ( v9 < v4 ) std::__throw_out_of_range_fmt( "%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v4, a2[1]); v10 = *a2; v35 = v37; std::string::_M_construct<char const*>(&v35, v4 + v10, v10 + v9, v8); v11 = v36 + v39; if ( v35 == v37 ) { if ( v11 <= 0xF || v38 == v40 ) goto LABEL_9; goto LABEL_7; } if ( v37[0] >= v11 ) goto LABEL_9; if ( v38 != v40 ) { LABEL_7: v12 = v40[0]; goto LABEL_8; } v12 = 15LL; LABEL_8: if ( v12 >= v11 ) { v13 = (char **)std::string::_M_replace(&v38, 0LL, 0LL); v14 = a1 + 2; v15 = (char *)(v13 + 2); v16 = v13[1]; *a1 = (char *)(a1 + 2); v17 = *v13; if ( *v13 != (char *)(v13 + 2) ) { LABEL_11: *a1 = v17; a1[2] = v13[2]; goto LABEL_12; } v20 = (_DWORD)v16 + 1; if ( (unsigned int)((_DWORD)v16 + 1) >= 8 ) { a1[2] = v13[2]; *(_QWORD *)((char *)v14 + v20 - 8) = *(_QWORD *)&v15[v20 - 8]; v21 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v22 = (char *)v14 - v21; v23 = (char *)(v15 - v22); v24 = ((_DWORD)v22 + v20) & 0xFFFFFFF8; if ( v24 >= 8 ) { v25 = v24 & 0xFFFFFFF8; v26 = 0; do { v27 = v26; v26 += 8; *(_QWORD *)(v21 + v27) = *(_QWORD *)&v23[v27]; } while ( v26 < v25 ); } goto LABEL_22; } goto LABEL_32; } LABEL_9: if ( 0x3FFFFFFFFFFFFFFFLL - v36 < v39 ) std::__throw_length_error("basic_string::append"); v13 = (char **)std::string::_M_append(&v35, v38); v14 = a1 + 2; v15 = (char *)(v13 + 2); v16 = v13[1]; *a1 = (char *)(a1 + 2); v17 = *v13; if ( *v13 != (char *)(v13 + 2) ) goto LABEL_11; v20 = (_DWORD)v16 + 1; if ( (unsigned int)((_DWORD)v16 + 1) >= 8 ) { a1[2] = v13[2]; *(_QWORD *)((char *)v14 + v20 - 8) = *(_QWORD *)&v15[v20 - 8]; v28 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v29 = (char *)v14 - v28; v30 = (char *)(v15 - v29); v31 = ((_DWORD)v29 + v20) & 0xFFFFFFF8; if ( v31 >= 8 ) { v32 = v31 & 0xFFFFFFF8; v33 = 0; do { v34 = v33; v33 += 8; *(_QWORD *)(v28 + v34) = *(_QWORD *)&v30[v34]; } while ( v33 < v32 ); } goto LABEL_22; } LABEL_32: if ( (v20 & 4) != 0 ) { *((_DWORD *)a1 + 4) = *((_DWORD *)v13 + 4); *(_DWORD *)((char *)v14 + v20 - 4) = *(_DWORD *)&v15[v20 - 4]; v16 = v13[1]; } else if ( v20 ) { *((_BYTE *)a1 + 16) = *((_BYTE *)v13 + 16); if ( (v20 & 2) == 0 ) { LABEL_22: v16 = v13[1]; goto LABEL_12; } *(_WORD *)((char *)v14 + v20 - 2) = *(_WORD *)&v15[v20 - 2]; v16 = v13[1]; } LABEL_12: a1[1] = v16; *v13 = v15; *((_BYTE *)v13 + 16) = 0; v18 = v35; v13[1] = 0LL; if ( v18 != v37 ) operator delete(v18, v37[0] + 1LL); if ( v38 != v40 ) operator delete(v38, v40[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 MOV R13,RSI PUSH R12 PUSH RBP MOVSXD RBP,EDX PUSH RBX MOV RBX,RDI SUB RSP,0x68 MOV RDX,qword ptr [R13 + 0x8] MOV RSI,qword ptr [RSI] MOV RCX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RCX XOR ECX,ECX LEA RDI,[RSP + 0x30] LEA R12,[RSP + 0x40] CMP RBP,RDX MOV qword ptr [RSP + 0x8],RDI CMOVBE RDX,RBP MOV qword ptr [RSP + 0x30],R12 ADD RDX,RSI LAB_00101600: CALL 0x00101500 MOV RDX,qword ptr [R13 + 0x8] CMP RDX,RBP JC 0x00101889 MOV RSI,qword ptr [R13] LEA R15,[RSP + 0x10] LEA R14,[RSP + 0x20] MOV RDI,R15 MOV qword ptr [RSP + 0x10],R14 ADD RDX,RSI ADD RSI,RBP LAB_0010162e: CALL 0x00101500 MOV R8,qword ptr [RSP + 0x18] MOV RDX,qword ptr [RSP + 0x38] MOV RCX,qword ptr [RSP + 0x10] MOV RSI,qword ptr [RSP + 0x30] LEA RAX,[R8 + RDX*0x1] CMP RCX,R14 JZ 0x001017c0 CMP qword ptr [RSP + 0x20],RAX JNC 0x00101672 CMP RSI,R12 JZ 0x001017b0 LAB_00101664: MOV RDI,qword ptr [RSP + 0x40] LAB_00101669: CMP RDI,RAX JNC 0x00101720 LAB_00101672: MOV RAX,0x3fffffffffffffff SUB RAX,R8 CMP RAX,RDX JC 0x001018b4 MOV RDI,R15 LAB_0010168b: CALL 0x00101120 LEA RCX,[RBX + 0x10] LEA RDI,[RAX + 0x10] MOV RSI,qword ptr [RAX + 0x8] MOV qword ptr [RBX],RCX MOV RDX,qword ptr [RAX] CMP RDX,RDI JZ 0x001017e0 LAB_001016ab: MOV qword ptr [RBX],RDX MOV RDX,qword ptr [RAX + 0x10] MOV qword ptr [RBX + 0x10],RDX LAB_001016b6: MOV qword ptr [RBX + 0x8],RSI MOV qword ptr [RAX],RDI MOV byte ptr [RAX + 0x10],0x0 MOV RDI,qword ptr [RSP + 0x10] MOV qword ptr [RAX + 0x8],0x0 CMP RDI,R14 JZ 0x001016e1 MOV RAX,qword ptr [RSP + 0x20] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_001016e1: MOV RDI,qword ptr [RSP + 0x30] CMP RDI,R12 JZ 0x001016f9 MOV RAX,qword ptr [RSP + 0x40] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_001016f9: MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101884 ADD RSP,0x68 MOV RAX,RBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101720: MOV RDI,qword ptr [RSP + 0x8] XOR EDX,EDX XOR ESI,ESI CALL 0x001011d0 LEA RCX,[RBX + 0x10] LEA RDI,[RAX + 0x10] MOV RSI,qword ptr [RAX + 0x8] MOV qword ptr [RBX],RCX MOV RDX,qword ptr [RAX] CMP RDX,RDI JNZ 0x001016ab LEA RDX,[RSI + 0x1] CMP EDX,0x8 JC 0x00101838 MOV RSI,qword ptr [RAX + 0x10] MOV R10,RDI MOV qword ptr [RBX + 0x10],RSI MOV ESI,EDX MOV R8,qword ptr [RDI + RSI*0x1 + -0x8] MOV qword ptr [RCX + RSI*0x1 + -0x8],R8 LEA R8,[RBX + 0x18] AND R8,-0x8 SUB RCX,R8 ADD EDX,ECX SUB R10,RCX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x001017a0 AND EDX,0xfffffff8 XOR ECX,ECX LAB_0010178a: MOV ESI,ECX ADD ECX,0x8 MOV R9,qword ptr [R10 + RSI*0x1] MOV qword ptr [R8 + RSI*0x1],R9 CMP ECX,EDX JC 0x0010178a NOP dword ptr [RAX + RAX*0x1] LAB_001017a0: MOV RSI,qword ptr [RAX + 0x8] JMP 0x001016b6 LAB_001017b0: MOV EDI,0xf JMP 0x00101669 LAB_001017c0: CMP RAX,0xf JBE 0x00101672 CMP RSI,R12 JNZ 0x00101664 JMP 0x00101672 LAB_001017e0: LEA RDX,[RSI + 0x1] CMP EDX,0x8 JC 0x00101838 MOV RSI,qword ptr [RAX + 0x10] MOV R10,RDI MOV qword ptr [RBX + 0x10],RSI MOV ESI,EDX MOV R8,qword ptr [RDI + RSI*0x1 + -0x8] MOV qword ptr [RCX + RSI*0x1 + -0x8],R8 LEA R8,[RBX + 0x18] AND R8,-0x8 SUB RCX,R8 ADD EDX,ECX SUB R10,RCX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x001017a0 AND EDX,0xfffffff8 XOR ECX,ECX LAB_0010181d: MOV ESI,ECX ADD ECX,0x8 MOV R9,qword ptr [R10 + RSI*0x1] MOV qword ptr [R8 + RSI*0x1],R9 CMP ECX,EDX JC 0x0010181d JMP 0x001017a0 LAB_00101838: TEST DL,0x4 JNZ 0x0010186b TEST EDX,EDX JZ 0x001016b6 MOVZX ESI,byte ptr [RAX + 0x10] MOV byte ptr [RBX + 0x10],SIL TEST DL,0x2 JZ 0x001017a0 MOV EDX,EDX MOVZX ESI,word ptr [RDI + RDX*0x1 + -0x2] MOV word ptr [RCX + RDX*0x1 + -0x2],SI MOV RSI,qword ptr [RAX + 0x8] JMP 0x001016b6 LAB_0010186b: MOV ESI,dword ptr [RAX + 0x10] MOV EDX,EDX MOV dword ptr [RBX + 0x10],ESI MOV ESI,dword ptr [RDI + RDX*0x1 + -0x4] MOV dword ptr [RCX + RDX*0x1 + -0x4],ESI MOV RSI,qword ptr [RAX + 0x8] JMP 0x001016b6 LAB_00101884: CALL 0x001011a0 LAB_00101889: MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101884 MOV RCX,RDX LEA RSI,[0x102004] MOV RDX,RBP XOR EAX,EAX LEA RDI,[0x102068] LAB_001018af: CALL 0x001011c0 LAB_001018b4: MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101884 LEA RDI,[0x102019] LAB_001018cb: CALL 0x00101150 LAB_001018d0: ENDBR64 MOV RBX,RAX JMP 0x00101208
/* func0(std::string, int) */ long * func0(long *param_1,long *param_2,int param_3) { long *plVar1; int8 uVar2; uint uVar3; long lVar4; uint uVar5; long *plVar6; ulong uVar7; ulong uVar8; long *plVar9; long in_FS_OFFSET; ulong *local_88; long local_80; ulong local_78 [2]; ulong *local_68; ulong local_60; ulong local_58 [3]; long local_40; uVar8 = (ulong)param_3; local_40 = *(long *)(in_FS_OFFSET + 0x28); uVar7 = param_2[1]; if (uVar8 <= (ulong)param_2[1]) { uVar7 = uVar8; } local_68 = local_58; std::string::_M_construct<char_const*> ((char *)&local_68,(char *)*param_2,(int)uVar7 + (int)(char *)*param_2); uVar7 = param_2[1]; if (uVar7 < uVar8) { if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) goto LAB_00101884; /* try { // try from 001018af to 001018b3 has its CatchHandler @ 001018d0 */ std::__throw_out_of_range_fmt ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::substr",uVar8 ,uVar7); LAB_001018b4: if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { /* try { // try from 001018cb to 001018cf has its CatchHandler @ 001018dc */ uVar2 = std::__throw_length_error("basic_string::append"); std::string::_M_dispose(); /* catch() { ... } // from try @ 0010162e with catch @ 001018d0 catch() { ... } // from try @ 001018af with catch @ 001018d0 */ if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar2); } } else { local_88 = local_78; /* try { // try from 0010162e to 00101632 has its CatchHandler @ 001018d0 */ std::string::_M_construct<char_const*> ((char *)&local_88,(char *)(*param_2 + uVar8),(int)uVar7 + (int)*param_2); uVar7 = local_80 + local_60; uVar8 = local_58[0]; if (local_88 == local_78) { if ((0xf < uVar7) && (local_68 != local_58)) goto LAB_00101669; LAB_00101672: if (0x3fffffffffffffffU - local_80 < local_60) goto LAB_001018b4; /* try { // try from 0010168b to 0010172d has its CatchHandler @ 001018dc */ plVar1 = (long *)std::string::_M_append((char *)&local_88,(ulong)local_68); plVar9 = plVar1 + 2; lVar4 = plVar1[1]; *param_1 = (long)(param_1 + 2); plVar6 = (long *)*plVar1; if (plVar6 != plVar9) goto LAB_001016ab; uVar7 = lVar4 + 1; if ((uint)uVar7 < 8) { LAB_00101838: if ((uVar7 & 4) == 0) { if ((int)uVar7 != 0) { *(int *)(param_1 + 2) = *(int *)(plVar1 + 2); if ((uVar7 & 2) == 0) goto LAB_001017a0; *(int2 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xe) = *(int2 *)((long)plVar9 + ((uVar7 & 0xffffffff) - 2)); lVar4 = plVar1[1]; } } else { *(int4 *)(param_1 + 2) = *(int4 *)(plVar1 + 2); *(int4 *)((long)param_1 + (uVar7 & 0xffffffff) + 0xc) = *(int4 *)((long)plVar9 + ((uVar7 & 0xffffffff) - 4)); lVar4 = plVar1[1]; } } else { param_1[2] = plVar1[2]; *(int8 *)((long)param_1 + (uVar7 & 0xffffffff) + 8) = *(int8 *)((long)plVar1 + (uVar7 & 0xffffffff) + 8); lVar4 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar5 = (uint)uVar7 + (int)lVar4 & 0xfffffff8; if (7 < uVar5) { uVar3 = 0; do { uVar7 = (ulong)uVar3; uVar3 = uVar3 + 8; *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + uVar7) = *(int8 *)((long)plVar9 + (uVar7 - lVar4)); } while (uVar3 < uVar5); } LAB_001017a0: lVar4 = plVar1[1]; } } else { if (uVar7 <= local_78[0]) goto LAB_00101672; if (local_68 == local_58) { uVar8 = 0xf; } LAB_00101669: if (uVar8 < uVar7) goto LAB_00101672; plVar1 = (long *)std::string::_M_replace((ulong)&local_68,0,(char *)0x0,(ulong)local_88); plVar9 = plVar1 + 2; lVar4 = plVar1[1]; *param_1 = (long)(param_1 + 2); plVar6 = (long *)*plVar1; if (plVar6 == plVar9) { uVar7 = lVar4 + 1; if ((uint)uVar7 < 8) goto LAB_00101838; param_1[2] = plVar1[2]; *(int8 *)((long)param_1 + (uVar7 & 0xffffffff) + 8) = *(int8 *)((long)plVar1 + (uVar7 & 0xffffffff) + 8); lVar4 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar5 = (uint)uVar7 + (int)lVar4 & 0xfffffff8; if (7 < uVar5) { uVar3 = 0; do { uVar7 = (ulong)uVar3; uVar3 = uVar3 + 8; *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + uVar7) = *(int8 *)((long)plVar9 + (uVar7 - lVar4)); } while (uVar3 < uVar5); } goto LAB_001017a0; } LAB_001016ab: *param_1 = (long)plVar6; param_1[2] = plVar1[2]; } param_1[1] = lVar4; *plVar1 = (long)plVar9; *(int *)(plVar1 + 2) = 0; plVar1[1] = 0; if (local_88 != local_78) { operator_delete(local_88,local_78[0] + 1); } if (local_68 != local_58) { operator_delete(local_68,local_58[0] + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } } LAB_00101884: /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,891
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string s, int d) { std::string tmp = s.substr(d) + s.substr(0, d); return tmp; }
int main() { assert(func0("python", 2) == "thonpy"); assert(func0("bigdata", 3) == "databig"); assert(func0("hadoop", 1) == "adooph"); return 0; }
O3
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int): endbr64 push %r15 movslq %edx,%r15 mov %rsi,%rcx push %r14 push %r13 mov %rdi,%r13 push %r12 push %rbp push %rbx sub $0x78,%rsp mov 0x8(%rsi),%r12 mov (%rsi),%rbx mov %fs:0x28,%rax mov %rax,0x68(%rsp) xor %eax,%eax lea 0x50(%rsp),%rbp cmp %r12,%r15 mov %r12,%r14 mov %rbx,%rax mov %rbp,0x40(%rsp) cmovbe %r15,%r14 add %r14,%rax je 15b7 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x57> test %rbx,%rbx je 1806 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2a6> mov %r14,0x18(%rsp) cmp $0xf,%r14 ja 1740 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1e0> cmp $0x1,%r14 jne 1710 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1b0> movzbl (%rbx),%eax mov %al,0x50(%rsp) mov %rbp,%rax mov %r14,0x48(%rsp) movb $0x0,(%rax,%r14,1) cmp %r12,%r15 ja 1812 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2b2> mov (%rcx),%rax lea 0x30(%rsp),%rbx mov %rbx,0x20(%rsp) lea (%rax,%r15,1),%r14 add %r12,%rax je 160c <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xac> test %r14,%r14 je 1832 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2d2> sub %r15,%r12 mov %r12,0x18(%rsp) cmp $0xf,%r12 ja 1798 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x238> cmp $0x1,%r12 jne 1728 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x1c8> movzbl (%r14),%eax mov %al,0x30(%rsp) mov %rbx,%rax mov %r12,0x28(%rsp) movb $0x0,(%rax,%r12,1) mov 0x20(%rsp),%r9 mov $0xf,%eax mov 0x28(%rsp),%r8 mov 0x48(%rsp),%rdx mov %rax,%rdi cmp %rbx,%r9 cmovne 0x30(%rsp),%rdi mov 0x40(%rsp),%rsi lea (%r8,%rdx,1),%rcx cmp %rdi,%rcx jbe 167d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x11d> cmp %rbp,%rsi cmovne 0x50(%rsp),%rax cmp %rax,%rcx jbe 17f0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x290> lea 0x20(%rsp),%rdi callq 1130 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> lea 0x10(%r13),%rdx mov %rdx,0x0(%r13) mov (%rax),%rcx lea 0x10(%rax),%rdx cmp %rdx,%rcx je 17d8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x278> mov %rcx,0x0(%r13) mov 0x10(%rax),%rcx mov %rcx,0x10(%r13) mov 0x8(%rax),%rcx mov %rdx,(%rax) mov 0x20(%rsp),%rdi movq $0x0,0x8(%rax) mov %rcx,0x8(%r13) movb $0x0,0x10(%rax) cmp %rbx,%rdi je 16d1 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x171> callq 1190 <_ZdlPv@plt> mov 0x40(%rsp),%rdi cmp %rbp,%rdi je 16e0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x180> callq 1190 <_ZdlPv@plt> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 182d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2cd> add $0x78,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw %cs:0x0(%rax,%rax,1) test %r14,%r14 jne 183e <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2de> mov %rbp,%rax jmpq 15da <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x7a> nopl 0x0(%rax) test %r12,%r12 jne 1846 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x2e6> mov %rbx,%rax jmpq 1633 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xd3> nopl 0x0(%rax) lea 0x40(%rsp),%rdi lea 0x18(%rsp),%rsi xor %edx,%edx mov %rcx,0x8(%rsp) callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@plt> mov 0x8(%rsp),%rcx mov %rax,0x40(%rsp) mov %rax,%rdi mov 0x18(%rsp),%rax mov %rax,0x50(%rsp) mov %r14,%rdx mov %rbx,%rsi mov %rcx,0x8(%rsp) callq 1170 <memcpy@plt> mov 0x8(%rsp),%rcx mov 0x18(%rsp),%r14 mov 0x40(%rsp),%rax mov 0x8(%rcx),%r12 jmpq 15da <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x7a> nopl (%rax) lea 0x18(%rsp),%rsi lea 0x20(%rsp),%rdi xor %edx,%edx callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@plt> mov %rax,0x20(%rsp) mov %rax,%rdi mov 0x18(%rsp),%rax mov %rax,0x30(%rsp) mov %r12,%rdx mov %r14,%rsi callq 1170 <memcpy@plt> mov 0x18(%rsp),%r12 mov 0x20(%rsp),%rax jmpq 1633 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xd3> nopl (%rax) movdqu 0x10(%rax),%xmm0 movups %xmm0,0x10(%r13) jmpq 16ab <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x14b> nopw 0x0(%rax,%rax,1) lea 0x40(%rsp),%rdi mov %r9,%rcx xor %edx,%edx xor %esi,%esi callq 11d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@plt> jmpq 1687 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x127> lea 0x7fb(%rip),%rdi callq 1160 <_ZSt19__throw_logic_errorPKc@plt> mov %r12,%rcx mov %r15,%rdx lea 0x900(%rip),%rsi xor %eax,%eax lea 0x810(%rip),%rdi callq 11b0 <_ZSt24__throw_out_of_range_fmtPKcz@plt> callq 11a0 <__stack_chk_fail@plt> lea 0x7cf(%rip),%rdi callq 1160 <_ZSt19__throw_logic_errorPKc@plt> mov %rbp,%rdi jmpq 176d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x20d> mov %rbx,%rdi jmpq 17bb <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x25b> endbr64 mov %rax,%r12 jmpq 120f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi.cold+0xf> endbr64 mov %rax,%r12 jmpq 1200 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi.cold> nopw %cs:0x0(%rax,%rax,1)
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 push r15 movsxd r8, edx mov r15, rsi push r14 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 78h mov rbx, [rsi+8] mov r12, [rsi] mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax lea r13, [rsp+0A8h+var_58] lea rax, [rsp+0A8h+var_68] cmp r8, rbx mov [rsp+0A8h+var_A8], rax cmovbe rbx, r8 mov [rsp+0A8h+var_68], r13 mov [rsp+0A8h+var_90], rbx cmp rbx, 0Fh ja loc_16F0 cmp rbx, 1 jnz loc_16C0 movzx eax, byte ptr [r12] mov byte ptr [rsp+0A8h+var_58], al mov rax, r13 loc_1571: mov [rsp+0A8h+var_60], rbx mov byte ptr [rax+rbx], 0 mov rbx, [r15+8] cmp rbx, r8 jb loc_18E1 mov rax, [r15] lea r12, [rsp+0A8h+var_78] sub rbx, r8 lea r14, [rsp+0A8h+var_88] mov [rsp+0A8h+var_88], r12 add rax, r8 mov [rsp+0A8h+var_90], rbx mov r15, rax cmp rbx, 0Fh ja loc_1740 cmp rbx, 1 jnz loc_16D8 movzx eax, byte ptr [rax] mov byte ptr [rsp+0A8h+var_78], al mov rax, r12 loc_15C5: mov [rsp+0A8h+var_80], rbx mov byte ptr [rax+rbx], 0 mov r8, [rsp+0A8h+var_80] mov rdx, [rsp+0A8h+var_60] mov rcx, [rsp+0A8h+var_88] mov rsi, [rsp+0A8h+var_68] lea rax, [r8+rdx] cmp rcx, r12 jz loc_1810 cmp [rsp+0A8h+var_78], rax jnb short loc_160D cmp rsi, r13 jz loc_1880 loc_15FF: mov rdi, [rsp+0A8h+var_58] loc_1604: cmp rdi, rax jnb loc_1780 loc_160D: mov rax, 3FFFFFFFFFFFFFFFh sub rax, r8 cmp rax, rdx jb loc_190C mov rdi, r14 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) lea rcx, [rbp+10h] lea rdi, [rax+10h] mov rsi, [rax+8] mov [rbp+0], rcx mov rdx, [rax] cmp rdx, rdi jz loc_1830 loc_1647: mov [rbp+0], rdx mov rdx, [rax+10h] mov [rbp+10h], rdx loc_1653: mov [rbp+8], rsi mov [rax], rdi mov byte ptr [rax+10h], 0 mov rdi, [rsp+0A8h+var_88]; void * mov qword ptr [rax+8], 0 cmp rdi, r12 jz short loc_167E mov rax, [rsp+0A8h+var_78] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_167E: mov rdi, [rsp+0A8h+var_68]; void * cmp rdi, r13 jz short loc_1696 mov rax, [rsp+0A8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1696: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz loc_18DC add rsp, 78h mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_16C0: test rbx, rbx jnz loc_1928 mov rax, r13 jmp loc_1571 loc_16D8: test rbx, rbx jnz loc_1930 mov rax, r12 jmp loc_15C5 loc_16F0: mov rdi, rax lea rsi, [rsp+0A8h+var_90] xor edx, edx mov [rsp+0A8h+var_A0], r8 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm; std::string::_M_create(ulong &,ulong) mov r8, [rsp+0A8h+var_A0] mov [rsp+0A8h+var_68], rax mov rdi, rax; dest mov rax, [rsp+0A8h+var_90] mov [rsp+0A8h+var_58], rax loc_171B: mov rdx, rbx; n mov rsi, r12; src mov [rsp+0A8h+var_A0], r8 call _memcpy mov rbx, [rsp+0A8h+var_90] mov rax, [rsp+0A8h+var_68] mov r8, [rsp+0A8h+var_A0] jmp loc_1571 loc_1740: lea rsi, [rsp+0A8h+var_90] xor edx, edx mov rdi, r14 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm; std::string::_M_create(ulong &,ulong) mov [rsp+0A8h+var_88], rax mov rdi, rax; dest mov rax, [rsp+0A8h+var_90] mov [rsp+0A8h+var_78], rax loc_1761: mov rdx, rbx; n mov rsi, r15; src call _memcpy mov rbx, [rsp+0A8h+var_90] mov rax, [rsp+0A8h+var_88] jmp loc_15C5 loc_1780: mov rdi, [rsp+0A8h+var_A8] xor edx, edx xor esi, esi call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm; std::string::_M_replace(ulong,ulong,char const*,ulong) lea rcx, [rbp+10h] lea rdi, [rax+10h] mov rsi, [rax+8] mov [rbp+0], rcx mov rdx, [rax] cmp rdx, rdi jnz loc_1647 lea rdx, [rsi+1] cmp edx, 8 jb loc_1890 mov rsi, [rax+10h] mov r10, rdi mov [rbp+10h], rsi mov esi, edx mov r8, [rdi+rsi-8] mov [rcx+rsi-8], r8 lea r8, [rbp+18h] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 add edx, ecx sub r10, rcx and edx, 0FFFFFFF8h cmp edx, 8 jb short loc_1800 and edx, 0FFFFFFF8h xor ecx, ecx loc_17EA: mov esi, ecx add ecx, 8 mov r9, [r10+rsi] mov [r8+rsi], r9 cmp ecx, edx jb short loc_17EA nop dword ptr [rax+rax+00h] loc_1800: mov rsi, [rax+8] jmp loc_1653 loc_1810: cmp rax, 0Fh jbe loc_160D cmp rsi, r13 jnz loc_15FF jmp loc_160D loc_1830: lea rdx, [rsi+1] cmp edx, 8 jb short loc_1890 mov rsi, [rax+10h] mov r10, rdi mov [rbp+10h], rsi mov esi, edx mov r8, [rdi+rsi-8] mov [rcx+rsi-8], r8 lea r8, [rbp+18h] and r8, 0FFFFFFFFFFFFFFF8h sub rcx, r8 add edx, ecx sub r10, rcx and edx, 0FFFFFFF8h cmp edx, 8 jb short loc_1800 and edx, 0FFFFFFF8h xor ecx, ecx loc_186D: mov esi, ecx add ecx, 8 mov r9, [r10+rsi] mov [r8+rsi], r9 cmp ecx, edx jb short loc_186D jmp short loc_1800 loc_1880: mov edi, 0Fh jmp loc_1604 loc_1890: test dl, 4 jnz short loc_18C3 test edx, edx jz loc_1653 movzx esi, byte ptr [rax+10h] mov [rbp+10h], sil test dl, 2 jz loc_1800 mov edx, edx movzx esi, word ptr [rdi+rdx-2] mov [rcx+rdx-2], si mov rsi, [rax+8] jmp loc_1653 loc_18C3: mov esi, [rax+10h] mov edx, edx mov [rbp+10h], esi mov esi, [rdi+rdx-4] mov [rcx+rdx-4], esi mov rsi, [rax+8] jmp loc_1653 loc_18DC: call ___stack_chk_fail loc_18E1: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_18DC mov rcx, rbx mov rdx, r8 lea rsi, aBasicStringSub; "basic_string::substr" xor eax, eax lea rdi, aSPosWhichIsZuT; "%s: __pos (which is %zu) > this->size()"... call __ZSt24__throw_out_of_range_fmtPKcz; std::__throw_out_of_range_fmt(char const*,...) loc_190C: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_18DC lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) loc_1928: mov rdi, r13 jmp loc_171B loc_1930: mov rdi, r12 jmp loc_1761 endbr64 mov rbx, rax jmp loc_1208 endbr64 mov rbx, rax jmp _Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi_cold; func0(std::string,int) [clone]
char ** func0(char **a1, long long a2, int a3) { unsigned long long v3; // r8 size_t v5; // rbx _BYTE *v6; // r12 _QWORD *v7; // rax unsigned long long v8; // rbx _BYTE *v9; // rax size_t v10; // rbx _BYTE *v11; // rax const void *v12; // r15 _QWORD *v13; // rax unsigned long long v14; // rax unsigned long long v15; // rdi char **v16; // rax _QWORD *v17; // rcx char *v18; // rdi char *v19; // rsi char *v20; // rdx _QWORD *v21; // rdi void *v23; // rax _QWORD *v24; // rdi _QWORD *v25; // rdi unsigned int v26; // edx unsigned long long v27; // r8 char *v28; // rcx char *v29; // r10 unsigned int v30; // edx unsigned int v31; // edx unsigned int v32; // ecx long long v33; // rsi unsigned long long v34; // r8 char *v35; // rcx char *v36; // r10 unsigned int v37; // edx unsigned int v38; // edx unsigned int v39; // ecx long long v40; // rsi unsigned long long v41; // [rsp+8h] [rbp-A0h] unsigned long long v42; // [rsp+8h] [rbp-A0h] size_t v43; // [rsp+18h] [rbp-90h] BYREF void *v44; // [rsp+20h] [rbp-88h] BYREF size_t v45; // [rsp+28h] [rbp-80h] _QWORD v46[2]; // [rsp+30h] [rbp-78h] BYREF void *v47; // [rsp+40h] [rbp-68h] BYREF unsigned long long v48; // [rsp+48h] [rbp-60h] _QWORD v49[11]; // [rsp+50h] [rbp-58h] BYREF v3 = a3; v5 = *(_QWORD *)(a2 + 8); v6 = *(_BYTE **)a2; v49[3] = __readfsqword(0x28u); if ( a3 <= v5 ) v5 = a3; v47 = v49; v43 = v5; if ( v5 > 0xF ) { v41 = a3; v23 = (void *)std::string::_M_create(&v47, &v43, 0LL); v3 = v41; v47 = v23; v24 = v23; v49[0] = v43; } else { if ( v5 == 1 ) { LOBYTE(v49[0]) = *v6; v7 = v49; goto LABEL_6; } if ( !v5 ) { v7 = v49; goto LABEL_6; } v24 = v49; } v42 = v3; memcpy(v24, v6, v5); v5 = v43; v7 = v47; v3 = v42; LABEL_6: v48 = v5; *((_BYTE *)v7 + v5) = 0; v8 = *(_QWORD *)(a2 + 8); if ( v8 < v3 ) std::__throw_out_of_range_fmt( "%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v3, *(_QWORD *)(a2 + 8)); v9 = *(_BYTE **)a2; v10 = v8 - v3; v44 = v46; v11 = &v9[v3]; v43 = v10; v12 = v11; if ( v10 > 0xF ) { v44 = (void *)std::string::_M_create(&v44, &v43, 0LL); v25 = v44; v46[0] = v43; } else { if ( v10 == 1 ) { LOBYTE(v46[0]) = *v11; v13 = v46; goto LABEL_10; } if ( !v10 ) { v13 = v46; goto LABEL_10; } v25 = v46; } memcpy(v25, v12, v10); v10 = v43; v13 = v44; LABEL_10: v45 = v10; *((_BYTE *)v13 + v10) = 0; v14 = v45 + v48; if ( v44 == v46 ) { if ( v14 <= 0xF || v47 == v49 ) goto LABEL_15; goto LABEL_13; } if ( v46[0] >= v14 ) goto LABEL_15; if ( v47 != v49 ) { LABEL_13: v15 = v49[0]; goto LABEL_14; } v15 = 15LL; LABEL_14: if ( v15 >= v14 ) { v16 = (char **)std::string::_M_replace(&v47, 0LL, 0LL); v17 = a1 + 2; v18 = (char *)(v16 + 2); v19 = v16[1]; *a1 = (char *)(a1 + 2); v20 = *v16; if ( *v16 != (char *)(v16 + 2) ) { LABEL_17: *a1 = v20; a1[2] = v16[2]; goto LABEL_18; } v26 = (_DWORD)v19 + 1; if ( (unsigned int)((_DWORD)v19 + 1) >= 8 ) { a1[2] = v16[2]; *(_QWORD *)((char *)v17 + v26 - 8) = *(_QWORD *)&v18[v26 - 8]; v27 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v28 = (char *)v17 - v27; v29 = (char *)(v18 - v28); v30 = ((_DWORD)v28 + v26) & 0xFFFFFFF8; if ( v30 >= 8 ) { v31 = v30 & 0xFFFFFFF8; v32 = 0; do { v33 = v32; v32 += 8; *(_QWORD *)(v27 + v33) = *(_QWORD *)&v29[v33]; } while ( v32 < v31 ); } goto LABEL_36; } goto LABEL_46; } LABEL_15: if ( 0x3FFFFFFFFFFFFFFFLL - v45 < v48 ) std::__throw_length_error("basic_string::append"); v16 = (char **)std::string::_M_append(&v44, v47); v17 = a1 + 2; v18 = (char *)(v16 + 2); v19 = v16[1]; *a1 = (char *)(a1 + 2); v20 = *v16; if ( *v16 != (char *)(v16 + 2) ) goto LABEL_17; v26 = (_DWORD)v19 + 1; if ( (unsigned int)((_DWORD)v19 + 1) >= 8 ) { a1[2] = v16[2]; *(_QWORD *)((char *)v17 + v26 - 8) = *(_QWORD *)&v18[v26 - 8]; v34 = (unsigned long long)(a1 + 3) & 0xFFFFFFFFFFFFFFF8LL; v35 = (char *)v17 - v34; v36 = (char *)(v18 - v35); v37 = ((_DWORD)v35 + v26) & 0xFFFFFFF8; if ( v37 >= 8 ) { v38 = v37 & 0xFFFFFFF8; v39 = 0; do { v40 = v39; v39 += 8; *(_QWORD *)(v34 + v40) = *(_QWORD *)&v36[v40]; } while ( v39 < v38 ); } goto LABEL_36; } LABEL_46: if ( (v26 & 4) != 0 ) { *((_DWORD *)a1 + 4) = *((_DWORD *)v16 + 4); *(_DWORD *)((char *)v17 + v26 - 4) = *(_DWORD *)&v18[v26 - 4]; v19 = v16[1]; } else if ( v26 ) { *((_BYTE *)a1 + 16) = *((_BYTE *)v16 + 16); if ( (v26 & 2) == 0 ) { LABEL_36: v19 = v16[1]; goto LABEL_18; } *(_WORD *)((char *)v17 + v26 - 2) = *(_WORD *)&v18[v26 - 2]; v19 = v16[1]; } LABEL_18: a1[1] = v19; *v16 = v18; *((_BYTE *)v16 + 16) = 0; v21 = v44; v16[1] = 0LL; if ( v21 != v46 ) operator delete(v21, v46[0] + 1LL); if ( v47 != v49 ) operator delete(v47, v49[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 MOVSXD R8,EDX MOV R15,RSI PUSH R14 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x78 MOV RBX,qword ptr [RSI + 0x8] MOV R12,qword ptr [RSI] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX LEA R13,[RSP + 0x50] LEA RAX,[RSP + 0x40] CMP R8,RBX MOV qword ptr [RSP],RAX CMOVBE RBX,R8 MOV qword ptr [RSP + 0x40],R13 MOV qword ptr [RSP + 0x18],RBX CMP RBX,0xf JA 0x001016f0 CMP RBX,0x1 JNZ 0x001016c0 MOVZX EAX,byte ptr [R12] MOV byte ptr [RSP + 0x50],AL MOV RAX,R13 LAB_00101571: MOV qword ptr [RSP + 0x48],RBX MOV byte ptr [RAX + RBX*0x1],0x0 MOV RBX,qword ptr [R15 + 0x8] CMP RBX,R8 JC 0x001018e1 MOV RAX,qword ptr [R15] LEA R12,[RSP + 0x30] SUB RBX,R8 LEA R14,[RSP + 0x20] MOV qword ptr [RSP + 0x20],R12 ADD RAX,R8 MOV qword ptr [RSP + 0x18],RBX MOV R15,RAX CMP RBX,0xf JA 0x00101740 CMP RBX,0x1 JNZ 0x001016d8 MOVZX EAX,byte ptr [RAX] MOV byte ptr [RSP + 0x30],AL MOV RAX,R12 LAB_001015c5: MOV qword ptr [RSP + 0x28],RBX MOV byte ptr [RAX + RBX*0x1],0x0 MOV R8,qword ptr [RSP + 0x28] MOV RDX,qword ptr [RSP + 0x48] MOV RCX,qword ptr [RSP + 0x20] MOV RSI,qword ptr [RSP + 0x40] LEA RAX,[R8 + RDX*0x1] CMP RCX,R12 JZ 0x00101810 CMP qword ptr [RSP + 0x30],RAX JNC 0x0010160d CMP RSI,R13 JZ 0x00101880 LAB_001015ff: MOV RDI,qword ptr [RSP + 0x50] LAB_00101604: CMP RDI,RAX JNC 0x00101780 LAB_0010160d: MOV RAX,0x3fffffffffffffff SUB RAX,R8 CMP RAX,RDX JC 0x0010190c MOV RDI,R14 LAB_00101626: CALL 0x00101120 LEA RCX,[RBP + 0x10] LEA RDI,[RAX + 0x10] MOV RSI,qword ptr [RAX + 0x8] MOV qword ptr [RBP],RCX MOV RDX,qword ptr [RAX] CMP RDX,RDI JZ 0x00101830 LAB_00101647: MOV qword ptr [RBP],RDX MOV RDX,qword ptr [RAX + 0x10] MOV qword ptr [RBP + 0x10],RDX LAB_00101653: MOV qword ptr [RBP + 0x8],RSI MOV qword ptr [RAX],RDI MOV byte ptr [RAX + 0x10],0x0 MOV RDI,qword ptr [RSP + 0x20] MOV qword ptr [RAX + 0x8],0x0 CMP RDI,R12 JZ 0x0010167e MOV RAX,qword ptr [RSP + 0x30] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_0010167e: MOV RDI,qword ptr [RSP + 0x40] CMP RDI,R13 JZ 0x00101696 MOV RAX,qword ptr [RSP + 0x50] LEA RSI,[RAX + 0x1] CALL 0x00101190 LAB_00101696: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018dc ADD RSP,0x78 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001016c0: TEST RBX,RBX JNZ 0x00101928 MOV RAX,R13 JMP 0x00101571 LAB_001016d8: TEST RBX,RBX JNZ 0x00101930 MOV RAX,R12 JMP 0x001015c5 LAB_001016f0: MOV RDI,RAX LEA RSI,[RSP + 0x18] XOR EDX,EDX MOV qword ptr [RSP + 0x8],R8 LAB_001016ff: CALL 0x001011f0 MOV R8,qword ptr [RSP + 0x8] MOV qword ptr [RSP + 0x40],RAX MOV RDI,RAX MOV RAX,qword ptr [RSP + 0x18] MOV qword ptr [RSP + 0x50],RAX LAB_0010171b: MOV RDX,RBX MOV RSI,R12 MOV qword ptr [RSP + 0x8],R8 CALL 0x00101180 MOV RBX,qword ptr [RSP + 0x18] MOV RAX,qword ptr [RSP + 0x40] MOV R8,qword ptr [RSP + 0x8] JMP 0x00101571 LAB_00101740: LEA RSI,[RSP + 0x18] XOR EDX,EDX MOV RDI,R14 LAB_0010174a: CALL 0x001011f0 MOV qword ptr [RSP + 0x20],RAX MOV RDI,RAX MOV RAX,qword ptr [RSP + 0x18] MOV qword ptr [RSP + 0x30],RAX LAB_00101761: MOV RDX,RBX MOV RSI,R15 CALL 0x00101180 MOV RBX,qword ptr [RSP + 0x18] MOV RAX,qword ptr [RSP + 0x20] JMP 0x001015c5 LAB_00101780: MOV RDI,qword ptr [RSP] XOR EDX,EDX XOR ESI,ESI LAB_00101788: CALL 0x001011d0 LEA RCX,[RBP + 0x10] LEA RDI,[RAX + 0x10] MOV RSI,qword ptr [RAX + 0x8] MOV qword ptr [RBP],RCX MOV RDX,qword ptr [RAX] CMP RDX,RDI JNZ 0x00101647 LEA RDX,[RSI + 0x1] CMP EDX,0x8 JC 0x00101890 MOV RSI,qword ptr [RAX + 0x10] MOV R10,RDI MOV qword ptr [RBP + 0x10],RSI MOV ESI,EDX MOV R8,qword ptr [RDI + RSI*0x1 + -0x8] MOV qword ptr [RCX + RSI*0x1 + -0x8],R8 LEA R8,[RBP + 0x18] AND R8,-0x8 SUB RCX,R8 ADD EDX,ECX SUB R10,RCX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x00101800 AND EDX,0xfffffff8 XOR ECX,ECX LAB_001017ea: MOV ESI,ECX ADD ECX,0x8 MOV R9,qword ptr [R10 + RSI*0x1] MOV qword ptr [R8 + RSI*0x1],R9 CMP ECX,EDX JC 0x001017ea NOP dword ptr [RAX + RAX*0x1] LAB_00101800: MOV RSI,qword ptr [RAX + 0x8] JMP 0x00101653 LAB_00101810: CMP RAX,0xf JBE 0x0010160d CMP RSI,R13 JNZ 0x001015ff JMP 0x0010160d LAB_00101830: LEA RDX,[RSI + 0x1] CMP EDX,0x8 JC 0x00101890 MOV RSI,qword ptr [RAX + 0x10] MOV R10,RDI MOV qword ptr [RBP + 0x10],RSI MOV ESI,EDX MOV R8,qword ptr [RDI + RSI*0x1 + -0x8] MOV qword ptr [RCX + RSI*0x1 + -0x8],R8 LEA R8,[RBP + 0x18] AND R8,-0x8 SUB RCX,R8 ADD EDX,ECX SUB R10,RCX AND EDX,0xfffffff8 CMP EDX,0x8 JC 0x00101800 AND EDX,0xfffffff8 XOR ECX,ECX LAB_0010186d: MOV ESI,ECX ADD ECX,0x8 MOV R9,qword ptr [R10 + RSI*0x1] MOV qword ptr [R8 + RSI*0x1],R9 CMP ECX,EDX JC 0x0010186d JMP 0x00101800 LAB_00101880: MOV EDI,0xf JMP 0x00101604 LAB_00101890: TEST DL,0x4 JNZ 0x001018c3 TEST EDX,EDX JZ 0x00101653 MOVZX ESI,byte ptr [RAX + 0x10] MOV byte ptr [RBP + 0x10],SIL TEST DL,0x2 JZ 0x00101800 MOV EDX,EDX MOVZX ESI,word ptr [RDI + RDX*0x1 + -0x2] MOV word ptr [RCX + RDX*0x1 + -0x2],SI MOV RSI,qword ptr [RAX + 0x8] JMP 0x00101653 LAB_001018c3: MOV ESI,dword ptr [RAX + 0x10] MOV EDX,EDX MOV dword ptr [RBP + 0x10],ESI MOV ESI,dword ptr [RDI + RDX*0x1 + -0x4] MOV dword ptr [RCX + RDX*0x1 + -0x4],ESI MOV RSI,qword ptr [RAX + 0x8] JMP 0x00101653 LAB_001018dc: CALL 0x001011a0 LAB_001018e1: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018dc MOV RCX,RBX MOV RDX,R8 LEA RSI,[0x102004] XOR EAX,EAX LEA RDI,[0x102068] LAB_00101907: CALL 0x001011c0 LAB_0010190c: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018dc LEA RDI,[0x102019] LAB_00101923: CALL 0x00101150 LAB_00101928: MOV RDI,R13 JMP 0x0010171b LAB_00101930: MOV RDI,R12 JMP 0x00101761
/* func0(std::string, int) */ long * func0(long *param_1,long *param_2,int param_3) { long *plVar1; ulong *__dest; uint uVar2; long lVar3; uint uVar4; long *plVar5; ulong uVar6; long *plVar7; ulong uVar8; ulong *__src; long in_FS_OFFSET; ulong local_90; ulong *local_88; ulong local_80; ulong local_78 [2]; ulong *local_68; ulong local_60; ulong local_58 [3]; long local_40; uVar8 = (ulong)param_3; __src = (ulong *)*param_2; local_40 = *(long *)(in_FS_OFFSET + 0x28); uVar6 = param_2[1]; if (uVar8 <= (ulong)param_2[1]) { uVar6 = uVar8; } local_90 = uVar6; local_68 = local_58; if (0xf < uVar6) { __dest = (ulong *)std::string::_M_create((ulong *)&local_68,(ulong)&local_90); local_58[0] = local_90; local_68 = __dest; goto LAB_0010171b; } if (uVar6 == 1) { local_58[0] = CONCAT71(local_58[0]._1_7_,*(int *)__src); } else { __dest = local_58; if (uVar6 != 0) goto LAB_0010171b; } while( true ) { *(int *)((long)local_68 + local_90) = 0; uVar6 = param_2[1]; local_60 = local_90; if (uVar8 <= uVar6) break; if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) goto LAB_001018dc; /* try { // try from 00101907 to 0010190b has its CatchHandler @ 00101938 */ std::__throw_out_of_range_fmt ("%s: __pos (which is %zu) > this->size() (which is %zu)","basic_string::substr",uVar8 ,uVar6); LAB_0010190c: if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) goto LAB_001018dc; /* try { // try from 00101923 to 00101927 has its CatchHandler @ 00101944 */ std::__throw_length_error("basic_string::append"); __dest = local_58; LAB_0010171b: memcpy(__dest,__src,uVar6); } __src = local_78; uVar6 = uVar6 - uVar8; param_2 = (long *)(*param_2 + uVar8); local_88 = __src; if (uVar6 < 0x10) { if (uVar6 == 1) { local_78[0] = CONCAT71(local_78[0]._1_7_,*(int *)param_2); } else { local_90 = uVar6; if (uVar6 != 0) goto LAB_00101761; } } else { local_90 = uVar6; /* try { // try from 0010174a to 0010174e has its CatchHandler @ 00101938 */ local_88 = (ulong *)std::string::_M_create((ulong *)&local_88,(ulong)&local_90); local_78[0] = local_90; LAB_00101761: memcpy(local_88,param_2,uVar6); uVar6 = local_90; } local_90 = uVar6; *(int *)((long)local_88 + local_90) = 0; uVar6 = local_90 + local_60; uVar8 = local_58[0]; local_80 = local_90; if (local_88 == __src) { if ((0xf < uVar6) && (local_68 != local_58)) goto LAB_00101604; LAB_0010160d: uVar6 = local_90; uVar8 = local_90; if (0x3fffffffffffffff - local_90 < local_60) goto LAB_0010190c; /* try { // try from 00101626 to 0010162a has its CatchHandler @ 00101944 */ plVar1 = (long *)std::string::_M_append((char *)&local_88,(ulong)local_68); plVar7 = plVar1 + 2; lVar3 = plVar1[1]; *param_1 = (long)(param_1 + 2); plVar5 = (long *)*plVar1; if (plVar5 == plVar7) { uVar6 = lVar3 + 1; if (7 < (uint)uVar6) { param_1[2] = plVar1[2]; *(int8 *)((long)param_1 + (uVar6 & 0xffffffff) + 8) = *(int8 *)((long)plVar1 + (uVar6 & 0xffffffff) + 8); lVar3 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar4 = (uint)uVar6 + (int)lVar3 & 0xfffffff8; if (7 < uVar4) { uVar2 = 0; do { uVar6 = (ulong)uVar2; uVar2 = uVar2 + 8; *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + uVar6) = *(int8 *)((long)plVar7 + (uVar6 - lVar3)); } while (uVar2 < uVar4); } goto LAB_00101800; } LAB_00101890: if ((uVar6 & 4) == 0) { if ((int)uVar6 != 0) { *(int *)(param_1 + 2) = *(int *)(plVar1 + 2); if ((uVar6 & 2) == 0) { LAB_00101800: lVar3 = plVar1[1]; } else { *(int2 *)((long)param_1 + (uVar6 & 0xffffffff) + 0xe) = *(int2 *)((long)plVar7 + ((uVar6 & 0xffffffff) - 2)); lVar3 = plVar1[1]; } } } else { *(int4 *)(param_1 + 2) = *(int4 *)(plVar1 + 2); *(int4 *)((long)param_1 + (uVar6 & 0xffffffff) + 0xc) = *(int4 *)((long)plVar7 + ((uVar6 & 0xffffffff) - 4)); lVar3 = plVar1[1]; } LAB_00101653: param_1[1] = lVar3; *plVar1 = (long)plVar7; *(int *)(plVar1 + 2) = 0; plVar1[1] = 0; if (local_88 != __src) { operator_delete(local_88,local_78[0] + 1); } if (local_68 != local_58) { operator_delete(local_68,local_58[0] + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } LAB_001018dc: /* WARNING: Subroutine does not return */ __stack_chk_fail(); } } else { if (uVar6 <= local_78[0]) goto LAB_0010160d; if (local_68 == local_58) { uVar8 = 0xf; } LAB_00101604: if (uVar8 < uVar6) goto LAB_0010160d; /* try { // try from 00101788 to 0010178c has its CatchHandler @ 00101944 */ plVar1 = (long *)std::string::_M_replace((ulong)&local_68,0,(char *)0x0,(ulong)local_88); plVar7 = plVar1 + 2; lVar3 = plVar1[1]; *param_1 = (long)(param_1 + 2); plVar5 = (long *)*plVar1; if (plVar5 == plVar7) { uVar6 = lVar3 + 1; if ((uint)uVar6 < 8) goto LAB_00101890; param_1[2] = plVar1[2]; *(int8 *)((long)param_1 + (uVar6 & 0xffffffff) + 8) = *(int8 *)((long)plVar1 + (uVar6 & 0xffffffff) + 8); lVar3 = (long)(param_1 + 2) - ((ulong)(param_1 + 3) & 0xfffffffffffffff8); uVar4 = (uint)uVar6 + (int)lVar3 & 0xfffffff8; if (7 < uVar4) { uVar2 = 0; do { uVar6 = (ulong)uVar2; uVar2 = uVar2 + 8; *(int8 *)(((ulong)(param_1 + 3) & 0xfffffffffffffff8) + uVar6) = *(int8 *)((long)plVar7 + (uVar6 - lVar3)); } while (uVar2 < uVar4); } goto LAB_00101800; } } *param_1 = (long)plVar5; param_1[2] = plVar1[2]; goto LAB_00101653; }
3,892
func0
#include <vector> #include <cassert>
int func0(std::vector<std::vector<int>> A) { int n = A.size(); std::vector<int> memo(n, 0); int lastRow = n - 1; for(int i = 0; i < A[lastRow].size(); ++i) { memo[i] = A[lastRow][i]; } for(int i = lastRow - 1; i >= 0; --i) { for(int j = 0; j < A[i].size(); ++j) { memo[j] = A[i][j] + std::min(memo[j], memo[j + 1]); } } return memo[0]; }
int main() { assert(func0({{2}, {3, 9}, {1, 6, 7}}) == 6); assert(func0({{2}, {3, 7}, {8, 5, 6}}) == 10); assert(func0({{3}, {6, 4}, {5, 2, 7}}) == 9); return 0; }
O0
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 push %rbp mov %rsp,%rbp push %r12 push %rbx sub $0x50,%rsp mov %rdi,-0x58(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x58(%rbp),%rax mov %rax,%rdi callq 1dc0 <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv> mov %eax,-0x38(%rbp) lea -0x49(%rbp),%rax mov %rax,%rdi callq 1df8 <_ZNSaIiEC1Ev> movl $0x0,-0x48(%rbp) mov -0x38(%rbp),%eax movslq %eax,%rsi lea -0x49(%rbp),%rcx lea -0x48(%rbp),%rdx lea -0x30(%rbp),%rax mov %rax,%rdi callq 1e38 <_ZNSt6vectorIiSaIiEEC1EmRKiRKS0_> lea -0x49(%rbp),%rax mov %rax,%rdi callq 1e18 <_ZNSaIiED1Ev> mov -0x38(%rbp),%eax sub $0x1,%eax mov %eax,-0x34(%rbp) movl $0x0,-0x44(%rbp) mov -0x44(%rbp),%eax movslq %eax,%rbx mov -0x34(%rbp),%eax movslq %eax,%rdx mov -0x58(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f08 <_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdi callq 1f36 <_ZNKSt6vectorIiSaIiEE4sizeEv> cmp %rax,%rbx setb %al test %al,%al je 1377 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xee> mov -0x34(%rbp),%eax movslq %eax,%rdx mov -0x58(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f08 <_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdx mov -0x44(%rbp),%eax cltq mov %rax,%rsi mov %rdx,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%ebx mov -0x44(%rbp),%eax movslq %eax,%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov %ebx,(%rax) addl $0x1,-0x44(%rbp) jmp 1303 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x7a> mov -0x34(%rbp),%eax sub $0x1,%eax mov %eax,-0x40(%rbp) cmpl $0x0,-0x40(%rbp) js 1454 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x1cb> movl $0x0,-0x3c(%rbp) mov -0x3c(%rbp),%eax movslq %eax,%rbx mov -0x40(%rbp),%eax movslq %eax,%rdx mov -0x58(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f08 <_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdi callq 1f36 <_ZNKSt6vectorIiSaIiEE4sizeEv> cmp %rax,%rbx setb %al test %al,%al je 144b <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x1c2> mov -0x40(%rbp),%eax movslq %eax,%rdx mov -0x58(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f08 <_ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdx mov -0x3c(%rbp),%eax cltq mov %rax,%rsi mov %rdx,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%ebx mov -0x3c(%rbp),%eax add $0x1,%eax movslq %eax,%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov %rax,%r12 mov -0x3c(%rbp),%eax movslq %eax,%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov %r12,%rsi mov %rax,%rdi callq 1f82 <_ZSt3minIiERKT_S2_S2_> mov (%rax),%eax add %eax,%ebx mov -0x3c(%rbp),%eax movslq %eax,%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov %ebx,(%rax) addl $0x1,-0x3c(%rbp) jmpq 1391 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> subl $0x1,-0x40(%rbp) jmpq 1380 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xf7> lea -0x30(%rbp),%rax mov $0x0,%esi mov %rax,%rdi callq 1f5e <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%ebx lea -0x30(%rbp),%rax mov %rax,%rdi callq 1ec0 <_ZNSt6vectorIiSaIiEED1Ev> mov %ebx,%eax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 14a9 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x220> jmp 14a4 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x21b> endbr64 mov %rax,%rbx lea -0x49(%rbp),%rax mov %rax,%rdi callq 1e18 <_ZNSaIiED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1190 <_Unwind_Resume@plt> callq 1150 <__stack_chk_fail@plt> add $0x50,%rsp pop %rbx pop %r12 pop %rbp retq
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 push rbp mov rbp, rsp push r12 push rbx sub rsp, 60h mov [rbp+var_68], rdi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+var_68] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv; std::vector<std::vector<int>>::size(void) mov [rbp+var_40], eax lea rax, [rbp+var_51] mov [rbp+var_38], rax nop nop mov [rbp+var_50], 0 mov eax, [rbp+var_40] movsxd rsi, eax lea rcx, [rbp+var_51] lea rdx, [rbp+var_50] lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEEC2EmRKiRKS0_; std::vector<int>::vector(ulong,int const&,std::allocator<int> const&) lea rax, [rbp+var_51] mov rdi, rax call _ZNSt15__new_allocatorIiED2Ev; std::__new_allocator<int>::~__new_allocator() nop mov eax, [rbp+var_40] sub eax, 1 mov [rbp+var_3C], eax mov [rbp+var_4C], 0 jmp short loc_1369 loc_1324: mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdx, rax mov eax, [rbp+var_4C] cdqe mov rsi, rax mov rdi, rdx call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] mov eax, [rbp+var_4C] movsxd rdx, eax lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov [rax], ebx add [rbp+var_4C], 1 loc_1369: mov eax, [rbp+var_4C] movsxd rbx, eax mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) cmp rbx, rax setb al test al, al jnz short loc_1324 mov eax, [rbp+var_3C] sub eax, 1 mov [rbp+var_48], eax jmp loc_1469 loc_13A4: mov [rbp+var_44], 0 jmp loc_1434 loc_13B0: mov eax, [rbp+var_48] movsxd rdx, eax mov rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdx, rax mov eax, [rbp+var_44] cdqe mov rsi, rax mov rdi, rdx call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] mov eax, [rbp+var_44] add eax, 1 movsxd rdx, eax lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov r12, rax mov eax, [rbp+var_44] movsxd rdx, eax lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov rsi, r12 mov rdi, rax call _ZSt3minIiERKT_S2_S2_; std::min<int>(int const&,int const&) mov eax, [rax] add ebx, eax mov eax, [rbp+var_44] movsxd rdx, eax lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov [rax], ebx add [rbp+var_44], 1 loc_1434: mov eax, [rbp+var_44] movsxd rbx, eax mov eax, [rbp+var_48] movsxd rdx, eax mov rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) cmp rbx, rax setb al test al, al jnz loc_13B0 sub [rbp+var_48], 1 loc_1469: cmp [rbp+var_48], 0 jns loc_13A4 lea rax, [rbp+var_30] mov esi, 0 mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov eax, ebx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14DD jmp short loc_14D8 endbr64 mov rbx, rax lea rax, [rbp+var_51] mov rdi, rax call _ZNSt15__new_allocatorIiED2Ev; std::__new_allocator<int>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14D0 call ___stack_chk_fail loc_14D0: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_14D8: call ___stack_chk_fail loc_14DD: add rsp, 60h pop rbx pop r12 pop rbp retn
long long func0(long long a1) { long long v1; // rax int v2; // ebx unsigned long long v3; // rbx long long v4; // rax long long v5; // rax int v6; // ebx long long v7; // r12 long long v8; // rax int v9; // ebx unsigned long long v10; // rbx long long v11; // rax unsigned int v12; // ebx char v14; // [rsp+1Fh] [rbp-51h] BYREF int v15; // [rsp+20h] [rbp-50h] BYREF int i; // [rsp+24h] [rbp-4Ch] int j; // [rsp+28h] [rbp-48h] int k; // [rsp+2Ch] [rbp-44h] int v19; // [rsp+30h] [rbp-40h] int v20; // [rsp+34h] [rbp-3Ch] char *v21; // [rsp+38h] [rbp-38h] _BYTE v22[24]; // [rsp+40h] [rbp-30h] BYREF unsigned long long v23; // [rsp+58h] [rbp-18h] v23 = __readfsqword(0x28u); v19 = std::vector<std::vector<int>>::size(a1); v21 = &v14; v15 = 0; std::vector<int>::vector(v22, v19, &v15, &v14); std::__new_allocator<int>::~__new_allocator(&v14); v20 = v19 - 1; for ( i = 0; ; ++i ) { v3 = i; v4 = std::vector<std::vector<int>>::operator[](a1, v20); if ( v3 >= std::vector<int>::size(v4) ) break; v1 = std::vector<std::vector<int>>::operator[](a1, v20); v2 = *(_DWORD *)std::vector<int>::operator[](v1, i); *(_DWORD *)std::vector<int>::operator[](v22, i) = v2; } for ( j = v20 - 1; j >= 0; --j ) { for ( k = 0; ; ++k ) { v10 = k; v11 = std::vector<std::vector<int>>::operator[](a1, j); if ( v10 >= std::vector<int>::size(v11) ) break; v5 = std::vector<std::vector<int>>::operator[](a1, j); v6 = *(_DWORD *)std::vector<int>::operator[](v5, k); v7 = std::vector<int>::operator[](v22, k + 1); v8 = std::vector<int>::operator[](v22, k); v9 = *(_DWORD *)std::min<int>(v8, v7) + v6; *(_DWORD *)std::vector<int>::operator[](v22, k) = v9; } } v12 = *(_DWORD *)std::vector<int>::operator[](v22, 0LL); std::vector<int>::~vector(v22); return v12; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R12 PUSH RBX SUB RSP,0x60 MOV qword ptr [RBP + -0x68],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x68] MOV RDI,RAX CALL 0x00101e2c MOV dword ptr [RBP + -0x40],EAX LEA RAX,[RBP + -0x51] MOV qword ptr [RBP + -0x38],RAX NOP NOP MOV dword ptr [RBP + -0x50],0x0 MOV EAX,dword ptr [RBP + -0x40] MOVSXD RSI,EAX LEA RCX,[RBP + -0x51] LEA RDX,[RBP + -0x50] LEA RAX,[RBP + -0x30] MOV RDI,RAX LAB_00101300: CALL 0x00101e5e LEA RAX,[RBP + -0x51] MOV RDI,RAX CALL 0x001021ca NOP MOV EAX,dword ptr [RBP + -0x40] SUB EAX,0x1 MOV dword ptr [RBP + -0x3c],EAX MOV dword ptr [RBP + -0x4c],0x0 JMP 0x00101369 LAB_00101324: MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f3e MOV RDX,RAX MOV EAX,dword ptr [RBP + -0x4c] CDQE MOV RSI,RAX MOV RDI,RDX CALL 0x00101f94 MOV EBX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x4c] MOVSXD RDX,EAX LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f94 MOV dword ptr [RAX],EBX ADD dword ptr [RBP + -0x4c],0x1 LAB_00101369: MOV EAX,dword ptr [RBP + -0x4c] MOVSXD RBX,EAX MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f3e MOV RDI,RAX CALL 0x00101f6c CMP RBX,RAX SETC AL TEST AL,AL JNZ 0x00101324 MOV EAX,dword ptr [RBP + -0x3c] SUB EAX,0x1 MOV dword ptr [RBP + -0x48],EAX JMP 0x00101469 LAB_001013a4: MOV dword ptr [RBP + -0x44],0x0 JMP 0x00101434 LAB_001013b0: MOV EAX,dword ptr [RBP + -0x48] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f3e MOV RDX,RAX MOV EAX,dword ptr [RBP + -0x44] CDQE MOV RSI,RAX MOV RDI,RDX CALL 0x00101f94 MOV EBX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x44] ADD EAX,0x1 MOVSXD RDX,EAX LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f94 MOV R12,RAX MOV EAX,dword ptr [RBP + -0x44] MOVSXD RDX,EAX LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f94 MOV RSI,R12 MOV RDI,RAX CALL 0x00101fb8 MOV EAX,dword ptr [RAX] ADD EBX,EAX MOV EAX,dword ptr [RBP + -0x44] MOVSXD RDX,EAX LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f94 MOV dword ptr [RAX],EBX ADD dword ptr [RBP + -0x44],0x1 LAB_00101434: MOV EAX,dword ptr [RBP + -0x44] MOVSXD RBX,EAX MOV EAX,dword ptr [RBP + -0x48] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101f3e MOV RDI,RAX CALL 0x00101f6c CMP RBX,RAX SETC AL TEST AL,AL JNZ 0x001013b0 SUB dword ptr [RBP + -0x48],0x1 LAB_00101469: CMP dword ptr [RBP + -0x48],0x0 JNS 0x001013a4 LEA RAX,[RBP + -0x30] MOV ESI,0x0 MOV RDI,RAX CALL 0x00101f94 MOV EBX,dword ptr [RAX] LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101ee4 MOV EAX,EBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x001014dd JMP 0x001014d8 LAB_001014d8: CALL 0x00101170 LAB_001014dd: ADD RSP,0x60 POP RBX POP R12 POP RBP RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ int4 func0(vector param_1) { int iVar1; int iVar2; int4 uVar3; vector<int,std::allocator<int>> *pvVar4; ulong uVar5; int *piVar6; int *piVar7; int4 *puVar8; ulong uVar9; int4 in_register_0000003c; vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *this; long in_FS_OFFSET; allocator local_59; int local_58; int local_54; int local_50; int local_4c; int local_48; int local_44; allocator *local_40; vector<int,std::allocator<int>> local_38 [24]; long local_20; this = (vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)CONCAT44(in_register_0000003c,param_1); local_20 = *(long *)(in_FS_OFFSET + 0x28); local_48 = std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::size(this); local_40 = &local_59; local_58 = 0; /* try { // try from 00101300 to 00101304 has its CatchHandler @ 001014a5 */ std::vector<int,std::allocator<int>>::vector(local_38,(long)local_48,&local_58,&local_59); std::__new_allocator<int>::~__new_allocator((__new_allocator<int> *)&local_59); local_44 = local_48 + -1; local_54 = 0; while( true ) { uVar9 = (ulong)local_54; pvVar4 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[](this,(long)local_44); uVar5 = std::vector<int,std::allocator<int>>::size(pvVar4); local_50 = local_44; if (uVar5 <= uVar9) break; pvVar4 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[](this,(long)local_44); puVar8 = (int4 *)std::vector<int,std::allocator<int>>::operator[](pvVar4,(long)local_54); uVar3 = *puVar8; puVar8 = (int4 *)std::vector<int,std::allocator<int>>::operator[](local_38,(long)local_54) ; *puVar8 = uVar3; local_54 = local_54 + 1; } while (local_50 = local_50 + -1, -1 < local_50) { local_4c = 0; while( true ) { uVar9 = (ulong)local_4c; pvVar4 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[](this,(long)local_50); uVar5 = std::vector<int,std::allocator<int>>::size(pvVar4); if (uVar5 <= uVar9) break; pvVar4 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[](this,(long)local_50); piVar6 = (int *)std::vector<int,std::allocator<int>>::operator[](pvVar4,(long)local_4c); iVar1 = *piVar6; piVar6 = (int *)std::vector<int,std::allocator<int>>::operator[] (local_38,(long)(local_4c + 1)); piVar7 = (int *)std::vector<int,std::allocator<int>>::operator[](local_38,(long)local_4c); piVar6 = std::min<int>(piVar7,piVar6); iVar2 = *piVar6; piVar6 = (int *)std::vector<int,std::allocator<int>>::operator[](local_38,(long)local_4c); *piVar6 = iVar1 + iVar2; local_4c = local_4c + 1; } } puVar8 = (int4 *)std::vector<int,std::allocator<int>>::operator[](local_38,0); uVar3 = *puVar8; std::vector<int,std::allocator<int>>::~vector(local_38); if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar3; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,893
func0
#include <vector> #include <cassert>
int func0(std::vector<std::vector<int>> A) { int n = A.size(); std::vector<int> memo(n, 0); int lastRow = n - 1; for(int i = 0; i < A[lastRow].size(); ++i) { memo[i] = A[lastRow][i]; } for(int i = lastRow - 1; i >= 0; --i) { for(int j = 0; j < A[i].size(); ++j) { memo[j] = A[i][j] + std::min(memo[j], memo[j + 1]); } } return memo[0]; }
int main() { assert(func0({{2}, {3, 9}, {1, 6, 7}}) == 6); assert(func0({{2}, {3, 7}, {8, 5, 6}}) == 10); assert(func0({{3}, {6, 4}, {5, 2, 7}}) == 9); return 0; }
O1
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov 0x8(%rdi),%rbx sub (%rdi),%rbx sar $0x3,%rbx movabs $0xaaaaaaaaaaaaaaab,%rax imul %rax,%rbx movslq %ebx,%rbp movabs $0x1fffffffffffffff,%rax cmp %rax,%rbp ja 1381 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xd8> mov %rdi,%r12 test %rbp,%rbp je 13d3 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x12a> lea 0x0(,%rbp,4),%r13 mov %r13,%rdi callq 1160 <_Znwm@plt> lea (%rax,%r13,1),%rcx mov %rax,%rdx movl $0x0,(%rdx) add $0x4,%rdx cmp %rcx,%rdx jne 1309 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x60> mov (%r12),%r8 lea -0x1(%rbx),%edx movslq %edx,%rdx lea (%rdx,%rdx,2),%rdx lea (%r8,%rdx,8),%rdx mov (%rdx),%rdi mov 0x8(%rdx),%rdx sub %rdi,%rdx sar $0x2,%rdx mov %rdx,%rsi je 1355 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xac> shl $0x2,%rsi mov $0x0,%edx mov (%rdi,%rdx,1),%ecx mov %ecx,(%rax,%rdx,1) add $0x4,%rdx cmp %rdx,%rsi jne 1346 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x9d> cmp $0x1,%ebx jle 13ff <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x156> lea 0x0(%rbp,%rbp,2),%rdx shl $0x3,%rdx lea -0x30(%r8,%rdx,1),%r9 lea -0x48(%r8,%rdx,1),%r10 lea -0x2(%rbx),%edx lea (%rdx,%rdx,2),%rdx shl $0x3,%rdx sub %rdx,%r10 jmp 1396 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xed> lea 0xc80(%rip),%rdi callq 1120 <_ZSt20__throw_length_errorPKc@plt> sub $0x18,%r9 cmp %r10,%r9 je 13ff <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x156> mov (%r9),%rdi mov 0x8(%r9),%r8 sub %rdi,%r8 mov %r8,%rbx shr $0x2,%rbx je 138d <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xe4> mov %rax,%rdx add %rax,%r8 mov %rdx,%rcx add $0x4,%rdx mov (%rcx),%ebx cmp %ebx,0x4(%rcx) mov %rcx,%rsi cmovl %rdx,%rsi mov (%rsi),%esi add (%rdi),%esi mov %esi,(%rcx) add $0x4,%rdi cmp %rdx,%r8 jne 13af <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x106> jmp 138d <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xe4> mov (%rdi),%r8 lea -0x1(%rbx),%eax cltq lea (%rax,%rax,2),%rax lea (%r8,%rax,8),%rax mov (%rax),%rdi mov 0x8(%rax),%rdx sub %rdi,%rdx sar $0x2,%rdx mov %rdx,%rsi mov $0x0,%eax jne 133d <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x94> mov (%rax),%ebx mov %rax,%rdi callq 1150 <_ZdlPv@plt> mov %ebx,%eax add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 mov rbp, [rdi+8] sub rbp, [rdi] sar rbp, 3 mov rax, 0AAAAAAAAAAAAAAABh imul rbp, rax movsxd r12, ebp mov rax, r12 shr rax, 3Dh jnz loc_137A mov r13, rdi test r12, r12 jz loc_1386 lea rbx, ds:0[r12*4] mov rdi, rbx; unsigned __int64 call __Znwm; operator new(ulong) mov r10, rax lea rdx, [rax+rbx] loc_1303: mov dword ptr [rax], 0 add rax, 4 cmp rdx, rax jnz short loc_1303 loc_1312: mov rdi, [r13+0] lea eax, [rbp-1] cdqe lea rax, [rax+rax*2] lea rsi, [rdi+rax*8] mov rcx, [rsi] cmp [rsi+8], rcx jz short loc_134F mov edx, 0 loc_1331: mov eax, [rcx+rdx*4] mov [r10+rdx*4], eax mov rcx, [rsi] add rdx, 1 mov rax, [rsi+8] sub rax, rcx sar rax, 2 cmp rdx, rax jb short loc_1331 loc_134F: cmp ebp, 1 jle loc_1401 lea rax, [r12+r12*2] shl rax, 3 lea r9, [rdi+rax-30h] lea r11, [rdi+rax-48h] lea eax, [rbp-2] lea rax, [rax+rax*2] shl rax, 3 sub r11, rax jmp short loc_13CB loc_137A: lea rdi, aCannotCreateSt; "cannot create std::vector larger than m"... call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) loc_1386: mov rbx, r12 mov r10d, 0 jmp short loc_1312 loc_1391: mov rax, rcx add rcx, 4 mov esi, [rax] cmp [rax+4], esi mov rsi, rcx cmovge rsi, rax mov esi, [rsi] add esi, [rdi+rdx*4] mov [rax], esi mov rdi, [r8] add rdx, 1 mov rax, [r8+8] sub rax, rdi sar rax, 2 cmp rdx, rax jb short loc_1391 loc_13C2: sub r9, 18h cmp r11, r9 jz short loc_13E1 loc_13CB: mov r8, r9 mov rdi, [r9] mov rcx, r10 mov edx, 0 cmp [r9+8], rdi jnz short loc_1391 jmp short loc_13C2 loc_13E1: mov ebp, [r10] test r10, r10 jz short loc_13F4 mov rsi, rbx; unsigned __int64 loc_13EC: mov rdi, r10; void * call __ZdlPvm; operator delete(void *,ulong) loc_13F4: mov eax, ebp add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn loc_1401: mov ebp, [r10] mov rsi, rbx jmp short loc_13EC
long long func0(long long *a1) { unsigned long long v1; // rbp unsigned long long v3; // rbx unsigned int *v4; // rax unsigned int *v5; // r10 unsigned int *v6; // rdx long long v7; // rdi long long *v8; // rsi long long v9; // rcx unsigned long long v10; // rdx long long *v11; // r9 long long v12; // r11 unsigned int *v13; // rax unsigned int *v14; // rcx unsigned int *v15; // rsi long long v16; // rdi unsigned long long v17; // rdx unsigned int v18; // ebp unsigned long long v19; // rsi v1 = 0xAAAAAAAAAAAAAAABLL * ((a1[1] - *a1) >> 3); if ( (unsigned long long)(int)v1 >> 61 ) std::__throw_length_error("cannot create std::vector larger than max_size()"); if ( (_DWORD)v1 ) { v3 = 4LL * (int)v1; v4 = (unsigned int *)operator new(v3); v5 = v4; v6 = &v4[v3 / 4]; do *v4++ = 0; while ( v6 != v4 ); } else { v3 = 0LL; v5 = 0LL; } v7 = *a1; v8 = (long long *)(*a1 + 24LL * ((int)v1 - 1)); v9 = *v8; if ( v8[1] != *v8 ) { v10 = 0LL; do { v5[v10] = *(_DWORD *)(v9 + 4 * v10); v9 = *v8; ++v10; } while ( v10 < (v8[1] - *v8) >> 2 ); } if ( (int)v1 <= 1 ) { v18 = *v5; v19 = v3; goto LABEL_20; } v11 = (long long *)(v7 + 24LL * (int)v1 - 48); v12 = v7 + 24LL * (int)v1 - 72 - 24LL * (unsigned int)(v1 - 2); do { v16 = *v11; v14 = v5; v17 = 0LL; if ( v11[1] != *v11 ) { do { v13 = v14++; v15 = v14; if ( (int)v13[1] >= (int)*v13 ) v15 = v13; *v13 = *(_DWORD *)(v16 + 4 * v17) + *v15; v16 = *v11; ++v17; } while ( v17 < (v11[1] - *v11) >> 2 ); } v11 -= 3; } while ( (long long *)v12 != v11 ); v18 = *v5; if ( v5 ) { v19 = v3; LABEL_20: operator delete(v5, v19); } return v18; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV RBP,qword ptr [RDI + 0x8] SUB RBP,qword ptr [RDI] SAR RBP,0x3 MOV RAX,-0x5555555555555555 IMUL RBP,RAX MOVSXD R12,EBP MOV RAX,R12 SHR RAX,0x3d JNZ 0x0010137a MOV R13,RDI TEST R12,R12 JZ 0x00101386 LEA RBX,[R12*0x4] MOV RDI,RBX CALL 0x00101150 MOV R10,RAX LEA RDX,[RAX + RBX*0x1] LAB_00101303: MOV dword ptr [RAX],0x0 ADD RAX,0x4 CMP RDX,RAX JNZ 0x00101303 LAB_00101312: MOV RDI,qword ptr [R13] LEA EAX,[RBP + -0x1] CDQE LEA RAX,[RAX + RAX*0x2] LEA RSI,[RDI + RAX*0x8] MOV RCX,qword ptr [RSI] CMP qword ptr [RSI + 0x8],RCX JZ 0x0010134f MOV EDX,0x0 LAB_00101331: MOV EAX,dword ptr [RCX + RDX*0x4] MOV dword ptr [R10 + RDX*0x4],EAX MOV RCX,qword ptr [RSI] ADD RDX,0x1 MOV RAX,qword ptr [RSI + 0x8] SUB RAX,RCX SAR RAX,0x2 CMP RDX,RAX JC 0x00101331 LAB_0010134f: CMP EBP,0x1 JLE 0x00101401 LEA RAX,[R12 + R12*0x2] SHL RAX,0x3 LEA R9,[RDI + RAX*0x1 + -0x30] LEA R11,[RDI + RAX*0x1 + -0x48] LEA EAX,[RBP + -0x2] LEA RAX,[RAX + RAX*0x2] SHL RAX,0x3 SUB R11,RAX JMP 0x001013cb LAB_0010137a: LEA RDI,[0x102008] CALL 0x00101110 LAB_00101386: MOV RBX,R12 MOV R10D,0x0 JMP 0x00101312 LAB_00101391: MOV RAX,RCX ADD RCX,0x4 MOV ESI,dword ptr [RAX] CMP dword ptr [RAX + 0x4],ESI MOV RSI,RCX CMOVGE RSI,RAX MOV ESI,dword ptr [RSI] ADD ESI,dword ptr [RDI + RDX*0x4] MOV dword ptr [RAX],ESI MOV RDI,qword ptr [R8] ADD RDX,0x1 MOV RAX,qword ptr [R8 + 0x8] SUB RAX,RDI SAR RAX,0x2 CMP RDX,RAX JC 0x00101391 LAB_001013c2: SUB R9,0x18 CMP R11,R9 JZ 0x001013e1 LAB_001013cb: MOV R8,R9 MOV RDI,qword ptr [R9] MOV RCX,R10 MOV EDX,0x0 CMP qword ptr [R9 + 0x8],RDI JNZ 0x00101391 JMP 0x001013c2 LAB_001013e1: MOV EBP,dword ptr [R10] TEST R10,R10 JZ 0x001013f4 MOV RSI,RBX LAB_001013ec: MOV RDI,R10 CALL 0x00101160 LAB_001013f4: MOV EAX,EBP ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET LAB_00101401: MOV EBP,dword ptr [R10] MOV RSI,RBX JMP 0x001013ec
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ int func0(vector param_1) { long lVar1; int *piVar2; int *piVar3; long lVar4; ulong uVar5; ulong uVar6; int iVar7; int *piVar8; int4 in_register_0000003c; long *plVar9; ulong uVar10; long *unaff_R13; plVar9 = (long *)CONCAT44(in_register_0000003c,param_1); iVar7 = (int)(plVar9[1] - *plVar9 >> 3) * -0x55555555; uVar10 = (ulong)iVar7; if (uVar10 >> 0x3d == 0) { unaff_R13 = plVar9; if (uVar10 != 0) { piVar2 = (int *)operator_new(uVar10 * 4); piVar3 = piVar2; do { *piVar3 = 0; piVar3 = piVar3 + 1; uVar6 = uVar10 * 4; } while (piVar2 + uVar10 != piVar3); goto LAB_00101312; } } else { std::__throw_length_error("cannot create std::vector larger than max_size()"); } piVar2 = (int *)0x0; uVar6 = uVar10; LAB_00101312: lVar1 = *unaff_R13; plVar9 = (long *)(lVar1 + (long)(iVar7 + -1) * 0x18); lVar4 = *plVar9; if (plVar9[1] != lVar4) { uVar5 = 0; do { piVar2[uVar5] = *(int *)(lVar4 + uVar5 * 4); lVar4 = *plVar9; uVar5 = uVar5 + 1; } while (uVar5 < (ulong)(plVar9[1] - lVar4 >> 2)); } if (iVar7 < 2) { iVar7 = *piVar2; } else { plVar9 = (long *)(lVar1 + -0x30 + uVar10 * 0x18); do { lVar4 = *plVar9; uVar5 = 0; piVar3 = piVar2; if (plVar9[1] != lVar4) { do { piVar8 = piVar3 + 1; if (*piVar3 <= piVar3[1]) { piVar8 = piVar3; } *piVar3 = *piVar8 + *(int *)(lVar4 + uVar5 * 4); lVar4 = *plVar9; uVar5 = uVar5 + 1; piVar3 = piVar3 + 1; } while (uVar5 < (ulong)(plVar9[1] - lVar4 >> 2)); } plVar9 = plVar9 + -3; } while ((long *)(lVar1 + -0x48 + uVar10 * 0x18 + (ulong)(iVar7 - 2) * -0x18) != plVar9); iVar7 = *piVar2; if (piVar2 == (int *)0x0) { return iVar7; } } operator_delete(piVar2,uVar6); return iVar7; }
3,894
func0
#include <vector> #include <cassert>
int func0(std::vector<std::vector<int>> A) { int n = A.size(); std::vector<int> memo(n, 0); int lastRow = n - 1; for(int i = 0; i < A[lastRow].size(); ++i) { memo[i] = A[lastRow][i]; } for(int i = lastRow - 1; i >= 0; --i) { for(int j = 0; j < A[i].size(); ++j) { memo[j] = A[i][j] + std::min(memo[j], memo[j + 1]); } } return memo[0]; }
int main() { assert(func0({{2}, {3, 9}, {1, 6, 7}}) == 6); assert(func0({{2}, {3, 7}, {8, 5, 6}}) == 10); assert(func0({{3}, {6, 4}, {5, 2, 7}}) == 9); return 0; }
O2
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 movabs $0xaaaaaaaaaaaaaaab,%rax push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov (%rdi),%rsi mov 0x8(%rdi),%rbx sub %rsi,%rbx sar $0x3,%rbx imul %rax,%rbx movabs $0x1fffffffffffffff,%rax movslq %ebx,%rbp cmp %rax,%rbp ja 182e <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x14e> test %rbp,%rbp je 1812 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x132> lea 0x0(,%rbp,4),%r12 mov %rdi,%r13 mov %r12,%rdi callq 1160 <_Znwm@plt> mov %rax,%rdi lea (%rax,%r12,1),%rdx nopl 0x0(%rax,%rax,1) movl $0x0,(%rax) add $0x4,%rax cmp %rax,%rdx jne 1748 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x68> lea -0x1(%rbx),%eax mov 0x0(%r13),%rsi cltq lea (%rax,%rax,2),%rax lea (%rsi,%rax,8),%rax mov (%rax),%r8 mov 0x8(%rax),%rdx sub %r8,%rdx sar $0x2,%rdx je 1790 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xb0> shl $0x2,%rdx xor %eax,%eax xchg %ax,%ax mov (%r8,%rax,1),%ecx mov %ecx,(%rdi,%rax,1) add $0x4,%rax cmp %rax,%rdx jne 1780 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xa0> sub $0x2,%ebx js 17fc <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x11c> movslq %ebx,%rax mov %ebx,%ebx lea (%rax,%rax,2),%rax lea (%rsi,%rax,8),%r8 lea 0x0(%rbp,%rbp,2),%rax lea -0x48(,%rax,8),%r9 lea (%rbx,%rbx,2),%rax shl $0x3,%rax sub %rax,%r9 add %rsi,%r9 nopl (%rax) mov (%r8),%rsi mov 0x8(%r8),%rax xor %edx,%edx sub %rsi,%rax mov %rax,%rbx shr $0x2,%rbx je 17f3 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x113> nopl (%rax) mov (%rdi,%rdx,1),%ecx cmp %ecx,0x4(%rdi,%rdx,1) cmovle 0x4(%rdi,%rdx,1),%ecx add (%rsi,%rdx,1),%ecx mov %ecx,(%rdi,%rdx,1) add $0x4,%rdx cmp %rdx,%rax jne 17d8 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xf8> sub $0x18,%r8 cmp %r8,%r9 jne 17c0 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xe0> mov (%rdi),%r12d callq 1150 <_ZdlPv@plt> add $0x8,%rsp pop %rbx mov %r12d,%eax pop %rbp pop %r12 pop %r13 retq mov -0x18(%rsi),%r8 mov -0x10(%rsi),%rdx mov $0x0,%edi sub %r8,%rdx sar $0x2,%rdx jne 1778 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x98> jmp 17fc <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x11c> lea 0x7d3(%rip),%rdi callq 1120 <_ZSt20__throw_length_errorPKc@plt> nopw 0x0(%rax,%rax,1)
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 mov rax, 0AAAAAAAAAAAAAAABh push r13 push r12 push rbp push rbx sub rsp, 8 mov r8, [rdi] mov rbp, [rdi+8] sub rbp, r8 sar rbp, 3 imul rbp, rax movsxd r13, ebp mov rax, r13 shr rax, 3Dh jnz loc_1923 test r13, r13 jz loc_191A lea rbx, ds:0[r13*4] mov r12, rdi mov rdi, rbx; unsigned __int64 call __Znwm; operator new(ulong) mov rdx, rbx; n xor esi, esi; c mov rdi, rax; s call _memset mov r8, [r12] mov rdi, rax; void * loc_185A: lea eax, [rbp-1] cdqe lea rax, [rax+rax*2] lea rax, [r8+rax*8] mov rdx, [rax+8] mov rcx, [rax] xor eax, eax mov rsi, rdx sub rsi, rcx sar rsi, 2 cmp rcx, rdx jz short loc_188F nop loc_1880: mov edx, [rcx+rax*4] mov [rdi+rax*4], edx add rax, 1 cmp rax, rsi jb short loc_1880 loc_188F: cmp ebp, 1 jle short loc_1903 lea rax, [r13+r13*2+0] lea edx, [rbp-2] shl rax, 3 lea rdx, [rdx+rdx*2] lea r9, [r8+rax-30h] shl rdx, 3 sub rax, 48h ; 'H' sub rax, rdx lea r10, [r8+rax] nop dword ptr [rax+rax+00000000h] loc_18C0: mov rax, [r9+8] mov rsi, [r9] mov r8, rax sub r8, rsi sar r8, 2 cmp rsi, rax jz short loc_18FA mov ecx, [rdi] xor edx, edx nop word ptr [rax+rax+00h] loc_18E0: mov eax, ecx mov ecx, [rdi+rdx*4+4] cmp ecx, eax cmovle eax, ecx add eax, [rsi+rdx*4] mov [rdi+rdx*4], eax add rdx, 1 cmp rdx, r8 jb short loc_18E0 loc_18FA: sub r9, 18h cmp r9, r10 jnz short loc_18C0 loc_1903: mov ebp, [rdi] mov rsi, rbx; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) add rsp, 8 pop rbx mov eax, ebp pop rbp pop r12 pop r13 retn loc_191A: xor ebx, ebx xor edi, edi jmp loc_185A loc_1923: lea rdi, aCannotCreateSt; "cannot create std::vector larger than m"... call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*)
long long func0(long long *a1) { long long v1; // r8 unsigned long long v2; // rbp unsigned long long v3; // rbx void *v4; // rax unsigned int *v5; // rax unsigned int *v6; // rdi long long *v7; // rax long long v8; // rdx long long v9; // rcx unsigned long long v10; // rax long long *v11; // r9 long long *v12; // r10 long long v13; // rsi unsigned long long v14; // r8 int v15; // ecx unsigned long long v16; // rdx int v17; // eax unsigned int v18; // ebp v1 = *a1; v2 = 0xAAAAAAAAAAAAAAABLL * ((a1[1] - *a1) >> 3); if ( (unsigned long long)(int)v2 >> 61 ) std::__throw_length_error("cannot create std::vector larger than max_size()"); if ( (_DWORD)v2 ) { v3 = 4LL * (int)v2; v4 = (void *)operator new(v3); v5 = (unsigned int *)memset(v4, 0, v3); v1 = *a1; v6 = v5; } else { v3 = 0LL; v6 = 0LL; } v7 = (long long *)(v1 + 24LL * ((int)v2 - 1)); v8 = v7[1]; v9 = *v7; v10 = 0LL; if ( v9 != v8 ) { do { v6[v10] = *(_DWORD *)(v9 + 4 * v10); ++v10; } while ( v10 < (v8 - v9) >> 2 ); } if ( (int)v2 > 1 ) { v11 = (long long *)(v1 + 24LL * (int)v2 - 48); v12 = (long long *)(v1 + 24LL * (int)v2 - 72 - 24LL * (unsigned int)(v2 - 2)); do { v13 = *v11; v14 = (v11[1] - *v11) >> 2; if ( *v11 != v11[1] ) { v15 = *v6; v16 = 0LL; do { v17 = v15; v15 = v6[v16 + 1]; if ( v15 <= v17 ) v17 = v6[v16 + 1]; v6[v16] = *(_DWORD *)(v13 + 4 * v16) + v17; ++v16; } while ( v16 < v14 ); } v11 -= 3; } while ( v11 != v12 ); } v18 = *v6; operator delete(v6, v3); return v18; }
func0: ENDBR64 MOV RAX,-0x5555555555555555 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV R8,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] SUB RBP,R8 SAR RBP,0x3 IMUL RBP,RAX MOVSXD R13,EBP MOV RAX,R13 SHR RAX,0x3d JNZ 0x00101923 TEST R13,R13 JZ 0x0010191a LEA RBX,[R13*0x4] MOV R12,RDI MOV RDI,RBX CALL 0x00101190 MOV RDX,RBX XOR ESI,ESI MOV RDI,RAX CALL 0x00101150 MOV R8,qword ptr [R12] MOV RDI,RAX LAB_0010185a: LEA EAX,[RBP + -0x1] CDQE LEA RAX,[RAX + RAX*0x2] LEA RAX,[R8 + RAX*0x8] MOV RDX,qword ptr [RAX + 0x8] MOV RCX,qword ptr [RAX] XOR EAX,EAX MOV RSI,RDX SUB RSI,RCX SAR RSI,0x2 CMP RCX,RDX JZ 0x0010188f NOP LAB_00101880: MOV EDX,dword ptr [RCX + RAX*0x4] MOV dword ptr [RDI + RAX*0x4],EDX ADD RAX,0x1 CMP RAX,RSI JC 0x00101880 LAB_0010188f: CMP EBP,0x1 JLE 0x00101903 LEA RAX,[R13 + R13*0x2] LEA EDX,[RBP + -0x2] SHL RAX,0x3 LEA RDX,[RDX + RDX*0x2] LEA R9,[R8 + RAX*0x1 + -0x30] SHL RDX,0x3 SUB RAX,0x48 SUB RAX,RDX LEA R10,[R8 + RAX*0x1] NOP dword ptr [RAX + RAX*0x1] LAB_001018c0: MOV RAX,qword ptr [R9 + 0x8] MOV RSI,qword ptr [R9] MOV R8,RAX SUB R8,RSI SAR R8,0x2 CMP RSI,RAX JZ 0x001018fa MOV ECX,dword ptr [RDI] XOR EDX,EDX NOP word ptr [RAX + RAX*0x1] LAB_001018e0: MOV EAX,ECX MOV ECX,dword ptr [RDI + RDX*0x4 + 0x4] CMP ECX,EAX CMOVLE EAX,ECX ADD EAX,dword ptr [RSI + RDX*0x4] MOV dword ptr [RDI + RDX*0x4],EAX ADD RDX,0x1 CMP RDX,R8 JC 0x001018e0 LAB_001018fa: SUB R9,0x18 CMP R9,R10 JNZ 0x001018c0 LAB_00101903: MOV EBP,dword ptr [RDI] MOV RSI,RBX CALL 0x001011a0 ADD RSP,0x8 POP RBX MOV EAX,EBP POP RBP POP R12 POP R13 RET LAB_0010191a: XOR EBX,EBX XOR EDI,EDI JMP 0x0010185a LAB_00101923: LEA RDI,[0x102008] CALL 0x00101140 NOP
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ void * func0(vector param_1) { uint uVar1; long lVar2; long lVar3; void *pvVar4; uint *puVar5; ulong uVar6; void *extraout_RAX; uint uVar7; ulong __n; int iVar8; int4 in_register_0000003c; long *plVar9; char *pcVar10; long lVar11; ulong uVar12; plVar9 = (long *)CONCAT44(in_register_0000003c,param_1); lVar11 = *plVar9; iVar8 = (int)(plVar9[1] - lVar11 >> 3) * -0x55555555; uVar12 = (ulong)iVar8; if (uVar12 >> 0x3d == 0) { if (uVar12 == 0) { __n = 0; puVar5 = (uint *)0x0; } else { __n = uVar12 * 4; pvVar4 = operator_new(__n); puVar5 = (uint *)memset(pvVar4,0,__n); lVar11 = *plVar9; } plVar9 = (long *)(lVar11 + (long)(iVar8 + -1) * 0x18); lVar2 = plVar9[1]; lVar3 = *plVar9; uVar6 = 0; if (lVar3 != lVar2) { do { puVar5[uVar6] = *(uint *)(lVar3 + uVar6 * 4); uVar6 = uVar6 + 1; } while (uVar6 < (ulong)(lVar2 - lVar3 >> 2)); } if (1 < iVar8) { plVar9 = (long *)(lVar11 + -0x30 + uVar12 * 0x18); do { lVar2 = plVar9[1]; lVar3 = *plVar9; if (lVar3 != lVar2) { uVar6 = 0; uVar7 = *puVar5; do { uVar1 = puVar5[uVar6 + 1]; if ((int)uVar1 <= (int)uVar7) { uVar7 = uVar1; } puVar5[uVar6] = uVar7 + *(int *)(lVar3 + uVar6 * 4); uVar6 = uVar6 + 1; uVar7 = uVar1; } while (uVar6 < (ulong)(lVar2 - lVar3 >> 2)); } plVar9 = plVar9 + -3; } while (plVar9 != (long *)(lVar11 + uVar12 * 0x18 + -0x48 + (ulong)(iVar8 - 2) * -0x18)); } uVar7 = *puVar5; operator_delete(puVar5,__n); return (void *)(ulong)uVar7; } pcVar10 = "cannot create std::vector larger than max_size()"; std::__throw_length_error("cannot create std::vector larger than max_size()"); pvVar4 = *(void **)pcVar10; if (pvVar4 != (void *)0x0) { operator_delete(pvVar4,*(long *)(pcVar10 + 0x10) - (long)pvVar4); return extraout_RAX; } return pvVar4; }
3,895
func0
#include <vector> #include <cassert>
int func0(std::vector<std::vector<int>> A) { int n = A.size(); std::vector<int> memo(n, 0); int lastRow = n - 1; for(int i = 0; i < A[lastRow].size(); ++i) { memo[i] = A[lastRow][i]; } for(int i = lastRow - 1; i >= 0; --i) { for(int j = 0; j < A[i].size(); ++j) { memo[j] = A[i][j] + std::min(memo[j], memo[j + 1]); } } return memo[0]; }
int main() { assert(func0({{2}, {3, 9}, {1, 6, 7}}) == 6); assert(func0({{2}, {3, 7}, {8, 5, 6}}) == 10); assert(func0({{3}, {6, 4}, {5, 2, 7}}) == 9); return 0; }
O3
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 movabs $0xaaaaaaaaaaaaaaab,%rax push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov (%rdi),%rcx mov 0x8(%rdi),%rbx sub %rcx,%rbx sar $0x3,%rbx imul %rax,%rbx movabs $0x1fffffffffffffff,%rax movslq %ebx,%rbp cmp %rax,%rbp ja 1abd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x32d> mov %rdi,%r12 xor %edi,%edi test %rbp,%rbp je 17fe <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x6e> lea 0x0(,%rbp,4),%r13 mov %r13,%rdi callq 1180 <_Znwm@plt> mov %r13,%rdx xor %esi,%esi mov %rax,%rdi callq 1140 <memset@plt> mov (%r12),%rcx mov %rax,%rdi lea -0x1(%rbx),%eax cltq lea (%rax,%rax,2),%rax lea (%rcx,%rax,8),%rax mov (%rax),%rsi mov 0x8(%rax),%rdx sub %rsi,%rdx mov %rdx,%r8 sar $0x2,%r8 je 1898 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> lea 0xf(%rdi),%rax sub %rsi,%rax cmp $0x1e,%rax jbe 1a96 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x306> lea -0x1(%r8),%rax cmp $0x3,%rax jbe 1a96 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x306> mov %r8,%rdx xor %eax,%eax shr $0x2,%rdx shl $0x4,%rdx nopw 0x0(%rax,%rax,1) movdqu (%rsi,%rax,1),%xmm5 movups %xmm5,(%rdi,%rax,1) add $0x10,%rax cmp %rdx,%rax jne 1850 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0xc0> mov %r8,%rax and $0xfffffffffffffffc,%rax test $0x3,%r8b je 1898 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> mov (%rsi,%rax,4),%edx mov %edx,(%rdi,%rax,4) lea 0x1(%rax),%edx movslq %edx,%rdx cmp %rdx,%r8 jbe 1898 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> mov (%rsi,%rdx,4),%r9d add $0x2,%eax cltq mov %r9d,(%rdi,%rdx,4) cmp %rax,%r8 jbe 1898 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> mov (%rsi,%rax,4),%edx mov %edx,(%rdi,%rax,4) sub $0x2,%ebx js 19ca <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x23a> movslq %ebx,%rax mov %ebx,%ebx lea 0xf(%rdi),%r11 lea (%rax,%rax,2),%rax lea (%rcx,%rax,8),%r9 lea 0x0(%rbp,%rbp,2),%rax lea -0x48(,%rax,8),%r10 lea (%rbx,%rbx,2),%rax shl $0x3,%rax sub %rax,%r10 add %rcx,%r10 nopl (%rax) mov (%r9),%rcx mov 0x8(%r9),%rdx sub %rcx,%rdx sar $0x2,%rdx je 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> mov %r11,%rax sub %rcx,%rax cmp $0x1e,%rax jbe 19e0 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x250> lea -0x1(%rdx),%rax cmp $0x2,%rax jbe 19e0 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x250> mov %rdx,%rsi xor %eax,%eax shr $0x2,%rsi shl $0x4,%rsi movdqu (%rdi,%rax,1),%xmm2 movdqu 0x4(%rdi,%rax,1),%xmm0 movdqu 0x4(%rdi,%rax,1),%xmm3 movdqu (%rcx,%rax,1),%xmm4 pcmpgtd %xmm2,%xmm0 movdqa %xmm2,%xmm1 pand %xmm0,%xmm1 pandn %xmm3,%xmm0 por %xmm1,%xmm0 paddd %xmm4,%xmm0 movups %xmm0,(%rdi,%rax,1) add $0x10,%rax cmp %rax,%rsi jne 1910 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x180> mov %rdx,%rax and $0xfffffffffffffffc,%rax test $0x3,%dl je 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> lea 0x1(%rax),%ebx lea (%rdi,%rax,4),%r12 movslq %ebx,%rbx mov (%r12),%esi lea 0x0(,%rbx,4),%r8 lea (%rdi,%r8,1),%rbp cmp %esi,0x0(%rbp) cmovle 0x0(%rbp),%esi add (%rcx,%rax,4),%esi mov %esi,(%r12) cmp %rbx,%rdx jbe 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> lea 0x4(%rdi,%r8,1),%r12 mov 0x0(%rbp),%esi cmp %esi,(%r12) cmovle (%r12),%esi add $0x2,%eax add (%rcx,%rbx,4),%esi cltq mov %esi,0x0(%rbp) cmp %rax,%rdx jbe 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> mov (%r12),%eax cmp %eax,0x8(%rdi,%r8,1) cmovle 0x8(%rdi,%r8,1),%eax add 0x4(%rcx,%r8,1),%eax mov %eax,(%r12) sub $0x18,%r9 cmp %r10,%r9 jne 18d0 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x140> mov (%rdi),%r12d callq 1170 <_ZdlPv@plt> add $0x8,%rsp pop %rbx mov %r12d,%eax pop %rbp pop %r12 pop %r13 retq cmp $0x2,%rdx jbe 1ab6 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x326> lea -0x3(%rdx),%rax mov (%rdi),%esi mov $0x2,%r8d shr %rax lea 0x4(%rax,%rax,1),%rbp jmp 1a14 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x284> add %r12d,%ebx mov %ebx,-0x4(%rdi,%r8,4) lea 0x2(%r8),%rbx cmp %rbp,%rbx je 1a4a <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x2ba> mov %rbx,%r8 mov -0x4(%rdi,%r8,4),%ebx mov %r8d,%eax cmp %esi,%ebx cmovle %ebx,%esi add -0x8(%rcx,%r8,4),%esi mov %esi,-0x8(%rdi,%r8,4) mov (%rdi,%r8,4),%esi mov -0x4(%rcx,%r8,4),%r12d cmp %esi,%ebx jle 1a00 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x270> lea (%r12,%rsi,1),%ebx mov %ebx,-0x4(%rdi,%r8,4) lea 0x2(%r8),%rbx cmp %rbx,%rbp jne 1a11 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x281> add $0x1,%eax cltq jmp 1a6f <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x2df> nopl 0x0(%rax) add %ebp,%esi mov %esi,(%rbx) lea 0x1(%rax),%rsi cmp %rdx,%rax jae 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> mov %rax,%r8 mov %rsi,%rax lea (%rdi,%r8,4),%rbx mov (%rcx,%r8,4),%ebp mov (%rdi,%rax,4),%r8d mov (%rbx),%esi cmp %esi,%r8d jge 1a58 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x2c8> add %ebp,%r8d lea 0x1(%rax),%rsi mov %r8d,(%rbx) cmp %rdx,%rax jb 1a69 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x2d9> jmpq 19bd <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x22d> xor %eax,%eax nopl 0x0(%rax,%rax,1) mov (%rsi,%rax,1),%r8d mov %r8d,(%rdi,%rax,1) add $0x4,%rax cmp %rdx,%rax jne 1aa0 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x310> jmpq 1898 <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x108> xor %eax,%eax xor %r8d,%r8d jmp 1a4a <_Z5func0St6vectorIS_IiSaIiEESaIS1_EE+0x2ba> lea 0x544(%rip),%rdi callq 1130 <_ZSt20__throw_length_errorPKc@plt> nopl 0x0(%rax)
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 mov rax, 0AAAAAAAAAAAAAAABh push r14 push r13 push r12 push rbp push rbx mov r10, [rdi] mov rbp, [rdi+8] sub rbp, r10 sar rbp, 3 imul rbp, rax movsxd r13, ebp mov rax, r13 shr rax, 3Dh jnz loc_1BA8 test r13, r13 jz loc_1B85 lea rbx, ds:0[r13*4] mov r12, rdi mov rdi, rbx; unsigned __int64 call __Znwm; operator new(ulong) mov rdx, rbx; n xor esi, esi; c mov rdi, rax; s call _memset mov r10, [r12] mov rdi, rax; void * loc_1898: lea eax, [rbp-1] cdqe lea rax, [rax+rax*2] lea rdx, [r10+rax*8] mov rax, [rdx+8] mov rdx, [rdx] mov rcx, rax sub rcx, rdx mov rsi, rcx sar rsi, 2 cmp rdx, rax jz short loc_18EF cmp rcx, 0Ch jbe loc_1B8E lea rax, [rdx+4] mov r8, rdi sub r8, rax xor eax, eax cmp r8, 8 ja loc_1B07 xchg ax, ax loc_18E0: mov ecx, [rdx+rax*4] mov [rdi+rax*4], ecx add rax, 1 cmp rax, rsi jb short loc_18E0 loc_18EF: cmp ebp, 1 jle loc_19E1 lea rax, [r13+r13*2+0] lea edx, [rbp-2] mov r11d, 1 shl rax, 3 lea rdx, [rdx+rdx*2] lea r9, [r10+rax-30h] shl rdx, 3 sub rax, 48h ; 'H' sub rax, rdx add r10, rax nop dword ptr [rax+00000000h] loc_1928: mov rdx, [r9+8] mov rsi, [r9] mov rax, rdx sub rax, rsi mov r8, rax sar r8, 2 cmp rsi, rdx jz loc_19D4 cmp rax, 0Ch jbe loc_1AF0 lea rcx, [rsi+4] mov rdx, rdi lea rbp, [r8-1] sub rdx, rcx cmp rdx, 8 ja loc_1A00 loc_1967: mov eax, [rdi] mov ecx, 2 loc_196E: mov edx, [rdi+rcx*4-4] cmp eax, edx cmovg eax, edx add eax, [rsi+rcx*4-8] mov [rdi+rcx*4-8], eax mov eax, [rdi+rcx*4] cmp edx, eax cmovg edx, eax add edx, [rsi+rcx*4-4] mov [rdi+rcx*4-4], edx mov rdx, rcx lea rcx, [rcx+2] lea r12, [rdx+1] cmp r12, rbp jb short loc_196E mov ecx, edx loc_19A1: add ecx, 1 movsxd rcx, ecx nop word ptr [rax+rax+00000000h] loc_19B0: lea rbp, [rdi+rdx*4] mov eax, [rdi+rcx*4] mov r12d, [rbp+0] cmp eax, r12d cmovg eax, r12d add eax, [rsi+rdx*4] mov rdx, rcx add rcx, 1 mov [rbp+0], eax cmp rdx, r8 jb short loc_19B0 loc_19D4: sub r9, 18h cmp r10, r9 jnz loc_1928 loc_19E1: mov ebp, [rdi] mov rsi, rbx; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) pop rbx mov eax, ebp pop rbp pop r12 pop r13 pop r14 retn loc_1A00: test rax, rax mov rcx, r11 cmovnz rcx, r8 xor eax, eax mov rdx, rcx shr rdx, 2 shl rdx, 4 loc_1A17: movdqu xmm2, xmmword ptr [rdi+rax] movdqu xmm0, xmmword ptr [rdi+rax+4] movdqu xmm3, xmmword ptr [rdi+rax+4] movdqu xmm4, xmmword ptr [rsi+rax] pcmpgtd xmm0, xmm2 movdqa xmm1, xmm2 pand xmm1, xmm0 pandn xmm0, xmm3 por xmm0, xmm1 paddd xmm0, xmm4 movups xmmword ptr [rdi+rax], xmm0 add rax, 10h cmp rax, rdx jnz short loc_1A17 mov rax, rcx and rax, 0FFFFFFFFFFFFFFFCh and ecx, 3 jz loc_19D4 lea ebp, [rax+1] lea r13, [rdi+rax*4] movsxd rbp, ebp mov r14d, [r13+0] lea rcx, ds:0[rbp*4] lea r12, [rdi+rcx] mov edx, [r12] cmp edx, r14d cmovg edx, r14d add edx, [rsi+rax*4] mov [r13+0], edx cmp rbp, r8 jnb loc_19D4 lea r13, [rdi+rcx+4] mov r14d, [r12] mov edx, [r13+0] cmp edx, r14d cmovg edx, r14d add eax, 2 add edx, [rsi+rbp*4] cdqe mov [r12], edx cmp rax, r8 jnb loc_19D4 mov eax, [rdi+rcx+8] mov edx, [r13+0] cmp eax, edx cmovg eax, edx sub r9, 18h add eax, [rsi+rcx+4] mov [r13+0], eax cmp r10, r9 jnz loc_1928 jmp loc_19E1 loc_1AF0: lea rbp, [r8-1] cmp rax, 8 ja loc_1967 xor ecx, ecx xor edx, edx jmp loc_19A1 loc_1B07: test rcx, rcx mov r8d, 1 cmovnz r8, rsi mov rcx, r8 shr rcx, 2 shl rcx, 4 nop loc_1B20: movdqu xmm5, xmmword ptr [rdx+rax] movups xmmword ptr [rdi+rax], xmm5 add rax, 10h cmp rax, rcx jnz short loc_1B20 mov rax, r8 and rax, 0FFFFFFFFFFFFFFFCh and r8d, 3 jz loc_18EF mov ecx, [rdx+rax*4] mov [rdi+rax*4], ecx lea ecx, [rax+1] movsxd rcx, ecx cmp rcx, rsi jnb loc_18EF mov r9d, [rdx+rcx*4] add eax, 2 lea r8, ds:0[rcx*4] cdqe mov [rdi+rcx*4], r9d cmp rax, rsi jnb loc_18EF mov eax, [rdx+r8+4] mov [rdi+r8+4], eax jmp loc_18EF loc_1B85: xor ebx, ebx xor edi, edi jmp loc_1898 loc_1B8E: xor eax, eax mov ecx, [rdx+rax*4] mov [rdi+rax*4], ecx add rax, 1 cmp rax, rsi jb loc_18E0 jmp loc_18EF loc_1BA8: lea rdi, aCannotCreateSt; "cannot create std::vector larger than m"... call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*)
long long func0(long long *a1) { long long v1; // r10 unsigned long long v2; // rbp unsigned long long v3; // rbx void *v4; // rax char *v5; // rax char *v6; // rdi char **v7; // rdx char *v8; // rax char *v9; // rdx unsigned long long v10; // rsi unsigned long long v11; // rax long long *v12; // r9 long long *v13; // r10 long long v14; // rsi long long v15; // rax unsigned long long v16; // r8 unsigned long long v17; // rbp int v18; // eax long long v19; // rcx int v20; // edx unsigned long long v21; // rdx int v22; // ecx unsigned long long v23; // rcx char *v24; // rbp int v25; // eax int v26; // eax unsigned int v27; // ebp unsigned long long v29; // rcx long long v30; // rax __m128i v31; // xmm2 __m128i v32; // xmm0 unsigned long long v33; // rax char *v34; // r13 unsigned long long v35; // rbp long long v36; // rcx char *v37; // r12 int v38; // edx char *v39; // r13 int v40; // edx int v41; // eax unsigned long long v42; // rax unsigned long long v43; // rcx v1 = *a1; v2 = 0xAAAAAAAAAAAAAAABLL * ((a1[1] - *a1) >> 3); if ( (unsigned long long)(int)v2 >> 61 ) std::__throw_length_error("cannot create std::vector larger than max_size()"); if ( (_DWORD)v2 ) { v3 = 4LL * (int)v2; v4 = (void *)operator new(v3); v5 = (char *)memset(v4, 0, v3); v1 = *a1; v6 = v5; } else { v3 = 0LL; v6 = 0LL; } v7 = (char **)(v1 + 24LL * ((int)v2 - 1)); v8 = v7[1]; v9 = *v7; v10 = (v8 - v9) >> 2; if ( v9 != v8 ) { if ( (unsigned long long)(v8 - v9) <= 0xC ) { *(_DWORD *)v6 = *(_DWORD *)v9; v11 = 1LL; if ( v10 <= 1 ) goto LABEL_8; goto LABEL_7; } v11 = 0LL; if ( (unsigned long long)(v6 - (v9 + 4)) <= 8 ) { do { LABEL_7: *(_DWORD *)&v6[4 * v11] = *(_DWORD *)&v9[4 * v11]; ++v11; } while ( v11 < v10 ); goto LABEL_8; } do { *(__m128i *)&v6[v11] = _mm_loadu_si128((const __m128i *)&v9[v11]); v11 += 16LL; } while ( v11 != 16 * (v10 >> 2) ); v42 = v10 & 0xFFFFFFFFFFFFFFFCLL; if ( (v10 & 3) != 0 ) { *(_DWORD *)&v6[4 * v42] = *(_DWORD *)&v9[4 * v42]; v43 = (int)v42 + 1; if ( v43 < v10 ) { *(_DWORD *)&v6[4 * v43] = *(_DWORD *)&v9[4 * v43]; if ( (int)v42 + 2 < v10 ) *(_DWORD *)&v6[4 * v43 + 4] = *(_DWORD *)&v9[4 * v43 + 4]; } } } LABEL_8: if ( (int)v2 > 1 ) { v12 = (long long *)(v1 + 24LL * (int)v2 - 48); v13 = (long long *)(24LL * (int)v2 - 72 - 24LL * (unsigned int)(v2 - 2) + v1); while ( 1 ) { while ( 1 ) { v14 = *v12; v15 = v12[1] - *v12; v16 = v15 >> 2; if ( *v12 != v12[1] ) break; LABEL_24: v12 -= 3; if ( v13 == v12 ) goto LABEL_25; } if ( (unsigned long long)v15 <= 0xC ) break; v17 = v16 - 1; if ( (unsigned long long)&v6[-v14 - 4] <= 8 ) goto LABEL_13; v29 = (v12[1] - *v12) >> 2; v30 = 0LL; do { v31 = _mm_loadu_si128((const __m128i *)&v6[v30]); v32 = _mm_cmpgt_epi32(_mm_loadu_si128((const __m128i *)&v6[v30 + 4]), v31); *(__m128i *)&v6[v30] = _mm_add_epi32( _mm_or_si128( _mm_andnot_si128(v32, _mm_loadu_si128((const __m128i *)&v6[v30 + 4])), _mm_and_si128(v31, v32)), _mm_loadu_si128((const __m128i *)(v14 + v30))); v30 += 16LL; } while ( v30 != 16 * (v29 >> 2) ); v33 = v29 & 0xFFFFFFFFFFFFFFFCLL; if ( (v29 & 3) == 0 ) goto LABEL_24; v34 = &v6[4 * v33]; v35 = (int)v33 + 1; v36 = 4 * v35; v37 = &v6[4 * v35]; v38 = *(_DWORD *)v37; if ( *(_DWORD *)v37 > *(_DWORD *)v34 ) v38 = *(_DWORD *)v34; *(_DWORD *)v34 = *(_DWORD *)(v14 + 4 * v33) + v38; if ( v35 >= v16 ) goto LABEL_24; v39 = &v6[v36 + 4]; v40 = *(_DWORD *)v39; if ( *(_DWORD *)v39 > *(_DWORD *)v37 ) v40 = *(_DWORD *)v37; *(_DWORD *)v37 = *(_DWORD *)(v14 + 4 * v35) + v40; if ( (int)v33 + 2 >= v16 ) goto LABEL_24; v41 = *(_DWORD *)&v6[v36 + 8]; if ( v41 > *(_DWORD *)v39 ) v41 = *(_DWORD *)v39; v12 -= 3; *(_DWORD *)v39 = *(_DWORD *)(v14 + v36 + 4) + v41; if ( v13 == v12 ) goto LABEL_25; } v17 = v16 - 1; if ( (unsigned long long)v15 > 8 ) { LABEL_13: v18 = *(_DWORD *)v6; v19 = 2LL; do { v20 = *(_DWORD *)&v6[4 * v19 - 4]; if ( v18 > v20 ) v18 = *(_DWORD *)&v6[4 * v19 - 4]; *(_DWORD *)&v6[4 * v19 - 8] = *(_DWORD *)(v14 + 4 * v19 - 8) + v18; v18 = *(_DWORD *)&v6[4 * v19]; if ( v20 > v18 ) v20 = *(_DWORD *)&v6[4 * v19]; *(_DWORD *)&v6[4 * v19 - 4] = *(_DWORD *)(v14 + 4 * v19 - 4) + v20; v21 = v19; v19 += 2LL; } while ( v21 + 1 < v17 ); v22 = v21; } else { v22 = 0; v21 = 0LL; } v23 = v22 + 1; do { v24 = &v6[4 * v21]; v25 = *(_DWORD *)&v6[4 * v23]; if ( v25 > *(_DWORD *)v24 ) v25 = *(_DWORD *)v24; v26 = *(_DWORD *)(v14 + 4 * v21) + v25; v21 = v23++; *(_DWORD *)v24 = v26; } while ( v21 < v16 ); goto LABEL_24; } LABEL_25: v27 = *(_DWORD *)v6; operator delete(v6, v3); return v27; }
func0: ENDBR64 MOV RAX,-0x5555555555555555 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R10,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] SUB RBP,R10 SAR RBP,0x3 IMUL RBP,RAX MOVSXD R13,EBP MOV RAX,R13 SHR RAX,0x3d JNZ 0x00101ba8 TEST R13,R13 JZ 0x00101b85 LEA RBX,[R13*0x4] MOV R12,RDI MOV RDI,RBX CALL 0x00101190 MOV RDX,RBX XOR ESI,ESI MOV RDI,RAX CALL 0x00101150 MOV R10,qword ptr [R12] MOV RDI,RAX LAB_00101898: LEA EAX,[RBP + -0x1] CDQE LEA RAX,[RAX + RAX*0x2] LEA RDX,[R10 + RAX*0x8] MOV RAX,qword ptr [RDX + 0x8] MOV RDX,qword ptr [RDX] MOV RCX,RAX SUB RCX,RDX MOV RSI,RCX SAR RSI,0x2 CMP RDX,RAX JZ 0x001018ef CMP RCX,0xc JBE 0x00101b8e LEA RAX,[RDX + 0x4] MOV R8,RDI SUB R8,RAX XOR EAX,EAX CMP R8,0x8 JA 0x00101b07 NOP LAB_001018e0: MOV ECX,dword ptr [RDX + RAX*0x4] MOV dword ptr [RDI + RAX*0x4],ECX ADD RAX,0x1 CMP RAX,RSI JC 0x001018e0 LAB_001018ef: CMP EBP,0x1 JLE 0x001019e1 LEA RAX,[R13 + R13*0x2] LEA EDX,[RBP + -0x2] MOV R11D,0x1 SHL RAX,0x3 LEA RDX,[RDX + RDX*0x2] LEA R9,[R10 + RAX*0x1 + -0x30] SHL RDX,0x3 SUB RAX,0x48 SUB RAX,RDX ADD R10,RAX NOP dword ptr [RAX] LAB_00101928: MOV RDX,qword ptr [R9 + 0x8] MOV RSI,qword ptr [R9] MOV RAX,RDX SUB RAX,RSI MOV R8,RAX SAR R8,0x2 CMP RSI,RDX JZ 0x001019d4 CMP RAX,0xc JBE 0x00101af0 LEA RCX,[RSI + 0x4] MOV RDX,RDI LEA RBP,[R8 + -0x1] SUB RDX,RCX CMP RDX,0x8 JA 0x00101a00 LAB_00101967: MOV EAX,dword ptr [RDI] MOV ECX,0x2 LAB_0010196e: MOV EDX,dword ptr [RDI + RCX*0x4 + -0x4] CMP EAX,EDX CMOVG EAX,EDX ADD EAX,dword ptr [RSI + RCX*0x4 + -0x8] MOV dword ptr [RDI + RCX*0x4 + -0x8],EAX MOV EAX,dword ptr [RDI + RCX*0x4] CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [RSI + RCX*0x4 + -0x4] MOV dword ptr [RDI + RCX*0x4 + -0x4],EDX MOV RDX,RCX LEA RCX,[RCX + 0x2] LEA R12,[RDX + 0x1] CMP R12,RBP JC 0x0010196e MOV ECX,EDX LAB_001019a1: ADD ECX,0x1 MOVSXD RCX,ECX NOP word ptr [RAX + RAX*0x1] LAB_001019b0: LEA RBP,[RDI + RDX*0x4] MOV EAX,dword ptr [RDI + RCX*0x4] MOV R12D,dword ptr [RBP] CMP EAX,R12D CMOVG EAX,R12D ADD EAX,dword ptr [RSI + RDX*0x4] MOV RDX,RCX ADD RCX,0x1 MOV dword ptr [RBP],EAX CMP RDX,R8 JC 0x001019b0 LAB_001019d4: SUB R9,0x18 CMP R10,R9 JNZ 0x00101928 LAB_001019e1: MOV EBP,dword ptr [RDI] MOV RSI,RBX CALL 0x001011a0 POP RBX MOV EAX,EBP POP RBP POP R12 POP R13 POP R14 RET LAB_00101a00: TEST RAX,RAX MOV RCX,R11 CMOVNZ RCX,R8 XOR EAX,EAX MOV RDX,RCX SHR RDX,0x2 SHL RDX,0x4 LAB_00101a17: MOVDQU XMM2,xmmword ptr [RDI + RAX*0x1] MOVDQU XMM0,xmmword ptr [RDI + RAX*0x1 + 0x4] MOVDQU XMM3,xmmword ptr [RDI + RAX*0x1 + 0x4] MOVDQU XMM4,xmmword ptr [RSI + RAX*0x1] PCMPGTD XMM0,XMM2 MOVDQA XMM1,XMM2 PAND XMM1,XMM0 PANDN XMM0,XMM3 POR XMM0,XMM1 PADDD XMM0,XMM4 MOVUPS xmmword ptr [RDI + RAX*0x1],XMM0 ADD RAX,0x10 CMP RAX,RDX JNZ 0x00101a17 MOV RAX,RCX AND RAX,-0x4 AND ECX,0x3 JZ 0x001019d4 LEA EBP,[RAX + 0x1] LEA R13,[RDI + RAX*0x4] MOVSXD RBP,EBP MOV R14D,dword ptr [R13] LEA RCX,[RBP*0x4] LEA R12,[RDI + RCX*0x1] MOV EDX,dword ptr [R12] CMP EDX,R14D CMOVG EDX,R14D ADD EDX,dword ptr [RSI + RAX*0x4] MOV dword ptr [R13],EDX CMP RBP,R8 JNC 0x001019d4 LEA R13,[RDI + RCX*0x1 + 0x4] MOV R14D,dword ptr [R12] MOV EDX,dword ptr [R13] CMP EDX,R14D CMOVG EDX,R14D ADD EAX,0x2 ADD EDX,dword ptr [RSI + RBP*0x4] CDQE MOV dword ptr [R12],EDX CMP RAX,R8 JNC 0x001019d4 MOV EAX,dword ptr [RDI + RCX*0x1 + 0x8] MOV EDX,dword ptr [R13] CMP EAX,EDX CMOVG EAX,EDX SUB R9,0x18 ADD EAX,dword ptr [RSI + RCX*0x1 + 0x4] MOV dword ptr [R13],EAX CMP R10,R9 JNZ 0x00101928 JMP 0x001019e1 LAB_00101af0: LEA RBP,[R8 + -0x1] CMP RAX,0x8 JA 0x00101967 XOR ECX,ECX XOR EDX,EDX JMP 0x001019a1 LAB_00101b07: TEST RCX,RCX MOV R8D,0x1 CMOVNZ R8,RSI MOV RCX,R8 SHR RCX,0x2 SHL RCX,0x4 NOP LAB_00101b20: MOVDQU XMM5,xmmword ptr [RDX + RAX*0x1] MOVUPS xmmword ptr [RDI + RAX*0x1],XMM5 ADD RAX,0x10 CMP RAX,RCX JNZ 0x00101b20 MOV RAX,R8 AND RAX,-0x4 AND R8D,0x3 JZ 0x001018ef MOV ECX,dword ptr [RDX + RAX*0x4] MOV dword ptr [RDI + RAX*0x4],ECX LEA ECX,[RAX + 0x1] MOVSXD RCX,ECX CMP RCX,RSI JNC 0x001018ef MOV R9D,dword ptr [RDX + RCX*0x4] ADD EAX,0x2 LEA R8,[RCX*0x4] CDQE MOV dword ptr [RDI + RCX*0x4],R9D CMP RAX,RSI JNC 0x001018ef MOV EAX,dword ptr [RDX + R8*0x1 + 0x4] MOV dword ptr [RDI + R8*0x1 + 0x4],EAX JMP 0x001018ef LAB_00101b85: XOR EBX,EBX XOR EDI,EDI JMP 0x00101898 LAB_00101b8e: XOR EAX,EAX MOV ECX,dword ptr [RDX + RAX*0x4] MOV dword ptr [RDI + RAX*0x4],ECX ADD RAX,0x1 CMP RAX,RSI JC 0x001018e0 JMP 0x001018ef LAB_00101ba8: LEA RDI,[0x102008] CALL 0x00101140 NOP word ptr CS:[RAX + RAX*0x1] NOP
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ void * func0(vector param_1) { int8 *puVar1; int *piVar2; int *piVar3; uint *puVar4; uint *puVar5; uint uVar6; uint uVar7; uint uVar8; uint uVar9; int iVar10; int iVar11; int8 uVar12; uint uVar13; void *pvVar14; uint *puVar15; ulong uVar16; long lVar17; void *extraout_RAX; ulong uVar18; uint uVar19; ulong __n; int iVar20; ulong uVar21; int4 in_register_0000003c; long *plVar22; char *pcVar23; ulong uVar24; long lVar25; long *plVar26; ulong uVar27; uint uVar28; uint uVar29; uint uVar30; uint uVar31; plVar22 = (long *)CONCAT44(in_register_0000003c,param_1); lVar25 = *plVar22; iVar20 = (int)(plVar22[1] - lVar25 >> 3) * -0x55555555; uVar27 = (ulong)iVar20; if (uVar27 >> 0x3d != 0) { pcVar23 = "cannot create std::vector larger than max_size()"; std::__throw_length_error("cannot create std::vector larger than max_size()"); pvVar14 = *(void **)pcVar23; if (pvVar14 == (void *)0x0) { return pvVar14; } operator_delete(pvVar14,*(long *)(pcVar23 + 0x10) - (long)pvVar14); return extraout_RAX; } if (uVar27 == 0) { __n = 0; puVar15 = (uint *)0x0; } else { __n = uVar27 * 4; pvVar14 = operator_new(__n); puVar15 = (uint *)memset(pvVar14,0,__n); lVar25 = *plVar22; } puVar1 = (int8 *)(lVar25 + (long)(iVar20 + -1) * 0x18); puVar4 = (uint *)puVar1[1]; puVar5 = (uint *)*puVar1; uVar18 = (long)puVar4 - (long)puVar5; uVar21 = (long)uVar18 >> 2; if (puVar5 != puVar4) { if (uVar18 < 0xd) { *puVar15 = *puVar5; uVar16 = 1; if (uVar21 < 2) goto LAB_001018ef; } else { uVar16 = 0; if (8 < (ulong)((long)puVar15 - (long)(puVar5 + 1))) { uVar24 = 1; if (uVar18 != 0) { uVar24 = uVar21; } do { uVar12 = ((int8 *)((long)puVar5 + uVar16))[1]; *(int8 *)((long)puVar15 + uVar16) = *(int8 *)((long)puVar5 + uVar16); ((int8 *)((long)puVar15 + uVar16))[1] = uVar12; uVar16 = uVar16 + 0x10; } while (uVar16 != (uVar24 >> 2) * 0x10); uVar18 = uVar24 & 0xfffffffffffffffc; if ((uVar24 & 3) != 0) { puVar15[uVar18] = puVar5[uVar18]; uVar16 = (ulong)((int)uVar18 + 1); if (uVar16 < uVar21) { puVar15[uVar16] = puVar5[uVar16]; if ((ulong)(long)((int)uVar18 + 2) < uVar21) { puVar15[uVar16 + 1] = puVar5[uVar16 + 1]; } } } goto LAB_001018ef; } } do { puVar15[uVar16] = puVar5[uVar16]; uVar16 = uVar16 + 1; } while (uVar16 < uVar21); } LAB_001018ef: if (1 < iVar20) { plVar22 = (long *)(lVar25 + -0x30 + uVar27 * 0x18); plVar26 = (long *)(lVar25 + uVar27 * 0x18 + -0x48 + (ulong)(iVar20 - 2) * -0x18); LAB_00101928: do { lVar25 = *plVar22; uVar27 = plVar22[1] - lVar25; uVar18 = (long)uVar27 >> 2; if (lVar25 == plVar22[1]) goto LAB_001019d4; if (uVar27 < 0xd) { if (uVar27 < 9) { iVar20 = 0; uVar21 = 0; } else { LAB_00101967: uVar13 = *puVar15; uVar27 = 2; do { uVar21 = uVar27; uVar19 = puVar15[uVar21 - 1]; if ((int)uVar19 < (int)uVar13) { uVar13 = uVar19; } puVar15[uVar21 - 2] = uVar13 + *(int *)(lVar25 + -8 + uVar21 * 4); uVar13 = puVar15[uVar21]; if ((int)uVar13 < (int)uVar19) { uVar19 = uVar13; } puVar15[uVar21 - 1] = uVar19 + *(int *)(lVar25 + -4 + uVar21 * 4); uVar27 = uVar21 + 2; } while (uVar21 + 1 < uVar18 - 1); iVar20 = (int)uVar21; } uVar27 = (long)(iVar20 + 1); do { uVar16 = uVar27; uVar13 = puVar15[uVar21]; uVar19 = puVar15[uVar16]; if ((int)uVar13 < (int)puVar15[uVar16]) { uVar19 = uVar13; } puVar15[uVar21] = uVar19 + *(int *)(lVar25 + uVar21 * 4); uVar27 = uVar16 + 1; uVar21 = uVar16; } while (uVar16 < uVar18); goto LAB_001019d4; } if ((ulong)((long)puVar15 - (lVar25 + 4)) < 9) goto LAB_00101967; uVar21 = 1; if (uVar27 != 0) { uVar21 = uVar18; } lVar17 = 0; do { puVar4 = (uint *)((long)puVar15 + lVar17); uVar13 = puVar4[1]; uVar19 = puVar4[2]; uVar6 = puVar4[3]; piVar3 = (int *)((long)puVar15 + lVar17 + 4); puVar5 = (uint *)((long)puVar15 + lVar17 + 4); uVar7 = puVar5[1]; uVar8 = puVar5[2]; uVar9 = puVar5[3]; piVar2 = (int *)(lVar25 + lVar17); iVar20 = piVar2[1]; iVar10 = piVar2[2]; iVar11 = piVar2[3]; uVar28 = -(uint)((int)*puVar4 < *piVar3); uVar29 = -(uint)((int)uVar13 < piVar3[1]); uVar30 = -(uint)((int)uVar19 < piVar3[2]); uVar31 = -(uint)((int)uVar6 < piVar3[3]); piVar3 = (int *)((long)puVar15 + lVar17); *piVar3 = (~uVar28 & *puVar5 | *puVar4 & uVar28) + *piVar2; piVar3[1] = (~uVar29 & uVar7 | uVar13 & uVar29) + iVar20; piVar3[2] = (~uVar30 & uVar8 | uVar19 & uVar30) + iVar10; piVar3[3] = (~uVar31 & uVar9 | uVar6 & uVar31) + iVar11; lVar17 = lVar17 + 0x10; } while (lVar17 != (uVar21 >> 2) * 0x10); uVar27 = uVar21 & 0xfffffffffffffffc; if ((uVar21 & 3) == 0) { LAB_001019d4: plVar22 = plVar22 + -3; if (plVar26 == plVar22) break; goto LAB_00101928; } uVar21 = (ulong)((int)uVar27 + 1); uVar13 = puVar15[uVar27]; puVar4 = puVar15 + uVar21; uVar19 = *puVar4; if ((int)uVar13 < (int)*puVar4) { uVar19 = uVar13; } puVar15[uVar27] = uVar19 + *(int *)(lVar25 + uVar27 * 4); if (uVar18 <= uVar21) goto LAB_001019d4; puVar5 = puVar15 + uVar21 + 1; uVar13 = *puVar5; if ((int)*puVar4 < (int)*puVar5) { uVar13 = *puVar4; } *puVar4 = uVar13 + *(int *)(lVar25 + uVar21 * 4); if (uVar18 <= (ulong)(long)((int)uVar27 + 2)) goto LAB_001019d4; uVar13 = puVar15[uVar21 + 2]; if ((int)*puVar5 < (int)puVar15[uVar21 + 2]) { uVar13 = *puVar5; } plVar22 = plVar22 + -3; *puVar5 = uVar13 + *(int *)(lVar25 + 4 + uVar21 * 4); } while (plVar26 != plVar22); } uVar13 = *puVar15; operator_delete(puVar15,__n); return (void *)(ulong)uVar13; }
3,896
func0
#include <assert.h> #define R 3 #define C 3
int func0(int cost[R][C], int m, int n) { int tc[R][C]; tc[0][0] = cost[0][0]; for (int i = 1; i <= m; ++i) { tc[i][0] = tc[i - 1][0] + cost[i][0]; } for (int j = 1; j <= n; ++j) { tc[0][j] = tc[0][j - 1] + cost[0][j]; } for (int i = 1; i <= m; ++i) { for (int j = 1; j <= n; ++j) { int min_val = tc[i - 1][j - 1]; if (tc[i - 1][j] < min_val) min_val = tc[i - 1][j]; if (tc[i][j - 1] < min_val) min_val = tc[i][j - 1]; tc[i][j] = min_val + cost[i][j]; } } return tc[m][n]; }
int main() { int cost1[R][C] = {{1, 2, 3}, {4, 8, 2}, {1, 5, 3}}; int cost2[R][C] = {{2, 3, 4}, {5, 9, 3}, {2, 6, 4}}; int cost3[R][C] = {{3, 4, 5}, {6, 10, 4}, {3, 7, 5}}; assert(func0(cost1, 2, 2) == 8); assert(func0(cost2, 2, 2) == 12); assert(func0(cost3, 2, 2) == 16); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x60,%rsp mov %rdi,-0x58(%rbp) mov %esi,-0x5c(%rbp) mov %edx,-0x60(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax mov -0x58(%rbp),%rax mov (%rax),%eax mov %eax,-0x30(%rbp) movl $0x1,-0x44(%rbp) jmp 1200 <func0+0x97> mov -0x44(%rbp),%eax sub $0x1,%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x2,%rax add %rbp,%rax sub $0x30,%rax mov (%rax),%ecx mov -0x44(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x2,%rax mov %rax,%rdx mov -0x58(%rbp),%rax add %rdx,%rax mov (%rax),%eax add %eax,%ecx mov -0x44(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x2,%rax add %rbp,%rax sub $0x30,%rax mov %ecx,(%rax) addl $0x1,-0x44(%rbp) mov -0x44(%rbp),%eax cmp -0x5c(%rbp),%eax jle 11a0 <func0+0x37> movl $0x1,-0x40(%rbp) jmp 123a <func0+0xd1> mov -0x40(%rbp),%eax sub $0x1,%eax cltq mov -0x30(%rbp,%rax,4),%ecx mov -0x58(%rbp),%rax mov -0x40(%rbp),%edx movslq %edx,%rdx mov (%rax,%rdx,4),%eax lea (%rcx,%rax,1),%edx mov -0x40(%rbp),%eax cltq mov %edx,-0x30(%rbp,%rax,4) addl $0x1,-0x40(%rbp) mov -0x40(%rbp),%eax cmp -0x60(%rbp),%eax jle 1211 <func0+0xa8> movl $0x1,-0x3c(%rbp) jmpq 1366 <func0+0x1fd> movl $0x1,-0x38(%rbp) jmpq 1356 <func0+0x1ed> mov -0x3c(%rbp),%eax lea -0x1(%rax),%edx mov -0x38(%rbp),%eax sub $0x1,%eax movslq %eax,%rcx movslq %edx,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax mov %eax,-0x34(%rbp) mov -0x3c(%rbp),%eax lea -0x1(%rax),%edx mov -0x38(%rbp),%eax movslq %eax,%rcx movslq %edx,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax cmp %eax,-0x34(%rbp) jle 12c5 <func0+0x15c> mov -0x3c(%rbp),%eax lea -0x1(%rax),%edx mov -0x38(%rbp),%eax movslq %eax,%rcx movslq %edx,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax mov %eax,-0x34(%rbp) mov -0x38(%rbp),%eax sub $0x1,%eax movslq %eax,%rcx mov -0x3c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax cmp %eax,-0x34(%rbp) jle 130b <func0+0x1a2> mov -0x38(%rbp),%eax sub $0x1,%eax movslq %eax,%rcx mov -0x3c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax mov %eax,-0x34(%rbp) mov -0x3c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x2,%rax mov %rax,%rdx mov -0x58(%rbp),%rax add %rax,%rdx mov -0x38(%rbp),%eax cltq mov (%rdx,%rax,4),%edx mov -0x34(%rbp),%eax lea (%rdx,%rax,1),%ecx mov -0x38(%rbp),%eax movslq %eax,%rsi mov -0x3c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rsi,%rax mov %ecx,-0x30(%rbp,%rax,4) addl $0x1,-0x38(%rbp) mov -0x38(%rbp),%eax cmp -0x60(%rbp),%eax jle 125a <func0+0xf1> addl $0x1,-0x3c(%rbp) mov -0x3c(%rbp),%eax cmp -0x5c(%rbp),%eax jle 124e <func0+0xe5> mov -0x60(%rbp),%eax movslq %eax,%rcx mov -0x5c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax add %rcx,%rax mov -0x30(%rbp,%rax,4),%eax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi je 13a2 <func0+0x239> callq 1060 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 60h mov [rbp+var_58], rdi mov [rbp+var_5C], esi mov [rbp+var_60], edx mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rax, [rbp+var_58] mov eax, [rax] mov [rbp+var_30], eax mov [rbp+var_44], 1 jmp short loc_1200 loc_11A0: mov eax, [rbp+var_44] sub eax, 1 movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 2 add rax, rbp sub rax, 30h ; '0' mov ecx, [rax] mov eax, [rbp+var_44] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 2 mov rdx, rax mov rax, [rbp+var_58] add rax, rdx mov eax, [rax] add ecx, eax mov eax, [rbp+var_44] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 2 add rax, rbp sub rax, 30h ; '0' mov [rax], ecx add [rbp+var_44], 1 loc_1200: mov eax, [rbp+var_44] cmp eax, [rbp+var_5C] jle short loc_11A0 mov [rbp+var_40], 1 jmp short loc_123A loc_1211: mov eax, [rbp+var_40] sub eax, 1 cdqe mov ecx, [rbp+rax*4+var_30] mov rax, [rbp+var_58] mov edx, [rbp+var_40] movsxd rdx, edx mov eax, [rax+rdx*4] lea edx, [rcx+rax] mov eax, [rbp+var_40] cdqe mov [rbp+rax*4+var_30], edx add [rbp+var_40], 1 loc_123A: mov eax, [rbp+var_40] cmp eax, [rbp+var_60] jle short loc_1211 mov [rbp+var_3C], 1 jmp loc_1366 loc_124E: mov [rbp+var_38], 1 jmp loc_1356 loc_125A: mov eax, [rbp+var_3C] lea edx, [rax-1] mov eax, [rbp+var_38] sub eax, 1 movsxd rcx, eax movsxd rdx, edx mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] mov [rbp+var_34], eax mov eax, [rbp+var_3C] lea edx, [rax-1] mov eax, [rbp+var_38] movsxd rcx, eax movsxd rdx, edx mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] cmp [rbp+var_34], eax jle short loc_12C5 mov eax, [rbp+var_3C] lea edx, [rax-1] mov eax, [rbp+var_38] movsxd rcx, eax movsxd rdx, edx mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] mov [rbp+var_34], eax loc_12C5: mov eax, [rbp+var_38] sub eax, 1 movsxd rcx, eax mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] cmp [rbp+var_34], eax jle short loc_130B mov eax, [rbp+var_38] sub eax, 1 movsxd rcx, eax mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] mov [rbp+var_34], eax loc_130B: mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 2 mov rdx, rax mov rax, [rbp+var_58] add rdx, rax mov eax, [rbp+var_38] cdqe mov edx, [rdx+rax*4] mov eax, [rbp+var_34] lea ecx, [rdx+rax] mov eax, [rbp+var_38] movsxd rsi, eax mov eax, [rbp+var_3C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx add rax, rsi mov [rbp+rax*4+var_30], ecx add [rbp+var_38], 1 loc_1356: mov eax, [rbp+var_38] cmp eax, [rbp+var_60] jle loc_125A add [rbp+var_3C], 1 loc_1366: mov eax, [rbp+var_3C] cmp eax, [rbp+var_5C] jle loc_124E mov eax, [rbp+var_60] movsxd rcx, eax mov eax, [rbp+var_5C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx add rax, rcx mov eax, [rbp+rax*4+var_30] mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_13A2 call ___stack_chk_fail locret_13A2: leave retn
long long func0(_DWORD *a1, int a2, int a3) { int i; // [rsp+1Ch] [rbp-44h] int j; // [rsp+20h] [rbp-40h] int k; // [rsp+24h] [rbp-3Ch] int m; // [rsp+28h] [rbp-38h] int v8; // [rsp+2Ch] [rbp-34h] _DWORD v9[10]; // [rsp+30h] [rbp-30h] unsigned long long v10; // [rsp+58h] [rbp-8h] v10 = __readfsqword(0x28u); v9[0] = *a1; for ( i = 1; i <= a2; ++i ) v9[3 * i] = a1[3 * i] + v9[3 * i - 3]; for ( j = 1; j <= a3; ++j ) v9[j] = v9[j - 1] + a1[j]; for ( k = 1; k <= a2; ++k ) { for ( m = 1; m <= a3; ++m ) { v8 = v9[3 * k - 4 + m]; if ( v8 > v9[3 * k - 3 + m] ) v8 = v9[3 * k - 3 + m]; if ( v8 > v9[3 * k - 1 + m] ) v8 = v9[3 * k - 1 + m]; v9[3 * k + m] = a1[3 * k + m] + v8; } } return (unsigned int)v9[3 * a2 + a3]; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x60 MOV qword ptr [RBP + -0x58],RDI MOV dword ptr [RBP + -0x5c],ESI MOV dword ptr [RBP + -0x60],EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x30],EAX MOV dword ptr [RBP + -0x44],0x1 JMP 0x00101200 LAB_001011a0: MOV EAX,dword ptr [RBP + -0x44] SUB EAX,0x1 MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x2 ADD RAX,RBP SUB RAX,0x30 MOV ECX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x44] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x2 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x58] ADD RAX,RDX MOV EAX,dword ptr [RAX] ADD ECX,EAX MOV EAX,dword ptr [RBP + -0x44] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x2 ADD RAX,RBP SUB RAX,0x30 MOV dword ptr [RAX],ECX ADD dword ptr [RBP + -0x44],0x1 LAB_00101200: MOV EAX,dword ptr [RBP + -0x44] CMP EAX,dword ptr [RBP + -0x5c] JLE 0x001011a0 MOV dword ptr [RBP + -0x40],0x1 JMP 0x0010123a LAB_00101211: MOV EAX,dword ptr [RBP + -0x40] SUB EAX,0x1 CDQE MOV ECX,dword ptr [RBP + RAX*0x4 + -0x30] MOV RAX,qword ptr [RBP + -0x58] MOV EDX,dword ptr [RBP + -0x40] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] LEA EDX,[RCX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x40] CDQE MOV dword ptr [RBP + RAX*0x4 + -0x30],EDX ADD dword ptr [RBP + -0x40],0x1 LAB_0010123a: MOV EAX,dword ptr [RBP + -0x40] CMP EAX,dword ptr [RBP + -0x60] JLE 0x00101211 MOV dword ptr [RBP + -0x3c],0x1 JMP 0x00101366 LAB_0010124e: MOV dword ptr [RBP + -0x38],0x1 JMP 0x00101356 LAB_0010125a: MOV EAX,dword ptr [RBP + -0x3c] LEA EDX,[RAX + -0x1] MOV EAX,dword ptr [RBP + -0x38] SUB EAX,0x1 MOVSXD RCX,EAX MOVSXD RDX,EDX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] MOV dword ptr [RBP + -0x34],EAX MOV EAX,dword ptr [RBP + -0x3c] LEA EDX,[RAX + -0x1] MOV EAX,dword ptr [RBP + -0x38] MOVSXD RCX,EAX MOVSXD RDX,EDX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] CMP dword ptr [RBP + -0x34],EAX JLE 0x001012c5 MOV EAX,dword ptr [RBP + -0x3c] LEA EDX,[RAX + -0x1] MOV EAX,dword ptr [RBP + -0x38] MOVSXD RCX,EAX MOVSXD RDX,EDX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] MOV dword ptr [RBP + -0x34],EAX LAB_001012c5: MOV EAX,dword ptr [RBP + -0x38] SUB EAX,0x1 MOVSXD RCX,EAX MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] CMP dword ptr [RBP + -0x34],EAX JLE 0x0010130b MOV EAX,dword ptr [RBP + -0x38] SUB EAX,0x1 MOVSXD RCX,EAX MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] MOV dword ptr [RBP + -0x34],EAX LAB_0010130b: MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x2 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x58] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x38] CDQE MOV EDX,dword ptr [RDX + RAX*0x4] MOV EAX,dword ptr [RBP + -0x34] LEA ECX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x38] MOVSXD RSI,EAX MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RSI MOV dword ptr [RBP + RAX*0x4 + -0x30],ECX ADD dword ptr [RBP + -0x38],0x1 LAB_00101356: MOV EAX,dword ptr [RBP + -0x38] CMP EAX,dword ptr [RBP + -0x60] JLE 0x0010125a ADD dword ptr [RBP + -0x3c],0x1 LAB_00101366: MOV EAX,dword ptr [RBP + -0x3c] CMP EAX,dword ptr [RBP + -0x5c] JLE 0x0010124e MOV EAX,dword ptr [RBP + -0x60] MOVSXD RCX,EAX MOV EAX,dword ptr [RBP + -0x5c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX ADD RAX,RCX MOV EAX,dword ptr [RBP + RAX*0x4 + -0x30] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x001013a2 CALL 0x00101060 LAB_001013a2: LEAVE RET
int func0(int *param_1,int param_2,int param_3) { long in_FS_OFFSET; int local_4c; int local_48; int local_44; int local_40; int local_3c; int local_38 [10]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38[0] = *param_1; for (local_4c = 1; local_4c <= param_2; local_4c = local_4c + 1) { local_38[(long)local_4c * 3] = local_38[(long)(local_4c + -1) * 3] + param_1[(long)local_4c * 3] ; } for (local_48 = 1; local_48 <= param_3; local_48 = local_48 + 1) { local_38[local_48] = local_38[local_48 + -1] + param_1[local_48]; } for (local_44 = 1; local_44 <= param_2; local_44 = local_44 + 1) { for (local_40 = 1; local_40 <= param_3; local_40 = local_40 + 1) { local_3c = local_38[(long)(local_44 + -1) * 3 + (long)(local_40 + -1)]; if (local_38[(long)(local_44 + -1) * 3 + (long)local_40] < local_3c) { local_3c = local_38[(long)(local_44 + -1) * 3 + (long)local_40]; } if (local_38[(long)local_44 * 3 + (long)(local_40 + -1)] < local_3c) { local_3c = local_38[(long)local_44 * 3 + (long)(local_40 + -1)]; } local_38[(long)local_44 * 3 + (long)local_40] = param_1[(long)local_44 * 3 + (long)local_40] + local_3c; } } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return local_38[(long)param_2 * 3 + (long)param_3]; }
3,897
func0
#include <assert.h> #define R 3 #define C 3
int func0(int cost[R][C], int m, int n) { int tc[R][C]; tc[0][0] = cost[0][0]; for (int i = 1; i <= m; ++i) { tc[i][0] = tc[i - 1][0] + cost[i][0]; } for (int j = 1; j <= n; ++j) { tc[0][j] = tc[0][j - 1] + cost[0][j]; } for (int i = 1; i <= m; ++i) { for (int j = 1; j <= n; ++j) { int min_val = tc[i - 1][j - 1]; if (tc[i - 1][j] < min_val) min_val = tc[i - 1][j]; if (tc[i][j - 1] < min_val) min_val = tc[i][j - 1]; tc[i][j] = min_val + cost[i][j]; } } return tc[m][n]; }
int main() { int cost1[R][C] = {{1, 2, 3}, {4, 8, 2}, {1, 5, 3}}; int cost2[R][C] = {{2, 3, 4}, {5, 9, 3}, {2, 6, 4}}; int cost3[R][C] = {{3, 4, 5}, {6, 10, 4}, {3, 7, 5}}; assert(func0(cost1, 2, 2) == 8); assert(func0(cost2, 2, 2) == 12); assert(func0(cost3, 2, 2) == 16); return 0; }
O1
c
func0: endbr64 sub $0x38,%rsp mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax mov (%rdi),%eax mov %eax,(%rsp) test %esi,%esi jle 1219 <func0+0xb0> mov %eax,%ecx add 0xc(%rdi),%ecx mov %ecx,0xc(%rsp) cmp $0x1,%esi jle 11a3 <func0+0x3a> add 0x18(%rdi),%ecx mov %ecx,0x18(%rsp) test %edx,%edx jle 11be <func0+0x55> add 0x4(%rdi),%eax mov %eax,0x4(%rsp) cmp $0x1,%edx jle 11ba <func0+0x51> add 0x8(%rdi),%eax mov %eax,0x8(%rsp) test %esi,%esi jle 121d <func0+0xb4> mov %rsp,%rax add $0x10,%rdi mov $0x1,%r9d jmp 11de <func0+0x75> add $0x1,%r9d add $0xc,%rax add $0xc,%rdi cmp %r9d,%esi jl 121d <func0+0xb4> test %edx,%edx jle 11cd <func0+0x64> mov 0x4(%rax),%ecx cmp %ecx,(%rax) mov %ecx,%r8d cmovle (%rax),%r8d cmp %r8d,0xc(%rax) cmovle 0xc(%rax),%r8d add (%rdi),%r8d mov %r8d,0x10(%rax) cmp $0x1,%edx jle 11cd <func0+0x64> cmp %ecx,0x8(%rax) cmovle 0x8(%rax),%ecx cmp %r8d,%ecx cmovg %r8d,%ecx add 0x4(%rdi),%ecx mov %ecx,0x14(%rax) jmp 11cd <func0+0x64> test %edx,%edx jg 11a7 <func0+0x3e> movslq %edx,%rdx movslq %esi,%rsi lea (%rsi,%rsi,2),%rax add %rax,%rdx mov (%rsp,%rdx,4),%eax mov 0x28(%rsp),%rsi xor %fs:0x28,%rsi jne 1242 <func0+0xd9> add $0x38,%rsp retq callq 1060 <__stack_chk_fail@plt>
func0: endbr64 sub rsp, 38h mov r8d, edx mov rax, fs:28h mov [rsp+38h+var_10], rax xor eax, eax mov eax, [rdi] mov [rsp+38h+var_38], eax test esi, esi jle loc_1220 mov edx, eax add edx, [rdi+0Ch] mov [rsp+38h+var_2C], edx cmp esi, 1 jle short loc_11A6 add edx, [rdi+18h] mov [rsp+38h+var_20], edx loc_11A6: test r8d, r8d jle short loc_11C3 loc_11AB: add eax, [rdi+4] mov [rsp+38h+var_34], eax cmp r8d, 1 jle short loc_11BF add eax, [rdi+8] mov [rsp+38h+var_30], eax loc_11BF: test esi, esi jle short loc_1224 loc_11C3: mov rcx, rsp add rdi, 10h mov r9d, 1 jmp short loc_11E3 loc_11D2: add r9d, 1 add rcx, 0Ch add rdi, 0Ch cmp esi, r9d jl short loc_1224 loc_11E3: test r8d, r8d jle short loc_11D2 mov edx, [rcx+4] mov eax, [rcx] cmp edx, eax cmovle eax, edx mov r10d, [rcx+0Ch] cmp eax, r10d cmovg eax, r10d add eax, [rdi] mov [rcx+10h], eax cmp r8d, 1 jle short loc_11D2 mov r10d, [rcx+8] cmp edx, r10d cmovg edx, r10d cmp edx, eax cmovg edx, eax add edx, [rdi+4] mov [rcx+14h], edx jmp short loc_11D2 loc_1220: test edx, edx jg short loc_11AB loc_1224: movsxd r8, r8d movsxd rsi, esi lea rax, [rsi+rsi*2] add rax, r8 mov eax, [rsp+rax*4+38h+var_38] mov rdx, [rsp+38h+var_10] sub rdx, fs:28h jnz short loc_1249 add rsp, 38h retn loc_1249: call ___stack_chk_fail
long long func0(int *a1, int a2, int a3) { int v4; // eax int v5; // edx int v6; // eax int *v7; // rcx _DWORD *v8; // rdi int i; // r9d int v10; // edx int v11; // eax int v12; // eax _DWORD v14[10]; // [rsp+0h] [rbp-38h] BYREF unsigned long long v15; // [rsp+28h] [rbp-10h] v15 = __readfsqword(0x28u); v4 = *a1; v14[0] = *a1; if ( a2 <= 0 ) { if ( a3 <= 0 ) return (unsigned int)v14[3 * a2 + a3]; } else { v5 = a1[3] + v4; v14[3] = v5; if ( a2 > 1 ) v14[6] = a1[6] + v5; if ( a3 <= 0 ) goto LABEL_8; } v6 = a1[1] + v4; v14[1] = v6; if ( a3 > 1 ) v14[2] = a1[2] + v6; if ( a2 > 0 ) { LABEL_8: v7 = v14; v8 = a1 + 4; for ( i = 1; i <= a2; ++i ) { if ( a3 > 0 ) { v10 = v7[1]; v11 = *v7; if ( v10 <= *v7 ) v11 = v7[1]; if ( v11 > v7[3] ) v11 = v7[3]; v12 = *v8 + v11; v7[4] = v12; if ( a3 > 1 ) { if ( v10 > v7[2] ) v10 = v7[2]; if ( v10 > v12 ) v10 = v12; v7[5] = v8[1] + v10; } } v7 += 3; v8 += 3; } } return (unsigned int)v14[3 * a2 + a3]; }
func0: ENDBR64 SUB RSP,0x38 MOV R8D,EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX XOR EAX,EAX MOV EAX,dword ptr [RDI] MOV dword ptr [RSP],EAX TEST ESI,ESI JLE 0x00101220 MOV EDX,EAX ADD EDX,dword ptr [RDI + 0xc] MOV dword ptr [RSP + 0xc],EDX CMP ESI,0x1 JLE 0x001011a6 ADD EDX,dword ptr [RDI + 0x18] MOV dword ptr [RSP + 0x18],EDX LAB_001011a6: TEST R8D,R8D JLE 0x001011c3 LAB_001011ab: ADD EAX,dword ptr [RDI + 0x4] MOV dword ptr [RSP + 0x4],EAX CMP R8D,0x1 JLE 0x001011bf ADD EAX,dword ptr [RDI + 0x8] MOV dword ptr [RSP + 0x8],EAX LAB_001011bf: TEST ESI,ESI JLE 0x00101224 LAB_001011c3: MOV RCX,RSP ADD RDI,0x10 MOV R9D,0x1 JMP 0x001011e3 LAB_001011d2: ADD R9D,0x1 ADD RCX,0xc ADD RDI,0xc CMP ESI,R9D JL 0x00101224 LAB_001011e3: TEST R8D,R8D JLE 0x001011d2 MOV EDX,dword ptr [RCX + 0x4] MOV EAX,dword ptr [RCX] CMP EDX,EAX CMOVLE EAX,EDX MOV R10D,dword ptr [RCX + 0xc] CMP EAX,R10D CMOVG EAX,R10D ADD EAX,dword ptr [RDI] MOV dword ptr [RCX + 0x10],EAX CMP R8D,0x1 JLE 0x001011d2 MOV R10D,dword ptr [RCX + 0x8] CMP EDX,R10D CMOVG EDX,R10D CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [RDI + 0x4] MOV dword ptr [RCX + 0x14],EDX JMP 0x001011d2 LAB_00101220: TEST EDX,EDX JG 0x001011ab LAB_00101224: MOVSXD R8,R8D MOVSXD RSI,ESI LEA RAX,[RSI + RSI*0x2] ADD RAX,R8 MOV EAX,dword ptr [RSP + RAX*0x4] MOV RDX,qword ptr [RSP + 0x28] SUB RDX,qword ptr FS:[0x28] JNZ 0x00101249 ADD RSP,0x38 RET LAB_00101249: CALL 0x00101060
int func0(int *param_1,int param_2,int param_3) { int iVar1; int *piVar2; int iVar3; int iVar4; long in_FS_OFFSET; int local_38 [6]; int local_20; long local_10; piVar2 = local_38; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38[0] = *param_1; if (param_2 < 1) { if (param_3 < 1) goto LAB_00101224; LAB_001011ab: local_38[1] = local_38[0] + param_1[1]; if (1 < param_3) { local_38[2] = local_38[0] + param_1[1] + param_1[2]; } if (param_2 < 1) goto LAB_00101224; } else { local_38[3] = local_38[0] + param_1[3]; if (1 < param_2) { local_20 = local_38[0] + param_1[3] + param_1[6]; } if (0 < param_3) goto LAB_001011ab; } param_1 = param_1 + 4; iVar4 = 1; do { if (0 < param_3) { iVar3 = piVar2[1]; iVar1 = *piVar2; if (iVar3 <= *piVar2) { iVar1 = iVar3; } if (piVar2[3] < iVar1) { iVar1 = piVar2[3]; } iVar1 = iVar1 + *param_1; piVar2[4] = iVar1; if (1 < param_3) { if (piVar2[2] < iVar3) { iVar3 = piVar2[2]; } if (iVar1 < iVar3) { iVar3 = iVar1; } piVar2[5] = iVar3 + param_1[1]; } } iVar4 = iVar4 + 1; piVar2 = piVar2 + 3; param_1 = param_1 + 3; } while (iVar4 <= param_2); LAB_00101224: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return local_38[(long)param_2 * 3 + (long)param_3]; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,898
func0
#include <assert.h> #define R 3 #define C 3
int func0(int cost[R][C], int m, int n) { int tc[R][C]; tc[0][0] = cost[0][0]; for (int i = 1; i <= m; ++i) { tc[i][0] = tc[i - 1][0] + cost[i][0]; } for (int j = 1; j <= n; ++j) { tc[0][j] = tc[0][j - 1] + cost[0][j]; } for (int i = 1; i <= m; ++i) { for (int j = 1; j <= n; ++j) { int min_val = tc[i - 1][j - 1]; if (tc[i - 1][j] < min_val) min_val = tc[i - 1][j]; if (tc[i][j - 1] < min_val) min_val = tc[i][j - 1]; tc[i][j] = min_val + cost[i][j]; } } return tc[m][n]; }
int main() { int cost1[R][C] = {{1, 2, 3}, {4, 8, 2}, {1, 5, 3}}; int cost2[R][C] = {{2, 3, 4}, {5, 9, 3}, {2, 6, 4}}; int cost3[R][C] = {{3, 4, 5}, {6, 10, 4}, {3, 7, 5}}; assert(func0(cost1, 2, 2) == 8); assert(func0(cost2, 2, 2) == 12); assert(func0(cost3, 2, 2) == 16); return 0; }
O2
c
func0: endbr64 sub $0x38,%rsp mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax mov (%rdi),%eax mov %eax,(%rsp) test %esi,%esi jle 1356 <func0+0x36> mov 0xc(%rdi),%ecx add %eax,%ecx mov %ecx,0xc(%rsp) cmp $0x1,%esi je 1356 <func0+0x36> add 0x18(%rdi),%ecx mov %ecx,0x18(%rsp) test %edx,%edx jle 136d <func0+0x4d> add 0x4(%rdi),%eax mov %eax,0x4(%rsp) cmp $0x1,%edx je 136d <func0+0x4d> add 0x8(%rdi),%eax mov %eax,0x8(%rsp) test %esi,%esi jle 13c8 <func0+0xa8> mov %rsp,%rax add $0x10,%rdi mov $0x1,%r9d test %edx,%edx jle 13b7 <func0+0x97> mov 0x4(%rax),%ecx cmp %ecx,(%rax) mov %ecx,%r8d cmovle (%rax),%r8d cmp %r8d,0xc(%rax) cmovle 0xc(%rax),%r8d add (%rdi),%r8d mov %r8d,0x10(%rax) cmp $0x1,%edx je 13b7 <func0+0x97> cmp %ecx,0x8(%rax) cmovle 0x8(%rax),%ecx cmp %r8d,%ecx cmovg %r8d,%ecx add 0x4(%rdi),%ecx mov %ecx,0x14(%rax) add $0x1,%r9d add $0xc,%rax add $0xc,%rdi cmp %r9d,%esi jge 137e <func0+0x5e> movslq %esi,%rsi movslq %edx,%rdx lea (%rsi,%rsi,2),%rax add %rax,%rdx mov 0x28(%rsp),%rsi xor %fs:0x28,%rsi mov (%rsp,%rdx,4),%eax jne 13ed <func0+0xcd> add $0x38,%rsp retq callq 1060 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 sub rsp, 38h movsxd r8, edx mov rax, fs:28h mov [rsp+38h+var_10], rax mov eax, [rdi] mov [rsp+38h+var_38], eax test esi, esi jle short loc_1357 mov edx, [rdi+0Ch] add edx, eax mov [rsp+38h+var_2C], edx cmp esi, 1 jz short loc_1357 add edx, [rdi+18h] mov [rsp+38h+var_20], edx loc_1357: test r8d, r8d jle short loc_1370 add eax, [rdi+4] mov [rsp+38h+var_34], eax cmp r8d, 1 jz short loc_1370 add eax, [rdi+8] mov [rsp+38h+var_30], eax loc_1370: test esi, esi jle short loc_13CD mov rcx, rsp add rdi, 10h mov r9d, 1 loc_1381: test r8d, r8d jle short loc_13BC mov edx, [rcx+4] mov eax, [rcx] mov r10d, [rcx+0Ch] cmp edx, eax cmovle eax, edx cmp eax, r10d cmovg eax, r10d add eax, [rdi] mov [rcx+10h], eax cmp r8d, 1 jz short loc_13BC mov r10d, [rcx+8] cmp edx, r10d cmovg edx, r10d cmp edx, eax cmovg edx, eax add edx, [rdi+4] mov [rcx+14h], edx loc_13BC: add r9d, 1 add rcx, 0Ch add rdi, 0Ch cmp esi, r9d jge short loc_1381 loc_13CD: movsxd rsi, esi lea rax, [rsi+rsi*2] add rax, r8 mov eax, [rsp+rax*4+38h+var_38] mov rdx, [rsp+38h+var_10] sub rdx, fs:28h jnz short loc_13EF add rsp, 38h retn loc_13EF: call ___stack_chk_fail
long long func0(int *a1, int a2, int a3) { long long v3; // r8 int v4; // eax int v5; // edx int v6; // eax int *v7; // rcx _DWORD *v8; // rdi int i; // r9d int v10; // edx int v11; // eax int v12; // eax _DWORD v14[10]; // [rsp+0h] [rbp-38h] BYREF unsigned long long v15; // [rsp+28h] [rbp-10h] v3 = a3; v15 = __readfsqword(0x28u); v4 = *a1; v14[0] = *a1; if ( a2 > 0 ) { v5 = v4 + a1[3]; v14[3] = v5; if ( a2 != 1 ) v14[6] = a1[6] + v5; } if ( (int)v3 > 0 ) { v6 = a1[1] + v4; v14[1] = v6; if ( (_DWORD)v3 != 1 ) v14[2] = a1[2] + v6; } if ( a2 > 0 ) { v7 = v14; v8 = a1 + 4; for ( i = 1; i <= a2; ++i ) { if ( (int)v3 > 0 ) { v10 = v7[1]; v11 = *v7; if ( v10 <= *v7 ) v11 = v7[1]; if ( v11 > v7[3] ) v11 = v7[3]; v12 = *v8 + v11; v7[4] = v12; if ( (_DWORD)v3 != 1 ) { if ( v10 > v7[2] ) v10 = v7[2]; if ( v10 > v12 ) v10 = v12; v7[5] = v8[1] + v10; } } v7 += 3; v8 += 3; } } return (unsigned int)v14[3 * a2 + v3]; }
func0: ENDBR64 SUB RSP,0x38 MOVSXD R8,EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX MOV EAX,dword ptr [RDI] MOV dword ptr [RSP],EAX TEST ESI,ESI JLE 0x00101357 MOV EDX,dword ptr [RDI + 0xc] ADD EDX,EAX MOV dword ptr [RSP + 0xc],EDX CMP ESI,0x1 JZ 0x00101357 ADD EDX,dword ptr [RDI + 0x18] MOV dword ptr [RSP + 0x18],EDX LAB_00101357: TEST R8D,R8D JLE 0x00101370 ADD EAX,dword ptr [RDI + 0x4] MOV dword ptr [RSP + 0x4],EAX CMP R8D,0x1 JZ 0x00101370 ADD EAX,dword ptr [RDI + 0x8] MOV dword ptr [RSP + 0x8],EAX LAB_00101370: TEST ESI,ESI JLE 0x001013cd MOV RCX,RSP ADD RDI,0x10 MOV R9D,0x1 LAB_00101381: TEST R8D,R8D JLE 0x001013bc MOV EDX,dword ptr [RCX + 0x4] MOV EAX,dword ptr [RCX] MOV R10D,dword ptr [RCX + 0xc] CMP EDX,EAX CMOVLE EAX,EDX CMP EAX,R10D CMOVG EAX,R10D ADD EAX,dword ptr [RDI] MOV dword ptr [RCX + 0x10],EAX CMP R8D,0x1 JZ 0x001013bc MOV R10D,dword ptr [RCX + 0x8] CMP EDX,R10D CMOVG EDX,R10D CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [RDI + 0x4] MOV dword ptr [RCX + 0x14],EDX LAB_001013bc: ADD R9D,0x1 ADD RCX,0xc ADD RDI,0xc CMP ESI,R9D JGE 0x00101381 LAB_001013cd: MOVSXD RSI,ESI LEA RAX,[RSI + RSI*0x2] ADD RAX,R8 MOV EAX,dword ptr [RSP + RAX*0x4] MOV RDX,qword ptr [RSP + 0x28] SUB RDX,qword ptr FS:[0x28] JNZ 0x001013ef ADD RSP,0x38 RET LAB_001013ef: CALL 0x00101060
int func0(int *param_1,int param_2,int param_3) { int iVar1; int *piVar2; int iVar3; int iVar4; long in_FS_OFFSET; int local_38 [6]; int local_20; long local_10; piVar2 = local_38; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38[0] = *param_1; if (0 < param_2) { local_38[3] = param_1[3] + local_38[0]; if (param_2 != 1) { local_20 = param_1[3] + local_38[0] + param_1[6]; } } if (0 < param_3) { local_38[1] = local_38[0] + param_1[1]; if (param_3 != 1) { local_38[2] = local_38[0] + param_1[1] + param_1[2]; } } if (0 < param_2) { param_1 = param_1 + 4; iVar4 = 1; do { if (0 < param_3) { iVar3 = piVar2[1]; iVar1 = *piVar2; if (iVar3 <= *piVar2) { iVar1 = iVar3; } if (piVar2[3] < iVar1) { iVar1 = piVar2[3]; } iVar1 = iVar1 + *param_1; piVar2[4] = iVar1; if (param_3 != 1) { if (piVar2[2] < iVar3) { iVar3 = piVar2[2]; } if (iVar1 < iVar3) { iVar3 = iVar1; } piVar2[5] = iVar3 + param_1[1]; } } iVar4 = iVar4 + 1; piVar2 = piVar2 + 3; param_1 = param_1 + 3; } while (iVar4 <= param_2); } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return local_38[(long)param_2 * 3 + (long)param_3]; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,899
func0
#include <assert.h> #define R 3 #define C 3
int func0(int cost[R][C], int m, int n) { int tc[R][C]; tc[0][0] = cost[0][0]; for (int i = 1; i <= m; ++i) { tc[i][0] = tc[i - 1][0] + cost[i][0]; } for (int j = 1; j <= n; ++j) { tc[0][j] = tc[0][j - 1] + cost[0][j]; } for (int i = 1; i <= m; ++i) { for (int j = 1; j <= n; ++j) { int min_val = tc[i - 1][j - 1]; if (tc[i - 1][j] < min_val) min_val = tc[i - 1][j]; if (tc[i][j - 1] < min_val) min_val = tc[i][j - 1]; tc[i][j] = min_val + cost[i][j]; } } return tc[m][n]; }
int main() { int cost1[R][C] = {{1, 2, 3}, {4, 8, 2}, {1, 5, 3}}; int cost2[R][C] = {{2, 3, 4}, {5, 9, 3}, {2, 6, 4}}; int cost3[R][C] = {{3, 4, 5}, {6, 10, 4}, {3, 7, 5}}; assert(func0(cost1, 2, 2) == 8); assert(func0(cost2, 2, 2) == 12); assert(func0(cost3, 2, 2) == 16); return 0; }
O3
c
func0: endbr64 sub $0x38,%rsp mov (%rdi),%r8d mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax mov %r8d,(%rsp) test %esi,%esi jle 12f9 <func0+0x39> mov 0xc(%rdi),%eax add %r8d,%eax mov %eax,0xc(%rsp) cmp $0x1,%esi je 12f9 <func0+0x39> add 0x18(%rdi),%eax mov %eax,0x18(%rsp) test %edx,%edx jle 14a8 <func0+0x1e8> mov 0x4(%rdi),%eax add %r8d,%eax mov %eax,0x4(%rsp) cmp $0x1,%edx je 14a8 <func0+0x1e8> add 0x8(%rdi),%eax mov %eax,0x8(%rsp) test %esi,%esi jle 1480 <func0+0x1c0> cmp $0x3,%edx jle 14b5 <func0+0x1f5> mov 0x4(%rsp),%eax mov 0xc(%rsp),%r10d mov 0x8(%rsp),%ecx cmp %r10d,%eax mov %r10d,%r9d cmovle %eax,%r9d cmp %r8d,%r9d cmovle %r9d,%r8d add 0x10(%rdi),%r8d cmp %ecx,%eax cmovg %ecx,%eax mov %r8d,0x10(%rsp) cmp %r8d,%eax cmovg %r8d,%eax add 0x14(%rdi),%eax cmp %r10d,%ecx cmovg %r10d,%ecx mov %eax,0x14(%rsp) cmp %eax,%ecx cmovg %eax,%ecx add 0x18(%rdi),%ecx mov %ecx,0x18(%rsp) mov $0x4,%ecx lea -0x1(%rcx),%r9d movslq %ecx,%r10 movslq %r9d,%r9 mov (%rsp,%r10,4),%r8d mov 0xc(%rsp,%r9,4),%eax cmp %eax,(%rsp,%r9,4) cmovle (%rsp,%r9,4),%eax lea 0xc(%rdi,%r10,4),%r9 cmp %eax,%r8d cmovle %r8d,%eax add $0x1,%ecx add (%r9),%eax mov %eax,0xc(%rsp,%r10,4) cmp %ecx,%edx jl 13d1 <func0+0x111> movslq %ecx,%rcx cmp %r8d,(%rsp,%rcx,4) cmovle (%rsp,%rcx,4),%r8d cmp %eax,%r8d cmovg %eax,%r8d add 0x4(%r9),%r8d mov %r8d,0xc(%rsp,%rcx,4) cmp $0x1,%esi jle 1480 <func0+0x1c0> mov $0x1,%ecx cmp $0x3,%edx jle 1425 <func0+0x165> mov 0x10(%rsp),%r8d mov 0xc(%rsp),%r9d cmp %r8d,0x18(%rsp) mov 0x14(%rsp),%eax mov %r8d,%ecx cmovle 0x18(%rsp),%ecx cmp %r9d,%ecx cmovg %r9d,%ecx add 0x1c(%rdi),%ecx cmp %r8d,%eax cmovg %r8d,%eax mov %ecx,0x1c(%rsp) cmp %ecx,%eax cmovg %ecx,%eax add 0x20(%rdi),%eax mov $0x4,%ecx mov %eax,0x20(%rsp) lea -0x1(%rcx),%r9d movslq %ecx,%r10 movslq %r9d,%r9 mov 0xc(%rsp,%r10,4),%r8d lea 0x18(%rdi,%r10,4),%rdi mov 0xc(%rsp,%r9,4),%eax cmp %eax,0x18(%rsp,%r9,4) cmovle 0x18(%rsp,%r9,4),%eax cmp %r8d,%eax cmovg %r8d,%eax add $0x1,%ecx add (%rdi),%eax mov %eax,0x18(%rsp,%r10,4) cmp %ecx,%edx jl 1480 <func0+0x1c0> movslq %ecx,%rcx cmp %r8d,0xc(%rsp,%rcx,4) cmovle 0xc(%rsp,%rcx,4),%r8d cmp %eax,%r8d cmovg %eax,%r8d add 0x4(%rdi),%r8d mov %r8d,0x18(%rsp,%rcx,4) nopl 0x0(%rax) movslq %esi,%rsi movslq %edx,%rdx lea (%rsi,%rsi,2),%rax add %rax,%rdx mov 0x28(%rsp),%rsi xor %fs:0x28,%rsi mov (%rsp,%rdx,4),%eax jne 14bf <func0+0x1ff> add $0x38,%rsp retq nopl (%rax) test %esi,%esi jle 1480 <func0+0x1c0> test %edx,%edx jle 1480 <func0+0x1c0> jmpq 1323 <func0+0x63> mov $0x1,%ecx jmpq 137e <func0+0xbe> callq 1060 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push rbx movsxd rcx, esi movsxd rsi, edx sub rsp, 30h mov rax, fs:28h mov [rsp+38h+var_10], rax mov eax, [rdi] mov [rsp+38h+var_38], eax test ecx, ecx jle loc_1438 mov edx, [rdi+0Ch] add edx, eax mov [rsp+38h+var_2C], edx cmp ecx, 1 jz short loc_12FF add edx, [rdi+18h] mov [rsp+38h+var_20], edx loc_12FF: test esi, esi jle loc_1411 mov edx, [rdi+4] add edx, eax mov [rsp+38h+var_34], edx cmp esi, 1 jz loc_1458 mov r10d, [rdi+8] add r10d, edx mov [rsp+38h+var_30], r10d cmp esi, 3 jle loc_1495 mov r8d, [rsp+38h+var_2C] mov r11d, 4 mov ebx, 10h cmp edx, r8d mov r9d, r8d cmovle r9d, edx cmp r9d, eax cmovg r9d, eax add r9d, [rdi+10h] cmp r10d, edx cmovle edx, r10d mov [rsp+38h+var_28], r9d cmp edx, r9d cmovg edx, r9d add edx, [rdi+14h] cmp r10d, r8d cmovg r10d, r8d cmp edx, r10d cmovg edx, r10d add edx, [rdi+18h] lea r10, [rdi+1Ch] cmp eax, r8d cmovg eax, r8d mov [rsp+38h+var_20], edx mov edx, r9d cmp eax, r9d cmovg eax, r9d add eax, [rdi+1Ch] mov [rsp+38h+var_1C], eax loc_139A: mov r9d, [rsp+38h+var_30] cmp edx, r9d cmovg edx, r9d cmp edx, eax cmovg edx, eax add edx, [r10+4] mov [rsp+38h+var_24], edx cmp ecx, 1 jz short loc_1411 cmp esi, 3 jle short loc_13D8 mov eax, [rsp+38h+var_28] mov edx, [rsp+38h+var_20] cmp eax, edx cmovg eax, edx cmp eax, r8d cmovg eax, r8d add eax, [rdi+1Ch] mov [rsp+38h+var_1C], eax loc_13D8: mov edx, [rsp+38h+var_20] mov eax, [rsp+r11*4+38h+var_2C] lea rdi, [rdi+rbx+18h] cmp r8d, edx cmovle edx, r8d mov r8d, [rsp+38h+var_24] cmp edx, eax cmovg edx, eax add edx, [rdi] cmp eax, r8d cmovg eax, r8d mov [rsp+r11*4+38h+var_20], edx cmp eax, edx cmovg eax, edx add eax, [rdi+4] mov [rsp+38h+var_18], eax loc_1411: lea rax, [rcx+rcx*2] add rax, rsi mov eax, [rsp+rax*4+38h+var_38] mov rdx, [rsp+38h+var_10] sub rdx, fs:28h jnz loc_14C1 add rsp, 30h pop rbx retn loc_1438: test esi, esi jle short loc_1411 add eax, [rdi+4] mov [rsp+38h+var_34], eax cmp esi, 1 jz short loc_1411 add eax, [rdi+8] mov [rsp+38h+var_30], eax jmp short loc_1411 loc_1458: mov r8d, edx mov edx, [rsp+38h+var_2C] cmp eax, edx cmovg eax, edx cmp eax, r8d cmovg eax, r8d add eax, [rdi+10h] mov [rsp+38h+var_28], eax cmp ecx, 1 jz short loc_1411 mov eax, [rsp+38h+var_20] cmp edx, eax cmovg edx, eax mov eax, [rsp+38h+var_28] cmp edx, eax cmovg edx, eax add edx, [rdi+1Ch] mov [rsp+38h+var_1C], edx jmp loc_1411 loc_1495: mov r8d, [rsp+38h+var_2C] lea r10, [rdi+10h] mov r11d, 1 mov ebx, 4 cmp eax, r8d cmovg eax, r8d cmp eax, edx cmovg eax, edx add eax, [rdi+10h] mov [rsp+38h+var_28], eax jmp loc_139A loc_14C1: call ___stack_chk_fail
long long func0(int *a1, int a2, int a3) { long long v3; // rcx long long v4; // rsi int v5; // eax int v6; // edx int v7; // edx int v8; // r10d int v9; // r8d long long v10; // r11 long long v11; // rbx int v12; // r9d int v13; // r9d int v14; // edx int v15; // edx _DWORD *v16; // r10 int v17; // eax int v18; // eax int v19; // edx int v20; // eax int *v21; // rdi int v22; // edx int v24; // eax int v25; // r8d int v26; // edx int v27; // [rsp+0h] [rbp-38h] int v28; // [rsp+4h] [rbp-34h] int v29; // [rsp+8h] [rbp-30h] int v30; // [rsp+Ch] [rbp-2Ch] int v31; // [rsp+10h] [rbp-28h] int v32; // [rsp+14h] [rbp-24h] int v33; // [rsp+18h] [rbp-20h] int v34; // [rsp+1Ch] [rbp-1Ch] int v35; // [rsp+20h] [rbp-18h] unsigned long long v36; // [rsp+28h] [rbp-10h] v3 = a2; v4 = a3; v36 = __readfsqword(0x28u); v5 = *a1; v27 = *a1; if ( (int)v3 <= 0 ) { if ( a3 > 0 ) { v24 = a1[1] + v5; v28 = v24; if ( a3 != 1 ) v29 = a1[2] + v24; } } else { v6 = v5 + a1[3]; v30 = v6; if ( (_DWORD)v3 != 1 ) v33 = a1[6] + v6; if ( (int)v4 > 0 ) { v7 = v5 + a1[1]; v28 = v7; if ( (_DWORD)v4 == 1 ) { v25 = v7; v26 = v30; if ( v5 > v30 ) v5 = v30; if ( v5 > v25 ) v5 = v25; v31 = a1[4] + v5; if ( (_DWORD)v3 != 1 ) { if ( v30 > v33 ) v26 = v33; if ( v26 > v31 ) v26 = v31; v34 = a1[7] + v26; } } else { v8 = v7 + a1[2]; v29 = v8; if ( (int)v4 <= 3 ) { v9 = v30; v16 = a1 + 4; v10 = 1LL; v11 = 1LL; if ( v5 > v30 ) v5 = v30; if ( v5 > v7 ) v5 = v7; v17 = a1[4] + v5; v31 = v17; } else { v9 = v30; v10 = 4LL; v11 = 4LL; v12 = v30; if ( v7 <= v30 ) v12 = v7; if ( v12 > v5 ) v12 = v5; v13 = a1[4] + v12; if ( v8 <= v7 ) v7 = v8; v31 = v13; if ( v7 > v13 ) v7 = v13; v14 = a1[5] + v7; if ( v8 > v30 ) v8 = v30; if ( v14 > v8 ) v14 = v8; v15 = a1[6] + v14; v16 = a1 + 7; if ( v5 > v30 ) v5 = v30; v33 = v15; v7 = v13; if ( v5 > v13 ) v5 = v13; v17 = a1[7] + v5; v34 = v17; } if ( v7 > v29 ) v7 = v29; if ( v7 > v17 ) v7 = v17; v32 = v16[1] + v7; if ( (_DWORD)v3 != 1 ) { if ( (int)v4 > 3 ) { v18 = v31; if ( v31 > v33 ) v18 = v33; if ( v18 > v9 ) v18 = v9; v34 = a1[7] + v18; } v19 = v33; v20 = *(&v30 + v10); v21 = &a1[v11 + 6]; if ( v9 <= v33 ) v19 = v9; if ( v19 > v20 ) v19 = *(&v30 + v10); v22 = *v21 + v19; if ( v20 > v32 ) v20 = v32; *(&v33 + v10) = v22; if ( v20 > v22 ) v20 = v22; v35 = v21[1] + v20; } } } } return (unsigned int)*(&v27 + 3 * v3 + v4); }
func0: ENDBR64 PUSH RBX MOVSXD RCX,ESI MOVSXD RSI,EDX SUB RSP,0x30 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX MOV EAX,dword ptr [RDI] MOV dword ptr [RSP],EAX TEST ECX,ECX JLE 0x00101438 MOV EDX,dword ptr [RDI + 0xc] ADD EDX,EAX MOV dword ptr [RSP + 0xc],EDX CMP ECX,0x1 JZ 0x001012ff ADD EDX,dword ptr [RDI + 0x18] MOV dword ptr [RSP + 0x18],EDX LAB_001012ff: TEST ESI,ESI JLE 0x00101411 MOV EDX,dword ptr [RDI + 0x4] ADD EDX,EAX MOV dword ptr [RSP + 0x4],EDX CMP ESI,0x1 JZ 0x00101458 MOV R10D,dword ptr [RDI + 0x8] ADD R10D,EDX MOV dword ptr [RSP + 0x8],R10D CMP ESI,0x3 JLE 0x00101495 MOV R8D,dword ptr [RSP + 0xc] MOV R11D,0x4 MOV EBX,0x10 CMP EDX,R8D MOV R9D,R8D CMOVLE R9D,EDX CMP R9D,EAX CMOVG R9D,EAX ADD R9D,dword ptr [RDI + 0x10] CMP R10D,EDX CMOVLE EDX,R10D MOV dword ptr [RSP + 0x10],R9D CMP EDX,R9D CMOVG EDX,R9D ADD EDX,dword ptr [RDI + 0x14] CMP R10D,R8D CMOVG R10D,R8D CMP EDX,R10D CMOVG EDX,R10D ADD EDX,dword ptr [RDI + 0x18] LEA R10,[RDI + 0x1c] CMP EAX,R8D CMOVG EAX,R8D MOV dword ptr [RSP + 0x18],EDX MOV EDX,R9D CMP EAX,R9D CMOVG EAX,R9D ADD EAX,dword ptr [RDI + 0x1c] MOV dword ptr [RSP + 0x1c],EAX LAB_0010139a: MOV R9D,dword ptr [RSP + 0x8] CMP EDX,R9D CMOVG EDX,R9D CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [R10 + 0x4] MOV dword ptr [RSP + 0x14],EDX CMP ECX,0x1 JZ 0x00101411 CMP ESI,0x3 JLE 0x001013d8 MOV EAX,dword ptr [RSP + 0x10] MOV EDX,dword ptr [RSP + 0x18] CMP EAX,EDX CMOVG EAX,EDX CMP EAX,R8D CMOVG EAX,R8D ADD EAX,dword ptr [RDI + 0x1c] MOV dword ptr [RSP + 0x1c],EAX LAB_001013d8: MOV EDX,dword ptr [RSP + 0x18] MOV EAX,dword ptr [RSP + R11*0x4 + 0xc] LEA RDI,[RDI + RBX*0x1 + 0x18] CMP R8D,EDX CMOVLE EDX,R8D MOV R8D,dword ptr [RSP + 0x14] CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [RDI] CMP EAX,R8D CMOVG EAX,R8D MOV dword ptr [RSP + R11*0x4 + 0x18],EDX CMP EAX,EDX CMOVG EAX,EDX ADD EAX,dword ptr [RDI + 0x4] MOV dword ptr [RSP + 0x20],EAX LAB_00101411: LEA RAX,[RCX + RCX*0x2] ADD RAX,RSI MOV EAX,dword ptr [RSP + RAX*0x4] MOV RDX,qword ptr [RSP + 0x28] SUB RDX,qword ptr FS:[0x28] JNZ 0x001014c1 ADD RSP,0x30 POP RBX RET LAB_00101438: TEST ESI,ESI JLE 0x00101411 ADD EAX,dword ptr [RDI + 0x4] MOV dword ptr [RSP + 0x4],EAX CMP ESI,0x1 JZ 0x00101411 ADD EAX,dword ptr [RDI + 0x8] MOV dword ptr [RSP + 0x8],EAX JMP 0x00101411 LAB_00101458: MOV R8D,EDX MOV EDX,dword ptr [RSP + 0xc] CMP EAX,EDX CMOVG EAX,EDX CMP EAX,R8D CMOVG EAX,R8D ADD EAX,dword ptr [RDI + 0x10] MOV dword ptr [RSP + 0x10],EAX CMP ECX,0x1 JZ 0x00101411 MOV EAX,dword ptr [RSP + 0x18] CMP EDX,EAX CMOVG EDX,EAX MOV EAX,dword ptr [RSP + 0x10] CMP EDX,EAX CMOVG EDX,EAX ADD EDX,dword ptr [RDI + 0x1c] MOV dword ptr [RSP + 0x1c],EDX JMP 0x00101411 LAB_00101495: MOV R8D,dword ptr [RSP + 0xc] LEA R10,[RDI + 0x10] MOV R11D,0x1 MOV EBX,0x4 CMP EAX,R8D CMOVG EAX,R8D CMP EAX,EDX CMOVG EAX,EDX ADD EAX,dword ptr [RDI + 0x10] MOV dword ptr [RSP + 0x10],EAX JMP 0x0010139a LAB_001014c1: CALL 0x00101060
int func0(int *param_1,int param_2,int param_3) { int iVar1; int iVar2; int iVar3; long lVar4; int *piVar5; long lVar6; long in_FS_OFFSET; int local_38 [4]; int local_28 [6]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38[0] = *param_1; if (param_2 < 1) { if (0 < param_3) { local_38[1] = local_38[0] + param_1[1]; if (param_3 != 1) { local_38[2] = local_38[0] + param_1[1] + param_1[2]; } } } else { local_38[3] = param_1[3] + local_38[0]; if (param_2 != 1) { local_28[2] = local_38[3] + param_1[6]; } if (0 < param_3) { iVar2 = param_1[1] + local_38[0]; local_38[1] = iVar2; if (param_3 == 1) { local_28[0] = local_38[0]; if (local_38[3] < local_38[0]) { local_28[0] = local_38[3]; } if (iVar2 < local_28[0]) { local_28[0] = iVar2; } local_28[0] = local_28[0] + param_1[4]; if (param_2 != 1) { iVar2 = local_38[3]; if (local_28[2] < local_38[3]) { iVar2 = local_28[2]; } if (local_28[0] < iVar2) { iVar2 = local_28[0]; } local_28[3] = iVar2 + param_1[7]; } } else { local_38[2] = param_1[2] + iVar2; if (param_3 < 4) { piVar5 = param_1 + 4; lVar6 = 1; lVar4 = 4; iVar1 = local_38[0]; if (local_38[3] < local_38[0]) { iVar1 = local_38[3]; } if (iVar2 < iVar1) { iVar1 = iVar2; } iVar1 = iVar1 + param_1[4]; local_28[0] = iVar1; } else { lVar6 = 4; lVar4 = 0x10; local_28[0] = local_38[3]; if (iVar2 <= local_38[3]) { local_28[0] = iVar2; } if (local_38[0] < local_28[0]) { local_28[0] = local_38[0]; } local_28[0] = local_28[0] + param_1[4]; if (local_38[2] <= iVar2) { iVar2 = local_38[2]; } if (local_28[0] < iVar2) { iVar2 = local_28[0]; } iVar1 = local_38[2]; if (local_38[3] < local_38[2]) { iVar1 = local_38[3]; } iVar3 = iVar2 + param_1[5]; if (iVar1 < iVar2 + param_1[5]) { iVar3 = iVar1; } piVar5 = param_1 + 7; iVar1 = local_38[0]; if (local_38[3] < local_38[0]) { iVar1 = local_38[3]; } local_28[2] = iVar3 + param_1[6]; if (local_28[0] < iVar1) { iVar1 = local_28[0]; } iVar1 = iVar1 + param_1[7]; local_28[3] = iVar1; iVar2 = local_28[0]; } if (local_38[2] < iVar2) { iVar2 = local_38[2]; } if (iVar1 < iVar2) { iVar2 = iVar1; } local_28[1] = iVar2 + piVar5[1]; if (param_2 != 1) { if (3 < param_3) { iVar2 = local_28[0]; if (local_28[2] < local_28[0]) { iVar2 = local_28[2]; } if (local_38[3] < iVar2) { iVar2 = local_38[3]; } local_28[3] = iVar2 + param_1[7]; } iVar2 = local_38[lVar6 + 3]; param_1 = (int *)((long)param_1 + lVar4 + 0x18); iVar1 = local_28[2]; if (local_38[3] <= local_28[2]) { iVar1 = local_38[3]; } if (iVar2 < iVar1) { iVar1 = iVar2; } iVar1 = iVar1 + *param_1; if (local_28[1] < iVar2) { iVar2 = local_28[1]; } local_38[lVar6 + 6] = iVar1; if (iVar1 < iVar2) { iVar2 = iVar1; } local_28[4] = iVar2 + param_1[1]; } } } } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return local_38[(long)param_2 * 3 + (long)param_3]; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,900
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h> // Function to find similar elements
int* func0(int test_tup1[], int size1, int test_tup2[], int size2, int* res_size) { int* temp = (int*)malloc((size1 < size2 ? size1 : size2) * sizeof(int)); if (!temp) { *res_size = 0; return NULL; } int count = 0; for(int i = 0; i < size1; i++) { for(int j = 0; j < size2; j++) { if(test_tup1[i] == test_tup2[j]) { // Check for duplicates int exists = 0; for(int k = 0; k < count; k++) { if(temp[k] == test_tup1[i]) { exists = 1; break; } } if(!exists) { temp[count++] = test_tup1[i]; } break; } } } // Sort the result for(int i = 0; i < count - 1; i++) { for(int j = i + 1; j < count; j++) { if(temp[i] > temp[j]) { int swap = temp[i]; temp[i] = temp[j]; temp[j] = swap; } } } *res_size = count; return temp; }
int main() { int res_size; int* res; // First assertion int test1_a[] = {3, 4, 5, 6}; int test1_b[] = {5, 7, 4, 10}; res = func0(test1_a, 4, test1_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 4 && res[1] == 5); free(res); // Second assertion int test2_a[] = {1, 2, 3, 4}; int test2_b[] = {5, 4, 3, 7}; res = func0(test2_a, 4, test2_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 3 && res[1] == 4); free(res); // Third assertion int test3_a[] = {11, 12, 14, 13}; int test3_b[] = {17, 15, 14, 13}; res = func0(test3_a, 4, test3_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 13 && res[1] == 14); free(res); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x50,%rsp mov %rdi,-0x38(%rbp) mov %esi,-0x3c(%rbp) mov %rdx,-0x48(%rbp) mov %ecx,-0x40(%rbp) mov %r8,-0x50(%rbp) mov -0x3c(%rbp),%eax cmp %eax,-0x40(%rbp) cmovle -0x40(%rbp),%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) cmpq $0x0,-0x8(%rbp) jne 11fe <func0+0x55> mov -0x50(%rbp),%rax movl $0x0,(%rax) mov $0x0,%eax jmpq 13dd <func0+0x234> movl $0x0,-0x28(%rbp) movl $0x0,-0x24(%rbp) jmpq 12f8 <func0+0x14f> movl $0x0,-0x20(%rbp) jmpq 12e5 <func0+0x13c> mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x38(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x20(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x48(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jne 12e1 <func0+0x138> movl $0x0,-0x1c(%rbp) movl $0x0,-0x18(%rbp) jmp 129e <func0+0xf5> mov -0x18(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x38(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jne 129a <func0+0xf1> movl $0x1,-0x1c(%rbp) jmp 12a6 <func0+0xfd> addl $0x1,-0x18(%rbp) mov -0x18(%rbp),%eax cmp -0x28(%rbp),%eax jl 1261 <func0+0xb8> cmpl $0x0,-0x1c(%rbp) jne 12f3 <func0+0x14a> mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x38(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x28(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x28(%rbp) cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov (%rcx),%eax mov %eax,(%rdx) jmp 12f3 <func0+0x14a> addl $0x1,-0x20(%rbp) mov -0x20(%rbp),%eax cmp -0x40(%rbp),%eax jl 121d <func0+0x74> jmp 12f4 <func0+0x14b> addl $0x1,-0x24(%rbp) mov -0x24(%rbp),%eax cmp -0x3c(%rbp),%eax jl 1211 <func0+0x68> movl $0x0,-0x14(%rbp) jmpq 13c1 <func0+0x218> mov -0x14(%rbp),%eax add $0x1,%eax mov %eax,-0x10(%rbp) jmpq 13b1 <func0+0x208> mov -0x14(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x8(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jle 13ad <func0+0x204> mov -0x14(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0xc(%rbp) mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rdx,%rax mov -0x14(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov -0xc(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x10(%rbp) mov -0x10(%rbp),%eax cmp -0x28(%rbp),%eax jl 131e <func0+0x175> addl $0x1,-0x14(%rbp) mov -0x28(%rbp),%eax sub $0x1,%eax cmp %eax,-0x14(%rbp) jl 1310 <func0+0x167> mov -0x50(%rbp),%rax mov -0x28(%rbp),%edx mov %edx,(%rax) mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 50h mov [rbp+var_38], rdi mov [rbp+var_3C], esi mov [rbp+var_48], rdx mov [rbp+var_40], ecx mov [rbp+var_50], r8 mov edx, [rbp+var_40] mov eax, [rbp+var_3C] cmp edx, eax cmovle eax, edx cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_8], rax cmp [rbp+var_8], 0 jnz short loc_11FF mov rax, [rbp+var_50] mov dword ptr [rax], 0 mov eax, 0 jmp locret_13DE loc_11FF: mov [rbp+var_28], 0 mov [rbp+var_24], 0 jmp loc_12F9 loc_1212: mov [rbp+var_20], 0 jmp loc_12E6 loc_121E: mov eax, [rbp+var_24] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] add rax, rdx mov edx, [rax] mov eax, [rbp+var_20] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_48] add rax, rcx mov eax, [rax] cmp edx, eax jnz loc_12E2 mov [rbp+var_1C], 0 mov [rbp+var_18], 0 jmp short loc_129F loc_1262: mov eax, [rbp+var_18] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rdx mov edx, [rax] mov eax, [rbp+var_24] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_38] add rax, rcx mov eax, [rax] cmp edx, eax jnz short loc_129B mov [rbp+var_1C], 1 jmp short loc_12A7 loc_129B: add [rbp+var_18], 1 loc_129F: mov eax, [rbp+var_18] cmp eax, [rbp+var_28] jl short loc_1262 loc_12A7: cmp [rbp+var_1C], 0 jnz short loc_12F4 mov eax, [rbp+var_24] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] lea rcx, [rdx+rax] mov eax, [rbp+var_28] lea edx, [rax+1] mov [rbp+var_28], edx cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rdx, rax mov eax, [rcx] mov [rdx], eax jmp short loc_12F4 loc_12E2: add [rbp+var_20], 1 loc_12E6: mov eax, [rbp+var_20] cmp eax, [rbp+var_40] jl loc_121E jmp short loc_12F5 loc_12F4: nop loc_12F5: add [rbp+var_24], 1 loc_12F9: mov eax, [rbp+var_24] cmp eax, [rbp+var_3C] jl loc_1212 mov [rbp+var_14], 0 jmp loc_13C2 loc_1311: mov eax, [rbp+var_14] add eax, 1 mov [rbp+var_10], eax jmp loc_13B2 loc_131F: mov eax, [rbp+var_14] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rdx mov edx, [rax] mov eax, [rbp+var_10] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rcx mov eax, [rax] cmp edx, eax jle short loc_13AE mov eax, [rbp+var_14] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rdx mov eax, [rax] mov [rbp+var_C], eax mov eax, [rbp+var_10] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rdx mov edx, [rbp+var_14] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_8] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_10] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rdx, rax mov eax, [rbp+var_C] mov [rdx], eax loc_13AE: add [rbp+var_10], 1 loc_13B2: mov eax, [rbp+var_10] cmp eax, [rbp+var_28] jl loc_131F add [rbp+var_14], 1 loc_13C2: mov eax, [rbp+var_28] sub eax, 1 cmp [rbp+var_14], eax jl loc_1311 mov rax, [rbp+var_50] mov edx, [rbp+var_28] mov [rax], edx mov rax, [rbp+var_8] locret_13DE: leave retn
_DWORD * func0(long long a1, int a2, long long a3, int a4, _DWORD *a5) { int v5; // eax int v7; // eax int v11; // [rsp+28h] [rbp-28h] int i; // [rsp+2Ch] [rbp-24h] int j; // [rsp+30h] [rbp-20h] int v14; // [rsp+34h] [rbp-1Ch] int k; // [rsp+38h] [rbp-18h] int m; // [rsp+3Ch] [rbp-14h] int n; // [rsp+40h] [rbp-10h] int v18; // [rsp+44h] [rbp-Ch] _DWORD *v19; // [rsp+48h] [rbp-8h] v5 = a2; if ( a4 <= a2 ) v5 = a4; v19 = malloc(4LL * v5); if ( v19 ) { v11 = 0; for ( i = 0; i < a2; ++i ) { for ( j = 0; j < a4; ++j ) { if ( *(_DWORD *)(4LL * i + a1) == *(_DWORD *)(4LL * j + a3) ) { v14 = 0; for ( k = 0; k < v11; ++k ) { if ( v19[k] == *(_DWORD *)(4LL * i + a1) ) { v14 = 1; break; } } if ( !v14 ) { v7 = v11++; v19[v7] = *(_DWORD *)(4LL * i + a1); } break; } } } for ( m = 0; m < v11 - 1; ++m ) { for ( n = m + 1; n < v11; ++n ) { if ( v19[m] > v19[n] ) { v18 = v19[m]; v19[m] = v19[n]; v19[n] = v18; } } } *a5 = v11; return v19; } else { *a5 = 0; return 0LL; } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x50 MOV qword ptr [RBP + -0x38],RDI MOV dword ptr [RBP + -0x3c],ESI MOV qword ptr [RBP + -0x48],RDX MOV dword ptr [RBP + -0x40],ECX MOV qword ptr [RBP + -0x50],R8 MOV EDX,dword ptr [RBP + -0x40] MOV EAX,dword ptr [RBP + -0x3c] CMP EDX,EAX CMOVLE EAX,EDX CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX CMP qword ptr [RBP + -0x8],0x0 JNZ 0x001011ff MOV RAX,qword ptr [RBP + -0x50] MOV dword ptr [RAX],0x0 MOV EAX,0x0 JMP 0x001013de LAB_001011ff: MOV dword ptr [RBP + -0x28],0x0 MOV dword ptr [RBP + -0x24],0x0 JMP 0x001012f9 LAB_00101212: MOV dword ptr [RBP + -0x20],0x0 JMP 0x001012e6 LAB_0010121e: MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x20] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x48] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JNZ 0x001012e2 MOV dword ptr [RBP + -0x1c],0x0 MOV dword ptr [RBP + -0x18],0x0 JMP 0x0010129f LAB_00101262: MOV EAX,dword ptr [RBP + -0x18] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JNZ 0x0010129b MOV dword ptr [RBP + -0x1c],0x1 JMP 0x001012a7 LAB_0010129b: ADD dword ptr [RBP + -0x18],0x1 LAB_0010129f: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x28] JL 0x00101262 LAB_001012a7: CMP dword ptr [RBP + -0x1c],0x0 JNZ 0x001012f4 MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x28] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x28],EDX CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV EAX,dword ptr [RCX] MOV dword ptr [RDX],EAX JMP 0x001012f4 LAB_001012e2: ADD dword ptr [RBP + -0x20],0x1 LAB_001012e6: MOV EAX,dword ptr [RBP + -0x20] CMP EAX,dword ptr [RBP + -0x40] JL 0x0010121e JMP 0x001012f5 LAB_001012f4: NOP LAB_001012f5: ADD dword ptr [RBP + -0x24],0x1 LAB_001012f9: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x3c] JL 0x00101212 MOV dword ptr [RBP + -0x14],0x0 JMP 0x001013c2 LAB_00101311: MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 MOV dword ptr [RBP + -0x10],EAX JMP 0x001013b2 LAB_0010131f: MOV EAX,dword ptr [RBP + -0x14] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JLE 0x001013ae MOV EAX,dword ptr [RBP + -0x14] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0xc],EAX MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x14] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0xc] MOV dword ptr [RDX],EAX LAB_001013ae: ADD dword ptr [RBP + -0x10],0x1 LAB_001013b2: MOV EAX,dword ptr [RBP + -0x10] CMP EAX,dword ptr [RBP + -0x28] JL 0x0010131f ADD dword ptr [RBP + -0x14],0x1 LAB_001013c2: MOV EAX,dword ptr [RBP + -0x28] SUB EAX,0x1 CMP dword ptr [RBP + -0x14],EAX JL 0x00101311 MOV RAX,qword ptr [RBP + -0x50] MOV EDX,dword ptr [RBP + -0x28] MOV dword ptr [RAX],EDX MOV RAX,qword ptr [RBP + -0x8] LAB_001013de: LEAVE RET
void * func0(long param_1,int param_2,long param_3,int param_4,int *param_5) { int4 uVar1; bool bVar2; int iVar3; void *pvVar4; int4 local_30; int4 local_2c; int4 local_28; int4 local_20; int4 local_1c; int4 local_18; iVar3 = param_2; if (param_4 <= param_2) { iVar3 = param_4; } pvVar4 = malloc((long)iVar3 << 2); if (pvVar4 == (void *)0x0) { *param_5 = 0; pvVar4 = (void *)0x0; } else { local_30 = 0; local_2c = 0; LAB_001012f9: if (local_2c < param_2) { for (local_28 = 0; local_28 < param_4; local_28 = local_28 + 1) { if (*(int *)(param_1 + (long)local_2c * 4) == *(int *)(param_3 + (long)local_28 * 4)) { bVar2 = false; local_20 = 0; goto LAB_0010129f; } } goto LAB_001012f5; } for (local_1c = 0; local_18 = local_1c, local_1c < local_30 + -1; local_1c = local_1c + 1) { while (local_18 = local_18 + 1, local_18 < local_30) { if (*(int *)((long)pvVar4 + (long)local_18 * 4) < *(int *)((long)pvVar4 + (long)local_1c * 4)) { uVar1 = *(int4 *)((long)pvVar4 + (long)local_1c * 4); *(int4 *)((long)pvVar4 + (long)local_1c * 4) = *(int4 *)((long)pvVar4 + (long)local_18 * 4); *(int4 *)((long)local_18 * 4 + (long)pvVar4) = uVar1; } } } *param_5 = local_30; } return pvVar4; LAB_0010129f: if (local_30 <= local_20) goto LAB_001012a7; if (*(int *)((long)pvVar4 + (long)local_20 * 4) == *(int *)(param_1 + (long)local_2c * 4)) { bVar2 = true; goto LAB_001012a7; } local_20 = local_20 + 1; goto LAB_0010129f; LAB_001012a7: if (!bVar2) { *(int4 *)((long)local_30 * 4 + (long)pvVar4) = *(int4 *)((long)local_2c * 4 + param_1); local_30 = local_30 + 1; } LAB_001012f5: local_2c = local_2c + 1; goto LAB_001012f9; }
3,901
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h> // Function to find similar elements
int* func0(int test_tup1[], int size1, int test_tup2[], int size2, int* res_size) { int* temp = (int*)malloc((size1 < size2 ? size1 : size2) * sizeof(int)); if (!temp) { *res_size = 0; return NULL; } int count = 0; for(int i = 0; i < size1; i++) { for(int j = 0; j < size2; j++) { if(test_tup1[i] == test_tup2[j]) { // Check for duplicates int exists = 0; for(int k = 0; k < count; k++) { if(temp[k] == test_tup1[i]) { exists = 1; break; } } if(!exists) { temp[count++] = test_tup1[i]; } break; } } } // Sort the result for(int i = 0; i < count - 1; i++) { for(int j = i + 1; j < count; j++) { if(temp[i] > temp[j]) { int swap = temp[i]; temp[i] = temp[j]; temp[j] = swap; } } } *res_size = count; return temp; }
int main() { int res_size; int* res; // First assertion int test1_a[] = {3, 4, 5, 6}; int test1_b[] = {5, 7, 4, 10}; res = func0(test1_a, 4, test1_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 4 && res[1] == 5); free(res); // Second assertion int test2_a[] = {1, 2, 3, 4}; int test2_b[] = {5, 4, 3, 7}; res = func0(test2_a, 4, test2_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 3 && res[1] == 4); free(res); // Third assertion int test3_a[] = {11, 12, 14, 13}; int test3_b[] = {17, 15, 14, 13}; res = func0(test3_a, 4, test3_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 13 && res[1] == 14); free(res); return 0; }
O1
c
func0: endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx mov %rdi,%r14 mov %esi,%r12d mov %rdx,%r13 mov %ecx,%ebp mov %r8,%rbx cmp %esi,%ecx mov %esi,%edi cmovle %ecx,%edi movslq %edi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 1208 <func0+0x5f> test %r12d,%r12d jle 12a5 <func0+0xfc> mov %r14,%r9 lea -0x1(%r12),%edx lea 0x4(%r14,%rdx,4),%r10 mov %r13,%r11 lea -0x1(%rbp),%edx lea 0x4(%r13,%rdx,4),%rsi mov $0x0,%r8d lea 0x4(%rax),%r12 jmp 1243 <func0+0x9a> movl $0x0,(%rbx) jmpq 12ae <func0+0x105> test %r8d,%r8d jle 1230 <func0+0x87> mov %rax,%rdx lea -0x1(%r8),%edi lea (%r12,%rdi,4),%rdi cmp (%rdx),%ecx je 123a <func0+0x91> add $0x4,%rdx cmp %rdi,%rdx jne 1223 <func0+0x7a> movslq %r8d,%rdx mov %ecx,(%rax,%rdx,4) lea 0x1(%r8),%r8d add $0x4,%r9 cmp %r10,%r9 je 125c <func0+0xb3> test %ebp,%ebp jle 123a <func0+0x91> mov (%r9),%ecx mov %r11,%rdx cmp (%rdx),%ecx je 1213 <func0+0x6a> add $0x4,%rdx cmp %rsi,%rdx jne 124d <func0+0xa4> jmp 123a <func0+0x91> cmp $0x1,%r8d jle 12ab <func0+0x102> mov %rax,%rdi lea -0x2(%r8),%r10d add $0x2,%r10 mov $0x1,%r9d jmp 129b <func0+0xf2> add $0x1,%rdx cmp %edx,%r8d jle 128e <func0+0xe5> mov (%rdi),%ecx mov (%rax,%rdx,4),%esi cmp %esi,%ecx jle 1275 <func0+0xcc> mov %esi,(%rdi) mov %ecx,(%rax,%rdx,4) jmp 1275 <func0+0xcc> add $0x1,%r9 add $0x4,%rdi cmp %r10,%r9 je 12ab <func0+0x102> cmp %r9d,%r8d jle 128e <func0+0xe5> mov %r9,%rdx jmp 127e <func0+0xd5> mov $0x0,%r8d mov %r8d,(%rbx) pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq
func0: endbr64 push r14 push r13 push r12 push rbp push rbx mov r14, rdi mov r13d, esi mov r12, rdx mov ebp, ecx mov rbx, r8 cmp ecx, esi mov edi, esi cmovle edi, ecx movsxd rdi, edi shl rdi, 2 call _malloc mov r10, rax test rax, rax jz loc_12CB test r13d, r13d jle loc_12B6 mov rdi, r14 lea eax, [r13-1] lea r8, [r14+rax*4+4] lea eax, [rbp-1] lea rcx, [r12+rax*4+4] mov r9d, 0 lea r11, [r10+4] jmp short loc_123C loc_120B: test r9d, r9d jle short loc_1228 mov rax, r10 lea esi, [r9-1] lea rsi, [r11+rsi*4] loc_121B: cmp edx, [rax] jz short loc_1233 add rax, 4 cmp rax, rsi jnz short loc_121B loc_1228: movsxd rax, r9d mov [r10+rax*4], edx lea r9d, [r9+1] loc_1233: add rdi, 4 cmp rdi, r8 jz short loc_1254 loc_123C: test ebp, ebp jle short loc_1233 mov edx, [rdi] mov rax, r12 loc_1245: cmp edx, [rax] jz short loc_120B add rax, 4 cmp rax, rcx jnz short loc_1245 jmp short loc_1233 loc_1254: cmp r9d, 1 jle short loc_12BC lea rsi, [r10+4] lea r11d, [r9-2] add r11, 2 mov r8d, 1 lea r12d, [r9-1] lea rbp, [r10+8] jmp short loc_129C loc_1276: add rax, 4 cmp rdi, rax jz short loc_128F loc_127F: mov edx, [rsi-4] mov ecx, [rax] cmp edx, ecx jle short loc_1276 mov [rsi-4], ecx mov [rax], edx jmp short loc_1276 loc_128F: add r8, 1 add rsi, 4 cmp r8, r11 jz short loc_12BC loc_129C: cmp r9d, r8d jle short loc_128F mov eax, r12d sub eax, r8d lea rax, [r8+rax-1] lea rdi, [rbp+rax*4+0] mov rax, rsi jmp short loc_127F loc_12B6: mov r9d, 0 loc_12BC: mov [rbx], r9d mov rax, r10 pop rbx pop rbp pop r12 pop r13 pop r14 retn loc_12CB: mov r9d, 0 jmp short loc_12BC
long long func0(int *a1, int a2, _DWORD *a3, int a4, int *a5) { int v9; // edi long long v10; // r10 int *v11; // rdi int v12; // r9d _DWORD *v13; // rax int v14; // edx _DWORD *v15; // rax _DWORD *v16; // rsi long long v17; // r8 _DWORD *v18; // rax int v19; // edx v9 = a2; if ( a4 <= a2 ) v9 = a4; v10 = malloc(4LL * v9); if ( v10 ) { if ( a2 <= 0 ) { v12 = 0; } else { v11 = a1; v12 = 0; do { if ( a4 > 0 ) { v14 = *v11; v15 = a3; while ( v14 != *v15 ) { if ( ++v15 == &a3[a4 - 1 + 1] ) goto LABEL_11; } if ( v12 <= 0 ) { LABEL_10: *(_DWORD *)(v10 + 4LL * v12++) = v14; } else { v13 = (_DWORD *)v10; while ( v14 != *v13 ) { if ( ++v13 == (_DWORD *)(v10 + 4 + 4LL * (unsigned int)(v12 - 1)) ) goto LABEL_10; } } } LABEL_11: ++v11; } while ( v11 != &a1[a2 - 1 + 1] ); if ( v12 > 1 ) { v16 = (_DWORD *)(v10 + 4); v17 = 1LL; do { if ( v12 > (int)v17 ) { v18 = v16; do { v19 = *(v16 - 1); if ( v19 > *v18 ) { *(v16 - 1) = *v18; *v18 = v19; } ++v18; } while ( (_DWORD *)(v10 + 8 + 4 * (v17 + (unsigned int)(v12 - 1 - v17) - 1)) != v18 ); } ++v17; ++v16; } while ( v17 != (unsigned int)(v12 - 2) + 2LL ); } } } else { v12 = 0; } *a5 = v12; return v10; }
func0: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R14,RDI MOV R13D,ESI MOV R12,RDX MOV EBP,ECX MOV RBX,R8 CMP ECX,ESI MOV EDI,ESI CMOVLE EDI,ECX MOVSXD RDI,EDI SHL RDI,0x2 CALL 0x001010b0 MOV R10,RAX TEST RAX,RAX JZ 0x001012cb TEST R13D,R13D JLE 0x001012b6 MOV RDI,R14 LEA EAX,[R13 + -0x1] LEA R8,[R14 + RAX*0x4 + 0x4] LEA EAX,[RBP + -0x1] LEA RCX,[R12 + RAX*0x4 + 0x4] MOV R9D,0x0 LEA R11,[R10 + 0x4] JMP 0x0010123c LAB_0010120b: TEST R9D,R9D JLE 0x00101228 MOV RAX,R10 LEA ESI,[R9 + -0x1] LEA RSI,[R11 + RSI*0x4] LAB_0010121b: CMP EDX,dword ptr [RAX] JZ 0x00101233 ADD RAX,0x4 CMP RAX,RSI JNZ 0x0010121b LAB_00101228: MOVSXD RAX,R9D MOV dword ptr [R10 + RAX*0x4],EDX LEA R9D,[R9 + 0x1] LAB_00101233: ADD RDI,0x4 CMP RDI,R8 JZ 0x00101254 LAB_0010123c: TEST EBP,EBP JLE 0x00101233 MOV EDX,dword ptr [RDI] MOV RAX,R12 LAB_00101245: CMP EDX,dword ptr [RAX] JZ 0x0010120b ADD RAX,0x4 CMP RAX,RCX JNZ 0x00101245 JMP 0x00101233 LAB_00101254: CMP R9D,0x1 JLE 0x001012bc LEA RSI,[R10 + 0x4] LEA R11D,[R9 + -0x2] ADD R11,0x2 MOV R8D,0x1 LEA R12D,[R9 + -0x1] LEA RBP,[R10 + 0x8] JMP 0x0010129c LAB_00101276: ADD RAX,0x4 CMP RDI,RAX JZ 0x0010128f LAB_0010127f: MOV EDX,dword ptr [RSI + -0x4] MOV ECX,dword ptr [RAX] CMP EDX,ECX JLE 0x00101276 MOV dword ptr [RSI + -0x4],ECX MOV dword ptr [RAX],EDX JMP 0x00101276 LAB_0010128f: ADD R8,0x1 ADD RSI,0x4 CMP R8,R11 JZ 0x001012bc LAB_0010129c: CMP R9D,R8D JLE 0x0010128f MOV EAX,R12D SUB EAX,R8D LEA RAX,[R8 + RAX*0x1 + -0x1] LEA RDI,[RBP + RAX*0x4] MOV RAX,RSI JMP 0x0010127f LAB_001012b6: MOV R9D,0x0 LAB_001012bc: MOV dword ptr [RBX],R9D MOV RAX,R10 POP RBX POP RBP POP R12 POP R13 POP R14 RET LAB_001012cb: MOV R9D,0x0 JMP 0x001012bc
int * func0(int *param_1,int param_2,int *param_3,int param_4,int *param_5) { int iVar1; int *piVar2; int *piVar3; int *piVar4; int iVar5; long lVar6; iVar5 = param_2; if (param_4 <= param_2) { iVar5 = param_4; } piVar3 = (int *)malloc((long)iVar5 << 2); if (piVar3 == (int *)0x0) { iVar5 = 0; } else { if (0 < param_2) { piVar2 = param_1 + (ulong)(param_2 - 1) + 1; iVar5 = 0; LAB_0010123c: if (0 < param_4) { iVar1 = *param_1; piVar4 = param_3; do { if (iVar1 == *piVar4) { if (iVar5 < 1) goto LAB_00101228; piVar4 = piVar3; goto LAB_0010121b; } piVar4 = piVar4 + 1; } while (piVar4 != param_3 + (ulong)(param_4 - 1) + 1); } goto LAB_00101233; } iVar5 = 0; } LAB_001012bc: *param_5 = iVar5; return piVar3; while (piVar4 = piVar4 + 1, piVar4 != piVar3 + (ulong)(iVar5 - 1) + 1) { LAB_0010121b: if (iVar1 == *piVar4) goto LAB_00101233; } LAB_00101228: piVar3[iVar5] = iVar1; iVar5 = iVar5 + 1; LAB_00101233: param_1 = param_1 + 1; if (param_1 == piVar2) goto LAB_00101254; goto LAB_0010123c; LAB_00101254: if (1 < iVar5) { lVar6 = 1; piVar2 = piVar3; do { if ((int)lVar6 < iVar5) { piVar4 = piVar2 + 1; do { iVar1 = *piVar2; if (*piVar4 < iVar1) { *piVar2 = *piVar4; *piVar4 = iVar1; } piVar4 = piVar4 + 1; } while (piVar3 + lVar6 + (ulong)(uint)((iVar5 + -1) - (int)lVar6) + 1 != piVar4); } lVar6 = lVar6 + 1; piVar2 = piVar2 + 1; } while (lVar6 != (ulong)(iVar5 - 2) + 2); } goto LAB_001012bc; }
3,902
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h> // Function to find similar elements
int* func0(int test_tup1[], int size1, int test_tup2[], int size2, int* res_size) { int* temp = (int*)malloc((size1 < size2 ? size1 : size2) * sizeof(int)); if (!temp) { *res_size = 0; return NULL; } int count = 0; for(int i = 0; i < size1; i++) { for(int j = 0; j < size2; j++) { if(test_tup1[i] == test_tup2[j]) { // Check for duplicates int exists = 0; for(int k = 0; k < count; k++) { if(temp[k] == test_tup1[i]) { exists = 1; break; } } if(!exists) { temp[count++] = test_tup1[i]; } break; } } } // Sort the result for(int i = 0; i < count - 1; i++) { for(int j = i + 1; j < count; j++) { if(temp[i] > temp[j]) { int swap = temp[i]; temp[i] = temp[j]; temp[j] = swap; } } } *res_size = count; return temp; }
int main() { int res_size; int* res; // First assertion int test1_a[] = {3, 4, 5, 6}; int test1_b[] = {5, 7, 4, 10}; res = func0(test1_a, 4, test1_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 4 && res[1] == 5); free(res); // Second assertion int test2_a[] = {1, 2, 3, 4}; int test2_b[] = {5, 4, 3, 7}; res = func0(test2_a, 4, test2_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 3 && res[1] == 4); free(res); // Third assertion int test3_a[] = {11, 12, 14, 13}; int test3_b[] = {17, 15, 14, 13}; res = func0(test3_a, 4, test3_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 13 && res[1] == 14); free(res); return 0; }
O2
c
func0: endbr64 push %r14 mov %esi,%r14d push %r13 movslq %ecx,%r13 push %r12 cmp %esi,%r13d mov %rdx,%r12 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx cmovle %r13,%rdi mov %r8,%rbx shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 152e <func0+0x11e> test %r14d,%r14d jle 1529 <func0+0x119> lea -0x1(%r14),%edx lea -0x1(%r13),%ecx mov %rbp,%r8 xor %r9d,%r9d lea 0x4(%rbp,%rdx,4),%rdx lea 0x4(%r12,%rcx,4),%r10 lea 0x4(%rax),%rbp nopl 0x0(%rax) test %r13d,%r13d jle 14ad <func0+0x9d> mov (%r8),%edi mov %r12,%rsi jmp 1489 <func0+0x79> nopl (%rax) add $0x4,%rsi cmp %r10,%rsi je 14ad <func0+0x9d> cmp (%rsi),%edi jne 1480 <func0+0x70> test %r9d,%r9d je 1510 <func0+0x100> lea -0x1(%r9),%ecx mov %rax,%rsi lea 0x0(%rbp,%rcx,4),%r11 jmp 14a9 <func0+0x99> add $0x4,%rsi cmp %r11,%rsi je 1510 <func0+0x100> cmp (%rsi),%edi jne 14a0 <func0+0x90> add $0x4,%r8 cmp %rdx,%r8 jne 1470 <func0+0x60> cmp $0x1,%r9d jle 1504 <func0+0xf4> lea -0x2(%r9),%r8d mov %rax,%rdi mov $0x1,%r10d add $0x2,%r8 nopl (%rax) cmp %r10d,%r9d jle 14f7 <func0+0xe7> mov %r10,%rdx nopl 0x0(%rax,%rax,1) mov (%rdi),%ecx mov (%rax,%rdx,4),%esi cmp %esi,%ecx jle 14ee <func0+0xde> mov %esi,(%rdi) mov %ecx,(%rax,%rdx,4) add $0x1,%rdx cmp %edx,%r9d jg 14e0 <func0+0xd0> add $0x1,%r10 add $0x4,%rdi cmp %r8,%r10 jne 14d0 <func0+0xc0> mov %r9d,(%rbx) pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq movslq %r9d,%rcx add $0x4,%r8 add $0x1,%r9d mov %edi,(%rax,%rcx,4) cmp %rdx,%r8 jne 1470 <func0+0x60> jmp 14b6 <func0+0xa6> xor %r9d,%r9d jmp 1504 <func0+0xf4> movl $0x0,(%rbx) jmp 1507 <func0+0xf7> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r14 mov r14d, esi push r13 movsxd r13, ecx push r12 cmp r13d, esi mov r12, rdx push rbp mov rbp, rdi movsxd rdi, esi push rbx cmovle rdi, r13 mov rbx, r8 shl rdi, 2 call _malloc mov r8, rax test rax, rax jz loc_1555 test r14d, r14d jle loc_1555 lea eax, [r14-1] mov rdi, rbp lea r11, [r8+4] xor r10d, r10d lea r9, [rbp+rax*4+4] lea eax, [r13-1] lea rcx, [r12+rax*4+4] nop loc_1470: test r13d, r13d jle short loc_14B9 mov edx, [rdi] mov rax, r12 jmp short loc_1489 loc_1480: add rax, 4 cmp rax, rcx jz short loc_14B9 loc_1489: cmp edx, [rax] jnz short loc_1480 test r10d, r10d jz loc_1538 lea esi, [r10-1] mov rax, r8 lea rsi, [r11+rsi*4] jmp short loc_14B5 loc_14A8: add rax, 4 cmp rax, rsi jz loc_1538 loc_14B5: cmp edx, [rax] jnz short loc_14A8 loc_14B9: add rdi, 4 cmp rdi, r9 jnz short loc_1470 loc_14C2: cmp r10d, 1 jle short loc_1524 lea r11d, [r10-2] lea rsi, [r8+4] mov r9d, 1 add r11, 2 lea r12d, [r10-1] lea rbp, [r8+8] nop word ptr [rax+rax+00h] loc_14E8: cmp r10d, r9d jle short loc_1517 mov eax, r12d sub eax, r9d lea rax, [r9+rax-1] lea rdi, [rbp+rax*4+0] mov rax, rsi loc_1500: mov edx, [rsi-4] mov ecx, [rax] cmp edx, ecx jle short loc_150E mov [rsi-4], ecx mov [rax], edx loc_150E: add rax, 4 cmp rax, rdi jnz short loc_1500 loc_1517: add r9, 1 add rsi, 4 cmp r9, r11 jnz short loc_14E8 loc_1524: mov [rbx], r10d mov rax, r8 pop rbx pop rbp pop r12 pop r13 pop r14 retn loc_1538: movsxd rax, r10d add rdi, 4 add r10d, 1 mov [r8+rax*4], edx cmp rdi, r9 jnz loc_1470 jmp loc_14C2 loc_1555: xor r10d, r10d mov rax, r8 mov [rbx], r10d pop rbx pop rbp pop r12 pop r13 pop r14 retn
long long func0(int *a1, int a2, _DWORD *a3, int a4, int *a5) { long long v8; // rdi long long result; // rax _DWORD *v11; // r8 int *v12; // rdi int v13; // r10d long long v14; // r9 int v15; // edx _DWORD *v16; // rax _DWORD *v17; // rax _DWORD *v18; // rsi long long v19; // r9 _DWORD *v20; // rax int v21; // edx long long v22; // rax v8 = a2; if ( a4 <= a2 ) v8 = a4; result = malloc(4 * v8); v11 = (_DWORD *)result; if ( !result || a2 <= 0 ) { *a5 = 0; return result; } v12 = a1; v13 = 0; v14 = (long long)&a1[a2 - 1 + 1]; do { while ( a4 <= 0 ) { LABEL_14: if ( ++v12 == (int *)v14 ) goto LABEL_15; } v15 = *v12; v16 = a3; while ( v15 != *v16 ) { if ( ++v16 == &a3[a4 - 1 + 1] ) goto LABEL_14; } if ( v13 ) { v17 = v11; while ( v15 != *v17 ) { if ( ++v17 == &v11[v13 - 1 + 1] ) goto LABEL_24; } goto LABEL_14; } LABEL_24: v22 = v13; ++v12; ++v13; v11[v22] = v15; } while ( v12 != (int *)v14 ); LABEL_15: if ( v13 > 1 ) { v18 = v11 + 1; v19 = 1LL; do { if ( v13 > (int)v19 ) { v20 = v18; do { v21 = *(v18 - 1); if ( v21 > *v20 ) { *(v18 - 1) = *v20; *v20 = v21; } ++v20; } while ( v20 != &v11[v19 + 1 + (unsigned int)(v13 - 1 - v19)] ); } ++v19; ++v18; } while ( v19 != (unsigned int)(v13 - 2) + 2LL ); } *a5 = v13; return (long long)v11; }
func0: ENDBR64 PUSH R14 MOV R14D,ESI PUSH R13 MOVSXD R13,ECX PUSH R12 CMP R13D,ESI MOV R12,RDX PUSH RBP MOV RBP,RDI MOVSXD RDI,ESI PUSH RBX CMOVLE RDI,R13 MOV RBX,R8 SHL RDI,0x2 CALL 0x001010b0 MOV R8,RAX TEST RAX,RAX JZ 0x00101555 TEST R14D,R14D JLE 0x00101555 LEA EAX,[R14 + -0x1] MOV RDI,RBP LEA R11,[R8 + 0x4] XOR R10D,R10D LEA R9,[RBP + RAX*0x4 + 0x4] LEA EAX,[R13 + -0x1] LEA RCX,[R12 + RAX*0x4 + 0x4] NOP LAB_00101470: TEST R13D,R13D JLE 0x001014b9 MOV EDX,dword ptr [RDI] MOV RAX,R12 JMP 0x00101489 LAB_00101480: ADD RAX,0x4 CMP RAX,RCX JZ 0x001014b9 LAB_00101489: CMP EDX,dword ptr [RAX] JNZ 0x00101480 TEST R10D,R10D JZ 0x00101538 LEA ESI,[R10 + -0x1] MOV RAX,R8 LEA RSI,[R11 + RSI*0x4] JMP 0x001014b5 LAB_001014a8: ADD RAX,0x4 CMP RAX,RSI JZ 0x00101538 LAB_001014b5: CMP EDX,dword ptr [RAX] JNZ 0x001014a8 LAB_001014b9: ADD RDI,0x4 CMP RDI,R9 JNZ 0x00101470 LAB_001014c2: CMP R10D,0x1 JLE 0x00101524 LEA R11D,[R10 + -0x2] LEA RSI,[R8 + 0x4] MOV R9D,0x1 ADD R11,0x2 LEA R12D,[R10 + -0x1] LEA RBP,[R8 + 0x8] NOP word ptr [RAX + RAX*0x1] LAB_001014e8: CMP R10D,R9D JLE 0x00101517 MOV EAX,R12D SUB EAX,R9D LEA RAX,[R9 + RAX*0x1 + -0x1] LEA RDI,[RBP + RAX*0x4] MOV RAX,RSI LAB_00101500: MOV EDX,dword ptr [RSI + -0x4] MOV ECX,dword ptr [RAX] CMP EDX,ECX JLE 0x0010150e MOV dword ptr [RSI + -0x4],ECX MOV dword ptr [RAX],EDX LAB_0010150e: ADD RAX,0x4 CMP RAX,RDI JNZ 0x00101500 LAB_00101517: ADD R9,0x1 ADD RSI,0x4 CMP R9,R11 JNZ 0x001014e8 LAB_00101524: MOV dword ptr [RBX],R10D MOV RAX,R8 POP RBX POP RBP POP R12 POP R13 POP R14 RET LAB_00101538: MOVSXD RAX,R10D ADD RDI,0x4 ADD R10D,0x1 MOV dword ptr [R8 + RAX*0x4],EDX CMP RDI,R9 JNZ 0x00101470 JMP 0x001014c2 LAB_00101555: XOR R10D,R10D MOV RAX,R8 MOV dword ptr [RBX],R10D POP RBX POP RBP POP R12 POP R13 POP R14 RET
int * func0(int *param_1,int param_2,int *param_3,int param_4,int *param_5) { int iVar1; int *piVar2; int *piVar3; int *piVar4; long lVar5; int iVar6; lVar5 = (long)param_2; if (param_4 <= param_2) { lVar5 = (long)param_4; } piVar3 = (int *)malloc(lVar5 << 2); if ((piVar3 == (int *)0x0) || (param_2 < 1)) { *param_5 = 0; return piVar3; } iVar6 = 0; piVar2 = param_1 + (ulong)(param_2 - 1) + 1; LAB_00101470: do { if (0 < param_4) { iVar1 = *param_1; piVar4 = param_3; do { if (iVar1 == *piVar4) { if (iVar6 == 0) goto LAB_00101538; piVar4 = piVar3; goto LAB_001014b5; } piVar4 = piVar4 + 1; } while (piVar4 != param_3 + (ulong)(param_4 - 1) + 1); } LAB_001014b9: param_1 = param_1 + 1; } while (param_1 != piVar2); goto LAB_001014c2; while (piVar4 = piVar4 + 1, piVar4 != piVar3 + (ulong)(iVar6 - 1) + 1) { LAB_001014b5: if (iVar1 == *piVar4) goto LAB_001014b9; } LAB_00101538: lVar5 = (long)iVar6; param_1 = param_1 + 1; iVar6 = iVar6 + 1; piVar3[lVar5] = iVar1; if (param_1 == piVar2) { LAB_001014c2: if (1 < iVar6) { lVar5 = 1; piVar2 = piVar3; do { if ((int)lVar5 < iVar6) { piVar4 = piVar2 + 1; do { iVar1 = *piVar2; if (*piVar4 < iVar1) { *piVar2 = *piVar4; *piVar4 = iVar1; } piVar4 = piVar4 + 1; } while (piVar4 != piVar3 + lVar5 + (ulong)(uint)((iVar6 + -1) - (int)lVar5) + 1); } lVar5 = lVar5 + 1; piVar2 = piVar2 + 1; } while (lVar5 != (ulong)(iVar6 - 2) + 2); } *param_5 = iVar6; return piVar3; } goto LAB_00101470; }
3,903
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h> // Function to find similar elements
int* func0(int test_tup1[], int size1, int test_tup2[], int size2, int* res_size) { int* temp = (int*)malloc((size1 < size2 ? size1 : size2) * sizeof(int)); if (!temp) { *res_size = 0; return NULL; } int count = 0; for(int i = 0; i < size1; i++) { for(int j = 0; j < size2; j++) { if(test_tup1[i] == test_tup2[j]) { // Check for duplicates int exists = 0; for(int k = 0; k < count; k++) { if(temp[k] == test_tup1[i]) { exists = 1; break; } } if(!exists) { temp[count++] = test_tup1[i]; } break; } } } // Sort the result for(int i = 0; i < count - 1; i++) { for(int j = i + 1; j < count; j++) { if(temp[i] > temp[j]) { int swap = temp[i]; temp[i] = temp[j]; temp[j] = swap; } } } *res_size = count; return temp; }
int main() { int res_size; int* res; // First assertion int test1_a[] = {3, 4, 5, 6}; int test1_b[] = {5, 7, 4, 10}; res = func0(test1_a, 4, test1_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 4 && res[1] == 5); free(res); // Second assertion int test2_a[] = {1, 2, 3, 4}; int test2_b[] = {5, 4, 3, 7}; res = func0(test2_a, 4, test2_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 3 && res[1] == 4); free(res); // Third assertion int test3_a[] = {11, 12, 14, 13}; int test3_b[] = {17, 15, 14, 13}; res = func0(test3_a, 4, test3_b, 4, &res_size); assert(res_size == 2); assert(res[0] == 13 && res[1] == 14); free(res); return 0; }
O3
c
func0: endbr64 push %r14 mov %esi,%r14d push %r13 movslq %ecx,%r13 push %r12 cmp %esi,%r13d mov %rdx,%r12 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx cmovle %r13,%rdi mov %r8,%rbx shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 14de <func0+0x11e> test %r14d,%r14d jle 14d9 <func0+0x119> lea -0x1(%r14),%edx lea -0x1(%r13),%ecx mov %rbp,%r8 xor %r9d,%r9d lea 0x4(%rbp,%rdx,4),%rdx lea 0x4(%r12,%rcx,4),%r10 lea 0x4(%rax),%rbp nopl 0x0(%rax) test %r13d,%r13d jle 145d <func0+0x9d> mov (%r8),%edi mov %r12,%rsi jmp 1439 <func0+0x79> nopl (%rax) add $0x4,%rsi cmp %r10,%rsi je 145d <func0+0x9d> cmp (%rsi),%edi jne 1430 <func0+0x70> test %r9d,%r9d je 14c0 <func0+0x100> lea -0x1(%r9),%ecx mov %rax,%rsi lea 0x0(%rbp,%rcx,4),%r11 jmp 1459 <func0+0x99> add $0x4,%rsi cmp %r11,%rsi je 14c0 <func0+0x100> cmp (%rsi),%edi jne 1450 <func0+0x90> add $0x4,%r8 cmp %rdx,%r8 jne 1420 <func0+0x60> cmp $0x1,%r9d jle 14b4 <func0+0xf4> lea -0x2(%r9),%r8d mov %rax,%rdi mov $0x1,%r10d add $0x2,%r8 nopl (%rax) cmp %r10d,%r9d jle 14a7 <func0+0xe7> mov %r10,%rdx nopl 0x0(%rax,%rax,1) mov (%rdi),%ecx mov (%rax,%rdx,4),%esi cmp %esi,%ecx jle 149e <func0+0xde> mov %esi,(%rdi) mov %ecx,(%rax,%rdx,4) add $0x1,%rdx cmp %edx,%r9d jg 1490 <func0+0xd0> add $0x1,%r10 add $0x4,%rdi cmp %r10,%r8 jne 1480 <func0+0xc0> mov %r9d,(%rbx) pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq movslq %r9d,%rcx add $0x4,%r8 add $0x1,%r9d mov %edi,(%rax,%rcx,4) cmp %rdx,%r8 jne 1420 <func0+0x60> jmp 1466 <func0+0xa6> xor %r9d,%r9d jmp 14b4 <func0+0xf4> movl $0x0,(%rbx) jmp 14b7 <func0+0xf7> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r14 movsxd r14, ecx push r13 movsxd r13, esi push r12 cmp r14d, r13d mov r12, rdx push rbp mov rbp, rdi movsxd rdi, r13d push rbx cmovle rdi, r14 mov rbx, r8 shl rdi, 2; size call _malloc mov r8, rax test rax, rax jz loc_150F test r13d, r13d jle loc_150F movsxd rax, r14d mov rdi, rbp lea r11, [rbp+r13*4+0] lea rcx, [r12+rax*4] loc_1412: test r14d, r14d jle loc_1502 xor r10d, r10d xchg ax, ax loc_1420: mov edx, [rdi] mov rax, r12 jmp short loc_1439 loc_1430: add rax, 4 cmp rax, rcx jz short loc_1469 loc_1439: cmp edx, [rax] jnz short loc_1430 movsxd r9, r10d test r10d, r10d jle loc_14E8 movsxd r9, r10d mov rax, r8 lea rsi, [r8+r9*4] jmp short loc_1465 loc_1458: add rax, 4 cmp rax, rsi jz loc_14E8 loc_1465: cmp edx, [rax] jnz short loc_1458 loc_1469: add rdi, 4 cmp rdi, r11 jnz short loc_1420 loc_1472: cmp r10d, 1 jle short loc_14D4 lea rsi, [r8+4] mov r11d, r10d mov r9d, 1 lea r12d, [r10-1] lea rbp, [r8+8] nop dword ptr [rax] loc_1490: cmp r10d, r9d jle short loc_14C7 mov eax, r12d sub eax, r9d lea rax, [r9+rax-1] lea rdi, [rbp+rax*4+0] mov rax, rsi nop dword ptr [rax+rax+00000000h] loc_14B0: mov edx, [rsi-4] mov ecx, [rax] cmp edx, ecx jle short loc_14BE mov [rsi-4], ecx mov [rax], edx loc_14BE: add rax, 4 cmp rax, rdi jnz short loc_14B0 loc_14C7: add r9, 1 add rsi, 4 cmp r9, r11 jnz short loc_1490 loc_14D4: mov [rbx], r10d mov rax, r8 pop rbx pop rbp pop r12 pop r13 pop r14 retn loc_14E8: add rdi, 4 mov [r8+r9*4], edx add r10d, 1 cmp rdi, r11 jnz loc_1420 jmp loc_1472 loc_1502: add rdi, 4 cmp rdi, r11 jnz loc_1412 loc_150F: xor r10d, r10d mov rax, r8 mov [rbx], r10d pop rbx pop rbp pop r12 pop r13 pop r14 retn
_DWORD * func0(int *a1, int a2, _DWORD *a3, int a4, int *a5) { long long v8; // rdi _DWORD *v10; // r8 int *v11; // rdi int *v12; // r11 int v13; // r10d int v14; // edx _DWORD *v15; // rax long long v16; // r9 _DWORD *v17; // rax _DWORD *v18; // rsi long long i; // r9 _DWORD *v20; // rax int v21; // edx _DWORD *result; // rax v8 = a2; if ( a4 <= a2 ) v8 = a4; v10 = malloc(4 * v8); if ( v10 && a2 > 0 ) { v11 = a1; v12 = &a1[a2]; while ( a4 <= 0 ) { if ( ++v11 == v12 ) goto LABEL_28; } v13 = 0; while ( 2 ) { while ( 2 ) { v14 = *v11; v15 = a3; while ( v14 != *v15 ) { if ( ++v15 == &a3[a4] ) goto LABEL_15; } v16 = v13; if ( v13 > 0 ) { v16 = v13; v17 = v10; while ( v14 != *v17 ) { if ( ++v17 == &v10[v13] ) goto LABEL_25; } LABEL_15: if ( ++v11 != v12 ) continue; goto LABEL_16; } break; } LABEL_25: ++v11; v10[v16] = v14; ++v13; if ( v11 != v12 ) continue; break; } LABEL_16: if ( v13 > 1 ) { v18 = v10 + 1; for ( i = 1LL; i != v13; ++i ) { if ( v13 > (int)i ) { v20 = v18; do { v21 = *(v18 - 1); if ( v21 > *v20 ) { *(v18 - 1) = *v20; *v20 = v21; } ++v20; } while ( v20 != &v10[i + 1 + (unsigned int)(v13 - 1 - i)] ); } ++v18; } } *a5 = v13; return v10; } else { LABEL_28: result = v10; *a5 = 0; } return result; }
func0: ENDBR64 PUSH R14 MOVSXD R14,ECX PUSH R13 MOVSXD R13,ESI PUSH R12 CMP R14D,R13D MOV R12,RDX PUSH RBP MOV RBP,RDI MOVSXD RDI,R13D PUSH RBX CMOVLE RDI,R14 MOV RBX,R8 SHL RDI,0x2 CALL 0x001010b0 MOV R8,RAX TEST RAX,RAX JZ 0x0010150f TEST R13D,R13D JLE 0x0010150f MOVSXD RAX,R14D MOV RDI,RBP LEA R11,[RBP + R13*0x4] LEA RCX,[R12 + RAX*0x4] LAB_00101412: TEST R14D,R14D JLE 0x00101502 XOR R10D,R10D NOP LAB_00101420: MOV EDX,dword ptr [RDI] MOV RAX,R12 JMP 0x00101439 LAB_00101430: ADD RAX,0x4 CMP RAX,RCX JZ 0x00101469 LAB_00101439: CMP EDX,dword ptr [RAX] JNZ 0x00101430 MOVSXD R9,R10D TEST R10D,R10D JLE 0x001014e8 MOVSXD R9,R10D MOV RAX,R8 LEA RSI,[R8 + R9*0x4] JMP 0x00101465 LAB_00101458: ADD RAX,0x4 CMP RAX,RSI JZ 0x001014e8 LAB_00101465: CMP EDX,dword ptr [RAX] JNZ 0x00101458 LAB_00101469: ADD RDI,0x4 CMP RDI,R11 JNZ 0x00101420 LAB_00101472: CMP R10D,0x1 JLE 0x001014d4 LEA RSI,[R8 + 0x4] MOV R11D,R10D MOV R9D,0x1 LEA R12D,[R10 + -0x1] LEA RBP,[R8 + 0x8] NOP dword ptr [RAX] LAB_00101490: CMP R10D,R9D JLE 0x001014c7 MOV EAX,R12D SUB EAX,R9D LEA RAX,[R9 + RAX*0x1 + -0x1] LEA RDI,[RBP + RAX*0x4] MOV RAX,RSI NOP dword ptr [RAX + RAX*0x1] LAB_001014b0: MOV EDX,dword ptr [RSI + -0x4] MOV ECX,dword ptr [RAX] CMP EDX,ECX JLE 0x001014be MOV dword ptr [RSI + -0x4],ECX MOV dword ptr [RAX],EDX LAB_001014be: ADD RAX,0x4 CMP RAX,RDI JNZ 0x001014b0 LAB_001014c7: ADD R9,0x1 ADD RSI,0x4 CMP R9,R11 JNZ 0x00101490 LAB_001014d4: MOV dword ptr [RBX],R10D MOV RAX,R8 POP RBX POP RBP POP R12 POP R13 POP R14 RET LAB_001014e8: ADD RDI,0x4 MOV dword ptr [R8 + R9*0x4],EDX ADD R10D,0x1 CMP RDI,R11 JNZ 0x00101420 JMP 0x00101472 LAB_00101502: ADD RDI,0x4 CMP RDI,R11 JNZ 0x00101412 LAB_0010150f: XOR R10D,R10D MOV RAX,R8 MOV dword ptr [RBX],R10D POP RBX POP RBP POP R12 POP R13 POP R14 RET
int * func0(int *param_1,int param_2,int *param_3,int param_4,uint *param_5) { int iVar1; int *piVar2; int *piVar3; int *piVar4; long lVar5; ulong uVar6; uint uVar7; lVar5 = (long)param_2; if (param_4 <= param_2) { lVar5 = (long)param_4; } piVar3 = (int *)malloc(lVar5 << 2); if ((piVar3 != (int *)0x0) && (0 < param_2)) { piVar2 = param_1 + param_2; do { if (0 < param_4) { uVar7 = 0; goto LAB_00101420; } param_1 = param_1 + 1; } while (param_1 != piVar2); } *param_5 = 0; return piVar3; LAB_00101420: do { iVar1 = *param_1; piVar4 = param_3; do { if (iVar1 == *piVar4) { if ((int)uVar7 < 1) goto LAB_001014e8; piVar4 = piVar3; goto LAB_00101465; } piVar4 = piVar4 + 1; } while (piVar4 != param_3 + param_4); LAB_00101469: param_1 = param_1 + 1; } while (param_1 != piVar2); goto LAB_00101472; while (piVar4 = piVar4 + 1, piVar4 != piVar3 + (int)uVar7) { LAB_00101465: if (iVar1 == *piVar4) goto LAB_00101469; } LAB_001014e8: param_1 = param_1 + 1; piVar3[(int)uVar7] = iVar1; uVar7 = uVar7 + 1; if (param_1 == piVar2) { LAB_00101472: if (1 < (int)uVar7) { uVar6 = 1; piVar2 = piVar3; do { if ((int)uVar6 < (int)uVar7) { piVar4 = piVar2 + 1; do { iVar1 = *piVar2; if (*piVar4 < iVar1) { *piVar2 = *piVar4; *piVar4 = iVar1; } piVar4 = piVar4 + 1; } while (piVar4 != piVar3 + uVar6 + ((uVar7 - 1) - (int)uVar6) + 1); } uVar6 = uVar6 + 1; piVar2 = piVar2 + 1; } while (uVar6 != uVar7); } *param_5 = uVar7; return piVar3; } goto LAB_00101420; }
3,904
func0
#include <stdio.h> #include <math.h> #include <assert.h>
int func0(int n) { int result = 0; for (int i = 2; i <= (int)sqrt(n); i++) { if (n % i == 0) { result = 1; } } return result; }
int main() { assert(func0(2) == 0); assert(func0(10) == 1); assert(func0(35) == 1); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %edi,-0x14(%rbp) movl $0x0,-0x8(%rbp) movl $0x2,-0x4(%rbp) jmp 11a0 <func0+0x37> mov -0x14(%rbp),%eax cltd idivl -0x4(%rbp) mov %edx,%eax test %eax,%eax jne 119c <func0+0x33> movl $0x1,-0x8(%rbp) addl $0x1,-0x4(%rbp) cvtsi2sdl -0x14(%rbp),%xmm0 callq 1070 <sqrt@plt> cvttsd2si %xmm0,%eax cmp %eax,-0x4(%rbp) jle 1188 <func0+0x1f> mov -0x8(%rbp),%eax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_14], edi mov [rbp+var_8], 0 mov [rbp+var_4], 2 jmp short loc_11A0 loc_1188: mov eax, [rbp+var_14] cdq idiv [rbp+var_4] mov eax, edx test eax, eax jnz short loc_119C mov [rbp+var_8], 1 loc_119C: add [rbp+var_4], 1 loc_11A0: pxor xmm1, xmm1 cvtsi2sd xmm1, [rbp+var_14] movq rax, xmm1 movq xmm0, rax; x call _sqrt cvttsd2si eax, xmm0 cmp [rbp+var_4], eax jle short loc_1188 mov eax, [rbp+var_8] leave retn
long long func0(int a1) { unsigned int v2; // [rsp+18h] [rbp-8h] int i; // [rsp+1Ch] [rbp-4h] v2 = 0; for ( i = 2; i <= (int)sqrt((double)a1); ++i ) { if ( !(a1 % i) ) v2 = 1; } return v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x2 JMP 0x001011a0 LAB_00101188: MOV EAX,dword ptr [RBP + -0x14] CDQ IDIV dword ptr [RBP + -0x4] MOV EAX,EDX TEST EAX,EAX JNZ 0x0010119c MOV dword ptr [RBP + -0x8],0x1 LAB_0010119c: ADD dword ptr [RBP + -0x4],0x1 LAB_001011a0: PXOR XMM1,XMM1 CVTSI2SD XMM1,dword ptr [RBP + -0x14] MOVQ RAX,XMM1 MOVQ XMM0,RAX CALL 0x00101070 CVTTSD2SI EAX,XMM0 CMP dword ptr [RBP + -0x4],EAX JLE 0x00101188 MOV EAX,dword ptr [RBP + -0x8] LEAVE RET
int4 func0(int param_1) { double dVar1; int4 local_10; int4 local_c; local_10 = 0; local_c = 2; while( true ) { dVar1 = sqrt((double)param_1); if ((int)dVar1 < local_c) break; if (param_1 % local_c == 0) { local_10 = 1; } local_c = local_c + 1; } return local_10; }
3,905
func0
#include <stdio.h> #include <math.h> #include <assert.h>
int func0(int n) { int result = 0; for (int i = 2; i <= (int)sqrt(n); i++) { if (n % i == 0) { result = 1; } } return result; }
int main() { assert(func0(2) == 0); assert(func0(10) == 1); assert(func0(35) == 1); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x18,%rsp mov %edi,%ebp pxor %xmm3,%xmm3 cvtsi2sd %edi,%xmm3 movsd %xmm3,0x8(%rsp) movapd %xmm3,%xmm0 sqrtsd %xmm0,%xmm0 cvttsd2si %xmm0,%r13d mov $0x2,%ebx mov $0x0,%r12d pxor %xmm1,%xmm1 ucomisd 0x8(%rsp),%xmm1 ja 11c5 <func0+0x5c> cmp %ebx,%r13d jl 11d2 <func0+0x69> mov %ebp,%eax cltd idiv %ebx test %edx,%edx mov $0x1,%eax cmove %eax,%r12d add $0x1,%ebx jmp 119f <func0+0x36> movsd 0x8(%rsp),%xmm0 callq 1070 <sqrt@plt> jmp 11ab <func0+0x42> mov %r12d,%eax add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq
func0: endbr64 push r12 push rbp push rbx mov ebp, edi mov ebx, 2 mov r12d, 0 jmp short loc_1193 loc_1180: mov eax, ebp cdq idiv ebx test edx, edx mov eax, 1 cmovz r12d, eax add ebx, 1 loc_1193: pxor xmm0, xmm0 cvtsi2sd xmm0, ebp pxor xmm1, xmm1 ucomisd xmm1, xmm0 ja short loc_11B9 sqrtsd xmm0, xmm0 loc_11A9: cvttsd2si eax, xmm0 cmp eax, ebx jge short loc_1180 mov eax, r12d pop rbx pop rbp pop r12 retn loc_11B9: call _sqrt jmp short loc_11A9
long long func0(int a1) { int v1; // ebx unsigned int v2; // r12d double v3; // xmm0_8 double v4; // xmm0_8 v1 = 2; v2 = 0; while ( 1 ) { v3 = (double)a1; v4 = (double)a1 < 0.0 ? sqrt(v3) : sqrt(v3); if ( (int)v4 < v1 ) break; if ( !(a1 % v1) ) v2 = 1; ++v1; } return v2; }
func0: ENDBR64 PUSH R12 PUSH RBP PUSH RBX MOV EBP,EDI MOV EBX,0x2 MOV R12D,0x0 JMP 0x00101193 LAB_00101180: MOV EAX,EBP CDQ IDIV EBX TEST EDX,EDX MOV EAX,0x1 CMOVZ R12D,EAX ADD EBX,0x1 LAB_00101193: PXOR XMM0,XMM0 CVTSI2SD XMM0,EBP PXOR XMM1,XMM1 UCOMISD XMM1,XMM0 JA 0x001011b9 SQRTSD XMM0,XMM0 LAB_001011a9: CVTTSD2SI EAX,XMM0 CMP EAX,EBX JGE 0x00101180 MOV EAX,R12D POP RBX POP RBP POP R12 RET LAB_001011b9: CALL 0x00101070 JMP 0x001011a9
int4 func0(int param_1) { int iVar1; int4 uVar2; double dVar3; iVar1 = 2; uVar2 = 0; while( true ) { dVar3 = (double)param_1; if (dVar3 < 0.0) { dVar3 = sqrt(dVar3); } else { dVar3 = SQRT(dVar3); } if ((int)dVar3 < iVar1) break; if (param_1 % iVar1 == 0) { uVar2 = 1; } iVar1 = iVar1 + 1; } return uVar2; }
3,906
func0
#include <stdio.h> #include <math.h> #include <assert.h>
int func0(int n) { int result = 0; for (int i = 2; i <= (int)sqrt(n); i++) { if (n % i == 0) { result = 1; } } return result; }
int main() { assert(func0(2) == 0); assert(func0(10) == 1); assert(func0(35) == 1); return 0; }
O2
c
func0: endbr64 pxor %xmm1,%xmm1 push %r13 pxor %xmm2,%xmm2 mov $0x1,%r13d cvtsi2sd %edi,%xmm1 push %r12 xor %r12d,%r12d push %rbp push %rbx mov $0x2,%ebx movapd %xmm1,%xmm0 sqrtsd %xmm0,%xmm0 sub $0x18,%rsp cvttsd2si %xmm0,%ebp jmp 11ae <func0+0x4e> nopw %cs:0x0(%rax,%rax,1) mov %edi,%eax cltd idiv %ebx test %edx,%edx cmove %r13d,%r12d add $0x1,%ebx ucomisd %xmm1,%xmm2 ja 11c6 <func0+0x66> cmp %ebx,%ebp jge 11a0 <func0+0x40> add $0x18,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 retq movapd %xmm1,%xmm0 mov %edi,0xc(%rsp) movsd %xmm1,(%rsp) callq 1050 <sqrt@plt> mov 0xc(%rsp),%edi movsd (%rsp),%xmm1 pxor %xmm2,%xmm2 jmp 11b4 <func0+0x54> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r12 pxor xmm1, xmm1 xor r12d, r12d pxor xmm2, xmm2 push rbp cvtsi2sd xmm1, edi mov ebp, 1 push rbx mov ebx, 2 sub rsp, 10h jmp short loc_124E loc_1240: mov eax, edi cdq idiv ebx test edx, edx cmovz r12d, ebp add ebx, 1 loc_124E: ucomisd xmm2, xmm1 ja short loc_1270 movapd xmm0, xmm1 sqrtsd xmm0, xmm0 loc_125C: cvttsd2si eax, xmm0 cmp eax, ebx jge short loc_1240 add rsp, 10h mov eax, r12d pop rbx pop rbp pop r12 retn loc_1270: movapd xmm0, xmm1 mov [rsp+28h+var_1C], edi movsd [rsp+28h+var_28], xmm1 call _sqrt mov edi, [rsp+28h+var_1C] movsd xmm1, [rsp+28h+var_28] pxor xmm2, xmm2 jmp short loc_125C
long long func0(int a1) { unsigned int v1; // r12d double v2; // xmm1_8 int i; // ebx double v4; // xmm0_8 v1 = 0; v2 = (double)a1; for ( i = 2; ; ++i ) { v4 = v2 < 0.0 ? sqrt(v2) : sqrt(v2); if ( (int)v4 < i ) break; if ( !(a1 % i) ) v1 = 1; } return v1; }
func0: ENDBR64 PUSH R12 PXOR XMM1,XMM1 XOR R12D,R12D PXOR XMM2,XMM2 PUSH RBP CVTSI2SD XMM1,EDI MOV EBP,0x1 PUSH RBX MOV EBX,0x2 SUB RSP,0x10 JMP 0x0010124e LAB_00101240: MOV EAX,EDI CDQ IDIV EBX TEST EDX,EDX CMOVZ R12D,EBP ADD EBX,0x1 LAB_0010124e: UCOMISD XMM2,XMM1 JA 0x00101270 MOVAPD XMM0,XMM1 SQRTSD XMM0,XMM0 LAB_0010125c: CVTTSD2SI EAX,XMM0 CMP EAX,EBX JGE 0x00101240 ADD RSP,0x10 MOV EAX,R12D POP RBX POP RBP POP R12 RET LAB_00101270: MOVAPD XMM0,XMM1 MOV dword ptr [RSP + 0xc],EDI MOVSD qword ptr [RSP],XMM1 CALL 0x00101070 MOV EDI,dword ptr [RSP + 0xc] MOVSD XMM1,qword ptr [RSP] PXOR XMM2,XMM2 JMP 0x0010125c
int4 func0(int param_1) { int iVar1; int4 uVar2; double dVar3; double __x; uVar2 = 0; __x = (double)param_1; iVar1 = 2; while( true ) { if (__x < 0.0) { dVar3 = sqrt(__x); } else { dVar3 = SQRT(__x); } if ((int)dVar3 < iVar1) break; if (param_1 % iVar1 == 0) { uVar2 = 1; } iVar1 = iVar1 + 1; } return uVar2; }
3,907
func0
#include <stdio.h> #include <math.h> #include <assert.h>
int func0(int n) { int result = 0; for (int i = 2; i <= (int)sqrt(n); i++) { if (n % i == 0) { result = 1; } } return result; }
int main() { assert(func0(2) == 0); assert(func0(10) == 1); assert(func0(35) == 1); return 0; }
O3
c
func0: endbr64 pxor %xmm1,%xmm1 push %r13 cvtsi2sd %edi,%xmm1 push %r12 push %rbp push %rbx movapd %xmm1,%xmm0 sqrtsd %xmm0,%xmm0 sub $0x18,%rsp cvttsd2si %xmm0,%ebx pxor %xmm0,%xmm0 ucomisd %xmm1,%xmm0 ja 11c9 <func0+0x69> lea 0x1(%rbx),%r8d mov $0x2,%ecx xor %r12d,%r12d mov $0x1,%esi cmp $0x1,%ebx jle 11bb <func0+0x5b> nopw 0x0(%rax,%rax,1) mov %edi,%eax cltd idiv %ecx test %edx,%edx cmove %esi,%r12d add $0x1,%ecx cmp %ecx,%r8d jne 11a8 <func0+0x48> add $0x18,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 retq mov $0x2,%ebp xor %r12d,%r12d mov $0x1,%r13d jmp 11f0 <func0+0x90> mov 0xc(%rsp),%edi movsd (%rsp),%xmm1 mov %edi,%eax cltd idiv %ebp test %edx,%edx cmove %r13d,%r12d add $0x1,%ebp movapd %xmm1,%xmm0 mov %edi,0xc(%rsp) movsd %xmm1,(%rsp) callq 1050 <sqrt@plt> cmp %ebp,%ebx jge 11d9 <func0+0x79> jmp 11bb <func0+0x5b> nopl 0x0(%rax,%rax,1)
func0: endbr64 pxor xmm1, xmm1 push r13 pxor xmm0, xmm0 cvtsi2sd xmm1, edi push r12 push rbp push rbx mov ebx, edi sub rsp, 18h ucomisd xmm0, xmm1 ja short loc_11BE sqrtsd xmm1, xmm1 mov ecx, 2 xor ebp, ebp mov edi, 1 cvttsd2si esi, xmm1 cmp esi, 1 jle short loc_11B1 nop dword ptr [rax+rax+00h] loc_11A0: mov eax, ebx cdq idiv ecx test edx, edx cmovz ebp, edi add ecx, 1 cmp esi, ecx jge short loc_11A0 loc_11B1: add rsp, 18h mov eax, ebp pop rbx pop rbp pop r12 pop r13 retn loc_11BE: mov r12d, 2 xor ebp, ebp mov r13d, 1 jmp short loc_11E4 loc_11CE: mov eax, ebx movsd xmm1, [rsp+38h+var_30] cdq idiv r12d test edx, edx cmovz ebp, r13d add r12d, 1 loc_11E4: movapd xmm0, xmm1; x movsd [rsp+38h+var_30], xmm1 call _sqrt cvttsd2si eax, xmm0 cmp r12d, eax jle short loc_11CE jmp short loc_11B1
long long func0(int a1) { double v1; // xmm1_8 int v2; // ecx unsigned int v3; // ebp int v4; // esi int v6; // r12d v1 = (double)a1; if ( (double)a1 < 0.0 ) { v6 = 2; v3 = 0; while ( v6 <= (int)sqrt(v1) ) { if ( !(a1 % v6) ) v3 = 1; ++v6; } } else { v2 = 2; v3 = 0; v4 = (int)sqrt(v1); if ( v4 > 1 ) { do { if ( !(a1 % v2) ) v3 = 1; ++v2; } while ( v4 >= v2 ); } } return v3; }
func0: ENDBR64 PXOR XMM1,XMM1 PUSH R13 PXOR XMM0,XMM0 CVTSI2SD XMM1,EDI PUSH R12 PUSH RBP PUSH RBX MOV EBX,EDI SUB RSP,0x18 UCOMISD XMM0,XMM1 JA 0x001011be SQRTSD XMM1,XMM1 MOV ECX,0x2 XOR EBP,EBP MOV EDI,0x1 CVTTSD2SI ESI,XMM1 CMP ESI,0x1 JLE 0x001011b1 NOP dword ptr [RAX + RAX*0x1] LAB_001011a0: MOV EAX,EBX CDQ IDIV ECX TEST EDX,EDX CMOVZ EBP,EDI ADD ECX,0x1 CMP ESI,ECX JGE 0x001011a0 LAB_001011b1: ADD RSP,0x18 MOV EAX,EBP POP RBX POP RBP POP R12 POP R13 RET LAB_001011be: MOV R12D,0x2 XOR EBP,EBP MOV R13D,0x1 JMP 0x001011e4 LAB_001011ce: MOV EAX,EBX MOVSD XMM1,qword ptr [RSP + 0x8] CDQ IDIV R12D TEST EDX,EDX CMOVZ EBP,R13D ADD R12D,0x1 LAB_001011e4: MOVAPD XMM0,XMM1 MOVSD qword ptr [RSP + 0x8],XMM1 CALL 0x00101050 CVTTSD2SI EAX,XMM0 CMP R12D,EAX JLE 0x001011ce JMP 0x001011b1
int8 func0(int param_1) { int iVar1; int8 uVar2; double dVar3; double __x; __x = (double)param_1; if (__x < 0.0) { uVar2 = 0; for (iVar1 = 2; dVar3 = sqrt(__x), iVar1 <= (int)dVar3; iVar1 = iVar1 + 1) { if (param_1 % iVar1 == 0) { uVar2 = 1; } } } else { iVar1 = 2; uVar2 = 0; if (1 < (int)SQRT(__x)) { do { if (param_1 % iVar1 == 0) { uVar2 = 1; } iVar1 = iVar1 + 1; } while (iVar1 <= (int)SQRT(__x)); } } return uVar2; }
3,908
func0
#include <assert.h> #include <stdlib.h> int compare(const void * a, const void * b) { return ( *(int*)b - *(int*)a ); }
void func0(int nums[], int size, int n, int result[]) { qsort(nums, size, sizeof(int), compare); for(int i = 0; i < n; i++) { result[i] = nums[i]; } }
int main() { int test1[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result1[3]; func0(test1, 9, 3, result1); assert(result1[0] == 85 && result1[1] == 75 && result1[2] == 65); int test2[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result2[2]; func0(test2, 9, 2, result2); assert(result2[0] == 85 && result2[1] == 75); int test3[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result3[5]; func0(test3, 9, 5, result3); assert(result3[0] == 85 && result3[1] == 75 && result3[2] == 65 && result3[3] == 58 && result3[4] == 35); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov %edx,-0x20(%rbp) mov %rcx,-0x28(%rbp) mov -0x1c(%rbp),%eax movslq %eax,%rsi mov -0x18(%rbp),%rax lea -0x4d(%rip),%rcx mov $0x4,%edx mov %rax,%rdi callq 1070 <qsort@plt> movl $0x0,-0x4(%rbp) jmp 121d <func0+0x72> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0x4(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x20(%rbp),%eax jl 11ec <func0+0x41> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+base], rdi mov [rbp+var_1C], esi mov [rbp+var_20], edx mov [rbp+var_28], rcx mov eax, [rbp+var_1C] movsxd rsi, eax; nmemb mov rax, [rbp+base] lea rdx, compare mov rcx, rdx; compar mov edx, 4; size mov rdi, rax; base call _qsort mov [rbp+var_4], 0 jmp short loc_1220 loc_11EF: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+base] add rax, rdx mov edx, [rbp+var_4] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax add [rbp+var_4], 1 loc_1220: mov eax, [rbp+var_4] cmp eax, [rbp+var_20] jl short loc_11EF nop nop leave retn
long long func0(void *a1, int a2, int a3, long long a4) { long long result; // rax unsigned int i; // [rsp+2Ch] [rbp-4h] qsort(a1, a2, 4uLL, compare); for ( i = 0; ; ++i ) { result = i; if ( (int)i >= a3 ) break; *(_DWORD *)(4LL * (int)i + a4) = *((_DWORD *)a1 + (int)i); } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV dword ptr [RBP + -0x20],EDX MOV qword ptr [RBP + -0x28],RCX MOV EAX,dword ptr [RBP + -0x1c] MOVSXD RSI,EAX MOV RAX,qword ptr [RBP + -0x18] LEA RDX,[0x101189] MOV RCX,RDX MOV EDX,0x4 MOV RDI,RAX CALL 0x00101070 MOV dword ptr [RBP + -0x4],0x0 JMP 0x00101220 LAB_001011ef: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x4] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX ADD dword ptr [RBP + -0x4],0x1 LAB_00101220: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x20] JL 0x001011ef NOP NOP LEAVE RET
void func0(void *param_1,int param_2,int param_3,long param_4) { int local_c; qsort(param_1,(long)param_2,4,compare); for (local_c = 0; local_c < param_3; local_c = local_c + 1) { *(int4 *)(param_4 + (long)local_c * 4) = *(int4 *)((long)param_1 + (long)local_c * 4); } return; }
3,909
func0
#include <assert.h> #include <stdlib.h> int compare(const void * a, const void * b) { return ( *(int*)b - *(int*)a ); }
void func0(int nums[], int size, int n, int result[]) { qsort(nums, size, sizeof(int), compare); for(int i = 0; i < n; i++) { result[i] = nums[i]; } }
int main() { int test1[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result1[3]; func0(test1, 9, 3, result1); assert(result1[0] == 85 && result1[1] == 75 && result1[2] == 65); int test2[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result2[2]; func0(test2, 9, 2, result2); assert(result2[0] == 85 && result2[1] == 75); int test3[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result3[5]; func0(test3, 9, 5, result3); assert(result3[0] == 85 && result3[1] == 75 && result3[2] == 65 && result3[3] == 58 && result3[4] == 35); return 0; }
O1
c
func0: endbr64 push %r12 push %rbp push %rbx mov %rdi,%rbx mov %edx,%r12d mov %rcx,%rbp movslq %esi,%rsi lea -0x24(%rip),%rcx mov $0x4,%edx callq 1070 <qsort@plt> test %r12d,%r12d jle 11d9 <func0+0x47> lea -0x1(%r12),%ecx mov $0x0,%eax mov (%rbx,%rax,4),%edx mov %edx,0x0(%rbp,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 11c6 <func0+0x34> pop %rbx pop %rbp pop %r12 retq
func0: endbr64 push r12 push rbp push rbx mov rbp, rdi mov ebx, edx mov r12, rcx movsxd rsi, esi lea rcx, compare mov edx, 4 call _qsort test ebx, ebx jle short loc_11D2 mov ecx, ebx mov eax, 0 loc_11C1: mov edx, [rbp+rax*4+0] mov [r12+rax*4], edx add rax, 1 cmp rax, rcx jnz short loc_11C1 loc_11D2: pop rbx pop rbp pop r12 retn
long long func0(long long a1, int a2, int a3, long long a4) { long long result; // rax result = qsort(a1, a2, 4LL, compare); if ( a3 > 0 ) { result = 0LL; do { *(_DWORD *)(a4 + 4 * result) = *(_DWORD *)(a1 + 4 * result); ++result; } while ( result != a3 ); } return result; }
func0: ENDBR64 PUSH R12 PUSH RBP PUSH RBX MOV RBP,RDI MOV EBX,EDX MOV R12,RCX MOVSXD RSI,ESI LEA RCX,[0x101189] MOV EDX,0x4 CALL 0x00101070 TEST EBX,EBX JLE 0x001011d2 MOV ECX,EBX MOV EAX,0x0 LAB_001011c1: MOV EDX,dword ptr [RBP + RAX*0x4] MOV dword ptr [R12 + RAX*0x4],EDX ADD RAX,0x1 CMP RAX,RCX JNZ 0x001011c1 LAB_001011d2: POP RBX POP RBP POP R12 RET
void func0(void *param_1,int param_2,uint param_3,long param_4) { ulong uVar1; qsort(param_1,(long)param_2,4,compare); if (0 < (int)param_3) { uVar1 = 0; do { *(int4 *)(param_4 + uVar1 * 4) = *(int4 *)((long)param_1 + uVar1 * 4); uVar1 = uVar1 + 1; } while (uVar1 != param_3); } return; }
3,910
func0
#include <assert.h> #include <stdlib.h> int compare(const void * a, const void * b) { return ( *(int*)b - *(int*)a ); }
void func0(int nums[], int size, int n, int result[]) { qsort(nums, size, sizeof(int), compare); for(int i = 0; i < n; i++) { result[i] = nums[i]; } }
int main() { int test1[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result1[3]; func0(test1, 9, 3, result1); assert(result1[0] == 85 && result1[1] == 75 && result1[2] == 65); int test2[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result2[2]; func0(test2, 9, 2, result2); assert(result2[0] == 85 && result2[1] == 75); int test3[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result3[5]; func0(test3, 9, 5, result3); assert(result3[0] == 85 && result3[1] == 75 && result3[2] == 65 && result3[3] == 58 && result3[4] == 35); return 0; }
O2
c
func0: endbr64 push %r12 movslq %esi,%rsi mov %edx,%r12d mov $0x4,%edx push %rbp mov %rcx,%rbp lea -0x2c(%rip),%rcx push %rbx mov %rdi,%rbx callq 1070 <qsort@plt> test %r12d,%r12d jle 13db <func0+0x4b> lea -0x1(%r12),%ecx xor %eax,%eax nopl 0x0(%rax) mov (%rbx,%rax,4),%edx mov %edx,0x0(%rbp,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 13c8 <func0+0x38> pop %rbx pop %rbp pop %r12 retq
func0: endbr64 push r12 movsxd rsi, esi mov r12, rcx lea rcx, compare push rbp mov rbp, rdi push rbx mov ebx, edx mov edx, 4 call _qsort test ebx, ebx jle short loc_13D1 movsxd rdx, ebx xor eax, eax nop dword ptr [rax] loc_13C0: mov ecx, [rbp+rax*4+0] mov [r12+rax*4], ecx add rax, 1 cmp rax, rdx jnz short loc_13C0 loc_13D1: pop rbx pop rbp pop r12 retn
long long func0(long long a1, int a2, int a3, long long a4) { long long result; // rax result = qsort(a1, a2, 4LL, compare); if ( a3 > 0 ) { result = 0LL; do { *(_DWORD *)(a4 + 4 * result) = *(_DWORD *)(a1 + 4 * result); ++result; } while ( result != a3 ); } return result; }
func0: ENDBR64 PUSH R12 MOVSXD RSI,ESI MOV R12,RCX LEA RCX,[0x101380] PUSH RBP MOV RBP,RDI PUSH RBX MOV EBX,EDX MOV EDX,0x4 CALL 0x00101070 TEST EBX,EBX JLE 0x001013d1 MOVSXD RDX,EBX XOR EAX,EAX NOP dword ptr [RAX] LAB_001013c0: MOV ECX,dword ptr [RBP + RAX*0x4] MOV dword ptr [R12 + RAX*0x4],ECX ADD RAX,0x1 CMP RAX,RDX JNZ 0x001013c0 LAB_001013d1: POP RBX POP RBP POP R12 RET
void func0(void *param_1,int param_2,int param_3,long param_4) { long lVar1; qsort(param_1,(long)param_2,4,compare); if (0 < param_3) { lVar1 = 0; do { *(int4 *)(param_4 + lVar1 * 4) = *(int4 *)((long)param_1 + lVar1 * 4); lVar1 = lVar1 + 1; } while (lVar1 != param_3); } return; }
3,911
func0
#include <assert.h> #include <stdlib.h> int compare(const void * a, const void * b) { return ( *(int*)b - *(int*)a ); }
void func0(int nums[], int size, int n, int result[]) { qsort(nums, size, sizeof(int), compare); for(int i = 0; i < n; i++) { result[i] = nums[i]; } }
int main() { int test1[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result1[3]; func0(test1, 9, 3, result1); assert(result1[0] == 85 && result1[1] == 75 && result1[2] == 65); int test2[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result2[2]; func0(test2, 9, 2, result2); assert(result2[0] == 85 && result2[1] == 75); int test3[9] = {25, 35, 22, 85, 14, 65, 75, 22, 58}; int result3[5]; func0(test3, 9, 5, result3); assert(result3[0] == 85 && result3[1] == 75 && result3[2] == 65 && result3[3] == 58 && result3[4] == 35); return 0; }
O3
c
func0: endbr64 push %r12 movslq %esi,%rsi mov %edx,%r12d mov $0x4,%edx push %rbp mov %rcx,%rbp lea -0x2c(%rip),%rcx push %rbx mov %rdi,%rbx callq 1070 <qsort@plt> test %r12d,%r12d jle 13fb <func0+0x9b> lea 0xf(%rbx),%rdx lea -0x1(%r12),%eax sub %rbp,%rdx cmp $0x1e,%rdx jbe 1400 <func0+0xa0> cmp $0x3,%eax jbe 1400 <func0+0xa0> mov %r12d,%edx xor %eax,%eax shr $0x2,%edx shl $0x4,%rdx nopl (%rax) movdqu (%rbx,%rax,1),%xmm0 movups %xmm0,0x0(%rbp,%rax,1) add $0x10,%rax cmp %rdx,%rax jne 13b0 <func0+0x50> mov %r12d,%eax and $0xfffffffc,%eax test $0x3,%r12b je 13fb <func0+0x9b> mov %eax,%edx mov (%rbx,%rdx,4),%ecx mov %ecx,0x0(%rbp,%rdx,4) lea 0x1(%rax),%edx cmp %edx,%r12d jle 13fb <func0+0x9b> movslq %edx,%rdx add $0x2,%eax mov (%rbx,%rdx,4),%ecx mov %ecx,0x0(%rbp,%rdx,4) cmp %eax,%r12d jle 13fb <func0+0x9b> cltq mov (%rbx,%rax,4),%edx mov %edx,0x0(%rbp,%rax,4) pop %rbx pop %rbp pop %r12 retq mov %eax,%edx xor %eax,%eax nopl 0x0(%rax) mov (%rbx,%rax,4),%ecx mov %ecx,0x0(%rbp,%rax,4) mov %rax,%rcx add $0x1,%rax cmp %rdx,%rcx jne 1408 <func0+0xa8> pop %rbx pop %rbp pop %r12 retq
func0: endbr64 push r12 movsxd rsi, esi; nmemb mov r12, rcx lea rcx, compare; compar push rbp mov rbp, rdi push rbx movsxd rbx, edx mov edx, 4; size call _qsort test ebx, ebx jle short loc_13C1 lea eax, [rbx-1] cmp eax, 2 jbe short loc_13A1 lea rdx, [rbp+4] mov rax, r12 sub rax, rdx cmp rax, 8 ja short loc_13D0 loc_13A1: shl rbx, 2 xor eax, eax nop word ptr [rax+rax+00000000h] loc_13B0: mov edx, [rbp+rax+0] mov [r12+rax], edx add rax, 4 cmp rbx, rax jnz short loc_13B0 loc_13C1: pop rbx pop rbp pop r12 retn loc_13D0: mov edx, ebx xor eax, eax shr edx, 2 shl rdx, 4 nop dword ptr [rax+rax+00h] loc_13E0: movdqu xmm0, xmmword ptr [rbp+rax+0] movups xmmword ptr [r12+rax], xmm0 add rax, 10h cmp rax, rdx jnz short loc_13E0 mov eax, ebx and eax, 0FFFFFFFCh test bl, 3 jz short loc_13C1 mov ecx, eax mov esi, [rbp+rcx*4+0] lea rdx, ds:0[rcx*4] mov [r12+rcx*4], esi lea ecx, [rax+1] cmp ebx, ecx jle short loc_13C1 mov ecx, [rbp+rdx+4] add eax, 2 mov [r12+rdx+4], ecx cmp ebx, eax jle short loc_13C1 mov eax, [rbp+rdx+8] mov [r12+rdx+8], eax pop rbx pop rbp pop r12 retn
void func0(char *a1, int a2, int a3, long long a4) { long long v5; // rbx long long v6; // rbx long long v7; // rax long long v8; // rax unsigned int v9; // eax long long v10; // rdx v5 = a3; qsort(a1, a2, 4uLL, compare); if ( (int)v5 > 0 ) { if ( (unsigned int)(v5 - 1) > 2 && (unsigned long long)(a4 - (_QWORD)(a1 + 4)) > 8 ) { v8 = 0LL; do { *(__m128i *)(a4 + v8) = _mm_loadu_si128((const __m128i *)&a1[v8]); v8 += 16LL; } while ( v8 != 16LL * ((unsigned int)v5 >> 2) ); v9 = v5 & 0xFFFFFFFC; if ( (v5 & 3) != 0 ) { v10 = 4LL * v9; *(_DWORD *)(a4 + v10) = *(_DWORD *)&a1[v10]; if ( (int)v5 > (int)(v9 + 1) ) { *(_DWORD *)(a4 + v10 + 4) = *(_DWORD *)&a1[v10 + 4]; if ( (int)v5 > (int)(v9 + 2) ) *(_DWORD *)(a4 + v10 + 8) = *(_DWORD *)&a1[v10 + 8]; } } } else { v6 = 4 * v5; v7 = 0LL; do { *(_DWORD *)(a4 + v7) = *(_DWORD *)&a1[v7]; v7 += 4LL; } while ( v6 != v7 ); } } }
func0: ENDBR64 PUSH R12 MOVSXD RSI,ESI MOV R12,RCX LEA RCX,[0x101350] PUSH RBP MOV RBP,RDI PUSH RBX MOVSXD RBX,EDX MOV EDX,0x4 CALL 0x00101070 TEST EBX,EBX JLE 0x001013c1 LEA EAX,[RBX + -0x1] CMP EAX,0x2 JBE 0x001013a1 LEA RDX,[RBP + 0x4] MOV RAX,R12 SUB RAX,RDX CMP RAX,0x8 JA 0x001013d0 LAB_001013a1: SHL RBX,0x2 XOR EAX,EAX NOP word ptr [RAX + RAX*0x1] LAB_001013b0: MOV EDX,dword ptr [RBP + RAX*0x1] MOV dword ptr [R12 + RAX*0x1],EDX ADD RAX,0x4 CMP RBX,RAX JNZ 0x001013b0 LAB_001013c1: POP RBX POP RBP POP R12 RET LAB_001013d0: MOV EDX,EBX XOR EAX,EAX SHR EDX,0x2 SHL RDX,0x4 NOP dword ptr [RAX + RAX*0x1] LAB_001013e0: MOVDQU XMM0,xmmword ptr [RBP + RAX*0x1] MOVUPS xmmword ptr [R12 + RAX*0x1],XMM0 ADD RAX,0x10 CMP RAX,RDX JNZ 0x001013e0 MOV EAX,EBX AND EAX,0xfffffffc TEST BL,0x3 JZ 0x001013c1 MOV ECX,EAX MOV ESI,dword ptr [RBP + RCX*0x4] LEA RDX,[RCX*0x4] MOV dword ptr [R12 + RCX*0x4],ESI LEA ECX,[RAX + 0x1] CMP EBX,ECX JLE 0x001013c1 MOV ECX,dword ptr [RBP + RDX*0x1 + 0x4] ADD EAX,0x2 MOV dword ptr [R12 + RDX*0x1 + 0x4],ECX CMP EBX,EAX JLE 0x001013c1 MOV EAX,dword ptr [RBP + RDX*0x1 + 0x8] MOV dword ptr [R12 + RDX*0x1 + 0x8],EAX POP RBX POP RBP POP R12 RET
void func0(void *param_1,int param_2,uint param_3,long param_4) { int8 uVar1; uint uVar2; long lVar3; ulong uVar4; qsort(param_1,(long)param_2,4,compare); if (0 < (int)param_3) { if ((param_3 - 1 < 3) || ((ulong)(param_4 - ((long)param_1 + 4)) < 9)) { lVar3 = 0; do { *(int4 *)(param_4 + lVar3) = *(int4 *)((long)param_1 + lVar3); lVar3 = lVar3 + 4; } while ((long)(int)param_3 * 4 != lVar3); } else { lVar3 = 0; do { uVar1 = ((int8 *)((long)param_1 + lVar3))[1]; *(int8 *)(param_4 + lVar3) = *(int8 *)((long)param_1 + lVar3); ((int8 *)(param_4 + lVar3))[1] = uVar1; lVar3 = lVar3 + 0x10; } while (lVar3 != (ulong)(param_3 >> 2) << 4); uVar2 = param_3 & 0xfffffffc; if (((long)(int)param_3 & 3U) != 0) { uVar4 = (ulong)uVar2; lVar3 = uVar4 * 4; *(int4 *)(param_4 + uVar4 * 4) = *(int4 *)((long)param_1 + uVar4 * 4); if (((int)(uVar2 + 1) < (int)param_3) && (*(int4 *)(param_4 + 4 + lVar3) = *(int4 *)((long)param_1 + lVar3 + 4), (int)(uVar2 + 2) < (int)param_3)) { *(int4 *)(param_4 + 8 + lVar3) = *(int4 *)((long)param_1 + lVar3 + 8); return; } } } } return; }
3,912
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h>
int func0(int n) { int *A = (int*)malloc((n + 1) * sizeof(int)); int *B = (int*)malloc((n + 1) * sizeof(int)); if (A == NULL || B == NULL) { fprintf(stderr, "Memory allocation failed\n"); exit(EXIT_FAILURE); } A[0] = 1; A[1] = 0; B[0] = 0; B[1] = 1; for (int i = 2; i <= n; i++) { A[i] = A[i - 2] + 2 * B[i - 1]; B[i] = A[i - 1] + B[i - 2]; } int result = A[n]; free(A); free(B); return result; }
int main() { assert(func0(2) == 3); assert(func0(8) == 153); assert(func0(12) == 2131); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %edi,-0x24(%rbp) mov -0x24(%rbp),%eax add $0x1,%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x10(%rbp) mov -0x24(%rbp),%eax add $0x1,%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) cmpq $0x0,-0x10(%rbp) je 1216 <func0+0x4d> cmpq $0x0,-0x8(%rbp) jne 1240 <func0+0x77> mov 0x2e03(%rip),%rax mov %rax,%rcx mov $0x19,%edx mov $0x1,%esi lea 0xdd7(%rip),%rdi callq 10d0 <fwrite@plt> mov $0x1,%edi callq 10c0 <exit@plt> mov -0x10(%rbp),%rax movl $0x1,(%rax) mov -0x10(%rbp),%rax add $0x4,%rax movl $0x0,(%rax) mov -0x8(%rbp),%rax movl $0x0,(%rax) mov -0x8(%rbp),%rax add $0x4,%rax movl $0x1,(%rax) movl $0x2,-0x18(%rbp) jmpq 130b <func0+0x142> mov -0x18(%rbp),%eax cltq shl $0x2,%rax lea -0x8(%rax),%rdx mov -0x10(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x18(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rcx mov -0x8(%rbp),%rax add %rcx,%rax mov (%rax),%eax lea (%rax,%rax,1),%ecx mov -0x18(%rbp),%eax cltq lea 0x0(,%rax,4),%rsi mov -0x10(%rbp),%rax add %rsi,%rax add %ecx,%edx mov %edx,(%rax) mov -0x18(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rdx mov -0x10(%rbp),%rax add %rdx,%rax mov (%rax),%ecx mov -0x18(%rbp),%eax cltq shl $0x2,%rax lea -0x8(%rax),%rdx mov -0x8(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x18(%rbp),%eax cltq lea 0x0(,%rax,4),%rsi mov -0x8(%rbp),%rax add %rsi,%rax add %ecx,%edx mov %edx,(%rax) addl $0x1,-0x18(%rbp) mov -0x18(%rbp),%eax cmp -0x24(%rbp),%eax jle 127c <func0+0xb3> mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x10(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x14(%rbp) mov -0x10(%rbp),%rax mov %rax,%rdi callq 1090 <free@plt> mov -0x8(%rbp),%rax mov %rax,%rdi callq 1090 <free@plt> mov -0x14(%rbp),%eax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_24], edi mov eax, [rbp+var_24] add eax, 1 cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+ptr], rax mov eax, [rbp+var_24] add eax, 1 cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_8], rax cmp [rbp+ptr], 0 jz short loc_1216 cmp [rbp+var_8], 0 jnz short loc_1243 loc_1216: mov rax, cs:__bss_start mov rcx, rax; s mov edx, 19h; n mov esi, 1; size lea rax, aMemoryAllocati; "Memory allocation failed\n" mov rdi, rax; ptr call _fwrite mov edi, 1; status call _exit loc_1243: mov rax, [rbp+ptr] mov dword ptr [rax], 1 mov rax, [rbp+ptr] add rax, 4 mov dword ptr [rax], 0 mov rax, [rbp+var_8] mov dword ptr [rax], 0 mov rax, [rbp+var_8] add rax, 4 mov dword ptr [rax], 1 mov [rbp+var_18], 2 jmp loc_130E loc_127F: mov eax, [rbp+var_18] cdqe shl rax, 2 lea rdx, [rax-8] mov rax, [rbp+ptr] add rax, rdx mov edx, [rax] mov eax, [rbp+var_18] cdqe shl rax, 2 lea rcx, [rax-4] mov rax, [rbp+var_8] add rax, rcx mov eax, [rax] lea ecx, [rax+rax] mov eax, [rbp+var_18] cdqe lea rsi, ds:0[rax*4] mov rax, [rbp+ptr] add rax, rsi add edx, ecx mov [rax], edx mov eax, [rbp+var_18] cdqe shl rax, 2 lea rdx, [rax-4] mov rax, [rbp+ptr] add rax, rdx mov ecx, [rax] mov eax, [rbp+var_18] cdqe shl rax, 2 lea rdx, [rax-8] mov rax, [rbp+var_8] add rax, rdx mov edx, [rax] mov eax, [rbp+var_18] cdqe lea rsi, ds:0[rax*4] mov rax, [rbp+var_8] add rax, rsi add edx, ecx mov [rax], edx add [rbp+var_18], 1 loc_130E: mov eax, [rbp+var_18] cmp eax, [rbp+var_24] jle loc_127F mov eax, [rbp+var_24] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+ptr] add rax, rdx mov eax, [rax] mov [rbp+var_14], eax mov rax, [rbp+ptr] mov rdi, rax; ptr call _free mov rax, [rbp+var_8] mov rdi, rax; ptr call _free mov eax, [rbp+var_14] leave retn
long long func0(int a1) { int i; // [rsp+18h] [rbp-18h] unsigned int v3; // [rsp+1Ch] [rbp-14h] _DWORD *ptr; // [rsp+20h] [rbp-10h] _DWORD *v5; // [rsp+28h] [rbp-8h] ptr = malloc(4LL * (a1 + 1)); v5 = malloc(4LL * (a1 + 1)); if ( !ptr || !v5 ) { fwrite("Memory allocation failed\n", 1uLL, 0x19uLL, _bss_start); exit(1); } *ptr = 1; ptr[1] = 0; *v5 = 0; v5[1] = 1; for ( i = 2; i <= a1; ++i ) { ptr[i] = 2 * v5[i - 1] + ptr[i - 2]; v5[i] = ptr[i - 1] + v5[i - 2]; } v3 = ptr[a1]; free(ptr); free(v5); return v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV dword ptr [RBP + -0x24],EDI MOV EAX,dword ptr [RBP + -0x24] ADD EAX,0x1 CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x10],RAX MOV EAX,dword ptr [RBP + -0x24] ADD EAX,0x1 CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX CMP qword ptr [RBP + -0x10],0x0 JZ 0x00101216 CMP qword ptr [RBP + -0x8],0x0 JNZ 0x00101243 LAB_00101216: MOV RAX,qword ptr [0x00104020] MOV RCX,RAX MOV EDX,0x19 MOV ESI,0x1 LEA RAX,[0x102004] MOV RDI,RAX CALL 0x001010d0 MOV EDI,0x1 CALL 0x001010c0 LAB_00101243: MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX],0x1 MOV RAX,qword ptr [RBP + -0x10] ADD RAX,0x4 MOV dword ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x8] MOV dword ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x8] ADD RAX,0x4 MOV dword ptr [RAX],0x1 MOV dword ptr [RBP + -0x18],0x2 JMP 0x0010130e LAB_0010127f: MOV EAX,dword ptr [RBP + -0x18] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x8] MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x18] CDQE SHL RAX,0x2 LEA RCX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RCX MOV EAX,dword ptr [RAX] LEA ECX,[RAX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x18] CDQE LEA RSI,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RSI ADD EDX,ECX MOV dword ptr [RAX],EDX MOV EAX,dword ptr [RBP + -0x18] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RDX MOV ECX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x18] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x8] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x18] CDQE LEA RSI,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RSI ADD EDX,ECX MOV dword ptr [RAX],EDX ADD dword ptr [RBP + -0x18],0x1 LAB_0010130e: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x24] JLE 0x0010127f MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x14],EAX MOV RAX,qword ptr [RBP + -0x10] MOV RDI,RAX CALL 0x00101090 MOV RAX,qword ptr [RBP + -0x8] MOV RDI,RAX CALL 0x00101090 MOV EAX,dword ptr [RBP + -0x14] LEAVE RET
int4 func0(int param_1) { int4 uVar1; int4 *__ptr; int4 *__ptr_00; int local_20; __ptr = (int4 *)malloc((long)(param_1 + 1) << 2); __ptr_00 = (int4 *)malloc((long)(param_1 + 1) << 2); if ((__ptr != (int4 *)0x0) && (__ptr_00 != (int4 *)0x0)) { *__ptr = 1; __ptr[1] = 0; *__ptr_00 = 0; __ptr_00[1] = 1; for (local_20 = 2; local_20 <= param_1; local_20 = local_20 + 1) { __ptr[local_20] = __ptr[(long)local_20 + -2] + __ptr_00[(long)local_20 + -1] * 2; __ptr_00[local_20] = __ptr_00[(long)local_20 + -2] + __ptr[(long)local_20 + -1]; } uVar1 = __ptr[param_1]; free(__ptr); free(__ptr_00); return uVar1; } fwrite("Memory allocation failed\n",1,0x19,stderr); /* WARNING: Subroutine does not return */ exit(1); }
3,913
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h>
int func0(int n) { int *A = (int*)malloc((n + 1) * sizeof(int)); int *B = (int*)malloc((n + 1) * sizeof(int)); if (A == NULL || B == NULL) { fprintf(stderr, "Memory allocation failed\n"); exit(EXIT_FAILURE); } A[0] = 1; A[1] = 0; B[0] = 0; B[1] = 1; for (int i = 2; i <= n; i++) { A[i] = A[i - 2] + 2 * B[i - 1]; B[i] = A[i - 1] + B[i - 2]; } int result = A[n]; free(A); free(B); return result; }
int main() { assert(func0(2) == 3); assert(func0(8) == 153); assert(func0(12) == 2131); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov %edi,%r13d lea 0x1(%rdi),%ebp movslq %ebp,%rbp shl $0x2,%rbp mov %rbp,%rdi callq 10b0 <malloc@plt> mov %rax,%rbx mov %rbp,%rdi callq 10b0 <malloc@plt> test %rbx,%rbx je 1274 <func0+0xab> mov %rax,%r12 test %rax,%rax je 1274 <func0+0xab> movl $0x1,(%rbx) movl $0x0,0x4(%rbx) movl $0x0,(%rax) movl $0x1,0x4(%rax) cmp $0x1,%r13d jle 1253 <func0+0x8a> mov %rbx,%rax mov %r12,%rdx lea -0x2(%r13),%ecx lea 0x4(%rbx,%rcx,4),%rdi mov 0x4(%rdx),%esi mov (%rax),%ecx lea (%rcx,%rsi,2),%ecx mov %ecx,0x8(%rax) mov (%rdx),%ecx add 0x4(%rax),%ecx mov %ecx,0x8(%rdx) add $0x4,%rax add $0x4,%rdx cmp %rdi,%rax jne 1233 <func0+0x6a> mov -0x4(%rbx,%rbp,1),%ebp mov %rbx,%rdi callq 1090 <free@plt> mov %r12,%rdi callq 1090 <free@plt> mov %ebp,%eax add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq mov 0x2da5(%rip),%rcx mov $0x19,%edx mov $0x1,%esi lea 0xd78(%rip),%rdi callq 10d0 <fwrite@plt> mov $0x1,%edi callq 10c0 <exit@plt>
func0: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 mov r13d, edi lea ebp, [rdi+1] movsxd rbp, ebp shl rbp, 2 mov rdi, rbp call _malloc mov rbx, rax mov rdi, rbp call _malloc test rbx, rbx jz short loc_1273 mov r12, rax test rax, rax jz short loc_1273 mov dword ptr [rbx], 1 mov dword ptr [rbx+4], 0 mov dword ptr [rax], 0 mov dword ptr [rax+4], 1 cmp r13d, 1 jle short loc_1252 mov rax, rbx mov rdx, r12 lea ecx, [r13-1] lea rdi, [rbx+rcx*4] loc_1232: mov esi, [rdx+4] mov ecx, [rax] lea ecx, [rcx+rsi*2] mov [rax+8], ecx mov ecx, [rdx] add ecx, [rax+4] mov [rdx+8], ecx add rax, 4 add rdx, 4 cmp rax, rdi jnz short loc_1232 loc_1252: mov ebp, [rbx+rbp-4] mov rdi, rbx call _free mov rdi, r12 call _free mov eax, ebp add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn loc_1273: mov rcx, cs:stderr@GLIBC_2_2_5 mov edx, 19h mov esi, 1 lea rdi, aMemoryAllocati; "Memory allocation failed\n" call _fwrite mov edi, 1 call _exit
long long func0(int a1, long long a2) { long long v2; // rbp _DWORD *v3; // rbx _DWORD *v4; // rax _DWORD *v5; // rdx _DWORD *v6; // r12 _DWORD *v7; // rax unsigned int v8; // ebp long long v9; // rdx v2 = 4LL * (a1 + 1); v3 = (_DWORD *)malloc(v2); v4 = (_DWORD *)malloc(v2); if ( !v3 || (v6 = v4) == 0LL ) { fwrite("Memory allocation failed\n", 1LL, 25LL, stderr); exit(1LL); } *v3 = 1; v3[1] = 0; *v4 = 0; v4[1] = 1; if ( a1 > 1 ) { v7 = v3; v5 = v6; do { a2 = (unsigned int)v5[1]; v7[2] = *v7 + 2 * a2; v5[2] = v7[1] + *v5; ++v7; ++v5; } while ( v7 != &v3[a1 - 1] ); } v8 = v3[(unsigned long long)v2 / 4 - 1]; free(v3, a2, v5); free(v6, a2, v9); return v8; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV R13D,EDI LEA EBP,[RDI + 0x1] MOVSXD RBP,EBP SHL RBP,0x2 MOV RDI,RBP CALL 0x001010b0 MOV RBX,RAX MOV RDI,RBP CALL 0x001010b0 TEST RBX,RBX JZ 0x00101273 MOV R12,RAX TEST RAX,RAX JZ 0x00101273 MOV dword ptr [RBX],0x1 MOV dword ptr [RBX + 0x4],0x0 MOV dword ptr [RAX],0x0 MOV dword ptr [RAX + 0x4],0x1 CMP R13D,0x1 JLE 0x00101252 MOV RAX,RBX MOV RDX,R12 LEA ECX,[R13 + -0x1] LEA RDI,[RBX + RCX*0x4] LAB_00101232: MOV ESI,dword ptr [RDX + 0x4] MOV ECX,dword ptr [RAX] LEA ECX,[RCX + RSI*0x2] MOV dword ptr [RAX + 0x8],ECX MOV ECX,dword ptr [RDX] ADD ECX,dword ptr [RAX + 0x4] MOV dword ptr [RDX + 0x8],ECX ADD RAX,0x4 ADD RDX,0x4 CMP RAX,RDI JNZ 0x00101232 LAB_00101252: MOV EBP,dword ptr [RBX + RBP*0x1 + -0x4] MOV RDI,RBX CALL 0x00101090 MOV RDI,R12 CALL 0x00101090 MOV EAX,EBP ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET LAB_00101273: MOV RCX,qword ptr [0x00104020] MOV EDX,0x19 MOV ESI,0x1 LEA RDI,[0x102004] CALL 0x001010d0 MOV EDI,0x1 CALL 0x001010c0
int func0(int param_1) { int iVar1; int *__ptr; int *__ptr_00; int *piVar2; int *piVar3; size_t __size; __size = (long)(param_1 + 1) * 4; __ptr = (int *)malloc(__size); __ptr_00 = (int *)malloc(__size); if ((__ptr != (int *)0x0) && (__ptr_00 != (int *)0x0)) { *__ptr = 1; __ptr[1] = 0; *__ptr_00 = 0; __ptr_00[1] = 1; if (1 < param_1) { piVar2 = __ptr; piVar3 = __ptr_00; do { piVar2[2] = *piVar2 + piVar3[1] * 2; piVar3[2] = *piVar3 + piVar2[1]; piVar2 = piVar2 + 1; piVar3 = piVar3 + 1; } while (piVar2 != __ptr + (param_1 - 1)); } iVar1 = __ptr[(long)(param_1 + 1) + -1]; free(__ptr); free(__ptr_00); return iVar1; } fwrite("Memory allocation failed\n",1,0x19,stderr); /* WARNING: Subroutine does not return */ exit(1); }
3,914
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h>
int func0(int n) { int *A = (int*)malloc((n + 1) * sizeof(int)); int *B = (int*)malloc((n + 1) * sizeof(int)); if (A == NULL || B == NULL) { fprintf(stderr, "Memory allocation failed\n"); exit(EXIT_FAILURE); } A[0] = 1; A[1] = 0; B[0] = 0; B[1] = 1; for (int i = 2; i <= n; i++) { A[i] = A[i - 2] + 2 * B[i - 1]; B[i] = A[i - 1] + B[i - 2]; } int result = A[n]; free(A); free(B); return result; }
int main() { assert(func0(2) == 3); assert(func0(8) == 153); assert(func0(12) == 2131); return 0; }
O2
c
func0: endbr64 push %r13 push %r12 mov %edi,%r12d push %rbp push %rbx lea 0x1(%rdi),%ebx movslq %ebx,%rbx shl $0x2,%rbx sub $0x8,%rsp mov %rbx,%rdi callq 10b0 <malloc@plt> mov %rbx,%rdi mov %rax,%r13 callq 10b0 <malloc@plt> test %r13,%r13 je 1334 <func0+0xc4> mov %rax,%rbp test %rax,%rax je 1334 <func0+0xc4> movabs $0x100000000,%rax movq $0x1,0x0(%r13) mov %rax,0x0(%rbp) cmp $0x1,%r12d jle 1311 <func0+0xa1> lea -0x2(%r12),%eax lea 0x4(%rbp),%rdx xor %ecx,%ecx mov $0x1,%edi lea 0x4(%r13),%rsi lea 0x4(%rbp,%rax,4),%r9 jmp 12fb <func0+0x8b> nopw 0x0(%rax,%rax,1) add $0x4,%rdx add $0x4,%rsi mov %r8d,%ecx mov (%rdx),%r8d lea (%rdi,%r8,2),%edi mov %edi,0x4(%rsi) mov (%rsi),%edi add %edi,%ecx mov %ecx,0x4(%rdx) cmp %r9,%rdx jne 12f0 <func0+0x80> mov %r13,%rdi mov -0x4(%r13,%rbx,1),%r12d callq 1090 <free@plt> mov %rbp,%rdi callq 1090 <free@plt> add $0x8,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 retq mov 0x2ce5(%rip),%rcx mov $0x19,%edx mov $0x1,%esi lea 0xcb8(%rip),%rdi callq 10d0 <fwrite@plt> mov $0x1,%edi callq 10c0 <exit@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push r13 push r12 mov r12d, edi push rbp push rbx lea ebx, [rdi+1] movsxd rbx, ebx shl rbx, 2 sub rsp, 8 mov rdi, rbx call _malloc mov rdi, rbx mov r13, rax call _malloc test r13, r13 jz loc_1334 mov rbp, rax test rax, rax jz loc_1334 mov rax, 100000000h mov qword ptr [r13+0], 1 mov [rbp+0], rax cmp r12d, 1 jle short loc_1311 lea eax, [r12-1] lea rdx, [rbp+4] xor ecx, ecx mov edi, 1 lea rsi, [r13+4] lea r9, [rbp+rax*4+0] jmp short loc_12FB loc_12F0: add rdx, 4 add rsi, 4 mov ecx, r8d loc_12FB: mov r8d, [rdx] lea edi, [rdi+r8*2] mov [rsi+4], edi mov edi, [rsi] add ecx, edi mov [rdx+4], ecx cmp rdx, r9 jnz short loc_12F0 loc_1311: mov rdi, r13 mov r12d, [r13+rbx-4] call _free mov rdi, rbp call _free add rsp, 8 mov eax, r12d pop rbx pop rbp pop r12 pop r13 retn loc_1334: mov rcx, cs:stderr@GLIBC_2_2_5 mov edx, 19h mov esi, 1 lea rdi, aMemoryAllocati; "Memory allocation failed\n" call _fwrite mov edi, 1 call _exit
long long func0(int a1) { long long v2; // rbx _QWORD *v3; // r13 _QWORD *v4; // rax _QWORD *v5; // rbp int *v6; // rdx int v7; // ecx int v8; // edi int *i; // rsi int v10; // r8d unsigned int v11; // r12d v2 = 4LL * (a1 + 1); v3 = (_QWORD *)malloc(v2); v4 = (_QWORD *)malloc(v2); if ( !v3 || (v5 = v4) == 0LL ) { fwrite("Memory allocation failed\n", 1LL, 25LL, stderr); exit(1LL); } *v3 = 1LL; *v4 = 0x100000000LL; if ( a1 > 1 ) { v6 = (int *)v4 + 1; v7 = 0; v8 = 1; for ( i = (int *)v3 + 1; ; ++i ) { v10 = *v6; i[1] = v8 + 2 * *v6; v8 = *i; v6[1] = *i + v7; if ( v6 == (int *)((char *)v4 + 4 * (unsigned int)(a1 - 1)) ) break; ++v6; v7 = v10; } } v11 = *(_DWORD *)((char *)v3 + v2 - 4); free(v3); free(v5); return v11; }
func0: ENDBR64 PUSH R13 PUSH R12 MOV R12D,EDI PUSH RBP PUSH RBX LEA EBX,[RDI + 0x1] MOVSXD RBX,EBX SHL RBX,0x2 SUB RSP,0x8 MOV RDI,RBX CALL 0x001010b0 MOV RDI,RBX MOV R13,RAX CALL 0x001010b0 TEST R13,R13 JZ 0x00101334 MOV RBP,RAX TEST RAX,RAX JZ 0x00101334 MOV RAX,0x100000000 MOV qword ptr [R13],0x1 MOV qword ptr [RBP],RAX CMP R12D,0x1 JLE 0x00101311 LEA EAX,[R12 + -0x1] LEA RDX,[RBP + 0x4] XOR ECX,ECX MOV EDI,0x1 LEA RSI,[R13 + 0x4] LEA R9,[RBP + RAX*0x4] JMP 0x001012fb LAB_001012f0: ADD RDX,0x4 ADD RSI,0x4 MOV ECX,R8D LAB_001012fb: MOV R8D,dword ptr [RDX] LEA EDI,[RDI + R8*0x2] MOV dword ptr [RSI + 0x4],EDI MOV EDI,dword ptr [RSI] ADD ECX,EDI MOV dword ptr [RDX + 0x4],ECX CMP RDX,R9 JNZ 0x001012f0 LAB_00101311: MOV RDI,R13 MOV R12D,dword ptr [R13 + RBX*0x1 + -0x4] CALL 0x00101090 MOV RDI,RBP CALL 0x00101090 ADD RSP,0x8 MOV EAX,R12D POP RBX POP RBP POP R12 POP R13 RET LAB_00101334: MOV RCX,qword ptr [0x00104020] MOV EDX,0x19 MOV ESI,0x1 LEA RDI,[0x102004] CALL 0x001010d0 MOV EDI,0x1 CALL 0x001010c0
int func0(int param_1) { int iVar1; int *piVar2; int *piVar3; int *__ptr; int *__ptr_00; int iVar4; int *piVar5; size_t __size; int iVar6; __size = (long)(param_1 + 1) * 4; __ptr = (int *)malloc(__size); __ptr_00 = (int *)malloc(__size); if ((__ptr != (int *)0x0) && (__ptr_00 != (int *)0x0)) { __ptr[0] = 1; __ptr[1] = 0; __ptr_00[0] = 0; __ptr_00[1] = 1; if (1 < param_1) { iVar6 = 1; iVar4 = 0; piVar2 = __ptr_00; piVar3 = __ptr; do { piVar5 = piVar2 + 1; iVar1 = *piVar5; piVar3[2] = iVar6 + iVar1 * 2; iVar6 = piVar3[1]; piVar2[2] = iVar4 + iVar6; iVar4 = iVar1; piVar2 = piVar5; piVar3 = piVar3 + 1; } while (piVar5 != __ptr_00 + (param_1 - 1)); } iVar6 = __ptr[(long)(param_1 + 1) + -1]; free(__ptr); free(__ptr_00); return iVar6; } fwrite("Memory allocation failed\n",1,0x19,stderr); /* WARNING: Subroutine does not return */ exit(1); }
3,915
func0
#include <assert.h> #include <stdio.h> #include <stdlib.h>
int func0(int n) { int *A = (int*)malloc((n + 1) * sizeof(int)); int *B = (int*)malloc((n + 1) * sizeof(int)); if (A == NULL || B == NULL) { fprintf(stderr, "Memory allocation failed\n"); exit(EXIT_FAILURE); } A[0] = 1; A[1] = 0; B[0] = 0; B[1] = 1; for (int i = 2; i <= n; i++) { A[i] = A[i - 2] + 2 * B[i - 1]; B[i] = A[i - 1] + B[i - 2]; } int result = A[n]; free(A); free(B); return result; }
int main() { assert(func0(2) == 3); assert(func0(8) == 153); assert(func0(12) == 2131); return 0; }
O3
c
func0: endbr64 push %r13 lea 0x1(%rdi),%r13d push %r12 movslq %r13d,%r13 push %rbp shl $0x2,%r13 push %rbx mov %edi,%ebx mov %r13,%rdi sub $0x8,%rsp callq 10b0 <malloc@plt> mov %r13,%rdi mov %rax,%rbp callq 10b0 <malloc@plt> test %rbp,%rbp je 136f <func0+0xff> mov %rax,%r12 test %rax,%rax je 136f <func0+0xff> movabs $0x100000000,%rax movq $0x1,0x0(%rbp) mov %rax,(%r12) cmp $0x1,%ebx jle 1345 <func0+0xd5> cmp $0x3,%ebx jle 1368 <func0+0xf8> lea -0x4(%rbx),%eax mov $0x1,%esi mov $0x1,%ecx shr %eax lea 0x6(%rax,%rax,1),%rdi mov $0x4,%eax lea (%rsi,%rcx,2),%esi movl $0x0,-0x4(%rbp,%rax,4) movslq %eax,%rdx add %esi,%ecx mov %esi,-0x8(%rbp,%rax,4) movl $0x0,-0x8(%r12,%rax,4) mov %ecx,-0x4(%r12,%rax,4) add $0x2,%rax cmp %rdi,%rax jne 12f0 <func0+0x80> nopl 0x0(%rax,%rax,1) mov -0x4(%r12,%rdx,4),%ecx mov -0x8(%rbp,%rdx,4),%eax lea (%rax,%rcx,2),%eax mov -0x8(%r12,%rdx,4),%ecx add -0x4(%rbp,%rdx,4),%ecx mov %eax,0x0(%rbp,%rdx,4) mov %ecx,(%r12,%rdx,4) add $0x1,%rdx cmp %edx,%ebx jge 1320 <func0+0xb0> mov %rbp,%rdi mov -0x4(%rbp,%r13,1),%r13d callq 1090 <free@plt> mov %r12,%rdi callq 1090 <free@plt> add $0x8,%rsp mov %r13d,%eax pop %rbx pop %rbp pop %r12 pop %r13 retq mov $0x2,%edx jmp 1320 <func0+0xb0> mov 0x2caa(%rip),%rcx mov $0x19,%edx mov $0x1,%esi lea 0xc7d(%rip),%rdi callq 10d0 <fwrite@plt> mov $0x1,%edi callq 10c0 <exit@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r13 mov r13d, edi push r12 push rbp lea ebp, [rdi+1] push rbx movsxd rbp, ebp shl rbp, 2 mov rdi, rbp; size sub rsp, 8 call _malloc mov rdi, rbp; size mov rbx, rax call _malloc test rbx, rbx jz loc_136D mov r12, rax test rax, rax jz loc_136D mov rax, cs:qword_2078 mov qword ptr [rbx], 1 mov [r12], rax cmp r13d, 1 jle short loc_1345 cmp r13d, 3 jle loc_1366 lea eax, [r13-4] mov edx, 4 mov esi, 1 mov ecx, 1 shr eax, 1 lea edi, [rax+3] add rdi, rdi loc_12F0: lea esi, [rsi+rcx*2] mov dword ptr [rbx+rdx*4-4], 0 mov rax, rdx add ecx, esi mov [rbx+rdx*4-8], esi mov dword ptr [r12+rdx*4-8], 0 mov [r12+rdx*4-4], ecx add rdx, 2 cmp rdi, rdx jnz short loc_12F0 loc_131B: cdqe nop dword ptr [rax] loc_1320: mov ecx, [r12+rax*4-4] mov edx, [rbx+rax*4-8] lea edx, [rdx+rcx*2] mov [rbx+rax*4], edx mov edx, [rbx+rax*4-4] add edx, [r12+rax*4-8] mov [r12+rax*4], edx add rax, 1 cmp r13d, eax jge short loc_1320 loc_1345: mov rdi, rbx; ptr mov ebp, [rbx+rbp-4] call _free mov rdi, r12; ptr call _free add rsp, 8 mov eax, ebp pop rbx pop rbp pop r12 pop r13 retn loc_1366: mov eax, 2 jmp short loc_131B loc_136D: mov rcx, cs:__bss_start; s mov edx, 19h; n mov esi, 1; size lea rdi, aMemoryAllocati; "Memory allocation failed\n" call _fwrite mov edi, 1; status call _exit
long long func0(int a1) { size_t v1; // rbp _QWORD *v2; // rbx _QWORD *v3; // rax _DWORD *v4; // r12 long long v5; // rdx int v6; // esi int v7; // ecx long long v8; // rax unsigned int v9; // ebp v1 = 4LL * (a1 + 1); v2 = malloc(v1); v3 = malloc(v1); if ( !v2 || (v4 = v3) == 0LL ) { fwrite("Memory allocation failed\n", 1uLL, 0x19uLL, _bss_start); exit(1); } *v2 = 1LL; *v3 = 0x100000000LL; if ( a1 > 1 ) { if ( a1 <= 3 ) { LODWORD(v8) = 2; } else { v5 = 2LL; v6 = 1; v7 = 1; do { v6 += 2 * v7; HIDWORD(v2[v5 - 1]) = 0; LODWORD(v8) = v5 * 2; v7 += v6; LODWORD(v2[v5 - 1]) = v6; v4[v5 * 2 - 2] = 0; v4[v5 * 2 - 1] = v7; ++v5; } while ( ((unsigned int)(a1 - 4) >> 1) + 3 != v5 ); } v8 = (int)v8; do { *((_DWORD *)v2 + v8) = *((_DWORD *)v2 + v8 - 2) + 2 * v4[v8 - 1]; v4[v8] = v4[v8 - 2] + *((_DWORD *)v2 + v8 - 1); ++v8; } while ( a1 >= (int)v8 ); } v9 = *(_DWORD *)((char *)v2 + v1 - 4); free(v2); free(v4); return v9; }
func0: ENDBR64 PUSH R13 MOV R13D,EDI PUSH R12 PUSH RBP LEA EBP,[RDI + 0x1] PUSH RBX MOVSXD RBP,EBP SHL RBP,0x2 MOV RDI,RBP SUB RSP,0x8 CALL 0x001010b0 MOV RDI,RBP MOV RBX,RAX CALL 0x001010b0 TEST RBX,RBX JZ 0x0010136d MOV R12,RAX TEST RAX,RAX JZ 0x0010136d MOV RAX,qword ptr [0x00102078] MOV qword ptr [RBX],0x1 MOV qword ptr [R12],RAX CMP R13D,0x1 JLE 0x00101345 CMP R13D,0x3 JLE 0x00101366 LEA EAX,[R13 + -0x4] MOV EDX,0x4 MOV ESI,0x1 MOV ECX,0x1 SHR EAX,0x1 LEA EDI,[RAX + 0x3] ADD RDI,RDI LAB_001012f0: LEA ESI,[RSI + RCX*0x2] MOV dword ptr [RBX + RDX*0x4 + -0x4],0x0 MOV RAX,RDX ADD ECX,ESI MOV dword ptr [RBX + RDX*0x4 + -0x8],ESI MOV dword ptr [R12 + RDX*0x4 + -0x8],0x0 MOV dword ptr [R12 + RDX*0x4 + -0x4],ECX ADD RDX,0x2 CMP RDI,RDX JNZ 0x001012f0 LAB_0010131b: CDQE NOP dword ptr [RAX] LAB_00101320: MOV ECX,dword ptr [R12 + RAX*0x4 + -0x4] MOV EDX,dword ptr [RBX + RAX*0x4 + -0x8] LEA EDX,[RDX + RCX*0x2] MOV dword ptr [RBX + RAX*0x4],EDX MOV EDX,dword ptr [RBX + RAX*0x4 + -0x4] ADD EDX,dword ptr [R12 + RAX*0x4 + -0x8] MOV dword ptr [R12 + RAX*0x4],EDX ADD RAX,0x1 CMP R13D,EAX JGE 0x00101320 LAB_00101345: MOV RDI,RBX MOV EBP,dword ptr [RBX + RBP*0x1 + -0x4] CALL 0x00101090 MOV RDI,R12 CALL 0x00101090 ADD RSP,0x8 MOV EAX,EBP POP RBX POP RBP POP R12 POP R13 RET LAB_00101366: MOV EAX,0x2 JMP 0x0010131b LAB_0010136d: MOV RCX,qword ptr [0x00104020] MOV EDX,0x19 MOV ESI,0x1 LEA RDI,[0x102004] CALL 0x001010d0 MOV EDI,0x1 CALL 0x001010c0
int4 func0(int param_1) { int4 uVar1; int8 uVar2; int iVar3; int8 *__ptr; int8 *__ptr_00; int iVar4; long lVar5; size_t __size; int iVar6; __size = (long)(param_1 + 1) * 4; __ptr = (int8 *)malloc(__size); __ptr_00 = (int8 *)malloc(__size); uVar2 = DAT_00102078; if ((__ptr != (int8 *)0x0) && (__ptr_00 != (int8 *)0x0)) { *__ptr = 1; *__ptr_00 = uVar2; if (1 < param_1) { if (param_1 < 4) { iVar3 = 2; } else { lVar5 = 4; iVar6 = 1; iVar4 = 1; do { iVar6 = iVar6 + iVar4 * 2; *(int4 *)((long)__ptr + lVar5 * 4 + -4) = 0; iVar3 = (int)lVar5; iVar4 = iVar4 + iVar6; *(int *)((long)__ptr + lVar5 * 4 + -8) = iVar6; *(int4 *)((long)__ptr_00 + lVar5 * 4 + -8) = 0; *(int *)((long)__ptr_00 + lVar5 * 4 + -4) = iVar4; lVar5 = lVar5 + 2; } while ((ulong)((param_1 - 4U >> 1) + 3) * 2 != lVar5); } lVar5 = (long)iVar3; do { *(int *)((long)__ptr + lVar5 * 4) = *(int *)((long)__ptr + lVar5 * 4 + -8) + *(int *)((long)__ptr_00 + lVar5 * 4 + -4) * 2; *(int *)((long)__ptr_00 + lVar5 * 4) = *(int *)((long)__ptr + lVar5 * 4 + -4) + *(int *)((long)__ptr_00 + lVar5 * 4 + -8); lVar5 = lVar5 + 1; } while ((int)lVar5 <= param_1); } uVar1 = *(int4 *)((long)__ptr + (__size - 4)); free(__ptr); free(__ptr_00); return uVar1; } fwrite("Memory allocation failed\n",1,0x19,stderr); /* WARNING: Subroutine does not return */ exit(1); }
3,916
func0
#include <stdbool.h> #include <assert.h>
bool func0(int a, int b) { return (a ^ b) && !((a ^ b) & ((a ^ b) - 1)); }
int main() { assert(func0(13,9) == true); assert(func0(15,8) == false); assert(func0(2,4) == false); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x4(%rbp) mov %esi,-0x8(%rbp) mov -0x4(%rbp),%eax cmp -0x8(%rbp),%eax je 117d <func0+0x34> mov -0x4(%rbp),%eax xor -0x8(%rbp),%eax mov %eax,%edx mov -0x4(%rbp),%eax xor -0x8(%rbp),%eax sub $0x1,%eax and %edx,%eax test %eax,%eax jne 117d <func0+0x34> mov $0x1,%eax jmp 1182 <func0+0x39> mov $0x0,%eax and $0x1,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_4], edi mov [rbp+var_8], esi mov eax, [rbp+var_4] cmp eax, [rbp+var_8] jz short loc_117D mov eax, [rbp+var_4] xor eax, [rbp+var_8] mov edx, eax mov eax, [rbp+var_4] xor eax, [rbp+var_8] sub eax, 1 and eax, edx test eax, eax jnz short loc_117D mov eax, 1 jmp short loc_1182 loc_117D: mov eax, 0 loc_1182: and eax, 1 pop rbp retn
_BOOL8 func0(int a1, int a2) { return a1 != a2 && ((a2 ^ a1) & ((a2 ^ a1) - 1)) == 0; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x4],EDI MOV dword ptr [RBP + -0x8],ESI MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x8] JZ 0x0010117d MOV EAX,dword ptr [RBP + -0x4] XOR EAX,dword ptr [RBP + -0x8] MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x4] XOR EAX,dword ptr [RBP + -0x8] SUB EAX,0x1 AND EAX,EDX TEST EAX,EAX JNZ 0x0010117d MOV EAX,0x1 JMP 0x00101182 LAB_0010117d: MOV EAX,0x0 LAB_00101182: AND EAX,0x1 POP RBP RET
int4 func0(uint param_1,uint param_2) { int4 uVar1; if ((param_1 == param_2) || (((param_1 ^ param_2) - 1 & (param_1 ^ param_2)) != 0)) { uVar1 = 0; } else { uVar1 = 1; } return uVar1; }
3,917
func0
#include <stdbool.h> #include <assert.h>
bool func0(int a, int b) { return (a ^ b) && !((a ^ b) & ((a ^ b) - 1)); }
int main() { assert(func0(13,9) == true); assert(func0(15,8) == false); assert(func0(2,4) == false); return 0; }
O1
c
func0: endbr64 mov $0x0,%eax cmp %esi,%edi je 1143 <func0+0x1a> xor %esi,%edi lea -0x1(%rdi),%eax test %edi,%eax sete %al movzbl %al,%eax and $0x1,%eax retq
func0: endbr64 mov eax, 0 cmp edi, esi jz short loc_1143 xor edi, esi lea eax, [rdi-1] test eax, edi setz al movzx eax, al loc_1143: and eax, 1 retn
_BOOL8 func0(int a1, int a2) { bool v2; // al v2 = 0; if ( a1 != a2 ) return ((a2 ^ a1) & ((a2 ^ a1) - 1)) == 0; return v2; }
func0: ENDBR64 MOV EAX,0x0 CMP EDI,ESI JZ 0x00101143 XOR EDI,ESI LEA EAX,[RDI + -0x1] TEST EAX,EDI SETZ AL MOVZX EAX,AL LAB_00101143: AND EAX,0x1 RET
bool func0(uint param_1,uint param_2) { bool bVar1; bVar1 = false; if (param_1 != param_2) { bVar1 = ((param_1 ^ param_2) - 1 & (param_1 ^ param_2)) == 0; } return bVar1; }
3,918
func0
#include <stdbool.h> #include <assert.h>
bool func0(int a, int b) { return (a ^ b) && !((a ^ b) & ((a ^ b) - 1)); }
int main() { assert(func0(13,9) == true); assert(func0(15,8) == false); assert(func0(2,4) == false); return 0; }
O2
c
func0: endbr64 xor %eax,%eax cmp %esi,%edi je 1154 <func0+0x14> xor %esi,%edi lea -0x1(%rdi),%eax test %edi,%eax sete %al retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 xor eax, eax cmp edi, esi jz short locret_1154 xor edi, esi lea eax, [rdi-1] test eax, edi setz al locret_1154: retn
bool func0(int a1, int a2) { bool result; // al result = 0; if ( a1 != a2 ) return ((a2 ^ a1) & ((a2 ^ a1) - 1)) == 0; return result; }
func0: ENDBR64 XOR EAX,EAX CMP EDI,ESI JZ 0x00101154 XOR EDI,ESI LEA EAX,[RDI + -0x1] TEST EAX,EDI SETZ AL LAB_00101154: RET
int4 func0(uint param_1,uint param_2) { uint uVar1; int4 uVar2; uVar2 = 0; if (param_1 != param_2) { uVar1 = (param_1 ^ param_2) - 1; uVar2 = CONCAT31((int3)(uVar1 >> 8),(uVar1 & (param_1 ^ param_2)) == 0); } return uVar2; }
3,919
func0
#include <stdbool.h> #include <assert.h>
bool func0(int a, int b) { return (a ^ b) && !((a ^ b) & ((a ^ b) - 1)); }
int main() { assert(func0(13,9) == true); assert(func0(15,8) == false); assert(func0(2,4) == false); return 0; }
O3
c
func0: endbr64 xor %eax,%eax cmp %esi,%edi je 1154 <func0+0x14> xor %esi,%edi lea -0x1(%rdi),%eax test %edi,%eax sete %al retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 xor eax, eax cmp edi, esi jz short locret_1154 xor edi, esi lea eax, [rdi-1] test eax, edi setz al locret_1154: retn
bool func0(int a1, int a2) { bool result; // al result = 0; if ( a1 != a2 ) return ((a2 ^ a1) & ((a2 ^ a1) - 1)) == 0; return result; }
func0: ENDBR64 XOR EAX,EAX CMP EDI,ESI JZ 0x00101154 XOR EDI,ESI LEA EAX,[RDI + -0x1] TEST EAX,EDI SETZ AL LAB_00101154: RET
int4 func0(uint param_1,uint param_2) { uint uVar1; int4 uVar2; uVar2 = 0; if (param_1 != param_2) { uVar1 = (param_1 ^ param_2) - 1; uVar2 = CONCAT31((int3)(uVar1 >> 8),(uVar1 & (param_1 ^ param_2)) == 0); } return uVar2; }
3,920
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char **func0(const char *text) { // Allocate memory for maximum possible words char **result = malloc(sizeof(char*) * (strlen(text) / 2 + 1)); int count = 0; char *copy = strdup(text); char *token = strtok(copy, " "); while(token != NULL) { // Remove punctuation if any char *end = token + strlen(token) - 1; while(end > token && (*end == '.' || *end == ',' || *end == '!' || *end == '?' || *end == ';' || *end == ':')) { *end = '\0'; end--; } if(strlen(token) >= 4) { result[count++] = strdup(token); } token = strtok(NULL, " "); } result[count] = NULL; free(copy); return result; }
int main() { // First assert { char **result = func0("Please move back to stream"); assert(strcmp(result[0], "Please") == 0); assert(strcmp(result[1], "move") == 0); assert(strcmp(result[2], "back") == 0); assert(strcmp(result[3], "stream") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Second assert { char **result = func0("Jing Eco and Tech"); assert(strcmp(result[0], "Jing") == 0); assert(strcmp(result[1], "Tech") == 0); assert(result[2] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Third assert { char **result = func0("Jhingai wulu road Zone 3"); assert(strcmp(result[0], "Jhingai") == 0); assert(strcmp(result[1], "wulu") == 0); assert(strcmp(result[2], "road") == 0); assert(strcmp(result[3], "Zone") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x48,%rsp mov %rdi,-0x48(%rbp) mov -0x48(%rbp),%rax mov %rax,%rdi callq 10c0 <strlen@plt> shr %rax add $0x1,%rax shl $0x3,%rax mov %rax,%rdi callq 10f0 <malloc@plt> mov %rax,-0x20(%rbp) movl $0x0,-0x34(%rbp) mov -0x48(%rbp),%rax mov %rax,%rdi callq 1110 <strdup@plt> mov %rax,-0x18(%rbp) mov -0x18(%rbp),%rax lea 0xda9(%rip),%rsi mov %rax,%rdi callq 1100 <strtok@plt> mov %rax,-0x30(%rbp) jmpq 1336 <func0+0x12d> mov -0x30(%rbp),%rax mov %rax,%rdi callq 10c0 <strlen@plt> lea -0x1(%rax),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov %rax,-0x28(%rbp) jmp 1299 <func0+0x90> mov -0x28(%rbp),%rax movb $0x0,(%rax) subq $0x1,-0x28(%rbp) mov -0x28(%rbp),%rax cmp -0x30(%rbp),%rax jbe 12e5 <func0+0xdc> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x2e,%al je 128d <func0+0x84> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x2c,%al je 128d <func0+0x84> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x21,%al je 128d <func0+0x84> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x3f,%al je 128d <func0+0x84> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x3b,%al je 128d <func0+0x84> mov -0x28(%rbp),%rax movzbl (%rax),%eax cmp $0x3a,%al je 128d <func0+0x84> mov -0x30(%rbp),%rax mov %rax,%rdi callq 10c0 <strlen@plt> cmp $0x3,%rax jbe 1321 <func0+0x118> mov -0x34(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x34(%rbp) cltq lea 0x0(,%rax,8),%rdx mov -0x20(%rbp),%rax lea (%rdx,%rax,1),%rbx mov -0x30(%rbp),%rax mov %rax,%rdi callq 1110 <strdup@plt> mov %rax,(%rbx) lea 0xce0(%rip),%rsi mov $0x0,%edi callq 1100 <strtok@plt> mov %rax,-0x30(%rbp) cmpq $0x0,-0x30(%rbp) jne 1270 <func0+0x67> mov -0x34(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x20(%rbp),%rax add %rdx,%rax movq $0x0,(%rax) mov -0x18(%rbp),%rax mov %rax,%rdi callq 10b0 <free@plt> mov -0x20(%rbp),%rax add $0x48,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 48h mov [rbp+s], rdi mov rax, [rbp+s] mov rdi, rax; s call _strlen shr rax, 1 add rax, 1 shl rax, 3 mov rdi, rax; size call _malloc mov [rbp+var_20], rax mov [rbp+var_34], 0 mov rax, [rbp+s] mov rdi, rax; s call _strdup mov [rbp+var_18], rax mov rax, [rbp+var_18] lea rdx, delim; " " mov rsi, rdx; delim mov rdi, rax; s call _strtok mov [rbp+var_30], rax jmp loc_133C loc_1273: mov rax, [rbp+var_30] mov rdi, rax; s call _strlen lea rdx, [rax-1] mov rax, [rbp+var_30] add rax, rdx mov [rbp+var_28], rax jmp short loc_129C loc_1290: mov rax, [rbp+var_28] mov byte ptr [rax], 0 sub [rbp+var_28], 1 loc_129C: mov rax, [rbp+var_28] cmp [rbp+var_30], rax jnb short loc_12E8 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 2Eh ; '.' jz short loc_1290 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 2Ch ; ',' jz short loc_1290 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 21h ; '!' jz short loc_1290 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 3Fh ; '?' jz short loc_1290 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 3Bh ; ';' jz short loc_1290 mov rax, [rbp+var_28] movzx eax, byte ptr [rax] cmp al, 3Ah ; ':' jz short loc_1290 loc_12E8: mov rax, [rbp+var_30] mov rdi, rax; s call _strlen cmp rax, 3 jbe short loc_1324 mov eax, [rbp+var_34] lea edx, [rax+1] mov [rbp+var_34], edx cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_20] lea rbx, [rdx+rax] mov rax, [rbp+var_30] mov rdi, rax; s call _strdup mov [rbx], rax loc_1324: lea rax, delim; " " mov rsi, rax; delim mov edi, 0; s call _strtok mov [rbp+var_30], rax loc_133C: cmp [rbp+var_30], 0 jnz loc_1273 mov eax, [rbp+var_34] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_20] add rax, rdx mov qword ptr [rax], 0 mov rax, [rbp+var_18] mov rdi, rax; ptr call _free mov rax, [rbp+var_20] mov rbx, [rbp+var_8] leave retn
_QWORD * func0(const char *a1) { size_t v1; // rax int v2; // eax int v4; // [rsp+1Ch] [rbp-34h] const char *i; // [rsp+20h] [rbp-30h] const char *j; // [rsp+28h] [rbp-28h] _QWORD *v7; // [rsp+30h] [rbp-20h] char *v8; // [rsp+38h] [rbp-18h] v1 = strlen(a1); v7 = malloc(8 * ((v1 >> 1) + 1)); v4 = 0; v8 = strdup(a1); for ( i = strtok(v8, " "); i; i = strtok(0LL, " ") ) { for ( j = &i[strlen(i) - 1]; i < j && (*j == 46 || *j == 44 || *j == 33 || *j == 63 || *j == 59 || *j == 58); --j ) *j = 0; if ( strlen(i) > 3 ) { v2 = v4++; v7[v2] = strdup(i); } } v7[v4] = 0LL; free(v8); return v7; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x48 MOV qword ptr [RBP + -0x48],RDI MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x001010c0 SHR RAX,0x1 ADD RAX,0x1 SHL RAX,0x3 MOV RDI,RAX CALL 0x001010f0 MOV qword ptr [RBP + -0x20],RAX MOV dword ptr [RBP + -0x34],0x0 MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x00101110 MOV qword ptr [RBP + -0x18],RAX MOV RAX,qword ptr [RBP + -0x18] LEA RDX,[0x102008] MOV RSI,RDX MOV RDI,RAX CALL 0x00101100 MOV qword ptr [RBP + -0x30],RAX JMP 0x0010133c LAB_00101273: MOV RAX,qword ptr [RBP + -0x30] MOV RDI,RAX CALL 0x001010c0 LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RDX MOV qword ptr [RBP + -0x28],RAX JMP 0x0010129c LAB_00101290: MOV RAX,qword ptr [RBP + -0x28] MOV byte ptr [RAX],0x0 SUB qword ptr [RBP + -0x28],0x1 LAB_0010129c: MOV RAX,qword ptr [RBP + -0x28] CMP qword ptr [RBP + -0x30],RAX JNC 0x001012e8 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x2e JZ 0x00101290 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x2c JZ 0x00101290 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x21 JZ 0x00101290 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x3f JZ 0x00101290 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x3b JZ 0x00101290 MOV RAX,qword ptr [RBP + -0x28] MOVZX EAX,byte ptr [RAX] CMP AL,0x3a JZ 0x00101290 LAB_001012e8: MOV RAX,qword ptr [RBP + -0x30] MOV RDI,RAX CALL 0x001010c0 CMP RAX,0x3 JBE 0x00101324 MOV EAX,dword ptr [RBP + -0x34] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x34],EDX CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x20] LEA RBX,[RDX + RAX*0x1] MOV RAX,qword ptr [RBP + -0x30] MOV RDI,RAX CALL 0x00101110 MOV qword ptr [RBX],RAX LAB_00101324: LEA RAX,[0x102008] MOV RSI,RAX MOV EDI,0x0 CALL 0x00101100 MOV qword ptr [RBP + -0x30],RAX LAB_0010133c: CMP qword ptr [RBP + -0x30],0x0 JNZ 0x00101273 MOV EAX,dword ptr [RBP + -0x34] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x20] ADD RAX,RDX MOV qword ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x18] MOV RDI,RAX CALL 0x001010b0 MOV RAX,qword ptr [RBP + -0x20] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(char *param_1) { size_t sVar1; void *pvVar2; char *__s; char *pcVar3; int local_3c; char *local_38; char *local_30; sVar1 = strlen(param_1); pvVar2 = malloc(((sVar1 >> 1) + 1) * 8); local_3c = 0; __s = strdup(param_1); local_38 = strtok(__s," "); while (local_38 != (char *)0x0) { sVar1 = strlen(local_38); for (local_30 = local_38 + (sVar1 - 1); (local_38 < local_30 && ((((*local_30 == '.' || (*local_30 == ',')) || (*local_30 == '!')) || (((*local_30 == '?' || (*local_30 == ';')) || (*local_30 == ':')))))); local_30 = local_30 + -1) { *local_30 = '\0'; } sVar1 = strlen(local_38); if (3 < sVar1) { pcVar3 = strdup(local_38); *(char **)((long)local_3c * 8 + (long)pvVar2) = pcVar3; local_3c = local_3c + 1; } local_38 = strtok((char *)0x0," "); } *(int8 *)((long)pvVar2 + (long)local_3c * 8) = 0; free(__s); return pvVar2; }
3,921
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char **func0(const char *text) { // Allocate memory for maximum possible words char **result = malloc(sizeof(char*) * (strlen(text) / 2 + 1)); int count = 0; char *copy = strdup(text); char *token = strtok(copy, " "); while(token != NULL) { // Remove punctuation if any char *end = token + strlen(token) - 1; while(end > token && (*end == '.' || *end == ',' || *end == '!' || *end == '?' || *end == ';' || *end == ':')) { *end = '\0'; end--; } if(strlen(token) >= 4) { result[count++] = strdup(token); } token = strtok(NULL, " "); } result[count] = NULL; free(copy); return result; }
int main() { // First assert { char **result = func0("Please move back to stream"); assert(strcmp(result[0], "Please") == 0); assert(strcmp(result[1], "move") == 0); assert(strcmp(result[2], "back") == 0); assert(strcmp(result[3], "stream") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Second assert { char **result = func0("Jing Eco and Tech"); assert(strcmp(result[0], "Jing") == 0); assert(strcmp(result[1], "Tech") == 0); assert(result[2] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Third assert { char **result = func0("Jhingai wulu road Zone 3"); assert(strcmp(result[0], "Jhingai") == 0); assert(strcmp(result[1], "wulu") == 0); assert(strcmp(result[2], "road") == 0); assert(strcmp(result[3], "Zone") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x18,%rsp mov %rdi,%rbx mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax sub $0x1,%rax shr %rax lea 0x8(,%rax,8),%rdi callq 10b0 <malloc@plt> mov %rax,%r14 mov %rbx,%rdi callq 10d0 <strdup@plt> mov %rax,0x8(%rsp) lea 0xde7(%rip),%rsi mov %rax,%rdi callq 10c0 <strtok@plt> test %rax,%rax je 12ca <func0+0x101> mov %rax,%rsi mov $0x0,%r13d mov $0xffffffffffffffff,%r12 mov $0x0,%ebp movabs $0x8c00500200000000,%rbx jmp 1299 <func0+0xd0> bt %rdx,%rbx jae 1269 <func0+0xa0> movb $0x0,(%rax) sub $0x1,%rax cmp %rsi,%rax je 1269 <func0+0xa0> movzbl (%rax),%edx cmp $0x3f,%dl jbe 124f <func0+0x86> mov %r12,%rcx mov %rsi,%rdi mov %ebp,%eax repnz scas %es:(%rdi),%al not %rcx sub $0x1,%rcx cmp $0x3,%rcx ja 12b2 <func0+0xe9> lea 0xd7d(%rip),%rsi mov $0x0,%edi callq 10c0 <strtok@plt> mov %rax,%rsi test %rax,%rax je 12d0 <func0+0x107> mov %r12,%rcx mov %rsi,%rdi mov %ebp,%eax repnz scas %es:(%rdi),%al not %rcx lea -0x2(%rsi,%rcx,1),%rax cmp %rsi,%rax ja 1261 <func0+0x98> jmp 1269 <func0+0xa0> lea 0x1(%r13),%r15d mov %rsi,%rdi callq 10d0 <strdup@plt> movslq %r13d,%r13 mov %rax,(%r14,%r13,8) mov %r15d,%r13d jmp 1280 <func0+0xb7> mov $0x0,%r13d movslq %r13d,%r13 movq $0x0,(%r14,%r13,8) mov 0x8(%rsp),%rdi callq 1090 <free@plt> mov %r14,%rax add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 18h mov rbx, rdi call _strlen shr rax, 1 lea rdi, ds:8[rax*8] call _malloc mov r14, rax mov rdi, rbx call _strdup mov [rsp+48h+var_40], rax lea rsi, unk_2004 mov rdi, rax call _strtok test rax, rax jz loc_12EB mov rbx, rax mov r12d, 0 mov rbp, 8C00000200000000h lea r13, unk_2004 jmp short loc_12BE loc_1277: mov byte ptr [rax], 0 sub rax, 1 cmp rax, rbx jz short loc_129B loc_1283: movzx edx, byte ptr [rax] mov ecx, edx and ecx, 0FFFFFFFDh cmp cl, 2Ch ; ',' jz short loc_1277 cmp dl, 3Fh ; '?' ja short loc_129B bt rbp, rdx jb short loc_1277 loc_129B: mov rdi, rbx call _strlen cmp rax, 3 ja short loc_12D2 loc_12A9: mov rsi, r13 mov edi, 0 call _strtok mov rbx, rax test rax, rax jz short loc_12F1 loc_12BE: mov rdi, rbx call _strlen lea rax, [rbx+rax-1] cmp rax, rbx ja short loc_1283 jmp short loc_129B loc_12D2: lea r15d, [r12+1] mov rdi, rbx call _strdup movsxd r12, r12d mov [r14+r12*8], rax mov r12d, r15d jmp short loc_12A9 loc_12EB: mov r12d, 0 loc_12F1: movsxd r12, r12d mov qword ptr [r14+r12*8], 0 mov rdi, [rsp+48h+var_40] call _free mov rax, r14 add rsp, 18h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn
long long func0(long long a1) { unsigned long long v1; // rax long long v2; // r14 long long v3; // rax unsigned long long v4; // rbx int v5; // r12d unsigned long long v6; // rbp _BYTE *v7; // rax unsigned long long v8; // rdx long long v10; // [rsp+8h] [rbp-40h] v1 = ((long long (*)(void))strlen)(); v2 = malloc(8 * (v1 >> 1) + 8); v10 = strdup(a1); v3 = strtok(v10, &unk_2004); if ( v3 ) { v4 = v3; v5 = 0; v6 = 0x8C00000200000000LL; do { v7 = (_BYTE *)(v4 + strlen(v4) - 1); if ( (unsigned long long)v7 > v4 ) { do { v8 = (unsigned __int8)*v7; if ( (*v7 & 0xFD) != 0x2C && ((unsigned __int8)v8 > 0x3Fu || !_bittest64((const long long *)&v6, v8)) ) break; *v7-- = 0; } while ( v7 != (_BYTE *)v4 ); } if ( (unsigned long long)strlen(v4) > 3 ) *(_QWORD *)(v2 + 8LL * v5++) = strdup(v4); v4 = strtok(0LL, &unk_2004); } while ( v4 ); } else { v5 = 0; } *(_QWORD *)(v2 + 8LL * v5) = 0LL; free(v10); return v2; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x18 MOV RBX,RDI CALL 0x001010c0 SHR RAX,0x1 LEA RDI,[0x8 + RAX*0x8] CALL 0x001010f0 MOV R14,RAX MOV RDI,RBX CALL 0x00101110 MOV qword ptr [RSP + 0x8],RAX LEA RSI,[0x102004] MOV RDI,RAX CALL 0x00101100 TEST RAX,RAX JZ 0x001012eb MOV RBX,RAX MOV R12D,0x0 MOV RBP,-0x73fffffe00000000 LEA R13,[0x102004] JMP 0x001012be LAB_00101277: MOV byte ptr [RAX],0x0 SUB RAX,0x1 CMP RAX,RBX JZ 0x0010129b LAB_00101283: MOVZX EDX,byte ptr [RAX] MOV ECX,EDX AND ECX,0xfffffffd CMP CL,0x2c JZ 0x00101277 CMP DL,0x3f JA 0x0010129b BT RBP,RDX JC 0x00101277 LAB_0010129b: MOV RDI,RBX CALL 0x001010c0 CMP RAX,0x3 JA 0x001012d2 LAB_001012a9: MOV RSI,R13 MOV EDI,0x0 CALL 0x00101100 MOV RBX,RAX TEST RAX,RAX JZ 0x001012f1 LAB_001012be: MOV RDI,RBX CALL 0x001010c0 LEA RAX,[RBX + RAX*0x1 + -0x1] CMP RAX,RBX JA 0x00101283 JMP 0x0010129b LAB_001012d2: LEA R15D,[R12 + 0x1] MOV RDI,RBX CALL 0x00101110 MOVSXD R12,R12D MOV qword ptr [R14 + R12*0x8],RAX MOV R12D,R15D JMP 0x001012a9 LAB_001012eb: MOV R12D,0x0 LAB_001012f1: MOVSXD R12,R12D MOV qword ptr [R14 + R12*0x8],0x0 MOV RDI,qword ptr [RSP + 0x8] CALL 0x001010b0 MOV RAX,R14 ADD RSP,0x18 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET
void * func0(char *param_1) { byte bVar1; size_t sVar2; void *pvVar3; char *__s; byte *__s_00; byte *pbVar4; char *pcVar5; int iVar6; sVar2 = strlen(param_1); pvVar3 = malloc((sVar2 >> 1) * 8 + 8); __s = strdup(param_1); __s_00 = (byte *)strtok(__s," "); if (__s_00 == (byte *)0x0) { iVar6 = 0; } else { iVar6 = 0; do { sVar2 = strlen((char *)__s_00); pbVar4 = __s_00 + (sVar2 - 1); if (__s_00 < pbVar4) { do { bVar1 = *pbVar4; if (((bVar1 & 0xfd) != 0x2c) && ((0x3f < bVar1 || ((0x8c00000200000000U >> ((ulong)bVar1 & 0x3f) & 1) == 0)))) break; *pbVar4 = 0; pbVar4 = pbVar4 + -1; } while (pbVar4 != __s_00); } sVar2 = strlen((char *)__s_00); if (3 < sVar2) { pcVar5 = strdup((char *)__s_00); *(char **)((long)pvVar3 + (long)iVar6 * 8) = pcVar5; iVar6 = iVar6 + 1; } __s_00 = (byte *)strtok((char *)0x0," "); } while (__s_00 != (byte *)0x0); } *(int8 *)((long)pvVar3 + (long)iVar6 * 8) = 0; free(__s); return pvVar3; }
3,922
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char **func0(const char *text) { // Allocate memory for maximum possible words char **result = malloc(sizeof(char*) * (strlen(text) / 2 + 1)); int count = 0; char *copy = strdup(text); char *token = strtok(copy, " "); while(token != NULL) { // Remove punctuation if any char *end = token + strlen(token) - 1; while(end > token && (*end == '.' || *end == ',' || *end == '!' || *end == '?' || *end == ';' || *end == ':')) { *end = '\0'; end--; } if(strlen(token) >= 4) { result[count++] = strdup(token); } token = strtok(NULL, " "); } result[count] = NULL; free(copy); return result; }
int main() { // First assert { char **result = func0("Please move back to stream"); assert(strcmp(result[0], "Please") == 0); assert(strcmp(result[1], "move") == 0); assert(strcmp(result[2], "back") == 0); assert(strcmp(result[3], "stream") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Second assert { char **result = func0("Jing Eco and Tech"); assert(strcmp(result[0], "Jing") == 0); assert(strcmp(result[1], "Tech") == 0); assert(result[2] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Third assert { char **result = func0("Jhingai wulu road Zone 3"); assert(strcmp(result[0], "Jhingai") == 0); assert(strcmp(result[1], "wulu") == 0); assert(strcmp(result[2], "road") == 0); assert(strcmp(result[3], "Zone") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp mov %rdi,%rbp push %rbx sub $0x18,%rsp callq 10b0 <strlen@plt> shr %rax lea 0x8(,%rax,8),%rdi callq 10d0 <malloc@plt> mov %rbp,%rdi mov %rax,%r12 callq 10f0 <strdup@plt> lea 0xa28(%rip),%rsi mov %rax,%rdi mov %rax,0x8(%rsp) callq 10e0 <strtok@plt> test %rax,%rax je 1685 <func0+0xe5> movabs $0x8c00500200000000,%r15 mov %rax,%rbp xor %ebx,%ebx jmp 163b <func0+0x9b> nopl 0x0(%rax,%rax,1) mov %rbp,%rdi callq 10b0 <strlen@plt> movslq %ebx,%rdx lea 0x0(,%rdx,8),%r13 lea (%r12,%r13,1),%r14 cmp $0x3,%rax ja 1670 <func0+0xd0> lea 0x9d8(%rip),%rsi xor %edi,%edi callq 10e0 <strtok@plt> mov %rax,%rbp test %rax,%rax je 1688 <func0+0xe8> mov %rbp,%rdi callq 10b0 <strlen@plt> lea -0x1(%rbp,%rax,1),%rdx cmp %rbp,%rdx jbe 1610 <func0+0x70> nopl (%rax) movzbl (%rdx),%eax cmp $0x3f,%al ja 1608 <func0+0x68> bt %rax,%r15 jae 1608 <func0+0x68> movb $0x0,(%rdx) sub $0x1,%rdx cmp %rbp,%rdx jne 1650 <func0+0xb0> jmp 1608 <func0+0x68> nopl 0x0(%rax,%rax,1) mov %rbp,%rdi add $0x1,%ebx callq 10f0 <strdup@plt> mov %rax,(%r14) lea 0x8(%r12,%r13,1),%r14 jmp 1625 <func0+0x85> mov %r12,%r14 movq $0x0,(%r14) mov 0x8(%rsp),%rdi callq 10a0 <free@plt> add $0x18,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 lea r12, unk_2004 push rbp mov rbp, rdi push rbx sub rsp, 18h call _strlen shr rax, 1 lea rdi, ds:8[rax*8] call _malloc mov rdi, rbp mov r13, rax call _strdup mov rsi, r12 mov rdi, rax mov [rsp+48h+var_40], rax call _strtok test rax, rax jz loc_167E mov rbx, 8C00000200000000h mov r14, rax xor ebp, ebp jmp short loc_160B loc_15E0: cmp cl, 3Fh ; '?' ja short loc_15EB bt rbx, rcx jb short loc_162E loc_15EB: mov rdi, r14 call _strlen loc_15F3: cmp rax, 3 ja short loc_1640 loc_15F9: mov rsi, r12 xor edi, edi call _strtok mov r14, rax test rax, rax jz short loc_1656 loc_160B: mov rdi, r14 call _strlen lea rdx, [r14+rax-1] cmp rdx, r14 jbe short loc_15F3 nop dword ptr [rax] loc_1620: movzx ecx, byte ptr [rdx] mov esi, ecx and esi, 0FFFFFFFDh cmp sil, 2Ch ; ',' jnz short loc_15E0 loc_162E: mov byte ptr [rdx], 0 sub rdx, 1 cmp rdx, r14 jnz short loc_1620 jmp short loc_15EB loc_1640: mov rdi, r14 lea r15d, [rbp+1] call _strdup mov [r13+rbp*8+0], rax movsxd rbp, r15d jmp short loc_15F9 loc_1656: lea rax, [r13+rbp*8+0] loc_165B: mov qword ptr [rax], 0 mov rdi, [rsp+48h+var_40] call _free add rsp, 18h mov rax, r13 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_167E: mov rax, r13 jmp short loc_165B
long long func0(long long a1) { unsigned long long v1; // rax long long v2; // r13 long long v3; // rax unsigned long long v4; // rbx unsigned long long v5; // r14 long long v6; // rbp unsigned long long v7; // rax _BYTE *v8; // rdx unsigned long long v9; // rcx _QWORD *v10; // rax long long v12; // [rsp+8h] [rbp-40h] v1 = ((long long (*)(void))strlen)(); v2 = malloc(8 * (v1 >> 1) + 8); v12 = strdup(a1); v3 = strtok(v12, &unk_2004); if ( v3 ) { v4 = 0x8C00000200000000LL; v5 = v3; v6 = 0LL; do { v7 = strlen(v5); v8 = (_BYTE *)(v5 + v7 - 1); if ( (unsigned long long)v8 > v5 ) { do { v9 = (unsigned __int8)*v8; if ( (*v8 & 0xFD) != 0x2C && ((unsigned __int8)v9 > 0x3Fu || !_bittest64((const long long *)&v4, v9)) ) break; *v8-- = 0; } while ( v8 != (_BYTE *)v5 ); v7 = strlen(v5); } if ( v7 > 3 ) { *(_QWORD *)(v2 + 8 * v6) = strdup(v5); v6 = (int)v6 + 1; } v5 = strtok(0LL, &unk_2004); } while ( v5 ); v10 = (_QWORD *)(v2 + 8 * v6); } else { v10 = (_QWORD *)v2; } *v10 = 0LL; free(v12); return v2; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 LEA R12,[0x102004] PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x18 CALL 0x001010c0 SHR RAX,0x1 LEA RDI,[0x8 + RAX*0x8] CALL 0x001010f0 MOV RDI,RBP MOV R13,RAX CALL 0x00101110 MOV RSI,R12 MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX CALL 0x00101100 TEST RAX,RAX JZ 0x0010167e MOV RBX,-0x73fffffe00000000 MOV R14,RAX XOR EBP,EBP JMP 0x0010160b LAB_001015e0: CMP CL,0x3f JA 0x001015eb BT RBX,RCX JC 0x0010162e LAB_001015eb: MOV RDI,R14 CALL 0x001010c0 LAB_001015f3: CMP RAX,0x3 JA 0x00101640 LAB_001015f9: MOV RSI,R12 XOR EDI,EDI CALL 0x00101100 MOV R14,RAX TEST RAX,RAX JZ 0x00101656 LAB_0010160b: MOV RDI,R14 CALL 0x001010c0 LEA RDX,[R14 + RAX*0x1 + -0x1] CMP RDX,R14 JBE 0x001015f3 NOP dword ptr [RAX] LAB_00101620: MOVZX ECX,byte ptr [RDX] MOV ESI,ECX AND ESI,0xfffffffd CMP SIL,0x2c JNZ 0x001015e0 LAB_0010162e: MOV byte ptr [RDX],0x0 SUB RDX,0x1 CMP RDX,R14 JNZ 0x00101620 JMP 0x001015eb LAB_00101640: MOV RDI,R14 LEA R15D,[RBP + 0x1] CALL 0x00101110 MOV qword ptr [R13 + RBP*0x8],RAX MOVSXD RBP,R15D JMP 0x001015f9 LAB_00101656: LEA RAX,[R13 + RBP*0x8] LAB_0010165b: MOV qword ptr [RAX],0x0 MOV RDI,qword ptr [RSP + 0x8] CALL 0x001010b0 ADD RSP,0x18 MOV RAX,R13 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010167e: MOV RAX,R13 JMP 0x0010165b
int8 * func0(char *param_1) { byte bVar1; size_t sVar2; int8 *puVar3; char *__s; byte *__s_00; ulong uVar4; char *pcVar5; int8 *puVar6; byte *pbVar7; long lVar8; sVar2 = strlen(param_1); puVar3 = (int8 *)malloc((sVar2 >> 1) * 8 + 8); __s = strdup(param_1); __s_00 = (byte *)strtok(__s," "); puVar6 = puVar3; if (__s_00 != (byte *)0x0) { lVar8 = 0; do { uVar4 = strlen((char *)__s_00); pbVar7 = __s_00 + (uVar4 - 1); if (__s_00 < pbVar7) { do { bVar1 = *pbVar7; if (((bVar1 & 0xfd) != 0x2c) && ((0x3f < bVar1 || ((0x8c00000200000000U >> ((ulong)bVar1 & 0x3f) & 1) == 0)))) break; *pbVar7 = 0; pbVar7 = pbVar7 + -1; } while (pbVar7 != __s_00); uVar4 = strlen((char *)__s_00); } if (3 < uVar4) { pcVar5 = strdup((char *)__s_00); puVar3[lVar8] = pcVar5; lVar8 = (long)((int)lVar8 + 1); } __s_00 = (byte *)strtok((char *)0x0," "); } while (__s_00 != (byte *)0x0); puVar6 = puVar3 + lVar8; } *puVar6 = 0; free(__s); return puVar3; }
3,923
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char **func0(const char *text) { // Allocate memory for maximum possible words char **result = malloc(sizeof(char*) * (strlen(text) / 2 + 1)); int count = 0; char *copy = strdup(text); char *token = strtok(copy, " "); while(token != NULL) { // Remove punctuation if any char *end = token + strlen(token) - 1; while(end > token && (*end == '.' || *end == ',' || *end == '!' || *end == '?' || *end == ';' || *end == ':')) { *end = '\0'; end--; } if(strlen(token) >= 4) { result[count++] = strdup(token); } token = strtok(NULL, " "); } result[count] = NULL; free(copy); return result; }
int main() { // First assert { char **result = func0("Please move back to stream"); assert(strcmp(result[0], "Please") == 0); assert(strcmp(result[1], "move") == 0); assert(strcmp(result[2], "back") == 0); assert(strcmp(result[3], "stream") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Second assert { char **result = func0("Jing Eco and Tech"); assert(strcmp(result[0], "Jing") == 0); assert(strcmp(result[1], "Tech") == 0); assert(result[2] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } // Third assert { char **result = func0("Jhingai wulu road Zone 3"); assert(strcmp(result[0], "Jhingai") == 0); assert(strcmp(result[1], "wulu") == 0); assert(strcmp(result[2], "road") == 0); assert(strcmp(result[3], "Zone") == 0); assert(result[4] == NULL); // Free allocated memory for(int i = 0; result[i] != NULL; i++) { free(result[i]); } free(result); } return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp mov %rdi,%rbp push %rbx sub $0x18,%rsp callq 10b0 <strlen@plt> shr %rax lea 0x8(,%rax,8),%rdi callq 10d0 <malloc@plt> mov %rbp,%rdi mov %rax,%r12 callq 10f0 <strdup@plt> lea 0xa28(%rip),%rsi mov %rax,%rdi mov %rax,0x8(%rsp) callq 10e0 <strtok@plt> test %rax,%rax je 16d1 <func0+0x131> mov %rax,%r14 xor %ebp,%ebp xor %ebx,%ebx movabs $0x8c00500200000000,%r13 nopl 0x0(%rax,%rax,1) mov %r14,%rdi callq 10b0 <strlen@plt> lea -0x1(%r14,%rax,1),%rdx cmp %r14,%rdx jbe 162f <func0+0x8f> nopw 0x0(%rax,%rax,1) movzbl (%rdx),%eax cmp $0x3f,%al jbe 1680 <func0+0xe0> mov %r14,%rdi callq 10b0 <strlen@plt> lea 0x0(,%rbx,8),%rdx lea (%r12,%rdx,1),%r15 cmp $0x3,%rax ja 1698 <func0+0xf8> lea 0x9bc(%rip),%rsi xor %edi,%edi callq 10e0 <strtok@plt> mov %rax,%r14 test %rax,%rax jne 1608 <func0+0x68> movq $0x0,(%r15) mov 0x8(%rsp),%rdi callq 10a0 <free@plt> add $0x18,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1) bt %rax,%r13 jae 1627 <func0+0x87> movb $0x0,(%rdx) sub $0x1,%rdx cmp %r14,%rdx jne 1620 <func0+0x80> jmp 1627 <func0+0x87> nopl 0x0(%rax) mov %r14,%rdi mov %rdx,(%rsp) add $0x1,%ebp callq 10f0 <strdup@plt> mov (%rsp),%rdx lea 0x952(%rip),%rsi xor %edi,%edi mov %rax,(%r15) lea 0x8(%r12,%rdx,1),%r15 callq 10e0 <strtok@plt> mov %rax,%r14 test %rax,%rax je 1657 <func0+0xb7> movslq %ebp,%rbx jmpq 1608 <func0+0x68> mov %r12,%r15 jmp 1657 <func0+0xb7> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp lea rbp, delim; " " push rbx mov rbx, rdi sub rsp, 18h call _strlen shr rax, 1 lea rdi, ds:8[rax*8]; size call _malloc mov rdi, rbx; s mov r12, rax call _strdup mov rsi, rbp; delim mov rdi, rax; s mov [rsp+48h+ptr], rax call _strtok test rax, rax jz loc_1683 mov r13, 8C00500200000000h mov r14, rax xor ebx, ebx nop dword ptr [rax+00h] loc_15D8: mov rdi, r14; s call _strlen lea rdx, [r14+rax-1] cmp r14, rdx jnb short loc_1612 nop word ptr [rax+rax+00h] loc_15F0: movzx ecx, byte ptr [rdx] cmp cl, 3Fh ; '?' ja short loc_160A bt r13, rcx jnb short loc_160A mov byte ptr [rdx], 0 sub rdx, 1 cmp rdx, r14 jnz short loc_15F0 loc_160A: mov rdi, r14; s call _strlen loc_1612: cmp rax, 3 ja short loc_1658 mov rsi, rbp; delim xor edi, edi; s call _strtok mov r14, rax test rax, rax jnz short loc_15D8 loc_162A: lea rax, [r12+rbx*8] loc_162E: mov qword ptr [rax], 0 mov rdi, [rsp+48h+ptr]; ptr call _free add rsp, 18h mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1658: mov rdi, r14; s lea r15d, [rbx+1] call _strdup mov rsi, rbp; delim xor edi, edi; s mov [r12+rbx*8], rax movsxd rbx, r15d call _strtok mov r14, rax test rax, rax jnz loc_15D8 jmp short loc_162A loc_1683: mov rax, r12 jmp short loc_162E
_QWORD * func0(char *s) { size_t v1; // rax _QWORD *v2; // r12 char *v3; // rax unsigned long long v4; // r13 char *v5; // r14 long long v6; // rbx size_t v7; // rax char *v8; // rdx unsigned long long v9; // rcx _QWORD *v10; // rax char *ptr; // [rsp+8h] [rbp-40h] v1 = strlen(s); v2 = malloc(8 * (v1 >> 1) + 8); ptr = strdup(s); v3 = strtok(ptr, " "); if ( v3 ) { v4 = 0x8C00500200000000LL; v5 = v3; v6 = 0LL; do { while ( 1 ) { v7 = strlen(v5); v8 = &v5[v7 - 1]; if ( v5 < v8 ) { do { v9 = (unsigned __int8)*v8; if ( (unsigned __int8)v9 > 0x3Fu ) break; if ( !_bittest64((const long long *)&v4, v9) ) break; *v8-- = 0; } while ( v8 != v5 ); v7 = strlen(v5); } if ( v7 > 3 ) break; v5 = strtok(0LL, " "); if ( !v5 ) goto LABEL_10; } v2[v6] = strdup(v5); v6 = (int)v6 + 1; v5 = strtok(0LL, " "); } while ( v5 ); LABEL_10: v10 = &v2[v6]; } else { v10 = v2; } *v10 = 0LL; free(ptr); return v2; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP LEA RBP,[0x102004] PUSH RBX MOV RBX,RDI SUB RSP,0x18 CALL 0x001010c0 SHR RAX,0x1 LEA RDI,[0x8 + RAX*0x8] CALL 0x001010f0 MOV RDI,RBX MOV R12,RAX CALL 0x00101110 MOV RSI,RBP MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX CALL 0x00101100 TEST RAX,RAX JZ 0x00101683 MOV R13,-0x73ffaffe00000000 MOV R14,RAX XOR EBX,EBX NOP dword ptr [RAX] LAB_001015d8: MOV RDI,R14 CALL 0x001010c0 LEA RDX,[R14 + RAX*0x1 + -0x1] CMP R14,RDX JNC 0x00101612 NOP word ptr [RAX + RAX*0x1] LAB_001015f0: MOVZX ECX,byte ptr [RDX] CMP CL,0x3f JA 0x0010160a BT R13,RCX JNC 0x0010160a MOV byte ptr [RDX],0x0 SUB RDX,0x1 CMP RDX,R14 JNZ 0x001015f0 LAB_0010160a: MOV RDI,R14 CALL 0x001010c0 LAB_00101612: CMP RAX,0x3 JA 0x00101658 MOV RSI,RBP XOR EDI,EDI CALL 0x00101100 MOV R14,RAX TEST RAX,RAX JNZ 0x001015d8 LAB_0010162a: LEA RAX,[R12 + RBX*0x8] LAB_0010162e: MOV qword ptr [RAX],0x0 MOV RDI,qword ptr [RSP + 0x8] CALL 0x001010b0 ADD RSP,0x18 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101658: MOV RDI,R14 LEA R15D,[RBX + 0x1] CALL 0x00101110 MOV RSI,RBP XOR EDI,EDI MOV qword ptr [R12 + RBX*0x8],RAX MOVSXD RBX,R15D CALL 0x00101100 MOV R14,RAX TEST RAX,RAX JNZ 0x001015d8 JMP 0x0010162a LAB_00101683: MOV RAX,R12 JMP 0x0010162e
int8 * func0(char *param_1) { size_t sVar1; int8 *puVar2; char *__s; byte *__s_00; ulong uVar3; int8 *puVar4; char *pcVar5; byte *pbVar6; long lVar7; sVar1 = strlen(param_1); puVar2 = (int8 *)malloc((sVar1 >> 1) * 8 + 8); __s = strdup(param_1); __s_00 = (byte *)strtok(__s," "); puVar4 = puVar2; if (__s_00 != (byte *)0x0) { lVar7 = 0; LAB_001015d8: do { uVar3 = strlen((char *)__s_00); pbVar6 = __s_00 + (uVar3 - 1); if (__s_00 < pbVar6) { do { if ((0x3f < *pbVar6) || ((0x8c00500200000000U >> ((ulong)*pbVar6 & 0x3f) & 1) == 0)) break; *pbVar6 = 0; pbVar6 = pbVar6 + -1; } while (pbVar6 != __s_00); uVar3 = strlen((char *)__s_00); } if (3 < uVar3) { pcVar5 = strdup((char *)__s_00); puVar2[lVar7] = pcVar5; lVar7 = (long)((int)lVar7 + 1); __s_00 = (byte *)strtok((char *)0x0," "); if (__s_00 == (byte *)0x0) break; goto LAB_001015d8; } __s_00 = (byte *)strtok((char *)0x0," "); } while (__s_00 != (byte *)0x0); puVar4 = puVar2 + lVar7; } *puVar4 = 0; free(__s); return puVar2; }
3,924
func0
#include <assert.h> #include <stdio.h>
void func0(int nums[], int result[], int size) { for (int i = 0; i < size; i++) { result[i] = nums[i] * nums[i]; } }
int main() { int nums1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int size1 = sizeof(nums1) / sizeof(nums1[0]); int result1[10]; func0(nums1, result1, size1); int expected1[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; for(int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int nums2[] = {10, 20, 30}; int size2 = sizeof(nums2) / sizeof(nums2[0]); int result2[3]; func0(nums2, result2, size2); int expected2[] = {100, 400, 900}; for(int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int nums3[] = {12, 15}; int size3 = sizeof(nums3) / sizeof(nums3[0]); int result3[2]; func0(nums3, result3, size3); int expected3[] = {144, 225}; for(int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %rsi,-0x20(%rbp) mov %edx,-0x24(%rbp) movl $0x0,-0x4(%rbp) jmp 11ef <func0+0x66> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%ecx mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov -0x4(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rsi mov -0x20(%rbp),%rdx add %rsi,%rdx imul %ecx,%eax mov %eax,(%rdx) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x24(%rbp),%eax jl 11a5 <func0+0x1c> pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_20], rsi mov [rbp+var_24], edx mov [rbp+var_4], 0 jmp short loc_11EF loc_11A5: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rax] mov eax, [rbp+var_4] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rcx mov eax, [rax] mov ecx, [rbp+var_4] movsxd rcx, ecx lea rsi, ds:0[rcx*4] mov rcx, [rbp+var_20] add rcx, rsi imul eax, edx mov [rcx], eax add [rbp+var_4], 1 loc_11EF: mov eax, [rbp+var_4] cmp eax, [rbp+var_24] jl short loc_11A5 nop nop pop rbp retn
long long func0(long long a1, long long a2, int a3) { long long result; // rax unsigned int i; // [rsp+20h] [rbp-4h] for ( i = 0; ; ++i ) { result = i; if ( (int)i >= a3 ) break; *(_DWORD *)(4LL * (int)i + a2) = *(_DWORD *)(4LL * (int)i + a1) * *(_DWORD *)(4LL * (int)i + a1); } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV qword ptr [RBP + -0x20],RSI MOV dword ptr [RBP + -0x24],EDX MOV dword ptr [RBP + -0x4],0x0 JMP 0x001011ef LAB_001011a5: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RCX MOV EAX,dword ptr [RAX] MOV ECX,dword ptr [RBP + -0x4] MOVSXD RCX,ECX LEA RSI,[RCX*0x4] MOV RCX,qword ptr [RBP + -0x20] ADD RCX,RSI IMUL EAX,EDX MOV dword ptr [RCX],EAX ADD dword ptr [RBP + -0x4],0x1 LAB_001011ef: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x24] JL 0x001011a5 NOP NOP POP RBP RET
void func0(long param_1,long param_2,int param_3) { int4 local_c; for (local_c = 0; local_c < param_3; local_c = local_c + 1) { *(int *)(param_2 + (long)local_c * 4) = *(int *)(param_1 + (long)local_c * 4) * *(int *)(param_1 + (long)local_c * 4); } return; }
3,925
func0
#include <assert.h> #include <stdio.h>
void func0(int nums[], int result[], int size) { for (int i = 0; i < size; i++) { result[i] = nums[i] * nums[i]; } }
int main() { int nums1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int size1 = sizeof(nums1) / sizeof(nums1[0]); int result1[10]; func0(nums1, result1, size1); int expected1[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; for(int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int nums2[] = {10, 20, 30}; int size2 = sizeof(nums2) / sizeof(nums2[0]); int result2[3]; func0(nums2, result2, size2); int expected2[] = {100, 400, 900}; for(int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int nums3[] = {12, 15}; int size3 = sizeof(nums3) / sizeof(nums3[0]); int result3[2]; func0(nums3, result3, size3); int expected3[] = {144, 225}; for(int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O1
c
func0: endbr64 test %edx,%edx jle 11ae <func0+0x25> lea -0x1(%rdx),%ecx mov $0x0,%eax mov (%rdi,%rax,4),%edx imul %edx,%edx mov %edx,(%rsi,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 1199 <func0+0x10> retq
func0: endbr64 test edx, edx jle short locret_11AA mov edx, edx mov eax, 0 loc_1198: mov ecx, [rdi+rax*4] imul ecx, ecx mov [rsi+rax*4], ecx add rax, 1 cmp rax, rdx jnz short loc_1198 locret_11AA: retn
void func0(long long a1, long long a2, int a3) { long long i; // rax if ( a3 > 0 ) { for ( i = 0LL; i != a3; ++i ) *(_DWORD *)(a2 + 4 * i) = *(_DWORD *)(a1 + 4 * i) * *(_DWORD *)(a1 + 4 * i); } }
func0: ENDBR64 TEST EDX,EDX JLE 0x001011aa MOV EDX,EDX MOV EAX,0x0 LAB_00101198: MOV ECX,dword ptr [RDI + RAX*0x4] IMUL ECX,ECX MOV dword ptr [RSI + RAX*0x4],ECX ADD RAX,0x1 CMP RAX,RDX JNZ 0x00101198 LAB_001011aa: RET
void func0(long param_1,long param_2,uint param_3) { int iVar1; ulong uVar2; if (0 < (int)param_3) { uVar2 = 0; do { iVar1 = *(int *)(param_1 + uVar2 * 4); *(int *)(param_2 + uVar2 * 4) = iVar1 * iVar1; uVar2 = uVar2 + 1; } while (uVar2 != param_3); } return; }
3,926
func0
#include <assert.h> #include <stdio.h>
void func0(int nums[], int result[], int size) { for (int i = 0; i < size; i++) { result[i] = nums[i] * nums[i]; } }
int main() { int nums1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int size1 = sizeof(nums1) / sizeof(nums1[0]); int result1[10]; func0(nums1, result1, size1); int expected1[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; for(int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int nums2[] = {10, 20, 30}; int size2 = sizeof(nums2) / sizeof(nums2[0]); int result2[3]; func0(nums2, result2, size2); int expected2[] = {100, 400, 900}; for(int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int nums3[] = {12, 15}; int size3 = sizeof(nums3) / sizeof(nums3[0]); int result3[2]; func0(nums3, result3, size3); int expected3[] = {144, 225}; for(int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O2
c
func0: endbr64 test %edx,%edx jle 1305 <func0+0x25> lea -0x1(%rdx),%ecx xor %eax,%eax nopl (%rax) mov (%rdi,%rax,4),%edx imul %edx,%edx mov %edx,(%rsi,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rdx,%rcx jne 12f0 <func0+0x10> retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 test edx, edx jle short locret_12F2 movsxd rdx, edx xor eax, eax nop dword ptr [rax] loc_12E0: mov ecx, [rdi+rax*4] imul ecx, ecx mov [rsi+rax*4], ecx add rax, 1 cmp rdx, rax jnz short loc_12E0 locret_12F2: retn
void func0(long long a1, long long a2, int a3) { long long i; // rax if ( a3 > 0 ) { for ( i = 0LL; i != a3; ++i ) *(_DWORD *)(a2 + 4 * i) = *(_DWORD *)(a1 + 4 * i) * *(_DWORD *)(a1 + 4 * i); } }
func0: ENDBR64 TEST EDX,EDX JLE 0x001012f2 MOVSXD RDX,EDX XOR EAX,EAX NOP dword ptr [RAX] LAB_001012e0: MOV ECX,dword ptr [RDI + RAX*0x4] IMUL ECX,ECX MOV dword ptr [RSI + RAX*0x4],ECX ADD RAX,0x1 CMP RDX,RAX JNZ 0x001012e0 LAB_001012f2: RET
void func0(long param_1,long param_2,int param_3) { int iVar1; long lVar2; if (0 < param_3) { lVar2 = 0; do { iVar1 = *(int *)(param_1 + lVar2 * 4); *(int *)(param_2 + lVar2 * 4) = iVar1 * iVar1; lVar2 = lVar2 + 1; } while (param_3 != lVar2); } return; }
3,927
func0
#include <assert.h> #include <stdio.h>
void func0(int nums[], int result[], int size) { for (int i = 0; i < size; i++) { result[i] = nums[i] * nums[i]; } }
int main() { int nums1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int size1 = sizeof(nums1) / sizeof(nums1[0]); int result1[10]; func0(nums1, result1, size1); int expected1[] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}; for(int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int nums2[] = {10, 20, 30}; int size2 = sizeof(nums2) / sizeof(nums2[0]); int result2[3]; func0(nums2, result2, size2); int expected2[] = {100, 400, 900}; for(int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int nums3[] = {12, 15}; int size3 = sizeof(nums3) / sizeof(nums3[0]); int result3[2]; func0(nums3, result3, size3); int expected3[] = {144, 225}; for(int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O3
c
func0: endbr64 test %edx,%edx jle 137d <func0+0xcd> lea 0xf(%rdi),%rcx lea -0x1(%rdx),%eax sub %rsi,%rcx cmp $0x1e,%rcx jbe 1360 <func0+0xb0> cmp $0x3,%eax jbe 1360 <func0+0xb0> mov %edx,%ecx xor %eax,%eax shr $0x2,%ecx shl $0x4,%rcx nopl 0x0(%rax) movdqu (%rdi,%rax,1),%xmm0 movdqa %xmm0,%xmm1 pmuludq %xmm0,%xmm1 psrlq $0x20,%xmm0 pmuludq %xmm0,%xmm0 pshufd $0x8,%xmm1,%xmm1 pshufd $0x8,%xmm0,%xmm0 punpckldq %xmm0,%xmm1 movups %xmm1,(%rsi,%rax,1) add $0x10,%rax cmp %rcx,%rax jne 12e8 <func0+0x38> mov %edx,%eax and $0xfffffffc,%eax test $0x3,%dl je 137d <func0+0xcd> mov %eax,%r8d mov (%rdi,%r8,4),%ecx imul %ecx,%ecx mov %ecx,(%rsi,%r8,4) lea 0x1(%rax),%ecx cmp %ecx,%edx jle 137d <func0+0xcd> movslq %ecx,%rcx add $0x2,%eax mov (%rdi,%rcx,4),%r8d imul %r8d,%r8d mov %r8d,(%rsi,%rcx,4) cmp %eax,%edx jle 137d <func0+0xcd> cltq mov (%rdi,%rax,4),%edx imul %edx,%edx mov %edx,(%rsi,%rax,4) retq nopw 0x0(%rax,%rax,1) mov %eax,%ecx xor %eax,%eax nopl 0x0(%rax) mov (%rdi,%rax,4),%edx imul %edx,%edx mov %edx,(%rsi,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 1368 <func0+0xb8> retq xchg %ax,%ax
func0: endbr64 movsxd rax, edx test eax, eax jle short locret_11B2 lea edx, [rax-1] cmp edx, 2 jbe short loc_1193 lea rcx, [rdi+4] mov rdx, rsi sub rdx, rcx cmp rdx, 8 ja short loc_11B8 loc_1193: lea rcx, ds:0[rax*4] xor eax, eax nop dword ptr [rax] loc_11A0: mov edx, [rdi+rax] imul edx, edx mov [rsi+rax], edx add rax, 4 cmp rcx, rax jnz short loc_11A0 locret_11B2: retn loc_11B8: mov ecx, eax xor edx, edx shr ecx, 2 shl rcx, 4 nop dword ptr [rax+rax+00h] loc_11C8: movdqu xmm0, xmmword ptr [rdi+rdx] movdqa xmm1, xmm0 pmuludq xmm1, xmm0 psrlq xmm0, 20h ; ' ' pmuludq xmm0, xmm0 pshufd xmm1, xmm1, 8 pshufd xmm0, xmm0, 8 punpckldq xmm1, xmm0 movups xmmword ptr [rsi+rdx], xmm1 add rdx, 10h cmp rdx, rcx jnz short loc_11C8 mov edx, eax and edx, 0FFFFFFFCh test al, 3 jz short locret_11B2 mov r9d, edx mov ecx, [rdi+r9*4] lea r8, ds:0[r9*4] imul ecx, ecx mov [rsi+r9*4], ecx lea ecx, [rdx+1] cmp eax, ecx jle short locret_11B2 mov ecx, [rdi+r8+4] add edx, 2 imul ecx, ecx mov [rsi+r8+4], ecx cmp eax, edx jle locret_11B2 mov eax, [rdi+r8+8] imul eax, eax mov [rsi+r8+8], eax retn
long long func0(long long a1, long long a2, int a3) { long long result; // rax long long v4; // rdx __m128i v5; // xmm0 __m128i v6; // xmm1 __m128i v7; // xmm0 unsigned int v8; // edx long long v9; // r8 result = a3; if ( a3 > 0 ) { if ( (unsigned int)(a3 - 1) > 2 && (unsigned long long)(a2 - (a1 + 4)) > 8 ) { v4 = 0LL; do { v5 = _mm_loadu_si128((const __m128i *)(a1 + v4)); v6 = _mm_mul_epu32(v5, v5); v7 = _mm_srli_epi64(v5, 0x20u); *(__m128i *)(a2 + v4) = _mm_unpacklo_epi32( _mm_shuffle_epi32(v6, 8), _mm_shuffle_epi32(_mm_mul_epu32(v7, v7), 8)); v4 += 16LL; } while ( v4 != 16LL * ((unsigned int)result >> 2) ); v8 = result & 0xFFFFFFFC; if ( (result & 3) != 0 ) { v9 = 4LL * v8; *(_DWORD *)(a2 + v9) = *(_DWORD *)(a1 + v9) * *(_DWORD *)(a1 + v9); if ( (int)result > (int)(v8 + 1) ) { *(_DWORD *)(a2 + v9 + 4) = *(_DWORD *)(a1 + v9 + 4) * *(_DWORD *)(a1 + v9 + 4); if ( (int)result > (int)(v8 + 2) ) { result = (unsigned int)(*(_DWORD *)(a1 + v9 + 8) * *(_DWORD *)(a1 + v9 + 8)); *(_DWORD *)(a2 + v9 + 8) = result; } } } } else { result = 0LL; do { *(_DWORD *)(a2 + result) = *(_DWORD *)(a1 + result) * *(_DWORD *)(a1 + result); result += 4LL; } while ( 4LL * a3 != result ); } } return result; }
func0: ENDBR64 MOVSXD RAX,EDX TEST EAX,EAX JLE 0x001011b2 LEA EDX,[RAX + -0x1] CMP EDX,0x2 JBE 0x00101193 LEA RCX,[RDI + 0x4] MOV RDX,RSI SUB RDX,RCX CMP RDX,0x8 JA 0x001011b8 LAB_00101193: LEA RCX,[RAX*0x4] XOR EAX,EAX NOP dword ptr [RAX] LAB_001011a0: MOV EDX,dword ptr [RDI + RAX*0x1] IMUL EDX,EDX MOV dword ptr [RSI + RAX*0x1],EDX ADD RAX,0x4 CMP RCX,RAX JNZ 0x001011a0 LAB_001011b2: RET LAB_001011b8: MOV ECX,EAX XOR EDX,EDX SHR ECX,0x2 SHL RCX,0x4 NOP dword ptr [RAX + RAX*0x1] LAB_001011c8: MOVDQU XMM0,xmmword ptr [RDI + RDX*0x1] MOVDQA XMM1,XMM0 PMULUDQ XMM1,XMM0 PSRLQ XMM0,0x20 PMULUDQ XMM0,XMM0 PSHUFD XMM1,XMM1,0x8 PSHUFD XMM0,XMM0,0x8 PUNPCKLDQ XMM1,XMM0 MOVUPS xmmword ptr [RSI + RDX*0x1],XMM1 ADD RDX,0x10 CMP RDX,RCX JNZ 0x001011c8 MOV EDX,EAX AND EDX,0xfffffffc TEST AL,0x3 JZ 0x001011b2 MOV R9D,EDX MOV ECX,dword ptr [RDI + R9*0x4] LEA R8,[R9*0x4] IMUL ECX,ECX MOV dword ptr [RSI + R9*0x4],ECX LEA ECX,[RDX + 0x1] CMP EAX,ECX JLE 0x001011b2 MOV ECX,dword ptr [RDI + R8*0x1 + 0x4] ADD EDX,0x2 IMUL ECX,ECX MOV dword ptr [RSI + R8*0x1 + 0x4],ECX CMP EAX,EDX JLE 0x001011b2 MOV EAX,dword ptr [RDI + R8*0x1 + 0x8] IMUL EAX,EAX MOV dword ptr [RSI + R8*0x1 + 0x8],EAX RET
void func0(long param_1,long param_2,uint param_3) { int8 *puVar1; int auVar2 [16]; int iVar3; long lVar4; uint uVar5; ulong uVar6; if (0 < (int)param_3) { if ((param_3 - 1 < 3) || ((ulong)(param_2 - (param_1 + 4)) < 9)) { lVar4 = 0; do { *(int *)(param_2 + lVar4) = *(int *)(param_1 + lVar4) * *(int *)(param_1 + lVar4); lVar4 = lVar4 + 4; } while ((long)(int)param_3 * 4 - lVar4 != 0); } else { lVar4 = 0; do { auVar2 = *(int (*) [16])(param_1 + lVar4); uVar6 = auVar2._8_8_ >> 0x20; puVar1 = (int8 *)(param_2 + lVar4); *puVar1 = CONCAT44(auVar2._4_4_ * auVar2._4_4_,auVar2._0_4_ * auVar2._0_4_); *(int *)(puVar1 + 2) = (int)((auVar2._8_8_ & 0xffffffff) * (ulong)auVar2._8_4_); *(int *)((long)puVar1 + 0x14) = (int)(uVar6 * uVar6); lVar4 = lVar4 + 0x10; } while (lVar4 != (ulong)(param_3 >> 2) << 4); uVar5 = param_3 & 0xfffffffc; if (((long)(int)param_3 & 3U) != 0) { uVar6 = (ulong)uVar5; iVar3 = *(int *)(param_1 + uVar6 * 4); lVar4 = uVar6 * 4; *(int *)(param_2 + uVar6 * 4) = iVar3 * iVar3; if (((int)(uVar5 + 1) < (int)param_3) && (iVar3 = *(int *)(param_1 + 4 + lVar4), *(int *)(param_2 + 4 + lVar4) = iVar3 * iVar3, (int)(uVar5 + 2) < (int)param_3)) { iVar3 = *(int *)(param_1 + 8 + lVar4); *(int *)(param_2 + 8 + lVar4) = iVar3 * iVar3; return; } } } } return; }
3,928
func0
#include <stdio.h> #include <string.h> #include <assert.h>
int func0(const char* str) { int n = strlen(str); char tmp[2 * n + 1]; strcpy(tmp, str); strcat(tmp, str); for (int i = 1; i <= n; i++) { int equal = 1; for (int j = 0; j < n; j++) { if (str[j] != tmp[i + j]) { equal = 0; break; } } if (equal) { return i; } } return n; }
int main() { assert(func0("aaaa") == 1); assert(func0("ab") == 2); assert(func0("abc") == 3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %r15 push %r14 push %r13 push %r12 push %rbx sub $0x48,%rsp mov %rdi,-0x68(%rbp) mov %fs:0x28,%rax mov %rax,-0x38(%rbp) xor %eax,%eax mov %rsp,%rax mov %rax,%rbx mov -0x68(%rbp),%rax mov %rax,%rdi callq 10a0 <strlen@plt> mov %eax,-0x4c(%rbp) mov -0x4c(%rbp),%eax add %eax,%eax add $0x1,%eax movslq %eax,%rdx sub $0x1,%rdx mov %rdx,-0x48(%rbp) movslq %eax,%rdx mov %rdx,%r14 mov $0x0,%r15d movslq %eax,%rdx mov %rdx,%r12 mov $0x0,%r13d cltq mov $0x10,%edx sub $0x1,%rdx add %rdx,%rax mov $0x10,%esi mov $0x0,%edx div %rsi imul $0x10,%rax,%rax mov %rax,%rdx and $0xfffffffffffff000,%rdx mov %rsp,%rcx sub %rdx,%rcx mov %rcx,%rdx cmp %rdx,%rsp je 127a <func0+0xb1> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 1263 <func0+0x9a> mov %rax,%rdx and $0xfff,%edx sub %rdx,%rsp mov %rax,%rdx and $0xfff,%edx test %rdx,%rdx je 12a4 <func0+0xdb> and $0xfff,%eax sub $0x8,%rax add %rsp,%rax orq $0x0,(%rax) mov %rsp,%rax add $0x0,%rax mov %rax,-0x40(%rbp) mov -0x68(%rbp),%rdx mov -0x40(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1090 <strcpy@plt> mov -0x68(%rbp),%rdx mov -0x40(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 10d0 <strcat@plt> movl $0x1,-0x50(%rbp) jmp 1338 <func0+0x16f> movl $0x1,-0x54(%rbp) movl $0x0,-0x58(%rbp) jmp 1321 <func0+0x158> mov -0x58(%rbp),%eax movslq %eax,%rdx mov -0x68(%rbp),%rax add %rdx,%rax movzbl (%rax),%ecx mov -0x50(%rbp),%edx mov -0x58(%rbp),%eax add %edx,%eax mov -0x40(%rbp),%rdx cltq movzbl (%rdx,%rax,1),%eax cmp %al,%cl je 131d <func0+0x154> movl $0x0,-0x54(%rbp) jmp 1329 <func0+0x160> addl $0x1,-0x58(%rbp) mov -0x58(%rbp),%eax cmp -0x4c(%rbp),%eax jl 12ee <func0+0x125> cmpl $0x0,-0x54(%rbp) je 1334 <func0+0x16b> mov -0x50(%rbp),%eax jmp 1343 <func0+0x17a> addl $0x1,-0x50(%rbp) mov -0x50(%rbp),%eax cmp -0x4c(%rbp),%eax jle 12de <func0+0x115> mov -0x4c(%rbp),%eax mov %rbx,%rsp mov -0x38(%rbp),%rsi xor %fs:0x28,%rsi je 135a <func0+0x191> callq 10b0 <__stack_chk_fail@plt> lea -0x28(%rbp),%rsp pop %rbx pop %r12 pop %r13 pop %r14 pop %r15 pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 48h mov [rbp+s], rdi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, rsp mov rbx, rax mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_2C], eax mov eax, [rbp+var_2C] add eax, eax add eax, 1 movsxd rdx, eax sub rdx, 1 mov [rbp+var_28], rdx cdqe mov edx, 10h sub rdx, 1 add rax, rdx mov esi, 10h mov edx, 0 div rsi imul rax, 10h mov rcx, rax and rcx, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rcx loc_1240: cmp rsp, rdx jz short loc_1257 sub rsp, 1000h or [rsp+1050h+var_58], 0 jmp short loc_1240 loc_1257: mov rdx, rax and edx, 0FFFh sub rsp, rdx mov rdx, rax and edx, 0FFFh test rdx, rdx jz short loc_1281 and eax, 0FFFh sub rax, 8 add rax, rsp or qword ptr [rax], 0 loc_1281: mov rax, rsp add rax, 0 mov [rbp+dest], rax mov rdx, [rbp+s] mov rax, [rbp+dest] mov rsi, rdx; src mov rdi, rax; dest call _strcpy mov rdx, [rbp+s] mov rax, [rbp+dest] mov rsi, rdx; src mov rdi, rax; dest call _strcat mov [rbp+var_38], 1 jmp short loc_1315 loc_12BB: mov [rbp+var_34], 1 mov [rbp+var_30], 0 jmp short loc_12FE loc_12CB: mov eax, [rbp+var_30] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx ecx, byte ptr [rax] mov edx, [rbp+var_38] mov eax, [rbp+var_30] add eax, edx mov rdx, [rbp+dest] cdqe movzx eax, byte ptr [rdx+rax] cmp cl, al jz short loc_12FA mov [rbp+var_34], 0 jmp short loc_1306 loc_12FA: add [rbp+var_30], 1 loc_12FE: mov eax, [rbp+var_30] cmp eax, [rbp+var_2C] jl short loc_12CB loc_1306: cmp [rbp+var_34], 0 jz short loc_1311 mov eax, [rbp+var_38] jmp short loc_1320 loc_1311: add [rbp+var_38], 1 loc_1315: mov eax, [rbp+var_38] cmp eax, [rbp+var_2C] jle short loc_12BB mov eax, [rbp+var_2C] loc_1320: mov rsp, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1337 call ___stack_chk_fail loc_1337: mov rbx, [rbp+var_8] leave retn
long long func0(char *a1) { int v1; // eax unsigned long long v2; // rax void *v3; // rsp char v5[8]; // [rsp+8h] [rbp-50h] BYREF char *s; // [rsp+10h] [rbp-48h] int i; // [rsp+20h] [rbp-38h] int v8; // [rsp+24h] [rbp-34h] int j; // [rsp+28h] [rbp-30h] int v10; // [rsp+2Ch] [rbp-2Ch] long long v11; // [rsp+30h] [rbp-28h] char *dest; // [rsp+38h] [rbp-20h] unsigned long long v13; // [rsp+40h] [rbp-18h] s = a1; v13 = __readfsqword(0x28u); v10 = strlen(a1); v1 = 2 * v10 + 1; v11 = v1 - 1LL; v2 = 16 * ((v1 + 15LL) / 0x10uLL); while ( v5 != &v5[-(v2 & 0xFFFFFFFFFFFFF000LL)] ) ; v3 = alloca(v2 & 0xFFF); if ( (v2 & 0xFFF) != 0 ) *(_QWORD *)&v5[(v2 & 0xFFF) - 8] = *(_QWORD *)&v5[(v2 & 0xFFF) - 8]; dest = v5; strcpy(v5, s); strcat(dest, s); for ( i = 1; i <= v10; ++i ) { v8 = 1; for ( j = 0; j < v10; ++j ) { if ( s[j] != dest[i + j] ) { v8 = 0; break; } } if ( v8 ) return (unsigned int)i; } return (unsigned int)v10; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x48 MOV qword ptr [RBP + -0x48],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,RSP MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x001010a0 MOV dword ptr [RBP + -0x2c],EAX MOV EAX,dword ptr [RBP + -0x2c] ADD EAX,EAX ADD EAX,0x1 MOVSXD RDX,EAX SUB RDX,0x1 MOV qword ptr [RBP + -0x28],RDX CDQE MOV EDX,0x10 SUB RDX,0x1 ADD RAX,RDX MOV ESI,0x10 MOV EDX,0x0 DIV RSI IMUL RAX,RAX,0x10 MOV RCX,RAX AND RCX,-0x1000 MOV RDX,RSP SUB RDX,RCX LAB_00101240: CMP RSP,RDX JZ 0x00101257 SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x00101240 LAB_00101257: MOV RDX,RAX AND EDX,0xfff SUB RSP,RDX MOV RDX,RAX AND EDX,0xfff TEST RDX,RDX JZ 0x00101281 AND EAX,0xfff SUB RAX,0x8 ADD RAX,RSP OR qword ptr [RAX],0x0 LAB_00101281: MOV RAX,RSP ADD RAX,0x0 MOV qword ptr [RBP + -0x20],RAX MOV RDX,qword ptr [RBP + -0x48] MOV RAX,qword ptr [RBP + -0x20] MOV RSI,RDX MOV RDI,RAX CALL 0x00101090 MOV RDX,qword ptr [RBP + -0x48] MOV RAX,qword ptr [RBP + -0x20] MOV RSI,RDX MOV RDI,RAX CALL 0x001010d0 MOV dword ptr [RBP + -0x38],0x1 JMP 0x00101315 LAB_001012bb: MOV dword ptr [RBP + -0x34],0x1 MOV dword ptr [RBP + -0x30],0x0 JMP 0x001012fe LAB_001012cb: MOV EAX,dword ptr [RBP + -0x30] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x48] ADD RAX,RDX MOVZX ECX,byte ptr [RAX] MOV EDX,dword ptr [RBP + -0x38] MOV EAX,dword ptr [RBP + -0x30] ADD EAX,EDX MOV RDX,qword ptr [RBP + -0x20] CDQE MOVZX EAX,byte ptr [RDX + RAX*0x1] CMP CL,AL JZ 0x001012fa MOV dword ptr [RBP + -0x34],0x0 JMP 0x00101306 LAB_001012fa: ADD dword ptr [RBP + -0x30],0x1 LAB_001012fe: MOV EAX,dword ptr [RBP + -0x30] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001012cb LAB_00101306: CMP dword ptr [RBP + -0x34],0x0 JZ 0x00101311 MOV EAX,dword ptr [RBP + -0x38] JMP 0x00101320 LAB_00101311: ADD dword ptr [RBP + -0x38],0x1 LAB_00101315: MOV EAX,dword ptr [RBP + -0x38] CMP EAX,dword ptr [RBP + -0x2c] JLE 0x001012bb MOV EAX,dword ptr [RBP + -0x2c] LAB_00101320: MOV RSP,RBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x00101337 CALL 0x001010b0 LAB_00101337: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int func0(char *param_1) { long lVar1; char *pcVar2; char *__dest; int iVar3; size_t sVar4; ulong uVar5; int *puVar6; long in_FS_OFFSET; int auStack_58 [8]; char *local_50; int local_40; int local_3c; int local_38; int local_34; long local_30; char *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_50 = param_1; sVar4 = strlen(param_1); local_34 = (int)sVar4; iVar3 = (int)sVar4 * 2 + 1; local_30 = (long)iVar3 + -1; uVar5 = (((long)iVar3 + 0xfU) / 0x10) * 0x10; for (puVar6 = auStack_58; puVar6 != auStack_58 + -(uVar5 & 0xfffffffffffff000); puVar6 = puVar6 + -0x1000) { *(int8 *)(puVar6 + -8) = *(int8 *)(puVar6 + -8); } lVar1 = -(ulong)((uint)uVar5 & 0xfff); if ((uVar5 & 0xfff) != 0) { *(int8 *)(puVar6 + ((ulong)((uint)uVar5 & 0xfff) - 8) + lVar1) = *(int8 *)(puVar6 + ((ulong)((uint)uVar5 & 0xfff) - 8) + lVar1); } pcVar2 = local_50; local_28 = puVar6 + lVar1; *(int8 *)(puVar6 + lVar1 + -8) = 0x10129f; strcpy(puVar6 + lVar1,pcVar2); __dest = local_28; pcVar2 = local_50; *(int8 *)(puVar6 + lVar1 + -8) = 0x1012b2; strcat(__dest,pcVar2); for (local_40 = 1; iVar3 = local_34, local_40 <= local_34; local_40 = local_40 + 1) { local_3c = 1; for (local_38 = 0; local_38 < local_34; local_38 = local_38 + 1) { if (local_50[local_38] != local_28[local_38 + local_40]) { local_3c = 0; break; } } iVar3 = local_40; if (local_3c != 0) break; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar3; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,929
func0
#include <stdio.h> #include <string.h> #include <assert.h>
int func0(const char* str) { int n = strlen(str); char tmp[2 * n + 1]; strcpy(tmp, str); strcat(tmp, str); for (int i = 1; i <= n; i++) { int equal = 1; for (int j = 0; j < n; j++) { if (str[j] != tmp[i + j]) { equal = 0; break; } } if (equal) { return i; } } return n; }
int main() { assert(func0("aaaa") == 1); assert(func0("ab") == 2); assert(func0("abc") == 3); return 0; }
O1
c
func0: endbr64 push %rbp mov %rsp,%rbp push %r14 push %r13 push %r12 push %rbx sub $0x10,%rsp mov %rdi,%rbx mov %fs:0x28,%rax mov %rax,-0x28(%rbp) xor %eax,%eax mov $0xffffffffffffffff,%rcx repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax lea -0x1(%rax),%r12 mov %r12d,%r13d lea 0x1(%r12,%r12,1),%eax cltq add $0xf,%rax mov %rax,%rdx and $0xfffffffffffffff0,%rdx and $0xfffffffffffff000,%rax mov %rsp,%rdi sub %rax,%rdi mov %rdi,%rax cmp %rax,%rsp je 121c <func0+0x73> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 1205 <func0+0x5c> mov %rdx,%rax and $0xfff,%eax sub %rax,%rsp test %rax,%rax je 1232 <func0+0x89> orq $0x0,-0x8(%rsp,%rax,1) mov %rsp,%r14 mov %rbx,%rsi mov %rsp,%rdi callq 1080 <strcpy@plt> mov %rbx,%rsi mov %rsp,%rdi callq 10b0 <strcat@plt> lea 0x1(%r14),%rcx mov $0x1,%edi lea -0x1(%r12),%esi mov $0x0,%r8d test %r12d,%r12d jg 12a8 <func0+0xff> mov %r12d,%edi jmp 127e <func0+0xd5> mov %rdx,%rax movzbl (%rcx,%rax,1),%edx cmp %dl,(%rbx,%rax,1) jne 129c <func0+0xf3> lea 0x1(%rax),%rdx cmp %rsi,%rax jne 1269 <func0+0xc0> mov -0x28(%rbp),%rax xor %fs:0x28,%rax jne 12b2 <func0+0x109> mov %edi,%eax lea -0x20(%rbp),%rsp pop %rbx pop %r12 pop %r13 pop %r14 pop %rbp retq add $0x1,%edi add $0x1,%rcx cmp %edi,%r13d jl 12ad <func0+0x104> mov %r8,%rax jmp 126c <func0+0xc3> mov %r12d,%edi jmp 127e <func0+0xd5> callq 1090 <__stack_chk_fail@plt>
func0: endbr64 push rbp mov rbp, rsp push r14 push r13 push r12 push rbx sub rsp, 10h mov rbx, rdi mov rax, fs:28h mov [rbp+var_28], rax xor eax, eax call _strlen mov r13, rax mov r12d, eax lea eax, [rax+rax+1] cdqe add rax, 0Fh mov rcx, rax and rcx, 0FFFFFFFFFFFFFFF0h and rax, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rax loc_1216: cmp rsp, rdx jz short loc_122D sub rsp, 1000h or [rsp+1030h+var_38], 0 jmp short loc_1216 loc_122D: mov rax, rcx and eax, 0FFFh sub rsp, rax test rax, rax jz short loc_1243 or [rsp+rax+30h+var_38], 0 loc_1243: mov r14, rsp mov rsi, rbx mov rdi, rsp call _strcpy mov rsi, rbx mov rdi, rsp call _strcat lea rcx, [r14+1] mov edi, 1 lea esi, [r13-1] mov r8d, 0 test r13d, r13d jg short loc_12B8 mov edi, r13d jmp short loc_128E loc_1279: mov rax, rdx loc_127C: movzx edx, byte ptr [rcx+rax] cmp [rbx+rax], dl jnz short loc_12AC lea rdx, [rax+1] cmp rax, rsi jnz short loc_1279 loc_128E: mov rax, [rbp+var_28] sub rax, fs:28h jnz short loc_12C2 mov eax, edi lea rsp, [rbp-20h] pop rbx pop r12 pop r13 pop r14 pop rbp retn loc_12AC: add edi, 1 add rcx, 1 cmp r12d, edi jl short loc_12BD loc_12B8: mov rax, r8 jmp short loc_127C loc_12BD: mov edi, r13d jmp short loc_128E loc_12C2: call ___stack_chk_fail
long long func0(long long a1) { int v2; // r13d signed long long v3; // rax void *v4; // rsp _BYTE *v5; // rcx int v6; // edi long long i; // rax long long v9; // [rsp+0h] [rbp-38h] char v10; // [rsp+8h] [rbp-30h] BYREF _BYTE v11[47]; // [rsp+9h] [rbp-2Fh] BYREF *(_QWORD *)&v11[7] = __readfsqword(0x28u); v2 = strlen(); while ( &v10 != &v11[-((2 * v2 + 1 + 15LL) & 0xFFFFFFFFFFFFF000LL) - 1] ) ; v3 = (2 * (_WORD)v2 + 16) & 0xFF0; v4 = alloca(v3); if ( ((2 * (_WORD)v2 + 16) & 0xFF0) != 0 ) *(long long *)((char *)&v9 + v3) = *(long long *)((char *)&v9 + v3); strcpy(&v10, a1); strcat(&v10, a1); v5 = v11; v6 = 1; if ( v2 > 0 ) { do { for ( i = 0LL; *(_BYTE *)(a1 + i) == v5[i]; ++i ) { if ( i == v2 - 1 ) return (unsigned int)v6; } ++v6; ++v5; } while ( v2 >= v6 ); return (unsigned int)v2; } else { return (unsigned int)v2; } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R14 PUSH R13 PUSH R12 PUSH RBX SUB RSP,0x10 MOV RBX,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x28],RAX XOR EAX,EAX CALL 0x001010a0 MOV R13,RAX MOV R12D,EAX LEA EAX,[RAX + RAX*0x1 + 0x1] CDQE ADD RAX,0xf MOV RCX,RAX AND RCX,-0x10 AND RAX,-0x1000 MOV RDX,RSP SUB RDX,RAX LAB_00101216: CMP RSP,RDX JZ 0x0010122d SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x00101216 LAB_0010122d: MOV RAX,RCX AND EAX,0xfff SUB RSP,RAX TEST RAX,RAX JZ 0x00101243 OR qword ptr [RSP + RAX*0x1 + -0x8],0x0 LAB_00101243: MOV R14,RSP MOV RSI,RBX MOV RDI,RSP CALL 0x00101090 MOV RSI,RBX MOV RDI,RSP CALL 0x001010d0 LEA RCX,[R14 + 0x1] MOV EDI,0x1 LEA ESI,[R13 + -0x1] MOV R8D,0x0 TEST R13D,R13D JG 0x001012b8 MOV EDI,R13D JMP 0x0010128e LAB_00101279: MOV RAX,RDX LAB_0010127c: MOVZX EDX,byte ptr [RCX + RAX*0x1] CMP byte ptr [RBX + RAX*0x1],DL JNZ 0x001012ac LEA RDX,[RAX + 0x1] CMP RAX,RSI JNZ 0x00101279 LAB_0010128e: MOV RAX,qword ptr [RBP + -0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x001012c2 MOV EAX,EDI LEA RSP,[RBP + -0x20] POP RBX POP R12 POP R13 POP R14 POP RBP RET LAB_001012ac: ADD EDI,0x1 ADD RCX,0x1 CMP R12D,EDI JL 0x001012bd LAB_001012b8: MOV RAX,R8 JMP 0x0010127c LAB_001012bd: MOV EDI,R13D JMP 0x0010128e LAB_001012c2: CALL 0x001010b0
ulong func0(char *param_1) { int iVar1; long lVar2; size_t sVar3; ulong uVar4; ulong uVar5; int1 *puVar6; int1 *puVar7; uint uVar8; long in_FS_OFFSET; bool bVar9; int1 auStack_38 [8]; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); sVar3 = strlen(param_1); iVar1 = (int)sVar3; uVar4 = (long)(iVar1 * 2 + 1) + 0xf; for (puVar7 = auStack_38; puVar7 != auStack_38 + -(uVar4 & 0xfffffffffffff000); puVar7 = puVar7 + -0x1000) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } uVar4 = (ulong)((uint)uVar4 & 0xff0); lVar2 = -uVar4; puVar6 = puVar7 + lVar2; if (uVar4 != 0) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } *(int8 *)(puVar7 + lVar2 + -8) = 0x101251; strcpy(puVar7 + lVar2,param_1); *(int8 *)(puVar7 + lVar2 + -8) = 0x10125c; strcat(puVar7 + lVar2,param_1); uVar4 = 1; if (iVar1 < 1) { uVar4 = sVar3 & 0xffffffff; } else { do { puVar6 = puVar6 + 1; uVar5 = 0; while (param_1[uVar5] == puVar6[uVar5]) { bVar9 = uVar5 == iVar1 - 1; uVar5 = uVar5 + 1; if (bVar9) goto LAB_0010128e; } uVar8 = (int)uVar4 + 1; uVar4 = (ulong)uVar8; } while ((int)uVar8 <= iVar1); uVar4 = sVar3 & 0xffffffff; } LAB_0010128e: if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ *(code **)(puVar7 + lVar2 + -8) = main; __stack_chk_fail(); } return uVar4; }
3,930
func0
#include <stdio.h> #include <string.h> #include <assert.h>
int func0(const char* str) { int n = strlen(str); char tmp[2 * n + 1]; strcpy(tmp, str); strcat(tmp, str); for (int i = 1; i <= n; i++) { int equal = 1; for (int j = 0; j < n; j++) { if (str[j] != tmp[i + j]) { equal = 0; break; } } if (equal) { return i; } } return n; }
int main() { assert(func0("aaaa") == 1); assert(func0("ab") == 2); assert(func0("abc") == 3); return 0; }
O2
c
func0: endbr64 push %rbp mov %rsp,%rbp push %r13 push %r12 push %rbx mov %rdi,%rbx sub $0x18,%rsp mov %fs:0x28,%rax mov %rax,-0x28(%rbp) xor %eax,%eax callq 1080 <strlen@plt> mov %rsp,%rsi mov %rax,%r13 mov %eax,%r12d lea 0x1(%rax,%rax,1),%eax cltq add $0xf,%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rsi and $0xfffffffffffffff0,%rdx mov %rsi,%rax cmp %rax,%rsp je 12b8 <func0+0x68> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 12a3 <func0+0x53> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 134d <func0+0xfd> mov %r13,%rdx mov %rbx,%rsi mov %rsp,%rdi callq 10b0 <memcpy@plt> mov %rbx,%rsi lea (%rsp,%r13,1),%rdi lea 0x1(%r13),%rdx callq 10b0 <memcpy@plt> lea 0x1(%rsp),%rcx mov $0x1,%r8d lea -0x1(%r13),%esi test %r13d,%r13d jle 132b <func0+0xdb> nopl 0x0(%rax) xor %eax,%eax jmp 1314 <func0+0xc4> nopl 0x0(%rax) lea 0x1(%rax),%rdx cmp %rsi,%rax je 1330 <func0+0xe0> mov %rdx,%rax movzbl (%rcx,%rax,1),%edi cmp %dil,(%rbx,%rax,1) je 1308 <func0+0xb8> add $0x1,%r8d add $0x1,%rcx cmp %r8d,%r12d jge 1300 <func0+0xb0> mov %r13d,%r8d xchg %ax,%ax mov -0x28(%rbp),%rax xor %fs:0x28,%rax jne 1358 <func0+0x108> lea -0x18(%rbp),%rsp mov %r8d,%eax pop %rbx pop %r12 pop %r13 pop %rbp retq orq $0x0,-0x8(%rsp,%rdx,1) jmpq 12ca <func0+0x7a> callq 1090 <__stack_chk_fail@plt> nopl (%rax)
func0: endbr64 push rbp mov rbp, rsp push r13 push r12 push rbx mov rbx, rdi sub rsp, 18h mov rax, fs:28h mov [rbp+var_28], rax xor eax, eax call _strlen mov rcx, rsp mov r13, rax mov r12d, eax lea eax, [rax+rax+1] cdqe add rax, 0Fh mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_12B5 loc_12A0: sub rsp, 1000h or [rsp+1030h+var_38], 0 cmp rsp, rcx jnz short loc_12A0 loc_12B5: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz loc_134D loc_12C7: mov rdx, r13 mov rsi, rbx mov rdi, rsp call _memcpy mov rsi, rbx lea rdi, [rsp+r13+1030h+var_1030] lea rdx, [r13+1] call _memcpy lea rcx, [rsp+1030h+var_102F] mov r8d, 1 lea esi, [r13-1] test r13d, r13d jle short loc_132B nop dword ptr [rax+00000000h] loc_1300: xor eax, eax jmp short loc_1314 loc_1308: lea rdx, [rax+1] cmp rax, rsi jz short loc_1330 mov rax, rdx loc_1314: movzx edi, byte ptr [rcx+rax] cmp [rbx+rax], dil jz short loc_1308 add r8d, 1 add rcx, 1 cmp r12d, r8d jge short loc_1300 loc_132B: mov r8d, r13d xchg ax, ax loc_1330: mov rax, [rbp+var_28] sub rax, fs:28h jnz short loc_1358 lea rsp, [rbp-18h] mov eax, r8d pop rbx pop r12 pop r13 pop rbp retn loc_134D: or [rsp+rdx+1030h+var_1038], 0 jmp loc_12C7 loc_1358: call ___stack_chk_fail
long long func0(long long a1) { long long v1; // r13 char *v2; // rcx signed long long v3; // rdx void *v4; // rsp char *v5; // rcx int v6; // r8d long long i; // rax long long v9; // [rsp+0h] [rbp-1038h] char v10; // [rsp+8h] [rbp-1030h] BYREF char v11; // [rsp+9h] [rbp-102Fh] BYREF _QWORD v12[6]; // [rsp+1008h] [rbp-30h] BYREF v12[1] = __readfsqword(0x28u); v1 = strlen(); v2 = (char *)v12 - ((2 * (int)v1 + 1 + 15LL) & 0xFFFFFFFFFFFFF000LL); if ( v12 != (_QWORD *)v2 ) { while ( &v10 != v2 ) ; } v3 = (2 * (_WORD)v1 + 16) & 0xFF0; v4 = alloca(v3); if ( ((2 * (_WORD)v1 + 16) & 0xFF0) != 0 ) *(long long *)((char *)&v9 + v3) = *(long long *)((char *)&v9 + v3); memcpy(&v10, a1, v1); memcpy(&v10 + v1, a1, v1 + 1); v5 = &v11; v6 = 1; if ( (int)v1 > 0 ) { do { for ( i = 0LL; *(_BYTE *)(a1 + i) == v5[i]; ++i ) { if ( i == (_DWORD)v1 - 1 ) return (unsigned int)v6; } ++v6; ++v5; } while ( (int)v1 >= v6 ); } return (unsigned int)v1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R13 PUSH R12 PUSH RBX MOV RBX,RDI SUB RSP,0x18 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x28],RAX XOR EAX,EAX CALL 0x00101080 MOV RCX,RSP MOV R13,RAX MOV R12D,EAX LEA EAX,[RAX + RAX*0x1 + 0x1] CDQE ADD RAX,0xf MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x001012b5 LAB_001012a0: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x001012a0 LAB_001012b5: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x0010134d LAB_001012c7: MOV RDX,R13 MOV RSI,RBX MOV RDI,RSP CALL 0x001010b0 MOV RSI,RBX LEA RDI,[RSP + R13*0x1] LEA RDX,[R13 + 0x1] CALL 0x001010b0 LEA RCX,[RSP + 0x1] MOV R8D,0x1 LEA ESI,[R13 + -0x1] TEST R13D,R13D JLE 0x0010132b NOP dword ptr [RAX] LAB_00101300: XOR EAX,EAX JMP 0x00101314 LAB_00101308: LEA RDX,[RAX + 0x1] CMP RAX,RSI JZ 0x00101330 MOV RAX,RDX LAB_00101314: MOVZX EDI,byte ptr [RCX + RAX*0x1] CMP byte ptr [RBX + RAX*0x1],DIL JZ 0x00101308 ADD R8D,0x1 ADD RCX,0x1 CMP R12D,R8D JGE 0x00101300 LAB_0010132b: MOV R8D,R13D NOP LAB_00101330: MOV RAX,qword ptr [RBP + -0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101358 LEA RSP,[RBP + -0x18] MOV EAX,R8D POP RBX POP R12 POP R13 POP RBP RET LAB_0010134d: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x001012c7 LAB_00101358: CALL 0x00101090
ulong func0(char *param_1) { int iVar1; long lVar2; size_t __n; ulong uVar3; ulong uVar4; int1 *puVar5; int1 *puVar6; uint uVar8; long in_FS_OFFSET; bool bVar9; int1 auStack_38 [8]; long local_30; int1 *puVar7; puVar6 = auStack_38; local_30 = *(long *)(in_FS_OFFSET + 0x28); __n = strlen(param_1); iVar1 = (int)__n; uVar3 = (long)(iVar1 * 2 + 1) + 0xf; puVar7 = auStack_38; puVar5 = auStack_38; while (puVar7 != auStack_38 + -(uVar3 & 0xfffffffffffff000)) { puVar6 = puVar5 + -0x1000; *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); puVar7 = puVar5 + -0x1000; puVar5 = puVar5 + -0x1000; } uVar3 = (ulong)((uint)uVar3 & 0xff0); lVar2 = -uVar3; puVar5 = puVar6 + lVar2; if (uVar3 != 0) { *(int8 *)(puVar6 + -8) = *(int8 *)(puVar6 + -8); } *(int8 *)(puVar6 + lVar2 + -8) = 0x1012d5; memcpy(puVar6 + lVar2,param_1,__n); *(int8 *)(puVar6 + lVar2 + -8) = 0x1012e5; memcpy(puVar6 + __n + lVar2,param_1,__n + 1); uVar3 = 1; if (0 < iVar1) { do { puVar5 = puVar5 + 1; uVar4 = 0; while (param_1[uVar4] == puVar5[uVar4]) { bVar9 = uVar4 == iVar1 - 1; uVar4 = uVar4 + 1; if (bVar9) goto LAB_00101330; } uVar8 = (int)uVar3 + 1; uVar3 = (ulong)uVar8; } while ((int)uVar8 <= iVar1); } uVar3 = __n & 0xffffffff; LAB_00101330: if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar3; } /* WARNING: Subroutine does not return */ *(int8 *)(puVar6 + lVar2 + -8) = 0x10135d; __stack_chk_fail(); }
3,931
func0
#include <stdio.h> #include <string.h> #include <assert.h>
int func0(const char* str) { int n = strlen(str); char tmp[2 * n + 1]; strcpy(tmp, str); strcat(tmp, str); for (int i = 1; i <= n; i++) { int equal = 1; for (int j = 0; j < n; j++) { if (str[j] != tmp[i + j]) { equal = 0; break; } } if (equal) { return i; } } return n; }
int main() { assert(func0("aaaa") == 1); assert(func0("ab") == 2); assert(func0("abc") == 3); return 0; }
O3
c
func0: endbr64 push %rbp mov %rsp,%rbp push %r13 push %r12 push %rbx mov %rdi,%rbx sub $0x18,%rsp mov %fs:0x28,%rax mov %rax,-0x28(%rbp) xor %eax,%eax callq 1080 <strlen@plt> mov %rsp,%rsi mov %rax,%r13 mov %eax,%r12d lea 0x1(%rax,%rax,1),%eax cltq add $0xf,%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rsi and $0xfffffffffffffff0,%rdx mov %rsi,%rax cmp %rax,%rsp je 12b8 <func0+0x68> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 12a3 <func0+0x53> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 134d <func0+0xfd> mov %r13,%rdx mov %rbx,%rsi mov %rsp,%rdi callq 10b0 <memcpy@plt> mov %rbx,%rsi lea (%rsp,%r13,1),%rdi lea 0x1(%r13),%rdx callq 10b0 <memcpy@plt> lea 0x1(%rsp),%rcx mov $0x1,%r8d lea -0x1(%r13),%esi test %r13d,%r13d jle 132b <func0+0xdb> nopl 0x0(%rax) xor %eax,%eax jmp 1314 <func0+0xc4> nopl 0x0(%rax) lea 0x1(%rax),%rdx cmp %rax,%rsi je 1330 <func0+0xe0> mov %rdx,%rax movzbl (%rcx,%rax,1),%edi cmp %dil,(%rbx,%rax,1) je 1308 <func0+0xb8> add $0x1,%r8d add $0x1,%rcx cmp %r8d,%r12d jge 1300 <func0+0xb0> mov %r13d,%r8d xchg %ax,%ax mov -0x28(%rbp),%rax xor %fs:0x28,%rax jne 1358 <func0+0x108> lea -0x18(%rbp),%rsp mov %r8d,%eax pop %rbx pop %r12 pop %r13 pop %rbp retq orq $0x0,-0x8(%rsp,%rdx,1) jmpq 12ca <func0+0x7a> callq 1090 <__stack_chk_fail@plt> nopl (%rax)
func0: endbr64 push rbp mov rbp, rsp push r14 push r13 push r12 push rbx mov rbx, rdi sub rsp, 10h mov rax, fs:28h mov [rbp+var_28], rax xor eax, eax call _strlen mov rcx, rsp lea r14d, [rax+rax+1] mov r13, rax mov r12d, eax movsxd r14, r14d lea rax, [r14+0Fh] mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_12B9 loc_12A4: sub rsp, 1000h or [rsp+1030h+var_38], 0 cmp rsp, rcx jnz short loc_12A4 loc_12B9: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz loc_1356 loc_12CB: mov rcx, r14 mov rdx, r13 mov rsi, rbx mov rdi, rsp call ___memcpy_chk mov rcx, r14 lea rdx, [r13+1] lea rdi, [rsp+r13+1030h+var_1030] sub rcx, r13 mov rsi, rbx call ___memcpy_chk test r13d, r13d jle short loc_1331 lea rcx, [rsp+1030h+var_102F] mov edi, 1 lea esi, [r13-1] nop dword ptr [rax] loc_1308: xor eax, eax jmp short loc_131C loc_1310: lea rdx, [rax+1] cmp rax, rsi jz short loc_1338 mov rax, rdx loc_131C: movzx edx, byte ptr [rcx+rax] cmp [rbx+rax], dl jz short loc_1310 add edi, 1 add rcx, 1 cmp r12d, edi jge short loc_1308 loc_1331: mov edi, r13d nop dword ptr [rax+00h] loc_1338: mov rax, [rbp+var_28] sub rax, fs:28h jnz short loc_1361 lea rsp, [rbp-20h] mov eax, edi pop rbx pop r12 pop r13 pop r14 pop rbp retn loc_1356: or [rsp+rdx+1030h+var_1038], 0 jmp loc_12CB loc_1361: call ___stack_chk_fail
long long func0(const char *a1) { size_t v2; // r13 long long v3; // r14 char *v4; // rcx signed long long v5; // rdx void *v6; // rsp char *v7; // rcx int v8; // edi long long i; // rax long long v11; // [rsp+0h] [rbp-1038h] char v12; // [rsp+8h] [rbp-1030h] BYREF char v13; // [rsp+9h] [rbp-102Fh] BYREF _QWORD v14[6]; // [rsp+1008h] [rbp-30h] BYREF v14[1] = __readfsqword(0x28u); v2 = strlen(a1); v3 = 2 * (int)v2 + 1; v4 = (char *)v14 - ((v3 + 15) & 0xFFFFFFFFFFFFF000LL); if ( v14 != (_QWORD *)v4 ) { while ( &v12 != v4 ) ; } v5 = (2 * (_WORD)v2 + 16) & 0xFF0; v6 = alloca(v5); if ( ((2 * (_WORD)v2 + 16) & 0xFF0) != 0 ) *(long long *)((char *)&v11 + v5) = *(long long *)((char *)&v11 + v5); __memcpy_chk(&v12, a1, v2, v3); __memcpy_chk(&v12 + v2, a1, v2 + 1, v3 - v2); if ( (int)v2 > 0 ) { v7 = &v13; v8 = 1; do { for ( i = 0LL; a1[i] == v7[i]; ++i ) { if ( i == (_DWORD)v2 - 1 ) return (unsigned int)v8; } ++v8; ++v7; } while ( (int)v2 >= v8 ); } return (unsigned int)v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R14 PUSH R13 PUSH R12 PUSH RBX MOV RBX,RDI SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x28],RAX XOR EAX,EAX CALL 0x00101080 MOV RCX,RSP LEA R14D,[RAX + RAX*0x1 + 0x1] MOV R13,RAX MOV R12D,EAX MOVSXD R14,R14D LEA RAX,[R14 + 0xf] MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x001012b9 LAB_001012a4: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x001012a4 LAB_001012b9: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x00101356 LAB_001012cb: MOV RCX,R14 MOV RDX,R13 MOV RSI,RBX MOV RDI,RSP CALL 0x001010b0 MOV RCX,R14 LEA RDX,[R13 + 0x1] LEA RDI,[RSP + R13*0x1] SUB RCX,R13 MOV RSI,RBX CALL 0x001010b0 TEST R13D,R13D JLE 0x00101331 LEA RCX,[RSP + 0x1] MOV EDI,0x1 LEA ESI,[R13 + -0x1] NOP dword ptr [RAX] LAB_00101308: XOR EAX,EAX JMP 0x0010131c LAB_00101310: LEA RDX,[RAX + 0x1] CMP RAX,RSI JZ 0x00101338 MOV RAX,RDX LAB_0010131c: MOVZX EDX,byte ptr [RCX + RAX*0x1] CMP byte ptr [RBX + RAX*0x1],DL JZ 0x00101310 ADD EDI,0x1 ADD RCX,0x1 CMP R12D,EDI JGE 0x00101308 LAB_00101331: MOV EDI,R13D NOP dword ptr [RAX] LAB_00101338: MOV RAX,qword ptr [RBP + -0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101361 LEA RSP,[RBP + -0x20] MOV EAX,EDI POP RBX POP R12 POP R13 POP R14 POP RBP RET LAB_00101356: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x001012cb LAB_00101361: CALL 0x00101090
ulong func0(char *param_1) { int iVar1; long lVar2; size_t sVar3; ulong uVar4; int *puVar5; int *puVar6; uint uVar8; ulong uVar9; long lVar10; long in_FS_OFFSET; bool bVar11; int auStack_38 [8]; long local_30; int *puVar7; puVar6 = auStack_38; local_30 = *(long *)(in_FS_OFFSET + 0x28); sVar3 = strlen(param_1); iVar1 = (int)sVar3; lVar10 = (long)(iVar1 * 2 + 1); puVar7 = auStack_38; puVar5 = auStack_38; while (puVar7 != auStack_38 + -(lVar10 + 0xfU & 0xfffffffffffff000)) { puVar6 = puVar5 + -0x1000; *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); puVar7 = puVar5 + -0x1000; puVar5 = puVar5 + -0x1000; } uVar9 = (ulong)((uint)(lVar10 + 0xfU) & 0xff0); lVar2 = -uVar9; puVar5 = puVar6 + lVar2; if (uVar9 != 0) { *(int8 *)(puVar6 + -8) = *(int8 *)(puVar6 + -8); } *(int8 *)(puVar6 + lVar2 + -8) = 0x1012dc; __memcpy_chk((long)puVar6 + lVar2,param_1,sVar3,lVar10); *(int8 *)(puVar6 + lVar2 + -8) = 0x1012f2; __memcpy_chk(puVar6 + sVar3 + lVar2,param_1,sVar3 + 1,lVar10 - sVar3); if (0 < iVar1) { uVar9 = 1; do { puVar5 = puVar5 + 1; uVar4 = 0; while (param_1[uVar4] == puVar5[uVar4]) { bVar11 = uVar4 == iVar1 - 1; uVar4 = uVar4 + 1; if (bVar11) goto LAB_00101338; } uVar8 = (int)uVar9 + 1; uVar9 = (ulong)uVar8; } while ((int)uVar8 <= iVar1); } uVar9 = sVar3 & 0xffffffff; LAB_00101338: if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar9; } /* WARNING: Subroutine does not return */ *(int8 *)(puVar6 + lVar2 + -8) = 0x101366; __stack_chk_fail(); }
3,932
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int arr[], int size, int n, int result[]) { int i, j, temp; // First copy elements to result and perform an initial sort for (i = 0; i < n; i++) { result[i] = arr[i]; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (result[i] > result[j]) { temp = result[i]; result[i] = result[j]; result[j] = temp; } } } // Process remaining elements in the input for (i = n; i < size; i++) { if (arr[i] < result[n-1]) { result[n-1] = arr[i]; // Insertion into sorted part of result for (j = n - 1; j > 0 && result[j] < result[j-1]; j--) { temp = result[j]; result[j] = result[j-1]; result[j-1] = temp; } } } }
int main() { int arr1[] = {10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100}; int size1 = sizeof(arr1) / sizeof(arr1[0]); int result1[2], result2[5], result3[3]; func0(arr1, size1, 2, result1); func0(arr1, size1, 5, result2); func0(arr1, size1, 3, result3); assert(result1[0] == 10 && result1[1] == 20); assert(result2[0] == 10 && result2[1] == 20 && result2[2] == 20 && result2[3] == 40 && result2[4] == 50); assert(result3[0] == 10 && result3[1] == 20 && result3[2] == 20); printf("All tests passed!\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov %edx,-0x20(%rbp) mov %rcx,-0x28(%rbp) movl $0x0,-0xc(%rbp) jmp 11d9 <func0+0x50> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0xc(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x20(%rbp),%eax jl 11a8 <func0+0x1f> movl $0x0,-0xc(%rbp) jmpq 129e <func0+0x115> mov -0xc(%rbp),%eax add $0x1,%eax mov %eax,-0x8(%rbp) jmpq 128e <func0+0x105> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jle 128a <func0+0x101> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x4(%rbp) mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov -0xc(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rax,%rdx mov -0x4(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x8(%rbp) mov -0x8(%rbp),%eax cmp -0x20(%rbp),%eax jl 11fb <func0+0x72> addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x20(%rbp),%eax jl 11ed <func0+0x64> mov -0x20(%rbp),%eax mov %eax,-0xc(%rbp) jmpq 13c2 <func0+0x239> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x20(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jge 13be <func0+0x235> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0x20(%rbp),%edx movslq %edx,%rdx shl $0x2,%rdx lea -0x4(%rdx),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x20(%rbp),%eax sub $0x1,%eax mov %eax,-0x8(%rbp) jmp 1384 <func0+0x1fb> mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x4(%rbp) mov -0x8(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov -0x8(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x8(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rdx mov -0x28(%rbp),%rax add %rax,%rdx mov -0x4(%rbp),%eax mov %eax,(%rdx) subl $0x1,-0x8(%rbp) cmpl $0x0,-0x8(%rbp) jle 13be <func0+0x235> mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x8(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jl 1321 <func0+0x198> addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x1c(%rbp),%eax jl 12b5 <func0+0x12c> pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov [rbp+var_20], edx mov [rbp+var_28], rcx mov [rbp+var_C], 0 jmp short loc_11D9 loc_11A8: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rbp+var_C] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax add [rbp+var_C], 1 loc_11D9: mov eax, [rbp+var_C] cmp eax, [rbp+var_20] jl short loc_11A8 mov [rbp+var_C], 0 jmp loc_129E loc_11ED: mov eax, [rbp+var_C] add eax, 1 mov [rbp+var_8], eax jmp loc_128E loc_11FB: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_8] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jle short loc_128A mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] mov [rbp+var_4], eax mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rbp+var_C] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rdx, rax mov eax, [rbp+var_4] mov [rdx], eax loc_128A: add [rbp+var_8], 1 loc_128E: mov eax, [rbp+var_8] cmp eax, [rbp+var_20] jl loc_11FB add [rbp+var_C], 1 loc_129E: mov eax, [rbp+var_C] cmp eax, [rbp+var_20] jl loc_11ED mov eax, [rbp+var_20] mov [rbp+var_C], eax jmp loc_13C2 loc_12B5: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rax] mov eax, [rbp+var_20] cdqe shl rax, 2 lea rcx, [rax-4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jge loc_13BE mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rbp+var_20] movsxd rdx, edx shl rdx, 2 lea rcx, [rdx-4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_20] sub eax, 1 mov [rbp+var_8], eax jmp short loc_1384 loc_1321: mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] mov [rbp+var_4], eax mov eax, [rbp+var_8] cdqe shl rax, 2 lea rdx, [rax-4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rbp+var_8] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_8] cdqe shl rax, 2 lea rdx, [rax-4] mov rax, [rbp+var_28] add rdx, rax mov eax, [rbp+var_4] mov [rdx], eax sub [rbp+var_8], 1 loc_1384: cmp [rbp+var_8], 0 jle short loc_13BE mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_8] cdqe shl rax, 2 lea rcx, [rax-4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jl loc_1321 loc_13BE: add [rbp+var_C], 1 loc_13C2: mov eax, [rbp+var_C] cmp eax, [rbp+var_1C] jl loc_12B5 nop nop pop rbp retn
long long func0(long long a1, int a2, int a3, long long a4) { long long result; // rax int i; // [rsp+1Ch] [rbp-Ch] int j; // [rsp+1Ch] [rbp-Ch] unsigned int m; // [rsp+1Ch] [rbp-Ch] int k; // [rsp+20h] [rbp-8h] int n; // [rsp+20h] [rbp-8h] int v10; // [rsp+24h] [rbp-4h] int v11; // [rsp+24h] [rbp-4h] for ( i = 0; i < a3; ++i ) *(_DWORD *)(4LL * i + a4) = *(_DWORD *)(4LL * i + a1); for ( j = 0; j < a3; ++j ) { for ( k = j + 1; k < a3; ++k ) { if ( *(_DWORD *)(4LL * j + a4) > *(_DWORD *)(4LL * k + a4) ) { v10 = *(_DWORD *)(4LL * j + a4); *(_DWORD *)(4LL * j + a4) = *(_DWORD *)(4LL * k + a4); *(_DWORD *)(a4 + 4LL * k) = v10; } } } for ( m = a3; ; ++m ) { result = m; if ( (int)m >= a2 ) break; if ( *(_DWORD *)(4LL * (int)m + a1) < *(_DWORD *)(4LL * a3 - 4 + a4) ) { *(_DWORD *)(4LL * a3 - 4 + a4) = *(_DWORD *)(4LL * (int)m + a1); for ( n = a3 - 1; n > 0 && *(_DWORD *)(4LL * n + a4) < *(_DWORD *)(4LL * n - 4 + a4); --n ) { v11 = *(_DWORD *)(4LL * n + a4); *(_DWORD *)(4LL * n + a4) = *(_DWORD *)(4LL * n - 4 + a4); *(_DWORD *)(a4 + 4LL * n - 4) = v11; } } } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV dword ptr [RBP + -0x20],EDX MOV qword ptr [RBP + -0x28],RCX MOV dword ptr [RBP + -0xc],0x0 JMP 0x001011d9 LAB_001011a8: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX ADD dword ptr [RBP + -0xc],0x1 LAB_001011d9: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x20] JL 0x001011a8 MOV dword ptr [RBP + -0xc],0x0 JMP 0x0010129e LAB_001011ed: MOV EAX,dword ptr [RBP + -0xc] ADD EAX,0x1 MOV dword ptr [RBP + -0x8],EAX JMP 0x0010128e LAB_001011fb: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JLE 0x0010128a MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RDX],EAX LAB_0010128a: ADD dword ptr [RBP + -0x8],0x1 LAB_0010128e: MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x20] JL 0x001011fb ADD dword ptr [RBP + -0xc],0x1 LAB_0010129e: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x20] JL 0x001011ed MOV EAX,dword ptr [RBP + -0x20] MOV dword ptr [RBP + -0xc],EAX JMP 0x001013c2 LAB_001012b5: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x20] CDQE SHL RAX,0x2 LEA RCX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JGE 0x001013be MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX SHL RDX,0x2 LEA RCX,[RDX + -0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x20] SUB EAX,0x1 MOV dword ptr [RBP + -0x8],EAX JMP 0x00101384 LAB_00101321: MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x8] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x8] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x8] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RDX],EAX SUB dword ptr [RBP + -0x8],0x1 LAB_00101384: CMP dword ptr [RBP + -0x8],0x0 JLE 0x001013be MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x8] CDQE SHL RAX,0x2 LEA RCX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JL 0x00101321 LAB_001013be: ADD dword ptr [RBP + -0xc],0x1 LAB_001013c2: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x1c] JL 0x001012b5 NOP NOP POP RBP RET
void func0(long param_1,int param_2,int param_3,long param_4) { int4 uVar1; int iVar2; int local_14; int local_10; for (local_14 = 0; local_14 < param_3; local_14 = local_14 + 1) { *(int4 *)(param_4 + (long)local_14 * 4) = *(int4 *)(param_1 + (long)local_14 * 4); } for (local_14 = 0; iVar2 = param_3, local_10 = local_14, local_14 < param_3; local_14 = local_14 + 1) { while (local_10 = local_10 + 1, local_10 < param_3) { if (*(int *)(param_4 + (long)local_10 * 4) < *(int *)(param_4 + (long)local_14 * 4)) { uVar1 = *(int4 *)(param_4 + (long)local_14 * 4); *(int4 *)(param_4 + (long)local_14 * 4) = *(int4 *)(param_4 + (long)local_10 * 4); *(int4 *)((long)local_10 * 4 + param_4) = uVar1; } } } while (local_14 = iVar2, local_14 < param_2) { if (*(int *)(param_1 + (long)local_14 * 4) < *(int *)(param_4 + (long)param_3 * 4 + -4)) { *(int4 *)(param_4 + (long)param_3 * 4 + -4) = *(int4 *)(param_1 + (long)local_14 * 4); local_10 = param_3 + -1; while ((0 < local_10 && (*(int *)(param_4 + (long)local_10 * 4) < *(int *)(param_4 + (long)local_10 * 4 + -4))) ) { uVar1 = *(int4 *)(param_4 + (long)local_10 * 4); *(int4 *)(param_4 + (long)local_10 * 4) = *(int4 *)(param_4 + (long)local_10 * 4 + -4); *(int4 *)((long)local_10 * 4 + -4 + param_4) = uVar1; local_10 = local_10 + -1; } } iVar2 = local_14 + 1; } return; }
3,933
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int arr[], int size, int n, int result[]) { int i, j, temp; // First copy elements to result and perform an initial sort for (i = 0; i < n; i++) { result[i] = arr[i]; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (result[i] > result[j]) { temp = result[i]; result[i] = result[j]; result[j] = temp; } } } // Process remaining elements in the input for (i = n; i < size; i++) { if (arr[i] < result[n-1]) { result[n-1] = arr[i]; // Insertion into sorted part of result for (j = n - 1; j > 0 && result[j] < result[j-1]; j--) { temp = result[j]; result[j] = result[j-1]; result[j-1] = temp; } } } }
int main() { int arr1[] = {10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100}; int size1 = sizeof(arr1) / sizeof(arr1[0]); int result1[2], result2[5], result3[3]; func0(arr1, size1, 2, result1); func0(arr1, size1, 5, result2); func0(arr1, size1, 3, result3); assert(result1[0] == 10 && result1[1] == 20); assert(result2[0] == 10 && result2[1] == 20 && result2[2] == 20 && result2[3] == 40 && result2[4] == 50); assert(result3[0] == 10 && result3[1] == 20 && result3[2] == 20); printf("All tests passed!\n"); return 0; }
O1
c
func0: endbr64 push %rbx test %edx,%edx jle 11ed <func0+0x64> lea -0x1(%rdx),%r9d lea 0x1(%r9),%rbx mov $0x0,%eax mov (%rdi,%rax,4),%r8d mov %r8d,(%rcx,%rax,4) mov %rax,%r8 add $0x1,%rax cmp %r9,%r8 jne 119f <func0+0x16> mov %rcx,%r10 mov $0x1,%r11d jmp 11e3 <func0+0x5a> add $0x1,%rax cmp %eax,%edx jle 11db <func0+0x52> mov (%r10),%r8d mov (%rcx,%rax,4),%r9d cmp %r9d,%r8d jle 11be <func0+0x35> mov %r9d,(%r10) mov %r8d,(%rcx,%rax,4) jmp 11be <func0+0x35> add $0x1,%r11 add $0x4,%r10 cmp %rbx,%r11 je 11ed <func0+0x64> mov %r11,%rax jmp 11c6 <func0+0x3d> cmp %esi,%edx jge 1261 <func0+0xd8> movslq %edx,%rax lea 0x0(,%rax,4),%r11 lea -0x4(%rcx,%r11,1),%r9 lea (%rdi,%r11,1),%r8 sub $0x1,%esi sub %edx,%esi add %rsi,%rax lea 0x4(%rdi,%rax,4),%r10 lea -0x1(%rdx),%eax cltq lea (%rcx,%rax,4),%rbx lea -0x8(%rcx,%r11,1),%rdi lea -0x2(%rdx),%eax shl $0x2,%rax sub %rax,%rdi jmp 1235 <func0+0xac> add $0x4,%r8 cmp %r10,%r8 je 1261 <func0+0xd8> mov (%r8),%eax cmp (%r9),%eax jge 122c <func0+0xa3> mov %eax,(%r9) mov %rbx,%rax cmp $0x1,%edx jle 122c <func0+0xa3> mov (%rax),%esi mov -0x4(%rax),%ecx cmp %ecx,%esi jge 122c <func0+0xa3> mov %ecx,(%rax) mov %esi,-0x4(%rax) sub $0x4,%rax cmp %rdi,%rax jne 1248 <func0+0xbf> jmp 122c <func0+0xa3> pop %rbx retq
func0: endbr64 push r13 push r12 push rbp push rbx mov r11, rdi mov ebx, esi mov r9d, edx mov rbp, rcx test edx, edx jle short loc_120A lea r12d, [rdx-1] mov r10d, edx mov eax, 0 loc_11AE: mov edx, [r11+rax*4] mov [rbp+rax*4+0], edx add rax, 1 cmp rax, r10 jnz short loc_11AE lea rsi, [rbp+4] mov r8d, 1 lea r13, [rbp+8] jmp short loc_11F0 loc_11CF: add rax, 4 cmp rax, rdi jz short loc_11E8 loc_11D8: mov edx, [rsi-4] mov ecx, [rax] cmp edx, ecx jle short loc_11CF mov [rsi-4], ecx mov [rax], edx jmp short loc_11CF loc_11E8: add r8, 1 add rsi, 4 loc_11F0: cmp r8, r10 jz short loc_120A mov eax, r12d sub eax, r8d lea rax, [r8+rax-1] lea rdi, [r13+rax*4+0] mov rax, rsi jmp short loc_11D8 loc_120A: cmp r9d, ebx jge short loc_1283 movsxd rax, r9d lea rdx, ds:0[rax*4] lea r8, [rbp+rdx-4] lea rsi, [r11+rdx] sub ebx, 1 sub ebx, r9d add rax, rbx lea r10, [r11+rax*4+4] lea eax, [r9-1] cdqe lea r11, [rbp+rax*4+0] lea rdi, [rbp+rdx-8] lea eax, [r9-2] shl rax, 2 sub rdi, rax jmp short loc_1257 loc_124E: add rsi, 4 cmp rsi, r10 jz short loc_1283 loc_1257: mov eax, [rsi] cmp eax, [r8] jge short loc_124E mov [r8], eax mov rax, r11 cmp r9d, 1 jle short loc_124E loc_126A: mov ecx, [rax] mov edx, [rax-4] cmp ecx, edx jge short loc_124E mov [rax], edx mov [rax-4], ecx sub rax, 4 cmp rax, rdi jnz short loc_126A jmp short loc_124E loc_1283: pop rbx pop rbp pop r12 pop r13 retn
void func0(long long a1, int a2, int a3, long long a4) { int v8; // r12d long long v9; // r10 long long i; // rax _DWORD *v11; // rsi long long j; // r8 _DWORD *v13; // rax int v14; // edx long long v15; // rdx _DWORD *v16; // r8 _DWORD *v17; // rsi long long v18; // rdi int *v19; // rax int v20; // ecx int v21; // edx if ( a3 > 0 ) { v8 = a3 - 1; v9 = (unsigned int)a3; for ( i = 0LL; i != a3; ++i ) *(_DWORD *)(a4 + 4 * i) = *(_DWORD *)(a1 + 4 * i); v11 = (_DWORD *)(a4 + 4); for ( j = 1LL; j != v9; ++j ) { v13 = v11; do { v14 = *(v11 - 1); if ( v14 > *v13 ) { *(v11 - 1) = *v13; *v13 = v14; } ++v13; } while ( v13 != (_DWORD *)(a4 + 8 + 4 * (j + (unsigned int)(v8 - j) - 1)) ); ++v11; } } if ( a3 < a2 ) { v15 = 4LL * a3; v16 = (_DWORD *)(a4 + v15 - 4); v17 = (_DWORD *)(a1 + v15); v18 = a4 + v15 - 8 - 4LL * (unsigned int)(a3 - 2); do { if ( *v17 < *v16 ) { *v16 = *v17; v19 = (int *)(a4 + 4LL * (a3 - 1)); if ( a3 > 1 ) { do { v20 = *v19; v21 = *(v19 - 1); if ( *v19 >= v21 ) break; *v19 = v21; *--v19 = v20; } while ( v19 != (int *)v18 ); } } ++v17; } while ( v17 != (_DWORD *)(a1 + 4 * ((unsigned int)(a2 - 1 - a3) + (long long)a3) + 4) ); } }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R11,RDI MOV EBX,ESI MOV R9D,EDX MOV RBP,RCX TEST EDX,EDX JLE 0x0010120a LEA R12D,[RDX + -0x1] MOV R10D,EDX MOV EAX,0x0 LAB_001011ae: MOV EDX,dword ptr [R11 + RAX*0x4] MOV dword ptr [RBP + RAX*0x4],EDX ADD RAX,0x1 CMP RAX,R10 JNZ 0x001011ae LEA RSI,[RBP + 0x4] MOV R8D,0x1 LEA R13,[RBP + 0x8] JMP 0x001011f0 LAB_001011cf: ADD RAX,0x4 CMP RAX,RDI JZ 0x001011e8 LAB_001011d8: MOV EDX,dword ptr [RSI + -0x4] MOV ECX,dword ptr [RAX] CMP EDX,ECX JLE 0x001011cf MOV dword ptr [RSI + -0x4],ECX MOV dword ptr [RAX],EDX JMP 0x001011cf LAB_001011e8: ADD R8,0x1 ADD RSI,0x4 LAB_001011f0: CMP R8,R10 JZ 0x0010120a MOV EAX,R12D SUB EAX,R8D LEA RAX,[R8 + RAX*0x1 + -0x1] LEA RDI,[R13 + RAX*0x4] MOV RAX,RSI JMP 0x001011d8 LAB_0010120a: CMP R9D,EBX JGE 0x00101283 MOVSXD RAX,R9D LEA RDX,[RAX*0x4] LEA R8,[RBP + RDX*0x1 + -0x4] LEA RSI,[R11 + RDX*0x1] SUB EBX,0x1 SUB EBX,R9D ADD RAX,RBX LEA R10,[R11 + RAX*0x4 + 0x4] LEA EAX,[R9 + -0x1] CDQE LEA R11,[RBP + RAX*0x4] LEA RDI,[RBP + RDX*0x1 + -0x8] LEA EAX,[R9 + -0x2] SHL RAX,0x2 SUB RDI,RAX JMP 0x00101257 LAB_0010124e: ADD RSI,0x4 CMP RSI,R10 JZ 0x00101283 LAB_00101257: MOV EAX,dword ptr [RSI] CMP EAX,dword ptr [R8] JGE 0x0010124e MOV dword ptr [R8],EAX MOV RAX,R11 CMP R9D,0x1 JLE 0x0010124e LAB_0010126a: MOV ECX,dword ptr [RAX] MOV EDX,dword ptr [RAX + -0x4] CMP ECX,EDX JGE 0x0010124e MOV dword ptr [RAX],EDX MOV dword ptr [RAX + -0x4],ECX SUB RAX,0x4 CMP RAX,RDI JNZ 0x0010126a JMP 0x0010124e LAB_00101283: POP RBX POP RBP POP R12 POP R13 RET
void func0(long param_1,int param_2,uint param_3,long param_4) { long lVar1; int iVar2; ulong uVar3; int *piVar4; int *piVar5; int *piVar6; if (0 < (int)param_3) { uVar3 = 0; do { *(int4 *)(param_4 + uVar3 * 4) = *(int4 *)(param_1 + uVar3 * 4); uVar3 = uVar3 + 1; } while (uVar3 != param_3); piVar6 = (int *)(param_4 + 4); for (uVar3 = 1; uVar3 != param_3; uVar3 = uVar3 + 1) { piVar4 = piVar6; do { iVar2 = piVar6[-1]; if (*piVar4 < iVar2) { piVar6[-1] = *piVar4; *piVar4 = iVar2; } piVar4 = piVar4 + 1; } while (piVar4 != (int *)(param_4 + 8 + ((uVar3 - 1) + (ulong)((param_3 - 1) - (int)uVar3)) * 4)); piVar6 = piVar6 + 1; } } if ((int)param_3 < param_2) { lVar1 = (long)(int)param_3 * 4; piVar4 = (int *)(param_4 + -4 + lVar1); piVar6 = (int *)(param_1 + lVar1); do { if ((*piVar6 < *piVar4) && (*piVar4 = *piVar6, piVar5 = (int *)(param_4 + (long)(int)(param_3 - 1) * 4), 1 < (int)param_3)) { do { iVar2 = *piVar5; if (piVar5[-1] <= iVar2) break; *piVar5 = piVar5[-1]; piVar5[-1] = iVar2; piVar5 = piVar5 + -1; } while (piVar5 != (int *)(param_4 + -8 + lVar1 + (ulong)(param_3 - 2) * -4)); } piVar6 = piVar6 + 1; } while (piVar6 != (int *)(param_1 + 4 + ((long)(int)param_3 + (ulong)((param_2 + -1) - param_3)) * 4)); } return; }
3,934
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int arr[], int size, int n, int result[]) { int i, j, temp; // First copy elements to result and perform an initial sort for (i = 0; i < n; i++) { result[i] = arr[i]; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (result[i] > result[j]) { temp = result[i]; result[i] = result[j]; result[j] = temp; } } } // Process remaining elements in the input for (i = n; i < size; i++) { if (arr[i] < result[n-1]) { result[n-1] = arr[i]; // Insertion into sorted part of result for (j = n - 1; j > 0 && result[j] < result[j-1]; j--) { temp = result[j]; result[j] = result[j-1]; result[j-1] = temp; } } } }
int main() { int arr1[] = {10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100}; int size1 = sizeof(arr1) / sizeof(arr1[0]); int result1[2], result2[5], result3[3]; func0(arr1, size1, 2, result1); func0(arr1, size1, 5, result2); func0(arr1, size1, 3, result3); assert(result1[0] == 10 && result1[1] == 20); assert(result2[0] == 10 && result2[1] == 20 && result2[2] == 20 && result2[3] == 40 && result2[4] == 50); assert(result3[0] == 10 && result3[1] == 20 && result3[2] == 20); printf("All tests passed!\n"); return 0; }
O2
c
func0: endbr64 push %rbx test %edx,%edx jle 1390 <func0+0x70> lea -0x1(%rdx),%r9d xor %eax,%eax lea 0x1(%r9),%rbx nopl 0x0(%rax,%rax,1) mov (%rdi,%rax,4),%r8d mov %r8d,(%rcx,%rax,4) mov %rax,%r8 add $0x1,%rax cmp %r9,%r8 jne 1338 <func0+0x18> mov $0x1,%r11d mov %rcx,%r10 cmp %rbx,%r11 je 1390 <func0+0x70> nopw 0x0(%rax,%rax,1) mov %r11,%rax nopl 0x0(%rax,%rax,1) mov (%r10),%r8d mov (%rcx,%rax,4),%r9d cmp %r9d,%r8d jle 137b <func0+0x5b> mov %r9d,(%r10) mov %r8d,(%rcx,%rax,4) add $0x1,%rax cmp %eax,%edx jg 1368 <func0+0x48> add $0x1,%r11 add $0x4,%r10 cmp %rbx,%r11 jne 1360 <func0+0x40> cmp %esi,%edx jge 140f <func0+0xef> sub $0x1,%esi movslq %edx,%rax sub %edx,%esi lea 0x0(,%rax,4),%r11 add %rsi,%rax lea (%rdi,%r11,1),%r8 lea -0x4(%rcx,%r11,1),%r9 lea 0x4(%rdi,%rax,4),%r10 lea -0x1(%rdx),%eax cltq lea -0x8(%rcx,%r11,1),%rdi lea (%rcx,%rax,4),%rbx lea -0x2(%rdx),%eax shl $0x2,%rax sub %rax,%rdi jmp 13d9 <func0+0xb9> add $0x4,%r8 cmp %r10,%r8 je 140f <func0+0xef> mov (%r8),%eax cmp (%r9),%eax jge 13d0 <func0+0xb0> mov %eax,(%r9) mov %rbx,%rax cmp $0x1,%edx jg 13fd <func0+0xdd> jmp 13d0 <func0+0xb0> xchg %ax,%ax mov %ecx,(%rax) sub $0x4,%rax mov %esi,(%rax) cmp %rax,%rdi je 13d0 <func0+0xb0> mov (%rax),%esi mov -0x4(%rax),%ecx cmp %ecx,%esi jl 13f0 <func0+0xd0> add $0x4,%r8 cmp %r10,%r8 jne 13d9 <func0+0xb9> pop %rbx retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
func0: endbr64 push r13 mov r11, rdi mov r9d, edx push r12 push rbp mov rbp, rcx push rbx mov ebx, esi test edx, edx jle short loc_13AC lea r12d, [rdx-1] mov r10d, edx xor eax, eax nop word ptr [rax+rax+00h] loc_1348: mov edx, [r11+rax*4] mov [rbp+rax*4+0], edx add rax, 1 cmp rax, r10 jnz short loc_1348 mov r8d, 1 lea rsi, [rbp+4] lea r13, [rbp+8] cmp r8, r10 jz short loc_13AC nop dword ptr [rax+00h] loc_1370: mov eax, r12d sub eax, r8d lea rax, [r8+rax-1] lea rdi, [r13+rax*4+0] mov rax, rsi nop dword ptr [rax+rax+00h] loc_1388: mov edx, [rsi-4] mov ecx, [rax] cmp edx, ecx jle short loc_1396 mov [rsi-4], ecx mov [rax], edx loc_1396: add rax, 4 cmp rax, rdi jnz short loc_1388 add r8, 1 add rsi, 4 cmp r8, r10 jnz short loc_1370 loc_13AC: cmp r9d, ebx jge short loc_142F sub ebx, 1 movsxd rax, r9d sub ebx, r9d lea rdx, ds:0[rax*4] add rax, rbx lea rsi, [r11+rdx] lea rdi, [rbp+rdx-8] lea r10, [r11+rax*4+4] lea eax, [r9-1] cdqe lea r8, [rbp+rdx-4] lea r11, [rbp+rax*4+0] lea eax, [r9-2] shl rax, 2 sub rdi, rax jmp short loc_13F9 loc_13F0: add rsi, 4 cmp rsi, r10 jz short loc_142F loc_13F9: mov eax, [rsi] cmp eax, [r8] jge short loc_13F0 mov [r8], eax mov rax, r11 cmp r9d, 1 jg short loc_141D jmp short loc_13F0 loc_1410: mov [rax], edx sub rax, 4 mov [rax], ecx cmp rdi, rax jz short loc_13F0 loc_141D: mov ecx, [rax] mov edx, [rax-4] cmp ecx, edx jl short loc_1410 add rsi, 4 cmp rsi, r10 jnz short loc_13F9 loc_142F: pop rbx pop rbp pop r12 pop r13 retn
void func0(long long a1, int a2, int a3, long long a4) { int v7; // r12d long long v8; // r10 long long i; // rax long long v10; // r8 _DWORD *v11; // rsi _DWORD *v12; // rax int v13; // edx long long v14; // rdx _DWORD *v15; // rsi long long v16; // r10 _DWORD *v17; // r8 long long v18; // rdi int *v19; // rax int v20; // ecx int v21; // edx if ( a3 > 0 ) { v7 = a3 - 1; v8 = (unsigned int)a3; for ( i = 0LL; i != a3; ++i ) *(_DWORD *)(a4 + 4 * i) = *(_DWORD *)(a1 + 4 * i); v10 = 1LL; v11 = (_DWORD *)(a4 + 4); if ( a3 != 1LL ) { do { v12 = v11; do { v13 = *(v11 - 1); if ( v13 > *v12 ) { *(v11 - 1) = *v12; *v12 = v13; } ++v12; } while ( v12 != (_DWORD *)(a4 + 8 + 4 * (v10 + (unsigned int)(v7 - v10) - 1)) ); ++v10; ++v11; } while ( v10 != v8 ); } } if ( a3 < a2 ) { v14 = 4LL * a3; v15 = (_DWORD *)(a1 + v14); v16 = a1 + 4 * ((unsigned int)(a2 - 1 - a3) + (long long)a3) + 4; v17 = (_DWORD *)(a4 + v14 - 4); v18 = a4 + v14 - 8 - 4LL * (unsigned int)(a3 - 2); do { while ( 1 ) { if ( *v15 < *v17 ) { *v17 = *v15; v19 = (int *)(a4 + 4LL * (a3 - 1)); if ( a3 > 1 ) break; } LABEL_12: if ( ++v15 == (_DWORD *)v16 ) return; } while ( 1 ) { v20 = *v19; v21 = *(v19 - 1); if ( *v19 >= v21 ) break; *v19-- = v21; *v19 = v20; if ( (int *)v18 == v19 ) goto LABEL_12; } ++v15; } while ( v15 != (_DWORD *)v16 ); } }
func0: ENDBR64 PUSH R13 MOV R11,RDI MOV R9D,EDX PUSH R12 PUSH RBP MOV RBP,RCX PUSH RBX MOV EBX,ESI TEST EDX,EDX JLE 0x001013ac LEA R12D,[RDX + -0x1] MOV R10D,EDX XOR EAX,EAX NOP word ptr [RAX + RAX*0x1] LAB_00101348: MOV EDX,dword ptr [R11 + RAX*0x4] MOV dword ptr [RBP + RAX*0x4],EDX ADD RAX,0x1 CMP RAX,R10 JNZ 0x00101348 MOV R8D,0x1 LEA RSI,[RBP + 0x4] LEA R13,[RBP + 0x8] CMP R8,R10 JZ 0x001013ac NOP dword ptr [RAX] LAB_00101370: MOV EAX,R12D SUB EAX,R8D LEA RAX,[R8 + RAX*0x1 + -0x1] LEA RDI,[R13 + RAX*0x4] MOV RAX,RSI NOP dword ptr [RAX + RAX*0x1] LAB_00101388: MOV EDX,dword ptr [RSI + -0x4] MOV ECX,dword ptr [RAX] CMP EDX,ECX JLE 0x00101396 MOV dword ptr [RSI + -0x4],ECX MOV dword ptr [RAX],EDX LAB_00101396: ADD RAX,0x4 CMP RAX,RDI JNZ 0x00101388 ADD R8,0x1 ADD RSI,0x4 CMP R8,R10 JNZ 0x00101370 LAB_001013ac: CMP R9D,EBX JGE 0x0010142f SUB EBX,0x1 MOVSXD RAX,R9D SUB EBX,R9D LEA RDX,[RAX*0x4] ADD RAX,RBX LEA RSI,[R11 + RDX*0x1] LEA RDI,[RBP + RDX*0x1 + -0x8] LEA R10,[R11 + RAX*0x4 + 0x4] LEA EAX,[R9 + -0x1] CDQE LEA R8,[RBP + RDX*0x1 + -0x4] LEA R11,[RBP + RAX*0x4] LEA EAX,[R9 + -0x2] SHL RAX,0x2 SUB RDI,RAX JMP 0x001013f9 LAB_001013f0: ADD RSI,0x4 CMP RSI,R10 JZ 0x0010142f LAB_001013f9: MOV EAX,dword ptr [RSI] CMP EAX,dword ptr [R8] JGE 0x001013f0 MOV dword ptr [R8],EAX MOV RAX,R11 CMP R9D,0x1 JG 0x0010141d JMP 0x001013f0 LAB_00101410: MOV dword ptr [RAX],EDX SUB RAX,0x4 MOV dword ptr [RAX],ECX CMP RDI,RAX JZ 0x001013f0 LAB_0010141d: MOV ECX,dword ptr [RAX] MOV EDX,dword ptr [RAX + -0x4] CMP ECX,EDX JL 0x00101410 ADD RSI,0x4 CMP RSI,R10 JNZ 0x001013f9 LAB_0010142f: POP RBX POP RBP POP R12 POP R13 RET
void func0(long param_1,int param_2,uint param_3,long param_4) { long lVar1; int iVar2; ulong uVar3; int *piVar4; int *piVar5; int *piVar6; ulong uVar7; if (0 < (int)param_3) { uVar7 = (ulong)param_3; uVar3 = 0; do { *(int4 *)(param_4 + uVar3 * 4) = *(int4 *)(param_1 + uVar3 * 4); uVar3 = uVar3 + 1; } while (uVar3 != uVar7); uVar3 = 1; piVar6 = (int *)(param_4 + 4); if (uVar7 != 1) { do { piVar4 = piVar6; do { iVar2 = piVar6[-1]; if (*piVar4 < iVar2) { piVar6[-1] = *piVar4; *piVar4 = iVar2; } piVar4 = piVar4 + 1; } while (piVar4 != (int *)(param_4 + 8 + ((uVar3 - 1) + (ulong)((param_3 - 1) - (int)uVar3)) * 4)); uVar3 = uVar3 + 1; piVar6 = piVar6 + 1; } while (uVar3 != uVar7); } } if ((int)param_3 < param_2) { lVar1 = (long)(int)param_3 * 4; piVar6 = (int *)(param_1 + lVar1); piVar4 = (int *)(param_4 + -4 + lVar1); do { if ((*piVar6 < *piVar4) && (*piVar4 = *piVar6, piVar5 = (int *)(param_4 + (long)(int)(param_3 - 1) * 4), 1 < (int)param_3)) { do { iVar2 = *piVar5; if (piVar5[-1] <= iVar2) break; *piVar5 = piVar5[-1]; piVar5 = piVar5 + -1; *piVar5 = iVar2; } while ((int *)(param_4 + -8 + lVar1 + (ulong)(param_3 - 2) * -4) != piVar5); } piVar6 = piVar6 + 1; } while (piVar6 != (int *)(param_1 + 4 + ((long)(int)param_3 + (ulong)((param_2 + -1) - param_3)) * 4)); } return; }
3,935
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int arr[], int size, int n, int result[]) { int i, j, temp; // First copy elements to result and perform an initial sort for (i = 0; i < n; i++) { result[i] = arr[i]; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (result[i] > result[j]) { temp = result[i]; result[i] = result[j]; result[j] = temp; } } } // Process remaining elements in the input for (i = n; i < size; i++) { if (arr[i] < result[n-1]) { result[n-1] = arr[i]; // Insertion into sorted part of result for (j = n - 1; j > 0 && result[j] < result[j-1]; j--) { temp = result[j]; result[j] = result[j-1]; result[j-1] = temp; } } } }
int main() { int arr1[] = {10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100}; int size1 = sizeof(arr1) / sizeof(arr1[0]); int result1[2], result2[5], result3[3]; func0(arr1, size1, 2, result1); func0(arr1, size1, 5, result2); func0(arr1, size1, 3, result3); assert(result1[0] == 10 && result1[1] == 20); assert(result2[0] == 10 && result2[1] == 20 && result2[2] == 20 && result2[3] == 40 && result2[4] == 50); assert(result3[0] == 10 && result3[1] == 20 && result3[2] == 20); printf("All tests passed!\n"); return 0; }
O3
c
func0: endbr64 push %rbx test %edx,%edx jle 13d0 <func0+0xd0> lea 0xf(%rdi),%rax lea -0x1(%rdx),%r8d sub %rcx,%rax cmp $0x1e,%rax jbe 1461 <func0+0x161> cmp $0x3,%r8d jbe 1461 <func0+0x161> mov %edx,%r8d xor %eax,%eax shr $0x2,%r8d shl $0x4,%r8 nopl 0x0(%rax) movdqu (%rdi,%rax,1),%xmm0 movups %xmm0,(%rcx,%rax,1) add $0x10,%rax cmp %r8,%rax jne 1340 <func0+0x40> mov %edx,%eax and $0xfffffffc,%eax test $0x3,%dl je 138c <func0+0x8c> mov %eax,%r8d mov (%rdi,%r8,4),%r9d mov %r9d,(%rcx,%r8,4) lea 0x1(%rax),%r8d cmp %r8d,%edx jle 138c <func0+0x8c> movslq %r8d,%r8 add $0x2,%eax mov (%rdi,%r8,4),%r9d mov %r9d,(%rcx,%r8,4) cmp %eax,%edx jle 138c <func0+0x8c> cltq mov (%rdi,%rax,4),%r8d mov %r8d,(%rcx,%rax,4) lea -0x2(%rdx),%ebx mov %rcx,%r10 mov $0x1,%r11d add $0x2,%rbx nopl 0x0(%rax) mov %r11,%rax nopl 0x0(%rax,%rax,1) mov (%r10),%r8d mov (%rcx,%rax,4),%r9d cmp %r9d,%r8d jle 13bb <func0+0xbb> mov %r9d,(%r10) mov %r8d,(%rcx,%rax,4) add $0x1,%rax cmp %eax,%edx jg 13a8 <func0+0xa8> add $0x1,%r11 add $0x4,%r10 cmp %rbx,%r11 jne 13a0 <func0+0xa0> cmp %esi,%edx jge 145f <func0+0x15f> sub $0x1,%esi movslq %edx,%rax lea -0x1(%rdx),%r10d sub %edx,%esi lea 0x0(,%rax,4),%r8 add %rsi,%rax lea -0x4(%rcx,%r8,1),%r9 add %rdi,%r8 lea 0x4(%rdi,%rax,4),%rdi movslq %r10d,%rax shl $0x2,%rax lea -0x4(%rcx,%rax,1),%rsi lea (%rcx,%rax,1),%r11 lea -0x2(%rdx),%eax shl $0x2,%rax sub %rax,%rsi jmp 1429 <func0+0x129> nopl 0x0(%rax,%rax,1) add $0x4,%r8 cmp %rdi,%r8 je 145f <func0+0x15f> mov (%r8),%eax cmp (%r9),%eax jge 1420 <func0+0x120> mov %eax,(%r9) mov %r11,%rax test %r10d,%r10d jg 144d <func0+0x14d> jmp 1420 <func0+0x120> xchg %ax,%ax mov %edx,(%rax) sub $0x4,%rax mov %ecx,(%rax) cmp %rsi,%rax je 1420 <func0+0x120> mov (%rax),%ecx mov -0x4(%rax),%edx cmp %edx,%ecx jl 1440 <func0+0x140> add $0x4,%r8 cmp %rdi,%r8 jne 1429 <func0+0x129> pop %rbx retq xor %eax,%eax nopl 0x0(%rax,%rax,1) mov (%rdi,%rax,4),%r9d mov %r9d,(%rcx,%rax,4) mov %rax,%r9 add $0x1,%rax cmp %r8,%r9 jne 1468 <func0+0x168> cmp $0x1,%edx je 13d0 <func0+0xd0> jmpq 138c <func0+0x8c> nopw 0x0(%rax,%rax,1)
func0: endbr64 mov r10, rdi push rbx mov r11d, esi mov r8d, edx mov rdi, rcx test edx, edx jle short loc_1394 lea eax, [rdx-1] cmp eax, 2 jbe short loc_1331 lea rdx, [r10+4] mov rax, rcx sub rax, rdx cmp rax, 8 ja loc_1432 loc_1331: movsxd rcx, r8d xor eax, eax shl rcx, 2 nop word ptr [rax+rax+00h] loc_1340: mov edx, [r10+rax] mov [rdi+rax], edx add rax, 4 cmp rax, rcx jnz short loc_1340 cmp r8d, 1 jz short loc_1394 loc_1356: mov rsi, rdi mov ebx, r8d mov r9d, 1 nop word ptr [rax+rax+00h] loc_1368: mov rax, r9 nop dword ptr [rax+rax+00h] loc_1370: mov edx, [rsi] mov ecx, [rdi+rax*4] cmp edx, ecx jle short loc_137E mov [rsi], ecx mov [rdi+rax*4], edx loc_137E: add rax, 1 cmp r8d, eax jg short loc_1370 add r9, 1 add rsi, 4 cmp r9, rbx jnz short loc_1368 loc_1394: cmp r8d, r11d jge loc_1430 movsxd rax, r8d sub r11d, r8d lea ebx, [r8-1] lea rsi, ds:0[rax*4] add rax, r11 lea r9, [rdi+rsi-4] add rsi, r10 lea r10, [r10+rax*4] movsxd rax, ebx shl rax, 2 lea r11, [rdi+rax-4] lea rdi, [rdi+rax-8] lea eax, [r8-2] shl rax, 2 sub rdi, rax jmp short loc_13E9 loc_13E0: add rsi, 4 cmp rsi, r10 jz short loc_1430 loc_13E9: mov eax, [rsi] cmp eax, [r9] jge short loc_13E0 mov [r9], eax mov rdx, r11 test ebx, ebx jg short loc_140D jmp short loc_13E0 loc_1400: movq qword ptr [rdx], xmm1 sub rdx, 4 cmp rdx, rdi jz short loc_13E0 loc_140D: movq xmm0, qword ptr [rdx] pshufd xmm2, xmm0, 0E5h movd ecx, xmm0 movd eax, xmm2 pshufd xmm1, xmm0, 0E1h cmp ecx, eax jg short loc_1400 add rsi, 4 cmp rsi, r10 jnz short loc_13E9 loc_1430: pop rbx retn loc_1432: mov edx, r8d xor eax, eax shr edx, 2 shl rdx, 4 xchg ax, ax loc_1440: movdqu xmm3, xmmword ptr [r10+rax] movups xmmword ptr [rdi+rax], xmm3 add rax, 10h cmp rax, rdx jnz short loc_1440 mov eax, r8d and eax, 0FFFFFFFCh test r8b, 3 jz loc_1356 mov ecx, eax mov esi, [r10+rcx*4] lea rdx, ds:0[rcx*4] mov [rdi+rcx*4], esi lea ecx, [rax+1] cmp r8d, ecx jle loc_1356 mov ecx, [r10+rdx+4] add eax, 2 mov [rdi+rdx+4], ecx cmp r8d, eax jle loc_1356 mov eax, [r10+rdx+8] mov [rdi+rdx+8], eax jmp loc_1356
void func0(long long a1, int a2, int a3, int *a4) { long long i; // rax int *v9; // rsi long long v10; // r9 long long v11; // rax int v12; // edx int v13; // ecx long long v14; // rsi int *v15; // r9 int *v16; // rsi int *v17; // r10 long long v18; // rax long long v19; // r11 long long v20; // rdi __m128i *v21; // rdx __m128i v22; // xmm0 unsigned long long v23; // xmm1_8 long long v24; // rax unsigned int v25; // eax long long v26; // rdx if ( a3 > 0 ) { if ( (unsigned int)(a3 - 1) > 2 && (unsigned long long)a4 - a1 - 4 > 8 ) { v24 = 0LL; do { *(__m128i *)&a4[v24] = _mm_loadu_si128((const __m128i *)(a1 + v24 * 4)); v24 += 4LL; } while ( v24 != 4LL * ((unsigned int)a3 >> 2) ); v25 = a3 & 0xFFFFFFFC; if ( (a3 & 3) != 0 ) { v26 = v25; a4[v26] = *(_DWORD *)(a1 + v26 * 4); if ( a3 > (int)(v25 + 1) ) { a4[v26 + 1] = *(_DWORD *)(a1 + v26 * 4 + 4); if ( a3 > (int)(v25 + 2) ) a4[v26 + 2] = *(_DWORD *)(a1 + v26 * 4 + 8); } } } else { for ( i = 0LL; i != a3; ++i ) a4[i] = *(_DWORD *)(a1 + i * 4); if ( a3 == 1 ) goto LABEL_13; } v9 = a4; v10 = 1LL; do { v11 = v10; do { v12 = *v9; v13 = a4[v11]; if ( *v9 > v13 ) { *v9 = v13; a4[v11] = v12; } ++v11; } while ( a3 > (int)v11 ); ++v10; ++v9; } while ( v10 != a3 ); } LABEL_13: if ( a3 < a2 ) { v14 = a3; v15 = &a4[v14 - 1]; v16 = (int *)(a1 + v14 * 4); v17 = (int *)(a1 + 4 * ((unsigned int)(a2 - a3) + (long long)a3)); v18 = a3 - 1; v19 = (long long)&a4[v18 - 1]; v20 = (long long)&a4[v18 - 2 - (unsigned int)(a3 - 2)]; do { while ( 1 ) { if ( *v16 < *v15 ) { *v15 = *v16; v21 = (__m128i *)v19; if ( a3 - 1 > 0 ) break; } LABEL_15: if ( ++v16 == v17 ) return; } while ( 1 ) { v22 = _mm_loadl_epi64(v21); v23 = _mm_shuffle_epi32(v22, 225).m128i_u64[0]; if ( _mm_cvtsi128_si32(v22) <= _mm_cvtsi128_si32(_mm_shuffle_epi32(v22, 229)) ) break; v21->m128i_i64[0] = v23; v21 = (__m128i *)((char *)v21 - 4); if ( v21 == (__m128i *)v20 ) goto LABEL_15; } ++v16; } while ( v16 != v17 ); } }
func0: ENDBR64 MOV R10,RDI PUSH RBX MOV R11D,ESI MOV R8D,EDX MOV RDI,RCX TEST EDX,EDX JLE 0x00101394 LEA EAX,[RDX + -0x1] CMP EAX,0x2 JBE 0x00101331 LEA RDX,[R10 + 0x4] MOV RAX,RCX SUB RAX,RDX CMP RAX,0x8 JA 0x00101432 LAB_00101331: MOVSXD RCX,R8D XOR EAX,EAX SHL RCX,0x2 NOP word ptr [RAX + RAX*0x1] LAB_00101340: MOV EDX,dword ptr [R10 + RAX*0x1] MOV dword ptr [RDI + RAX*0x1],EDX ADD RAX,0x4 CMP RAX,RCX JNZ 0x00101340 CMP R8D,0x1 JZ 0x00101394 LAB_00101356: MOV RSI,RDI MOV EBX,R8D MOV R9D,0x1 NOP word ptr [RAX + RAX*0x1] LAB_00101368: MOV RAX,R9 NOP dword ptr [RAX + RAX*0x1] LAB_00101370: MOV EDX,dword ptr [RSI] MOV ECX,dword ptr [RDI + RAX*0x4] CMP EDX,ECX JLE 0x0010137e MOV dword ptr [RSI],ECX MOV dword ptr [RDI + RAX*0x4],EDX LAB_0010137e: ADD RAX,0x1 CMP R8D,EAX JG 0x00101370 ADD R9,0x1 ADD RSI,0x4 CMP R9,RBX JNZ 0x00101368 LAB_00101394: CMP R8D,R11D JGE 0x00101430 MOVSXD RAX,R8D SUB R11D,R8D LEA EBX,[R8 + -0x1] LEA RSI,[RAX*0x4] ADD RAX,R11 LEA R9,[RDI + RSI*0x1 + -0x4] ADD RSI,R10 LEA R10,[R10 + RAX*0x4] MOVSXD RAX,EBX SHL RAX,0x2 LEA R11,[RDI + RAX*0x1 + -0x4] LEA RDI,[RDI + RAX*0x1 + -0x8] LEA EAX,[R8 + -0x2] SHL RAX,0x2 SUB RDI,RAX JMP 0x001013e9 LAB_001013e0: ADD RSI,0x4 CMP RSI,R10 JZ 0x00101430 LAB_001013e9: MOV EAX,dword ptr [RSI] CMP EAX,dword ptr [R9] JGE 0x001013e0 MOV dword ptr [R9],EAX MOV RDX,R11 TEST EBX,EBX JG 0x0010140d JMP 0x001013e0 LAB_00101400: MOVQ qword ptr [RDX],XMM1 SUB RDX,0x4 CMP RDX,RDI JZ 0x001013e0 LAB_0010140d: MOVQ XMM0,qword ptr [RDX] PSHUFD XMM2,XMM0,0xe5 MOVD ECX,XMM0 MOVD EAX,XMM2 PSHUFD XMM1,XMM0,0xe1 CMP ECX,EAX JG 0x00101400 ADD RSI,0x4 CMP RSI,R10 JNZ 0x001013e9 LAB_00101430: POP RBX RET LAB_00101432: MOV EDX,R8D XOR EAX,EAX SHR EDX,0x2 SHL RDX,0x4 NOP LAB_00101440: MOVDQU XMM3,xmmword ptr [R10 + RAX*0x1] MOVUPS xmmword ptr [RDI + RAX*0x1],XMM3 ADD RAX,0x10 CMP RAX,RDX JNZ 0x00101440 MOV EAX,R8D AND EAX,0xfffffffc TEST R8B,0x3 JZ 0x00101356 MOV ECX,EAX MOV ESI,dword ptr [R10 + RCX*0x4] LEA RDX,[RCX*0x4] MOV dword ptr [RDI + RCX*0x4],ESI LEA ECX,[RAX + 0x1] CMP R8D,ECX JLE 0x00101356 MOV ECX,dword ptr [R10 + RDX*0x1 + 0x4] ADD EAX,0x2 MOV dword ptr [RDI + RDX*0x1 + 0x4],ECX CMP R8D,EAX JLE 0x00101356 MOV EAX,dword ptr [R10 + RDX*0x1 + 0x8] MOV dword ptr [RDI + RDX*0x1 + 0x8],EAX JMP 0x00101356
void func0(long param_1,int param_2,uint param_3,int *param_4) { int8 uVar1; uint uVar2; long lVar3; ulong uVar4; int *piVar5; int iVar6; int *piVar7; ulong uVar8; int iVar9; int iVar10; if (0 < (int)param_3) { if ((param_3 - 1 < 3) || ((ulong)((long)param_4 - (param_1 + 4)) < 9)) { lVar3 = 0; do { *(int4 *)((long)param_4 + lVar3) = *(int4 *)(param_1 + lVar3); lVar3 = lVar3 + 4; } while (lVar3 != (long)(int)param_3 * 4); if (param_3 == 1) goto LAB_00101394; } else { lVar3 = 0; do { uVar1 = ((int8 *)(param_1 + lVar3))[1]; *(int8 *)((long)param_4 + lVar3) = *(int8 *)(param_1 + lVar3); ((int8 *)((long)param_4 + lVar3))[1] = uVar1; lVar3 = lVar3 + 0x10; } while (lVar3 != (ulong)(param_3 >> 2) << 4); uVar2 = param_3 & 0xfffffffc; if ((param_3 & 3) != 0) { uVar4 = (ulong)uVar2; param_4[uVar4] = *(int *)(param_1 + uVar4 * 4); if (((int)(uVar2 + 1) < (int)param_3) && (param_4[uVar4 + 1] = *(int *)(param_1 + 4 + uVar4 * 4), (int)(uVar2 + 2) < (int)param_3) ) { param_4[uVar4 + 2] = *(int *)(param_1 + 8 + uVar4 * 4); } } } uVar8 = 1; uVar4 = uVar8; piVar7 = param_4; do { do { iVar6 = *piVar7; if (param_4[uVar8] < iVar6) { *piVar7 = param_4[uVar8]; param_4[uVar8] = iVar6; } uVar8 = uVar8 + 1; } while ((int)uVar8 < (int)param_3); uVar8 = uVar4 + 1; piVar7 = piVar7 + 1; uVar4 = uVar8; } while (uVar8 != param_3); } LAB_00101394: if ((int)param_3 < param_2) { lVar3 = (long)(int)param_3; iVar6 = param_3 - 1; piVar7 = (int *)(lVar3 * 4 + param_1); do { if ((*piVar7 < param_4[lVar3 + -1]) && (param_4[lVar3 + -1] = *piVar7, piVar5 = param_4 + (long)iVar6 + -1, 0 < iVar6)) { do { iVar9 = (int)*(int8 *)piVar5; iVar10 = (int)((ulong)*(int8 *)piVar5 >> 0x20); if (iVar9 <= iVar10) break; *(ulong *)piVar5 = CONCAT44(iVar9,iVar10); piVar5 = piVar5 + -1; } while (piVar5 != param_4 + (long)iVar6 + (-2 - (ulong)(param_3 - 2))); } piVar7 = piVar7 + 1; } while (piVar7 != (int *)(param_1 + (lVar3 + (ulong)(param_2 - param_3)) * 4)); } return; }
3,936
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(const char *str, char ch) { int len = strlen(str); int first = -1, last = -1; // Find the first and last occurrence of the character for (int i = 0; i < len; i++) { if (str[i] == ch) { if (first == -1) { first = i; // First occurrence } last = i; // Last occurrence (will keep updating) } } // If both occurrences are found and are not the same if (first != -1 && last != -1 && first != last) { // Allocate memory for the new string char *new_str = (char *)malloc(len - 2 + 1); // We remove 2 characters int new_index = 0; // Copy characters before the first occurrence for (int i = 0; i < first; i++) { new_str[new_index++] = str[i]; } // Copy characters between the first and last occurrences for (int i = first + 1; i < last; i++) { new_str[new_index++] = str[i]; } // Copy characters after the last occurrence for (int i = last + 1; i < len; i++) { new_str[new_index++] = str[i]; } new_str[new_index] = '\0'; // Null-terminate the new string return new_str; } // If no valid removals were done, return the original string as a new string char *new_str = (char *)malloc(len + 1); strcpy(new_str, str); return new_str; }
int main() { assert(strcmp(func0("hello",'l'), "heo") == 0); assert(strcmp(func0("abcda",'a'), "bcd") == 0); assert(strcmp(func0("PHP",'P'), "H") == 0); assert(strcmp(func0("hellolloll",'l'), "helollol") == 0); assert(strcmp(func0("",'l'), "") == 0); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x40,%rsp mov %rdi,-0x38(%rbp) mov %esi,%eax mov %al,-0x3c(%rbp) mov -0x38(%rbp),%rax mov %rax,%rdi callq 10a0 <strlen@plt> mov %eax,-0x14(%rbp) movl $0xffffffff,-0x30(%rbp) movl $0xffffffff,-0x2c(%rbp) movl $0x0,-0x28(%rbp) jmp 122f <func0+0x66> mov -0x28(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp %al,-0x3c(%rbp) jne 122b <func0+0x62> cmpl $0xffffffff,-0x30(%rbp) jne 1225 <func0+0x5c> mov -0x28(%rbp),%eax mov %eax,-0x30(%rbp) mov -0x28(%rbp),%eax mov %eax,-0x2c(%rbp) addl $0x1,-0x28(%rbp) mov -0x28(%rbp),%eax cmp -0x14(%rbp),%eax jl 1204 <func0+0x3b> cmpl $0xffffffff,-0x30(%rbp) je 133d <func0+0x174> cmpl $0xffffffff,-0x2c(%rbp) je 133d <func0+0x174> mov -0x30(%rbp),%eax cmp -0x2c(%rbp),%eax je 133d <func0+0x174> mov -0x14(%rbp),%eax sub $0x1,%eax cltq mov %rax,%rdi callq 10d0 <malloc@plt> mov %rax,-0x10(%rbp) movl $0x0,-0x24(%rbp) movl $0x0,-0x20(%rbp) jmp 12a5 <func0+0xdc> mov -0x20(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x24(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x24(%rbp) movslq %eax,%rdx mov -0x10(%rbp),%rax add %rax,%rdx movzbl (%rcx),%eax mov %al,(%rdx) addl $0x1,-0x20(%rbp) mov -0x20(%rbp),%eax cmp -0x30(%rbp),%eax jl 127b <func0+0xb2> mov -0x30(%rbp),%eax add $0x1,%eax mov %eax,-0x1c(%rbp) jmp 12e2 <func0+0x119> mov -0x1c(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x24(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x24(%rbp) movslq %eax,%rdx mov -0x10(%rbp),%rax add %rax,%rdx movzbl (%rcx),%eax mov %al,(%rdx) addl $0x1,-0x1c(%rbp) mov -0x1c(%rbp),%eax cmp -0x2c(%rbp),%eax jl 12b8 <func0+0xef> mov -0x2c(%rbp),%eax add $0x1,%eax mov %eax,-0x18(%rbp) jmp 131f <func0+0x156> mov -0x18(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x24(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x24(%rbp) movslq %eax,%rdx mov -0x10(%rbp),%rax add %rax,%rdx movzbl (%rcx),%eax mov %al,(%rdx) addl $0x1,-0x18(%rbp) mov -0x18(%rbp),%eax cmp -0x14(%rbp),%eax jl 12f5 <func0+0x12c> mov -0x24(%rbp),%eax movslq %eax,%rdx mov -0x10(%rbp),%rax add %rdx,%rax movb $0x0,(%rax) mov -0x10(%rbp),%rax jmp 1368 <func0+0x19f> mov -0x14(%rbp),%eax add $0x1,%eax cltq mov %rax,%rdi callq 10d0 <malloc@plt> mov %rax,-0x8(%rbp) mov -0x38(%rbp),%rdx mov -0x8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1090 <strcpy@plt> mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 40h mov [rbp+s], rdi mov eax, esi mov [rbp+var_3C], al mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_14], eax mov [rbp+var_30], 0FFFFFFFFh mov [rbp+var_2C], 0FFFFFFFFh mov [rbp+var_28], 0 jmp short loc_122F loc_1204: mov eax, [rbp+var_28] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp [rbp+var_3C], al jnz short loc_122B cmp [rbp+var_30], 0FFFFFFFFh jnz short loc_1225 mov eax, [rbp+var_28] mov [rbp+var_30], eax loc_1225: mov eax, [rbp+var_28] mov [rbp+var_2C], eax loc_122B: add [rbp+var_28], 1 loc_122F: mov eax, [rbp+var_28] cmp eax, [rbp+var_14] jl short loc_1204 cmp [rbp+var_30], 0FFFFFFFFh jz loc_133D cmp [rbp+var_2C], 0FFFFFFFFh jz loc_133D mov eax, [rbp+var_30] cmp eax, [rbp+var_2C] jz loc_133D mov eax, [rbp+var_14] sub eax, 1 cdqe mov rdi, rax; size call _malloc mov [rbp+var_10], rax mov [rbp+var_24], 0 mov [rbp+var_20], 0 jmp short loc_12A5 loc_127B: mov eax, [rbp+var_20] movsxd rdx, eax mov rax, [rbp+s] lea rcx, [rdx+rax] mov eax, [rbp+var_24] lea edx, [rax+1] mov [rbp+var_24], edx movsxd rdx, eax mov rax, [rbp+var_10] add rdx, rax movzx eax, byte ptr [rcx] mov [rdx], al add [rbp+var_20], 1 loc_12A5: mov eax, [rbp+var_20] cmp eax, [rbp+var_30] jl short loc_127B mov eax, [rbp+var_30] add eax, 1 mov [rbp+var_1C], eax jmp short loc_12E2 loc_12B8: mov eax, [rbp+var_1C] movsxd rdx, eax mov rax, [rbp+s] lea rcx, [rdx+rax] mov eax, [rbp+var_24] lea edx, [rax+1] mov [rbp+var_24], edx movsxd rdx, eax mov rax, [rbp+var_10] add rdx, rax movzx eax, byte ptr [rcx] mov [rdx], al add [rbp+var_1C], 1 loc_12E2: mov eax, [rbp+var_1C] cmp eax, [rbp+var_2C] jl short loc_12B8 mov eax, [rbp+var_2C] add eax, 1 mov [rbp+var_18], eax jmp short loc_131F loc_12F5: mov eax, [rbp+var_18] movsxd rdx, eax mov rax, [rbp+s] lea rcx, [rdx+rax] mov eax, [rbp+var_24] lea edx, [rax+1] mov [rbp+var_24], edx movsxd rdx, eax mov rax, [rbp+var_10] add rdx, rax movzx eax, byte ptr [rcx] mov [rdx], al add [rbp+var_18], 1 loc_131F: mov eax, [rbp+var_18] cmp eax, [rbp+var_14] jl short loc_12F5 mov eax, [rbp+var_24] movsxd rdx, eax mov rax, [rbp+var_10] add rax, rdx mov byte ptr [rax], 0 mov rax, [rbp+var_10] jmp short locret_1368 loc_133D: mov eax, [rbp+var_14] add eax, 1 cdqe mov rdi, rax; size call _malloc mov [rbp+dest], rax mov rdx, [rbp+s] mov rax, [rbp+dest] mov rsi, rdx; src mov rdi, rax; dest call _strcpy mov rax, [rbp+dest] locret_1368: leave retn
char * func0(const char *a1, char a2) { int v2; // eax int v3; // eax int v4; // eax int v6; // [rsp+10h] [rbp-30h] int v7; // [rsp+14h] [rbp-2Ch] int i; // [rsp+18h] [rbp-28h] int v9; // [rsp+1Ch] [rbp-24h] int j; // [rsp+20h] [rbp-20h] int k; // [rsp+24h] [rbp-1Ch] int m; // [rsp+28h] [rbp-18h] int v13; // [rsp+2Ch] [rbp-14h] _BYTE *v14; // [rsp+30h] [rbp-10h] char *dest; // [rsp+38h] [rbp-8h] v13 = strlen(a1); v6 = -1; v7 = -1; for ( i = 0; i < v13; ++i ) { if ( a2 == a1[i] ) { if ( v6 == -1 ) v6 = i; v7 = i; } } if ( v6 == -1 || v7 == -1 || v6 == v7 ) { dest = (char *)malloc(v13 + 1); strcpy(dest, a1); return dest; } else { v14 = malloc(v13 - 1); v9 = 0; for ( j = 0; j < v6; ++j ) { v2 = v9++; v14[v2] = a1[j]; } for ( k = v6 + 1; k < v7; ++k ) { v3 = v9++; v14[v3] = a1[k]; } for ( m = v7 + 1; m < v13; ++m ) { v4 = v9++; v14[v4] = a1[m]; } v14[v9] = 0; return v14; } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 MOV qword ptr [RBP + -0x38],RDI MOV EAX,ESI MOV byte ptr [RBP + -0x3c],AL MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x001010a0 MOV dword ptr [RBP + -0x14],EAX MOV dword ptr [RBP + -0x30],0xffffffff MOV dword ptr [RBP + -0x2c],0xffffffff MOV dword ptr [RBP + -0x28],0x0 JMP 0x0010122f LAB_00101204: MOV EAX,dword ptr [RBP + -0x28] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP byte ptr [RBP + -0x3c],AL JNZ 0x0010122b CMP dword ptr [RBP + -0x30],-0x1 JNZ 0x00101225 MOV EAX,dword ptr [RBP + -0x28] MOV dword ptr [RBP + -0x30],EAX LAB_00101225: MOV EAX,dword ptr [RBP + -0x28] MOV dword ptr [RBP + -0x2c],EAX LAB_0010122b: ADD dword ptr [RBP + -0x28],0x1 LAB_0010122f: MOV EAX,dword ptr [RBP + -0x28] CMP EAX,dword ptr [RBP + -0x14] JL 0x00101204 CMP dword ptr [RBP + -0x30],-0x1 JZ 0x0010133d CMP dword ptr [RBP + -0x2c],-0x1 JZ 0x0010133d MOV EAX,dword ptr [RBP + -0x30] CMP EAX,dword ptr [RBP + -0x2c] JZ 0x0010133d MOV EAX,dword ptr [RBP + -0x14] SUB EAX,0x1 CDQE MOV RDI,RAX CALL 0x001010d0 MOV qword ptr [RBP + -0x10],RAX MOV dword ptr [RBP + -0x24],0x0 MOV dword ptr [RBP + -0x20],0x0 JMP 0x001012a5 LAB_0010127b: MOV EAX,dword ptr [RBP + -0x20] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x24] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x24],EDX MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x10] ADD RDX,RAX MOVZX EAX,byte ptr [RCX] MOV byte ptr [RDX],AL ADD dword ptr [RBP + -0x20],0x1 LAB_001012a5: MOV EAX,dword ptr [RBP + -0x20] CMP EAX,dword ptr [RBP + -0x30] JL 0x0010127b MOV EAX,dword ptr [RBP + -0x30] ADD EAX,0x1 MOV dword ptr [RBP + -0x1c],EAX JMP 0x001012e2 LAB_001012b8: MOV EAX,dword ptr [RBP + -0x1c] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x24] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x24],EDX MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x10] ADD RDX,RAX MOVZX EAX,byte ptr [RCX] MOV byte ptr [RDX],AL ADD dword ptr [RBP + -0x1c],0x1 LAB_001012e2: MOV EAX,dword ptr [RBP + -0x1c] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001012b8 MOV EAX,dword ptr [RBP + -0x2c] ADD EAX,0x1 MOV dword ptr [RBP + -0x18],EAX JMP 0x0010131f LAB_001012f5: MOV EAX,dword ptr [RBP + -0x18] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x24] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x24],EDX MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x10] ADD RDX,RAX MOVZX EAX,byte ptr [RCX] MOV byte ptr [RDX],AL ADD dword ptr [RBP + -0x18],0x1 LAB_0010131f: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x14] JL 0x001012f5 MOV EAX,dword ptr [RBP + -0x24] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RDX MOV byte ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x10] JMP 0x00101368 LAB_0010133d: MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 CDQE MOV RDI,RAX CALL 0x001010d0 MOV qword ptr [RBP + -0x8],RAX MOV RDX,qword ptr [RBP + -0x38] MOV RAX,qword ptr [RBP + -0x8] MOV RSI,RDX MOV RDI,RAX CALL 0x00101090 MOV RAX,qword ptr [RBP + -0x8] LAB_00101368: LEAVE RET
char * func0(char *param_1,char param_2) { int iVar1; size_t sVar2; char *__dest; int local_38; int local_34; int local_30; int local_2c; int local_28; int local_24; int local_20; sVar2 = strlen(param_1); iVar1 = (int)sVar2; local_38 = -1; local_34 = -1; for (local_30 = 0; local_30 < iVar1; local_30 = local_30 + 1) { if (param_2 == param_1[local_30]) { if (local_38 == -1) { local_38 = local_30; } local_34 = local_30; } } if (((local_38 == -1) || (local_34 == -1)) || (local_38 == local_34)) { __dest = (char *)malloc((long)(iVar1 + 1)); strcpy(__dest,param_1); } else { __dest = (char *)malloc((long)(iVar1 + -1)); local_2c = 0; for (local_28 = 0; local_24 = local_38, local_28 < local_38; local_28 = local_28 + 1) { __dest[local_2c] = param_1[local_28]; local_2c = local_2c + 1; } while (local_24 = local_24 + 1, local_20 = local_34, local_24 < local_34) { __dest[local_2c] = param_1[local_24]; local_2c = local_2c + 1; } while (local_20 = local_20 + 1, local_20 < iVar1) { __dest[local_2c] = param_1[local_20]; local_2c = local_2c + 1; } __dest[local_2c] = '\0'; } return __dest; }
3,937
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(const char *str, char ch) { int len = strlen(str); int first = -1, last = -1; // Find the first and last occurrence of the character for (int i = 0; i < len; i++) { if (str[i] == ch) { if (first == -1) { first = i; // First occurrence } last = i; // Last occurrence (will keep updating) } } // If both occurrences are found and are not the same if (first != -1 && last != -1 && first != last) { // Allocate memory for the new string char *new_str = (char *)malloc(len - 2 + 1); // We remove 2 characters int new_index = 0; // Copy characters before the first occurrence for (int i = 0; i < first; i++) { new_str[new_index++] = str[i]; } // Copy characters between the first and last occurrences for (int i = first + 1; i < last; i++) { new_str[new_index++] = str[i]; } // Copy characters after the last occurrence for (int i = last + 1; i < len; i++) { new_str[new_index++] = str[i]; } new_str[new_index] = '\0'; // Null-terminate the new string return new_str; } // If no valid removals were done, return the original string as a new string char *new_str = (char *)malloc(len + 1); strcpy(new_str, str); return new_str; }
int main() { assert(strcmp(func0("hello",'l'), "heo") == 0); assert(strcmp(func0("abcda",'a'), "bcd") == 0); assert(strcmp(func0("PHP",'P'), "H") == 0); assert(strcmp(func0("hellolloll",'l'), "helollol") == 0); assert(strcmp(func0("",'l'), "") == 0); return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x18,%rsp mov %rdi,%rbx mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al not %rcx lea -0x1(%rcx),%rbp test %ebp,%ebp jle 120d <func0+0x84> mov %ebp,%r15d lea -0x1(%rbp),%eax mov %eax,0xc(%rsp) mov %eax,%ecx mov $0x0,%eax mov $0xffffffff,%r12d mov $0xffffffff,%r13d jmp 11e2 <func0+0x59> lea 0x1(%rax),%rdx cmp %rcx,%rax je 11f6 <func0+0x6d> mov %rdx,%rax cmp %sil,(%rbx,%rax,1) jne 11d6 <func0+0x4d> mov %eax,%r12d cmp $0xffffffff,%r13d jne 11d6 <func0+0x4d> mov %eax,%r13d jmp 11d6 <func0+0x4d> cmp $0xffffffff,%r13d setne %dl cmp $0xffffffff,%r12d setne %al test %al,%dl je 120d <func0+0x84> cmp %r12d,%r13d jne 1238 <func0+0xaf> lea 0x1(%rbp),%edi movslq %edi,%rdi callq 1090 <malloc@plt> mov %rax,%r14 mov %rbx,%rsi mov %rax,%rdi callq 1070 <strcpy@plt> mov %r14,%rax add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea -0x1(%rbp),%edi movslq %edi,%rdi callq 1090 <malloc@plt> mov %rax,%r14 test %r13d,%r13d jle 12df <func0+0x156> lea -0x1(%r13),%ecx mov $0x0,%eax movzbl (%rbx,%rax,1),%edx mov %dl,(%r14,%rax,1) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 1258 <func0+0xcf> mov %r13d,%esi lea 0x1(%r13),%eax cmp %eax,%r12d jle 12a1 <func0+0x118> cltq movslq %esi,%rcx movslq %r13d,%rdx sub %rdx,%rcx add %r14,%rcx movzbl (%rbx,%rax,1),%edx mov %dl,-0x1(%rcx,%rax,1) add $0x1,%rax cmp %eax,%r12d jg 1286 <func0+0xfd> lea -0x1(%r12),%eax sub %r13d,%eax add %eax,%esi lea 0x1(%r12),%eax cmp %eax,%ebp jle 12d2 <func0+0x149> cltq movslq %esi,%rcx movslq %r12d,%rdx sub %rdx,%rcx add %r14,%rcx movzbl (%rbx,%rax,1),%edx mov %dl,-0x1(%rcx,%rax,1) add $0x1,%rax cmp %eax,%r15d jg 12b8 <func0+0x12f> mov 0xc(%rsp),%eax sub %r12d,%eax add %eax,%esi movslq %esi,%rsi movb $0x0,(%r14,%rsi,1) jmpq 1226 <func0+0x9d> mov $0x0,%esi jmp 126f <func0+0xe6>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 18h mov rbx, rdi mov ebp, esi call _strlen mov r12, rax test eax, eax jle short loc_1242 mov r15d, eax lea eax, [rax-1] mov [rsp+48h+var_3C], eax mov ecx, eax mov eax, 0 mov r13d, 0FFFFFFFFh mov r14d, 0FFFFFFFFh jmp short loc_1217 loc_120B: lea rdx, [rax+1] cmp rax, rcx jz short loc_122B mov rax, rdx loc_1217: cmp [rbx+rax], bpl jnz short loc_120B mov r13d, eax cmp r14d, 0FFFFFFFFh jnz short loc_120B mov r14d, eax jmp short loc_120B loc_122B: cmp r14d, 0FFFFFFFFh setnz dl cmp r13d, 0FFFFFFFFh setnz al test dl, al jz short loc_1242 cmp r14d, r13d jnz short loc_126F loc_1242: lea edi, [r12+1] movsxd rdi, edi call _malloc mov rbp, rax mov rsi, rbx mov rdi, rax call _strcpy loc_125D: mov rax, rbp add rsp, 18h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_126F: lea edi, [r12-1] movsxd rdi, edi call _malloc mov rbp, rax test r14d, r14d jle loc_1313 mov ecx, r14d mov eax, 0 loc_1290: movzx edx, byte ptr [rbx+rax] mov [rbp+rax+0], dl add rax, 1 cmp rax, rcx jnz short loc_1290 mov esi, r14d loc_12A4: lea eax, [r14+1] cmp r13d, eax jle short loc_12D5 cdqe movsxd rcx, esi movsxd rdx, r14d sub rcx, rdx add rcx, rbp loc_12BB: movzx edx, byte ptr [rbx+rax] mov [rcx+rax-1], dl add rax, 1 cmp r13d, eax jg short loc_12BB lea eax, [r13-1] sub eax, r14d add esi, eax loc_12D5: lea eax, [r13+1] cmp r12d, eax jle short loc_1306 cdqe movsxd rcx, esi movsxd rdx, r13d sub rcx, rdx add rcx, rbp loc_12EC: movzx edx, byte ptr [rbx+rax] mov [rcx+rax-1], dl add rax, 1 cmp r15d, eax jg short loc_12EC mov eax, [rsp+48h+var_3C] sub eax, r13d add esi, eax loc_1306: movsxd rsi, esi mov byte ptr [rbp+rsi+0], 0 jmp loc_125D loc_1313: mov esi, 0 jmp short loc_12A4
long long func0(long long a1, char a2) { int v2; // eax int v3; // r12d int v4; // r15d long long v5; // rcx long long v6; // rax int v7; // r13d int v8; // r14d long long v9; // rbp long long i; // rax int v12; // esi long long v13; // rax long long v14; // rax int v15; // [rsp+Ch] [rbp-3Ch] v2 = strlen(); v3 = v2; if ( v2 <= 0 ) goto LABEL_10; v4 = v2; v15 = v2 - 1; v5 = (unsigned int)(v2 - 1); v6 = 0LL; v7 = -1; v8 = -1; while ( 1 ) { if ( *(_BYTE *)(a1 + v6) == a2 ) { v7 = v6; if ( v8 == -1 ) v8 = v6; } if ( v6 == v5 ) break; ++v6; } if ( v7 != -1 && v8 != -1 && v8 != v7 ) { v9 = malloc(v3 - 1); if ( v8 <= 0 ) { v12 = 0; } else { for ( i = 0LL; i != v8; ++i ) *(_BYTE *)(v9 + i) = *(_BYTE *)(a1 + i); v12 = v8; } LODWORD(v13) = v8 + 1; if ( v7 > v8 + 1 ) { v13 = (int)v13; do { *(_BYTE *)(v9 + v12 - (long long)v8 + v13 - 1) = *(_BYTE *)(a1 + v13); ++v13; } while ( v7 > (int)v13 ); v12 += v7 - 1 - v8; } LODWORD(v14) = v7 + 1; if ( v3 > v7 + 1 ) { v14 = (int)v14; do { *(_BYTE *)(v9 + v12 - (long long)v7 + v14 - 1) = *(_BYTE *)(a1 + v14); ++v14; } while ( v4 > (int)v14 ); v12 += v15 - v7; } *(_BYTE *)(v9 + v12) = 0; } else { LABEL_10: v9 = malloc(v3 + 1); strcpy(v9, a1); } return v9; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x18 MOV RBX,RDI MOV EBP,ESI CALL 0x001010a0 MOV R12,RAX TEST EAX,EAX JLE 0x00101242 MOV R15D,EAX LEA EAX,[RAX + -0x1] MOV dword ptr [RSP + 0xc],EAX MOV ECX,EAX MOV EAX,0x0 MOV R13D,0xffffffff MOV R14D,0xffffffff JMP 0x00101217 LAB_0010120b: LEA RDX,[RAX + 0x1] CMP RAX,RCX JZ 0x0010122b MOV RAX,RDX LAB_00101217: CMP byte ptr [RBX + RAX*0x1],BPL JNZ 0x0010120b MOV R13D,EAX CMP R14D,-0x1 JNZ 0x0010120b MOV R14D,EAX JMP 0x0010120b LAB_0010122b: CMP R14D,-0x1 SETNZ DL CMP R13D,-0x1 SETNZ AL TEST DL,AL JZ 0x00101242 CMP R14D,R13D JNZ 0x0010126f LAB_00101242: LEA EDI,[R12 + 0x1] MOVSXD RDI,EDI CALL 0x001010d0 MOV RBP,RAX MOV RSI,RBX MOV RDI,RAX CALL 0x00101090 LAB_0010125d: MOV RAX,RBP ADD RSP,0x18 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010126f: LEA EDI,[R12 + -0x1] MOVSXD RDI,EDI CALL 0x001010d0 MOV RBP,RAX TEST R14D,R14D JLE 0x00101313 MOV ECX,R14D MOV EAX,0x0 LAB_00101290: MOVZX EDX,byte ptr [RBX + RAX*0x1] MOV byte ptr [RBP + RAX*0x1],DL ADD RAX,0x1 CMP RAX,RCX JNZ 0x00101290 MOV ESI,R14D LAB_001012a4: LEA EAX,[R14 + 0x1] CMP R13D,EAX JLE 0x001012d5 CDQE MOVSXD RCX,ESI MOVSXD RDX,R14D SUB RCX,RDX ADD RCX,RBP LAB_001012bb: MOVZX EDX,byte ptr [RBX + RAX*0x1] MOV byte ptr [RCX + RAX*0x1 + -0x1],DL ADD RAX,0x1 CMP R13D,EAX JG 0x001012bb LEA EAX,[R13 + -0x1] SUB EAX,R14D ADD ESI,EAX LAB_001012d5: LEA EAX,[R13 + 0x1] CMP R12D,EAX JLE 0x00101306 CDQE MOVSXD RCX,ESI MOVSXD RDX,R13D SUB RCX,RDX ADD RCX,RBP LAB_001012ec: MOVZX EDX,byte ptr [RBX + RAX*0x1] MOV byte ptr [RCX + RAX*0x1 + -0x1],DL ADD RAX,0x1 CMP R15D,EAX JG 0x001012ec MOV EAX,dword ptr [RSP + 0xc] SUB EAX,R13D ADD ESI,EAX LAB_00101306: MOVSXD RSI,ESI MOV byte ptr [RBP + RSI*0x1],0x0 JMP 0x0010125d LAB_00101313: MOV ESI,0x0 JMP 0x001012a4
char * func0(char *param_1,char param_2) { int iVar1; size_t sVar2; char *pcVar3; ulong uVar4; long lVar5; uint uVar6; uint uVar7; ulong uVar8; uint uVar9; bool bVar10; sVar2 = strlen(param_1); iVar1 = (int)sVar2; if (0 < iVar1) { uVar8 = 0xffffffff; uVar9 = 0xffffffff; uVar4 = 0; do { if (param_1[uVar4] == param_2) { uVar8 = uVar4 & 0xffffffff; if (uVar9 == 0xffffffff) { uVar9 = (uint)uVar4; } } bVar10 = uVar4 != iVar1 - 1U; uVar4 = uVar4 + 1; } while (bVar10); uVar7 = (uint)uVar8; if ((uVar9 != 0xffffffff && uVar7 != 0xffffffff) && (uVar9 != uVar7)) { pcVar3 = (char *)malloc((long)(iVar1 + -1)); if ((int)uVar9 < 1) { uVar6 = 0; } else { uVar4 = 0; do { pcVar3[uVar4] = param_1[uVar4]; uVar4 = uVar4 + 1; uVar6 = uVar9; } while (uVar4 != uVar9); } if ((int)(uVar9 + 1) < (int)uVar7) { lVar5 = (long)(int)(uVar9 + 1); do { pcVar3[lVar5 + ((long)(int)uVar6 - (long)(int)uVar9) + -1] = param_1[lVar5]; lVar5 = lVar5 + 1; } while ((int)lVar5 < (int)uVar7); uVar6 = uVar6 + ((uVar7 - 1) - uVar9); } if ((int)(uVar7 + 1) < iVar1) { lVar5 = (long)(int)(uVar7 + 1); do { pcVar3[lVar5 + ((long)(int)uVar6 - (long)(int)uVar7) + -1] = param_1[lVar5]; lVar5 = lVar5 + 1; } while ((int)lVar5 < iVar1); uVar6 = uVar6 + ((iVar1 - 1U) - uVar7); } pcVar3[(int)uVar6] = '\0'; return pcVar3; } } pcVar3 = (char *)malloc((long)(iVar1 + 1)); strcpy(pcVar3,param_1); return pcVar3; }
3,938
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(const char *str, char ch) { int len = strlen(str); int first = -1, last = -1; // Find the first and last occurrence of the character for (int i = 0; i < len; i++) { if (str[i] == ch) { if (first == -1) { first = i; // First occurrence } last = i; // Last occurrence (will keep updating) } } // If both occurrences are found and are not the same if (first != -1 && last != -1 && first != last) { // Allocate memory for the new string char *new_str = (char *)malloc(len - 2 + 1); // We remove 2 characters int new_index = 0; // Copy characters before the first occurrence for (int i = 0; i < first; i++) { new_str[new_index++] = str[i]; } // Copy characters between the first and last occurrences for (int i = first + 1; i < last; i++) { new_str[new_index++] = str[i]; } // Copy characters after the last occurrence for (int i = last + 1; i < len; i++) { new_str[new_index++] = str[i]; } new_str[new_index] = '\0'; // Null-terminate the new string return new_str; } // If no valid removals were done, return the original string as a new string char *new_str = (char *)malloc(len + 1); strcpy(new_str, str); return new_str; }
int main() { assert(strcmp(func0("hello",'l'), "heo") == 0); assert(strcmp(func0("abcda",'a'), "bcd") == 0); assert(strcmp(func0("PHP",'P'), "H") == 0); assert(strcmp(func0("hellolloll",'l'), "helollol") == 0); assert(strcmp(func0("",'l'), "") == 0); return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 mov %esi,%r12d push %rbp mov %rdi,%rbp push %rbx sub $0x18,%rsp callq 1080 <strlen@plt> mov %rax,%r13 test %eax,%eax jle 1392 <func0+0x72> lea -0x1(%rax),%esi mov %eax,%edx mov $0xffffffff,%r14d xor %eax,%eax mov %rsi,%r15 mov $0xffffffff,%ebx jmp 1363 <func0+0x43> nopl 0x0(%rax,%rax,1) mov %rcx,%rax cmp %r12b,0x0(%rbp,%rax,1) jne 1373 <func0+0x53> cmp $0xffffffff,%ebx mov %eax,%r14d cmove %eax,%ebx lea 0x1(%rax),%rcx cmp %rsi,%rax jne 1360 <func0+0x40> cmp $0xffffffff,%ebx setne %cl cmp $0xffffffff,%r14d setne %al test %al,%cl je 1392 <func0+0x72> cmp %r14d,%ebx jne 13c8 <func0+0xa8> lea 0x1(%r13),%edi movslq %edi,%rdi callq 10b0 <malloc@plt> lea 0x1(%r13),%rdx mov %rbp,%rsi mov %rax,%rdi callq 10a0 <memcpy@plt> mov %rax,%r8 add $0x18,%rsp mov %r8,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1) movslq %r15d,%rdi mov %edx,0xc(%rsp) callq 10b0 <malloc@plt> test %ebx,%ebx mov 0xc(%rsp),%edx mov %rax,%r8 jle 1487 <func0+0x167> lea -0x1(%rbx),%esi xor %eax,%eax nopl 0x0(%rax,%rax,1) movzbl 0x0(%rbp,%rax,1),%ecx mov %cl,(%r8,%rax,1) mov %rax,%rcx add $0x1,%rax cmp %rcx,%rsi jne 13f0 <func0+0xd0> movslq %ebx,%rdi mov %ebx,%esi lea (%r8,%rdi,1),%rcx lea 0x1(%rbx),%eax cmp %eax,%r14d jle 1449 <func0+0x129> movslq %ebx,%rdi movslq %esi,%rcx cltq sub %rdi,%rcx add %r8,%rcx nopl 0x0(%rax) movzbl 0x0(%rbp,%rax,1),%edi mov %dil,-0x1(%rcx,%rax,1) add $0x1,%rax cmp %eax,%r14d jg 1428 <func0+0x108> lea -0x1(%r14),%eax sub %ebx,%eax add %eax,%esi movslq %esi,%rcx add %r8,%rcx lea 0x1(%r14),%eax cmp %eax,%r13d jle 147f <func0+0x15f> movslq %esi,%rcx movslq %r14d,%rdi cltq sub %rdi,%rcx add %r8,%rcx movzbl 0x0(%rbp,%rax,1),%edi mov %dil,-0x1(%rcx,%rax,1) add $0x1,%rax cmp %eax,%edx jg 1460 <func0+0x140> sub %r14d,%r15d add %r15d,%esi movslq %esi,%rsi lea (%r8,%rsi,1),%rcx movb $0x0,(%rcx) jmpq 13b0 <func0+0x90> mov %rax,%rcx xor %esi,%esi jmp 140e <func0+0xee> xchg %ax,%ax
func0: endbr64 push r15 push r14 push r13 push r12 mov r12d, esi push rbp mov rbp, rdi push rbx sub rsp, 18h call _strlen mov r13, rax test eax, eax jle short loc_13A2 lea ecx, [rax-1] mov r14d, 0FFFFFFFFh xor eax, eax mov ebx, 0FFFFFFFFh mov r15, rcx jmp short loc_1373 loc_1370: mov rax, rdx loc_1373: cmp [rbp+rax+0], r12b jnz short loc_1383 cmp ebx, 0FFFFFFFFh mov r14d, eax cmovz ebx, eax loc_1383: lea rdx, [rax+1] cmp rcx, rax jnz short loc_1370 cmp ebx, 0FFFFFFFFh setnz dl cmp r14d, 0FFFFFFFFh setnz al test dl, al jz short loc_13A2 cmp ebx, r14d jnz short loc_13D8 loc_13A2: lea edi, [r13+1] movsxd rdi, edi call _malloc lea rdx, [r13+1] mov rsi, rbp mov rdi, rax mov r12, rax call _memcpy loc_13C0: add rsp, 18h mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_13D8: movsxd rdi, r15d call _malloc mov r12, rax test ebx, ebx jle loc_1490 movsxd rdx, ebx mov rsi, rbp mov rdi, rax mov [rsp+48h+var_40], rdx call _memcpy mov rdx, [rsp+48h+var_40] mov r8d, ebx lea rax, [r12+rdx] loc_140A: lea ecx, [rbx+1] cmp r14d, ecx jle short loc_1448 lea edx, [r14-2] movsxd rdi, r8d movsxd rcx, ecx mov dword ptr [rsp+48h+var_40], r8d sub edx, ebx add rdi, r12 lea rsi, [rbp+rcx+0] add rdx, 1 call _memcpy mov r8d, dword ptr [rsp+48h+var_40] lea eax, [r14-1] sub eax, ebx add r8d, eax movsxd rax, r8d add rax, r12 loc_1448: lea ecx, [r14+1] cmp r13d, ecx jle short loc_1488 lea edx, [r13-2] movsxd rdi, r8d movsxd rcx, ecx mov dword ptr [rsp+48h+var_40], r8d mov r13d, edx add rdi, r12 lea rsi, [rbp+rcx+0] sub r15d, r14d sub r13d, r14d lea rdx, [r13+1] call _memcpy mov r8d, dword ptr [rsp+48h+var_40] lea eax, [r15+r8] cdqe add rax, r12 loc_1488: mov byte ptr [rax], 0 jmp loc_13C0 loc_1490: xor r8d, r8d jmp loc_140A
long long func0(long long a1, char a2) { int v2; // eax int v3; // r13d long long v4; // rcx int v5; // r14d long long v6; // rax int v7; // ebx int v8; // r15d long long v9; // r12 _BYTE *v11; // rax int v12; // r8d int v13; // [rsp+8h] [rbp-40h] int v14; // [rsp+8h] [rbp-40h] v2 = strlen(); v3 = v2; if ( v2 <= 0 ) goto LABEL_10; v4 = (unsigned int)(v2 - 1); v5 = -1; v6 = 0LL; v7 = -1; v8 = v4; while ( 1 ) { if ( *(_BYTE *)(a1 + v6) == a2 ) { v5 = v6; if ( v7 == -1 ) v7 = v6; } if ( v4 == v6 ) break; ++v6; } if ( v5 != -1 && v7 != -1 && v7 != v5 ) { v11 = (_BYTE *)malloc((int)v4); v9 = (long long)v11; if ( v7 <= 0 ) { v12 = 0; } else { memcpy(v11, a1); v12 = v7; v11 = (_BYTE *)(v9 + v7); } if ( v5 > v7 + 1 ) { v13 = v12; memcpy(v9 + v12, a1 + v7 + 1); v12 = v5 - 1 - v7 + v13; v11 = (_BYTE *)(v9 + v12); } if ( v3 > v5 + 1 ) { v14 = v12; memcpy(v9 + v12, a1 + v5 + 1); v11 = (_BYTE *)(v9 + v8 - v5 + v14); } *v11 = 0; } else { LABEL_10: v9 = malloc(v3 + 1); memcpy(v9, a1); } return v9; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12D,ESI PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x18 CALL 0x00101090 MOV R13,RAX TEST EAX,EAX JLE 0x001013a2 LEA ECX,[RAX + -0x1] MOV R14D,0xffffffff XOR EAX,EAX MOV EBX,0xffffffff MOV R15,RCX JMP 0x00101373 LAB_00101370: MOV RAX,RDX LAB_00101373: CMP byte ptr [RBP + RAX*0x1],R12B JNZ 0x00101383 CMP EBX,-0x1 MOV R14D,EAX CMOVZ EBX,EAX LAB_00101383: LEA RDX,[RAX + 0x1] CMP RCX,RAX JNZ 0x00101370 CMP EBX,-0x1 SETNZ DL CMP R14D,-0x1 SETNZ AL TEST DL,AL JZ 0x001013a2 CMP EBX,R14D JNZ 0x001013d8 LAB_001013a2: LEA EDI,[R13 + 0x1] MOVSXD RDI,EDI CALL 0x001010d0 LEA RDX,[R13 + 0x1] MOV RSI,RBP MOV RDI,RAX MOV R12,RAX CALL 0x001010c0 LAB_001013c0: ADD RSP,0x18 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001013d8: MOVSXD RDI,R15D CALL 0x001010d0 MOV R12,RAX TEST EBX,EBX JLE 0x00101490 MOVSXD RDX,EBX MOV RSI,RBP MOV RDI,RAX MOV qword ptr [RSP + 0x8],RDX CALL 0x001010c0 MOV RDX,qword ptr [RSP + 0x8] MOV R8D,EBX LEA RAX,[R12 + RDX*0x1] LAB_0010140a: LEA ECX,[RBX + 0x1] CMP R14D,ECX JLE 0x00101448 LEA EDX,[R14 + -0x2] MOVSXD RDI,R8D MOVSXD RCX,ECX MOV dword ptr [RSP + 0x8],R8D SUB EDX,EBX ADD RDI,R12 LEA RSI,[RBP + RCX*0x1] ADD RDX,0x1 CALL 0x001010c0 MOV R8D,dword ptr [RSP + 0x8] LEA EAX,[R14 + -0x1] SUB EAX,EBX ADD R8D,EAX MOVSXD RAX,R8D ADD RAX,R12 LAB_00101448: LEA ECX,[R14 + 0x1] CMP R13D,ECX JLE 0x00101488 LEA EDX,[R13 + -0x2] MOVSXD RDI,R8D MOVSXD RCX,ECX MOV dword ptr [RSP + 0x8],R8D MOV R13D,EDX ADD RDI,R12 LEA RSI,[RBP + RCX*0x1] SUB R15D,R14D SUB R13D,R14D LEA RDX,[R13 + 0x1] CALL 0x001010c0 MOV R8D,dword ptr [RSP + 0x8] LEA EAX,[R15 + R8*0x1] CDQE ADD RAX,R12 LAB_00101488: MOV byte ptr [RAX],0x0 JMP 0x001013c0 LAB_00101490: XOR R8D,R8D JMP 0x0010140a
int1 * func0(char *param_1,char param_2) { int iVar1; size_t sVar2; ulong uVar3; int1 *puVar4; int1 *puVar5; uint uVar6; int iVar7; int iVar8; int iVar9; ulong uVar10; bool bVar11; sVar2 = strlen(param_1); iVar1 = (int)sVar2; if (0 < iVar1) { uVar6 = iVar1 - 1; uVar10 = 0xffffffff; iVar7 = -1; uVar3 = 0; do { if (param_1[uVar3] == param_2) { uVar10 = uVar3 & 0xffffffff; if (iVar7 == -1) { iVar7 = (int)uVar3; } } bVar11 = uVar6 != uVar3; uVar3 = uVar3 + 1; } while (bVar11); iVar9 = (int)uVar10; if ((iVar7 != -1 && iVar9 != -1) && (iVar7 != iVar9)) { puVar4 = (int1 *)malloc((long)(int)uVar6); if (iVar7 < 1) { iVar8 = 0; puVar5 = puVar4; } else { memcpy(puVar4,param_1,(long)iVar7); puVar5 = puVar4 + iVar7; iVar8 = iVar7; } if (iVar7 + 1 < iVar9) { memcpy(puVar4 + iVar8,param_1 + (iVar7 + 1),(ulong)(uint)((iVar9 + -2) - iVar7) + 1); iVar8 = iVar8 + ((iVar9 + -1) - iVar7); puVar5 = puVar4 + iVar8; } if (iVar9 + 1 < iVar1) { memcpy(puVar4 + iVar8,param_1 + (iVar9 + 1),(ulong)(uint)((iVar1 + -2) - iVar9) + 1); puVar5 = puVar4 + (int)((uVar6 - iVar9) + iVar8); } *puVar5 = 0; return puVar4; } } puVar4 = (int1 *)malloc((long)(iVar1 + 1)); memcpy(puVar4,param_1,sVar2 + 1); return puVar4; }
3,939
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(const char *str, char ch) { int len = strlen(str); int first = -1, last = -1; // Find the first and last occurrence of the character for (int i = 0; i < len; i++) { if (str[i] == ch) { if (first == -1) { first = i; // First occurrence } last = i; // Last occurrence (will keep updating) } } // If both occurrences are found and are not the same if (first != -1 && last != -1 && first != last) { // Allocate memory for the new string char *new_str = (char *)malloc(len - 2 + 1); // We remove 2 characters int new_index = 0; // Copy characters before the first occurrence for (int i = 0; i < first; i++) { new_str[new_index++] = str[i]; } // Copy characters between the first and last occurrences for (int i = first + 1; i < last; i++) { new_str[new_index++] = str[i]; } // Copy characters after the last occurrence for (int i = last + 1; i < len; i++) { new_str[new_index++] = str[i]; } new_str[new_index] = '\0'; // Null-terminate the new string return new_str; } // If no valid removals were done, return the original string as a new string char *new_str = (char *)malloc(len + 1); strcpy(new_str, str); return new_str; }
int main() { assert(strcmp(func0("hello",'l'), "heo") == 0); assert(strcmp(func0("abcda",'a'), "bcd") == 0); assert(strcmp(func0("PHP",'P'), "H") == 0); assert(strcmp(func0("hellolloll",'l'), "helollol") == 0); assert(strcmp(func0("",'l'), "") == 0); return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 mov %esi,%r12d push %rbp mov %rdi,%rbp push %rbx sub $0x18,%rsp callq 1080 <strlen@plt> mov %rax,%r13 test %eax,%eax jle 1392 <func0+0x72> lea -0x1(%rax),%ecx mov $0xffffffff,%r14d xor %eax,%eax mov $0xffffffff,%ebx mov %rcx,%r15 jmp 1363 <func0+0x43> nopl 0x0(%rax) mov %rdx,%rax cmp 0x0(%rbp,%rax,1),%r12b jne 1373 <func0+0x53> cmp $0xffffffff,%ebx mov %eax,%r14d cmove %eax,%ebx lea 0x1(%rax),%rdx cmp %rax,%rcx jne 1360 <func0+0x40> cmp $0xffffffff,%ebx setne %dl cmp $0xffffffff,%r14d setne %al test %al,%dl je 1392 <func0+0x72> cmp %ebx,%r14d jne 13c8 <func0+0xa8> lea 0x1(%r13),%edi movslq %edi,%rdi callq 10b0 <malloc@plt> lea 0x1(%r13),%rdx mov %rbp,%rsi mov %rax,%rdi mov %rax,%r12 callq 10a0 <memcpy@plt> add $0x18,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1) movslq %r15d,%rdi callq 10b0 <malloc@plt> mov %rax,%r12 test %ebx,%ebx jle 1480 <func0+0x160> lea -0x1(%rbx),%edx mov %rbp,%rsi mov %rax,%rdi add $0x1,%rdx callq 10a0 <memcpy@plt> movslq %ebx,%rax mov %ebx,%r8d add %r12,%rax lea 0x1(%rbx),%edx cmp %edx,%r14d jle 1438 <func0+0x118> lea -0x2(%r14),%r9d movslq %r8d,%rdi movslq %edx,%rdx mov %r8d,0xc(%rsp) sub %ebx,%r9d lea 0x0(%rbp,%rdx,1),%rsi add %r12,%rdi add $0x1,%r9 mov %r9,%rdx callq 10a0 <memcpy@plt> mov 0xc(%rsp),%r8d lea -0x1(%r14),%eax sub %ebx,%eax add %eax,%r8d movslq %r8d,%rax add %r12,%rax lea 0x1(%r14),%ecx cmp %ecx,%r13d jle 1478 <func0+0x158> lea -0x2(%r13),%edx movslq %r8d,%rdi movslq %ecx,%rcx mov %r8d,0xc(%rsp) mov %edx,%r13d add %r12,%rdi lea 0x0(%rbp,%rcx,1),%rsi sub %r14d,%r15d sub %r14d,%r13d lea 0x1(%r13),%rdx callq 10a0 <memcpy@plt> mov 0xc(%rsp),%r8d lea (%r15,%r8,1),%eax cltq add %r12,%rax movb $0x0,(%rax) jmpq 13b0 <func0+0x90> xor %r8d,%r8d jmpq 13f6 <func0+0xd6> nopl 0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 mov r12d, esi push rbp push rbx mov rbx, rdi sub rsp, 18h call _strlen mov r13, rax test eax, eax jle short loc_13C1 lea ecx, [rax-1] mov r14d, 0FFFFFFFFh xor eax, eax mov ebp, 0FFFFFFFFh mov r15, rcx jmp short loc_1393 loc_1390: mov rax, rdx loc_1393: cmp [rbx+rax], r12b jnz short loc_13A2 cmp ebp, 0FFFFFFFFh mov r14d, eax cmovz ebp, eax loc_13A2: lea rdx, [rax+1] cmp rcx, rax jnz short loc_1390 cmp ebp, 0FFFFFFFFh setnz dl cmp r14d, 0FFFFFFFFh setnz al test dl, al jz short loc_13C1 cmp ebp, r14d jnz short loc_1400 loc_13C1: lea ebp, [r13+1] movsxd rbp, ebp mov rdi, rbp; size call _malloc lea rdx, [r13+1] mov rcx, rbp mov rsi, rbx mov rdi, rax mov r12, rax call ___memcpy_chk loc_13E5: add rsp, 18h mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1400: movsxd rdi, r15d; size call _malloc mov r12, rax test ebp, ebp jle loc_14AD mov edx, ebp; n mov rsi, rbx; src mov rdi, rax; dest call _memcpy movsxd rax, ebp mov r8d, ebp add rax, r12 loc_1429: lea ecx, [rbp+1] cmp ecx, r14d jge short loc_1466 lea edx, [r14-2] movsxd rdi, r8d movsxd rcx, ecx mov [rsp+48h+var_3C], r8d sub edx, ebp add rdi, r12; dest lea rsi, [rbx+rcx]; src add rdx, 1; n call _memcpy mov r8d, [rsp+48h+var_3C] lea eax, [r14-1] sub eax, ebp add r8d, eax movsxd rax, r8d add rax, r12 loc_1466: lea ecx, [r14+1] cmp r13d, ecx jle short loc_14A5 lea edx, [r13-2] movsxd rdi, r8d movsxd rcx, ecx mov [rsp+48h+var_3C], r8d mov r13d, edx add rdi, r12; dest lea rsi, [rbx+rcx]; src sub r15d, r14d sub r13d, r14d lea rdx, [r13+1]; n call _memcpy mov r8d, [rsp+48h+var_3C] lea eax, [r15+r8] cdqe add rax, r12 loc_14A5: mov byte ptr [rax], 0 jmp loc_13E5 loc_14AD: xor r8d, r8d jmp loc_1429
char * func0(const char *src, char a2) { size_t v2; // rax size_t v3; // r13 long long v4; // rcx int v5; // r14d long long v6; // rax int v7; // ebp int v8; // r15d char *v9; // r12 char *v11; // rax int v12; // r8d int v13; // [rsp+Ch] [rbp-3Ch] int v14; // [rsp+Ch] [rbp-3Ch] v2 = strlen(src); v3 = v2; if ( (int)v2 <= 0 ) goto LABEL_10; v4 = (unsigned int)(v2 - 1); v5 = -1; v6 = 0LL; v7 = -1; v8 = v4; while ( 1 ) { if ( src[v6] == a2 ) { v5 = v6; if ( v7 == -1 ) v7 = v6; } if ( v4 == v6 ) break; ++v6; } if ( v5 != -1 && v7 != -1 && v7 != v5 ) { v11 = (char *)malloc((int)v4); v9 = v11; if ( v7 <= 0 ) { v12 = 0; } else { memcpy(v11, src, (unsigned int)v7); v12 = v7; v11 = &v9[v7]; } if ( v7 + 1 < v5 ) { v13 = v12; memcpy(&v9[v12], &src[v7 + 1], (unsigned int)(v5 - 2 - v7) + 1LL); v12 = v5 - 1 - v7 + v13; v11 = &v9[v12]; } if ( (int)v3 > v5 + 1 ) { v14 = v12; memcpy(&v9[v12], &src[v5 + 1], (unsigned int)(v3 - 2 - v5) + 1LL); v11 = &v9[v8 - v5 + v14]; } *v11 = 0; } else { LABEL_10: v9 = (char *)malloc((int)v3 + 1); __memcpy_chk(v9, src, v3 + 1, (int)v3 + 1); } return v9; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12D,ESI PUSH RBP PUSH RBX MOV RBX,RDI SUB RSP,0x18 CALL 0x001010a0 MOV R13,RAX TEST EAX,EAX JLE 0x001013c1 LEA ECX,[RAX + -0x1] MOV R14D,0xffffffff XOR EAX,EAX MOV EBP,0xffffffff MOV R15,RCX JMP 0x00101393 LAB_00101390: MOV RAX,RDX LAB_00101393: CMP byte ptr [RBX + RAX*0x1],R12B JNZ 0x001013a2 CMP EBP,-0x1 MOV R14D,EAX CMOVZ EBP,EAX LAB_001013a2: LEA RDX,[RAX + 0x1] CMP RCX,RAX JNZ 0x00101390 CMP EBP,-0x1 SETNZ DL CMP R14D,-0x1 SETNZ AL TEST DL,AL JZ 0x001013c1 CMP EBP,R14D JNZ 0x00101400 LAB_001013c1: LEA EBP,[R13 + 0x1] MOVSXD RBP,EBP MOV RDI,RBP CALL 0x001010f0 LEA RDX,[R13 + 0x1] MOV RCX,RBP MOV RSI,RBX MOV RDI,RAX MOV R12,RAX CALL 0x001010d0 LAB_001013e5: ADD RSP,0x18 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101400: MOVSXD RDI,R15D CALL 0x001010f0 MOV R12,RAX TEST EBP,EBP JLE 0x001014ad MOV EDX,EBP MOV RSI,RBX MOV RDI,RAX CALL 0x001010e0 MOVSXD RAX,EBP MOV R8D,EBP ADD RAX,R12 LAB_00101429: LEA ECX,[RBP + 0x1] CMP ECX,R14D JGE 0x00101466 LEA EDX,[R14 + -0x2] MOVSXD RDI,R8D MOVSXD RCX,ECX MOV dword ptr [RSP + 0xc],R8D SUB EDX,EBP ADD RDI,R12 LEA RSI,[RBX + RCX*0x1] ADD RDX,0x1 CALL 0x001010e0 MOV R8D,dword ptr [RSP + 0xc] LEA EAX,[R14 + -0x1] SUB EAX,EBP ADD R8D,EAX MOVSXD RAX,R8D ADD RAX,R12 LAB_00101466: LEA ECX,[R14 + 0x1] CMP R13D,ECX JLE 0x001014a5 LEA EDX,[R13 + -0x2] MOVSXD RDI,R8D MOVSXD RCX,ECX MOV dword ptr [RSP + 0xc],R8D MOV R13D,EDX ADD RDI,R12 LEA RSI,[RBX + RCX*0x1] SUB R15D,R14D SUB R13D,R14D LEA RDX,[R13 + 0x1] CALL 0x001010e0 MOV R8D,dword ptr [RSP + 0xc] LEA EAX,[R15 + R8*0x1] CDQE ADD RAX,R12 LAB_001014a5: MOV byte ptr [RAX],0x0 JMP 0x001013e5 LAB_001014ad: XOR R8D,R8D JMP 0x00101429
int * func0(char *param_1,char param_2) { int iVar1; size_t sVar2; ulong uVar3; int *puVar4; int *puVar5; uint uVar6; uint uVar7; uint uVar8; uint uVar9; ulong uVar10; bool bVar11; sVar2 = strlen(param_1); iVar1 = (int)sVar2; if (0 < iVar1) { uVar6 = iVar1 - 1; uVar10 = 0xffffffff; uVar7 = 0xffffffff; uVar3 = 0; do { if (param_1[uVar3] == param_2) { uVar10 = uVar3 & 0xffffffff; if (uVar7 == 0xffffffff) { uVar7 = (uint)uVar3; } } bVar11 = uVar6 != uVar3; uVar3 = uVar3 + 1; } while (bVar11); uVar9 = (uint)uVar10; if ((uVar7 != 0xffffffff && uVar9 != 0xffffffff) && (uVar7 != uVar9)) { puVar4 = (int *)malloc((long)(int)uVar6); if ((int)uVar7 < 1) { uVar8 = 0; puVar5 = puVar4; } else { memcpy(puVar4,param_1,(ulong)uVar7); puVar5 = puVar4 + (int)uVar7; uVar8 = uVar7; } if ((int)(uVar7 + 1) < (int)uVar9) { memcpy(puVar4 + (int)uVar8,param_1 + (int)(uVar7 + 1),(ulong)((uVar9 - 2) - uVar7) + 1); uVar8 = uVar8 + ((uVar9 - 1) - uVar7); puVar5 = puVar4 + (int)uVar8; } if ((int)(uVar9 + 1) < iVar1) { memcpy(puVar4 + (int)uVar8,param_1 + (int)(uVar9 + 1),(ulong)((iVar1 + -2) - uVar9) + 1); puVar5 = puVar4 + (int)((uVar6 - uVar9) + uVar8); } *puVar5 = 0; return puVar4; } } puVar4 = (int *)malloc((long)(iVar1 + 1)); __memcpy_chk(puVar4,param_1,sVar2 + 1,(long)(iVar1 + 1)); return puVar4; }
3,940
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> int sum(const int *row, int cols) { int total = 0; for (int i = 0; i < cols; i++) { total += row[i]; } return total; } int compare(const void *a, const void *b, void *cols) { int sum_a = sum(*(const int **)a, *(int *)cols); int sum_b = sum(*(const int **)b, *(int *)cols); return (sum_a > sum_b) - (sum_a < sum_b); }
void func0(int **M, int rows, int cols) { qsort_r(M, rows, sizeof(int *), compare, &cols); }
int main() { int rows1 = 3, cols1 =3; int row1[] = {1, 2, 3}, row2[] = {2, 4, 5}, row3[] = {1, 1, 1}; int *matrix1[] = {row1, row2, row3}; func0(matrix1, rows1, cols1); assert(matrix1[0][0] == 1 && matrix1[0][1] == 1 && matrix1[0][2] == 1); assert(matrix1[1][0] == 1 && matrix1[1][1] == 2 && matrix1[1][2] == 3); assert(matrix1[2][0] == 2 && matrix1[2][1] == 4 && matrix1[2][2] == 5); int row4[] = {1, 2, 3}, row5[] = {-2, 4, -5}, row6[] = {1, -1, 1}; int *matrix2[] = {row4, row5, row6}; func0(matrix2, rows1, cols1); assert(matrix2[0][0] == -2 && matrix2[0][1] == 4 && matrix2[0][2] == -5); assert(matrix2[1][0] == 1 && matrix2[1][1] == -1 && matrix2[1][2] == 1); assert(matrix2[2][0] == 1 && matrix2[2][1] == 2 && matrix2[2][2] == 3); int row7[] = {5, 8, 9}, row8[] = {6, 4, 3}, row9[] = {2, 1, 4}; int *matrix3[] = {row7, row8, row9}; func0(matrix3, rows1, cols1); assert(matrix3[0][0] == 2 && matrix3[0][1] == 1 && matrix3[0][2] == 4); assert(matrix3[1][0] == 6 && matrix3[1][1] == 4 && matrix3[1][2] == 3); assert(matrix3[2][0] == 5 && matrix3[2][1] == 8 && matrix3[2][2] == 9); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %rdi,-0x8(%rbp) mov %esi,-0xc(%rbp) mov %edx,-0x10(%rbp) lea -0x10(%rbp),%rdx mov -0xc(%rbp),%esi mov -0x8(%rbp),%rax mov %rdx,%r8 lea -0x95(%rip),%rcx mov $0x8,%edx mov %rax,%rdi mov $0x0,%eax callq 1090 <qsort_r@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov [rbp+nmemb+4], rdi mov dword ptr [rbp+nmemb], esi mov [rbp+arg], edx lea rdx, [rbp+arg] mov esi, dword ptr [rbp+nmemb]; nmemb mov rax, [rbp+nmemb+4] mov r8, rdx; arg lea rdx, compare mov rcx, rdx; compar mov edx, 8; size mov rdi, rax; base mov eax, 0 call _qsort_r nop leave retn
void func0(void *a1, unsigned int a2, int a3) { _DWORD arg[2]; // [rsp+0h] [rbp-10h] BYREF void *nmemb_4; // [rsp+8h] [rbp-8h] nmemb_4 = a1; arg[1] = a2; arg[0] = a3; qsort_r(a1, a2, 8uLL, compare, arg); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV qword ptr [RBP + -0x8],RDI MOV dword ptr [RBP + -0xc],ESI MOV dword ptr [RBP + -0x10],EDX LEA RDX,[RBP + -0x10] MOV ESI,dword ptr [RBP + -0xc] MOV RAX,qword ptr [RBP + -0x8] MOV R8,RDX LEA RDX,[0x1011d2] MOV RCX,RDX MOV EDX,0x8 MOV RDI,RAX MOV EAX,0x0 CALL 0x00101090 NOP LEAVE RET
void func0(void *param_1,uint param_2,int4 param_3) { int4 local_18; uint local_14; void *local_10; local_18 = param_3; local_14 = param_2; local_10 = param_1; qsort_r(param_1,(ulong)param_2,8,compare,&local_18); return; }
3,941
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> int sum(const int *row, int cols) { int total = 0; for (int i = 0; i < cols; i++) { total += row[i]; } return total; } int compare(const void *a, const void *b, void *cols) { int sum_a = sum(*(const int **)a, *(int *)cols); int sum_b = sum(*(const int **)b, *(int *)cols); return (sum_a > sum_b) - (sum_a < sum_b); }
void func0(int **M, int rows, int cols) { qsort_r(M, rows, sizeof(int *), compare, &cols); }
int main() { int rows1 = 3, cols1 =3; int row1[] = {1, 2, 3}, row2[] = {2, 4, 5}, row3[] = {1, 1, 1}; int *matrix1[] = {row1, row2, row3}; func0(matrix1, rows1, cols1); assert(matrix1[0][0] == 1 && matrix1[0][1] == 1 && matrix1[0][2] == 1); assert(matrix1[1][0] == 1 && matrix1[1][1] == 2 && matrix1[1][2] == 3); assert(matrix1[2][0] == 2 && matrix1[2][1] == 4 && matrix1[2][2] == 5); int row4[] = {1, 2, 3}, row5[] = {-2, 4, -5}, row6[] = {1, -1, 1}; int *matrix2[] = {row4, row5, row6}; func0(matrix2, rows1, cols1); assert(matrix2[0][0] == -2 && matrix2[0][1] == 4 && matrix2[0][2] == -5); assert(matrix2[1][0] == 1 && matrix2[1][1] == -1 && matrix2[1][2] == 1); assert(matrix2[2][0] == 1 && matrix2[2][1] == 2 && matrix2[2][2] == 3); int row7[] = {5, 8, 9}, row8[] = {6, 4, 3}, row9[] = {2, 1, 4}; int *matrix3[] = {row7, row8, row9}; func0(matrix3, rows1, cols1); assert(matrix3[0][0] == 2 && matrix3[0][1] == 1 && matrix3[0][2] == 4); assert(matrix3[1][0] == 6 && matrix3[1][1] == 4 && matrix3[1][2] == 3); assert(matrix3[2][0] == 5 && matrix3[2][1] == 8 && matrix3[2][2] == 9); return 0; }
O1
c
func0: endbr64 sub $0x18,%rsp mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 lea -0x56(%rip),%rcx mov $0x8,%edx mov $0x0,%eax callq 1090 <qsort_r@plt> add $0x18,%rsp retq
func0: endbr64 sub rsp, 18h mov [rsp+18h+var_C], edx lea r8, [rsp+18h+var_C] lea rcx, compare mov edx, 8 mov eax, 0 call _qsort_r add rsp, 18h retn
long long func0(long long a1, long long a2, int a3) { _DWORD v4[3]; // [rsp+Ch] [rbp-Ch] BYREF v4[0] = a3; return qsort_r(a1, a2, 8LL, compare, v4); }
func0: ENDBR64 SUB RSP,0x18 MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] LEA RCX,[0x1011b6] MOV EDX,0x8 MOV EAX,0x0 CALL 0x00101090 ADD RSP,0x18 RET
void func0(void *param_1,size_t param_2,int4 param_3) { int4 local_c [3]; local_c[0] = param_3; qsort_r(param_1,param_2,8,compare,local_c); return; }
3,942
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> int sum(const int *row, int cols) { int total = 0; for (int i = 0; i < cols; i++) { total += row[i]; } return total; } int compare(const void *a, const void *b, void *cols) { int sum_a = sum(*(const int **)a, *(int *)cols); int sum_b = sum(*(const int **)b, *(int *)cols); return (sum_a > sum_b) - (sum_a < sum_b); }
void func0(int **M, int rows, int cols) { qsort_r(M, rows, sizeof(int *), compare, &cols); }
int main() { int rows1 = 3, cols1 =3; int row1[] = {1, 2, 3}, row2[] = {2, 4, 5}, row3[] = {1, 1, 1}; int *matrix1[] = {row1, row2, row3}; func0(matrix1, rows1, cols1); assert(matrix1[0][0] == 1 && matrix1[0][1] == 1 && matrix1[0][2] == 1); assert(matrix1[1][0] == 1 && matrix1[1][1] == 2 && matrix1[1][2] == 3); assert(matrix1[2][0] == 2 && matrix1[2][1] == 4 && matrix1[2][2] == 5); int row4[] = {1, 2, 3}, row5[] = {-2, 4, -5}, row6[] = {1, -1, 1}; int *matrix2[] = {row4, row5, row6}; func0(matrix2, rows1, cols1); assert(matrix2[0][0] == -2 && matrix2[0][1] == 4 && matrix2[0][2] == -5); assert(matrix2[1][0] == 1 && matrix2[1][1] == -1 && matrix2[1][2] == 1); assert(matrix2[2][0] == 1 && matrix2[2][1] == 2 && matrix2[2][2] == 3); int row7[] = {5, 8, 9}, row8[] = {6, 4, 3}, row9[] = {2, 1, 4}; int *matrix3[] = {row7, row8, row9}; func0(matrix3, rows1, cols1); assert(matrix3[0][0] == 2 && matrix3[0][1] == 1 && matrix3[0][2] == 4); assert(matrix3[1][0] == 6 && matrix3[1][1] == 4 && matrix3[1][2] == 3); assert(matrix3[2][0] == 5 && matrix3[2][1] == 8 && matrix3[2][2] == 9); return 0; }
O2
c
func0: endbr64 sub $0x18,%rsp lea -0xaf(%rip),%rcx xor %eax,%eax mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 mov $0x8,%edx callq 1090 <qsort_r@plt> add $0x18,%rsp retq nopl 0x0(%rax)
func0: endbr64 sub rsp, 18h lea rcx, compare xor eax, eax mov [rsp+18h+var_C], edx lea r8, [rsp+18h+var_C] mov edx, 8 call _qsort_r add rsp, 18h retn
long long func0(long long a1, long long a2, int a3) { _DWORD v4[3]; // [rsp+Ch] [rbp-Ch] BYREF v4[0] = a3; return qsort_r(a1, a2, 8LL, compare, v4); }
func0: ENDBR64 SUB RSP,0x18 LEA RCX,[0x1015e0] XOR EAX,EAX MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] MOV EDX,0x8 CALL 0x00101090 ADD RSP,0x18 RET
void func0(void *param_1,size_t param_2,int4 param_3) { int4 local_c [3]; local_c[0] = param_3; qsort_r(param_1,param_2,8,compare,local_c); return; }
3,943
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> int sum(const int *row, int cols) { int total = 0; for (int i = 0; i < cols; i++) { total += row[i]; } return total; } int compare(const void *a, const void *b, void *cols) { int sum_a = sum(*(const int **)a, *(int *)cols); int sum_b = sum(*(const int **)b, *(int *)cols); return (sum_a > sum_b) - (sum_a < sum_b); }
void func0(int **M, int rows, int cols) { qsort_r(M, rows, sizeof(int *), compare, &cols); }
int main() { int rows1 = 3, cols1 =3; int row1[] = {1, 2, 3}, row2[] = {2, 4, 5}, row3[] = {1, 1, 1}; int *matrix1[] = {row1, row2, row3}; func0(matrix1, rows1, cols1); assert(matrix1[0][0] == 1 && matrix1[0][1] == 1 && matrix1[0][2] == 1); assert(matrix1[1][0] == 1 && matrix1[1][1] == 2 && matrix1[1][2] == 3); assert(matrix1[2][0] == 2 && matrix1[2][1] == 4 && matrix1[2][2] == 5); int row4[] = {1, 2, 3}, row5[] = {-2, 4, -5}, row6[] = {1, -1, 1}; int *matrix2[] = {row4, row5, row6}; func0(matrix2, rows1, cols1); assert(matrix2[0][0] == -2 && matrix2[0][1] == 4 && matrix2[0][2] == -5); assert(matrix2[1][0] == 1 && matrix2[1][1] == -1 && matrix2[1][2] == 1); assert(matrix2[2][0] == 1 && matrix2[2][1] == 2 && matrix2[2][2] == 3); int row7[] = {5, 8, 9}, row8[] = {6, 4, 3}, row9[] = {2, 1, 4}; int *matrix3[] = {row7, row8, row9}; func0(matrix3, rows1, cols1); assert(matrix3[0][0] == 2 && matrix3[0][1] == 1 && matrix3[0][2] == 4); assert(matrix3[1][0] == 6 && matrix3[1][1] == 4 && matrix3[1][2] == 3); assert(matrix3[2][0] == 5 && matrix3[2][1] == 8 && matrix3[2][2] == 9); return 0; }
O3
c
func0: endbr64 sub $0x18,%rsp lea -0x22f(%rip),%rcx xor %eax,%eax mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 mov $0x8,%edx callq 1090 <qsort_r@plt> add $0x18,%rsp retq nopl 0x0(%rax)
func0: endbr64 sub rsp, 18h lea rcx, compare; compar xor eax, eax mov [rsp+18h+arg], edx lea r8, [rsp+18h+arg]; arg mov edx, 8; size call _qsort_r add rsp, 18h retn
void func0(void *a1, size_t a2, int a3) { _DWORD arg[3]; // [rsp+Ch] [rbp-Ch] BYREF arg[0] = a3; qsort_r(a1, a2, 8uLL, compare, arg); }
func0: ENDBR64 SUB RSP,0x18 LEA RCX,[0x101620] XOR EAX,EAX MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] MOV EDX,0x8 CALL 0x00101090 ADD RSP,0x18 RET
void func0(void *param_1,size_t param_2,int4 param_3) { int4 local_c [3]; local_c[0] = param_3; qsort_r(param_1,param_2,8,compare,local_c); return; }
3,944
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define MAX_WORDS 100 #define MAX_WORD_LENGTH 50 typedef struct { char word[MAX_WORD_LENGTH]; int count; } WordCount;
void func0(char words[][MAX_WORD_LENGTH], int num_words, WordCount result[], int *result_size) { WordCount counts[MAX_WORDS] = {0}; int unique_words = 0; // Count each word for (int i = 0; i < num_words; i++) { int found = 0; for (int j = 0; j < unique_words; j++) { if (strcmp(words[i], counts[j].word) == 0) { counts[j].count++; found = 1; break; } } if (!found) { strcpy(counts[unique_words].word, words[i]); counts[unique_words].count = 1; unique_words++; } } // Simple sorting (selection sort) to get top 4 for (int i=0; i < 4 && i < unique_words; i++) { int max_idx = i; for (int j=i+1; j < unique_words; j++) { if (counts[j].count > counts[max_idx].count) { max_idx = j; } } // Swap max element with the i-th position WordCount tmp = counts[i]; counts[i] = counts[max_idx]; counts[max_idx] = tmp; // Copy to results strcpy(result[i].word, counts[i].word); result[i].count = counts[i].count; } *result_size = unique_words > 4 ? 4 : unique_words; }
int main() { WordCount result[4]; int result_size; char data1[][MAX_WORD_LENGTH] = {"red","green","black","pink","black","white","black","eyes","white","black","orange","pink","pink","red","red","white","orange","white","black","pink","green","green","pink","green","pink","white","orange","orange","red"}; func0(data1, 29, result, &result_size); assert(strcmp(result[0].word, "pink") == 0 && result[0].count == 6); assert(strcmp(result[1].word, "black") == 0 && result[1].count == 5); assert(strcmp(result[2].word, "white") == 0 && result[2].count == 5); assert(strcmp(result[3].word, "red") == 0 && result[3].count == 4); char data2[][MAX_WORD_LENGTH] = {"one", "two", "three", "four", "five", "one", "two", "one", "three", "one"}; func0(data2, 10, result, &result_size); assert(strcmp(result[0].word, "one") == 0 && result[0].count == 4); assert(strcmp(result[1].word, "two") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "three") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "four") == 0 && result[3].count == 1); char data3[][MAX_WORD_LENGTH] = {"Facebook", "Apple", "Amazon", "Netflix", "Google", "Apple", "Netflix", "Amazon"}; func0(data3, 8, result, &result_size); assert(strcmp(result[0].word, "Apple") == 0 && result[0].count == 2); assert(strcmp(result[1].word, "Amazon") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "Netflix") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "Facebook") == 0 && result[3].count == 1); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x1000,%rsp orq $0x0,(%rsp) sub $0x678,%rsp mov %rdi,-0x1668(%rbp) mov %esi,-0x166c(%rbp) mov %rdx,-0x1678(%rbp) mov %rcx,-0x1680(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax lea -0x1600(%rbp),%rdx mov $0x0,%eax mov $0x2bc,%ecx mov %rdx,%rdi rep stos %rax,%es:(%rdi) movl $0x0,-0x165c(%rbp) movl $0x0,-0x1658(%rbp) jmpq 13aa <func0+0x201> movl $0x0,-0x1654(%rbp) movl $0x0,-0x1650(%rbp) jmpq 12f8 <func0+0x14f> lea -0x1600(%rbp),%rcx mov -0x1650(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax add %rax,%rcx mov -0x1658(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x2,%rax add %rdx,%rax lea 0x0(,%rax,4),%rdx add %rdx,%rax add %rax,%rax mov %rax,%rdx mov -0x1668(%rbp),%rax add %rdx,%rax mov %rcx,%rsi mov %rax,%rdi callq 10b0 <strcmp@plt> test %eax,%eax jne 12f1 <func0+0x148> mov -0x1650(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rbx add %rbx,%rax sub $0x15bc,%rax mov (%rax),%eax lea 0x1(%rax),%ecx mov -0x1650(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rbx add %rbx,%rax sub $0x15bc,%rax mov %ecx,(%rax) movl $0x1,-0x1654(%rbp) jmp 130a <func0+0x161> addl $0x1,-0x1650(%rbp) mov -0x1650(%rbp),%eax cmp -0x165c(%rbp),%eax jl 1238 <func0+0x8f> cmpl $0x0,-0x1654(%rbp) jne 13a3 <func0+0x1fa> mov -0x1658(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x2,%rax add %rdx,%rax lea 0x0(,%rax,4),%rdx add %rdx,%rax add %rax,%rax mov %rax,%rdx mov -0x1668(%rbp),%rax lea (%rdx,%rax,1),%rcx lea -0x1600(%rbp),%rsi mov -0x165c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax add %rsi,%rax mov %rcx,%rsi mov %rax,%rdi callq 1080 <strcpy@plt> mov -0x165c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rbx add %rbx,%rax sub $0x15bc,%rax movl $0x1,(%rax) addl $0x1,-0x165c(%rbp) addl $0x1,-0x1658(%rbp) mov -0x1658(%rbp),%eax cmp -0x166c(%rbp),%eax jl 121f <func0+0x76> movl $0x0,-0x164c(%rbp) jmpq 165d <func0+0x4b4> mov -0x164c(%rbp),%eax mov %eax,-0x1648(%rbp) mov -0x164c(%rbp),%eax add $0x1,%eax mov %eax,-0x1644(%rbp) jmp 144b <func0+0x2a2> mov -0x1644(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rsi add %rsi,%rax sub $0x15bc,%rax mov (%rax),%ecx mov -0x1648(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rdi add %rdi,%rax sub $0x15bc,%rax mov (%rax),%eax cmp %eax,%ecx jle 1444 <func0+0x29b> mov -0x1644(%rbp),%eax mov %eax,-0x1648(%rbp) addl $0x1,-0x1644(%rbp) mov -0x1644(%rbp),%eax cmp -0x165c(%rbp),%eax jl 13e8 <func0+0x23f> mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rbx add %rbx,%rax sub $0x15f0,%rax mov (%rax),%rcx mov 0x8(%rax),%rbx mov %rcx,-0x1640(%rbp) mov %rbx,-0x1638(%rbp) mov 0x10(%rax),%rcx mov 0x18(%rax),%rbx mov %rcx,-0x1630(%rbp) mov %rbx,-0x1628(%rbp) mov 0x20(%rax),%rcx mov 0x28(%rax),%rbx mov %rcx,-0x1620(%rbp) mov %rbx,-0x1618(%rbp) mov 0x30(%rax),%rax mov %rax,-0x1610(%rbp) mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rsi add %rsi,%rax lea -0x15f0(%rax),%rdx mov -0x1648(%rbp),%eax movslq %eax,%rcx mov %rcx,%rax shl $0x3,%rax sub %rcx,%rax shl $0x3,%rax lea -0x10(%rbp),%rdi add %rdi,%rax sub $0x15f0,%rax mov (%rax),%rcx mov 0x8(%rax),%rbx mov %rcx,(%rdx) mov %rbx,0x8(%rdx) mov 0x10(%rax),%rcx mov 0x18(%rax),%rbx mov %rcx,0x10(%rdx) mov %rbx,0x18(%rdx) mov 0x20(%rax),%rcx mov 0x28(%rax),%rbx mov %rcx,0x20(%rdx) mov %rbx,0x28(%rdx) mov 0x30(%rax),%rax mov %rax,0x30(%rdx) mov -0x1648(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rbx add %rbx,%rax sub $0x15f0,%rax mov -0x1640(%rbp),%rcx mov -0x1638(%rbp),%rbx mov %rcx,(%rax) mov %rbx,0x8(%rax) mov -0x1630(%rbp),%rcx mov -0x1628(%rbp),%rbx mov %rcx,0x10(%rax) mov %rbx,0x18(%rax) mov -0x1620(%rbp),%rcx mov -0x1618(%rbp),%rbx mov %rcx,0x20(%rax) mov %rbx,0x28(%rax) mov -0x1610(%rbp),%rdx mov %rdx,0x30(%rax) lea -0x1600(%rbp),%rcx mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax add %rax,%rcx mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax mov %rax,%rdx mov -0x1678(%rbp),%rax add %rdx,%rax mov %rcx,%rsi mov %rax,%rdi callq 1080 <strcpy@plt> mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax mov %rax,%rdx mov -0x1678(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x164c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax shl $0x3,%rax sub %rdx,%rax shl $0x3,%rax lea -0x10(%rbp),%rsi add %rsi,%rax sub $0x15bc,%rax mov (%rax),%eax mov %eax,0x34(%rcx) addl $0x1,-0x164c(%rbp) cmpl $0x3,-0x164c(%rbp) jg 1678 <func0+0x4cf> mov -0x164c(%rbp),%eax cmp -0x165c(%rbp),%eax jl 13cb <func0+0x222> mov $0x4,%eax cmpl $0x4,-0x165c(%rbp) cmovle -0x165c(%rbp),%eax mov %eax,%edx mov -0x1680(%rbp),%rax mov %edx,(%rax) mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 16ab <func0+0x502> callq 1090 <__stack_chk_fail@plt> add $0x1678,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 1000h or [rsp+1008h+var_1008], 0 sub rsp, 678h mov [rbp+var_1668], rdi mov [rbp+var_166C], esi mov [rbp+var_1678], rdx mov [rbp+var_1680], rcx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax lea rdx, [rbp+var_1600] mov eax, 0 mov ecx, 2BCh mov rdi, rdx rep stosq mov [rbp+var_165C], 0 mov [rbp+var_1658], 0 jmp loc_13AA loc_121F: mov [rbp+var_1654], 0 mov [rbp+var_1650], 0 jmp loc_12F8 loc_1238: lea rcx, [rbp+var_1600] mov eax, [rbp+var_1650] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 add rcx, rax mov eax, [rbp+var_1658] movsxd rdx, eax mov rax, rdx shl rax, 2 add rax, rdx lea rdx, ds:0[rax*4] add rax, rdx add rax, rax mov rdx, rax mov rax, [rbp+var_1668] add rax, rdx mov rsi, rcx; s2 mov rdi, rax; s1 call _strcmp test eax, eax jnz short loc_12F1 mov eax, [rbp+var_1650] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov eax, [rax] lea ecx, [rax+1] mov eax, [rbp+var_1650] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov [rax], ecx mov [rbp+var_1654], 1 jmp short loc_130A loc_12F1: add [rbp+var_1650], 1 loc_12F8: mov eax, [rbp+var_1650] cmp eax, [rbp+var_165C] jl loc_1238 loc_130A: cmp [rbp+var_1654], 0 jnz loc_13A3 mov eax, [rbp+var_1658] movsxd rdx, eax mov rax, rdx shl rax, 2 add rax, rdx lea rdx, ds:0[rax*4] add rax, rdx add rax, rax mov rdx, rax mov rax, [rbp+var_1668] lea rcx, [rdx+rax] lea rsi, [rbp+var_1600] mov eax, [rbp+var_165C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 add rax, rsi mov rsi, rcx; src mov rdi, rax; dest call _strcpy mov eax, [rbp+var_165C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov dword ptr [rax], 1 add [rbp+var_165C], 1 loc_13A3: add [rbp+var_1658], 1 loc_13AA: mov eax, [rbp+var_1658] cmp eax, [rbp+var_166C] jl loc_121F mov [rbp+var_164C], 0 jmp loc_165D loc_13CB: mov eax, [rbp+var_164C] mov [rbp+var_1648], eax mov eax, [rbp+var_164C] add eax, 1 mov [rbp+var_1644], eax jmp short loc_144B loc_13E8: mov eax, [rbp+var_1644] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov ecx, [rax] mov eax, [rbp+var_1648] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov eax, [rax] cmp ecx, eax jle short loc_1444 mov eax, [rbp+var_1644] mov [rbp+var_1648], eax loc_1444: add [rbp+var_1644], 1 loc_144B: mov eax, [rbp+var_1644] cmp eax, [rbp+var_165C] jl short loc_13E8 mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15F0h mov rcx, [rax] mov rbx, [rax+8] mov [rbp+var_1640], rcx mov [rbp+var_1638], rbx mov rcx, [rax+10h] mov rbx, [rax+18h] mov [rbp+var_1630], rcx mov [rbp+var_1628], rbx mov rcx, [rax+20h] mov rbx, [rax+28h] mov [rbp+var_1620], rcx mov [rbp+var_1618], rbx mov rax, [rax+30h] mov [rbp+var_1610], rax mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp lea rdx, [rax-15F0h] mov eax, [rbp+var_1648] movsxd rcx, eax mov rax, rcx shl rax, 3 sub rax, rcx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15F0h mov rcx, [rax] mov rbx, [rax+8] mov [rdx], rcx mov [rdx+8], rbx mov rcx, [rax+10h] mov rbx, [rax+18h] mov [rdx+10h], rcx mov [rdx+18h], rbx mov rcx, [rax+20h] mov rbx, [rax+28h] mov [rdx+20h], rcx mov [rdx+28h], rbx mov rax, [rax+30h] mov [rdx+30h], rax mov eax, [rbp+var_1648] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15F0h mov rcx, [rbp+var_1640] mov rbx, [rbp+var_1638] mov [rax], rcx mov [rax+8], rbx mov rcx, [rbp+var_1630] mov rbx, [rbp+var_1628] mov [rax+10h], rcx mov [rax+18h], rbx mov rcx, [rbp+var_1620] mov rbx, [rbp+var_1618] mov [rax+20h], rcx mov [rax+28h], rbx mov rdx, [rbp+var_1610] mov [rax+30h], rdx lea rcx, [rbp+var_1600] mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 add rcx, rax mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 mov rdx, rax mov rax, [rbp+var_1678] add rax, rdx mov rsi, rcx; src mov rdi, rax; dest call _strcpy mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 mov rdx, rax mov rax, [rbp+var_1678] lea rcx, [rdx+rax] mov eax, [rbp+var_164C] movsxd rdx, eax mov rax, rdx shl rax, 3 sub rax, rdx shl rax, 3 lea rax, [rax-10h] add rax, rbp sub rax, 15BCh mov eax, [rax] mov [rcx+34h], eax add [rbp+var_164C], 1 loc_165D: cmp [rbp+var_164C], 3 jg short loc_1678 mov eax, [rbp+var_164C] cmp eax, [rbp+var_165C] jl loc_13CB loc_1678: mov eax, [rbp+var_165C] mov edx, 4 cmp eax, edx cmovle edx, eax mov rax, [rbp+var_1680] mov [rax], edx nop mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_16A6 call ___stack_chk_fail loc_16A6: mov rbx, [rbp+var_8] leave retn
unsigned long long func0(long long a1, int a2, long long a3, int *a4) { _QWORD *v4; // rdx _QWORD *v5; // rax long long v6; // rbx long long v7; // rbx long long v8; // rbx int v9; // edx int v13; // [rsp+24h] [rbp-165Ch] int i; // [rsp+28h] [rbp-1658h] int v15; // [rsp+2Ch] [rbp-1654h] int j; // [rsp+30h] [rbp-1650h] int k; // [rsp+34h] [rbp-164Ch] int v18; // [rsp+38h] [rbp-1648h] int m; // [rsp+3Ch] [rbp-1644h] long long v20; // [rsp+40h] [rbp-1640h] long long v21; // [rsp+48h] [rbp-1638h] long long v22; // [rsp+50h] [rbp-1630h] long long v23; // [rsp+58h] [rbp-1628h] long long v24; // [rsp+60h] [rbp-1620h] long long v25; // [rsp+68h] [rbp-1618h] long long v26; // [rsp+70h] [rbp-1610h] _QWORD v27[701]; // [rsp+80h] [rbp-1600h] BYREF unsigned long long v28; // [rsp+1668h] [rbp-18h] v28 = __readfsqword(0x28u); memset(v27, 0, 0x15E0uLL); v13 = 0; for ( i = 0; i < a2; ++i ) { v15 = 0; for ( j = 0; j < v13; ++j ) { if ( !strcmp((const char *)(50LL * i + a1), (const char *)&v27[7 * j]) ) { ++HIDWORD(v27[7 * j + 6]); v15 = 1; break; } } if ( !v15 ) { strcpy((char *)&v27[7 * v13], (const char *)(50LL * i + a1)); HIDWORD(v27[7 * v13++ + 6]) = 1; } } for ( k = 0; k <= 3 && k < v13; ++k ) { v18 = k; for ( m = k + 1; m < v13; ++m ) { if ( SHIDWORD(v27[7 * m + 6]) > SHIDWORD(v27[7 * v18 + 6]) ) v18 = m; } v20 = v27[7 * k]; v21 = v27[7 * k + 1]; v22 = v27[7 * k + 2]; v23 = v27[7 * k + 3]; v24 = v27[7 * k + 4]; v25 = v27[7 * k + 5]; v26 = v27[7 * k + 6]; v4 = &v27[7 * k]; v5 = &v27[7 * v18]; v6 = v5[1]; *v4 = *v5; v4[1] = v6; v7 = v5[3]; v4[2] = v27[7 * v18 + 2]; v4[3] = v7; v8 = v5[5]; v4[4] = v5[4]; v4[5] = v8; v4[6] = v5[6]; *v5 = v20; v5[1] = v21; v5[2] = v22; v5[3] = v23; v5[4] = v24; v5[5] = v25; v5[6] = v26; strcpy((char *)(56LL * k + a3), (const char *)&v27[7 * k]); *(_DWORD *)(56LL * k + a3 + 52) = HIDWORD(v27[7 * k + 6]); } v9 = 4; if ( v13 <= 4 ) v9 = v13; *a4 = v9; return v28 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x1000 OR qword ptr [RSP],0x0 SUB RSP,0x678 MOV qword ptr [RBP + -0x1668],RDI MOV dword ptr [RBP + -0x166c],ESI MOV qword ptr [RBP + -0x1678],RDX MOV qword ptr [RBP + -0x1680],RCX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX LEA RDX,[RBP + -0x1600] MOV EAX,0x0 MOV ECX,0x2bc MOV RDI,RDX STOSQ.REP RDI MOV dword ptr [RBP + -0x165c],0x0 MOV dword ptr [RBP + -0x1658],0x0 JMP 0x001013aa LAB_0010121f: MOV dword ptr [RBP + -0x1654],0x0 MOV dword ptr [RBP + -0x1650],0x0 JMP 0x001012f8 LAB_00101238: LEA RCX,[RBP + -0x1600] MOV EAX,dword ptr [RBP + -0x1650] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 ADD RCX,RAX MOV EAX,dword ptr [RBP + -0x1658] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x2 ADD RAX,RDX LEA RDX,[RAX*0x4] ADD RAX,RDX ADD RAX,RAX MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x1668] ADD RAX,RDX MOV RSI,RCX MOV RDI,RAX CALL 0x001010b0 TEST EAX,EAX JNZ 0x001012f1 MOV EAX,dword ptr [RBP + -0x1650] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV EAX,dword ptr [RAX] LEA ECX,[RAX + 0x1] MOV EAX,dword ptr [RBP + -0x1650] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV dword ptr [RAX],ECX MOV dword ptr [RBP + -0x1654],0x1 JMP 0x0010130a LAB_001012f1: ADD dword ptr [RBP + -0x1650],0x1 LAB_001012f8: MOV EAX,dword ptr [RBP + -0x1650] CMP EAX,dword ptr [RBP + -0x165c] JL 0x00101238 LAB_0010130a: CMP dword ptr [RBP + -0x1654],0x0 JNZ 0x001013a3 MOV EAX,dword ptr [RBP + -0x1658] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x2 ADD RAX,RDX LEA RDX,[RAX*0x4] ADD RAX,RDX ADD RAX,RAX MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x1668] LEA RCX,[RDX + RAX*0x1] LEA RSI,[RBP + -0x1600] MOV EAX,dword ptr [RBP + -0x165c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 ADD RAX,RSI MOV RSI,RCX MOV RDI,RAX CALL 0x00101080 MOV EAX,dword ptr [RBP + -0x165c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV dword ptr [RAX],0x1 ADD dword ptr [RBP + -0x165c],0x1 LAB_001013a3: ADD dword ptr [RBP + -0x1658],0x1 LAB_001013aa: MOV EAX,dword ptr [RBP + -0x1658] CMP EAX,dword ptr [RBP + -0x166c] JL 0x0010121f MOV dword ptr [RBP + -0x164c],0x0 JMP 0x0010165d LAB_001013cb: MOV EAX,dword ptr [RBP + -0x164c] MOV dword ptr [RBP + -0x1648],EAX MOV EAX,dword ptr [RBP + -0x164c] ADD EAX,0x1 MOV dword ptr [RBP + -0x1644],EAX JMP 0x0010144b LAB_001013e8: MOV EAX,dword ptr [RBP + -0x1644] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV ECX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x1648] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV EAX,dword ptr [RAX] CMP ECX,EAX JLE 0x00101444 MOV EAX,dword ptr [RBP + -0x1644] MOV dword ptr [RBP + -0x1648],EAX LAB_00101444: ADD dword ptr [RBP + -0x1644],0x1 LAB_0010144b: MOV EAX,dword ptr [RBP + -0x1644] CMP EAX,dword ptr [RBP + -0x165c] JL 0x001013e8 MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15f0 MOV RCX,qword ptr [RAX] MOV RBX,qword ptr [RAX + 0x8] MOV qword ptr [RBP + -0x1640],RCX MOV qword ptr [RBP + -0x1638],RBX MOV RCX,qword ptr [RAX + 0x10] MOV RBX,qword ptr [RAX + 0x18] MOV qword ptr [RBP + -0x1630],RCX MOV qword ptr [RBP + -0x1628],RBX MOV RCX,qword ptr [RAX + 0x20] MOV RBX,qword ptr [RAX + 0x28] MOV qword ptr [RBP + -0x1620],RCX MOV qword ptr [RBP + -0x1618],RBX MOV RAX,qword ptr [RAX + 0x30] MOV qword ptr [RBP + -0x1610],RAX MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP LEA RDX,[RAX + -0x15f0] MOV EAX,dword ptr [RBP + -0x1648] MOVSXD RCX,EAX MOV RAX,RCX SHL RAX,0x3 SUB RAX,RCX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15f0 MOV RCX,qword ptr [RAX] MOV RBX,qword ptr [RAX + 0x8] MOV qword ptr [RDX],RCX MOV qword ptr [RDX + 0x8],RBX MOV RCX,qword ptr [RAX + 0x10] MOV RBX,qword ptr [RAX + 0x18] MOV qword ptr [RDX + 0x10],RCX MOV qword ptr [RDX + 0x18],RBX MOV RCX,qword ptr [RAX + 0x20] MOV RBX,qword ptr [RAX + 0x28] MOV qword ptr [RDX + 0x20],RCX MOV qword ptr [RDX + 0x28],RBX MOV RAX,qword ptr [RAX + 0x30] MOV qword ptr [RDX + 0x30],RAX MOV EAX,dword ptr [RBP + -0x1648] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15f0 MOV RCX,qword ptr [RBP + -0x1640] MOV RBX,qword ptr [RBP + -0x1638] MOV qword ptr [RAX],RCX MOV qword ptr [RAX + 0x8],RBX MOV RCX,qword ptr [RBP + -0x1630] MOV RBX,qword ptr [RBP + -0x1628] MOV qword ptr [RAX + 0x10],RCX MOV qword ptr [RAX + 0x18],RBX MOV RCX,qword ptr [RBP + -0x1620] MOV RBX,qword ptr [RBP + -0x1618] MOV qword ptr [RAX + 0x20],RCX MOV qword ptr [RAX + 0x28],RBX MOV RDX,qword ptr [RBP + -0x1610] MOV qword ptr [RAX + 0x30],RDX LEA RCX,[RBP + -0x1600] MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 ADD RCX,RAX MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x1678] ADD RAX,RDX MOV RSI,RCX MOV RDI,RAX CALL 0x00101080 MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x1678] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x164c] MOVSXD RDX,EAX MOV RAX,RDX SHL RAX,0x3 SUB RAX,RDX SHL RAX,0x3 LEA RAX,[RAX + -0x10] ADD RAX,RBP SUB RAX,0x15bc MOV EAX,dword ptr [RAX] MOV dword ptr [RCX + 0x34],EAX ADD dword ptr [RBP + -0x164c],0x1 LAB_0010165d: CMP dword ptr [RBP + -0x164c],0x3 JG 0x00101678 MOV EAX,dword ptr [RBP + -0x164c] CMP EAX,dword ptr [RBP + -0x165c] JL 0x001013cb LAB_00101678: MOV EAX,dword ptr [RBP + -0x165c] MOV EDX,0x4 CMP EAX,EDX CMOVLE EDX,EAX MOV RAX,qword ptr [RBP + -0x1680] MOV dword ptr [RAX],EDX NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001016a6 CALL 0x00101090 LAB_001016a6: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
void func0(long param_1,int param_2,long param_3,int *param_4) { int8 uVar1; int8 uVar2; int8 uVar3; int8 uVar4; int8 uVar5; int8 uVar6; int8 uVar7; int8 uVar8; bool bVar9; int iVar10; long lVar11; long lVar12; long lVar13; long lVar14; char *pcVar15; long in_FS_OFFSET; int local_1664; int local_1660; int local_1658; int local_1654; int local_1650; int local_164c; char local_1608 [8]; char acStack_1600 [8]; char acStack_15f8 [8]; char acStack_15f0 [8]; char acStack_15e8 [8]; char acStack_15e0 [8]; int8 uStack_15d8; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); pcVar15 = local_1608; for (lVar11 = 700; lVar11 != 0; lVar11 = lVar11 + -1) { pcVar15[0] = '\0'; pcVar15[1] = '\0'; pcVar15[2] = '\0'; pcVar15[3] = '\0'; pcVar15[4] = '\0'; pcVar15[5] = '\0'; pcVar15[6] = '\0'; pcVar15[7] = '\0'; pcVar15 = pcVar15 + 8; } local_1664 = 0; local_1660 = 0; do { if (param_2 <= local_1660) { for (local_1654 = 0; (local_1654 < 4 && (local_1654 < local_1664)); local_1654 = local_1654 + 1) { local_1650 = local_1654; local_164c = local_1654; while (local_164c = local_164c + 1, local_164c < local_1664) { if (*(int *)((long)&uStack_15d8 + (long)local_1650 * 0x38 + 4) < *(int *)((long)&uStack_15d8 + (long)local_164c * 0x38 + 4)) { local_1650 = local_164c; } } lVar13 = (long)local_1654; lVar11 = lVar13 * 0x38; uVar1 = *(int8 *)(acStack_1600 + (lVar13 * 7 + -1) * 8); uVar2 = *(int8 *)(acStack_1600 + lVar13 * 0x38); uVar3 = *(int8 *)(acStack_1600 + lVar11 + 8); uVar4 = *(int8 *)(acStack_1600 + lVar11 + 0x10); uVar5 = *(int8 *)(acStack_1600 + lVar11 + 0x18); uVar6 = *(int8 *)(acStack_1600 + lVar11 + 0x20); uVar7 = (&uStack_15d8)[lVar13 * 7]; lVar14 = (long)local_1654; lVar11 = lVar14 * 0x38; lVar12 = (long)local_1650; lVar13 = lVar12 * 0x38; uVar8 = *(int8 *)(acStack_1600 + lVar12 * 0x38); *(int8 *)(acStack_1600 + (lVar14 * 7 + -1) * 8) = *(int8 *)(acStack_1600 + (lVar12 * 7 + -1) * 8); *(int8 *)(acStack_1600 + lVar14 * 0x38) = uVar8; uVar8 = *(int8 *)(acStack_1600 + lVar13 + 0x10); *(int8 *)(acStack_1600 + lVar11 + 8) = *(int8 *)(acStack_1600 + lVar13 + 8); *(int8 *)(acStack_1600 + lVar11 + 0x10) = uVar8; uVar8 = *(int8 *)(acStack_1600 + lVar13 + 0x20); *(int8 *)(acStack_1600 + lVar11 + 0x18) = *(int8 *)(acStack_1600 + lVar13 + 0x18); *(int8 *)(acStack_1600 + lVar11 + 0x20) = uVar8; (&uStack_15d8)[lVar14 * 7] = (&uStack_15d8)[lVar12 * 7]; lVar13 = (long)local_1650; lVar11 = lVar13 * 0x38; *(int8 *)(acStack_1600 + (lVar13 * 7 + -1) * 8) = uVar1; *(int8 *)(acStack_1600 + lVar13 * 0x38) = uVar2; *(int8 *)(acStack_1600 + lVar11 + 8) = uVar3; *(int8 *)(acStack_1600 + lVar11 + 0x10) = uVar4; *(int8 *)(acStack_1600 + lVar11 + 0x18) = uVar5; *(int8 *)(acStack_1600 + lVar11 + 0x20) = uVar6; (&uStack_15d8)[lVar13 * 7] = uVar7; strcpy((char *)(param_3 + (long)local_1654 * 0x38), acStack_1600 + ((long)local_1654 * 7 + -1) * 8); *(int4 *)((long)local_1654 * 0x38 + param_3 + 0x34) = *(int4 *)((long)&uStack_15d8 + (long)local_1654 * 0x38 + 4); } iVar10 = 4; if (local_1664 < 5) { iVar10 = local_1664; } *param_4 = iVar10; if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); } bVar9 = false; for (local_1658 = 0; local_1658 < local_1664; local_1658 = local_1658 + 1) { iVar10 = strcmp((char *)(param_1 + (long)local_1660 * 0x32), acStack_1600 + ((long)local_1658 * 7 + -1) * 8); if (iVar10 == 0) { *(int *)((long)&uStack_15d8 + (long)local_1658 * 0x38 + 4) = *(int *)((long)&uStack_15d8 + (long)local_1658 * 0x38 + 4) + 1; bVar9 = true; break; } } if (!bVar9) { strcpy(acStack_1600 + ((long)local_1664 * 7 + -1) * 8, (char *)((long)local_1660 * 0x32 + param_1)); *(int4 *)((long)&uStack_15d8 + (long)local_1664 * 0x38 + 4) = 1; local_1664 = local_1664 + 1; } local_1660 = local_1660 + 1; } while( true ); }
3,945
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define MAX_WORDS 100 #define MAX_WORD_LENGTH 50 typedef struct { char word[MAX_WORD_LENGTH]; int count; } WordCount;
void func0(char words[][MAX_WORD_LENGTH], int num_words, WordCount result[], int *result_size) { WordCount counts[MAX_WORDS] = {0}; int unique_words = 0; // Count each word for (int i = 0; i < num_words; i++) { int found = 0; for (int j = 0; j < unique_words; j++) { if (strcmp(words[i], counts[j].word) == 0) { counts[j].count++; found = 1; break; } } if (!found) { strcpy(counts[unique_words].word, words[i]); counts[unique_words].count = 1; unique_words++; } } // Simple sorting (selection sort) to get top 4 for (int i=0; i < 4 && i < unique_words; i++) { int max_idx = i; for (int j=i+1; j < unique_words; j++) { if (counts[j].count > counts[max_idx].count) { max_idx = j; } } // Swap max element with the i-th position WordCount tmp = counts[i]; counts[i] = counts[max_idx]; counts[max_idx] = tmp; // Copy to results strcpy(result[i].word, counts[i].word); result[i].count = counts[i].count; } *result_size = unique_words > 4 ? 4 : unique_words; }
int main() { WordCount result[4]; int result_size; char data1[][MAX_WORD_LENGTH] = {"red","green","black","pink","black","white","black","eyes","white","black","orange","pink","pink","red","red","white","orange","white","black","pink","green","green","pink","green","pink","white","orange","orange","red"}; func0(data1, 29, result, &result_size); assert(strcmp(result[0].word, "pink") == 0 && result[0].count == 6); assert(strcmp(result[1].word, "black") == 0 && result[1].count == 5); assert(strcmp(result[2].word, "white") == 0 && result[2].count == 5); assert(strcmp(result[3].word, "red") == 0 && result[3].count == 4); char data2[][MAX_WORD_LENGTH] = {"one", "two", "three", "four", "five", "one", "two", "one", "three", "one"}; func0(data2, 10, result, &result_size); assert(strcmp(result[0].word, "one") == 0 && result[0].count == 4); assert(strcmp(result[1].word, "two") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "three") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "four") == 0 && result[3].count == 1); char data3[][MAX_WORD_LENGTH] = {"Facebook", "Apple", "Amazon", "Netflix", "Google", "Apple", "Netflix", "Amazon"}; func0(data3, 8, result, &result_size); assert(strcmp(result[0].word, "Apple") == 0 && result[0].count == 2); assert(strcmp(result[1].word, "Amazon") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "Netflix") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "Facebook") == 0 && result[3].count == 1); return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x1000,%rsp orq $0x0,(%rsp) sub $0x658,%rsp mov %rdi,%r8 mov %rdx,0x10(%rsp) mov %rcx,0x18(%rsp) mov %fs:0x28,%rax mov %rax,0x1648(%rsp) xor %eax,%eax lea 0x60(%rsp),%rdi mov $0x2bc,%ecx rep stos %rax,%es:(%rdi) test %esi,%esi jle 13e6 <func0+0x23d> mov %r8,%r14 lea -0x1(%rsi),%eax lea (%rax,%rax,4),%rax lea (%rax,%rax,4),%rax lea 0x32(%r8,%rax,2),%r15 mov $0x0,%r12d lea 0x60(%rsp),%rax mov %rax,0x8(%rsp) jmp 128a <func0+0xe1> movslq %ebx,%rbx lea 0x0(,%rbx,8),%rax mov %rax,%rdx sub %rbx,%rdx mov 0x94(%rsp,%rdx,8),%eax add $0x1,%eax mov %eax,0x94(%rsp,%rdx,8) jmp 1281 <func0+0xd8> movslq %r12d,%rbp lea 0x0(,%rbp,8),%rbx mov %rbx,%rax sub %rbp,%rax mov 0x8(%rsp),%rcx lea (%rcx,%rax,8),%rdi mov $0x32,%edx mov %r14,%rsi callq 10b0 <__strcpy_chk@plt> sub %rbp,%rbx movl $0x1,0x94(%rsp,%rbx,8) add $0x1,%r12d add $0x32,%r14 cmp %r15,%r14 je 12bd <func0+0x114> mov %r14,%r13 lea 0x60(%rsp),%rbp mov $0x0,%ebx test %r12d,%r12d jle 1248 <func0+0x9f> mov %rbp,%rsi mov %r13,%rdi callq 10a0 <strcmp@plt> test %eax,%eax je 1224 <func0+0x7b> add $0x1,%ebx add $0x38,%rbp cmp %r12d,%ebx jne 129c <func0+0xf3> jmp 1248 <func0+0x9f> test %r12d,%r12d jle 1490 <func0+0x2e7> lea 0x60(%rsp),%rbx mov 0x10(%rsp),%r13 mov $0x0,%ebp jmpq 13ab <func0+0x202> mov (%rbx),%r14 mov 0x8(%rbx),%r15 mov %r14,0x20(%rsp) mov %r15,0x28(%rsp) mov 0x10(%rbx),%r10 mov 0x18(%rbx),%r11 mov %r10,0x30(%rsp) mov %r11,0x38(%rsp) mov 0x20(%rbx),%r8 mov 0x28(%rbx),%r9 mov %r8,0x40(%rsp) mov %r9,0x48(%rsp) mov 0x30(%rbx),%rdi mov %rdi,0x50(%rsp) movslq %ecx,%rcx lea 0x0(,%rcx,8),%rax mov %rax,%rdx sub %rcx,%rdx shl $0x3,%rdx lea 0x60(%rsp,%rdx,1),%rsi movdqu 0x60(%rsp,%rdx,1),%xmm0 movups %xmm0,(%rbx) movdqu 0x10(%rsi),%xmm1 movups %xmm1,0x10(%rbx) movdqu 0x20(%rsi),%xmm2 movups %xmm2,0x20(%rbx) mov 0x30(%rsi),%rdx mov %rdx,0x30(%rbx) sub %rcx,%rax shl $0x3,%rax mov %r14,0x60(%rsp,%rax,1) mov %r15,0x68(%rsp,%rax,1) mov %r10,0x10(%rsi) mov %r11,0x18(%rsi) mov %r8,0x20(%rsi) mov %r9,0x28(%rsi) mov %rdi,0x30(%rsi) mov $0x32,%edx mov %rbx,%rsi mov %r13,%rdi callq 10b0 <__strcpy_chk@plt> mov 0x34(%rbx),%eax mov %eax,0x34(%r13) add $0x38,%rbx add $0x38,%r13 cmp $0x3,%ebp jg 1490 <func0+0x2e7> cmp %ebp,%r12d jle 1490 <func0+0x2e7> mov %ebp,%ecx add $0x1,%ebp cmp %ebp,%r12d je 13f1 <func0+0x248> mov %rbx,%rsi mov %ebp,%eax movslq %ecx,%rdi lea 0x0(,%rdi,8),%rdx sub %rdi,%rdx mov 0x94(%rsp,%rdx,8),%edi cmp %edi,0x6c(%rsi) cmovg %eax,%ecx add $0x1,%eax add $0x38,%rsi cmp %eax,%r12d jne 13ba <func0+0x211> jmpq 12da <func0+0x131> mov $0x0,%r12d jmpq 1490 <func0+0x2e7> movslq %ecx,%rbp lea 0x0(,%rbp,8),%rbx mov %rbx,%rax sub %rbp,%rax shl $0x3,%rax lea 0x60(%rsp,%rax,1),%rdx mov 0x60(%rsp,%rax,1),%r10 mov 0x68(%rsp,%rax,1),%r11 mov %r10,0x20(%rsp) mov %r11,0x28(%rsp) mov 0x10(%rdx),%r8 mov 0x18(%rdx),%r9 mov %r8,0x30(%rsp) mov %r9,0x38(%rsp) mov 0x20(%rdx),%rsi mov 0x28(%rdx),%rdi mov %rsi,0x40(%rsp) mov %rdi,0x48(%rsp) mov 0x30(%rdx),%rcx mov %rcx,0x50(%rsp) mov %r8,0x10(%rdx) mov %r9,0x18(%rdx) mov %rsi,0x20(%rdx) mov %rdi,0x28(%rdx) mov %rcx,0x30(%rdx) mov %rbx,%rax sub %rbp,%rax shl $0x3,%rax mov 0x10(%rsp),%r13 add %rax,%r13 mov %rdx,%rsi mov $0x32,%edx mov %r13,%rdi callq 10b0 <__strcpy_chk@plt> sub %rbp,%rbx mov 0x94(%rsp,%rbx,8),%eax mov %eax,0x34(%r13) cmp $0x4,%r12d mov $0x4,%eax cmovg %eax,%r12d mov 0x18(%rsp),%rax mov %r12d,(%rax) mov 0x1648(%rsp),%rax xor %fs:0x28,%rax jne 14ca <func0+0x321> add $0x1658,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq callq 1080 <__stack_chk_fail@plt>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 1000h or [rsp+1030h+var_1030], 0 sub rsp, 658h mov r8, rdi mov [rsp+1688h+var_1678], rdx mov [rsp+1688h+var_1670], rcx mov rax, fs:28h mov [rsp+1688h+var_40], rax xor eax, eax lea rdi, [rsp+1688h+var_1628] mov ecx, 2BCh rep stosq test esi, esi jle loc_13F6 mov r13, r8 lea eax, [rsi-1] lea rax, [rax+rax*4] lea rax, [rax+rax*4] lea r14, [r8+rax*2+32h] mov r15d, 0 lea rax, [rsp+1688h+var_1628] mov [rsp+1688h+var_1680], rax jmp short loc_128A loc_1224: movsxd rbx, ebx lea rax, ds:0[rbx*8] mov rdx, rax sub rdx, rbx mov eax, [rsp+rdx*8+1688h+var_15F4] add eax, 1 mov [rsp+rdx*8+1688h+var_15F4], eax jmp short loc_1281 loc_1248: movsxd rbp, r15d lea rbx, ds:0[rbp*8] mov rax, rbx sub rax, rbp mov rdi, [rsp+1688h+var_1680] lea rdi, [rdi+rax*8] mov edx, 32h ; '2' mov rsi, r13 call ___strcpy_chk sub rbx, rbp mov [rsp+rbx*8+1688h+var_15F4], 1 add r15d, 1 loc_1281: add r13, 32h ; '2' cmp r13, r14 jz short loc_12BD loc_128A: mov r12, r13 lea rbp, [rsp+1688h+var_1628] mov ebx, 0 test r15d, r15d jle short loc_1248 loc_129C: mov rsi, rbp mov rdi, r12 call _strcmp test eax, eax jz loc_1224 add ebx, 1 add rbp, 38h ; '8' cmp ebx, r15d jnz short loc_129C jmp short loc_1248 loc_12BD: test r15d, r15d jle loc_1401 lea r12, [rsp+1688h+var_1628] mov r14, [rsp+1688h+var_1678] mov r13d, 0 jmp loc_13D2 loc_12DB: mov ebx, ebp loc_12DD: movsxd rsi, edx lea rax, ds:0[rsi*8] sub rax, rsi mov eax, [rsp+rax*8+1688h+var_15F4] cmp [rcx+6Ch], eax cmovg edx, ebx lea ebp, [rbx+1] add rcx, 38h ; '8' cmp r15d, ebp jnz short loc_12DB movdqu xmm0, xmmword ptr [r12] movaps [rsp+1688h+var_1668], xmm0 mov r10, [r12+10h] mov r11, [r12+18h] mov [rsp+1688h+var_1658], r10 mov [rsp+1688h+var_1650], r11 mov r8, [r12+20h] mov r9, [r12+28h] mov [rsp+1688h+var_1648], r8 mov [rsp+1688h+var_1640], r9 mov rdi, [r12+30h] mov [rsp+1688h+var_1638], rdi movsxd rdx, edx lea rax, ds:0[rdx*8] mov rcx, rax sub rcx, rdx shl rcx, 3 lea rsi, [rsp+rcx+1688h+var_1628] movdqu xmm1, [rsp+rcx+1688h+var_1628] movups xmmword ptr [r12], xmm1 movdqu xmm2, xmmword ptr [rsi+10h] movups xmmword ptr [r12+10h], xmm2 movdqu xmm3, xmmword ptr [rsi+20h] movups xmmword ptr [r12+20h], xmm3 mov rcx, [rsi+30h] mov [r12+30h], rcx sub rax, rdx shl rax, 3 movups [rsp+rax+1688h+var_1628], xmm0 mov [rsi+10h], r10 mov [rsi+18h], r11 mov [rsi+20h], r8 mov [rsi+28h], r9 mov [rsi+30h], rdi mov edx, 32h ; '2' mov rsi, r12 mov rdi, r14 call ___strcpy_chk mov eax, [r12+34h] mov [r14+34h], eax add r12, 38h ; '8' add r14, 38h ; '8' cmp r13d, 3 jg short loc_13EE cmp dword ptr [rsp+1688h+var_1680], ebx jge short loc_13EE loc_13D2: mov edx, r13d mov dword ptr [rsp+1688h+var_1680], r13d add r13d, 1 cmp r15d, r13d jz short loc_1409 mov rcx, r12 mov ebx, r13d jmp loc_12DD loc_13EE: mov r13d, ebp jmp loc_14AB loc_13F6: mov r13d, 0 jmp loc_14AB loc_1401: mov r13d, r15d jmp loc_14AB loc_1409: movsxd r15, dword ptr [rsp+1688h+var_1680] lea rbx, ds:0[r15*8] mov rax, rbx sub rax, r15 shl rax, 3 lea rdx, [rsp+rax+1688h+var_1628] mov r10, qword ptr [rsp+rax+1688h+var_1628] mov r11, qword ptr [rsp+rax+1688h+var_1628+8] mov qword ptr [rsp+1688h+var_1668], r10 mov qword ptr [rsp+1688h+var_1668+8], r11 mov r8, [rdx+10h] mov r9, [rdx+18h] mov [rsp+1688h+var_1658], r8 mov [rsp+1688h+var_1650], r9 mov rsi, [rdx+20h] mov rdi, [rdx+28h] mov [rsp+1688h+var_1648], rsi mov [rsp+1688h+var_1640], rdi mov rcx, [rdx+30h] mov [rsp+1688h+var_1638], rcx mov [rdx+10h], r8 mov [rdx+18h], r9 mov [rdx+20h], rsi mov [rdx+28h], rdi mov [rdx+30h], rcx mov rax, rbx sub rax, r15 shl rax, 3 mov r12, [rsp+1688h+var_1678] add r12, rax mov rsi, rdx mov edx, 32h ; '2' mov rdi, r12 call ___strcpy_chk sub rbx, r15 mov eax, [rsp+rbx*8+1688h+var_15F4] mov [r12+34h], eax loc_14AB: mov eax, 4 cmp r13d, eax cmovle eax, r13d mov rdi, [rsp+1688h+var_1670] mov [rdi], eax mov rax, [rsp+1688h+var_40] sub rax, fs:28h jnz short loc_14E3 add rsp, 1658h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_14E3: call ___stack_chk_fail
unsigned long long func0(long long a1, int a2, long long a3, int *a4) { long long v4; // r13 int v5; // r15d _OWORD *v6; // rbp int v7; // ebx __m128i *v8; // r12 long long v9; // r14 int v10; // r13d int i; // ebx int v12; // edx __m128i *v13; // rcx long long v14; // r10 long long v15; // r8 long long v16; // rdi __m128i *v17; // rsi _QWORD *v18; // rdx long long v19; // rsi long long v20; // rcx int v21; // eax int v23; // [rsp+8h] [rbp-1680h] __m128i v26; // [rsp+20h] [rbp-1668h] long long v27; // [rsp+38h] [rbp-1650h] long long v28; // [rsp+38h] [rbp-1650h] long long v29; // [rsp+48h] [rbp-1640h] long long v30; // [rsp+48h] [rbp-1640h] _OWORD v31[350]; // [rsp+60h] [rbp-1628h] BYREF unsigned long long v32; // [rsp+1648h] [rbp-40h] v32 = __readfsqword(0x28u); memset(v31, 0, sizeof(v31)); if ( a2 <= 0 ) { v10 = 0; } else { v4 = a1; v5 = 0; do { v6 = v31; v7 = 0; if ( v5 <= 0 ) { LABEL_4: __strcpy_chk((char *)v31 + 56 * v5, v4, 50LL); *((_DWORD *)&v31[3] + 14 * v5++ + 1) = 1; } else { while ( (unsigned int)strcmp(v4, v6) ) { ++v7; v6 = (_OWORD *)((char *)v6 + 56); if ( v7 == v5 ) goto LABEL_4; } ++*((_DWORD *)&v31[3] + 14 * v7 + 1); } v4 += 50LL; } while ( v4 != a1 + 50LL * (unsigned int)(a2 - 1) + 50 ); if ( v5 <= 0 ) { v10 = v5; } else { v8 = (__m128i *)v31; v9 = a3; v10 = 0; while ( 1 ) { v12 = v10; v23 = v10++; if ( v5 == v10 ) break; v13 = v8; for ( i = v10; ; ++i ) { if ( v13[6].m128i_i32[3] > *((_DWORD *)&v31[3] + 14 * v12 + 1) ) v12 = i; v13 = (__m128i *)((char *)v13 + 56); if ( v5 == i + 1 ) break; } v26 = _mm_loadu_si128(v8); v14 = v8[1].m128i_i64[0]; v27 = v8[1].m128i_i64[1]; v15 = v8[2].m128i_i64[0]; v29 = v8[2].m128i_i64[1]; v16 = v8[3].m128i_i64[0]; v17 = (__m128i *)((char *)v31 + 56 * v12); *v8 = _mm_loadu_si128(v17); v8[1] = _mm_loadu_si128(v17 + 1); v8[2] = _mm_loadu_si128(v17 + 2); v8[3].m128i_i64[0] = v17[3].m128i_i64[0]; *v17 = v26; v17[1].m128i_i64[0] = v14; v17[1].m128i_i64[1] = v27; v17[2].m128i_i64[0] = v15; v17[2].m128i_i64[1] = v29; v17[3].m128i_i64[0] = v16; __strcpy_chk(v9, v8, 50LL); *(_DWORD *)(v9 + 52) = v8[3].m128i_i32[1]; v8 = (__m128i *)((char *)v8 + 56); v9 += 56LL; if ( v10 > 3 || v23 >= i ) { v10 = i + 1; goto LABEL_24; } } v18 = (_QWORD *)v31 + 7 * v23; v28 = v18[3]; v19 = v18[4]; v30 = v18[5]; v20 = v18[6]; v18[2] = v18[2]; v18[3] = v28; v18[4] = v19; v18[5] = v30; v18[6] = v20; __strcpy_chk(56LL * v23 + a3, v18, 50LL); *(_DWORD *)(56LL * v23 + a3 + 52) = *((_DWORD *)&v31[3] + 14 * v23 + 1); } } LABEL_24: v21 = 4; if ( v10 <= 4 ) v21 = v10; *a4 = v21; return v32 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x1000 OR qword ptr [RSP],0x0 SUB RSP,0x658 MOV R8,RDI MOV qword ptr [RSP + 0x10],RDX MOV qword ptr [RSP + 0x18],RCX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1648],RAX XOR EAX,EAX LEA RDI,[RSP + 0x60] MOV ECX,0x2bc STOSQ.REP RDI TEST ESI,ESI JLE 0x001013f6 MOV R13,R8 LEA EAX,[RSI + -0x1] LEA RAX,[RAX + RAX*0x4] LEA RAX,[RAX + RAX*0x4] LEA R14,[R8 + RAX*0x2 + 0x32] MOV R15D,0x0 LEA RAX,[RSP + 0x60] MOV qword ptr [RSP + 0x8],RAX JMP 0x0010128a LAB_00101224: MOVSXD RBX,EBX LEA RAX,[RBX*0x8] MOV RDX,RAX SUB RDX,RBX MOV EAX,dword ptr [RSP + RDX*0x8 + 0x94] ADD EAX,0x1 MOV dword ptr [RSP + RDX*0x8 + 0x94],EAX JMP 0x00101281 LAB_00101248: MOVSXD RBP,R15D LEA RBX,[RBP*0x8] MOV RAX,RBX SUB RAX,RBP MOV RDI,qword ptr [RSP + 0x8] LEA RDI,[RDI + RAX*0x8] MOV EDX,0x32 MOV RSI,R13 CALL 0x001010b0 SUB RBX,RBP MOV dword ptr [RSP + RBX*0x8 + 0x94],0x1 ADD R15D,0x1 LAB_00101281: ADD R13,0x32 CMP R13,R14 JZ 0x001012bd LAB_0010128a: MOV R12,R13 LEA RBP,[RSP + 0x60] MOV EBX,0x0 TEST R15D,R15D JLE 0x00101248 LAB_0010129c: MOV RSI,RBP MOV RDI,R12 CALL 0x001010a0 TEST EAX,EAX JZ 0x00101224 ADD EBX,0x1 ADD RBP,0x38 CMP EBX,R15D JNZ 0x0010129c JMP 0x00101248 LAB_001012bd: TEST R15D,R15D JLE 0x00101401 LEA R12,[RSP + 0x60] MOV R14,qword ptr [RSP + 0x10] MOV R13D,0x0 JMP 0x001013d2 LAB_001012db: MOV EBX,EBP LAB_001012dd: MOVSXD RSI,EDX LEA RAX,[RSI*0x8] SUB RAX,RSI MOV EAX,dword ptr [RSP + RAX*0x8 + 0x94] CMP dword ptr [RCX + 0x6c],EAX CMOVG EDX,EBX LEA EBP,[RBX + 0x1] ADD RCX,0x38 CMP R15D,EBP JNZ 0x001012db MOVDQU XMM0,xmmword ptr [R12] MOVAPS xmmword ptr [RSP + 0x20],XMM0 MOV R10,qword ptr [R12 + 0x10] MOV R11,qword ptr [R12 + 0x18] MOV qword ptr [RSP + 0x30],R10 MOV qword ptr [RSP + 0x38],R11 MOV R8,qword ptr [R12 + 0x20] MOV R9,qword ptr [R12 + 0x28] MOV qword ptr [RSP + 0x40],R8 MOV qword ptr [RSP + 0x48],R9 MOV RDI,qword ptr [R12 + 0x30] MOV qword ptr [RSP + 0x50],RDI MOVSXD RDX,EDX LEA RAX,[RDX*0x8] MOV RCX,RAX SUB RCX,RDX SHL RCX,0x3 LEA RSI,[RSP + RCX*0x1 + 0x60] MOVDQU XMM1,xmmword ptr [RSP + RCX*0x1 + 0x60] MOVUPS xmmword ptr [R12],XMM1 MOVDQU XMM2,xmmword ptr [RSI + 0x10] MOVUPS xmmword ptr [R12 + 0x10],XMM2 MOVDQU XMM3,xmmword ptr [RSI + 0x20] MOVUPS xmmword ptr [R12 + 0x20],XMM3 MOV RCX,qword ptr [RSI + 0x30] MOV qword ptr [R12 + 0x30],RCX SUB RAX,RDX SHL RAX,0x3 MOVUPS xmmword ptr [RSP + RAX*0x1 + 0x60],XMM0 MOV qword ptr [RSI + 0x10],R10 MOV qword ptr [RSI + 0x18],R11 MOV qword ptr [RSI + 0x20],R8 MOV qword ptr [RSI + 0x28],R9 MOV qword ptr [RSI + 0x30],RDI MOV EDX,0x32 MOV RSI,R12 MOV RDI,R14 CALL 0x001010b0 MOV EAX,dword ptr [R12 + 0x34] MOV dword ptr [R14 + 0x34],EAX ADD R12,0x38 ADD R14,0x38 CMP R13D,0x3 JG 0x001013ee CMP dword ptr [RSP + 0x8],EBX JGE 0x001013ee LAB_001013d2: MOV EDX,R13D MOV dword ptr [RSP + 0x8],R13D ADD R13D,0x1 CMP R15D,R13D JZ 0x00101409 MOV RCX,R12 MOV EBX,R13D JMP 0x001012dd LAB_001013ee: MOV R13D,EBP JMP 0x001014ab LAB_001013f6: MOV R13D,0x0 JMP 0x001014ab LAB_00101401: MOV R13D,R15D JMP 0x001014ab LAB_00101409: MOVSXD R15,dword ptr [RSP + 0x8] LEA RBX,[R15*0x8] MOV RAX,RBX SUB RAX,R15 SHL RAX,0x3 LEA RDX,[RSP + RAX*0x1 + 0x60] MOV R10,qword ptr [RSP + RAX*0x1 + 0x60] MOV R11,qword ptr [RSP + RAX*0x1 + 0x68] MOV qword ptr [RSP + 0x20],R10 MOV qword ptr [RSP + 0x28],R11 MOV R8,qword ptr [RDX + 0x10] MOV R9,qword ptr [RDX + 0x18] MOV qword ptr [RSP + 0x30],R8 MOV qword ptr [RSP + 0x38],R9 MOV RSI,qword ptr [RDX + 0x20] MOV RDI,qword ptr [RDX + 0x28] MOV qword ptr [RSP + 0x40],RSI MOV qword ptr [RSP + 0x48],RDI MOV RCX,qword ptr [RDX + 0x30] MOV qword ptr [RSP + 0x50],RCX MOV qword ptr [RDX + 0x10],R8 MOV qword ptr [RDX + 0x18],R9 MOV qword ptr [RDX + 0x20],RSI MOV qword ptr [RDX + 0x28],RDI MOV qword ptr [RDX + 0x30],RCX MOV RAX,RBX SUB RAX,R15 SHL RAX,0x3 MOV R12,qword ptr [RSP + 0x10] ADD R12,RAX MOV RSI,RDX MOV EDX,0x32 MOV RDI,R12 CALL 0x001010b0 SUB RBX,R15 MOV EAX,dword ptr [RSP + RBX*0x8 + 0x94] MOV dword ptr [R12 + 0x34],EAX LAB_001014ab: MOV EAX,0x4 CMP R13D,EAX CMOVLE EAX,R13D MOV RDI,qword ptr [RSP + 0x18] MOV dword ptr [RDI],EAX MOV RAX,qword ptr [RSP + 0x1648] SUB RAX,qword ptr FS:[0x28] JNZ 0x001014e3 ADD RSP,0x1658 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001014e3: CALL 0x00101080
void func0(char *param_1,int param_2,long param_3,int *param_4) { int8 uVar1; int8 uVar2; int8 uVar3; int8 uVar4; int8 uVar5; bool bVar6; int8 uVar7; int8 uVar8; int8 uVar9; int iVar10; long lVar11; int iVar12; long lVar13; int iVar14; int iVar15; char *pcVar16; char *pcVar17; int iVar18; int iVar19; long in_FS_OFFSET; char local_1628 [8]; int8 auStack_1620 [5]; int8 local_15f8; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); pcVar17 = local_1628; for (lVar11 = 700; lVar11 != 0; lVar11 = lVar11 + -1) { pcVar17[0] = '\0'; pcVar17[1] = '\0'; pcVar17[2] = '\0'; pcVar17[3] = '\0'; pcVar17[4] = '\0'; pcVar17[5] = '\0'; pcVar17[6] = '\0'; pcVar17[7] = '\0'; pcVar17 = pcVar17 + 8; } if (param_2 < 1) { iVar14 = 0; } else { pcVar17 = param_1 + (ulong)(param_2 - 1) * 0x32 + 0x32; iVar19 = 0; do { pcVar16 = local_1628; iVar14 = 0; if (0 < iVar19) { do { iVar10 = strcmp(param_1,pcVar16); if (iVar10 == 0) { *(int *)((long)&local_15f8 + (long)iVar14 * 0x38 + 4) = *(int *)((long)&local_15f8 + (long)iVar14 * 0x38 + 4) + 1; goto LAB_00101281; } iVar14 = iVar14 + 1; pcVar16 = pcVar16 + 0x38; } while (iVar14 != iVar19); } __strcpy_chk(auStack_1620 + (long)iVar19 * 7 + -1,param_1,0x32); *(int4 *)((long)&local_15f8 + (long)iVar19 * 0x38 + 4) = 1; iVar19 = iVar19 + 1; LAB_00101281: param_1 = param_1 + 0x32; } while (param_1 != pcVar17); iVar14 = iVar19; if (0 < iVar19) { pcVar17 = local_1628; lVar11 = param_3; iVar10 = 0; while (iVar18 = iVar10 + 1, pcVar16 = pcVar17, iVar12 = iVar10, iVar14 = iVar18, iVar19 != iVar18) { do { iVar15 = iVar14; if (*(int *)((long)&local_15f8 + (long)iVar12 * 0x38 + 4) < *(int *)(pcVar16 + 0x6c)) { iVar12 = iVar15; } iVar14 = iVar15 + 1; pcVar16 = pcVar16 + 0x38; } while (iVar19 != iVar14); uVar7 = *(int8 *)pcVar17; uVar8 = *(int8 *)(pcVar17 + 8); uVar1 = *(int8 *)(pcVar17 + 0x10); uVar2 = *(int8 *)(pcVar17 + 0x18); uVar3 = *(int8 *)(pcVar17 + 0x20); uVar4 = *(int8 *)(pcVar17 + 0x28); uVar5 = *(int8 *)(pcVar17 + 0x30); lVar13 = (long)iVar12; uVar9 = auStack_1620[lVar13 * 7]; *(int8 *)pcVar17 = auStack_1620[lVar13 * 7 + -1]; *(int8 *)(pcVar17 + 8) = uVar9; uVar9 = auStack_1620[lVar13 * 7 + 2]; *(int8 *)(pcVar17 + 0x10) = auStack_1620[lVar13 * 7 + 1]; *(int8 *)(pcVar17 + 0x18) = uVar9; uVar9 = auStack_1620[lVar13 * 7 + 4]; *(int8 *)(pcVar17 + 0x20) = auStack_1620[lVar13 * 7 + 3]; *(int8 *)(pcVar17 + 0x28) = uVar9; *(int8 *)(pcVar17 + 0x30) = (&local_15f8)[lVar13 * 7]; auStack_1620[lVar13 * 7 + -1] = uVar7; auStack_1620[lVar13 * 7] = uVar8; auStack_1620[lVar13 * 7 + 1] = uVar1; auStack_1620[lVar13 * 7 + 2] = uVar2; auStack_1620[lVar13 * 7 + 3] = uVar3; auStack_1620[lVar13 * 7 + 4] = uVar4; (&local_15f8)[lVar13 * 7] = uVar5; __strcpy_chk(lVar11,pcVar17,0x32); *(int4 *)(lVar11 + 0x34) = *(int4 *)(pcVar17 + 0x34); pcVar17 = pcVar17 + 0x38; lVar11 = lVar11 + 0x38; if ((3 < iVar18) || (bVar6 = iVar15 <= iVar10, iVar10 = iVar18, bVar6)) goto LAB_001014ab; } lVar11 = (long)iVar10; uVar1 = (&local_15f8)[lVar11 * 7]; auStack_1620[lVar11 * 7 + 1] = auStack_1620[lVar11 * 7 + 1]; auStack_1620[lVar11 * 7 + 2] = auStack_1620[lVar11 * 7 + 2]; auStack_1620[lVar11 * 7 + 3] = auStack_1620[lVar11 * 7 + 3]; auStack_1620[lVar11 * 7 + 4] = auStack_1620[lVar11 * 7 + 4]; (&local_15f8)[lVar11 * 7] = uVar1; param_3 = param_3 + lVar11 * 0x38; __strcpy_chk(param_3,auStack_1620 + lVar11 * 7 + -1,0x32); *(int4 *)(param_3 + 0x34) = *(int4 *)((long)&local_15f8 + lVar11 * 0x38 + 4); } } LAB_001014ab: iVar19 = 4; if (iVar14 < 5) { iVar19 = iVar14; } *param_4 = iVar19; if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
3,946
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define MAX_WORDS 100 #define MAX_WORD_LENGTH 50 typedef struct { char word[MAX_WORD_LENGTH]; int count; } WordCount;
void func0(char words[][MAX_WORD_LENGTH], int num_words, WordCount result[], int *result_size) { WordCount counts[MAX_WORDS] = {0}; int unique_words = 0; // Count each word for (int i = 0; i < num_words; i++) { int found = 0; for (int j = 0; j < unique_words; j++) { if (strcmp(words[i], counts[j].word) == 0) { counts[j].count++; found = 1; break; } } if (!found) { strcpy(counts[unique_words].word, words[i]); counts[unique_words].count = 1; unique_words++; } } // Simple sorting (selection sort) to get top 4 for (int i=0; i < 4 && i < unique_words; i++) { int max_idx = i; for (int j=i+1; j < unique_words; j++) { if (counts[j].count > counts[max_idx].count) { max_idx = j; } } // Swap max element with the i-th position WordCount tmp = counts[i]; counts[i] = counts[max_idx]; counts[max_idx] = tmp; // Copy to results strcpy(result[i].word, counts[i].word); result[i].count = counts[i].count; } *result_size = unique_words > 4 ? 4 : unique_words; }
int main() { WordCount result[4]; int result_size; char data1[][MAX_WORD_LENGTH] = {"red","green","black","pink","black","white","black","eyes","white","black","orange","pink","pink","red","red","white","orange","white","black","pink","green","green","pink","green","pink","white","orange","orange","red"}; func0(data1, 29, result, &result_size); assert(strcmp(result[0].word, "pink") == 0 && result[0].count == 6); assert(strcmp(result[1].word, "black") == 0 && result[1].count == 5); assert(strcmp(result[2].word, "white") == 0 && result[2].count == 5); assert(strcmp(result[3].word, "red") == 0 && result[3].count == 4); char data2[][MAX_WORD_LENGTH] = {"one", "two", "three", "four", "five", "one", "two", "one", "three", "one"}; func0(data2, 10, result, &result_size); assert(strcmp(result[0].word, "one") == 0 && result[0].count == 4); assert(strcmp(result[1].word, "two") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "three") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "four") == 0 && result[3].count == 1); char data3[][MAX_WORD_LENGTH] = {"Facebook", "Apple", "Amazon", "Netflix", "Google", "Apple", "Netflix", "Amazon"}; func0(data3, 8, result, &result_size); assert(strcmp(result[0].word, "Apple") == 0 && result[0].count == 2); assert(strcmp(result[1].word, "Amazon") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "Netflix") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "Facebook") == 0 && result[3].count == 1); return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x1000,%rsp orq $0x0,(%rsp) sub $0x648,%rsp mov %rcx,0x8(%rsp) lea 0x50(%rsp),%r12 mov %rdi,%rbp mov $0x2bc,%ecx mov %rdx,(%rsp) mov %r12,%rdi mov %fs:0x28,%rax mov %rax,0x1638(%rsp) xor %eax,%eax rep stos %rax,%es:(%rdi) test %esi,%esi jle 17df <func0+0x27f> lea -0x1(%rsi),%eax xor %ebx,%ebx lea (%rax,%rax,4),%rax lea (%rax,%rax,4),%rax lea 0x32(%rbp,%rax,2),%r13 nopw 0x0(%rax,%rax,1) mov %r12,%r14 xor %r15d,%r15d test %ebx,%ebx jne 15f1 <func0+0x91> jmpq 1740 <func0+0x1e0> add $0x1,%r15d add $0x38,%r14 cmp %ebx,%r15d je 1740 <func0+0x1e0> mov %r14,%rsi mov %rbp,%rdi callq 10a0 <strcmp@plt> test %eax,%eax jne 15e0 <func0+0x80> movslq %r15d,%rdx lea 0x0(,%rdx,8),%rax sub %rdx,%rax addl $0x1,0x84(%rsp,%rax,8) add $0x32,%rbp cmp %r13,%rbp jne 15d0 <func0+0x70> mov (%rsp),%rdi mov %r12,%rbp xor %r13d,%r13d movslq %r13d,%rax add $0x1,%r13d cmp %r13d,%ebx je 177b <func0+0x21b> mov %rbp,%rsi mov %r13d,%edx lea 0x0(,%rax,8),%rcx movslq %edx,%r8 sub %rax,%rcx mov 0x84(%rsp,%rcx,8),%ecx cmp %ecx,0x6c(%rsi) cmovg %r8,%rax add $0x1,%edx add $0x38,%rsi cmp %edx,%ebx jne 1640 <func0+0xe0> lea 0x0(,%rax,8),%rdx movdqu 0x0(%rbp),%xmm2 movdqu 0x10(%rbp),%xmm1 sub %rax,%rdx movdqu 0x20(%rbp),%xmm0 mov 0x30(%rbp),%rcx mov %rdx,%rax movaps %xmm2,0x10(%rsp) shl $0x3,%rax mov %rcx,0x40(%rsp) movdqu 0x50(%rsp,%rax,1),%xmm3 lea 0x50(%rsp,%rax,1),%rdx movaps %xmm1,0x20(%rsp) movaps %xmm0,0x30(%rsp) movups %xmm3,0x0(%rbp) movdqu 0x10(%rdx),%xmm4 movups %xmm4,0x10(%rbp) movdqu 0x20(%rdx),%xmm5 movups %xmm5,0x20(%rbp) mov 0x30(%rdx),%rsi mov %rsi,0x30(%rbp) mov %rbp,%rsi add $0x38,%rbp movups %xmm2,0x50(%rsp,%rax,1) mov %rcx,0x30(%rdx) movups %xmm1,0x10(%rdx) movups %xmm0,0x20(%rdx) mov $0x32,%edx callq 10b0 <__strcpy_chk@plt> mov %rax,%rdi mov -0x4(%rbp),%eax add $0x38,%rdi mov %eax,-0x4(%rdi) cmp $0x4,%r13d jne 1629 <func0+0xc9> cmp $0x4,%ebx cmovg %r13d,%ebx mov 0x8(%rsp),%rax mov %ebx,(%rax) mov 0x1638(%rsp),%rax xor %fs:0x28,%rax jne 17e6 <func0+0x286> add $0x1648,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax) movslq %ebx,%rax mov $0x32,%edx mov %rbp,%rsi add $0x1,%ebx lea 0x0(,%rax,8),%rcx sub %rax,%rcx lea 0x0(,%rcx,8),%r14 lea (%r12,%r14,1),%rdi callq 10b0 <__strcpy_chk@plt> movl $0x1,0x84(%rsp,%r14,1) jmpq 1616 <func0+0xb6> lea 0x0(,%rax,8),%rbp mov (%rsp),%r14 mov $0x32,%edx sub %rax,%rbp shl $0x3,%rbp movdqu 0x50(%rsp,%rbp,1),%xmm6 lea 0x50(%rsp,%rbp,1),%rax add %rbp,%r14 lea (%r12,%rbp,1),%rsi movdqu 0x10(%rax),%xmm7 mov %r14,%rdi movaps %xmm6,0x10(%rsp) movdqu 0x20(%rax),%xmm6 mov 0x30(%rax),%rax movaps %xmm7,0x20(%rsp) mov %rax,0x40(%rsp) movaps %xmm6,0x30(%rsp) callq 10b0 <__strcpy_chk@plt> mov 0x84(%rsp,%rbp,1),%eax mov %eax,0x34(%r14) jmpq 1709 <func0+0x1a9> xor %ebx,%ebx jmpq 1709 <func0+0x1a9> callq 1080 <__stack_chk_fail@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 1000h or [rsp+1030h+var_1030], 0 sub rsp, 648h mov [rsp+1678h+var_1670], rcx lea r12, [rsp+1678h+var_1628] mov rbp, rdi mov ecx, 2BCh mov [rsp+1678h+var_1678], rdx mov rdi, r12 mov rax, fs:28h mov [rsp+1678h+var_40], rax xor eax, eax rep stosq test esi, esi jle loc_17DF lea eax, [rsi-1] xor ebx, ebx lea rax, [rax+rax*4] lea rax, [rax+rax*4] lea r13, [rbp+rax*2+32h] nop word ptr [rax+rax+00h] loc_15D0: mov r14, r12 xor r15d, r15d test ebx, ebx jnz short loc_15F1 jmp loc_1740 loc_15E0: add r15d, 1 add r14, 38h ; '8' cmp ebx, r15d jz loc_1740 loc_15F1: mov rsi, r14 mov rdi, rbp call _strcmp test eax, eax jnz short loc_15E0 movsxd rdx, r15d lea rax, ds:0[rdx*8] sub rax, rdx add [rsp+rax*8+1678h+var_15F4], 1 loc_1616: add rbp, 32h ; '2' cmp rbp, r13 jnz short loc_15D0 mov rdi, [rsp+1678h+var_1678] mov r13, r12 xor ebp, ebp loc_1628: movsxd rax, ebp add ebp, 1 cmp ebx, ebp jz loc_177B mov rsi, r13 mov edx, ebp nop dword ptr [rax+rax+00h] loc_1640: lea rcx, ds:0[rax*8] movsxd r8, edx sub rcx, rax mov ecx, [rsp+rcx*8+1678h+var_15F4] cmp [rsi+6Ch], ecx cmovg rax, r8 add edx, 1 add rsi, 38h ; '8' cmp ebx, edx jnz short loc_1640 lea rdx, ds:0[rax*8] movdqu xmm2, xmmword ptr [r13+0] movdqu xmm1, xmmword ptr [r13+10h] sub rdx, rax movdqu xmm0, xmmword ptr [r13+20h] mov rcx, [r13+30h] lea rax, ds:0[rdx*8] movaps [rsp+1678h+var_1668], xmm2 movdqu xmm3, [rsp+rax+1678h+var_1628] lea rdx, [rsp+rax+1678h+var_1628] mov [rsp+1678h+var_1638], rcx movaps [rsp+1678h+var_1658], xmm1 movups xmmword ptr [r13+0], xmm3 movdqu xmm4, xmmword ptr [rdx+10h] movaps [rsp+1678h+var_1648], xmm0 movups xmmword ptr [r13+10h], xmm4 movdqu xmm5, xmmword ptr [rdx+20h] movups xmmword ptr [r13+20h], xmm5 mov rsi, [rdx+30h] mov [r13+30h], rsi mov rsi, r13 add r13, 38h ; '8' movups [rsp+rax+1678h+var_1628], xmm2 mov [rdx+30h], rcx movups xmmword ptr [rdx+10h], xmm1 movups xmmword ptr [rdx+20h], xmm0 mov edx, 32h ; '2' call ___strcpy_chk mov rdi, rax mov eax, [r13-4] add rdi, 38h ; '8' mov [rdi-4], eax cmp ebp, 4 jnz loc_1628 cmp ebx, ebp cmovle ebp, ebx loc_170E: mov rax, [rsp+1678h+var_1670] mov [rax], ebp mov rax, [rsp+1678h+var_40] sub rax, fs:28h jnz loc_17E6 add rsp, 1648h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1740: movsxd rax, ebx mov edx, 32h ; '2' mov rsi, rbp add ebx, 1 lea rcx, ds:0[rax*8] sub rcx, rax lea r14, ds:0[rcx*8] lea rdi, [r12+r14] call ___strcpy_chk mov [rsp+r14+1678h+var_15F4], 1 jmp loc_1616 loc_177B: lea rbx, ds:0[rax*8] mov r14, [rsp+1678h+var_1678] mov edx, 32h ; '2' sub rbx, rax shl rbx, 3 movdqu xmm6, [rsp+rbx+1678h+var_1628] lea rax, [rsp+rbx+1678h+var_1628] add r14, rbx lea rsi, [r12+rbx] movdqu xmm7, xmmword ptr [rax+10h] mov rdi, r14 movaps [rsp+1678h+var_1668], xmm6 movdqu xmm6, xmmword ptr [rax+20h] mov rax, [rax+30h] movaps [rsp+1678h+var_1658], xmm7 mov [rsp+1678h+var_1638], rax movaps [rsp+1678h+var_1648], xmm6 call ___strcpy_chk mov eax, [rsp+rbx+1678h+var_15F4] mov [r14+34h], eax jmp loc_170E loc_17DF: xor ebp, ebp jmp loc_170E loc_17E6: call ___stack_chk_fail
unsigned long long func0(long long a1, int a2, long long a3, int *a4) { long long v4; // rbp int v5; // ebx _OWORD *v6; // r14 int v7; // r15d long long v8; // rdi __m128i *v9; // r13 int v10; // ebp long long v11; // rax __m128i *v12; // rsi int v13; // edx __m128i v14; // xmm0 __m128i *v15; // rdx __m128i *v16; // rsi long long v17; // rax long long v19; // rax long long v20; // r14 long long v21; // rbx __m128i v24; // [rsp+10h] [rbp-1668h] __m128i v25; // [rsp+20h] [rbp-1658h] long long v26; // [rsp+40h] [rbp-1638h] _OWORD v27[350]; // [rsp+50h] [rbp-1628h] BYREF unsigned long long v28; // [rsp+1638h] [rbp-40h] v4 = a1; v28 = __readfsqword(0x28u); memset(v27, 0, sizeof(v27)); if ( a2 <= 0 ) { v10 = 0; } else { v5 = 0; do { v6 = v27; v7 = 0; if ( v5 ) { while ( (unsigned int)strcmp(v4, v6) ) { ++v7; v6 = (_OWORD *)((char *)v6 + 56); if ( v5 == v7 ) goto LABEL_19; } ++*((_DWORD *)&v27[3] + 14 * v7 + 1); } else { LABEL_19: v19 = v5++; v20 = 56 * v19; __strcpy_chk((char *)v27 + 56 * v19, v4, 50LL); *(_DWORD *)((char *)&v27[3] + v20 + 4) = 1; } v4 += 50LL; } while ( v4 != a1 + 50LL * (unsigned int)(a2 - 1) + 50 ); v8 = a3; v9 = (__m128i *)v27; v10 = 0; do { v11 = v10++; if ( v5 == v10 ) { v21 = 56 * v11; __strcpy_chk(v21 + a3, (char *)v27 + v21, 50LL); *(_DWORD *)(v21 + a3 + 52) = *(_DWORD *)((char *)&v27[3] + v21 + 4); goto LABEL_18; } v12 = v9; v13 = v10; do { if ( v12[6].m128i_i32[3] > *((_DWORD *)&v27[3] + 14 * v11 + 1) ) v11 = v13; ++v13; v12 = (__m128i *)((char *)v12 + 56); } while ( v5 != v13 ); v14 = _mm_loadu_si128(v9 + 2); v24 = _mm_loadu_si128(v9); v15 = (__m128i *)((char *)v27 + 56 * v11); v26 = v9[3].m128i_i64[0]; v25 = _mm_loadu_si128(v9 + 1); *v9 = _mm_loadu_si128(v15); v9[1] = _mm_loadu_si128(v15 + 1); v9[2] = _mm_loadu_si128(v15 + 2); v9[3].m128i_i64[0] = v15[3].m128i_i64[0]; v16 = v9; v9 = (__m128i *)((char *)v9 + 56); *v15 = v24; v15[3].m128i_i64[0] = v26; v15[1] = v25; v15[2] = v14; v17 = __strcpy_chk(v8, v16, 50LL); v8 = v17 + 56; *(_DWORD *)(v17 + 52) = v9[-1].m128i_i32[3]; } while ( v10 != 4 ); if ( v5 <= 4 ) v10 = v5; } LABEL_18: *a4 = v10; return v28 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x1000 OR qword ptr [RSP],0x0 SUB RSP,0x648 MOV qword ptr [RSP + 0x8],RCX LEA R12,[RSP + 0x50] MOV RBP,RDI MOV ECX,0x2bc MOV qword ptr [RSP],RDX MOV RDI,R12 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1638],RAX XOR EAX,EAX STOSQ.REP RDI TEST ESI,ESI JLE 0x001017df LEA EAX,[RSI + -0x1] XOR EBX,EBX LEA RAX,[RAX + RAX*0x4] LEA RAX,[RAX + RAX*0x4] LEA R13,[RBP + RAX*0x2 + 0x32] NOP word ptr [RAX + RAX*0x1] LAB_001015d0: MOV R14,R12 XOR R15D,R15D TEST EBX,EBX JNZ 0x001015f1 JMP 0x00101740 LAB_001015e0: ADD R15D,0x1 ADD R14,0x38 CMP EBX,R15D JZ 0x00101740 LAB_001015f1: MOV RSI,R14 MOV RDI,RBP CALL 0x001010a0 TEST EAX,EAX JNZ 0x001015e0 MOVSXD RDX,R15D LEA RAX,[RDX*0x8] SUB RAX,RDX ADD dword ptr [RSP + RAX*0x8 + 0x84],0x1 LAB_00101616: ADD RBP,0x32 CMP RBP,R13 JNZ 0x001015d0 MOV RDI,qword ptr [RSP] MOV R13,R12 XOR EBP,EBP LAB_00101628: MOVSXD RAX,EBP ADD EBP,0x1 CMP EBX,EBP JZ 0x0010177b MOV RSI,R13 MOV EDX,EBP NOP dword ptr [RAX + RAX*0x1] LAB_00101640: LEA RCX,[RAX*0x8] MOVSXD R8,EDX SUB RCX,RAX MOV ECX,dword ptr [RSP + RCX*0x8 + 0x84] CMP dword ptr [RSI + 0x6c],ECX CMOVG RAX,R8 ADD EDX,0x1 ADD RSI,0x38 CMP EBX,EDX JNZ 0x00101640 LEA RDX,[RAX*0x8] MOVDQU XMM2,xmmword ptr [R13] MOVDQU XMM1,xmmword ptr [R13 + 0x10] SUB RDX,RAX MOVDQU XMM0,xmmword ptr [R13 + 0x20] MOV RCX,qword ptr [R13 + 0x30] LEA RAX,[RDX*0x8] MOVAPS xmmword ptr [RSP + 0x10],XMM2 MOVDQU XMM3,xmmword ptr [RSP + RAX*0x1 + 0x50] LEA RDX,[RSP + RAX*0x1 + 0x50] MOV qword ptr [RSP + 0x40],RCX MOVAPS xmmword ptr [RSP + 0x20],XMM1 MOVUPS xmmword ptr [R13],XMM3 MOVDQU XMM4,xmmword ptr [RDX + 0x10] MOVAPS xmmword ptr [RSP + 0x30],XMM0 MOVUPS xmmword ptr [R13 + 0x10],XMM4 MOVDQU XMM5,xmmword ptr [RDX + 0x20] MOVUPS xmmword ptr [R13 + 0x20],XMM5 MOV RSI,qword ptr [RDX + 0x30] MOV qword ptr [R13 + 0x30],RSI MOV RSI,R13 ADD R13,0x38 MOVUPS xmmword ptr [RSP + RAX*0x1 + 0x50],XMM2 MOV qword ptr [RDX + 0x30],RCX MOVUPS xmmword ptr [RDX + 0x10],XMM1 MOVUPS xmmword ptr [RDX + 0x20],XMM0 MOV EDX,0x32 CALL 0x001010b0 MOV RDI,RAX MOV EAX,dword ptr [R13 + -0x4] ADD RDI,0x38 MOV dword ptr [RDI + -0x4],EAX CMP EBP,0x4 JNZ 0x00101628 CMP EBX,EBP CMOVLE EBP,EBX LAB_0010170e: MOV RAX,qword ptr [RSP + 0x8] MOV dword ptr [RAX],EBP MOV RAX,qword ptr [RSP + 0x1638] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017e6 ADD RSP,0x1648 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101740: MOVSXD RAX,EBX MOV EDX,0x32 MOV RSI,RBP ADD EBX,0x1 LEA RCX,[RAX*0x8] SUB RCX,RAX LEA R14,[RCX*0x8] LEA RDI,[R12 + R14*0x1] CALL 0x001010b0 MOV dword ptr [RSP + R14*0x1 + 0x84],0x1 JMP 0x00101616 LAB_0010177b: LEA RBX,[RAX*0x8] MOV R14,qword ptr [RSP] MOV EDX,0x32 SUB RBX,RAX SHL RBX,0x3 MOVDQU XMM6,xmmword ptr [RSP + RBX*0x1 + 0x50] LEA RAX,[RSP + RBX*0x1 + 0x50] ADD R14,RBX LEA RSI,[R12 + RBX*0x1] MOVDQU XMM7,xmmword ptr [RAX + 0x10] MOV RDI,R14 MOVAPS xmmword ptr [RSP + 0x10],XMM6 MOVDQU XMM6,xmmword ptr [RAX + 0x20] MOV RAX,qword ptr [RAX + 0x30] MOVAPS xmmword ptr [RSP + 0x20],XMM7 MOV qword ptr [RSP + 0x40],RAX MOVAPS xmmword ptr [RSP + 0x30],XMM6 CALL 0x001010b0 MOV EAX,dword ptr [RSP + RBX*0x1 + 0x84] MOV dword ptr [R14 + 0x34],EAX JMP 0x0010170e LAB_001017df: XOR EBP,EBP JMP 0x0010170e LAB_001017e6: CALL 0x00101080
void func0(char *param_1,int param_2,long param_3,int *param_4) { int *piVar1; int8 uVar2; int8 uVar3; int8 uVar4; int8 uVar5; int8 uVar6; int8 uVar7; int8 uVar8; int8 uVar9; long lVar10; long lVar11; int iVar12; int iVar13; int iVar14; char *pcVar15; char *pcVar16; long in_FS_OFFSET; char local_1628 [8]; int8 auStack_1620 [5]; int8 local_15f8; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); pcVar15 = local_1628; for (lVar11 = 700; lVar11 != 0; lVar11 = lVar11 + -1) { pcVar15[0] = '\0'; pcVar15[1] = '\0'; pcVar15[2] = '\0'; pcVar15[3] = '\0'; pcVar15[4] = '\0'; pcVar15[5] = '\0'; pcVar15[6] = '\0'; pcVar15[7] = '\0'; pcVar15 = pcVar15 + 8; } if (param_2 < 1) { iVar14 = 0; } else { iVar13 = 0; pcVar15 = param_1 + (ulong)(param_2 - 1) * 0x32 + 0x32; do { iVar14 = 0; pcVar16 = local_1628; if (iVar13 != 0) { do { iVar12 = strcmp(param_1,pcVar16); if (iVar12 == 0) { piVar1 = (int *)((long)&local_15f8 + (long)iVar14 * 0x38 + 4); *piVar1 = *piVar1 + 1; goto LAB_00101616; } iVar14 = iVar14 + 1; pcVar16 = pcVar16 + 0x38; } while (iVar13 != iVar14); } lVar11 = (long)iVar13; iVar13 = iVar13 + 1; __strcpy_chk(local_1628 + lVar11 * 0x38,param_1,0x32); *(int4 *)((long)&local_15f8 + lVar11 * 0x38 + 4) = 1; LAB_00101616: param_1 = param_1 + 0x32; } while (param_1 != pcVar15); iVar14 = 0; lVar11 = param_3; pcVar15 = local_1628; do { lVar10 = (long)iVar14; iVar14 = iVar14 + 1; pcVar16 = pcVar15; iVar12 = iVar14; if (iVar13 == iVar14) { param_3 = param_3 + lVar10 * 0x38; __strcpy_chk(param_3,local_1628 + lVar10 * 0x38,0x32); *(int4 *)(param_3 + 0x34) = *(int4 *)((long)&local_15f8 + lVar10 * 0x38 + 4); goto LAB_0010170e; } do { if (*(int *)((long)&local_15f8 + lVar10 * 0x38 + 4) < *(int *)(pcVar16 + 0x6c)) { lVar10 = (long)iVar12; } iVar12 = iVar12 + 1; pcVar16 = pcVar16 + 0x38; } while (iVar13 != iVar12); uVar3 = *(int8 *)pcVar15; uVar4 = *(int8 *)(pcVar15 + 8); uVar5 = *(int8 *)(pcVar15 + 0x10); uVar6 = *(int8 *)(pcVar15 + 0x18); uVar7 = *(int8 *)(pcVar15 + 0x20); uVar8 = *(int8 *)(pcVar15 + 0x28); uVar2 = *(int8 *)(pcVar15 + 0x30); uVar9 = auStack_1620[lVar10 * 7]; *(int8 *)pcVar15 = auStack_1620[lVar10 * 7 + -1]; *(int8 *)(pcVar15 + 8) = uVar9; uVar9 = auStack_1620[lVar10 * 7 + 2]; *(int8 *)(pcVar15 + 0x10) = auStack_1620[lVar10 * 7 + 1]; *(int8 *)(pcVar15 + 0x18) = uVar9; uVar9 = auStack_1620[lVar10 * 7 + 4]; *(int8 *)(pcVar15 + 0x20) = auStack_1620[lVar10 * 7 + 3]; *(int8 *)(pcVar15 + 0x28) = uVar9; *(int8 *)(pcVar15 + 0x30) = (&local_15f8)[lVar10 * 7]; auStack_1620[lVar10 * 7 + -1] = uVar3; auStack_1620[lVar10 * 7] = uVar4; (&local_15f8)[lVar10 * 7] = uVar2; auStack_1620[lVar10 * 7 + 1] = uVar5; auStack_1620[lVar10 * 7 + 2] = uVar6; auStack_1620[lVar10 * 7 + 3] = uVar7; auStack_1620[lVar10 * 7 + 4] = uVar8; lVar10 = __strcpy_chk(lVar11,pcVar15,0x32); lVar11 = lVar10 + 0x38; *(int4 *)(lVar10 + 0x34) = *(int4 *)(pcVar15 + 0x34); pcVar15 = pcVar15 + 0x38; } while (iVar14 != 4); if (iVar13 < 5) { iVar14 = iVar13; } } LAB_0010170e: *param_4 = iVar14; if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
3,947
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define MAX_WORDS 100 #define MAX_WORD_LENGTH 50 typedef struct { char word[MAX_WORD_LENGTH]; int count; } WordCount;
void func0(char words[][MAX_WORD_LENGTH], int num_words, WordCount result[], int *result_size) { WordCount counts[MAX_WORDS] = {0}; int unique_words = 0; // Count each word for (int i = 0; i < num_words; i++) { int found = 0; for (int j = 0; j < unique_words; j++) { if (strcmp(words[i], counts[j].word) == 0) { counts[j].count++; found = 1; break; } } if (!found) { strcpy(counts[unique_words].word, words[i]); counts[unique_words].count = 1; unique_words++; } } // Simple sorting (selection sort) to get top 4 for (int i=0; i < 4 && i < unique_words; i++) { int max_idx = i; for (int j=i+1; j < unique_words; j++) { if (counts[j].count > counts[max_idx].count) { max_idx = j; } } // Swap max element with the i-th position WordCount tmp = counts[i]; counts[i] = counts[max_idx]; counts[max_idx] = tmp; // Copy to results strcpy(result[i].word, counts[i].word); result[i].count = counts[i].count; } *result_size = unique_words > 4 ? 4 : unique_words; }
int main() { WordCount result[4]; int result_size; char data1[][MAX_WORD_LENGTH] = {"red","green","black","pink","black","white","black","eyes","white","black","orange","pink","pink","red","red","white","orange","white","black","pink","green","green","pink","green","pink","white","orange","orange","red"}; func0(data1, 29, result, &result_size); assert(strcmp(result[0].word, "pink") == 0 && result[0].count == 6); assert(strcmp(result[1].word, "black") == 0 && result[1].count == 5); assert(strcmp(result[2].word, "white") == 0 && result[2].count == 5); assert(strcmp(result[3].word, "red") == 0 && result[3].count == 4); char data2[][MAX_WORD_LENGTH] = {"one", "two", "three", "four", "five", "one", "two", "one", "three", "one"}; func0(data2, 10, result, &result_size); assert(strcmp(result[0].word, "one") == 0 && result[0].count == 4); assert(strcmp(result[1].word, "two") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "three") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "four") == 0 && result[3].count == 1); char data3[][MAX_WORD_LENGTH] = {"Facebook", "Apple", "Amazon", "Netflix", "Google", "Apple", "Netflix", "Amazon"}; func0(data3, 8, result, &result_size); assert(strcmp(result[0].word, "Apple") == 0 && result[0].count == 2); assert(strcmp(result[1].word, "Amazon") == 0 && result[1].count == 2); assert(strcmp(result[2].word, "Netflix") == 0 && result[2].count == 2); assert(strcmp(result[3].word, "Facebook") == 0 && result[3].count == 1); return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x1000,%rsp orq $0x0,(%rsp) sub $0x648,%rsp mov %rcx,0x8(%rsp) lea 0x50(%rsp),%r12 mov %rdi,%rbp mov $0x2bc,%ecx mov %rdx,(%rsp) mov %r12,%rdi mov %fs:0x28,%rax mov %rax,0x1638(%rsp) xor %eax,%eax rep stos %rax,%es:(%rdi) test %esi,%esi jle 17d7 <func0+0x277> lea -0x1(%rsi),%eax xor %ebx,%ebx lea (%rax,%rax,4),%rax lea (%rax,%rax,4),%rax lea 0x32(%rbp,%rax,2),%r13 nopw 0x0(%rax,%rax,1) mov %r12,%r14 xor %r15d,%r15d test %ebx,%ebx jne 15f1 <func0+0x91> jmpq 1738 <func0+0x1d8> add $0x1,%r15d add $0x38,%r14 cmp %ebx,%r15d je 1738 <func0+0x1d8> mov %r14,%rsi mov %rbp,%rdi callq 10a0 <strcmp@plt> test %eax,%eax jne 15e0 <func0+0x80> movslq %r15d,%rdx lea 0x0(,%rdx,8),%rax sub %rdx,%rax addl $0x1,0x84(%rsp,%rax,8) add $0x32,%rbp cmp %r13,%rbp jne 15d0 <func0+0x70> mov (%rsp),%r8 mov %r12,%rbp xor %r13d,%r13d movslq %r13d,%rdi add $0x1,%r13d cmp %r13d,%ebx je 1773 <func0+0x213> mov 0x34(%rbp),%esi mov %rbp,%rdx mov %r13d,%eax nopw 0x0(%rax,%rax,1) mov 0x6c(%rdx),%ecx cmp %esi,%ecx jle 1654 <func0+0xf4> mov %ecx,%esi movslq %eax,%rdi add $0x1,%eax add $0x38,%rdx cmp %eax,%ebx jne 1648 <func0+0xe8> lea 0x0(,%rdi,8),%rax movdqu 0x0(%rbp),%xmm2 movdqu 0x10(%rbp),%xmm1 sub %rdi,%rax movdqu 0x20(%rbp),%xmm0 mov 0x30(%rbp),%rcx mov %r8,%rdi shl $0x3,%rax movaps %xmm2,0x10(%rsp) movdqu 0x50(%rsp,%rax,1),%xmm3 lea 0x50(%rsp,%rax,1),%rdx mov %rcx,0x40(%rsp) movaps %xmm1,0x20(%rsp) movups %xmm3,0x0(%rbp) movdqu 0x10(%rdx),%xmm4 movaps %xmm0,0x30(%rsp) movups %xmm4,0x10(%rbp) movdqu 0x20(%rdx),%xmm5 movups %xmm5,0x20(%rbp) mov 0x30(%rdx),%rsi mov %rsi,0x30(%rbp) mov %rbp,%rsi add $0x38,%rbp movups %xmm2,0x50(%rsp,%rax,1) mov %rcx,0x30(%rdx) movups %xmm1,0x10(%rdx) movups %xmm0,0x20(%rdx) mov $0x32,%edx callq 10b0 <__strcpy_chk@plt> mov %rax,%r8 mov -0x4(%rbp),%eax add $0x38,%r8 mov %eax,-0x4(%r8) cmp $0x4,%r13d jne 1629 <func0+0xc9> cmp $0x4,%ebx cmovg %r13d,%ebx mov 0x8(%rsp),%rax mov %ebx,(%rax) mov 0x1638(%rsp),%rax xor %fs:0x28,%rax jne 17de <func0+0x27e> add $0x1648,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1) movslq %ebx,%rax mov $0x32,%edx mov %rbp,%rsi add $0x1,%ebx lea 0x0(,%rax,8),%rcx sub %rax,%rcx lea 0x0(,%rcx,8),%r14 lea (%r12,%r14,1),%rdi callq 10b0 <__strcpy_chk@plt> movl $0x1,0x84(%rsp,%r14,1) jmpq 1616 <func0+0xb6> lea 0x0(,%rdi,8),%rbp mov (%rsp),%r14 mov $0x32,%edx sub %rdi,%rbp shl $0x3,%rbp movdqu 0x50(%rsp,%rbp,1),%xmm6 lea 0x50(%rsp,%rbp,1),%rax add %rbp,%r14 lea (%r12,%rbp,1),%rsi movdqu 0x10(%rax),%xmm7 mov %r14,%rdi movaps %xmm6,0x10(%rsp) movdqu 0x20(%rax),%xmm6 mov 0x30(%rax),%rax movaps %xmm7,0x20(%rsp) mov %rax,0x40(%rsp) movaps %xmm6,0x30(%rsp) callq 10b0 <__strcpy_chk@plt> mov 0x84(%rsp,%rbp,1),%eax mov %eax,0x34(%r14) jmpq 1702 <func0+0x1a2> xor %ebx,%ebx jmpq 1702 <func0+0x1a2> callq 1080 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 1000h or [rsp+1030h+var_1030], 0 sub rsp, 648h mov [rsp+1678h+var_1670], rcx lea r12, [rsp+1678h+s2] mov rbp, rdi mov ecx, 2BCh mov [rsp+1678h+var_1678], rdx mov rdi, r12 mov rax, fs:28h mov [rsp+1678h+var_40], rax xor eax, eax rep stosq test esi, esi jle loc_17EC movsxd rsi, esi xor ebx, ebx lea rax, [rsi+rsi*4] lea rax, [rax+rax*4] lea r13, [rbp+rax*2+0] nop word ptr [rax+rax+00h] loc_15D0: test ebx, ebx jle loc_1740 loc_15D8: mov r15, r12 xor r14d, r14d jmp short loc_15F1 loc_15E0: add r14d, 1 add r15, 38h ; '8' cmp r14d, ebx jz loc_1740 loc_15F1: mov rsi, r15; s2 mov rdi, rbp; s1 call _strcmp test eax, eax jnz short loc_15E0 movsxd rdx, r14d add rbp, 32h ; '2' lea rax, ds:0[rdx*8] sub rax, rdx add [rsp+rax*8+1678h+var_15F4], 1 cmp rbp, r13 jnz short loc_15D8 loc_161F: test ebx, ebx jle loc_1703 mov r8, [rsp+1678h+var_1678] mov rbp, r12 xor r13d, r13d loc_1631: movsxd rdi, r13d add r13d, 1 cmp r13d, ebx jz loc_1788 mov esi, [rbp+34h] mov rdx, rbp mov eax, r13d nop word ptr [rax+rax+00h] loc_1650: mov ecx, [rdx+6Ch] cmp ecx, esi jle short loc_165C mov esi, ecx movsxd rdi, eax loc_165C: add eax, 1 add rdx, 38h ; '8' cmp eax, ebx jnz short loc_1650 lea rax, ds:0[rdi*8] movdqu xmm2, xmmword ptr [rbp+0] movdqu xmm1, xmmword ptr [rbp+10h] sub rax, rdi movdqu xmm0, xmmword ptr [rbp+20h] mov rcx, [rbp+30h] mov rdi, r8 shl rax, 3 movaps [rsp+1678h+var_1668], xmm2 movdqu xmm3, xmmword ptr [rsp+rax+1678h+s2] lea rdx, [rsp+rax+1678h+s2] mov [rsp+1678h+var_1638], rcx movaps [rsp+1678h+var_1658], xmm1 movups xmmword ptr [rbp+0], xmm3 movdqu xmm4, xmmword ptr [rdx+10h] movaps [rsp+1678h+var_1648], xmm0 movups xmmword ptr [rbp+10h], xmm4 movdqu xmm5, xmmword ptr [rdx+20h] movups xmmword ptr [rbp+20h], xmm5 mov rsi, [rdx+30h] mov [rbp+30h], rsi mov rsi, rbp add rbp, 38h ; '8' movups xmmword ptr [rsp+rax+1678h+s2], xmm2 mov [rdx+30h], rcx movups xmmword ptr [rdx+10h], xmm1 movups xmmword ptr [rdx+20h], xmm0 mov edx, 32h ; '2' call ___strcpy_chk mov r8, rax mov eax, [rbp-4] add r8, 38h ; '8' mov [r8-4], eax cmp r13d, 4 jnz loc_1631 loc_1703: mov eax, 4 cmp ebx, eax cmovle eax, ebx loc_170D: mov rcx, [rsp+1678h+var_1670] mov [rcx], eax mov rax, [rsp+1678h+var_40] sub rax, fs:28h jnz loc_17F3 add rsp, 1648h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1740: movsxd rax, ebx mov rsi, rbp mov edx, 32h ; '2' add rbp, 32h ; '2' lea rcx, ds:0[rax*8] add ebx, 1 sub rcx, rax lea r14, ds:0[rcx*8] lea rdi, [r12+r14] call ___strcpy_chk mov [rsp+r14+1678h+var_15F4], 1 cmp r13, rbp jnz loc_15D0 jmp loc_161F loc_1788: lea rbp, ds:0[rdi*8] mov r14, [rsp+1678h+var_1678] mov edx, 32h ; '2' sub rbp, rdi shl rbp, 3 movdqu xmm6, xmmword ptr [rsp+rbp+1678h+s2] lea rax, [rsp+rbp+1678h+s2] add r14, rbp lea rsi, [r12+rbp] movdqu xmm7, xmmword ptr [rax+10h] mov rdi, r14 movaps [rsp+1678h+var_1668], xmm6 movdqu xmm6, xmmword ptr [rax+20h] mov rax, [rax+30h] movaps [rsp+1678h+var_1658], xmm7 mov [rsp+1678h+var_1638], rax movaps [rsp+1678h+var_1648], xmm6 call ___strcpy_chk mov eax, [rsp+rbp+1678h+var_15F4] mov [r14+34h], eax jmp loc_1703 loc_17EC: xor eax, eax jmp loc_170D loc_17F3: call ___stack_chk_fail
unsigned long long func0(char *s1, int a2, long long a3, int *a4) { const char *v4; // rbp int v5; // ebx char *v6; // r13 char *v7; // r15 int v8; // r14d long long v9; // r8 __m128i *v10; // rbp int v11; // r13d long long v12; // rdi __int32 v13; // esi __m128i *v14; // rdx int v15; // eax __m128i v16; // xmm0 __m128i *v17; // rdx __m128i *v18; // rsi long long v19; // rax int v20; // eax long long v22; // rax const char *v23; // rsi long long v24; // rcx long long v25; // r14 __m128i v28; // [rsp+10h] [rbp-1668h] __m128i v29; // [rsp+20h] [rbp-1658h] long long v30; // [rsp+40h] [rbp-1638h] char s2[5608]; // [rsp+50h] [rbp-1628h] BYREF unsigned long long v32; // [rsp+1638h] [rbp-40h] v4 = s1; v32 = __readfsqword(0x28u); memset(s2, 0, 0x15E0uLL); if ( a2 <= 0 ) { v20 = 0; } else { v5 = 0; v6 = &s1[50 * a2]; while ( v5 <= 0 ) { LABEL_19: v22 = v5; v23 = v4; v4 += 50; v24 = 8LL * v5++; v25 = 8 * (v24 - v22); __strcpy_chk(&s2[v25], v23, 50LL); *(_DWORD *)&s2[v25 + 52] = 1; if ( v6 == v4 ) goto LABEL_8; } do { v7 = s2; v8 = 0; while ( strcmp(v4, v7) ) { ++v8; v7 += 56; if ( v8 == v5 ) goto LABEL_19; } v4 += 50; ++*(_DWORD *)&s2[56 * v8 + 52]; } while ( v4 != v6 ); LABEL_8: if ( v5 > 0 ) { v9 = a3; v10 = (__m128i *)s2; v11 = 0; while ( 1 ) { v12 = v11++; if ( v11 == v5 ) break; v13 = v10[3].m128i_i32[1]; v14 = v10; v15 = v11; do { if ( v14[6].m128i_i32[3] > v13 ) { v13 = v14[6].m128i_i32[3]; v12 = v15; } ++v15; v14 = (__m128i *)((char *)v14 + 56); } while ( v15 != v5 ); v16 = _mm_loadu_si128(v10 + 2); v28 = _mm_loadu_si128(v10); v17 = (__m128i *)&s2[56 * v12]; v30 = v10[3].m128i_i64[0]; v29 = _mm_loadu_si128(v10 + 1); *v10 = _mm_loadu_si128(v17); v10[1] = _mm_loadu_si128(v17 + 1); v10[2] = _mm_loadu_si128(v17 + 2); v10[3].m128i_i64[0] = v17[3].m128i_i64[0]; v18 = v10; v10 = (__m128i *)((char *)v10 + 56); *v17 = v28; v17[3].m128i_i64[0] = v30; v17[1] = v29; v17[2] = v16; v19 = __strcpy_chk(v9, v18, 50LL); v9 = v19 + 56; *(_DWORD *)(v19 + 52) = v10[-1].m128i_i32[3]; if ( v11 == 4 ) goto LABEL_16; } __strcpy_chk(56 * v12 + a3, &s2[56 * v12], 50LL); *(_DWORD *)(56 * v12 + a3 + 52) = *(_DWORD *)&s2[56 * v12 + 52]; } LABEL_16: v20 = 4; if ( v5 <= 4 ) v20 = v5; } *a4 = v20; return v32 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x1000 OR qword ptr [RSP],0x0 SUB RSP,0x648 MOV qword ptr [RSP + 0x8],RCX LEA R12,[RSP + 0x50] MOV RBP,RDI MOV ECX,0x2bc MOV qword ptr [RSP],RDX MOV RDI,R12 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1638],RAX XOR EAX,EAX STOSQ.REP RDI TEST ESI,ESI JLE 0x001017ec MOVSXD RSI,ESI XOR EBX,EBX LEA RAX,[RSI + RSI*0x4] LEA RAX,[RAX + RAX*0x4] LEA R13,[RBP + RAX*0x2] NOP word ptr [RAX + RAX*0x1] LAB_001015d0: TEST EBX,EBX JLE 0x00101740 LAB_001015d8: MOV R15,R12 XOR R14D,R14D JMP 0x001015f1 LAB_001015e0: ADD R14D,0x1 ADD R15,0x38 CMP R14D,EBX JZ 0x00101740 LAB_001015f1: MOV RSI,R15 MOV RDI,RBP CALL 0x001010a0 TEST EAX,EAX JNZ 0x001015e0 MOVSXD RDX,R14D ADD RBP,0x32 LEA RAX,[RDX*0x8] SUB RAX,RDX ADD dword ptr [RSP + RAX*0x8 + 0x84],0x1 CMP RBP,R13 JNZ 0x001015d8 LAB_0010161f: TEST EBX,EBX JLE 0x00101703 MOV R8,qword ptr [RSP] MOV RBP,R12 XOR R13D,R13D LAB_00101631: MOVSXD RDI,R13D ADD R13D,0x1 CMP R13D,EBX JZ 0x00101788 MOV ESI,dword ptr [RBP + 0x34] MOV RDX,RBP MOV EAX,R13D NOP word ptr [RAX + RAX*0x1] LAB_00101650: MOV ECX,dword ptr [RDX + 0x6c] CMP ECX,ESI JLE 0x0010165c MOV ESI,ECX MOVSXD RDI,EAX LAB_0010165c: ADD EAX,0x1 ADD RDX,0x38 CMP EAX,EBX JNZ 0x00101650 LEA RAX,[RDI*0x8] MOVDQU XMM2,xmmword ptr [RBP] MOVDQU XMM1,xmmword ptr [RBP + 0x10] SUB RAX,RDI MOVDQU XMM0,xmmword ptr [RBP + 0x20] MOV RCX,qword ptr [RBP + 0x30] MOV RDI,R8 SHL RAX,0x3 MOVAPS xmmword ptr [RSP + 0x10],XMM2 MOVDQU XMM3,xmmword ptr [RSP + RAX*0x1 + 0x50] LEA RDX,[RSP + RAX*0x1 + 0x50] MOV qword ptr [RSP + 0x40],RCX MOVAPS xmmword ptr [RSP + 0x20],XMM1 MOVUPS xmmword ptr [RBP],XMM3 MOVDQU XMM4,xmmword ptr [RDX + 0x10] MOVAPS xmmword ptr [RSP + 0x30],XMM0 MOVUPS xmmword ptr [RBP + 0x10],XMM4 MOVDQU XMM5,xmmword ptr [RDX + 0x20] MOVUPS xmmword ptr [RBP + 0x20],XMM5 MOV RSI,qword ptr [RDX + 0x30] MOV qword ptr [RBP + 0x30],RSI MOV RSI,RBP ADD RBP,0x38 MOVUPS xmmword ptr [RSP + RAX*0x1 + 0x50],XMM2 MOV qword ptr [RDX + 0x30],RCX MOVUPS xmmword ptr [RDX + 0x10],XMM1 MOVUPS xmmword ptr [RDX + 0x20],XMM0 MOV EDX,0x32 CALL 0x001010b0 MOV R8,RAX MOV EAX,dword ptr [RBP + -0x4] ADD R8,0x38 MOV dword ptr [R8 + -0x4],EAX CMP R13D,0x4 JNZ 0x00101631 LAB_00101703: MOV EAX,0x4 CMP EBX,EAX CMOVLE EAX,EBX LAB_0010170d: MOV RCX,qword ptr [RSP + 0x8] MOV dword ptr [RCX],EAX MOV RAX,qword ptr [RSP + 0x1638] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017f3 ADD RSP,0x1648 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101740: MOVSXD RAX,EBX MOV RSI,RBP MOV EDX,0x32 ADD RBP,0x32 LEA RCX,[RAX*0x8] ADD EBX,0x1 SUB RCX,RAX LEA R14,[RCX*0x8] LEA RDI,[R12 + R14*0x1] CALL 0x001010b0 MOV dword ptr [RSP + R14*0x1 + 0x84],0x1 CMP R13,RBP JNZ 0x001015d0 JMP 0x0010161f LAB_00101788: LEA RBP,[RDI*0x8] MOV R14,qword ptr [RSP] MOV EDX,0x32 SUB RBP,RDI SHL RBP,0x3 MOVDQU XMM6,xmmword ptr [RSP + RBP*0x1 + 0x50] LEA RAX,[RSP + RBP*0x1 + 0x50] ADD R14,RBP LEA RSI,[R12 + RBP*0x1] MOVDQU XMM7,xmmword ptr [RAX + 0x10] MOV RDI,R14 MOVAPS xmmword ptr [RSP + 0x10],XMM6 MOVDQU XMM6,xmmword ptr [RAX + 0x20] MOV RAX,qword ptr [RAX + 0x30] MOVAPS xmmword ptr [RSP + 0x20],XMM7 MOV qword ptr [RSP + 0x40],RAX MOVAPS xmmword ptr [RSP + 0x30],XMM6 CALL 0x001010b0 MOV EAX,dword ptr [RSP + RBP*0x1 + 0x84] MOV dword ptr [R14 + 0x34],EAX JMP 0x00101703 LAB_001017ec: XOR EAX,EAX JMP 0x0010170d LAB_001017f3: CALL 0x00101080
void func0(char *param_1,int param_2,long param_3,int *param_4) { int *piVar1; int8 uVar2; int8 uVar3; int8 uVar4; int8 uVar5; int8 uVar6; int8 uVar7; int8 uVar8; int8 uVar9; int iVar10; int iVar11; long lVar12; char *pcVar13; int iVar14; char *pcVar15; long lVar16; int iVar17; long in_FS_OFFSET; char local_1628 [8]; int8 auStack_1620 [5]; int8 local_15f8; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); pcVar15 = local_1628; for (lVar12 = 700; lVar12 != 0; lVar12 = lVar12 + -1) { pcVar15[0] = '\0'; pcVar15[1] = '\0'; pcVar15[2] = '\0'; pcVar15[3] = '\0'; pcVar15[4] = '\0'; pcVar15[5] = '\0'; pcVar15[6] = '\0'; pcVar15[7] = '\0'; pcVar15 = pcVar15 + 8; } if (param_2 < 1) { iVar17 = 0; } else { iVar14 = 0; pcVar15 = param_1; do { if (0 < iVar14) { do { iVar17 = 0; pcVar13 = local_1628; while (iVar10 = strcmp(pcVar15,pcVar13), iVar10 != 0) { iVar17 = iVar17 + 1; pcVar13 = pcVar13 + 0x38; if (iVar17 == iVar14) goto LAB_00101740; } pcVar15 = pcVar15 + 0x32; piVar1 = (int *)((long)&local_15f8 + (long)iVar17 * 0x38 + 4); *piVar1 = *piVar1 + 1; } while (pcVar15 != param_1 + (long)param_2 * 0x32); break; } LAB_00101740: lVar12 = (long)iVar14; pcVar13 = pcVar15 + 0x32; iVar14 = iVar14 + 1; __strcpy_chk(local_1628 + lVar12 * 0x38,pcVar15,0x32); *(int4 *)((long)&local_15f8 + lVar12 * 0x38 + 4) = 1; pcVar15 = pcVar13; } while (param_1 + (long)param_2 * 0x32 != pcVar13); if (0 < iVar14) { iVar17 = 0; pcVar15 = local_1628; lVar12 = param_3; do { lVar16 = (long)iVar17; iVar17 = iVar17 + 1; if (iVar17 == iVar14) { param_3 = param_3 + lVar16 * 0x38; __strcpy_chk(param_3,local_1628 + lVar16 * 0x38,0x32); *(int4 *)(param_3 + 0x34) = *(int4 *)((long)&local_15f8 + lVar16 * 0x38 + 4); break; } iVar10 = *(int *)(pcVar15 + 0x34); pcVar13 = pcVar15; iVar11 = iVar17; do { if (iVar10 < *(int *)(pcVar13 + 0x6c)) { lVar16 = (long)iVar11; iVar10 = *(int *)(pcVar13 + 0x6c); } iVar11 = iVar11 + 1; pcVar13 = pcVar13 + 0x38; } while (iVar11 != iVar14); uVar3 = *(int8 *)pcVar15; uVar4 = *(int8 *)(pcVar15 + 8); uVar5 = *(int8 *)(pcVar15 + 0x10); uVar6 = *(int8 *)(pcVar15 + 0x18); uVar7 = *(int8 *)(pcVar15 + 0x20); uVar8 = *(int8 *)(pcVar15 + 0x28); uVar2 = *(int8 *)(pcVar15 + 0x30); uVar9 = auStack_1620[lVar16 * 7]; *(int8 *)pcVar15 = auStack_1620[lVar16 * 7 + -1]; *(int8 *)(pcVar15 + 8) = uVar9; uVar9 = auStack_1620[lVar16 * 7 + 2]; *(int8 *)(pcVar15 + 0x10) = auStack_1620[lVar16 * 7 + 1]; *(int8 *)(pcVar15 + 0x18) = uVar9; uVar9 = auStack_1620[lVar16 * 7 + 4]; *(int8 *)(pcVar15 + 0x20) = auStack_1620[lVar16 * 7 + 3]; *(int8 *)(pcVar15 + 0x28) = uVar9; *(int8 *)(pcVar15 + 0x30) = (&local_15f8)[lVar16 * 7]; auStack_1620[lVar16 * 7 + -1] = uVar3; auStack_1620[lVar16 * 7] = uVar4; (&local_15f8)[lVar16 * 7] = uVar2; auStack_1620[lVar16 * 7 + 1] = uVar5; auStack_1620[lVar16 * 7 + 2] = uVar6; auStack_1620[lVar16 * 7 + 3] = uVar7; auStack_1620[lVar16 * 7 + 4] = uVar8; lVar16 = __strcpy_chk(lVar12,pcVar15,0x32); lVar12 = lVar16 + 0x38; *(int4 *)(lVar16 + 0x34) = *(int4 *)(pcVar15 + 0x34); pcVar15 = pcVar15 + 0x38; } while (iVar17 != 4); } iVar17 = 4; if (iVar14 < 5) { iVar17 = iVar14; } } *param_4 = iVar17; if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
3,948
func0
#include <assert.h>
float func0(float l, float b, float h) { return ((l * b * h) / 2); }
int main() { assert(func0(10, 8, 6) == 240); assert(func0(3, 2, 2) == 6); assert(func0(1, 2, 1) == 1); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp movss %xmm0,-0x4(%rbp) movss %xmm1,-0x8(%rbp) movss %xmm2,-0xc(%rbp) movss -0x4(%rbp),%xmm0 mulss -0x8(%rbp),%xmm0 mulss -0xc(%rbp),%xmm0 movss 0xf11(%rip),%xmm1 divss %xmm1,%xmm0 pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp movss [rbp+var_4], xmm0 movss [rbp+var_8], xmm1 movss [rbp+var_C], xmm2 movss xmm0, [rbp+var_4] mulss xmm0, [rbp+var_8] mulss xmm0, [rbp+var_C] movss xmm1, cs:dword_2068 divss xmm0, xmm1 pop rbp retn
float func0(float a1, float a2, float a3) { return (float)((float)(a1 * a2) * a3) / 2.0; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOVSS dword ptr [RBP + -0x4],XMM0 MOVSS dword ptr [RBP + -0x8],XMM1 MOVSS dword ptr [RBP + -0xc],XMM2 MOVSS XMM0,dword ptr [RBP + -0x4] MULSS XMM0,dword ptr [RBP + -0x8] MULSS XMM0,dword ptr [RBP + -0xc] MOVSS XMM1,dword ptr [0x00102068] DIVSS XMM0,XMM1 POP RBP RET
float func0(float param_1,float param_2,float param_3) { return (param_1 * param_2 * param_3) / DAT_00102068; }
3,949
func0
#include <assert.h>
float func0(float l, float b, float h) { return ((l * b * h) / 2); }
int main() { assert(func0(10, 8, 6) == 240); assert(func0(3, 2, 2) == 6); assert(func0(1, 2, 1) == 1); return 0; }
O1
c
func0: endbr64 mulss %xmm1,%xmm0 mulss %xmm2,%xmm0 mulss 0xec7(%rip),%xmm0 retq
func0: endbr64 mulss xmm0, xmm1 mulss xmm0, xmm2 mulss xmm0, cs:dword_2004 retn
float func0(float a1, float a2, float a3) { return (float)((float)(a1 * a2) * a3) * 0.5; }
func0: ENDBR64 MULSS XMM0,XMM1 MULSS XMM0,XMM2 MULSS XMM0,dword ptr [0x00102004] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ float func0(float param_1,float param_2,float param_3) { return param_1 * param_2 * param_3 * _DAT_00102004; }
3,950
func0
#include <assert.h>
float func0(float l, float b, float h) { return ((l * b * h) / 2); }
int main() { assert(func0(10, 8, 6) == 240); assert(func0(3, 2, 2) == 6); assert(func0(1, 2, 1) == 1); return 0; }
O2
c
func0: endbr64 mulss %xmm1,%xmm0 mulss %xmm2,%xmm0 mulss 0xeb0(%rip),%xmm0 retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 mulss xmm0, xmm1 mulss xmm0, xmm2 mulss xmm0, cs:dword_2004 retn
float func0(float a1, float a2, float a3) { return (float)((float)(a1 * a2) * a3) * 0.5; }
func0: ENDBR64 MULSS XMM0,XMM1 MULSS XMM0,XMM2 MULSS XMM0,dword ptr [0x00102004] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ float func0(float param_1,float param_2,float param_3) { return param_1 * param_2 * param_3 * _DAT_00102004; }
3,951
func0
#include <assert.h>
float func0(float l, float b, float h) { return ((l * b * h) / 2); }
int main() { assert(func0(10, 8, 6) == 240); assert(func0(3, 2, 2) == 6); assert(func0(1, 2, 1) == 1); return 0; }
O3
c
func0: endbr64 mulss %xmm1,%xmm0 mulss %xmm2,%xmm0 mulss 0xeb0(%rip),%xmm0 retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 mulss xmm0, xmm1 mulss xmm0, xmm2 mulss xmm0, cs:dword_2004 retn
float func0(float a1, float a2, float a3) { return (float)((float)(a1 * a2) * a3) * 0.5; }
func0: ENDBR64 MULSS XMM0,XMM1 MULSS XMM0,XMM2 MULSS XMM0,dword ptr [0x00102004] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ float func0(float param_1,float param_2,float param_3) { return param_1 * param_2 * param_3 * _DAT_00102004; }
3,952
func0
#include <assert.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
char** func0(const char* text, int* count) { char** result = NULL; *count = 0; int len = strlen(text); int i = 0; while (i < len) { if (islower((unsigned char)text[i])) { int start = i; i++; while (i < len && !islower((unsigned char)text[i])) { i++; } int end = i; int substr_len = end - start; char* substr = (char*)malloc(substr_len + 1); strncpy(substr, text + start, substr_len); substr[substr_len] = '\0'; result = (char**)realloc(result, sizeof(char*) * (*count + 1)); result[*count] = substr; (*count)++; } else { i++; } } return result; }
int main() { // Test case 1 int count1; char** res1 = func0("AbCd", &count1); assert(count1 == 2); assert(strcmp(res1[0], "bC") == 0); assert(strcmp(res1[1], "d") == 0); for(int i = 0; i < count1; i++) free(res1[i]); free(res1); // Test case 2 int count2; char** res2 = func0("Python", &count2); assert(count2 == 5); assert(strcmp(res2[0], "y") == 0); assert(strcmp(res2[1], "t") == 0); assert(strcmp(res2[2], "h") == 0); assert(strcmp(res2[3], "o") == 0); assert(strcmp(res2[4], "n") == 0); for(int i = 0; i < count2; i++) free(res2[i]); free(res2); // Test case 3 int count3; char** res3 = func0("Programming", &count3); assert(count3 == 10); assert(strcmp(res3[0], "r") == 0); assert(strcmp(res3[1], "o") == 0); assert(strcmp(res3[2], "g") == 0); assert(strcmp(res3[3], "r") == 0); assert(strcmp(res3[4], "a") == 0); assert(strcmp(res3[5], "m") == 0); assert(strcmp(res3[6], "m") == 0); assert(strcmp(res3[7], "i") == 0); assert(strcmp(res3[8], "n") == 0); assert(strcmp(res3[9], "g") == 0); for(int i = 0; i < count3; i++) free(res3[i]); free(res3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x40,%rsp mov %rdi,-0x38(%rbp) mov %rsi,-0x40(%rbp) movq $0x0,-0x10(%rbp) mov -0x40(%rbp),%rax movl $0x0,(%rax) mov -0x38(%rbp),%rax mov %rax,%rdi callq 10f0 <strlen@plt> mov %eax,-0x20(%rbp) movl $0x0,-0x24(%rbp) jmpq 13b4 <func0+0x16b> callq 1150 <__ctype_b_loc@plt> mov (%rax),%rax mov -0x24(%rbp),%edx movslq %edx,%rcx mov -0x38(%rbp),%rdx add %rcx,%rdx movzbl (%rdx),%edx movzbl %dl,%edx add %rdx,%rdx add %rdx,%rax movzwl (%rax),%eax movzwl %ax,%eax and $0x200,%eax test %eax,%eax je 13b0 <func0+0x167> mov -0x24(%rbp),%eax mov %eax,-0x1c(%rbp) addl $0x1,-0x24(%rbp) jmp 12ce <func0+0x85> addl $0x1,-0x24(%rbp) mov -0x24(%rbp),%eax cmp -0x20(%rbp),%eax jge 1306 <func0+0xbd> callq 1150 <__ctype_b_loc@plt> mov (%rax),%rax mov -0x24(%rbp),%edx movslq %edx,%rcx mov -0x38(%rbp),%rdx add %rcx,%rdx movzbl (%rdx),%edx movzbl %dl,%edx add %rdx,%rdx add %rdx,%rax movzwl (%rax),%eax movzwl %ax,%eax and $0x200,%eax test %eax,%eax je 12ca <func0+0x81> mov -0x24(%rbp),%eax mov %eax,-0x18(%rbp) mov -0x18(%rbp),%eax sub -0x1c(%rbp),%eax mov %eax,-0x14(%rbp) mov -0x14(%rbp),%eax add $0x1,%eax cltq mov %rax,%rdi callq 1130 <malloc@plt> mov %rax,-0x8(%rbp) mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x1c(%rbp),%eax movslq %eax,%rcx mov -0x38(%rbp),%rax add %rax,%rcx mov -0x8(%rbp),%rax mov %rcx,%rsi mov %rax,%rdi callq 10e0 <strncpy@plt> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x8(%rbp),%rax add %rdx,%rax movb $0x0,(%rax) mov -0x40(%rbp),%rax mov (%rax),%eax add $0x1,%eax cltq lea 0x0(,%rax,8),%rdx mov -0x10(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1140 <realloc@plt> mov %rax,-0x10(%rbp) mov -0x40(%rbp),%rax mov (%rax),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x10(%rbp),%rax add %rax,%rdx mov -0x8(%rbp),%rax mov %rax,(%rdx) mov -0x40(%rbp),%rax mov (%rax),%eax lea 0x1(%rax),%edx mov -0x40(%rbp),%rax mov %edx,(%rax) jmp 13b4 <func0+0x16b> addl $0x1,-0x24(%rbp) mov -0x24(%rbp),%eax cmp -0x20(%rbp),%eax jl 128a <func0+0x41> mov -0x10(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 40h mov [rbp+s], rdi mov [rbp+var_40], rsi mov [rbp+ptr], 0 mov rax, [rbp+var_40] mov dword ptr [rax], 0 mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_20], eax mov [rbp+var_24], 0 jmp loc_13B4 loc_128A: call ___ctype_b_loc mov rax, [rax] mov edx, [rbp+var_24] movsxd rcx, edx mov rdx, [rbp+s] add rdx, rcx movzx edx, byte ptr [rdx] movzx edx, dl add rdx, rdx add rax, rdx movzx eax, word ptr [rax] movzx eax, ax and eax, 200h test eax, eax jz loc_13B0 mov eax, [rbp+var_24] mov [rbp+var_1C], eax add [rbp+var_24], 1 jmp short loc_12CE loc_12CA: add [rbp+var_24], 1 loc_12CE: mov eax, [rbp+var_24] cmp eax, [rbp+var_20] jge short loc_1306 call ___ctype_b_loc mov rax, [rax] mov edx, [rbp+var_24] movsxd rcx, edx mov rdx, [rbp+s] add rdx, rcx movzx edx, byte ptr [rdx] movzx edx, dl add rdx, rdx add rax, rdx movzx eax, word ptr [rax] movzx eax, ax and eax, 200h test eax, eax jz short loc_12CA loc_1306: mov eax, [rbp+var_24] mov [rbp+var_18], eax mov eax, [rbp+var_18] sub eax, [rbp+var_1C] mov [rbp+var_14], eax mov eax, [rbp+var_14] add eax, 1 cdqe mov rdi, rax; size call _malloc mov [rbp+dest], rax mov eax, [rbp+var_14] movsxd rdx, eax; n mov eax, [rbp+var_1C] movsxd rcx, eax mov rax, [rbp+s] add rcx, rax mov rax, [rbp+dest] mov rsi, rcx; src mov rdi, rax; dest call _strncpy mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+dest] add rax, rdx mov byte ptr [rax], 0 mov rax, [rbp+var_40] mov eax, [rax] add eax, 1 cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+ptr] mov rsi, rdx; size mov rdi, rax; ptr call _realloc mov [rbp+ptr], rax mov rax, [rbp+var_40] mov eax, [rax] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+ptr] add rdx, rax mov rax, [rbp+dest] mov [rdx], rax mov rax, [rbp+var_40] mov eax, [rax] lea edx, [rax+1] mov rax, [rbp+var_40] mov [rax], edx jmp short loc_13B4 loc_13B0: add [rbp+var_24], 1 loc_13B4: mov eax, [rbp+var_24] cmp eax, [rbp+var_20] jl loc_128A mov rax, [rbp+ptr] leave retn
void * func0(const char *a1, _DWORD *a2) { int v3; // [rsp+1Ch] [rbp-24h] int v4; // [rsp+20h] [rbp-20h] int v5; // [rsp+24h] [rbp-1Ch] void *ptr; // [rsp+30h] [rbp-10h] char *dest; // [rsp+38h] [rbp-8h] ptr = 0LL; *a2 = 0; v4 = strlen(a1); v3 = 0; while ( v3 < v4 ) { if ( ((*__ctype_b_loc())[(unsigned __int8)a1[v3]] & 0x200) != 0 ) { v5 = v3++; while ( v3 < v4 && ((*__ctype_b_loc())[(unsigned __int8)a1[v3]] & 0x200) == 0 ) ++v3; dest = (char *)malloc(v3 - v5 + 1); strncpy(dest, &a1[v5], v3 - v5); dest[v3 - v5] = 0; ptr = realloc(ptr, 8LL * (*a2 + 1)); *((_QWORD *)ptr + (int)(*a2)++) = dest; } else { ++v3; } } return ptr; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 MOV qword ptr [RBP + -0x38],RDI MOV qword ptr [RBP + -0x40],RSI MOV qword ptr [RBP + -0x10],0x0 MOV RAX,qword ptr [RBP + -0x40] MOV dword ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x001010f0 MOV dword ptr [RBP + -0x20],EAX MOV dword ptr [RBP + -0x24],0x0 JMP 0x001013b4 LAB_0010128a: CALL 0x00101150 MOV RAX,qword ptr [RAX] MOV EDX,dword ptr [RBP + -0x24] MOVSXD RCX,EDX MOV RDX,qword ptr [RBP + -0x38] ADD RDX,RCX MOVZX EDX,byte ptr [RDX] MOVZX EDX,DL ADD RDX,RDX ADD RAX,RDX MOVZX EAX,word ptr [RAX] MOVZX EAX,AX AND EAX,0x200 TEST EAX,EAX JZ 0x001013b0 MOV EAX,dword ptr [RBP + -0x24] MOV dword ptr [RBP + -0x1c],EAX ADD dword ptr [RBP + -0x24],0x1 JMP 0x001012ce LAB_001012ca: ADD dword ptr [RBP + -0x24],0x1 LAB_001012ce: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x20] JGE 0x00101306 CALL 0x00101150 MOV RAX,qword ptr [RAX] MOV EDX,dword ptr [RBP + -0x24] MOVSXD RCX,EDX MOV RDX,qword ptr [RBP + -0x38] ADD RDX,RCX MOVZX EDX,byte ptr [RDX] MOVZX EDX,DL ADD RDX,RDX ADD RAX,RDX MOVZX EAX,word ptr [RAX] MOVZX EAX,AX AND EAX,0x200 TEST EAX,EAX JZ 0x001012ca LAB_00101306: MOV EAX,dword ptr [RBP + -0x24] MOV dword ptr [RBP + -0x18],EAX MOV EAX,dword ptr [RBP + -0x18] SUB EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RBP + -0x14],EAX MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 CDQE MOV RDI,RAX CALL 0x00101130 MOV qword ptr [RBP + -0x8],RAX MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV EAX,dword ptr [RBP + -0x1c] MOVSXD RCX,EAX MOV RAX,qword ptr [RBP + -0x38] ADD RCX,RAX MOV RAX,qword ptr [RBP + -0x8] MOV RSI,RCX MOV RDI,RAX CALL 0x001010e0 MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV byte ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x40] MOV EAX,dword ptr [RAX] ADD EAX,0x1 CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x10] MOV RSI,RDX MOV RDI,RAX CALL 0x00101140 MOV qword ptr [RBP + -0x10],RAX MOV RAX,qword ptr [RBP + -0x40] MOV EAX,dword ptr [RAX] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x10] ADD RDX,RAX MOV RAX,qword ptr [RBP + -0x8] MOV qword ptr [RDX],RAX MOV RAX,qword ptr [RBP + -0x40] MOV EAX,dword ptr [RAX] LEA EDX,[RAX + 0x1] MOV RAX,qword ptr [RBP + -0x40] MOV dword ptr [RAX],EDX JMP 0x001013b4 LAB_001013b0: ADD dword ptr [RBP + -0x24],0x1 LAB_001013b4: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x20] JL 0x0010128a MOV RAX,qword ptr [RBP + -0x10] LEAVE RET
void * func0(char *param_1,int *param_2) { int iVar1; int iVar2; size_t sVar3; ushort **ppuVar4; char *__dest; int local_2c; void *local_18; local_18 = (void *)0x0; *param_2 = 0; sVar3 = strlen(param_1); local_2c = 0; do { while( true ) { iVar1 = local_2c; if ((int)sVar3 <= local_2c) { return local_18; } ppuVar4 = __ctype_b_loc(); if (((*ppuVar4)[(byte)param_1[local_2c]] & 0x200) != 0) break; local_2c = local_2c + 1; } do { local_2c = local_2c + 1; if ((int)sVar3 <= local_2c) break; ppuVar4 = __ctype_b_loc(); } while (((*ppuVar4)[(byte)param_1[local_2c]] & 0x200) == 0); iVar2 = local_2c - iVar1; __dest = (char *)malloc((long)(iVar2 + 1)); strncpy(__dest,param_1 + iVar1,(long)iVar2); __dest[iVar2] = '\0'; local_18 = realloc(local_18,(long)(*param_2 + 1) * 8); *(char **)((long)*param_2 * 8 + (long)local_18) = __dest; *param_2 = *param_2 + 1; } while( true ); }
3,953
func0
#include <assert.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
char** func0(const char* text, int* count) { char** result = NULL; *count = 0; int len = strlen(text); int i = 0; while (i < len) { if (islower((unsigned char)text[i])) { int start = i; i++; while (i < len && !islower((unsigned char)text[i])) { i++; } int end = i; int substr_len = end - start; char* substr = (char*)malloc(substr_len + 1); strncpy(substr, text + start, substr_len); substr[substr_len] = '\0'; result = (char**)realloc(result, sizeof(char*) * (*count + 1)); result[*count] = substr; (*count)++; } else { i++; } } return result; }
int main() { // Test case 1 int count1; char** res1 = func0("AbCd", &count1); assert(count1 == 2); assert(strcmp(res1[0], "bC") == 0); assert(strcmp(res1[1], "d") == 0); for(int i = 0; i < count1; i++) free(res1[i]); free(res1); // Test case 2 int count2; char** res2 = func0("Python", &count2); assert(count2 == 5); assert(strcmp(res2[0], "y") == 0); assert(strcmp(res2[1], "t") == 0); assert(strcmp(res2[2], "h") == 0); assert(strcmp(res2[3], "o") == 0); assert(strcmp(res2[4], "n") == 0); for(int i = 0; i < count2; i++) free(res2[i]); free(res2); // Test case 3 int count3; char** res3 = func0("Programming", &count3); assert(count3 == 10); assert(strcmp(res3[0], "r") == 0); assert(strcmp(res3[1], "o") == 0); assert(strcmp(res3[2], "g") == 0); assert(strcmp(res3[3], "r") == 0); assert(strcmp(res3[4], "a") == 0); assert(strcmp(res3[5], "m") == 0); assert(strcmp(res3[6], "m") == 0); assert(strcmp(res3[7], "i") == 0); assert(strcmp(res3[8], "n") == 0); assert(strcmp(res3[9], "g") == 0); for(int i = 0; i < count3; i++) free(res3[i]); free(res3); return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x18,%rsp mov %rdi,%r12 movl $0x0,(%rsi) mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax sub $0x1,%rax test %eax,%eax jle 130e <func0+0x105> mov %rsi,%r15 mov %eax,%r13d callq 1110 <__ctype_b_loc@plt> mov %rax,(%rsp) mov $0x0,%esi movq $0x0,0x8(%rsp) jmp 126f <func0+0x66> add $0x1,%esi cmp %esi,%r13d jle 1317 <func0+0x10e> mov (%rsp),%rax mov (%rax),%rcx movslq %esi,%rbp add %r12,%rbp movzbl 0x0(%rbp),%eax testb $0x2,0x1(%rcx,%rax,2) je 1263 <func0+0x5a> lea 0x1(%rsi),%ebx cmp %ebx,%r13d jle 12ac <func0+0xa3> movslq %ebx,%rax mov %eax,%ebx movzbl (%r12,%rax,1),%edx testb $0x2,0x1(%rcx,%rdx,2) jne 12ac <func0+0xa3> lea 0x1(%rax),%ebx add $0x1,%rax cmp %eax,%r13d jg 1292 <func0+0x89> mov %ebx,%r14d sub %esi,%r14d lea 0x1(%r14),%edi movslq %edi,%rdi callq 10f0 <malloc@plt> movslq %r14d,%r14 mov %r14,%rdx mov %rbp,%rsi mov %rax,%rbp mov %rax,%rdi callq 10c0 <strncpy@plt> movb $0x0,0x0(%rbp,%r14,1) mov (%r15),%eax lea 0x1(%rax),%esi movslq %esi,%rsi shl $0x3,%rsi mov 0x8(%rsp),%rdi callq 1100 <realloc@plt> mov %rax,%rdi mov %rax,0x8(%rsp) mov (%r15),%eax movslq %eax,%rdx mov %rbp,(%rdi,%rdx,8) add $0x1,%eax mov %eax,(%r15) mov %ebx,%esi jmpq 1266 <func0+0x5d> movq $0x0,0x8(%rsp) mov 0x8(%rsp),%rax add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 18h mov [rsp+48h+var_48], rdi mov r15, rsi mov dword ptr [rsi], 0 call _strlen test eax, eax jle loc_1338 mov r12d, eax call ___ctype_b_loc mov r14, rax mov esi, 0 mov [rsp+48h+var_40], 0 jmp loc_131A loc_1293: lea ebx, [rsi+1] cmp r12d, ebx jle short loc_12B8 movsxd rax, ebx add rax, [rsp+48h+var_48] loc_12A2: movzx edx, byte ptr [rax] test byte ptr [rcx+rdx*2+1], 2 jnz short loc_12B8 add ebx, 1 add rax, 1 cmp r12d, ebx jnz short loc_12A2 loc_12B8: mov r13d, ebx sub r13d, esi lea edi, [r13+1] movsxd rdi, edi call _malloc movsxd r13, r13d mov rdx, r13 mov rsi, rbp mov rbp, rax mov rdi, rax call _strncpy mov byte ptr [rbp+r13+0], 0 mov eax, [r15] lea esi, [rax+1] movsxd rsi, esi shl rsi, 3 mov rdi, [rsp+48h+var_40] call _realloc mov rdi, rax mov [rsp+48h+var_40], rax mov eax, [r15] movsxd rdx, eax mov [rdi+rdx*8], rbp add eax, 1 mov [r15], eax mov esi, ebx loc_1315: cmp r12d, esi jle short loc_1341 loc_131A: mov rcx, [r14] movsxd rbp, esi add rbp, [rsp+48h+var_48] movzx eax, byte ptr [rbp+0] test byte ptr [rcx+rax*2+1], 2 jnz loc_1293 add esi, 1 jmp short loc_1315 loc_1338: mov [rsp+48h+var_40], 0 loc_1341: mov rax, [rsp+48h+var_40] add rsp, 18h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn
long long func0(long long a1, int *a2) { int v3; // eax int v4; // r12d _QWORD *v5; // r14 int v6; // esi int v7; // ebx unsigned __int8 *v8; // rax long long v9; // rbp int v10; // eax long long v12; // [rsp+8h] [rbp-40h] *a2 = 0; v3 = strlen(); if ( v3 <= 0 ) return 0LL; v4 = v3; v5 = (_QWORD *)__ctype_b_loc(); v6 = 0; v12 = 0LL; do { if ( (*(_BYTE *)(*v5 + 2LL * *(unsigned __int8 *)(a1 + v6) + 1) & 2) != 0 ) { v7 = v6 + 1; if ( v4 > v6 + 1 ) { v8 = (unsigned __int8 *)(a1 + v7); do { if ( (*(_BYTE *)(*v5 + 2LL * *v8 + 1) & 2) != 0 ) break; ++v7; ++v8; } while ( v4 != v7 ); } v9 = malloc(v7 - v6 + 1); strncpy(v9, a1 + v6, v7 - v6); *(_BYTE *)(v9 + v7 - v6) = 0; v12 = realloc(v12, 8LL * (*a2 + 1)); v10 = *a2; *(_QWORD *)(v12 + 8LL * *a2) = v9; *a2 = v10 + 1; v6 = v7; } else { ++v6; } } while ( v4 > v6 ); return v12; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x18 MOV qword ptr [RSP],RDI MOV R15,RSI MOV dword ptr [RSI],0x0 CALL 0x001010f0 TEST EAX,EAX JLE 0x00101338 MOV R12D,EAX CALL 0x00101150 MOV R14,RAX MOV ESI,0x0 MOV qword ptr [RSP + 0x8],0x0 JMP 0x0010131a LAB_00101293: LEA EBX,[RSI + 0x1] CMP R12D,EBX JLE 0x001012b8 MOVSXD RAX,EBX ADD RAX,qword ptr [RSP] LAB_001012a2: MOVZX EDX,byte ptr [RAX] TEST byte ptr [RCX + RDX*0x2 + 0x1],0x2 JNZ 0x001012b8 ADD EBX,0x1 ADD RAX,0x1 CMP R12D,EBX JNZ 0x001012a2 LAB_001012b8: MOV R13D,EBX SUB R13D,ESI LEA EDI,[R13 + 0x1] MOVSXD RDI,EDI CALL 0x00101130 MOVSXD R13,R13D MOV RDX,R13 MOV RSI,RBP MOV RBP,RAX MOV RDI,RAX CALL 0x001010e0 MOV byte ptr [RBP + R13*0x1],0x0 MOV EAX,dword ptr [R15] LEA ESI,[RAX + 0x1] MOVSXD RSI,ESI SHL RSI,0x3 MOV RDI,qword ptr [RSP + 0x8] CALL 0x00101140 MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX MOV EAX,dword ptr [R15] MOVSXD RDX,EAX MOV qword ptr [RDI + RDX*0x8],RBP ADD EAX,0x1 MOV dword ptr [R15],EAX MOV ESI,EBX LAB_00101315: CMP R12D,ESI JLE 0x00101341 LAB_0010131a: MOV RCX,qword ptr [R14] MOVSXD RBP,ESI ADD RBP,qword ptr [RSP] MOVZX EAX,byte ptr [RBP] TEST byte ptr [RCX + RAX*0x2 + 0x1],0x2 JNZ 0x00101293 ADD ESI,0x1 JMP 0x00101315 LAB_00101338: MOV qword ptr [RSP + 0x8],0x0 LAB_00101341: MOV RAX,qword ptr [RSP + 0x8] ADD RSP,0x18 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET
void * func0(char *param_1,int *param_2) { int iVar1; size_t sVar2; ushort **ppuVar3; byte *pbVar4; char *__dest; int iVar5; int iVar6; int iVar7; void *local_40; *param_2 = 0; sVar2 = strlen(param_1); iVar1 = (int)sVar2; if (iVar1 < 1) { local_40 = (void *)0x0; } else { ppuVar3 = __ctype_b_loc(); iVar6 = 0; local_40 = (void *)0x0; do { if ((*(byte *)((long)*ppuVar3 + (ulong)(byte)param_1[iVar6] * 2 + 1) & 2) == 0) { iVar6 = iVar6 + 1; } else { iVar5 = iVar6 + 1; if (iVar5 < iVar1) { pbVar4 = (byte *)(param_1 + iVar5); do { if ((*(byte *)((long)*ppuVar3 + (ulong)*pbVar4 * 2 + 1) & 2) != 0) break; iVar5 = iVar5 + 1; pbVar4 = pbVar4 + 1; } while (iVar1 != iVar5); } iVar7 = iVar5 - iVar6; __dest = (char *)malloc((long)(iVar7 + 1)); strncpy(__dest,param_1 + iVar6,(long)iVar7); __dest[iVar7] = '\0'; local_40 = realloc(local_40,(long)(*param_2 + 1) << 3); iVar6 = *param_2; *(char **)((long)local_40 + (long)iVar6 * 8) = __dest; *param_2 = iVar6 + 1; iVar6 = iVar5; } } while (iVar6 < iVar1); } return local_40; }
3,954
func0
#include <assert.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
char** func0(const char* text, int* count) { char** result = NULL; *count = 0; int len = strlen(text); int i = 0; while (i < len) { if (islower((unsigned char)text[i])) { int start = i; i++; while (i < len && !islower((unsigned char)text[i])) { i++; } int end = i; int substr_len = end - start; char* substr = (char*)malloc(substr_len + 1); strncpy(substr, text + start, substr_len); substr[substr_len] = '\0'; result = (char**)realloc(result, sizeof(char*) * (*count + 1)); result[*count] = substr; (*count)++; } else { i++; } } return result; }
int main() { // Test case 1 int count1; char** res1 = func0("AbCd", &count1); assert(count1 == 2); assert(strcmp(res1[0], "bC") == 0); assert(strcmp(res1[1], "d") == 0); for(int i = 0; i < count1; i++) free(res1[i]); free(res1); // Test case 2 int count2; char** res2 = func0("Python", &count2); assert(count2 == 5); assert(strcmp(res2[0], "y") == 0); assert(strcmp(res2[1], "t") == 0); assert(strcmp(res2[2], "h") == 0); assert(strcmp(res2[3], "o") == 0); assert(strcmp(res2[4], "n") == 0); for(int i = 0; i < count2; i++) free(res2[i]); free(res2); // Test case 3 int count3; char** res3 = func0("Programming", &count3); assert(count3 == 10); assert(strcmp(res3[0], "r") == 0); assert(strcmp(res3[1], "o") == 0); assert(strcmp(res3[2], "g") == 0); assert(strcmp(res3[3], "r") == 0); assert(strcmp(res3[4], "a") == 0); assert(strcmp(res3[5], "m") == 0); assert(strcmp(res3[6], "m") == 0); assert(strcmp(res3[7], "i") == 0); assert(strcmp(res3[8], "n") == 0); assert(strcmp(res3[9], "g") == 0); for(int i = 0; i < count3; i++) free(res3[i]); free(res3); return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 mov %rdi,%r13 push %r12 push %rbp push %rbx sub $0x28,%rsp movl $0x0,(%rsi) mov %rsi,0x8(%rsp) callq 10e0 <strlen@plt> test %eax,%eax jle 1802 <func0+0x162> mov %eax,%r14d xor %ebx,%ebx callq 1130 <__ctype_b_loc@plt> mov 0x8(%rsp),%rcx xor %r8d,%r8d mov (%rax),%r15 jmp 16f3 <func0+0x53> nopl 0x0(%rax) mov %edx,%ebx cmp %ebx,%r14d jle 17bd <func0+0x11d> movslq %ebx,%rbp lea 0x1(%rbx),%edx add %r13,%rbp movzbl 0x0(%rbp),%eax testb $0x2,0x1(%r15,%rax,2) je 16e8 <func0+0x48> movslq %edx,%rax cmp %edx,%r14d jg 1728 <func0+0x88> jmpq 17ed <func0+0x14d> nopl (%rax) lea 0x1(%rax),%edx add $0x1,%rax cmp %eax,%r14d jle 17d0 <func0+0x130> movzbl 0x0(%r13,%rax,1),%edx mov %eax,%r12d testb $0x2,0x1(%r15,%rdx,2) je 1718 <func0+0x78> sub %ebx,%r12d mov %eax,%ebx movslq %r12d,%rsi lea 0x1(%r12),%edi mov %rsi,0x8(%rsp) movslq %edi,%rdi mov %rcx,0x18(%rsp) mov %r8,0x10(%rsp) callq 1110 <malloc@plt> mov 0x8(%rsp),%rdx mov %rbp,%rsi mov %rax,%rdi mov %rax,%r12 callq 10d0 <strncpy@plt> mov 0x8(%rsp),%rax mov 0x18(%rsp),%rcx mov 0x10(%rsp),%r8 movb $0x0,(%r12,%rax,1) mov (%rcx),%eax mov %r8,%rdi mov %rcx,0x8(%rsp) lea 0x1(%rax),%esi movslq %esi,%rsi shl $0x3,%rsi callq 1120 <realloc@plt> mov 0x8(%rsp),%rcx mov %rax,%r8 movslq (%rcx),%rdx mov %rdx,%rax mov %r12,(%r8,%rdx,8) add $0x1,%eax mov %eax,(%rcx) cmp %ebx,%r14d jg 16f3 <func0+0x53> add $0x28,%rsp mov %r8,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov %edx,%r12d sub %ebx,%r12d mov %edx,%ebx lea 0x1(%r12),%edi movslq %r12d,%rax mov %rax,0x8(%rsp) movslq %edi,%rdi jmpq 174e <func0+0xae> movq $0x1,0x8(%rsp) mov %edx,%ebx mov $0x2,%edi jmpq 174e <func0+0xae> xor %r8d,%r8d jmp 17bd <func0+0x11d> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r15 mov r15, rsi push r14 push r13 mov r13, rdi push r12 push rbp push rbx sub rsp, 28h mov dword ptr [rsi], 0 call _strlen test eax, eax jle loc_17E9 mov ebp, eax xor ebx, ebx call ___ctype_b_loc xor r8d, r8d mov r12, [rax] jmp short loc_16EA loc_16E0: mov ebx, eax cmp ebx, ebp jge loc_17A1 loc_16EA: movsxd rsi, ebx lea eax, [rbx+1] add rsi, r13 movzx edx, byte ptr [rsi] test byte ptr [r12+rdx*2+1], 2 jz short loc_16E0 movsxd rdx, eax add rdx, r13 cmp ebp, eax jg short loc_171F jmp loc_17D4 loc_1710: add eax, 1 add rdx, 1 cmp ebp, eax jz loc_17B8 loc_171F: movzx ecx, byte ptr [rdx] test byte ptr [r12+rcx*2+1], 2 jz short loc_1710 mov r14d, eax sub r14d, ebx movsxd rbx, r14d lea edi, [r14+1] mov [rsp+58h+var_50], rbx movsxd rdi, edi mov ebx, eax loc_1741: mov [rsp+58h+var_40], r8 mov [rsp+58h+var_48], rsi call _malloc mov rdx, [rsp+58h+var_50] mov rsi, [rsp+58h+var_48] mov rdi, rax mov r14, rax call _strncpy mov rax, [rsp+58h+var_50] mov rdi, [rsp+58h+var_40] mov byte ptr [r14+rax], 0 mov eax, [r15] lea esi, [rax+1] movsxd rsi, esi shl rsi, 3 call _realloc movsxd rdx, dword ptr [r15] mov r8, rax mov rax, rdx mov [r8+rdx*8], r14 add eax, 1 mov [r15], eax cmp ebx, ebp jl loc_16EA loc_17A1: add rsp, 28h mov rax, r8 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_17B8: mov r14d, ebp sub r14d, ebx mov ebx, ebp lea edi, [r14+1] movsxd rax, r14d mov [rsp+58h+var_50], rax movsxd rdi, edi jmp loc_1741 loc_17D4: mov [rsp+58h+var_50], 1 mov ebx, eax mov edi, 2 jmp loc_1741 loc_17E9: xor r8d, r8d jmp short loc_17A1
long long func0(long long a1, int *a2) { int v4; // eax int v5; // ebp int v6; // ebx long long *v7; // rax long long v8; // r8 long long v9; // r12 int v10; // eax unsigned __int8 *v11; // rsi unsigned __int8 *v12; // rdx long long v13; // r14 int v14; // eax int v16; // r14d long long v17; // rdi long long v18; // [rsp+8h] [rbp-50h] long long v19; // [rsp+18h] [rbp-40h] *a2 = 0; v4 = strlen(); if ( v4 <= 0 ) return 0LL; v5 = v4; v6 = 0; v7 = (long long *)__ctype_b_loc(); v8 = 0LL; v9 = *v7; do { while ( 1 ) { v10 = v6 + 1; v11 = (unsigned __int8 *)(a1 + v6); if ( (*(_BYTE *)(v9 + 2LL * *v11 + 1) & 2) != 0 ) break; ++v6; if ( v10 >= v5 ) return v8; } v12 = (unsigned __int8 *)(a1 + v10); if ( v5 > v10 ) { do { if ( (*(_BYTE *)(v9 + 2LL * *v12 + 1) & 2) != 0 ) { v18 = v10 - v6; v17 = v10 - v6 + 1; v6 = v10; goto LABEL_10; } ++v10; ++v12; } while ( v5 != v10 ); v16 = v5 - v6; v6 = v5; v18 = v16; v17 = v16 + 1; } else { v18 = 1LL; ++v6; v17 = 2LL; } LABEL_10: v19 = v8; v13 = malloc(v17); strncpy(v13, v11, v18); *(_BYTE *)(v13 + v18) = 0; v8 = realloc(v19, 8LL * (*a2 + 1)); v14 = *a2; *(_QWORD *)(v8 + 8LL * *a2) = v13; *a2 = v14 + 1; } while ( v6 < v5 ); return v8; }
func0: ENDBR64 PUSH R15 MOV R15,RSI PUSH R14 PUSH R13 MOV R13,RDI PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x28 MOV dword ptr [RSI],0x0 CALL 0x001010e0 TEST EAX,EAX JLE 0x001017e9 MOV EBP,EAX XOR EBX,EBX CALL 0x00101130 XOR R8D,R8D MOV R12,qword ptr [RAX] JMP 0x001016ea LAB_001016e0: MOV EBX,EAX CMP EBX,EBP JGE 0x001017a1 LAB_001016ea: MOVSXD RSI,EBX LEA EAX,[RBX + 0x1] ADD RSI,R13 MOVZX EDX,byte ptr [RSI] TEST byte ptr [R12 + RDX*0x2 + 0x1],0x2 JZ 0x001016e0 MOVSXD RDX,EAX ADD RDX,R13 CMP EBP,EAX JG 0x0010171f JMP 0x001017d4 LAB_00101710: ADD EAX,0x1 ADD RDX,0x1 CMP EBP,EAX JZ 0x001017b8 LAB_0010171f: MOVZX ECX,byte ptr [RDX] TEST byte ptr [R12 + RCX*0x2 + 0x1],0x2 JZ 0x00101710 MOV R14D,EAX SUB R14D,EBX MOVSXD RBX,R14D LEA EDI,[R14 + 0x1] MOV qword ptr [RSP + 0x8],RBX MOVSXD RDI,EDI MOV EBX,EAX LAB_00101741: MOV qword ptr [RSP + 0x18],R8 MOV qword ptr [RSP + 0x10],RSI CALL 0x00101110 MOV RDX,qword ptr [RSP + 0x8] MOV RSI,qword ptr [RSP + 0x10] MOV RDI,RAX MOV R14,RAX CALL 0x001010d0 MOV RAX,qword ptr [RSP + 0x8] MOV RDI,qword ptr [RSP + 0x18] MOV byte ptr [R14 + RAX*0x1],0x0 MOV EAX,dword ptr [R15] LEA ESI,[RAX + 0x1] MOVSXD RSI,ESI SHL RSI,0x3 CALL 0x00101120 MOVSXD RDX,dword ptr [R15] MOV R8,RAX MOV RAX,RDX MOV qword ptr [R8 + RDX*0x8],R14 ADD EAX,0x1 MOV dword ptr [R15],EAX CMP EBX,EBP JL 0x001016ea LAB_001017a1: ADD RSP,0x28 MOV RAX,R8 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001017b8: MOV R14D,EBP SUB R14D,EBX MOV EBX,EBP LEA EDI,[R14 + 0x1] MOVSXD RAX,R14D MOV qword ptr [RSP + 0x8],RAX MOVSXD RDI,EDI JMP 0x00101741 LAB_001017d4: MOV qword ptr [RSP + 0x8],0x1 MOV EBX,EAX MOV EDI,0x2 JMP 0x00101741 LAB_001017e9: XOR R8D,R8D JMP 0x001017a1
void * func0(char *param_1,int *param_2) { ushort *puVar1; int iVar2; int iVar3; size_t sVar4; ushort **ppuVar5; char *__dest; void *__ptr; byte *pbVar6; int iVar7; size_t local_50; *param_2 = 0; sVar4 = strlen(param_1); iVar2 = (int)sVar4; if (iVar2 < 1) { __ptr = (void *)0x0; } else { ppuVar5 = __ctype_b_loc(); __ptr = (void *)0x0; puVar1 = *ppuVar5; iVar7 = 0; do { while( true ) { iVar3 = iVar7 + 1; if ((*(byte *)((long)puVar1 + (ulong)(byte)param_1[iVar7] * 2 + 1) & 2) == 0) break; pbVar6 = (byte *)(param_1 + iVar3); if (iVar3 < iVar2) { do { if ((*(byte *)((long)puVar1 + (ulong)*pbVar6 * 2 + 1) & 2) != 0) { local_50 = (size_t)(iVar3 - iVar7); sVar4 = (size_t)((iVar3 - iVar7) + 1); goto LAB_00101741; } iVar3 = iVar3 + 1; pbVar6 = pbVar6 + 1; } while (iVar2 != iVar3); local_50 = (size_t)(iVar2 - iVar7); sVar4 = (size_t)((iVar2 - iVar7) + 1); iVar3 = iVar2; } else { local_50 = 1; sVar4 = 2; } LAB_00101741: __dest = (char *)malloc(sVar4); strncpy(__dest,param_1 + iVar7,local_50); __dest[local_50] = '\0'; __ptr = realloc(__ptr,(long)(*param_2 + 1) << 3); iVar7 = *param_2; *(char **)((long)__ptr + (long)iVar7 * 8) = __dest; *param_2 = iVar7 + 1; iVar7 = iVar3; if (iVar2 <= iVar3) { return __ptr; } } iVar7 = iVar3; } while (iVar3 < iVar2); } return __ptr; }
3,955
func0
#include <assert.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
char** func0(const char* text, int* count) { char** result = NULL; *count = 0; int len = strlen(text); int i = 0; while (i < len) { if (islower((unsigned char)text[i])) { int start = i; i++; while (i < len && !islower((unsigned char)text[i])) { i++; } int end = i; int substr_len = end - start; char* substr = (char*)malloc(substr_len + 1); strncpy(substr, text + start, substr_len); substr[substr_len] = '\0'; result = (char**)realloc(result, sizeof(char*) * (*count + 1)); result[*count] = substr; (*count)++; } else { i++; } } return result; }
int main() { // Test case 1 int count1; char** res1 = func0("AbCd", &count1); assert(count1 == 2); assert(strcmp(res1[0], "bC") == 0); assert(strcmp(res1[1], "d") == 0); for(int i = 0; i < count1; i++) free(res1[i]); free(res1); // Test case 2 int count2; char** res2 = func0("Python", &count2); assert(count2 == 5); assert(strcmp(res2[0], "y") == 0); assert(strcmp(res2[1], "t") == 0); assert(strcmp(res2[2], "h") == 0); assert(strcmp(res2[3], "o") == 0); assert(strcmp(res2[4], "n") == 0); for(int i = 0; i < count2; i++) free(res2[i]); free(res2); // Test case 3 int count3; char** res3 = func0("Programming", &count3); assert(count3 == 10); assert(strcmp(res3[0], "r") == 0); assert(strcmp(res3[1], "o") == 0); assert(strcmp(res3[2], "g") == 0); assert(strcmp(res3[3], "r") == 0); assert(strcmp(res3[4], "a") == 0); assert(strcmp(res3[5], "m") == 0); assert(strcmp(res3[6], "m") == 0); assert(strcmp(res3[7], "i") == 0); assert(strcmp(res3[8], "n") == 0); assert(strcmp(res3[9], "g") == 0); for(int i = 0; i < count3; i++) free(res3[i]); free(res3); return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 mov %rdi,%r13 push %r12 push %rbp push %rbx sub $0x28,%rsp movl $0x0,(%rsi) mov %rsi,0x8(%rsp) callq 10e0 <strlen@plt> test %eax,%eax jle 1802 <func0+0x162> mov %eax,%r14d xor %ebx,%ebx callq 1130 <__ctype_b_loc@plt> mov 0x8(%rsp),%rcx xor %r8d,%r8d mov (%rax),%r15 jmp 16f3 <func0+0x53> nopl 0x0(%rax) mov %edx,%ebx cmp %ebx,%r14d jle 17bd <func0+0x11d> movslq %ebx,%rbp lea 0x1(%rbx),%edx add %r13,%rbp movzbl 0x0(%rbp),%eax testb $0x2,0x1(%r15,%rax,2) je 16e8 <func0+0x48> movslq %edx,%rax cmp %edx,%r14d jg 1728 <func0+0x88> jmpq 17ed <func0+0x14d> nopl (%rax) lea 0x1(%rax),%edx add $0x1,%rax cmp %eax,%r14d jle 17d0 <func0+0x130> movzbl 0x0(%r13,%rax,1),%edx mov %eax,%r12d testb $0x2,0x1(%r15,%rdx,2) je 1718 <func0+0x78> sub %ebx,%r12d mov %eax,%ebx movslq %r12d,%rsi lea 0x1(%r12),%edi mov %rsi,0x8(%rsp) movslq %edi,%rdi mov %rcx,0x18(%rsp) mov %r8,0x10(%rsp) callq 1110 <malloc@plt> mov 0x8(%rsp),%rdx mov %rbp,%rsi mov %rax,%rdi mov %rax,%r12 callq 10d0 <strncpy@plt> mov 0x8(%rsp),%rax mov 0x18(%rsp),%rcx mov 0x10(%rsp),%r8 movb $0x0,(%r12,%rax,1) mov (%rcx),%eax mov %r8,%rdi mov %rcx,0x8(%rsp) lea 0x1(%rax),%esi movslq %esi,%rsi shl $0x3,%rsi callq 1120 <realloc@plt> mov 0x8(%rsp),%rcx mov %rax,%r8 movslq (%rcx),%rdx mov %rdx,%rax mov %r12,(%r8,%rdx,8) add $0x1,%eax mov %eax,(%rcx) cmp %ebx,%r14d jg 16f3 <func0+0x53> add $0x28,%rsp mov %r8,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov %edx,%r12d sub %ebx,%r12d mov %edx,%ebx lea 0x1(%r12),%edi movslq %r12d,%rax mov %rax,0x8(%rsp) movslq %edi,%rdi jmpq 174e <func0+0xae> movq $0x1,0x8(%rsp) mov %edx,%ebx mov $0x2,%edi jmpq 174e <func0+0xae> xor %r8d,%r8d jmp 17bd <func0+0x11d> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r15 mov r15, rsi push r14 push r13 mov r13, rdi push r12 push rbp push rbx sub rsp, 28h mov dword ptr [rsi], 0 call _strlen test eax, eax jle loc_17EF mov ebp, eax xor ebx, ebx call ___ctype_b_loc xor r8d, r8d mov r12, [rax] jmp short loc_16EA loc_16E0: mov ebx, eax cmp ebx, ebp jge loc_17AB loc_16EA: movsxd rsi, ebx lea eax, [rbx+1] add rsi, r13 movzx edx, byte ptr [rsi] test byte ptr [r12+rdx*2+1], 2 jz short loc_16E0 movsxd rdx, eax add rdx, r13 cmp ebp, eax jg short loc_171F jmp loc_17DB loc_1710: add eax, 1 add rdx, 1 cmp ebp, eax jz loc_17C0 loc_171F: movzx ecx, byte ptr [rdx] test byte ptr [r12+rcx*2+1], 2 jz short loc_1710 mov r14d, eax sub r14d, ebx mov ebx, eax movsxd rdi, r14d lea ecx, [r14+1] mov [rsp+58h+var_58], rdi movsxd rcx, ecx loc_1740: mov rdi, rcx; size mov [rsp+58h+ptr], r8 mov [rsp+58h+var_48], rsi mov [rsp+58h+var_50], rcx call _malloc mov rdx, [rsp+58h+var_58] mov rcx, [rsp+58h+var_50] mov rsi, [rsp+58h+var_48] mov rdi, rax mov r14, rax call ___strncpy_chk mov rax, [rsp+58h+var_58] mov rdi, [rsp+58h+ptr]; ptr mov byte ptr [r14+rax], 0 mov eax, [r15] lea esi, [rax+1] movsxd rsi, esi shl rsi, 3; size call _realloc movsxd rdx, dword ptr [r15] mov r8, rax mov rax, rdx mov [r8+rdx*8], r14 add eax, 1 mov [r15], eax cmp ebx, ebp jl loc_16EA loc_17AB: add rsp, 28h mov rax, r8 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_17C0: mov r14d, ebp sub r14d, ebx mov ebx, ebp lea ecx, [r14+1] movsxd rax, r14d mov [rsp+58h+var_58], rax movsxd rcx, ecx jmp loc_1740 loc_17DB: mov [rsp+58h+var_58], 1 mov ebx, eax mov ecx, 2 jmp loc_1740 loc_17EF: xor r8d, r8d jmp short loc_17AB
void * func0(const char *a1, int *a2) { int v3; // eax int v4; // ebp int v5; // ebx const unsigned __int16 **v6; // rax void *v7; // r8 const unsigned __int16 *v8; // r12 int v9; // eax const char *v10; // rsi const char *v11; // rdx int v12; // r14d _BYTE *v13; // r14 int v14; // eax int v16; // r14d size_t v17; // rcx long long v18; // [rsp+0h] [rbp-58h] size_t v19; // [rsp+8h] [rbp-50h] void *ptr; // [rsp+18h] [rbp-40h] *a2 = 0; v3 = strlen(a1); if ( v3 <= 0 ) return 0LL; v4 = v3; v5 = 0; v6 = __ctype_b_loc(); v7 = 0LL; v8 = *v6; do { while ( 1 ) { v9 = v5 + 1; v10 = &a1[v5]; if ( (v8[*(unsigned __int8 *)v10] & 0x200) != 0 ) break; ++v5; if ( v9 >= v4 ) return v7; } v11 = &a1[v9]; if ( v4 > v9 ) { do { if ( (v8[*(unsigned __int8 *)v11] & 0x200) != 0 ) { v12 = v9 - v5; v5 = v9; v18 = v12; v17 = v12 + 1; goto LABEL_10; } ++v9; ++v11; } while ( v4 != v9 ); v16 = v4 - v5; v5 = v4; v18 = v16; v17 = v16 + 1; } else { v18 = 1LL; ++v5; v17 = 2LL; } LABEL_10: ptr = v7; v19 = v17; v13 = malloc(v17); __strncpy_chk(v13, v10, v18, v19); v13[v18] = 0; v7 = realloc(ptr, 8LL * (*a2 + 1)); v14 = *a2; *((_QWORD *)v7 + *a2) = v13; *a2 = v14 + 1; } while ( v5 < v4 ); return v7; }
func0: ENDBR64 PUSH R15 MOV R15,RSI PUSH R14 PUSH R13 MOV R13,RDI PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x28 MOV dword ptr [RSI],0x0 CALL 0x001010d0 TEST EAX,EAX JLE 0x001017ef MOV EBP,EAX XOR EBX,EBX CALL 0x00101130 XOR R8D,R8D MOV R12,qword ptr [RAX] JMP 0x001016ea LAB_001016e0: MOV EBX,EAX CMP EBX,EBP JGE 0x001017ab LAB_001016ea: MOVSXD RSI,EBX LEA EAX,[RBX + 0x1] ADD RSI,R13 MOVZX EDX,byte ptr [RSI] TEST byte ptr [R12 + RDX*0x2 + 0x1],0x2 JZ 0x001016e0 MOVSXD RDX,EAX ADD RDX,R13 CMP EBP,EAX JG 0x0010171f JMP 0x001017db LAB_00101710: ADD EAX,0x1 ADD RDX,0x1 CMP EBP,EAX JZ 0x001017c0 LAB_0010171f: MOVZX ECX,byte ptr [RDX] TEST byte ptr [R12 + RCX*0x2 + 0x1],0x2 JZ 0x00101710 MOV R14D,EAX SUB R14D,EBX MOV EBX,EAX MOVSXD RDI,R14D LEA ECX,[R14 + 0x1] MOV qword ptr [RSP],RDI MOVSXD RCX,ECX LAB_00101740: MOV RDI,RCX MOV qword ptr [RSP + 0x18],R8 MOV qword ptr [RSP + 0x10],RSI MOV qword ptr [RSP + 0x8],RCX CALL 0x00101100 MOV RDX,qword ptr [RSP] MOV RCX,qword ptr [RSP + 0x8] MOV RSI,qword ptr [RSP + 0x10] MOV RDI,RAX MOV R14,RAX CALL 0x00101110 MOV RAX,qword ptr [RSP] MOV RDI,qword ptr [RSP + 0x18] MOV byte ptr [R14 + RAX*0x1],0x0 MOV EAX,dword ptr [R15] LEA ESI,[RAX + 0x1] MOVSXD RSI,ESI SHL RSI,0x3 CALL 0x00101120 MOVSXD RDX,dword ptr [R15] MOV R8,RAX MOV RAX,RDX MOV qword ptr [R8 + RDX*0x8],R14 ADD EAX,0x1 MOV dword ptr [R15],EAX CMP EBX,EBP JL 0x001016ea LAB_001017ab: ADD RSP,0x28 MOV RAX,R8 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001017c0: MOV R14D,EBP SUB R14D,EBX MOV EBX,EBP LEA ECX,[R14 + 0x1] MOVSXD RAX,R14D MOV qword ptr [RSP],RAX MOVSXD RCX,ECX JMP 0x00101740 LAB_001017db: MOV qword ptr [RSP],0x1 MOV EBX,EAX MOV ECX,0x2 JMP 0x00101740 LAB_001017ef: XOR R8D,R8D JMP 0x001017ab
void * func0(char *param_1,int *param_2) { ushort *puVar1; int iVar2; int iVar3; size_t sVar4; ushort **ppuVar5; void *pvVar6; void *__ptr; byte *pbVar7; int iVar8; long local_58; *param_2 = 0; sVar4 = strlen(param_1); iVar2 = (int)sVar4; if (iVar2 < 1) { __ptr = (void *)0x0; } else { ppuVar5 = __ctype_b_loc(); __ptr = (void *)0x0; puVar1 = *ppuVar5; iVar8 = 0; do { while( true ) { iVar3 = iVar8 + 1; if ((*(byte *)((long)puVar1 + (ulong)(byte)param_1[iVar8] * 2 + 1) & 2) == 0) break; pbVar7 = (byte *)(param_1 + iVar3); if (iVar3 < iVar2) { do { if ((*(byte *)((long)puVar1 + (ulong)*pbVar7 * 2 + 1) & 2) != 0) { local_58 = (long)(iVar3 - iVar8); sVar4 = (size_t)((iVar3 - iVar8) + 1); goto LAB_00101740; } iVar3 = iVar3 + 1; pbVar7 = pbVar7 + 1; } while (iVar2 != iVar3); local_58 = (long)(iVar2 - iVar8); sVar4 = (size_t)((iVar2 - iVar8) + 1); iVar3 = iVar2; } else { local_58 = 1; sVar4 = 2; } LAB_00101740: pvVar6 = malloc(sVar4); __strncpy_chk(pvVar6,param_1 + iVar8,local_58,sVar4); *(int *)((long)pvVar6 + local_58) = 0; __ptr = realloc(__ptr,(long)(*param_2 + 1) << 3); iVar8 = *param_2; *(void **)((long)__ptr + (long)iVar8 * 8) = pvVar6; *param_2 = iVar8 + 1; iVar8 = iVar3; if (iVar2 <= iVar3) { return __ptr; } } iVar8 = iVar3; } while (iVar3 < iVar2); } return __ptr; }
3,956
func0
#include <stdio.h> #include <string.h> #include <regex.h> #include <assert.h>
char* func0(const char* text) { regex_t regex; char* pattern = "^[a-z]+_[a-z]+$"; regcomp(&regex, pattern, REG_EXTENDED); int reti = regexec(&regex, text, 0, NULL, 0); regfree(&regex); if (!reti) return "Found a match!"; else return "Not matched!"; }
int main() { assert(strcmp(func0("aab_cbbbc"), "Found a match!") == 0); assert(strcmp(func0("aab_Abbbc"), "Not matched!") == 0); assert(strcmp(func0("Aaab_abbbc"), "Not matched!") == 0); assert(strcmp(func0("aab-cbbbc"), "Not matched!") == 0); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x70,%rsp mov %rdi,-0x68(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea 0xdf9(%rip),%rax mov %rax,-0x58(%rbp) mov -0x58(%rbp),%rcx lea -0x50(%rbp),%rax mov $0x1,%edx mov %rcx,%rsi mov %rax,%rdi callq 10d0 <regcomp@plt> mov -0x68(%rbp),%rsi lea -0x50(%rbp),%rax mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rax,%rdi callq 10f0 <regexec@plt> mov %eax,-0x5c(%rbp) lea -0x50(%rbp),%rax mov %rax,%rdi callq 10a0 <regfree@plt> cmpl $0x0,-0x5c(%rbp) jne 1269 <func0+0x80> lea 0xdb1(%rip),%rax jmp 1270 <func0+0x87> lea 0xdb7(%rip),%rax mov -0x8(%rbp),%rdx xor %fs:0x28,%rdx je 1284 <func0+0x9b> callq 10b0 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 70h mov [rbp+string], rdi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rax, aAZAZ; "^[a-z]+_[a-z]+$" mov [rbp+pattern], rax mov rcx, [rbp+pattern] lea rax, [rbp+preg] mov edx, 1; cflags mov rsi, rcx; pattern mov rdi, rax; preg call _regcomp mov rsi, [rbp+string]; string lea rax, [rbp+preg] mov r8d, 0; eflags mov ecx, 0; pmatch mov edx, 0; nmatch mov rdi, rax; preg call _regexec mov [rbp+var_5C], eax lea rax, [rbp+preg] mov rdi, rax; preg call _regfree cmp [rbp+var_5C], 0 jnz short loc_1269 lea rax, s2; "Found a match!" jmp short loc_1270 loc_1269: lea rax, aNotMatched; "Not matched!" loc_1270: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_1284 call ___stack_chk_fail locret_1284: leave retn
const char * func0(const char *a1) { int v2; // [rsp+14h] [rbp-5Ch] regex_t preg; // [rsp+20h] [rbp-50h] BYREF unsigned long long v4; // [rsp+68h] [rbp-8h] v4 = __readfsqword(0x28u); regcomp(&preg, "^[a-z]+_[a-z]+$", 1); v2 = regexec(&preg, a1, 0LL, 0LL, 0); regfree(&preg); if ( v2 ) return "Not matched!"; else return "Found a match!"; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x70 MOV qword ptr [RBP + -0x68],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RAX,[0x102008] MOV qword ptr [RBP + -0x58],RAX MOV RCX,qword ptr [RBP + -0x58] LEA RAX,[RBP + -0x50] MOV EDX,0x1 MOV RSI,RCX MOV RDI,RAX CALL 0x001010d0 MOV RSI,qword ptr [RBP + -0x68] LEA RAX,[RBP + -0x50] MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RDI,RAX CALL 0x001010f0 MOV dword ptr [RBP + -0x5c],EAX LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x001010a0 CMP dword ptr [RBP + -0x5c],0x0 JNZ 0x00101269 LEA RAX,[0x102018] JMP 0x00101270 LAB_00101269: LEA RAX,[0x102027] LAB_00101270: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x00101284 CALL 0x001010b0 LAB_00101284: LEAVE RET
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t local_58; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); regcomp(&local_58,"^[a-z]+_[a-z]+$",1); iVar1 = regexec(&local_58,param_1,0,(regmatch_t *)0x0,0); regfree(&local_58); if (iVar1 == 0) { pcVar2 = "Found a match!"; } else { pcVar2 = "Not matched!"; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return pcVar2; }
3,957
func0
#include <stdio.h> #include <string.h> #include <regex.h> #include <assert.h>
char* func0(const char* text) { regex_t regex; char* pattern = "^[a-z]+_[a-z]+$"; regcomp(&regex, pattern, REG_EXTENDED); int reti = regexec(&regex, text, 0, NULL, 0); regfree(&regex); if (!reti) return "Found a match!"; else return "Not matched!"; }
int main() { assert(strcmp(func0("aab_cbbbc"), "Found a match!") == 0); assert(strcmp(func0("aab_Abbbc"), "Not matched!") == 0); assert(strcmp(func0("Aaab_abbbc"), "Not matched!") == 0); assert(strcmp(func0("aab-cbbbc"), "Not matched!") == 0); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0x58,%rsp mov %rdi,%rbx mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax mov %rsp,%rbp mov $0x1,%edx lea 0xe2b(%rip),%rsi mov %rbp,%rdi callq 10c0 <regcomp@plt> mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rbx,%rsi mov %rbp,%rdi callq 10d0 <regexec@plt> mov %eax,%ebx mov %rbp,%rdi callq 1090 <regfree@plt> test %ebx,%ebx lea 0xdd9(%rip),%rax lea 0xde1(%rip),%rdx cmovne %rdx,%rax mov 0x48(%rsp),%rcx xor %fs:0x28,%rcx jne 124d <func0+0x84> add $0x58,%rsp pop %rbx pop %rbp retq callq 10a0 <__stack_chk_fail@plt>
func0: endbr64 push rbp push rbx sub rsp, 58h mov rbx, rdi mov rax, fs:28h mov [rsp+var_s48], rax xor eax, eax mov rbp, rsp mov edx, 1 lea rsi, aAZAZ; "^[a-z]+_[a-z]+$" mov rdi, rbp call _regcomp mov r8d, 0 mov ecx, 0 mov edx, 0 mov rsi, rbx mov rdi, rbp call _regexec mov ebx, eax mov rdi, rbp call _regfree test ebx, ebx lea rax, aFoundAMatch; "Found a match!" lea rdx, aNotMatched; "Not matched!" cmovnz rax, rdx mov rdx, [rsp+var_s48] sub rdx, fs:28h jnz short loc_126D add rsp, 58h pop rbx pop rbp retn loc_126D: call ___stack_chk_fail
const char * func0(long long a1) { int v1; // ebx const char *result; // rax _QWORD _0[13]; // [rsp+0h] [rbp+0h] BYREF _0[9] = __readfsqword(0x28u); regcomp(_0, "^[a-z]+_[a-z]+$", 1LL); v1 = regexec(_0, a1, 0LL, 0LL, 0LL); regfree(_0); result = "Found a match!"; if ( v1 ) return "Not matched!"; return result; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x58 MOV RBX,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX MOV RBP,RSP MOV EDX,0x1 LEA RSI,[0x102020] MOV RDI,RBP CALL 0x001010d0 MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,RBX MOV RDI,RBP CALL 0x001010f0 MOV EBX,EAX MOV RDI,RBP CALL 0x001010a0 TEST EBX,EBX LEA RAX,[0x102004] LEA RDX,[0x102013] CMOVNZ RAX,RDX MOV RDX,qword ptr [RSP + 0x48] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010126d ADD RSP,0x58 POP RBX POP RBP RET LAB_0010126d: CALL 0x001010b0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_68; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); regcomp(&rStack_68,"^[a-z]+_[a-z]+$",1); iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0); regfree(&rStack_68); pcVar2 = "Found a match!"; if (iVar1 != 0) { pcVar2 = "Not matched!"; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,958
func0
#include <stdio.h> #include <string.h> #include <regex.h> #include <assert.h>
char* func0(const char* text) { regex_t regex; char* pattern = "^[a-z]+_[a-z]+$"; regcomp(&regex, pattern, REG_EXTENDED); int reti = regexec(&regex, text, 0, NULL, 0); regfree(&regex); if (!reti) return "Found a match!"; else return "Not matched!"; }
int main() { assert(strcmp(func0("aab_cbbbc"), "Found a match!") == 0); assert(strcmp(func0("aab_Abbbc"), "Not matched!") == 0); assert(strcmp(func0("Aaab_abbbc"), "Not matched!") == 0); assert(strcmp(func0("aab-cbbbc"), "Not matched!") == 0); return 0; }
O2
c
func0: endbr64 push %r12 mov $0x1,%edx mov %rdi,%r12 lea 0xd1b(%rip),%rsi push %rbp push %rbx sub $0x50,%rsp mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax mov %rsp,%rbp mov %rbp,%rdi callq 10c0 <regcomp@plt> xor %ecx,%ecx xor %edx,%edx xor %r8d,%r8d mov %r12,%rsi mov %rbp,%rdi callq 10d0 <regexec@plt> mov %rbp,%rdi mov %eax,%ebx callq 1090 <regfree@plt> test %ebx,%ebx lea 0xcb9(%rip),%rax lea 0xcc1(%rip),%rdx cmovne %rdx,%rax mov 0x48(%rsp),%rcx xor %fs:0x28,%rcx jne 136f <func0+0x7f> add $0x50,%rsp pop %rbx pop %rbp pop %r12 retq callq 10a0 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push r12 mov edx, 1 mov r12, rdi lea rsi, aAZAZ; "^[a-z]+_[a-z]+$" push rbp push rbx sub rsp, 50h mov rax, fs:28h mov [rsp+var_s48], rax xor eax, eax mov rbp, rsp mov rdi, rbp call _regcomp xor edx, edx xor r8d, r8d xor ecx, ecx mov rsi, r12 mov rdi, rbp call _regexec mov rdi, rbp mov ebx, eax call _regfree test ebx, ebx lea rax, aFoundAMatch; "Found a match!" lea rdx, aNotMatched; "Not matched!" cmovnz rax, rdx mov rdx, [rsp+var_s48] sub rdx, fs:28h jnz short loc_136F add rsp, 50h pop rbx pop rbp pop r12 retn loc_136F: call ___stack_chk_fail
const char * func0(long long a1) { int v1; // ebx const char *result; // rax _QWORD _0[13]; // [rsp+0h] [rbp+0h] BYREF _0[9] = __readfsqword(0x28u); regcomp(_0, "^[a-z]+_[a-z]+$", 1LL); v1 = regexec(_0, a1, 0LL, 0LL, 0LL); regfree(_0); result = "Found a match!"; if ( v1 ) return "Not matched!"; return result; }
func0: ENDBR64 PUSH R12 MOV EDX,0x1 MOV R12,RDI LEA RSI,[0x102020] PUSH RBP PUSH RBX SUB RSP,0x50 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX MOV RBP,RSP MOV RDI,RBP CALL 0x001010d0 XOR EDX,EDX XOR R8D,R8D XOR ECX,ECX MOV RSI,R12 MOV RDI,RBP CALL 0x001010f0 MOV RDI,RBP MOV EBX,EAX CALL 0x001010a0 TEST EBX,EBX LEA RAX,[0x102004] LEA RDX,[0x102013] CMOVNZ RAX,RDX MOV RDX,qword ptr [RSP + 0x48] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010136f ADD RSP,0x50 POP RBX POP RBP POP R12 RET LAB_0010136f: CALL 0x001010b0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_68; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); regcomp(&rStack_68,"^[a-z]+_[a-z]+$",1); iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0); regfree(&rStack_68); pcVar2 = "Found a match!"; if (iVar1 != 0) { pcVar2 = "Not matched!"; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,959
func0
#include <stdio.h> #include <string.h> #include <regex.h> #include <assert.h>
char* func0(const char* text) { regex_t regex; char* pattern = "^[a-z]+_[a-z]+$"; regcomp(&regex, pattern, REG_EXTENDED); int reti = regexec(&regex, text, 0, NULL, 0); regfree(&regex); if (!reti) return "Found a match!"; else return "Not matched!"; }
int main() { assert(strcmp(func0("aab_cbbbc"), "Found a match!") == 0); assert(strcmp(func0("aab_Abbbc"), "Not matched!") == 0); assert(strcmp(func0("Aaab_abbbc"), "Not matched!") == 0); assert(strcmp(func0("aab-cbbbc"), "Not matched!") == 0); return 0; }
O3
c
func0: endbr64 push %r12 mov $0x1,%edx mov %rdi,%r12 lea 0xd1b(%rip),%rsi push %rbp push %rbx sub $0x50,%rsp mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax mov %rsp,%rbp mov %rbp,%rdi callq 10c0 <regcomp@plt> xor %ecx,%ecx xor %edx,%edx xor %r8d,%r8d mov %r12,%rsi mov %rbp,%rdi callq 10d0 <regexec@plt> mov %rbp,%rdi mov %eax,%ebx callq 1090 <regfree@plt> test %ebx,%ebx lea 0xcb9(%rip),%rax lea 0xcc1(%rip),%rdx cmovne %rdx,%rax mov 0x48(%rsp),%rcx xor %fs:0x28,%rcx jne 136f <func0+0x7f> add $0x50,%rsp pop %rbx pop %rbp pop %r12 retq callq 10a0 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push rbp mov edx, 1; cflags lea rsi, pattern; "^[a-z]+_[a-z]+$" push rbx mov rbx, rdi sub rsp, 58h mov rax, fs:28h mov [rsp+var_s48], rax xor eax, eax mov rbp, rsp mov rdi, rbp; preg call _regcomp xor edx, edx; nmatch xor r8d, r8d; eflags xor ecx, ecx; pmatch mov rsi, rbx; string mov rdi, rbp; preg call _regexec mov rdi, rbp; preg mov ebx, eax call _regfree test ebx, ebx lea rax, aNotMatched; "Not matched!" lea rdx, s2; "Found a match!" cmovz rax, rdx mov rdx, [rsp+var_s48] sub rdx, fs:28h jnz short loc_136B add rsp, 58h pop rbx pop rbp retn loc_136B: call ___stack_chk_fail
const char * func0(char *string) { int v1; // ebx const char *result; // rax regex_t _0; // [rsp+0h] [rbp+0h] BYREF unsigned long long vars48; // [rsp+48h] [rbp+48h] vars48 = __readfsqword(0x28u); regcomp(&_0, "^[a-z]+_[a-z]+$", 1); v1 = regexec(&_0, string, 0LL, 0LL, 0); regfree(&_0); result = "Not matched!"; if ( !v1 ) return "Found a match!"; return result; }
func0: ENDBR64 PUSH RBP MOV EDX,0x1 LEA RSI,[0x102020] PUSH RBX MOV RBX,RDI SUB RSP,0x58 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX MOV RBP,RSP MOV RDI,RBP CALL 0x001010d0 XOR EDX,EDX XOR R8D,R8D XOR ECX,ECX MOV RSI,RBX MOV RDI,RBP CALL 0x001010f0 MOV RDI,RBP MOV EBX,EAX CALL 0x001010a0 TEST EBX,EBX LEA RAX,[0x102013] LEA RDX,[0x102004] CMOVZ RAX,RDX MOV RDX,qword ptr [RSP + 0x48] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010136b ADD RSP,0x58 POP RBX POP RBP RET LAB_0010136b: CALL 0x001010b0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_68; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); regcomp(&rStack_68,"^[a-z]+_[a-z]+$",1); iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0); regfree(&rStack_68); pcVar2 = "Not matched!"; if (iVar1 == 0) { pcVar2 = "Found a match!"; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
3,960
func0
#include <assert.h>
int func0(int a) { int perimeter = 4 * a; return perimeter; }
int main() { assert(func0(10) == 40); assert(func0(5) == 20); assert(func0(4) == 16); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov -0x14(%rbp),%eax shl $0x2,%eax mov %eax,-0x4(%rbp) mov -0x4(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov eax, [rbp+var_14] shl eax, 2 mov [rbp+var_4], eax mov eax, [rbp+var_4] pop rbp retn
long long func0(int a1) { return (unsigned int)(4 * a1); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV EAX,dword ptr [RBP + -0x14] SHL EAX,0x2 MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x4] POP RBP RET
int func0(int param_1) { return param_1 << 2; }
3,961
func0
#include <assert.h>
int func0(int a) { int perimeter = 4 * a; return perimeter; }
int main() { assert(func0(10) == 40); assert(func0(5) == 20); assert(func0(4) == 16); return 0; }
O1
c
func0: endbr64 lea 0x0(,%rdi,4),%eax retq
func0: endbr64 lea eax, ds:0[rdi*4] retn
long long func0(int a1) { return (unsigned int)(4 * a1); }
3,962
func0
#include <assert.h>
int func0(int a) { int perimeter = 4 * a; return perimeter; }
int main() { assert(func0(10) == 40); assert(func0(5) == 20); assert(func0(4) == 16); return 0; }
O2
c
func0: endbr64 lea 0x0(,%rdi,4),%eax retq nopl 0x0(%rax)
func0: endbr64 lea eax, ds:0[rdi*4] retn
long long func0(int a1) { return (unsigned int)(4 * a1); }
func0: ENDBR64 LEA EAX,[RDI*0x4] RET
int func0(int param_1) { return param_1 * 4; }
3,963
func0
#include <assert.h>
int func0(int a) { int perimeter = 4 * a; return perimeter; }
int main() { assert(func0(10) == 40); assert(func0(5) == 20); assert(func0(4) == 16); return 0; }
O3
c
func0: endbr64 lea 0x0(,%rdi,4),%eax retq nopl 0x0(%rax)
func0: endbr64 lea eax, ds:0[rdi*4] retn
long long func0(int a1) { return (unsigned int)(4 * a1); }
func0: ENDBR64 LEA EAX,[RDI*0x4] RET
int func0(int param_1) { return param_1 * 4; }
3,964
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define NO_OF_CHARS 256 char *str_to_list(char *string) { static char temp[256]; int i = 0; while (*string) { temp[i++] = *string++; } temp[i] = '\0'; return temp; } char *lst_to_string(char *list, int res_ind) { static char result[256]; strncpy(result, list, res_ind); result[res_ind] = '\0'; return result; } int *get_char_count_array(char *string) { static int count[NO_OF_CHARS]; memset(count, 0, sizeof(count)); while (*string) { count[(int)(*string)]++; string++; } return count; }
char *func0(char *string, char *second_string) { int *count = get_char_count_array(second_string); int ip_ind = 0, res_ind = 0; char *str_list = str_to_list(string); while (str_list[ip_ind] != '\0') { char temp = str_list[ip_ind]; if (count[(int)temp] == 0) { str_list[res_ind++] = temp; } ip_ind++; } return lst_to_string(str_list, res_ind); }
int main() { assert(strcmp(func0("probasscurve", "pros"), "bacuve") == 0); assert(strcmp(func0("digitalindia", "talent"), "digiidi") == 0); assert(strcmp(func0("exoticmiles", "toxic"), "emles") == 0); printf("All tests passed.\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x28(%rbp) mov %rsi,-0x30(%rbp) mov -0x30(%rbp),%rax mov %rax,%rdi callq 126c <get_char_count_array> mov %rax,-0x10(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) mov -0x28(%rbp),%rax mov %rax,%rdi callq 11c9 <str_to_list> mov %rax,-0x8(%rbp) jmp 1371 <func0+0x8e> mov -0x18(%rbp),%eax movslq %eax,%rdx mov -0x8(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax mov %al,-0x19(%rbp) movsbq -0x19(%rbp),%rax lea 0x0(,%rax,4),%rdx mov -0x10(%rbp),%rax add %rdx,%rax mov (%rax),%eax test %eax,%eax jne 136d <func0+0x8a> mov -0x14(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x14(%rbp) movslq %eax,%rdx mov -0x8(%rbp),%rax add %rax,%rdx movzbl -0x19(%rbp),%eax mov %al,(%rdx) addl $0x1,-0x18(%rbp) mov -0x18(%rbp),%eax movslq %eax,%rdx mov -0x8(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax test %al,%al jne 1327 <func0+0x44> mov -0x14(%rbp),%edx mov -0x8(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 1227 <lst_to_string> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_28], rdi mov [rbp+var_30], rsi mov rax, [rbp+var_30] mov rdi, rax call get_char_count_array mov [rbp+var_10], rax mov [rbp+var_18], 0 mov [rbp+var_14], 0 mov rax, [rbp+var_28] mov rdi, rax call str_to_list mov [rbp+var_8], rax jmp short loc_1377 loc_132D: mov eax, [rbp+var_18] movsxd rdx, eax mov rax, [rbp+var_8] add rax, rdx movzx eax, byte ptr [rax] mov [rbp+var_19], al movsx rax, [rbp+var_19] lea rdx, ds:0[rax*4] mov rax, [rbp+var_10] add rax, rdx mov eax, [rax] test eax, eax jnz short loc_1373 mov eax, [rbp+var_14] lea edx, [rax+1] mov [rbp+var_14], edx movsxd rdx, eax mov rax, [rbp+var_8] add rdx, rax movzx eax, [rbp+var_19] mov [rdx], al loc_1373: add [rbp+var_18], 1 loc_1377: mov eax, [rbp+var_18] movsxd rdx, eax mov rax, [rbp+var_8] add rax, rdx movzx eax, byte ptr [rax] test al, al jnz short loc_132D mov edx, [rbp+var_14] mov rax, [rbp+var_8] mov esi, edx mov rdi, rax call lst_to_string leave retn
long long func0(long long a1, long long a2) { int v2; // eax char v4; // [rsp+17h] [rbp-19h] int v5; // [rsp+18h] [rbp-18h] unsigned int v6; // [rsp+1Ch] [rbp-14h] long long char_count_array; // [rsp+20h] [rbp-10h] long long v8; // [rsp+28h] [rbp-8h] char_count_array = get_char_count_array(a2); v5 = 0; v6 = 0; v8 = str_to_list(a1); while ( *(_BYTE *)(v5 + v8) ) { v4 = *(_BYTE *)(v5 + v8); if ( !*(_DWORD *)(4LL * v4 + char_count_array) ) { v2 = v6++; *(_BYTE *)(v8 + v2) = v4; } ++v5; } return lst_to_string(v8, v6); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x28],RDI MOV qword ptr [RBP + -0x30],RSI MOV RAX,qword ptr [RBP + -0x30] MOV RDI,RAX CALL 0x0010126f MOV qword ptr [RBP + -0x10],RAX MOV dword ptr [RBP + -0x18],0x0 MOV dword ptr [RBP + -0x14],0x0 MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x001011c9 MOV qword ptr [RBP + -0x8],RAX JMP 0x00101377 LAB_0010132d: MOV EAX,dword ptr [RBP + -0x18] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBP + -0x19],AL MOVSX RAX,byte ptr [RBP + -0x19] LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x10] ADD RAX,RDX MOV EAX,dword ptr [RAX] TEST EAX,EAX JNZ 0x00101373 MOV EAX,dword ptr [RBP + -0x14] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x14],EDX MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOVZX EAX,byte ptr [RBP + -0x19] MOV byte ptr [RDX],AL LAB_00101373: ADD dword ptr [RBP + -0x18],0x1 LAB_00101377: MOV EAX,dword ptr [RBP + -0x18] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] TEST AL,AL JNZ 0x0010132d MOV EDX,dword ptr [RBP + -0x14] MOV RAX,qword ptr [RBP + -0x8] MOV ESI,EDX MOV RDI,RAX CALL 0x00101227 LEAVE RET
void func0(int8 param_1,int8 param_2) { long lVar1; long lVar2; int4 local_20; int4 local_1c; lVar1 = get_char_count_array(param_2); local_20 = 0; local_1c = 0; lVar2 = str_to_list(param_1); for (; *(char *)(lVar2 + local_20) != '\0'; local_20 = local_20 + 1) { if (*(int *)(lVar1 + (long)*(char *)(lVar2 + local_20) * 4) == 0) { *(char *)(local_1c + lVar2) = *(char *)(lVar2 + local_20); local_1c = local_1c + 1; } } lst_to_string(lVar2,local_1c); return; }
3,965
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define NO_OF_CHARS 256 char *str_to_list(char *string) { static char temp[256]; int i = 0; while (*string) { temp[i++] = *string++; } temp[i] = '\0'; return temp; } char *lst_to_string(char *list, int res_ind) { static char result[256]; strncpy(result, list, res_ind); result[res_ind] = '\0'; return result; } int *get_char_count_array(char *string) { static int count[NO_OF_CHARS]; memset(count, 0, sizeof(count)); while (*string) { count[(int)(*string)]++; string++; } return count; }
char *func0(char *string, char *second_string) { int *count = get_char_count_array(second_string); int ip_ind = 0, res_ind = 0; char *str_list = str_to_list(string); while (str_list[ip_ind] != '\0') { char temp = str_list[ip_ind]; if (count[(int)temp] == 0) { str_list[res_ind++] = temp; } ip_ind++; } return lst_to_string(str_list, res_ind); }
int main() { assert(strcmp(func0("probasscurve", "pros"), "bacuve") == 0); assert(strcmp(func0("digitalindia", "talent"), "digiidi") == 0); assert(strcmp(func0("exoticmiles", "toxic"), "emles") == 0); printf("All tests passed.\n"); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0x8,%rsp mov %rdi,%rbp mov %rsi,%rdi callq 11f4 <get_char_count_array> mov %rax,%rbx mov %rbp,%rdi callq 1189 <str_to_list> mov %rax,%rdi movzbl (%rax),%edx test %dl,%dl je 128f <func0+0x58> lea 0x1(%rax),%rcx mov $0x0,%r8d jmp 1279 <func0+0x42> add $0x1,%rcx movzbl -0x1(%rcx),%edx test %dl,%dl je 1295 <func0+0x5e> movsbq %dl,%rsi cmpl $0x0,(%rbx,%rsi,4) jne 126d <func0+0x36> movslq %r8d,%rax mov %dl,(%rdi,%rax,1) lea 0x1(%r8),%r8d jmp 126d <func0+0x36> mov $0x0,%r8d mov %r8d,%esi callq 11c8 <lst_to_string> add $0x8,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp push rbx sub rsp, 8 mov rbp, rdi mov rdi, rsi call get_char_count_array mov rbx, rax mov rdi, rbp call str_to_list mov rdi, rax movzx edx, byte ptr [rax] test dl, dl jz short loc_12B6 lea rcx, [rax+1] mov r8d, 0 jmp short loc_12A0 loc_1294: add rcx, 1 movzx edx, byte ptr [rcx-1] test dl, dl jz short loc_12BC loc_12A0: movsx rsi, dl cmp dword ptr [rbx+rsi*4], 0 jnz short loc_1294 movsxd rax, r8d mov [rdi+rax], dl lea r8d, [r8+1] jmp short loc_1294 loc_12B6: mov r8d, 0 loc_12BC: mov esi, r8d call lst_to_string add rsp, 8 pop rbx pop rbp retn
long long func0(long long a1, long long a2) { long long char_count_array; // rbx char *v3; // rax char v4; // dl char *v5; // rcx unsigned int v6; // r8d char_count_array = get_char_count_array(a2); v3 = (char *)str_to_list(a1); v4 = *v3; if ( *v3 ) { v5 = v3 + 1; v6 = 0; do { if ( !*(_DWORD *)(char_count_array + 4LL * v4) ) v3[v6++] = v4; v4 = *v5++; } while ( v4 ); } else { v6 = 0; } return lst_to_string(v3, v6); }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x8 MOV RBP,RDI MOV RDI,RSI CALL 0x0010121b MOV RBX,RAX MOV RDI,RBP CALL 0x001011a9 MOV RDI,RAX MOVZX EDX,byte ptr [RAX] TEST DL,DL JZ 0x001012b6 LEA RCX,[RAX + 0x1] MOV R8D,0x0 JMP 0x001012a0 LAB_00101294: ADD RCX,0x1 MOVZX EDX,byte ptr [RCX + -0x1] TEST DL,DL JZ 0x001012bc LAB_001012a0: MOVSX RSI,DL CMP dword ptr [RBX + RSI*0x4],0x0 JNZ 0x00101294 MOVSXD RAX,R8D MOV byte ptr [RDI + RAX*0x1],DL LEA R8D,[R8 + 0x1] JMP 0x00101294 LAB_001012b6: MOV R8D,0x0 LAB_001012bc: MOV ESI,R8D CALL 0x001011e8 ADD RSP,0x8 POP RBX POP RBP RET
void func0(int8 param_1,int8 param_2) { long lVar1; char *pcVar2; char *pcVar3; char cVar4; int iVar5; lVar1 = get_char_count_array(param_2); pcVar2 = (char *)str_to_list(param_1); cVar4 = *pcVar2; if (cVar4 == '\0') { iVar5 = 0; } else { iVar5 = 0; pcVar3 = pcVar2; do { pcVar3 = pcVar3 + 1; if (*(int *)(lVar1 + (long)cVar4 * 4) == 0) { pcVar2[iVar5] = cVar4; iVar5 = iVar5 + 1; } cVar4 = *pcVar3; } while (cVar4 != '\0'); } lst_to_string(pcVar2,iVar5); return; }
3,966
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define NO_OF_CHARS 256 char *str_to_list(char *string) { static char temp[256]; int i = 0; while (*string) { temp[i++] = *string++; } temp[i] = '\0'; return temp; } char *lst_to_string(char *list, int res_ind) { static char result[256]; strncpy(result, list, res_ind); result[res_ind] = '\0'; return result; } int *get_char_count_array(char *string) { static int count[NO_OF_CHARS]; memset(count, 0, sizeof(count)); while (*string) { count[(int)(*string)]++; string++; } return count; }
char *func0(char *string, char *second_string) { int *count = get_char_count_array(second_string); int ip_ind = 0, res_ind = 0; char *str_list = str_to_list(string); while (str_list[ip_ind] != '\0') { char temp = str_list[ip_ind]; if (count[(int)temp] == 0) { str_list[res_ind++] = temp; } ip_ind++; } return lst_to_string(str_list, res_ind); }
int main() { assert(strcmp(func0("probasscurve", "pros"), "bacuve") == 0); assert(strcmp(func0("digitalindia", "talent"), "digiidi") == 0); assert(strcmp(func0("exoticmiles", "toxic"), "emles") == 0); printf("All tests passed.\n"); return 0; }
O2
c
func0: endbr64 push %rbx mov %rdi,%r8 mov %rsi,%rdi callq 1310 <get_char_count_array> movzbl (%r8),%ecx test %cl,%cl je 1410 <func0+0xc0> mov $0x1,%edx lea 0x31c7(%rip),%rdi nopl 0x0(%rax,%rax,1) mov %cl,(%rdi,%rdx,1) movslq %edx,%rsi add $0x1,%rdx movzbl -0x1(%r8,%rdx,1),%ecx test %cl,%cl jne 1380 <func0+0x30> lea 0x31a5(%rip),%r9 movb $0x0,(%r9,%rsi,1) movzbl 0x3199(%rip),%edx test %dl,%dl je 1418 <func0+0xc8> lea 0x1(%r9),%rcx xor %edi,%edi xor %ebx,%ebx nopl 0x0(%rax,%rax,1) movsbq %dl,%rsi mov %rbx,%r8 mov (%rax,%rsi,4),%esi test %esi,%esi jne 13d3 <func0+0x83> add $0x1,%edi mov %dl,(%r9,%rbx,1) movslq %edi,%rbx mov %rbx,%r8 movzbl (%rcx),%edx add $0x1,%rcx test %dl,%dl jne 13b8 <func0+0x68> mov $0x100,%ecx mov %r8,%rdx lea 0x3153(%rip),%rsi lea 0x304c(%rip),%rdi callq 1090 <__strncpy_chk@plt> lea 0x3040(%rip),%rax movb $0x0,(%rax,%rbx,1) pop %rbx retq nopw %cs:0x0(%rax,%rax,1) xor %esi,%esi jmp 1394 <func0+0x44> nopl 0x0(%rax) xor %r8d,%r8d xor %ebx,%ebx jmp 13de <func0+0x8e>
func0: endbr64 lea rdx, count_1 xor eax, eax mov r8, rdi push rbx mov ecx, 80h mov rdi, rdx rep stosq movsx rax, byte ptr [rsi] test al, al jz short loc_1398 nop dword ptr [rax+00h] loc_1388: add rsi, 1 add dword ptr [rdx+rax*4], 1 movsx rax, byte ptr [rsi] test al, al jnz short loc_1388 loc_1398: movzx ecx, byte ptr [r8] mov eax, 1 lea rdi, unk_453F xor esi, esi test cl, cl jz short loc_13C4 xchg ax, ax loc_13B0: mov [rdi+rax], cl movsxd rsi, eax add rax, 1 movzx ecx, byte ptr [r8+rax-1] test cl, cl jnz short loc_13B0 loc_13C4: lea r8, temp_3 mov byte ptr [r8+rsi], 0 movzx eax, cs:temp_3 test al, al jz short loc_1430 lea rcx, [r8+1] xor esi, esi nop dword ptr [rax+00000000h] loc_13E8: movsx rdi, al mov edi, [rdx+rdi*4] test edi, edi jnz short loc_13FD movsxd rdi, esi add esi, 1 mov [r8+rdi], al loc_13FD: movzx eax, byte ptr [rcx] add rcx, 1 test al, al jnz short loc_13E8 movsxd rbx, esi mov rdx, rbx loc_140E: mov rsi, r8 lea r8, result_2 mov ecx, 100h mov rdi, r8 call ___strncpy_chk mov byte ptr [rax+rbx], 0 pop rbx retn loc_1430: xor edx, edx xor ebx, ebx jmp short loc_140E
long long func0(char *a1, char *a2) { long long i; // rax char v3; // cl long long v4; // rax long long j; // rsi char v6; // al char *v7; // rcx int v8; // esi long long v9; // rdi long long v10; // rbx long long v11; // rdx long long result; // rax memset(count_1, 0, sizeof(count_1)); for ( i = *a2; (_BYTE)i; i = *a2 ) { ++a2; ++count_1[i]; } v3 = *a1; v4 = 1LL; for ( j = 0LL; v3; v3 = a1[v4 - 1] ) { *((_BYTE *)&unk_453F + v4) = v3; j = (int)v4++; } temp_3[j] = 0; v6 = temp_3[0]; if ( temp_3[0] ) { v7 = &temp_3[1]; v8 = 0; do { if ( !count_1[v6] ) { v9 = v8++; temp_3[v9] = v6; } v6 = *v7++; } while ( v6 ); v10 = v8; v11 = v8; } else { v11 = 0LL; v10 = 0LL; } result = __strncpy_chk(&result_2, temp_3, v11, 256LL); *(_BYTE *)(result + v10) = 0; return result; }
func0: ENDBR64 LEA RDX,[0x104040] XOR EAX,EAX MOV R8,RDI PUSH RBX MOV ECX,0x80 MOV RDI,RDX STOSQ.REP RDI MOVSX RAX,byte ptr [RSI] TEST AL,AL JZ 0x00101398 NOP dword ptr [RAX] LAB_00101388: ADD RSI,0x1 ADD dword ptr [RDX + RAX*0x4],0x1 MOVSX RAX,byte ptr [RSI] TEST AL,AL JNZ 0x00101388 LAB_00101398: MOVZX ECX,byte ptr [R8] MOV EAX,0x1 LEA RDI,[0x10453f] XOR ESI,ESI TEST CL,CL JZ 0x001013c4 NOP LAB_001013b0: MOV byte ptr [RDI + RAX*0x1],CL MOVSXD RSI,EAX ADD RAX,0x1 MOVZX ECX,byte ptr [R8 + RAX*0x1 + -0x1] TEST CL,CL JNZ 0x001013b0 LAB_001013c4: LEA R8,[0x104540] MOV byte ptr [R8 + RSI*0x1],0x0 MOVZX EAX,byte ptr [0x00104540] TEST AL,AL JZ 0x00101430 LEA RCX,[R8 + 0x1] XOR ESI,ESI NOP dword ptr [RAX] LAB_001013e8: MOVSX RDI,AL MOV EDI,dword ptr [RDX + RDI*0x4] TEST EDI,EDI JNZ 0x001013fd MOVSXD RDI,ESI ADD ESI,0x1 MOV byte ptr [R8 + RDI*0x1],AL LAB_001013fd: MOVZX EAX,byte ptr [RCX] ADD RCX,0x1 TEST AL,AL JNZ 0x001013e8 MOVSXD RBX,ESI MOV RDX,RBX LAB_0010140e: MOV RSI,R8 LEA R8,[0x104440] MOV ECX,0x100 MOV RDI,R8 CALL 0x001010b0 MOV byte ptr [RAX + RBX*0x1],0x0 POP RBX RET LAB_00101430: XOR EDX,EDX XOR EBX,EBX JMP 0x0010140e
void func0(char *param_1,char *param_2) { char cVar1; long lVar2; char *pcVar3; int iVar4; long lVar5; int8 *puVar6; puVar6 = (int8 *)&count_1; for (lVar2 = 0x80; lVar2 != 0; lVar2 = lVar2 + -1) { *puVar6 = 0; puVar6 = puVar6 + 1; } cVar1 = *param_2; while (cVar1 != '\0') { param_2 = param_2 + 1; (&count_1)[cVar1] = (&count_1)[cVar1] + 1; cVar1 = *param_2; } lVar5 = 0; cVar1 = *param_1; lVar2 = 1; while (cVar1 != '\0') { result_2[lVar2 + 0xff] = cVar1; lVar5 = (long)(int)lVar2; cVar1 = param_1[lVar2]; lVar2 = lVar2 + 1; } (&temp_3)[lVar5] = 0; if (temp_3 == '\0') { lVar2 = 0; } else { pcVar3 = &DAT_00104541; iVar4 = 0; cVar1 = temp_3; do { if ((&count_1)[cVar1] == 0) { lVar2 = (long)iVar4; iVar4 = iVar4 + 1; (&temp_3)[lVar2] = cVar1; } cVar1 = *pcVar3; pcVar3 = pcVar3 + 1; } while (cVar1 != '\0'); lVar2 = (long)iVar4; } lVar5 = __strncpy_chk(result_2,&temp_3,lVar2,0x100); *(int1 *)(lVar5 + lVar2) = 0; return; }
3,967
func0
#include <stdio.h> #include <string.h> #include <assert.h> #define NO_OF_CHARS 256 char *str_to_list(char *string) { static char temp[256]; int i = 0; while (*string) { temp[i++] = *string++; } temp[i] = '\0'; return temp; } char *lst_to_string(char *list, int res_ind) { static char result[256]; strncpy(result, list, res_ind); result[res_ind] = '\0'; return result; } int *get_char_count_array(char *string) { static int count[NO_OF_CHARS]; memset(count, 0, sizeof(count)); while (*string) { count[(int)(*string)]++; string++; } return count; }
char *func0(char *string, char *second_string) { int *count = get_char_count_array(second_string); int ip_ind = 0, res_ind = 0; char *str_list = str_to_list(string); while (str_list[ip_ind] != '\0') { char temp = str_list[ip_ind]; if (count[(int)temp] == 0) { str_list[res_ind++] = temp; } ip_ind++; } return lst_to_string(str_list, res_ind); }
int main() { assert(strcmp(func0("probasscurve", "pros"), "bacuve") == 0); assert(strcmp(func0("digitalindia", "talent"), "digiidi") == 0); assert(strcmp(func0("exoticmiles", "toxic"), "emles") == 0); printf("All tests passed.\n"); return 0; }
O3
c
func0: endbr64 lea 0x2ce5(%rip),%rdx xor %eax,%eax mov %rdi,%r8 push %rbx mov $0x80,%ecx mov %rdx,%rdi rep stos %rax,%es:(%rdi) movsbq (%rsi),%rax test %al,%al je 1388 <func0+0x38> nopl 0x0(%rax) add $0x1,%rsi addl $0x1,(%rdx,%rax,4) movsbq (%rsi),%rax test %al,%al jne 1378 <func0+0x28> movzbl (%r8),%ecx mov $0x1,%eax lea 0x31a7(%rip),%rdi xor %esi,%esi test %cl,%cl je 13b4 <func0+0x64> xchg %ax,%ax mov %cl,(%rdi,%rax,1) movslq %eax,%rsi add $0x1,%rax movzbl -0x1(%r8,%rax,1),%ecx test %cl,%cl jne 13a0 <func0+0x50> lea 0x3185(%rip),%r9 movb $0x0,(%r9,%rsi,1) movzbl 0x3179(%rip),%eax test %al,%al je 1440 <func0+0xf0> lea 0x1(%r9),%rcx xor %edi,%edi xor %ebx,%ebx nopl 0x0(%rax,%rax,1) movsbq %al,%rsi mov %rbx,%r8 mov (%rdx,%rsi,4),%esi test %esi,%esi jne 1430 <func0+0xe0> add $0x1,%rcx mov %al,(%r9,%rbx,1) add $0x1,%edi movzbl -0x1(%rcx),%eax movslq %edi,%rbx mov %rbx,%r8 test %al,%al jne 13d8 <func0+0x88> mov $0x100,%ecx mov %r8,%rdx lea 0x3132(%rip),%rsi lea 0x302b(%rip),%rdi callq 1090 <__strncpy_chk@plt> lea 0x301f(%rip),%rax movb $0x0,(%rax,%rbx,1) pop %rbx retq nopw 0x0(%rax,%rax,1) movzbl (%rcx),%eax add $0x1,%rcx test %al,%al jne 13d8 <func0+0x88> jmp 13ff <func0+0xaf> nopl (%rax) xor %r8d,%r8d xor %ebx,%ebx jmp 13ff <func0+0xaf> nopw 0x0(%rax,%rax,1)
func0: endbr64 lea rdx, count_1 xor eax, eax mov r8, rdi push rbx mov ecx, 80h mov rdi, rdx rep stosq movsx rax, byte ptr [rsi] test al, al jz short loc_13A8 nop dword ptr [rax+00h] loc_1398: add rsi, 1 add dword ptr [rdx+rax*4], 1 movsx rax, byte ptr [rsi] test al, al jnz short loc_1398 loc_13A8: movzx ecx, byte ptr [r8] mov eax, 1 lea rdi, unk_453F xor esi, esi test cl, cl jz short loc_13D4 xchg ax, ax loc_13C0: mov [rdi+rax], cl mov rsi, rax add rax, 1 movzx ecx, byte ptr [r8+rax-1] test cl, cl jnz short loc_13C0 loc_13D4: lea r8, temp_3 movsxd rsi, esi mov byte ptr [r8+rsi], 0 movzx eax, cs:temp_3 test al, al jz short loc_1458 lea rcx, [r8+1] xor esi, esi nop dword ptr [rax+00h] loc_13F8: movsx rdi, al mov edi, [rdx+rdi*4] test edi, edi jnz short loc_1424 loc_1403: add rcx, 1 mov [r8+rsi], al lea edi, [rsi+1] movzx eax, byte ptr [rcx-1] test al, al jz short loc_1450 movsxd rsi, edi movsx rdi, al mov edi, [rdx+rdi*4] test edi, edi jz short loc_1403 loc_1424: movzx eax, byte ptr [rcx] add rcx, 1 test al, al jnz short loc_13F8 loc_142F: movsxd rbx, esi mov rdx, rbx loc_1435: mov ecx, 100h mov rsi, r8 lea rdi, result_2 call ___strncpy_chk mov byte ptr [rax+rbx], 0 pop rbx retn loc_1450: mov esi, edi jmp short loc_142F loc_1458: xor edx, edx xor ebx, ebx jmp short loc_1435
long long func0(char *a1, char *a2) { long long i; // rax char v3; // cl long long v4; // rax int j; // esi char v6; // al char *v7; // rcx long long v8; // rsi long long v9; // rbx long long v10; // rdx long long result; // rax memset(count_1, 0, sizeof(count_1)); for ( i = *a2; (_BYTE)i; i = *a2 ) { ++a2; ++count_1[i]; } v3 = *a1; v4 = 1LL; for ( j = 0; v3; v3 = a1[v4 - 1] ) { *((_BYTE *)&unk_453F + v4) = v3; j = v4++; } temp_3[j] = 0; v6 = temp_3[0]; if ( temp_3[0] ) { v7 = &temp_3[1]; v8 = 0LL; while ( count_1[v6] ) { LABEL_10: v6 = *v7++; if ( !v6 ) goto LABEL_11; } while ( 1 ) { ++v7; temp_3[v8] = v6; v6 = *(v7 - 1); if ( !v6 ) break; v8 = (int)v8 + 1; if ( count_1[v6] ) goto LABEL_10; } LODWORD(v8) = v8 + 1; LABEL_11: v9 = (int)v8; v10 = (int)v8; } else { v10 = 0LL; v9 = 0LL; } result = __strncpy_chk(&result_2, temp_3, v10, 256LL); *(_BYTE *)(result + v9) = 0; return result; }
func0: ENDBR64 LEA RDX,[0x104040] XOR EAX,EAX MOV R8,RDI PUSH RBX MOV ECX,0x80 MOV RDI,RDX STOSQ.REP RDI MOVSX RAX,byte ptr [RSI] TEST AL,AL JZ 0x001013a8 NOP dword ptr [RAX] LAB_00101398: ADD RSI,0x1 ADD dword ptr [RDX + RAX*0x4],0x1 MOVSX RAX,byte ptr [RSI] TEST AL,AL JNZ 0x00101398 LAB_001013a8: MOVZX ECX,byte ptr [R8] MOV EAX,0x1 LEA RDI,[0x10453f] XOR ESI,ESI TEST CL,CL JZ 0x001013d4 NOP LAB_001013c0: MOV byte ptr [RDI + RAX*0x1],CL MOV RSI,RAX ADD RAX,0x1 MOVZX ECX,byte ptr [R8 + RAX*0x1 + -0x1] TEST CL,CL JNZ 0x001013c0 LAB_001013d4: LEA R8,[0x104540] MOVSXD RSI,ESI MOV byte ptr [R8 + RSI*0x1],0x0 MOVZX EAX,byte ptr [0x00104540] TEST AL,AL JZ 0x00101458 LEA RCX,[R8 + 0x1] XOR ESI,ESI NOP dword ptr [RAX] LAB_001013f8: MOVSX RDI,AL MOV EDI,dword ptr [RDX + RDI*0x4] TEST EDI,EDI JNZ 0x00101424 LAB_00101403: ADD RCX,0x1 MOV byte ptr [R8 + RSI*0x1],AL LEA EDI,[RSI + 0x1] MOVZX EAX,byte ptr [RCX + -0x1] TEST AL,AL JZ 0x00101450 MOVSXD RSI,EDI MOVSX RDI,AL MOV EDI,dword ptr [RDX + RDI*0x4] TEST EDI,EDI JZ 0x00101403 LAB_00101424: MOVZX EAX,byte ptr [RCX] ADD RCX,0x1 TEST AL,AL JNZ 0x001013f8 LAB_0010142f: MOVSXD RBX,ESI MOV RDX,RBX LAB_00101435: MOV ECX,0x100 MOV RSI,R8 LEA RDI,[0x104440] CALL 0x001010b0 MOV byte ptr [RAX + RBX*0x1],0x0 POP RBX RET LAB_00101450: MOV ESI,EDI JMP 0x0010142f LAB_00101458: XOR EDX,EDX XOR EBX,EBX JMP 0x00101435
void func0(char *param_1,char *param_2) { char cVar1; long lVar2; long lVar3; char *pcVar4; int iVar5; ulong uVar6; uint uVar7; int8 *puVar8; puVar8 = (int8 *)&count_1; for (lVar3 = 0x80; lVar3 != 0; lVar3 = lVar3 + -1) { *puVar8 = 0; puVar8 = puVar8 + 1; } cVar1 = *param_2; while (cVar1 != '\0') { param_2 = param_2 + 1; (&count_1)[cVar1] = (&count_1)[cVar1] + 1; cVar1 = *param_2; } iVar5 = 0; cVar1 = *param_1; lVar3 = 1; while (cVar1 != '\0') { result_2[lVar3 + 0xff] = cVar1; iVar5 = (int)lVar3; cVar1 = param_1[lVar3]; lVar3 = lVar3 + 1; } (&temp_3)[iVar5] = 0; if (temp_3 == '\0') { lVar3 = 0; } else { pcVar4 = &DAT_00104541; uVar6 = 0; cVar1 = temp_3; do { iVar5 = (&count_1)[cVar1]; while (iVar5 == 0) { (&temp_3)[uVar6] = cVar1; uVar7 = (int)uVar6 + 1; cVar1 = *pcVar4; if (cVar1 == '\0') { uVar6 = (ulong)uVar7; goto LAB_0010142f; } uVar6 = (ulong)(int)uVar7; pcVar4 = pcVar4 + 1; iVar5 = (&count_1)[cVar1]; } cVar1 = *pcVar4; pcVar4 = pcVar4 + 1; } while (cVar1 != '\0'); LAB_0010142f: lVar3 = (long)(int)uVar6; } lVar2 = __strncpy_chk(result_2,&temp_3,lVar3,0x100); *(int *)(lVar2 + lVar3) = 0; return; }
3,968
func0
#include <assert.h> #include <stdbool.h>
bool func0(int arraynums[], int length) { bool found_duplicate = false; for (int i = 0; i < length; i++) { for (int j = i + 1; j < length; j++) { if (arraynums[i] == arraynums[j]) { found_duplicate = true; break; } } if (found_duplicate) { break; } } return found_duplicate; }
int main() { int array1[] = {1, 2, 3, 4, 5}; int array2[] = {1, 2, 3, 4, 4}; int array3[] = {1, 1, 2, 2, 3, 3, 4, 4, 5}; assert(func0(array1, sizeof(array1)/sizeof(array1[0])) == false); assert(func0(array2, sizeof(array2)/sizeof(array2[0])) == true); assert(func0(array3, sizeof(array3)/sizeof(array3[0])) == true); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) movb $0x0,-0x9(%rbp) movl $0x0,-0x8(%rbp) jmp 11dc <func0+0x73> mov -0x8(%rbp),%eax add $0x1,%eax mov %eax,-0x4(%rbp) jmp 11ca <func0+0x61> mov -0x8(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x18(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jne 11c6 <func0+0x5d> movb $0x1,-0x9(%rbp) jmp 11d2 <func0+0x69> addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x1c(%rbp),%eax jl 1190 <func0+0x27> cmpb $0x0,-0x9(%rbp) jne 11e6 <func0+0x7d> addl $0x1,-0x8(%rbp) mov -0x8(%rbp),%eax cmp -0x1c(%rbp),%eax jl 1185 <func0+0x1c> jmp 11e7 <func0+0x7e> movzbl -0x9(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov [rbp+var_9], 0 mov [rbp+var_8], 0 jmp short loc_11DC loc_1185: mov eax, [rbp+var_8] add eax, 1 mov [rbp+var_4], eax jmp short loc_11CA loc_1190: mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rax] mov eax, [rbp+var_4] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rcx mov eax, [rax] cmp edx, eax jnz short loc_11C6 mov [rbp+var_9], 1 jmp short loc_11D2 loc_11C6: add [rbp+var_4], 1 loc_11CA: mov eax, [rbp+var_4] cmp eax, [rbp+var_1C] jl short loc_1190 loc_11D2: cmp [rbp+var_9], 0 jnz short loc_11E6 add [rbp+var_8], 1 loc_11DC: mov eax, [rbp+var_8] cmp eax, [rbp+var_1C] jl short loc_1185 jmp short loc_11E7 loc_11E6: nop loc_11E7: movzx eax, [rbp+var_9] pop rbp retn
long long func0(long long a1, int a2) { unsigned __int8 v3; // [rsp+13h] [rbp-9h] int i; // [rsp+14h] [rbp-8h] int j; // [rsp+18h] [rbp-4h] v3 = 0; for ( i = 0; i < a2; ++i ) { for ( j = i + 1; j < a2; ++j ) { if ( *(_DWORD *)(4LL * i + a1) == *(_DWORD *)(4LL * j + a1) ) { v3 = 1; break; } } if ( v3 ) break; } return v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV byte ptr [RBP + -0x9],0x0 MOV dword ptr [RBP + -0x8],0x0 JMP 0x001011dc LAB_00101185: MOV EAX,dword ptr [RBP + -0x8] ADD EAX,0x1 MOV dword ptr [RBP + -0x4],EAX JMP 0x001011ca LAB_00101190: MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JNZ 0x001011c6 MOV byte ptr [RBP + -0x9],0x1 JMP 0x001011d2 LAB_001011c6: ADD dword ptr [RBP + -0x4],0x1 LAB_001011ca: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x1c] JL 0x00101190 LAB_001011d2: CMP byte ptr [RBP + -0x9],0x0 JNZ 0x001011e6 ADD dword ptr [RBP + -0x8],0x1 LAB_001011dc: MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x1c] JL 0x00101185 JMP 0x001011e7 LAB_001011e6: NOP LAB_001011e7: MOVZX EAX,byte ptr [RBP + -0x9] POP RBP RET
char func0(long param_1,int param_2) { char local_11; int local_10; int local_c; local_11 = '\0'; local_10 = 0; do { local_c = local_10; if (param_2 <= local_10) { return local_11; } do { local_c = local_c + 1; if (param_2 <= local_c) goto LAB_001011d2; } while (*(int *)(param_1 + (long)local_10 * 4) != *(int *)(param_1 + (long)local_c * 4)); local_11 = '\x01'; LAB_001011d2: if (local_11 != '\0') { return local_11; } local_10 = local_10 + 1; } while( true ); }
3,969
func0
#include <assert.h> #include <stdbool.h>
bool func0(int arraynums[], int length) { bool found_duplicate = false; for (int i = 0; i < length; i++) { for (int j = i + 1; j < length; j++) { if (arraynums[i] == arraynums[j]) { found_duplicate = true; break; } } if (found_duplicate) { break; } } return found_duplicate; }
int main() { int array1[] = {1, 2, 3, 4, 5}; int array2[] = {1, 2, 3, 4, 4}; int array3[] = {1, 1, 2, 2, 3, 3, 4, 4, 5}; assert(func0(array1, sizeof(array1)/sizeof(array1[0])) == false); assert(func0(array2, sizeof(array2)/sizeof(array2[0])) == true); assert(func0(array3, sizeof(array3)/sizeof(array3[0])) == true); return 0; }
O1
c
func0: endbr64 mov $0x1,%ecx jmp 1178 <func0+0xf> add $0x1,%rcx lea -0x1(%rcx),%eax cmp %eax,%esi jle 1199 <func0+0x30> cmp %ecx,%esi jle 1174 <func0+0xb> mov -0x4(%rdi,%rcx,4),%edx movslq %ecx,%rax cmp (%rdi,%rax,4),%edx je 119f <func0+0x36> add $0x1,%rax cmp %eax,%esi jg 118a <func0+0x21> jmp 1174 <func0+0xb> mov $0x0,%eax retq mov $0x1,%eax retq
func0: endbr64 mov ecx, 1 jmp short loc_1178 loc_1174: add rcx, 1 loc_1178: lea eax, [rcx-1] cmp esi, eax jle short loc_1199 cmp esi, ecx jle short loc_1174 mov edx, [rdi+rcx*4-4] movsxd rax, ecx loc_118A: cmp edx, [rdi+rax*4] jz short loc_119F add rax, 1 cmp esi, eax jg short loc_118A jmp short loc_1174 loc_1199: mov eax, 0 retn loc_119F: mov eax, 1 retn
long long func0(long long a1, int a2) { long long i; // rcx long long v3; // rax for ( i = 1LL; ; ++i ) { if ( a2 <= (int)i - 1 ) return 0LL; if ( a2 > (int)i ) break; LABEL_2: ; } v3 = (int)i; while ( *(_DWORD *)(a1 + 4 * i - 4) != *(_DWORD *)(a1 + 4 * v3) ) { if ( a2 <= (int)++v3 ) goto LABEL_2; } return 1LL; }
func0: ENDBR64 MOV ECX,0x1 JMP 0x00101178 LAB_00101174: ADD RCX,0x1 LAB_00101178: LEA EAX,[RCX + -0x1] CMP ESI,EAX JLE 0x00101199 CMP ESI,ECX JLE 0x00101174 MOV EDX,dword ptr [RDI + RCX*0x4 + -0x4] MOVSXD RAX,ECX LAB_0010118a: CMP EDX,dword ptr [RDI + RAX*0x4] JZ 0x0010119f ADD RAX,0x1 CMP ESI,EAX JG 0x0010118a JMP 0x00101174 LAB_00101199: MOV EAX,0x0 RET LAB_0010119f: MOV EAX,0x1 RET
int8 func0(long param_1,int param_2) { int iVar1; long lVar2; long lVar3; lVar3 = 1; do { iVar1 = (int)lVar3; if (param_2 <= iVar1 + -1) { return 0; } if (iVar1 < param_2) { lVar2 = (long)iVar1; do { if (*(int *)(param_1 + -4 + lVar3 * 4) == *(int *)(param_1 + lVar2 * 4)) { return 1; } lVar2 = lVar2 + 1; } while ((int)lVar2 < param_2); } lVar3 = lVar3 + 1; } while( true ); }
3,970
func0
#include <assert.h> #include <stdbool.h>
bool func0(int arraynums[], int length) { bool found_duplicate = false; for (int i = 0; i < length; i++) { for (int j = i + 1; j < length; j++) { if (arraynums[i] == arraynums[j]) { found_duplicate = true; break; } } if (found_duplicate) { break; } } return found_duplicate; }
int main() { int array1[] = {1, 2, 3, 4, 5}; int array2[] = {1, 2, 3, 4, 4}; int array3[] = {1, 1, 2, 2, 3, 3, 4, 4, 5}; assert(func0(array1, sizeof(array1)/sizeof(array1[0])) == false); assert(func0(array2, sizeof(array2)/sizeof(array2[0])) == true); assert(func0(array3, sizeof(array3)/sizeof(array3[0])) == true); return 0; }
O2
c
func0: endbr64 test %esi,%esi jle 12e1 <func0+0x51> lea -0x1(%rsi),%r8d mov $0x1,%ecx add $0x1,%r8 cmp %r8,%rcx je 12e1 <func0+0x51> nopw 0x0(%rax,%rax,1) mov -0x4(%rdi,%rcx,4),%edx mov %rcx,%rax jmp 12c8 <func0+0x38> nopl 0x0(%rax) add $0x1,%rax cmp %eax,%esi jle 12d8 <func0+0x48> cmp (%rdi,%rax,4),%edx jne 12c0 <func0+0x30> mov $0x1,%eax retq nopl 0x0(%rax,%rax,1) add $0x1,%rcx cmp %r8,%rcx jne 12b0 <func0+0x20> xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 test esi, esi jle short loc_1309 movsxd r8, esi mov ecx, 1 cmp rcx, r8 jz short loc_1309 nop dword ptr [rax] loc_12D8: mov edx, [rdi+rcx*4-4] mov rax, rcx jmp short loc_12F0 loc_12E8: add rax, 1 cmp esi, eax jle short loc_1300 loc_12F0: cmp edx, [rdi+rax*4] jnz short loc_12E8 mov eax, 1 retn loc_1300: add rcx, 1 cmp rcx, r8 jnz short loc_12D8 loc_1309: xor eax, eax retn
long long func0(long long a1, int a2) { long long i; // rcx long long v3; // rax if ( a2 > 0 ) { for ( i = 1LL; i != a2; ++i ) { v3 = i; do { if ( *(_DWORD *)(a1 + 4 * i - 4) == *(_DWORD *)(a1 + 4 * v3) ) return 1LL; ++v3; } while ( a2 > (int)v3 ); } } return 0LL; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101309 MOVSXD R8,ESI MOV ECX,0x1 CMP RCX,R8 JZ 0x00101309 NOP dword ptr [RAX] LAB_001012d8: MOV EDX,dword ptr [RDI + RCX*0x4 + -0x4] MOV RAX,RCX JMP 0x001012f0 LAB_001012e8: ADD RAX,0x1 CMP ESI,EAX JLE 0x00101300 LAB_001012f0: CMP EDX,dword ptr [RDI + RAX*0x4] JNZ 0x001012e8 MOV EAX,0x1 RET LAB_00101300: ADD RCX,0x1 CMP RCX,R8 JNZ 0x001012d8 LAB_00101309: XOR EAX,EAX RET
int8 func0(long param_1,int param_2) { long lVar1; long lVar2; if (0 < param_2) { lVar2 = 1; if ((long)param_2 != 1) { do { lVar1 = lVar2; do { if (*(int *)(param_1 + -4 + lVar2 * 4) == *(int *)(param_1 + lVar1 * 4)) { return 1; } lVar1 = lVar1 + 1; } while ((int)lVar1 < param_2); lVar2 = lVar2 + 1; } while (lVar2 != param_2); } } return 0; }
3,971
func0
#include <assert.h> #include <stdbool.h>
bool func0(int arraynums[], int length) { bool found_duplicate = false; for (int i = 0; i < length; i++) { for (int j = i + 1; j < length; j++) { if (arraynums[i] == arraynums[j]) { found_duplicate = true; break; } } if (found_duplicate) { break; } } return found_duplicate; }
int main() { int array1[] = {1, 2, 3, 4, 5}; int array2[] = {1, 2, 3, 4, 4}; int array3[] = {1, 1, 2, 2, 3, 3, 4, 4, 5}; assert(func0(array1, sizeof(array1)/sizeof(array1[0])) == false); assert(func0(array2, sizeof(array2)/sizeof(array2[0])) == true); assert(func0(array3, sizeof(array3)/sizeof(array3[0])) == true); return 0; }
O3
c
func0: endbr64 test %esi,%esi jle 12e1 <func0+0x51> lea -0x1(%rsi),%r8d mov $0x1,%ecx add $0x1,%r8 cmp %rcx,%r8 je 12e1 <func0+0x51> nopw 0x0(%rax,%rax,1) mov -0x4(%rdi,%rcx,4),%edx mov %rcx,%rax jmp 12c8 <func0+0x38> nopl 0x0(%rax) add $0x1,%rax cmp %eax,%esi jle 12d8 <func0+0x48> cmp (%rdi,%rax,4),%edx jne 12c0 <func0+0x30> mov $0x1,%eax retq nopl 0x0(%rax,%rax,1) add $0x1,%rcx cmp %rcx,%r8 jne 12b0 <func0+0x20> xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 mov ecx, 1 lea eax, [rcx-1] cmp esi, eax jle short loc_1183 loc_1150: cmp esi, ecx jle short loc_1178 mov edx, [rdi+rcx*4-4] mov rax, rcx jmp short loc_1168 loc_1160: add rax, 1 cmp esi, eax jle short loc_1178 loc_1168: cmp edx, [rdi+rax*4] jnz short loc_1160 mov eax, 1 retn loc_1178: add rcx, 1 lea eax, [rcx-1] cmp esi, eax jg short loc_1150 loc_1183: xor eax, eax retn
long long func0(long long a1, int a2) { long long v2; // rcx long long v3; // rax v2 = 1LL; if ( a2 <= 0 ) return 0LL; while ( a2 <= (int)v2 ) { LABEL_7: if ( a2 <= (int)++v2 - 1 ) return 0LL; } v3 = v2; while ( *(_DWORD *)(a1 + 4 * v2 - 4) != *(_DWORD *)(a1 + 4 * v3) ) { if ( a2 <= (int)++v3 ) goto LABEL_7; } return 1LL; }
func0: ENDBR64 MOV ECX,0x1 LEA EAX,[RCX + -0x1] CMP ESI,EAX JLE 0x00101183 LAB_00101150: CMP ESI,ECX JLE 0x00101178 MOV EDX,dword ptr [RDI + RCX*0x4 + -0x4] MOV RAX,RCX JMP 0x00101168 LAB_00101160: ADD RAX,0x1 CMP ESI,EAX JLE 0x00101178 LAB_00101168: CMP EDX,dword ptr [RDI + RAX*0x4] JNZ 0x00101160 MOV EAX,0x1 RET LAB_00101178: ADD RCX,0x1 LEA EAX,[RCX + -0x1] CMP ESI,EAX JG 0x00101150 LAB_00101183: XOR EAX,EAX RET
int8 func0(long param_1,int param_2) { long lVar1; int iVar2; long lVar3; lVar3 = 1; if (0 < param_2) { do { iVar2 = (int)lVar3; if (iVar2 < param_2) { lVar1 = lVar3; do { if (*(int *)(param_1 + -4 + lVar3 * 4) == *(int *)(param_1 + lVar1 * 4)) { return 1; } lVar1 = lVar1 + 1; } while ((int)lVar1 < param_2); } lVar3 = lVar3 + 1; } while (iVar2 < param_2); } return 0; }
3,972
func0
#include <stdbool.h> #include <assert.h>
bool func0(long long x) { if (x % 2 == 0) { return false; } if (x == 1) { return true; } x = x + 1; long long p = 0; while (x % 2 == 0) { x = x / 2; p = p + 1; if (p == x) { return true; } } return false; }
int main() { assert(func0(383) == true); assert(func0(254) == false); assert(func0(200) == false); assert(func0(32212254719) == true); assert(func0(32212254718) == false); assert(func0(159) == true); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov -0x18(%rbp),%rax and $0x1,%eax test %rax,%rax jne 1168 <func0+0x1f> mov $0x0,%eax jmp 11c1 <func0+0x78> cmpq $0x1,-0x18(%rbp) jne 1176 <func0+0x2d> mov $0x1,%eax jmp 11c1 <func0+0x78> addq $0x1,-0x18(%rbp) movq $0x0,-0x8(%rbp) jmp 11b0 <func0+0x67> mov -0x18(%rbp),%rax mov %rax,%rdx shr $0x3f,%rdx add %rdx,%rax sar %rax mov %rax,-0x18(%rbp) addq $0x1,-0x8(%rbp) mov -0x8(%rbp),%rax cmp -0x18(%rbp),%rax jne 11b0 <func0+0x67> mov $0x1,%eax jmp 11c1 <func0+0x78> mov -0x18(%rbp),%rax and $0x1,%eax test %rax,%rax je 1185 <func0+0x3c> mov $0x0,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov rax, [rbp+var_18] and eax, 1 test rax, rax jnz short loc_1168 mov eax, 0 jmp short loc_11C1 loc_1168: cmp [rbp+var_18], 1 jnz short loc_1176 mov eax, 1 jmp short loc_11C1 loc_1176: add [rbp+var_18], 1 mov [rbp+var_8], 0 jmp short loc_11B0 loc_1185: mov rax, [rbp+var_18] mov rdx, rax shr rdx, 3Fh add rax, rdx sar rax, 1 mov [rbp+var_18], rax add [rbp+var_8], 1 mov rax, [rbp+var_8] cmp rax, [rbp+var_18] jnz short loc_11B0 mov eax, 1 jmp short loc_11C1 loc_11B0: mov rax, [rbp+var_18] and eax, 1 test rax, rax jz short loc_1185 mov eax, 0 loc_11C1: pop rbp retn
long long func0(long long a1) { long long v2; // [rsp+0h] [rbp-18h] long long v3; // [rsp+10h] [rbp-8h] if ( (a1 & 1) == 0 ) return 0LL; if ( a1 == 1 ) return 1LL; v2 = a1 + 1; v3 = 0LL; while ( (v2 & 1) == 0 ) { v2 /= 2LL; if ( ++v3 == v2 ) return 1LL; } return 0LL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV RAX,qword ptr [RBP + -0x18] AND EAX,0x1 TEST RAX,RAX JNZ 0x00101168 MOV EAX,0x0 JMP 0x001011c1 LAB_00101168: CMP qword ptr [RBP + -0x18],0x1 JNZ 0x00101176 MOV EAX,0x1 JMP 0x001011c1 LAB_00101176: ADD qword ptr [RBP + -0x18],0x1 MOV qword ptr [RBP + -0x8],0x0 JMP 0x001011b0 LAB_00101185: MOV RAX,qword ptr [RBP + -0x18] MOV RDX,RAX SHR RDX,0x3f ADD RAX,RDX SAR RAX,0x1 MOV qword ptr [RBP + -0x18],RAX ADD qword ptr [RBP + -0x8],0x1 MOV RAX,qword ptr [RBP + -0x8] CMP RAX,qword ptr [RBP + -0x18] JNZ 0x001011b0 MOV EAX,0x1 JMP 0x001011c1 LAB_001011b0: MOV RAX,qword ptr [RBP + -0x18] AND EAX,0x1 TEST RAX,RAX JZ 0x00101185 MOV EAX,0x0 LAB_001011c1: POP RBP RET
int8 func0(ulong param_1) { int8 uVar1; ulong local_20; ulong local_10; if ((param_1 & 1) == 0) { uVar1 = 0; } else if (param_1 == 1) { uVar1 = 1; } else { local_20 = param_1 + 1; local_10 = 0; do { if ((local_20 & 1) != 0) { return 0; } local_20 = (long)local_20 / 2; local_10 = local_10 + 1; } while (local_10 != local_20); uVar1 = 1; } return uVar1; }
3,973
func0
#include <stdbool.h> #include <assert.h>
bool func0(long long x) { if (x % 2 == 0) { return false; } if (x == 1) { return true; } x = x + 1; long long p = 0; while (x % 2 == 0) { x = x / 2; p = p + 1; if (p == x) { return true; } } return false; }
int main() { assert(func0(383) == true); assert(func0(254) == false); assert(func0(200) == false); assert(func0(32212254719) == true); assert(func0(32212254718) == false); assert(func0(159) == true); return 0; }
O1
c
func0: endbr64 mov $0x0,%eax test $0x1,%dil je 118e <func0+0x45> mov $0x1,%eax cmp $0x1,%rdi je 118e <func0+0x45> lea 0x1(%rdi),%rax mov $0x0,%edx test $0x1,%al jne 118f <func0+0x46> mov %rax,%rdi shr $0x3f,%rdi add %rax,%rdi sar %rdi mov %rdi,%rax add $0x1,%rdx cmp %rdx,%rdi jne 116c <func0+0x23> mov $0x1,%eax retq mov $0x0,%eax retq
func0: endbr64 mov eax, 0 test dil, 1 jz short locret_1190 mov eax, 1 cmp rdi, 1 jz short locret_1190 add rdi, 1 mov edx, 0 loc_116C: test dil, 1 jnz short loc_1191 mov rax, rdi shr rax, 3Fh add rax, rdi sar rax, 1 mov rdi, rax add rdx, 1 cmp rax, rdx jnz short loc_116C mov eax, 1 locret_1190: retn loc_1191: mov eax, 0 retn
long long func0(long long a1) { long long result; // rax long long v2; // rdi long long v3; // rdx result = 0LL; if ( (a1 & 1) != 0 ) { result = 1LL; if ( a1 != 1 ) { v2 = a1 + 1; v3 = 0LL; while ( (v2 & 1) == 0 ) { v2 /= 2LL; if ( v2 == ++v3 ) return 1LL; } return 0LL; } } return result; }
func0: ENDBR64 MOV EAX,0x0 TEST DIL,0x1 JZ 0x00101190 MOV EAX,0x1 CMP RDI,0x1 JZ 0x00101190 ADD RDI,0x1 MOV EDX,0x0 LAB_0010116c: TEST DIL,0x1 JNZ 0x00101191 MOV RAX,RDI SHR RAX,0x3f ADD RAX,RDI SAR RAX,0x1 MOV RDI,RAX ADD RDX,0x1 CMP RAX,RDX JNZ 0x0010116c MOV EAX,0x1 LAB_00101190: RET LAB_00101191: MOV EAX,0x0 RET
int8 func0(ulong param_1) { int8 uVar1; ulong uVar2; uVar1 = 0; if (((param_1 & 1) != 0) && (uVar1 = 1, param_1 != 1)) { param_1 = param_1 + 1; uVar2 = 0; do { if ((param_1 & 1) != 0) { return 0; } param_1 = (long)param_1 / 2; uVar2 = uVar2 + 1; } while (param_1 != uVar2); uVar1 = 1; } return uVar1; }
3,974
func0
#include <stdbool.h> #include <assert.h>
bool func0(long long x) { if (x % 2 == 0) { return false; } if (x == 1) { return true; } x = x + 1; long long p = 0; while (x % 2 == 0) { x = x / 2; p = p + 1; if (p == x) { return true; } } return false; }
int main() { assert(func0(383) == true); assert(func0(254) == false); assert(func0(200) == false); assert(func0(32212254719) == true); assert(func0(32212254718) == false); assert(func0(159) == true); return 0; }
O2
c
func0: endbr64 test $0x1,%dil je 1248 <func0+0x18> cmp $0x1,%rdi je 1250 <func0+0x20> jmp 11f0 <func0.part.0> nopw 0x0(%rax,%rax,1) xor %eax,%eax retq nopl 0x0(%rax,%rax,1) mov $0x1,%eax retq nopw %cs:0x0(%rax,%rax,1)
func0_part_0: add rdi, 1 xor eax, eax jmp short loc_1216 loc_1200: mov rdx, rdi add rax, 1 shr rdx, 3Fh add rdi, rdx sar rdi, 1 cmp rdi, rax jz short loc_1220 loc_1216: test dil, 1 jz short loc_1200 xor eax, eax retn loc_1220: mov eax, 1 retn
long long func0_part_0(long long a1) { long long v1; // rdi long long v2; // rax v1 = a1 + 1; v2 = 0LL; do { if ( (v1 & 1) != 0 ) return 0LL; ++v2; v1 /= 2LL; } while ( v1 != v2 ); return 1LL; }
func0.part.0: ADD RDI,0x1 XOR EAX,EAX JMP 0x00101216 LAB_00101200: MOV RDX,RDI ADD RAX,0x1 SHR RDX,0x3f ADD RDI,RDX SAR RDI,0x1 CMP RDI,RAX JZ 0x00101220 LAB_00101216: TEST DIL,0x1 JZ 0x00101200 XOR EAX,EAX RET LAB_00101220: MOV EAX,0x1 RET
int8 func0_part_0(long param_1) { ulong uVar1; ulong uVar2; uVar2 = param_1 + 1; uVar1 = 0; do { if ((uVar2 & 1) != 0) { return 0; } uVar1 = uVar1 + 1; uVar2 = (long)uVar2 / 2; } while (uVar2 != uVar1); return 1; }
3,975
func0
#include <stdbool.h> #include <assert.h>
bool func0(long long x) { if (x % 2 == 0) { return false; } if (x == 1) { return true; } x = x + 1; long long p = 0; while (x % 2 == 0) { x = x / 2; p = p + 1; if (p == x) { return true; } } return false; }
int main() { assert(func0(383) == true); assert(func0(254) == false); assert(func0(200) == false); assert(func0(32212254719) == true); assert(func0(32212254718) == false); assert(func0(159) == true); return 0; }
O3
c
func0: endbr64 xor %eax,%eax test $0x1,%dil je 1275 <func0+0x45> mov $0x1,%eax cmp $0x1,%rdi je 1275 <func0+0x45> add $0x1,%rdi xor %eax,%eax jmp 1266 <func0+0x36> mov %rdi,%rdx add $0x1,%rax shr $0x3f,%rdx add %rdx,%rdi sar %rdi cmp %rax,%rdi je 1270 <func0+0x40> test $0x1,%dil je 1250 <func0+0x20> xor %eax,%eax retq mov $0x1,%eax retq nopw %cs:0x0(%rax,%rax,1)
func0_part_0: add rdi, 1 xor eax, eax jmp short loc_1216 loc_1200: mov rdx, rdi add rax, 1 shr rdx, 3Fh add rdi, rdx sar rdi, 1 cmp rdi, rax jz short loc_1220 loc_1216: test dil, 1 jz short loc_1200 xor eax, eax retn loc_1220: mov eax, 1 retn
long long func0_part_0(long long a1) { long long v1; // rdi long long v2; // rax v1 = a1 + 1; v2 = 0LL; do { if ( (v1 & 1) != 0 ) return 0LL; ++v2; v1 /= 2LL; } while ( v1 != v2 ); return 1LL; }
func0.part.0: ADD RDI,0x1 XOR EAX,EAX JMP 0x00101216 LAB_00101200: MOV RDX,RDI ADD RAX,0x1 SHR RDX,0x3f ADD RDI,RDX SAR RDI,0x1 CMP RDI,RAX JZ 0x00101220 LAB_00101216: TEST DIL,0x1 JZ 0x00101200 XOR EAX,EAX RET LAB_00101220: MOV EAX,0x1 RET
int8 func0_part_0(long param_1) { ulong uVar1; ulong uVar2; uVar2 = param_1 + 1; uVar1 = 0; do { if ((uVar2 & 1) != 0) { return 0; } uVar1 = uVar1 + 1; uVar2 = (long)uVar2 / 2; } while (uVar2 != uVar1); return 1; }
3,976
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
int* func0(int m, int n, int* length) { *length = m; int* results = malloc(sizeof(int) * m); if (!results) { return NULL; } for (int i = 0; i < m; i++) { results[i] = (i + 1) * n; } return results; }
int main() { int length, *result; result = func0(4, 3, &length); int expected1[] = {3, 6, 9, 12}; for (int i = 0; i < length; i++) { assert(result[i] == expected1[i]); } free(result); result = func0(2, 5, &length); int expected2[] = {5, 10}; for (int i = 0; i < length; i++) { assert(result[i] == expected2[i]); } free(result); result = func0(9, 2, &length); int expected3[] = {2, 4, 6, 8, 10, 12, 14, 16, 18}; for (int i = 0; i < length; i++) { assert(result[i] == expected3[i]); } free(result); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov %rdx,-0x20(%rbp) mov -0x20(%rbp),%rax mov -0x14(%rbp),%edx mov %edx,(%rax) mov -0x14(%rbp),%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) cmpq $0x0,-0x8(%rbp) jne 11eb <func0+0x42> mov $0x0,%eax jmp 1225 <func0+0x7c> movl $0x0,-0xc(%rbp) jmp 1219 <func0+0x70> mov -0xc(%rbp),%eax add $0x1,%eax mov -0xc(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx imul -0x18(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x14(%rbp),%eax jl 11f4 <func0+0x4b> mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_14], edi mov [rbp+var_18], esi mov [rbp+var_20], rdx mov rax, [rbp+var_20] mov edx, [rbp+var_14] mov [rax], edx mov eax, [rbp+var_14] cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_8], rax cmp [rbp+var_8], 0 jnz short loc_11EB mov eax, 0 jmp short locret_1225 loc_11EB: mov [rbp+var_C], 0 jmp short loc_1219 loc_11F4: mov eax, [rbp+var_C] add eax, 1 mov edx, [rbp+var_C] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_8] add rdx, rcx imul eax, [rbp+var_18] mov [rdx], eax add [rbp+var_C], 1 loc_1219: mov eax, [rbp+var_C] cmp eax, [rbp+var_14] jl short loc_11F4 mov rax, [rbp+var_8] locret_1225: leave retn
_DWORD * func0(int a1, int a2, _DWORD *a3) { int i; // [rsp+14h] [rbp-Ch] _DWORD *v5; // [rsp+18h] [rbp-8h] *a3 = a1; v5 = malloc(4LL * a1); if ( !v5 ) return 0LL; for ( i = 0; i < a1; ++i ) v5[i] = a2 * (i + 1); return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV qword ptr [RBP + -0x20],RDX MOV RAX,qword ptr [RBP + -0x20] MOV EDX,dword ptr [RBP + -0x14] MOV dword ptr [RAX],EDX MOV EAX,dword ptr [RBP + -0x14] CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX CMP qword ptr [RBP + -0x8],0x0 JNZ 0x001011eb MOV EAX,0x0 JMP 0x00101225 LAB_001011eb: MOV dword ptr [RBP + -0xc],0x0 JMP 0x00101219 LAB_001011f4: MOV EAX,dword ptr [RBP + -0xc] ADD EAX,0x1 MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX IMUL EAX,dword ptr [RBP + -0x18] MOV dword ptr [RDX],EAX ADD dword ptr [RBP + -0xc],0x1 LAB_00101219: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x14] JL 0x001011f4 MOV RAX,qword ptr [RBP + -0x8] LAB_00101225: LEAVE RET
void * func0(int param_1,int param_2,int *param_3) { void *pvVar1; int4 local_14; *param_3 = param_1; pvVar1 = malloc((long)param_1 << 2); if (pvVar1 == (void *)0x0) { pvVar1 = (void *)0x0; } else { for (local_14 = 0; local_14 < param_1; local_14 = local_14 + 1) { *(int *)((long)pvVar1 + (long)local_14 * 4) = (local_14 + 1) * param_2; } } return pvVar1; }
3,977
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
int* func0(int m, int n, int* length) { *length = m; int* results = malloc(sizeof(int) * m); if (!results) { return NULL; } for (int i = 0; i < m; i++) { results[i] = (i + 1) * n; } return results; }
int main() { int length, *result; result = func0(4, 3, &length); int expected1[] = {3, 6, 9, 12}; for (int i = 0; i < length; i++) { assert(result[i] == expected1[i]); } free(result); result = func0(2, 5, &length); int expected2[] = {5, 10}; for (int i = 0; i < length; i++) { assert(result[i] == expected2[i]); } free(result); result = func0(9, 2, &length); int expected3[] = {2, 4, 6, 8, 10, 12, 14, 16, 18}; for (int i = 0; i < length; i++) { assert(result[i] == expected3[i]); } free(result); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0x8,%rsp mov %edi,%ebp mov %esi,%ebx mov %edi,(%rdx) movslq %edi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 11ea <func0+0x41> test %ebp,%ebp jle 11ea <func0+0x41> mov %ebx,%edi mov %rax,%rdx lea -0x1(%rbp),%ecx lea 0x4(%rax,%rcx,4),%rcx mov %ebx,%esi mov %esi,(%rdx) add %edi,%esi add $0x4,%rdx cmp %rcx,%rdx jne 11dd <func0+0x34> add $0x8,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp push rbx sub rsp, 8 mov ebp, edi mov ebx, esi mov [rdx], edi movsxd rdi, edi shl rdi, 2 call _malloc test rax, rax jz short loc_11E6 test ebp, ebp jle short loc_11E6 mov rdx, rax mov ebp, ebp lea rsi, [rax+rbp*4] mov ecx, ebx loc_11D9: mov [rdx], ecx add ecx, ebx add rdx, 4 cmp rdx, rsi jnz short loc_11D9 loc_11E6: add rsp, 8 pop rbx pop rbp retn
long long func0(int a1, int a2, int *a3) { long long result; // rax _DWORD *v4; // rdx int v5; // ecx *a3 = a1; result = malloc(4LL * a1); if ( result && a1 > 0 ) { v4 = (_DWORD *)result; v5 = a2; do { *v4 = v5; v5 += a2; ++v4; } while ( v4 != (_DWORD *)(result + 4LL * (unsigned int)a1) ); } return result; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x8 MOV EBP,EDI MOV EBX,ESI MOV dword ptr [RDX],EDI MOVSXD RDI,EDI SHL RDI,0x2 CALL 0x001010b0 TEST RAX,RAX JZ 0x001011e6 TEST EBP,EBP JLE 0x001011e6 MOV RDX,RAX MOV EBP,EBP LEA RSI,[RAX + RBP*0x4] MOV ECX,EBX LAB_001011d9: MOV dword ptr [RDX],ECX ADD ECX,EBX ADD RDX,0x4 CMP RDX,RSI JNZ 0x001011d9 LAB_001011e6: ADD RSP,0x8 POP RBX POP RBP RET
void func0(uint param_1,int param_2,uint *param_3) { int *piVar1; int *piVar2; int iVar3; *param_3 = param_1; piVar2 = (int *)malloc((long)(int)param_1 << 2); if ((piVar2 != (int *)0x0) && (0 < (int)param_1)) { piVar1 = piVar2 + param_1; iVar3 = param_2; do { *piVar2 = iVar3; iVar3 = iVar3 + param_2; piVar2 = piVar2 + 1; } while (piVar2 != piVar1); } return; }
3,978
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
int* func0(int m, int n, int* length) { *length = m; int* results = malloc(sizeof(int) * m); if (!results) { return NULL; } for (int i = 0; i < m; i++) { results[i] = (i + 1) * n; } return results; }
int main() { int length, *result; result = func0(4, 3, &length); int expected1[] = {3, 6, 9, 12}; for (int i = 0; i < length; i++) { assert(result[i] == expected1[i]); } free(result); result = func0(2, 5, &length); int expected2[] = {5, 10}; for (int i = 0; i < length; i++) { assert(result[i] == expected2[i]); } free(result); result = func0(9, 2, &length); int expected3[] = {2, 4, 6, 8, 10, 12, 14, 16, 18}; for (int i = 0; i < length; i++) { assert(result[i] == expected3[i]); } free(result); return 0; }
O2
c
func0: endbr64 push %rbp movslq %edi,%rdi push %rbx mov %rdi,%rbp mov %esi,%ebx sub $0x8,%rsp mov %edi,(%rdx) shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 13b5 <func0+0x45> test %ebp,%ebp jle 13b5 <func0+0x45> lea -0x1(%rbp),%ecx mov %rax,%rdx lea 0x4(%rax,%rcx,4),%rsi mov %ebx,%ecx nopl 0x0(%rax,%rax,1) mov %ecx,(%rdx) add $0x4,%rdx add %ebx,%ecx cmp %rsi,%rdx jne 13a8 <func0+0x38> add $0x8,%rsp pop %rbx pop %rbp retq nopl 0x0(%rax)
func0: endbr64 push rbp movsxd rdi, edi push rbx mov rbp, rdi mov ebx, esi sub rsp, 8 mov [rdx], edi shl rdi, 2 call _malloc test rax, rax jz short loc_13B5 test ebp, ebp jle short loc_13B5 mov ebp, ebp mov rdx, rax mov ecx, ebx lea rsi, [rax+rbp*4] nop dword ptr [rax+00000000h] loc_13A8: mov [rdx], ecx add rdx, 4 add ecx, ebx cmp rdx, rsi jnz short loc_13A8 loc_13B5: add rsp, 8 pop rbx pop rbp retn
long long func0(int a1, int a2, int *a3) { long long result; // rax _DWORD *v4; // rdx int v5; // ecx *a3 = a1; result = malloc(4LL * a1); if ( result && a1 > 0 ) { v4 = (_DWORD *)result; v5 = a2; do { *v4++ = v5; v5 += a2; } while ( v4 != (_DWORD *)(result + 4LL * (unsigned int)a1) ); } return result; }
func0: ENDBR64 PUSH RBP MOVSXD RDI,EDI PUSH RBX MOV RBP,RDI MOV EBX,ESI SUB RSP,0x8 MOV dword ptr [RDX],EDI SHL RDI,0x2 CALL 0x001010b0 TEST RAX,RAX JZ 0x001013b5 TEST EBP,EBP JLE 0x001013b5 MOV EBP,EBP MOV RDX,RAX MOV ECX,EBX LEA RSI,[RAX + RBP*0x4] NOP dword ptr [RAX] LAB_001013a8: MOV dword ptr [RDX],ECX ADD RDX,0x4 ADD ECX,EBX CMP RDX,RSI JNZ 0x001013a8 LAB_001013b5: ADD RSP,0x8 POP RBX POP RBP RET
void func0(uint param_1,int param_2,uint *param_3) { int *piVar1; int *piVar2; int iVar3; *param_3 = param_1; piVar2 = (int *)malloc((long)(int)param_1 << 2); if ((piVar2 != (int *)0x0) && (0 < (int)param_1)) { piVar1 = piVar2 + param_1; iVar3 = param_2; do { *piVar2 = iVar3; piVar2 = piVar2 + 1; iVar3 = iVar3 + param_2; } while (piVar2 != piVar1); } return; }
3,979
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
int* func0(int m, int n, int* length) { *length = m; int* results = malloc(sizeof(int) * m); if (!results) { return NULL; } for (int i = 0; i < m; i++) { results[i] = (i + 1) * n; } return results; }
int main() { int length, *result; result = func0(4, 3, &length); int expected1[] = {3, 6, 9, 12}; for (int i = 0; i < length; i++) { assert(result[i] == expected1[i]); } free(result); result = func0(2, 5, &length); int expected2[] = {5, 10}; for (int i = 0; i < length; i++) { assert(result[i] == expected2[i]); } free(result); result = func0(9, 2, &length); int expected3[] = {2, 4, 6, 8, 10, 12, 14, 16, 18}; for (int i = 0; i < length; i++) { assert(result[i] == expected3[i]); } free(result); return 0; }
O3
c
func0: endbr64 push %rbp movslq %edi,%rdi mov %esi,%ebp push %rbx mov %rdi,%rbx sub $0x8,%rsp mov %edi,(%rdx) shl $0x2,%rdi callq 10b0 <malloc@plt> test %rax,%rax je 1493 <func0+0xe3> test %ebx,%ebx jle 1493 <func0+0xe3> lea -0x1(%rbx),%edx cmp $0x2,%edx jbe 149a <func0+0xea> movd %ebp,%xmm7 mov %ebx,%ecx movdqa 0xca8(%rip),%xmm2 movdqa 0xcb0(%rip),%xmm6 pshufd $0x0,%xmm7,%xmm3 shr $0x2,%ecx movdqa 0xcb0(%rip),%xmm5 mov %rax,%rdx shl $0x4,%rcx movdqa %xmm3,%xmm4 add %rax,%rcx psrlq $0x20,%xmm4 nopl 0x0(%rax,%rax,1) movdqa %xmm2,%xmm0 add $0x10,%rdx paddd %xmm6,%xmm2 paddd %xmm5,%xmm0 movdqa %xmm0,%xmm1 psrlq $0x20,%xmm0 pmuludq %xmm3,%xmm1 pmuludq %xmm4,%xmm0 pshufd $0x8,%xmm1,%xmm1 pshufd $0x8,%xmm0,%xmm0 punpckldq %xmm0,%xmm1 movups %xmm1,-0x10(%rdx) cmp %rcx,%rdx jne 1428 <func0+0x78> mov %ebx,%edx and $0xfffffffc,%edx test $0x3,%bl je 1493 <func0+0xe3> lea 0x1(%rdx),%ecx movslq %edx,%rdi mov %ecx,%esi imul %ebp,%esi mov %esi,(%rax,%rdi,4) cmp %ebx,%ecx jge 1493 <func0+0xe3> add %ebp,%esi movslq %ecx,%rcx add $0x2,%edx mov %esi,(%rax,%rcx,4) cmp %edx,%ebx jle 1493 <func0+0xe3> movslq %edx,%rdx add %esi,%ebp mov %ebp,(%rax,%rdx,4) add $0x8,%rsp pop %rbx pop %rbp retq xor %edx,%edx jmp 146a <func0+0xba> xchg %ax,%ax
func0: endbr64 push rbp movsxd rdi, edi mov ebp, esi push rbx mov rbx, rdi sub rsp, 8 mov [rdx], edi shl rdi, 2; size call _malloc mov rcx, rax test rax, rax jz loc_1461 test ebx, ebx jle loc_1461 lea eax, [rbx-1] cmp eax, 2 jbe loc_146B movd xmm7, ebp mov edx, ebx movdqa xmm2, cs:xmmword_2080 movdqa xmm6, cs:xmmword_2090 pshufd xmm3, xmm7, 0 shr edx, 2 movdqa xmm5, cs:xmmword_20A0 mov rax, rcx shl rdx, 4 movdqa xmm4, xmm3 add rdx, rcx psrlq xmm4, 20h ; ' ' nop word ptr [rax+rax+00000000h] loc_13F0: movdqa xmm0, xmm2 add rax, 10h paddd xmm2, xmm6 paddd xmm0, xmm5 movdqa xmm1, xmm0 psrlq xmm0, 20h ; ' ' pmuludq xmm1, xmm3 pmuludq xmm0, xmm4 pshufd xmm1, xmm1, 8 pshufd xmm0, xmm0, 8 punpckldq xmm1, xmm0 movups xmmword ptr [rax-10h], xmm1 cmp rax, rdx jnz short loc_13F0 mov eax, ebx and eax, 0FFFFFFFCh test bl, 3 jz short loc_1461 loc_1432: lea esi, [rax+1] movsxd rdi, eax mov edx, esi lea r8, ds:0[rdi*4] imul edx, ebp mov [rcx+rdi*4], edx cmp esi, ebx jge short loc_1461 add edx, ebp add eax, 2 mov [rcx+r8+4], edx cmp ebx, eax jle short loc_1461 add ebp, edx mov [rcx+r8+8], ebp loc_1461: add rsp, 8 mov rax, rcx pop rbx pop rbp retn loc_146B: xor eax, eax jmp short loc_1432
__m128i * func0(int a1, unsigned int a2, int *a3) { __m128i *v3; // rcx __m128i si128; // xmm2 __m128i v5; // xmm6 __m128i v6; // xmm3 __m128i v7; // xmm5 __m128i *v8; // rax __m128i v9; // xmm4 __m128i v10; // xmm0 __m128i v11; // xmm1 int v12; // eax long long v13; // r8 int v14; // edx unsigned int v15; // edx *a3 = a1; v3 = (__m128i *)malloc(4LL * a1); if ( v3 && a1 > 0 ) { if ( (unsigned int)(a1 - 1) <= 2 ) { v12 = 0; } else { si128 = _mm_load_si128((const __m128i *)&xmmword_2080); v5 = _mm_load_si128((const __m128i *)&xmmword_2090); v6 = _mm_shuffle_epi32(_mm_cvtsi32_si128(a2), 0); v7 = _mm_load_si128((const __m128i *)&xmmword_20A0); v8 = v3; v9 = _mm_srli_epi64(v6, 0x20u); do { v10 = si128; ++v8; si128 = _mm_add_epi32(si128, v5); v11 = _mm_add_epi32(v10, v7); v8[-1] = _mm_unpacklo_epi32( _mm_shuffle_epi32(_mm_mul_epu32(v11, v6), 8), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_epi64(v11, 0x20u), v9), 8)); } while ( v8 != &v3[(unsigned int)a1 >> 2] ); v12 = a1 & 0x7FFFFFFC; if ( (a1 & 3) == 0 ) return v3; } v13 = v12; v14 = a2 * (v12 + 1); v3->m128i_i32[v13] = v14; if ( v12 + 1 < a1 ) { v15 = a2 + v14; v3->m128i_i32[v13 + 1] = v15; if ( a1 > v12 + 2 ) v3->m128i_i32[v13 + 2] = v15 + a2; } } return v3; }
func0: ENDBR64 PUSH RBP MOVSXD RDI,EDI MOV EBP,ESI PUSH RBX MOV RBX,RDI SUB RSP,0x8 MOV dword ptr [RDX],EDI SHL RDI,0x2 CALL 0x001010b0 MOV RCX,RAX TEST RAX,RAX JZ 0x00101461 TEST EBX,EBX JLE 0x00101461 LEA EAX,[RBX + -0x1] CMP EAX,0x2 JBE 0x0010146b MOVD XMM7,EBP MOV EDX,EBX MOVDQA XMM2,xmmword ptr [0x00102080] MOVDQA XMM6,xmmword ptr [0x00102090] PSHUFD XMM3,XMM7,0x0 SHR EDX,0x2 MOVDQA XMM5,xmmword ptr [0x001020a0] MOV RAX,RCX SHL RDX,0x4 MOVDQA XMM4,XMM3 ADD RDX,RCX PSRLQ XMM4,0x20 NOP word ptr CS:[RAX + RAX*0x1] LAB_001013f0: MOVDQA XMM0,XMM2 ADD RAX,0x10 PADDD XMM2,XMM6 PADDD XMM0,XMM5 MOVDQA XMM1,XMM0 PSRLQ XMM0,0x20 PMULUDQ XMM1,XMM3 PMULUDQ XMM0,XMM4 PSHUFD XMM1,XMM1,0x8 PSHUFD XMM0,XMM0,0x8 PUNPCKLDQ XMM1,XMM0 MOVUPS xmmword ptr [RAX + -0x10],XMM1 CMP RAX,RDX JNZ 0x001013f0 MOV EAX,EBX AND EAX,0xfffffffc TEST BL,0x3 JZ 0x00101461 LAB_00101432: LEA ESI,[RAX + 0x1] MOVSXD RDI,EAX MOV EDX,ESI LEA R8,[RDI*0x4] IMUL EDX,EBP MOV dword ptr [RCX + RDI*0x4],EDX CMP ESI,EBX JGE 0x00101461 ADD EDX,EBP ADD EAX,0x2 MOV dword ptr [RCX + R8*0x1 + 0x4],EDX CMP EBX,EAX JLE 0x00101461 ADD EBP,EDX MOV dword ptr [RCX + R8*0x1 + 0x8],EBP LAB_00101461: ADD RSP,0x8 MOV RAX,RCX POP RBX POP RBP RET LAB_0010146b: XOR EAX,EAX JMP 0x00101432
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ int8 * func0(uint param_1,uint param_2,uint *param_3) { long lVar1; int auVar2 [16]; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; uint uVar10; int8 *puVar11; int8 *puVar12; int8 *puVar13; int iVar14; ulong uVar15; int auVar16 [16]; int iVar17; int iVar18; int iVar19; int iVar20; uVar15 = (ulong)(int)param_1; *param_3 = param_1; puVar11 = (int8 *)malloc(uVar15 << 2); iVar9 = _UNK_001020ac; iVar8 = _UNK_001020a8; iVar7 = _UNK_001020a4; iVar6 = _DAT_001020a0; iVar5 = _UNK_0010209c; iVar4 = _UNK_00102098; iVar3 = _UNK_00102094; iVar14 = _DAT_00102090; if ((puVar11 != (int8 *)0x0) && (0 < (int)param_1)) { if (param_1 - 1 < 3) { uVar10 = 0; } else { auVar2._4_4_ = param_2; auVar2._0_4_ = param_2; auVar2._8_4_ = param_2; auVar2._12_4_ = param_2; puVar12 = puVar11; iVar17 = _DAT_00102080; iVar18 = _UNK_00102084; iVar19 = _UNK_00102088; iVar20 = _UNK_0010208c; do { puVar13 = puVar12 + 2; auVar16._0_4_ = iVar17 + iVar6; auVar16._4_4_ = iVar18 + iVar7; auVar16._8_4_ = iVar19 + iVar8; auVar16._12_4_ = iVar20 + iVar9; *puVar12 = CONCAT44(auVar16._4_4_ * param_2,auVar16._0_4_ * param_2); *(int *)(puVar12 + 2) = (int)((auVar16._8_8_ & 0xffffffff) * (ulong)param_2); *(int *)((long)puVar12 + 0x14) = (int)((auVar16._8_8_ >> 0x20) * (auVar2._8_8_ >> 0x20)); puVar12 = puVar13; iVar17 = iVar17 + iVar14; iVar18 = iVar18 + iVar3; iVar19 = iVar19 + iVar4; iVar20 = iVar20 + iVar5; } while (puVar13 != puVar11 + (uVar15 >> 2 & 0x3fffffff) * 2); uVar10 = param_1 & 0xfffffffc; if ((uVar15 & 3) == 0) { return puVar11; } } lVar1 = (long)(int)uVar10 * 4; iVar14 = (uVar10 + 1) * param_2; *(int *)((long)puVar11 + (long)(int)uVar10 * 4) = iVar14; if ((int)(uVar10 + 1) < (int)param_1) { iVar14 = iVar14 + param_2; *(int *)((long)puVar11 + lVar1 + 4) = iVar14; if ((int)(uVar10 + 2) < (int)param_1) { *(uint *)((long)puVar11 + lVar1 + 8) = param_2 + iVar14; } } } return puVar11; }
3,980
func0
#include <assert.h> #include <stdbool.h>
int func0(int nums[], int length) { bool exists[1001] = {false}; // Assuming numbers are within 1 to 1000 int no_duplicate = -1; for (int i = 0; i < length; i++) { if (exists[nums[i]]) { return nums[i]; } else { exists[nums[i]] = true; } } return no_duplicate; }
int main() { int arr1[] = {1, 2, 3, 4, 4, 5}; int arr2[] = {1, 2, 3, 4}; int arr3[] = {1, 1, 2, 3, 3, 2, 2}; assert(func0(arr1, 6) == 4); assert(func0(arr2, 4) == -1); assert(func0(arr3, 7) == 1); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x420,%rsp mov %rdi,-0x418(%rbp) mov %esi,-0x41c(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea -0x400(%rbp),%rdx mov $0x0,%eax mov $0x7d,%ecx mov %rdx,%rdi rep stos %rax,%es:(%rdi) mov %rdi,%rdx mov %al,(%rdx) add $0x1,%rdx movl $0xffffffff,-0x404(%rbp) movl $0x0,-0x408(%rbp) jmp 123f <func0+0xd6> mov -0x408(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x418(%rbp),%rax add %rdx,%rax mov (%rax),%eax cltq movzbl -0x400(%rbp,%rax,1),%eax test %al,%al je 1212 <func0+0xa9> mov -0x408(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x418(%rbp),%rax add %rdx,%rax mov (%rax),%eax jmp 1257 <func0+0xee> mov -0x408(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x418(%rbp),%rax add %rdx,%rax mov (%rax),%eax cltq movb $0x1,-0x400(%rbp,%rax,1) addl $0x1,-0x408(%rbp) mov -0x408(%rbp),%eax cmp -0x41c(%rbp),%eax jl 11ca <func0+0x61> mov -0x404(%rbp),%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi je 126b <func0+0x102> callq 1060 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 420h mov [rbp+var_418], rdi mov [rbp+var_41C], esi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rdx, [rbp+var_400] mov eax, 0 mov ecx, 7Dh ; '}' mov rdi, rdx rep stosq mov rdx, rdi mov [rdx], al add rdx, 1 mov [rbp+var_404], 0FFFFFFFFh mov [rbp+var_408], 0 jmp short loc_123F loc_11CA: mov eax, [rbp+var_408] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_418] add rax, rdx mov eax, [rax] cdqe movzx eax, [rbp+rax+var_400] test al, al jz short loc_1212 mov eax, [rbp+var_408] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_418] add rax, rdx mov eax, [rax] jmp short loc_1257 loc_1212: mov eax, [rbp+var_408] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_418] add rax, rdx mov eax, [rax] cdqe mov [rbp+rax+var_400], 1 add [rbp+var_408], 1 loc_123F: mov eax, [rbp+var_408] cmp eax, [rbp+var_41C] jl loc_11CA mov eax, [rbp+var_404] loc_1257: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_126B call ___stack_chk_fail locret_126B: leave retn
long long func0(long long a1, int a2) { int i; // [rsp+18h] [rbp-408h] _BYTE v4[1016]; // [rsp+20h] [rbp-400h] BYREF unsigned long long v5; // [rsp+418h] [rbp-8h] v5 = __readfsqword(0x28u); memset(v4, 0, 1001); for ( i = 0; i < a2; ++i ) { if ( v4[*(int *)(4LL * i + a1)] ) return *(unsigned int *)(4LL * i + a1); v4[*(int *)(4LL * i + a1)] = 1; } return 0xFFFFFFFFLL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x420 MOV qword ptr [RBP + -0x418],RDI MOV dword ptr [RBP + -0x41c],ESI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RDX,[RBP + -0x400] MOV EAX,0x0 MOV ECX,0x7d MOV RDI,RDX STOSQ.REP RDI MOV RDX,RDI MOV byte ptr [RDX],AL ADD RDX,0x1 MOV dword ptr [RBP + -0x404],0xffffffff MOV dword ptr [RBP + -0x408],0x0 JMP 0x0010123f LAB_001011ca: MOV EAX,dword ptr [RBP + -0x408] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x418] ADD RAX,RDX MOV EAX,dword ptr [RAX] CDQE MOVZX EAX,byte ptr [RBP + RAX*0x1 + -0x400] TEST AL,AL JZ 0x00101212 MOV EAX,dword ptr [RBP + -0x408] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x418] ADD RAX,RDX MOV EAX,dword ptr [RAX] JMP 0x00101257 LAB_00101212: MOV EAX,dword ptr [RBP + -0x408] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x418] ADD RAX,RDX MOV EAX,dword ptr [RAX] CDQE MOV byte ptr [RBP + RAX*0x1 + -0x400],0x1 ADD dword ptr [RBP + -0x408],0x1 LAB_0010123f: MOV EAX,dword ptr [RBP + -0x408] CMP EAX,dword ptr [RBP + -0x41c] JL 0x001011ca MOV EAX,dword ptr [RBP + -0x404] LAB_00101257: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x0010126b CALL 0x00101060 LAB_0010126b: LEAVE RET
int4 func0(long param_1,int param_2) { int4 uVar1; long lVar2; char *pcVar3; long in_FS_OFFSET; int local_410; char local_408 [1016]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); pcVar3 = local_408; for (lVar2 = 0x7d; lVar2 != 0; lVar2 = lVar2 + -1) { pcVar3[0] = '\0'; pcVar3[1] = '\0'; pcVar3[2] = '\0'; pcVar3[3] = '\0'; pcVar3[4] = '\0'; pcVar3[5] = '\0'; pcVar3[6] = '\0'; pcVar3[7] = '\0'; pcVar3 = pcVar3 + 8; } *pcVar3 = '\0'; local_410 = 0; do { if (param_2 <= local_410) { uVar1 = 0xffffffff; LAB_00101257: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar1; } if (local_408[*(int *)(param_1 + (long)local_410 * 4)] != '\0') { uVar1 = *(int4 *)(param_1 + (long)local_410 * 4); goto LAB_00101257; } local_408[*(int *)(param_1 + (long)local_410 * 4)] = '\x01'; local_410 = local_410 + 1; } while( true ); }
3,981
func0
#include <assert.h> #include <stdbool.h>
int func0(int nums[], int length) { bool exists[1001] = {false}; // Assuming numbers are within 1 to 1000 int no_duplicate = -1; for (int i = 0; i < length; i++) { if (exists[nums[i]]) { return nums[i]; } else { exists[nums[i]] = true; } } return no_duplicate; }
int main() { int arr1[] = {1, 2, 3, 4, 4, 5}; int arr2[] = {1, 2, 3, 4}; int arr3[] = {1, 1, 2, 3, 3, 2, 2}; assert(func0(arr1, 6) == 4); assert(func0(arr2, 4) == -1); assert(func0(arr3, 7) == 1); return 0; }
O1
c
func0: endbr64 sub $0x408,%rsp mov %rdi,%r8 mov %fs:0x28,%rax mov %rax,0x3f8(%rsp) xor %eax,%eax mov %rsp,%rdi mov $0x7d,%ecx rep stos %rax,%es:(%rdi) movb $0x0,(%rdi) test %esi,%esi jle 11df <func0+0x76> mov %r8,%rdx lea -0x1(%rsi),%eax lea 0x4(%r8,%rax,4),%rsi mov (%rdx),%eax movslq %eax,%rcx cmpb $0x0,(%rsp,%rcx,1) jne 11c4 <func0+0x5b> movb $0x1,(%rsp,%rcx,1) add $0x4,%rdx cmp %rsi,%rdx jne 11a7 <func0+0x3e> mov $0xffffffff,%eax mov 0x3f8(%rsp),%rdi xor %fs:0x28,%rdi jne 11e6 <func0+0x7d> add $0x408,%rsp retq mov $0xffffffff,%eax jmp 11c4 <func0+0x5b> callq 1060 <__stack_chk_fail@plt>
func0: endbr64 sub rsp, 408h mov r8, rdi mov rax, fs:28h mov [rsp+408h+var_10], rax xor eax, eax mov rdi, rsp mov ecx, 7Dh ; '}' rep stosq mov byte ptr [rdi], 0 test esi, esi jle short loc_11DF mov rdx, r8 lea eax, [rsi-1] lea rsi, [r8+rax*4+4] loc_11A7: mov eax, [rdx] movsxd rcx, eax cmp [rsp+rcx+408h+var_408], 0 jnz short loc_11C4 mov [rsp+rcx+408h+var_408], 1 add rdx, 4 cmp rdx, rsi jnz short loc_11A7 mov eax, 0FFFFFFFFh loc_11C4: mov rdx, [rsp+408h+var_10] sub rdx, fs:28h jnz short loc_11E6 add rsp, 408h retn loc_11DF: mov eax, 0FFFFFFFFh jmp short loc_11C4 loc_11E6: call ___stack_chk_fail
long long func0(unsigned int *a1, int a2) { unsigned int *v2; // rdx long long v3; // rsi long long result; // rax _BYTE v5[1016]; // [rsp+0h] [rbp-408h] BYREF unsigned long long v6; // [rsp+3F8h] [rbp-10h] v6 = __readfsqword(0x28u); memset(v5, 0, 1001); if ( a2 <= 0 ) return 0xFFFFFFFFLL; v2 = a1; v3 = (long long)&a1[a2 - 1 + 1]; while ( 1 ) { result = *v2; if ( v5[(int)result] ) break; v5[(int)result] = 1; if ( ++v2 == (unsigned int *)v3 ) return 0xFFFFFFFFLL; } return result; }
func0: ENDBR64 SUB RSP,0x408 MOV R8,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x3f8],RAX XOR EAX,EAX MOV RDI,RSP MOV ECX,0x7d STOSQ.REP RDI MOV byte ptr [RDI],0x0 TEST ESI,ESI JLE 0x001011df MOV RDX,R8 LEA EAX,[RSI + -0x1] LEA RSI,[R8 + RAX*0x4 + 0x4] LAB_001011a7: MOV EAX,dword ptr [RDX] MOVSXD RCX,EAX CMP byte ptr [RSP + RCX*0x1],0x0 JNZ 0x001011c4 MOV byte ptr [RSP + RCX*0x1],0x1 ADD RDX,0x4 CMP RDX,RSI JNZ 0x001011a7 MOV EAX,0xffffffff LAB_001011c4: MOV RDX,qword ptr [RSP + 0x3f8] SUB RDX,qword ptr FS:[0x28] JNZ 0x001011e6 ADD RSP,0x408 RET LAB_001011df: MOV EAX,0xffffffff JMP 0x001011c4 LAB_001011e6: CALL 0x00101060
int func0(int *param_1,int param_2) { int *piVar1; int iVar2; long lVar3; char *pcVar4; long in_FS_OFFSET; char local_408 [1016]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); pcVar4 = local_408; for (lVar3 = 0x7d; lVar3 != 0; lVar3 = lVar3 + -1) { *(int8 *)pcVar4 = 0; pcVar4 = (char *)((long)pcVar4 + 8); } *pcVar4 = 0; if (param_2 < 1) { iVar2 = -1; } else { piVar1 = param_1 + (ulong)(param_2 - 1) + 1; do { iVar2 = *param_1; if (local_408[iVar2] != '\0') goto LAB_001011c4; local_408[iVar2] = '\x01'; param_1 = param_1 + 1; } while (param_1 != piVar1); iVar2 = -1; } LAB_001011c4: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }