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
5,382
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> // Function to maintain the min heap property void min_heapify(int* heap, int size, int i) { int smallest = i; int left = 2*i +1; int right = 2*i +2; if(left < size && heap[left] < heap[smallest]) smallest = left; if(right < size && heap[right] < heap[smallest]) smallest = right; if(smallest != i){ int temp = heap[i]; heap[i] = heap[smallest]; heap[smallest] = temp; min_heapify(heap, size, smallest); } }
int* func0(int* nums, int size) { // Copy nums to heap array int* heap = malloc(size * sizeof(int)); for(int i=0; i<size; i++) heap[i] = nums[i]; // Heapify for(int i=(size/2)-1; i>=0; i--) min_heapify(heap, size, i); // Extract elements int* sorted = malloc(size * sizeof(int)); int heap_size = size; for(int i=0; i<size; i++) { sorted[i] = heap[0]; heap[0] = heap[heap_size-1]; heap_size--; min_heapify(heap, heap_size, 0); } free(heap); return sorted; }
int main() { // Test Case 1 int test1[] = {18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1}; int expected1[] = {1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18}; int size1 = sizeof(test1)/sizeof(test1[0]); int* result1 = func0(test1, size1); for(int i=0; i<size1; i++) assert(result1[i] == expected1[i]); free(result1); // Test Case 2 int test2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58}; int expected2[] = {14, 22, 25, 25, 35, 58, 65, 75, 85}; int size2 = sizeof(test2)/sizeof(test2[0]); int* result2 = func0(test2, size2); for(int i=0; i<size2; i++) assert(result2[i] == expected2[i]); free(result2); // Test Case 3 int test3[] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0}; int expected3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int size3 = sizeof(test3)/sizeof(test3[0]); int* result3 = func0(test3, size3); for(int i=0; i<size3; i++) assert(result3[i] == expected3[i]); free(result3); return 0; }
O2
c
func0: endbr64 push %r15 mov %rdi,%r15 push %r14 push %r13 movslq %esi,%r13 push %r12 mov %r13,%r12 shl $0x2,%r13 push %rbp mov %r13,%rdi push %rbx mov %r12d,%ebx shr $0x1f,%ebx add %r12d,%ebx sub $0x8,%rsp sar %ebx callq 10b0 <malloc@plt> sub $0x1,%ebx mov %rax,%rbp test %r12d,%r12d jle 1648 <func0+0xe8> lea -0x1(%r12),%ecx xor %eax,%eax mov %rcx,%r14 nopl 0x0(%rax,%rax,1) mov (%r15,%rax,4),%edx mov %edx,0x0(%rbp,%rax,4) mov %rax,%rdx add $0x1,%rax cmp %rcx,%rdx jne 15b0 <func0+0x50> test %ebx,%ebx js 1660 <func0+0x100> nopl 0x0(%rax) mov %ebx,%edx mov %r12d,%esi mov %rbp,%rdi sub $0x1,%ebx callq 14d0 <min_heapify> cmp $0xffffffff,%ebx jne 15d0 <func0+0x70> mov %r13,%rdi callq 10b0 <malloc@plt> mov %rax,%r15 test %r12d,%r12d jle 1629 <func0+0xc9> lea -0x1(%r12),%r14d movslq %r14d,%r14 xor %r13d,%r13d mov 0x0(%rbp),%eax mov %r14d,%esi xor %edx,%edx mov %rbp,%rdi mov %eax,(%r15,%r13,4) mov 0x0(%rbp,%r14,4),%eax add $0x1,%r13 sub $0x1,%r14 mov %eax,0x0(%rbp) callq 14d0 <min_heapify> cmp %r13d,%r12d jg 1600 <func0+0xa0> mov %rbp,%rdi callq 1080 <free@plt> add $0x8,%rsp mov %r15,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax,%rax,1) test %ebx,%ebx jns 15d0 <func0+0x70> mov %r13,%rdi callq 10b0 <malloc@plt> mov %rax,%r15 jmp 1629 <func0+0xc9> nopl 0x0(%rax) mov %r13,%rdi callq 10b0 <malloc@plt> mov %rax,%r15 jmp 15fa <func0+0x9a> nopl (%rax)
func0: endbr64 push r14 mov r14, rdi push r13 movsxd r13, esi push r12 mov r12, r13 shl r13, 2 push rbp mov rdi, r13 push rbx mov ebx, r12d shr ebx, 1Fh add ebx, r12d call _malloc sar ebx, 1 mov rbp, rax sub ebx, 1 test r12d, r12d jle loc_1638 mov rdx, r13 mov rsi, r14 mov rdi, rax call _memcpy test ebx, ebx js loc_1650 nop dword ptr [rax+00000000h] loc_15C8: mov edx, ebx mov esi, r12d mov rdi, rbp call min_heapify sub ebx, 1 jnb short loc_15C8 mov rdi, r13 call _malloc mov r14, rax test r12d, r12d jle short loc_161F loc_15EA: lea ebx, [r12-1] xor r13d, r13d movsxd rbx, ebx nop dword ptr [rax] loc_15F8: mov eax, [rbp+0] mov esi, ebx xor edx, edx mov rdi, rbp mov [r14+r13*4], eax mov eax, [rbp+rbx*4+0] add r13, 1 sub rbx, 1 mov [rbp+0], eax call min_heapify cmp r12d, r13d jg short loc_15F8 loc_161F: mov rdi, rbp call _free pop rbx mov rax, r14 pop rbp pop r12 pop r13 pop r14 retn loc_1638: test ebx, ebx jns short loc_15C8 mov rdi, r13 call _malloc mov r14, rax jmp short loc_161F loc_1650: mov rdi, r13 call _malloc mov r14, rax jmp short loc_15EA
long long func0(long long a1, int a2) { long long v3; // r13 long long v4; // rax _DWORD *v5; // rbp int v6; // ebx long long v8; // r14 long long v9; // r13 long long v10; // rbx long long v11; // rsi int v12; // eax v3 = 4LL * a2; v4 = malloc(v3); v5 = (_DWORD *)v4; v6 = a2 / 2 - 1; if ( a2 <= 0 ) { if ( v6 < 0 ) { v8 = malloc(4LL * a2); goto LABEL_7; } } else { memcpy(v4, a1, 4LL * a2); if ( v6 < 0 ) { v8 = malloc(v3); LABEL_5: v9 = 0LL; v10 = a2 - 1; do { v11 = (unsigned int)v10; *(_DWORD *)(v8 + 4 * v9) = *v5; v12 = v5[v10]; ++v9; --v10; *v5 = v12; min_heapify(v5, v11, 0LL); } while ( a2 > (int)v9 ); goto LABEL_7; } } do min_heapify(v5, (unsigned int)a2, (unsigned int)v6); while ( v6-- != 0 ); v8 = malloc(v3); if ( a2 > 0 ) goto LABEL_5; LABEL_7: free(v5); return v8; }
func0: ENDBR64 PUSH R14 MOV R14,RDI PUSH R13 MOVSXD R13,ESI PUSH R12 MOV R12,R13 SHL R13,0x2 PUSH RBP MOV RDI,R13 PUSH RBX MOV EBX,R12D SHR EBX,0x1f ADD EBX,R12D CALL 0x001010d0 SAR EBX,0x1 MOV RBP,RAX SUB EBX,0x1 TEST R12D,R12D JLE 0x00101638 MOV RDX,R13 MOV RSI,R14 MOV RDI,RAX CALL 0x001010c0 TEST EBX,EBX JS 0x00101650 NOP dword ptr [RAX] LAB_001015c8: MOV EDX,EBX MOV ESI,R12D MOV RDI,RBP CALL 0x001014f0 SUB EBX,0x1 JNC 0x001015c8 MOV RDI,R13 CALL 0x001010d0 MOV R14,RAX TEST R12D,R12D JLE 0x0010161f LAB_001015ea: LEA EBX,[R12 + -0x1] XOR R13D,R13D MOVSXD RBX,EBX NOP dword ptr [RAX] LAB_001015f8: MOV EAX,dword ptr [RBP] MOV ESI,EBX XOR EDX,EDX MOV RDI,RBP MOV dword ptr [R14 + R13*0x4],EAX MOV EAX,dword ptr [RBP + RBX*0x4] ADD R13,0x1 SUB RBX,0x1 MOV dword ptr [RBP],EAX CALL 0x001014f0 CMP R12D,R13D JG 0x001015f8 LAB_0010161f: MOV RDI,RBP CALL 0x00101090 POP RBX MOV RAX,R14 POP RBP POP R12 POP R13 POP R14 RET LAB_00101638: TEST EBX,EBX JNS 0x001015c8 MOV RDI,R13 CALL 0x001010d0 MOV R14,RAX JMP 0x0010161f LAB_00101650: MOV RDI,R13 CALL 0x001010d0 MOV R14,RAX JMP 0x001015ea
void * func0(void *param_1,int param_2) { int4 *puVar1; int4 *__dest; void *pvVar2; int iVar3; ulong uVar4; ulong uVar5; size_t __size; long lVar6; bool bVar7; __size = (long)param_2 << 2; __dest = (int4 *)malloc(__size); iVar3 = ((int)(((uint)((ulong)(long)param_2 >> 0x1f) & 1) + param_2) >> 1) + -1; if (param_2 < 1) { if (iVar3 < 0) { pvVar2 = malloc(__size); goto LAB_0010161f; } LAB_001015c8: do { min_heapify(__dest,param_2,iVar3); bVar7 = iVar3 != 0; iVar3 = iVar3 + -1; } while (bVar7); pvVar2 = malloc(__size); if (param_2 < 1) goto LAB_0010161f; } else { memcpy(__dest,param_1,__size); if (-1 < iVar3) goto LAB_001015c8; pvVar2 = malloc(__size); } lVar6 = 0; uVar4 = (ulong)(param_2 + -1); do { uVar5 = uVar4 & 0xffffffff; *(int4 *)((long)pvVar2 + lVar6 * 4) = *__dest; puVar1 = __dest + uVar4; lVar6 = lVar6 + 1; uVar4 = uVar4 - 1; *__dest = *puVar1; min_heapify(__dest,uVar5,0); } while ((int)lVar6 < param_2); LAB_0010161f: free(__dest); return pvVar2; }
5,383
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> // Function to maintain the min heap property void min_heapify(int* heap, int size, int i) { int smallest = i; int left = 2*i +1; int right = 2*i +2; if(left < size && heap[left] < heap[smallest]) smallest = left; if(right < size && heap[right] < heap[smallest]) smallest = right; if(smallest != i){ int temp = heap[i]; heap[i] = heap[smallest]; heap[smallest] = temp; min_heapify(heap, size, smallest); } }
int* func0(int* nums, int size) { // Copy nums to heap array int* heap = malloc(size * sizeof(int)); for(int i=0; i<size; i++) heap[i] = nums[i]; // Heapify for(int i=(size/2)-1; i>=0; i--) min_heapify(heap, size, i); // Extract elements int* sorted = malloc(size * sizeof(int)); int heap_size = size; for(int i=0; i<size; i++) { sorted[i] = heap[0]; heap[0] = heap[heap_size-1]; heap_size--; min_heapify(heap, heap_size, 0); } free(heap); return sorted; }
int main() { // Test Case 1 int test1[] = {18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1}; int expected1[] = {1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18}; int size1 = sizeof(test1)/sizeof(test1[0]); int* result1 = func0(test1, size1); for(int i=0; i<size1; i++) assert(result1[i] == expected1[i]); free(result1); // Test Case 2 int test2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58}; int expected2[] = {14, 22, 25, 25, 35, 58, 65, 75, 85}; int size2 = sizeof(test2)/sizeof(test2[0]); int* result2 = func0(test2, size2); for(int i=0; i<size2; i++) assert(result2[i] == expected2[i]); free(result2); // Test Case 3 int test3[] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0}; int expected3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int size3 = sizeof(test3)/sizeof(test3[0]); int* result3 = func0(test3, size3); for(int i=0; i<size3; i++) assert(result3[i] == expected3[i]); free(result3); return 0; }
O3
c
func0: endbr64 push %r15 mov %rdi,%r15 push %r14 push %r13 movslq %esi,%r13 push %r12 mov %r13,%r12 shl $0x2,%r13 push %rbp mov %r13,%rdi push %rbx mov %r12d,%ebx shr $0x1f,%ebx add %r12d,%ebx sub $0x8,%rsp sar %ebx callq 10d0 <malloc@plt> sub $0x1,%ebx mov %rax,%rbp test %r12d,%r12d jle 16c8 <func0+0xe8> lea -0x1(%r12),%eax mov %r15,%rsi mov %rbp,%rdi lea 0x4(,%rax,4),%rdx mov %rax,%r14 callq 10c0 <memcpy@plt> test %ebx,%ebx js 16e0 <func0+0x100> nopl 0x0(%rax) mov %ebx,%edx mov %r12d,%esi mov %rbp,%rdi sub $0x1,%ebx callq 1550 <min_heapify> cmp $0xffffffff,%ebx jne 1648 <func0+0x68> mov %r13,%rdi callq 10d0 <malloc@plt> mov %rax,%r15 test %r12d,%r12d jle 16a9 <func0+0xc9> lea -0x1(%r12),%r14d movslq %r14d,%r14 xor %r13d,%r13d nopl 0x0(%rax,%rax,1) mov 0x0(%rbp),%eax mov %r14d,%esi xor %edx,%edx mov %rbp,%rdi mov %eax,(%r15,%r13,4) mov 0x0(%rbp,%r14,4),%eax add $0x1,%r13 sub $0x1,%r14 mov %eax,0x0(%rbp) callq 1550 <min_heapify> cmp %r13d,%r12d jg 1680 <func0+0xa0> mov %rbp,%rdi callq 1090 <free@plt> add $0x8,%rsp mov %r15,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax,%rax,1) test %ebx,%ebx jns 1648 <func0+0x68> mov %r13,%rdi callq 10d0 <malloc@plt> mov %rax,%r15 jmp 16a9 <func0+0xc9> nopl (%rax) mov %r13,%rdi callq 10d0 <malloc@plt> mov %rax,%r15 jmp 1672 <func0+0x92> nopl (%rax)
func0: endbr64 push r13 movsxd r13, esi push r12 mov r12, rdi push rbp push rbx mov rbx, r13 shl r13, 2 mov rdi, r13; size sub rsp, 8 call _malloc mov rbp, rax test ebx, ebx jle loc_1590 mov edx, ebx mov rsi, r12; src mov rdi, rax; dest shl rdx, 2; n call _memcpy mov eax, ebx sar eax, 1 lea r12d, [rax-1] jz short loc_1533 nop dword ptr [rax+00000000h] loc_1520: mov edx, r12d mov esi, ebx mov rdi, rbp call min_heapify sub r12d, 1 jnb short loc_1520 loc_1533: mov rdi, r13; size sub ebx, 1 call _malloc movsxd rbx, ebx mov r13, rax mov r12, rax nop word ptr [rax+rax+00000000h] loc_1550: mov eax, [rbp+0] mov esi, ebx xor edx, edx mov rdi, rbp add r12, 4 mov [r12-4], eax mov eax, [rbp+rbx*4+0] sub rbx, 1 mov [rbp+0], eax call min_heapify cmp rbx, 0FFFFFFFFFFFFFFFFh jnz short loc_1550 loc_1579: mov rdi, rbp; ptr call _free add rsp, 8 mov rax, r13 pop rbx pop rbp pop r12 pop r13 retn loc_1590: mov rdi, r13; size call _malloc mov r13, rax jmp short loc_1579
_DWORD * func0(void *src, int a2) { _DWORD *v2; // rax _DWORD *v3; // rbp unsigned int v4; // r12d long long v6; // rbx _DWORD *v7; // r13 _DWORD *v8; // r12 long long v9; // rsi int v10; // eax v2 = malloc(4LL * a2); v3 = v2; if ( a2 <= 0 ) { v7 = malloc(4LL * a2); } else { memcpy(v2, src, 4LL * (unsigned int)a2); v4 = (a2 >> 1) - 1; if ( a2 >> 1 ) { do min_heapify(v3, (unsigned int)a2, v4); while ( v4-- != 0 ); } v6 = a2 - 1; v7 = malloc(4LL * a2); v8 = v7; do { v9 = (unsigned int)v6; *v8++ = *v3; v10 = v3[v6--]; *v3 = v10; min_heapify(v3, v9, 0LL); } while ( v6 != -1 ); } free(v3); return v7; }
func0: ENDBR64 PUSH R13 MOVSXD R13,ESI PUSH R12 MOV R12,RDI PUSH RBP PUSH RBX MOV RBX,R13 SHL R13,0x2 MOV RDI,R13 SUB RSP,0x8 CALL 0x001010d0 MOV RBP,RAX TEST EBX,EBX JLE 0x00101590 MOV EDX,EBX MOV RSI,R12 MOV RDI,RAX SHL RDX,0x2 CALL 0x001010c0 MOV EAX,EBX SAR EAX,0x1 LEA R12D,[RAX + -0x1] JZ 0x00101533 NOP dword ptr [RAX] LAB_00101520: MOV EDX,R12D MOV ESI,EBX MOV RDI,RBP CALL 0x00101430 SUB R12D,0x1 JNC 0x00101520 LAB_00101533: MOV RDI,R13 SUB EBX,0x1 CALL 0x001010d0 MOVSXD RBX,EBX MOV R13,RAX MOV R12,RAX NOP word ptr [RAX + RAX*0x1] LAB_00101550: MOV EAX,dword ptr [RBP] MOV ESI,EBX XOR EDX,EDX MOV RDI,RBP ADD R12,0x4 MOV dword ptr [R12 + -0x4],EAX MOV EAX,dword ptr [RBP + RBX*0x4] SUB RBX,0x1 MOV dword ptr [RBP],EAX CALL 0x00101430 CMP RBX,-0x1 JNZ 0x00101550 LAB_00101579: MOV RDI,RBP CALL 0x00101090 ADD RSP,0x8 MOV RAX,R13 POP RBX POP RBP POP R12 POP R13 RET LAB_00101590: MOV RDI,R13 CALL 0x001010d0 MOV R13,RAX JMP 0x00101579
int4 * func0(void *param_1,uint param_2) { int4 *puVar1; int iVar2; int4 *__dest; int4 *puVar3; ulong uVar4; ulong uVar5; int4 *puVar6; size_t __size; __size = (long)(int)param_2 << 2; __dest = (int4 *)malloc(__size); if ((int)param_2 < 1) { puVar3 = (int4 *)malloc(__size); } else { memcpy(__dest,param_1,(ulong)param_2 << 2); iVar2 = (int)param_2 >> 1; while (iVar2 != 0) { iVar2 = iVar2 + -1; min_heapify(__dest,param_2,iVar2); } puVar3 = (int4 *)malloc(__size); uVar4 = (ulong)(int)(param_2 - 1); puVar6 = puVar3; do { uVar5 = uVar4 & 0xffffffff; *puVar6 = *__dest; puVar1 = __dest + uVar4; uVar4 = uVar4 - 1; *__dest = *puVar1; min_heapify(__dest,uVar5,0); puVar6 = puVar6 + 1; } while (uVar4 != 0xffffffffffffffff); } free(__dest); return puVar3; }
5,384
func0
#include <assert.h>
int func0(int l, int w, int h) { int volume = l * w * h; return volume; }
int main() { assert(func0(1, 2, 3) == 6); assert(func0(5, 7, 9) == 315); assert(func0(10, 15, 21) == 3150); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov %edx,-0x1c(%rbp) mov -0x14(%rbp),%eax imul -0x18(%rbp),%eax mov -0x1c(%rbp),%edx imul %edx,%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 [rbp+var_18], esi mov [rbp+var_1C], edx mov eax, [rbp+var_14] imul eax, [rbp+var_18] mov edx, [rbp+var_1C] imul eax, edx mov [rbp+var_4], eax mov eax, [rbp+var_4] pop rbp retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(a3 * a2 * a1); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV dword ptr [RBP + -0x1c],EDX MOV EAX,dword ptr [RBP + -0x14] IMUL EAX,dword ptr [RBP + -0x18] MOV EDX,dword ptr [RBP + -0x1c] IMUL EAX,EDX MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x4] POP RBP RET
int func0(int param_1,int param_2,int param_3) { return param_1 * param_2 * param_3; }
5,385
func0
#include <assert.h>
int func0(int l, int w, int h) { int volume = l * w * h; return volume; }
int main() { assert(func0(1, 2, 3) == 6); assert(func0(5, 7, 9) == 315); assert(func0(10, 15, 21) == 3150); return 0; }
O1
c
func0: endbr64 imul %esi,%edi mov %edi,%eax imul %edx,%eax retq
func0: endbr64 imul edi, esi mov eax, edi imul eax, edx retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(a3 * a2 * a1); }
func0: ENDBR64 IMUL EDI,ESI MOV EAX,EDI IMUL EAX,EDX RET
int func0(int param_1,int param_2,int param_3) { return param_1 * param_2 * param_3; }
5,386
func0
#include <assert.h>
int func0(int l, int w, int h) { int volume = l * w * h; return volume; }
int main() { assert(func0(1, 2, 3) == 6); assert(func0(5, 7, 9) == 315); assert(func0(10, 15, 21) == 3150); return 0; }
O2
c
func0: endbr64 imul %esi,%edi mov %edi,%eax imul %edx,%eax retq nopl (%rax)
func0: endbr64 imul edi, esi mov eax, edi imul eax, edx retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(a3 * a2 * a1); }
func0: ENDBR64 IMUL EDI,ESI MOV EAX,EDI IMUL EAX,EDX RET
int func0(int param_1,int param_2,int param_3) { return param_1 * param_2 * param_3; }
5,387
func0
#include <assert.h>
int func0(int l, int w, int h) { int volume = l * w * h; return volume; }
int main() { assert(func0(1, 2, 3) == 6); assert(func0(5, 7, 9) == 315); assert(func0(10, 15, 21) == 3150); return 0; }
O3
c
func0: endbr64 imul %esi,%edi mov %edi,%eax imul %edx,%eax retq nopl (%rax)
func0: endbr64 imul edi, esi mov eax, edi imul eax, edx retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(a3 * a2 * a1); }
func0: ENDBR64 IMUL EDI,ESI MOV EAX,EDI IMUL EAX,EDX RET
int func0(int param_1,int param_2,int param_3) { return param_1 * param_2 * param_3; }
5,388
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
void func0(const char *str, char **result, int *index) { int len = strlen(str); if (len == 0) { result[*index] = strdup(""); (*index)++; return; } char **prev_list = malloc(40320 * sizeof(char *)); // 40320 = 8! maximum permutations for 8 characters int prev_index = 0; func0(str + 1, prev_list, &prev_index); int i, j, k; for (i = 0; i < prev_index; i++) { for (j = 0; j <= strlen(prev_list[i]); j++) { char *new_str = malloc((len + 1) * sizeof(char)); strncpy(new_str, prev_list[i], j); new_str[j] = str[0]; strcpy(new_str + j + 1, prev_list[i] + j); int found = 0; for (k = 0; k < *index; k++) { if (strcmp(result[k], new_str) == 0) { found = 1; break; } } if (!found) { result[*index] = new_str; (*index)++; } else { free(new_str); } } } for (i = 0; i < prev_index; i++) { free(prev_list[i]); } free(prev_list); }
int main() { char *result[100]; int index; index = 0; func0("ab", result, &index); assert(strcmp(result[0], "ab") == 0 && strcmp(result[1], "ba") == 0 && index == 2); index = 0; func0("abc", result, &index); assert(strcmp(result[0], "abc") == 0 && strcmp(result[1], "bac") == 0 && strcmp(result[2], "bca") == 0 && strcmp(result[3], "acb") == 0 && strcmp(result[4], "cab") == 0 && strcmp(result[5], "cba") == 0 && index == 6); index = 0; func0("abcd", result, &index); assert(index == 24); // Clean up allocated memory for (int i = 0; i < index; i++) { free(result[i]); } return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x58,%rsp mov %rdi,-0x48(%rbp) mov %rsi,-0x50(%rbp) mov %rdx,-0x58(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x48(%rbp),%rax mov %rax,%rdi callq 1100 <strlen@plt> mov %eax,-0x2c(%rbp) cmpl $0x0,-0x2c(%rbp) jne 12c1 <func0+0x78> mov -0x58(%rbp),%rax mov (%rax),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x50(%rbp),%rax lea (%rdx,%rax,1),%rbx lea 0xd63(%rip),%rdi callq 1150 <strdup@plt> mov %rax,(%rbx) mov -0x58(%rbp),%rax mov (%rax),%eax lea 0x1(%rax),%edx mov -0x58(%rbp),%rax mov %edx,(%rax) jmpq 14ae <func0+0x265> mov $0x4ec00,%edi callq 1140 <malloc@plt> mov %rax,-0x28(%rbp) movl $0x0,-0x40(%rbp) mov -0x48(%rbp),%rax lea 0x1(%rax),%rcx lea -0x40(%rbp),%rdx mov -0x28(%rbp),%rax mov %rax,%rsi mov %rcx,%rdi callq 1249 <func0> movl $0x0,-0x3c(%rbp) jmpq 1462 <func0+0x219> movl $0x0,-0x38(%rbp) jmpq 1430 <func0+0x1e7> mov -0x2c(%rbp),%eax add $0x1,%eax cltq mov %rax,%rdi callq 1140 <malloc@plt> mov %rax,-0x20(%rbp) mov -0x38(%rbp),%eax movslq %eax,%rdx mov -0x3c(%rbp),%eax cltq lea 0x0(,%rax,8),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%rcx mov -0x20(%rbp),%rax mov %rcx,%rsi mov %rax,%rdi callq 10e0 <strncpy@plt> mov -0x38(%rbp),%eax movslq %eax,%rdx mov -0x20(%rbp),%rax add %rax,%rdx mov -0x48(%rbp),%rax movzbl (%rax),%eax mov %al,(%rdx) mov -0x3c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%rdx mov -0x38(%rbp),%eax cltq add %rax,%rdx mov -0x38(%rbp),%eax cltq lea 0x1(%rax),%rcx mov -0x20(%rbp),%rax add %rcx,%rax mov %rdx,%rsi mov %rax,%rdi callq 10f0 <strcpy@plt> movl $0x0,-0x30(%rbp) movl $0x0,-0x34(%rbp) jmp 13e0 <func0+0x197> mov -0x34(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x50(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov -0x20(%rbp),%rdx mov %rdx,%rsi mov %rax,%rdi callq 1130 <strcmp@plt> test %eax,%eax jne 13dc <func0+0x193> movl $0x1,-0x30(%rbp) jmp 13eb <func0+0x1a2> addl $0x1,-0x34(%rbp) mov -0x58(%rbp),%rax mov (%rax),%eax cmp %eax,-0x34(%rbp) jl 13a9 <func0+0x160> cmpl $0x0,-0x30(%rbp) jne 1420 <func0+0x1d7> mov -0x58(%rbp),%rax mov (%rax),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x50(%rbp),%rax add %rax,%rdx mov -0x20(%rbp),%rax mov %rax,(%rdx) mov -0x58(%rbp),%rax mov (%rax),%eax lea 0x1(%rax),%edx mov -0x58(%rbp),%rax mov %edx,(%rax) jmp 142c <func0+0x1e3> mov -0x20(%rbp),%rax mov %rax,%rdi callq 10d0 <free@plt> addl $0x1,-0x38(%rbp) mov -0x38(%rbp),%eax movslq %eax,%rbx mov -0x3c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov %rax,%rdi callq 1100 <strlen@plt> cmp %rax,%rbx jbe 1309 <func0+0xc0> addl $0x1,-0x3c(%rbp) mov -0x40(%rbp),%eax cmp %eax,-0x3c(%rbp) jl 12fd <func0+0xb4> movl $0x0,-0x3c(%rbp) jmp 149a <func0+0x251> mov -0x3c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov %rax,%rdi callq 10d0 <free@plt> addl $0x1,-0x3c(%rbp) mov -0x40(%rbp),%eax cmp %eax,-0x3c(%rbp) jl 1477 <func0+0x22e> mov -0x28(%rbp),%rax mov %rax,%rdi callq 10d0 <free@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 14c2 <func0+0x279> callq 1110 <__stack_chk_fail@plt> add $0x58,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 58h mov [rbp+s], rdi mov [rbp+var_50], rsi mov [rbp+var_58], rdx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_2C], eax cmp [rbp+var_2C], 0 jnz short loc_12C4 mov rax, [rbp+var_58] mov eax, [rax] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_50] lea rbx, [rdx+rax] lea rax, s mov rdi, rax; s call _strdup mov [rbx], rax mov rax, [rbp+var_58] mov eax, [rax] lea edx, [rax+1] mov rax, [rbp+var_58] mov [rax], edx jmp loc_14B1 loc_12C4: mov edi, 4EC00h; size call _malloc mov [rbp+ptr], rax mov [rbp+var_40], 0 mov rax, [rbp+s] lea rcx, [rax+1] lea rdx, [rbp+var_40] mov rax, [rbp+ptr] mov rsi, rax mov rdi, rcx call func0 mov [rbp+var_3C], 0 jmp loc_1465 loc_1300: mov [rbp+var_38], 0 jmp loc_1433 loc_130C: mov eax, [rbp+var_2C] add eax, 1 cdqe mov rdi, rax; size call _malloc mov [rbp+dest], rax mov eax, [rbp+var_38] movsxd rdx, eax; n mov eax, [rbp+var_3C] cdqe lea rcx, ds:0[rax*8] mov rax, [rbp+ptr] add rax, rcx mov rcx, [rax] mov rax, [rbp+dest] mov rsi, rcx; src mov rdi, rax; dest call _strncpy mov eax, [rbp+var_38] movsxd rdx, eax mov rax, [rbp+dest] add rdx, rax mov rax, [rbp+s] movzx eax, byte ptr [rax] mov [rdx], al mov eax, [rbp+var_3C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+ptr] add rax, rdx mov rdx, [rax] mov eax, [rbp+var_38] cdqe add rdx, rax mov eax, [rbp+var_38] cdqe lea rcx, [rax+1] mov rax, [rbp+dest] add rax, rcx mov rsi, rdx; src mov rdi, rax; dest call _strcpy mov [rbp+var_30], 0 mov [rbp+var_34], 0 jmp short loc_13E3 loc_13AC: mov eax, [rbp+var_34] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_50] add rax, rdx mov rax, [rax] mov rdx, [rbp+dest] mov rsi, rdx; s2 mov rdi, rax; s1 call _strcmp test eax, eax jnz short loc_13DF mov [rbp+var_30], 1 jmp short loc_13EE loc_13DF: add [rbp+var_34], 1 loc_13E3: mov rax, [rbp+var_58] mov eax, [rax] cmp [rbp+var_34], eax jl short loc_13AC loc_13EE: cmp [rbp+var_30], 0 jnz short loc_1423 mov rax, [rbp+var_58] mov eax, [rax] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_50] add rdx, rax mov rax, [rbp+dest] mov [rdx], rax mov rax, [rbp+var_58] mov eax, [rax] lea edx, [rax+1] mov rax, [rbp+var_58] mov [rax], edx jmp short loc_142F loc_1423: mov rax, [rbp+dest] mov rdi, rax; ptr call _free loc_142F: add [rbp+var_38], 1 loc_1433: mov eax, [rbp+var_38] movsxd rbx, eax mov eax, [rbp+var_3C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+ptr] add rax, rdx mov rax, [rax] mov rdi, rax; s call _strlen cmp rax, rbx jnb loc_130C add [rbp+var_3C], 1 loc_1465: mov eax, [rbp+var_40] cmp [rbp+var_3C], eax jl loc_1300 mov [rbp+var_3C], 0 jmp short loc_149D loc_147A: mov eax, [rbp+var_3C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+ptr] add rax, rdx mov rax, [rax] mov rdi, rax; ptr call _free add [rbp+var_3C], 1 loc_149D: mov eax, [rbp+var_40] cmp [rbp+var_3C], eax jl short loc_147A mov rax, [rbp+ptr] mov rdi, rax; ptr call _free loc_14B1: mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_14C5 call ___stack_chk_fail loc_14C5: mov rbx, [rbp+var_8] leave retn
unsigned long long func0(const char *a1, long long a2, int *a3) { char **v3; // rbx size_t v4; // rbx int v7; // [rsp+20h] [rbp-40h] BYREF int i; // [rsp+24h] [rbp-3Ch] int j; // [rsp+28h] [rbp-38h] int k; // [rsp+2Ch] [rbp-34h] int v11; // [rsp+30h] [rbp-30h] int v12; // [rsp+34h] [rbp-2Ch] void *ptr; // [rsp+38h] [rbp-28h] char *dest; // [rsp+40h] [rbp-20h] unsigned long long v15; // [rsp+48h] [rbp-18h] v15 = __readfsqword(0x28u); v12 = strlen(a1); if ( v12 ) { ptr = malloc(0x4EC00uLL); v7 = 0; func0(a1 + 1, ptr, &v7); for ( i = 0; i < v7; ++i ) { for ( j = 0; ; ++j ) { v4 = j; if ( strlen(*((const char **)ptr + i)) < v4 ) break; dest = (char *)malloc(v12 + 1); strncpy(dest, *((const char **)ptr + i), j); dest[j] = *a1; strcpy(&dest[j + 1], (const char *)(j + *((_QWORD *)ptr + i))); v11 = 0; for ( k = 0; k < *a3; ++k ) { if ( !strcmp(*(const char **)(8LL * k + a2), dest) ) { v11 = 1; break; } } if ( v11 ) free(dest); else *(_QWORD *)(a2 + 8LL * (*a3)++) = dest; } } for ( i = 0; i < v7; ++i ) free(*((void **)ptr + i)); free(ptr); } else { v3 = (char **)(8LL * *a3 + a2); *v3 = strdup(&s); ++*a3; } return v15 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x58 MOV qword ptr [RBP + -0x48],RDI MOV qword ptr [RBP + -0x50],RSI MOV qword ptr [RBP + -0x58],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x48] MOV RDI,RAX CALL 0x00101100 MOV dword ptr [RBP + -0x2c],EAX CMP dword ptr [RBP + -0x2c],0x0 JNZ 0x001012c4 MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x50] LEA RBX,[RDX + RAX*0x1] LEA RAX,[0x102008] MOV RDI,RAX CALL 0x00101150 MOV qword ptr [RBX],RAX MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] LEA EDX,[RAX + 0x1] MOV RAX,qword ptr [RBP + -0x58] MOV dword ptr [RAX],EDX JMP 0x001014b1 LAB_001012c4: MOV EDI,0x4ec00 CALL 0x00101140 MOV qword ptr [RBP + -0x28],RAX MOV dword ptr [RBP + -0x40],0x0 MOV RAX,qword ptr [RBP + -0x48] LEA RCX,[RAX + 0x1] LEA RDX,[RBP + -0x40] MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RAX MOV RDI,RCX CALL 0x00101249 MOV dword ptr [RBP + -0x3c],0x0 JMP 0x00101465 LAB_00101300: MOV dword ptr [RBP + -0x38],0x0 JMP 0x00101433 LAB_0010130c: MOV EAX,dword ptr [RBP + -0x2c] ADD EAX,0x1 CDQE MOV RDI,RAX CALL 0x00101140 MOV qword ptr [RBP + -0x20],RAX MOV EAX,dword ptr [RBP + -0x38] MOVSXD RDX,EAX MOV EAX,dword ptr [RBP + -0x3c] CDQE LEA RCX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV RCX,qword ptr [RAX] MOV RAX,qword ptr [RBP + -0x20] MOV RSI,RCX MOV RDI,RAX CALL 0x001010e0 MOV EAX,dword ptr [RBP + -0x38] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x20] ADD RDX,RAX MOV RAX,qword ptr [RBP + -0x48] MOVZX EAX,byte ptr [RAX] MOV byte ptr [RDX],AL MOV EAX,dword ptr [RBP + -0x3c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV RDX,qword ptr [RAX] MOV EAX,dword ptr [RBP + -0x38] CDQE ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x38] CDQE LEA RCX,[RAX + 0x1] MOV RAX,qword ptr [RBP + -0x20] ADD RAX,RCX MOV RSI,RDX MOV RDI,RAX CALL 0x001010f0 MOV dword ptr [RBP + -0x30],0x0 MOV dword ptr [RBP + -0x34],0x0 JMP 0x001013e3 LAB_001013ac: MOV EAX,dword ptr [RBP + -0x34] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x50] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV RDX,qword ptr [RBP + -0x20] MOV RSI,RDX MOV RDI,RAX CALL 0x00101130 TEST EAX,EAX JNZ 0x001013df MOV dword ptr [RBP + -0x30],0x1 JMP 0x001013ee LAB_001013df: ADD dword ptr [RBP + -0x34],0x1 LAB_001013e3: MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0x34],EAX JL 0x001013ac LAB_001013ee: CMP dword ptr [RBP + -0x30],0x0 JNZ 0x00101423 MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x50] ADD RDX,RAX MOV RAX,qword ptr [RBP + -0x20] MOV qword ptr [RDX],RAX MOV RAX,qword ptr [RBP + -0x58] MOV EAX,dword ptr [RAX] LEA EDX,[RAX + 0x1] MOV RAX,qword ptr [RBP + -0x58] MOV dword ptr [RAX],EDX JMP 0x0010142f LAB_00101423: MOV RAX,qword ptr [RBP + -0x20] MOV RDI,RAX CALL 0x001010d0 LAB_0010142f: ADD dword ptr [RBP + -0x38],0x1 LAB_00101433: MOV EAX,dword ptr [RBP + -0x38] MOVSXD RBX,EAX MOV EAX,dword ptr [RBP + -0x3c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV RDI,RAX CALL 0x00101100 CMP RAX,RBX JNC 0x0010130c ADD dword ptr [RBP + -0x3c],0x1 LAB_00101465: MOV EAX,dword ptr [RBP + -0x40] CMP dword ptr [RBP + -0x3c],EAX JL 0x00101300 MOV dword ptr [RBP + -0x3c],0x0 JMP 0x0010149d LAB_0010147a: MOV EAX,dword ptr [RBP + -0x3c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV RDI,RAX CALL 0x001010d0 ADD dword ptr [RBP + -0x3c],0x1 LAB_0010149d: MOV EAX,dword ptr [RBP + -0x40] CMP dword ptr [RBP + -0x3c],EAX JL 0x0010147a MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x001010d0 LAB_001014b1: MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001014c5 CALL 0x00101110 LAB_001014c5: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
void func0(char *param_1,long param_2,int *param_3) { int iVar1; size_t sVar2; char *pcVar3; ulong uVar4; long in_FS_OFFSET; int local_48; int local_44; int local_40; int local_3c; int local_38; int local_34; void *local_30; char *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); sVar2 = strlen(param_1); local_34 = (int)sVar2; if (local_34 == 0) { iVar1 = *param_3; pcVar3 = strdup(""); *(char **)((long)iVar1 * 8 + param_2) = pcVar3; *param_3 = *param_3 + 1; } else { local_30 = malloc(0x4ec00); local_48 = 0; func0(param_1 + 1,local_30,&local_48); for (local_44 = 0; local_44 < local_48; local_44 = local_44 + 1) { local_40 = 0; while( true ) { uVar4 = (ulong)local_40; sVar2 = strlen(*(char **)((long)local_30 + (long)local_44 * 8)); if (sVar2 < uVar4) break; local_28 = (char *)malloc((long)(local_34 + 1)); strncpy(local_28,*(char **)((long)local_30 + (long)local_44 * 8),(long)local_40); local_28[local_40] = *param_1; strcpy(local_28 + (long)local_40 + 1, (char *)(*(long *)((long)local_30 + (long)local_44 * 8) + (long)local_40)); local_38 = 0; for (local_3c = 0; local_3c < *param_3; local_3c = local_3c + 1) { iVar1 = strcmp(*(char **)(param_2 + (long)local_3c * 8),local_28); if (iVar1 == 0) { local_38 = 1; break; } } if (local_38 == 0) { *(char **)((long)*param_3 * 8 + param_2) = local_28; *param_3 = *param_3 + 1; } else { free(local_28); } local_40 = local_40 + 1; } } for (local_44 = 0; local_44 < local_48; local_44 = local_44 + 1) { free(*(void **)((long)local_30 + (long)local_44 * 8)); } free(local_30); } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
5,389
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
void func0(const char *str, char **result, int *index) { int len = strlen(str); if (len == 0) { result[*index] = strdup(""); (*index)++; return; } char **prev_list = malloc(40320 * sizeof(char *)); // 40320 = 8! maximum permutations for 8 characters int prev_index = 0; func0(str + 1, prev_list, &prev_index); int i, j, k; for (i = 0; i < prev_index; i++) { for (j = 0; j <= strlen(prev_list[i]); j++) { char *new_str = malloc((len + 1) * sizeof(char)); strncpy(new_str, prev_list[i], j); new_str[j] = str[0]; strcpy(new_str + j + 1, prev_list[i] + j); int found = 0; for (k = 0; k < *index; k++) { if (strcmp(result[k], new_str) == 0) { found = 1; break; } } if (!found) { result[*index] = new_str; (*index)++; } else { free(new_str); } } } for (i = 0; i < prev_index; i++) { free(prev_list[i]); } free(prev_list); }
int main() { char *result[100]; int index; index = 0; func0("ab", result, &index); assert(strcmp(result[0], "ab") == 0 && strcmp(result[1], "ba") == 0 && index == 2); index = 0; func0("abc", result, &index); assert(strcmp(result[0], "abc") == 0 && strcmp(result[1], "bac") == 0 && strcmp(result[2], "bca") == 0 && strcmp(result[3], "acb") == 0 && strcmp(result[4], "cab") == 0 && strcmp(result[5], "cba") == 0 && index == 6); index = 0; func0("abcd", result, &index); assert(index == 24); // Clean up allocated memory for (int i = 0; i < index; i++) { free(result[i]); } return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %rdi,0x18(%rsp) mov %rsi,0x10(%rsp) mov %rdx,0x8(%rsp) mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax mov $0xffffffffffffffff,%rcx repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax sub $0x1,%rax test %eax,%eax je 12c8 <func0+0x9f> mov %eax,%ebx mov $0x4ec00,%edi callq 1120 <malloc@plt> mov %rax,%r15 mov %rax,0x38(%rsp) movl $0x0,0x44(%rsp) lea 0x44(%rsp),%rdx mov 0x18(%rsp),%rcx lea 0x1(%rcx),%rdi mov %rax,%rsi callq 1229 <func0> cmpl $0x0,0x44(%rsp) jle 1332 <func0+0x109> mov %r15,0x30(%rsp) movl $0x0,0x2c(%rsp) add $0x1,%ebx movslq %ebx,%rax mov %rax,0x20(%rsp) jmp 12fe <func0+0xd5> mov %rdx,%r15 movslq (%rdx),%rax lea (%rsi,%rax,8),%rbx lea 0xd53(%rip),%rdi callq 1130 <strdup@plt> mov %rax,(%rbx) addl $0x1,(%r15) jmp 133c <func0+0x113> addl $0x1,0x2c(%rsp) mov 0x2c(%rsp),%edx mov 0x44(%rsp),%eax addq $0x8,0x30(%rsp) cmp %edx,%eax jle 1311 <func0+0xe8> mov 0x30(%rsp),%rax mov (%rax),%r15 mov $0x0,%r13d jmpq 1397 <func0+0x16e> test %eax,%eax jle 1332 <func0+0x109> mov $0x0,%ebx mov 0x38(%rsp),%rax mov (%rax,%rbx,8),%rdi callq 10c0 <free@plt> add $0x1,%rbx cmp %ebx,0x44(%rsp) jg 131a <func0+0xf1> mov 0x38(%rsp),%rdi callq 10c0 <free@plt> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1419 <func0+0x1f0> add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq movslq %r14d,%r14 mov 0x10(%rsp),%rax mov %rbp,(%rax,%r14,8) mov 0x8(%rsp),%rax addl $0x1,(%rax) mov $0xffffffffffffffff,%rcx mov $0x0,%eax mov %r15,%rdi repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax sub $0x1,%rax cmp %r13,%rax jb 12e7 <func0+0xbe> mov 0x20(%rsp),%rdi callq 1120 <malloc@plt> mov %rax,%rbp mov %r13,%rdx mov %r15,%rsi mov %rax,%rdi callq 10d0 <strncpy@plt> mov 0x18(%rsp),%rax movzbl (%rax),%eax mov %al,0x0(%rbp,%r13,1) lea (%r15,%r13,1),%rsi add $0x1,%r13 lea 0x0(%rbp,%r13,1),%rdi callq 10e0 <strcpy@plt> mov 0x8(%rsp),%rax mov (%rax),%r14d test %r14d,%r14d jle 135f <func0+0x136> mov 0x10(%rsp),%rdx mov %rdx,%rbx lea -0x1(%r14),%eax lea 0x8(%rdx,%rax,8),%r12 mov %rbp,%rsi mov (%rbx),%rdi callq 1110 <strcmp@plt> test %eax,%eax je 140c <func0+0x1e3> add $0x8,%rbx cmp %rbx,%r12 jne 13ef <func0+0x1c6> jmpq 135f <func0+0x136> mov %rbp,%rdi callq 10c0 <free@plt> jmpq 1373 <func0+0x14a> callq 10f0 <__stack_chk_fail@plt>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 58h mov [rsp+88h+var_78], rdi mov r15, rsi mov [rsp+88h+var_80], rdx mov rax, fs:28h mov [rsp+88h+var_40], rax xor eax, eax call _strlen test eax, eax jz short loc_12E1 mov ebx, eax mov edi, 4EC00h call _malloc mov r14, rax mov [rsp+88h+var_58], rax mov [rsp+88h+var_44], 0 lea rdx, [rsp+88h+var_44] mov rax, [rsp+88h+var_78] lea rdi, [rax+1] mov rsi, r14 call func0 mov eax, [rsp+88h+var_44] test eax, eax jle loc_1343 mov [rsp+88h+var_50], r14 mov eax, eax lea rax, [r14+rax*8] mov [rsp+88h+var_60], rax mov [rsp+88h+var_68], r14 add ebx, 1 movsxd rax, ebx mov [rsp+88h+var_70], rax jmp short loc_1314 loc_12E1: mov r14, [rsp+88h+var_80] movsxd rax, dword ptr [r14] lea rbx, [r15+rax*8] lea rdi, aIndex24+0Bh; "" call _strdup mov [rbx], rax add dword ptr [r14], 1 jmp short loc_134D loc_1302: add [rsp+88h+var_68], 8 mov rax, [rsp+88h+var_68] cmp rax, [rsp+88h+var_60] jz short loc_1328 loc_1314: mov rax, [rsp+88h+var_68] mov rax, [rax] mov [rsp+88h+var_88], rax mov r13d, 0 jmp short loc_1391 loc_1328: mov rbx, [rsp+88h+var_50] mov rbp, [rsp+88h+var_60] loc_1332: mov rdi, [rbx] call _free add rbx, 8 cmp rbx, rbp jnz short loc_1332 loc_1343: mov rdi, [rsp+88h+var_58] call _free loc_134D: mov rax, [rsp+88h+var_40] sub rax, fs:28h jnz loc_1412 add rsp, 58h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1370: movsxd r14, r14d mov [r15+r14*8], rbp mov rax, [rsp+88h+var_80] add dword ptr [rax], 1 loc_137F: mov rdi, [rsp+88h+var_88] call _strlen cmp rax, r13 jb loc_1302 loc_1391: mov rdi, [rsp+88h+var_70] call _malloc mov rbp, rax mov rdx, r13 mov rbx, [rsp+88h+var_88] mov rsi, rbx mov rdi, rax call _strncpy mov rax, [rsp+88h+var_78] movzx eax, byte ptr [rax] mov [rbp+r13+0], al lea rsi, [rbx+r13] add r13, 1 lea rdi, [rbp+r13+0] call _strcpy mov rax, [rsp+88h+var_80] mov r14d, [rax] test r14d, r14d jle short loc_1370 mov rbx, r15 lea eax, [r14-1] lea r12, [r15+rax*8+8] loc_13E8: mov rsi, rbp mov rdi, [rbx] call _strcmp test eax, eax jz short loc_1405 add rbx, 8 cmp rbx, r12 jnz short loc_13E8 jmp loc_1370 loc_1405: mov rdi, rbp call _free jmp loc_137F loc_1412: call ___stack_chk_fail
unsigned long long func0(_BYTE *a1, _QWORD *a2, int *a3) { int v4; // eax int v5; // ebx long long v6; // r14 _QWORD *v7; // rbx unsigned long long v8; // r13 long long *v9; // rbx long long v11; // rbp long long v12; // rsi int v13; // r14d _QWORD *v14; // rbx long long v15; // [rsp+0h] [rbp-88h] long long v17; // [rsp+18h] [rbp-70h] long long *v18; // [rsp+20h] [rbp-68h] long long *v19; // [rsp+28h] [rbp-60h] long long v20; // [rsp+30h] [rbp-58h] long long *v21; // [rsp+38h] [rbp-50h] int v22; // [rsp+44h] [rbp-44h] BYREF unsigned long long v23; // [rsp+48h] [rbp-40h] v23 = __readfsqword(0x28u); v4 = ((long long (*)(void))strlen)(); if ( v4 ) { v5 = v4; v6 = malloc(322560LL); v20 = v6; v22 = 0; func0(a1 + 1, v6, &v22); if ( v22 > 0 ) { v21 = (long long *)v6; v19 = (long long *)(v6 + 8LL * (unsigned int)v22); v18 = (long long *)v6; v17 = v5 + 1; do { v15 = *v18; v8 = 0LL; do { v11 = malloc(v17); strncpy(v11, v15, v8); *(_BYTE *)(v11 + v8) = *a1; v12 = v15 + v8++; strcpy(v11 + v8, v12); v13 = *a3; if ( *a3 <= 0 ) { LABEL_11: a2[v13] = v11; ++*a3; } else { v14 = a2; while ( (unsigned int)strcmp(*v14, v11) ) { if ( ++v14 == &a2[(unsigned int)(v13 - 1) + 1] ) goto LABEL_11; } free(v11); } } while ( strlen(v15) >= v8 ); ++v18; } while ( v18 != v19 ); v9 = v21; do free(*v9++); while ( v9 != v19 ); } free(v20); } else { v7 = &a2[*a3]; *v7 = strdup(""); ++*a3; } return v23 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x58 MOV qword ptr [RSP + 0x10],RDI MOV R15,RSI MOV qword ptr [RSP + 0x8],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX CALL 0x00101100 TEST EAX,EAX JZ 0x001012e1 MOV EBX,EAX MOV EDI,0x4ec00 CALL 0x00101140 MOV R14,RAX MOV qword ptr [RSP + 0x30],RAX MOV dword ptr [RSP + 0x44],0x0 LEA RDX,[RSP + 0x44] MOV RAX,qword ptr [RSP + 0x10] LEA RDI,[RAX + 0x1] MOV RSI,R14 CALL 0x00101249 MOV EAX,dword ptr [RSP + 0x44] TEST EAX,EAX JLE 0x00101343 MOV qword ptr [RSP + 0x38],R14 MOV EAX,EAX LEA RAX,[R14 + RAX*0x8] MOV qword ptr [RSP + 0x28],RAX MOV qword ptr [RSP + 0x20],R14 ADD EBX,0x1 MOVSXD RAX,EBX MOV qword ptr [RSP + 0x18],RAX JMP 0x00101314 LAB_001012e1: MOV R14,qword ptr [RSP + 0x8] MOVSXD RAX,dword ptr [R14] LEA RBX,[R15 + RAX*0x8] LEA RDI,[0x102049] CALL 0x00101150 MOV qword ptr [RBX],RAX ADD dword ptr [R14],0x1 JMP 0x0010134d LAB_00101302: ADD qword ptr [RSP + 0x20],0x8 MOV RAX,qword ptr [RSP + 0x20] CMP RAX,qword ptr [RSP + 0x28] JZ 0x00101328 LAB_00101314: MOV RAX,qword ptr [RSP + 0x20] MOV RAX,qword ptr [RAX] MOV qword ptr [RSP],RAX MOV R13D,0x0 JMP 0x00101391 LAB_00101328: MOV RBX,qword ptr [RSP + 0x38] MOV RBP,qword ptr [RSP + 0x28] LAB_00101332: MOV RDI,qword ptr [RBX] CALL 0x001010d0 ADD RBX,0x8 CMP RBX,RBP JNZ 0x00101332 LAB_00101343: MOV RDI,qword ptr [RSP + 0x30] CALL 0x001010d0 LAB_0010134d: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101412 ADD RSP,0x58 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101370: MOVSXD R14,R14D MOV qword ptr [R15 + R14*0x8],RBP MOV RAX,qword ptr [RSP + 0x8] ADD dword ptr [RAX],0x1 LAB_0010137f: MOV RDI,qword ptr [RSP] CALL 0x00101100 CMP RAX,R13 JC 0x00101302 LAB_00101391: MOV RDI,qword ptr [RSP + 0x18] CALL 0x00101140 MOV RBP,RAX MOV RDX,R13 MOV RBX,qword ptr [RSP] MOV RSI,RBX MOV RDI,RAX CALL 0x001010e0 MOV RAX,qword ptr [RSP + 0x10] MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBP + R13*0x1],AL LEA RSI,[RBX + R13*0x1] ADD R13,0x1 LEA RDI,[RBP + R13*0x1] CALL 0x001010f0 MOV RAX,qword ptr [RSP + 0x8] MOV R14D,dword ptr [RAX] TEST R14D,R14D JLE 0x00101370 MOV RBX,R15 LEA EAX,[R14 + -0x1] LEA R12,[R15 + RAX*0x8 + 0x8] LAB_001013e8: MOV RSI,RBP MOV RDI,qword ptr [RBX] CALL 0x00101130 TEST EAX,EAX JZ 0x00101405 ADD RBX,0x8 CMP RBX,R12 JNZ 0x001013e8 JMP 0x00101370 LAB_00101405: MOV RDI,RBP CALL 0x001010d0 JMP 0x0010137f LAB_00101412: CALL 0x00101110
void func0(char *param_1,int8 *param_2,int *param_3) { char *__src; int iVar1; int iVar2; size_t sVar3; int8 *__ptr; ulong uVar4; char *pcVar5; size_t sVar6; char *__dest; int8 *puVar7; size_t __n; long in_FS_OFFSET; int8 *local_68; uint local_44; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); sVar3 = strlen(param_1); if ((int)sVar3 == 0) { iVar1 = *param_3; pcVar5 = strdup(""); param_2[iVar1] = pcVar5; *param_3 = *param_3 + 1; } else { __ptr = (int8 *)malloc(0x4ec00); local_44 = 0; func0(param_1 + 1,__ptr,&local_44); if (0 < (int)local_44) { uVar4 = (ulong)local_44; local_68 = __ptr; do { pcVar5 = (char *)*local_68; __n = 0; do { __dest = (char *)malloc((long)((int)sVar3 + 1)); strncpy(__dest,pcVar5,__n); __dest[__n] = *param_1; __src = pcVar5 + __n; __n = __n + 1; strcpy(__dest + __n,__src); iVar1 = *param_3; if (0 < iVar1) { puVar7 = param_2; do { iVar2 = strcmp((char *)*puVar7,__dest); if (iVar2 == 0) { free(__dest); goto LAB_0010137f; } puVar7 = puVar7 + 1; } while (puVar7 != param_2 + (ulong)(iVar1 - 1) + 1); } param_2[iVar1] = __dest; *param_3 = *param_3 + 1; LAB_0010137f: sVar6 = strlen(pcVar5); } while (__n <= sVar6); local_68 = local_68 + 1; puVar7 = __ptr; } while (local_68 != __ptr + uVar4); do { free((void *)*puVar7); puVar7 = puVar7 + 1; } while (puVar7 != __ptr + uVar4); } free(__ptr); } if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
5,390
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
void func0(const char *str, char **result, int *index) { int len = strlen(str); if (len == 0) { result[*index] = strdup(""); (*index)++; return; } char **prev_list = malloc(40320 * sizeof(char *)); // 40320 = 8! maximum permutations for 8 characters int prev_index = 0; func0(str + 1, prev_list, &prev_index); int i, j, k; for (i = 0; i < prev_index; i++) { for (j = 0; j <= strlen(prev_list[i]); j++) { char *new_str = malloc((len + 1) * sizeof(char)); strncpy(new_str, prev_list[i], j); new_str[j] = str[0]; strcpy(new_str + j + 1, prev_list[i] + j); int found = 0; for (k = 0; k < *index; k++) { if (strcmp(result[k], new_str) == 0) { found = 1; break; } } if (!found) { result[*index] = new_str; (*index)++; } else { free(new_str); } } } for (i = 0; i < prev_index; i++) { free(prev_list[i]); } free(prev_list); }
int main() { char *result[100]; int index; index = 0; func0("ab", result, &index); assert(strcmp(result[0], "ab") == 0 && strcmp(result[1], "ba") == 0 && index == 2); index = 0; func0("abc", result, &index); assert(strcmp(result[0], "abc") == 0 && strcmp(result[1], "bac") == 0 && strcmp(result[2], "bca") == 0 && strcmp(result[3], "acb") == 0 && strcmp(result[4], "cab") == 0 && strcmp(result[5], "cba") == 0 && index == 6); index = 0; func0("abcd", result, &index); assert(index == 24); // Clean up allocated memory for (int i = 0; i < index; i++) { free(result[i]); } return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %rdi,0x18(%rsp) mov %rsi,0x10(%rsp) mov %rdx,0x8(%rsp) mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax callq 1100 <strlen@plt> test %eax,%eax je 162d <func0+0x1cd> mov $0x4ec00,%edi mov %rax,%rbx callq 1140 <malloc@plt> mov 0x18(%rsp),%rcx add $0x1,%ebx lea 0x44(%rsp),%rdx mov %rax,%rsi mov %rax,0x38(%rsp) lea 0x1(%rcx),%rdi movl $0x0,0x44(%rsp) callq 1460 <func0> movslq %ebx,%rax movq $0x0,0x30(%rsp) mov %rax,0x20(%rsp) mov 0x10(%rsp),%rax add $0x8,%rax mov %rax,0x28(%rsp) mov 0x44(%rsp),%eax test %eax,%eax jle 15e0 <func0+0x180> nopl 0x0(%rax) mov 0x38(%rsp),%rax mov 0x30(%rsp),%rdx xor %ebp,%ebp mov (%rax,%rdx,8),%r13 mov 0x20(%rsp),%rdi callq 1140 <malloc@plt> mov %rbp,%rdx mov %r13,%rsi mov %rax,%rdi mov %rax,%r14 callq 10e0 <strncpy@plt> mov 0x18(%rsp),%rax lea 0x0(%r13,%rbp,1),%rsi movzbl (%rax),%eax mov %al,(%r14,%rbp,1) add $0x1,%rbp lea (%r14,%rbp,1),%rdi callq 10f0 <strcpy@plt> mov 0x8(%rsp),%rax mov (%rax),%r12d test %r12d,%r12d jle 1610 <func0+0x1b0> mov 0x28(%rsp),%rcx lea -0x1(%r12),%eax mov 0x10(%rsp),%r15 lea (%rcx,%rax,8),%rbx jmp 157d <func0+0x11d> add $0x8,%r15 cmp %rbx,%r15 je 1610 <func0+0x1b0> mov (%r15),%rdi mov %r14,%rsi callq 1130 <strcmp@plt> test %eax,%eax jne 1570 <func0+0x110> mov %r14,%rdi callq 10d0 <free@plt> mov %r13,%rdi callq 1100 <strlen@plt> cmp %rbp,%rax jae 1510 <func0+0xb0> addq $0x1,0x30(%rsp) mov 0x44(%rsp),%eax mov 0x30(%rsp),%rcx cmp %ecx,%eax jg 1500 <func0+0xa0> test %eax,%eax jle 15e0 <func0+0x180> xor %ebx,%ebx nopw 0x0(%rax,%rax,1) mov 0x38(%rsp),%rax mov (%rax,%rbx,8),%rdi add $0x1,%rbx callq 10d0 <free@plt> cmp %ebx,0x44(%rsp) jg 15c8 <func0+0x168> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1670 <func0+0x210> mov 0x38(%rsp),%rdi add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 jmpq 10d0 <free@plt> nopl 0x0(%rax) mov 0x10(%rsp),%rdx movslq %r12d,%rax add $0x1,%r12d mov %r14,(%rdx,%rax,8) mov 0x8(%rsp),%rax mov %r12d,(%rax) jmpq 1594 <func0+0x134> mov 0x8(%rsp),%r14 mov 0x10(%rsp),%rcx lea 0x9ee(%rip),%rdi movslq (%r14),%rax lea (%rcx,%rax,8),%rbx callq 1150 <strdup@plt> mov %rax,(%rbx) addl $0x1,(%r14) mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1670 <func0+0x210> add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq callq 1110 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 68h mov [rsp+98h+var_80], rdi mov [rsp+98h+var_88], rsi mov [rsp+98h+var_90], rdx mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax call _strlen test eax, eax jz loc_1615 mov edi, 4EC00h mov rbx, rax call _malloc mov rcx, [rsp+98h+var_80] lea rdx, [rsp+98h+var_44] mov [rsp+98h+var_44], 0 mov rsi, rax mov [rsp+98h+var_58], rax lea rdi, [rcx+1] call func0 mov eax, [rsp+98h+var_44] test eax, eax jle loc_15C9 add ebx, 1 movsxd rcx, ebx mov [rsp+98h+var_78], rcx mov rcx, [rsp+98h+var_58] lea rax, [rcx+rax*8] mov [rsp+98h+var_50], rcx mov [rsp+98h+var_60], rax mov rax, [rsp+98h+var_88] mov [rsp+98h+var_68], rcx add rax, 8 mov [rsp+98h+var_70], rax nop dword ptr [rax+rax+00h] loc_14F0: mov rax, [rsp+98h+var_68] xor ebp, ebp mov r13, [rax] nop word ptr [rax+rax+00h] loc_1500: mov rdi, [rsp+98h+var_78] call _malloc mov rdx, rbp mov rsi, r13 mov rdi, rax mov r14, rax call _strncpy mov rax, [rsp+98h+var_80] lea rsi, [r13+rbp+0] movzx eax, byte ptr [rax] mov [r14+rbp], al add rbp, 1 lea rdi, [r14+rbp] call _strcpy mov rax, [rsp+98h+var_90] mov r12d, [rax] test r12d, r12d jle loc_15F8 mov rcx, [rsp+98h+var_70] lea eax, [r12-1] mov r15, [rsp+98h+var_88] lea rbx, [rcx+rax*8] jmp short loc_156D loc_1560: add r15, 8 cmp rbx, r15 jz loc_15F8 loc_156D: mov rdi, [r15] mov rsi, r14 call _strcmp test eax, eax jnz short loc_1560 mov rdi, r14 call _free loc_1584: mov rdi, r13 call _strlen cmp rax, rbp jnb loc_1500 add [rsp+98h+var_68], 8 mov rax, [rsp+98h+var_68] cmp rax, [rsp+98h+var_60] jnz loc_14F0 mov rbx, [rsp+98h+var_50] mov rbp, [rsp+98h+var_60] nop dword ptr [rax] loc_15B8: mov rdi, [rbx] add rbx, 8 call _free cmp rbx, rbp jnz short loc_15B8 loc_15C9: mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1658 mov rdi, [rsp+98h+var_58] add rsp, 68h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 jmp _free loc_15F8: mov rdx, [rsp+98h+var_88] movsxd rax, r12d add r12d, 1 mov [rdx+rax*8], r14 mov rax, [rsp+98h+var_90] mov [rax], r12d jmp loc_1584 loc_1615: mov r14, [rsp+98h+var_90] mov rcx, [rsp+98h+var_88] lea rdi, aIndex24+0Bh; "" movsxd rax, dword ptr [r14] lea rbx, [rcx+rax*8] call _strdup mov [rbx], rax add dword ptr [r14], 1 mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1658 add rsp, 68h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1658: call ___stack_chk_fail
long long func0(_BYTE *a1, _QWORD *a2, int *a3) { int v3; // eax int v4; // ebx unsigned long long v5; // rbp long long v6; // r13 long long v7; // r14 long long v8; // rsi int v9; // r12d _QWORD *v10; // r15 long long *v11; // rbx long long v12; // rdi _QWORD *v14; // rbx long long *v17; // [rsp+30h] [rbp-68h] long long *v18; // [rsp+38h] [rbp-60h] long long v19; // [rsp+40h] [rbp-58h] int v20; // [rsp+54h] [rbp-44h] BYREF unsigned long long v21; // [rsp+58h] [rbp-40h] v21 = __readfsqword(0x28u); v3 = ((long long (*)(void))strlen)(); if ( v3 ) { v4 = v3; v20 = 0; v19 = malloc(322560LL); func0(a1 + 1, v19, &v20); if ( v20 > 0 ) { v18 = (long long *)(v19 + 8LL * (unsigned int)v20); v17 = (long long *)v19; do { v5 = 0LL; v6 = *v17; do { v7 = malloc(v4 + 1); strncpy(v7, v6, v5); v8 = v6 + v5; *(_BYTE *)(v7 + v5++) = *a1; strcpy(v7 + v5, v8); v9 = *a3; if ( *a3 <= 0 ) { LABEL_15: a2[v9] = v7; *a3 = v9 + 1; } else { v10 = a2; while ( (unsigned int)strcmp(*v10, v7) ) { if ( &a2[(unsigned int)(v9 - 1) + 1] == ++v10 ) goto LABEL_15; } free(v7); } } while ( strlen(v6) >= v5 ); ++v17; } while ( v17 != v18 ); v11 = (long long *)v19; do { v12 = *v11++; free(v12); } while ( v11 != v18 ); } return free(v19); } else { v14 = &a2[*a3]; *v14 = strdup(""); ++*a3; return v21 - __readfsqword(0x28u); } }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x68 MOV qword ptr [RSP + 0x18],RDI MOV qword ptr [RSP + 0x10],RSI MOV qword ptr [RSP + 0x8],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX CALL 0x00101100 TEST EAX,EAX JZ 0x00101615 MOV EDI,0x4ec00 MOV RBX,RAX CALL 0x00101140 MOV RCX,qword ptr [RSP + 0x18] LEA RDX,[RSP + 0x54] MOV dword ptr [RSP + 0x54],0x0 MOV RSI,RAX MOV qword ptr [RSP + 0x40],RAX LEA RDI,[RCX + 0x1] CALL 0x00101440 MOV EAX,dword ptr [RSP + 0x54] TEST EAX,EAX JLE 0x001015c9 ADD EBX,0x1 MOVSXD RCX,EBX MOV qword ptr [RSP + 0x20],RCX MOV RCX,qword ptr [RSP + 0x40] LEA RAX,[RCX + RAX*0x8] MOV qword ptr [RSP + 0x48],RCX MOV qword ptr [RSP + 0x38],RAX MOV RAX,qword ptr [RSP + 0x10] MOV qword ptr [RSP + 0x30],RCX ADD RAX,0x8 MOV qword ptr [RSP + 0x28],RAX NOP dword ptr [RAX + RAX*0x1] LAB_001014f0: MOV RAX,qword ptr [RSP + 0x30] XOR EBP,EBP MOV R13,qword ptr [RAX] NOP word ptr [RAX + RAX*0x1] LAB_00101500: MOV RDI,qword ptr [RSP + 0x20] CALL 0x00101140 MOV RDX,RBP MOV RSI,R13 MOV RDI,RAX MOV R14,RAX CALL 0x001010e0 MOV RAX,qword ptr [RSP + 0x18] LEA RSI,[R13 + RBP*0x1] MOVZX EAX,byte ptr [RAX] MOV byte ptr [R14 + RBP*0x1],AL ADD RBP,0x1 LEA RDI,[R14 + RBP*0x1] CALL 0x001010f0 MOV RAX,qword ptr [RSP + 0x8] MOV R12D,dword ptr [RAX] TEST R12D,R12D JLE 0x001015f8 MOV RCX,qword ptr [RSP + 0x28] LEA EAX,[R12 + -0x1] MOV R15,qword ptr [RSP + 0x10] LEA RBX,[RCX + RAX*0x8] JMP 0x0010156d LAB_00101560: ADD R15,0x8 CMP RBX,R15 JZ 0x001015f8 LAB_0010156d: MOV RDI,qword ptr [R15] MOV RSI,R14 CALL 0x00101130 TEST EAX,EAX JNZ 0x00101560 MOV RDI,R14 CALL 0x001010d0 LAB_00101584: MOV RDI,R13 CALL 0x00101100 CMP RAX,RBP JNC 0x00101500 ADD qword ptr [RSP + 0x30],0x8 MOV RAX,qword ptr [RSP + 0x30] CMP RAX,qword ptr [RSP + 0x38] JNZ 0x001014f0 MOV RBX,qword ptr [RSP + 0x48] MOV RBP,qword ptr [RSP + 0x38] NOP dword ptr [RAX] LAB_001015b8: MOV RDI,qword ptr [RBX] ADD RBX,0x8 CALL 0x001010d0 CMP RBX,RBP JNZ 0x001015b8 LAB_001015c9: MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101658 MOV RDI,qword ptr [RSP + 0x40] ADD RSP,0x68 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 JMP 0x001010d0 LAB_001015f8: MOV RDX,qword ptr [RSP + 0x10] MOVSXD RAX,R12D ADD R12D,0x1 MOV qword ptr [RDX + RAX*0x8],R14 MOV RAX,qword ptr [RSP + 0x8] MOV dword ptr [RAX],R12D JMP 0x00101584 LAB_00101615: MOV R14,qword ptr [RSP + 0x8] MOV RCX,qword ptr [RSP + 0x10] LEA RDI,[0x102049] MOVSXD RAX,dword ptr [R14] LEA RBX,[RCX + RAX*0x8] CALL 0x00101150 MOV qword ptr [RBX],RAX ADD dword ptr [R14],0x1 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101658 ADD RSP,0x68 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101658: CALL 0x00101110
void func0(char *param_1,int8 *param_2,int *param_3) { char *__src; int iVar1; int iVar2; size_t sVar3; int8 *__ptr; ulong uVar4; char *__dest; size_t sVar5; char *pcVar6; int8 *puVar7; int8 *puVar8; size_t __n; long in_FS_OFFSET; int8 *local_68; uint local_44; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); sVar3 = strlen(param_1); if ((int)sVar3 == 0) { iVar1 = *param_3; pcVar6 = strdup(""); param_2[iVar1] = pcVar6; *param_3 = *param_3 + 1; if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return; } } else { __ptr = (int8 *)malloc(0x4ec00); local_44 = 0; func0(param_1 + 1,__ptr,&local_44); uVar4 = (ulong)local_44; if (0 < (int)local_44) { local_68 = __ptr; do { __n = 0; pcVar6 = (char *)*local_68; do { __dest = (char *)malloc((long)((int)sVar3 + 1)); strncpy(__dest,pcVar6,__n); __src = pcVar6 + __n; __dest[__n] = *param_1; __n = __n + 1; strcpy(__dest + __n,__src); iVar1 = *param_3; if (0 < iVar1) { puVar7 = param_2; do { iVar2 = strcmp((char *)*puVar7,__dest); if (iVar2 == 0) { free(__dest); goto LAB_00101584; } puVar7 = puVar7 + 1; } while (param_2 + (ulong)(iVar1 - 1) + 1 != puVar7); } param_2[iVar1] = __dest; *param_3 = iVar1 + 1; LAB_00101584: sVar5 = strlen(pcVar6); } while (__n <= sVar5); local_68 = local_68 + 1; puVar7 = __ptr; } while (local_68 != __ptr + uVar4); do { puVar8 = puVar7 + 1; free((void *)*puVar7); puVar7 = puVar8; } while (puVar8 != __ptr + uVar4); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { free(__ptr); return; } } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,391
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
void func0(const char *str, char **result, int *index) { int len = strlen(str); if (len == 0) { result[*index] = strdup(""); (*index)++; return; } char **prev_list = malloc(40320 * sizeof(char *)); // 40320 = 8! maximum permutations for 8 characters int prev_index = 0; func0(str + 1, prev_list, &prev_index); int i, j, k; for (i = 0; i < prev_index; i++) { for (j = 0; j <= strlen(prev_list[i]); j++) { char *new_str = malloc((len + 1) * sizeof(char)); strncpy(new_str, prev_list[i], j); new_str[j] = str[0]; strcpy(new_str + j + 1, prev_list[i] + j); int found = 0; for (k = 0; k < *index; k++) { if (strcmp(result[k], new_str) == 0) { found = 1; break; } } if (!found) { result[*index] = new_str; (*index)++; } else { free(new_str); } } } for (i = 0; i < prev_index; i++) { free(prev_list[i]); } free(prev_list); }
int main() { char *result[100]; int index; index = 0; func0("ab", result, &index); assert(strcmp(result[0], "ab") == 0 && strcmp(result[1], "ba") == 0 && index == 2); index = 0; func0("abc", result, &index); assert(strcmp(result[0], "abc") == 0 && strcmp(result[1], "bac") == 0 && strcmp(result[2], "bca") == 0 && strcmp(result[3], "acb") == 0 && strcmp(result[4], "cab") == 0 && strcmp(result[5], "cba") == 0 && index == 6); index = 0; func0("abcd", result, &index); assert(index == 24); // Clean up allocated memory for (int i = 0; i < index; i++) { free(result[i]); } return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %rdi,0x18(%rsp) mov %rsi,0x10(%rsp) mov %rdx,0x8(%rsp) mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax callq 1100 <strlen@plt> test %eax,%eax je 162d <func0+0x1cd> mov $0x4ec00,%edi mov %rax,%rbx callq 1140 <malloc@plt> mov 0x18(%rsp),%rcx add $0x1,%ebx lea 0x44(%rsp),%rdx mov %rax,%rsi mov %rax,0x38(%rsp) lea 0x1(%rcx),%rdi movl $0x0,0x44(%rsp) callq 1460 <func0> movslq %ebx,%rax movq $0x0,0x30(%rsp) mov %rax,0x20(%rsp) mov 0x10(%rsp),%rax add $0x8,%rax mov %rax,0x28(%rsp) mov 0x44(%rsp),%eax test %eax,%eax jle 15e0 <func0+0x180> nopl 0x0(%rax) mov 0x38(%rsp),%rax mov 0x30(%rsp),%rdx xor %ebp,%ebp mov (%rax,%rdx,8),%r13 mov 0x20(%rsp),%rdi callq 1140 <malloc@plt> mov %rbp,%rdx mov %r13,%rsi mov %rax,%rdi mov %rax,%r14 callq 10e0 <strncpy@plt> mov 0x18(%rsp),%rax lea 0x0(%r13,%rbp,1),%rsi movzbl (%rax),%eax mov %al,(%r14,%rbp,1) add $0x1,%rbp lea (%r14,%rbp,1),%rdi callq 10f0 <strcpy@plt> mov 0x8(%rsp),%rax mov (%rax),%r12d test %r12d,%r12d jle 1610 <func0+0x1b0> mov 0x28(%rsp),%rcx lea -0x1(%r12),%eax mov 0x10(%rsp),%r15 lea (%rcx,%rax,8),%rbx jmp 157d <func0+0x11d> add $0x8,%r15 cmp %r15,%rbx je 1610 <func0+0x1b0> mov (%r15),%rdi mov %r14,%rsi callq 1130 <strcmp@plt> test %eax,%eax jne 1570 <func0+0x110> mov %r14,%rdi callq 10d0 <free@plt> mov %r13,%rdi callq 1100 <strlen@plt> cmp %rax,%rbp jbe 1510 <func0+0xb0> addq $0x1,0x30(%rsp) mov 0x44(%rsp),%eax mov 0x30(%rsp),%rcx cmp %ecx,%eax jg 1500 <func0+0xa0> test %eax,%eax jle 15e0 <func0+0x180> xor %ebx,%ebx nopw 0x0(%rax,%rax,1) mov 0x38(%rsp),%rax mov (%rax,%rbx,8),%rdi add $0x1,%rbx callq 10d0 <free@plt> cmp %ebx,0x44(%rsp) jg 15c8 <func0+0x168> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1670 <func0+0x210> mov 0x38(%rsp),%rdi add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 jmpq 10d0 <free@plt> nopl 0x0(%rax) mov 0x10(%rsp),%rdx movslq %r12d,%rax add $0x1,%r12d mov %r14,(%rdx,%rax,8) mov 0x8(%rsp),%rax mov %r12d,(%rax) jmpq 1594 <func0+0x134> mov 0x8(%rsp),%r14 mov 0x10(%rsp),%rcx lea 0x9ee(%rip),%rdi movslq (%r14),%rax lea (%rcx,%rax,8),%rbx callq 1150 <strdup@plt> mov %rax,(%rbx) addl $0x1,(%r14) mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1670 <func0+0x210> add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq callq 1110 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 mov r14, rsi push r13 push r12 push rbp push rbx sub rsp, 58h mov [rsp+88h+var_78], rdi mov [rsp+88h+var_88], rdx mov rax, fs:28h mov [rsp+88h+var_40], rax xor eax, eax call _strlen test eax, eax jz loc_162B mov edi, 4EC00h; size mov ebx, eax call _malloc lea rdx, [rsp+88h+var_44] mov [rsp+88h+var_44], 0 mov r13, rax mov rax, [rsp+88h+var_78] mov rsi, r13 lea rdi, [rax+1]; s call func0 movsxd rax, [rsp+88h+var_44] test eax, eax jle loc_15E2 lea rax, [r13+rax*8+0] mov [rsp+88h+var_58], r13 mov [rsp+88h+var_60], rax lea eax, [rbx+1] mov [rsp+88h+var_6C], eax mov [rsp+88h+var_50], r13 mov [rsp+88h+var_68], r13 nop dword ptr [rax] loc_14D8: mov rax, [rsp+88h+var_68] xor ebp, ebp mov r13, [rax] nop word ptr [rax+rax+00h] loc_14E8: mov rdi, r13; s call _strlen cmp rax, rbp jb loc_15A6 loc_14F9: movsxd r15, [rsp+88h+var_6C] mov rdi, r15; size call _malloc mov rdx, rbp mov rcx, r15 mov rsi, r13 mov rdi, rax mov rbx, rax call ___strncpy_chk mov rax, [rsp+88h+var_78] lea rsi, [r13+rbp+0] mov rdx, r15 movzx eax, byte ptr [rax] mov [rbx+rbp], al add rbp, 1 cmp r15, rbp lea rdi, [rbx+rbp] cmovb rdx, rbp sub rdx, rbp call ___strcpy_chk mov rax, [rsp+88h+var_88] mov edx, [rax] movsxd rsi, edx test edx, edx jle loc_1619 movsxd rsi, edx mov [rsp+88h+var_70], edx mov r12, r14 mov [rsp+88h+var_80], rsi lea r15, [r14+rsi*8] jmp short loc_157D loc_1570: add r12, 8 cmp r15, r12 jz loc_1610 loc_157D: mov rdi, [r12]; s1 mov rsi, rbx; s2 call _strcmp test eax, eax jnz short loc_1570 mov rdi, rbx; ptr call _free mov rdi, r13; s call _strlen cmp rax, rbp jnb loc_14F9 loc_15A6: add [rsp+88h+var_68], 8 mov rcx, [rsp+88h+var_60] mov rax, [rsp+88h+var_68] cmp rax, rcx jnz loc_14D8 mov r13, [rsp+88h+var_58] mov rbp, [rsp+88h+var_50] mov rbx, rcx nop dword ptr [rax+00h] loc_15D0: mov rdi, [rbp+0]; ptr add rbp, 8 call _free cmp rbp, rbx jnz short loc_15D0 loc_15E2: mov rax, [rsp+88h+var_40] sub rax, fs:28h jnz short loc_1668 add rsp, 58h mov rdi, r13; ptr pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 jmp _free loc_1610: mov edx, [rsp+88h+var_70] mov rsi, [rsp+88h+var_80] loc_1619: mov rax, [rsp+88h+var_88] lea ecx, [rdx+1] mov [r14+rsi*8], rbx mov [rax], ecx jmp loc_14E8 loc_162B: mov r15, [rsp+88h+var_88] lea rdi, aIndex24+0Bh; s movsxd rax, dword ptr [r15] lea rbx, [r14+rax*8] call _strdup mov [rbx], rax add dword ptr [r15], 1 mov rax, [rsp+88h+var_40] sub rax, fs:28h jnz short loc_1668 add rsp, 58h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1668: call ___stack_chk_fail
void func0(const char *a1, const char **a2, int *a3) { int v4; // eax int v5; // ebx const char **v6; // r13 size_t v7; // rbp const char *v8; // r13 char *v9; // rbx const char *v10; // rsi size_t v11; // rdx int v12; // edx long long v13; // rsi const char **v14; // r12 const char **v15; // r15 void **v16; // rbp void *v17; // rdi char **v18; // rbx long long v20; // [rsp+8h] [rbp-80h] int v21; // [rsp+18h] [rbp-70h] int v22; // [rsp+1Ch] [rbp-6Ch] const char **v23; // [rsp+20h] [rbp-68h] const char **v24; // [rsp+28h] [rbp-60h] const char **v25; // [rsp+30h] [rbp-58h] void **v26; // [rsp+38h] [rbp-50h] int v27; // [rsp+44h] [rbp-44h] BYREF unsigned long long v28; // [rsp+48h] [rbp-40h] v28 = __readfsqword(0x28u); v4 = strlen(a1); if ( v4 ) { v5 = v4; v27 = 0; v6 = (const char **)malloc(0x4EC00uLL); func0(a1 + 1, v6, &v27); if ( v27 > 0 ) { v25 = v6; v24 = &v6[v27]; v22 = v5 + 1; v26 = (void **)v6; v23 = v6; do { v7 = 0LL; v8 = *v23; while ( strlen(v8) >= v7 ) { while ( 2 ) { v9 = (char *)malloc(v22); __strncpy_chk(v9, v8, v7, v22); v10 = &v8[v7]; v11 = v22; v9[v7++] = *a1; if ( v22 < v7 ) v11 = v7; __strcpy_chk(&v9[v7], v10, v11 - v7); v12 = *a3; v13 = *a3; if ( *a3 > 0 ) { v21 = *a3; v14 = a2; v20 = v12; v15 = &a2[v12]; while ( strcmp(*v14, v9) ) { if ( v15 == ++v14 ) { v12 = v21; v13 = v20; goto LABEL_18; } } free(v9); if ( strlen(v8) >= v7 ) continue; goto LABEL_13; } break; } LABEL_18: a2[v13] = v9; *a3 = v12 + 1; } LABEL_13: ++v23; } while ( v23 != v24 ); v6 = v25; v16 = v26; do { v17 = *v16++; free(v17); } while ( v16 != (void **)v24 ); } free(v6); } else { v18 = (char **)&a2[*a3]; *v18 = strdup(""); ++*a3; } }
func0: ENDBR64 PUSH R15 PUSH R14 MOV R14,RSI PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x58 MOV qword ptr [RSP + 0x10],RDI MOV qword ptr [RSP],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX CALL 0x001010e0 TEST EAX,EAX JZ 0x0010162b MOV EDI,0x4ec00 MOV EBX,EAX CALL 0x00101120 LEA RDX,[RSP + 0x44] MOV dword ptr [RSP + 0x44],0x0 MOV R13,RAX MOV RAX,qword ptr [RSP + 0x10] MOV RSI,R13 LEA RDI,[RAX + 0x1] CALL 0x00101440 MOVSXD RAX,dword ptr [RSP + 0x44] TEST EAX,EAX JLE 0x001015e2 LEA RAX,[R13 + RAX*0x8] MOV qword ptr [RSP + 0x30],R13 MOV qword ptr [RSP + 0x28],RAX LEA EAX,[RBX + 0x1] MOV dword ptr [RSP + 0x1c],EAX MOV qword ptr [RSP + 0x38],R13 MOV qword ptr [RSP + 0x20],R13 NOP dword ptr [RAX] LAB_001014d8: MOV RAX,qword ptr [RSP + 0x20] XOR EBP,EBP MOV R13,qword ptr [RAX] NOP word ptr [RAX + RAX*0x1] LAB_001014e8: MOV RDI,R13 CALL 0x001010e0 CMP RAX,RBP JC 0x001015a6 LAB_001014f9: MOVSXD R15,dword ptr [RSP + 0x1c] MOV RDI,R15 CALL 0x00101120 MOV RDX,RBP MOV RCX,R15 MOV RSI,R13 MOV RDI,RAX MOV RBX,RAX CALL 0x00101130 MOV RAX,qword ptr [RSP + 0x10] LEA RSI,[R13 + RBP*0x1] MOV RDX,R15 MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBX + RBP*0x1],AL ADD RBP,0x1 CMP R15,RBP LEA RDI,[RBX + RBP*0x1] CMOVC RDX,RBP SUB RDX,RBP CALL 0x00101140 MOV RAX,qword ptr [RSP] MOV EDX,dword ptr [RAX] MOVSXD RSI,EDX TEST EDX,EDX JLE 0x00101619 MOVSXD RSI,EDX MOV dword ptr [RSP + 0x18],EDX MOV R12,R14 MOV qword ptr [RSP + 0x8],RSI LEA R15,[R14 + RSI*0x8] JMP 0x0010157d LAB_00101570: ADD R12,0x8 CMP R15,R12 JZ 0x00101610 LAB_0010157d: MOV RDI,qword ptr [R12] MOV RSI,RBX CALL 0x00101110 TEST EAX,EAX JNZ 0x00101570 MOV RDI,RBX CALL 0x001010d0 MOV RDI,R13 CALL 0x001010e0 CMP RAX,RBP JNC 0x001014f9 LAB_001015a6: ADD qword ptr [RSP + 0x20],0x8 MOV RCX,qword ptr [RSP + 0x28] MOV RAX,qword ptr [RSP + 0x20] CMP RAX,RCX JNZ 0x001014d8 MOV R13,qword ptr [RSP + 0x30] MOV RBP,qword ptr [RSP + 0x38] MOV RBX,RCX NOP dword ptr [RAX] LAB_001015d0: MOV RDI,qword ptr [RBP] ADD RBP,0x8 CALL 0x001010d0 CMP RBP,RBX JNZ 0x001015d0 LAB_001015e2: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101668 ADD RSP,0x58 MOV RDI,R13 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 JMP 0x001010d0 LAB_00101610: MOV EDX,dword ptr [RSP + 0x18] MOV RSI,qword ptr [RSP + 0x8] LAB_00101619: MOV RAX,qword ptr [RSP] LEA ECX,[RDX + 0x1] MOV qword ptr [R14 + RSI*0x8],RBX MOV dword ptr [RAX],ECX JMP 0x001014e8 LAB_0010162b: MOV R15,qword ptr [RSP] LEA RDI,[0x10204a] MOVSXD RAX,dword ptr [R15] LEA RBX,[R14 + RAX*0x8] CALL 0x00101150 MOV qword ptr [RBX],RAX ADD dword ptr [R15],0x1 MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101668 ADD RSP,0x58 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101668: CALL 0x001010f0
void func0(char *param_1,int8 *param_2,int *param_3) { char *pcVar1; int iVar2; int iVar3; size_t sVar4; int8 *__ptr; long lVar5; size_t sVar6; char *__s2; char *pcVar7; ulong uVar8; int8 *puVar9; int8 *puVar10; long in_FS_OFFSET; int8 *local_68; int local_44; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); sVar4 = strlen(param_1); if ((int)sVar4 == 0) { iVar2 = *param_3; pcVar7 = strdup(""); param_2[iVar2] = pcVar7; *param_3 = *param_3 + 1; if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return; } } else { __ptr = (int8 *)malloc(0x4ec00); local_44 = 0; func0(param_1 + 1,__ptr,&local_44); lVar5 = (long)local_44; if (0 < local_44) { local_68 = __ptr; do { uVar8 = 0; pcVar7 = (char *)*local_68; while (sVar6 = strlen(pcVar7), uVar8 <= sVar6) { while( true ) { sVar6 = (size_t)((int)sVar4 + 1); __s2 = (char *)malloc(sVar6); __strncpy_chk(__s2,pcVar7,uVar8,sVar6); pcVar1 = pcVar7 + uVar8; __s2[uVar8] = *param_1; uVar8 = uVar8 + 1; if (sVar6 < uVar8) { sVar6 = uVar8; } __strcpy_chk(__s2 + uVar8,pcVar1,sVar6 - uVar8); iVar2 = *param_3; if (iVar2 < 1) break; puVar9 = param_2; while (iVar3 = strcmp((char *)*puVar9,__s2), iVar3 != 0) { puVar9 = puVar9 + 1; if (param_2 + iVar2 == puVar9) goto LAB_00101619; } free(__s2); sVar6 = strlen(pcVar7); if (sVar6 < uVar8) goto LAB_001015a6; } LAB_00101619: param_2[iVar2] = __s2; *param_3 = iVar2 + 1; } LAB_001015a6: local_68 = local_68 + 1; puVar9 = __ptr; } while (local_68 != __ptr + lVar5); do { puVar10 = puVar9 + 1; free((void *)*puVar9); puVar9 = puVar10; } while (puVar10 != __ptr + lVar5); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { free(__ptr); return; } } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,392
func0
#include <assert.h>
int func0(int n, int m) { int a = (n / m) * m; int b = a + m; return (n - a > b - n) ? b : a; }
int main() { assert(func0(4722, 10) == 4720); assert(func0(1111, 5) == 1110); assert(func0(219, 2) == 218); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov -0x14(%rbp),%eax cltd idivl -0x18(%rbp) mov %eax,%edx mov -0x18(%rbp),%eax imul %edx,%eax mov %eax,-0x8(%rbp) mov -0x8(%rbp),%edx mov -0x18(%rbp),%eax add %edx,%eax mov %eax,-0x4(%rbp) mov -0x14(%rbp),%eax sub -0x8(%rbp),%eax mov %eax,%edx mov -0x4(%rbp),%eax sub -0x14(%rbp),%eax cmp %eax,%edx jle 118b <func0+0x42> mov -0x4(%rbp),%eax jmp 118e <func0+0x45> mov -0x8(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov [rbp+var_18], esi mov eax, [rbp+var_14] cdq idiv [rbp+var_18] mov edx, eax mov eax, [rbp+var_18] imul eax, edx mov [rbp+var_8], eax mov edx, [rbp+var_8] mov eax, [rbp+var_18] add eax, edx mov [rbp+var_4], eax mov eax, [rbp+var_14] sub eax, [rbp+var_8] mov edx, eax mov eax, [rbp+var_4] sub eax, [rbp+var_14] cmp edx, eax jle short loc_118B mov eax, [rbp+var_4] jmp short loc_118E loc_118B: mov eax, [rbp+var_8] loc_118E: pop rbp retn
long long func0(int a1, int a2) { if ( a1 % a2 <= a1 / a2 * a2 + a2 - a1 ) return (unsigned int)(a1 / a2 * a2); else return (unsigned int)(a1 / a2 * a2 + a2); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV EAX,dword ptr [RBP + -0x14] CDQ IDIV dword ptr [RBP + -0x18] MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x18] IMUL EAX,EDX MOV dword ptr [RBP + -0x8],EAX MOV EDX,dword ptr [RBP + -0x8] MOV EAX,dword ptr [RBP + -0x18] ADD EAX,EDX MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x14] SUB EAX,dword ptr [RBP + -0x8] MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x4] SUB EAX,dword ptr [RBP + -0x14] CMP EDX,EAX JLE 0x0010118b MOV EAX,dword ptr [RBP + -0x4] JMP 0x0010118e LAB_0010118b: MOV EAX,dword ptr [RBP + -0x8] LAB_0010118e: POP RBP RET
int func0(int param_1,int param_2) { int iVar1; iVar1 = param_2 * (param_1 / param_2); if ((param_2 + iVar1) - param_1 < param_1 - iVar1) { iVar1 = param_2 + iVar1; } return iVar1; }
5,393
func0
#include <assert.h>
int func0(int n, int m) { int a = (n / m) * m; int b = a + m; return (n - a > b - n) ? b : a; }
int main() { assert(func0(4722, 10) == 4720); assert(func0(1111, 5) == 1110); assert(func0(219, 2) == 218); return 0; }
O1
c
func0: endbr64 mov %edi,%eax cltd idiv %esi imul %esi,%eax mov %eax,%ecx lea (%rsi,%rax,1),%eax sub %edi,%eax add %ecx,%esi cmp %edx,%eax mov %ecx,%eax cmovl %esi,%eax retq
func0: endbr64 mov eax, edi cdq idiv esi imul eax, esi mov ecx, eax lea eax, [rsi+rax] sub eax, edi add esi, ecx cmp eax, edx mov eax, ecx cmovl eax, esi retn
long long func0(int a1, int a2) { int v2; // edx unsigned int v3; // ecx int v4; // eax unsigned int v5; // esi bool v6; // cc long long result; // rax v2 = a1 % a2; v3 = a2 * (a1 / a2); v4 = a2 + v3 - a1; v5 = v3 + a2; v6 = v4 < v2; result = v3; if ( v6 ) return v5; return result; }
func0: ENDBR64 MOV EAX,EDI CDQ IDIV ESI IMUL EAX,ESI MOV ECX,EAX LEA EAX,[RSI + RAX*0x1] SUB EAX,EDI ADD ESI,ECX CMP EAX,EDX MOV EAX,ECX CMOVL EAX,ESI RET
int func0(int param_1,int param_2) { int iVar1; iVar1 = (param_1 / param_2) * param_2; if ((param_2 + iVar1) - param_1 < param_1 % param_2) { iVar1 = param_2 + iVar1; } return iVar1; }
5,394
func0
#include <assert.h>
int func0(int n, int m) { int a = (n / m) * m; int b = a + m; return (n - a > b - n) ? b : a; }
int main() { assert(func0(4722, 10) == 4720); assert(func0(1111, 5) == 1110); assert(func0(219, 2) == 218); return 0; }
O2
c
func0: endbr64 mov %edi,%eax cltd idiv %esi imul %esi,%eax mov %eax,%ecx lea (%rsi,%rax,1),%eax mov %eax,%esi sub %edi,%esi cmp %edx,%esi cmovge %ecx,%eax retq nopl 0x0(%rax,%rax,1)
func0: endbr64 mov eax, edi cdq idiv esi imul eax, esi mov ecx, eax lea eax, [rsi+rax] mov esi, eax sub esi, edi cmp esi, edx cmovge eax, ecx retn
long long func0(int a1, int a2) { unsigned int v2; // ecx long long result; // rax v2 = a2 * (a1 / a2); result = a2 + v2; if ( (int)(a2 + v2 - a1) >= a1 % a2 ) return v2; return result; }
func0: ENDBR64 MOV EAX,EDI CDQ IDIV ESI IMUL EAX,ESI MOV ECX,EAX LEA EAX,[RSI + RAX*0x1] MOV ESI,EAX SUB ESI,EDI CMP ESI,EDX CMOVGE EAX,ECX RET
int func0(int param_1,int param_2) { int iVar1; int iVar2; iVar2 = (param_1 / param_2) * param_2; iVar1 = param_2 + iVar2; if (param_1 % param_2 <= iVar1 - param_1) { iVar1 = iVar2; } return iVar1; }
5,395
func0
#include <assert.h>
int func0(int n, int m) { int a = (n / m) * m; int b = a + m; return (n - a > b - n) ? b : a; }
int main() { assert(func0(4722, 10) == 4720); assert(func0(1111, 5) == 1110); assert(func0(219, 2) == 218); return 0; }
O3
c
func0: endbr64 mov %edi,%eax cltd idiv %esi imul %esi,%eax mov %eax,%ecx lea (%rsi,%rax,1),%eax mov %eax,%esi sub %edi,%esi cmp %edx,%esi cmovge %ecx,%eax retq nopl 0x0(%rax,%rax,1)
func0: endbr64 mov eax, edi cdq idiv esi imul eax, esi add esi, eax mov ecx, esi sub ecx, edi cmp ecx, edx cmovl eax, esi retn
long long func0(int a1, int a2) { int v2; // edx long long result; // rax unsigned int v4; // esi v2 = a1 % a2; result = (unsigned int)(a2 * (a1 / a2)); v4 = result + a2; if ( (int)(v4 - a1) < v2 ) return v4; return result; }
func0: ENDBR64 MOV EAX,EDI CDQ IDIV ESI IMUL EAX,ESI ADD ESI,EAX MOV ECX,ESI SUB ECX,EDI CMP ECX,EDX CMOVL EAX,ESI RET
int func0(int param_1,int param_2) { int iVar1; int iVar2; iVar1 = (param_1 / param_2) * param_2; iVar2 = param_2 + iVar1; if (iVar2 - param_1 < param_1 % param_2) { iVar1 = iVar2; } return iVar1; }
5,396
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h> #include <stdlib.h> typedef struct { int *arr; int length; } Tuple;
Tuple func0(Tuple test_tup) { bool found[256] = {false}; // Assuming numbers in tuple are within 0-255 Tuple res; res.arr = (int*)malloc(test_tup.length * sizeof(int)); res.length = test_tup.length; for (int i = 0; i < test_tup.length; i++) { int ele = test_tup.arr[i]; if (!found[ele]) { res.arr[i] = ele; found[ele] = true; } else { res.arr[i] = -1; // -1 will represent 'MSP' } } return res; }
int main() { Tuple tuple1 = { (int[]){1, 1, 4, 4, 4, 5, 5, 6, 7, 7}, 10 }; Tuple res1 = func0(tuple1); int expected1[10] = {1, -1, 4, -1, -1, 5, -1, 6, 7, -1}; for (int i = 0; i < 10; i++) { assert(res1.arr[i] == expected1[i]); } Tuple tuple2 = { (int[]){2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9}, 11 }; Tuple res2 = func0(tuple2); int expected2[11] = {2, 3, 4, -1, 5, 6, -1, 7, 8, 9, -1}; for (int i = 0; i < 11; i++) { assert(res2.arr[i] == expected2[i]); } Tuple tuple3 = { (int[]){2, 2, 5, 4, 5, 7, 5, 6, 7, 7}, 10 }; Tuple res3 = func0(tuple3); int expected3[10] = {2, -1, 5, 4, -1, 7, -1, 6, -1, -1}; for (int i = 0; i < 10; i++) { assert(res3.arr[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x140,%rsp mov %rdi,%rax mov %rsi,%rcx mov %rcx,%rdx mov %rax,-0x140(%rbp) mov %rdx,-0x138(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea -0x110(%rbp),%rdx mov $0x0,%eax mov $0x20,%ecx mov %rdx,%rdi rep stos %rax,%es:(%rdi) mov -0x138(%rbp),%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x120(%rbp) mov -0x138(%rbp),%eax mov %eax,-0x118(%rbp) movl $0x0,-0x128(%rbp) jmpq 12b6 <func0+0x10d> mov -0x140(%rbp),%rax mov -0x128(%rbp),%edx movslq %edx,%rdx shl $0x2,%rdx add %rdx,%rax mov (%rax),%eax mov %eax,-0x124(%rbp) mov -0x124(%rbp),%eax cltq movzbl -0x110(%rbp,%rax,1),%eax xor $0x1,%eax test %al,%al je 1292 <func0+0xe9> mov -0x120(%rbp),%rax mov -0x128(%rbp),%edx movslq %edx,%rdx shl $0x2,%rdx add %rax,%rdx mov -0x124(%rbp),%eax mov %eax,(%rdx) mov -0x124(%rbp),%eax cltq movb $0x1,-0x110(%rbp,%rax,1) jmp 12af <func0+0x106> mov -0x120(%rbp),%rax mov -0x128(%rbp),%edx movslq %edx,%rdx shl $0x2,%rdx add %rdx,%rax movl $0xffffffff,(%rax) addl $0x1,-0x128(%rbp) mov -0x138(%rbp),%eax cmp %eax,-0x128(%rbp) jl 122b <func0+0x82> mov -0x120(%rbp),%rax mov -0x118(%rbp),%rdx mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi je 12ea <func0+0x141> callq 1090 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 140h mov rax, rdi mov rcx, rsi mov rdx, rcx mov [rbp+var_140], rax mov [rbp+var_138], rdx mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rdx, [rbp+var_110] mov eax, 0 mov ecx, 20h ; ' ' mov rdi, rdx rep stosq mov eax, dword ptr [rbp+var_138] cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_120], rax mov eax, dword ptr [rbp+var_138] mov dword ptr [rbp+var_118], eax mov [rbp+var_128], 0 jmp loc_12B6 loc_122B: mov rax, [rbp+var_140] mov edx, [rbp+var_128] movsxd rdx, edx shl rdx, 2 add rax, rdx mov eax, [rax] mov [rbp+var_124], eax mov eax, [rbp+var_124] cdqe movzx eax, [rbp+rax+var_110] xor eax, 1 test al, al jz short loc_1292 mov rax, [rbp+var_120] mov edx, [rbp+var_128] movsxd rdx, edx shl rdx, 2 add rdx, rax mov eax, [rbp+var_124] mov [rdx], eax mov eax, [rbp+var_124] cdqe mov [rbp+rax+var_110], 1 jmp short loc_12AF loc_1292: mov rax, [rbp+var_120] mov edx, [rbp+var_128] movsxd rdx, edx shl rdx, 2 add rax, rdx mov dword ptr [rax], 0FFFFFFFFh loc_12AF: add [rbp+var_128], 1 loc_12B6: mov eax, dword ptr [rbp+var_138] cmp [rbp+var_128], eax jl loc_122B mov rax, [rbp+var_120] mov rdx, [rbp+var_118] mov rcx, [rbp+var_8] sub rcx, fs:28h jz short locret_12EA call ___stack_chk_fail locret_12EA: leave retn
_DWORD * func0(long long a1, int a2) { int i; // [rsp+18h] [rbp-128h] int v4; // [rsp+1Ch] [rbp-124h] _DWORD *v5; // [rsp+20h] [rbp-120h] _BYTE v6[264]; // [rsp+30h] [rbp-110h] BYREF unsigned long long v7; // [rsp+138h] [rbp-8h] v7 = __readfsqword(0x28u); memset(v6, 0, 0x100uLL); v5 = malloc(4LL * a2); for ( i = 0; i < a2; ++i ) { v4 = *(_DWORD *)(4LL * i + a1); if ( v6[v4] != 1 ) { v5[i] = v4; v6[v4] = 1; } else { v5[i] = -1; } } return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x140 MOV RAX,RDI MOV RCX,RSI MOV RDX,RCX MOV qword ptr [RBP + -0x140],RAX MOV qword ptr [RBP + -0x138],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RDX,[RBP + -0x110] MOV EAX,0x0 MOV ECX,0x20 MOV RDI,RDX STOSQ.REP RDI MOV EAX,dword ptr [RBP + -0x138] CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x120],RAX MOV EAX,dword ptr [RBP + -0x138] MOV dword ptr [RBP + -0x118],EAX MOV dword ptr [RBP + -0x128],0x0 JMP 0x001012b6 LAB_0010122b: MOV RAX,qword ptr [RBP + -0x140] MOV EDX,dword ptr [RBP + -0x128] MOVSXD RDX,EDX SHL RDX,0x2 ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x124],EAX MOV EAX,dword ptr [RBP + -0x124] CDQE MOVZX EAX,byte ptr [RBP + RAX*0x1 + -0x110] XOR EAX,0x1 TEST AL,AL JZ 0x00101292 MOV RAX,qword ptr [RBP + -0x120] MOV EDX,dword ptr [RBP + -0x128] MOVSXD RDX,EDX SHL RDX,0x2 ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x124] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x124] CDQE MOV byte ptr [RBP + RAX*0x1 + -0x110],0x1 JMP 0x001012af LAB_00101292: MOV RAX,qword ptr [RBP + -0x120] MOV EDX,dword ptr [RBP + -0x128] MOVSXD RDX,EDX SHL RDX,0x2 ADD RAX,RDX MOV dword ptr [RAX],0xffffffff LAB_001012af: ADD dword ptr [RBP + -0x128],0x1 LAB_001012b6: MOV EAX,dword ptr [RBP + -0x138] CMP dword ptr [RBP + -0x128],EAX JL 0x0010122b MOV RAX,qword ptr [RBP + -0x120] MOV RDX,qword ptr [RBP + -0x118] MOV RCX,qword ptr [RBP + -0x8] SUB RCX,qword ptr FS:[0x28] JZ 0x001012ea CALL 0x00101090 LAB_001012ea: LEAVE RET
void * func0(long param_1,int param_2) { int iVar1; void *pvVar2; long lVar3; char *pcVar4; long in_FS_OFFSET; int local_130; char local_118 [264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); pcVar4 = local_118; for (lVar3 = 0x20; lVar3 != 0; lVar3 = lVar3 + -1) { pcVar4[0] = '\0'; pcVar4[1] = '\0'; pcVar4[2] = '\0'; pcVar4[3] = '\0'; pcVar4[4] = '\0'; pcVar4[5] = '\0'; pcVar4[6] = '\0'; pcVar4[7] = '\0'; pcVar4 = pcVar4 + 8; } pvVar2 = malloc((long)param_2 << 2); for (local_130 = 0; local_130 < param_2; local_130 = local_130 + 1) { iVar1 = *(int *)(param_1 + (long)local_130 * 4); if (local_118[iVar1] == '\x01') { *(int4 *)((long)pvVar2 + (long)local_130 * 4) = 0xffffffff; } else { *(int *)((long)local_130 * 4 + (long)pvVar2) = iVar1; local_118[iVar1] = '\x01'; } } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return pvVar2; }
5,397
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h> #include <stdlib.h> typedef struct { int *arr; int length; } Tuple;
Tuple func0(Tuple test_tup) { bool found[256] = {false}; // Assuming numbers in tuple are within 0-255 Tuple res; res.arr = (int*)malloc(test_tup.length * sizeof(int)); res.length = test_tup.length; for (int i = 0; i < test_tup.length; i++) { int ele = test_tup.arr[i]; if (!found[ele]) { res.arr[i] = ele; found[ele] = true; } else { res.arr[i] = -1; // -1 will represent 'MSP' } } return res; }
int main() { Tuple tuple1 = { (int[]){1, 1, 4, 4, 4, 5, 5, 6, 7, 7}, 10 }; Tuple res1 = func0(tuple1); int expected1[10] = {1, -1, 4, -1, -1, 5, -1, 6, 7, -1}; for (int i = 0; i < 10; i++) { assert(res1.arr[i] == expected1[i]); } Tuple tuple2 = { (int[]){2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9}, 11 }; Tuple res2 = func0(tuple2); int expected2[11] = {2, 3, 4, -1, 5, 6, -1, 7, 8, 9, -1}; for (int i = 0; i < 11; i++) { assert(res2.arr[i] == expected2[i]); } Tuple tuple3 = { (int[]){2, 2, 5, 4, 5, 7, 5, 6, 7, 7}, 10 }; Tuple res3 = func0(tuple3); int expected3[10] = {2, -1, 5, 4, -1, 7, -1, 6, -1, -1}; for (int i = 0; i < 10; i++) { assert(res3.arr[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0x118,%rsp mov %rdi,%rbp mov %rsi,%rbx mov %fs:0x28,%rax mov %rax,0x108(%rsp) xor %eax,%eax mov %rsp,%rdi mov $0x20,%ecx rep stos %rax,%es:(%rdi) movslq %esi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> test %ebx,%ebx jle 1220 <func0+0x77> mov %rbp,%rdi lea -0x1(%rbx),%r8d mov $0x0,%edx jmp 120b <func0+0x62> movl $0xffffffff,(%rax,%rdx,4) lea 0x1(%rdx),%rcx cmp %r8,%rdx je 1220 <func0+0x77> mov %rcx,%rdx mov (%rdi,%rdx,4),%ecx movslq %ecx,%rsi cmpb $0x0,(%rsp,%rsi,1) jne 11f8 <func0+0x4f> mov %ecx,(%rax,%rdx,4) movb $0x1,(%rsp,%rsi,1) jmp 11ff <func0+0x56> mov %ebx,%edx mov 0x108(%rsp),%rbx xor %fs:0x28,%rbx jne 123f <func0+0x96> add $0x118,%rsp pop %rbx pop %rbp retq callq 1090 <__stack_chk_fail@plt>
func0: endbr64 push rbp push rbx sub rsp, 118h mov rbx, rdi mov rbp, rsi mov rax, fs:28h mov [rsp+128h+var_20], rax xor eax, eax mov rdi, rsp mov ecx, 20h ; ' ' rep stosq movsxd rdi, esi shl rdi, 2 call _malloc test ebp, ebp jle short loc_1218 mov edi, ebp mov edx, 0 jmp short loc_1203 loc_11F3: mov dword ptr [rax+rdx*4], 0FFFFFFFFh loc_11FA: add rdx, 1 cmp rdx, rdi jz short loc_1218 loc_1203: mov ecx, [rbx+rdx*4] movsxd rsi, ecx cmp [rsp+rsi+128h+var_128], 0 jnz short loc_11F3 mov [rax+rdx*4], ecx mov [rsp+rsi+128h+var_128], 1 jmp short loc_11FA loc_1218: mov edx, ebp mov rcx, [rsp+128h+var_20] sub rcx, fs:28h jnz short loc_1237 add rsp, 118h pop rbx pop rbp retn loc_1237: call ___stack_chk_fail
long long func0(long long a1, int a2) { long long result; // rax long long i; // rdx int v4; // ecx _BYTE v5[264]; // [rsp+0h] [rbp-128h] BYREF unsigned long long v6; // [rsp+108h] [rbp-20h] v6 = __readfsqword(0x28u); memset(v5, 0, 0x100uLL); result = malloc(4LL * a2); if ( a2 > 0 ) { for ( i = 0LL; i != a2; ++i ) { v4 = *(_DWORD *)(a1 + 4 * i); if ( v5[v4] ) { *(_DWORD *)(result + 4 * i) = -1; } else { *(_DWORD *)(result + 4 * i) = v4; v5[v4] = 1; } } } return result; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x118 MOV RBX,RDI MOV RBP,RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x108],RAX XOR EAX,EAX MOV RDI,RSP MOV ECX,0x20 STOSQ.REP RDI MOVSXD RDI,ESI SHL RDI,0x2 CALL 0x001010b0 TEST EBP,EBP JLE 0x00101218 MOV EDI,EBP MOV EDX,0x0 JMP 0x00101203 LAB_001011f3: MOV dword ptr [RAX + RDX*0x4],0xffffffff LAB_001011fa: ADD RDX,0x1 CMP RDX,RDI JZ 0x00101218 LAB_00101203: MOV ECX,dword ptr [RBX + RDX*0x4] MOVSXD RSI,ECX CMP byte ptr [RSP + RSI*0x1],0x0 JNZ 0x001011f3 MOV dword ptr [RAX + RDX*0x4],ECX MOV byte ptr [RSP + RSI*0x1],0x1 JMP 0x001011fa LAB_00101218: MOV EDX,EBP MOV RCX,qword ptr [RSP + 0x108] SUB RCX,qword ptr FS:[0x28] JNZ 0x00101237 ADD RSP,0x118 POP RBX POP RBP RET LAB_00101237: CALL 0x00101090
void func0(long param_1,uint param_2) { int iVar1; void *pvVar2; long lVar3; ulong uVar4; char *pcVar5; long in_FS_OFFSET; char acStack_128 [264]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); pcVar5 = acStack_128; for (lVar3 = 0x20; lVar3 != 0; lVar3 = lVar3 + -1) { *(int8 *)pcVar5 = 0; pcVar5 = (char *)((long)pcVar5 + 8); } pvVar2 = malloc((long)(int)param_2 << 2); if (0 < (int)param_2) { uVar4 = 0; do { iVar1 = *(int *)(param_1 + uVar4 * 4); if (acStack_128[iVar1] == '\0') { *(int *)((long)pvVar2 + uVar4 * 4) = iVar1; acStack_128[iVar1] = '\x01'; } else { *(int4 *)((long)pvVar2 + uVar4 * 4) = 0xffffffff; } uVar4 = uVar4 + 1; } while (uVar4 != param_2); } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,398
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h> #include <stdlib.h> typedef struct { int *arr; int length; } Tuple;
Tuple func0(Tuple test_tup) { bool found[256] = {false}; // Assuming numbers in tuple are within 0-255 Tuple res; res.arr = (int*)malloc(test_tup.length * sizeof(int)); res.length = test_tup.length; for (int i = 0; i < test_tup.length; i++) { int ele = test_tup.arr[i]; if (!found[ele]) { res.arr[i] = ele; found[ele] = true; } else { res.arr[i] = -1; // -1 will represent 'MSP' } } return res; }
int main() { Tuple tuple1 = { (int[]){1, 1, 4, 4, 4, 5, 5, 6, 7, 7}, 10 }; Tuple res1 = func0(tuple1); int expected1[10] = {1, -1, 4, -1, -1, 5, -1, 6, 7, -1}; for (int i = 0; i < 10; i++) { assert(res1.arr[i] == expected1[i]); } Tuple tuple2 = { (int[]){2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9}, 11 }; Tuple res2 = func0(tuple2); int expected2[11] = {2, 3, 4, -1, 5, 6, -1, 7, 8, 9, -1}; for (int i = 0; i < 11; i++) { assert(res2.arr[i] == expected2[i]); } Tuple tuple3 = { (int[]){2, 2, 5, 4, 5, 7, 5, 6, 7, 7}, 10 }; Tuple res3 = func0(tuple3); int expected3[10] = {2, -1, 5, 4, -1, 7, -1, 6, -1, -1}; for (int i = 0; i < 10; i++) { assert(res3.arr[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O2
c
func0: endbr64 push %rbp mov $0x20,%ecx mov %rsi,%rbp push %rbx mov %rdi,%rbx sub $0x118,%rsp mov %fs:0x28,%rax mov %rax,0x108(%rsp) xor %eax,%eax mov %rsp,%rdi rep stos %rax,%es:(%rdi) movslq %esi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> lea -0x1(%rbp),%r9d xor %ecx,%ecx test %ebp,%ebp jg 1543 <func0+0x63> jmp 155d <func0+0x7d> nopl 0x0(%rax) mov %edi,(%rax,%rcx,4) movb $0x1,(%rsp,%rdi,1) lea 0x1(%rcx),%rdi cmp %rcx,%r9 je 155d <func0+0x7d> mov %rdi,%rcx movslq (%rbx,%rcx,4),%rdi cmpb $0x0,(%rsp,%rdi,1) je 1530 <func0+0x50> movl $0xffffffff,(%rax,%rcx,4) lea 0x1(%rcx),%rdi cmp %rcx,%r9 jne 1540 <func0+0x60> mov 0x108(%rsp),%rsi xor %fs:0x28,%rsi mov %ebp,%edx jne 157c <func0+0x9c> add $0x118,%rsp pop %rbx pop %rbp retq callq 1090 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
func0: endbr64 push r12 mov ecx, 20h ; ' ' mov r12, rsi push rbp movsxd rbp, esi push rbx mov rbx, rdi sub rsp, 110h mov rax, fs:28h mov [rsp+128h+var_20], rax xor eax, eax mov rdi, rsp rep stosq lea rdi, ds:0[rbp*4] call _malloc xor ecx, ecx test r12d, r12d jg short loc_1540 jmp short loc_155A loc_1530: mov [rax+rcx*4], esi add rcx, 1 mov [rsp+rsi+128h+var_128], 1 cmp rbp, rcx jz short loc_155A loc_1540: movsxd rsi, dword ptr [rbx+rcx*4] cmp [rsp+rsi+128h+var_128], 0 jz short loc_1530 mov dword ptr [rax+rcx*4], 0FFFFFFFFh add rcx, 1 cmp rbp, rcx jnz short loc_1540 loc_155A: mov edx, r12d mov rcx, [rsp+128h+var_20] sub rcx, fs:28h jnz short loc_157C add rsp, 110h pop rbx pop rbp pop r12 retn loc_157C: call ___stack_chk_fail
long long func0(long long a1, int a2) { long long v2; // rbp long long result; // rax long long v4; // rcx long long v5; // rsi _BYTE v6[264]; // [rsp+0h] [rbp-128h] BYREF unsigned long long v7; // [rsp+108h] [rbp-20h] v2 = a2; v7 = __readfsqword(0x28u); memset(v6, 0, 0x100uLL); result = malloc(4LL * a2); v4 = 0LL; if ( a2 > 0 ) { do { while ( 1 ) { v5 = *(int *)(a1 + 4 * v4); if ( v6[v5] ) break; *(_DWORD *)(result + 4 * v4++) = v5; v6[v5] = 1; if ( v2 == v4 ) return result; } *(_DWORD *)(result + 4 * v4++) = -1; } while ( v2 != v4 ); } return result; }
func0: ENDBR64 PUSH R12 MOV ECX,0x20 MOV R12,RSI PUSH RBP MOVSXD RBP,ESI PUSH RBX MOV RBX,RDI SUB RSP,0x110 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x108],RAX XOR EAX,EAX MOV RDI,RSP STOSQ.REP RDI LEA RDI,[RBP*0x4] CALL 0x001010b0 XOR ECX,ECX TEST R12D,R12D JG 0x00101540 JMP 0x0010155a LAB_00101530: MOV dword ptr [RAX + RCX*0x4],ESI ADD RCX,0x1 MOV byte ptr [RSP + RSI*0x1],0x1 CMP RBP,RCX JZ 0x0010155a LAB_00101540: MOVSXD RSI,dword ptr [RBX + RCX*0x4] CMP byte ptr [RSP + RSI*0x1],0x0 JZ 0x00101530 MOV dword ptr [RAX + RCX*0x4],0xffffffff ADD RCX,0x1 CMP RBP,RCX JNZ 0x00101540 LAB_0010155a: MOV EDX,R12D MOV RCX,qword ptr [RSP + 0x108] SUB RCX,qword ptr FS:[0x28] JNZ 0x0010157c ADD RSP,0x110 POP RBX POP RBP POP R12 RET LAB_0010157c: CALL 0x00101090
void func0(long param_1,int param_2) { int iVar1; void *pvVar2; long lVar3; long lVar4; char *pcVar5; long in_FS_OFFSET; char acStack_128 [264]; long local_20; lVar4 = (long)param_2; local_20 = *(long *)(in_FS_OFFSET + 0x28); pcVar5 = acStack_128; for (lVar3 = 0x20; lVar3 != 0; lVar3 = lVar3 + -1) { *(int8 *)pcVar5 = 0; pcVar5 = (char *)((long)pcVar5 + 8); } pvVar2 = malloc(lVar4 * 4); lVar3 = 0; if (0 < param_2) { do { while( true ) { iVar1 = *(int *)(param_1 + lVar3 * 4); if (acStack_128[iVar1] == '\0') break; *(int4 *)((long)pvVar2 + lVar3 * 4) = 0xffffffff; lVar3 = lVar3 + 1; if (lVar4 == lVar3) goto LAB_0010155a; } *(int *)((long)pvVar2 + lVar3 * 4) = iVar1; lVar3 = lVar3 + 1; acStack_128[iVar1] = '\x01'; } while (lVar4 != lVar3); } LAB_0010155a: if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
5,399
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h> #include <stdlib.h> typedef struct { int *arr; int length; } Tuple;
Tuple func0(Tuple test_tup) { bool found[256] = {false}; // Assuming numbers in tuple are within 0-255 Tuple res; res.arr = (int*)malloc(test_tup.length * sizeof(int)); res.length = test_tup.length; for (int i = 0; i < test_tup.length; i++) { int ele = test_tup.arr[i]; if (!found[ele]) { res.arr[i] = ele; found[ele] = true; } else { res.arr[i] = -1; // -1 will represent 'MSP' } } return res; }
int main() { Tuple tuple1 = { (int[]){1, 1, 4, 4, 4, 5, 5, 6, 7, 7}, 10 }; Tuple res1 = func0(tuple1); int expected1[10] = {1, -1, 4, -1, -1, 5, -1, 6, 7, -1}; for (int i = 0; i < 10; i++) { assert(res1.arr[i] == expected1[i]); } Tuple tuple2 = { (int[]){2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9}, 11 }; Tuple res2 = func0(tuple2); int expected2[11] = {2, 3, 4, -1, 5, 6, -1, 7, 8, 9, -1}; for (int i = 0; i < 11; i++) { assert(res2.arr[i] == expected2[i]); } Tuple tuple3 = { (int[]){2, 2, 5, 4, 5, 7, 5, 6, 7, 7}, 10 }; Tuple res3 = func0(tuple3); int expected3[10] = {2, -1, 5, 4, -1, 7, -1, 6, -1, -1}; for (int i = 0; i < 10; i++) { assert(res3.arr[i] == expected3[i]); } printf("All tests passed!\n"); return 0; }
O3
c
func0: endbr64 push %rbp mov $0x20,%ecx mov %rsi,%rbp push %rbx mov %rdi,%rbx sub $0x118,%rsp mov %fs:0x28,%rax mov %rax,0x108(%rsp) xor %eax,%eax mov %rsp,%rdi rep stos %rax,%es:(%rdi) movslq %esi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> lea -0x1(%rbp),%r9d xor %ecx,%ecx test %ebp,%ebp jg 15a3 <func0+0x63> jmp 15bd <func0+0x7d> nopl 0x0(%rax) mov %edi,(%rax,%rcx,4) movb $0x1,(%rsp,%rdi,1) lea 0x1(%rcx),%rdi cmp %rcx,%r9 je 15bd <func0+0x7d> mov %rdi,%rcx movslq (%rbx,%rcx,4),%rdi cmpb $0x0,(%rsp,%rdi,1) je 1590 <func0+0x50> movl $0xffffffff,(%rax,%rcx,4) lea 0x1(%rcx),%rdi cmp %rcx,%r9 jne 15a0 <func0+0x60> mov 0x108(%rsp),%rsi xor %fs:0x28,%rsi mov %ebp,%edx jne 15dc <func0+0x9c> add $0x118,%rsp pop %rbx pop %rbp retq callq 1090 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
func0: endbr64 push r12 mov ecx, 20h ; ' ' mov r12, rsi push rbp mov rbp, rdi push rbx movsxd rbx, esi shl rbx, 2 sub rsp, 110h mov rax, fs:28h mov [rsp+128h+var_20], rax xor eax, eax mov rdi, rsp rep stosq mov rdi, rbx; size call _malloc xor ecx, ecx test r12d, r12d jg short loc_1490 jmp short loc_14AB loc_1480: mov [rax+rcx], esi add rcx, 4 mov [rsp+rsi+128h+var_128], 1 cmp rbx, rcx jz short loc_14AB loc_1490: movsxd rsi, dword ptr [rbp+rcx+0] cmp [rsp+rsi+128h+var_128], 0 jz short loc_1480 mov dword ptr [rax+rcx], 0FFFFFFFFh add rcx, 4 cmp rbx, rcx jnz short loc_1490 loc_14AB: mov edx, r12d mov rcx, [rsp+128h+var_20] sub rcx, fs:28h jnz short loc_14CD add rsp, 110h pop rbx pop rbp pop r12 retn loc_14CD: call ___stack_chk_fail
char * func0(long long a1, int a2) { size_t v2; // rbx char *result; // rax long long v4; // rcx long long v5; // rsi _BYTE v6[264]; // [rsp+0h] [rbp-128h] BYREF unsigned long long v7; // [rsp+108h] [rbp-20h] v2 = 4LL * a2; v7 = __readfsqword(0x28u); memset(v6, 0, 0x100uLL); result = (char *)malloc(v2); v4 = 0LL; if ( a2 > 0 ) { do { while ( 1 ) { v5 = *(int *)(a1 + v4); if ( v6[v5] ) break; *(_DWORD *)&result[v4] = v5; v4 += 4LL; v6[v5] = 1; if ( v2 == v4 ) return result; } *(_DWORD *)&result[v4] = -1; v4 += 4LL; } while ( v2 != v4 ); } return result; }
func0: ENDBR64 PUSH R12 MOV ECX,0x20 MOV R12,RSI PUSH RBP MOV RBP,RDI PUSH RBX MOVSXD RBX,ESI SHL RBX,0x2 SUB RSP,0x110 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x108],RAX XOR EAX,EAX MOV RDI,RSP STOSQ.REP RDI MOV RDI,RBX CALL 0x001010b0 XOR ECX,ECX TEST R12D,R12D JG 0x00101490 JMP 0x001014ab LAB_00101480: MOV dword ptr [RAX + RCX*0x1],ESI ADD RCX,0x4 MOV byte ptr [RSP + RSI*0x1],0x1 CMP RBX,RCX JZ 0x001014ab LAB_00101490: MOVSXD RSI,dword ptr [RBP + RCX*0x1] CMP byte ptr [RSP + RSI*0x1],0x0 JZ 0x00101480 MOV dword ptr [RAX + RCX*0x1],0xffffffff ADD RCX,0x4 CMP RBX,RCX JNZ 0x00101490 LAB_001014ab: MOV EDX,R12D MOV RCX,qword ptr [RSP + 0x108] SUB RCX,qword ptr FS:[0x28] JNZ 0x001014cd ADD RSP,0x110 POP RBX POP RBP POP R12 RET LAB_001014cd: CALL 0x00101090
void func0(long param_1,int param_2) { int iVar1; void *pvVar2; long lVar3; size_t sVar4; size_t __size; char *pcVar5; long in_FS_OFFSET; char acStack_128 [264]; long local_20; __size = (long)param_2 * 4; local_20 = *(long *)(in_FS_OFFSET + 0x28); pcVar5 = acStack_128; for (lVar3 = 0x20; lVar3 != 0; lVar3 = lVar3 + -1) { *(int8 *)pcVar5 = 0; pcVar5 = (char *)((long)pcVar5 + 8); } pvVar2 = malloc(__size); sVar4 = 0; if (0 < param_2) { do { while( true ) { iVar1 = *(int *)(param_1 + sVar4); if (acStack_128[iVar1] == '\0') break; *(int4 *)((long)pvVar2 + sVar4) = 0xffffffff; sVar4 = sVar4 + 4; if (__size == sVar4) goto LAB_001014ab; } *(int *)((long)pvVar2 + sVar4) = iVar1; sVar4 = sVar4 + 4; acStack_128[iVar1] = '\x01'; } while (__size != sVar4); } LAB_001014ab: if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return; }
5,400
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(char* s, char c) { int counts = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] == c) { counts++; } } char* result = (char*)malloc(strlen(s) - counts + 1); int j = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] != c) { result[j] = s[i]; j++; } } result[j] = '\0'; return result; }
int main() { assert(strcmp(func0("aba", 'a'), "b") == 0); assert(strcmp(func0("toggle", 'g'), "tole") == 0); assert(strcmp(func0("aabbc", 'b'), "aac") == 0); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x28(%rbp) mov %esi,%eax mov %al,-0x2c(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) jmp 11eb <func0+0x42> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp %al,-0x2c(%rbp) jne 11e7 <func0+0x3e> addl $0x1,-0x18(%rbp) addl $0x1,-0x14(%rbp) mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax test %al,%al jne 11ce <func0+0x25> mov -0x28(%rbp),%rax mov %rax,%rdi callq 1080 <strlen@plt> mov -0x18(%rbp),%edx movslq %edx,%rdx sub %rdx,%rax add $0x1,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) movl $0x0,-0x10(%rbp) movl $0x0,-0xc(%rbp) jmp 1270 <func0+0xc7> mov -0xc(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp %al,-0x2c(%rbp) je 126c <func0+0xc3> mov -0xc(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov -0x10(%rbp),%edx movslq %edx,%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx movzbl (%rax),%eax mov %al,(%rdx) addl $0x1,-0x10(%rbp) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax test %al,%al jne 1234 <func0+0x8b> mov -0x10(%rbp),%eax movslq %eax,%rdx mov -0x8(%rbp),%rax add %rdx,%rax movb $0x0,(%rax) mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+s], rdi mov eax, esi mov [rbp+var_2C], al mov [rbp+var_18], 0 mov [rbp+var_14], 0 jmp short loc_11EB loc_11CE: mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp [rbp+var_2C], al jnz short loc_11E7 add [rbp+var_18], 1 loc_11E7: add [rbp+var_14], 1 loc_11EB: mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] test al, al jnz short loc_11CE mov rax, [rbp+s] mov rdi, rax; s call _strlen mov rdx, rax mov eax, [rbp+var_18] cdqe sub rdx, rax lea rax, [rdx+1] mov rdi, rax; size call _malloc mov [rbp+var_8], rax mov [rbp+var_10], 0 mov [rbp+var_C], 0 jmp short loc_1272 loc_1236: mov eax, [rbp+var_C] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp [rbp+var_2C], al jz short loc_126E mov eax, [rbp+var_C] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx mov edx, [rbp+var_10] movsxd rcx, edx mov rdx, [rbp+var_8] add rdx, rcx movzx eax, byte ptr [rax] mov [rdx], al add [rbp+var_10], 1 loc_126E: add [rbp+var_C], 1 loc_1272: mov eax, [rbp+var_C] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] test al, al jnz short loc_1236 mov eax, [rbp+var_10] movsxd rdx, eax mov rax, [rbp+var_8] add rax, rdx mov byte ptr [rax], 0 mov rax, [rbp+var_8] leave retn
_BYTE * func0(const char *a1, char a2) { size_t v2; // rax int v4; // [rsp+18h] [rbp-18h] int i; // [rsp+1Ch] [rbp-14h] int v6; // [rsp+20h] [rbp-10h] int j; // [rsp+24h] [rbp-Ch] _BYTE *v8; // [rsp+28h] [rbp-8h] v4 = 0; for ( i = 0; a1[i]; ++i ) { if ( a2 == a1[i] ) ++v4; } v2 = strlen(a1); v8 = malloc(v2 - v4 + 1); v6 = 0; for ( j = 0; a1[j]; ++j ) { if ( a2 != a1[j] ) v8[v6++] = a1[j]; } v8[v6] = 0; return v8; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x28],RDI MOV EAX,ESI MOV byte ptr [RBP + -0x2c],AL MOV dword ptr [RBP + -0x18],0x0 MOV dword ptr [RBP + -0x14],0x0 JMP 0x001011eb LAB_001011ce: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP byte ptr [RBP + -0x2c],AL JNZ 0x001011e7 ADD dword ptr [RBP + -0x18],0x1 LAB_001011e7: ADD dword ptr [RBP + -0x14],0x1 LAB_001011eb: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] TEST AL,AL JNZ 0x001011ce MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x00101080 MOV RDX,RAX MOV EAX,dword ptr [RBP + -0x18] CDQE SUB RDX,RAX LEA RAX,[RDX + 0x1] MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX MOV dword ptr [RBP + -0x10],0x0 MOV dword ptr [RBP + -0xc],0x0 JMP 0x00101272 LAB_00101236: MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP byte ptr [RBP + -0x2c],AL JZ 0x0010126e MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x10] MOVSXD RCX,EDX MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX MOVZX EAX,byte ptr [RAX] MOV byte ptr [RDX],AL ADD dword ptr [RBP + -0x10],0x1 LAB_0010126e: ADD dword ptr [RBP + -0xc],0x1 LAB_00101272: MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] TEST AL,AL JNZ 0x00101236 MOV EAX,dword ptr [RBP + -0x10] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x8] ADD RAX,RDX MOV byte ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(char *param_1,char param_2) { size_t sVar1; void *pvVar2; int local_20; int local_1c; int local_18; int local_14; local_20 = 0; for (local_1c = 0; param_1[local_1c] != '\0'; local_1c = local_1c + 1) { if (param_2 == param_1[local_1c]) { local_20 = local_20 + 1; } } sVar1 = strlen(param_1); pvVar2 = malloc((sVar1 - (long)local_20) + 1); local_18 = 0; for (local_14 = 0; param_1[local_14] != '\0'; local_14 = local_14 + 1) { if (param_2 != param_1[local_14]) { *(char *)((long)pvVar2 + (long)local_18) = param_1[local_14]; local_18 = local_18 + 1; } } *(int *)((long)pvVar2 + (long)local_18) = 0; return pvVar2; }
5,401
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(char* s, char c) { int counts = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] == c) { counts++; } } char* result = (char*)malloc(strlen(s) - counts + 1); int j = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] != c) { result[j] = s[i]; j++; } } result[j] = '\0'; return result; }
int main() { assert(strcmp(func0("aba", 'a'), "b") == 0); assert(strcmp(func0("toggle", 'g'), "tole") == 0); assert(strcmp(func0("aabbc", 'b'), "aac") == 0); return 0; }
O1
c
func0: endbr64 push %r12 push %rbp push %rbx movzbl (%rdi),%ebx test %bl,%bl je 11e4 <func0+0x7b> mov %esi,%r12d lea 0x1(%rdi),%rbp mov %rbp,%rsi mov %ebx,%edx mov $0x0,%r8d cmp %dl,%r12b sete %dl movzbl %dl,%edx add %edx,%r8d add $0x1,%rsi movzbl -0x1(%rsi),%edx test %dl,%dl jne 118a <func0+0x21> mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al not %rcx movslq %r8d,%r8 mov %rcx,%rdi sub %r8,%rdi callq 1070 <malloc@plt> mov $0x0,%edx jmp 11dd <func0+0x74> movslq %edx,%rcx mov %bl,(%rax,%rcx,1) add $0x1,%edx add $0x1,%rbp movzbl -0x1(%rbp),%ebx test %bl,%bl je 1202 <func0+0x99> cmp %bl,%r12b jne 11c8 <func0+0x5f> jmp 11d1 <func0+0x68> mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al mov %rcx,%rdi not %rdi callq 1070 <malloc@plt> mov $0x0,%edx movslq %edx,%rdx movb $0x0,(%rax,%rdx,1) pop %rbx pop %rbp pop %r12 retq
func0: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 movzx ebx, byte ptr [rdi] test bl, bl jz short loc_121F mov r12d, esi lea rbp, [rdi+1] mov rdx, rbp mov eax, ebx mov r13d, 0 loc_11D0: cmp r12b, al setz al movzx eax, al add r13d, eax add rdx, 1 movzx eax, byte ptr [rdx-1] test al, al jnz short loc_11D0 call _strlen movsxd r13, r13d sub rax, r13 lea rdi, [rax+1] call _malloc mov edx, 0 jmp short loc_120F loc_1203: add rbp, 1 movzx ebx, byte ptr [rbp-1] test bl, bl jz short loc_1232 loc_120F: cmp r12b, bl jz short loc_1203 movsxd rcx, edx mov [rax+rcx], bl add edx, 1 jmp short loc_1203 loc_121F: call _strlen lea rdi, [rax+1] call _malloc mov edx, 0 loc_1232: movsxd rdx, edx mov byte ptr [rax+rdx], 0 add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn
long long func0(char *a1, char a2) { char v2; // bl char *v3; // rbp char *v4; // rdx char v5; // al int v6; // r13d long long v7; // rax long long result; // rax int v9; // edx long long v10; // rax v2 = *a1; if ( *a1 ) { v3 = a1 + 1; v4 = a1 + 1; v5 = *a1; v6 = 0; do { v6 += a2 == v5; v5 = *v4++; } while ( v5 ); v7 = strlen(); result = malloc(v7 - v6 + 1); v9 = 0; do { if ( a2 != v2 ) *(_BYTE *)(result + v9++) = v2; v2 = *v3++; } while ( v2 ); } else { v10 = strlen(); result = malloc(v10 + 1); v9 = 0; } *(_BYTE *)(result + v9) = 0; return result; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOVZX EBX,byte ptr [RDI] TEST BL,BL JZ 0x0010121f MOV R12D,ESI LEA RBP,[RDI + 0x1] MOV RDX,RBP MOV EAX,EBX MOV R13D,0x0 LAB_001011d0: CMP R12B,AL SETZ AL MOVZX EAX,AL ADD R13D,EAX ADD RDX,0x1 MOVZX EAX,byte ptr [RDX + -0x1] TEST AL,AL JNZ 0x001011d0 CALL 0x00101080 MOVSXD R13,R13D SUB RAX,R13 LEA RDI,[RAX + 0x1] CALL 0x001010b0 MOV EDX,0x0 JMP 0x0010120f LAB_00101203: ADD RBP,0x1 MOVZX EBX,byte ptr [RBP + -0x1] TEST BL,BL JZ 0x00101232 LAB_0010120f: CMP R12B,BL JZ 0x00101203 MOVSXD RCX,EDX MOV byte ptr [RAX + RCX*0x1],BL ADD EDX,0x1 JMP 0x00101203 LAB_0010121f: CALL 0x00101080 LEA RDI,[RAX + 0x1] CALL 0x001010b0 MOV EDX,0x0 LAB_00101232: MOVSXD RDX,EDX MOV byte ptr [RAX + RDX*0x1],0x0 ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET
void func0(char *param_1,char param_2) { char cVar1; size_t sVar2; void *pvVar3; char *pcVar4; char cVar5; int iVar6; cVar5 = *param_1; if (cVar5 == '\0') { sVar2 = strlen(param_1); pvVar3 = malloc(sVar2 + 1); iVar6 = 0; } else { iVar6 = 0; pcVar4 = param_1 + 1; cVar1 = cVar5; do { iVar6 = iVar6 + (uint)(param_2 == cVar1); cVar1 = *pcVar4; pcVar4 = pcVar4 + 1; } while (cVar1 != '\0'); sVar2 = strlen(param_1); pvVar3 = malloc((sVar2 - (long)iVar6) + 1); iVar6 = 0; pcVar4 = param_1 + 1; do { if (param_2 != cVar5) { *(char *)((long)pvVar3 + (long)iVar6) = cVar5; iVar6 = iVar6 + 1; } cVar5 = *pcVar4; pcVar4 = pcVar4 + 1; } while (cVar5 != '\0'); } *(int1 *)((long)pvVar3 + (long)iVar6) = 0; return; }
5,402
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(char* s, char c) { int counts = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] == c) { counts++; } } char* result = (char*)malloc(strlen(s) - counts + 1); int j = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] != c) { result[j] = s[i]; j++; } } result[j] = '\0'; return result; }
int main() { assert(strcmp(func0("aba", 'a'), "b") == 0); assert(strcmp(func0("toggle", 'g'), "tole") == 0); assert(strcmp(func0("aabbc", 'b'), "aac") == 0); return 0; }
O2
c
func0: endbr64 push %r12 mov %esi,%r12d push %rbp mov %rdi,%rbp push %rbx movzbl (%rdi),%ebx callq 1070 <strlen@plt> test %bl,%bl je 1300 <func0+0x90> add $0x1,%rbp mov %ebx,%edx xor %r8d,%r8d mov %rbp,%rcx nopw %cs:0x0(%rax,%rax,1) cmp %dl,%r12b sete %dl add $0x1,%rcx movzbl %dl,%edx add %edx,%r8d movzbl -0x1(%rcx),%edx test %dl,%dl jne 12a0 <func0+0x30> lea 0x1(%rax),%rdi movslq %r8d,%r8 sub %r8,%rdi callq 1090 <malloc@plt> xor %esi,%esi xor %ecx,%ecx nopl 0x0(%rax,%rax,1) lea (%rax,%rcx,1),%rdx cmp %bl,%r12b je 12e5 <func0+0x75> add $0x1,%esi mov %bl,(%rdx) movslq %esi,%rcx lea (%rax,%rcx,1),%rdx movzbl 0x0(%rbp),%ebx add $0x1,%rbp test %bl,%bl jne 12d0 <func0+0x60> movb $0x0,(%rdx) pop %rbx pop %rbp pop %r12 retq nopl 0x0(%rax) lea 0x1(%rax),%rdi callq 1090 <malloc@plt> mov %rax,%rdx movb $0x0,(%rdx) pop %rbx pop %rbp pop %r12 retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push r12 mov r12d, esi push rbp mov rbp, rdi push rbx movzx ebx, byte ptr [rdi] call _strlen test bl, bl jz short loc_1300 add rbp, 1 mov edx, ebx xor esi, esi mov rcx, rbp nop dword ptr [rax] loc_12A8: cmp r12b, dl setz dl add rcx, 1 movzx edx, dl add esi, edx movzx edx, byte ptr [rcx-1] test dl, dl jnz short loc_12A8 lea rdi, [rax+1] movsxd rsi, esi sub rdi, rsi call _malloc xor edx, edx loc_12D0: cmp r12b, bl jz short loc_12DE movsxd rcx, edx add edx, 1 mov [rax+rcx], bl loc_12DE: movzx ebx, byte ptr [rbp+0] add rbp, 1 test bl, bl jnz short loc_12D0 movsxd rdx, edx add rdx, rax mov byte ptr [rdx], 0 pop rbx pop rbp pop r12 retn loc_1300: lea rdi, [rax+1] call _malloc mov rdx, rax mov byte ptr [rdx], 0 pop rbx pop rbp pop r12 retn
_BYTE * func0(char *a1, char a2) { char v3; // bl long long v4; // rax char *v5; // rbp char v6; // dl int v7; // esi _BYTE *v8; // rcx _BYTE *result; // rax int v10; // edx long long v11; // rcx v3 = *a1; v4 = strlen(); if ( v3 ) { v5 = a1 + 1; v6 = v3; v7 = 0; v8 = a1 + 1; do { ++v8; v7 += a2 == v6; v6 = *(v8 - 1); } while ( v6 ); result = (_BYTE *)malloc(v4 + 1 - v7); v10 = 0; do { if ( a2 != v3 ) { v11 = v10++; result[v11] = v3; } v3 = *v5++; } while ( v3 ); result[v10] = 0; } else { result = (_BYTE *)malloc(v4 + 1); *result = 0; } return result; }
func0: ENDBR64 PUSH R12 MOV R12D,ESI PUSH RBP MOV RBP,RDI PUSH RBX MOVZX EBX,byte ptr [RDI] CALL 0x00101080 TEST BL,BL JZ 0x00101300 ADD RBP,0x1 MOV EDX,EBX XOR ESI,ESI MOV RCX,RBP NOP dword ptr [RAX] LAB_001012a8: CMP R12B,DL SETZ DL ADD RCX,0x1 MOVZX EDX,DL ADD ESI,EDX MOVZX EDX,byte ptr [RCX + -0x1] TEST DL,DL JNZ 0x001012a8 LEA RDI,[RAX + 0x1] MOVSXD RSI,ESI SUB RDI,RSI CALL 0x001010b0 XOR EDX,EDX LAB_001012d0: CMP R12B,BL JZ 0x001012de MOVSXD RCX,EDX ADD EDX,0x1 MOV byte ptr [RAX + RCX*0x1],BL LAB_001012de: MOVZX EBX,byte ptr [RBP] ADD RBP,0x1 TEST BL,BL JNZ 0x001012d0 MOVSXD RDX,EDX ADD RDX,RAX MOV byte ptr [RDX],0x0 POP RBX POP RBP POP R12 RET LAB_00101300: LEA RDI,[RAX + 0x1] CALL 0x001010b0 MOV RDX,RAX MOV byte ptr [RDX],0x0 POP RBX POP RBP POP R12 RET
void func0(char *param_1,char param_2) { size_t sVar1; void *pvVar2; int1 *puVar3; char *pcVar4; long lVar5; char cVar6; char cVar7; int iVar8; cVar7 = *param_1; sVar1 = strlen(param_1); if (cVar7 != '\0') { param_1 = param_1 + 1; iVar8 = 0; pcVar4 = param_1; cVar6 = cVar7; do { iVar8 = iVar8 + (uint)(param_2 == cVar6); cVar6 = *pcVar4; pcVar4 = pcVar4 + 1; } while (cVar6 != '\0'); pvVar2 = malloc((sVar1 + 1) - (long)iVar8); iVar8 = 0; do { if (param_2 != cVar7) { lVar5 = (long)iVar8; iVar8 = iVar8 + 1; *(char *)((long)pvVar2 + lVar5) = cVar7; } cVar7 = *param_1; param_1 = param_1 + 1; } while (cVar7 != '\0'); *(int1 *)((long)iVar8 + (long)pvVar2) = 0; return; } puVar3 = (int1 *)malloc(sVar1 + 1); *puVar3 = 0; return; }
5,403
func0
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h>
char* func0(char* s, char c) { int counts = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] == c) { counts++; } } char* result = (char*)malloc(strlen(s) - counts + 1); int j = 0; for(int i = 0; s[i] != '\0'; i++) { if(s[i] != c) { result[j] = s[i]; j++; } } result[j] = '\0'; return result; }
int main() { assert(strcmp(func0("aba", 'a'), "b") == 0); assert(strcmp(func0("toggle", 'g'), "tole") == 0); assert(strcmp(func0("aabbc", 'b'), "aac") == 0); return 0; }
O3
c
func0: endbr64 push %r12 mov %esi,%r12d push %rbp mov %rdi,%rbp push %rbx movzbl (%rdi),%ebx callq 1070 <strlen@plt> test %bl,%bl je 1318 <func0+0xa8> add $0x1,%rbp mov %ebx,%edx xor %r8d,%r8d mov %rbp,%rcx nopw 0x0(%rax,%rax,1) cmp %dl,%r12b sete %dl add $0x1,%rcx movzbl %dl,%edx add %edx,%r8d movzbl -0x1(%rcx),%edx test %dl,%dl jne 12a0 <func0+0x30> lea 0x1(%rax),%rdi movslq %r8d,%r8 sub %r8,%rdi callq 1090 <malloc@plt> xor %esi,%esi xor %ecx,%ecx nopl 0x0(%rax,%rax,1) lea (%rax,%rcx,1),%rdx cmp %bl,%r12b je 1300 <func0+0x90> add $0x1,%rbp mov %bl,(%rdx) add $0x1,%esi movzbl -0x1(%rbp),%ebx movslq %esi,%rcx lea (%rax,%rcx,1),%rdx test %bl,%bl jne 12d0 <func0+0x60> movb $0x0,(%rdx) pop %rbx pop %rbp pop %r12 retq nopl 0x0(%rax) movzbl 0x0(%rbp),%ebx add $0x1,%rbp test %bl,%bl jne 12d0 <func0+0x60> movb $0x0,(%rdx) pop %rbx pop %rbp pop %r12 retq nopl 0x0(%rax) lea 0x1(%rax),%rdi callq 1090 <malloc@plt> mov %rax,%rdx movb $0x0,(%rdx) pop %rbx pop %rbp pop %r12 retq nopl 0x0(%rax)
func0: endbr64 push r12 mov r12d, esi push rbp mov rbp, rdi push rbx movzx ebx, byte ptr [rdi] call _strlen test bl, bl jz short loc_1310 add rbp, 1 mov edx, ebx xor esi, esi mov rcx, rbp nop dword ptr [rax] loc_12A8: cmp r12b, dl setz dl add rcx, 1 movzx edx, dl add esi, edx movzx edx, byte ptr [rcx-1] test dl, dl jnz short loc_12A8 lea rdi, [rax+1] movsxd rsi, esi sub rdi, rsi; size call _malloc xor edx, edx loc_12D0: cmp r12b, bl jz short loc_1300 movsxd rcx, edx add rbp, 1 add edx, 1 mov [rax+rcx], bl movzx ebx, byte ptr [rbp-1] test bl, bl jnz short loc_12D0 loc_12EA: movsxd rdx, edx add rdx, rax mov byte ptr [rdx], 0 pop rbx pop rbp pop r12 retn loc_1300: movzx ebx, byte ptr [rbp+0] add rbp, 1 test bl, bl jnz short loc_12D0 jmp short loc_12EA loc_1310: lea rdi, [rax+1]; size call _malloc mov rdx, rax mov byte ptr [rdx], 0 pop rbx pop rbp pop r12 retn
_BYTE * func0(const char *a1, char a2) { char v3; // bl size_t v4; // rax char *v5; // rbp char v6; // dl int v7; // esi const char *v8; // rcx _BYTE *result; // rax int v10; // edx long long v11; // rcx v3 = *a1; v4 = strlen(a1); if ( v3 ) { v5 = (char *)(a1 + 1); v6 = v3; v7 = 0; v8 = a1 + 1; do { ++v8; v7 += a2 == v6; v6 = *(v8 - 1); } while ( v6 ); result = malloc(v4 + 1 - v7); v10 = 0; do { while ( a2 != v3 ) { v11 = v10; ++v5; ++v10; result[v11] = v3; v3 = *(v5 - 1); if ( !v3 ) goto LABEL_7; } v3 = *v5++; } while ( v3 ); LABEL_7: result[v10] = 0; } else { result = malloc(v4 + 1); *result = 0; } return result; }
func0: ENDBR64 PUSH R12 MOV R12D,ESI PUSH RBP MOV RBP,RDI PUSH RBX MOVZX EBX,byte ptr [RDI] CALL 0x00101080 TEST BL,BL JZ 0x00101310 ADD RBP,0x1 MOV EDX,EBX XOR ESI,ESI MOV RCX,RBP NOP dword ptr [RAX] LAB_001012a8: CMP R12B,DL SETZ DL ADD RCX,0x1 MOVZX EDX,DL ADD ESI,EDX MOVZX EDX,byte ptr [RCX + -0x1] TEST DL,DL JNZ 0x001012a8 LEA RDI,[RAX + 0x1] MOVSXD RSI,ESI SUB RDI,RSI CALL 0x001010b0 XOR EDX,EDX LAB_001012d0: CMP R12B,BL JZ 0x00101300 MOVSXD RCX,EDX ADD RBP,0x1 ADD EDX,0x1 MOV byte ptr [RAX + RCX*0x1],BL MOVZX EBX,byte ptr [RBP + -0x1] TEST BL,BL JNZ 0x001012d0 LAB_001012ea: MOVSXD RDX,EDX ADD RDX,RAX MOV byte ptr [RDX],0x0 POP RBX POP RBP POP R12 RET LAB_00101300: MOVZX EBX,byte ptr [RBP] ADD RBP,0x1 TEST BL,BL JNZ 0x001012d0 JMP 0x001012ea LAB_00101310: LEA RDI,[RAX + 0x1] CALL 0x001010b0 MOV RDX,RAX MOV byte ptr [RDX],0x0 POP RBX POP RBP POP R12 RET
void func0(char *param_1,char param_2) { size_t sVar1; void *pvVar2; int *puVar3; long lVar4; char cVar5; char cVar6; char *pcVar7; int iVar8; cVar6 = *param_1; sVar1 = strlen(param_1); if (cVar6 == '\0') { puVar3 = (int *)malloc(sVar1 + 1); *puVar3 = 0; return; } iVar8 = 0; pcVar7 = param_1 + 1; cVar5 = cVar6; do { iVar8 = iVar8 + (uint)(param_2 == cVar5); cVar5 = *pcVar7; pcVar7 = pcVar7 + 1; } while (cVar5 != '\0'); pvVar2 = malloc((sVar1 + 1) - (long)iVar8); iVar8 = 0; pcVar7 = param_1 + 1; do { while (param_2 == cVar6) { cVar6 = *pcVar7; pcVar7 = pcVar7 + 1; if (cVar6 == '\0') goto LAB_001012ea; } lVar4 = (long)iVar8; iVar8 = iVar8 + 1; *(char *)((long)pvVar2 + lVar4) = cVar6; cVar6 = *pcVar7; pcVar7 = pcVar7 + 1; } while (cVar6 != '\0'); LAB_001012ea: *(int *)((long)iVar8 + (long)pvVar2) = 0; return; }
5,404
func0
#include <assert.h> #include <stdio.h>
void func0(int test_list[], int n, int result[]) { result[0] = test_list[n-1]; for (int i = 1; i < n; i++) { result[i] = test_list[i-1]; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 4 && result1[1] == 1 && result1[2] == 2 && result1[3] == 3); int test2[] = {0, 1, 2, 3}; int result2[4]; func0(test2, 4, result2); assert(result2[0] == 3 && result2[1] == 0 && result2[2] == 1 && result2[3] == 2); int test3[] = {9, 8, 7, 1}; int result3[4]; func0(test3, 4, result3); assert(result3[0] == 1 && result3[1] == 9 && result3[2] == 8 && result3[3] == 7); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov %rdx,-0x28(%rbp) mov -0x1c(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x28(%rbp),%rax mov %edx,(%rax) movl $0x1,-0x4(%rbp) jmp 11d2 <func0+0x69> mov -0x4(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%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 -0x1c(%rbp),%eax jl 11a1 <func0+0x38> pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov [rbp+var_28], rdx mov eax, [rbp+var_1C] cdqe shl rax, 2 lea rdx, [rax-4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rax] mov rax, [rbp+var_28] mov [rax], edx mov [rbp+var_4], 1 jmp short loc_11D2 loc_11A1: mov eax, [rbp+var_4] cdqe shl rax, 2 lea rdx, [rax-4] mov rax, [rbp+var_18] 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_11D2: mov eax, [rbp+var_4] cmp eax, [rbp+var_1C] jl short loc_11A1 nop nop pop rbp retn
long long func0(long long a1, int a2, _DWORD *a3) { long long result; // rax int i; // [rsp+24h] [rbp-4h] *a3 = *(_DWORD *)(4LL * a2 - 4 + a1); for ( i = 1; ; ++i ) { result = (unsigned int)i; if ( i >= a2 ) break; a3[i] = *(_DWORD *)(4LL * i - 4 + a1); } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV qword ptr [RBP + -0x28],RDX MOV EAX,dword ptr [RBP + -0x1c] CDQE SHL RAX,0x2 LEA RDX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV RAX,qword ptr [RBP + -0x28] MOV dword ptr [RAX],EDX MOV dword ptr [RBP + -0x4],0x1 JMP 0x001011d2 LAB_001011a1: MOV EAX,dword ptr [RBP + -0x4] CDQE SHL RAX,0x2 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_001011d2: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x1c] JL 0x001011a1 NOP NOP POP RBP RET
void func0(long param_1,int param_2,int4 *param_3) { int local_c; *param_3 = *(int4 *)(param_1 + (long)param_2 * 4 + -4); for (local_c = 1; local_c < param_2; local_c = local_c + 1) { param_3[local_c] = *(int4 *)(param_1 + (long)local_c * 4 + -4); } return; }
5,405
func0
#include <assert.h> #include <stdio.h>
void func0(int test_list[], int n, int result[]) { result[0] = test_list[n-1]; for (int i = 1; i < n; i++) { result[i] = test_list[i-1]; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 4 && result1[1] == 1 && result1[2] == 2 && result1[3] == 3); int test2[] = {0, 1, 2, 3}; int result2[4]; func0(test2, 4, result2); assert(result2[0] == 3 && result2[1] == 0 && result2[2] == 1 && result2[3] == 2); int test3[] = {9, 8, 7, 1}; int result3[4]; func0(test3, 4, result3); assert(result3[0] == 1 && result3[1] == 9 && result3[2] == 8 && result3[3] == 7); return 0; }
O1
c
func0: endbr64 movslq %esi,%rax mov -0x4(%rdi,%rax,4),%eax mov %eax,(%rdx) cmp $0x1,%esi jle 1196 <func0+0x2d> lea -0x2(%rsi),%esi mov $0x0,%eax mov (%rdi,%rax,4),%ecx mov %ecx,0x4(%rdx,%rax,4) mov %rax,%rcx add $0x1,%rax cmp %rsi,%rcx jne 1183 <func0+0x1a> retq
func0: endbr64 movsxd rax, esi mov eax, [rdi+rax*4-4] mov [rdx], eax cmp esi, 1 jle short locret_1193 lea esi, [rsi-1] mov eax, 0 loc_1183: mov ecx, [rdi+rax*4] mov [rdx+rax*4+4], ecx add rax, 1 cmp rax, rsi jnz short loc_1183 locret_1193: retn
long long func0(long long a1, int a2, _DWORD *a3) { long long result; // rax long long v4; // rsi result = *(unsigned int *)(a1 + 4LL * a2 - 4); *a3 = result; if ( a2 > 1 ) { v4 = (unsigned int)(a2 - 1); result = 0LL; do { a3[result + 1] = *(_DWORD *)(a1 + 4 * result); ++result; } while ( result != v4 ); } return result; }
func0: ENDBR64 MOVSXD RAX,ESI MOV EAX,dword ptr [RDI + RAX*0x4 + -0x4] MOV dword ptr [RDX],EAX CMP ESI,0x1 JLE 0x00101193 LEA ESI,[RSI + -0x1] MOV EAX,0x0 LAB_00101183: MOV ECX,dword ptr [RDI + RAX*0x4] MOV dword ptr [RDX + RAX*0x4 + 0x4],ECX ADD RAX,0x1 CMP RAX,RSI JNZ 0x00101183 LAB_00101193: RET
void func0(long param_1,int param_2,int4 *param_3) { ulong uVar1; *param_3 = *(int4 *)(param_1 + -4 + (long)param_2 * 4); if (1 < param_2) { uVar1 = 0; do { param_3[uVar1 + 1] = *(int4 *)(param_1 + uVar1 * 4); uVar1 = uVar1 + 1; } while (uVar1 != param_2 - 1); } return; }
5,406
func0
#include <assert.h> #include <stdio.h>
void func0(int test_list[], int n, int result[]) { result[0] = test_list[n-1]; for (int i = 1; i < n; i++) { result[i] = test_list[i-1]; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 4 && result1[1] == 1 && result1[2] == 2 && result1[3] == 3); int test2[] = {0, 1, 2, 3}; int result2[4]; func0(test2, 4, result2); assert(result2[0] == 3 && result2[1] == 0 && result2[2] == 1 && result2[3] == 2); int test3[] = {9, 8, 7, 1}; int result3[4]; func0(test3, 4, result3); assert(result3[0] == 1 && result3[1] == 9 && result3[2] == 8 && result3[3] == 7); return 0; }
O2
c
func0: endbr64 movslq %esi,%rax mov -0x4(%rdi,%rax,4),%eax mov %eax,(%rdx) cmp $0x1,%esi jle 1173 <func0+0x33> sub $0x2,%esi xor %eax,%eax nopw 0x0(%rax,%rax,1) mov (%rdi,%rax,4),%ecx mov %ecx,0x4(%rdx,%rax,4) mov %rax,%rcx add $0x1,%rax cmp %rcx,%rsi jne 1160 <func0+0x20> retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 movsxd rax, esi mov eax, [rdi+rax*4-4] mov [rdx], eax cmp esi, 1 jle short locret_1340 sub esi, 1 xor eax, eax nop word ptr [rax+rax+00000000h] loc_1330: mov ecx, [rdi+rax*4] mov [rdx+rax*4+4], ecx add rax, 1 cmp rax, rsi jnz short loc_1330 locret_1340: retn
long long func0(long long a1, int a2, _DWORD *a3) { long long result; // rax long long v4; // rsi result = *(unsigned int *)(a1 + 4LL * a2 - 4); *a3 = result; if ( a2 > 1 ) { v4 = (unsigned int)(a2 - 1); result = 0LL; do { a3[result + 1] = *(_DWORD *)(a1 + 4 * result); ++result; } while ( result != v4 ); } return result; }
func0: ENDBR64 MOVSXD RAX,ESI MOV EAX,dword ptr [RDI + RAX*0x4 + -0x4] MOV dword ptr [RDX],EAX CMP ESI,0x1 JLE 0x00101340 SUB ESI,0x1 XOR EAX,EAX NOP word ptr [RAX + RAX*0x1] LAB_00101330: MOV ECX,dword ptr [RDI + RAX*0x4] MOV dword ptr [RDX + RAX*0x4 + 0x4],ECX ADD RAX,0x1 CMP RAX,RSI JNZ 0x00101330 LAB_00101340: RET
void func0(long param_1,int param_2,int4 *param_3) { ulong uVar1; *param_3 = *(int4 *)(param_1 + -4 + (long)param_2 * 4); if (1 < param_2) { uVar1 = 0; do { param_3[uVar1 + 1] = *(int4 *)(param_1 + uVar1 * 4); uVar1 = uVar1 + 1; } while (uVar1 != param_2 - 1); } return; }
5,407
func0
#include <assert.h> #include <stdio.h>
void func0(int test_list[], int n, int result[]) { result[0] = test_list[n-1]; for (int i = 1; i < n; i++) { result[i] = test_list[i-1]; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 4 && result1[1] == 1 && result1[2] == 2 && result1[3] == 3); int test2[] = {0, 1, 2, 3}; int result2[4]; func0(test2, 4, result2); assert(result2[0] == 3 && result2[1] == 0 && result2[2] == 1 && result2[3] == 2); int test3[] = {9, 8, 7, 1}; int result3[4]; func0(test3, 4, result3); assert(result3[0] == 1 && result3[1] == 9 && result3[2] == 8 && result3[3] == 7); return 0; }
O3
c
func0: endbr64 movslq %esi,%rax mov -0x4(%rdi,%rax,4),%eax mov %eax,(%rdx) cmp $0x1,%esi jle 1203 <func0+0xc3> lea 0x10(%rdi),%r8 lea 0x4(%rdx),%rcx cmp %rcx,%r8 lea 0x14(%rdx),%rcx lea -0x2(%rsi),%eax setbe %r8b cmp %rcx,%rdi setae %cl or %cl,%r8b je 11e8 <func0+0xa8> cmp $0x3,%eax jbe 11e8 <func0+0xa8> lea -0x1(%rsi),%r8d xor %eax,%eax mov %r8d,%ecx shr $0x2,%ecx shl $0x4,%rcx nopl 0x0(%rax) movdqu (%rdi,%rax,1),%xmm0 movups %xmm0,0x4(%rdx,%rax,1) add $0x10,%rax cmp %rcx,%rax jne 1190 <func0+0x50> mov %r8d,%eax and $0xfffffffc,%eax lea 0x1(%rax),%ecx cmp %eax,%r8d je 1203 <func0+0xc3> movslq %ecx,%rcx mov -0x4(%rdi,%rcx,4),%r8d mov %r8d,(%rdx,%rcx,4) lea 0x2(%rax),%ecx cmp %ecx,%esi jle 1203 <func0+0xc3> movslq %ecx,%rcx add $0x3,%eax mov -0x4(%rdi,%rcx,4),%r8d mov %r8d,(%rdx,%rcx,4) cmp %eax,%esi jle 1203 <func0+0xc3> cltq mov -0x4(%rdi,%rax,4),%ecx mov %ecx,(%rdx,%rax,4) retq nopl 0x0(%rax) mov %eax,%ecx xor %eax,%eax nopl 0x0(%rax) mov (%rdi,%rax,4),%esi mov %esi,0x4(%rdx,%rax,4) mov %rax,%rsi add $0x1,%rax cmp %rcx,%rsi jne 11f0 <func0+0xb0> retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 movsxd rax, esi mov rcx, rdi mov eax, [rdi+rax*4-4] mov [rdx], eax cmp esi, 1 jle short locret_1180 lea eax, [rsi-2] cmp eax, 2 jbe short loc_1169 mov rax, rdx sub rax, rdi cmp rax, 8 ja short loc_1188 loc_1169: lea edi, [rsi-1] xor eax, eax xchg ax, ax loc_1170: mov esi, [rcx+rax*4] mov [rdx+rax*4+4], esi add rax, 1 cmp rdi, rax jnz short loc_1170 locret_1180: retn loc_1188: lea r8d, [rsi-1] xor eax, eax mov edi, r8d shr edi, 2 shl rdi, 4 nop dword ptr [rax+rax+00000000h] loc_11A0: movdqu xmm0, xmmword ptr [rcx+rax] movups xmmword ptr [rdx+rax+4], xmm0 add rax, 10h cmp rax, rdi jnz short loc_11A0 mov eax, r8d and eax, 0FFFFFFFCh and r8d, 3 lea edi, [rax+1] jz short locret_1180 movsxd rdi, edi lea r8, ds:0[rdi*4] mov r9d, [rcx+r8-4] mov [rdx+rdi*4], r9d lea r9d, [rax+2] cmp esi, r9d jle short locret_1180 mov edi, [rcx+rdi*4] add eax, 3 mov [rdx+r8+4], edi cmp esi, eax jle short locret_1180 mov eax, [rcx+r8+4] mov [rdx+r8+8], eax retn
long long func0(long long a1, int a2, _DWORD *a3) { long long result; // rax int v5; // r8d long long v6; // rax int v7; // edi long long v8; // r8 result = *(unsigned int *)(a1 + 4LL * a2 - 4); *a3 = result; if ( a2 > 1 ) { if ( (unsigned int)(a2 - 2) > 2 && (unsigned long long)a3 - a1 > 8 ) { v5 = a2 - 1; v6 = 0LL; do { *(__m128i *)&a3[v6 + 1] = _mm_loadu_si128((const __m128i *)(a1 + v6 * 4)); v6 += 4LL; } while ( v6 != 4LL * ((unsigned int)(a2 - 1) >> 2) ); result = v5 & 0xFFFFFFFC; v7 = result + 1; if ( (v5 & 3) != 0 ) { v8 = v7; a3[v8] = *(_DWORD *)(a1 + v8 * 4 - 4); if ( a2 > (int)result + 2 ) { result = (unsigned int)(result + 3); a3[v7 + 1] = *(_DWORD *)(a1 + 4LL * v7); if ( a2 > (int)result ) { result = *(unsigned int *)(a1 + v8 * 4 + 4); a3[v8 + 2] = result; } } } } else { result = 0LL; do { a3[result + 1] = *(_DWORD *)(a1 + 4 * result); ++result; } while ( a2 - 1 != result ); } } return result; }
func0: ENDBR64 MOVSXD RAX,ESI MOV RCX,RDI MOV EAX,dword ptr [RDI + RAX*0x4 + -0x4] MOV dword ptr [RDX],EAX CMP ESI,0x1 JLE 0x00101180 LEA EAX,[RSI + -0x2] CMP EAX,0x2 JBE 0x00101169 MOV RAX,RDX SUB RAX,RDI CMP RAX,0x8 JA 0x00101188 LAB_00101169: LEA EDI,[RSI + -0x1] XOR EAX,EAX NOP LAB_00101170: MOV ESI,dword ptr [RCX + RAX*0x4] MOV dword ptr [RDX + RAX*0x4 + 0x4],ESI ADD RAX,0x1 CMP RDI,RAX JNZ 0x00101170 LAB_00101180: RET LAB_00101188: LEA R8D,[RSI + -0x1] XOR EAX,EAX MOV EDI,R8D SHR EDI,0x2 SHL RDI,0x4 NOP dword ptr [RAX + RAX*0x1] LAB_001011a0: MOVDQU XMM0,xmmword ptr [RCX + RAX*0x1] MOVUPS xmmword ptr [RDX + RAX*0x1 + 0x4],XMM0 ADD RAX,0x10 CMP RAX,RDI JNZ 0x001011a0 MOV EAX,R8D AND EAX,0xfffffffc AND R8D,0x3 LEA EDI,[RAX + 0x1] JZ 0x00101180 MOVSXD RDI,EDI LEA R8,[RDI*0x4] MOV R9D,dword ptr [RCX + R8*0x1 + -0x4] MOV dword ptr [RDX + RDI*0x4],R9D LEA R9D,[RAX + 0x2] CMP ESI,R9D JLE 0x00101180 MOV EDI,dword ptr [RCX + RDI*0x4] ADD EAX,0x3 MOV dword ptr [RDX + R8*0x1 + 0x4],EDI CMP ESI,EAX JLE 0x00101180 MOV EAX,dword ptr [RCX + R8*0x1 + 0x4] MOV dword ptr [RDX + R8*0x1 + 0x8],EAX RET
void func0(long param_1,int param_2,int4 *param_3) { uint uVar1; int8 *puVar2; int8 uVar3; uint uVar4; ulong uVar5; long lVar6; *param_3 = *(int4 *)(param_1 + -4 + (long)param_2 * 4); if (1 < param_2) { if ((param_2 - 2U < 3) || ((ulong)((long)param_3 - param_1) < 9)) { uVar5 = 0; do { param_3[uVar5 + 1] = *(int4 *)(param_1 + uVar5 * 4); uVar5 = uVar5 + 1; } while (param_2 - 1 != uVar5); } else { uVar1 = param_2 - 1; lVar6 = 0; do { uVar3 = ((int8 *)(param_1 + lVar6))[1]; puVar2 = (int8 *)((long)param_3 + lVar6 + 4); *puVar2 = *(int8 *)(param_1 + lVar6); puVar2[1] = uVar3; lVar6 = lVar6 + 0x10; } while (lVar6 != (ulong)(uVar1 >> 2) << 4); uVar4 = uVar1 & 0xfffffffc; if ((uVar1 & 3) != 0) { lVar6 = (long)(int)(uVar4 + 1); param_3[lVar6] = *(int4 *)(param_1 + -4 + lVar6 * 4); if (((int)(uVar4 + 2) < param_2) && (param_3[lVar6 + 1] = *(int4 *)(param_1 + lVar6 * 4), (int)(uVar4 + 3) < param_2)) { param_3[lVar6 + 2] = *(int4 *)(param_1 + 4 + lVar6 * 4); return; } } } } return; }
5,408
func0
#include <assert.h>
int func0(int l, int w, int h) { int SA = 2 * (l * w + l * h + w * h); return SA; }
int main() { assert(func0(1, 2, 3) == 22); assert(func0(5, 7, 9) == 286); assert(func0(10, 15, 21) == 1350); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov %edx,-0x1c(%rbp) mov -0x14(%rbp),%eax imul -0x18(%rbp),%eax mov %eax,%edx mov -0x14(%rbp),%eax imul -0x1c(%rbp),%eax add %eax,%edx mov -0x18(%rbp),%eax imul -0x1c(%rbp),%eax add %edx,%eax add %eax,%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 [rbp+var_18], esi mov [rbp+var_1C], edx mov eax, [rbp+var_14] imul eax, [rbp+var_18] mov edx, eax mov eax, [rbp+var_14] imul eax, [rbp+var_1C] add edx, eax mov eax, [rbp+var_18] imul eax, [rbp+var_1C] add eax, edx add eax, eax mov [rbp+var_4], eax mov eax, [rbp+var_4] pop rbp retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(2 * (a3 * a1 + a2 * a1 + a3 * a2)); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV dword ptr [RBP + -0x1c],EDX MOV EAX,dword ptr [RBP + -0x14] IMUL EAX,dword ptr [RBP + -0x18] MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x14] IMUL EAX,dword ptr [RBP + -0x1c] ADD EDX,EAX MOV EAX,dword ptr [RBP + -0x18] IMUL EAX,dword ptr [RBP + -0x1c] ADD EAX,EDX ADD EAX,EAX MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x4] POP RBP RET
int func0(int param_1,int param_2,int param_3) { return (param_2 * param_3 + param_1 * param_2 + param_1 * param_3) * 2; }
5,409
func0
#include <assert.h>
int func0(int l, int w, int h) { int SA = 2 * (l * w + l * h + w * h); return SA; }
int main() { assert(func0(1, 2, 3) == 22); assert(func0(5, 7, 9) == 286); assert(func0(10, 15, 21) == 1350); return 0; }
O1
c
func0: endbr64 mov %edi,%ecx lea (%rdx,%rsi,1),%edi imul %ecx,%edi imul %edx,%esi lea (%rdi,%rsi,1),%eax add %eax,%eax retq
func0: endbr64 lea eax, [rdx+rsi] imul eax, edi imul esi, edx add eax, esi add eax, eax retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(2 * (a3 * a2 + a1 * (a3 + a2))); }
func0: ENDBR64 LEA EAX,[RDX + RSI*0x1] IMUL EAX,EDI IMUL ESI,EDX ADD EAX,ESI ADD EAX,EAX RET
int func0(int param_1,int param_2,int param_3) { return ((param_3 + param_2) * param_1 + param_2 * param_3) * 2; }
5,410
func0
#include <assert.h>
int func0(int l, int w, int h) { int SA = 2 * (l * w + l * h + w * h); return SA; }
int main() { assert(func0(1, 2, 3) == 22); assert(func0(5, 7, 9) == 286); assert(func0(10, 15, 21) == 1350); return 0; }
O2
c
func0: endbr64 mov %edi,%r8d lea (%rdx,%rsi,1),%edi imul %r8d,%edi imul %edx,%esi lea (%rdi,%rsi,1),%eax add %eax,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 lea eax, [rdx+rsi] imul eax, edi imul esi, edx add eax, esi add eax, eax retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(2 * (a3 * a2 + a1 * (a3 + a2))); }
func0: ENDBR64 LEA EAX,[RDX + RSI*0x1] IMUL EAX,EDI IMUL ESI,EDX ADD EAX,ESI ADD EAX,EAX RET
int func0(int param_1,int param_2,int param_3) { return ((param_3 + param_2) * param_1 + param_2 * param_3) * 2; }
5,411
func0
#include <assert.h>
int func0(int l, int w, int h) { int SA = 2 * (l * w + l * h + w * h); return SA; }
int main() { assert(func0(1, 2, 3) == 22); assert(func0(5, 7, 9) == 286); assert(func0(10, 15, 21) == 1350); return 0; }
O3
c
func0: endbr64 mov %edi,%r8d lea (%rdx,%rsi,1),%edi imul %r8d,%edi imul %edx,%esi lea (%rdi,%rsi,1),%eax add %eax,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 lea eax, [rdx+rsi] imul eax, edi imul esi, edx add eax, esi add eax, eax retn
long long func0(int a1, int a2, int a3) { return (unsigned int)(2 * (a3 * a2 + a1 * (a3 + a2))); }
func0: ENDBR64 LEA EAX,[RDX + RSI*0x1] IMUL EAX,EDI IMUL ESI,EDX ADD EAX,ESI ADD EAX,EAX RET
int func0(int param_1,int param_2,int param_3) { return ((param_3 + param_2) * param_1 + param_2 * param_3) * 2; }
5,412
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h>
int** func0(int rownum, int colnum) { int **matrix = malloc(rownum * sizeof(int*)); for (int i = 0; i < rownum; i++) { matrix[i] = malloc(colnum * sizeof(int)); for (int j = 0; j < colnum; j++) { matrix[i][j] = i * j; } } return matrix; }
int main() { int **result; int i, j; result = func0(3, 4); int expected_3_4[3][4] = {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}}; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { assert(result[i][j] == expected_3_4[i][j]); } } result = func0(5, 7); int expected_5_7[5][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6}, {0, 2, 4, 6, 8, 10, 12}, {0, 3, 6, 9, 12, 15, 18}, {0, 4, 8, 12, 16, 20, 24}}; for (i = 0; i < 5; i++) { for (j = 0; j < 7; j++) { assert(result[i][j] == expected_5_7[i][j]); } } result = func0(10, 15); int expected_10_15[10][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}, {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42}, {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56}, {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70}, {0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84}, {0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112}, {0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126}}; for (i = 0; i < 10; i++) { for (j = 0; j < 15; j++) { assert(result[i][j] == expected_10_15[i][j]); } } for (i = 0; i < 10; i++) { free(result[i]); } free(result); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x28,%rsp mov %edi,-0x24(%rbp) mov %esi,-0x28(%rbp) mov -0x24(%rbp),%eax cltq shl $0x3,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x18(%rbp) movl $0x0,-0x20(%rbp) jmp 124a <func0+0xa1> mov -0x28(%rbp),%eax cltq shl $0x2,%rax mov -0x20(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,8),%rcx mov -0x18(%rbp),%rdx lea (%rcx,%rdx,1),%rbx mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,(%rbx) movl $0x0,-0x1c(%rbp) jmp 123e <func0+0x95> mov -0x20(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov -0x1c(%rbp),%edx movslq %edx,%rdx shl $0x2,%rdx add %rax,%rdx mov -0x20(%rbp),%eax imul -0x1c(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x1c(%rbp) mov -0x1c(%rbp),%eax cmp -0x28(%rbp),%eax jl 120d <func0+0x64> addl $0x1,-0x20(%rbp) mov -0x20(%rbp),%eax cmp -0x24(%rbp),%eax jl 11da <func0+0x31> mov -0x18(%rbp),%rax add $0x28,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 28h mov [rbp+var_24], edi mov [rbp+var_28], esi mov eax, [rbp+var_24] cdqe shl rax, 3 mov rdi, rax; size call _malloc mov [rbp+var_18], rax mov [rbp+var_20], 0 jmp short loc_124A loc_11DA: mov eax, [rbp+var_28] cdqe shl rax, 2 mov edx, [rbp+var_20] movsxd rdx, edx lea rcx, ds:0[rdx*8] mov rdx, [rbp+var_18] lea rbx, [rcx+rdx] mov rdi, rax; size call _malloc mov [rbx], rax mov [rbp+var_1C], 0 jmp short loc_123E loc_120D: mov eax, [rbp+var_20] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_18] add rax, rdx mov rax, [rax] mov edx, [rbp+var_1C] movsxd rdx, edx shl rdx, 2 add rdx, rax mov eax, [rbp+var_20] imul eax, [rbp+var_1C] mov [rdx], eax add [rbp+var_1C], 1 loc_123E: mov eax, [rbp+var_1C] cmp eax, [rbp+var_28] jl short loc_120D add [rbp+var_20], 1 loc_124A: mov eax, [rbp+var_20] cmp eax, [rbp+var_24] jl short loc_11DA mov rax, [rbp+var_18] mov rbx, [rbp+var_8] leave retn
_QWORD * func0(int a1, int a2) { int i; // [rsp+10h] [rbp-20h] int j; // [rsp+14h] [rbp-1Ch] _QWORD *v5; // [rsp+18h] [rbp-18h] v5 = malloc(8LL * a1); for ( i = 0; i < a1; ++i ) { v5[i] = malloc(4LL * a2); for ( j = 0; j < a2; ++j ) *(_DWORD *)(v5[i] + 4LL * j) = j * i; } return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x28 MOV dword ptr [RBP + -0x24],EDI MOV dword ptr [RBP + -0x28],ESI MOV EAX,dword ptr [RBP + -0x24] CDQE SHL RAX,0x3 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x18],RAX MOV dword ptr [RBP + -0x20],0x0 JMP 0x0010124a LAB_001011da: MOV EAX,dword ptr [RBP + -0x28] CDQE SHL RAX,0x2 MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX LEA RCX,[RDX*0x8] MOV RDX,qword ptr [RBP + -0x18] LEA RBX,[RCX + RDX*0x1] MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBX],RAX MOV dword ptr [RBP + -0x1c],0x0 JMP 0x0010123e LAB_0010120d: MOV EAX,dword ptr [RBP + -0x20] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV EDX,dword ptr [RBP + -0x1c] MOVSXD RDX,EDX SHL RDX,0x2 ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x20] IMUL EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RDX],EAX ADD dword ptr [RBP + -0x1c],0x1 LAB_0010123e: MOV EAX,dword ptr [RBP + -0x1c] CMP EAX,dword ptr [RBP + -0x28] JL 0x0010120d ADD dword ptr [RBP + -0x20],0x1 LAB_0010124a: MOV EAX,dword ptr [RBP + -0x20] CMP EAX,dword ptr [RBP + -0x24] JL 0x001011da MOV RAX,qword ptr [RBP + -0x18] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(int param_1,int param_2) { void *pvVar1; void *pvVar2; int4 local_28; int4 local_24; pvVar1 = malloc((long)param_1 << 3); for (local_28 = 0; local_28 < param_1; local_28 = local_28 + 1) { pvVar2 = malloc((long)param_2 << 2); *(void **)((long)local_28 * 8 + (long)pvVar1) = pvVar2; for (local_24 = 0; local_24 < param_2; local_24 = local_24 + 1) { *(int *)((long)local_24 * 4 + *(long *)((long)pvVar1 + (long)local_28 * 8)) = local_28 * local_24; } } return pvVar1; }
5,413
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h>
int** func0(int rownum, int colnum) { int **matrix = malloc(rownum * sizeof(int*)); for (int i = 0; i < rownum; i++) { matrix[i] = malloc(colnum * sizeof(int)); for (int j = 0; j < colnum; j++) { matrix[i][j] = i * j; } } return matrix; }
int main() { int **result; int i, j; result = func0(3, 4); int expected_3_4[3][4] = {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}}; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { assert(result[i][j] == expected_3_4[i][j]); } } result = func0(5, 7); int expected_5_7[5][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6}, {0, 2, 4, 6, 8, 10, 12}, {0, 3, 6, 9, 12, 15, 18}, {0, 4, 8, 12, 16, 20, 24}}; for (i = 0; i < 5; i++) { for (j = 0; j < 7; j++) { assert(result[i][j] == expected_5_7[i][j]); } } result = func0(10, 15); int expected_10_15[10][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}, {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42}, {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56}, {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70}, {0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84}, {0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112}, {0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126}}; for (i = 0; i < 10; i++) { for (j = 0; j < 15; j++) { assert(result[i][j] == expected_10_15[i][j]); } } for (i = 0; i < 10; 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 %edi,%r13d mov %esi,%r14d movslq %edi,%rdi shl $0x3,%rdi callq 10b0 <malloc@plt> mov %rax,0x8(%rsp) test %r13d,%r13d jle 1236 <func0+0x8d> movslq %r14d,%r15 shl $0x2,%r15 mov %rax,%rbp lea -0x1(%r14),%eax lea 0x4(,%rax,4),%rbx mov $0x0,%r12d jmp 1202 <func0+0x59> add $0x1,%r12d add $0x8,%rbp cmp %r12d,%r13d je 1236 <func0+0x8d> mov %r15,%rdi callq 10b0 <malloc@plt> mov %rbp,%rsi mov %rax,0x0(%rbp) test %r14d,%r14d jle 11f5 <func0+0x4c> mov %r12d,%edi mov $0x0,%edx mov $0x0,%eax mov (%rsi),%rcx mov %edx,(%rcx,%rax,1) add $0x4,%rax add %edi,%edx cmp %rbx,%rax jne 1223 <func0+0x7a> jmp 11f5 <func0+0x4c> 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, 8 mov ebp, edi mov r12d, esi movsxd rdi, edi shl rdi, 3 call _malloc mov r13, rax test ebp, ebp jle short loc_1220 movsxd r15, r12d shl r15, 2 mov ebp, ebp lea r14d, [r12-1] mov ebx, 0 add r14, 1 loc_11EA: mov rdi, r15 call _malloc mov [r13+rbx*8+0], rax test r12d, r12d jle short loc_1217 mov esi, ebx mov rdx, rax lea rcx, [rax+r14*4] mov eax, 0 loc_120A: mov [rdx], eax add eax, esi add rdx, 4 cmp rdx, rcx jnz short loc_120A loc_1217: add rbx, 1 cmp rbx, rbp jnz short loc_11EA loc_1220: mov rax, r13 add rsp, 8 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn
long long func0(int a1, int a2) { long long v2; // r13 long long i; // rbx long long v4; // rax _DWORD *v5; // rdx _DWORD *v6; // rcx int v7; // eax v2 = malloc(8LL * a1); if ( a1 > 0 ) { for ( i = 0LL; i != a1; ++i ) { v4 = malloc(4LL * a2); *(_QWORD *)(v2 + 8 * i) = v4; if ( a2 > 0 ) { v5 = (_DWORD *)v4; v6 = (_DWORD *)(v4 + 4 * ((unsigned int)(a2 - 1) + 1LL)); v7 = 0; do { *v5 = v7; v7 += i; ++v5; } while ( v5 != v6 ); } } } return v2; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV EBP,EDI MOV R12D,ESI MOVSXD RDI,EDI SHL RDI,0x3 CALL 0x001010b0 MOV R13,RAX TEST EBP,EBP JLE 0x00101220 MOVSXD R15,R12D SHL R15,0x2 MOV EBP,EBP LEA R14D,[R12 + -0x1] MOV EBX,0x0 ADD R14,0x1 LAB_001011ea: MOV RDI,R15 CALL 0x001010b0 MOV qword ptr [R13 + RBX*0x8],RAX TEST R12D,R12D JLE 0x00101217 MOV ESI,EBX MOV RDX,RAX LEA RCX,[RAX + R14*0x4] MOV EAX,0x0 LAB_0010120a: MOV dword ptr [RDX],EAX ADD EAX,ESI ADD RDX,0x4 CMP RDX,RCX JNZ 0x0010120a LAB_00101217: ADD RBX,0x1 CMP RBX,RBP JNZ 0x001011ea LAB_00101220: MOV RAX,R13 ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET
void * func0(uint param_1,int param_2) { int *piVar1; int iVar2; void *pvVar3; int *piVar4; ulong uVar5; pvVar3 = malloc((long)(int)param_1 << 3); if (0 < (int)param_1) { uVar5 = 0; do { piVar4 = (int *)malloc((long)param_2 << 2); *(int **)((long)pvVar3 + uVar5 * 8) = piVar4; if (0 < param_2) { piVar1 = piVar4 + (ulong)(param_2 - 1) + 1; iVar2 = 0; do { *piVar4 = iVar2; iVar2 = iVar2 + (int)uVar5; piVar4 = piVar4 + 1; } while (piVar4 != piVar1); } uVar5 = uVar5 + 1; } while (uVar5 != param_1); } return pvVar3; }
5,414
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h>
int** func0(int rownum, int colnum) { int **matrix = malloc(rownum * sizeof(int*)); for (int i = 0; i < rownum; i++) { matrix[i] = malloc(colnum * sizeof(int)); for (int j = 0; j < colnum; j++) { matrix[i][j] = i * j; } } return matrix; }
int main() { int **result; int i, j; result = func0(3, 4); int expected_3_4[3][4] = {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}}; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { assert(result[i][j] == expected_3_4[i][j]); } } result = func0(5, 7); int expected_5_7[5][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6}, {0, 2, 4, 6, 8, 10, 12}, {0, 3, 6, 9, 12, 15, 18}, {0, 4, 8, 12, 16, 20, 24}}; for (i = 0; i < 5; i++) { for (j = 0; j < 7; j++) { assert(result[i][j] == expected_5_7[i][j]); } } result = func0(10, 15); int expected_10_15[10][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}, {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42}, {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56}, {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70}, {0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84}, {0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112}, {0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126}}; for (i = 0; i < 10; i++) { for (j = 0; j < 15; j++) { assert(result[i][j] == expected_10_15[i][j]); } } for (i = 0; i < 10; i++) { free(result[i]); } free(result); return 0; }
O2
c
func0: endbr64 push %r15 movslq %edi,%rdi push %r14 push %r13 push %r12 push %rbp mov %rdi,%rbp shl $0x3,%rdi push %rbx mov %esi,%ebx sub $0x8,%rsp callq 10b0 <malloc@plt> mov %rax,%r12 test %ebp,%ebp jle 1550 <func0+0x80> movslq %ebx,%r13 lea -0x1(%rbp),%r14d lea -0x1(%rbx),%ebp xor %r15d,%r15d shl $0x2,%r13 add $0x1,%rbp mov %r13,%rdi callq 10b0 <malloc@plt> mov %rax,(%r12,%r15,8) test %ebx,%ebx jle 153d <func0+0x6d> mov %r15d,%esi lea (%rax,%rbp,4),%rcx xor %edx,%edx nopl 0x0(%rax) mov %edx,(%rax) add $0x4,%rax add %esi,%edx cmp %rcx,%rax jne 1530 <func0+0x60> lea 0x1(%r15),%rax cmp %r14,%r15 je 1550 <func0+0x80> mov %rax,%r15 jmp 1510 <func0+0x40> nopl 0x0(%rax,%rax,1) add $0x8,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push r15 push r14 movsxd r14, edi push r13 lea rdi, ds:0[r14*8] push r12 push rbp push rbx mov ebx, esi sub rsp, 8 call _malloc mov r12, rax test r14d, r14d jle short loc_1536 movsxd r13, ebx lea ebp, [rbx-1] xor r15d, r15d shl r13, 2 add rbp, 1 nop dword ptr [rax] loc_1500: mov rdi, r13 call _malloc mov [r12+r15*8], rax test ebx, ebx jle short loc_152D mov esi, r15d lea rcx, [rax+rbp*4] xor edx, edx nop dword ptr [rax+00000000h] loc_1520: mov [rax], edx add rax, 4 add edx, esi cmp rax, rcx jnz short loc_1520 loc_152D: add r15, 1 cmp r15, r14 jnz short loc_1500 loc_1536: add rsp, 8 mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn
long long func0(int a1, int a2) { long long v2; // r12 long long i; // r15 _DWORD *v4; // rax _DWORD *v5; // rcx int v6; // edx v2 = malloc(8LL * a1); if ( a1 > 0 ) { for ( i = 0LL; i != a1; ++i ) { v4 = (_DWORD *)malloc(4LL * a2); *(_QWORD *)(v2 + 8 * i) = v4; if ( a2 > 0 ) { v5 = &v4[a2 - 1 + 1]; v6 = 0; do { *v4++ = v6; v6 += i; } while ( v4 != v5 ); } } } return v2; }
func0: ENDBR64 PUSH R15 PUSH R14 MOVSXD R14,EDI PUSH R13 LEA RDI,[R14*0x8] PUSH R12 PUSH RBP PUSH RBX MOV EBX,ESI SUB RSP,0x8 CALL 0x001010b0 MOV R12,RAX TEST R14D,R14D JLE 0x00101536 MOVSXD R13,EBX LEA EBP,[RBX + -0x1] XOR R15D,R15D SHL R13,0x2 ADD RBP,0x1 NOP dword ptr [RAX] LAB_00101500: MOV RDI,R13 CALL 0x001010b0 MOV qword ptr [R12 + R15*0x8],RAX TEST EBX,EBX JLE 0x0010152d MOV ESI,R15D LEA RCX,[RAX + RBP*0x4] XOR EDX,EDX NOP dword ptr [RAX] LAB_00101520: MOV dword ptr [RAX],EDX ADD RAX,0x4 ADD EDX,ESI CMP RAX,RCX JNZ 0x00101520 LAB_0010152d: ADD R15,0x1 CMP R15,R14 JNZ 0x00101500 LAB_00101536: ADD RSP,0x8 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET
void * func0(int param_1,int param_2) { int *piVar1; void *pvVar2; int *piVar3; int iVar4; long lVar5; pvVar2 = malloc((long)param_1 * 8); if (0 < param_1) { lVar5 = 0; do { piVar3 = (int *)malloc((long)param_2 << 2); *(int **)((long)pvVar2 + lVar5 * 8) = piVar3; if (0 < param_2) { piVar1 = piVar3 + (ulong)(param_2 - 1) + 1; iVar4 = 0; do { *piVar3 = iVar4; piVar3 = piVar3 + 1; iVar4 = iVar4 + (int)lVar5; } while (piVar3 != piVar1); } lVar5 = lVar5 + 1; } while (lVar5 != param_1); } return pvVar2; }
5,415
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h>
int** func0(int rownum, int colnum) { int **matrix = malloc(rownum * sizeof(int*)); for (int i = 0; i < rownum; i++) { matrix[i] = malloc(colnum * sizeof(int)); for (int j = 0; j < colnum; j++) { matrix[i][j] = i * j; } } return matrix; }
int main() { int **result; int i, j; result = func0(3, 4); int expected_3_4[3][4] = {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}}; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { assert(result[i][j] == expected_3_4[i][j]); } } result = func0(5, 7); int expected_5_7[5][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6}, {0, 2, 4, 6, 8, 10, 12}, {0, 3, 6, 9, 12, 15, 18}, {0, 4, 8, 12, 16, 20, 24}}; for (i = 0; i < 5; i++) { for (j = 0; j < 7; j++) { assert(result[i][j] == expected_5_7[i][j]); } } result = func0(10, 15); int expected_10_15[10][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}, {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42}, {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56}, {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70}, {0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84}, {0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98}, {0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112}, {0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126}}; for (i = 0; i < 10; i++) { for (j = 0; j < 15; j++) { assert(result[i][j] == expected_10_15[i][j]); } } for (i = 0; i < 10; i++) { free(result[i]); } free(result); return 0; }
O3
c
func0: endbr64 push %r15 movslq %edi,%rdi push %r14 mov %esi,%r14d push %r13 push %r12 push %rbp push %rbx mov %rdi,%rbx shl $0x3,%rdi sub $0x28,%rsp callq 10b0 <malloc@plt> mov %rax,%r12 test %ebx,%ebx jle 1800 <func0+0x140> mov %r14d,%ebp lea -0x1(%rbx),%eax movslq %r14d,%r13 mov %r14d,%ebx shr $0x2,%ebp mov %rax,0x8(%rsp) lea -0x1(%r14),%eax shl $0x2,%r13 shl $0x4,%rbp mov %eax,0x14(%rsp) and $0xfffffffc,%ebx xor %r15d,%r15d mov %rbp,0x18(%rsp) xchg %ax,%ax mov %r13,%rdi mov %r15d,%ebp callq 10b0 <malloc@plt> test %r14d,%r14d movdqa 0xbfa(%rip),%xmm5 mov %rax,(%r12,%r15,8) jle 17e8 <func0+0x128> cmpl $0x2,0x14(%rsp) jbe 1812 <func0+0x152> movd %r15d,%xmm6 mov 0x18(%rsp),%rdi movdqa 0xbc3(%rip),%xmm2 mov %rax,%rdx pshufd $0x0,%xmm6,%xmm3 movdqa %xmm3,%xmm4 lea (%rdi,%rax,1),%rcx psrlq $0x20,%xmm4 nopw 0x0(%rax,%rax,1) movdqa %xmm2,%xmm0 add $0x10,%rdx paddd %xmm5,%xmm2 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 1778 <func0+0xb8> mov %ebx,%edx cmp %ebx,%r14d je 17e8 <func0+0x128> mov %edx,%ecx movslq %edx,%r10 imul %ebp,%ecx lea 0x0(,%r10,4),%rdi mov %ecx,(%rax,%r10,4) lea 0x1(%rdx),%r10d cmp %r10d,%r14d jle 17e8 <func0+0x128> add %ebp,%ecx add $0x2,%edx mov %ecx,0x4(%rax,%rdi,1) cmp %edx,%r14d jle 17e8 <func0+0x128> lea 0x0(%rbp,%rcx,1),%r9d mov %r9d,0x8(%rax,%rdi,1) lea 0x1(%r15),%rax cmp 0x8(%rsp),%r15 je 1800 <func0+0x140> mov %rax,%r15 jmpq 1720 <func0+0x60> nopl 0x0(%rax,%rax,1) add $0x28,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq xor %edx,%edx jmp 17b3 <func0+0xf3> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 mov r15d, esi push r14 movsxd r14, edi push r13 lea rdi, ds:0[r14*8]; size push r12 push rbp push rbx sub rsp, 28h call _malloc mov rbp, rax test r14d, r14d jle loc_16CE movsxd r13, r15d mov r12d, r15d mov ebx, r15d lea rax, ds:0[r13*4] shr r12d, 2 and ebx, 0FFFFFFFCh xor r13d, r13d mov [rsp+58h+size], rax shl r12, 4 lea eax, [r15-1] mov [rsp+58h+var_44], eax mov [rsp+58h+var_40], r12 nop word ptr [rax+rax+00h] loc_15F8: mov rdi, [rsp+58h+size]; size mov r12d, r13d call _malloc test r15d, r15d movdqa xmm5, cs:xmmword_2310 mov [rbp+r13*8+0], rax mov rdx, rax jle loc_16C1 cmp [rsp+58h+var_44], 2 jbe loc_16E0 movd xmm6, r13d mov rsi, [rsp+58h+var_40] movdqa xmm2, cs:xmmword_2300 pshufd xmm3, xmm6, 0 movdqa xmm4, xmm3 lea rcx, [rsi+rax] psrlq xmm4, 20h ; ' ' nop dword ptr [rax] loc_1650: movdqa xmm0, xmm2 add rax, 10h paddd xmm2, 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, rcx jnz short loc_1650 mov eax, ebx cmp r15d, ebx jz short loc_16C1 loc_168B: mov ecx, r12d movsxd r10, eax imul ecx, eax lea rdi, ds:0[r10*4] mov [rdx+r10*4], ecx lea r10d, [rax+1] cmp r15d, r10d jle short loc_16C1 add ecx, r12d add eax, 2 mov [rdx+rdi+4], ecx cmp r15d, eax jle short loc_16C1 lea r8d, [r12+rcx] mov [rdx+rdi+8], r8d loc_16C1: add r13, 1 cmp r14, r13 jnz loc_15F8 loc_16CE: add rsp, 28h mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_16E0: xor eax, eax jmp short loc_168B
_QWORD * func0(int a1, int a2) { long long v2; // r14 _QWORD *v3; // rbp long long i; // r13 __m128i *v5; // rax __m128i si128; // xmm5 __m128i *v7; // rdx __m128i v8; // xmm2 __m128i v9; // xmm3 __m128i *v10; // rcx __m128i v11; // xmm4 __m128i v12; // xmm0 signed int v13; // eax long long v14; // rdi __int32 v15; // ecx v2 = a1; v3 = malloc(8LL * a1); if ( a1 > 0 ) { for ( i = 0LL; v2 != i; ++i ) { v5 = (__m128i *)malloc(4LL * a2); si128 = _mm_load_si128((const __m128i *)&xmmword_2310); v3[i] = v5; v7 = v5; if ( a2 > 0 ) { if ( (unsigned int)(a2 - 1) <= 2 ) { v13 = 0; LABEL_8: v14 = v13; v7->m128i_i32[v14] = v13 * i; if ( a2 > v13 + 1 ) { v15 = i + v13 * i; v7->m128i_i32[v14 + 1] = v15; if ( a2 > v13 + 2 ) v7->m128i_i32[v14 + 2] = i + v15; } continue; } v8 = _mm_load_si128((const __m128i *)&xmmword_2300); v9 = _mm_shuffle_epi32(_mm_cvtsi32_si128(i), 0); v10 = &v5[(unsigned int)a2 >> 2]; v11 = _mm_srli_epi64(v9, 0x20u); do { v12 = v8; ++v5; v8 = _mm_add_epi32(v8, si128); v5[-1] = _mm_unpacklo_epi32( _mm_shuffle_epi32(_mm_mul_epu32(v12, v9), 8), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_epi64(v12, 0x20u), v11), 8)); } while ( v5 != v10 ); v13 = a2 & 0xFFFFFFFC; if ( a2 != (a2 & 0xFFFFFFFC) ) goto LABEL_8; } } } return v3; }
func0: ENDBR64 PUSH R15 MOV R15D,ESI PUSH R14 MOVSXD R14,EDI PUSH R13 LEA RDI,[R14*0x8] PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x28 CALL 0x001010b0 MOV RBP,RAX TEST R14D,R14D JLE 0x001016ce MOVSXD R13,R15D MOV R12D,R15D MOV EBX,R15D LEA RAX,[R13*0x4] SHR R12D,0x2 AND EBX,0xfffffffc XOR R13D,R13D MOV qword ptr [RSP + 0x8],RAX SHL R12,0x4 LEA EAX,[R15 + -0x1] MOV dword ptr [RSP + 0x14],EAX MOV qword ptr [RSP + 0x18],R12 NOP word ptr [RAX + RAX*0x1] LAB_001015f8: MOV RDI,qword ptr [RSP + 0x8] MOV R12D,R13D CALL 0x001010b0 TEST R15D,R15D MOVDQA XMM5,xmmword ptr [0x00102310] MOV qword ptr [RBP + R13*0x8],RAX MOV RDX,RAX JLE 0x001016c1 CMP dword ptr [RSP + 0x14],0x2 JBE 0x001016e0 MOVD XMM6,R13D MOV RSI,qword ptr [RSP + 0x18] MOVDQA XMM2,xmmword ptr [0x00102300] PSHUFD XMM3,XMM6,0x0 MOVDQA XMM4,XMM3 LEA RCX,[RSI + RAX*0x1] PSRLQ XMM4,0x20 NOP dword ptr [RAX] LAB_00101650: MOVDQA XMM0,XMM2 ADD RAX,0x10 PADDD XMM2,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,RCX JNZ 0x00101650 MOV EAX,EBX CMP R15D,EBX JZ 0x001016c1 LAB_0010168b: MOV ECX,R12D MOVSXD R10,EAX IMUL ECX,EAX LEA RDI,[R10*0x4] MOV dword ptr [RDX + R10*0x4],ECX LEA R10D,[RAX + 0x1] CMP R15D,R10D JLE 0x001016c1 ADD ECX,R12D ADD EAX,0x2 MOV dword ptr [RDX + RDI*0x1 + 0x4],ECX CMP R15D,EAX JLE 0x001016c1 LEA R8D,[R12 + RCX*0x1] MOV dword ptr [RDX + RDI*0x1 + 0x8],R8D LAB_001016c1: ADD R13,0x1 CMP R14,R13 JNZ 0x001015f8 LAB_001016ce: ADD RSP,0x28 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001016e0: XOR EAX,EAX JMP 0x0010168b
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ void * func0(int param_1,uint param_2) { long lVar1; int auVar2 [16]; int iVar3; int iVar4; int iVar5; uint uVar6; void *pvVar7; int8 *puVar8; int8 *puVar9; int8 *puVar10; int iVar11; int iVar12; ulong uVar13; int auVar14 [16]; int auVar15 [16]; pvVar7 = malloc((long)param_1 * 8); if (0 < param_1) { uVar13 = 0; do { iVar12 = (int)uVar13; puVar8 = (int8 *)malloc((long)(int)param_2 * 4); iVar5 = _UNK_0010231c; iVar4 = _UNK_00102318; iVar3 = _UNK_00102314; iVar11 = _DAT_00102310; *(int8 **)((long)pvVar7 + uVar13 * 8) = puVar8; if (0 < (int)param_2) { if (param_2 - 1 < 3) { uVar6 = 0; } else { auVar2._4_4_ = iVar12; auVar2._0_4_ = iVar12; auVar2._8_4_ = iVar12; auVar2._12_4_ = iVar12; puVar9 = puVar8; auVar14 = _DAT_00102300; do { puVar10 = puVar9 + 2; auVar15._0_4_ = auVar14._0_4_ + iVar11; auVar15._4_4_ = auVar14._4_4_ + iVar3; auVar15._8_4_ = auVar14._8_4_ + iVar4; auVar15._12_4_ = auVar14._12_4_ + iVar5; *puVar9 = CONCAT44((int)((auVar14._0_8_ >> 0x20) * (uVar13 & 0xffffffff)), (int)((ulong)auVar14._0_4_ * (uVar13 & 0xffffffff))); *(int *)(puVar9 + 2) = (int)((auVar14._8_8_ & 0xffffffff) * (uVar13 & 0xffffffff)); *(int *)((long)puVar9 + 0x14) = (int)((auVar14._8_8_ >> 0x20) * (auVar2._8_8_ >> 0x20)); puVar9 = puVar10; auVar14 = auVar15; } while (puVar10 != puVar8 + (ulong)(param_2 >> 2) * 2); uVar6 = param_2 & 0xfffffffc; if (param_2 == (param_2 & 0xfffffffc)) goto LAB_001016c1; } lVar1 = (long)(int)uVar6 * 4; *(uint *)((long)puVar8 + (long)(int)uVar6 * 4) = iVar12 * uVar6; if ((int)(uVar6 + 1) < (int)param_2) { iVar11 = iVar12 * uVar6 + iVar12; *(int *)((long)puVar8 + lVar1 + 4) = iVar11; if ((int)(uVar6 + 2) < (int)param_2) { *(int *)((long)puVar8 + lVar1 + 8) = iVar12 + iVar11; } } } LAB_001016c1: uVar13 = uVar13 + 1; } while ((long)param_1 != uVar13); } return pvVar7; }
5,416
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct { const char* name; int score1; int score2; } Tuple; int compare_by_index(const void *a, const void *b, void *index_ptr) { int index = *(int*)index_ptr; Tuple *tupleA = (Tuple*)a; Tuple *tupleB = (Tuple*)b; if (index == 0) { return strcmp(tupleA->name, tupleB->name); } else if (index == 1) { return (tupleA->score1 - tupleB->score1); } else if (index == 2) { return (tupleA->score2 - tupleB->score2); } return 0; // Should never be reached, assuming valid index }
void func0(Tuple *list_data, int size, int index_no) { qsort_r(list_data, size, sizeof(Tuple), compare_by_index, &index_no); }
int main() { Tuple data[] = { {"Greyson Fulton", 98, 99}, {"Brady Kent", 97, 96}, {"Wyatt Knott", 91, 94}, {"Beau Turnbull", 94, 98} }; int num_tuples = sizeof(data) / sizeof(data[0]); func0(data, num_tuples, 0); assert(strcmp(data[0].name, "Beau Turnbull") == 0 && strcmp(data[1].name, "Brady Kent") == 0 && strcmp(data[2].name, "Greyson Fulton") == 0 && strcmp(data[3].name, "Wyatt Knott") == 0); func0(data, num_tuples, 1); assert(data[0].score1 == 91 && data[1].score1 == 94 && data[2].score1 == 97 && data[3].score1 == 98); func0(data, num_tuples, 2); assert(data[0].score2 == 94 && data[1].score2 == 96 && data[2].score2 == 98 && data[3].score2 == 99); 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 -0xb8(%rip),%rcx mov $0x10,%edx mov %rax,%rdi mov $0x0,%eax callq 10b0 <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_by_index mov rcx, rdx; compar mov edx, 10h; 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, 0x10uLL, compare_by_index, 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,[0x1011a9] MOV RCX,RDX MOV EDX,0x10 MOV RDI,RAX MOV EAX,0x0 CALL 0x001010b0 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,0x10,compare_by_index,&local_18); return; }
5,417
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct { const char* name; int score1; int score2; } Tuple; int compare_by_index(const void *a, const void *b, void *index_ptr) { int index = *(int*)index_ptr; Tuple *tupleA = (Tuple*)a; Tuple *tupleB = (Tuple*)b; if (index == 0) { return strcmp(tupleA->name, tupleB->name); } else if (index == 1) { return (tupleA->score1 - tupleB->score1); } else if (index == 2) { return (tupleA->score2 - tupleB->score2); } return 0; // Should never be reached, assuming valid index }
void func0(Tuple *list_data, int size, int index_no) { qsort_r(list_data, size, sizeof(Tuple), compare_by_index, &index_no); }
int main() { Tuple data[] = { {"Greyson Fulton", 98, 99}, {"Brady Kent", 97, 96}, {"Wyatt Knott", 91, 94}, {"Beau Turnbull", 94, 98} }; int num_tuples = sizeof(data) / sizeof(data[0]); func0(data, num_tuples, 0); assert(strcmp(data[0].name, "Beau Turnbull") == 0 && strcmp(data[1].name, "Brady Kent") == 0 && strcmp(data[2].name, "Greyson Fulton") == 0 && strcmp(data[3].name, "Wyatt Knott") == 0); func0(data, num_tuples, 1); assert(data[0].score1 == 91 && data[1].score1 == 94 && data[2].score1 == 97 && data[3].score1 == 98); func0(data, num_tuples, 2); assert(data[0].score2 == 94 && data[1].score2 == 96 && data[2].score2 == 98 && data[3].score2 == 99); return 0; }
O1
c
func0: endbr64 sub $0x18,%rsp mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 lea -0x54(%rip),%rcx mov $0x10,%edx mov $0x0,%eax callq 10b0 <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_by_index mov edx, 10h 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, 16LL, compare_by_index, v4); }
func0: ENDBR64 SUB RSP,0x18 MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] LEA RCX,[0x1011a9] MOV EDX,0x10 MOV EAX,0x0 CALL 0x001010b0 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,0x10,compare_by_index,local_c); return; }
5,418
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct { const char* name; int score1; int score2; } Tuple; int compare_by_index(const void *a, const void *b, void *index_ptr) { int index = *(int*)index_ptr; Tuple *tupleA = (Tuple*)a; Tuple *tupleB = (Tuple*)b; if (index == 0) { return strcmp(tupleA->name, tupleB->name); } else if (index == 1) { return (tupleA->score1 - tupleB->score1); } else if (index == 2) { return (tupleA->score2 - tupleB->score2); } return 0; // Should never be reached, assuming valid index }
void func0(Tuple *list_data, int size, int index_no) { qsort_r(list_data, size, sizeof(Tuple), compare_by_index, &index_no); }
int main() { Tuple data[] = { {"Greyson Fulton", 98, 99}, {"Brady Kent", 97, 96}, {"Wyatt Knott", 91, 94}, {"Beau Turnbull", 94, 98} }; int num_tuples = sizeof(data) / sizeof(data[0]); func0(data, num_tuples, 0); assert(strcmp(data[0].name, "Beau Turnbull") == 0 && strcmp(data[1].name, "Brady Kent") == 0 && strcmp(data[2].name, "Greyson Fulton") == 0 && strcmp(data[3].name, "Wyatt Knott") == 0); func0(data, num_tuples, 1); assert(data[0].score1 == 91 && data[1].score1 == 94 && data[2].score1 == 97 && data[3].score1 == 98); func0(data, num_tuples, 2); assert(data[0].score2 == 94 && data[1].score2 == 96 && data[2].score2 == 98 && data[3].score2 == 99); return 0; }
O2
c
func0: endbr64 sub $0x18,%rsp lea -0x5f(%rip),%rcx xor %eax,%eax mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 mov $0x10,%edx callq 10b0 <qsort_r@plt> add $0x18,%rsp retq nopl 0x0(%rax)
func0: endbr64 sub rsp, 18h lea rcx, compare_by_index xor eax, eax mov [rsp+18h+var_C], edx lea r8, [rsp+18h+var_C] mov edx, 10h 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, 16LL, compare_by_index, v4); }
func0: ENDBR64 SUB RSP,0x18 LEA RCX,[0x1013e0] XOR EAX,EAX MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] MOV EDX,0x10 CALL 0x001010b0 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,0x10,compare_by_index,local_c); return; }
5,419
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct { const char* name; int score1; int score2; } Tuple; int compare_by_index(const void *a, const void *b, void *index_ptr) { int index = *(int*)index_ptr; Tuple *tupleA = (Tuple*)a; Tuple *tupleB = (Tuple*)b; if (index == 0) { return strcmp(tupleA->name, tupleB->name); } else if (index == 1) { return (tupleA->score1 - tupleB->score1); } else if (index == 2) { return (tupleA->score2 - tupleB->score2); } return 0; // Should never be reached, assuming valid index }
void func0(Tuple *list_data, int size, int index_no) { qsort_r(list_data, size, sizeof(Tuple), compare_by_index, &index_no); }
int main() { Tuple data[] = { {"Greyson Fulton", 98, 99}, {"Brady Kent", 97, 96}, {"Wyatt Knott", 91, 94}, {"Beau Turnbull", 94, 98} }; int num_tuples = sizeof(data) / sizeof(data[0]); func0(data, num_tuples, 0); assert(strcmp(data[0].name, "Beau Turnbull") == 0 && strcmp(data[1].name, "Brady Kent") == 0 && strcmp(data[2].name, "Greyson Fulton") == 0 && strcmp(data[3].name, "Wyatt Knott") == 0); func0(data, num_tuples, 1); assert(data[0].score1 == 91 && data[1].score1 == 94 && data[2].score1 == 97 && data[3].score1 == 98); func0(data, num_tuples, 2); assert(data[0].score2 == 94 && data[1].score2 == 96 && data[2].score2 == 98 && data[3].score2 == 99); return 0; }
O3
c
func0: endbr64 sub $0x18,%rsp lea -0x5f(%rip),%rcx xor %eax,%eax mov %edx,0xc(%rsp) lea 0xc(%rsp),%r8 mov $0x10,%edx callq 10b0 <qsort_r@plt> add $0x18,%rsp retq nopl 0x0(%rax)
func0: endbr64 sub rsp, 18h lea rcx, compare_by_index; compar xor eax, eax mov [rsp+18h+arg], edx lea r8, [rsp+18h+arg]; arg mov edx, 10h; 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, 0x10uLL, compare_by_index, arg); }
func0: ENDBR64 SUB RSP,0x18 LEA RCX,[0x1013d0] XOR EAX,EAX MOV dword ptr [RSP + 0xc],EDX LEA R8,[RSP + 0xc] MOV EDX,0x10 CALL 0x001010b0 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,0x10,compare_by_index,local_c); return; }
5,420
func0
#include <assert.h>
int func0(int A[], int n) { int left = 0; int right = n - 1; while (left <= right) { if (A[left] <= A[right]) { return left; } int mid = (left + right) / 2; int next = (mid + 1) % n; int prev = (mid - 1 + n) % n; if (A[mid] <= A[next] && A[mid] <= A[prev]) { return mid; } else if (A[mid] <= A[right]) { right = mid - 1; } else if (A[mid] >= A[left]) { left = mid + 1; } } return -1; }
int main() { int arr1[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}; int n1 = sizeof(arr1) / sizeof(arr1[0]); assert(func0(arr1, n1) == 3); int arr2[] = {8, 9, 10, 2, 5, 6}; int n2 = sizeof(arr2) / sizeof(arr2[0]); assert(func0(arr2, n2) == 3); int arr3[] = {2, 5, 6, 8, 9, 10}; int n3 = sizeof(arr3) / sizeof(arr3[0]); assert(func0(arr3, n3) == 0); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) movl $0x0,-0x14(%rbp) mov -0x2c(%rbp),%eax sub $0x1,%eax mov %eax,-0x10(%rbp) jmpq 12d4 <func0+0x16b> mov -0x14(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jg 11c5 <func0+0x5c> mov -0x14(%rbp),%eax jmpq 12e5 <func0+0x17c> mov -0x14(%rbp),%edx mov -0x10(%rbp),%eax add %edx,%eax mov %eax,%edx shr $0x1f,%edx add %edx,%eax sar %eax mov %eax,-0xc(%rbp) mov -0xc(%rbp),%eax add $0x1,%eax cltd idivl -0x2c(%rbp) mov %edx,-0x8(%rbp) mov -0xc(%rbp),%eax lea -0x1(%rax),%edx mov -0x2c(%rbp),%eax add %edx,%eax cltd idivl -0x2c(%rbp) mov %edx,-0x4(%rbp) 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 jg 1260 <func0+0xf7> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jg 1260 <func0+0xf7> mov -0xc(%rbp),%eax jmpq 12e5 <func0+0x17c> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jg 129b <func0+0x132> mov -0xc(%rbp),%eax sub $0x1,%eax mov %eax,-0x10(%rbp) jmp 12d4 <func0+0x16b> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x14(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jl 12d4 <func0+0x16b> mov -0xc(%rbp),%eax add $0x1,%eax mov %eax,-0x14(%rbp) mov -0x14(%rbp),%eax cmp -0x10(%rbp),%eax jle 118d <func0+0x24> mov $0xffffffff,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov [rbp+var_14], 0 mov eax, [rbp+var_2C] sub eax, 1 mov [rbp+var_10], eax jmp loc_12D4 loc_118D: mov eax, [rbp+var_14] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_10] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jg short loc_11C5 mov eax, [rbp+var_14] jmp loc_12E5 loc_11C5: mov edx, [rbp+var_14] mov eax, [rbp+var_10] add eax, edx mov edx, eax shr edx, 1Fh add eax, edx sar eax, 1 mov [rbp+var_C], eax mov eax, [rbp+var_C] add eax, 1 cdq idiv [rbp+var_2C] mov [rbp+var_8], edx mov eax, [rbp+var_C] lea edx, [rax-1] mov eax, [rbp+var_2C] add eax, edx cdq idiv [rbp+var_2C] mov [rbp+var_4], edx 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 jg short loc_1260 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_4] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jg short loc_1260 mov eax, [rbp+var_C] jmp loc_12E5 loc_1260: 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_10] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jg short loc_129B mov eax, [rbp+var_C] sub eax, 1 mov [rbp+var_10], eax jmp short loc_12D4 loc_129B: 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_14] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jl short loc_12D4 mov eax, [rbp+var_C] add eax, 1 mov [rbp+var_14], eax loc_12D4: mov eax, [rbp+var_14] cmp eax, [rbp+var_10] jle loc_118D mov eax, 0FFFFFFFFh loc_12E5: pop rbp retn
long long func0(long long a1, int a2) { int v3; // [rsp+18h] [rbp-14h] int v4; // [rsp+1Ch] [rbp-10h] int v5; // [rsp+20h] [rbp-Ch] v3 = 0; v4 = a2 - 1; while ( v3 <= v4 ) { if ( *(_DWORD *)(4LL * v3 + a1) <= *(_DWORD *)(4LL * v4 + a1) ) return (unsigned int)v3; v5 = (v3 + v4) / 2; if ( *(_DWORD *)(4LL * v5 + a1) <= *(_DWORD *)(4LL * ((v5 + 1) % a2) + a1) && *(_DWORD *)(4LL * v5 + a1) <= *(_DWORD *)(4LL * (((v3 + v4) / 2 - 1 + a2) % a2) + a1) ) { return (unsigned int)v5; } if ( *(_DWORD *)(4LL * v5 + a1) > *(_DWORD *)(4LL * v4 + a1) ) { if ( *(_DWORD *)(4LL * v5 + a1) >= *(_DWORD *)(4LL * v3 + a1) ) v3 = v5 + 1; } else { v4 = v5 - 1; } } return 0xFFFFFFFFLL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV dword ptr [RBP + -0x14],0x0 MOV EAX,dword ptr [RBP + -0x2c] SUB EAX,0x1 MOV dword ptr [RBP + -0x10],EAX JMP 0x001012d4 LAB_0010118d: MOV EAX,dword ptr [RBP + -0x14] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JG 0x001011c5 MOV EAX,dword ptr [RBP + -0x14] JMP 0x001012e5 LAB_001011c5: MOV EDX,dword ptr [RBP + -0x14] MOV EAX,dword ptr [RBP + -0x10] ADD EAX,EDX MOV EDX,EAX SHR EDX,0x1f ADD EAX,EDX SAR EAX,0x1 MOV dword ptr [RBP + -0xc],EAX MOV EAX,dword ptr [RBP + -0xc] ADD EAX,0x1 CDQ IDIV dword ptr [RBP + -0x2c] MOV dword ptr [RBP + -0x8],EDX MOV EAX,dword ptr [RBP + -0xc] LEA EDX,[RAX + -0x1] MOV EAX,dword ptr [RBP + -0x2c] ADD EAX,EDX CDQ IDIV dword ptr [RBP + -0x2c] MOV dword ptr [RBP + -0x4],EDX 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 JG 0x00101260 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 + -0x4] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JG 0x00101260 MOV EAX,dword ptr [RBP + -0xc] JMP 0x001012e5 LAB_00101260: 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 + -0x10] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JG 0x0010129b MOV EAX,dword ptr [RBP + -0xc] SUB EAX,0x1 MOV dword ptr [RBP + -0x10],EAX JMP 0x001012d4 LAB_0010129b: 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 + -0x14] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JL 0x001012d4 MOV EAX,dword ptr [RBP + -0xc] ADD EAX,0x1 MOV dword ptr [RBP + -0x14],EAX LAB_001012d4: MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x10] JLE 0x0010118d MOV EAX,0xffffffff LAB_001012e5: POP RBP RET
int func0(long param_1,int param_2) { int iVar1; int local_1c; int local_18; local_1c = 0; local_18 = param_2 + -1; while( true ) { if (local_18 < local_1c) { return -1; } if (*(int *)(param_1 + (long)local_1c * 4) <= *(int *)(param_1 + (long)local_18 * 4)) break; iVar1 = (local_18 + local_1c) / 2; if ((*(int *)(param_1 + (long)iVar1 * 4) <= *(int *)(param_1 + (long)((iVar1 + 1) % param_2) * 4)) && (*(int *)(param_1 + (long)iVar1 * 4) <= *(int *)(param_1 + (long)((param_2 + iVar1 + -1) % param_2) * 4))) { return iVar1; } if (*(int *)(param_1 + (long)local_18 * 4) < *(int *)(param_1 + (long)iVar1 * 4)) { if (*(int *)(param_1 + (long)local_1c * 4) <= *(int *)(param_1 + (long)iVar1 * 4)) { local_1c = iVar1 + 1; } } else { local_18 = iVar1 + -1; } } return local_1c; }
5,421
func0
#include <assert.h>
int func0(int A[], int n) { int left = 0; int right = n - 1; while (left <= right) { if (A[left] <= A[right]) { return left; } int mid = (left + right) / 2; int next = (mid + 1) % n; int prev = (mid - 1 + n) % n; if (A[mid] <= A[next] && A[mid] <= A[prev]) { return mid; } else if (A[mid] <= A[right]) { right = mid - 1; } else if (A[mid] >= A[left]) { left = mid + 1; } } return -1; }
int main() { int arr1[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}; int n1 = sizeof(arr1) / sizeof(arr1[0]); assert(func0(arr1, n1) == 3); int arr2[] = {8, 9, 10, 2, 5, 6}; int n2 = sizeof(arr2) / sizeof(arr2[0]); assert(func0(arr2, n2) == 3); int arr3[] = {2, 5, 6, 8, 9, 10}; int n3 = sizeof(arr3) / sizeof(arr3[0]); assert(func0(arr3, n3) == 0); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx lea -0x1(%rsi),%ecx mov $0x0,%r10d movslq %r10d,%rax lea (%rdi,%rax,4),%rbx jmp 118c <func0+0x23> cmp %r13d,%r8d jl 11e1 <func0+0x78> mov %ebp,%ecx cmp %ecx,%r10d jg 11ea <func0+0x81> mov (%rbx),%r11d movslq %ecx,%rax mov (%rdi,%rax,4),%r8d cmp %r8d,%r11d jle 11f0 <func0+0x87> lea (%r10,%rcx,1),%edx mov %edx,%eax shr $0x1f,%eax add %edx,%eax sar %eax mov %eax,%r12d lea 0x1(%rax),%r9d lea -0x1(%rax),%ebp cltq mov (%rdi,%rax,4),%r13d mov %r9d,%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r13d jg 1185 <func0+0x1c> lea 0x0(%rbp,%rsi,1),%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r13d jg 1185 <func0+0x1c> mov %r12d,%r10d jmp 11f0 <func0+0x87> cmp %r13d,%r11d cmovle %r9d,%r10d jmp 117c <func0+0x13> mov $0xffffffff,%r10d mov %r10d,%eax pop %rbx pop %rbp pop %r12 pop %r13 retq
func0: endbr64 push r13 push r12 push rbp push rbx mov r8d, esi lea esi, [rsi-1] mov r11d, 0 loc_117F: movsxd rax, r11d lea rbp, [rdi+rax*4] jmp short loc_1190 loc_1188: cmp r10d, r9d jl short loc_11E7 mov esi, r13d loc_1190: cmp r11d, esi jg short loc_11F0 mov ebx, [rbp+0] movsxd rax, esi mov r10d, [rdi+rax*4] cmp ebx, r10d jle short loc_11F6 lea eax, [r11+rsi] mov ecx, eax shr ecx, 1Fh add ecx, eax sar ecx, 1 lea r12d, [rcx+1] lea r13d, [rcx-1] movsxd rax, ecx mov r9d, [rdi+rax*4] mov eax, r12d cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jg short loc_1188 lea eax, [r13+r8+0] cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jg short loc_1188 mov r11d, ecx jmp short loc_11F6 loc_11E7: cmp ebx, r9d cmovle r11d, r12d jmp short loc_117F loc_11F0: mov r11d, 0FFFFFFFFh loc_11F6: mov eax, r11d pop rbx pop rbp pop r12 pop r13 retn
long long func0(long long a1, int a2) { int v3; // esi int v4; // r11d int v5; // ebx int v6; // r10d int v7; // ecx int v8; // r9d v3 = a2 - 1; v4 = 0; while ( v4 <= v3 ) { v5 = *(_DWORD *)(a1 + 4LL * v4); v6 = *(_DWORD *)(a1 + 4LL * v3); if ( v5 <= v6 ) return (unsigned int)v4; v7 = (v4 + v3) / 2; v8 = *(_DWORD *)(a1 + 4LL * v7); if ( v8 <= *(_DWORD *)(a1 + 4LL * ((v7 + 1) % a2)) && v8 <= *(_DWORD *)(a1 + 4LL * ((v7 - 1 + a2) % a2)) ) return (unsigned int)((v4 + v3) / 2); if ( v6 < v8 ) { if ( v5 <= v8 ) v4 = v7 + 1; } else { v3 = v7 - 1; } } return (unsigned int)-1; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R8D,ESI LEA ESI,[RSI + -0x1] MOV R11D,0x0 LAB_0010117f: MOVSXD RAX,R11D LEA RBP,[RDI + RAX*0x4] JMP 0x00101190 LAB_00101188: CMP R10D,R9D JL 0x001011e7 MOV ESI,R13D LAB_00101190: CMP R11D,ESI JG 0x001011f0 MOV EBX,dword ptr [RBP] MOVSXD RAX,ESI MOV R10D,dword ptr [RDI + RAX*0x4] CMP EBX,R10D JLE 0x001011f6 LEA EAX,[R11 + RSI*0x1] MOV ECX,EAX SHR ECX,0x1f ADD ECX,EAX SAR ECX,0x1 LEA R12D,[RCX + 0x1] LEA R13D,[RCX + -0x1] MOVSXD RAX,ECX MOV R9D,dword ptr [RDI + RAX*0x4] MOV EAX,R12D CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JG 0x00101188 LEA EAX,[R13 + R8*0x1] CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JG 0x00101188 MOV R11D,ECX JMP 0x001011f6 LAB_001011e7: CMP EBX,R9D CMOVLE R11D,R12D JMP 0x0010117f LAB_001011f0: MOV R11D,0xffffffff LAB_001011f6: MOV EAX,R11D POP RBX POP RBP POP R12 POP R13 RET
int func0(long param_1,int param_2) { int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; iVar6 = param_2 + -1; iVar7 = 0; do { iVar4 = iVar6; do { iVar6 = iVar4; if (iVar6 < iVar7) { return -1; } iVar1 = *(int *)(param_1 + (long)iVar7 * 4); iVar2 = *(int *)(param_1 + (long)iVar6 * 4); if (iVar1 <= iVar2) { return iVar7; } iVar5 = (iVar7 + iVar6) / 2; iVar3 = *(int *)(param_1 + (long)iVar5 * 4); if ((iVar3 <= *(int *)(param_1 + (long)((iVar5 + 1) % param_2) * 4)) && (iVar3 <= *(int *)(param_1 + (long)((iVar5 + -1 + param_2) % param_2) * 4))) { return iVar5; } iVar4 = iVar5 + -1; } while (iVar3 <= iVar2); if (iVar1 <= iVar3) { iVar7 = iVar5 + 1; } } while( true ); }
5,422
func0
#include <assert.h>
int func0(int A[], int n) { int left = 0; int right = n - 1; while (left <= right) { if (A[left] <= A[right]) { return left; } int mid = (left + right) / 2; int next = (mid + 1) % n; int prev = (mid - 1 + n) % n; if (A[mid] <= A[next] && A[mid] <= A[prev]) { return mid; } else if (A[mid] <= A[right]) { right = mid - 1; } else if (A[mid] >= A[left]) { left = mid + 1; } } return -1; }
int main() { int arr1[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}; int n1 = sizeof(arr1) / sizeof(arr1[0]); assert(func0(arr1, n1) == 3); int arr2[] = {8, 9, 10, 2, 5, 6}; int n2 = sizeof(arr2) / sizeof(arr2[0]); assert(func0(arr2, n2) == 3); int arr3[] = {2, 5, 6, 8, 9, 10}; int n3 = sizeof(arr3) / sizeof(arr3[0]); assert(func0(arr3, n3) == 0); return 0; }
O2
c
func0: endbr64 push %r14 lea -0x1(%rsi),%r8d xor %r14d,%r14d push %r13 push %r12 xor %r12d,%r12d push %rbp push %rbx lea (%rdi,%r14,4),%r13 jmp 134a <func0+0x6a> nopl 0x0(%rax) movslq %r8d,%rax mov 0x0(%r13),%ebp mov (%rdi,%rax,4),%r10d cmp %r10d,%ebp jle 1355 <func0+0x75> lea (%r12,%r8,1),%ecx sar %ecx movslq %ecx,%rax lea 0x1(%rcx),%r11d lea -0x1(%rcx),%ebx mov (%rdi,%rax,4),%r9d mov %r11d,%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r9d jg 1342 <func0+0x62> lea (%rbx,%rsi,1),%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r9d jle 1378 <func0+0x98> cmp %r9d,%r10d jl 1368 <func0+0x88> mov %ebx,%r8d cmp %r8d,%r12d jle 1300 <func0+0x20> mov $0xffffffff,%r12d pop %rbx mov %r12d,%eax pop %rbp pop %r12 pop %r13 pop %r14 retq nopl 0x0(%rax) cmp %r9d,%ebp jg 12f6 <func0+0x16> movslq %r11d,%r14 mov %r14,%r12 jmp 12f6 <func0+0x16> nopl (%rax) mov %ecx,%r12d pop %rbx pop %rbp mov %r12d,%eax pop %r12 pop %r13 pop %r14 retq nopw 0x0(%rax,%rax,1)
func0: endbr64 push r14 mov r8d, esi xor r14d, r14d sub esi, 1 push r13 push r12 xor r12d, r12d push rbp push rbx loc_12F8: lea r13, [rdi+r14*4] jmp short loc_134C loc_1300: movsxd rax, esi mov ebp, [r13+0] mov r10d, [rdi+rax*4] cmp ebp, r10d jle short loc_1357 lea ecx, [r12+rsi] sar ecx, 1 movsxd rax, ecx lea r11d, [rcx+1] lea ebx, [rcx-1] mov r9d, [rdi+rax*4] mov eax, r11d cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jg short loc_1345 lea eax, [rbx+r8] cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jle short loc_1378 loc_1345: cmp r10d, r9d jl short loc_1368 mov esi, ebx loc_134C: cmp r12d, esi jle short loc_1300 mov r12d, 0FFFFFFFFh loc_1357: pop rbx mov eax, r12d pop rbp pop r12 pop r13 pop r14 retn loc_1368: cmp ebp, r9d jg short loc_12F8 movsxd r14, r11d mov r12, r14 jmp short loc_12F8 loc_1378: mov r12d, ecx pop rbx pop rbp mov eax, r12d pop r12 pop r13 pop r14 retn
long long func0(long long a1, int a2) { long long v3; // r14 int v4; // esi int v5; // r12d int v6; // ebp int v7; // r10d int v8; // ecx int v9; // r9d v3 = 0LL; v4 = a2 - 1; v5 = 0; while ( 1 ) { if ( v5 > v4 ) return (unsigned int)-1; v6 = *(_DWORD *)(a1 + 4 * v3); v7 = *(_DWORD *)(a1 + 4LL * v4); if ( v6 <= v7 ) return (unsigned int)v5; v8 = (v5 + v4) >> 1; v9 = *(_DWORD *)(a1 + 4LL * v8); if ( v9 <= *(_DWORD *)(a1 + 4LL * ((v8 + 1) % a2)) && v9 <= *(_DWORD *)(a1 + 4LL * ((v8 - 1 + a2) % a2)) ) break; if ( v7 < v9 ) { if ( v6 <= v9 ) { v3 = v8 + 1; v5 = v8 + 1; } } else { v4 = v8 - 1; } } return (unsigned int)v8; }
func0: ENDBR64 PUSH R14 MOV R8D,ESI XOR R14D,R14D SUB ESI,0x1 PUSH R13 PUSH R12 XOR R12D,R12D PUSH RBP PUSH RBX LAB_001012f8: LEA R13,[RDI + R14*0x4] JMP 0x0010134c LAB_00101300: MOVSXD RAX,ESI MOV EBP,dword ptr [R13] MOV R10D,dword ptr [RDI + RAX*0x4] CMP EBP,R10D JLE 0x00101357 LEA ECX,[R12 + RSI*0x1] SAR ECX,0x1 MOVSXD RAX,ECX LEA R11D,[RCX + 0x1] LEA EBX,[RCX + -0x1] MOV R9D,dword ptr [RDI + RAX*0x4] MOV EAX,R11D CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JG 0x00101345 LEA EAX,[RBX + R8*0x1] CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JLE 0x00101378 LAB_00101345: CMP R10D,R9D JL 0x00101368 MOV ESI,EBX LAB_0010134c: CMP R12D,ESI JLE 0x00101300 MOV R12D,0xffffffff LAB_00101357: POP RBX MOV EAX,R12D POP RBP POP R12 POP R13 POP R14 RET LAB_00101368: CMP EBP,R9D JG 0x001012f8 MOVSXD R14,R11D MOV R12,R14 JMP 0x001012f8 LAB_00101378: MOV R12D,ECX POP RBX POP RBP MOV EAX,R12D POP R12 POP R13 POP R14 RET
ulong func0(long param_1,int param_2) { int iVar1; int iVar2; int iVar3; int iVar4; uint uVar5; int iVar6; ulong uVar7; ulong uVar8; iVar6 = param_2 + -1; uVar7 = 0; uVar8 = 0; do { iVar4 = iVar6; do { iVar6 = iVar4; if (iVar6 < (int)uVar7) { uVar7 = 0xffffffff; LAB_00101357: return uVar7 & 0xffffffff; } iVar1 = *(int *)(param_1 + uVar8 * 4); iVar2 = *(int *)(param_1 + (long)iVar6 * 4); if (iVar1 <= iVar2) goto LAB_00101357; uVar5 = (int)uVar7 + iVar6 >> 1; iVar3 = *(int *)(param_1 + (long)(int)uVar5 * 4); if ((iVar3 <= *(int *)(param_1 + (long)((int)(uVar5 + 1) % param_2) * 4)) && (iVar3 <= *(int *)(param_1 + (long)((int)((uVar5 - 1) + param_2) % param_2) * 4))) { return (ulong)uVar5; } iVar4 = uVar5 - 1; } while (iVar3 <= iVar2); if (iVar1 <= iVar3) { uVar7 = (ulong)(int)(uVar5 + 1); uVar8 = uVar7; } } while( true ); }
5,423
func0
#include <assert.h>
int func0(int A[], int n) { int left = 0; int right = n - 1; while (left <= right) { if (A[left] <= A[right]) { return left; } int mid = (left + right) / 2; int next = (mid + 1) % n; int prev = (mid - 1 + n) % n; if (A[mid] <= A[next] && A[mid] <= A[prev]) { return mid; } else if (A[mid] <= A[right]) { right = mid - 1; } else if (A[mid] >= A[left]) { left = mid + 1; } } return -1; }
int main() { int arr1[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}; int n1 = sizeof(arr1) / sizeof(arr1[0]); assert(func0(arr1, n1) == 3); int arr2[] = {8, 9, 10, 2, 5, 6}; int n2 = sizeof(arr2) / sizeof(arr2[0]); assert(func0(arr2, n2) == 3); int arr3[] = {2, 5, 6, 8, 9, 10}; int n3 = sizeof(arr3) / sizeof(arr3[0]); assert(func0(arr3, n3) == 0); return 0; }
O3
c
func0: endbr64 push %r14 lea -0x1(%rsi),%r8d xor %r14d,%r14d push %r13 push %r12 xor %r12d,%r12d push %rbp push %rbx lea (%rdi,%r14,4),%r13 jmp 130a <func0+0x6a> nopl 0x0(%rax) movslq %r8d,%rax mov 0x0(%r13),%ebp mov (%rdi,%rax,4),%r10d cmp %r10d,%ebp jle 1315 <func0+0x75> lea (%r12,%r8,1),%ecx sar %ecx movslq %ecx,%rax lea 0x1(%rcx),%r11d lea -0x1(%rcx),%ebx mov (%rdi,%rax,4),%r9d mov %r11d,%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r9d jg 1302 <func0+0x62> lea (%rbx,%rsi,1),%eax cltd idiv %esi movslq %edx,%rdx cmp (%rdi,%rdx,4),%r9d jle 1338 <func0+0x98> cmp %r9d,%r10d jl 1328 <func0+0x88> mov %ebx,%r8d cmp %r8d,%r12d jle 12c0 <func0+0x20> mov $0xffffffff,%r12d pop %rbx mov %r12d,%eax pop %rbp pop %r12 pop %r13 pop %r14 retq nopl 0x0(%rax) cmp %r9d,%ebp jg 12b6 <func0+0x16> movslq %r11d,%r14 mov %r14,%r12 jmp 12b6 <func0+0x16> nopl (%rax) mov %ecx,%r12d pop %rbx pop %rbp mov %r12d,%eax pop %r12 pop %r13 pop %r14 retq nopw 0x0(%rax,%rax,1)
func0: endbr64 push r14 mov r8d, esi xor r14d, r14d sub esi, 1 push r13 push r12 push rbp xor ebp, ebp push rbx loc_12B7: lea r13, [rdi+r14*4] jmp short loc_1313 loc_12C0: movsxd rax, esi mov r12d, [r13+0] mov r10d, [rdi+rax*4] cmp r12d, r10d jle short loc_131C lea eax, [rbp+rsi+0] mov ecx, eax shr ecx, 1Fh add ecx, eax sar ecx, 1 movsxd rax, ecx lea r11d, [rcx+1] lea ebx, [rcx-1] mov r9d, [rdi+rax*4] mov eax, r11d cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jg short loc_130C lea eax, [rbx+r8] cdq idiv r8d movsxd rdx, edx cmp r9d, [rdi+rdx*4] jle short loc_1340 loc_130C: cmp r10d, r9d jl short loc_1330 mov esi, ebx loc_1313: cmp ebp, esi jle short loc_12C0 mov ebp, 0FFFFFFFFh loc_131C: pop rbx mov eax, ebp pop rbp pop r12 pop r13 pop r14 retn loc_1330: cmp r12d, r9d jg short loc_12B7 movsxd r14, r11d mov rbp, r14 jmp loc_12B7 loc_1340: mov ebp, ecx pop rbx mov eax, ebp pop rbp pop r12 pop r13 pop r14 retn
long long func0(long long a1, int a2) { long long v3; // r14 int v4; // esi int v5; // ebp int v6; // r12d int v7; // r10d int v8; // ecx int v9; // r9d v3 = 0LL; v4 = a2 - 1; v5 = 0; while ( 1 ) { if ( v5 > v4 ) return (unsigned int)-1; v6 = *(_DWORD *)(a1 + 4 * v3); v7 = *(_DWORD *)(a1 + 4LL * v4); if ( v6 <= v7 ) return (unsigned int)v5; v8 = (v5 + v4) / 2; v9 = *(_DWORD *)(a1 + 4LL * v8); if ( v9 <= *(_DWORD *)(a1 + 4LL * ((v8 + 1) % a2)) && v9 <= *(_DWORD *)(a1 + 4LL * ((v8 - 1 + a2) % a2)) ) break; if ( v7 < v9 ) { if ( v6 <= v9 ) { v3 = v8 + 1; v5 = v8 + 1; } } else { v4 = v8 - 1; } } return (unsigned int)v8; }
func0: ENDBR64 PUSH R14 MOV R8D,ESI XOR R14D,R14D SUB ESI,0x1 PUSH R13 PUSH R12 PUSH RBP XOR EBP,EBP PUSH RBX LAB_001012b7: LEA R13,[RDI + R14*0x4] JMP 0x00101313 LAB_001012c0: MOVSXD RAX,ESI MOV R12D,dword ptr [R13] MOV R10D,dword ptr [RDI + RAX*0x4] CMP R12D,R10D JLE 0x0010131c LEA EAX,[RBP + RSI*0x1] MOV ECX,EAX SHR ECX,0x1f ADD ECX,EAX SAR ECX,0x1 MOVSXD RAX,ECX LEA R11D,[RCX + 0x1] LEA EBX,[RCX + -0x1] MOV R9D,dword ptr [RDI + RAX*0x4] MOV EAX,R11D CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JG 0x0010130c LEA EAX,[RBX + R8*0x1] CDQ IDIV R8D MOVSXD RDX,EDX CMP R9D,dword ptr [RDI + RDX*0x4] JLE 0x00101340 LAB_0010130c: CMP R10D,R9D JL 0x00101330 MOV ESI,EBX LAB_00101313: CMP EBP,ESI JLE 0x001012c0 MOV EBP,0xffffffff LAB_0010131c: POP RBX MOV EAX,EBP POP RBP POP R12 POP R13 POP R14 RET LAB_00101330: CMP R12D,R9D JG 0x001012b7 MOVSXD R14,R11D MOV RBP,R14 JMP 0x001012b7 LAB_00101340: MOV EBP,ECX POP RBX MOV EAX,EBP POP RBP POP R12 POP R13 POP R14 RET
ulong func0(long param_1,int param_2) { int iVar1; int iVar2; int iVar3; int iVar4; uint uVar5; ulong uVar6; int iVar7; ulong uVar8; iVar7 = param_2 + -1; uVar6 = 0; uVar8 = 0; do { iVar4 = iVar7; do { iVar7 = iVar4; if (iVar7 < (int)uVar6) { uVar6 = 0xffffffff; LAB_0010131c: return uVar6 & 0xffffffff; } iVar1 = *(int *)(param_1 + uVar8 * 4); iVar2 = *(int *)(param_1 + (long)iVar7 * 4); if (iVar1 <= iVar2) goto LAB_0010131c; uVar5 = ((int)uVar6 + iVar7) / 2; iVar3 = *(int *)(param_1 + (long)(int)uVar5 * 4); if ((iVar3 <= *(int *)(param_1 + (long)((int)(uVar5 + 1) % param_2) * 4)) && (iVar3 <= *(int *)(param_1 + (long)((int)((uVar5 - 1) + param_2) % param_2) * 4))) { return (ulong)uVar5; } iVar4 = uVar5 - 1; } while (iVar3 <= iVar2); if (iVar1 <= iVar3) { uVar6 = (ulong)(int)(uVar5 + 1); uVar8 = uVar6; } } while( true ); }
5,424
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res = 0, count = 0, temp = n; while(temp > 0) { if (count % 2 == 0) { res = res | (1 << count); } count = count + 1; temp >>= 1; } return n ^ res; }
int main() { assert(func0(10) == 15); assert(func0(20) == 1); assert(func0(30) == 11); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) movl $0x0,-0xc(%rbp) movl $0x0,-0x8(%rbp) mov -0x14(%rbp),%eax mov %eax,-0x4(%rbp) jmp 118c <func0+0x43> mov -0x8(%rbp),%eax and $0x1,%eax test %eax,%eax jne 1185 <func0+0x3c> mov -0x8(%rbp),%eax mov $0x1,%edx mov %eax,%ecx shl %cl,%edx mov %edx,%eax or %eax,-0xc(%rbp) addl $0x1,-0x8(%rbp) sarl -0x4(%rbp) cmpl $0x0,-0x4(%rbp) jg 116a <func0+0x21> mov -0x14(%rbp),%eax xor -0xc(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov [rbp+var_C], 0 mov [rbp+var_8], 0 mov eax, [rbp+var_14] mov [rbp+var_4], eax jmp short loc_118C loc_116A: mov eax, [rbp+var_8] and eax, 1 test eax, eax jnz short loc_1185 mov eax, [rbp+var_8] mov edx, 1 mov ecx, eax shl edx, cl mov eax, edx or [rbp+var_C], eax loc_1185: add [rbp+var_8], 1 sar [rbp+var_4], 1 loc_118C: cmp [rbp+var_4], 0 jg short loc_116A mov eax, [rbp+var_14] xor eax, [rbp+var_C] pop rbp retn
long long func0(int a1) { int v2; // [rsp+8h] [rbp-Ch] char v3; // [rsp+Ch] [rbp-8h] int i; // [rsp+10h] [rbp-4h] v2 = 0; v3 = 0; for ( i = a1; i > 0; i >>= 1 ) { if ( (v3 & 1) == 0 ) v2 |= 1 << v3; ++v3; } return v2 ^ (unsigned int)a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0xc],0x0 MOV dword ptr [RBP + -0x8],0x0 MOV EAX,dword ptr [RBP + -0x14] MOV dword ptr [RBP + -0x4],EAX JMP 0x0010118c LAB_0010116a: MOV EAX,dword ptr [RBP + -0x8] AND EAX,0x1 TEST EAX,EAX JNZ 0x00101185 MOV EAX,dword ptr [RBP + -0x8] MOV EDX,0x1 MOV ECX,EAX SHL EDX,CL MOV EAX,EDX OR dword ptr [RBP + -0xc],EAX LAB_00101185: ADD dword ptr [RBP + -0x8],0x1 SAR dword ptr [RBP + -0x4],0x1 LAB_0010118c: CMP dword ptr [RBP + -0x4],0x0 JG 0x0010116a MOV EAX,dword ptr [RBP + -0x14] XOR EAX,dword ptr [RBP + -0xc] POP RBP RET
uint func0(uint param_1) { byte bVar1; int4 local_14; int4 local_c; local_14 = 0; bVar1 = 0; for (local_c = param_1; 0 < (int)local_c; local_c = (int)local_c >> 1) { if (!(bool)(bVar1 & 1)) { local_14 = local_14 | 1 << (bVar1 & 0x1f); } bVar1 = bVar1 + 1; } return param_1 ^ local_14; }
5,425
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res = 0, count = 0, temp = n; while(temp > 0) { if (count % 2 == 0) { res = res | (1 << count); } count = count + 1; temp >>= 1; } return n ^ res; }
int main() { assert(func0(10) == 15); assert(func0(20) == 1); assert(func0(30) == 11); return 0; }
O1
c
func0: endbr64 test %edi,%edi jle 117c <func0+0x33> mov %edi,%edx mov $0x0,%ecx mov $0x0,%eax mov $0x1,%r8d jmp 116e <func0+0x25> add $0x1,%ecx sar %edx test %edx,%edx jle 1181 <func0+0x38> test $0x1,%cl jne 1165 <func0+0x1c> mov %r8d,%esi shl %cl,%esi or %esi,%eax jmp 1165 <func0+0x1c> mov $0x0,%eax xor %edi,%eax retq
func0: endbr64 mov eax, edi test edi, edi jle short loc_117F mov edx, edi mov ecx, 0 mov esi, 0 mov edi, 1 jmp short loc_116F loc_1166: add ecx, 1 sar edx, 1 test edx, edx jle short loc_1184 loc_116F: test cl, 1 jnz short loc_1166 mov r8d, edi shl r8d, cl or esi, r8d jmp short loc_1166 loc_117F: mov esi, 0 loc_1184: xor eax, esi retn
long long func0(int a1) { int v1; // edx char v2; // cl int v3; // esi if ( a1 <= 0 ) { v3 = 0; } else { v1 = a1; v2 = 0; v3 = 0; do { if ( (v2 & 1) == 0 ) v3 |= 1 << v2; ++v2; v1 >>= 1; } while ( v1 > 0 ); } return v3 ^ (unsigned int)a1; }
func0: ENDBR64 MOV EAX,EDI TEST EDI,EDI JLE 0x0010117f MOV EDX,EDI MOV ECX,0x0 MOV ESI,0x0 MOV EDI,0x1 JMP 0x0010116f LAB_00101166: ADD ECX,0x1 SAR EDX,0x1 TEST EDX,EDX JLE 0x00101184 LAB_0010116f: TEST CL,0x1 JNZ 0x00101166 MOV R8D,EDI SHL R8D,CL OR ESI,R8D JMP 0x00101166 LAB_0010117f: MOV ESI,0x0 LAB_00101184: XOR EAX,ESI RET
uint func0(uint param_1) { bool bVar1; uint uVar2; uint uVar3; if ((int)param_1 < 1) { uVar3 = 0; } else { bVar1 = false; uVar3 = 0; uVar2 = param_1; do { if (!bVar1) { uVar3 = uVar3 | 1 << bVar1; } bVar1 = (bool)(bVar1 ^ 1); uVar2 = (int)uVar2 >> 1; } while (0 < (int)uVar2); } return param_1 ^ uVar3; }
5,426
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res = 0, count = 0, temp = n; while(temp > 0) { if (count % 2 == 0) { res = res | (1 << count); } count = count + 1; temp >>= 1; } return n ^ res; }
int main() { assert(func0(10) == 15); assert(func0(20) == 1); assert(func0(30) == 11); return 0; }
O2
c
func0: endbr64 test %edi,%edi jle 1170 <func0+0x30> mov %edi,%edx xor %ecx,%ecx xor %eax,%eax mov $0x1,%r8d nopl 0x0(%rax) test $0x1,%cl jne 1164 <func0+0x24> mov %r8d,%esi shl %cl,%esi or %esi,%eax add $0x1,%ecx sar %edx jne 1158 <func0+0x18> xor %edi,%eax retq xchg %ax,%ax mov %edi,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 test edi, edi jle short loc_1220 mov edx, edi xor ecx, ecx xor eax, eax mov r8d, 1 nop dword ptr [rax+00h] loc_1208: test cl, 1 jnz short loc_1214 mov esi, r8d shl esi, cl or eax, esi loc_1214: add ecx, 1 sar edx, 1 jnz short loc_1208 xor eax, edi retn loc_1220: mov eax, edi retn
long long func0(int a1) { int v1; // edx char v2; // cl unsigned int v3; // eax if ( a1 <= 0 ) return (unsigned int)a1; v1 = a1; v2 = 0; v3 = 0; do { if ( (v2 & 1) == 0 ) v3 |= 1 << v2; ++v2; v1 >>= 1; } while ( v1 ); return a1 ^ v3; }
func0: ENDBR64 TEST EDI,EDI JLE 0x00101220 MOV EDX,EDI XOR ECX,ECX XOR EAX,EAX MOV R8D,0x1 NOP dword ptr [RAX] LAB_00101208: TEST CL,0x1 JNZ 0x00101214 MOV ESI,R8D SHL ESI,CL OR EAX,ESI LAB_00101214: ADD ECX,0x1 SAR EDX,0x1 JNZ 0x00101208 XOR EAX,EDI RET LAB_00101220: MOV EAX,EDI RET
uint func0(uint param_1) { byte bVar1; uint uVar2; uint uVar3; if (0 < (int)param_1) { bVar1 = 0; uVar2 = 0; uVar3 = param_1; do { if (!(bool)(bVar1 & 1)) { uVar2 = uVar2 | 1 << (bVar1 & 0x1f); } bVar1 = bVar1 + 1; uVar3 = (int)uVar3 >> 1; } while (uVar3 != 0); return uVar2 ^ param_1; } return param_1; }
5,427
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res = 0, count = 0, temp = n; while(temp > 0) { if (count % 2 == 0) { res = res | (1 << count); } count = count + 1; temp >>= 1; } return n ^ res; }
int main() { assert(func0(10) == 15); assert(func0(20) == 1); assert(func0(30) == 11); return 0; }
O3
c
func0: endbr64 test %edi,%edi jle 1170 <func0+0x30> mov %edi,%edx xor %ecx,%ecx xor %eax,%eax mov $0x1,%r8d nopl 0x0(%rax) test $0x1,%cl jne 1164 <func0+0x24> mov %r8d,%esi shl %cl,%esi or %esi,%eax add $0x1,%ecx sar %edx jne 1158 <func0+0x18> xor %edi,%eax retq xchg %ax,%ax mov %edi,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 test edi, edi jle short loc_1178 mov edx, edi xor ecx, ecx xor esi, esi mov eax, 1 nop dword ptr [rax+rax+00h] loc_1158: test cl, 1 jnz short loc_1166 mov r8d, eax shl r8d, cl or esi, r8d loc_1166: add ecx, 1 sar edx, 1 jnz short loc_1158 mov eax, edi xor eax, esi retn loc_1178: mov eax, edi retn
long long func0(int a1) { int v1; // edx char v2; // cl int v3; // esi if ( a1 <= 0 ) return (unsigned int)a1; v1 = a1; v2 = 0; v3 = 0; do { if ( (v2 & 1) == 0 ) v3 |= 1 << v2; ++v2; v1 >>= 1; } while ( v1 ); return v3 ^ (unsigned int)a1; }
func0: ENDBR64 TEST EDI,EDI JLE 0x00101178 MOV EDX,EDI XOR ECX,ECX XOR ESI,ESI MOV EAX,0x1 NOP dword ptr [RAX + RAX*0x1] LAB_00101158: TEST CL,0x1 JNZ 0x00101166 MOV R8D,EAX SHL R8D,CL OR ESI,R8D LAB_00101166: ADD ECX,0x1 SAR EDX,0x1 JNZ 0x00101158 MOV EAX,EDI XOR EAX,ESI RET LAB_00101178: MOV EAX,EDI RET
uint func0(uint param_1) { byte bVar1; uint uVar2; uint uVar3; if (0 < (int)param_1) { bVar1 = 0; uVar3 = 0; uVar2 = param_1; do { if (!(bool)(bVar1 & 1)) { uVar3 = uVar3 | 1 << (bVar1 & 0x1f); } bVar1 = bVar1 + 1; uVar2 = (int)uVar2 >> 1; } while (uVar2 != 0); return param_1 ^ uVar3; } return param_1; }
5,428
func0
#include <assert.h>
int func0(int n, int arr[]) { int mn = arr[0]; int freq = 1; for (int i = 1; i < n; i++) { if (arr[i] < mn) { mn = arr[i]; freq = 1; } else if (arr[i] == mn) { freq++; } } return freq; }
int main() { int arr1[] = {1, 2, 3, 4, 3}; int arr2[] = {3, 1, 2, 5, 6, 2, 3}; int arr3[] = {3, 3, 6, 3, 7, 4, 9}; assert(func0(5, arr1) == 1); assert(func0(7, arr2) == 1); assert(func0(7, arr3) == 3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %rsi,-0x20(%rbp) mov -0x20(%rbp),%rax mov (%rax),%eax mov %eax,-0xc(%rbp) movl $0x1,-0x8(%rbp) movl $0x1,-0x4(%rbp) jmp 11f1 <func0+0x88> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x20(%rbp),%rax add %rdx,%rax mov (%rax),%eax cmp %eax,-0xc(%rbp) jle 11ce <func0+0x65> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x20(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0xc(%rbp) movl $0x1,-0x8(%rbp) jmp 11ed <func0+0x84> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x20(%rbp),%rax add %rdx,%rax mov (%rax),%eax cmp %eax,-0xc(%rbp) jne 11ed <func0+0x84> addl $0x1,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x14(%rbp),%eax jl 1191 <func0+0x28> mov -0x8(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov [rbp+var_20], rsi mov rax, [rbp+var_20] mov eax, [rax] mov [rbp+var_C], eax mov [rbp+var_8], 1 mov [rbp+var_4], 1 jmp short loc_11F1 loc_1191: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_20] add rax, rdx mov eax, [rax] cmp [rbp+var_C], eax jle short loc_11CE mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_20] add rax, rdx mov eax, [rax] mov [rbp+var_C], eax mov [rbp+var_8], 1 jmp short loc_11ED loc_11CE: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_20] add rax, rdx mov eax, [rax] cmp [rbp+var_C], eax jnz short loc_11ED add [rbp+var_8], 1 loc_11ED: add [rbp+var_4], 1 loc_11F1: mov eax, [rbp+var_4] cmp eax, [rbp+var_14] jl short loc_1191 mov eax, [rbp+var_8] pop rbp retn
long long func0(int a1, int *a2) { int v3; // [rsp+14h] [rbp-Ch] unsigned int v4; // [rsp+18h] [rbp-8h] int i; // [rsp+1Ch] [rbp-4h] v3 = *a2; v4 = 1; for ( i = 1; i < a1; ++i ) { if ( v3 <= a2[i] ) { if ( v3 == a2[i] ) ++v4; } else { v3 = a2[i]; v4 = 1; } } return v4; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV qword ptr [RBP + -0x20],RSI MOV RAX,qword ptr [RBP + -0x20] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0xc],EAX MOV dword ptr [RBP + -0x8],0x1 MOV dword ptr [RBP + -0x4],0x1 JMP 0x001011f1 LAB_00101191: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x20] ADD RAX,RDX MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0xc],EAX JLE 0x001011ce MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x20] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0xc],EAX MOV dword ptr [RBP + -0x8],0x1 JMP 0x001011ed LAB_001011ce: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x20] ADD RAX,RDX MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0xc],EAX JNZ 0x001011ed ADD dword ptr [RBP + -0x8],0x1 LAB_001011ed: ADD dword ptr [RBP + -0x4],0x1 LAB_001011f1: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x14] JL 0x00101191 MOV EAX,dword ptr [RBP + -0x8] POP RBP RET
int func0(int param_1,int *param_2) { int local_14; int local_10; int local_c; local_14 = *param_2; local_10 = 1; for (local_c = 1; local_c < param_1; local_c = local_c + 1) { if (param_2[local_c] < local_14) { local_14 = param_2[local_c]; local_10 = 1; } else if (local_14 == param_2[local_c]) { local_10 = local_10 + 1; } } return local_10; }
5,429
func0
#include <assert.h>
int func0(int n, int arr[]) { int mn = arr[0]; int freq = 1; for (int i = 1; i < n; i++) { if (arr[i] < mn) { mn = arr[i]; freq = 1; } else if (arr[i] == mn) { freq++; } } return freq; }
int main() { int arr1[] = {1, 2, 3, 4, 3}; int arr2[] = {3, 1, 2, 5, 6, 2, 3}; int arr3[] = {3, 3, 6, 3, 7, 4, 9}; assert(func0(5, arr1) == 1); assert(func0(7, arr2) == 1); assert(func0(7, arr3) == 3); return 0; }
O1
c
func0: endbr64 mov (%rsi),%ecx cmp $0x1,%edi jle 11a7 <func0+0x3e> lea 0x4(%rsi),%rax lea -0x2(%rdi),%edx lea 0x8(%rsi,%rdx,4),%rdi mov $0x1,%esi jmp 1197 <func0+0x2e> mov %edx,%ecx mov $0x1,%esi add $0x4,%rax cmp %rdi,%rax je 11ac <func0+0x43> mov (%rax),%edx cmp %ecx,%edx jl 1187 <func0+0x1e> sete %dl movzbl %dl,%edx add %edx,%esi jmp 118e <func0+0x25> mov $0x1,%esi mov %esi,%eax retq
func0: endbr64 mov ecx, [rsi] cmp edi, 1 jle short loc_11A7 lea rax, [rsi+4] lea edx, [rdi-2] lea rdi, [rsi+rdx*4+8] mov esi, 1 jmp short loc_1197 loc_1187: mov ecx, edx mov esi, 1 loc_118E: add rax, 4 cmp rax, rdi jz short loc_11AC loc_1197: mov edx, [rax] cmp edx, ecx jl short loc_1187 setz dl movzx edx, dl add esi, edx jmp short loc_118E loc_11A7: mov esi, 1 loc_11AC: mov eax, esi retn
long long func0(int a1, int *a2) { int v2; // ecx int *v3; // rax long long v4; // rdi unsigned int v5; // esi v2 = *a2; if ( a1 <= 1 ) { return 1; } else { v3 = a2 + 1; v4 = (long long)&a2[a1 - 2 + 2]; v5 = 1; do { if ( *v3 < v2 ) { v2 = *v3; v5 = 1; } else { v5 += *v3 == v2; } ++v3; } while ( v3 != (int *)v4 ); } return v5; }
func0: ENDBR64 MOV ECX,dword ptr [RSI] CMP EDI,0x1 JLE 0x001011a7 LEA RAX,[RSI + 0x4] LEA EDX,[RDI + -0x2] LEA RDI,[RSI + RDX*0x4 + 0x8] MOV ESI,0x1 JMP 0x00101197 LAB_00101187: MOV ECX,EDX MOV ESI,0x1 LAB_0010118e: ADD RAX,0x4 CMP RAX,RDI JZ 0x001011ac LAB_00101197: MOV EDX,dword ptr [RAX] CMP EDX,ECX JL 0x00101187 SETZ DL MOVZX EDX,DL ADD ESI,EDX JMP 0x0010118e LAB_001011a7: MOV ESI,0x1 LAB_001011ac: MOV EAX,ESI RET
int func0(int param_1,int *param_2) { int iVar1; int *piVar2; int iVar3; int iVar4; iVar3 = *param_2; if (param_1 < 2) { iVar4 = 1; } else { piVar2 = param_2 + 1; iVar4 = 1; do { iVar1 = *piVar2; if (iVar1 < iVar3) { iVar4 = 1; iVar3 = iVar1; } else { iVar4 = iVar4 + (uint)(iVar1 == iVar3); } piVar2 = piVar2 + 1; } while (piVar2 != param_2 + (ulong)(param_1 - 2) + 2); } return iVar4; }
5,430
func0
#include <assert.h>
int func0(int n, int arr[]) { int mn = arr[0]; int freq = 1; for (int i = 1; i < n; i++) { if (arr[i] < mn) { mn = arr[i]; freq = 1; } else if (arr[i] == mn) { freq++; } } return freq; }
int main() { int arr1[] = {1, 2, 3, 4, 3}; int arr2[] = {3, 1, 2, 5, 6, 2, 3}; int arr3[] = {3, 3, 6, 3, 7, 4, 9}; assert(func0(5, arr1) == 1); assert(func0(7, arr2) == 1); assert(func0(7, arr3) == 3); return 0; }
O2
c
func0: endbr64 mov (%rsi),%ecx cmp $0x1,%edi jle 13c0 <func0+0x50> lea -0x2(%rdi),%edx lea 0x4(%rsi),%rax mov $0x1,%r8d lea 0x8(%rsi,%rdx,4),%rsi jmp 13a2 <func0+0x32> sete %dl add $0x4,%rax movzbl %dl,%edx add %edx,%r8d cmp %rsi,%rax je 13b9 <func0+0x49> mov (%rax),%edx cmp %ecx,%edx jge 1390 <func0+0x20> add $0x4,%rax mov %edx,%ecx mov $0x1,%r8d cmp %rsi,%rax jne 13a2 <func0+0x32> mov %r8d,%eax retq nopl (%rax) mov $0x1,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 mov ecx, [rsi] cmp edi, 1 jle short loc_1320 lea edx, [rdi-2] lea rax, [rsi+4] mov r8d, 1 lea rsi, [rsi+rdx*4+8] jmp short loc_1302 loc_12F0: setz dl add rax, 4 movzx edx, dl add r8d, edx cmp rax, rsi jz short loc_1319 loc_1302: mov edx, [rax] cmp edx, ecx jge short loc_12F0 add rax, 4 mov ecx, edx mov r8d, 1 cmp rax, rsi jnz short loc_1302 loc_1319: mov eax, r8d retn loc_1320: mov r8d, 1 mov eax, r8d retn
long long func0(int a1, int *a2) { int v2; // ecx int *v3; // rax unsigned int v4; // r8d long long v5; // rsi int v6; // edx bool v7; // zf v2 = *a2; if ( a1 <= 1 ) return 1LL; v3 = a2 + 1; v4 = 1; v5 = (long long)&a2[a1 - 2 + 2]; do { while ( 1 ) { v6 = *v3; v7 = *v3 == v2; if ( *v3 < v2 ) break; ++v3; v4 += v7; if ( v3 == (int *)v5 ) return v4; } ++v3; v2 = v6; v4 = 1; } while ( v3 != (int *)v5 ); return v4; }
func0: ENDBR64 MOV ECX,dword ptr [RSI] CMP EDI,0x1 JLE 0x00101320 LEA EDX,[RDI + -0x2] LEA RAX,[RSI + 0x4] MOV R8D,0x1 LEA RSI,[RSI + RDX*0x4 + 0x8] JMP 0x00101302 LAB_001012f0: SETZ DL ADD RAX,0x4 MOVZX EDX,DL ADD R8D,EDX CMP RAX,RSI JZ 0x00101319 LAB_00101302: MOV EDX,dword ptr [RAX] CMP EDX,ECX JGE 0x001012f0 ADD RAX,0x4 MOV ECX,EDX MOV R8D,0x1 CMP RAX,RSI JNZ 0x00101302 LAB_00101319: MOV EAX,R8D RET LAB_00101320: MOV R8D,0x1 MOV EAX,R8D RET
int func0(int param_1,int *param_2) { int iVar1; int *piVar2; int iVar3; int iVar4; if (param_1 < 2) { return 1; } piVar2 = param_2 + 1; iVar4 = 1; iVar3 = *param_2; do { while( true ) { iVar1 = *piVar2; if (iVar1 < iVar3) break; piVar2 = piVar2 + 1; iVar4 = iVar4 + (uint)(iVar1 == iVar3); if (piVar2 == param_2 + (ulong)(param_1 - 2) + 2) { return iVar4; } } piVar2 = piVar2 + 1; iVar4 = 1; iVar3 = iVar1; } while (piVar2 != param_2 + (ulong)(param_1 - 2) + 2); return 1; }
5,431
func0
#include <assert.h>
int func0(int n, int arr[]) { int mn = arr[0]; int freq = 1; for (int i = 1; i < n; i++) { if (arr[i] < mn) { mn = arr[i]; freq = 1; } else if (arr[i] == mn) { freq++; } } return freq; }
int main() { int arr1[] = {1, 2, 3, 4, 3}; int arr2[] = {3, 1, 2, 5, 6, 2, 3}; int arr3[] = {3, 3, 6, 3, 7, 4, 9}; assert(func0(5, arr1) == 1); assert(func0(7, arr2) == 1); assert(func0(7, arr3) == 3); return 0; }
O3
c
func0: endbr64 mov (%rsi),%ecx cmp $0x1,%edi jle 1450 <func0+0x50> lea -0x2(%rdi),%edx lea 0x4(%rsi),%rax mov $0x1,%r8d lea 0x8(%rsi,%rdx,4),%rsi jmp 1432 <func0+0x32> sete %dl add $0x4,%rax movzbl %dl,%edx add %edx,%r8d cmp %rax,%rsi je 1449 <func0+0x49> mov (%rax),%edx cmp %edx,%ecx jle 1420 <func0+0x20> add $0x4,%rax mov %edx,%ecx mov $0x1,%r8d cmp %rax,%rsi jne 1432 <func0+0x32> mov %r8d,%eax retq nopl (%rax) mov $0x1,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 mov r8d, [rsi] cmp edi, 1 jle short loc_1190 lea edx, [rdi-2] lea rax, [rsi+4] mov ecx, 1 lea rsi, [rsi+rdx*4+8] jmp short loc_1171 loc_1160: setz dl add rax, 4 movzx edx, dl add ecx, edx cmp rsi, rax jz short loc_1189 loc_1171: mov edx, [rax] cmp r8d, edx jle short loc_1160 add rax, 4 mov r8d, edx mov ecx, 1 cmp rsi, rax jnz short loc_1171 loc_1189: mov eax, ecx retn loc_1190: mov ecx, 1 mov eax, ecx retn
long long func0(int a1, int *a2) { int v2; // r8d int *v3; // rax unsigned int v4; // ecx long long v5; // rsi int v6; // edx bool v7; // zf v2 = *a2; if ( a1 <= 1 ) return 1LL; v3 = a2 + 1; v4 = 1; v5 = (long long)&a2[a1 - 2 + 2]; do { while ( 1 ) { v6 = *v3; v7 = v2 == *v3; if ( v2 > *v3 ) break; ++v3; v4 += v7; if ( (int *)v5 == v3 ) return v4; } ++v3; v2 = v6; v4 = 1; } while ( (int *)v5 != v3 ); return v4; }
func0: ENDBR64 MOV R8D,dword ptr [RSI] CMP EDI,0x1 JLE 0x00101190 LEA EDX,[RDI + -0x2] LEA RAX,[RSI + 0x4] MOV ECX,0x1 LEA RSI,[RSI + RDX*0x4 + 0x8] JMP 0x00101171 LAB_00101160: SETZ DL ADD RAX,0x4 MOVZX EDX,DL ADD ECX,EDX CMP RSI,RAX JZ 0x00101189 LAB_00101171: MOV EDX,dword ptr [RAX] CMP R8D,EDX JLE 0x00101160 ADD RAX,0x4 MOV R8D,EDX MOV ECX,0x1 CMP RSI,RAX JNZ 0x00101171 LAB_00101189: MOV EAX,ECX RET LAB_00101190: MOV ECX,0x1 MOV EAX,ECX RET
int func0(int param_1,int *param_2) { int iVar1; int *piVar2; int iVar3; int iVar4; if (param_1 < 2) { return 1; } piVar2 = param_2 + 1; iVar3 = 1; iVar4 = *param_2; do { while( true ) { iVar1 = *piVar2; if (iVar1 < iVar4) break; piVar2 = piVar2 + 1; iVar3 = iVar3 + (uint)(iVar4 == iVar1); if (param_2 + (ulong)(param_1 - 2) + 2 == piVar2) { return iVar3; } } piVar2 = piVar2 + 1; iVar3 = 1; iVar4 = iVar1; } while (param_2 + (ulong)(param_1 - 2) + 2 != piVar2); return 1; }
5,432
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 3; if (n == 1) return 0; if (n == 2) return 2; return func0(n - 2) + func0(n - 3); }
int main() { assert(func0(9) == 12); assert(func0(4) == 2); assert(func0(6) == 5); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x18,%rsp mov %edi,-0x14(%rbp) cmpl $0x0,-0x14(%rbp) jne 1166 <func0+0x1d> mov $0x3,%eax jmp 119e <func0+0x55> cmpl $0x1,-0x14(%rbp) jne 1173 <func0+0x2a> mov $0x0,%eax jmp 119e <func0+0x55> cmpl $0x2,-0x14(%rbp) jne 1180 <func0+0x37> mov $0x2,%eax jmp 119e <func0+0x55> mov -0x14(%rbp),%eax sub $0x2,%eax mov %eax,%edi callq 1149 <func0> mov %eax,%ebx mov -0x14(%rbp),%eax sub $0x3,%eax mov %eax,%edi callq 1149 <func0> add %ebx,%eax add $0x18,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 18h mov [rbp+var_14], edi cmp [rbp+var_14], 0 jnz short loc_1166 mov eax, 3 jmp short loc_119E loc_1166: cmp [rbp+var_14], 1 jnz short loc_1173 mov eax, 0 jmp short loc_119E loc_1173: cmp [rbp+var_14], 2 jnz short loc_1180 mov eax, 2 jmp short loc_119E loc_1180: mov eax, [rbp+var_14] sub eax, 2 mov edi, eax call func0 mov ebx, eax mov eax, [rbp+var_14] sub eax, 3 mov edi, eax call func0 add eax, ebx loc_119E: mov rbx, [rbp+var_8] leave retn
long long func0(int a1) { int v2; // ebx switch ( a1 ) { case 0: return 3LL; case 1: return 0LL; case 2: return 2LL; } v2 = func0((unsigned int)(a1 - 2)); return v2 + (unsigned int)func0((unsigned int)(a1 - 3)); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x18 MOV dword ptr [RBP + -0x14],EDI CMP dword ptr [RBP + -0x14],0x0 JNZ 0x00101166 MOV EAX,0x3 JMP 0x0010119e LAB_00101166: CMP dword ptr [RBP + -0x14],0x1 JNZ 0x00101173 MOV EAX,0x0 JMP 0x0010119e LAB_00101173: CMP dword ptr [RBP + -0x14],0x2 JNZ 0x00101180 MOV EAX,0x2 JMP 0x0010119e LAB_00101180: MOV EAX,dword ptr [RBP + -0x14] SUB EAX,0x2 MOV EDI,EAX CALL 0x00101149 MOV EBX,EAX MOV EAX,dword ptr [RBP + -0x14] SUB EAX,0x3 MOV EDI,EAX CALL 0x00101149 ADD EAX,EBX LAB_0010119e: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int func0(int param_1) { int iVar1; int iVar2; if (param_1 == 0) { iVar2 = 3; } else if (param_1 == 1) { iVar2 = 0; } else if (param_1 == 2) { iVar2 = 2; } else { iVar1 = func0(param_1 + -2); iVar2 = func0(param_1 + -3); iVar2 = iVar2 + iVar1; } return iVar2; }
5,433
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 3; if (n == 1) return 0; if (n == 2) return 2; return func0(n - 2) + func0(n - 3); }
int main() { assert(func0(9) == 12); assert(func0(4) == 2); assert(func0(6) == 5); return 0; }
O1
c
func0: endbr64 mov $0x3,%eax test %edi,%edi je 118a <func0+0x41> push %rbp push %rbx sub $0x8,%rsp mov %edi,%ebx mov $0x0,%eax cmp $0x1,%edi je 1183 <func0+0x3a> mov %edi,%eax cmp $0x2,%edi je 1183 <func0+0x3a> lea -0x2(%rdi),%edi callq 1149 <func0> mov %eax,%ebp lea -0x3(%rbx),%edi callq 1149 <func0> add %ebp,%eax add $0x8,%rsp pop %rbx pop %rbp retq retq
func0: endbr64 mov eax, 3 test edi, edi jz short locret_118A push rbp push rbx sub rsp, 8 mov ebx, edi mov eax, 0 cmp edi, 1 jz short loc_1183 mov eax, edi cmp edi, 2 jz short loc_1183 lea edi, [rdi-2] call func0 mov ebp, eax lea edi, [rbx-3] call func0 add eax, ebp loc_1183: add rsp, 8 pop rbx pop rbp retn locret_118A: retn
long long func0(unsigned int a1) { long long result; // rax int v2; // ebp result = 3LL; if ( a1 ) { result = 0LL; if ( a1 != 1 ) { result = a1; if ( a1 != 2 ) { v2 = func0(a1 - 2); return v2 + (unsigned int)func0(a1 - 3); } } } return result; }
func0: ENDBR64 MOV EAX,0x3 TEST EDI,EDI JZ 0x0010118a PUSH RBP PUSH RBX SUB RSP,0x8 MOV EBX,EDI MOV EAX,0x0 CMP EDI,0x1 JZ 0x00101183 MOV EAX,EDI CMP EDI,0x2 JZ 0x00101183 LEA EDI,[RDI + -0x2] CALL 0x00101149 MOV EBP,EAX LEA EDI,[RBX + -0x3] CALL 0x00101149 ADD EAX,EBP LAB_00101183: ADD RSP,0x8 POP RBX POP RBP RET LAB_0010118a: RET
int func0(int param_1) { int iVar1; int iVar2; if (param_1 != 0) { iVar2 = 0; if ((param_1 != 1) && (iVar2 = param_1, param_1 != 2)) { iVar1 = func0(param_1 + -2); iVar2 = func0(param_1 + -3); iVar2 = iVar2 + iVar1; } return iVar2; } return 3; }
5,434
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 3; if (n == 1) return 0; if (n == 2) return 2; return func0(n - 2) + func0(n - 3); }
int main() { assert(func0(9) == 12); assert(func0(4) == 2); assert(func0(6) == 5); return 0; }
O2
c
func0: endbr64 push %r12 push %rbx sub $0x8,%rsp test %edi,%edi je 1250 <func0+0x60> cmp $0x1,%edi je 1260 <func0+0x70> lea -0x2(%rdi),%ebx xor %r12d,%r12d cmp $0x2,%edi je 1268 <func0+0x78> mov %ebx,%edi callq 11f0 <func0> add %eax,%r12d cmp $0x1,%ebx je 1240 <func0+0x50> cmp $0x2,%ebx je 122c <func0+0x3c> sub $0x3,%ebx jne 120f <func0+0x1f> add $0x2,%r12d add $0x8,%rsp mov %r12d,%eax pop %rbx pop %r12 retq nopw 0x0(%rax,%rax,1) add $0x3,%r12d add $0x8,%rsp mov %r12d,%eax pop %rbx pop %r12 retq mov $0x3,%r12d jmp 122c <func0+0x3c> nopl 0x0(%rax,%rax,1) xor %r12d,%r12d jmp 122c <func0+0x3c> nopl (%rax) mov $0x2,%r12d jmp 122c <func0+0x3c>
func0: endbr64 test edi, edi jz loc_15F8 mov r8d, edi cmp edi, 1 jz loc_1602 cmp edi, 2 jz loc_15FE push r15 lea eax, [rdi-3] xor r8d, r8d push r14 push r13 push r12 push rbp push rbx sub rsp, 38h mov [rsp+68h+var_60], eax mov edi, [rsp+68h+var_60] mov [rsp+68h+var_68], r8d mov eax, edi add eax, 1 jz loc_15BD loc_123C: cmp eax, 1 jz loc_15EE cmp eax, 2 jz loc_15D4 lea eax, [rdi-2] xor ecx, ecx mov [rsp+68h+var_5C], eax mov edi, [rsp+68h+var_5C] mov [rsp+68h+var_64], ecx mov eax, edi add eax, 1 jz loc_1582 loc_126A: cmp eax, 1 jz loc_15C3 cmp eax, 2 jz loc_1589 lea ecx, [rdi-2] xor r11d, r11d mov eax, ecx add eax, 1 jz loc_153F loc_128D: cmp eax, 1 jz loc_1486 cmp eax, 2 jz loc_154A lea edx, [rcx-2] xor r10d, r10d mov eax, edx add eax, 1 jz loc_1434 loc_12B0: cmp eax, 1 jz loc_1475 cmp eax, 2 jz loc_1512 lea ebp, [rdx-2] xor r9d, r9d mov r8d, ebp loc_12CB: mov eax, r8d add eax, 1 jz loc_1505 cmp eax, 1 jz loc_1407 cmp eax, 2 jz loc_14FA lea ebx, [r8-2] xor esi, esi mov r12d, ebx loc_12F2: mov eax, r12d add eax, 1 jz loc_14C7 cmp eax, 1 jz loc_13F8 cmp eax, 2 jz loc_14AF lea r15d, [r12-2] xor ebp, ebp loc_1317: mov eax, r15d add eax, 1 jz loc_14BB cmp eax, 1 jz loc_13E7 cmp eax, 2 jz loc_1446 lea r14d, [r15-2] xor ebx, ebx loc_133B: mov eax, r14d add eax, 1 jz loc_14E8 cmp eax, 1 jz loc_13D8 cmp eax, 2 jz loc_14A1 lea edi, [r14-1] xor r13d, r13d loc_1360: mov [rsp+68h+var_3C], r8d mov [rsp+68h+var_40], edx mov [rsp+68h+var_44], ecx mov [rsp+68h+var_48], r9d mov [rsp+68h+var_4C], esi mov [rsp+68h+var_50], r10d mov [rsp+68h+var_54], r11d mov [rsp+68h+var_58], edi call func0 mov edi, [rsp+68h+var_58] mov r11d, [rsp+68h+var_54] add r13d, eax mov r10d, [rsp+68h+var_50] mov esi, [rsp+68h+var_4C] cmp edi, 1 mov r9d, [rsp+68h+var_48] mov ecx, [rsp+68h+var_44] mov edx, [rsp+68h+var_40] mov r8d, [rsp+68h+var_3C] jz loc_14D8 cmp edi, 2 jz short loc_13C7 sub edi, 3 jnz short loc_1360 add r13d, 2 loc_13C7: add ebx, r13d test r14d, r14d jnz loc_1491 nop dword ptr [rax+rax+00h] loc_13D8: add ebx, 3 nop dword ptr [rax+rax+00h] loc_13E0: add ebp, ebx test r15d, r15d jnz short loc_143A loc_13E7: add ebp, 3 loc_13EA: add esi, ebp test r12d, r12d jnz short loc_1450 nop dword ptr [rax+00000000h] loc_13F8: mov r12d, esi add r12d, 3 loc_13FF: add r9d, r12d test r8d, r8d jnz short loc_1461 loc_1407: mov ebx, r9d add ebx, 3 loc_140D: add r10d, ebx test edx, edx jz short loc_1475 loc_1414: cmp edx, 1 jz loc_1545 cmp edx, 2 jz loc_1512 loc_1426: sub edx, 3 mov eax, edx add eax, 1 jnz loc_12B0 loc_1434: add r10d, 3 jmp short loc_1426 loc_143A: cmp r15d, 1 jz short loc_13EA cmp r15d, 2 jnz short loc_14BE loc_1446: add ebp, 2 add esi, ebp test r12d, r12d jz short loc_13F8 loc_1450: cmp r12d, 1 jnz short loc_14A9 mov r12d, esi add r9d, r12d test r8d, r8d jz short loc_1407 loc_1461: cmp r8d, 1 jnz loc_14F4 mov ebx, r9d add r10d, ebx test edx, edx jnz short loc_1414 loc_1475: mov ebp, r10d add ebp, 3 add r11d, ebp test ecx, ecx jnz loc_1523 loc_1486: mov ebx, r11d add ebx, 3 jmp loc_1550 loc_1491: cmp r14d, 1 jz loc_13E0 cmp r14d, 2 jnz short loc_14EB loc_14A1: add ebx, 2 jmp loc_13E0 loc_14A9: cmp r12d, 2 jnz short loc_14CA loc_14AF: mov r12d, esi add r12d, 2 jmp loc_13FF loc_14BB: add ebp, 3 loc_14BE: sub r15d, 3 jmp loc_1317 loc_14C7: add esi, 3 loc_14CA: sub r12d, 3 jmp loc_12F2 loc_14D8: add r13d, 3 jmp loc_13C7 loc_14E8: add ebx, 3 loc_14EB: sub r14d, 3 jmp loc_133B loc_14F4: cmp r8d, 2 jnz short loc_1509 loc_14FA: mov ebx, r9d add ebx, 2 jmp loc_140D loc_1505: add r9d, 3 loc_1509: sub r8d, 3 jmp loc_12CB loc_1512: mov ebp, r10d add ebp, 2 loc_1518: add r11d, ebp test ecx, ecx jz loc_1486 loc_1523: cmp ecx, 1 jz loc_15CC cmp ecx, 2 jz short loc_154A loc_1531: sub ecx, 3 mov eax, ecx add eax, 1 jnz loc_128D loc_153F: add r11d, 3 jmp short loc_1531 loc_1545: mov ebp, r10d jmp short loc_1518 loc_154A: mov ebx, r11d add ebx, 2 loc_1550: mov edx, [rsp+68h+var_5C] add [rsp+68h+var_64], ebx test edx, edx jz short loc_15C3 mov eax, [rsp+68h+var_5C] cmp eax, 1 jz loc_1607 cmp eax, 2 jz short loc_1589 loc_156E: sub [rsp+68h+var_5C], 3 mov edi, [rsp+68h+var_5C] mov eax, edi add eax, 1 jnz loc_126A loc_1582: add [rsp+68h+var_64], 3 jmp short loc_156E loc_1589: mov ecx, [rsp+68h+var_64] add ecx, 2 loc_1590: mov eax, [rsp+68h+var_60] add [rsp+68h+var_68], ecx test eax, eax jz short loc_15EE mov eax, [rsp+68h+var_60] cmp eax, 1 jz short loc_160D cmp eax, 2 jz short loc_15D4 loc_15A9: sub [rsp+68h+var_60], 3 mov edi, [rsp+68h+var_60] mov eax, edi add eax, 1 jnz loc_123C loc_15BD: add [rsp+68h+var_68], 3 jmp short loc_15A9 loc_15C3: mov ecx, [rsp+68h+var_64] add ecx, 3 jmp short loc_1590 loc_15CC: mov ebx, r11d jmp loc_1550 loc_15D4: mov r8d, [rsp+68h+var_68] add r8d, 2 loc_15DC: add rsp, 38h mov eax, r8d pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_15EE: mov r8d, [rsp+68h+var_68] add r8d, 3 jmp short loc_15DC loc_15F8: mov r8d, 3 loc_15FE: mov eax, r8d retn loc_1602: xor r8d, r8d jmp short loc_15FE loc_1607: mov ecx, [rsp+68h+var_64] jmp short loc_1590 loc_160D: mov r8d, [rsp+68h+var_68] jmp short loc_15DC
long long func0(unsigned int a1) { unsigned int v1; // r8d unsigned int v2; // edi unsigned int v3; // eax unsigned int v4; // edi unsigned int v5; // eax unsigned int v6; // ecx int v7; // r11d int v8; // eax unsigned int v9; // edx int v10; // r10d int v11; // eax int v12; // r9d unsigned int i; // r8d int v14; // esi unsigned int v15; // r12d int v16; // r15d int v17; // ebp int v18; // r14d int v19; // ebx int v20; // edi int v21; // r13d int v22; // eax int v23; // ebx int v24; // r12d int v25; // ebx int v26; // ebx int v27; // ebp int v28; // ecx unsigned int v31; // [rsp+0h] [rbp-68h] int v32; // [rsp+4h] [rbp-64h] unsigned int v33; // [rsp+8h] [rbp-60h] unsigned int v34; // [rsp+Ch] [rbp-5Ch] int v35; // [rsp+14h] [rbp-54h] int v36; // [rsp+18h] [rbp-50h] int v37; // [rsp+20h] [rbp-48h] unsigned int v38; // [rsp+24h] [rbp-44h] unsigned int v39; // [rsp+28h] [rbp-40h] unsigned int v40; // [rsp+2Ch] [rbp-3Ch] if ( !a1 ) return 3; v1 = a1; if ( a1 == 1 ) return 0; if ( a1 == 2 ) return v1; v33 = a1 - 3; v2 = a1 - 3; v31 = 0; v3 = v2 + 1; if ( v2 == -1 ) goto LABEL_86; while ( 2 ) { if ( v3 == 1 ) return v31 + 3; if ( v3 == 2 ) return v31 + 2; v34 = v2 - 2; v4 = v2 - 2; v32 = 0; v5 = v4 + 1; if ( v4 == -1 ) { do { v32 += 3; LABEL_79: v34 -= 3; v4 = v34; v5 = v34 + 1; } while ( v34 == -1 ); } if ( v5 == 1 ) { LABEL_87: v28 = v32 + 3; goto LABEL_82; } if ( v5 == 2 ) goto LABEL_81; v6 = v4 - 2; v7 = 0; v8 = v4 - 2 + 1; if ( v4 == 1 ) { do { v7 += 3; LABEL_72: v6 -= 3; v8 = v6 + 1; } while ( v6 == -1 ); } if ( v8 == 1 ) goto LABEL_52; if ( v8 == 2 ) goto LABEL_75; v9 = v6 - 2; v10 = 0; v11 = v6 - 2 + 1; if ( v6 == 1 ) { do { v10 += 3; LABEL_47: v9 -= 3; v11 = v9 + 1; } while ( v9 == -1 ); } if ( v11 == 1 ) { LABEL_51: v7 += v10 + 3; if ( v6 ) goto LABEL_70; LABEL_52: v26 = v7 + 3; goto LABEL_76; } if ( v11 == 2 ) goto LABEL_68; v12 = 0; for ( i = v9 - 2; ; i -= 3 ) { switch ( i ) { case 0xFFFFFFFF: v12 += 3; continue; case 0u: v25 = v12 + 3; goto LABEL_44; case 1u: goto LABEL_65; } v14 = 0; v15 = i - 2; LABEL_21: if ( v15 == -1 ) { v14 += 3; goto LABEL_60; } if ( v15 ) { if ( v15 == 1 ) goto LABEL_56; v16 = v15 - 2; v17 = 0; while ( 1 ) { switch ( v16 ) { case -1: v17 += 3; goto LABEL_58; case 0: v14 += v17 + 3; goto LABEL_55; case 1: goto LABEL_50; } v18 = v16 - 2; v19 = 0; while ( 1 ) { if ( v18 == -1 ) { v19 += 3; goto LABEL_63; } if ( !v18 ) { v23 = v19 + 3; goto LABEL_39; } if ( v18 == 1 ) break; v20 = v18 - 1; v21 = 0; while ( 1 ) { v40 = i; v39 = v9; v38 = v6; v37 = v12; v36 = v10; v35 = v7; v22 = func0(); v7 = v35; v21 += v22; v10 = v36; v12 = v37; v6 = v38; v9 = v39; i = v40; if ( v20 == 1 ) break; if ( v20 == 2 ) goto LABEL_37; v20 -= 3; if ( !v20 ) { v21 += 2; goto LABEL_37; } } v21 += 3; LABEL_37: v19 += v21; if ( v18 == 2 ) break; LABEL_63: v18 -= 3; } v23 = v19 + 2; LABEL_39: v17 += v23; if ( v16 == 2 ) { LABEL_50: v14 += v17 + 2; LABEL_55: if ( v15 == 2 ) { LABEL_56: v24 = v14 + 2; goto LABEL_42; } LABEL_60: v15 -= 3; goto LABEL_21; } LABEL_58: v16 -= 3; } } v24 = v14 + 3; LABEL_42: v12 += v24; if ( i == 2 ) break; } LABEL_65: v25 = v12 + 2; LABEL_44: v10 += v25; switch ( v9 ) { case 0u: goto LABEL_51; case 1u: v27 = v10; break; case 2u: LABEL_68: v27 = v10 + 2; break; default: goto LABEL_47; } v7 += v27; if ( !v6 ) goto LABEL_52; LABEL_70: if ( v6 == 1 ) { v26 = v7; } else { if ( v6 != 2 ) goto LABEL_72; LABEL_75: v26 = v7 + 2; } LABEL_76: v32 += v26; switch ( v34 ) { case 0u: goto LABEL_87; case 1u: v28 = v32; break; case 2u: LABEL_81: v28 = v32 + 2; break; default: goto LABEL_79; } LABEL_82: v31 += v28; if ( !v33 ) return v31 + 3; if ( v33 != 1 ) { if ( v33 == 2 ) return v31 + 2; while ( 1 ) { v33 -= 3; v2 = v33; v3 = v33 + 1; if ( v33 != -1 ) break; LABEL_86: v31 += 3; } continue; } break; } return v31; }
func0: ENDBR64 TEST EDI,EDI JZ 0x001015f8 MOV R8D,EDI CMP EDI,0x1 JZ 0x00101602 CMP EDI,0x2 JZ 0x001015fe PUSH R15 LEA EAX,[RDI + -0x3] XOR R8D,R8D PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x38 MOV dword ptr [RSP + 0x8],EAX MOV EDI,dword ptr [RSP + 0x8] MOV dword ptr [RSP],R8D MOV EAX,EDI ADD EAX,0x1 JZ 0x001015bd LAB_0010123c: CMP EAX,0x1 JZ 0x001015ee CMP EAX,0x2 JZ 0x001015d4 LEA EAX,[RDI + -0x2] XOR ECX,ECX MOV dword ptr [RSP + 0xc],EAX MOV EDI,dword ptr [RSP + 0xc] MOV dword ptr [RSP + 0x4],ECX MOV EAX,EDI ADD EAX,0x1 JZ 0x00101582 LAB_0010126a: CMP EAX,0x1 JZ 0x001015c3 CMP EAX,0x2 JZ 0x00101589 LEA ECX,[RDI + -0x2] XOR R11D,R11D MOV EAX,ECX ADD EAX,0x1 JZ 0x0010153f LAB_0010128d: CMP EAX,0x1 JZ 0x00101486 CMP EAX,0x2 JZ 0x0010154a LEA EDX,[RCX + -0x2] XOR R10D,R10D MOV EAX,EDX ADD EAX,0x1 JZ 0x00101434 LAB_001012b0: CMP EAX,0x1 JZ 0x00101475 CMP EAX,0x2 JZ 0x00101512 LEA EBP,[RDX + -0x2] XOR R9D,R9D MOV R8D,EBP LAB_001012cb: MOV EAX,R8D ADD EAX,0x1 JZ 0x00101505 CMP EAX,0x1 JZ 0x00101407 CMP EAX,0x2 JZ 0x001014fa LEA EBX,[R8 + -0x2] XOR ESI,ESI MOV R12D,EBX LAB_001012f2: MOV EAX,R12D ADD EAX,0x1 JZ 0x001014c7 CMP EAX,0x1 JZ 0x001013f8 CMP EAX,0x2 JZ 0x001014af LEA R15D,[R12 + -0x2] XOR EBP,EBP LAB_00101317: MOV EAX,R15D ADD EAX,0x1 JZ 0x001014bb CMP EAX,0x1 JZ 0x001013e7 CMP EAX,0x2 JZ 0x00101446 LEA R14D,[R15 + -0x2] XOR EBX,EBX LAB_0010133b: MOV EAX,R14D ADD EAX,0x1 JZ 0x001014e8 CMP EAX,0x1 JZ 0x001013d8 CMP EAX,0x2 JZ 0x001014a1 LEA EDI,[R14 + -0x1] XOR R13D,R13D LAB_00101360: MOV dword ptr [RSP + 0x2c],R8D MOV dword ptr [RSP + 0x28],EDX MOV dword ptr [RSP + 0x24],ECX MOV dword ptr [RSP + 0x20],R9D MOV dword ptr [RSP + 0x1c],ESI MOV dword ptr [RSP + 0x18],R10D MOV dword ptr [RSP + 0x14],R11D MOV dword ptr [RSP + 0x10],EDI CALL 0x001011f0 MOV EDI,dword ptr [RSP + 0x10] MOV R11D,dword ptr [RSP + 0x14] ADD R13D,EAX MOV R10D,dword ptr [RSP + 0x18] MOV ESI,dword ptr [RSP + 0x1c] CMP EDI,0x1 MOV R9D,dword ptr [RSP + 0x20] MOV ECX,dword ptr [RSP + 0x24] MOV EDX,dword ptr [RSP + 0x28] MOV R8D,dword ptr [RSP + 0x2c] JZ 0x001014d8 CMP EDI,0x2 JZ 0x001013c7 SUB EDI,0x3 JNZ 0x00101360 ADD R13D,0x2 LAB_001013c7: ADD EBX,R13D TEST R14D,R14D JNZ 0x00101491 NOP dword ptr [RAX + RAX*0x1] LAB_001013d8: ADD EBX,0x3 NOP dword ptr [RAX + RAX*0x1] LAB_001013e0: ADD EBP,EBX TEST R15D,R15D JNZ 0x0010143a LAB_001013e7: ADD EBP,0x3 LAB_001013ea: ADD ESI,EBP TEST R12D,R12D JNZ 0x00101450 NOP dword ptr [RAX] LAB_001013f8: MOV R12D,ESI ADD R12D,0x3 LAB_001013ff: ADD R9D,R12D TEST R8D,R8D JNZ 0x00101461 LAB_00101407: MOV EBX,R9D ADD EBX,0x3 LAB_0010140d: ADD R10D,EBX TEST EDX,EDX JZ 0x00101475 LAB_00101414: CMP EDX,0x1 JZ 0x00101545 CMP EDX,0x2 JZ 0x00101512 LAB_00101426: SUB EDX,0x3 MOV EAX,EDX ADD EAX,0x1 JNZ 0x001012b0 LAB_00101434: ADD R10D,0x3 JMP 0x00101426 LAB_0010143a: CMP R15D,0x1 JZ 0x001013ea CMP R15D,0x2 JNZ 0x001014be LAB_00101446: ADD EBP,0x2 ADD ESI,EBP TEST R12D,R12D JZ 0x001013f8 LAB_00101450: CMP R12D,0x1 JNZ 0x001014a9 MOV R12D,ESI ADD R9D,R12D TEST R8D,R8D JZ 0x00101407 LAB_00101461: CMP R8D,0x1 JNZ 0x001014f4 MOV EBX,R9D ADD R10D,EBX TEST EDX,EDX JNZ 0x00101414 LAB_00101475: MOV EBP,R10D ADD EBP,0x3 ADD R11D,EBP TEST ECX,ECX JNZ 0x00101523 LAB_00101486: MOV EBX,R11D ADD EBX,0x3 JMP 0x00101550 LAB_00101491: CMP R14D,0x1 JZ 0x001013e0 CMP R14D,0x2 JNZ 0x001014eb LAB_001014a1: ADD EBX,0x2 JMP 0x001013e0 LAB_001014a9: CMP R12D,0x2 JNZ 0x001014ca LAB_001014af: MOV R12D,ESI ADD R12D,0x2 JMP 0x001013ff LAB_001014bb: ADD EBP,0x3 LAB_001014be: SUB R15D,0x3 JMP 0x00101317 LAB_001014c7: ADD ESI,0x3 LAB_001014ca: SUB R12D,0x3 JMP 0x001012f2 LAB_001014d8: ADD R13D,0x3 JMP 0x001013c7 LAB_001014e8: ADD EBX,0x3 LAB_001014eb: SUB R14D,0x3 JMP 0x0010133b LAB_001014f4: CMP R8D,0x2 JNZ 0x00101509 LAB_001014fa: MOV EBX,R9D ADD EBX,0x2 JMP 0x0010140d LAB_00101505: ADD R9D,0x3 LAB_00101509: SUB R8D,0x3 JMP 0x001012cb LAB_00101512: MOV EBP,R10D ADD EBP,0x2 LAB_00101518: ADD R11D,EBP TEST ECX,ECX JZ 0x00101486 LAB_00101523: CMP ECX,0x1 JZ 0x001015cc CMP ECX,0x2 JZ 0x0010154a LAB_00101531: SUB ECX,0x3 MOV EAX,ECX ADD EAX,0x1 JNZ 0x0010128d LAB_0010153f: ADD R11D,0x3 JMP 0x00101531 LAB_00101545: MOV EBP,R10D JMP 0x00101518 LAB_0010154a: MOV EBX,R11D ADD EBX,0x2 LAB_00101550: MOV EDX,dword ptr [RSP + 0xc] ADD dword ptr [RSP + 0x4],EBX TEST EDX,EDX JZ 0x001015c3 MOV EAX,dword ptr [RSP + 0xc] CMP EAX,0x1 JZ 0x00101607 CMP EAX,0x2 JZ 0x00101589 LAB_0010156e: SUB dword ptr [RSP + 0xc],0x3 MOV EDI,dword ptr [RSP + 0xc] MOV EAX,EDI ADD EAX,0x1 JNZ 0x0010126a LAB_00101582: ADD dword ptr [RSP + 0x4],0x3 JMP 0x0010156e LAB_00101589: MOV ECX,dword ptr [RSP + 0x4] ADD ECX,0x2 LAB_00101590: MOV EAX,dword ptr [RSP + 0x8] ADD dword ptr [RSP],ECX TEST EAX,EAX JZ 0x001015ee MOV EAX,dword ptr [RSP + 0x8] CMP EAX,0x1 JZ 0x0010160d CMP EAX,0x2 JZ 0x001015d4 LAB_001015a9: SUB dword ptr [RSP + 0x8],0x3 MOV EDI,dword ptr [RSP + 0x8] MOV EAX,EDI ADD EAX,0x1 JNZ 0x0010123c LAB_001015bd: ADD dword ptr [RSP],0x3 JMP 0x001015a9 LAB_001015c3: MOV ECX,dword ptr [RSP + 0x4] ADD ECX,0x3 JMP 0x00101590 LAB_001015cc: MOV EBX,R11D JMP 0x00101550 LAB_001015d4: MOV R8D,dword ptr [RSP] ADD R8D,0x2 LAB_001015dc: ADD RSP,0x38 MOV EAX,R8D POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001015ee: MOV R8D,dword ptr [RSP] ADD R8D,0x3 JMP 0x001015dc LAB_001015f8: MOV R8D,0x3 LAB_001015fe: MOV EAX,R8D RET LAB_00101602: XOR R8D,R8D JMP 0x001015fe LAB_00101607: MOV ECX,dword ptr [RSP + 0x4] JMP 0x00101590 LAB_0010160d: MOV R8D,dword ptr [RSP] JMP 0x001015dc
int func0(int param_1) { int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; int iVar15; int local_68; int local_64; int local_60; int local_5c; if (param_1 == 0) { param_1 = 3; } else if (param_1 == 1) { param_1 = 0; } else if (param_1 != 2) { local_68 = 0; iVar1 = param_1 + -2; local_60 = param_1 + -3; if (iVar1 == 0) goto LAB_001015bd; while (iVar1 != 1) { if (iVar1 == 2) { LAB_001015d4: return local_68 + 2; } local_64 = 0; iVar1 = local_60 + -1; local_5c = local_60 + -2; if (iVar1 == 0) goto LAB_00101582; while (iVar1 != 1) { if (iVar1 == 2) { LAB_00101589: local_64 = local_64 + 2; goto LAB_00101590; } iVar1 = local_5c + -2; iVar11 = 0; iVar2 = local_5c + -1; if (iVar2 == 0) goto LAB_0010153f; while (iVar2 != 1) { if (iVar2 == 2) { LAB_0010154a: iVar11 = iVar11 + 2; goto LAB_00101550; } iVar5 = iVar1 + -2; iVar2 = 0; iVar3 = iVar1 + -1; if (iVar3 == 0) goto LAB_00101434; while (iVar3 != 1) { if (iVar3 == 2) { LAB_00101512: iVar2 = iVar2 + 2; goto joined_r0x0010151d; } iVar8 = 0; for (iVar3 = iVar5 + -2; iVar3 == -1; iVar3 = iVar3 + -3) { iVar8 = iVar8 + 3; LAB_00101509: } if (iVar3 == 0) { LAB_00101407: iVar8 = iVar8 + 3; } else if (iVar3 == 1) { LAB_001014fa: iVar8 = iVar8 + 2; } else { iVar12 = 0; for (iVar6 = iVar3 + -2; iVar6 == -1; iVar6 = iVar6 + -3) { iVar12 = iVar12 + 3; LAB_001014ca: } if (iVar6 == 0) { LAB_001013f8: iVar12 = iVar12 + 3; } else if (iVar6 == 1) { LAB_001014af: iVar12 = iVar12 + 2; } else { iVar9 = 0; for (iVar15 = iVar6 + -2; iVar15 == -1; iVar15 = iVar15 + -3) { iVar9 = iVar9 + 3; LAB_001014be: } if (iVar15 == 0) { LAB_001013e7: iVar9 = iVar9 + 3; } else if (iVar15 == 1) { LAB_00101446: iVar9 = iVar9 + 2; } else { iVar7 = 0; for (iVar14 = iVar15 + -2; iVar14 == -1; iVar14 = iVar14 + -3) { iVar7 = iVar7 + 3; LAB_001014eb: } if (iVar14 == 0) { LAB_001013d8: iVar7 = iVar7 + 3; } else if (iVar14 == 1) { LAB_001014a1: iVar7 = iVar7 + 2; } else { iVar10 = iVar14 + -1; iVar13 = 0; do { iVar4 = func0(); iVar13 = iVar13 + iVar4; if (iVar10 == 1) { iVar13 = iVar13 + 3; goto LAB_001013c7; } if (iVar10 == 2) goto LAB_001013c7; iVar10 = iVar10 + -3; } while (iVar10 != 0); iVar13 = iVar13 + 2; LAB_001013c7: iVar7 = iVar7 + iVar13; if (iVar14 == 0) goto LAB_001013d8; if (iVar14 != 1) { if (iVar14 != 2) goto LAB_001014eb; goto LAB_001014a1; } } iVar9 = iVar9 + iVar7; if (iVar15 == 0) goto LAB_001013e7; if (iVar15 != 1) { if (iVar15 != 2) goto LAB_001014be; goto LAB_00101446; } } iVar12 = iVar12 + iVar9; if (iVar6 == 0) goto LAB_001013f8; if (iVar6 != 1) { if (iVar6 != 2) goto LAB_001014ca; goto LAB_001014af; } } iVar8 = iVar8 + iVar12; if (iVar3 == 0) goto LAB_00101407; if (iVar3 != 1) { if (iVar3 != 2) goto LAB_00101509; goto LAB_001014fa; } } iVar2 = iVar2 + iVar8; if (iVar5 == 0) break; if (iVar5 == 1) goto joined_r0x0010151d; iVar3 = iVar5; if (iVar5 == 2) goto LAB_00101512; while( true ) { iVar5 = iVar3 + -3; iVar3 = iVar3 + -2; if (iVar3 != 0) break; LAB_00101434: iVar2 = iVar2 + 3; iVar3 = iVar5; } } iVar2 = iVar2 + 3; joined_r0x0010151d: iVar11 = iVar11 + iVar2; if (iVar1 == 0) break; if (iVar1 == 1) goto LAB_00101550; iVar2 = iVar1; if (iVar1 == 2) goto LAB_0010154a; while( true ) { iVar1 = iVar2 + -3; iVar2 = iVar2 + -2; if (iVar2 != 0) break; LAB_0010153f: iVar11 = iVar11 + 3; iVar2 = iVar1; } } iVar11 = iVar11 + 3; LAB_00101550: local_64 = local_64 + iVar11; if (local_5c == 0) break; if (local_5c == 1) goto LAB_00101590; if (local_5c == 2) goto LAB_00101589; while( true ) { iVar11 = local_5c + -3; iVar1 = local_5c + -2; local_5c = iVar11; if (iVar1 != 0) break; LAB_00101582: local_64 = local_64 + 3; } } local_64 = local_64 + 3; LAB_00101590: local_68 = local_68 + local_64; if (local_60 == 0) break; if (local_60 == 1) { return local_68; } if (local_60 == 2) goto LAB_001015d4; while( true ) { iVar11 = local_60 + -3; iVar1 = local_60 + -2; local_60 = iVar11; if (iVar1 != 0) break; LAB_001015bd: local_68 = local_68 + 3; } } return local_68 + 3; } return param_1; }
5,435
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 3; if (n == 1) return 0; if (n == 2) return 2; return func0(n - 2) + func0(n - 3); }
int main() { assert(func0(9) == 12); assert(func0(4) == 2); assert(func0(6) == 5); return 0; }
O3
c
func0: endbr64 push %r12 push %rbx sub $0x8,%rsp test %edi,%edi je 1250 <func0+0x60> cmp $0x1,%edi je 1260 <func0+0x70> lea -0x2(%rdi),%ebx xor %r12d,%r12d cmp $0x2,%edi je 1268 <func0+0x78> mov %ebx,%edi callq 11f0 <func0> add %eax,%r12d cmp $0x1,%ebx je 1240 <func0+0x50> cmp $0x2,%ebx je 122c <func0+0x3c> sub $0x3,%ebx jne 120f <func0+0x1f> add $0x2,%r12d add $0x8,%rsp mov %r12d,%eax pop %rbx pop %r12 retq nopw 0x0(%rax,%rax,1) add $0x3,%r12d add $0x8,%rsp mov %r12d,%eax pop %rbx pop %r12 retq mov $0x3,%r12d jmp 122c <func0+0x3c> nopl 0x0(%rax,%rax,1) xor %r12d,%r12d jmp 122c <func0+0x3c> nopl (%rax) mov $0x2,%r12d jmp 122c <func0+0x3c>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 38h test edi, edi jz loc_1537 mov r13d, edi cmp edi, 1 jz loc_1542 cmp edi, 2 jz loc_1488 lea ebx, [rdi-2] xor ebp, ebp loc_1244: cmp ebx, 1 jz loc_152B cmp ebx, 2 jz loc_1481 mov [rsp+68h+var_68], ebp lea r12d, [rbx-2] xor r15d, r15d mov r13d, ebx loc_1263: cmp r12d, 1 jz loc_151C cmp r12d, 2 jz loc_146B mov [rsp+68h+var_64], r15d lea ebx, [r12-2] xor ebp, ebp mov r14d, r13d mov [rsp+68h+var_60], r12d mov r13d, ebp mov r12d, ebx loc_1291: cmp r12d, 1 jz loc_1504 cmp r12d, 2 jz loc_144B lea ebp, [r12-2] xor r15d, r15d mov [rsp+68h+var_5C], r12d mov eax, r14d mov r12d, r13d mov ebx, r15d mov r14d, ebp loc_12BE: cmp r14d, 1 jz loc_14ED cmp r14d, 2 jz loc_142C lea r15d, [r14-2] xor r13d, r13d mov edx, r14d mov ecx, eax mov esi, r15d mov r14d, r13d mov r15d, r12d loc_12E7: cmp esi, 1 jz loc_14D9 cmp esi, 2 jz loc_1410 xor r12d, r12d lea r13d, [rsi-2] mov r8d, r14d mov r9d, r12d mov r12d, ebx mov ebx, r13d loc_130C: cmp ebx, 1 jz loc_14B9 cmp ebx, 2 jz loc_13F7 lea r14d, [rbx-2] xor r10d, r10d mov ebp, r14d loc_1328: cmp ebp, 1 jz loc_14AE cmp ebp, 2 jz loc_13E5 lea r14d, [rbp-2] mov r11d, ebp xor r13d, r13d mov ebp, ebx mov ebx, r14d loc_1349: cmp ebx, 1 jz loc_14A0 cmp ebx, 2 jz short loc_13D0 lea edi, [rbx-2] xor r14d, r14d loc_135D: mov [rsp+68h+var_3C], ecx mov [rsp+68h+var_40], r11d mov [rsp+68h+var_44], r10d mov [rsp+68h+var_48], edx mov [rsp+68h+var_4C], r9d mov [rsp+68h+var_50], r8d mov [rsp+68h+var_54], esi mov [rsp+68h+var_58], edi call func0 mov edi, [rsp+68h+var_58] mov esi, [rsp+68h+var_54] add r14d, eax mov r8d, [rsp+68h+var_50] mov r9d, [rsp+68h+var_4C] cmp edi, 1 mov edx, [rsp+68h+var_48] mov r10d, [rsp+68h+var_44] mov r11d, [rsp+68h+var_40] mov ecx, [rsp+68h+var_3C] jz loc_14D0 cmp edi, 2 jz short loc_13C4 sub edi, 3 jnz short loc_135D add r14d, 2 loc_13C4: add r13d, r14d sub ebx, 3 jnz loc_1349 loc_13D0: mov ebx, ebp add r13d, 2 mov ebp, r11d loc_13D9: add r10d, r13d sub ebp, 3 jnz loc_1328 loc_13E5: mov ebp, r10d add ebp, 2 loc_13EB: add r9d, ebp sub ebx, 3 jnz loc_130C loc_13F7: mov ebx, r12d mov r12d, r9d mov r14d, r8d add r12d, 2 loc_1404: add r14d, r12d sub esi, 3 jnz loc_12E7 loc_1410: mov r13d, r14d mov r12d, r15d mov r14d, edx mov eax, ecx add r13d, 2 loc_141F: add ebx, r13d sub r14d, 3 jnz loc_12BE loc_142C: mov r13d, r12d mov r15d, ebx mov r12d, [rsp+68h+var_5C] mov r14d, eax add r15d, 2 loc_143E: add r13d, r15d sub r12d, 3 jnz loc_1291 loc_144B: mov ebp, r13d mov r15d, [rsp+68h+var_64] mov r12d, [rsp+68h+var_60] mov r13d, r14d add ebp, 2 loc_145E: add r15d, ebp sub r12d, 3 jnz loc_1263 loc_146B: mov ebp, [rsp+68h+var_68] mov ebx, r13d add r15d, 2 loc_1475: add ebp, r15d sub ebx, 3 jnz loc_1244 loc_1481: mov r13d, ebp add r13d, 2 loc_1488: add rsp, 38h mov eax, r13d pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_14A0: mov ebx, ebp add r13d, 3 mov ebp, r11d jmp loc_13D9 loc_14AE: mov ebp, r10d add ebp, 3 jmp loc_13EB loc_14B9: mov ebx, r12d mov r12d, r9d mov r14d, r8d add r12d, 3 jmp loc_1404 loc_14D0: add r14d, 3 jmp loc_13C4 loc_14D9: mov r13d, r14d mov r12d, r15d mov r14d, edx mov eax, ecx add r13d, 3 jmp loc_141F loc_14ED: mov r15d, ebx mov r13d, r12d mov r14d, eax mov r12d, [rsp+68h+var_5C] add r15d, 3 jmp loc_143E loc_1504: mov ebp, r13d mov r15d, [rsp+68h+var_64] mov r12d, [rsp+68h+var_60] mov r13d, r14d add ebp, 3 jmp loc_145E loc_151C: mov ebp, [rsp+68h+var_68] mov ebx, r13d add r15d, 3 jmp loc_1475 loc_152B: mov r13d, ebp add r13d, 3 jmp loc_1488 loc_1537: mov r13d, 3 jmp loc_1488 loc_1542: xor r13d, r13d jmp loc_1488
long long func0(unsigned int a1) { unsigned int v1; // r13d unsigned int v2; // ebx int v3; // ebp unsigned int v4; // r12d int v5; // r15d unsigned int v6; // r13d unsigned int v7; // r14d int v8; // r13d unsigned int v9; // r12d unsigned int v10; // ebp unsigned int v11; // eax int v12; // r12d int v13; // ebx unsigned int v14; // r14d unsigned int v15; // edx unsigned int v16; // ecx unsigned int v17; // esi int v18; // r14d int v19; // r15d int v20; // r8d int v21; // r9d int v22; // r12d unsigned int v23; // ebx int v24; // r10d int v25; // ebp int v26; // r14d int v27; // r11d int v28; // r13d int v29; // ebp int v30; // ebx int v31; // edi int v32; // r14d int v33; // r13d int v34; // ebp int v35; // ebp int v36; // r14d int v37; // r12d int v38; // r13d unsigned int v39; // r14d int v40; // r13d int v41; // r13d unsigned int v42; // r12d int v43; // r15d int v44; // ebp int v45; // r15d unsigned int v46; // r12d int v47; // ebp int v48; // ebp unsigned int v49; // ebx int v50; // r15d int v52; // r13d int v53; // ebp int v54; // [rsp+0h] [rbp-68h] int v55; // [rsp+4h] [rbp-64h] unsigned int v56; // [rsp+8h] [rbp-60h] unsigned int v57; // [rsp+Ch] [rbp-5Ch] int v58; // [rsp+18h] [rbp-50h] int v59; // [rsp+1Ch] [rbp-4Ch] unsigned int v60; // [rsp+20h] [rbp-48h] int v61; // [rsp+24h] [rbp-44h] int v62; // [rsp+28h] [rbp-40h] unsigned int v63; // [rsp+2Ch] [rbp-3Ch] if ( a1 ) { v1 = a1; if ( a1 == 1 ) { return 0; } else if ( a1 != 2 ) { v2 = a1 - 2; v3 = 0; while ( v2 != 1 ) { if ( v2 != 2 ) { v54 = v3; v4 = v2 - 2; v5 = 0; v6 = v2; while ( v4 != 1 ) { if ( v4 != 2 ) { v55 = v5; v7 = v6; v56 = v4; v8 = 0; v9 = v4 - 2; while ( v9 != 1 ) { if ( v9 != 2 ) { v10 = v9 - 2; v57 = v9; v11 = v7; v12 = v8; v13 = 0; v14 = v10; while ( v14 != 1 ) { if ( v14 != 2 ) { v15 = v14; v16 = v11; v17 = v14 - 2; v18 = 0; v19 = v12; while ( v17 != 1 ) { if ( v17 != 2 ) { v20 = v18; v21 = 0; v22 = v13; v23 = v17 - 2; while ( v23 != 1 ) { if ( v23 != 2 ) { v24 = 0; v25 = v23 - 2; while ( v25 != 1 ) { if ( v25 != 2 ) { v26 = v25 - 2; v27 = v25; v28 = 0; v29 = v23; v30 = v26; while ( v30 != 1 ) { if ( v30 != 2 ) { v31 = v30 - 2; v32 = 0; while ( 1 ) { v63 = v16; v62 = v27; v61 = v24; v60 = v15; v59 = v21; v58 = v20; v32 += func0(); v20 = v58; v21 = v59; v15 = v60; v24 = v61; v27 = v62; v16 = v63; if ( v31 == 1 ) break; if ( v31 == 2 ) goto LABEL_33; v31 -= 3; if ( !v31 ) { v32 += 2; goto LABEL_33; } } v32 += 3; LABEL_33: v28 += v32; v30 -= 3; if ( v30 ) continue; } v23 = v29; v33 = v28 + 2; v34 = v27; goto LABEL_35; } v23 = v29; v33 = v28 + 3; v34 = v27; LABEL_35: v24 += v33; v25 = v34 - 3; if ( v25 ) continue; } v35 = v24 + 2; goto LABEL_37; } v35 = v24 + 3; LABEL_37: v21 += v35; v23 -= 3; if ( v23 ) continue; } v13 = v22; v36 = v20; v37 = v21 + 2; goto LABEL_39; } v13 = v22; v36 = v20; v37 = v21 + 3; LABEL_39: v18 = v37 + v36; v17 -= 3; if ( v17 ) continue; } v38 = v18; v12 = v19; v39 = v15; v11 = v16; v40 = v38 + 2; goto LABEL_41; } v52 = v18; v12 = v19; v39 = v15; v11 = v16; v40 = v52 + 3; LABEL_41: v13 += v40; v14 = v39 - 3; if ( v14 ) continue; } v41 = v12; v42 = v57; v7 = v11; v43 = v13 + 2; goto LABEL_43; } v41 = v12; v7 = v11; v42 = v57; v43 = v13 + 3; LABEL_43: v8 = v43 + v41; v9 = v42 - 3; if ( v9 ) continue; } v44 = v8; v45 = v55; v46 = v56; v6 = v7; v47 = v44 + 2; goto LABEL_45; } v53 = v8; v45 = v55; v46 = v56; v6 = v7; v47 = v53 + 3; LABEL_45: v5 = v47 + v45; v4 = v46 - 3; if ( v4 ) continue; } v48 = v54; v49 = v6; v50 = v5 + 2; goto LABEL_47; } v48 = v54; v49 = v6; v50 = v5 + 3; LABEL_47: v3 = v50 + v48; v2 = v49 - 3; if ( v2 ) continue; } return (unsigned int)(v3 + 2); } return (unsigned int)(v3 + 3); } } else { return 3; } return v1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x38 TEST EDI,EDI JZ 0x00101537 MOV R13D,EDI CMP EDI,0x1 JZ 0x00101542 CMP EDI,0x2 JZ 0x00101488 LEA EBX,[RDI + -0x2] XOR EBP,EBP LAB_00101244: CMP EBX,0x1 JZ 0x0010152b CMP EBX,0x2 JZ 0x00101481 MOV dword ptr [RSP],EBP LEA R12D,[RBX + -0x2] XOR R15D,R15D MOV R13D,EBX LAB_00101263: CMP R12D,0x1 JZ 0x0010151c CMP R12D,0x2 JZ 0x0010146b MOV dword ptr [RSP + 0x4],R15D LEA EBX,[R12 + -0x2] XOR EBP,EBP MOV R14D,R13D MOV dword ptr [RSP + 0x8],R12D MOV R13D,EBP MOV R12D,EBX LAB_00101291: CMP R12D,0x1 JZ 0x00101504 CMP R12D,0x2 JZ 0x0010144b LEA EBP,[R12 + -0x2] XOR R15D,R15D MOV dword ptr [RSP + 0xc],R12D MOV EAX,R14D MOV R12D,R13D MOV EBX,R15D MOV R14D,EBP LAB_001012be: CMP R14D,0x1 JZ 0x001014ed CMP R14D,0x2 JZ 0x0010142c LEA R15D,[R14 + -0x2] XOR R13D,R13D MOV EDX,R14D MOV ECX,EAX MOV ESI,R15D MOV R14D,R13D MOV R15D,R12D LAB_001012e7: CMP ESI,0x1 JZ 0x001014d9 CMP ESI,0x2 JZ 0x00101410 XOR R12D,R12D LEA R13D,[RSI + -0x2] MOV R8D,R14D MOV R9D,R12D MOV R12D,EBX MOV EBX,R13D LAB_0010130c: CMP EBX,0x1 JZ 0x001014b9 CMP EBX,0x2 JZ 0x001013f7 LEA R14D,[RBX + -0x2] XOR R10D,R10D MOV EBP,R14D LAB_00101328: CMP EBP,0x1 JZ 0x001014ae CMP EBP,0x2 JZ 0x001013e5 LEA R14D,[RBP + -0x2] MOV R11D,EBP XOR R13D,R13D MOV EBP,EBX MOV EBX,R14D LAB_00101349: CMP EBX,0x1 JZ 0x001014a0 CMP EBX,0x2 JZ 0x001013d0 LEA EDI,[RBX + -0x2] XOR R14D,R14D LAB_0010135d: MOV dword ptr [RSP + 0x2c],ECX MOV dword ptr [RSP + 0x28],R11D MOV dword ptr [RSP + 0x24],R10D MOV dword ptr [RSP + 0x20],EDX MOV dword ptr [RSP + 0x1c],R9D MOV dword ptr [RSP + 0x18],R8D MOV dword ptr [RSP + 0x14],ESI MOV dword ptr [RSP + 0x10],EDI CALL 0x00101210 MOV EDI,dword ptr [RSP + 0x10] MOV ESI,dword ptr [RSP + 0x14] ADD R14D,EAX MOV R8D,dword ptr [RSP + 0x18] MOV R9D,dword ptr [RSP + 0x1c] CMP EDI,0x1 MOV EDX,dword ptr [RSP + 0x20] MOV R10D,dword ptr [RSP + 0x24] MOV R11D,dword ptr [RSP + 0x28] MOV ECX,dword ptr [RSP + 0x2c] JZ 0x001014d0 CMP EDI,0x2 JZ 0x001013c4 SUB EDI,0x3 JNZ 0x0010135d ADD R14D,0x2 LAB_001013c4: ADD R13D,R14D SUB EBX,0x3 JNZ 0x00101349 LAB_001013d0: MOV EBX,EBP ADD R13D,0x2 MOV EBP,R11D LAB_001013d9: ADD R10D,R13D SUB EBP,0x3 JNZ 0x00101328 LAB_001013e5: MOV EBP,R10D ADD EBP,0x2 LAB_001013eb: ADD R9D,EBP SUB EBX,0x3 JNZ 0x0010130c LAB_001013f7: MOV EBX,R12D MOV R12D,R9D MOV R14D,R8D ADD R12D,0x2 LAB_00101404: ADD R14D,R12D SUB ESI,0x3 JNZ 0x001012e7 LAB_00101410: MOV R13D,R14D MOV R12D,R15D MOV R14D,EDX MOV EAX,ECX ADD R13D,0x2 LAB_0010141f: ADD EBX,R13D SUB R14D,0x3 JNZ 0x001012be LAB_0010142c: MOV R13D,R12D MOV R15D,EBX MOV R12D,dword ptr [RSP + 0xc] MOV R14D,EAX ADD R15D,0x2 LAB_0010143e: ADD R13D,R15D SUB R12D,0x3 JNZ 0x00101291 LAB_0010144b: MOV EBP,R13D MOV R15D,dword ptr [RSP + 0x4] MOV R12D,dword ptr [RSP + 0x8] MOV R13D,R14D ADD EBP,0x2 LAB_0010145e: ADD R15D,EBP SUB R12D,0x3 JNZ 0x00101263 LAB_0010146b: MOV EBP,dword ptr [RSP] MOV EBX,R13D ADD R15D,0x2 LAB_00101475: ADD EBP,R15D SUB EBX,0x3 JNZ 0x00101244 LAB_00101481: MOV R13D,EBP ADD R13D,0x2 LAB_00101488: ADD RSP,0x38 MOV EAX,R13D POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001014a0: MOV EBX,EBP ADD R13D,0x3 MOV EBP,R11D JMP 0x001013d9 LAB_001014ae: MOV EBP,R10D ADD EBP,0x3 JMP 0x001013eb LAB_001014b9: MOV EBX,R12D MOV R12D,R9D MOV R14D,R8D ADD R12D,0x3 JMP 0x00101404 LAB_001014d0: ADD R14D,0x3 JMP 0x001013c4 LAB_001014d9: MOV R13D,R14D MOV R12D,R15D MOV R14D,EDX MOV EAX,ECX ADD R13D,0x3 JMP 0x0010141f LAB_001014ed: MOV R15D,EBX MOV R13D,R12D MOV R14D,EAX MOV R12D,dword ptr [RSP + 0xc] ADD R15D,0x3 JMP 0x0010143e LAB_00101504: MOV EBP,R13D MOV R15D,dword ptr [RSP + 0x4] MOV R12D,dword ptr [RSP + 0x8] MOV R13D,R14D ADD EBP,0x3 JMP 0x0010145e LAB_0010151c: MOV EBP,dword ptr [RSP] MOV EBX,R13D ADD R15D,0x3 JMP 0x00101475 LAB_0010152b: MOV R13D,EBP ADD R13D,0x3 JMP 0x00101488 LAB_00101537: MOV R13D,0x3 JMP 0x00101488 LAB_00101542: XOR R13D,R13D JMP 0x00101488
int func0(int param_1) { int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; int iVar15; int iVar16; int iVar17; int iVar18; if (param_1 == 0) { param_1 = 3; } else if (param_1 == 1) { param_1 = 0; } else if (param_1 != 2) { iVar3 = param_1 + -2; param_1 = 0; do { if (iVar3 == 1) { return param_1 + 3; } if (iVar3 == 2) break; iVar10 = iVar3 + -2; iVar18 = 0; do { if (iVar10 == 1) { iVar18 = iVar18 + 3; goto LAB_00101475; } if (iVar10 == 2) break; iVar11 = iVar10 + -2; iVar15 = 0; do { if (iVar11 == 1) { iVar15 = iVar15 + 3; goto LAB_0010145e; } if (iVar11 == 2) break; iVar4 = iVar11 + -2; iVar2 = 0; do { if (iVar4 == 1) { iVar2 = iVar2 + 3; goto LAB_0010143e; } if (iVar4 == 2) break; iVar6 = iVar4 + -2; iVar12 = 0; do { if (iVar6 == 1) { iVar12 = iVar12 + 3; goto LAB_0010141f; } if (iVar6 == 2) break; iVar8 = 0; iVar13 = iVar6 + -2; do { if (iVar13 == 1) { iVar8 = iVar8 + 3; goto LAB_00101404; } if (iVar13 == 2) break; iVar5 = iVar13 + -2; iVar9 = 0; do { if (iVar5 == 1) { iVar9 = iVar9 + 3; goto LAB_001013eb; } if (iVar5 == 2) break; iVar16 = iVar5 + -2; iVar14 = 0; do { if (iVar16 == 1) { iVar14 = iVar14 + 3; goto LAB_001013d9; } if (iVar16 == 2) break; iVar7 = iVar16 + -2; iVar17 = 0; do { iVar1 = func0(); iVar17 = iVar17 + iVar1; if (iVar7 == 1) { iVar17 = iVar17 + 3; goto LAB_001013c4; } if (iVar7 == 2) goto LAB_001013c4; iVar7 = iVar7 + -3; } while (iVar7 != 0); iVar17 = iVar17 + 2; LAB_001013c4: iVar14 = iVar14 + iVar17; iVar16 = iVar16 + -3; } while (iVar16 != 0); iVar14 = iVar14 + 2; LAB_001013d9: iVar9 = iVar9 + iVar14; iVar5 = iVar5 + -3; } while (iVar5 != 0); iVar9 = iVar9 + 2; LAB_001013eb: iVar8 = iVar8 + iVar9; iVar13 = iVar13 + -3; } while (iVar13 != 0); iVar8 = iVar8 + 2; LAB_00101404: iVar12 = iVar12 + iVar8; iVar6 = iVar6 + -3; } while (iVar6 != 0); iVar12 = iVar12 + 2; LAB_0010141f: iVar2 = iVar2 + iVar12; iVar4 = iVar4 + -3; } while (iVar4 != 0); iVar2 = iVar2 + 2; LAB_0010143e: iVar15 = iVar15 + iVar2; iVar11 = iVar11 + -3; } while (iVar11 != 0); iVar15 = iVar15 + 2; LAB_0010145e: iVar18 = iVar18 + iVar15; iVar10 = iVar10 + -3; } while (iVar10 != 0); iVar18 = iVar18 + 2; LAB_00101475: param_1 = param_1 + iVar18; iVar3 = iVar3 + -3; } while (iVar3 != 0); param_1 = param_1 + 2; } return param_1; }
5,436
func0
#include <assert.h> #include <string.h>
int func0(const char *s) { int count_left = 0; int count_right = 0; int swap = 0; int imbalance = 0; int i; for (i = 0; i < strlen(s); i++) { if (s[i] == '[') { count_left++; if (imbalance > 0) { swap += imbalance; imbalance--; } } else if (s[i] == ']') { count_right++; imbalance = count_right - count_left; } } return swap; }
int main() { assert(func0("[]][][") == 2); assert(func0("[[][]]") == 0); assert(func0("[[][]]][") == 1); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %rdi,-0x38(%rbp) movl $0x0,-0x24(%rbp) movl $0x0,-0x20(%rbp) movl $0x0,-0x1c(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) jmp 11ee <func0+0x85> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x5b,%al jne 11c9 <func0+0x60> addl $0x1,-0x24(%rbp) cmpl $0x0,-0x18(%rbp) jle 11ea <func0+0x81> mov -0x18(%rbp),%eax add %eax,-0x1c(%rbp) subl $0x1,-0x18(%rbp) jmp 11ea <func0+0x81> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x38(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x5d,%al jne 11ea <func0+0x81> addl $0x1,-0x20(%rbp) mov -0x20(%rbp),%eax sub -0x24(%rbp),%eax mov %eax,-0x18(%rbp) addl $0x1,-0x14(%rbp) mov -0x14(%rbp),%eax movslq %eax,%rbx mov -0x38(%rbp),%rax mov %rax,%rdi callq 1060 <strlen@plt> cmp %rax,%rbx jb 119f <func0+0x36> mov -0x1c(%rbp),%eax add $0x38,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 38h mov [rbp+s], rdi mov [rbp+var_24], 0 mov [rbp+var_20], 0 mov [rbp+var_1C], 0 mov [rbp+var_18], 0 mov [rbp+var_14], 0 jmp short loc_11EE loc_119F: mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 5Bh ; '[' jnz short loc_11C9 add [rbp+var_24], 1 cmp [rbp+var_18], 0 jle short loc_11EA mov eax, [rbp+var_18] add [rbp+var_1C], eax sub [rbp+var_18], 1 jmp short loc_11EA loc_11C9: mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 5Dh ; ']' jnz short loc_11EA add [rbp+var_20], 1 mov eax, [rbp+var_20] sub eax, [rbp+var_24] mov [rbp+var_18], eax loc_11EA: add [rbp+var_14], 1 loc_11EE: mov eax, [rbp+var_14] movsxd rbx, eax mov rax, [rbp+s] mov rdi, rax; s call _strlen cmp rbx, rax jb short loc_119F mov eax, [rbp+var_1C] mov rbx, [rbp+var_8] leave retn
long long func0(const char *a1) { int v2; // [rsp+1Ch] [rbp-24h] int v3; // [rsp+20h] [rbp-20h] unsigned int v4; // [rsp+24h] [rbp-1Ch] int v5; // [rsp+28h] [rbp-18h] int i; // [rsp+2Ch] [rbp-14h] v2 = 0; v3 = 0; v4 = 0; v5 = 0; for ( i = 0; i < strlen(a1); ++i ) { if ( a1[i] == 91 ) { ++v2; if ( v5 > 0 ) v4 += v5--; } else if ( a1[i] == 93 ) { v5 = ++v3 - v2; } } return v4; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x38 MOV qword ptr [RBP + -0x38],RDI MOV dword ptr [RBP + -0x24],0x0 MOV dword ptr [RBP + -0x20],0x0 MOV dword ptr [RBP + -0x1c],0x0 MOV dword ptr [RBP + -0x18],0x0 MOV dword ptr [RBP + -0x14],0x0 JMP 0x001011ee LAB_0010119f: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x5b JNZ 0x001011c9 ADD dword ptr [RBP + -0x24],0x1 CMP dword ptr [RBP + -0x18],0x0 JLE 0x001011ea MOV EAX,dword ptr [RBP + -0x18] ADD dword ptr [RBP + -0x1c],EAX SUB dword ptr [RBP + -0x18],0x1 JMP 0x001011ea LAB_001011c9: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x5d JNZ 0x001011ea ADD dword ptr [RBP + -0x20],0x1 MOV EAX,dword ptr [RBP + -0x20] SUB EAX,dword ptr [RBP + -0x24] MOV dword ptr [RBP + -0x18],EAX LAB_001011ea: ADD dword ptr [RBP + -0x14],0x1 LAB_001011ee: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RBX,EAX MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x00101060 CMP RBX,RAX JC 0x0010119f MOV EAX,dword ptr [RBP + -0x1c] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int func0(char *param_1) { size_t sVar1; int local_2c; int local_28; int local_24; int local_20; int local_1c; local_2c = 0; local_28 = 0; local_24 = 0; local_20 = 0; local_1c = 0; while( true ) { sVar1 = strlen(param_1); if (sVar1 <= (ulong)(long)local_1c) break; if (param_1[local_1c] == '[') { local_2c = local_2c + 1; if (0 < local_20) { local_24 = local_24 + local_20; local_20 = local_20 + -1; } } else if (param_1[local_1c] == ']') { local_28 = local_28 + 1; local_20 = local_28 - local_2c; } local_1c = local_1c + 1; } return local_24; }
5,437
func0
#include <assert.h> #include <string.h>
int func0(const char *s) { int count_left = 0; int count_right = 0; int swap = 0; int imbalance = 0; int i; for (i = 0; i < strlen(s); i++) { if (s[i] == '[') { count_left++; if (imbalance > 0) { swap += imbalance; imbalance--; } } else if (s[i] == ']') { count_right++; imbalance = count_right - count_left; } } return swap; }
int main() { assert(func0("[]][][") == 2); assert(func0("[[][]]") == 0); assert(func0("[[][]]][") == 1); return 0; }
O1
c
func0: endbr64 mov %rdi,%rsi mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al not %rcx mov %rsi,%rdx lea -0x1(%rsi,%rcx,1),%rsi mov $0x0,%ecx mov $0x0,%r9d mov $0x0,%r8d mov $0x0,%edi jmp 1192 <func0+0x49> add $0x1,%edi test %ecx,%ecx jle 118e <func0+0x45> add %ecx,%r9d sub $0x1,%ecx add $0x1,%rdx cmp %rsi,%rdx je 11ad <func0+0x64> movzbl (%rdx),%eax cmp $0x5b,%al je 1181 <func0+0x38> cmp $0x5d,%al jne 118e <func0+0x45> add $0x1,%r8d mov %r8d,%ecx sub %edi,%ecx jmp 118e <func0+0x45> mov %r9d,%eax retq
func0: endbr64 push rbx mov rbx, rdi call _strlen mov rdi, rax mov rax, rbx add rdi, rbx mov ecx, 0 mov r9d, 0 mov r8d, 0 mov esi, 0 jmp short loc_11A8 loc_1197: add esi, 1 test ecx, ecx jle short loc_11A4 add r9d, ecx sub ecx, 1 loc_11A4: add rax, 1 loc_11A8: cmp rax, rdi jz short loc_11C5 movzx edx, byte ptr [rax] cmp dl, 5Bh ; '[' jz short loc_1197 cmp dl, 5Dh ; ']' jnz short loc_11A4 add r8d, 1 mov ecx, r8d sub ecx, esi jmp short loc_11A4 loc_11C5: mov eax, r9d pop rbx retn
long long func0(_BYTE *a1) { long long v2; // rdi _BYTE *v3; // rax _BYTE *v4; // rdi int v5; // ecx unsigned int v6; // r9d int v7; // r8d int v8; // esi v2 = strlen(); v3 = a1; v4 = &a1[v2]; v5 = 0; v6 = 0; v7 = 0; v8 = 0; while ( v3 != v4 ) { if ( *v3 == 91 ) { ++v8; if ( v5 > 0 ) v6 += v5--; } else if ( *v3 == 93 ) { v5 = ++v7 - v8; } ++v3; } return v6; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101060 MOV RDI,RAX MOV RAX,RBX ADD RDI,RBX MOV ECX,0x0 MOV R9D,0x0 MOV R8D,0x0 MOV ESI,0x0 JMP 0x001011a8 LAB_00101197: ADD ESI,0x1 TEST ECX,ECX JLE 0x001011a4 ADD R9D,ECX SUB ECX,0x1 LAB_001011a4: ADD RAX,0x1 LAB_001011a8: CMP RAX,RDI JZ 0x001011c5 MOVZX EDX,byte ptr [RAX] CMP DL,0x5b JZ 0x00101197 CMP DL,0x5d JNZ 0x001011a4 ADD R8D,0x1 MOV ECX,R8D SUB ECX,ESI JMP 0x001011a4 LAB_001011c5: MOV EAX,R9D POP RBX RET
int func0(char *param_1) { size_t sVar1; int iVar2; int iVar3; char *pcVar4; int iVar5; int iVar6; sVar1 = strlen(param_1); pcVar4 = param_1 + sVar1; iVar2 = 0; iVar6 = 0; iVar5 = 0; iVar3 = 0; for (; param_1 != pcVar4; param_1 = param_1 + 1) { if (*param_1 == '[') { iVar3 = iVar3 + 1; if (0 < iVar2) { iVar6 = iVar6 + iVar2; iVar2 = iVar2 + -1; } } else if (*param_1 == ']') { iVar5 = iVar5 + 1; iVar2 = iVar5 - iVar3; } } return iVar6; }
5,438
func0
#include <assert.h> #include <string.h>
int func0(const char *s) { int count_left = 0; int count_right = 0; int swap = 0; int imbalance = 0; int i; for (i = 0; i < strlen(s); i++) { if (s[i] == '[') { count_left++; if (imbalance > 0) { swap += imbalance; imbalance--; } } else if (s[i] == ']') { count_right++; imbalance = count_right - count_left; } } return swap; }
int main() { assert(func0("[]][][") == 2); assert(func0("[[][]]") == 0); assert(func0("[[][]]][") == 1); return 0; }
O2
c
func0: endbr64 push %rbx mov %rdi,%rbx callq 1060 <strlen@plt> mov %rbx,%rdi xor %ecx,%ecx xor %r9d,%r9d add %rbx,%rax xor %r8d,%r8d xor %esi,%esi jmp 1242 <func0+0x32> cmp $0x5d,%dl jne 123e <func0+0x2e> add $0x1,%r8d mov %r8d,%ecx sub %esi,%ecx add $0x1,%rdi cmp %rdi,%rax je 1260 <func0+0x50> movzbl (%rdi),%edx cmp $0x5b,%dl jne 1230 <func0+0x20> add $0x1,%esi test %ecx,%ecx jle 123e <func0+0x2e> add %ecx,%r9d sub $0x1,%ecx jmp 123e <func0+0x2e> xchg %ax,%ax mov %r9d,%eax pop %rbx retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push rbx mov rbx, rdi call _strlen mov rdi, rbx xor ecx, ecx xor r9d, r9d add rax, rbx xor r8d, r8d xor esi, esi jmp short loc_1242 loc_1230: cmp dl, 5Dh ; ']' jnz short loc_123E add r8d, 1 mov ecx, r8d sub ecx, esi loc_123E: add rdi, 1 loc_1242: cmp rax, rdi jz short loc_1260 movzx edx, byte ptr [rdi] cmp dl, 5Bh ; '[' jnz short loc_1230 add esi, 1 test ecx, ecx jle short loc_123E add r9d, ecx sub ecx, 1 jmp short loc_123E loc_1260: mov eax, r9d pop rbx retn
long long func0(_BYTE *a1) { long long v1; // rax int v2; // ecx unsigned int v3; // r9d _BYTE *v4; // rax int v5; // r8d int v6; // esi v1 = strlen(); v2 = 0; v3 = 0; v4 = &a1[v1]; v5 = 0; v6 = 0; while ( v4 != a1 ) { if ( *a1 == 91 ) { ++v6; if ( v2 > 0 ) v3 += v2--; } else if ( *a1 == 93 ) { v2 = ++v5 - v6; } ++a1; } return v3; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101060 MOV RDI,RBX XOR ECX,ECX XOR R9D,R9D ADD RAX,RBX XOR R8D,R8D XOR ESI,ESI JMP 0x00101242 LAB_00101230: CMP DL,0x5d JNZ 0x0010123e ADD R8D,0x1 MOV ECX,R8D SUB ECX,ESI LAB_0010123e: ADD RDI,0x1 LAB_00101242: CMP RAX,RDI JZ 0x00101260 MOVZX EDX,byte ptr [RDI] CMP DL,0x5b JNZ 0x00101230 ADD ESI,0x1 TEST ECX,ECX JLE 0x0010123e ADD R9D,ECX SUB ECX,0x1 JMP 0x0010123e LAB_00101260: MOV EAX,R9D POP RBX RET
int func0(char *param_1) { size_t sVar1; char *pcVar2; int iVar3; int iVar4; int iVar5; int iVar6; sVar1 = strlen(param_1); iVar3 = 0; iVar6 = 0; pcVar2 = param_1 + sVar1; iVar5 = 0; iVar4 = 0; for (; pcVar2 != param_1; param_1 = param_1 + 1) { if (*param_1 == '[') { iVar4 = iVar4 + 1; if (0 < iVar3) { iVar6 = iVar6 + iVar3; iVar3 = iVar3 + -1; } } else if (*param_1 == ']') { iVar5 = iVar5 + 1; iVar3 = iVar5 - iVar4; } } return iVar6; }
5,439
func0
#include <assert.h> #include <string.h>
int func0(const char *s) { int count_left = 0; int count_right = 0; int swap = 0; int imbalance = 0; int i; for (i = 0; i < strlen(s); i++) { if (s[i] == '[') { count_left++; if (imbalance > 0) { swap += imbalance; imbalance--; } } else if (s[i] == ']') { count_right++; imbalance = count_right - count_left; } } return swap; }
int main() { assert(func0("[]][][") == 2); assert(func0("[[][]]") == 0); assert(func0("[[][]]][") == 1); return 0; }
O3
c
func0: endbr64 push %rbx mov %rdi,%rbx callq 1060 <strlen@plt> test %rax,%rax je 1270 <func0+0x60> mov %rbx,%rdi lea (%rbx,%rax,1),%rdx xor %ecx,%ecx xor %r9d,%r9d xor %r8d,%r8d xor %esi,%esi jmp 124e <func0+0x3e> nopl (%rax) cmp $0x5d,%al jne 1245 <func0+0x35> add $0x1,%r8d mov %r8d,%ecx sub %esi,%ecx add $0x1,%rdi cmp %rdi,%rdx je 126b <func0+0x5b> movzbl (%rdi),%eax cmp $0x5b,%al jne 1238 <func0+0x28> add $0x1,%esi test %ecx,%ecx jle 1245 <func0+0x35> add $0x1,%rdi add %ecx,%r9d sub $0x1,%ecx cmp %rdi,%rdx jne 124e <func0+0x3e> mov %r9d,%eax pop %rbx retq xor %r9d,%r9d pop %rbx mov %r9d,%eax retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbx mov rbx, rdi call _strlen test rax, rax jz short loc_1278 mov rdi, rbx add rax, rbx xor ecx, ecx xor r9d, r9d xor r8d, r8d xor esi, esi jmp short loc_124F loc_1238: cmp dl, 5Dh ; ']' jnz short loc_1246 add r8d, 1 mov ecx, r8d sub ecx, esi loc_1246: add rdi, 1 cmp rax, rdi jz short loc_126D loc_124F: movzx edx, byte ptr [rdi] cmp dl, 5Bh ; '[' jnz short loc_1238 add esi, 1 test ecx, ecx jle short loc_1246 add rdi, 1 add r9d, ecx sub ecx, 1 cmp rax, rdi jnz short loc_124F loc_126D: mov eax, r9d pop rbx retn loc_1278: xor r9d, r9d pop rbx mov eax, r9d retn
long long func0(const char *a1) { size_t v1; // rax const char *v2; // rax int v3; // ecx unsigned int v4; // r9d int v5; // r8d int v6; // esi v1 = strlen(a1); if ( v1 ) { v2 = &a1[v1]; v3 = 0; v4 = 0; v5 = 0; v6 = 0; while ( *a1 == 91 ) { ++v6; if ( v3 <= 0 ) { LABEL_5: if ( v2 == ++a1 ) return v4; } else { ++a1; v4 += v3--; if ( v2 == a1 ) return v4; } } if ( *a1 == 93 ) v3 = ++v5 - v6; goto LABEL_5; } return 0LL; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101060 TEST RAX,RAX JZ 0x00101278 MOV RDI,RBX ADD RAX,RBX XOR ECX,ECX XOR R9D,R9D XOR R8D,R8D XOR ESI,ESI JMP 0x0010124f LAB_00101238: CMP DL,0x5d JNZ 0x00101246 ADD R8D,0x1 MOV ECX,R8D SUB ECX,ESI LAB_00101246: ADD RDI,0x1 CMP RAX,RDI JZ 0x0010126d LAB_0010124f: MOVZX EDX,byte ptr [RDI] CMP DL,0x5b JNZ 0x00101238 ADD ESI,0x1 TEST ECX,ECX JLE 0x00101246 ADD RDI,0x1 ADD R9D,ECX SUB ECX,0x1 CMP RAX,RDI JNZ 0x0010124f LAB_0010126d: MOV EAX,R9D POP RBX RET LAB_00101278: XOR R9D,R9D POP RBX MOV EAX,R9D RET
int func0(char *param_1) { size_t sVar1; char *pcVar2; int iVar3; int iVar4; int iVar5; int iVar6; sVar1 = strlen(param_1); if (sVar1 != 0) { pcVar2 = param_1 + sVar1; iVar3 = 0; iVar6 = 0; iVar5 = 0; iVar4 = 0; do { if (*param_1 == '[') { iVar4 = iVar4 + 1; if (0 < iVar3) { iVar6 = iVar6 + iVar3; iVar3 = iVar3 + -1; } } else if (*param_1 == ']') { iVar5 = iVar5 + 1; iVar3 = iVar5 - iVar4; } param_1 = param_1 + 1; } while (pcVar2 != param_1); return iVar6; } return 0; }
5,440
func0
#include <assert.h> #include <string.h>
char* func0(const char* N) { int l = strlen(N); if (N[l-1]=='0' || N[l-1]=='2' || N[l-1]=='4' || N[l-1]=='6' || N[l-1]=='8' || N[l-1]=='A' || N[l-1]=='C' || N[l-1]=='E') { return "Even"; } else { return "Odd"; } }
int main() { assert(strcmp(func0("AB3454D"), "Odd") == 0); assert(strcmp(func0("ABC"), "Even") == 0); assert(strcmp(func0("AAD"), "Odd") == 0); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %rdi,-0x18(%rbp) mov -0x18(%rbp),%rax mov %rax,%rdi callq 1070 <strlen@plt> mov %eax,-0x4(%rbp) mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x30,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x32,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x34,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x36,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x38,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x41,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x43,%al je 1268 <func0+0xdf> mov -0x4(%rbp),%eax cltq lea -0x1(%rax),%rdx mov -0x18(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp $0x45,%al jne 1271 <func0+0xe8> lea 0xd99(%rip),%rax jmp 1278 <func0+0xef> lea 0xd95(%rip),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+s], rdi mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_4], eax mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 30h ; '0' jz loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 32h ; '2' jz loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 34h ; '4' jz short loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 36h ; '6' jz short loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 38h ; '8' jz short loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 41h ; 'A' jz short loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 43h ; 'C' jz short loc_1268 mov eax, [rbp+var_4] cdqe lea rdx, [rax-1] mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] cmp al, 45h ; 'E' jnz short loc_1271 loc_1268: lea rax, aEven; "Even" jmp short locret_1278 loc_1271: lea rax, s2; "Odd" locret_1278: leave retn
const char * func0(const char *a1) { int v2; // [rsp+1Ch] [rbp-4h] v2 = strlen(a1); if ( a1[v2 - 1] == 48 || a1[v2 - 1] == 50 || a1[v2 - 1] == 52 || a1[v2 - 1] == 54 || a1[v2 - 1] == 56 || a1[v2 - 1] == 65 || a1[v2 - 1] == 67 || a1[v2 - 1] == 69 ) { return "Even"; } else { return "Odd"; } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV qword ptr [RBP + -0x18],RDI MOV RAX,qword ptr [RBP + -0x18] MOV RDI,RAX CALL 0x00101070 MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x30 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x32 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x34 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x36 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x38 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x41 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x43 JZ 0x00101268 MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] CMP AL,0x45 JNZ 0x00101271 LAB_00101268: LEA RAX,[0x102008] JMP 0x00101278 LAB_00101271: LEA RAX,[0x10200d] LAB_00101278: LEAVE RET
int * func0(char *param_1) { int iVar1; size_t sVar2; int *puVar3; sVar2 = strlen(param_1); iVar1 = (int)sVar2; if (((((param_1[(long)iVar1 + -1] == '0') || (param_1[(long)iVar1 + -1] == '2')) || (param_1[(long)iVar1 + -1] == '4')) || ((param_1[(long)iVar1 + -1] == '6' || (param_1[(long)iVar1 + -1] == '8')))) || ((param_1[(long)iVar1 + -1] == 'A' || ((param_1[(long)iVar1 + -1] == 'C' || (param_1[(long)iVar1 + -1] == 'E')))))) { puVar3 = &DAT_00102008; } else { puVar3 = &DAT_0010200d; } return puVar3; }
5,441
func0
#include <assert.h> #include <string.h>
char* func0(const char* N) { int l = strlen(N); if (N[l-1]=='0' || N[l-1]=='2' || N[l-1]=='4' || N[l-1]=='6' || N[l-1]=='8' || N[l-1]=='A' || N[l-1]=='C' || N[l-1]=='E') { return "Even"; } else { return "Odd"; } }
int main() { assert(strcmp(func0("AB3454D"), "Odd") == 0); assert(strcmp(func0("ABC"), "Even") == 0); assert(strcmp(func0("AAD"), "Odd") == 0); return 0; }
O1
c
func0: endbr64 mov %rdi,%rdx mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax sub $0x1,%rax cltq movzbl -0x1(%rdx,%rax,1),%ecx sub $0x30,%ecx lea 0xe8b(%rip),%rax cmp $0x15,%cl ja 119a <func0+0x51> mov $0x2a0155,%eax shr %cl,%rax test $0x1,%al lea 0xe79(%rip),%rax lea 0xe6e(%rip),%rdx cmove %rdx,%rax retq
func0: endbr64 push rbx mov rbx, rdi call _strlen cdqe movzx ecx, byte ptr [rbx+rax-1] mov edx, ecx and edx, 0FFFFFFFDh lea rax, aEven; "Even" cmp dl, 30h ; '0' jz short loc_11D9 sub ecx, 34h ; '4' lea rax, aOdd; "Odd" cmp cl, 11h ja short loc_11D9 mov eax, 2A015h shr rax, cl test al, 1 lea rax, aOdd; "Odd" lea rdx, aEven; "Even" cmovnz rax, rdx loc_11D9: pop rbx retn
const char * func0(long long a1) { char v1; // cl const char *result; // rax unsigned __int8 v3; // cl v1 = *(_BYTE *)(a1 + (int)strlen() - 1); result = "Even"; if ( (v1 & 0xFD) != 0x30 ) { v3 = v1 - 52; result = "Odd"; if ( v3 <= 0x11u ) { result = "Odd"; if ( ((0x2A015uLL >> v3) & 1) != 0 ) return "Even"; } } return result; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101070 CDQE MOVZX ECX,byte ptr [RBX + RAX*0x1 + -0x1] MOV EDX,ECX AND EDX,0xfffffffd LEA RAX,[0x102004] CMP DL,0x30 JZ 0x001011d9 SUB ECX,0x34 LEA RAX,[0x102009] CMP CL,0x11 JA 0x001011d9 MOV EAX,0x2a015 SHR RAX,CL TEST AL,0x1 LEA RAX,[0x102009] LEA RDX,[0x102004] CMOVNZ RAX,RDX LAB_001011d9: POP RBX RET
int * func0(char *param_1) { size_t sVar1; int *puVar2; byte bVar3; sVar1 = strlen(param_1); puVar2 = &DAT_00102004; if ((param_1[(long)(int)sVar1 + -1] & 0xfdU) != 0x30) { bVar3 = param_1[(long)(int)sVar1 + -1] - 0x34; puVar2 = &DAT_00102009; if ((bVar3 < 0x12) && (puVar2 = &DAT_00102009, (0x2a015UL >> (bVar3 & 0x3f) & 1) != 0)) { puVar2 = &DAT_00102004; } } return puVar2; }
5,442
func0
#include <assert.h> #include <string.h>
char* func0(const char* N) { int l = strlen(N); if (N[l-1]=='0' || N[l-1]=='2' || N[l-1]=='4' || N[l-1]=='6' || N[l-1]=='8' || N[l-1]=='A' || N[l-1]=='C' || N[l-1]=='E') { return "Even"; } else { return "Odd"; } }
int main() { assert(strcmp(func0("AB3454D"), "Odd") == 0); assert(strcmp(func0("ABC"), "Even") == 0); assert(strcmp(func0("AAD"), "Odd") == 0); return 0; }
O2
c
func0: endbr64 push %rbx mov %rdi,%rbx callq 1060 <strlen@plt> cltq movzbl -0x1(%rbx,%rax,1),%ecx lea 0xd99(%rip),%rax sub $0x30,%ecx cmp $0x15,%cl ja 1289 <func0+0x39> mov $0x2a0155,%edx shr %cl,%rdx and $0x1,%edx lea 0xd83(%rip),%rdx cmovne %rdx,%rax pop %rbx retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbx mov rbx, rdi call _strlen cdqe movzx ecx, byte ptr [rbx+rax-1] lea rax, aEven; "Even" mov edx, ecx and edx, 0FFFFFFFDh cmp dl, 30h ; '0' jz short loc_12AA sub ecx, 34h ; '4' lea rax, aOdd; "Odd" cmp cl, 11h ja short loc_12AA mov edx, 2A015h shr rdx, cl and edx, 1 lea rdx, aEven; "Even" cmovnz rax, rdx loc_12AA: pop rbx retn
const char * func0(long long a1) { char v1; // cl const char *result; // rax unsigned __int8 v3; // cl v1 = *(_BYTE *)(a1 + (int)strlen() - 1); result = "Even"; if ( (v1 & 0xFD) != 0x30 ) { v3 = v1 - 52; result = "Odd"; if ( v3 <= 0x11u && ((0x2A015uLL >> v3) & 1) != 0 ) return "Even"; } return result; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101070 CDQE MOVZX ECX,byte ptr [RBX + RAX*0x1 + -0x1] LEA RAX,[0x102004] MOV EDX,ECX AND EDX,0xfffffffd CMP DL,0x30 JZ 0x001012aa SUB ECX,0x34 LEA RAX,[0x102009] CMP CL,0x11 JA 0x001012aa MOV EDX,0x2a015 SHR RDX,CL AND EDX,0x1 LEA RDX,[0x102004] CMOVNZ RAX,RDX LAB_001012aa: POP RBX RET
int * func0(char *param_1) { size_t sVar1; int *puVar2; byte bVar3; sVar1 = strlen(param_1); puVar2 = &DAT_00102004; if ((param_1[(long)(int)sVar1 + -1] & 0xfdU) != 0x30) { bVar3 = param_1[(long)(int)sVar1 + -1] - 0x34; puVar2 = &DAT_00102009; if ((bVar3 < 0x12) && ((0x2a015UL >> (bVar3 & 0x3f) & 1) != 0)) { puVar2 = &DAT_00102004; } } return puVar2; }
5,443
func0
#include <assert.h> #include <string.h>
char* func0(const char* N) { int l = strlen(N); if (N[l-1]=='0' || N[l-1]=='2' || N[l-1]=='4' || N[l-1]=='6' || N[l-1]=='8' || N[l-1]=='A' || N[l-1]=='C' || N[l-1]=='E') { return "Even"; } else { return "Odd"; } }
int main() { assert(strcmp(func0("AB3454D"), "Odd") == 0); assert(strcmp(func0("ABC"), "Even") == 0); assert(strcmp(func0("AAD"), "Odd") == 0); return 0; }
O3
c
func0: endbr64 push %rbx mov %rdi,%rbx callq 1060 <strlen@plt> cltq movzbl -0x1(%rbx,%rax,1),%ecx lea 0xd99(%rip),%rax sub $0x30,%ecx cmp $0x15,%cl ja 1289 <func0+0x39> mov $0x2a0155,%edx shr %cl,%rdx and $0x1,%edx lea 0xd83(%rip),%rdx cmovne %rdx,%rax pop %rbx retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbx mov rbx, rdi call _strlen lea rdx, s2; "Odd" cdqe movzx eax, byte ptr [rbx+rax-1] sub eax, 30h ; '0' cmp al, 15h ja short loc_1296 mov ecx, 2A0155h bt rcx, rax lea rax, aEven; "Even" cmovb rdx, rax loc_1296: mov rax, rdx pop rbx retn
const char * func0(const char *a1) { int v1; // eax const char *v2; // rdx unsigned long long v3; // rax long long v4; // rcx v1 = strlen(a1); v2 = "Odd"; v3 = (unsigned int)(unsigned __int8)a1[v1 - 1] - 48; if ( (unsigned __int8)v3 <= 0x15u ) { v4 = 2752853LL; if ( _bittest64(&v4, v3) ) return "Even"; } return v2; }
func0: ENDBR64 PUSH RBX MOV RBX,RDI CALL 0x00101070 LEA RDX,[0x102009] CDQE MOVZX EAX,byte ptr [RBX + RAX*0x1 + -0x1] SUB EAX,0x30 CMP AL,0x15 JA 0x00101296 MOV ECX,0x2a0155 BT RCX,RAX LEA RAX,[0x102004] CMOVC RDX,RAX LAB_00101296: MOV RAX,RDX POP RBX RET
int * func0(char *param_1) { size_t sVar1; int *puVar2; sVar1 = strlen(param_1); puVar2 = &DAT_00102009; if (((byte)((byte)param_1[(long)(int)sVar1 + -1] - 0x30) < 0x16) && ((0x2a0155UL >> ((ulong)((byte)param_1[(long)(int)sVar1 + -1] - 0x30) & 0x3f) & 1) != 0)) { puVar2 = &DAT_00102004; } return puVar2; }
5,444
func0
#include <assert.h>
int func0(int n) { int res = 0; for (int i = n; i > 0; --i) { if ((i & (i - 1)) == 0) { res = i; break; } } return res; }
int main() { assert(func0(10) == 8); assert(func0(19) == 16); assert(func0(32) == 32); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) movl $0x0,-0x8(%rbp) mov -0x14(%rbp),%eax mov %eax,-0x4(%rbp) jmp 117c <func0+0x33> mov -0x4(%rbp),%eax sub $0x1,%eax and -0x4(%rbp),%eax test %eax,%eax jne 1178 <func0+0x2f> mov -0x4(%rbp),%eax mov %eax,-0x8(%rbp) jmp 1182 <func0+0x39> subl $0x1,-0x4(%rbp) cmpl $0x0,-0x4(%rbp) jg 1163 <func0+0x1a> mov -0x8(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov [rbp+var_8], 0 mov eax, [rbp+var_14] mov [rbp+var_4], eax jmp short loc_117C loc_1163: mov eax, [rbp+var_4] sub eax, 1 and eax, [rbp+var_4] test eax, eax jnz short loc_1178 mov eax, [rbp+var_4] mov [rbp+var_8], eax jmp short loc_1182 loc_1178: sub [rbp+var_4], 1 loc_117C: cmp [rbp+var_4], 0 jg short loc_1163 loc_1182: mov eax, [rbp+var_8] pop rbp retn
long long func0(int a1) { unsigned int v2; // [rsp+Ch] [rbp-8h] v2 = 0; while ( a1 > 0 ) { if ( (a1 & (a1 - 1)) == 0 ) return (unsigned int)a1; --a1; } return v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x8],0x0 MOV EAX,dword ptr [RBP + -0x14] MOV dword ptr [RBP + -0x4],EAX JMP 0x0010117c LAB_00101163: MOV EAX,dword ptr [RBP + -0x4] SUB EAX,0x1 AND EAX,dword ptr [RBP + -0x4] TEST EAX,EAX JNZ 0x00101178 MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RBP + -0x8],EAX JMP 0x00101182 LAB_00101178: SUB dword ptr [RBP + -0x4],0x1 LAB_0010117c: CMP dword ptr [RBP + -0x4],0x0 JG 0x00101163 LAB_00101182: MOV EAX,dword ptr [RBP + -0x8] POP RBP RET
uint func0(uint param_1) { uint local_c; local_c = param_1; while( true ) { if ((int)local_c < 1) { return 0; } if ((local_c - 1 & local_c) == 0) break; local_c = local_c - 1; } return local_c; }
5,445
func0
#include <assert.h>
int func0(int n) { int res = 0; for (int i = n; i > 0; --i) { if ((i & (i - 1)) == 0) { res = i; break; } } return res; }
int main() { assert(func0(10) == 8); assert(func0(19) == 16); assert(func0(32) == 32); return 0; }
O1
c
func0: endbr64 test %edi,%edi jle 115c <func0+0x13> lea -0x1(%rdi),%eax test %edi,%eax je 1162 <func0+0x19> mov %eax,%edi jmp 114d <func0+0x4> mov $0x0,%eax retq mov %edi,%eax retq
func0: endbr64 loc_114D: test edi, edi jle short loc_115C lea eax, [rdi-1] test eax, edi jz short loc_1162 mov edi, eax jmp short loc_114D loc_115C: mov eax, 0 retn loc_1162: mov eax, edi retn
long long func0(int a1) { while ( 1 ) { if ( a1 <= 0 ) return 0LL; if ( (a1 & (a1 - 1)) == 0 ) break; --a1; } return (unsigned int)a1; }
func0: ENDBR64 LAB_0010114d: TEST EDI,EDI JLE 0x0010115c LEA EAX,[RDI + -0x1] TEST EAX,EDI JZ 0x00101162 MOV EDI,EAX JMP 0x0010114d LAB_0010115c: MOV EAX,0x0 RET LAB_00101162: MOV EAX,EDI RET
uint func0(uint param_1) { uint uVar1; do { uVar1 = param_1; if ((int)uVar1 < 1) { return 0; } param_1 = uVar1 - 1; } while ((uVar1 - 1 & uVar1) != 0); return uVar1; }
5,446
func0
#include <assert.h>
int func0(int n) { int res = 0; for (int i = n; i > 0; --i) { if ((i & (i - 1)) == 0) { res = i; break; } } return res; }
int main() { assert(func0(10) == 8); assert(func0(19) == 16); assert(func0(32) == 32); return 0; }
O2
c
func0: endbr64 jmp 11e9 <func0+0x19> nopw %cs:0x0(%rax,%rax,1) lea -0x1(%rdi),%eax test %edi,%eax je 11f0 <func0+0x20> mov %eax,%edi test %edi,%edi jg 11e0 <func0+0x10> xor %eax,%eax retq mov %edi,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 jmp short loc_11E9 loc_11E0: lea eax, [rdi-1] test eax, edi jz short loc_11F0 mov edi, eax loc_11E9: test edi, edi jg short loc_11E0 xor eax, eax retn loc_11F0: mov eax, edi retn
long long func0(int a1) { while ( 1 ) { if ( a1 <= 0 ) return 0LL; if ( (a1 & (a1 - 1)) == 0 ) break; --a1; } return (unsigned int)a1; }
func0: ENDBR64 JMP 0x001011e9 LAB_001011e0: LEA EAX,[RDI + -0x1] TEST EAX,EDI JZ 0x001011f0 MOV EDI,EAX
void func0(void) { FUN_001011e9(); return; }
5,447
func0
#include <assert.h>
int func0(int n) { int res = 0; for (int i = n; i > 0; --i) { if ((i & (i - 1)) == 0) { res = i; break; } } return res; }
int main() { assert(func0(10) == 8); assert(func0(19) == 16); assert(func0(32) == 32); return 0; }
O3
c
func0: endbr64 jmp 11b9 <func0+0x19> nopw %cs:0x0(%rax,%rax,1) lea -0x1(%rdi),%eax test %edi,%eax je 11c0 <func0+0x20> mov %eax,%edi test %edi,%edi jg 11b0 <func0+0x10> xor %eax,%eax retq mov %edi,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 test edi, edi jle short loc_11C0 nop dword ptr [rax+rax+00000000h] loc_11B0: mov eax, edi sub edi, 1 test edi, eax jnz short loc_11B0 retn loc_11C0: xor eax, eax retn
long long func0(int a1) { long long result; // rax if ( a1 <= 0 ) return 0LL; do result = (unsigned int)a1--; while ( ((unsigned int)result & a1) != 0 ); return result; }
func0: ENDBR64 TEST EDI,EDI JLE 0x001011c0 NOP dword ptr [RAX + RAX*0x1] LAB_001011b0: MOV EAX,EDI SUB EDI,0x1 TEST EDI,EAX JNZ 0x001011b0 RET LAB_001011c0: XOR EAX,EAX RET
uint func0(uint param_1) { uint uVar1; uint uVar2; if ((int)param_1 < 1) { return 0; } do { uVar2 = param_1; uVar1 = param_1 - 1 & param_1; param_1 = param_1 - 1; } while (uVar1 != 0); return uVar2; }
5,448
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 2; if (n == 1) return 1; return func0(n - 1) + func0(n - 2); }
int main() { assert(func0(9) == 76); assert(func0(4) == 7); assert(func0(3) == 4); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x18,%rsp mov %edi,-0x14(%rbp) cmpl $0x0,-0x14(%rbp) jne 1166 <func0+0x1d> mov $0x2,%eax jmp 1191 <func0+0x48> cmpl $0x1,-0x14(%rbp) jne 1173 <func0+0x2a> mov $0x1,%eax jmp 1191 <func0+0x48> mov -0x14(%rbp),%eax sub $0x1,%eax mov %eax,%edi callq 1149 <func0> mov %eax,%ebx mov -0x14(%rbp),%eax sub $0x2,%eax mov %eax,%edi callq 1149 <func0> add %ebx,%eax add $0x18,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 18h mov [rbp+var_14], edi cmp [rbp+var_14], 0 jnz short loc_1166 mov eax, 2 jmp short loc_1191 loc_1166: cmp [rbp+var_14], 1 jnz short loc_1173 mov eax, 1 jmp short loc_1191 loc_1173: mov eax, [rbp+var_14] sub eax, 1 mov edi, eax call func0 mov ebx, eax mov eax, [rbp+var_14] sub eax, 2 mov edi, eax call func0 add eax, ebx loc_1191: mov rbx, [rbp+var_8] leave retn
long long func0(int a1) { int v2; // ebx if ( !a1 ) return 2LL; if ( a1 == 1 ) return 1LL; v2 = func0((unsigned int)(a1 - 1)); return v2 + (unsigned int)func0((unsigned int)(a1 - 2)); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x18 MOV dword ptr [RBP + -0x14],EDI CMP dword ptr [RBP + -0x14],0x0 JNZ 0x00101166 MOV EAX,0x2 JMP 0x00101191 LAB_00101166: CMP dword ptr [RBP + -0x14],0x1 JNZ 0x00101173 MOV EAX,0x1 JMP 0x00101191 LAB_00101173: MOV EAX,dword ptr [RBP + -0x14] SUB EAX,0x1 MOV EDI,EAX CALL 0x00101149 MOV EBX,EAX MOV EAX,dword ptr [RBP + -0x14] SUB EAX,0x2 MOV EDI,EAX CALL 0x00101149 ADD EAX,EBX LAB_00101191: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int func0(int param_1) { int iVar1; int iVar2; if (param_1 == 0) { iVar2 = 2; } else if (param_1 == 1) { iVar2 = 1; } else { iVar1 = func0(param_1 + -1); iVar2 = func0(param_1 + -2); iVar2 = iVar2 + iVar1; } return iVar2; }
5,449
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 2; if (n == 1) return 1; return func0(n - 1) + func0(n - 2); }
int main() { assert(func0(9) == 76); assert(func0(4) == 7); assert(func0(3) == 4); return 0; }
O1
c
func0: endbr64 mov $0x2,%eax test %edi,%edi je 1180 <func0+0x37> push %rbp push %rbx sub $0x8,%rsp mov %edi,%ebx mov %edi,%eax cmp $0x1,%edi je 1179 <func0+0x30> lea -0x1(%rdi),%edi callq 1149 <func0> mov %eax,%ebp lea -0x2(%rbx),%edi callq 1149 <func0> add %ebp,%eax add $0x8,%rsp pop %rbx pop %rbp retq retq
func0: endbr64 mov eax, 2 test edi, edi jz short locret_1180 push rbp push rbx sub rsp, 8 mov ebx, edi mov eax, edi cmp edi, 1 jz short loc_1179 lea edi, [rdi-1] call func0 mov ebp, eax lea edi, [rbx-2] call func0 add eax, ebp loc_1179: add rsp, 8 pop rbx pop rbp retn locret_1180: retn
long long func0(unsigned int a1) { long long result; // rax int v2; // ebp result = 2LL; if ( a1 ) { result = a1; if ( a1 != 1 ) { v2 = func0(a1 - 1); return v2 + (unsigned int)func0(a1 - 2); } } return result; }
func0: ENDBR64 MOV EAX,0x2 TEST EDI,EDI JZ 0x00101180 PUSH RBP PUSH RBX SUB RSP,0x8 MOV EBX,EDI MOV EAX,EDI CMP EDI,0x1 JZ 0x00101179 LEA EDI,[RDI + -0x1] CALL 0x00101149 MOV EBP,EAX LEA EDI,[RBX + -0x2] CALL 0x00101149 ADD EAX,EBP LAB_00101179: ADD RSP,0x8 POP RBX POP RBP RET LAB_00101180: RET
int func0(int param_1) { int iVar1; if (param_1 != 0) { if (param_1 != 1) { iVar1 = func0(param_1 + -1); param_1 = func0(param_1 + -2); param_1 = param_1 + iVar1; } return param_1; } return 2; }
5,450
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 2; if (n == 1) return 1; return func0(n - 1) + func0(n - 2); }
int main() { assert(func0(9) == 76); assert(func0(4) == 7); assert(func0(3) == 4); return 0; }
O2
c
func0: endbr64 test %edi,%edi je 1238 <func0+0x48> push %rbp push %rbx mov %edi,%ebx sub $0x8,%rsp cmp $0x1,%edi je 1240 <func0+0x50> xor %ebp,%ebp lea -0x1(%rbx),%edi callq 11f0 <func0> add %eax,%ebp sub $0x2,%ebx je 1228 <func0+0x38> cmp $0x1,%ebx jne 1207 <func0+0x17> lea 0x1(%rbp),%eax add $0x8,%rsp pop %rbx pop %rbp retq nopl (%rax) add $0x8,%rsp lea 0x2(%rbp),%eax pop %rbx pop %rbp retq nopw 0x0(%rax,%rax,1) mov $0x2,%eax retq xchg %ax,%ax mov $0x1,%eax jmp 121e <func0+0x2e> nopw 0x0(%rax,%rax,1)
func0: endbr64 test edi, edi jz loc_1691 mov eax, edi cmp edi, 1 jz locret_1697 push r15 sub eax, 2 xor r8d, r8d push r14 push r13 push r12 push rbp push rbx sub rsp, 38h mov [rsp+68h+var_60], eax mov edi, [rsp+68h+var_60] mov [rsp+68h+var_68], r8d mov eax, edi add eax, 1 jz loc_1626 loc_1232: cmp eax, 1 jz loc_167A lea eax, [rdi-1] xor ecx, ecx mov [rsp+68h+var_5C], eax mov edi, [rsp+68h+var_5C] mov [rsp+68h+var_64], ecx mov eax, edi add eax, 1 jz loc_1515 loc_1257: cmp eax, 1 jz loc_1655 lea eax, [rdi-1] xor edx, edx mov [rsp+68h+var_58], eax mov edi, [rsp+68h+var_58] mov eax, edi add eax, 1 jz loc_15E8 loc_1278: cmp eax, 1 jz loc_1630 lea esi, [rdi-1] xor ecx, ecx mov [rsp+68h+var_54], edx mov eax, esi mov r13d, ecx add eax, 1 jz loc_1423 loc_1298: cmp eax, 1 jz loc_15AA mov [rsp+68h+var_4C], esi lea r9d, [rsi-1] xor r8d, r8d mov [rsp+68h+var_50], r13d mov r14d, r9d mov r13d, r8d loc_12B7: mov eax, r14d add eax, 1 jz loc_1580 cmp eax, 1 jz loc_1565 lea ebp, [r14-1] xor esi, esi mov ecx, r13d mov r8d, r14d loc_12D8: mov eax, ebp add eax, 1 jz loc_152D cmp eax, 1 jz loc_1538 lea ebx, [rbp-1] xor r12d, r12d mov r9d, ebp loc_12F5: mov eax, ebx add eax, 1 jz loc_1429 cmp eax, 1 jz loc_151C mov eax, ebx lea r15d, [rbx-1] xor r14d, r14d mov ebx, ecx mov ecx, r12d mov r12d, esi mov esi, eax loc_131C: mov ebp, r15d add ebp, 1 jz loc_1438 cmp ebp, 1 jz loc_1590 mov [rsp+68h+var_48], r15d xor r13d, r13d mov r15d, r14d mov r14d, ecx loc_133F: lea edi, [rbp-1] mov [rsp+68h+var_3C], esi mov [rsp+68h+var_40], r9d mov [rsp+68h+var_44], r8d call func0 mov r8d, [rsp+68h+var_44] mov r9d, [rsp+68h+var_40] add r13d, eax sub ebp, 2 mov esi, [rsp+68h+var_3C] jz loc_1550 cmp ebp, 1 jnz short loc_133F mov ecx, r14d mov r14d, r15d mov r15d, [rsp+68h+var_48] loc_137F: add r13d, ebp mov edx, r15d add r14d, r13d test r15d, r15d jz loc_1445 cmp r15d, 1 jnz loc_143C mov eax, esi mov esi, r12d mov r12d, ecx mov ecx, ebx mov ebx, eax loc_13A7: add edx, r14d mov eax, ebx add r12d, edx test ebx, ebx jz loc_1466 loc_13B7: cmp ebx, 1 jnz short loc_142D mov ebp, r9d loc_13BF: add eax, r12d mov edx, ebp add esi, eax test ebp, ebp jnz loc_147D loc_13CE: mov r13d, ecx mov r14d, r8d mov edx, 2 loc_13D9: add edx, esi mov r10d, r14d add r13d, edx test r14d, r14d jnz loc_149D loc_13EA: mov r8d, r13d mov esi, [rsp+68h+var_4C] mov r13d, [rsp+68h+var_50] mov r10d, 2 loc_13FC: add r10d, r8d mov eax, esi add r13d, r10d test esi, esi jz loc_14C3 loc_140C: cmp esi, 1 jz loc_15ED loc_1415: sub esi, 2 mov eax, esi add eax, 1 jnz loc_1298 loc_1423: add r13d, 2 jmp short loc_1415 loc_1429: add r12d, 2 loc_142D: sub ebx, 2 jmp loc_12F5 loc_1438: add r14d, 2 loc_143C: sub r15d, 2 jmp loc_131C loc_1445: mov eax, esi mov edx, 2 mov esi, r12d mov r12d, ecx add edx, r14d mov ecx, ebx mov ebx, eax mov eax, ebx add r12d, edx test ebx, ebx jnz loc_13B7 loc_1466: mov eax, 2 mov ebp, r9d add eax, r12d mov edx, ebp add esi, eax test ebp, ebp jz loc_13CE loc_147D: cmp ebp, 1 jnz loc_1530 mov r13d, ecx mov r14d, r8d add edx, esi mov r10d, r14d add r13d, edx test r14d, r14d jz loc_13EA loc_149D: cmp r14d, 1 jnz loc_1584 mov r8d, r13d mov esi, [rsp+68h+var_4C] mov r13d, [rsp+68h+var_50] add r10d, r8d mov eax, esi add r13d, r10d test esi, esi jnz loc_140C loc_14C3: mov edx, [rsp+68h+var_54] mov ecx, r13d mov eax, 2 mov esi, [rsp+68h+var_58] add eax, ecx add edx, eax test esi, esi jnz loc_15C9 loc_14DF: mov esi, 2 loc_14E4: mov eax, [rsp+68h+var_5C] add esi, edx add [rsp+68h+var_64], esi test eax, eax jz loc_164A loc_14F6: cmp [rsp+68h+var_5C], 1 jz loc_15F6 loc_1501: sub [rsp+68h+var_5C], 2 mov edi, [rsp+68h+var_5C] mov eax, edi add eax, 1 jnz loc_1257 loc_1515: add [rsp+68h+var_64], 2 jmp short loc_1501 loc_151C: mov ebp, r9d add r12d, 1 mov eax, 2 jmp loc_13BF loc_152D: add esi, 2 loc_1530: sub ebp, 2 jmp loc_12D8 loc_1538: mov r13d, ecx mov r14d, r8d add esi, 1 mov edx, 2 jmp loc_13D9 loc_1550: mov ecx, r14d mov ebp, 2 mov r14d, r15d mov r15d, [rsp+68h+var_48] jmp loc_137F loc_1565: mov r8d, r13d mov esi, [rsp+68h+var_4C] mov r13d, [rsp+68h+var_50] mov r10d, 2 add r8d, 1 jmp loc_13FC loc_1580: add r13d, 2 loc_1584: sub r14d, 2 jmp loc_12B7 loc_1590: mov eax, esi add r14d, 1 mov esi, r12d mov edx, 2 mov r12d, ecx mov ecx, ebx mov ebx, eax jmp loc_13A7 loc_15AA: mov ecx, r13d mov edx, [rsp+68h+var_54] mov eax, 2 add ecx, 1 loc_15B9: mov esi, [rsp+68h+var_58] add eax, ecx add edx, eax test esi, esi jz loc_14DF loc_15C9: cmp [rsp+68h+var_58], 1 jz loc_14E4 loc_15D4: sub [rsp+68h+var_58], 2 mov edi, [rsp+68h+var_58] mov eax, edi add eax, 1 jnz loc_1278 loc_15E8: add edx, 2 jmp short loc_15D4 loc_15ED: mov edx, [rsp+68h+var_54] mov ecx, r13d jmp short loc_15B9 loc_15F6: mov ecx, [rsp+68h+var_64] loc_15FA: add eax, ecx add [rsp+68h+var_68], eax mov eax, [rsp+68h+var_60] test eax, eax jz loc_1698 cmp [rsp+68h+var_60], 1 jz short loc_1663 loc_1612: sub [rsp+68h+var_60], 2 mov edi, [rsp+68h+var_60] mov eax, edi add eax, 1 jnz loc_1232 loc_1626: add [rsp+68h+var_68], 2 jmp short loc_1612 loc_1630: mov eax, [rsp+68h+var_5C] add edx, 1 mov esi, 2 add esi, edx add [rsp+68h+var_64], esi test eax, eax jnz loc_14F6 loc_164A: mov ecx, [rsp+68h+var_64] mov eax, 2 jmp short loc_15FA loc_1655: mov ecx, [rsp+68h+var_64] mov eax, 2 add ecx, 1 jmp short loc_15FA loc_1663: mov r8d, [rsp+68h+var_68] lea eax, [r8+1] loc_166B: add rsp, 38h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_167A: mov r8d, [rsp+68h+var_68] add rsp, 38h pop rbx pop rbp lea eax, [r8+3] pop r12 pop r13 pop r14 pop r15 retn loc_1691: mov eax, 2 retn locret_1697: retn loc_1698: mov r8d, [rsp+68h+var_68] lea eax, [r8+2] jmp short loc_166B
long long func0(unsigned int a1) { long long result; // rax unsigned int v2; // edi unsigned int v3; // eax int v4; // edi int v5; // eax int v6; // edx int v7; // edi int v8; // eax int v9; // esi int v10; // r13d int v11; // eax int v12; // r14d int v13; // r13d int v14; // ebp int v15; // esi int v16; // ecx int v17; // r8d int v18; // ebx int v19; // r12d int v20; // r9d int v21; // eax int v22; // r15d int v23; // r14d int v24; // ebx int v25; // ecx int v26; // r12d int v27; // esi int v28; // ebp int v29; // r13d int v30; // r15d int v31; // r14d int v32; // eax int v33; // r14d int v34; // edx int v35; // eax int v36; // r12d int v37; // eax int v38; // eax int v39; // r10d int v40; // esi int v41; // eax int v42; // eax int v43; // edx int v44; // ecx int v45; // ecx int v46; // [rsp+0h] [rbp-68h] int v47; // [rsp+4h] [rbp-64h] unsigned int v48; // [rsp+8h] [rbp-60h] int v49; // [rsp+Ch] [rbp-5Ch] int v50; // [rsp+10h] [rbp-58h] int v51; // [rsp+14h] [rbp-54h] int v52; // [rsp+18h] [rbp-50h] int v53; // [rsp+1Ch] [rbp-4Ch] int v54; // [rsp+20h] [rbp-48h] int v55; // [rsp+24h] [rbp-44h] int v56; // [rsp+28h] [rbp-40h] if ( !a1 ) return 2LL; result = a1; if ( a1 != 1 ) { v48 = a1 - 2; v2 = a1 - 2; v46 = 0; v3 = result - 2 + 1; if ( !v3 ) goto LABEL_69; while ( 1 ) { if ( v3 == 1 ) return (unsigned int)(v46 + 3); v49 = v2 - 1; v4 = v2 - 1; v47 = 0; v5 = v4 + 1; if ( v4 == -1 ) { do { v47 += 2; LABEL_48: v49 -= 2; v4 = v49; v5 = v49 + 1; } while ( v49 == -1 ); } if ( v5 == 1 ) { v41 = 2; v45 = v47 + 1; goto LABEL_66; } v6 = 0; v50 = v4 - 1; v7 = v4 - 1; v8 = v7 + 1; if ( v7 == -1 ) { do { v6 += 2; LABEL_62: v50 -= 2; v7 = v50; v8 = v50 + 1; } while ( v50 == -1 ); } if ( v8 == 1 ) { v41 = v49; v47 += v6 + 3; if ( v49 ) goto LABEL_47; LABEL_71: v45 = v47; v41 = 2; goto LABEL_66; } v9 = v7 - 1; v51 = v6; v10 = 0; v11 = v7; if ( !v7 ) goto LABEL_35; while ( 2 ) { if ( v11 == 1 ) { v43 = v51; v38 = 2; v44 = v10 + 1; goto LABEL_60; } v53 = v9; v52 = v10; v12 = v9 - 1; v13 = 0; while ( 1 ) { if ( v12 == -1 ) { v13 += 2; goto LABEL_57; } if ( !v12 ) { v9 = v53; v38 = v53; v10 = v13 + 3 + v52; if ( v53 ) goto LABEL_33; LABEL_44: v40 = v50; v6 = v10 + 2 + v51; if ( v50 ) goto LABEL_61; LABEL_45: v40 = 2; goto LABEL_46; } v14 = v12 - 1; v15 = 0; v16 = v13; v17 = v12; LABEL_15: if ( v14 == -1 ) { v15 += 2; goto LABEL_52; } if ( v14 ) { v18 = v14 - 1; v19 = 0; v20 = v14; while ( 1 ) { if ( v18 == -1 ) { v19 += 2; goto LABEL_37; } if ( !v18 ) { v14 = v20; ++v19; v37 = 2; goto LABEL_31; } v21 = v18; v22 = v18 - 1; v23 = 0; v24 = v16; v25 = v19; v26 = v15; v27 = v21; while ( 1 ) { v28 = v22 + 1; if ( v22 == -1 ) { v23 += 2; goto LABEL_39; } if ( !v22 ) break; v54 = v22; v29 = 0; v30 = v23; v31 = v25; while ( 1 ) { v56 = v20; v55 = v17; v32 = func0((unsigned int)(v28 - 1)); v17 = v55; v20 = v56; v29 += v32; v28 -= 2; if ( !v28 ) break; if ( v28 == 1 ) { v25 = v31; v33 = v30; v22 = v54; goto LABEL_27; } } v25 = v31; v28 = 2; v33 = v30; v22 = v54; LABEL_27: v34 = v22; v23 = v28 + v29 + v33; if ( v22 == 1 ) { v35 = v27; v15 = v26; v36 = v25; v16 = v24; v18 = v35; goto LABEL_29; } LABEL_39: v22 -= 2; } v42 = v27; ++v23; v15 = v26; v34 = 2; v36 = v25; v16 = v24; v18 = v42; LABEL_29: v37 = v18; v19 = v23 + v34 + v36; if ( v18 == 1 ) { v14 = v20; LABEL_31: v15 += v19 + v37; if ( v14 == 1 ) { v12 = v17; v39 = v17; v13 = v15 + 1 + v16; goto LABEL_42; } LABEL_52: v14 -= 2; goto LABEL_15; } LABEL_37: v18 -= 2; } } v12 = v17; v39 = v17; v13 = v15 + 3 + v16; LABEL_42: if ( v12 == 1 ) break; LABEL_57: v12 -= 2; } v9 = v53; v38 = v53; v10 = v13 + v39 + v52; if ( !v53 ) goto LABEL_44; LABEL_33: if ( v9 != 1 ) { while ( 2 ) { v9 -= 2; v11 = v9 + 1; if ( v9 == -1 ) { LABEL_35: v10 += 2; continue; } break; } continue; } break; } v43 = v51; v44 = v10; LABEL_60: v40 = v50; v6 = v44 + v38 + v43; if ( !v50 ) goto LABEL_45; LABEL_61: if ( v50 != 1 ) goto LABEL_62; LABEL_46: v41 = v49; v47 += v6 + v40; if ( !v49 ) goto LABEL_71; LABEL_47: if ( v49 != 1 ) goto LABEL_48; v45 = v47; LABEL_66: v46 += v45 + v41; if ( !v48 ) return (unsigned int)(v46 + 2); if ( v48 == 1 ) return (unsigned int)(v46 + 1); while ( 1 ) { v48 -= 2; v2 = v48; v3 = v48 + 1; if ( v48 != -1 ) break; LABEL_69: v46 += 2; } } } return result; }
func0: ENDBR64 TEST EDI,EDI JZ 0x00101691 MOV EAX,EDI CMP EDI,0x1 JZ 0x00101697 PUSH R15 SUB EAX,0x2 XOR R8D,R8D PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x38 MOV dword ptr [RSP + 0x8],EAX MOV EDI,dword ptr [RSP + 0x8] MOV dword ptr [RSP],R8D MOV EAX,EDI ADD EAX,0x1 JZ 0x00101626 LAB_00101232: CMP EAX,0x1 JZ 0x0010167a LEA EAX,[RDI + -0x1] XOR ECX,ECX MOV dword ptr [RSP + 0xc],EAX MOV EDI,dword ptr [RSP + 0xc] MOV dword ptr [RSP + 0x4],ECX MOV EAX,EDI ADD EAX,0x1 JZ 0x00101515 LAB_00101257: CMP EAX,0x1 JZ 0x00101655 LEA EAX,[RDI + -0x1] XOR EDX,EDX MOV dword ptr [RSP + 0x10],EAX MOV EDI,dword ptr [RSP + 0x10] MOV EAX,EDI ADD EAX,0x1 JZ 0x001015e8 LAB_00101278: CMP EAX,0x1 JZ 0x00101630 LEA ESI,[RDI + -0x1] XOR ECX,ECX MOV dword ptr [RSP + 0x14],EDX MOV EAX,ESI MOV R13D,ECX ADD EAX,0x1 JZ 0x00101423 LAB_00101298: CMP EAX,0x1 JZ 0x001015aa MOV dword ptr [RSP + 0x1c],ESI LEA R9D,[RSI + -0x1] XOR R8D,R8D MOV dword ptr [RSP + 0x18],R13D MOV R14D,R9D MOV R13D,R8D LAB_001012b7: MOV EAX,R14D ADD EAX,0x1 JZ 0x00101580 CMP EAX,0x1 JZ 0x00101565 LEA EBP,[R14 + -0x1] XOR ESI,ESI MOV ECX,R13D MOV R8D,R14D LAB_001012d8: MOV EAX,EBP ADD EAX,0x1 JZ 0x0010152d CMP EAX,0x1 JZ 0x00101538 LEA EBX,[RBP + -0x1] XOR R12D,R12D MOV R9D,EBP LAB_001012f5: MOV EAX,EBX ADD EAX,0x1 JZ 0x00101429 CMP EAX,0x1 JZ 0x0010151c MOV EAX,EBX LEA R15D,[RBX + -0x1] XOR R14D,R14D MOV EBX,ECX MOV ECX,R12D MOV R12D,ESI MOV ESI,EAX LAB_0010131c: MOV EBP,R15D ADD EBP,0x1 JZ 0x00101438 CMP EBP,0x1 JZ 0x00101590 MOV dword ptr [RSP + 0x20],R15D XOR R13D,R13D MOV R15D,R14D MOV R14D,ECX LAB_0010133f: LEA EDI,[RBP + -0x1] MOV dword ptr [RSP + 0x2c],ESI MOV dword ptr [RSP + 0x28],R9D MOV dword ptr [RSP + 0x24],R8D CALL 0x001011f0 MOV R8D,dword ptr [RSP + 0x24] MOV R9D,dword ptr [RSP + 0x28] ADD R13D,EAX SUB EBP,0x2 MOV ESI,dword ptr [RSP + 0x2c] JZ 0x00101550 CMP EBP,0x1 JNZ 0x0010133f MOV ECX,R14D MOV R14D,R15D MOV R15D,dword ptr [RSP + 0x20] LAB_0010137f: ADD R13D,EBP MOV EDX,R15D ADD R14D,R13D TEST R15D,R15D JZ 0x00101445 CMP R15D,0x1 JNZ 0x0010143c MOV EAX,ESI MOV ESI,R12D MOV R12D,ECX MOV ECX,EBX MOV EBX,EAX LAB_001013a7: ADD EDX,R14D MOV EAX,EBX ADD R12D,EDX TEST EBX,EBX JZ 0x00101466 LAB_001013b7: CMP EBX,0x1 JNZ 0x0010142d MOV EBP,R9D LAB_001013bf: ADD EAX,R12D MOV EDX,EBP ADD ESI,EAX TEST EBP,EBP JNZ 0x0010147d LAB_001013ce: MOV R13D,ECX MOV R14D,R8D MOV EDX,0x2 LAB_001013d9: ADD EDX,ESI MOV R10D,R14D ADD R13D,EDX TEST R14D,R14D JNZ 0x0010149d LAB_001013ea: MOV R8D,R13D MOV ESI,dword ptr [RSP + 0x1c] MOV R13D,dword ptr [RSP + 0x18] MOV R10D,0x2 LAB_001013fc: ADD R10D,R8D MOV EAX,ESI ADD R13D,R10D TEST ESI,ESI JZ 0x001014c3 LAB_0010140c: CMP ESI,0x1 JZ 0x001015ed LAB_00101415: SUB ESI,0x2 MOV EAX,ESI ADD EAX,0x1 JNZ 0x00101298 LAB_00101423: ADD R13D,0x2 JMP 0x00101415 LAB_00101429: ADD R12D,0x2 LAB_0010142d: SUB EBX,0x2 JMP 0x001012f5 LAB_00101438: ADD R14D,0x2 LAB_0010143c: SUB R15D,0x2 JMP 0x0010131c LAB_00101445: MOV EAX,ESI MOV EDX,0x2 MOV ESI,R12D MOV R12D,ECX ADD EDX,R14D MOV ECX,EBX MOV EBX,EAX MOV EAX,EBX ADD R12D,EDX TEST EBX,EBX JNZ 0x001013b7 LAB_00101466: MOV EAX,0x2 MOV EBP,R9D ADD EAX,R12D MOV EDX,EBP ADD ESI,EAX TEST EBP,EBP JZ 0x001013ce LAB_0010147d: CMP EBP,0x1 JNZ 0x00101530 MOV R13D,ECX MOV R14D,R8D ADD EDX,ESI MOV R10D,R14D ADD R13D,EDX TEST R14D,R14D JZ 0x001013ea LAB_0010149d: CMP R14D,0x1 JNZ 0x00101584 MOV R8D,R13D MOV ESI,dword ptr [RSP + 0x1c] MOV R13D,dword ptr [RSP + 0x18] ADD R10D,R8D MOV EAX,ESI ADD R13D,R10D TEST ESI,ESI JNZ 0x0010140c LAB_001014c3: MOV EDX,dword ptr [RSP + 0x14] MOV ECX,R13D MOV EAX,0x2 MOV ESI,dword ptr [RSP + 0x10] ADD EAX,ECX ADD EDX,EAX TEST ESI,ESI JNZ 0x001015c9 LAB_001014df: MOV ESI,0x2 LAB_001014e4: MOV EAX,dword ptr [RSP + 0xc] ADD ESI,EDX ADD dword ptr [RSP + 0x4],ESI TEST EAX,EAX JZ 0x0010164a LAB_001014f6: CMP dword ptr [RSP + 0xc],0x1 JZ 0x001015f6 LAB_00101501: SUB dword ptr [RSP + 0xc],0x2 MOV EDI,dword ptr [RSP + 0xc] MOV EAX,EDI ADD EAX,0x1 JNZ 0x00101257 LAB_00101515: ADD dword ptr [RSP + 0x4],0x2 JMP 0x00101501 LAB_0010151c: MOV EBP,R9D ADD R12D,0x1 MOV EAX,0x2 JMP 0x001013bf LAB_0010152d: ADD ESI,0x2 LAB_00101530: SUB EBP,0x2 JMP 0x001012d8 LAB_00101538: MOV R13D,ECX MOV R14D,R8D ADD ESI,0x1 MOV EDX,0x2 JMP 0x001013d9 LAB_00101550: MOV ECX,R14D MOV EBP,0x2 MOV R14D,R15D MOV R15D,dword ptr [RSP + 0x20] JMP 0x0010137f LAB_00101565: MOV R8D,R13D MOV ESI,dword ptr [RSP + 0x1c] MOV R13D,dword ptr [RSP + 0x18] MOV R10D,0x2 ADD R8D,0x1 JMP 0x001013fc LAB_00101580: ADD R13D,0x2 LAB_00101584: SUB R14D,0x2 JMP 0x001012b7 LAB_00101590: MOV EAX,ESI ADD R14D,0x1 MOV ESI,R12D MOV EDX,0x2 MOV R12D,ECX MOV ECX,EBX MOV EBX,EAX JMP 0x001013a7 LAB_001015aa: MOV ECX,R13D MOV EDX,dword ptr [RSP + 0x14] MOV EAX,0x2 ADD ECX,0x1 LAB_001015b9: MOV ESI,dword ptr [RSP + 0x10] ADD EAX,ECX ADD EDX,EAX TEST ESI,ESI JZ 0x001014df LAB_001015c9: CMP dword ptr [RSP + 0x10],0x1 JZ 0x001014e4 LAB_001015d4: SUB dword ptr [RSP + 0x10],0x2 MOV EDI,dword ptr [RSP + 0x10] MOV EAX,EDI ADD EAX,0x1 JNZ 0x00101278 LAB_001015e8: ADD EDX,0x2 JMP 0x001015d4 LAB_001015ed: MOV EDX,dword ptr [RSP + 0x14] MOV ECX,R13D JMP 0x001015b9 LAB_001015f6: MOV ECX,dword ptr [RSP + 0x4] LAB_001015fa: ADD EAX,ECX ADD dword ptr [RSP],EAX MOV EAX,dword ptr [RSP + 0x8] TEST EAX,EAX JZ 0x00101698 CMP dword ptr [RSP + 0x8],0x1 JZ 0x00101663 LAB_00101612: SUB dword ptr [RSP + 0x8],0x2 MOV EDI,dword ptr [RSP + 0x8] MOV EAX,EDI ADD EAX,0x1 JNZ 0x00101232 LAB_00101626: ADD dword ptr [RSP],0x2 JMP 0x00101612 LAB_00101630: MOV EAX,dword ptr [RSP + 0xc] ADD EDX,0x1 MOV ESI,0x2 ADD ESI,EDX ADD dword ptr [RSP + 0x4],ESI TEST EAX,EAX JNZ 0x001014f6 LAB_0010164a: MOV ECX,dword ptr [RSP + 0x4] MOV EAX,0x2 JMP 0x001015fa LAB_00101655: MOV ECX,dword ptr [RSP + 0x4] MOV EAX,0x2 ADD ECX,0x1 JMP 0x001015fa LAB_00101663: MOV R8D,dword ptr [RSP] LEA EAX,[R8 + 0x1] LAB_0010166b: ADD RSP,0x38 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010167a: MOV R8D,dword ptr [RSP] ADD RSP,0x38 POP RBX POP RBP LEA EAX,[R8 + 0x3] POP R12 POP R13 POP R14 POP R15 RET LAB_00101691: MOV EAX,0x2 RET LAB_00101697: RET LAB_00101698: MOV R8D,dword ptr [RSP] LEA EAX,[R8 + 0x2] JMP 0x0010166b
int func0(int param_1) { int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; int local_68; int local_64; int local_60; int local_5c; int local_58; if (param_1 == 0) { return 2; } if (param_1 == 1) { return param_1; } local_68 = 0; iVar1 = param_1 + -1; local_60 = param_1 + -2; if (iVar1 == 0) goto LAB_00101626; do { if (iVar1 == 1) { return local_68 + 3; } local_64 = 0; iVar1 = local_60; local_5c = local_60 + -1; if (local_60 == 0) goto LAB_00101515; while (iVar1 != 1) { iVar1 = 0; iVar9 = local_5c; local_58 = local_5c + -1; if (local_5c == 0) goto LAB_001015e8; while (iVar9 != 1) { iVar9 = local_58 + -1; iVar3 = 0; iVar10 = local_58; if (local_58 == 0) goto LAB_00101423; LAB_00101298: if (iVar10 != 1) { iVar11 = iVar9 + -1; iVar10 = 0; LAB_001012b7: if (iVar11 == -1) { iVar10 = iVar10 + 2; goto LAB_00101584; } if (iVar11 != 0) { iVar8 = iVar11 + -1; iVar5 = 0; LAB_001012d8: if (iVar8 == -1) { iVar5 = iVar5 + 2; goto LAB_00101530; } if (iVar8 != 0) { iVar6 = iVar8 + -1; iVar12 = 0; LAB_001012f5: if (iVar6 == -1) { iVar12 = iVar12 + 2; goto LAB_0010142d; } if (iVar6 != 0) { iVar4 = iVar6 + -1; iVar14 = 0; do { iVar7 = iVar4 + 1; if (iVar7 == 0) { iVar14 = iVar14 + 2; } else { if (iVar7 == 1) { iVar14 = iVar14 + 1; iVar4 = 2; goto LAB_001013a7; } iVar13 = 0; do { iVar2 = func0(iVar7 + -1); iVar13 = iVar13 + iVar2; iVar7 = iVar7 + -2; if (iVar7 == 0) { iVar7 = 2; goto LAB_0010137f; } } while (iVar7 != 1); iVar7 = 1; LAB_0010137f: iVar14 = iVar14 + iVar13 + iVar7; if (iVar4 == 0) { iVar4 = iVar14 + 2; goto joined_r0x00101460; } if (iVar4 == 1) goto code_r0x0010139b; } iVar4 = iVar4 + -2; } while( true ); } iVar12 = iVar12 + 1; iVar6 = 2; goto LAB_001013bf; } iVar5 = iVar5 + 1; goto LAB_001013d9; } iVar10 = iVar10 + 1; goto LAB_001013fc; } iVar9 = 2; iVar3 = iVar3 + 1; LAB_001015b9: iVar9 = iVar9 + iVar3; joined_r0x001014d9: iVar1 = iVar1 + iVar9; if (local_58 == 0) { local_58 = 2; LAB_001014e4: local_58 = local_58 + iVar1; goto joined_r0x00101644; } if (local_58 == 1) goto LAB_001014e4; while( true ) { iVar3 = local_58 + -2; iVar9 = local_58 + -1; local_58 = iVar3; if (iVar9 != 0) break; LAB_001015e8: iVar1 = iVar1 + 2; } } local_58 = iVar1 + 3; joined_r0x00101644: local_64 = local_64 + local_58; if (local_5c == 0) { iVar1 = 2; goto LAB_001015fa; } if (local_5c == 1) { iVar1 = 1; goto LAB_001015fa; } while( true ) { iVar9 = local_5c + -2; iVar1 = local_5c + -1; local_5c = iVar9; if (iVar1 != 0) break; LAB_00101515: local_64 = local_64 + 2; } } iVar1 = 2; local_64 = local_64 + 1; LAB_001015fa: local_68 = local_68 + iVar1 + local_64; if (local_60 == 0) { return local_68 + 2; } if (local_60 == 1) { return local_68 + 1; } while( true ) { iVar9 = local_60 + -2; iVar1 = local_60 + -1; local_60 = iVar9; if (iVar1 != 0) break; LAB_00101626: local_68 = local_68 + 2; } } while( true ); code_r0x0010139b: iVar4 = 1; LAB_001013a7: iVar4 = iVar4 + iVar14; joined_r0x00101460: iVar12 = iVar12 + iVar4; if (iVar6 == 0) { iVar6 = iVar12 + 2; goto joined_r0x00101477; } if (iVar6 == 1) goto code_r0x001013bc; LAB_0010142d: iVar6 = iVar6 + -2; goto LAB_001012f5; code_r0x001013bc: iVar6 = 1; LAB_001013bf: iVar6 = iVar6 + iVar12; joined_r0x00101477: iVar5 = iVar5 + iVar6; if (iVar8 == 0) { LAB_001013d9: iVar5 = iVar5 + 2; goto joined_r0x00101497; } if (iVar8 == 1) goto code_r0x00101486; LAB_00101530: iVar8 = iVar8 + -2; goto LAB_001012d8; code_r0x00101486: iVar5 = iVar5 + 1; joined_r0x00101497: iVar10 = iVar10 + iVar5; if (iVar11 == 0) { LAB_001013fc: iVar10 = iVar10 + 2; goto joined_r0x001014bd; } if (iVar11 == 1) goto code_r0x001014a7; LAB_00101584: iVar11 = iVar11 + -2; goto LAB_001012b7; code_r0x001014a7: iVar10 = iVar10 + 1; joined_r0x001014bd: iVar3 = iVar3 + iVar10; if (iVar9 == 0) { iVar9 = iVar3 + 2; goto joined_r0x001014d9; } iVar10 = iVar9; if (iVar9 == 1) { iVar9 = 1; goto LAB_001015b9; } while( true ) { iVar9 = iVar10 + -2; iVar10 = iVar10 + -1; if (iVar10 != 0) break; LAB_00101423: iVar3 = iVar3 + 2; iVar10 = iVar9; } goto LAB_00101298; }
5,451
func0
#include <assert.h>
int func0(int n) { if (n == 0) return 2; if (n == 1) return 1; return func0(n - 1) + func0(n - 2); }
int main() { assert(func0(9) == 76); assert(func0(4) == 7); assert(func0(3) == 4); return 0; }
O3
c
func0: endbr64 test %edi,%edi je 1238 <func0+0x48> push %rbp push %rbx mov %edi,%ebx sub $0x8,%rsp cmp $0x1,%edi je 1240 <func0+0x50> xor %ebp,%ebp lea -0x1(%rbx),%edi callq 11f0 <func0> add %eax,%ebp sub $0x2,%ebx je 1228 <func0+0x38> cmp $0x1,%ebx jne 1207 <func0+0x17> lea 0x1(%rbp),%eax add $0x8,%rsp pop %rbx pop %rbp retq nopl (%rax) add $0x8,%rsp lea 0x2(%rbp),%eax pop %rbx pop %rbp retq nopw 0x0(%rax,%rax,1) mov $0x2,%eax retq xchg %ax,%ax mov $0x1,%eax jmp 121e <func0+0x2e> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 58h test edi, edi jz loc_1528 mov r15d, edi cmp edi, 1 jz loc_143D lea r13d, [rdi-1] xor r15d, r15d loc_121D: cmp r13d, 1 jz loc_151F lea ebx, [r13-1] mov [rsp+88h+var_6C], r15d xor r12d, r12d mov [rsp+88h+var_68], r13d mov ebp, r12d mov [rsp+88h+var_64], ebx loc_123F: cmp ebx, 1 jz loc_1500 lea edx, [rbx-1] mov [rsp+88h+var_60], ebx xor r13d, r13d mov ecx, ebp mov ebx, edx loc_1256: cmp ebx, 1 jz loc_14EC mov [rsp+88h+var_5C], edx lea edi, [rbx-1] xor r12d, r12d mov [rsp+88h+var_58], r13d mov r15d, edi loc_1271: cmp r15d, 1 jz loc_14D4 lea r9d, [r15-1] xor ebp, ebp mov [rsp+88h+var_54], ecx mov [rsp+88h+var_50], r12d mov r14d, r9d mov [rsp+88h+var_78], ebp mov [rsp+88h+var_4C], edi mov [rsp+88h+var_48], ebx mov [rsp+88h+var_44], r9d mov [rsp+88h+var_40], r15d loc_12A3: cmp r14d, 1 jz loc_1491 lea ebx, [r14-1] xor r15d, r15d mov [rsp+88h+var_3C], ebx mov r13d, ebx loc_12BB: cmp r13d, 1 jz loc_146C lea ebp, [r13-1] mov [rsp+88h+var_84], r14d xor esi, esi mov [rsp+88h+var_80], ebp mov ebx, ebp mov [rsp+88h+var_7C], r13d loc_12DB: cmp ebx, 1 jz loc_144F lea ebp, [rbx-1] mov ecx, ebx xor r13d, r13d mov r14d, ebp mov edx, ebp mov ebp, esi mov ebx, r14d loc_12F6: mov r12d, ebx cmp ebx, 1 jz loc_14C0 mov [rsp+88h+var_74], ebx xor r14d, r14d mov ebx, edx loc_130B: lea edi, [r12-1] mov [rsp+88h+var_70], ecx call func0 mov ecx, [rsp+88h+var_70] add r14d, eax sub r12d, 2 jz loc_1480 cmp r12d, 1 jnz short loc_130B mov edx, ebx mov ebx, [rsp+88h+var_74] loc_1336: lea eax, [r14+r12] add r13d, eax sub ebx, 2 jnz short loc_12F6 mov esi, ebp mov ebx, ecx mov ebp, edx mov edi, 1 loc_134D: add edi, r13d sub ebx, 2 add esi, edi cmp ebp, 1 jnz short loc_12DB mov r14d, [rsp+88h+var_84] mov ebp, [rsp+88h+var_80] mov ebx, esi mov edx, 1 mov r13d, [rsp+88h+var_7C] loc_136F: add edx, ebx sub r13d, 2 add r15d, edx cmp ebp, 1 jnz loc_12BB mov ebx, [rsp+88h+var_3C] mov ebp, r15d mov eax, 1 loc_138D: add eax, ebp sub r14d, 2 add [rsp+88h+var_78], eax cmp ebx, 1 jnz loc_12A3 mov ecx, [rsp+88h+var_54] mov r12d, [rsp+88h+var_50] mov r11d, 1 mov ebp, [rsp+88h+var_78] mov edi, [rsp+88h+var_4C] mov ebx, [rsp+88h+var_48] mov r9d, [rsp+88h+var_44] mov r15d, [rsp+88h+var_40] loc_13C5: add r11d, ebp sub r15d, 2 add r12d, r11d cmp r9d, 1 jnz loc_1271 mov edx, [rsp+88h+var_5C] mov r13d, [rsp+88h+var_58] loc_13E2: add r9d, r12d sub ebx, 2 add r13d, r9d cmp edi, 1 jnz loc_1256 mov ebx, [rsp+88h+var_60] mov ebp, ecx mov esi, 1 loc_13FF: add esi, r13d sub ebx, 2 add ebp, esi cmp edx, 1 jnz loc_123F mov r15d, [rsp+88h+var_6C] mov r13d, [rsp+88h+var_68] mov r12d, ebp mov eax, 1 mov ebx, [rsp+88h+var_64] loc_1426: add eax, r12d sub r13d, 2 add r15d, eax cmp ebx, 1 jnz loc_121D add r15d, 1 loc_143D: add rsp, 58h mov eax, r15d pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_144F: mov ebx, esi mov r14d, [rsp+88h+var_84] mov ebp, [rsp+88h+var_80] mov edx, 2 mov r13d, [rsp+88h+var_7C] add ebx, 1 jmp loc_136F loc_146C: mov ebp, r15d mov ebx, [rsp+88h+var_3C] mov eax, 2 add ebp, 1 jmp loc_138D loc_1480: mov edx, ebx mov r12d, 2 mov ebx, [rsp+88h+var_74] jmp loc_1336 loc_1491: mov ebp, [rsp+88h+var_78] mov ecx, [rsp+88h+var_54] mov r11d, 2 mov r12d, [rsp+88h+var_50] mov edi, [rsp+88h+var_4C] mov ebx, [rsp+88h+var_48] mov r9d, [rsp+88h+var_44] add ebp, 1 mov r15d, [rsp+88h+var_40] jmp loc_13C5 loc_14C0: mov esi, ebp mov ebx, ecx mov ebp, edx add r13d, 1 mov edi, 2 jmp loc_134D loc_14D4: mov edx, [rsp+88h+var_5C] mov r13d, [rsp+88h+var_58] add r12d, 1 mov r9d, 2 jmp loc_13E2 loc_14EC: mov ebx, [rsp+88h+var_60] mov ebp, ecx add r13d, 1 mov esi, 2 jmp loc_13FF loc_1500: mov r12d, ebp mov r15d, [rsp+88h+var_6C] mov r13d, [rsp+88h+var_68] mov eax, 2 mov ebx, [rsp+88h+var_64] add r12d, 1 jmp loc_1426 loc_151F: add r15d, 3 jmp loc_143D loc_1528: mov r15d, 2 jmp loc_143D
long long func0(unsigned int a1) { unsigned int v1; // r15d unsigned int v2; // r13d int v3; // r15d unsigned int v4; // ebx int v5; // ebp unsigned int v6; // edx int v7; // r13d int v8; // ecx unsigned int v9; // ebx unsigned int v10; // edi int v11; // r12d unsigned int v12; // r15d unsigned int v13; // r14d int v14; // r15d int v15; // r13d int v16; // esi int v17; // ebx int v18; // ecx int v19; // r13d int v20; // edx int v21; // ebx int v22; // r12d int v23; // r14d int v24; // ebx int v25; // eax int v26; // ebx int v27; // ebx int v28; // ebp int v29; // edi int v30; // ebp int v31; // ebx int v32; // edx int v33; // r13d int v34; // ebx int v35; // ebp int v36; // eax int v37; // r12d int v38; // r11d int v39; // ebp int v40; // r9d unsigned int v41; // r15d int v42; // r13d unsigned int v43; // ebx int v44; // ebp int v45; // esi int v46; // r15d unsigned int v47; // r13d int v48; // r12d int v49; // eax unsigned int v50; // ebx int v52; // [rsp+4h] [rbp-84h] int v53; // [rsp+8h] [rbp-80h] int v54; // [rsp+Ch] [rbp-7Ch] int v55; // [rsp+10h] [rbp-78h] int v56; // [rsp+14h] [rbp-74h] int v57; // [rsp+18h] [rbp-70h] int v58; // [rsp+1Ch] [rbp-6Ch] unsigned int v59; // [rsp+20h] [rbp-68h] unsigned int v60; // [rsp+24h] [rbp-64h] unsigned int v61; // [rsp+28h] [rbp-60h] unsigned int v62; // [rsp+2Ch] [rbp-5Ch] int v63; // [rsp+30h] [rbp-58h] int v64; // [rsp+34h] [rbp-54h] int v65; // [rsp+38h] [rbp-50h] unsigned int v66; // [rsp+3Ch] [rbp-4Ch] unsigned int v67; // [rsp+40h] [rbp-48h] int v68; // [rsp+44h] [rbp-44h] unsigned int v69; // [rsp+48h] [rbp-40h] int v70; // [rsp+4Ch] [rbp-3Ch] if ( a1 ) { v1 = a1; if ( a1 != 1 ) { v2 = a1 - 1; v3 = 0; while ( v2 != 1 ) { v4 = v2 - 1; v58 = v3; v59 = v2; v5 = 0; v60 = v2 - 1; while ( v4 != 1 ) { v6 = v4 - 1; v61 = v4; v7 = 0; v8 = v5; v9 = v4 - 1; while ( v9 != 1 ) { v62 = v6; v10 = v9 - 1; v11 = 0; v63 = v7; v12 = v9 - 1; while ( v12 != 1 ) { v64 = v8; v65 = v11; v13 = v12 - 1; v55 = 0; v66 = v10; v67 = v9; v68 = v12 - 1; v69 = v12; while ( v13 != 1 ) { v14 = 0; v70 = v13 - 1; v15 = v13 - 1; while ( v15 != 1 ) { v52 = v13; v16 = 0; v53 = v15 - 1; v17 = v15 - 1; v54 = v15; while ( v17 != 1 ) { v18 = v17; v19 = 0; v20 = v17 - 1; v21 = v17 - 1; while ( 1 ) { v22 = v21; if ( v21 == 1 ) break; v56 = v21; v23 = 0; v24 = v20; while ( 1 ) { v57 = v18; v25 = func0((unsigned int)(v22 - 1)); v18 = v57; v23 += v25; v22 -= 2; if ( !v22 ) break; if ( v22 == 1 ) { v20 = v24; v26 = v56; goto LABEL_23; } } v20 = v24; v22 = 2; v26 = v56; LABEL_23: v19 += v23 + v22; v21 = v26 - 2; if ( !v21 ) { v27 = v57; v28 = v20; v29 = 1; goto LABEL_25; } } v27 = v18; v28 = v20; ++v19; v29 = 2; LABEL_25: v17 = v27 - 2; v16 += v19 + v29; if ( v28 == 1 ) { v13 = v52; v30 = v53; v31 = v16; v32 = 1; v33 = v54; goto LABEL_27; } } v13 = v52; v30 = v53; v32 = 2; v33 = v54; v31 = v16 + 1; LABEL_27: v15 = v33 - 2; v14 += v31 + v32; if ( v30 == 1 ) { v34 = v70; v35 = v14; v36 = 1; goto LABEL_29; } } v34 = v70; v36 = 2; v35 = v14 + 1; LABEL_29: v13 -= 2; v55 += v35 + v36; if ( v34 == 1 ) { v8 = v64; v37 = v65; v38 = 1; v39 = v55; v10 = v66; v9 = v67; v40 = v68; v41 = v69; goto LABEL_31; } } v8 = v64; v38 = 2; v37 = v65; v10 = v66; v9 = v67; v40 = v68; v39 = v55 + 1; v41 = v69; LABEL_31: v12 = v41 - 2; v11 = v39 + v38 + v37; if ( v40 == 1 ) { v6 = v62; v42 = v63; goto LABEL_33; } } v6 = v62; v42 = v63; ++v11; v40 = 2; LABEL_33: v9 -= 2; v7 = v11 + v40 + v42; if ( v10 == 1 ) { v43 = v61; v44 = v8; v45 = 1; goto LABEL_35; } } v43 = v61; v44 = v8; ++v7; v45 = 2; LABEL_35: v4 = v43 - 2; v5 = v7 + v45 + v44; if ( v6 == 1 ) { v46 = v58; v47 = v59; v48 = v5; v49 = 1; v50 = v60; goto LABEL_37; } } v46 = v58; v47 = v59; v49 = 2; v50 = v60; v48 = v5 + 1; LABEL_37: v2 = v47 - 2; v3 = v48 + v49 + v46; if ( v50 == 1 ) return (unsigned int)(v3 + 1); } return (unsigned int)(v3 + 3); } } else { return 2; } return v1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x58 TEST EDI,EDI JZ 0x00101528 MOV R15D,EDI CMP EDI,0x1 JZ 0x0010143d LEA R13D,[RDI + -0x1] XOR R15D,R15D LAB_0010121d: CMP R13D,0x1 JZ 0x0010151f LEA EBX,[R13 + -0x1] MOV dword ptr [RSP + 0x1c],R15D XOR R12D,R12D MOV dword ptr [RSP + 0x20],R13D MOV EBP,R12D MOV dword ptr [RSP + 0x24],EBX LAB_0010123f: CMP EBX,0x1 JZ 0x00101500 LEA EDX,[RBX + -0x1] MOV dword ptr [RSP + 0x28],EBX XOR R13D,R13D MOV ECX,EBP MOV EBX,EDX LAB_00101256: CMP EBX,0x1 JZ 0x001014ec MOV dword ptr [RSP + 0x2c],EDX LEA EDI,[RBX + -0x1] XOR R12D,R12D MOV dword ptr [RSP + 0x30],R13D MOV R15D,EDI LAB_00101271: CMP R15D,0x1 JZ 0x001014d4 LEA R9D,[R15 + -0x1] XOR EBP,EBP MOV dword ptr [RSP + 0x34],ECX MOV dword ptr [RSP + 0x38],R12D MOV R14D,R9D MOV dword ptr [RSP + 0x10],EBP MOV dword ptr [RSP + 0x3c],EDI MOV dword ptr [RSP + 0x40],EBX MOV dword ptr [RSP + 0x44],R9D MOV dword ptr [RSP + 0x48],R15D LAB_001012a3: CMP R14D,0x1 JZ 0x00101491 LEA EBX,[R14 + -0x1] XOR R15D,R15D MOV dword ptr [RSP + 0x4c],EBX MOV R13D,EBX LAB_001012bb: CMP R13D,0x1 JZ 0x0010146c LEA EBP,[R13 + -0x1] MOV dword ptr [RSP + 0x4],R14D XOR ESI,ESI MOV dword ptr [RSP + 0x8],EBP MOV EBX,EBP MOV dword ptr [RSP + 0xc],R13D LAB_001012db: CMP EBX,0x1 JZ 0x0010144f LEA EBP,[RBX + -0x1] MOV ECX,EBX XOR R13D,R13D MOV R14D,EBP MOV EDX,EBP MOV EBP,ESI MOV EBX,R14D LAB_001012f6: MOV R12D,EBX CMP EBX,0x1 JZ 0x001014c0 MOV dword ptr [RSP + 0x14],EBX XOR R14D,R14D MOV EBX,EDX LAB_0010130b: LEA EDI,[R12 + -0x1] MOV dword ptr [RSP + 0x18],ECX CALL 0x001011f0 MOV ECX,dword ptr [RSP + 0x18] ADD R14D,EAX SUB R12D,0x2 JZ 0x00101480 CMP R12D,0x1 JNZ 0x0010130b MOV EDX,EBX MOV EBX,dword ptr [RSP + 0x14] LAB_00101336: LEA EAX,[R14 + R12*0x1] ADD R13D,EAX SUB EBX,0x2 JNZ 0x001012f6 MOV ESI,EBP MOV EBX,ECX MOV EBP,EDX MOV EDI,0x1 LAB_0010134d: ADD EDI,R13D SUB EBX,0x2 ADD ESI,EDI CMP EBP,0x1 JNZ 0x001012db MOV R14D,dword ptr [RSP + 0x4] MOV EBP,dword ptr [RSP + 0x8] MOV EBX,ESI MOV EDX,0x1 MOV R13D,dword ptr [RSP + 0xc] LAB_0010136f: ADD EDX,EBX SUB R13D,0x2 ADD R15D,EDX CMP EBP,0x1 JNZ 0x001012bb MOV EBX,dword ptr [RSP + 0x4c] MOV EBP,R15D MOV EAX,0x1 LAB_0010138d: ADD EAX,EBP SUB R14D,0x2 ADD dword ptr [RSP + 0x10],EAX CMP EBX,0x1 JNZ 0x001012a3 MOV ECX,dword ptr [RSP + 0x34] MOV R12D,dword ptr [RSP + 0x38] MOV R11D,0x1 MOV EBP,dword ptr [RSP + 0x10] MOV EDI,dword ptr [RSP + 0x3c] MOV EBX,dword ptr [RSP + 0x40] MOV R9D,dword ptr [RSP + 0x44] MOV R15D,dword ptr [RSP + 0x48] LAB_001013c5: ADD R11D,EBP SUB R15D,0x2 ADD R12D,R11D CMP R9D,0x1 JNZ 0x00101271 MOV EDX,dword ptr [RSP + 0x2c] MOV R13D,dword ptr [RSP + 0x30] LAB_001013e2: ADD R9D,R12D SUB EBX,0x2 ADD R13D,R9D CMP EDI,0x1 JNZ 0x00101256 MOV EBX,dword ptr [RSP + 0x28] MOV EBP,ECX MOV ESI,0x1 LAB_001013ff: ADD ESI,R13D SUB EBX,0x2 ADD EBP,ESI CMP EDX,0x1 JNZ 0x0010123f MOV R15D,dword ptr [RSP + 0x1c] MOV R13D,dword ptr [RSP + 0x20] MOV R12D,EBP MOV EAX,0x1 MOV EBX,dword ptr [RSP + 0x24] LAB_00101426: ADD EAX,R12D SUB R13D,0x2 ADD R15D,EAX CMP EBX,0x1 JNZ 0x0010121d ADD R15D,0x1 LAB_0010143d: ADD RSP,0x58 MOV EAX,R15D POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010144f: MOV EBX,ESI MOV R14D,dword ptr [RSP + 0x4] MOV EBP,dword ptr [RSP + 0x8] MOV EDX,0x2 MOV R13D,dword ptr [RSP + 0xc] ADD EBX,0x1 JMP 0x0010136f LAB_0010146c: MOV EBP,R15D MOV EBX,dword ptr [RSP + 0x4c] MOV EAX,0x2 ADD EBP,0x1 JMP 0x0010138d LAB_00101480: MOV EDX,EBX MOV R12D,0x2 MOV EBX,dword ptr [RSP + 0x14] JMP 0x00101336 LAB_00101491: MOV EBP,dword ptr [RSP + 0x10] MOV ECX,dword ptr [RSP + 0x34] MOV R11D,0x2 MOV R12D,dword ptr [RSP + 0x38] MOV EDI,dword ptr [RSP + 0x3c] MOV EBX,dword ptr [RSP + 0x40] MOV R9D,dword ptr [RSP + 0x44] ADD EBP,0x1 MOV R15D,dword ptr [RSP + 0x48] JMP 0x001013c5 LAB_001014c0: MOV ESI,EBP MOV EBX,ECX MOV EBP,EDX ADD R13D,0x1 MOV EDI,0x2 JMP 0x0010134d LAB_001014d4: MOV EDX,dword ptr [RSP + 0x2c] MOV R13D,dword ptr [RSP + 0x30] ADD R12D,0x1 MOV R9D,0x2 JMP 0x001013e2 LAB_001014ec: MOV EBX,dword ptr [RSP + 0x28] MOV EBP,ECX ADD R13D,0x1 MOV ESI,0x2 JMP 0x001013ff LAB_00101500: MOV R12D,EBP MOV R15D,dword ptr [RSP + 0x1c] MOV R13D,dword ptr [RSP + 0x20] MOV EAX,0x2 MOV EBX,dword ptr [RSP + 0x24] ADD R12D,0x1 JMP 0x00101426 LAB_0010151f: ADD R15D,0x3 JMP 0x0010143d LAB_00101528: MOV R15D,0x2 JMP 0x0010143d
int func0(int param_1) { int iVar1; int iVar2; int iVar3; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; int iVar15; int iVar16; int iVar17; int iVar18; int iVar19; int iVar20; int iVar21; int iVar22; int iVar23; int iVar24; int local_78; if (param_1 == 0) { param_1 = 2; } else if (param_1 != 1) { iVar20 = param_1 + -1; param_1 = 0; do { if (iVar20 == 1) { return param_1 + 3; } iVar5 = iVar20 + -1; iVar12 = 0; iVar10 = iVar5; do { if (iVar10 == 1) { iVar10 = 2; iVar12 = iVar12 + 1; goto LAB_00101426; } iVar1 = iVar10 + -1; iVar19 = 0; iVar9 = iVar1; do { if (iVar9 == 1) { iVar19 = iVar19 + 1; iVar9 = 2; goto LAB_001013ff; } iVar14 = iVar9 + -1; iVar15 = 0; iVar24 = iVar14; do { if (iVar24 == 1) { iVar15 = iVar15 + 1; iVar24 = 2; goto LAB_001013e2; } iVar2 = iVar24 + -1; local_78 = 0; iVar22 = iVar2; do { if (iVar22 == 1) { iVar22 = 2; local_78 = local_78 + 1; goto LAB_001013c5; } iVar6 = iVar22 + -1; iVar23 = 0; iVar18 = iVar6; do { if (iVar18 == 1) { iVar18 = 2; iVar23 = iVar23 + 1; goto LAB_0010138d; } iVar3 = iVar18 + -1; iVar13 = 0; iVar8 = iVar3; do { if (iVar8 == 1) { iVar8 = 2; iVar13 = iVar13 + 1; goto LAB_0010136f; } iVar11 = iVar8 + -1; iVar17 = 0; iVar7 = iVar11; do { if (iVar7 == 1) { iVar17 = iVar17 + 1; iVar7 = 2; goto LAB_0010134d; } iVar21 = 0; iVar16 = iVar7; do { iVar4 = func0(iVar16 + -1); iVar21 = iVar21 + iVar4; iVar16 = iVar16 + -2; if (iVar16 == 0) { iVar16 = 2; goto LAB_00101336; } } while (iVar16 != 1); iVar16 = 1; LAB_00101336: iVar17 = iVar17 + iVar21 + iVar16; iVar7 = iVar7 + -2; } while (iVar7 != 0); iVar7 = 1; LAB_0010134d: iVar8 = iVar8 + -2; iVar13 = iVar13 + iVar7 + iVar17; } while (iVar11 != 1); iVar8 = 1; LAB_0010136f: iVar18 = iVar18 + -2; iVar23 = iVar23 + iVar8 + iVar13; } while (iVar3 != 1); iVar18 = 1; LAB_0010138d: iVar22 = iVar22 + -2; local_78 = local_78 + iVar18 + iVar23; } while (iVar6 != 1); iVar22 = 1; LAB_001013c5: iVar24 = iVar24 + -2; iVar15 = iVar15 + iVar22 + local_78; } while (iVar2 != 1); iVar24 = 1; LAB_001013e2: iVar9 = iVar9 + -2; iVar19 = iVar19 + iVar24 + iVar15; } while (iVar14 != 1); iVar9 = 1; LAB_001013ff: iVar10 = iVar10 + -2; iVar12 = iVar12 + iVar9 + iVar19; } while (iVar1 != 1); iVar10 = 1; LAB_00101426: iVar20 = iVar20 + -2; param_1 = param_1 + iVar10 + iVar12; } while (iVar5 != 1); param_1 = param_1 + 1; } return param_1; }
5,452
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char** func0(char* list[], int size, const char* format) { char** result = malloc(size * sizeof(char*)); for(int i = 0; i < size; i++) { result[i] = malloc(100); sprintf(result[i], format, list[i]); } return result; }
int main() { // First test case char* list1[] = {"1", "2", "3", "4"}; char** res1 = func0(list1, 4, "temp%s"); assert(strcmp(res1[0], "temp1") == 0); assert(strcmp(res1[1], "temp2") == 0); assert(strcmp(res1[2], "temp3") == 0); assert(strcmp(res1[3], "temp4") == 0); for(int i = 0; i < 4; i++) free(res1[i]); free(res1); // Second test case char* list2[] = {"a", "b", "c", "d"}; char** res2 = func0(list2, 4, "python%s"); assert(strcmp(res2[0], "pythona") == 0); assert(strcmp(res2[1], "pythonb") == 0); assert(strcmp(res2[2], "pythonc") == 0); assert(strcmp(res2[3], "pythond") == 0); for(int i = 0; i < 4; i++) free(res2[i]); free(res2); // Third test case char* list3[] = {"5", "6", "7", "8"}; char** res3 = func0(list3, 4, "string%s"); assert(strcmp(res3[0], "string5") == 0); assert(strcmp(res3[1], "string6") == 0); assert(strcmp(res3[2], "string7") == 0); assert(strcmp(res3[3], "string8") == 0); for(int i = 0; i < 4; i++) free(res3[i]); free(res3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) mov %rdx,-0x38(%rbp) mov -0x2c(%rbp),%eax cltq shl $0x3,%rax mov %rax,%rdi callq 10e0 <malloc@plt> mov %rax,-0x18(%rbp) movl $0x0,-0x1c(%rbp) jmp 1287 <func0+0x9e> mov -0x1c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x18(%rbp),%rax lea (%rdx,%rax,1),%rbx mov $0x64,%edi callq 10e0 <malloc@plt> mov %rax,(%rbx) mov -0x1c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%rdx mov -0x1c(%rbp),%eax cltq lea 0x0(,%rax,8),%rcx mov -0x18(%rbp),%rax add %rcx,%rax mov (%rax),%rax mov -0x38(%rbp),%rcx mov %rcx,%rsi mov %rax,%rdi mov $0x0,%eax callq 10f0 <sprintf@plt> addl $0x1,-0x1c(%rbp) mov -0x1c(%rbp),%eax cmp -0x2c(%rbp),%eax jl 121f <func0+0x36> mov -0x18(%rbp),%rax add $0x38,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 38h mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov [rbp+format], rdx mov eax, [rbp+var_2C] cdqe shl rax, 3 mov rdi, rax; size call _malloc mov [rbp+var_18], rax mov [rbp+var_1C], 0 jmp short loc_1287 loc_121F: mov eax, [rbp+var_1C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_18] lea rbx, [rdx+rax] mov edi, 64h ; 'd'; size call _malloc mov [rbx], rax mov eax, [rbp+var_1C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_28] add rax, rdx mov rdx, [rax] mov eax, [rbp+var_1C] cdqe lea rcx, ds:0[rax*8] mov rax, [rbp+var_18] add rax, rcx mov rax, [rax] mov rcx, [rbp+format] mov rsi, rcx; format mov rdi, rax; s mov eax, 0 call _sprintf add [rbp+var_1C], 1 loc_1287: mov eax, [rbp+var_1C] cmp eax, [rbp+var_2C] jl short loc_121F mov rax, [rbp+var_18] mov rbx, [rbp+var_8] leave retn
_QWORD * func0(long long a1, int a2, const char *a3) { int i; // [rsp+24h] [rbp-1Ch] _QWORD *v6; // [rsp+28h] [rbp-18h] v6 = malloc(8LL * a2); for ( i = 0; i < a2; ++i ) { v6[i] = malloc(0x64uLL); sprintf((char *)v6[i], a3, *(_QWORD *)(8LL * i + a1)); } return v6; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x38 MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV qword ptr [RBP + -0x38],RDX MOV EAX,dword ptr [RBP + -0x2c] CDQE SHL RAX,0x3 MOV RDI,RAX CALL 0x001010e0 MOV qword ptr [RBP + -0x18],RAX MOV dword ptr [RBP + -0x1c],0x0 JMP 0x00101287 LAB_0010121f: MOV EAX,dword ptr [RBP + -0x1c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x18] LEA RBX,[RDX + RAX*0x1] MOV EDI,0x64 CALL 0x001010e0 MOV qword ptr [RBX],RAX MOV EAX,dword ptr [RBP + -0x1c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV RDX,qword ptr [RAX] MOV EAX,dword ptr [RBP + -0x1c] CDQE LEA RCX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RCX MOV RAX,qword ptr [RAX] MOV RCX,qword ptr [RBP + -0x38] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x001010f0 ADD dword ptr [RBP + -0x1c],0x1 LAB_00101287: MOV EAX,dword ptr [RBP + -0x1c] CMP EAX,dword ptr [RBP + -0x2c] JL 0x0010121f MOV RAX,qword ptr [RBP + -0x18] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(long param_1,int param_2,char *param_3) { void *pvVar1; void *pvVar2; int4 local_24; pvVar1 = malloc((long)param_2 << 3); for (local_24 = 0; local_24 < param_2; local_24 = local_24 + 1) { pvVar2 = malloc(100); *(void **)((long)local_24 * 8 + (long)pvVar1) = pvVar2; sprintf(*(char **)((long)pvVar1 + (long)local_24 * 8),param_3, *(int8 *)(param_1 + (long)local_24 * 8)); } return pvVar1; }
5,453
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char** func0(char* list[], int size, const char* format) { char** result = malloc(size * sizeof(char*)); for(int i = 0; i < size; i++) { result[i] = malloc(100); sprintf(result[i], format, list[i]); } return result; }
int main() { // First test case char* list1[] = {"1", "2", "3", "4"}; char** res1 = func0(list1, 4, "temp%s"); assert(strcmp(res1[0], "temp1") == 0); assert(strcmp(res1[1], "temp2") == 0); assert(strcmp(res1[2], "temp3") == 0); assert(strcmp(res1[3], "temp4") == 0); for(int i = 0; i < 4; i++) free(res1[i]); free(res1); // Second test case char* list2[] = {"a", "b", "c", "d"}; char** res2 = func0(list2, 4, "python%s"); assert(strcmp(res2[0], "pythona") == 0); assert(strcmp(res2[1], "pythonb") == 0); assert(strcmp(res2[2], "pythonc") == 0); assert(strcmp(res2[3], "pythond") == 0); for(int i = 0; i < 4; i++) free(res2[i]); free(res2); // Third test case char* list3[] = {"5", "6", "7", "8"}; char** res3 = func0(list3, 4, "string%s"); assert(strcmp(res3[0], "string5") == 0); assert(strcmp(res3[1], "string6") == 0); assert(strcmp(res3[2], "string7") == 0); assert(strcmp(res3[3], "string8") == 0); for(int i = 0; i < 4; i++) free(res3[i]); free(res3); return 0; }
O1
c
func0: endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx mov %rdi,%r12 mov %esi,%ebx mov %rdx,%r13 movslq %esi,%rdi shl $0x3,%rdi callq 10c0 <malloc@plt> mov %rax,%rbp test %ebx,%ebx jle 1232 <func0+0x69> lea -0x1(%rbx),%r14d mov $0x0,%ebx mov $0x64,%edi callq 10c0 <malloc@plt> mov %rax,%rdi mov %rax,0x0(%rbp,%rbx,8) mov (%r12,%rbx,8),%r8 mov %r13,%rcx mov $0x64,%edx mov $0x1,%esi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> mov %rbx,%rax add $0x1,%rbx cmp %r14,%rax jne 11f9 <func0+0x30> mov %rbp,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq
func0: endbr64 push r14 push r13 push r12 push rbp push rbx mov r13, rdi mov ebp, esi mov r14, rdx movsxd rdi, esi shl rdi, 3 call _malloc mov r12, rax test ebp, ebp jle short loc_124D mov ebp, ebp mov ebx, 0 loc_1217: mov edi, 64h ; 'd' call _malloc mov rdi, rax mov [r12+rbx*8], rax mov r8, [r13+rbx*8+0] mov rcx, r14 mov edx, 64h ; 'd' mov esi, 1 mov eax, 0 call ___sprintf_chk add rbx, 1 cmp rbx, rbp jnz short loc_1217 loc_124D: mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 retn
long long func0(long long a1, int a2, long long a3) { long long v4; // r12 long long i; // rbx long long v6; // rax v4 = malloc(8LL * a2); if ( a2 > 0 ) { for ( i = 0LL; i != a2; __sprintf_chk(v6, 1LL, 100LL, a3, *(_QWORD *)(a1 + 8 * i++)) ) { v6 = malloc(100LL); *(_QWORD *)(v4 + 8 * i) = v6; } } return v4; }
func0: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R13,RDI MOV EBP,ESI MOV R14,RDX MOVSXD RDI,ESI SHL RDI,0x3 CALL 0x001010e0 MOV R12,RAX TEST EBP,EBP JLE 0x0010124d MOV EBP,EBP MOV EBX,0x0 LAB_00101217: MOV EDI,0x64 CALL 0x001010e0 MOV RDI,RAX MOV qword ptr [R12 + RBX*0x8],RAX MOV R8,qword ptr [R13 + RBX*0x8] MOV RCX,R14 MOV EDX,0x64 MOV ESI,0x1 MOV EAX,0x0 CALL 0x001010f0 ADD RBX,0x1 CMP RBX,RBP JNZ 0x00101217 LAB_0010124d: MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 RET
void * func0(long param_1,uint param_2,int8 param_3) { void *pvVar1; void *pvVar2; ulong uVar3; pvVar1 = malloc((long)(int)param_2 << 3); if (0 < (int)param_2) { uVar3 = 0; do { pvVar2 = malloc(100); *(void **)((long)pvVar1 + uVar3 * 8) = pvVar2; __sprintf_chk(pvVar2,1,100,param_3,*(int8 *)(param_1 + uVar3 * 8)); uVar3 = uVar3 + 1; } while (uVar3 != param_2); } return pvVar1; }
5,454
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char** func0(char* list[], int size, const char* format) { char** result = malloc(size * sizeof(char*)); for(int i = 0; i < size; i++) { result[i] = malloc(100); sprintf(result[i], format, list[i]); } return result; }
int main() { // First test case char* list1[] = {"1", "2", "3", "4"}; char** res1 = func0(list1, 4, "temp%s"); assert(strcmp(res1[0], "temp1") == 0); assert(strcmp(res1[1], "temp2") == 0); assert(strcmp(res1[2], "temp3") == 0); assert(strcmp(res1[3], "temp4") == 0); for(int i = 0; i < 4; i++) free(res1[i]); free(res1); // Second test case char* list2[] = {"a", "b", "c", "d"}; char** res2 = func0(list2, 4, "python%s"); assert(strcmp(res2[0], "pythona") == 0); assert(strcmp(res2[1], "pythonb") == 0); assert(strcmp(res2[2], "pythonc") == 0); assert(strcmp(res2[3], "pythond") == 0); for(int i = 0; i < 4; i++) free(res2[i]); free(res2); // Third test case char* list3[] = {"5", "6", "7", "8"}; char** res3 = func0(list3, 4, "string%s"); assert(strcmp(res3[0], "string5") == 0); assert(strcmp(res3[1], "string6") == 0); assert(strcmp(res3[2], "string7") == 0); assert(strcmp(res3[3], "string8") == 0); for(int i = 0; i < 4; i++) free(res3[i]); free(res3); return 0; }
O2
c
func0: endbr64 push %r14 push %r13 mov %rdx,%r13 push %r12 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx mov %rdi,%rbx shl $0x3,%rdi callq 10c0 <malloc@plt> mov %rax,%r12 test %ebx,%ebx jle 16b6 <func0+0x66> lea -0x1(%rbx),%r14d xor %ebx,%ebx xchg %ax,%ax mov $0x64,%edi callq 10c0 <malloc@plt> mov 0x0(%rbp,%rbx,8),%r8 mov %r13,%rcx mov $0x64,%edx mov %rax,(%r12,%rbx,8) mov %rax,%rdi mov $0x1,%esi xor %eax,%eax callq 10d0 <__sprintf_chk@plt> mov %rbx,%rax add $0x1,%rbx cmp %rax,%r14 jne 1680 <func0+0x30> pop %rbx mov %r12,%rax pop %rbp pop %r12 pop %r13 pop %r14 retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push r14 movsxd r14, esi push r13 mov r13, rdx push r12 push rbp mov rbp, rdi lea rdi, ds:0[r14*8] push rbx call _malloc mov r12, rax test r14d, r14d jle short loc_1683 xor ebx, ebx nop dword ptr [rax+00h] loc_1650: mov edi, 64h ; 'd' call _malloc mov r8, [rbp+rbx*8+0] mov rcx, r13 mov edx, 64h ; 'd' mov [r12+rbx*8], rax mov rdi, rax mov esi, 1 xor eax, eax call ___sprintf_chk add rbx, 1 cmp rbx, r14 jnz short loc_1650 loc_1683: pop rbx mov rax, r12 pop rbp pop r12 pop r13 pop r14 retn
long long func0(long long a1, int a2, long long a3) { long long v4; // r12 long long i; // rbx long long v6; // rax long long v7; // r8 v4 = malloc(8LL * a2); if ( a2 > 0 ) { for ( i = 0LL; i != a2; ++i ) { v6 = malloc(100LL); v7 = *(_QWORD *)(a1 + 8 * i); *(_QWORD *)(v4 + 8 * i) = v6; __sprintf_chk(v6, 1LL, 100LL, a3, v7); } } return v4; }
func0: ENDBR64 PUSH R14 MOVSXD R14,ESI PUSH R13 MOV R13,RDX PUSH R12 PUSH RBP MOV RBP,RDI LEA RDI,[R14*0x8] PUSH RBX CALL 0x001010e0 MOV R12,RAX TEST R14D,R14D JLE 0x00101683 XOR EBX,EBX NOP dword ptr [RAX] LAB_00101650: MOV EDI,0x64 CALL 0x001010e0 MOV R8,qword ptr [RBP + RBX*0x8] MOV RCX,R13 MOV EDX,0x64 MOV qword ptr [R12 + RBX*0x8],RAX MOV RDI,RAX MOV ESI,0x1 XOR EAX,EAX CALL 0x001010f0 ADD RBX,0x1 CMP RBX,R14 JNZ 0x00101650 LAB_00101683: POP RBX MOV RAX,R12 POP RBP POP R12 POP R13 POP R14 RET
void * func0(long param_1,int param_2,int8 param_3) { int8 uVar1; void *pvVar2; void *pvVar3; long lVar4; pvVar2 = malloc((long)param_2 * 8); if (0 < param_2) { lVar4 = 0; do { pvVar3 = malloc(100); uVar1 = *(int8 *)(param_1 + lVar4 * 8); *(void **)((long)pvVar2 + lVar4 * 8) = pvVar3; __sprintf_chk(pvVar3,1,100,param_3,uVar1); lVar4 = lVar4 + 1; } while (lVar4 != param_2); } return pvVar2; }
5,455
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h>
char** func0(char* list[], int size, const char* format) { char** result = malloc(size * sizeof(char*)); for(int i = 0; i < size; i++) { result[i] = malloc(100); sprintf(result[i], format, list[i]); } return result; }
int main() { // First test case char* list1[] = {"1", "2", "3", "4"}; char** res1 = func0(list1, 4, "temp%s"); assert(strcmp(res1[0], "temp1") == 0); assert(strcmp(res1[1], "temp2") == 0); assert(strcmp(res1[2], "temp3") == 0); assert(strcmp(res1[3], "temp4") == 0); for(int i = 0; i < 4; i++) free(res1[i]); free(res1); // Second test case char* list2[] = {"a", "b", "c", "d"}; char** res2 = func0(list2, 4, "python%s"); assert(strcmp(res2[0], "pythona") == 0); assert(strcmp(res2[1], "pythonb") == 0); assert(strcmp(res2[2], "pythonc") == 0); assert(strcmp(res2[3], "pythond") == 0); for(int i = 0; i < 4; i++) free(res2[i]); free(res2); // Third test case char* list3[] = {"5", "6", "7", "8"}; char** res3 = func0(list3, 4, "string%s"); assert(strcmp(res3[0], "string5") == 0); assert(strcmp(res3[1], "string6") == 0); assert(strcmp(res3[2], "string7") == 0); assert(strcmp(res3[3], "string8") == 0); for(int i = 0; i < 4; i++) free(res3[i]); free(res3); return 0; }
O3
c
func0: endbr64 push %r14 push %r13 mov %rdx,%r13 push %r12 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx mov %rdi,%rbx shl $0x3,%rdi callq 10c0 <malloc@plt> mov %rax,%r12 test %ebx,%ebx jle 16c6 <func0+0x66> lea -0x1(%rbx),%r14d xor %ebx,%ebx xchg %ax,%ax mov $0x64,%edi callq 10c0 <malloc@plt> mov 0x0(%rbp,%rbx,8),%r8 mov %r13,%rcx mov $0x64,%edx mov %rax,(%r12,%rbx,8) mov %rax,%rdi mov $0x1,%esi xor %eax,%eax callq 10d0 <__sprintf_chk@plt> mov %rbx,%rax add $0x1,%rbx cmp %r14,%rax jne 1690 <func0+0x30> pop %rbx mov %r12,%rax pop %rbp pop %r12 pop %r13 pop %r14 retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push r14 push r13 mov r13, rdx push r12 movsxd r12, esi push rbp mov rbp, rdi push rbx mov rbx, r12 shl r12, 3 mov rdi, r12; size call _malloc mov r14, rax test ebx, ebx jle short loc_169E mov rbx, rax add r12, rax nop dword ptr [rax+00000000h] loc_1668: mov edi, 64h ; 'd'; size add rbx, 8 add rbp, 8 call _malloc mov r8, [rbp-8] mov rcx, r13 mov edx, 64h ; 'd' mov [rbx-8], rax mov rdi, rax mov esi, 2 xor eax, eax call ___sprintf_chk cmp rbx, r12 jnz short loc_1668 loc_169E: pop rbx mov rax, r14 pop rbp pop r12 pop r13 pop r14 retn
char * func0(long long a1, int a2, long long a3) { char *v5; // rax char *v6; // r14 char *v7; // rbx char *v8; // r12 void *v9; // rax long long v10; // r8 v5 = (char *)malloc(8LL * a2); v6 = v5; if ( a2 > 0 ) { v7 = v5; v8 = &v5[8 * a2]; do { v7 += 8; a1 += 8LL; v9 = malloc(0x64uLL); v10 = *(_QWORD *)(a1 - 8); *((_QWORD *)v7 - 1) = v9; __sprintf_chk(v9, 2LL, 100LL, a3, v10); } while ( v7 != v8 ); } return v6; }
func0: ENDBR64 PUSH R14 PUSH R13 MOV R13,RDX PUSH R12 MOVSXD R12,ESI PUSH RBP MOV RBP,RDI PUSH RBX MOV RBX,R12 SHL R12,0x3 MOV RDI,R12 CALL 0x001010e0 MOV R14,RAX TEST EBX,EBX JLE 0x0010169e MOV RBX,RAX ADD R12,RAX NOP dword ptr [RAX] LAB_00101668: MOV EDI,0x64 ADD RBX,0x8 ADD RBP,0x8 CALL 0x001010e0 MOV R8,qword ptr [RBP + -0x8] MOV RCX,R13 MOV EDX,0x64 MOV qword ptr [RBX + -0x8],RAX MOV RDI,RAX MOV ESI,0x2 XOR EAX,EAX CALL 0x001010f0 CMP RBX,R12 JNZ 0x00101668 LAB_0010169e: POP RBX MOV RAX,R14 POP RBP POP R12 POP R13 POP R14 RET
int8 * func0(int8 *param_1,int param_2,int8 param_3) { int8 uVar1; int8 *puVar2; void *pvVar3; int8 *puVar4; int8 *puVar5; puVar2 = (int8 *)malloc((long)param_2 * 8); if (0 < param_2) { puVar4 = puVar2; do { puVar5 = puVar4 + 1; pvVar3 = malloc(100); uVar1 = *param_1; *puVar4 = pvVar3; __sprintf_chk(pvVar3,2,100,param_3,uVar1); puVar4 = puVar5; param_1 = param_1 + 1; } while (puVar5 != puVar2 + param_2); } return puVar2; }
5,456
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <stdlib.h> typedef struct { char *key; int value; } dictionary; typedef struct { char *key; dictionary dict; } dict_of_dict;
dict_of_dict *func0(char *l1[], char *l2[], int l3[], int size){ dict_of_dict *result = (dict_of_dict *)malloc(sizeof(dict_of_dict) * size); for (int i = 0; i < size; i++) { result[i].key = l1[i]; result[i].dict.key = l2[i]; result[i].dict.value = l3[i]; } return result; }
int main() { char *keys1[] = {"S001", "S002", "S003", "S004"}; char *values1[] = {"Adina Park", "Leyton Marsh", "Duncan Boyle", "Saim Richards"}; int numbers1[] = {85, 98, 89, 92}; dict_of_dict *result1 = func0(keys1, values1, numbers1, 4); char *keys2[] = {"abc", "def", "ghi", "jkl"}; char *values2[] = {"python", "program", "language", "programs"}; int numbers2[] = {100, 200, 300, 400}; dict_of_dict *result2 = func0(keys2, values2, numbers2, 4); char *keys3[] = {"A1", "A2", "A3", "A4"}; char *values3[] = {"java", "C", "C++", "DBMS"}; int numbers3[] = {10, 20, 30, 40}; dict_of_dict *result3 = func0(keys3, values3, numbers3, 4); // Using string comparisons for dictionary checks assert(strcmp(result1[0].key, "S001") == 0 && strcmp(result1[0].dict.key, "Adina Park") == 0 && result1[0].dict.value == 85); assert(strcmp(result1[1].key, "S002") == 0 && strcmp(result1[1].dict.key, "Leyton Marsh") == 0 && result1[1].dict.value == 98); assert(strcmp(result1[2].key, "S003") == 0 && strcmp(result1[2].dict.key, "Duncan Boyle") == 0 && result1[2].dict.value == 89); assert(strcmp(result1[3].key, "S004") == 0 && strcmp(result1[3].dict.key, "Saim Richards") == 0 && result1[3].dict.value == 92); assert(strcmp(result2[0].key, "abc") == 0 && strcmp(result2[0].dict.key, "python") == 0 && result2[0].dict.value == 100); assert(strcmp(result2[1].key, "def") == 0 && strcmp(result2[1].dict.key, "program") == 0 && result2[1].dict.value == 200); assert(strcmp(result2[2].key, "ghi") == 0 && strcmp(result2[2].dict.key, "language") == 0 && result2[2].dict.value == 300); assert(strcmp(result2[3].key, "jkl") == 0 && strcmp(result2[3].dict.key, "programs") == 0 && result2[3].dict.value == 400); assert(strcmp(result3[0].key, "A1") == 0 && strcmp(result3[0].dict.key, "java") == 0 && result3[0].dict.value == 10); assert(strcmp(result3[1].key, "A2") == 0 && strcmp(result3[1].dict.key, "C") == 0 && result3[1].dict.value == 20); assert(strcmp(result3[2].key, "A3") == 0 && strcmp(result3[2].dict.key, "C++") == 0 && result3[2].dict.value == 30); assert(strcmp(result3[3].key, "A4") == 0 && strcmp(result3[3].dict.key, "DBMS") == 0 && result3[3].dict.value == 40); free(result1); free(result2); free(result3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x18(%rbp) mov %rsi,-0x20(%rbp) mov %rdx,-0x28(%rbp) mov %ecx,-0x2c(%rbp) mov -0x2c(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax mov %rax,%rdi callq 10d0 <malloc@plt> mov %rax,-0x8(%rbp) movl $0x0,-0xc(%rbp) jmpq 12bb <func0+0xf2> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x18(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0xc(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax mov %rax,%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov (%rcx),%rax mov %rax,(%rdx) mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x20(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0xc(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax mov %rax,%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov (%rcx),%rax mov %rax,0x8(%rdx) mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0xc(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax mov %rax,%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov (%rcx),%eax mov %eax,0x10(%rdx) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x2c(%rbp),%eax jl 120f <func0+0x46> mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_18], rdi mov [rbp+var_20], rsi mov [rbp+var_28], rdx mov [rbp+var_2C], ecx mov eax, [rbp+var_2C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 mov rdi, rax; size call _malloc mov [rbp+var_8], rax mov [rbp+var_C], 0 jmp loc_12BB loc_120F: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_18] lea rcx, [rdx+rax] mov eax, [rbp+var_C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 mov rdx, rax mov rax, [rbp+var_8] add rdx, rax mov rax, [rcx] mov [rdx], rax mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_20] lea rcx, [rdx+rax] mov eax, [rbp+var_C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 mov rdx, rax mov rax, [rbp+var_8] add rdx, rax mov rax, [rcx] mov [rdx+8], rax mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] lea rcx, [rdx+rax] mov eax, [rbp+var_C] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 mov rdx, rax mov rax, [rbp+var_8] add rdx, rax mov eax, [rcx] mov [rdx+10h], eax add [rbp+var_C], 1 loc_12BB: mov eax, [rbp+var_C] cmp eax, [rbp+var_2C] jl loc_120F mov rax, [rbp+var_8] leave retn
_QWORD * func0(long long a1, long long a2, long long a3, int a4) { int i; // [rsp+24h] [rbp-Ch] _QWORD *v8; // [rsp+28h] [rbp-8h] v8 = malloc(24LL * a4); for ( i = 0; i < a4; ++i ) { v8[3 * i] = *(_QWORD *)(8LL * i + a1); v8[3 * i + 1] = *(_QWORD *)(8LL * i + a2); LODWORD(v8[3 * i + 2]) = *(_DWORD *)(4LL * i + a3); } return v8; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x18],RDI MOV qword ptr [RBP + -0x20],RSI MOV qword ptr [RBP + -0x28],RDX MOV dword ptr [RBP + -0x2c],ECX MOV EAX,dword ptr [RBP + -0x2c] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 MOV RDI,RAX CALL 0x001010d0 MOV qword ptr [RBP + -0x8],RAX MOV dword ptr [RBP + -0xc],0x0 JMP 0x001012bb LAB_0010120f: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x18] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV RAX,qword ptr [RCX] MOV qword ptr [RDX],RAX MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x20] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV RAX,qword ptr [RCX] MOV qword ptr [RDX + 0x8],RAX MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV EAX,dword ptr [RCX] MOV dword ptr [RDX + 0x10],EAX ADD dword ptr [RBP + -0xc],0x1 LAB_001012bb: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x2c] JL 0x0010120f MOV RAX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(long param_1,long param_2,long param_3,int param_4) { void *pvVar1; int local_14; pvVar1 = malloc((long)param_4 * 0x18); for (local_14 = 0; local_14 < param_4; local_14 = local_14 + 1) { *(int8 *)((long)local_14 * 0x18 + (long)pvVar1) = *(int8 *)((long)local_14 * 8 + param_1); *(int8 *)((long)pvVar1 + (long)local_14 * 0x18 + 8) = *(int8 *)((long)local_14 * 8 + param_2); *(int4 *)((long)pvVar1 + (long)local_14 * 0x18 + 0x10) = *(int4 *)((long)local_14 * 4 + param_3); } return pvVar1; }
5,457
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <stdlib.h> typedef struct { char *key; int value; } dictionary; typedef struct { char *key; dictionary dict; } dict_of_dict;
dict_of_dict *func0(char *l1[], char *l2[], int l3[], int size){ dict_of_dict *result = (dict_of_dict *)malloc(sizeof(dict_of_dict) * size); for (int i = 0; i < size; i++) { result[i].key = l1[i]; result[i].dict.key = l2[i]; result[i].dict.value = l3[i]; } return result; }
int main() { char *keys1[] = {"S001", "S002", "S003", "S004"}; char *values1[] = {"Adina Park", "Leyton Marsh", "Duncan Boyle", "Saim Richards"}; int numbers1[] = {85, 98, 89, 92}; dict_of_dict *result1 = func0(keys1, values1, numbers1, 4); char *keys2[] = {"abc", "def", "ghi", "jkl"}; char *values2[] = {"python", "program", "language", "programs"}; int numbers2[] = {100, 200, 300, 400}; dict_of_dict *result2 = func0(keys2, values2, numbers2, 4); char *keys3[] = {"A1", "A2", "A3", "A4"}; char *values3[] = {"java", "C", "C++", "DBMS"}; int numbers3[] = {10, 20, 30, 40}; dict_of_dict *result3 = func0(keys3, values3, numbers3, 4); // Using string comparisons for dictionary checks assert(strcmp(result1[0].key, "S001") == 0 && strcmp(result1[0].dict.key, "Adina Park") == 0 && result1[0].dict.value == 85); assert(strcmp(result1[1].key, "S002") == 0 && strcmp(result1[1].dict.key, "Leyton Marsh") == 0 && result1[1].dict.value == 98); assert(strcmp(result1[2].key, "S003") == 0 && strcmp(result1[2].dict.key, "Duncan Boyle") == 0 && result1[2].dict.value == 89); assert(strcmp(result1[3].key, "S004") == 0 && strcmp(result1[3].dict.key, "Saim Richards") == 0 && result1[3].dict.value == 92); assert(strcmp(result2[0].key, "abc") == 0 && strcmp(result2[0].dict.key, "python") == 0 && result2[0].dict.value == 100); assert(strcmp(result2[1].key, "def") == 0 && strcmp(result2[1].dict.key, "program") == 0 && result2[1].dict.value == 200); assert(strcmp(result2[2].key, "ghi") == 0 && strcmp(result2[2].dict.key, "language") == 0 && result2[2].dict.value == 300); assert(strcmp(result2[3].key, "jkl") == 0 && strcmp(result2[3].dict.key, "programs") == 0 && result2[3].dict.value == 400); assert(strcmp(result3[0].key, "A1") == 0 && strcmp(result3[0].dict.key, "java") == 0 && result3[0].dict.value == 10); assert(strcmp(result3[1].key, "A2") == 0 && strcmp(result3[1].dict.key, "C") == 0 && result3[1].dict.value == 20); assert(strcmp(result3[2].key, "A3") == 0 && strcmp(result3[2].dict.key, "C++") == 0 && result3[2].dict.value == 30); assert(strcmp(result3[3].key, "A4") == 0 && strcmp(result3[3].dict.key, "DBMS") == 0 && result3[3].dict.value == 40); free(result1); free(result2); free(result3); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov %rdi,%rbx mov %rsi,%rbp mov %rdx,%r12 mov %ecx,%r13d movslq %ecx,%rax lea (%rax,%rax,2),%rdi shl $0x3,%rdi callq 10b0 <malloc@plt> test %r13d,%r13d jle 120b <func0+0x62> mov %rax,%rcx lea -0x1(%r13),%edi mov $0x0,%edx mov (%rbx,%rdx,8),%rsi mov %rsi,(%rcx) mov 0x0(%rbp,%rdx,8),%rsi mov %rsi,0x8(%rcx) mov (%r12,%rdx,4),%esi mov %esi,0x10(%rcx) mov %rdx,%rsi add $0x1,%rdx add $0x18,%rcx cmp %rdi,%rsi jne 11e4 <func0+0x3b> add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq
func0: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 mov rbx, rdi mov rbp, rsi mov r12, rdx mov r13d, ecx movsxd rax, ecx lea rdi, [rax+rax*2] shl rdi, 3 call _malloc test r13d, r13d jle short loc_1227 mov rcx, rax mov edi, r13d mov edx, 0 loc_1203: mov rsi, [rbx+rdx*8] mov [rcx], rsi mov rsi, [rbp+rdx*8+0] mov [rcx+8], rsi mov esi, [r12+rdx*4] mov [rcx+10h], esi add rdx, 1 add rcx, 18h cmp rdx, rdi jnz short loc_1203 loc_1227: add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn
long long func0(long long a1, long long a2, long long a3, int a4) { long long result; // rax long long v7; // rcx long long v8; // rdx result = malloc(24LL * a4); if ( a4 > 0 ) { v7 = result; v8 = 0LL; do { *(_QWORD *)v7 = *(_QWORD *)(a1 + 8 * v8); *(_QWORD *)(v7 + 8) = *(_QWORD *)(a2 + 8 * v8); *(_DWORD *)(v7 + 16) = *(_DWORD *)(a3 + 4 * v8++); v7 += 24LL; } while ( v8 != a4 ); } return result; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV RBX,RDI MOV RBP,RSI MOV R12,RDX MOV R13D,ECX MOVSXD RAX,ECX LEA RDI,[RAX + RAX*0x2] SHL RDI,0x3 CALL 0x001010d0 TEST R13D,R13D JLE 0x00101227 MOV RCX,RAX MOV EDI,R13D MOV EDX,0x0 LAB_00101203: MOV RSI,qword ptr [RBX + RDX*0x8] MOV qword ptr [RCX],RSI MOV RSI,qword ptr [RBP + RDX*0x8] MOV qword ptr [RCX + 0x8],RSI MOV ESI,dword ptr [R12 + RDX*0x4] MOV dword ptr [RCX + 0x10],ESI ADD RDX,0x1 ADD RCX,0x18 CMP RDX,RDI JNZ 0x00101203 LAB_00101227: ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET
void func0(long param_1,long param_2,long param_3,uint param_4) { int8 *puVar1; ulong uVar2; puVar1 = (int8 *)malloc((long)(int)param_4 * 0x18); if (0 < (int)param_4) { uVar2 = 0; do { *puVar1 = *(int8 *)(param_1 + uVar2 * 8); puVar1[1] = *(int8 *)(param_2 + uVar2 * 8); *(int4 *)(puVar1 + 2) = *(int4 *)(param_3 + uVar2 * 4); uVar2 = uVar2 + 1; puVar1 = puVar1 + 3; } while (uVar2 != param_4); } return; }
5,458
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <stdlib.h> typedef struct { char *key; int value; } dictionary; typedef struct { char *key; dictionary dict; } dict_of_dict;
dict_of_dict *func0(char *l1[], char *l2[], int l3[], int size){ dict_of_dict *result = (dict_of_dict *)malloc(sizeof(dict_of_dict) * size); for (int i = 0; i < size; i++) { result[i].key = l1[i]; result[i].dict.key = l2[i]; result[i].dict.value = l3[i]; } return result; }
int main() { char *keys1[] = {"S001", "S002", "S003", "S004"}; char *values1[] = {"Adina Park", "Leyton Marsh", "Duncan Boyle", "Saim Richards"}; int numbers1[] = {85, 98, 89, 92}; dict_of_dict *result1 = func0(keys1, values1, numbers1, 4); char *keys2[] = {"abc", "def", "ghi", "jkl"}; char *values2[] = {"python", "program", "language", "programs"}; int numbers2[] = {100, 200, 300, 400}; dict_of_dict *result2 = func0(keys2, values2, numbers2, 4); char *keys3[] = {"A1", "A2", "A3", "A4"}; char *values3[] = {"java", "C", "C++", "DBMS"}; int numbers3[] = {10, 20, 30, 40}; dict_of_dict *result3 = func0(keys3, values3, numbers3, 4); // Using string comparisons for dictionary checks assert(strcmp(result1[0].key, "S001") == 0 && strcmp(result1[0].dict.key, "Adina Park") == 0 && result1[0].dict.value == 85); assert(strcmp(result1[1].key, "S002") == 0 && strcmp(result1[1].dict.key, "Leyton Marsh") == 0 && result1[1].dict.value == 98); assert(strcmp(result1[2].key, "S003") == 0 && strcmp(result1[2].dict.key, "Duncan Boyle") == 0 && result1[2].dict.value == 89); assert(strcmp(result1[3].key, "S004") == 0 && strcmp(result1[3].dict.key, "Saim Richards") == 0 && result1[3].dict.value == 92); assert(strcmp(result2[0].key, "abc") == 0 && strcmp(result2[0].dict.key, "python") == 0 && result2[0].dict.value == 100); assert(strcmp(result2[1].key, "def") == 0 && strcmp(result2[1].dict.key, "program") == 0 && result2[1].dict.value == 200); assert(strcmp(result2[2].key, "ghi") == 0 && strcmp(result2[2].dict.key, "language") == 0 && result2[2].dict.value == 300); assert(strcmp(result2[3].key, "jkl") == 0 && strcmp(result2[3].dict.key, "programs") == 0 && result2[3].dict.value == 400); assert(strcmp(result3[0].key, "A1") == 0 && strcmp(result3[0].dict.key, "java") == 0 && result3[0].dict.value == 10); assert(strcmp(result3[1].key, "A2") == 0 && strcmp(result3[1].dict.key, "C") == 0 && result3[1].dict.value == 20); assert(strcmp(result3[2].key, "A3") == 0 && strcmp(result3[2].dict.key, "C++") == 0 && result3[2].dict.value == 30); assert(strcmp(result3[3].key, "A4") == 0 && strcmp(result3[3].dict.key, "DBMS") == 0 && result3[3].dict.value == 40); free(result1); free(result2); free(result3); return 0; }
O2
c
func0: endbr64 push %r13 movslq %ecx,%rax push %r12 mov %rax,%r13 mov %rdx,%r12 push %rbp mov %rsi,%rbp push %rbx mov %rdi,%rbx lea (%rax,%rax,2),%rdi shl $0x3,%rdi sub $0x8,%rsp callq 10b0 <malloc@plt> test %r13d,%r13d jle 1949 <func0+0x69> mov %rax,%rdi lea -0x1(%r13),%edx xor %ecx,%ecx nopl 0x0(%rax,%rax,1) mov (%rbx,%rcx,8),%r8 add $0x18,%rdi mov %r8,-0x18(%rdi) mov 0x0(%rbp,%rcx,8),%r8 mov %r8,-0x10(%rdi) mov (%r12,%rcx,4),%r8d mov %r8d,-0x8(%rdi) mov %rcx,%r8 add $0x1,%rcx cmp %rdx,%r8 jne 1920 <func0+0x40> add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push r14 push r13 movsxd r13, ecx push r12 mov r12, rdx push rbp mov rbp, rsi push rbx mov rbx, rdi lea rdi, [r13+r13*2+0] shl rdi, 3 call _malloc test r13d, r13d jle short loc_18A5 mov rcx, rax xor edx, edx loc_1880: mov rsi, [rbx+rdx*8] add rcx, 18h mov [rcx-18h], rsi mov rsi, [rbp+rdx*8+0] mov [rcx-10h], rsi mov esi, [r12+rdx*4] add rdx, 1 mov [rcx-8], esi cmp rdx, r13 jnz short loc_1880 loc_18A5: pop rbx pop rbp pop r12 pop r13 pop r14 retn
long long func0(long long a1, long long a2, long long a3, int a4) { long long v4; // r13 long long result; // rax long long v8; // rcx long long i; // rdx int v10; // esi v4 = a4; result = malloc(24LL * a4); if ( (int)v4 > 0 ) { v8 = result; for ( i = 0LL; i != v4; ++i ) { v8 += 24LL; *(_QWORD *)(v8 - 24) = *(_QWORD *)(a1 + 8 * i); *(_QWORD *)(v8 - 16) = *(_QWORD *)(a2 + 8 * i); v10 = *(_DWORD *)(a3 + 4 * i); *(_DWORD *)(v8 - 8) = v10; } } return result; }
func0: ENDBR64 PUSH R14 PUSH R13 MOVSXD R13,ECX PUSH R12 MOV R12,RDX PUSH RBP MOV RBP,RSI PUSH RBX MOV RBX,RDI LEA RDI,[R13 + R13*0x2] SHL RDI,0x3 CALL 0x001010d0 TEST R13D,R13D JLE 0x001018a5 MOV RCX,RAX XOR EDX,EDX LAB_00101880: MOV RSI,qword ptr [RBX + RDX*0x8] ADD RCX,0x18 MOV qword ptr [RCX + -0x18],RSI MOV RSI,qword ptr [RBP + RDX*0x8] MOV qword ptr [RCX + -0x10],RSI MOV ESI,dword ptr [R12 + RDX*0x4] ADD RDX,0x1 MOV dword ptr [RCX + -0x8],ESI CMP RDX,R13 JNZ 0x00101880 LAB_001018a5: POP RBX POP RBP POP R12 POP R13 POP R14 RET
void func0(long param_1,long param_2,long param_3,int param_4) { long lVar1; int8 *puVar2; long lVar3; puVar2 = (int8 *)malloc((long)param_4 * 0x18); if (0 < param_4) { lVar3 = 0; do { *puVar2 = *(int8 *)(param_1 + lVar3 * 8); puVar2[1] = *(int8 *)(param_2 + lVar3 * 8); lVar1 = lVar3 * 4; lVar3 = lVar3 + 1; *(int4 *)(puVar2 + 2) = *(int4 *)(param_3 + lVar1); puVar2 = puVar2 + 3; } while (lVar3 != param_4); } return; }
5,459
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <stdlib.h> typedef struct { char *key; int value; } dictionary; typedef struct { char *key; dictionary dict; } dict_of_dict;
dict_of_dict *func0(char *l1[], char *l2[], int l3[], int size){ dict_of_dict *result = (dict_of_dict *)malloc(sizeof(dict_of_dict) * size); for (int i = 0; i < size; i++) { result[i].key = l1[i]; result[i].dict.key = l2[i]; result[i].dict.value = l3[i]; } return result; }
int main() { char *keys1[] = {"S001", "S002", "S003", "S004"}; char *values1[] = {"Adina Park", "Leyton Marsh", "Duncan Boyle", "Saim Richards"}; int numbers1[] = {85, 98, 89, 92}; dict_of_dict *result1 = func0(keys1, values1, numbers1, 4); char *keys2[] = {"abc", "def", "ghi", "jkl"}; char *values2[] = {"python", "program", "language", "programs"}; int numbers2[] = {100, 200, 300, 400}; dict_of_dict *result2 = func0(keys2, values2, numbers2, 4); char *keys3[] = {"A1", "A2", "A3", "A4"}; char *values3[] = {"java", "C", "C++", "DBMS"}; int numbers3[] = {10, 20, 30, 40}; dict_of_dict *result3 = func0(keys3, values3, numbers3, 4); // Using string comparisons for dictionary checks assert(strcmp(result1[0].key, "S001") == 0 && strcmp(result1[0].dict.key, "Adina Park") == 0 && result1[0].dict.value == 85); assert(strcmp(result1[1].key, "S002") == 0 && strcmp(result1[1].dict.key, "Leyton Marsh") == 0 && result1[1].dict.value == 98); assert(strcmp(result1[2].key, "S003") == 0 && strcmp(result1[2].dict.key, "Duncan Boyle") == 0 && result1[2].dict.value == 89); assert(strcmp(result1[3].key, "S004") == 0 && strcmp(result1[3].dict.key, "Saim Richards") == 0 && result1[3].dict.value == 92); assert(strcmp(result2[0].key, "abc") == 0 && strcmp(result2[0].dict.key, "python") == 0 && result2[0].dict.value == 100); assert(strcmp(result2[1].key, "def") == 0 && strcmp(result2[1].dict.key, "program") == 0 && result2[1].dict.value == 200); assert(strcmp(result2[2].key, "ghi") == 0 && strcmp(result2[2].dict.key, "language") == 0 && result2[2].dict.value == 300); assert(strcmp(result2[3].key, "jkl") == 0 && strcmp(result2[3].dict.key, "programs") == 0 && result2[3].dict.value == 400); assert(strcmp(result3[0].key, "A1") == 0 && strcmp(result3[0].dict.key, "java") == 0 && result3[0].dict.value == 10); assert(strcmp(result3[1].key, "A2") == 0 && strcmp(result3[1].dict.key, "C") == 0 && result3[1].dict.value == 20); assert(strcmp(result3[2].key, "A3") == 0 && strcmp(result3[2].dict.key, "C++") == 0 && result3[2].dict.value == 30); assert(strcmp(result3[3].key, "A4") == 0 && strcmp(result3[3].dict.key, "DBMS") == 0 && result3[3].dict.value == 40); free(result1); free(result2); free(result3); return 0; }
O3
c
func0: endbr64 push %r13 movslq %ecx,%rax mov %rdx,%r13 push %r12 mov %rax,%r12 push %rbp mov %rdi,%rbp lea (%rax,%rax,2),%rdi push %rbx shl $0x3,%rdi mov %rsi,%rbx sub $0x8,%rsp callq 10b0 <malloc@plt> test %r12d,%r12d jle 1a1e <func0+0x14e> lea -0x1(%r12),%edx cmp $0x2,%edx jbe 1a29 <func0+0x159> mov %r12d,%ecx mov %rax,%rdi mov %r13,%r9 xor %r8d,%r8d shr $0x2,%ecx shl $0x5,%rcx nopl 0x0(%rax) movdqu 0x10(%rbx,%r8,1),%xmm0 add $0x60,%rdi add $0x10,%r9 movdqu (%rbx,%r8,1),%xmm1 movdqu 0x0(%rbp,%r8,1),%xmm3 movdqu 0x10(%rbp,%r8,1),%xmm2 add $0x20,%r8 movq %xmm0,-0x28(%rdi) movhps %xmm0,-0x10(%rdi) movdqu -0x10(%r9),%xmm0 movq %xmm1,-0x58(%rdi) movhps %xmm1,-0x40(%rdi) pshufd $0x55,%xmm0,%xmm1 movd %xmm1,-0x38(%rdi) movdqa %xmm0,%xmm1 punpckhdq %xmm0,%xmm1 movd %xmm0,-0x50(%rdi) pshufd $0xff,%xmm0,%xmm0 movq %xmm3,-0x60(%rdi) movhps %xmm3,-0x48(%rdi) movq %xmm2,-0x30(%rdi) movhps %xmm2,-0x18(%rdi) movd %xmm1,-0x20(%rdi) movd %xmm0,-0x8(%rdi) cmp %r8,%rcx jne 1928 <func0+0x58> mov %r12d,%ecx and $0xfffffffc,%ecx test $0x3,%r12b je 1a1e <func0+0x14e> movslq %ecx,%rdx movq 0x0(%rbp,%rdx,8),%xmm0 lea (%rdx,%rdx,2),%rsi shl $0x3,%rsi movhps (%rbx,%rdx,8),%xmm0 mov 0x0(%r13,%rdx,4),%edx lea (%rax,%rsi,1),%rdi movups %xmm0,(%rdi) mov %edx,0x10(%rdi) lea 0x1(%rcx),%edx cmp %edx,%r12d jle 1a1e <func0+0x14e> movslq %edx,%rdx lea 0x18(%rax,%rsi,1),%rdi add $0x2,%ecx movq 0x0(%rbp,%rdx,8),%xmm0 movhps (%rbx,%rdx,8),%xmm0 mov 0x0(%r13,%rdx,4),%edx movups %xmm0,(%rdi) mov %edx,0x10(%rdi) cmp %ecx,%r12d jle 1a1e <func0+0x14e> movslq %ecx,%rcx lea 0x30(%rax,%rsi,1),%rdx movq 0x0(%rbp,%rcx,8),%xmm0 movhps (%rbx,%rcx,8),%xmm0 mov 0x0(%r13,%rcx,4),%ecx movups %xmm0,(%rdx) mov %ecx,0x10(%rdx) add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq xor %ecx,%ecx jmp 19b0 <func0+0xe0> nopl (%rax)
func0: endbr64 push r13 movsxd rax, ecx push r12 mov r13, rax mov r12, rdx push rbp mov rbp, rdi lea rdi, [rax+rax*2] push rbx shl rdi, 3; size mov rbx, rsi sub rsp, 8 call _malloc mov r8, rax test r13d, r13d jle loc_19A6 lea eax, [r13-1] cmp eax, 2 jbe loc_19B4 mov edi, r13d mov rax, r8 mov rcx, r12 xor edx, edx shr edi, 2 shl rdi, 5 nop dword ptr [rax] loc_18B8: lea rsi, [rbp+rdx+0] mov r9d, [rcx+8] mov r11d, [rcx] add rax, 60h ; '`' movq xmm3, qword ptr [rsi] movq xmm2, qword ptr [rsi+8] add rcx, 10h movq xmm0, qword ptr [rsi+18h] movq xmm1, qword ptr [rsi+10h] movhps xmm3, qword ptr [rbx+rdx] mov esi, [rcx-4] mov r10d, [rcx-0Ch] movups xmmword ptr [rax-60h], xmm3 movhps xmm2, qword ptr [rbx+rdx+8] movups xmmword ptr [rax-48h], xmm2 movhps xmm1, qword ptr [rbx+rdx+10h] movups xmmword ptr [rax-30h], xmm1 movhps xmm0, qword ptr [rbx+rdx+18h] add rdx, 20h ; ' ' mov [rax-50h], r11d movups xmmword ptr [rax-18h], xmm0 mov [rax-38h], r10d mov [rax-20h], r9d mov [rax-8], esi cmp rdi, rdx jnz short loc_18B8 mov edx, r13d and edx, 0FFFFFFFCh test r13b, 3 jz short loc_19A6 loc_192D: movsxd rax, edx movq xmm0, qword ptr [rbp+rax*8+0] lea rcx, [rax+rax*2] lea rsi, ds:0[rax*8] shl rcx, 3 lea r9, ds:0[rax*4] movhps xmm0, qword ptr [rbx+rax*8] mov eax, [r12+rax*4] lea rdi, [r8+rcx] movups xmmword ptr [rdi], xmm0 mov [rdi+10h], eax lea eax, [rdx+1] cmp r13d, eax jle short loc_19A6 movq xmm0, qword ptr [rbp+rsi+8] mov edi, [r12+r9+4] lea rax, [r8+rcx+18h] add edx, 2 movhps xmm0, qword ptr [rbx+rsi+8] mov [rax+10h], edi movups xmmword ptr [rax], xmm0 cmp r13d, edx jle short loc_19A6 mov edx, [r12+r9+8] lea rax, [r8+rcx+30h] movq xmm0, qword ptr [rbp+rsi+10h] mov [rax+10h], edx movhps xmm0, qword ptr [rbx+rsi+10h] movups xmmword ptr [rax], xmm0 loc_19A6: add rsp, 8 mov rax, r8 pop rbx pop rbp pop r12 pop r13 retn loc_19B4: xor edx, edx jmp loc_192D
__m128 * func0(long long a1, long long a2, __int32 *a3, int a4) { __m128 *v7; // r8 __m128 *v8; // rax __int32 *v9; // rcx long long v10; // rdx __int32 v11; // r9d __int32 v12; // r11d __int32 v13; // esi __int32 v14; // r10d __m128 v15; // xmm0 int v16; // edx long long v17; // rsi long long v18; // rcx long long v19; // r9 __int32 v20; // eax __m128 *v21; // rdi long long v22; // rax __m128 v23; // xmm0 __m128 *v24; // rax v7 = (__m128 *)malloc(24LL * a4); if ( a4 > 0 ) { if ( (unsigned int)(a4 - 1) <= 2 ) { v16 = 0; } else { v8 = v7; v9 = a3; v10 = 0LL; do { v11 = v9[2]; v12 = *v9; v8 += 6; v9 += 4; v13 = *(v9 - 1); v14 = *(v9 - 3); v8[-6] = _mm_loadh_ps((const double *)(a2 + v10)); *(__m128 *)((char *)v8 - 72) = _mm_loadh_ps((const double *)(a2 + v10 + 8)); v8[-3] = _mm_loadh_ps((const double *)(a2 + v10 + 16)); v15 = _mm_loadh_ps((const double *)(a2 + v10 + 24)); v10 += 32LL; v8[-5].m128_i32[0] = v12; *(__m128 *)((char *)v8 - 24) = v15; v8[-4].m128_i32[2] = v14; v8[-2].m128_i32[0] = v11; v8[-1].m128_i32[2] = v13; } while ( 32LL * ((unsigned int)a4 >> 2) != v10 ); v16 = a4 & 0x7FFFFFFC; if ( (a4 & 3) == 0 ) return v7; } v17 = 8LL * v16; v18 = 24LL * v16; v19 = v16; v20 = a3[v19]; v21 = (__m128 *)((char *)v7 + v18); *v21 = _mm_loadh_ps((const double *)(a2 + v17)); v21[1].m128_i32[0] = v20; if ( a4 > v16 + 1 ) { v22 = (long long)&v7[1].m128_i64[(unsigned long long)v18 / 8 + 1]; v23 = _mm_loadh_ps((const double *)(a2 + v17 + 8)); *(_DWORD *)(v22 + 16) = a3[v19 + 1]; *(__m128 *)v22 = v23; if ( a4 > v16 + 2 ) { v24 = (__m128 *)((char *)v7 + v18 + 48); v24[1].m128_i32[0] = a3[v19 + 2]; *v24 = _mm_loadh_ps((const double *)(a2 + v17 + 16)); } } } return v7; }
func0: ENDBR64 PUSH R13 MOVSXD RAX,ECX PUSH R12 MOV R13,RAX MOV R12,RDX PUSH RBP MOV RBP,RDI LEA RDI,[RAX + RAX*0x2] PUSH RBX SHL RDI,0x3 MOV RBX,RSI SUB RSP,0x8 CALL 0x001010d0 MOV R8,RAX TEST R13D,R13D JLE 0x001019a6 LEA EAX,[R13 + -0x1] CMP EAX,0x2 JBE 0x001019b4 MOV EDI,R13D MOV RAX,R8 MOV RCX,R12 XOR EDX,EDX SHR EDI,0x2 SHL RDI,0x5 NOP dword ptr [RAX] LAB_001018b8: LEA RSI,[RBP + RDX*0x1] MOV R9D,dword ptr [RCX + 0x8] MOV R11D,dword ptr [RCX] ADD RAX,0x60 MOVQ XMM3,qword ptr [RSI] MOVQ XMM2,qword ptr [RSI + 0x8] ADD RCX,0x10 MOVQ XMM0,qword ptr [RSI + 0x18] MOVQ XMM1,qword ptr [RSI + 0x10] MOVHPS XMM3,qword ptr [RBX + RDX*0x1] MOV ESI,dword ptr [RCX + -0x4] MOV R10D,dword ptr [RCX + -0xc] MOVUPS xmmword ptr [RAX + -0x60],XMM3 MOVHPS XMM2,qword ptr [RBX + RDX*0x1 + 0x8] MOVUPS xmmword ptr [RAX + -0x48],XMM2 MOVHPS XMM1,qword ptr [RBX + RDX*0x1 + 0x10] MOVUPS xmmword ptr [RAX + -0x30],XMM1 MOVHPS XMM0,qword ptr [RBX + RDX*0x1 + 0x18] ADD RDX,0x20 MOV dword ptr [RAX + -0x50],R11D MOVUPS xmmword ptr [RAX + -0x18],XMM0 MOV dword ptr [RAX + -0x38],R10D MOV dword ptr [RAX + -0x20],R9D MOV dword ptr [RAX + -0x8],ESI CMP RDI,RDX JNZ 0x001018b8 MOV EDX,R13D AND EDX,0xfffffffc TEST R13B,0x3 JZ 0x001019a6 LAB_0010192d: MOVSXD RAX,EDX MOVQ XMM0,qword ptr [RBP + RAX*0x8] LEA RCX,[RAX + RAX*0x2] LEA RSI,[RAX*0x8] SHL RCX,0x3 LEA R9,[RAX*0x4] MOVHPS XMM0,qword ptr [RBX + RAX*0x8] MOV EAX,dword ptr [R12 + RAX*0x4] LEA RDI,[R8 + RCX*0x1] MOVUPS xmmword ptr [RDI],XMM0 MOV dword ptr [RDI + 0x10],EAX LEA EAX,[RDX + 0x1] CMP R13D,EAX JLE 0x001019a6 MOVQ XMM0,qword ptr [RBP + RSI*0x1 + 0x8] MOV EDI,dword ptr [R12 + R9*0x1 + 0x4] LEA RAX,[R8 + RCX*0x1 + 0x18] ADD EDX,0x2 MOVHPS XMM0,qword ptr [RBX + RSI*0x1 + 0x8] MOV dword ptr [RAX + 0x10],EDI MOVUPS xmmword ptr [RAX],XMM0 CMP R13D,EDX JLE 0x001019a6 MOV EDX,dword ptr [R12 + R9*0x1 + 0x8] LEA RAX,[R8 + RCX*0x1 + 0x30] MOVQ XMM0,qword ptr [RBP + RSI*0x1 + 0x10] MOV dword ptr [RAX + 0x10],EDX MOVHPS XMM0,qword ptr [RBX + RSI*0x1 + 0x10] MOVUPS xmmword ptr [RAX],XMM0 LAB_001019a6: ADD RSP,0x8 MOV RAX,R8 POP RBX POP RBP POP R12 POP R13 RET LAB_001019b4: XOR EDX,EDX JMP 0x0010192d
int8 * func0(long param_1,long param_2,int4 *param_3,uint param_4) { int8 *puVar1; int8 uVar2; int8 uVar3; int8 uVar4; int8 uVar5; int4 uVar6; int4 uVar7; int4 uVar8; int4 uVar9; ulong uVar10; int8 *puVar11; int8 *puVar12; long lVar13; int4 *puVar14; uint uVar15; long lVar16; uVar10 = (ulong)(int)param_4; puVar11 = (int8 *)malloc(uVar10 * 0x18); if (0 < (int)param_4) { if (param_4 - 1 < 3) { uVar15 = 0; } else { lVar16 = 0; puVar12 = puVar11; puVar14 = param_3; do { puVar1 = (int8 *)(param_1 + lVar16); uVar6 = puVar14[2]; uVar7 = *puVar14; uVar2 = puVar1[1]; uVar3 = puVar1[3]; uVar4 = puVar1[2]; uVar5 = *(int8 *)(param_2 + lVar16); uVar8 = puVar14[3]; uVar9 = puVar14[1]; *puVar12 = *puVar1; puVar12[1] = uVar5; uVar5 = *(int8 *)(param_2 + 8 + lVar16); puVar12[3] = uVar2; puVar12[4] = uVar5; uVar2 = *(int8 *)(param_2 + 0x10 + lVar16); puVar12[6] = uVar4; puVar12[7] = uVar2; uVar2 = *(int8 *)(param_2 + 0x18 + lVar16); lVar16 = lVar16 + 0x20; *(int4 *)(puVar12 + 2) = uVar7; puVar12[9] = uVar3; puVar12[10] = uVar2; *(int4 *)(puVar12 + 5) = uVar9; *(int4 *)(puVar12 + 8) = uVar6; *(int4 *)(puVar12 + 0xb) = uVar8; puVar12 = puVar12 + 0xc; puVar14 = puVar14 + 4; } while ((uVar10 >> 2 & 0x3fffffff) << 5 != lVar16); uVar15 = param_4 & 0xfffffffc; if ((uVar10 & 3) == 0) { return puVar11; } } lVar13 = (long)(int)uVar15; lVar16 = lVar13 * 8; uVar2 = *(int8 *)(param_2 + lVar13 * 8); uVar6 = param_3[lVar13]; puVar12 = puVar11 + lVar13 * 3; *puVar12 = *(int8 *)(param_1 + lVar13 * 8); puVar12[1] = uVar2; *(int4 *)(puVar12 + 2) = uVar6; if ((int)(uVar15 + 1) < (int)param_4) { uVar2 = *(int8 *)(param_1 + 8 + lVar16); puVar12 = puVar11 + lVar13 * 3 + 3; uVar3 = *(int8 *)(param_2 + 8 + lVar16); *(int4 *)(puVar12 + 2) = param_3[lVar13 + 1]; *puVar12 = uVar2; puVar12[1] = uVar3; if ((int)(uVar15 + 2) < (int)param_4) { puVar12 = puVar11 + lVar13 * 3 + 6; uVar2 = *(int8 *)(param_1 + 0x10 + lVar16); *(int4 *)(puVar12 + 2) = param_3[lVar13 + 2]; uVar3 = *(int8 *)(param_2 + 0x10 + lVar16); *puVar12 = uVar2; puVar12[1] = uVar3; } } } return puVar11; }
5,460
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res[n + 1]; res[0] = 0; res[1] = 1; int i = 2; while (i < n + 1) { res[i] = i; int temp = res[i / 2] + res[i / 3] + res[i / 4] + res[i / 5]; if (temp > res[i]) res[i] = temp; i++; } return res[n]; }
int main() { assert(func0(60) == 106); assert(func0(10) == 12); assert(func0(2) == 2); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %edi,-0x34(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov %rsp,%rax mov %rax,%rsi mov -0x34(%rbp),%eax add $0x1,%eax movslq %eax,%rdx sub $0x1,%rdx mov %rdx,-0x28(%rbp) movslq %eax,%rdx mov %rdx,%r8 mov $0x0,%r9d movslq %eax,%rdx mov %rdx,%rcx mov $0x0,%ebx cltq lea 0x0(,%rax,4),%rdx mov $0x10,%eax sub $0x1,%rax add %rdx,%rax mov $0x10,%edi mov $0x0,%edx div %rdi imul $0x10,%rax,%rax mov %rax,%rdx and $0xfffffffffffff000,%rdx mov %rsp,%rbx sub %rdx,%rbx mov %rbx,%rdx cmp %rdx,%rsp je 1207 <func0+0x9e> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 11f0 <func0+0x87> mov %rax,%rdx and $0xfff,%edx sub %rdx,%rsp mov %rax,%rdx and $0xfff,%edx test %rdx,%rdx je 1231 <func0+0xc8> and $0xfff,%eax sub $0x8,%rax add %rsp,%rax orq $0x0,(%rax) mov %rsp,%rax add $0x3,%rax shr $0x2,%rax shl $0x2,%rax mov %rax,-0x20(%rbp) mov -0x20(%rbp),%rax movl $0x0,(%rax) mov -0x20(%rbp),%rax movl $0x1,0x4(%rax) movl $0x2,-0x30(%rbp) jmpq 1318 <func0+0x1af> mov -0x20(%rbp),%rax mov -0x30(%rbp),%edx movslq %edx,%rdx mov -0x30(%rbp),%ecx mov %ecx,(%rax,%rdx,4) mov -0x30(%rbp),%eax mov %eax,%edx shr $0x1f,%edx add %edx,%eax sar %eax mov %eax,%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%ecx mov -0x30(%rbp),%eax movslq %eax,%rdx imul $0x55555556,%rdx,%rdx shr $0x20,%rdx sar $0x1f,%eax sub %eax,%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax add %eax,%ecx mov -0x30(%rbp),%eax lea 0x3(%rax),%edx test %eax,%eax cmovs %edx,%eax sar $0x2,%eax mov %eax,%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax add %eax,%ecx mov -0x30(%rbp),%eax movslq %eax,%rdx imul $0x66666667,%rdx,%rdx shr $0x20,%rdx sar %edx sar $0x1f,%eax sub %eax,%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax add %ecx,%eax mov %eax,-0x2c(%rbp) mov -0x20(%rbp),%rax mov -0x30(%rbp),%edx movslq %edx,%rdx mov (%rax,%rdx,4),%eax cmp %eax,-0x2c(%rbp) jle 1314 <func0+0x1ab> mov -0x20(%rbp),%rax mov -0x30(%rbp),%edx movslq %edx,%rdx mov -0x2c(%rbp),%ecx mov %ecx,(%rax,%rdx,4) addl $0x1,-0x30(%rbp) mov -0x34(%rbp),%eax cmp -0x30(%rbp),%eax jge 1265 <func0+0xfc> mov -0x20(%rbp),%rax mov -0x34(%rbp),%edx movslq %edx,%rdx mov (%rax,%rdx,4),%eax mov %rsi,%rsp mov -0x18(%rbp),%rdi xor %fs:0x28,%rdi je 1348 <func0+0x1df> callq 1060 <__stack_chk_fail@plt> mov -0x8(%rbp),%rbx leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_24], edi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rax, rsp mov rsi, rax mov eax, [rbp+var_24] add eax, 1 movsxd rdx, eax sub rdx, 1 mov [rbp+var_18], rdx cdqe lea rdx, ds:0[rax*4] mov eax, 10h sub rax, 1 add rax, rdx mov edi, 10h mov edx, 0 div rdi imul rax, 10h mov rcx, rax and rcx, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rcx loc_11D5: cmp rsp, rdx jz short loc_11EC sub rsp, 1000h or [rsp+1030h+var_38], 0 jmp short loc_11D5 loc_11EC: mov rdx, rax and edx, 0FFFh sub rsp, rdx mov rdx, rax and edx, 0FFFh test rdx, rdx jz short loc_1216 and eax, 0FFFh sub rax, 8 add rax, rsp or qword ptr [rax], 0 loc_1216: mov rax, rsp add rax, 3 shr rax, 2 shl rax, 2 mov [rbp+var_10], rax mov rax, [rbp+var_10] mov dword ptr [rax], 0 mov rax, [rbp+var_10] mov dword ptr [rax+4], 1 mov [rbp+var_20], 2 jmp loc_12FD loc_124A: mov rax, [rbp+var_10] mov edx, [rbp+var_20] movsxd rdx, edx mov ecx, [rbp+var_20] mov [rax+rdx*4], ecx mov eax, [rbp+var_20] mov edx, eax shr edx, 1Fh add eax, edx sar eax, 1 mov edx, eax mov rax, [rbp+var_10] movsxd rdx, edx mov ecx, [rax+rdx*4] mov eax, [rbp+var_20] movsxd rdx, eax imul rdx, 55555556h shr rdx, 20h sar eax, 1Fh sub edx, eax mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] add ecx, eax mov eax, [rbp+var_20] lea edx, [rax+3] test eax, eax cmovs eax, edx sar eax, 2 mov edx, eax mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] add ecx, eax mov eax, [rbp+var_20] movsxd rdx, eax imul rdx, 66666667h shr rdx, 20h sar edx, 1 sar eax, 1Fh sub edx, eax mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] add eax, ecx mov [rbp+var_1C], eax mov rax, [rbp+var_10] mov edx, [rbp+var_20] movsxd rdx, edx mov eax, [rax+rdx*4] cmp [rbp+var_1C], eax jle short loc_12F9 mov rax, [rbp+var_10] mov edx, [rbp+var_20] movsxd rdx, edx mov ecx, [rbp+var_1C] mov [rax+rdx*4], ecx loc_12F9: add [rbp+var_20], 1 loc_12FD: mov eax, [rbp+var_24] cmp eax, [rbp+var_20] jge loc_124A mov rax, [rbp+var_10] mov edx, [rbp+var_24] movsxd rdx, edx mov eax, [rax+rdx*4] mov rsp, rsi mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_132D call ___stack_chk_fail locret_132D: leave retn
long long func0(int a1) { unsigned long long v1; // rax void *v2; // rsp _DWORD v4[3]; // [rsp+8h] [rbp-30h] BYREF int v5; // [rsp+14h] [rbp-24h] int i; // [rsp+18h] [rbp-20h] int v7; // [rsp+1Ch] [rbp-1Ch] long long v8; // [rsp+20h] [rbp-18h] _DWORD *v9; // [rsp+28h] [rbp-10h] unsigned long long v10; // [rsp+30h] [rbp-8h] v5 = a1; v10 = __readfsqword(0x28u); v8 = a1 + 1 - 1LL; v1 = 16 * ((4LL * (a1 + 1) + 15) / 0x10uLL); while ( v4 != (_DWORD *)((char *)v4 - (v1 & 0xFFFFFFFFFFFFF000LL)) ) ; v2 = alloca(v1 & 0xFFF); if ( (v1 & 0xFFF) != 0 ) *(_QWORD *)((char *)&v4[-2] + (v1 & 0xFFF)) = *(_QWORD *)((char *)&v4[-2] + (v1 & 0xFFF)); v9 = v4; v4[0] = 0; v4[1] = 1; for ( i = 2; v5 >= i; ++i ) { v9[i] = i; v7 = v9[i / 4] + v9[i / 3] + v9[i / 2] + v9[i / 5]; if ( v7 > v9[i] ) v9[i] = v7; } return (unsigned int)v9[v5]; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV dword ptr [RBP + -0x24],EDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RAX,RSP MOV RSI,RAX MOV EAX,dword ptr [RBP + -0x24] ADD EAX,0x1 MOVSXD RDX,EAX SUB RDX,0x1 MOV qword ptr [RBP + -0x18],RDX CDQE LEA RDX,[RAX*0x4] MOV EAX,0x10 SUB RAX,0x1 ADD RAX,RDX MOV EDI,0x10 MOV EDX,0x0 DIV RDI IMUL RAX,RAX,0x10 MOV RCX,RAX AND RCX,-0x1000 MOV RDX,RSP SUB RDX,RCX LAB_001011d5: CMP RSP,RDX JZ 0x001011ec SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011d5 LAB_001011ec: MOV RDX,RAX AND EDX,0xfff SUB RSP,RDX MOV RDX,RAX AND EDX,0xfff TEST RDX,RDX JZ 0x00101216 AND EAX,0xfff SUB RAX,0x8 ADD RAX,RSP OR qword ptr [RAX],0x0 LAB_00101216: MOV RAX,RSP ADD RAX,0x3 SHR RAX,0x2 SHL RAX,0x2 MOV qword ptr [RBP + -0x10],RAX MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX],0x0 MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX + 0x4],0x1 MOV dword ptr [RBP + -0x20],0x2 JMP 0x001012fd LAB_0010124a: MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX MOV ECX,dword ptr [RBP + -0x20] MOV dword ptr [RAX + RDX*0x4],ECX MOV EAX,dword ptr [RBP + -0x20] MOV EDX,EAX SHR EDX,0x1f ADD EAX,EDX SAR EAX,0x1 MOV EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV ECX,dword ptr [RAX + RDX*0x4] MOV EAX,dword ptr [RBP + -0x20] MOVSXD RDX,EAX IMUL RDX,RDX,0x55555556 SHR RDX,0x20 SAR EAX,0x1f SUB EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] ADD ECX,EAX MOV EAX,dword ptr [RBP + -0x20] LEA EDX,[RAX + 0x3] TEST EAX,EAX CMOVS EAX,EDX SAR EAX,0x2 MOV EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] ADD ECX,EAX MOV EAX,dword ptr [RBP + -0x20] MOVSXD RDX,EAX IMUL RDX,RDX,0x66666667 SHR RDX,0x20 SAR EDX,0x1 SAR EAX,0x1f SUB EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] ADD EAX,ECX MOV dword ptr [RBP + -0x1c],EAX MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] CMP dword ptr [RBP + -0x1c],EAX JLE 0x001012f9 MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX MOV ECX,dword ptr [RBP + -0x1c] MOV dword ptr [RAX + RDX*0x4],ECX LAB_001012f9: ADD dword ptr [RBP + -0x20],0x1 LAB_001012fd: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x20] JGE 0x0010124a MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x24] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] MOV RSP,RSI MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x0010132d CALL 0x00101060 LAB_0010132d: LEAVE RET
int4 func0(int param_1) { long lVar1; int iVar2; ulong uVar3; int *puVar4; long in_FS_OFFSET; int auStack_38 [12]; int local_2c; int local_28; int local_24; long local_20; int *local_18; long local_10; local_2c = param_1; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_20 = (long)(param_1 + 1) + -1; uVar3 = (((long)(param_1 + 1) * 4 + 0xfU) / 0x10) * 0x10; for (puVar4 = auStack_38; puVar4 != auStack_38 + -(uVar3 & 0xfffffffffffff000); puVar4 = puVar4 + -0x1000) { *(int8 *)(puVar4 + -8) = *(int8 *)(puVar4 + -8); } lVar1 = -(ulong)((uint)uVar3 & 0xfff); if ((uVar3 & 0xfff) != 0) { *(int8 *)(puVar4 + ((ulong)((uint)uVar3 & 0xfff) - 8) + lVar1) = *(int8 *)(puVar4 + ((ulong)((uint)uVar3 & 0xfff) - 8) + lVar1); } *(int4 *)(puVar4 + lVar1) = 0; *(int4 *)(puVar4 + lVar1 + 4) = 1; for (local_28 = 2; local_28 <= local_2c; local_28 = local_28 + 1) { *(int *)(puVar4 + (long)local_28 * 4 + lVar1) = local_28; iVar2 = local_28; if (local_28 < 0) { iVar2 = local_28 + 3; } local_24 = *(int *)(puVar4 + (long)(local_28 / 5) * 4 + lVar1) + *(int *)(puVar4 + (long)(local_28 / 2) * 4 + lVar1) + *(int *)(puVar4 + (long)(local_28 / 3) * 4 + lVar1) + *(int *)(puVar4 + (long)(iVar2 >> 2) * 4 + lVar1); if (*(int *)(puVar4 + (long)local_28 * 4 + lVar1) < local_24) { *(int *)(puVar4 + (long)local_28 * 4 + lVar1) = local_24; } } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { local_18 = puVar4 + lVar1; /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return *(int4 *)(puVar4 + (long)local_2c * 4 + lVar1); }
5,461
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res[n + 1]; res[0] = 0; res[1] = 1; int i = 2; while (i < n + 1) { res[i] = i; int temp = res[i / 2] + res[i / 3] + res[i / 4] + res[i / 5]; if (temp > res[i]) res[i] = temp; i++; } return res[n]; }
int main() { assert(func0(60) == 106); assert(func0(10) == 12); assert(func0(2) == 2); return 0; }
O1
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea 0x1(%rdi),%eax cltq lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffffff0,%rdx and $0xfffffffffffff000,%rax mov %rsp,%rsi sub %rax,%rsi mov %rsi,%rax cmp %rax,%rsp je 11be <func0+0x55> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 11a7 <func0+0x3e> mov %rdx,%rax and $0xfff,%eax sub %rax,%rsp test %rax,%rax je 11d4 <func0+0x6b> orq $0x0,-0x8(%rsp,%rax,1) lea 0x3(%rsp),%r9 mov %r9,%rax shr $0x2,%rax and $0xfffffffffffffffc,%r9 mov %r9,%rsi movl $0x0,0x0(,%rax,4) movl $0x1,0x4(,%rax,4) cmp $0x1,%edi jle 127e <func0+0x115> lea -0x2(%rdi),%r8d add $0x3,%r8 mov $0x2,%eax mov %eax,(%rsi,%rax,4) mov %eax,%r10d shr $0x1f,%r10d add %eax,%r10d sar %r10d movslq %r10d,%r10 movslq %eax,%rcx imul $0x55555556,%rcx,%rdx shr $0x20,%rdx mov %eax,%r11d sar $0x1f,%r11d sub %r11d,%edx movslq %edx,%rdx mov (%rsi,%rdx,4),%edx add (%rsi,%r10,4),%edx lea 0x3(%rax),%r10d test %eax,%eax cmovns %eax,%r10d sar $0x2,%r10d movslq %r10d,%r10 add (%rsi,%r10,4),%edx imul $0x66666667,%rcx,%rcx sar $0x21,%rcx sub %r11d,%ecx movslq %ecx,%rcx add (%rsi,%rcx,4),%edx cmp %eax,%edx cmovle %eax,%edx mov %edx,(%rsi,%rax,4) add $0x1,%rax cmp %r8,%rax jne 120f <func0+0xa6> movslq %edi,%rdi mov (%r9,%rdi,4),%eax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi jne 1296 <func0+0x12d> leaveq retq callq 1060 <__stack_chk_fail@plt>
func0: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov r9d, edi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea eax, [rdi+1] cdqe lea rax, ds:0Fh[rax*4] mov rcx, rax and rcx, 0FFFFFFFFFFFFFFF0h and rax, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rax loc_11A7: cmp rsp, rdx jz short loc_11BE sub rsp, 1000h or [rsp+1010h+var_18], 0 jmp short loc_11A7 loc_11BE: mov rax, rcx and eax, 0FFFh sub rsp, rax test rax, rax jz short loc_11D4 or [rsp+rax+10h+var_18], 0 loc_11D4: lea rdi, [rsp+10h+var_D] mov rax, rdi shr rax, 2 and rdi, 0FFFFFFFFFFFFFFFCh mov ds:dword_0[rax*4], 0 mov dword ptr ds:byte_4[rax*4], 1 cmp r9d, 1 jle short loc_1276 lea r8d, [r9+1] mov eax, 2 jmp short loc_1217 loc_120B: mov [rdi+rax*4], edx add rax, 1 cmp rax, r8 jz short loc_1276 loc_1217: mov [rdi+rax*4], eax mov esi, eax shr esi, 1Fh add esi, eax sar esi, 1 movsxd rsi, esi movsxd rdx, eax imul rcx, rdx, 55555556h shr rcx, 20h mov r10d, eax sar r10d, 1Fh sub ecx, r10d movsxd rcx, ecx mov ecx, [rdi+rcx*4] add ecx, [rdi+rsi*4] lea esi, [rax+3] test eax, eax cmovns esi, eax sar esi, 2 movsxd rsi, esi add ecx, [rdi+rsi*4] imul rdx, 66666667h sar rdx, 21h sub edx, r10d movsxd rdx, edx add ecx, [rdi+rdx*4] mov edx, ecx cmp ecx, eax jg short loc_120B mov edx, eax jmp short loc_120B loc_1276: movsxd r9, r9d mov eax, [rdi+r9*4] mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_128E leave retn loc_128E: call ___stack_chk_fail
long long func0(int a1) { signed long long v1; // rax void *v2; // rsp unsigned long long v3; // rax long long v4; // rax int v5; // edx _BYTE v8[3]; // [rsp+8h] [rbp-10h] BYREF char v9; // [rsp+Bh] [rbp-Dh] BYREF unsigned long long v10; // [rsp+10h] [rbp-8h] v10 = __readfsqword(0x28u); while ( v8 != &v8[-((4LL * (a1 + 1) + 15) & 0xFFFFFFFFFFFFF000LL)] ) ; v1 = (4 * ((_WORD)a1 + 1) + 15) & 0xFF0; v2 = alloca(v1); if ( ((4 * ((_WORD)a1 + 1) + 15) & 0xFF0) != 0 ) *(_QWORD *)&v8[v1 - 8] = *(_QWORD *)&v8[v1 - 8]; v3 = (unsigned long long)&v9 >> 2; *(_DWORD *)(4 * v3) = 0; *(_DWORD *)&byte_4[4 * v3] = 1; if ( a1 > 1 ) { v4 = 2LL; do { *(_DWORD *)&v8[4 * v4] = v4; v5 = *(_DWORD *)&v8[4 * ((int)v4 / 5)] + *(_DWORD *)&v8[4 * ((int)v4 / 4)] + *(_DWORD *)&v8[4 * ((int)v4 / 2)] + *(_DWORD *)&v8[4 * ((int)v4 / 3)]; if ( v5 <= (int)v4 ) v5 = v4; *(_DWORD *)&v8[4 * v4++] = v5; } while ( v4 != a1 + 1 ); } return *(unsigned int *)&v8[4 * a1]; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV R9D,EDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA EAX,[RDI + 0x1] CDQE LEA RAX,[0xf + RAX*0x4] MOV RCX,RAX AND RCX,-0x10 AND RAX,-0x1000 MOV RDX,RSP SUB RDX,RAX LAB_001011a7: CMP RSP,RDX JZ 0x001011be SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011a7 LAB_001011be: MOV RAX,RCX AND EAX,0xfff SUB RSP,RAX TEST RAX,RAX JZ 0x001011d4 OR qword ptr [RSP + RAX*0x1 + -0x8],0x0 LAB_001011d4: LEA RDI,[RSP + 0x3] MOV RAX,RDI SHR RAX,0x2 AND RDI,-0x4 MOV dword ptr [RAX*0x4],0x0 MOV dword ptr [0x4 + RAX*0x4],0x1 CMP R9D,0x1 JLE 0x00101276 LEA R8D,[R9 + 0x1] MOV EAX,0x2 JMP 0x00101217 LAB_0010120b: MOV dword ptr [RDI + RAX*0x4],EDX ADD RAX,0x1 CMP RAX,R8 JZ 0x00101276 LAB_00101217: MOV dword ptr [RDI + RAX*0x4],EAX MOV ESI,EAX SHR ESI,0x1f ADD ESI,EAX SAR ESI,0x1 MOVSXD RSI,ESI MOVSXD RDX,EAX IMUL RCX,RDX,0x55555556 SHR RCX,0x20 MOV R10D,EAX SAR R10D,0x1f SUB ECX,R10D MOVSXD RCX,ECX MOV ECX,dword ptr [RDI + RCX*0x4] ADD ECX,dword ptr [RDI + RSI*0x4] LEA ESI,[RAX + 0x3] TEST EAX,EAX CMOVNS ESI,EAX SAR ESI,0x2 MOVSXD RSI,ESI ADD ECX,dword ptr [RDI + RSI*0x4] IMUL RDX,RDX,0x66666667 SAR RDX,0x21 SUB EDX,R10D MOVSXD RDX,EDX ADD ECX,dword ptr [RDI + RDX*0x4] MOV EDX,ECX CMP ECX,EAX JG 0x0010120b MOV EDX,EAX JMP 0x0010120b LAB_00101276: MOVSXD R9,R9D MOV EAX,dword ptr [RDI + R9*0x4] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010128e LEAVE RET LAB_0010128e: CALL 0x00101060
int4 func0(int param_1) { long lVar1; int iVar2; ulong uVar3; int iVar4; int1 *puVar5; int iVar6; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar3 = (long)(param_1 + 1) * 4 + 0xf; for (puVar5 = auStack_18; puVar5 != auStack_18 + -(uVar3 & 0xfffffffffffff000); puVar5 = puVar5 + -0x1000) { *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); } uVar3 = (ulong)((uint)uVar3 & 0xff0); lVar1 = -uVar3; if (uVar3 != 0) { *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); } *(int4 *)(((ulong)(puVar5 + lVar1 + 3) >> 2) * 4) = 0; *(int4 *)(((ulong)(puVar5 + lVar1 + 3) >> 2) * 4 + 4) = 1; if (1 < param_1) { uVar3 = 2; do { iVar2 = (int)uVar3; *(int *)(puVar5 + uVar3 * 4 + lVar1) = iVar2; iVar6 = iVar2 + 3; if (-1 < iVar2) { iVar6 = iVar2; } iVar4 = *(int *)(puVar5 + (long)(iVar2 / 3) * 4 + lVar1) + *(int *)(puVar5 + (long)((int)(((uint)(uVar3 >> 0x1f) & 1) + iVar2) >> 1) * 4 + lVar1) + *(int *)(puVar5 + (long)(iVar6 >> 2) * 4 + lVar1) + *(int *)(puVar5 + (long)(iVar2 / 5) * 4 + lVar1); if (*(int *)(puVar5 + (long)(iVar2 / 3) * 4 + lVar1) + *(int *)(puVar5 + (long)((int)(((uint)(uVar3 >> 0x1f) & 1) + iVar2) >> 1) * 4 + lVar1) + *(int *)(puVar5 + (long)(iVar6 >> 2) * 4 + lVar1) + *(int *)(puVar5 + (long)(iVar2 / 5) * 4 + lVar1) <= iVar2) { iVar4 = iVar2; } *(int *)(puVar5 + uVar3 * 4 + lVar1) = iVar4; uVar3 = uVar3 + 1; } while (uVar3 != param_1 + 1); } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return *(int4 *)(puVar5 + (long)param_1 * 4 + lVar1); } /* WARNING: Subroutine does not return */ *(code **)(puVar5 + lVar1 + -8) = main; __stack_chk_fail(); }
5,462
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res[n + 1]; res[0] = 0; res[1] = 1; int i = 2; while (i < n + 1) { res[i] = i; int temp = res[i / 2] + res[i / 3] + res[i / 4] + res[i / 5]; if (temp > res[i]) res[i] = temp; i++; } return res[n]; }
int main() { assert(func0(60) == 106); assert(func0(10) == 12); assert(func0(2) == 2); return 0; }
O2
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea 0x1(%rdi),%eax mov %rsp,%rsi cltq lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rsi and $0xfffffffffffffff0,%rdx mov %rsi,%rax cmp %rax,%rsp je 1268 <func0+0x58> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1253 <func0+0x43> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 1338 <func0+0x128> movabs $0x100000000,%rcx lea 0x3(%rsp),%rsi mov %rsi,%rax and $0xfffffffffffffffc,%rsi shr $0x2,%rax mov %rcx,0x0(,%rax,4) cmp $0x1,%edi jle 131a <func0+0x10a> lea -0x2(%rdi),%r8d mov $0xaaaaaaab,%r10d movl $0x2,0x8(,%rax,4) mov $0xcccccccd,%r9d add $0x3,%r8 mov $0x3,%eax jmp 1315 <func0+0x105> nopw 0x0(%rax,%rax,1) mov %eax,%ecx mov %eax,%r11d mov %eax,(%rsi,%rax,4) mov %rcx,%rdx sar %r11d imul %r9,%rcx imul %r10,%rdx movslq %r11d,%r11 shr $0x22,%rcx shr $0x21,%rdx mov (%rsi,%rdx,4),%edx add (%rsi,%r11,4),%edx mov %eax,%r11d sar $0x2,%r11d movslq %r11d,%r11 add (%rsi,%r11,4),%edx add (%rsi,%rcx,4),%edx cmp %eax,%edx cmovle %eax,%edx mov %edx,(%rsi,%rax,4) add $0x1,%rax cmp %r8,%rax jne 12d0 <func0+0xc0> movslq %edi,%rdi mov (%rsi,%rdi,4),%eax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi jne 1343 <func0+0x133> leaveq retq nopl 0x0(%rax) orq $0x0,-0x8(%rsp,%rdx,1) jmpq 127a <func0+0x6a> callq 1060 <__stack_chk_fail@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp movsxd r10, edi lea edi, [r10+1] mov rbp, rsp sub rsp, 10h mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax movsxd rax, edi mov rcx, rsp lea rax, ds:0Fh[rax*4] mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_126A loc_1255: sub rsp, 1000h or [rsp+1010h+var_18], 0 cmp rsp, rcx jnz short loc_1255 loc_126A: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz loc_1320 loc_127C: lea rsi, [rsp+1010h+var_100D] mov edi, edi mov rdx, 100000000h mov r9d, 0AAAAAAABh mov rax, rsi mov r8d, 0CCCCCCCDh and rsi, 0FFFFFFFFFFFFFFFCh shr rax, 2 mov qword ptr ds:dword_0[rax*4], rdx mov edx, 2 cmp r10d, 1 jle short loc_130A nop word ptr [rax+rax+00000000h] loc_12C0: mov ecx, edx mov r11d, edx mov [rsi+rdx*4], edx mov rax, rcx sar r11d, 1 imul rcx, r8 imul rax, r9 movsxd r11, r11d shr rcx, 22h shr rax, 21h mov eax, [rsi+rax*4] add eax, [rsi+r11*4] mov r11d, edx sar r11d, 2 movsxd r11, r11d add eax, [rsi+r11*4] add eax, [rsi+rcx*4] cmp eax, edx cmovl eax, edx mov [rsi+rdx*4], eax add rdx, 1 cmp rdx, rdi jnz short loc_12C0 loc_130A: mov eax, [rsi+r10*4] mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_132B leave retn loc_1320: or [rsp+rdx+1010h+var_1018], 0 jmp loc_127C loc_132B: call ___stack_chk_fail
long long func0(int a1) { long long v1; // r10 int v2; // edi long long v3; // rdx _QWORD *v4; // rcx __int16 v5; // dx signed long long v6; // rdx void *v7; // rsp long long v8; // rdx int v9; // eax _QWORD v12[511]; // [rsp+8h] [rbp-1010h] BYREF _QWORD v13[2]; // [rsp+1008h] [rbp-10h] BYREF v1 = a1; v2 = a1 + 1; v13[1] = __readfsqword(0x28u); v3 = 4LL * v2 + 15; v4 = (_QWORD *)((char *)v13 - (v3 & 0xFFFFFFFFFFFFF000LL)); v5 = v3 & 0xFFF0; if ( v13 != v4 ) { while ( v12 != v4 ) ; } v6 = v5 & 0xFFF; v7 = alloca(v6); if ( v6 ) *(_QWORD *)((char *)&v12[-1] + v6) = *(_QWORD *)((char *)&v12[-1] + v6); v12[0] = 0x100000000LL; v8 = 2LL; if ( (int)v1 > 1 ) { do { *((_DWORD *)v12 + v8) = v8; v9 = *((_DWORD *)v12 + (unsigned int)v8 / 5uLL) + *((_DWORD *)v12 + ((int)v8 >> 2)) + *((_DWORD *)v12 + ((int)v8 >> 1)) + *((_DWORD *)v12 + (unsigned int)v8 / 3uLL); if ( v9 < (int)v8 ) v9 = v8; *((_DWORD *)v12 + v8++) = v9; } while ( v8 != v2 ); } return *((unsigned int *)v12 + v1); }
func0: ENDBR64 PUSH RBP MOVSXD R10,EDI LEA EDI,[R10 + 0x1] MOV RBP,RSP SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOVSXD RAX,EDI MOV RCX,RSP LEA RAX,[0xf + RAX*0x4] MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x0010126a LAB_00101255: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x00101255 LAB_0010126a: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x00101320 LAB_0010127c: LEA RSI,[RSP + 0x3] MOV EDI,EDI MOV RDX,0x100000000 MOV R9D,0xaaaaaaab MOV RAX,RSI MOV R8D,0xcccccccd AND RSI,-0x4 SHR RAX,0x2 MOV qword ptr [RAX*0x4],RDX MOV EDX,0x2 CMP R10D,0x1 JLE 0x0010130a NOP word ptr [RAX + RAX*0x1] LAB_001012c0: MOV ECX,EDX MOV R11D,EDX MOV dword ptr [RSI + RDX*0x4],EDX MOV RAX,RCX SAR R11D,0x1 IMUL RCX,R8 IMUL RAX,R9 MOVSXD R11,R11D SHR RCX,0x22 SHR RAX,0x21 MOV EAX,dword ptr [RSI + RAX*0x4] ADD EAX,dword ptr [RSI + R11*0x4] MOV R11D,EDX SAR R11D,0x2 MOVSXD R11,R11D ADD EAX,dword ptr [RSI + R11*0x4] ADD EAX,dword ptr [RSI + RCX*0x4] CMP EAX,EDX CMOVL EAX,EDX MOV dword ptr [RSI + RDX*0x4],EAX ADD RDX,0x1 CMP RDX,RDI JNZ 0x001012c0 LAB_0010130a: MOV EAX,dword ptr [RSI + R10*0x4] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010132b LEAVE RET LAB_00101320: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x0010127c LAB_0010132b: CALL 0x00101060
int4 func0(int param_1) { long lVar1; int1 *puVar2; int iVar3; int iVar4; ulong uVar5; int1 *puVar6; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; int1 *puVar7; puVar6 = auStack_18; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar5 = (long)(int)(param_1 + 1U) * 4 + 0xf; puVar7 = auStack_18; puVar2 = auStack_18; while (puVar7 != auStack_18 + -(uVar5 & 0xfffffffffffff000)) { puVar6 = puVar2 + -0x1000; *(int8 *)(puVar2 + -8) = *(int8 *)(puVar2 + -8); puVar7 = puVar2 + -0x1000; puVar2 = puVar2 + -0x1000; } uVar5 = (ulong)((uint)uVar5 & 0xff0); lVar1 = -uVar5; if (uVar5 != 0) { *(int8 *)(puVar6 + -8) = *(int8 *)(puVar6 + -8); } *(int8 *)(puVar6 + lVar1) = 0x100000000; uVar5 = 2; if (1 < param_1) { do { iVar4 = (int)uVar5; *(int *)(puVar6 + uVar5 * 4 + lVar1) = iVar4; iVar3 = *(int *)(puVar6 + ((uVar5 & 0xffffffff) / 3) * 4 + lVar1) + *(int *)(puVar6 + (long)(iVar4 >> 1) * 4 + lVar1) + *(int *)(puVar6 + (long)(iVar4 >> 2) * 4 + lVar1) + *(int *)(puVar6 + ((uVar5 & 0xffffffff) / 5) * 4 + lVar1); if (iVar3 < iVar4) { iVar3 = iVar4; } *(int *)(puVar6 + uVar5 * 4 + lVar1) = iVar3; uVar5 = uVar5 + 1; } while (uVar5 != param_1 + 1U); } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return *(int4 *)(puVar6 + (long)param_1 * 4 + lVar1); } /* WARNING: Subroutine does not return */ *(code **)(puVar6 + lVar1 + -8) = _fini; __stack_chk_fail(); }
5,463
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { int res[n + 1]; res[0] = 0; res[1] = 1; int i = 2; while (i < n + 1) { res[i] = i; int temp = res[i / 2] + res[i / 3] + res[i / 4] + res[i / 5]; if (temp > res[i]) res[i] = temp; i++; } return res[n]; }
int main() { assert(func0(60) == 106); assert(func0(10) == 12); assert(func0(2) == 2); return 0; }
O3
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea 0x1(%rdi),%eax mov %rsp,%rsi cltq lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rsi and $0xfffffffffffffff0,%rdx mov %rsi,%rax cmp %rax,%rsp je 1268 <func0+0x58> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1253 <func0+0x43> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 1338 <func0+0x128> movabs $0x100000000,%rcx lea 0x3(%rsp),%rsi mov %rsi,%rax and $0xfffffffffffffffc,%rsi shr $0x2,%rax mov %rcx,0x0(,%rax,4) cmp $0x1,%edi jle 131a <func0+0x10a> movl $0x2,0x8(,%rax,4) cmp $0x2,%edi je 131a <func0+0x10a> lea -0x3(%rdi),%r8d mov $0x3,%eax mov $0xaaaaaaab,%r10d mov $0xcccccccd,%r9d add $0x4,%r8 nopw 0x0(%rax,%rax,1) mov %eax,%ecx mov %eax,%r11d mov %eax,(%rsi,%rax,4) mov %rcx,%rdx sar %r11d imul %r9,%rcx imul %r10,%rdx movslq %r11d,%r11 shr $0x22,%rcx shr $0x21,%rdx mov (%rsi,%rdx,4),%edx add (%rsi,%r11,4),%edx mov %eax,%r11d sar $0x2,%r11d movslq %r11d,%r11 add (%rsi,%r11,4),%edx add (%rsi,%rcx,4),%edx cmp %eax,%edx cmovle %eax,%edx mov %edx,(%rsi,%rax,4) add $0x1,%rax cmp %rax,%r8 jne 12d0 <func0+0xc0> movslq %edi,%rdi mov (%rsi,%rdi,4),%eax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi jne 1343 <func0+0x133> leaveq retq nopl 0x0(%rax) orq $0x0,-0x8(%rsp,%rdx,1) jmpq 127a <func0+0x6a> callq 1060 <__stack_chk_fail@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp movsxd r11, edi lea r8d, [r11+1] mov rbp, rsp sub rsp, 10h mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax movsxd rax, r8d mov rcx, rsp lea rax, ds:0Fh[rax*4] mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_126A loc_1255: sub rsp, 1000h or [rsp+1010h+var_18], 0 cmp rsp, rcx jnz short loc_1255 loc_126A: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz loc_1320 loc_127C: lea rsi, [rsp+1010h+var_100D] mov rdx, cs:qword_2058 mov r8d, r8d mov r10d, 0AAAAAAABh mov rax, rsi mov r9d, 0CCCCCCCDh and rsi, 0FFFFFFFFFFFFFFFCh shr rax, 2 mov qword ptr ds:dword_0[rax*4], rdx mov eax, 2 cmp r11d, 1 jle short loc_12FB nop dword ptr [rax] loc_12B8: mov ecx, eax mov edi, eax mov [rsi+rax*4], eax mov rdx, rcx sar edi, 1 imul rcx, r9 imul rdx, r10 movsxd rdi, edi shr rcx, 22h shr rdx, 21h mov edx, [rsi+rdx*4] add edx, [rsi+rdi*4] mov edi, eax sar edi, 2 movsxd rdi, edi add edx, [rsi+rdi*4] add edx, [rsi+rcx*4] cmp edx, eax jg short loc_1310 mov [rsi+rax*4], eax add rax, 1 cmp r8, rax jnz short loc_12B8 loc_12FB: mov eax, [rsi+r11*4] mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_132B leave retn loc_1310: mov [rsi+rax*4], edx add rax, 1 cmp r8, rax jnz short loc_12B8 jmp short loc_12FB loc_1320: or [rsp+rdx+1010h+var_1018], 0 jmp loc_127C loc_132B: call ___stack_chk_fail
long long func0(int a1) { int v1; // r8d long long v2; // rdx _QWORD *v3; // rcx __int16 v4; // dx signed long long v5; // rdx void *v6; // rsp long long v7; // rax int v8; // edx _QWORD v11[511]; // [rsp+8h] [rbp-1010h] BYREF _QWORD v12[2]; // [rsp+1008h] [rbp-10h] BYREF v1 = a1 + 1; v12[1] = __readfsqword(0x28u); v2 = 4LL * (a1 + 1) + 15; v3 = (_QWORD *)((char *)v12 - (v2 & 0xFFFFFFFFFFFFF000LL)); v4 = v2 & 0xFFF0; if ( v12 != v3 ) { while ( v11 != v3 ) ; } v5 = v4 & 0xFFF; v6 = alloca(v5); if ( v5 ) *(_QWORD *)((char *)&v11[-1] + v5) = *(_QWORD *)((char *)&v11[-1] + v5); v11[0] = 0x100000000LL; v7 = 2LL; if ( a1 > 1 ) { do { while ( 1 ) { *((_DWORD *)v11 + v7) = v7; v8 = *((_DWORD *)v11 + (unsigned int)v7 / 5uLL) + *((_DWORD *)v11 + ((int)v7 >> 2)) + *((_DWORD *)v11 + ((int)v7 >> 1)) + *((_DWORD *)v11 + (unsigned int)v7 / 3uLL); if ( v8 > (int)v7 ) break; *((_DWORD *)v11 + v7) = v7; if ( v1 == ++v7 ) return *((unsigned int *)v11 + a1); } *((_DWORD *)v11 + v7++) = v8; } while ( v1 != v7 ); } return *((unsigned int *)v11 + a1); }
func0: ENDBR64 PUSH RBP MOVSXD R11,EDI LEA R8D,[R11 + 0x1] MOV RBP,RSP SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOVSXD RAX,R8D MOV RCX,RSP LEA RAX,[0xf + RAX*0x4] MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x0010126a LAB_00101255: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x00101255 LAB_0010126a: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x00101320 LAB_0010127c: LEA RSI,[RSP + 0x3] MOV RDX,qword ptr [0x00102058] MOV R8D,R8D MOV R10D,0xaaaaaaab MOV RAX,RSI MOV R9D,0xcccccccd AND RSI,-0x4 SHR RAX,0x2 MOV qword ptr [RAX*0x4],RDX MOV EAX,0x2 CMP R11D,0x1 JLE 0x001012fb NOP dword ptr [RAX] LAB_001012b8: MOV ECX,EAX MOV EDI,EAX MOV dword ptr [RSI + RAX*0x4],EAX MOV RDX,RCX SAR EDI,0x1 IMUL RCX,R9 IMUL RDX,R10 MOVSXD RDI,EDI SHR RCX,0x22 SHR RDX,0x21 MOV EDX,dword ptr [RSI + RDX*0x4] ADD EDX,dword ptr [RSI + RDI*0x4] MOV EDI,EAX SAR EDI,0x2 MOVSXD RDI,EDI ADD EDX,dword ptr [RSI + RDI*0x4] ADD EDX,dword ptr [RSI + RCX*0x4] CMP EDX,EAX JG 0x00101310 MOV dword ptr [RSI + RAX*0x4],EAX ADD RAX,0x1 CMP R8,RAX JNZ 0x001012b8 LAB_001012fb: MOV EAX,dword ptr [RSI + R11*0x4] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010132b LEAVE RET LAB_00101310: MOV dword ptr [RSI + RAX*0x4],EDX ADD RAX,0x1 CMP R8,RAX JNZ 0x001012b8 JMP 0x001012fb LAB_00101320: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x0010127c LAB_0010132b: CALL 0x00101060
int4 func0(int param_1) { long lVar1; int *puVar2; int iVar3; ulong uVar4; int iVar5; int *puVar6; uint uVar8; long in_FS_OFFSET; int auStack_18 [8]; long local_10; int *puVar7; uVar8 = param_1 + 1; puVar6 = auStack_18; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar4 = (long)(int)uVar8 * 4 + 0xf; puVar7 = auStack_18; puVar2 = auStack_18; while (puVar7 != auStack_18 + -(uVar4 & 0xfffffffffffff000)) { puVar6 = puVar2 + -0x1000; *(int8 *)(puVar2 + -8) = *(int8 *)(puVar2 + -8); puVar7 = puVar2 + -0x1000; puVar2 = puVar2 + -0x1000; } uVar4 = (ulong)((uint)uVar4 & 0xff0); lVar1 = -uVar4; if (uVar4 != 0) { *(int8 *)(puVar6 + -8) = *(int8 *)(puVar6 + -8); } *(int8 *)(puVar6 + lVar1) = DAT_00102058; uVar4 = 2; if (1 < param_1) { do { while( true ) { iVar3 = (int)uVar4; *(int *)(puVar6 + uVar4 * 4 + lVar1) = iVar3; iVar5 = *(int *)(puVar6 + ((uVar4 & 0xffffffff) / 3) * 4 + lVar1) + *(int *)(puVar6 + (long)(iVar3 >> 1) * 4 + lVar1) + *(int *)(puVar6 + (long)(iVar3 >> 2) * 4 + lVar1) + *(int *)(puVar6 + ((uVar4 & 0xffffffff) / 5) * 4 + lVar1); if (iVar3 < iVar5) break; *(int *)(puVar6 + uVar4 * 4 + lVar1) = iVar3; uVar4 = uVar4 + 1; if (uVar8 == uVar4) goto LAB_001012fb; } *(int *)(puVar6 + uVar4 * 4 + lVar1) = iVar5; uVar4 = uVar4 + 1; } while (uVar8 != uVar4); } LAB_001012fb: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return *(int4 *)(puVar6 + (long)param_1 * 4 + lVar1); } /* WARNING: Subroutine does not return */ *(code **)(puVar6 + lVar1 + -8) = _fini; __stack_chk_fail(); }
5,464
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct { int length; int *list; } MaxLengthListResult;
MaxLengthListResult func0(int **input_list, int list_size, int *sublist_sizes) { int max_length = 0; int *max_list = NULL; for (int i = 0; i < list_size; i++) { if (sublist_sizes[i] > max_length) { max_length = sublist_sizes[i]; max_list = input_list[i]; } } MaxLengthListResult result = {max_length, max_list}; return result; }
int main() { int list1[] = {0}; int list2[] = {1, 3}; int list3[] = {5, 7}; int list4[] = {9, 11}; int list5[] = {13, 15, 17}; int *input1[] = {list1, list2, list3, list4, list5}; int sizes1[] = {1, 2, 2, 2, 3}; MaxLengthListResult result1 = func0(input1, 5, sizes1); assert(result1.length == 3 && result1.list[0] == 13 && result1.list[1] == 15 && result1.list[2] == 17); int list6[] = {1, 2, 3, 4, 5}; int list7[] = {1, 2, 3, 4}; int list8[] = {1, 2, 3}; int list9[] = {1, 2}; int list10[] = {1}; int *input2[] = {list6, list7, list8, list9, list10}; int sizes2[] = {5, 4, 3, 2, 1}; MaxLengthListResult result2 = func0(input2, 5, sizes2); assert(result2.length == 5 && result2.list[0] == 1 && result2.list[1] == 2 && result2.list[2] == 3 && result2.list[3] == 4 && result2.list[4] == 5); int list11[] = {3, 4, 5}; int list12[] = {6, 7, 8, 9}; int list13[] = {10, 11, 12}; int *input3[] = {list11, list12, list13}; int sizes3[] = {3, 4, 3}; MaxLengthListResult result3 = func0(input3, 3, sizes3); assert(result3.length == 4 && result3.list[0] == 6 && result3.list[1] == 7 && result3.list[2] == 8 && result3.list[3] == 9); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx mov %rdi,-0x30(%rbp) mov %esi,-0x34(%rbp) mov %rdx,-0x40(%rbp) movl $0x0,-0x28(%rbp) movq $0x0,-0x20(%rbp) movl $0x0,-0x24(%rbp) jmp 11e8 <func0+0x7f> mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x40(%rbp),%rax add %rdx,%rax mov (%rax),%eax cmp %eax,-0x28(%rbp) jge 11e4 <func0+0x7b> mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x40(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x28(%rbp) mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov %rax,-0x20(%rbp) addl $0x1,-0x24(%rbp) mov -0x24(%rbp),%eax cmp -0x34(%rbp),%eax jl 1195 <func0+0x2c> mov -0x28(%rbp),%eax mov %eax,-0x18(%rbp) mov -0x20(%rbp),%rax mov %rax,-0x10(%rbp) mov -0x18(%rbp),%rax mov -0x10(%rbp),%rdx mov %rax,%rcx mov %rdx,%rbx mov %ecx,%eax pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx mov [rbp+var_38], rdi mov [rbp+var_3C], esi mov [rbp+var_48], rdx mov [rbp+var_30], 0 mov [rbp+var_28], 0 mov [rbp+var_2C], 0 jmp short loc_11E8 loc_1195: mov eax, [rbp+var_2C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_48] add rax, rdx mov eax, [rax] cmp [rbp+var_30], eax jge short loc_11E4 mov eax, [rbp+var_2C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_48] add rax, rdx mov eax, [rax] mov [rbp+var_30], eax mov eax, [rbp+var_2C] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_38] add rax, rdx mov rax, [rax] mov [rbp+var_28], rax loc_11E4: add [rbp+var_2C], 1 loc_11E8: mov eax, [rbp+var_2C] cmp eax, [rbp+var_3C] jl short loc_1195 mov eax, [rbp+var_30] mov dword ptr [rbp+var_20], eax mov rax, [rbp+var_28] mov [rbp+var_18], rax mov rax, [rbp+var_20] mov rdx, [rbp+var_18] mov rsi, rax mov rdi, rdx mov rcx, rax mov rbx, rdx mov eax, esi mov rdx, rbx mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, int a2, long long a3) { unsigned int v4; // [rsp+18h] [rbp-30h] int i; // [rsp+1Ch] [rbp-2Ch] v4 = 0; for ( i = 0; i < a2; ++i ) { if ( (signed int)v4 < *(_DWORD *)(4LL * i + a3) ) v4 = *(_DWORD *)(4LL * i + a3); } return v4; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX MOV qword ptr [RBP + -0x38],RDI MOV dword ptr [RBP + -0x3c],ESI MOV qword ptr [RBP + -0x48],RDX MOV dword ptr [RBP + -0x30],0x0 MOV qword ptr [RBP + -0x28],0x0 MOV dword ptr [RBP + -0x2c],0x0 JMP 0x001011e8 LAB_00101195: MOV EAX,dword ptr [RBP + -0x2c] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x48] ADD RAX,RDX MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0x30],EAX JGE 0x001011e4 MOV EAX,dword ptr [RBP + -0x2c] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x48] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x30],EAX MOV EAX,dword ptr [RBP + -0x2c] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV qword ptr [RBP + -0x28],RAX LAB_001011e4: ADD dword ptr [RBP + -0x2c],0x1 LAB_001011e8: MOV EAX,dword ptr [RBP + -0x2c] CMP EAX,dword ptr [RBP + -0x3c] JL 0x00101195 MOV EAX,dword ptr [RBP + -0x30] MOV dword ptr [RBP + -0x20],EAX MOV RAX,qword ptr [RBP + -0x28] MOV qword ptr [RBP + -0x18],RAX MOV RAX,qword ptr [RBP + -0x20] MOV RDX,qword ptr [RBP + -0x18] MOV RSI,RAX MOV RDI,RDX MOV RCX,RAX MOV RBX,RDX MOV EAX,ESI MOV RDX,RBX MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int [16] func0(long param_1,int param_2,long param_3) { int auVar1 [16]; int4 local_38; int4 local_34; int8 local_30; local_38 = 0; local_30 = 0; for (local_34 = 0; local_34 < param_2; local_34 = local_34 + 1) { if ((int)local_38 < *(int *)(param_3 + (long)local_34 * 4)) { local_38 = *(uint *)(param_3 + (long)local_34 * 4); local_30 = *(int8 *)(param_1 + (long)local_34 * 8); } } auVar1._4_4_ = 0; auVar1._0_4_ = local_38; auVar1._8_8_ = local_30; return auVar1; }
5,465
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct { int length; int *list; } MaxLengthListResult;
MaxLengthListResult func0(int **input_list, int list_size, int *sublist_sizes) { int max_length = 0; int *max_list = NULL; for (int i = 0; i < list_size; i++) { if (sublist_sizes[i] > max_length) { max_length = sublist_sizes[i]; max_list = input_list[i]; } } MaxLengthListResult result = {max_length, max_list}; return result; }
int main() { int list1[] = {0}; int list2[] = {1, 3}; int list3[] = {5, 7}; int list4[] = {9, 11}; int list5[] = {13, 15, 17}; int *input1[] = {list1, list2, list3, list4, list5}; int sizes1[] = {1, 2, 2, 2, 3}; MaxLengthListResult result1 = func0(input1, 5, sizes1); assert(result1.length == 3 && result1.list[0] == 13 && result1.list[1] == 15 && result1.list[2] == 17); int list6[] = {1, 2, 3, 4, 5}; int list7[] = {1, 2, 3, 4}; int list8[] = {1, 2, 3}; int list9[] = {1, 2}; int list10[] = {1}; int *input2[] = {list6, list7, list8, list9, list10}; int sizes2[] = {5, 4, 3, 2, 1}; MaxLengthListResult result2 = func0(input2, 5, sizes2); assert(result2.length == 5 && result2.list[0] == 1 && result2.list[1] == 2 && result2.list[2] == 3 && result2.list[3] == 4 && result2.list[4] == 5); int list11[] = {3, 4, 5}; int list12[] = {6, 7, 8, 9}; int list13[] = {10, 11, 12}; int *input3[] = {list11, list12, list13}; int sizes3[] = {3, 4, 3}; MaxLengthListResult result3 = func0(input3, 3, sizes3); assert(result3.length == 4 && result3.list[0] == 6 && result3.list[1] == 7 && result3.list[2] == 8 && result3.list[3] == 9); return 0; }
O1
c
func0: endbr64 test %esi,%esi jle 11a2 <func0+0x39> lea -0x1(%rsi),%r8d mov $0x0,%ecx mov $0x0,%r9d mov $0x0,%eax jmp 1193 <func0+0x2a> lea 0x1(%rcx),%rsi cmp %r8,%rcx je 11ad <func0+0x44> mov %rsi,%rcx mov (%rdx,%rcx,4),%esi cmp %eax,%esi jle 1187 <func0+0x1e> mov (%rdi,%rcx,8),%r9 mov %esi,%eax jmp 1187 <func0+0x1e> mov $0x0,%r9d mov $0x0,%eax mov %eax,%eax mov %r9,%rdx retq
func0: endbr64 test esi, esi jle short loc_11A0 mov esi, esi mov ecx, 0 mov r9d, 0 mov eax, 0 jmp short loc_118E loc_1185: add rcx, 1 cmp rcx, rsi jz short loc_11AB loc_118E: mov r8d, [rdx+rcx*4] cmp r8d, eax jle short loc_1185 mov r9, [rdi+rcx*8] mov eax, r8d jmp short loc_1185 loc_11A0: mov r9d, 0 mov eax, 0 loc_11AB: mov rdx, r9 retn
long long func0(long long a1, int a2, long long a3) { long long v3; // rcx long long result; // rax int v5; // r8d if ( a2 <= 0 ) return 0LL; v3 = 0LL; result = 0LL; do { v5 = *(_DWORD *)(a3 + 4 * v3); if ( v5 > (int)result ) result = (unsigned int)v5; ++v3; } while ( v3 != a2 ); return result; }
func0: ENDBR64 TEST ESI,ESI JLE 0x001011a0 MOV ESI,ESI MOV ECX,0x0 MOV R9D,0x0 MOV EAX,0x0 JMP 0x0010118e LAB_00101185: ADD RCX,0x1 CMP RCX,RSI JZ 0x001011ab LAB_0010118e: MOV R8D,dword ptr [RDX + RCX*0x4] CMP R8D,EAX JLE 0x00101185 MOV R9,qword ptr [RDI + RCX*0x8] MOV EAX,R8D JMP 0x00101185 LAB_001011a0: MOV R9D,0x0 MOV EAX,0x0 LAB_001011ab: MOV RDX,R9 RET
int1 [16] func0(long param_1,uint param_2,long param_3) { uint uVar1; ulong uVar2; ulong uVar3; int8 uVar4; int1 auVar5 [16]; if ((int)param_2 < 1) { uVar4 = 0; uVar2 = 0; } else { uVar3 = 0; uVar4 = 0; uVar2 = 0; do { uVar1 = *(uint *)(param_3 + uVar3 * 4); if ((int)uVar2 < (int)uVar1) { uVar4 = *(int8 *)(param_1 + uVar3 * 8); uVar2 = (ulong)uVar1; } uVar3 = uVar3 + 1; } while (uVar3 != param_2); } auVar5._8_8_ = uVar4; auVar5._0_8_ = uVar2; return auVar5; }
5,466
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct { int length; int *list; } MaxLengthListResult;
MaxLengthListResult func0(int **input_list, int list_size, int *sublist_sizes) { int max_length = 0; int *max_list = NULL; for (int i = 0; i < list_size; i++) { if (sublist_sizes[i] > max_length) { max_length = sublist_sizes[i]; max_list = input_list[i]; } } MaxLengthListResult result = {max_length, max_list}; return result; }
int main() { int list1[] = {0}; int list2[] = {1, 3}; int list3[] = {5, 7}; int list4[] = {9, 11}; int list5[] = {13, 15, 17}; int *input1[] = {list1, list2, list3, list4, list5}; int sizes1[] = {1, 2, 2, 2, 3}; MaxLengthListResult result1 = func0(input1, 5, sizes1); assert(result1.length == 3 && result1.list[0] == 13 && result1.list[1] == 15 && result1.list[2] == 17); int list6[] = {1, 2, 3, 4, 5}; int list7[] = {1, 2, 3, 4}; int list8[] = {1, 2, 3}; int list9[] = {1, 2}; int list10[] = {1}; int *input2[] = {list6, list7, list8, list9, list10}; int sizes2[] = {5, 4, 3, 2, 1}; MaxLengthListResult result2 = func0(input2, 5, sizes2); assert(result2.length == 5 && result2.list[0] == 1 && result2.list[1] == 2 && result2.list[2] == 3 && result2.list[3] == 4 && result2.list[4] == 5); int list11[] = {3, 4, 5}; int list12[] = {6, 7, 8, 9}; int list13[] = {10, 11, 12}; int *input3[] = {list11, list12, list13}; int sizes3[] = {3, 4, 3}; MaxLengthListResult result3 = func0(input3, 3, sizes3); assert(result3.length == 4 && result3.list[0] == 6 && result3.list[1] == 7 && result3.list[2] == 8 && result3.list[3] == 9); return 0; }
O2
c
func0: endbr64 test %esi,%esi jle 1178 <func0+0x38> lea -0x1(%rsi),%r8d xor %ecx,%ecx xor %r9d,%r9d xor %eax,%eax jmp 115b <func0+0x1b> nopl (%rax) mov %rsi,%rcx mov (%rdx,%rcx,4),%esi cmp %eax,%esi jle 1168 <func0+0x28> mov (%rdi,%rcx,8),%r9 mov %esi,%eax lea 0x1(%rcx),%rsi cmp %r8,%rcx jne 1158 <func0+0x18> mov %r9,%rdx retq nopl (%rax) xor %r9d,%r9d xor %eax,%eax mov %r9,%rdx retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
func0: endbr64 test esi, esi jle short loc_1518 movsxd rsi, esi xor ecx, ecx xor r9d, r9d xor eax, eax nop word ptr [rax+rax+00h] loc_14F8: mov r8d, [rdx+rcx*4] cmp r8d, eax jle short loc_1508 mov r9, [rdi+rcx*8] mov eax, r8d loc_1508: add rcx, 1 cmp rcx, rsi jnz short loc_14F8 mov rdx, r9 retn loc_1518: xor r9d, r9d xor eax, eax mov rdx, r9 retn
long long func0(long long a1, int a2, long long a3) { long long v3; // rcx long long result; // rax int v5; // r8d if ( a2 <= 0 ) return 0LL; v3 = 0LL; result = 0LL; do { v5 = *(_DWORD *)(a3 + 4 * v3); if ( v5 > (int)result ) result = (unsigned int)v5; ++v3; } while ( v3 != a2 ); return result; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101518 MOVSXD RSI,ESI XOR ECX,ECX XOR R9D,R9D XOR EAX,EAX NOP word ptr [RAX + RAX*0x1] LAB_001014f8: MOV R8D,dword ptr [RDX + RCX*0x4] CMP R8D,EAX JLE 0x00101508 MOV R9,qword ptr [RDI + RCX*0x8] MOV EAX,R8D LAB_00101508: ADD RCX,0x1 CMP RCX,RSI JNZ 0x001014f8 MOV RDX,R9 RET LAB_00101518: XOR R9D,R9D XOR EAX,EAX MOV RDX,R9 RET
int1 [16] func0(long param_1,int param_2,long param_3) { uint uVar1; ulong uVar2; long lVar3; int8 uVar4; int1 auVar5 [16]; if (0 < param_2) { lVar3 = 0; uVar4 = 0; uVar2 = 0; do { uVar1 = *(uint *)(param_3 + lVar3 * 4); if ((int)uVar2 < (int)uVar1) { uVar4 = *(int8 *)(param_1 + lVar3 * 8); uVar2 = (ulong)uVar1; } lVar3 = lVar3 + 1; } while (lVar3 != param_2); auVar5._8_8_ = uVar4; auVar5._0_8_ = uVar2; return auVar5; } return ZEXT816(0); }
5,467
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> typedef struct { int length; int *list; } MaxLengthListResult;
MaxLengthListResult func0(int **input_list, int list_size, int *sublist_sizes) { int max_length = 0; int *max_list = NULL; for (int i = 0; i < list_size; i++) { if (sublist_sizes[i] > max_length) { max_length = sublist_sizes[i]; max_list = input_list[i]; } } MaxLengthListResult result = {max_length, max_list}; return result; }
int main() { int list1[] = {0}; int list2[] = {1, 3}; int list3[] = {5, 7}; int list4[] = {9, 11}; int list5[] = {13, 15, 17}; int *input1[] = {list1, list2, list3, list4, list5}; int sizes1[] = {1, 2, 2, 2, 3}; MaxLengthListResult result1 = func0(input1, 5, sizes1); assert(result1.length == 3 && result1.list[0] == 13 && result1.list[1] == 15 && result1.list[2] == 17); int list6[] = {1, 2, 3, 4, 5}; int list7[] = {1, 2, 3, 4}; int list8[] = {1, 2, 3}; int list9[] = {1, 2}; int list10[] = {1}; int *input2[] = {list6, list7, list8, list9, list10}; int sizes2[] = {5, 4, 3, 2, 1}; MaxLengthListResult result2 = func0(input2, 5, sizes2); assert(result2.length == 5 && result2.list[0] == 1 && result2.list[1] == 2 && result2.list[2] == 3 && result2.list[3] == 4 && result2.list[4] == 5); int list11[] = {3, 4, 5}; int list12[] = {6, 7, 8, 9}; int list13[] = {10, 11, 12}; int *input3[] = {list11, list12, list13}; int sizes3[] = {3, 4, 3}; MaxLengthListResult result3 = func0(input3, 3, sizes3); assert(result3.length == 4 && result3.list[0] == 6 && result3.list[1] == 7 && result3.list[2] == 8 && result3.list[3] == 9); return 0; }
O3
c
func0: endbr64 test %esi,%esi jle 1468 <func0+0x38> lea -0x1(%rsi),%r8d xor %ecx,%ecx xor %r9d,%r9d xor %eax,%eax jmp 144b <func0+0x1b> nopl (%rax) mov %rsi,%rcx mov (%rdx,%rcx,4),%esi cmp %eax,%esi jle 1458 <func0+0x28> mov (%rdi,%rcx,8),%r9 mov %esi,%eax lea 0x1(%rcx),%rsi cmp %r8,%rcx jne 1448 <func0+0x18> mov %r9,%rdx retq nopl (%rax) xor %r9d,%r9d xor %eax,%eax mov %r9,%rdx retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
func0: endbr64 test esi, esi jle short loc_1178 movsxd rsi, esi xor ecx, ecx xor r9d, r9d xor eax, eax nop word ptr [rax+rax+00h] loc_1158: mov r8d, [rdx+rcx*4] cmp r8d, eax jle short loc_1168 mov r9, [rdi+rcx*8] mov eax, r8d loc_1168: add rcx, 1 cmp rsi, rcx jnz short loc_1158 mov rdx, r9 retn loc_1178: xor r9d, r9d xor eax, eax mov rdx, r9 retn
long long func0(long long a1, int a2, long long a3) { long long v3; // rcx long long result; // rax int v5; // r8d if ( a2 <= 0 ) return 0LL; v3 = 0LL; result = 0LL; do { v5 = *(_DWORD *)(a3 + 4 * v3); if ( v5 > (int)result ) result = (unsigned int)v5; ++v3; } while ( a2 != v3 ); return result; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101178 MOVSXD RSI,ESI XOR ECX,ECX XOR R9D,R9D XOR EAX,EAX NOP word ptr [RAX + RAX*0x1] LAB_00101158: MOV R8D,dword ptr [RDX + RCX*0x4] CMP R8D,EAX JLE 0x00101168 MOV R9,qword ptr [RDI + RCX*0x8] MOV EAX,R8D LAB_00101168: ADD RCX,0x1 CMP RSI,RCX JNZ 0x00101158 MOV RDX,R9 RET LAB_00101178: XOR R9D,R9D XOR EAX,EAX MOV RDX,R9 RET
int [16] func0(long param_1,int param_2,long param_3) { uint uVar1; ulong uVar2; long lVar3; int8 uVar4; int auVar5 [16]; if (0 < param_2) { lVar3 = 0; uVar4 = 0; uVar2 = 0; do { uVar1 = *(uint *)(param_3 + lVar3 * 4); if ((int)uVar2 < (int)uVar1) { uVar4 = *(int8 *)(param_1 + lVar3 * 8); uVar2 = (ulong)uVar1; } lVar3 = lVar3 + 1; } while (param_2 != lVar3); auVar5._8_8_ = uVar4; auVar5._0_8_ = uVar2; return auVar5; } return ZEXT816(0); }
5,468
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int test_tup[], int size) { bool res = true; int temp[size]; int temp_size = 0; for (int i = 0; i < size; i++) { int ele = test_tup[i]; bool found = false; for (int j = 0; j < temp_size; j++) { if (temp[j] == ele) { found = true; break; } } if (found) { res = false; break; } temp[temp_size++] = ele; } return res; }
int main() { int test1[] = {1, 4, 5, 6, 1, 4}; int test2[] = {1, 4, 5, 6}; int test3[] = {2, 3, 4, 5, 6}; assert(func0(test1, sizeof(test1)/sizeof(test1[0])) == false); assert(func0(test2, sizeof(test2)/sizeof(test2[0])) == true); assert(func0(test3, sizeof(test3)/sizeof(test3[0])) == true); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x48,%rsp mov %rdi,-0x48(%rbp) mov %esi,-0x4c(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov %rsp,%rax mov %rax,%rsi movb $0x1,-0x39(%rbp) mov -0x4c(%rbp),%eax movslq %eax,%rdx sub $0x1,%rdx mov %rdx,-0x28(%rbp) movslq %eax,%rdx mov %rdx,%r8 mov $0x0,%r9d movslq %eax,%rdx mov %rdx,%rcx mov $0x0,%ebx cltq lea 0x0(,%rax,4),%rdx mov $0x10,%eax sub $0x1,%rax add %rdx,%rax mov $0x10,%edi mov $0x0,%edx div %rdi imul $0x10,%rax,%rax mov %rax,%rdx and $0xfffffffffffff000,%rdx mov %rsp,%rbx sub %rdx,%rbx mov %rbx,%rdx cmp %rdx,%rsp je 120c <func0+0xa3> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 11f5 <func0+0x8c> mov %rax,%rdx and $0xfff,%edx sub %rdx,%rsp mov %rax,%rdx and $0xfff,%edx test %rdx,%rdx je 1236 <func0+0xcd> and $0xfff,%eax sub $0x8,%rax add %rsp,%rax orq $0x0,(%rax) mov %rsp,%rax add $0x3,%rax shr $0x2,%rax shl $0x2,%rax mov %rax,-0x20(%rbp) movl $0x0,-0x30(%rbp) movl $0x0,-0x34(%rbp) jmp 12c8 <func0+0x15f> mov -0x34(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x48(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x2c(%rbp) movb $0x0,-0x3a(%rbp) movl $0x0,-0x38(%rbp) jmp 129b <func0+0x132> mov -0x20(%rbp),%rax mov -0x38(%rbp),%edx movslq %edx,%rdx mov (%rax,%rdx,4),%eax cmp %eax,-0x2c(%rbp) jne 1297 <func0+0x12e> movb $0x1,-0x3a(%rbp) jmp 12a3 <func0+0x13a> addl $0x1,-0x38(%rbp) mov -0x38(%rbp),%eax cmp -0x30(%rbp),%eax jl 127f <func0+0x116> cmpb $0x0,-0x3a(%rbp) je 12af <func0+0x146> movb $0x0,-0x39(%rbp) jmp 12d0 <func0+0x167> mov -0x30(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x30(%rbp) mov -0x20(%rbp),%rdx cltq mov -0x2c(%rbp),%ecx mov %ecx,(%rdx,%rax,4) addl $0x1,-0x34(%rbp) mov -0x34(%rbp),%eax cmp -0x4c(%rbp),%eax jl 1259 <func0+0xf0> movzbl -0x39(%rbp),%eax mov %rsi,%rsp mov -0x18(%rbp),%rdi xor %fs:0x28,%rdi je 12eb <func0+0x182> callq 1060 <__stack_chk_fail@plt> mov -0x8(%rbp),%rbx leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 40h mov [rbp+var_38], rdi mov [rbp+var_3C], esi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rax, rsp mov rsi, rax mov [rbp+var_2A], 1 mov eax, [rbp+var_3C] movsxd rdx, eax sub rdx, 1 mov [rbp+var_18], rdx cdqe lea rdx, ds:0[rax*4] mov eax, 10h sub rax, 1 add rax, rdx mov edi, 10h mov edx, 0 div rdi imul rax, 10h mov rcx, rax and rcx, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rcx loc_11DA: cmp rsp, rdx jz short loc_11F1 sub rsp, 1000h or [rsp+1040h+var_48], 0 jmp short loc_11DA loc_11F1: mov rdx, rax and edx, 0FFFh sub rsp, rdx mov rdx, rax and edx, 0FFFh test rdx, rdx jz short loc_121B and eax, 0FFFh sub rax, 8 add rax, rsp or qword ptr [rax], 0 loc_121B: mov rax, rsp add rax, 3 shr rax, 2 shl rax, 2 mov [rbp+var_10], rax mov [rbp+var_28], 0 mov [rbp+var_24], 0 jmp short loc_12AD loc_123E: mov eax, [rbp+var_24] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] add rax, rdx mov eax, [rax] mov [rbp+var_1C], eax mov [rbp+var_29], 0 mov [rbp+var_20], 0 jmp short loc_1280 loc_1264: mov rax, [rbp+var_10] mov edx, [rbp+var_20] movsxd rdx, edx mov eax, [rax+rdx*4] cmp [rbp+var_1C], eax jnz short loc_127C mov [rbp+var_29], 1 jmp short loc_1288 loc_127C: add [rbp+var_20], 1 loc_1280: mov eax, [rbp+var_20] cmp eax, [rbp+var_28] jl short loc_1264 loc_1288: cmp [rbp+var_29], 0 jz short loc_1294 mov [rbp+var_2A], 0 jmp short loc_12B5 loc_1294: mov eax, [rbp+var_28] lea edx, [rax+1] mov [rbp+var_28], edx mov rdx, [rbp+var_10] cdqe mov ecx, [rbp+var_1C] mov [rdx+rax*4], ecx add [rbp+var_24], 1 loc_12AD: mov eax, [rbp+var_24] cmp eax, [rbp+var_3C] jl short loc_123E loc_12B5: movzx eax, [rbp+var_2A] mov rsp, rsi mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_12D0 call ___stack_chk_fail locret_12D0: leave retn
long long func0(long long a1, int a2) { unsigned long long v2; // rax void *v3; // rsp int v4; // eax _BYTE v6[4]; // [rsp+8h] [rbp-40h] BYREF int v7; // [rsp+Ch] [rbp-3Ch] long long v8; // [rsp+10h] [rbp-38h] unsigned __int8 v9; // [rsp+1Eh] [rbp-2Ah] char v10; // [rsp+1Fh] [rbp-29h] int v11; // [rsp+20h] [rbp-28h] int i; // [rsp+24h] [rbp-24h] int j; // [rsp+28h] [rbp-20h] int v14; // [rsp+2Ch] [rbp-1Ch] long long v15; // [rsp+30h] [rbp-18h] _BYTE *v16; // [rsp+38h] [rbp-10h] unsigned long long v17; // [rsp+40h] [rbp-8h] v8 = a1; v7 = a2; v17 = __readfsqword(0x28u); v9 = 1; v15 = a2 - 1LL; v2 = 16 * ((4LL * a2 + 15) / 0x10uLL); while ( v6 != &v6[-(v2 & 0xFFFFFFFFFFFFF000LL)] ) ; v3 = alloca(v2 & 0xFFF); if ( (v2 & 0xFFF) != 0 ) *(_QWORD *)&v6[(v2 & 0xFFF) - 8] = *(_QWORD *)&v6[(v2 & 0xFFF) - 8]; v16 = v6; v11 = 0; for ( i = 0; i < v7; ++i ) { v14 = *(_DWORD *)(4LL * i + v8); v10 = 0; for ( j = 0; j < v11; ++j ) { if ( v14 == *(_DWORD *)&v16[4 * j] ) { v10 = 1; break; } } if ( v10 ) return 0; v4 = v11++; *(_DWORD *)&v16[4 * v4] = v14; } return v9; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 MOV qword ptr [RBP + -0x38],RDI MOV dword ptr [RBP + -0x3c],ESI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RAX,RSP MOV RSI,RAX MOV byte ptr [RBP + -0x2a],0x1 MOV EAX,dword ptr [RBP + -0x3c] MOVSXD RDX,EAX SUB RDX,0x1 MOV qword ptr [RBP + -0x18],RDX CDQE LEA RDX,[RAX*0x4] MOV EAX,0x10 SUB RAX,0x1 ADD RAX,RDX MOV EDI,0x10 MOV EDX,0x0 DIV RDI IMUL RAX,RAX,0x10 MOV RCX,RAX AND RCX,-0x1000 MOV RDX,RSP SUB RDX,RCX LAB_001011da: CMP RSP,RDX JZ 0x001011f1 SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011da LAB_001011f1: MOV RDX,RAX AND EDX,0xfff SUB RSP,RDX MOV RDX,RAX AND EDX,0xfff TEST RDX,RDX JZ 0x0010121b AND EAX,0xfff SUB RAX,0x8 ADD RAX,RSP OR qword ptr [RAX],0x0 LAB_0010121b: MOV RAX,RSP ADD RAX,0x3 SHR RAX,0x2 SHL RAX,0x2 MOV qword ptr [RBP + -0x10],RAX MOV dword ptr [RBP + -0x28],0x0 MOV dword ptr [RBP + -0x24],0x0 JMP 0x001012ad LAB_0010123e: MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x1c],EAX MOV byte ptr [RBP + -0x29],0x0 MOV dword ptr [RBP + -0x20],0x0 JMP 0x00101280 LAB_00101264: MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x20] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] CMP dword ptr [RBP + -0x1c],EAX JNZ 0x0010127c MOV byte ptr [RBP + -0x29],0x1 JMP 0x00101288 LAB_0010127c: ADD dword ptr [RBP + -0x20],0x1 LAB_00101280: MOV EAX,dword ptr [RBP + -0x20] CMP EAX,dword ptr [RBP + -0x28] JL 0x00101264 LAB_00101288: CMP byte ptr [RBP + -0x29],0x0 JZ 0x00101294 MOV byte ptr [RBP + -0x2a],0x0 JMP 0x001012b5 LAB_00101294: MOV EAX,dword ptr [RBP + -0x28] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x28],EDX MOV RDX,qword ptr [RBP + -0x10] CDQE MOV ECX,dword ptr [RBP + -0x1c] MOV dword ptr [RDX + RAX*0x4],ECX ADD dword ptr [RBP + -0x24],0x1 LAB_001012ad: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x3c] JL 0x0010123e LAB_001012b5: MOVZX EAX,byte ptr [RBP + -0x2a] MOV RSP,RSI MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x001012d0 CALL 0x00101060 LAB_001012d0: LEAVE RET
int func0(long param_1,int param_2) { long lVar1; ulong uVar2; int *puVar3; long in_FS_OFFSET; int auStack_48 [4]; int local_44; long local_40; int local_32; char local_31; int local_30; int local_2c; int local_28; int local_24; long local_20; int *local_18; long local_10; local_40 = param_1; local_44 = param_2; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_32 = 1; local_20 = (long)param_2 + -1; uVar2 = (((long)param_2 * 4 + 0xfU) / 0x10) * 0x10; for (puVar3 = auStack_48; puVar3 != auStack_48 + -(uVar2 & 0xfffffffffffff000); puVar3 = puVar3 + -0x1000) { *(int8 *)(puVar3 + -8) = *(int8 *)(puVar3 + -8); } lVar1 = -(ulong)((uint)uVar2 & 0xfff); if ((uVar2 & 0xfff) != 0) { *(int8 *)(puVar3 + ((ulong)((uint)uVar2 & 0xfff) - 8) + lVar1) = *(int8 *)(puVar3 + ((ulong)((uint)uVar2 & 0xfff) - 8) + lVar1); } local_30 = 0; local_2c = 0; do { if (local_44 <= local_2c) { LAB_001012b5: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { local_18 = puVar3 + lVar1; /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return local_32; } local_24 = *(int *)(local_40 + (long)local_2c * 4); local_31 = '\0'; for (local_28 = 0; local_28 < local_30; local_28 = local_28 + 1) { if (local_24 == *(int *)(puVar3 + (long)local_28 * 4 + lVar1)) { local_31 = '\x01'; break; } } if (local_31 != '\0') { local_32 = 0; goto LAB_001012b5; } *(int *)(puVar3 + (long)local_30 * 4 + lVar1) = local_24; local_2c = local_2c + 1; local_30 = local_30 + 1; } while( true ); }
5,469
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int test_tup[], int size) { bool res = true; int temp[size]; int temp_size = 0; for (int i = 0; i < size; i++) { int ele = test_tup[i]; bool found = false; for (int j = 0; j < temp_size; j++) { if (temp[j] == ele) { found = true; break; } } if (found) { res = false; break; } temp[temp_size++] = ele; } return res; }
int main() { int test1[] = {1, 4, 5, 6, 1, 4}; int test2[] = {1, 4, 5, 6}; int test3[] = {2, 3, 4, 5, 6}; assert(func0(test1, sizeof(test1)/sizeof(test1[0])) == false); assert(func0(test2, sizeof(test2)/sizeof(test2[0])) == true); assert(func0(test3, sizeof(test3)/sizeof(test3[0])) == true); return 0; }
O1
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %esi,%r8d mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movslq %esi,%rax lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffffff0,%rdx and $0xfffffffffffff000,%rax mov %rsp,%rsi sub %rax,%rsi mov %rsi,%rax cmp %rax,%rsp je 11bf <func0+0x56> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 11a8 <func0+0x3f> mov %rdx,%rax and $0xfff,%eax sub %rax,%rsp test %rax,%rax je 11d5 <func0+0x6c> orq $0x0,-0x8(%rsp,%rax,1) mov %rsp,%rcx mov $0x1,%eax test %r8d,%r8d jle 1224 <func0+0xbb> mov (%rdi),%edx add $0x4,%rdi mov %rcx,%r9 add $0x4,%rcx mov $0x1,%esi mov %edx,-0x4(%rcx) cmp %r8d,%esi je 1235 <func0+0xcc> mov (%rdi),%edx test %esi,%esi jle 1212 <func0+0xa9> mov %r9,%rax cmp %edx,(%rax) je 121f <func0+0xb6> add $0x4,%rax cmp %rcx,%rax jne 1205 <func0+0x9c> add $0x1,%esi add $0x4,%rdi add $0x4,%rcx jmp 11f4 <func0+0x8b> mov $0x0,%eax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi jne 123c <func0+0xd3> leaveq retq mov $0x1,%eax jmp 1224 <func0+0xbb> callq 1060 <__stack_chk_fail@plt>
func0: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov r9d, esi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax movsxd rax, esi lea rax, ds:0Fh[rax*4] mov rcx, rax and rcx, 0FFFFFFFFFFFFFFF0h and rax, 0FFFFFFFFFFFFF000h mov rdx, rsp sub rdx, rax loc_11A5: cmp rsp, rdx jz short loc_11BC sub rsp, 1000h or [rsp+1010h+var_18], 0 jmp short loc_11A5 loc_11BC: mov rax, rcx and eax, 0FFFh sub rsp, rax test rax, rax jz short loc_11D2 or [rsp+rax+10h+var_18], 0 loc_11D2: mov r8, rsp mov eax, 1 test r9d, r9d jle short loc_121E mov edx, [rdi] lea rcx, [r8+4] add rdi, 4 mov esi, 1 loc_11EE: mov [rcx-4], edx cmp esi, r9d jz short loc_122F mov edx, [rdi] test esi, esi jle short loc_120C mov rax, r8 loc_11FF: cmp [rax], edx jz short loc_1219 add rax, 4 cmp rax, rcx jnz short loc_11FF loc_120C: add esi, 1 add rcx, 4 add rdi, 4 jmp short loc_11EE loc_1219: mov eax, 0 loc_121E: mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_1236 leave retn loc_122F: mov eax, 1 jmp short loc_121E loc_1236: call ___stack_chk_fail
long long func0(int *a1, int a2) { signed long long v3; // rax void *v4; // rsp long long result; // rax int v6; // edx _BYTE *v7; // rcx int *v8; // rdi int i; // esi _DWORD *v10; // rax _BYTE v12[4]; // [rsp+8h] [rbp-10h] BYREF _BYTE v13[12]; // [rsp+Ch] [rbp-Ch] BYREF *(_QWORD *)&v13[4] = __readfsqword(0x28u); while ( v12 != &v12[-((4LL * a2 + 15) & 0xFFFFFFFFFFFFF000LL)] ) ; v3 = (4 * (_WORD)a2 + 15) & 0xFF0; v4 = alloca(v3); if ( ((4 * (_WORD)a2 + 15) & 0xFF0) != 0 ) *(_QWORD *)&v12[v3 - 8] = *(_QWORD *)&v12[v3 - 8]; result = 1LL; if ( a2 > 0 ) { v6 = *a1; v7 = v13; v8 = a1 + 1; for ( i = 1; ; ++i ) { *((_DWORD *)v7 - 1) = v6; if ( i == a2 ) return 1LL; v6 = *v8; if ( i > 0 ) break; LABEL_12: v7 += 4; ++v8; } v10 = v12; while ( *v10 != v6 ) { if ( ++v10 == (_DWORD *)v7 ) goto LABEL_12; } return 0LL; } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV R9D,ESI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOVSXD RAX,ESI LEA RAX,[0xf + RAX*0x4] MOV RCX,RAX AND RCX,-0x10 AND RAX,-0x1000 MOV RDX,RSP SUB RDX,RAX LAB_001011a5: CMP RSP,RDX JZ 0x001011bc SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011a5 LAB_001011bc: MOV RAX,RCX AND EAX,0xfff SUB RSP,RAX TEST RAX,RAX JZ 0x001011d2 OR qword ptr [RSP + RAX*0x1 + -0x8],0x0 LAB_001011d2: MOV R8,RSP MOV EAX,0x1 TEST R9D,R9D JLE 0x0010121e MOV EDX,dword ptr [RDI] LEA RCX,[R8 + 0x4] ADD RDI,0x4 MOV ESI,0x1 LAB_001011ee: MOV dword ptr [RCX + -0x4],EDX CMP ESI,R9D JZ 0x0010122f MOV EDX,dword ptr [RDI] TEST ESI,ESI JLE 0x0010120c MOV RAX,R8 LAB_001011ff: CMP dword ptr [RAX],EDX JZ 0x00101219 ADD RAX,0x4 CMP RAX,RCX JNZ 0x001011ff LAB_0010120c: ADD ESI,0x1 ADD RCX,0x4 ADD RDI,0x4 JMP 0x001011ee LAB_00101219: MOV EAX,0x0 LAB_0010121e: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x00101236 LEAVE RET LAB_0010122f: MOV EAX,0x1 JMP 0x0010121e LAB_00101236: CALL 0x00101060
int8 func0(int *param_1,int param_2) { long lVar1; int *piVar2; ulong uVar3; int8 uVar4; int *piVar5; int iVar6; int1 *puVar7; int iVar8; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar3 = (long)param_2 * 4 + 0xf; for (puVar7 = auStack_18; puVar7 != auStack_18 + -(uVar3 & 0xfffffffffffff000); puVar7 = puVar7 + -0x1000) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } uVar3 = (ulong)((uint)uVar3 & 0xff0); lVar1 = -uVar3; if (uVar3 != 0) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } uVar4 = 1; if (0 < param_2) { iVar6 = *param_1; param_1 = param_1 + 1; iVar8 = 1; piVar2 = (int *)(puVar7 + lVar1); while( true ) { *piVar2 = iVar6; if (iVar8 == param_2) break; iVar6 = *param_1; piVar5 = (int *)(puVar7 + lVar1); if (0 < iVar8) { do { if (*piVar5 == iVar6) { uVar4 = 0; goto LAB_0010121e; } piVar5 = piVar5 + 1; } while (piVar5 != piVar2 + 1); } iVar8 = iVar8 + 1; param_1 = param_1 + 1; piVar2 = piVar2 + 1; } uVar4 = 1; } LAB_0010121e: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ *(code **)(puVar7 + lVar1 + -8) = main; __stack_chk_fail(); } return uVar4; }
5,470
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int test_tup[], int size) { bool res = true; int temp[size]; int temp_size = 0; for (int i = 0; i < size; i++) { int ele = test_tup[i]; bool found = false; for (int j = 0; j < temp_size; j++) { if (temp[j] == ele) { found = true; break; } } if (found) { res = false; break; } temp[temp_size++] = ele; } return res; }
int main() { int test1[] = {1, 4, 5, 6, 1, 4}; int test2[] = {1, 4, 5, 6}; int test3[] = {2, 3, 4, 5, 6}; assert(func0(test1, sizeof(test1)/sizeof(test1[0])) == false); assert(func0(test2, sizeof(test2)/sizeof(test2[0])) == true); assert(func0(test3, sizeof(test3)/sizeof(test3[0])) == true); return 0; }
O2
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movslq %esi,%rax mov %rsp,%rcx lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rcx and $0xfffffffffffffff0,%rdx mov %rcx,%rax cmp %rax,%rsp je 1396 <func0+0x56> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1381 <func0+0x41> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 140b <func0+0xcb> mov %rsp,%r9 test %esi,%esi jle 1404 <func0+0xc4> mov (%rdi),%edx mov $0x1,%r8d lea 0x4(%r9),%rcx add $0x4,%rdi mov %edx,-0x4(%rcx) cmp %esi,%r8d je 1404 <func0+0xc4> nopl 0x0(%rax,%rax,1) mov (%rdi),%edx mov %r9,%rax jmp 13d9 <func0+0x99> add $0x4,%rax cmp %rcx,%rax je 13f0 <func0+0xb0> cmp %edx,(%rax) jne 13d0 <func0+0x90> xor %eax,%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi jne 1413 <func0+0xd3> leaveq retq add $0x1,%r8d add $0x4,%rcx add $0x4,%rdi mov %edx,-0x4(%rcx) cmp %esi,%r8d jne 13c8 <func0+0x88> mov $0x1,%eax jmp 13df <func0+0x9f> orq $0x0,-0x8(%rsp,%rdx,1) jmp 13a4 <func0+0x64> callq 1060 <__stack_chk_fail@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp mov r8d, esi mov rbp, rsp sub rsp, 10h mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax movsxd rax, esi mov rcx, rsp lea rax, ds:0Fh[rax*4] mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_12E6 loc_12D1: sub rsp, 1000h or [rsp+1010h+var_18], 0 cmp rsp, rcx jnz short loc_12D1 loc_12E6: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz short loc_135A loc_12F4: mov r9, rsp test r8d, r8d jle short loc_1353 mov edx, [rdi] lea rsi, [rdi+4] mov edi, 1 lea rcx, [r9+4] mov [rcx-4], edx cmp edi, r8d jz short loc_1353 nop dword ptr [rax+rax+00h] loc_1318: mov edx, [rsi] mov rax, r9 jmp short loc_1329 loc_1320: add rax, 4 cmp rax, rcx jz short loc_1340 loc_1329: cmp [rax], edx jnz short loc_1320 xor eax, eax loc_132F: mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_1362 leave retn loc_1340: add edi, 1 add rcx, 4 add rsi, 4 mov [rcx-4], edx cmp edi, r8d jnz short loc_1318 loc_1353: mov eax, 1 jmp short loc_132F loc_135A: or [rsp+rdx+1010h+var_1018], 0 jmp short loc_12F4 loc_1362: call ___stack_chk_fail
long long func0(int *a1, int a2) { long long v3; // rdx int *v4; // rcx __int16 v5; // dx signed long long v6; // rdx void *v7; // rsp int v8; // edx int *v9; // rsi int v10; // edi int *v11; // rcx int v12; // edx int *p_i; // rax long long v15; // [rsp+0h] [rbp-1018h] int i; // [rsp+8h] [rbp-1010h] BYREF int v17; // [rsp+Ch] [rbp-100Ch] BYREF _QWORD v18[2]; // [rsp+1008h] [rbp-10h] BYREF v18[1] = __readfsqword(0x28u); v3 = 4LL * a2 + 15; v4 = (int *)((char *)v18 - (v3 & 0xFFFFFFFFFFFFF000LL)); v5 = v3 & 0xFFF0; if ( v18 != (_QWORD *)v4 ) { while ( &i != v4 ) ; } v6 = v5 & 0xFFF; v7 = alloca(v6); if ( v6 ) *(long long *)((char *)&v15 + v6) = *(long long *)((char *)&v15 + v6); if ( a2 > 0 ) { v8 = *a1; v9 = a1 + 1; v10 = 1; v11 = &v17; for ( i = v8; v10 != a2; *(v11 - 1) = v12 ) { v12 = *v9; p_i = &i; do { if ( *p_i == v12 ) return 0LL; ++p_i; } while ( p_i != v11 ); ++v10; ++v11; ++v9; } } return 1LL; }
func0: ENDBR64 PUSH RBP MOV R8D,ESI MOV RBP,RSP SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOVSXD RAX,ESI MOV RCX,RSP LEA RAX,[0xf + RAX*0x4] MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x001012e6 LAB_001012d1: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x001012d1 LAB_001012e6: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x0010135a LAB_001012f4: MOV R9,RSP TEST R8D,R8D JLE 0x00101353 MOV EDX,dword ptr [RDI] LEA RSI,[RDI + 0x4] MOV EDI,0x1 LEA RCX,[R9 + 0x4] MOV dword ptr [RCX + -0x4],EDX CMP EDI,R8D JZ 0x00101353 NOP dword ptr [RAX + RAX*0x1] LAB_00101318: MOV EDX,dword ptr [RSI] MOV RAX,R9 JMP 0x00101329 LAB_00101320: ADD RAX,0x4 CMP RAX,RCX JZ 0x00101340 LAB_00101329: CMP dword ptr [RAX],EDX JNZ 0x00101320 XOR EAX,EAX LAB_0010132f: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x00101362 LEAVE RET LAB_00101340: ADD EDI,0x1 ADD RCX,0x4 ADD RSI,0x4 MOV dword ptr [RCX + -0x4],EDX CMP EDI,R8D JNZ 0x00101318 LAB_00101353: MOV EAX,0x1 JMP 0x0010132f LAB_0010135a: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x001012f4 LAB_00101362: CALL 0x00101060
int8 func0(int4 *param_1,int param_2) { int iVar1; long lVar2; int1 *puVar3; int *piVar4; int8 uVar5; ulong uVar6; int1 *puVar7; int *piVar9; int *piVar10; int iVar11; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; int1 *puVar8; puVar7 = auStack_18; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar6 = (long)param_2 * 4 + 0xf; puVar8 = auStack_18; puVar3 = auStack_18; while (puVar8 != auStack_18 + -(uVar6 & 0xfffffffffffff000)) { puVar7 = puVar3 + -0x1000; *(int8 *)(puVar3 + -8) = *(int8 *)(puVar3 + -8); puVar8 = puVar3 + -0x1000; puVar3 = puVar3 + -0x1000; } uVar6 = (ulong)((uint)uVar6 & 0xff0); lVar2 = -uVar6; piVar9 = (int *)(puVar7 + lVar2); if (uVar6 != 0) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } if (0 < param_2) { piVar10 = param_1 + 1; iVar11 = 1; *(int4 *)(puVar7 + lVar2) = *param_1; if (param_2 != 1) { do { piVar9 = piVar9 + 1; iVar1 = *piVar10; piVar4 = (int *)(puVar7 + lVar2); do { if (*piVar4 == iVar1) { uVar5 = 0; goto LAB_0010132f; } piVar4 = piVar4 + 1; } while (piVar4 != piVar9); iVar11 = iVar11 + 1; piVar10 = piVar10 + 1; *piVar9 = iVar1; } while (iVar11 != param_2); } } uVar5 = 1; LAB_0010132f: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar5; } /* WARNING: Subroutine does not return */ *(int8 *)(puVar7 + lVar2 + -8) = 0x101367; __stack_chk_fail(); }
5,471
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int test_tup[], int size) { bool res = true; int temp[size]; int temp_size = 0; for (int i = 0; i < size; i++) { int ele = test_tup[i]; bool found = false; for (int j = 0; j < temp_size; j++) { if (temp[j] == ele) { found = true; break; } } if (found) { res = false; break; } temp[temp_size++] = ele; } return res; }
int main() { int test1[] = {1, 4, 5, 6, 1, 4}; int test2[] = {1, 4, 5, 6}; int test3[] = {2, 3, 4, 5, 6}; assert(func0(test1, sizeof(test1)/sizeof(test1[0])) == false); assert(func0(test2, sizeof(test2)/sizeof(test2[0])) == true); assert(func0(test3, sizeof(test3)/sizeof(test3[0])) == true); return 0; }
O3
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movslq %esi,%rax mov %rsp,%rcx lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rcx and $0xfffffffffffffff0,%rdx mov %rcx,%rax cmp %rax,%rsp je 1266 <func0+0x56> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1251 <func0+0x41> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 12db <func0+0xcb> mov %rsp,%r9 test %esi,%esi jle 12d4 <func0+0xc4> mov (%rdi),%edx mov $0x1,%r8d lea 0x4(%r9),%rcx add $0x4,%rdi mov %edx,-0x4(%rcx) cmp %esi,%r8d je 12d4 <func0+0xc4> nopl 0x0(%rax,%rax,1) mov (%rdi),%edx mov %r9,%rax jmp 12a9 <func0+0x99> add $0x4,%rax cmp %rcx,%rax je 12c0 <func0+0xb0> cmp %edx,(%rax) jne 12a0 <func0+0x90> xor %eax,%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi jne 12e3 <func0+0xd3> leaveq retq add $0x1,%r8d add $0x4,%rcx add $0x4,%rdi mov %edx,-0x4(%rcx) cmp %esi,%r8d jne 1298 <func0+0x88> mov $0x1,%eax jmp 12af <func0+0x9f> orq $0x0,-0x8(%rsp,%rdx,1) jmp 1274 <func0+0x64> callq 1060 <__stack_chk_fail@plt> nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp movsxd r8, esi mov rbp, rsp sub rsp, 10h mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rax, ds:0Fh[r8*4] mov rcx, rsp mov rdx, rax and rax, 0FFFFFFFFFFFFF000h sub rcx, rax and rdx, 0FFFFFFFFFFFFFFF0h cmp rsp, rcx jz short loc_11B3 loc_119E: sub rsp, 1000h or [rsp+1010h+var_18], 0 cmp rsp, rcx jnz short loc_119E loc_11B3: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz short loc_1216 loc_11C1: mov r9, rsp test esi, esi jle short loc_120F mov rdx, r9 xor esi, esi nop dword ptr [rax] loc_11D0: mov ecx, [rdi+rsi*4] test esi, esi jz short loc_1200 mov rax, r9 jmp short loc_11E9 loc_11E0: add rax, 4 cmp rax, rdx jz short loc_1200 loc_11E9: cmp [rax], ecx jnz short loc_11E0 xor eax, eax loc_11EF: mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_121E leave retn loc_1200: add rsi, 1 mov [rdx], ecx add rdx, 4 cmp r8, rsi jnz short loc_11D0 loc_120F: mov eax, 1 jmp short loc_11EF loc_1216: or [rsp+rdx+1010h+var_1018], 0 jmp short loc_11C1 loc_121E: call ___stack_chk_fail
long long func0(long long a1, int a2) { long long v2; // r8 long long v3; // rdx _BYTE *v4; // rcx __int16 v5; // dx signed long long v6; // rdx void *v7; // rsp _DWORD *v8; // rdx long long v9; // rsi int v10; // ecx _DWORD *v11; // rax _BYTE v14[4088]; // [rsp+8h] [rbp-1010h] BYREF _QWORD v15[2]; // [rsp+1008h] [rbp-10h] BYREF v2 = a2; v15[1] = __readfsqword(0x28u); v3 = 4LL * a2 + 15; v4 = (char *)v15 - (v3 & 0xFFFFFFFFFFFFF000LL); v5 = v3 & 0xFFF0; if ( v15 != (_QWORD *)v4 ) { while ( v14 != v4 ) ; } v6 = v5 & 0xFFF; v7 = alloca(v6); if ( v6 ) *(_QWORD *)&v14[v6 - 8] = *(_QWORD *)&v14[v6 - 8]; if ( a2 <= 0 ) return 1LL; v8 = v14; v9 = 0LL; while ( 1 ) { v10 = *(_DWORD *)(a1 + 4 * v9); if ( (_DWORD)v9 ) break; LABEL_12: ++v9; *v8++ = v10; if ( v2 == v9 ) return 1LL; } v11 = v14; while ( *v11 != v10 ) { if ( ++v11 == v8 ) goto LABEL_12; } return 0LL; }
func0: ENDBR64 PUSH RBP MOVSXD R8,ESI MOV RBP,RSP SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RAX,[0xf + R8*0x4] MOV RCX,RSP MOV RDX,RAX AND RAX,-0x1000 SUB RCX,RAX AND RDX,-0x10 CMP RSP,RCX JZ 0x001011b3 LAB_0010119e: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x0010119e LAB_001011b3: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x00101216 LAB_001011c1: MOV R9,RSP TEST ESI,ESI JLE 0x0010120f MOV RDX,R9 XOR ESI,ESI NOP dword ptr [RAX] LAB_001011d0: MOV ECX,dword ptr [RDI + RSI*0x4] TEST ESI,ESI JZ 0x00101200 MOV RAX,R9 JMP 0x001011e9 LAB_001011e0: ADD RAX,0x4 CMP RAX,RDX JZ 0x00101200 LAB_001011e9: CMP dword ptr [RAX],ECX JNZ 0x001011e0 XOR EAX,EAX LAB_001011ef: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x0010121e LEAVE RET LAB_00101200: ADD RSI,0x1 MOV dword ptr [RDX],ECX ADD RDX,0x4 CMP R8,RSI JNZ 0x001011d0 LAB_0010120f: MOV EAX,0x1 JMP 0x001011ef LAB_00101216: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x001011c1 LAB_0010121e: CALL 0x00101050
int8 func0(long param_1,int param_2) { int iVar1; long lVar2; int *puVar3; int *piVar4; int8 uVar5; ulong uVar6; int *piVar7; int *puVar8; long lVar10; long in_FS_OFFSET; int auStack_18 [8]; long local_10; int *puVar9; puVar8 = auStack_18; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar6 = (long)param_2 * 4 + 0xf; puVar9 = auStack_18; puVar3 = auStack_18; while (puVar9 != auStack_18 + -(uVar6 & 0xfffffffffffff000)) { puVar8 = puVar3 + -0x1000; *(int8 *)(puVar3 + -8) = *(int8 *)(puVar3 + -8); puVar9 = puVar3 + -0x1000; puVar3 = puVar3 + -0x1000; } uVar6 = (ulong)((uint)uVar6 & 0xff0); lVar2 = -uVar6; piVar7 = (int *)(puVar8 + lVar2); if (uVar6 != 0) { *(int8 *)(puVar8 + -8) = *(int8 *)(puVar8 + -8); } if (0 < param_2) { lVar10 = 0; do { iVar1 = *(int *)(param_1 + lVar10 * 4); piVar4 = (int *)(puVar8 + lVar2); if ((int)lVar10 != 0) { do { if (*piVar4 == iVar1) { uVar5 = 0; goto LAB_001011ef; } piVar4 = piVar4 + 1; } while (piVar4 != piVar7); } lVar10 = lVar10 + 1; *piVar7 = iVar1; piVar7 = piVar7 + 1; } while (param_2 != lVar10); } uVar5 = 1; LAB_001011ef: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar5; } /* WARNING: Subroutine does not return */ *(int8 *)(puVar8 + lVar2 + -8) = 0x101223; __stack_chk_fail(); }
5,472
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char func0(char* str1) { int ctr[256] = {0}; char char_order[256]; int idx = 0; int length = strlen(str1); for (int i = 0; i < length; i++) { char c = str1[i]; if (ctr[c] == 0) { char_order[idx++] = c; } ctr[c]++; } for (int i = 0; i < idx; i++) { char c = char_order[i]; if (ctr[c] == 1) { return c; } } return '\0'; // Using '\0' to represent None }
int main() { assert(func0("abcabc") == '\0'); assert(func0("abc") == 'a'); assert(func0("ababc") == 'c'); printf("All tests passed!\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x540,%rsp mov %rdi,-0x538(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea -0x510(%rbp),%rdx mov $0x0,%eax mov $0x80,%ecx mov %rdx,%rdi rep stos %rax,%es:(%rdi) movl $0x0,-0x520(%rbp) mov -0x538(%rbp),%rax mov %rax,%rdi callq 1090 <strlen@plt> mov %eax,-0x514(%rbp) movl $0x0,-0x51c(%rbp) jmp 1283 <func0+0xda> mov -0x51c(%rbp),%eax movslq %eax,%rdx mov -0x538(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax mov %al,-0x521(%rbp) movsbl -0x521(%rbp),%eax cltq mov -0x510(%rbp,%rax,4),%eax test %eax,%eax jne 125f <func0+0xb6> mov -0x520(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x520(%rbp) cltq movzbl -0x521(%rbp),%edx mov %dl,-0x110(%rbp,%rax,1) movsbl -0x521(%rbp),%eax movslq %eax,%rdx mov -0x510(%rbp,%rdx,4),%edx add $0x1,%edx cltq mov %edx,-0x510(%rbp,%rax,4) addl $0x1,-0x51c(%rbp) mov -0x51c(%rbp),%eax cmp -0x514(%rbp),%eax jl 1210 <func0+0x67> movl $0x0,-0x518(%rbp) jmp 12dc <func0+0x133> mov -0x518(%rbp),%eax cltq movzbl -0x110(%rbp,%rax,1),%eax mov %al,-0x522(%rbp) movsbl -0x522(%rbp),%eax cltq mov -0x510(%rbp,%rax,4),%eax cmp $0x1,%eax jne 12d5 <func0+0x12c> movzbl -0x522(%rbp),%eax jmp 12ef <func0+0x146> addl $0x1,-0x518(%rbp) mov -0x518(%rbp),%eax cmp -0x520(%rbp),%eax jl 12a1 <func0+0xf8> mov $0x0,%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi je 1303 <func0+0x15a> callq 10a0 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 540h mov [rbp+s], rdi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rdx, [rbp+var_510] mov eax, 0 mov ecx, 80h mov rdi, rdx rep stosq mov [rbp+var_520], 0 mov rax, [rbp+s] mov rdi, rax; s call _strlen mov [rbp+var_514], eax mov [rbp+var_51C], 0 jmp short loc_1283 loc_1210: mov eax, [rbp+var_51C] movsxd rdx, eax mov rax, [rbp+s] add rax, rdx movzx eax, byte ptr [rax] mov [rbp+var_521], al movsx eax, [rbp+var_521] cdqe mov eax, [rbp+rax*4+var_510] test eax, eax jnz short loc_125F mov eax, [rbp+var_520] lea edx, [rax+1] mov [rbp+var_520], edx cdqe movzx edx, [rbp+var_521] mov [rbp+rax+var_110], dl loc_125F: movsx eax, [rbp+var_521] movsxd rdx, eax mov edx, [rbp+rdx*4+var_510] add edx, 1 cdqe mov [rbp+rax*4+var_510], edx add [rbp+var_51C], 1 loc_1283: mov eax, [rbp+var_51C] cmp eax, [rbp+var_514] jl loc_1210 mov [rbp+var_518], 0 jmp short loc_12DC loc_12A1: mov eax, [rbp+var_518] cdqe movzx eax, [rbp+rax+var_110] mov [rbp+var_522], al movsx eax, [rbp+var_522] cdqe mov eax, [rbp+rax*4+var_510] cmp eax, 1 jnz short loc_12D5 movzx eax, [rbp+var_522] jmp short loc_12EF loc_12D5: add [rbp+var_518], 1 loc_12DC: mov eax, [rbp+var_518] cmp eax, [rbp+var_520] jl short loc_12A1 mov eax, 0 loc_12EF: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_1303 call ___stack_chk_fail locret_1303: leave retn
long long func0(const char *a1) { int v1; // eax unsigned __int8 v3; // [rsp+1Eh] [rbp-522h] char v4; // [rsp+1Fh] [rbp-521h] int v5; // [rsp+20h] [rbp-520h] int i; // [rsp+24h] [rbp-51Ch] int j; // [rsp+28h] [rbp-518h] int v8; // [rsp+2Ch] [rbp-514h] _DWORD v9[322]; // [rsp+30h] [rbp-510h] BYREF unsigned long long v10; // [rsp+538h] [rbp-8h] v10 = __readfsqword(0x28u); memset(v9, 0, 0x400uLL); v5 = 0; v8 = strlen(a1); for ( i = 0; i < v8; ++i ) { v4 = a1[i]; if ( !v9[v4] ) { v1 = v5++; *((_BYTE *)&v9[256] + v1) = v4; } ++v9[v4]; } for ( j = 0; j < v5; ++j ) { v3 = *((_BYTE *)&v9[256] + j); if ( v9[(char)v3] == 1 ) return v3; } return 0LL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x540 MOV qword ptr [RBP + -0x538],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RDX,[RBP + -0x510] MOV EAX,0x0 MOV ECX,0x80 MOV RDI,RDX STOSQ.REP RDI MOV dword ptr [RBP + -0x520],0x0 MOV RAX,qword ptr [RBP + -0x538] MOV RDI,RAX CALL 0x00101090 MOV dword ptr [RBP + -0x514],EAX MOV dword ptr [RBP + -0x51c],0x0 JMP 0x00101283 LAB_00101210: MOV EAX,dword ptr [RBP + -0x51c] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x538] ADD RAX,RDX MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBP + -0x521],AL MOVSX EAX,byte ptr [RBP + -0x521] CDQE MOV EAX,dword ptr [RBP + RAX*0x4 + -0x510] TEST EAX,EAX JNZ 0x0010125f MOV EAX,dword ptr [RBP + -0x520] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x520],EDX CDQE MOVZX EDX,byte ptr [RBP + -0x521] MOV byte ptr [RBP + RAX*0x1 + -0x110],DL LAB_0010125f: MOVSX EAX,byte ptr [RBP + -0x521] MOVSXD RDX,EAX MOV EDX,dword ptr [RBP + RDX*0x4 + -0x510] ADD EDX,0x1 CDQE MOV dword ptr [RBP + RAX*0x4 + -0x510],EDX ADD dword ptr [RBP + -0x51c],0x1 LAB_00101283: MOV EAX,dword ptr [RBP + -0x51c] CMP EAX,dword ptr [RBP + -0x514] JL 0x00101210 MOV dword ptr [RBP + -0x518],0x0 JMP 0x001012dc LAB_001012a1: MOV EAX,dword ptr [RBP + -0x518] CDQE MOVZX EAX,byte ptr [RBP + RAX*0x1 + -0x110] MOV byte ptr [RBP + -0x522],AL MOVSX EAX,byte ptr [RBP + -0x522] CDQE MOV EAX,dword ptr [RBP + RAX*0x4 + -0x510] CMP EAX,0x1 JNZ 0x001012d5 MOVZX EAX,byte ptr [RBP + -0x522] JMP 0x001012ef LAB_001012d5: ADD dword ptr [RBP + -0x518],0x1 LAB_001012dc: MOV EAX,dword ptr [RBP + -0x518] CMP EAX,dword ptr [RBP + -0x520] JL 0x001012a1 MOV EAX,0x0 LAB_001012ef: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x00101303 CALL 0x001010a0 LAB_00101303: LEAVE RET
char func0(char *param_1) { char cVar1; size_t sVar2; long lVar3; int *piVar4; long in_FS_OFFSET; int local_528; int local_524; int local_520; int local_518 [256]; char acStack_118 [264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); piVar4 = local_518; for (lVar3 = 0x80; lVar3 != 0; lVar3 = lVar3 + -1) { piVar4[0] = 0; piVar4[1] = 0; piVar4 = piVar4 + 2; } local_528 = 0; sVar2 = strlen(param_1); for (local_524 = 0; local_524 < (int)sVar2; local_524 = local_524 + 1) { cVar1 = param_1[local_524]; if (local_518[(int)cVar1] == 0) { acStack_118[local_528] = cVar1; local_528 = local_528 + 1; } local_518[(int)cVar1] = local_518[(int)cVar1] + 1; } for (local_520 = 0; local_520 < local_528; local_520 = local_520 + 1) { cVar1 = acStack_118[local_520]; if (local_518[(int)cVar1] == 1) goto LAB_001012ef; } cVar1 = '\0'; LAB_001012ef: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return cVar1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,473
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char func0(char* str1) { int ctr[256] = {0}; char char_order[256]; int idx = 0; int length = strlen(str1); for (int i = 0; i < length; i++) { char c = str1[i]; if (ctr[c] == 0) { char_order[idx++] = c; } ctr[c]++; } for (int i = 0; i < idx; i++) { char c = char_order[i]; if (ctr[c] == 1) { return c; } } return '\0'; // Using '\0' to represent None }
int main() { assert(func0("abcabc") == '\0'); assert(func0("abc") == 'a'); assert(func0("ababc") == 'c'); printf("All tests passed!\n"); return 0; }
O1
c
func0: endbr64 sub $0x518,%rsp mov %rdi,%rsi mov %fs:0x28,%rax mov %rax,0x508(%rsp) xor %eax,%eax mov %rsp,%rdi mov $0x80,%ecx rep stos %rax,%es:(%rdi) mov $0xffffffffffffffff,%rcx mov %rsi,%rdi repnz scas %es:(%rdi),%al not %rcx sub $0x1,%rcx test %ecx,%ecx jle 1265 <func0+0xdc> mov %rsi,%rdx lea -0x1(%rcx),%eax lea 0x1(%rsi,%rax,1),%r8 mov $0x0,%edi jmp 11f4 <func0+0x6b> movslq %ecx,%rcx add $0x1,%eax mov %eax,(%rsp,%rcx,4) add $0x1,%rdx cmp %r8,%rdx je 1216 <func0+0x8d> movzbl (%rdx),%esi movsbl %sil,%ecx movsbq %sil,%rax mov (%rsp,%rax,4),%eax test %eax,%eax jne 11e2 <func0+0x59> movslq %edi,%r9 mov %sil,0x400(%rsp,%r9,1) lea 0x1(%rdi),%edi jmp 11e2 <func0+0x59> test %edi,%edi jle 126c <func0+0xe3> lea 0x400(%rsp),%rax lea -0x1(%rdi),%edx lea 0x401(%rsp,%rdx,1),%rsi movzbl (%rax),%edx movsbq %dl,%rcx cmpl $0x1,(%rsp,%rcx,4) je 1248 <func0+0xbf> add $0x1,%rax cmp %rsi,%rax jne 122d <func0+0xa4> mov $0x0,%edx mov 0x508(%rsp),%rax xor %fs:0x28,%rax jne 1273 <func0+0xea> mov %edx,%eax add $0x518,%rsp retq mov $0x0,%edx jmp 1248 <func0+0xbf> mov $0x0,%edx jmp 1248 <func0+0xbf> callq 1080 <__stack_chk_fail@plt>
func0: endbr64 push rbx sub rsp, 510h mov rbx, rdi mov rax, fs:28h mov [rsp+518h+var_10], rax xor eax, eax mov rdi, rsp mov ecx, 80h rep stosq mov rdi, rbx call _strlen test eax, eax jle loc_127C mov rdx, rbx lea eax, [rax-1] lea r8, [rbx+rax+1] mov edi, 0 jmp short loc_120A loc_11F8: movsxd rcx, ecx add eax, 1 mov [rsp+rcx*4+518h+var_518], eax add rdx, 1 cmp rdx, r8 jz short loc_122C loc_120A: movzx esi, byte ptr [rdx] movsx ecx, sil movsx rax, sil mov eax, [rsp+rax*4+518h+var_518] test eax, eax jnz short loc_11F8 movsxd r9, edi mov [rsp+r9+518h+var_118], sil lea edi, [rdi+1] jmp short loc_11F8 loc_122C: test edi, edi jle short loc_1283 lea rax, [rsp+518h+var_118] lea edx, [rdi-1] lea rsi, [rsp+rdx+518h+var_117] loc_1243: movzx edx, byte ptr [rax] movsx rcx, dl cmp [rsp+rcx*4+518h+var_518], 1 jz short loc_125E add rax, 1 cmp rax, rsi jnz short loc_1243 mov edx, 0 loc_125E: mov rax, [rsp+518h+var_10] sub rax, fs:28h jnz short loc_128A mov eax, edx add rsp, 510h pop rbx retn loc_127C: mov edx, 0 jmp short loc_125E loc_1283: mov edx, 0 jmp short loc_125E loc_128A: call ___stack_chk_fail
long long func0(char *a1) { int v1; // eax char *v2; // rdx long long v3; // r8 int v4; // edi int v5; // ecx int v6; // eax unsigned __int8 *v7; // rax unsigned int v8; // edx _DWORD v10[256]; // [rsp+0h] [rbp-518h] BYREF _BYTE v11[264]; // [rsp+400h] [rbp-118h] BYREF unsigned long long v12; // [rsp+508h] [rbp-10h] v12 = __readfsqword(0x28u); memset(v10, 0, sizeof(v10)); v1 = strlen(a1); if ( v1 <= 0 ) { return 0; } else { v2 = a1; v3 = (long long)&a1[v1 - 1 + 1]; v4 = 0; do { v5 = *v2; v6 = v10[*v2]; if ( !v6 ) v11[v4++] = *v2; v10[v5] = v6 + 1; ++v2; } while ( v2 != (char *)v3 ); if ( v4 <= 0 ) { return 0; } else { v7 = v11; while ( 1 ) { v8 = *v7; if ( v10[(char)v8] == 1 ) break; if ( ++v7 == &v11[v4 - 1 + 1] ) return 0; } } } return v8; }
func0: ENDBR64 PUSH RBX SUB RSP,0x510 MOV RBX,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x508],RAX XOR EAX,EAX MOV RDI,RSP MOV ECX,0x80 STOSQ.REP RDI MOV RDI,RBX CALL 0x00101090 TEST EAX,EAX JLE 0x0010127c MOV RDX,RBX LEA EAX,[RAX + -0x1] LEA R8,[RBX + RAX*0x1 + 0x1] MOV EDI,0x0 JMP 0x0010120a LAB_001011f8: MOVSXD RCX,ECX ADD EAX,0x1 MOV dword ptr [RSP + RCX*0x4],EAX ADD RDX,0x1 CMP RDX,R8 JZ 0x0010122c LAB_0010120a: MOVZX ESI,byte ptr [RDX] MOVSX ECX,SIL MOVSX RAX,SIL MOV EAX,dword ptr [RSP + RAX*0x4] TEST EAX,EAX JNZ 0x001011f8 MOVSXD R9,EDI MOV byte ptr [RSP + R9*0x1 + 0x400],SIL LEA EDI,[RDI + 0x1] JMP 0x001011f8 LAB_0010122c: TEST EDI,EDI JLE 0x00101283 LEA RAX,[RSP + 0x400] LEA EDX,[RDI + -0x1] LEA RSI,[RSP + RDX*0x1 + 0x401] LAB_00101243: MOVZX EDX,byte ptr [RAX] MOVSX RCX,DL CMP dword ptr [RSP + RCX*0x4],0x1 JZ 0x0010125e ADD RAX,0x1 CMP RAX,RSI JNZ 0x00101243 MOV EDX,0x0 LAB_0010125e: MOV RAX,qword ptr [RSP + 0x508] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010128a MOV EAX,EDX ADD RSP,0x510 POP RBX RET LAB_0010127c: MOV EDX,0x0 JMP 0x0010125e LAB_00101283: MOV EDX,0x0 JMP 0x0010125e LAB_0010128a: CALL 0x001010a0
char func0(char *param_1) { int iVar1; size_t sVar2; char *pcVar3; long lVar4; char cVar5; int iVar6; int *piVar7; long in_FS_OFFSET; int aiStack_518 [256]; char local_118 [264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); piVar7 = aiStack_518; for (lVar4 = 0x80; lVar4 != 0; lVar4 = lVar4 + -1) { *(int8 *)piVar7 = 0; piVar7 = (int *)((long)piVar7 + 8); } sVar2 = strlen(param_1); if ((int)sVar2 < 1) { cVar5 = '\0'; } else { pcVar3 = param_1 + (ulong)((int)sVar2 - 1) + 1; iVar6 = 0; do { cVar5 = *param_1; iVar1 = aiStack_518[cVar5]; if (iVar1 == 0) { local_118[iVar6] = cVar5; iVar6 = iVar6 + 1; } aiStack_518[(int)cVar5] = iVar1 + 1; param_1 = param_1 + 1; } while (param_1 != pcVar3); if (iVar6 < 1) { cVar5 = '\0'; } else { pcVar3 = local_118; do { cVar5 = *pcVar3; if (aiStack_518[cVar5] == 1) goto LAB_0010125e; pcVar3 = pcVar3 + 1; } while (pcVar3 != local_118 + (ulong)(iVar6 - 1) + 1); cVar5 = '\0'; } } LAB_0010125e: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return cVar5; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,474
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char func0(char* str1) { int ctr[256] = {0}; char char_order[256]; int idx = 0; int length = strlen(str1); for (int i = 0; i < length; i++) { char c = str1[i]; if (ctr[c] == 0) { char_order[idx++] = c; } ctr[c]++; } for (int i = 0; i < idx; i++) { char c = char_order[i]; if (ctr[c] == 1) { return c; } } return '\0'; // Using '\0' to represent None }
int main() { assert(func0("abcabc") == '\0'); assert(func0("abc") == 'a'); assert(func0("ababc") == 'c'); printf("All tests passed!\n"); return 0; }
O2
c
func0: endbr64 push %rbx mov $0x80,%ecx mov %rdi,%rbx sub $0x510,%rsp mov %fs:0x28,%rax mov %rax,0x508(%rsp) xor %eax,%eax mov %rsp,%rdi rep stos %rax,%es:(%rdi) mov %rbx,%rdi callq 1090 <strlen@plt> test %eax,%eax jle 1330 <func0+0xd0> sub $0x1,%eax mov %rbx,%rdi xor %esi,%esi lea 0x1(%rbx,%rax,1),%r8 nopw 0x0(%rax,%rax,1) movsbq (%rdi),%rdx mov (%rsp,%rdx,4),%eax test %eax,%eax jne 12c9 <func0+0x69> movslq %esi,%r9 add $0x1,%esi mov %dl,0x400(%rsp,%r9,1) add $0x1,%eax add $0x1,%rdi mov %eax,(%rsp,%rdx,4) cmp %r8,%rdi jne 12b0 <func0+0x50> test %esi,%esi je 1330 <func0+0xd0> lea -0x1(%rsi),%edx lea 0x400(%rsp),%rax lea 0x401(%rsp,%rdx,1),%rcx jmp 1301 <func0+0xa1> nopl 0x0(%rax) add $0x1,%rax cmp %rax,%rcx je 1330 <func0+0xd0> movsbq (%rax),%rdx cmpl $0x1,(%rsp,%rdx,4) mov %rdx,%r8 jne 12f8 <func0+0x98> mov 0x508(%rsp),%rax xor %fs:0x28,%rax jne 1335 <func0+0xd5> add $0x510,%rsp mov %r8d,%eax pop %rbx retq nopl (%rax) xor %r8d,%r8d jmp 130e <func0+0xae> callq 10a0 <__stack_chk_fail@plt> nopw 0x0(%rax,%rax,1)
func0: endbr64 push rbx mov ecx, 80h mov rbx, rdi sub rsp, 510h mov rax, fs:28h mov [rsp+518h+var_10], rax xor eax, eax mov rdi, rsp rep stosq mov rdi, rbx call _strlen test eax, eax jle loc_1330 sub eax, 1 mov rdi, rbx xor esi, esi lea r8, [rbx+rax+1] nop word ptr [rax+rax+00h] loc_12B0: movsx rdx, byte ptr [rdi] mov eax, [rsp+rdx*4+518h+var_518] test eax, eax jnz short loc_12C9 movsxd r9, esi add esi, 1 mov [rsp+r9+518h+var_118], dl loc_12C9: add eax, 1 add rdi, 1 mov [rsp+rdx*4+518h+var_518], eax cmp rdi, r8 jnz short loc_12B0 test esi, esi jz short loc_1330 lea edx, [rsi-1] lea rax, [rsp+518h+var_118] lea rcx, [rsp+rdx+518h+var_117] jmp short loc_1301 loc_12F8: add rax, 1 cmp rcx, rax jz short loc_1330 loc_1301: movsx rdx, byte ptr [rax] cmp [rsp+rdx*4+518h+var_518], 1 mov r8, rdx jnz short loc_12F8 loc_130E: mov rax, [rsp+518h+var_10] sub rax, fs:28h jnz short loc_1335 add rsp, 510h mov eax, r8d pop rbx retn loc_1330: xor r8d, r8d jmp short loc_130E loc_1335: call ___stack_chk_fail
long long func0(char *a1) { int v1; // eax int v2; // esi long long v3; // r8 long long v4; // rdx int v5; // eax long long v6; // r9 char *v7; // rax unsigned int v8; // r8d _DWORD v10[256]; // [rsp+0h] [rbp-518h] BYREF _BYTE v11[264]; // [rsp+400h] [rbp-118h] BYREF unsigned long long v12; // [rsp+508h] [rbp-10h] v12 = __readfsqword(0x28u); memset(v10, 0, sizeof(v10)); v1 = strlen(a1); if ( v1 <= 0 ) return 0; v2 = 0; v3 = (long long)&a1[v1 - 1 + 1]; do { v4 = *a1; v5 = v10[v4]; if ( !v5 ) { v6 = v2++; v11[v6] = v4; } ++a1; v10[v4] = v5 + 1; } while ( a1 != (char *)v3 ); if ( v2 ) { v7 = v11; while ( 1 ) { v8 = *v7; if ( v10[*v7] == 1 ) break; if ( &v11[v2 - 1 + 1] == ++v7 ) return 0; } } else { return 0; } return v8; }
func0: ENDBR64 PUSH RBX MOV ECX,0x80 MOV RBX,RDI SUB RSP,0x510 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x508],RAX XOR EAX,EAX MOV RDI,RSP STOSQ.REP RDI MOV RDI,RBX CALL 0x00101090 TEST EAX,EAX JLE 0x00101330 SUB EAX,0x1 MOV RDI,RBX XOR ESI,ESI LEA R8,[RBX + RAX*0x1 + 0x1] NOP word ptr [RAX + RAX*0x1] LAB_001012b0: MOVSX RDX,byte ptr [RDI] MOV EAX,dword ptr [RSP + RDX*0x4] TEST EAX,EAX JNZ 0x001012c9 MOVSXD R9,ESI ADD ESI,0x1 MOV byte ptr [RSP + R9*0x1 + 0x400],DL LAB_001012c9: ADD EAX,0x1 ADD RDI,0x1 MOV dword ptr [RSP + RDX*0x4],EAX CMP RDI,R8 JNZ 0x001012b0 TEST ESI,ESI JZ 0x00101330 LEA EDX,[RSI + -0x1] LEA RAX,[RSP + 0x400] LEA RCX,[RSP + RDX*0x1 + 0x401] JMP 0x00101301 LAB_001012f8: ADD RAX,0x1 CMP RCX,RAX JZ 0x00101330 LAB_00101301: MOVSX RDX,byte ptr [RAX] CMP dword ptr [RSP + RDX*0x4],0x1 MOV R8,RDX JNZ 0x001012f8 LAB_0010130e: MOV RAX,qword ptr [RSP + 0x508] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101335 ADD RSP,0x510 MOV EAX,R8D POP RBX RET LAB_00101330: XOR R8D,R8D JMP 0x0010130e LAB_00101335: CALL 0x001010a0
ulong func0(char *param_1) { char cVar1; int iVar2; size_t sVar3; char *pcVar4; long lVar5; ulong uVar6; int iVar7; int *piVar8; long in_FS_OFFSET; int aiStack_518 [256]; char local_118 [264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); piVar8 = aiStack_518; for (lVar5 = 0x80; lVar5 != 0; lVar5 = lVar5 + -1) { *(int8 *)piVar8 = 0; piVar8 = (int *)((long)piVar8 + 8); } sVar3 = strlen(param_1); if (0 < (int)sVar3) { iVar7 = 0; pcVar4 = param_1 + (ulong)((int)sVar3 - 1) + 1; do { cVar1 = *param_1; iVar2 = aiStack_518[cVar1]; if (iVar2 == 0) { lVar5 = (long)iVar7; iVar7 = iVar7 + 1; local_118[lVar5] = cVar1; } param_1 = param_1 + 1; aiStack_518[cVar1] = iVar2 + 1; } while (param_1 != pcVar4); if (iVar7 != 0) { pcVar4 = local_118; do { uVar6 = (ulong)*pcVar4; if (aiStack_518[uVar6] == 1) goto LAB_0010130e; pcVar4 = pcVar4 + 1; } while (local_118 + (ulong)(iVar7 - 1) + 1 != pcVar4); } } uVar6 = 0; LAB_0010130e: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar6 & 0xffffffff; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,475
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char func0(char* str1) { int ctr[256] = {0}; char char_order[256]; int idx = 0; int length = strlen(str1); for (int i = 0; i < length; i++) { char c = str1[i]; if (ctr[c] == 0) { char_order[idx++] = c; } ctr[c]++; } for (int i = 0; i < idx; i++) { char c = char_order[i]; if (ctr[c] == 1) { return c; } } return '\0'; // Using '\0' to represent None }
int main() { assert(func0("abcabc") == '\0'); assert(func0("abc") == 'a'); assert(func0("ababc") == 'c'); printf("All tests passed!\n"); return 0; }
O3
c
func0: endbr64 push %rbx mov $0x80,%ecx mov %rdi,%rbx sub $0x510,%rsp mov %fs:0x28,%rax mov %rax,0x508(%rsp) xor %eax,%eax mov %rsp,%rdi rep stos %rax,%es:(%rdi) mov %rbx,%rdi callq 1090 <strlen@plt> test %eax,%eax jle 1348 <func0+0xe8> sub $0x1,%eax mov %rbx,%rdi xor %ecx,%ecx lea 0x1(%rbx,%rax,1),%r8 nopw 0x0(%rax,%rax,1) movsbq (%rdi),%rdx mov (%rsp,%rdx,4),%eax test %eax,%eax jne 12e4 <func0+0x84> add $0x1,%rdi mov %dl,0x400(%rsp,%rcx,1) lea 0x1(%rcx),%r9d movl $0x1,(%rsp,%rdx,4) cmp %r8,%rdi je 12fa <func0+0x9a> movsbq (%rdi),%rdx movslq %r9d,%rcx mov (%rsp,%rdx,4),%eax test %eax,%eax je 12bb <func0+0x5b> add $0x1,%eax add $0x1,%rdi mov %eax,(%rsp,%rdx,4) cmp %r8,%rdi jne 12b0 <func0+0x50> test %ecx,%ecx je 1348 <func0+0xe8> mov %ecx,%r9d lea -0x1(%r9),%edx lea 0x400(%rsp),%rax lea 0x401(%rsp,%rdx,1),%rcx jmp 1319 <func0+0xb9> add $0x1,%rax cmp %rax,%rcx je 1348 <func0+0xe8> movsbq (%rax),%rdx cmpl $0x1,(%rsp,%rdx,4) mov %rdx,%r8 jne 1310 <func0+0xb0> mov 0x508(%rsp),%rax xor %fs:0x28,%rax jne 134d <func0+0xed> add $0x510,%rsp mov %r8d,%eax pop %rbx retq nopl (%rax) xor %r8d,%r8d jmp 1326 <func0+0xc6> callq 10a0 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push rbx mov ecx, 80h mov rbx, rdi sub rsp, 510h mov rax, fs:28h mov [rsp+518h+var_10], rax xor eax, eax mov rdi, rsp rep stosq mov rdi, rbx; s call _strlen test eax, eax jle loc_1340 sub eax, 1 mov rdi, rbx xor edx, edx lea r8, [rbx+rax+1] nop word ptr [rax+rax+00h] loc_12B0: movsx rcx, byte ptr [rdi] mov eax, [rsp+rcx*4+518h+var_518] test eax, eax jnz short loc_1328 lea eax, [rdx+1] add rdi, 1 mov [rsp+rdx+518h+var_118], cl mov [rsp+rcx*4+518h+var_518], 1 movsxd rdx, eax cmp rdi, r8 jnz short loc_12B0 loc_12D8: test edx, edx jle short loc_1340 lea rax, [rsp+518h+var_118] add rdx, rax jmp short loc_12F9 loc_12F0: add rax, 1 cmp rdx, rax jz short loc_1340 loc_12F9: movsx rsi, byte ptr [rax] cmp [rsp+rsi*4+518h+var_518], 1 mov rcx, rsi jnz short loc_12F0 loc_1306: mov rax, [rsp+518h+var_10] sub rax, fs:28h jnz short loc_1344 add rsp, 510h mov eax, ecx pop rbx retn loc_1328: add eax, 1 add rdi, 1 mov [rsp+rcx*4+518h+var_518], eax cmp rdi, r8 jnz loc_12B0 jmp short loc_12D8 loc_1340: xor ecx, ecx jmp short loc_1306 loc_1344: call ___stack_chk_fail
long long func0(char *s) { int v1; // eax long long v2; // rdx char *v3; // r8 long long v4; // rcx int v5; // eax char *v6; // rax char *v7; // rdx unsigned int v8; // ecx _DWORD v10[256]; // [rsp+0h] [rbp-518h] BYREF _BYTE v11[264]; // [rsp+400h] [rbp-118h] BYREF unsigned long long v12; // [rsp+508h] [rbp-10h] v12 = __readfsqword(0x28u); memset(v10, 0, sizeof(v10)); v1 = strlen(s); if ( v1 <= 0 ) return 0; v2 = 0LL; v3 = &s[v1 - 1 + 1]; do { while ( 1 ) { v4 = *s; v5 = v10[v4]; if ( v5 ) break; ++s; v11[v2] = v4; v10[v4] = 1; v2 = (int)v2 + 1; if ( s == v3 ) goto LABEL_5; } ++s; v10[v4] = v5 + 1; } while ( s != v3 ); LABEL_5: if ( (int)v2 <= 0 ) { return 0; } else { v6 = v11; v7 = &v11[v2]; while ( 1 ) { v8 = *v6; if ( v10[*v6] == 1 ) break; if ( v7 == ++v6 ) return 0; } } return v8; }
func0: ENDBR64 PUSH RBX MOV ECX,0x80 MOV RBX,RDI SUB RSP,0x510 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x508],RAX XOR EAX,EAX MOV RDI,RSP STOSQ.REP RDI MOV RDI,RBX CALL 0x00101090 TEST EAX,EAX JLE 0x00101340 SUB EAX,0x1 MOV RDI,RBX XOR EDX,EDX LEA R8,[RBX + RAX*0x1 + 0x1] NOP word ptr [RAX + RAX*0x1] LAB_001012b0: MOVSX RCX,byte ptr [RDI] MOV EAX,dword ptr [RSP + RCX*0x4] TEST EAX,EAX JNZ 0x00101328 LEA EAX,[RDX + 0x1] ADD RDI,0x1 MOV byte ptr [RSP + RDX*0x1 + 0x400],CL MOV dword ptr [RSP + RCX*0x4],0x1 MOVSXD RDX,EAX CMP RDI,R8 JNZ 0x001012b0 LAB_001012d8: TEST EDX,EDX JLE 0x00101340 LEA RAX,[RSP + 0x400] ADD RDX,RAX JMP 0x001012f9 LAB_001012f0: ADD RAX,0x1 CMP RDX,RAX JZ 0x00101340 LAB_001012f9: MOVSX RSI,byte ptr [RAX] CMP dword ptr [RSP + RSI*0x4],0x1 MOV RCX,RSI JNZ 0x001012f0 LAB_00101306: MOV RAX,qword ptr [RSP + 0x508] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101344 ADD RSP,0x510 MOV EAX,ECX POP RBX RET LAB_00101328: ADD EAX,0x1 ADD RDI,0x1 MOV dword ptr [RSP + RCX*0x4],EAX CMP RDI,R8 JNZ 0x001012b0 JMP 0x001012d8 LAB_00101340: XOR ECX,ECX JMP 0x00101306 LAB_00101344: CALL 0x001010a0
ulong func0(char *param_1) { char cVar1; size_t sVar2; char *pcVar3; long lVar4; char *pcVar5; ulong uVar6; int *piVar7; long in_FS_OFFSET; int aiStack_518 [256]; char local_118 [264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); piVar7 = aiStack_518; for (lVar4 = 0x80; lVar4 != 0; lVar4 = lVar4 + -1) { *(int8 *)piVar7 = 0; piVar7 = (int *)((long)piVar7 + 8); } sVar2 = strlen(param_1); if (0 < (int)sVar2) { lVar4 = 0; pcVar3 = param_1 + (ulong)((int)sVar2 - 1) + 1; do { while( true ) { cVar1 = *param_1; if (aiStack_518[cVar1] != 0) break; param_1 = param_1 + 1; local_118[lVar4] = cVar1; aiStack_518[cVar1] = 1; lVar4 = (long)((int)lVar4 + 1); if (param_1 == pcVar3) goto LAB_001012d8; } param_1 = param_1 + 1; aiStack_518[cVar1] = aiStack_518[cVar1] + 1; } while (param_1 != pcVar3); LAB_001012d8: if (0 < (int)lVar4) { pcVar3 = local_118; pcVar5 = pcVar3 + lVar4; do { uVar6 = (ulong)*pcVar3; if (aiStack_518[uVar6] == 1) goto LAB_00101306; pcVar3 = pcVar3 + 1; } while (pcVar5 != pcVar3); } } uVar6 = 0; LAB_00101306: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar6 & 0xffffffff; }
5,476
func0
#include <stdio.h> #include <assert.h> #include <regex.h>
char* func0(const char* string) { regex_t regex; int reti; char msgbuf[100]; // Compile regular expression reti = regcomp(&regex, "^[a-z]$|^([a-z]).*\\1$", REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return "Invalid"; } // Execute regular expression reti = regexec(&regex, string, 0, NULL, 0); if (!reti) { regfree(&regex); return "Valid"; } else if (reti == REG_NOMATCH) { regfree(&regex); return "Invalid"; } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); regfree(&regex); return "Invalid"; } }
int main() { assert(func0("abba") == "Valid"); assert(func0("a") == "Valid"); assert(func0("abcd") == "Invalid"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0xd0,%rsp mov %rdi,-0xc8(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea -0xb0(%rbp),%rax mov $0x1,%edx lea 0xda7(%rip),%rsi mov %rax,%rdi callq 10f0 <regcomp@plt> mov %eax,-0xb4(%rbp) cmpl $0x0,-0xb4(%rbp) je 12a4 <func0+0x7b> mov 0x2da1(%rip),%rax mov %rax,%rcx mov $0x18,%edx mov $0x1,%esi lea 0xd8b(%rip),%rdi callq 1130 <fwrite@plt> lea 0xd98(%rip),%rax jmpq 1364 <func0+0x13b> mov -0xc8(%rbp),%rsi lea -0xb0(%rbp),%rax mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rax,%rdi callq 1120 <regexec@plt> mov %eax,-0xb4(%rbp) cmpl $0x0,-0xb4(%rbp) jne 12f1 <func0+0xc8> lea -0xb0(%rbp),%rax mov %rax,%rdi callq 10c0 <regfree@plt> lea 0xd50(%rip),%rax jmp 1364 <func0+0x13b> cmpl $0x1,-0xb4(%rbp) jne 1312 <func0+0xe9> lea -0xb0(%rbp),%rax mov %rax,%rdi callq 10c0 <regfree@plt> lea 0xd27(%rip),%rax jmp 1364 <func0+0x13b> lea -0x70(%rbp),%rdx lea -0xb0(%rbp),%rsi mov -0xb4(%rbp),%eax mov $0x64,%ecx mov %eax,%edi callq 1110 <regerror@plt> mov 0x2cea(%rip),%rax lea -0x70(%rbp),%rdx lea 0xd04(%rip),%rsi mov %rax,%rdi mov $0x0,%eax callq 1100 <fprintf@plt> lea -0xb0(%rbp),%rax mov %rax,%rdi callq 10c0 <regfree@plt> lea 0xcd3(%rip),%rax mov -0x8(%rbp),%rcx xor %fs:0x28,%rcx je 1378 <func0+0x14f> callq 10d0 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 0D0h mov [rbp+string], rdi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rax, [rbp+preg] mov edx, 1; cflags lea rcx, pattern; "^[a-z]$|^([a-z]).*\\1$" mov rsi, rcx; pattern mov rdi, rax; preg call _regcomp mov [rbp+errcode], eax cmp [rbp+errcode], 0 jz short loc_12AA mov rax, cs:__bss_start mov rcx, rax; s mov edx, 18h; n mov esi, 1; size lea rax, aCouldNotCompil; "Could not compile regex\n" mov rdi, rax; ptr call _fwrite lea rax, aInvalid; "Invalid" jmp loc_136D loc_12AA: 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+errcode], eax cmp [rbp+errcode], 0 jnz short loc_12F7 lea rax, [rbp+preg] mov rdi, rax; preg call _regfree lea rax, aValid; "Valid" jmp short loc_136D loc_12F7: cmp [rbp+errcode], 1 jnz short loc_1318 lea rax, [rbp+preg] mov rdi, rax; preg call _regfree lea rax, aInvalid; "Invalid" jmp short loc_136D loc_1318: lea rdx, [rbp+errbuf]; errbuf lea rsi, [rbp+preg]; preg mov eax, [rbp+errcode] mov ecx, 64h ; 'd'; errbuf_size mov edi, eax; errcode call _regerror mov rax, cs:__bss_start lea rdx, [rbp+errbuf] lea rcx, format; "Regex match failed: %s\n" mov rsi, rcx; format mov rdi, rax; stream mov eax, 0 call _fprintf lea rax, [rbp+preg] mov rdi, rax; preg call _regfree lea rax, aInvalid; "Invalid" loc_136D: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_1381 call ___stack_chk_fail locret_1381: leave retn
const char * func0(const char *a1) { int errcode; // [rsp+1Ch] [rbp-B4h] regex_t preg; // [rsp+20h] [rbp-B0h] BYREF char errbuf[104]; // [rsp+60h] [rbp-70h] BYREF unsigned long long v5; // [rsp+C8h] [rbp-8h] v5 = __readfsqword(0x28u); if ( regcomp(&preg, "^[a-z]$|^([a-z]).*\\1$", 1) ) { fwrite("Could not compile regex\n", 1uLL, 0x18uLL, _bss_start); return "Invalid"; } else { errcode = regexec(&preg, a1, 0LL, 0LL, 0); if ( errcode ) { if ( errcode != 1 ) { regerror(errcode, &preg, errbuf, 0x64uLL); fprintf(_bss_start, "Regex match failed: %s\n", errbuf); } regfree(&preg); return "Invalid"; } else { regfree(&preg); return "Valid"; } } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0xd0 MOV qword ptr [RBP + -0xc8],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RAX,[RBP + -0xb0] MOV EDX,0x1 LEA RCX,[0x102004] MOV RSI,RCX MOV RDI,RAX CALL 0x001010f0 MOV dword ptr [RBP + -0xb4],EAX CMP dword ptr [RBP + -0xb4],0x0 JZ 0x001012aa MOV RAX,qword ptr [0x00104020] MOV RCX,RAX MOV EDX,0x18 MOV ESI,0x1 LEA RAX,[0x10201a] MOV RDI,RAX CALL 0x00101130 LEA RAX,[0x102033] JMP 0x0010136d LAB_001012aa: MOV RSI,qword ptr [RBP + -0xc8] LEA RAX,[RBP + -0xb0] MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RDI,RAX CALL 0x00101120 MOV dword ptr [RBP + -0xb4],EAX CMP dword ptr [RBP + -0xb4],0x0 JNZ 0x001012f7 LEA RAX,[RBP + -0xb0] MOV RDI,RAX CALL 0x001010c0 LEA RAX,[0x10203b] JMP 0x0010136d LAB_001012f7: CMP dword ptr [RBP + -0xb4],0x1 JNZ 0x00101318 LEA RAX,[RBP + -0xb0] MOV RDI,RAX CALL 0x001010c0 LEA RAX,[0x102033] JMP 0x0010136d LAB_00101318: LEA RDX,[RBP + -0x70] LEA RSI,[RBP + -0xb0] MOV EAX,dword ptr [RBP + -0xb4] MOV ECX,0x64 MOV EDI,EAX CALL 0x00101110 MOV RAX,qword ptr [0x00104020] LEA RDX,[RBP + -0x70] LEA RCX,[0x102041] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x00101100 LEA RAX,[RBP + -0xb0] MOV RDI,RAX CALL 0x001010c0 LEA RAX,[0x102033] LAB_0010136d: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x00101381 CALL 0x001010d0 LAB_00101381: LEAVE RET
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t local_b8; char local_78 [104]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = regcomp(&local_b8,"^[a-z]$|^([a-z]).*\\1$",1); if (iVar1 == 0) { iVar1 = regexec(&local_b8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { regfree(&local_b8); pcVar2 = "Valid"; } else if (iVar1 == 1) { regfree(&local_b8); pcVar2 = "Invalid"; } else { regerror(iVar1,&local_b8,local_78,100); fprintf(stderr,"Regex match failed: %s\n",local_78); regfree(&local_b8); pcVar2 = "Invalid"; } } else { fwrite("Could not compile regex\n",1,0x18,stderr); pcVar2 = "Invalid"; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return pcVar2; }
5,477
func0
#include <stdio.h> #include <assert.h> #include <regex.h>
char* func0(const char* string) { regex_t regex; int reti; char msgbuf[100]; // Compile regular expression reti = regcomp(&regex, "^[a-z]$|^([a-z]).*\\1$", REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return "Invalid"; } // Execute regular expression reti = regexec(&regex, string, 0, NULL, 0); if (!reti) { regfree(&regex); return "Valid"; } else if (reti == REG_NOMATCH) { regfree(&regex); return "Invalid"; } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); regfree(&regex); return "Invalid"; } }
int main() { assert(func0("abba") == "Valid"); assert(func0("a") == "Valid"); assert(func0("abcd") == "Invalid"); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0xb8,%rsp mov %rdi,%rbx mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%rdi mov $0x1,%edx lea 0xdb7(%rip),%rsi callq 10f0 <regcomp@plt> test %eax,%eax jne 12fa <func0+0xd1> mov %rsp,%rdi mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rbx,%rsi callq 1110 <regexec@plt> test %eax,%eax je 1320 <func0+0xf7> cmp $0x1,%eax je 1331 <func0+0x108> lea 0x40(%rsp),%rbp mov %rsp,%rbx mov $0x64,%ecx mov %rbp,%rdx mov %rbx,%rsi mov %eax,%edi callq 1100 <regerror@plt> mov %rbp,%rcx lea 0xd89(%rip),%rdx mov $0x1,%esi mov 0x2d5c(%rip),%rdi mov $0x0,%eax callq 1130 <__fprintf_chk@plt> mov %rbx,%rdi callq 10c0 <regfree@plt> lea 0xd27(%rip),%rax mov 0xa8(%rsp),%rcx xor %fs:0x28,%rcx jne 1342 <func0+0x119> add $0xb8,%rsp pop %rbx pop %rbp retq mov 0x2d1f(%rip),%rcx mov $0x18,%edx mov $0x1,%esi lea 0xd16(%rip),%rdi callq 1120 <fwrite@plt> lea 0xce6(%rip),%rax jmp 12dd <func0+0xb4> mov %rsp,%rdi callq 10c0 <regfree@plt> lea 0xcdd(%rip),%rax jmp 12dd <func0+0xb4> mov %rsp,%rdi callq 10c0 <regfree@plt> lea 0xcc4(%rip),%rax jmp 12dd <func0+0xb4> callq 10d0 <__stack_chk_fail@plt>
func0: endbr64 push rbp push rbx sub rsp, 0B8h mov rbx, rdi mov rax, fs:28h mov [rsp+0C8h+var_20], rax xor eax, eax mov rdi, rsp mov edx, 1 lea rsi, aAZAZ1; "^[a-z]$|^([a-z]).*\\1$" call _regcomp test eax, eax jnz loc_12FA mov rdi, rsp mov r8d, 0 mov ecx, 0 mov edx, 0 mov rsi, rbx call _regexec test eax, eax jz loc_1320 cmp eax, 1 jz loc_1331 lea rbp, [rsp+0C8h+var_88] mov rbx, rsp mov ecx, 64h ; 'd' mov rdx, rbp mov rsi, rbx mov edi, eax call _regerror mov rcx, rbp lea rdx, aRegexMatchFail; "Regex match failed: %s\n" mov esi, 1 mov rdi, cs:stderr@GLIBC_2_2_5 mov eax, 0 call ___fprintf_chk mov rdi, rbx call _regfree lea rax, aInvalid; "Invalid" loc_12DD: mov rdx, [rsp+0C8h+var_20] sub rdx, fs:28h jnz short loc_1342 add rsp, 0B8h pop rbx pop rbp retn loc_12FA: mov rcx, cs:stderr@GLIBC_2_2_5 mov edx, 18h mov esi, 1 lea rdi, aCouldNotCompil; "Could not compile regex\n" call _fwrite lea rax, aInvalid; "Invalid" jmp short loc_12DD loc_1320: mov rdi, rsp call _regfree lea rax, aValid; "Valid" jmp short loc_12DD loc_1331: mov rdi, rsp call _regfree lea rax, aInvalid; "Invalid" jmp short loc_12DD loc_1342: call ___stack_chk_fail
const char * func0(long long a1) { unsigned int v1; // eax _BYTE v3[64]; // [rsp+0h] [rbp-C8h] BYREF char v4[104]; // [rsp+40h] [rbp-88h] BYREF unsigned long long v5; // [rsp+A8h] [rbp-20h] v5 = __readfsqword(0x28u); if ( (unsigned int)regcomp(v3, "^[a-z]$|^([a-z]).*\\1$", 1LL) ) { fwrite("Could not compile regex\n", 1LL, 24LL, stderr); return "Invalid"; } else { v1 = regexec(v3, a1, 0LL, 0LL, 0LL); if ( v1 ) { if ( v1 != 1 ) { regerror(v1, v3, v4, 100LL); __fprintf_chk(stderr, 1LL, "Regex match failed: %s\n", v4); } regfree(v3); return "Invalid"; } else { regfree(v3); return "Valid"; } } }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0xb8 MOV RBX,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV RDI,RSP MOV EDX,0x1 LEA RSI,[0x102012] CALL 0x001010f0 TEST EAX,EAX JNZ 0x001012fa MOV RDI,RSP MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,RBX CALL 0x00101110 TEST EAX,EAX JZ 0x00101320 CMP EAX,0x1 JZ 0x00101331 LEA RBP,[RSP + 0x40] MOV RBX,RSP MOV ECX,0x64 MOV RDX,RBP MOV RSI,RBX MOV EDI,EAX CALL 0x00101100 MOV RCX,RBP LEA RDX,[0x102041] MOV ESI,0x1 MOV RDI,qword ptr [0x00104020] MOV EAX,0x0 CALL 0x00101130 MOV RDI,RBX CALL 0x001010c0 LEA RAX,[0x102004] LAB_001012dd: MOV RDX,qword ptr [RSP + 0xa8] SUB RDX,qword ptr FS:[0x28] JNZ 0x00101342 ADD RSP,0xb8 POP RBX POP RBP RET LAB_001012fa: MOV RCX,qword ptr [0x00104020] MOV EDX,0x18 MOV ESI,0x1 LEA RDI,[0x102028] CALL 0x00101120 LEA RAX,[0x102004] JMP 0x001012dd LAB_00101320: MOV RDI,RSP CALL 0x001010c0 LEA RAX,[0x10200c] JMP 0x001012dd LAB_00101331: MOV RDI,RSP CALL 0x001010c0 LEA RAX,[0x102004] JMP 0x001012dd LAB_00101342: CALL 0x001010d0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_c8; char local_88 [104]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = regcomp(&rStack_c8,"^[a-z]$|^([a-z]).*\\1$",1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { regfree(&rStack_c8); pcVar2 = "Valid"; } else if (iVar1 == 1) { regfree(&rStack_c8); pcVar2 = "Invalid"; } else { regerror(iVar1,&rStack_c8,local_88,100); __fprintf_chk(stderr,1,"Regex match failed: %s\n",local_88); regfree(&rStack_c8); pcVar2 = "Invalid"; } } else { fwrite("Could not compile regex\n",1,0x18,stderr); pcVar2 = "Invalid"; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,478
func0
#include <stdio.h> #include <assert.h> #include <regex.h>
char* func0(const char* string) { regex_t regex; int reti; char msgbuf[100]; // Compile regular expression reti = regcomp(&regex, "^[a-z]$|^([a-z]).*\\1$", REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return "Invalid"; } // Execute regular expression reti = regexec(&regex, string, 0, NULL, 0); if (!reti) { regfree(&regex); return "Valid"; } else if (reti == REG_NOMATCH) { regfree(&regex); return "Invalid"; } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); regfree(&regex); return "Invalid"; } }
int main() { assert(func0("abba") == "Valid"); assert(func0("a") == "Valid"); assert(func0("abcd") == "Invalid"); return 0; }
O2
c
func0: endbr64 push %r12 mov $0x1,%edx mov %rdi,%r12 lea 0xd1d(%rip),%rsi push %rbp sub $0xb8,%rsp mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%rbp mov %rbp,%rdi callq 10f0 <regcomp@plt> test %eax,%eax jne 13a8 <func0+0xc8> mov %rbp,%rdi xor %r8d,%r8d xor %ecx,%ecx xor %edx,%edx mov %r12,%rsi callq 1110 <regexec@plt> mov %eax,%edi test %eax,%eax je 13d0 <func0+0xf0> cmp $0x1,%eax je 1376 <func0+0x96> lea 0x40(%rsp),%r12 mov $0x64,%ecx mov %rbp,%rsi mov %r12,%rdx callq 1100 <regerror@plt> mov %r12,%rcx mov $0x1,%esi xor %eax,%eax mov 0x2cb6(%rip),%rdi lea 0xcd0(%rip),%rdx callq 1130 <__fprintf_chk@plt> mov %rbp,%rdi callq 10c0 <regfree@plt> lea 0xc7f(%rip),%rax mov 0xa8(%rsp),%rcx xor %fs:0x28,%rcx jne 13e1 <func0+0x101> add $0xb8,%rsp pop %rbp pop %r12 retq nopl 0x0(%rax,%rax,1) mov 0x2c71(%rip),%rcx mov $0x18,%edx mov $0x1,%esi lea 0xc68(%rip),%rdi callq 1120 <fwrite@plt> lea 0xc38(%rip),%rax jmp 1385 <func0+0xa5> xchg %ax,%ax mov %rbp,%rdi callq 10c0 <regfree@plt> lea 0xc2d(%rip),%rax jmp 1385 <func0+0xa5> callq 10d0 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r12 mov edx, 1 mov r12, rdi lea rsi, aAZAZ1; "^[a-z]$|^([a-z]).*\\1$" push rbp sub rsp, 0B8h mov rax, fs:28h mov [rsp+var_sA8], rax xor eax, eax mov rbp, rsp mov rdi, rbp call _regcomp test eax, eax jnz loc_13A8 mov rdi, rbp xor r8d, r8d xor ecx, ecx xor edx, edx mov rsi, r12 call _regexec mov edi, eax test eax, eax jz loc_13D0 cmp eax, 1 jz short loc_1376 lea r12, [rsp+var_s40] mov ecx, 64h ; 'd' mov rsi, rbp mov rdx, r12 call _regerror mov rcx, r12 mov esi, 1 xor eax, eax mov rdi, cs:stderr@GLIBC_2_2_5 lea rdx, aRegexMatchFail; "Regex match failed: %s\n" call ___fprintf_chk loc_1376: mov rdi, rbp call _regfree lea rax, aInvalid; "Invalid" loc_1385: mov rdx, [rsp+var_sA8] sub rdx, fs:28h jnz short loc_13E1 add rsp, 0B8h pop rbp pop r12 retn loc_13A8: mov rcx, cs:stderr@GLIBC_2_2_5 mov edx, 18h mov esi, 1 lea rdi, aCouldNotCompil; "Could not compile regex\n" call _fwrite lea rax, aInvalid; "Invalid" jmp short loc_1385 loc_13D0: mov rdi, rbp call _regfree lea rax, aValid; "Valid" jmp short loc_1385 loc_13E1: call ___stack_chk_fail
const char * func0(long long a1) { unsigned int v1; // eax _BYTE _0[64]; // [rsp+0h] [rbp+0h] BYREF char vars40[104]; // [rsp+40h] [rbp+40h] BYREF unsigned long long varsA8; // [rsp+A8h] [rbp+A8h] varsA8 = __readfsqword(0x28u); if ( (unsigned int)regcomp(_0, "^[a-z]$|^([a-z]).*\\1$", 1LL) ) { fwrite("Could not compile regex\n", 1LL, 24LL, stderr); return "Invalid"; } else { v1 = regexec(_0, a1, 0LL, 0LL, 0LL); if ( v1 ) { if ( v1 != 1 ) { regerror(v1, _0, vars40, 100LL); __fprintf_chk(stderr, 1LL, "Regex match failed: %s\n", vars40); } regfree(_0); return "Invalid"; } else { regfree(_0); return "Valid"; } } }
func0: ENDBR64 PUSH R12 MOV EDX,0x1 MOV R12,RDI LEA RSI,[0x102012] PUSH RBP SUB RSP,0xb8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV RBP,RSP MOV RDI,RBP CALL 0x001010f0 TEST EAX,EAX JNZ 0x001013a8 MOV RDI,RBP XOR R8D,R8D XOR ECX,ECX XOR EDX,EDX MOV RSI,R12 CALL 0x00101110 MOV EDI,EAX TEST EAX,EAX JZ 0x001013d0 CMP EAX,0x1 JZ 0x00101376 LEA R12,[RSP + 0x40] MOV ECX,0x64 MOV RSI,RBP MOV RDX,R12 CALL 0x00101100 MOV RCX,R12 MOV ESI,0x1 XOR EAX,EAX MOV RDI,qword ptr [0x00104020] LEA RDX,[0x102041] CALL 0x00101130 LAB_00101376: MOV RDI,RBP CALL 0x001010c0 LEA RAX,[0x102004] LAB_00101385: MOV RDX,qword ptr [RSP + 0xa8] SUB RDX,qword ptr FS:[0x28] JNZ 0x001013e1 ADD RSP,0xb8 POP RBP POP R12 RET LAB_001013a8: MOV RCX,qword ptr [0x00104020] MOV EDX,0x18 MOV ESI,0x1 LEA RDI,[0x102028] CALL 0x00101120 LEA RAX,[0x102004] JMP 0x00101385 LAB_001013d0: MOV RDI,RBP CALL 0x001010c0 LEA RAX,[0x10200c] JMP 0x00101385 LAB_001013e1: CALL 0x001010d0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_c8; char local_88 [104]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = regcomp(&rStack_c8,"^[a-z]$|^([a-z]).*\\1$",1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { regfree(&rStack_c8); pcVar2 = "Valid"; } else { if (iVar1 != 1) { regerror(iVar1,&rStack_c8,local_88,100); __fprintf_chk(stderr,1,"Regex match failed: %s\n",local_88); } regfree(&rStack_c8); pcVar2 = "Invalid"; } } else { fwrite("Could not compile regex\n",1,0x18,stderr); pcVar2 = "Invalid"; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,479
func0
#include <stdio.h> #include <assert.h> #include <regex.h>
char* func0(const char* string) { regex_t regex; int reti; char msgbuf[100]; // Compile regular expression reti = regcomp(&regex, "^[a-z]$|^([a-z]).*\\1$", REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return "Invalid"; } // Execute regular expression reti = regexec(&regex, string, 0, NULL, 0); if (!reti) { regfree(&regex); return "Valid"; } else if (reti == REG_NOMATCH) { regfree(&regex); return "Invalid"; } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); regfree(&regex); return "Invalid"; } }
int main() { assert(func0("abba") == "Valid"); assert(func0("a") == "Valid"); assert(func0("abcd") == "Invalid"); return 0; }
O3
c
func0: endbr64 push %r12 mov $0x1,%edx mov %rdi,%r12 lea 0xd1d(%rip),%rsi push %rbp sub $0xb8,%rsp mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%rbp mov %rbp,%rdi callq 10f0 <regcomp@plt> test %eax,%eax jne 13a8 <func0+0xc8> mov %rbp,%rdi xor %r8d,%r8d xor %ecx,%ecx xor %edx,%edx mov %r12,%rsi callq 1110 <regexec@plt> mov %eax,%edi test %eax,%eax je 13d0 <func0+0xf0> cmp $0x1,%eax je 1376 <func0+0x96> lea 0x40(%rsp),%r12 mov $0x64,%ecx mov %rbp,%rsi mov %r12,%rdx callq 1100 <regerror@plt> mov %r12,%rcx mov $0x1,%esi xor %eax,%eax mov 0x2cb6(%rip),%rdi lea 0xcd0(%rip),%rdx callq 1130 <__fprintf_chk@plt> mov %rbp,%rdi callq 10c0 <regfree@plt> lea 0xc7f(%rip),%rax mov 0xa8(%rsp),%rcx xor %fs:0x28,%rcx jne 13e1 <func0+0x101> add $0xb8,%rsp pop %rbp pop %r12 retq nopl 0x0(%rax,%rax,1) mov 0x2c71(%rip),%rcx mov $0x18,%edx mov $0x1,%esi lea 0xc68(%rip),%rdi callq 1120 <fwrite@plt> lea 0xc38(%rip),%rax jmp 1385 <func0+0xa5> xchg %ax,%ax mov %rbp,%rdi callq 10c0 <regfree@plt> lea 0xc2d(%rip),%rax jmp 1385 <func0+0xa5> callq 10d0 <__stack_chk_fail@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push rbp mov edx, 1; cflags mov rbp, rdi lea rsi, pattern; "^[a-z]$|^([a-z]).*\\1$" push rbx sub rsp, 0B8h mov rax, fs:28h mov [rsp+0C8h+var_20], rax xor eax, eax mov rbx, rsp mov rdi, rbx; preg call _regcomp test eax, eax jnz loc_13A8 xor r8d, r8d; eflags xor ecx, ecx; pmatch xor edx, edx; nmatch mov rsi, rbp; string mov rdi, rbx; preg call _regexec test eax, eax jz loc_13E0 cmp eax, 1 jz loc_13D0 lea rbp, [rsp+0C8h+errbuf] mov ecx, 64h ; 'd'; errbuf_size mov rsi, rbx; preg mov edi, eax; errcode mov rdx, rbp; errbuf call _regerror mov rcx, rbp mov esi, 2 xor eax, eax mov rdi, cs:__bss_start lea rdx, aRegexMatchFail; "Regex match failed: %s\n" call ___fprintf_chk mov rdi, rbx; preg call _regfree loc_1381: lea rax, aInvalid; "Invalid" loc_1388: mov rdx, [rsp+0C8h+var_20] sub rdx, fs:28h jnz short loc_13F1 add rsp, 0B8h pop rbx pop rbp retn loc_13A8: mov rcx, cs:__bss_start; s mov edx, 18h; n mov esi, 1; size lea rdi, aCouldNotCompil; "Could not compile regex\n" call _fwrite jmp short loc_1381 loc_13D0: mov rdi, rbx; preg call _regfree jmp short loc_1381 loc_13E0: mov rdi, rbx; preg call _regfree lea rax, aValid; "Valid" jmp short loc_1388 loc_13F1: call ___stack_chk_fail
const char * func0(char *string) { int v1; // eax regex_t v3; // [rsp+0h] [rbp-C8h] BYREF char errbuf[104]; // [rsp+40h] [rbp-88h] BYREF unsigned long long v5; // [rsp+A8h] [rbp-20h] v5 = __readfsqword(0x28u); if ( regcomp(&v3, "^[a-z]$|^([a-z]).*\\1$", 1) ) { fwrite("Could not compile regex\n", 1uLL, 0x18uLL, _bss_start); return "Invalid"; } v1 = regexec(&v3, string, 0LL, 0LL, 0); if ( v1 ) { if ( v1 != 1 ) { regerror(v1, &v3, errbuf, 0x64uLL); __fprintf_chk(_bss_start, 2LL, "Regex match failed: %s\n", errbuf); } regfree(&v3); return "Invalid"; } regfree(&v3); return "Valid"; }
func0: ENDBR64 PUSH RBP MOV EDX,0x1 MOV RBP,RDI LEA RSI,[0x102012] PUSH RBX SUB RSP,0xb8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV RBX,RSP MOV RDI,RBX CALL 0x001010f0 TEST EAX,EAX JNZ 0x001013a8 XOR R8D,R8D XOR ECX,ECX XOR EDX,EDX MOV RSI,RBP MOV RDI,RBX CALL 0x00101110 TEST EAX,EAX JZ 0x001013e0 CMP EAX,0x1 JZ 0x001013d0 LEA RBP,[RSP + 0x40] MOV ECX,0x64 MOV RSI,RBX MOV EDI,EAX MOV RDX,RBP CALL 0x00101100 MOV RCX,RBP MOV ESI,0x2 XOR EAX,EAX MOV RDI,qword ptr [0x00104020] LEA RDX,[0x102041] CALL 0x00101130 MOV RDI,RBX CALL 0x001010c0 LAB_00101381: LEA RAX,[0x102004] LAB_00101388: MOV RDX,qword ptr [RSP + 0xa8] SUB RDX,qword ptr FS:[0x28] JNZ 0x001013f1 ADD RSP,0xb8 POP RBX POP RBP RET LAB_001013a8: MOV RCX,qword ptr [0x00104020] MOV EDX,0x18 MOV ESI,0x1 LEA RDI,[0x102028] CALL 0x00101120 JMP 0x00101381 LAB_001013d0: MOV RDI,RBX CALL 0x001010c0 JMP 0x00101381 LAB_001013e0: MOV RDI,RBX CALL 0x001010c0 LEA RAX,[0x10200c] JMP 0x00101388 LAB_001013f1: CALL 0x001010d0
char * func0(char *param_1) { int iVar1; char *pcVar2; long in_FS_OFFSET; regex_t rStack_c8; char local_88 [104]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = regcomp(&rStack_c8,"^[a-z]$|^([a-z]).*\\1$",1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { regfree(&rStack_c8); pcVar2 = "Valid"; goto LAB_00101388; } if (iVar1 == 1) { regfree(&rStack_c8); } else { regerror(iVar1,&rStack_c8,local_88,100); __fprintf_chk(stderr,2,"Regex match failed: %s\n",local_88); regfree(&rStack_c8); } } else { fwrite("Could not compile regex\n",1,0x18,stderr); } pcVar2 = "Invalid"; LAB_00101388: if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return pcVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
5,480
func0
#include <assert.h>
int func0(int a, int b, int c) { int median; if (a > b) { if (a < c) { median = a; } else if (b > c) { median = b; } else { median = c; } } else { if (a > c) { median = a; } else if (b < c) { median = b; } else { median = c; } } return median; }
int main() { assert(func0(25, 55, 65) == 55); assert(func0(20, 10, 30) == 20); assert(func0(15, 45, 75) == 45); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov %edx,-0x1c(%rbp) mov -0x14(%rbp),%eax cmp -0x18(%rbp),%eax jle 118a <func0+0x41> mov -0x14(%rbp),%eax cmp -0x1c(%rbp),%eax jge 1172 <func0+0x29> mov -0x14(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11b0 <func0+0x67> mov -0x18(%rbp),%eax cmp -0x1c(%rbp),%eax jle 1182 <func0+0x39> mov -0x18(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11b0 <func0+0x67> mov -0x1c(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11b0 <func0+0x67> mov -0x14(%rbp),%eax cmp -0x1c(%rbp),%eax jle 119a <func0+0x51> mov -0x14(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11b0 <func0+0x67> mov -0x18(%rbp),%eax cmp -0x1c(%rbp),%eax jge 11aa <func0+0x61> mov -0x18(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11b0 <func0+0x67> mov -0x1c(%rbp),%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 [rbp+var_18], esi mov [rbp+var_1C], edx mov eax, [rbp+var_14] cmp eax, [rbp+var_18] jle short loc_118A mov eax, [rbp+var_14] cmp eax, [rbp+var_1C] jge short loc_1172 mov eax, [rbp+var_14] mov [rbp+var_4], eax jmp short loc_11B0 loc_1172: mov eax, [rbp+var_18] cmp eax, [rbp+var_1C] jle short loc_1182 mov eax, [rbp+var_18] mov [rbp+var_4], eax jmp short loc_11B0 loc_1182: mov eax, [rbp+var_1C] mov [rbp+var_4], eax jmp short loc_11B0 loc_118A: mov eax, [rbp+var_14] cmp eax, [rbp+var_1C] jle short loc_119A mov eax, [rbp+var_14] mov [rbp+var_4], eax jmp short loc_11B0 loc_119A: mov eax, [rbp+var_18] cmp eax, [rbp+var_1C] jge short loc_11AA mov eax, [rbp+var_18] mov [rbp+var_4], eax jmp short loc_11B0 loc_11AA: mov eax, [rbp+var_1C] mov [rbp+var_4], eax loc_11B0: mov eax, [rbp+var_4] pop rbp retn
long long func0(signed int a1, signed int a2, signed int a3) { if ( a1 <= a2 ) { if ( a1 <= a3 ) { if ( a2 >= a3 ) return (unsigned int)a3; else return (unsigned int)a2; } else { return (unsigned int)a1; } } else if ( a1 >= a3 ) { if ( a2 <= a3 ) return (unsigned int)a3; else return (unsigned int)a2; } else { return (unsigned int)a1; } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV dword ptr [RBP + -0x1c],EDX MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x18] JLE 0x0010118a MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x1c] JGE 0x00101172 MOV EAX,dword ptr [RBP + -0x14] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011b0 LAB_00101172: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x1c] JLE 0x00101182 MOV EAX,dword ptr [RBP + -0x18] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011b0 LAB_00101182: MOV EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011b0 LAB_0010118a: MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x1c] JLE 0x0010119a MOV EAX,dword ptr [RBP + -0x14] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011b0 LAB_0010119a: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x1c] JGE 0x001011aa MOV EAX,dword ptr [RBP + -0x18] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011b0 LAB_001011aa: MOV EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RBP + -0x4],EAX LAB_001011b0: MOV EAX,dword ptr [RBP + -0x4] POP RBP RET
int func0(int param_1,int param_2,int param_3) { int local_c; local_c = param_1; if (param_2 < param_1) { if ((param_3 <= param_1) && (local_c = param_3, param_3 < param_2)) { local_c = param_2; } } else if ((param_1 <= param_3) && (local_c = param_3, param_2 < param_3)) { local_c = param_2; } return local_c; }
5,481
func0
#include <assert.h>
int func0(int a, int b, int c) { int median; if (a > b) { if (a < c) { median = a; } else if (b > c) { median = b; } else { median = c; } } else { if (a > c) { median = a; } else if (b < c) { median = b; } else { median = c; } } return median; }
int main() { assert(func0(25, 55, 65) == 55); assert(func0(20, 10, 30) == 20); assert(func0(15, 45, 75) == 45); return 0; }
O1
c
func0: endbr64 mov %edi,%eax cmp %esi,%edi jle 113f <func0+0x16> cmp %edx,%edi jl 114a <func0+0x21> cmp %edx,%esi mov %edx,%eax cmovge %esi,%eax retq cmp %edx,%edi jg 114a <func0+0x21> cmp %edx,%esi mov %edx,%eax cmovle %esi,%eax retq
func0: endbr64 mov eax, edi cmp edi, esi jle short loc_113E cmp esi, edx cmovl esi, edx cmp edi, edx cmovge eax, esi retn loc_113E: cmp esi, edx cmovg esi, edx cmp edi, edx cmovle eax, esi retn
long long func0(signed int a1, signed int a2, signed int a3) { long long result; // rax result = (unsigned int)a1; if ( a1 <= a2 ) { if ( a2 > a3 ) a2 = a3; if ( a1 <= a3 ) return (unsigned int)a2; } else { if ( a2 < a3 ) a2 = a3; if ( a1 >= a3 ) return (unsigned int)a2; } return result; }
func0: ENDBR64 MOV EAX,EDI CMP EDI,ESI JLE 0x0010113e CMP ESI,EDX CMOVL ESI,EDX CMP EDI,EDX CMOVGE EAX,ESI RET LAB_0010113e: CMP ESI,EDX CMOVG ESI,EDX CMP EDI,EDX CMOVLE EAX,ESI RET
int func0(int param_1,int param_2,int param_3) { if (param_2 < param_1) { if (param_2 < param_3) { param_2 = param_3; } if (param_3 <= param_1) { param_1 = param_2; } return param_1; } if (param_3 < param_2) { param_2 = param_3; } if (param_1 <= param_3) { param_1 = param_2; } return param_1; }