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
6,482
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <ctype.h>
char** func0(const char* text, int* count) { int len = strlen(text); char** result = malloc(len * sizeof(char*)); if (result == NULL) { perror("Failed to allocate memory"); exit(EXIT_FAILURE); } int current_word = 0; int start = 0; for (int i = 1; i <= len; i++) { if (isupper(text[i]) || text[i] == '\0') { int word_length = i - start; result[current_word] = malloc(word_length+1); if (result[current_word] == NULL) { perror("Failed to allocate memory"); exit(EXIT_FAILURE); } memcpy(result[current_word], text + start, word_length); result[current_word][word_length] = '\0'; start = i; current_word++; } } *count = current_word; return result; }
int main() { int count = 0; char** result; result = func0("PythonProgramLanguage", &count); assert(count == 3); assert(strcmp(result[0], "Python") == 0); assert(strcmp(result[1], "Program") == 0); assert(strcmp(result[2], "Language") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); result = func0("PythonProgram", &count); assert(count == 2); assert(strcmp(result[0], "Python") == 0); assert(strcmp(result[1], "Program") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); result = func0("ProgrammingLanguage", &count); assert(count == 2); assert(strcmp(result[0], "Programming") == 0); assert(strcmp(result[1], "Language") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x28,%rsp mov %rsi,0x18(%rsp) callq 10e0 <strlen@plt> movslq %eax,%rdi mov %eax,0x4(%rsp) mov %rax,%rbx shl $0x3,%rdi callq 1120 <malloc@plt> mov %rax,0x10(%rsp) test %rax,%rax je 1670 <func0+0xe0> xor %ebp,%ebp test %ebx,%ebx jle 1655 <func0+0xc5> callq 1150 <__ctype_b_loc@plt> mov $0x1,%r13d xor %r15d,%r15d xor %ebp,%ebp mov (%rax),%rax mov %rax,0x8(%rsp) xchg %ax,%ax movsbq (%r12,%r13,1),%rdx mov 0x8(%rsp),%rcx mov %r13d,%ebx testb $0x1,0x1(%rcx,%rdx,2) jne 1608 <func0+0x78> test %dl,%dl jne 164a <func0+0xba> mov %ebx,%r14d sub %r15d,%r14d lea 0x1(%r14),%edi movslq %edi,%rdi callq 1120 <malloc@plt> mov 0x10(%rsp),%rcx mov %rax,%rdi movslq %ebp,%rax mov %rdi,(%rcx,%rax,8) test %rdi,%rdi je 1670 <func0+0xe0> movslq %r14d,%r14 movslq %r15d,%rsi add $0x1,%ebp mov %ebx,%r15d add %r12,%rsi mov %r14,%rdx callq 1110 <memcpy@plt> movb $0x0,(%rax,%r14,1) add $0x1,%r13 cmp %r13d,0x4(%rsp) jge 15f0 <func0+0x60> mov 0x18(%rsp),%rax mov %ebp,(%rax) mov 0x10(%rsp),%rax add $0x28,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0x98d(%rip),%rdi callq 1130 <perror@plt> mov $0x1,%edi callq 1140 <exit@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 mov r12, rdi push rbp push rbx sub rsp, 28h mov [rsp+58h+var_40], rsi call _strlen movsxd rdi, eax mov [rsp+58h+var_54], eax mov rbx, rax shl rdi, 3 call _malloc mov [rsp+58h+var_48], rax test rax, rax jz loc_163A xor ebp, ebp test ebx, ebx jle loc_161F call ___ctype_b_loc mov r13d, 1 xor r15d, r15d xor ebp, ebp mov rax, [rax] mov [rsp+58h+var_50], rax nop word ptr [rax+rax+00h] loc_15B8: movsx rsi, byte ptr [r12+r13] mov rcx, [rsp+58h+var_50] mov ebx, r13d test byte ptr [rcx+rsi*2+1], 1 jnz short loc_15D1 test sil, sil jnz short loc_1614 loc_15D1: mov r14d, ebx sub r14d, r15d lea edi, [r14+1] movsxd rdi, edi call _malloc mov rdx, [rsp+58h+var_48] mov rdi, rax movsxd rax, ebp mov [rdx+rax*8], rdi test rdi, rdi jz short loc_163A movsxd rdx, r15d movsxd r14, r14d add ebp, 1 mov r15d, ebx lea rsi, [r12+rdx] mov rdx, r14 call _memcpy mov byte ptr [rax+r14], 0 loc_1614: add r13, 1 cmp [rsp+58h+var_54], r13d jge short loc_15B8 loc_161F: mov rax, [rsp+58h+var_40] mov [rax], ebp mov rax, [rsp+58h+var_48] add rsp, 28h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_163A: lea rdi, aFailedToAlloca; "Failed to allocate memory" call _perror mov edi, 1 call _exit
long long func0(long long a1, _DWORD *a2) { int v3; // ebp long long v4; // r13 int v5; // r15d long long v6; // rsi int v7; // r14d long long v8; // rdi long long v9; // rdx int v11; // [rsp+4h] [rbp-54h] long long v12; // [rsp+8h] [rbp-50h] long long v13; // [rsp+10h] [rbp-48h] v11 = strlen(); v13 = malloc(8LL * v11); if ( !v13 ) { LABEL_10: perror("Failed to allocate memory"); exit(1LL); } v3 = 0; if ( v11 > 0 ) { v4 = 1LL; v5 = 0; v3 = 0; v12 = *(_QWORD *)__ctype_b_loc(); do { v6 = *(char *)(a1 + v4); if ( (*(_BYTE *)(v12 + 2 * v6 + 1) & 1) != 0 || !(_BYTE)v6 ) { v7 = v4 - v5; v8 = malloc((int)v4 - v5 + 1); *(_QWORD *)(v13 + 8LL * v3) = v8; if ( !v8 ) goto LABEL_10; v9 = v5; ++v3; v5 = v4; *(_BYTE *)(memcpy(v8, a1 + v9, v7) + v7) = 0; } ++v4; } while ( v11 >= (int)v4 ); } *a2 = v3; return v13; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12,RDI PUSH RBP PUSH RBX SUB RSP,0x28 MOV qword ptr [RSP + 0x18],RSI CALL 0x001010f0 MOVSXD RDI,EAX MOV dword ptr [RSP + 0x4],EAX MOV RBX,RAX SHL RDI,0x3 CALL 0x00101140 MOV qword ptr [RSP + 0x10],RAX TEST RAX,RAX JZ 0x0010163a XOR EBP,EBP TEST EBX,EBX JLE 0x0010161f CALL 0x00101170 MOV R13D,0x1 XOR R15D,R15D XOR EBP,EBP MOV RAX,qword ptr [RAX] MOV qword ptr [RSP + 0x8],RAX NOP word ptr [RAX + RAX*0x1] LAB_001015b8: MOVSX RSI,byte ptr [R12 + R13*0x1] MOV RCX,qword ptr [RSP + 0x8] MOV EBX,R13D TEST byte ptr [RCX + RSI*0x2 + 0x1],0x1 JNZ 0x001015d1 TEST SIL,SIL JNZ 0x00101614 LAB_001015d1: MOV R14D,EBX SUB R14D,R15D LEA EDI,[R14 + 0x1] MOVSXD RDI,EDI CALL 0x00101140 MOV RDX,qword ptr [RSP + 0x10] MOV RDI,RAX MOVSXD RAX,EBP MOV qword ptr [RDX + RAX*0x8],RDI TEST RDI,RDI JZ 0x0010163a MOVSXD RDX,R15D MOVSXD R14,R14D ADD EBP,0x1 MOV R15D,EBX LEA RSI,[R12 + RDX*0x1] MOV RDX,R14 CALL 0x00101130 MOV byte ptr [RAX + R14*0x1],0x0 LAB_00101614: ADD R13,0x1 CMP dword ptr [RSP + 0x4],R13D JGE 0x001015b8 LAB_0010161f: MOV RAX,qword ptr [RSP + 0x18] MOV dword ptr [RAX],EBP MOV RAX,qword ptr [RSP + 0x10] ADD RSP,0x28 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010163a: LEA RDI,[0x102004] CALL 0x00101150 MOV EDI,0x1 CALL 0x00101160
void * func0(char *param_1,int *param_2) { ushort *puVar1; int iVar2; size_t sVar3; void *pvVar4; ushort **ppuVar5; void *pvVar6; int iVar7; long lVar8; int iVar9; int iVar10; sVar3 = strlen(param_1); iVar2 = (int)sVar3; pvVar4 = malloc((long)iVar2 << 3); if (pvVar4 != (void *)0x0) { iVar7 = 0; if (0 < iVar2) { ppuVar5 = __ctype_b_loc(); lVar8 = 1; iVar10 = 0; iVar7 = 0; puVar1 = *ppuVar5; do { if (((*(byte *)((long)puVar1 + (long)param_1[lVar8] * 2 + 1) & 1) != 0) || (param_1[lVar8] == '\0')) { iVar9 = (int)lVar8 - iVar10; pvVar6 = malloc((long)(iVar9 + 1)); *(void **)((long)pvVar4 + (long)iVar7 * 8) = pvVar6; if (pvVar6 == (void *)0x0) goto LAB_0010163a; iVar7 = iVar7 + 1; pvVar6 = memcpy(pvVar6,param_1 + iVar10,(long)iVar9); *(int1 *)((long)pvVar6 + (long)iVar9) = 0; iVar10 = (int)lVar8; } lVar8 = lVar8 + 1; } while ((int)lVar8 <= iVar2); } *param_2 = iVar7; return pvVar4; } LAB_0010163a: perror("Failed to allocate memory"); /* WARNING: Subroutine does not return */ exit(1); }
6,483
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <ctype.h>
char** func0(const char* text, int* count) { int len = strlen(text); char** result = malloc(len * sizeof(char*)); if (result == NULL) { perror("Failed to allocate memory"); exit(EXIT_FAILURE); } int current_word = 0; int start = 0; for (int i = 1; i <= len; i++) { if (isupper(text[i]) || text[i] == '\0') { int word_length = i - start; result[current_word] = malloc(word_length+1); if (result[current_word] == NULL) { perror("Failed to allocate memory"); exit(EXIT_FAILURE); } memcpy(result[current_word], text + start, word_length); result[current_word][word_length] = '\0'; start = i; current_word++; } } *count = current_word; return result; }
int main() { int count = 0; char** result; result = func0("PythonProgramLanguage", &count); assert(count == 3); assert(strcmp(result[0], "Python") == 0); assert(strcmp(result[1], "Program") == 0); assert(strcmp(result[2], "Language") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); result = func0("PythonProgram", &count); assert(count == 2); assert(strcmp(result[0], "Python") == 0); assert(strcmp(result[1], "Program") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); result = func0("ProgrammingLanguage", &count); assert(count == 2); assert(strcmp(result[0], "Programming") == 0); assert(strcmp(result[1], "Language") == 0); for (int i = 0; i < count; i++) free(result[i]); free(result); return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x28,%rsp mov %rsi,0x18(%rsp) callq 10e0 <strlen@plt> movslq %eax,%rdi mov %eax,0x4(%rsp) mov %rax,%rbx shl $0x3,%rdi callq 1120 <malloc@plt> mov %rax,0x10(%rsp) test %rax,%rax je 1650 <func0+0xe0> xor %ebp,%ebp test %ebx,%ebx jle 1635 <func0+0xc5> callq 1150 <__ctype_b_loc@plt> mov $0x1,%r13d xor %r15d,%r15d xor %ebp,%ebp mov (%rax),%rax mov %rax,0x8(%rsp) xchg %ax,%ax movsbq (%r12,%r13,1),%rdx mov 0x8(%rsp),%rcx mov %r13d,%ebx testb $0x1,0x1(%rcx,%rdx,2) jne 15e8 <func0+0x78> test %dl,%dl jne 162a <func0+0xba> mov %ebx,%r14d sub %r15d,%r14d lea 0x1(%r14),%edi movslq %edi,%rdi callq 1120 <malloc@plt> mov 0x10(%rsp),%rcx mov %rax,%rdi movslq %ebp,%rax mov %rdi,(%rcx,%rax,8) test %rdi,%rdi je 1650 <func0+0xe0> movslq %r14d,%r14 movslq %r15d,%rsi add $0x1,%ebp mov %ebx,%r15d add %r12,%rsi mov %r14,%rdx callq 1110 <memcpy@plt> movb $0x0,(%rax,%r14,1) add $0x1,%r13 cmp %r13d,0x4(%rsp) jge 15d0 <func0+0x60> mov 0x18(%rsp),%rax mov %ebp,(%rax) mov 0x10(%rsp),%rax add $0x28,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0x9ad(%rip),%rdi callq 1130 <perror@plt> mov $0x1,%edi callq 1140 <exit@plt> nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r15 push r14 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 28h mov [rsp+58h+var_40], rsi call _strlen movsxd rdi, eax mov [rsp+58h+var_4C], eax mov rbx, rax shl rdi, 3; size call _malloc mov [rsp+58h+var_48], rax test rax, rax jz func0_cold test ebx, ebx jle loc_1660 call ___ctype_b_loc mov r13d, 1 xor r15d, r15d xor ebx, ebx mov r14, [rax] nop dword ptr [rax+rax+00h] loc_15D0: movsx rcx, byte ptr [rbp+r13+0] test byte ptr [r14+rcx*2+1], 1 jnz short loc_15E2 test cl, cl jnz short loc_1636 loc_15E2: mov r12d, r13d sub r12d, r15d lea ecx, [r12+1] movsxd rcx, ecx mov rdi, rcx; size mov [rsp+58h+var_58], rcx call _malloc mov rdx, [rsp+58h+var_48] mov rdi, rax movsxd rax, ebx mov [rdx+rax*8], rdi test rdi, rdi jz func0_cold movsxd rdx, r15d movsxd r12, r12d mov rcx, [rsp+58h+var_58] add ebx, 1 lea rsi, [rbp+rdx+0] mov rdx, r12 mov r15d, r13d call ___memcpy_chk mov byte ptr [rax+r12], 0 loc_1636: add r13, 1 cmp [rsp+58h+var_4C], r13d jge short loc_15D0 loc_1641: mov rax, [rsp+58h+var_40] mov [rax], ebx mov rax, [rsp+58h+var_48] add rsp, 28h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1660: xor ebx, ebx jmp short loc_1641
_QWORD * func0(const char *a1, _DWORD *a2) { long long v3; // r13 int v4; // r15d int v5; // ebx const unsigned __int16 *v6; // r14 long long v7; // rcx int v8; // r12d void *v9; // rdi const char *v10; // rsi int v12; // [rsp+Ch] [rbp-4Ch] _QWORD *v13; // [rsp+10h] [rbp-48h] v12 = strlen(a1); v13 = malloc(8LL * v12); if ( !v13 ) LABEL_11: func0_cold(); if ( v12 <= 0 ) { v5 = 0; } else { v3 = 1LL; v4 = 0; v5 = 0; v6 = *__ctype_b_loc(); do { v7 = a1[v3]; if ( (v6[v7] & 0x100) != 0 || !(_BYTE)v7 ) { v8 = v3 - v4; v9 = malloc((int)v3 - v4 + 1); v13[v5] = v9; if ( !v9 ) goto LABEL_11; ++v5; v10 = &a1[v4]; v4 = v3; *(_BYTE *)(__memcpy_chk(v9, v10, v8, v8 + 1) + v8) = 0; } ++v3; } while ( v12 >= (int)v3 ); } *a2 = v5; return v13; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x28 MOV qword ptr [RSP + 0x18],RSI CALL 0x001010f0 MOVSXD RDI,EAX MOV dword ptr [RSP + 0xc],EAX MOV RBX,RAX SHL RDI,0x3 CALL 0x00101140 MOV qword ptr [RSP + 0x10],RAX TEST RAX,RAX JZ 0x00101180 TEST EBX,EBX JLE 0x00101660 CALL 0x00101170 MOV R13D,0x1 XOR R15D,R15D XOR EBX,EBX MOV R14,qword ptr [RAX] NOP dword ptr [RAX + RAX*0x1] LAB_001015d0: MOVSX RCX,byte ptr [RBP + R13*0x1] TEST byte ptr [R14 + RCX*0x2 + 0x1],0x1 JNZ 0x001015e2 TEST CL,CL JNZ 0x00101636 LAB_001015e2: MOV R12D,R13D SUB R12D,R15D LEA ECX,[R12 + 0x1] MOVSXD RCX,ECX MOV RDI,RCX MOV qword ptr [RSP],RCX CALL 0x00101140 MOV RDX,qword ptr [RSP + 0x10] MOV RDI,RAX MOVSXD RAX,EBX MOV qword ptr [RDX + RAX*0x8],RDI TEST RDI,RDI JZ 0x00101180 MOVSXD RDX,R15D MOVSXD R12,R12D MOV RCX,qword ptr [RSP] ADD EBX,0x1 LEA RSI,[RBP + RDX*0x1] MOV RDX,R12 MOV R15D,R13D CALL 0x00101130 MOV byte ptr [RAX + R12*0x1],0x0 LAB_00101636: ADD R13,0x1 CMP dword ptr [RSP + 0xc],R13D JGE 0x001015d0 LAB_00101641: MOV RAX,qword ptr [RSP + 0x18] MOV dword ptr [RAX],EBX MOV RAX,qword ptr [RSP + 0x10] ADD RSP,0x28 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101660: XOR EBX,EBX JMP 0x00101641
void * func0(char *param_1,int *param_2) { ushort *puVar1; int iVar2; size_t sVar3; void *pvVar4; ushort **ppuVar5; void *pvVar6; long lVar7; int iVar8; int iVar9; long lVar10; int iVar11; sVar3 = strlen(param_1); iVar2 = (int)sVar3; pvVar4 = malloc((long)iVar2 << 3); if (pvVar4 != (void *)0x0) { if (iVar2 < 1) { iVar8 = 0; } else { ppuVar5 = __ctype_b_loc(); lVar10 = 1; iVar11 = 0; iVar8 = 0; puVar1 = *ppuVar5; do { if (((*(byte *)((long)puVar1 + (long)param_1[lVar10] * 2 + 1) & 1) != 0) || (param_1[lVar10] == '\0')) { iVar9 = (int)lVar10 - iVar11; pvVar6 = malloc((long)(iVar9 + 1)); *(void **)((long)pvVar4 + (long)iVar8 * 8) = pvVar6; if (pvVar6 == (void *)0x0) goto func0_cold; iVar8 = iVar8 + 1; lVar7 = __memcpy_chk(pvVar6,param_1 + iVar11,(long)iVar9,(long)(iVar9 + 1)); *(int *)(lVar7 + iVar9) = 0; iVar11 = (int)lVar10; } lVar10 = lVar10 + 1; } while ((int)lVar10 <= iVar2); } *param_2 = iVar8; return pvVar4; } func0_cold: perror("Failed to allocate memory"); /* WARNING: Subroutine does not return */ exit(1); }
6,484
func0
#include <assert.h> #include <stdlib.h>
int* func0(int lst[], int size) { int* result = malloc(size * sizeof(int)); int i; for (i = 0; i < size; i += 2) { if (i + 1 < size) { result[i] = lst[i + 1]; result[i + 1] = lst[i]; } else { result[i] = lst[i]; } } return result; }
int main() { int lst1[] = {0, 1, 2, 3, 4, 5}; int size1 = sizeof(lst1) / sizeof(lst1[0]); int* result1 = func0(lst1, size1); int expected1[] = {1, 0, 3, 2, 5, 4}; for (int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int lst2[] = {5, 6, 7, 8, 9, 10}; int size2 = sizeof(lst2) / sizeof(lst2[0]); int* result2 = func0(lst2, size2); int expected2[] = {6, 5, 8, 7, 10, 9}; for (int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int lst3[] = {25, 35, 45, 55, 75, 95}; int size3 = sizeof(lst3) / sizeof(lst3[0]); int* result3 = func0(lst3, size3); int expected3[] = {35, 25, 55, 45, 95, 75}; for (int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } free(result1); free(result2); free(result3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov -0x1c(%rbp),%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) movl $0x0,-0xc(%rbp) jmpq 127d <func0+0xd4> mov -0xc(%rbp),%eax add $0x1,%eax cmp %eax,-0x1c(%rbp) jle 124c <func0+0xa3> mov -0xc(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0xc(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0xc(%rbp),%edx movslq %edx,%rdx add $0x1,%rdx lea 0x0(,%rdx,4),%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) jmp 1279 <func0+0xd0> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov -0xc(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x8(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) addl $0x2,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x1c(%rbp),%eax jl 11dd <func0+0x34> mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov eax, [rbp+var_1C] cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_8], rax mov [rbp+var_C], 0 jmp loc_127D loc_11DD: mov eax, [rbp+var_C] add eax, 1 cmp [rbp+var_1C], eax jle short loc_124C mov eax, [rbp+var_C] cdqe add rax, 1 lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rbp+var_C] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_8] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rbp+var_C] movsxd rdx, edx add rdx, 1 lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_8] add rdx, rcx mov eax, [rax] mov [rdx], eax jmp short loc_1279 loc_124C: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rbp+var_C] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_8] add rdx, rcx mov eax, [rax] mov [rdx], eax loc_1279: add [rbp+var_C], 2 loc_127D: mov eax, [rbp+var_C] cmp eax, [rbp+var_1C] jl loc_11DD mov rax, [rbp+var_8] leave retn
_DWORD * func0(long long a1, int a2) { long long v2; // rcx int i; // [rsp+14h] [rbp-Ch] _DWORD *v5; // [rsp+18h] [rbp-8h] v5 = malloc(4LL * a2); for ( i = 0; i < a2; i += 2 ) { if ( a2 <= i + 1 ) { v2 = i; } else { v5[i] = *(_DWORD *)(4 * (i + 1LL) + a1); v2 = i + 1LL; } v5[v2] = *(_DWORD *)(4LL * i + a1); } return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV EAX,dword ptr [RBP + -0x1c] CDQE SHL RAX,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX MOV dword ptr [RBP + -0xc],0x0 JMP 0x0010127d LAB_001011dd: MOV EAX,dword ptr [RBP + -0xc] ADD EAX,0x1 CMP dword ptr [RBP + -0x1c],EAX JLE 0x0010124c MOV EAX,dword ptr [RBP + -0xc] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX ADD RDX,0x1 LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX JMP 0x00101279 LAB_0010124c: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0xc] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x8] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX LAB_00101279: ADD dword ptr [RBP + -0xc],0x2 LAB_0010127d: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x1c] JL 0x001011dd MOV RAX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(long param_1,int param_2) { void *pvVar1; int4 local_14; pvVar1 = malloc((long)param_2 << 2); for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 2) { if (local_14 + 1 < param_2) { *(int4 *)((long)pvVar1 + (long)local_14 * 4) = *(int4 *)(param_1 + ((long)local_14 + 1) * 4); *(int4 *)((long)pvVar1 + ((long)local_14 + 1) * 4) = *(int4 *)(param_1 + (long)local_14 * 4); } else { *(int4 *)((long)pvVar1 + (long)local_14 * 4) = *(int4 *)(param_1 + (long)local_14 * 4); } } return pvVar1; }
6,485
func0
#include <assert.h> #include <stdlib.h>
int* func0(int lst[], int size) { int* result = malloc(size * sizeof(int)); int i; for (i = 0; i < size; i += 2) { if (i + 1 < size) { result[i] = lst[i + 1]; result[i + 1] = lst[i]; } else { result[i] = lst[i]; } } return result; }
int main() { int lst1[] = {0, 1, 2, 3, 4, 5}; int size1 = sizeof(lst1) / sizeof(lst1[0]); int* result1 = func0(lst1, size1); int expected1[] = {1, 0, 3, 2, 5, 4}; for (int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int lst2[] = {5, 6, 7, 8, 9, 10}; int size2 = sizeof(lst2) / sizeof(lst2[0]); int* result2 = func0(lst2, size2); int expected2[] = {6, 5, 8, 7, 10, 9}; for (int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int lst3[] = {25, 35, 45, 55, 75, 95}; int size3 = sizeof(lst3) / sizeof(lst3[0]); int* result3 = func0(lst3, size3); int expected3[] = {35, 25, 55, 45, 95, 75}; for (int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } free(result1); free(result2); free(result3); return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0x8,%rsp mov %rdi,%rbp mov %esi,%ebx movslq %esi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> test %ebx,%ebx jle 11f6 <func0+0x4d> mov $0x0,%edx jmp 11de <func0+0x35> mov 0x0(%rbp,%rdx,4),%ecx mov %ecx,(%rax,%rdx,4) add $0x2,%rdx cmp %edx,%ebx jle 11f6 <func0+0x4d> lea 0x1(%rdx),%ecx cmp %ecx,%ebx jle 11cf <func0+0x26> mov 0x4(%rbp,%rdx,4),%ecx mov %ecx,(%rax,%rdx,4) mov 0x0(%rbp,%rdx,4),%ecx mov %ecx,0x4(%rax,%rdx,4) jmp 11d6 <func0+0x2d> add $0x8,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp push rbx sub rsp, 8 mov rbp, rdi mov ebx, esi movsxd rdi, esi shl rdi, 2 call _malloc test ebx, ebx jle short loc_11F6 mov edx, 0 jmp short loc_11DE loc_11CF: mov ecx, [rbp+rdx*4+0] mov [rax+rdx*4], ecx loc_11D6: add rdx, 2 cmp ebx, edx jle short loc_11F6 loc_11DE: lea ecx, [rdx+1] cmp ebx, ecx jle short loc_11CF mov ecx, [rbp+rdx*4+4] mov [rax+rdx*4], ecx mov ecx, [rbp+rdx*4+0] mov [rax+rdx*4+4], ecx jmp short loc_11D6 loc_11F6: add rsp, 8 pop rbx pop rbp retn
long long func0(long long a1, int a2) { long long result; // rax long long v3; // rdx result = malloc(4LL * a2); if ( a2 > 0 ) { v3 = 0LL; do { if ( a2 <= (int)v3 + 1 ) { *(_DWORD *)(result + 4 * v3) = *(_DWORD *)(a1 + 4 * v3); } else { *(_DWORD *)(result + 4 * v3) = *(_DWORD *)(a1 + 4 * v3 + 4); *(_DWORD *)(result + 4 * v3 + 4) = *(_DWORD *)(a1 + 4 * v3); } v3 += 2LL; } while ( a2 > (int)v3 ); } return result; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x8 MOV RBP,RDI MOV EBX,ESI MOVSXD RDI,ESI SHL RDI,0x2 CALL 0x001010b0 TEST EBX,EBX JLE 0x001011f6 MOV EDX,0x0 JMP 0x001011de LAB_001011cf: MOV ECX,dword ptr [RBP + RDX*0x4] MOV dword ptr [RAX + RDX*0x4],ECX LAB_001011d6: ADD RDX,0x2 CMP EBX,EDX JLE 0x001011f6 LAB_001011de: LEA ECX,[RDX + 0x1] CMP EBX,ECX JLE 0x001011cf MOV ECX,dword ptr [RBP + RDX*0x4 + 0x4] MOV dword ptr [RAX + RDX*0x4],ECX MOV ECX,dword ptr [RBP + RDX*0x4] MOV dword ptr [RAX + RDX*0x4 + 0x4],ECX JMP 0x001011d6 LAB_001011f6: ADD RSP,0x8 POP RBX POP RBP RET
void func0(long param_1,int param_2) { void *pvVar1; long lVar2; pvVar1 = malloc((long)param_2 << 2); if (0 < param_2) { lVar2 = 0; do { if ((int)lVar2 + 1 < param_2) { *(int4 *)((long)pvVar1 + lVar2 * 4) = *(int4 *)(param_1 + 4 + lVar2 * 4); *(int4 *)((long)pvVar1 + lVar2 * 4 + 4) = *(int4 *)(param_1 + lVar2 * 4); } else { *(int4 *)((long)pvVar1 + lVar2 * 4) = *(int4 *)(param_1 + lVar2 * 4); } lVar2 = lVar2 + 2; } while ((int)lVar2 < param_2); } return; }
6,486
func0
#include <assert.h> #include <stdlib.h>
int* func0(int lst[], int size) { int* result = malloc(size * sizeof(int)); int i; for (i = 0; i < size; i += 2) { if (i + 1 < size) { result[i] = lst[i + 1]; result[i + 1] = lst[i]; } else { result[i] = lst[i]; } } return result; }
int main() { int lst1[] = {0, 1, 2, 3, 4, 5}; int size1 = sizeof(lst1) / sizeof(lst1[0]); int* result1 = func0(lst1, size1); int expected1[] = {1, 0, 3, 2, 5, 4}; for (int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int lst2[] = {5, 6, 7, 8, 9, 10}; int size2 = sizeof(lst2) / sizeof(lst2[0]); int* result2 = func0(lst2, size2); int expected2[] = {6, 5, 8, 7, 10, 9}; for (int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int lst3[] = {25, 35, 45, 55, 75, 95}; int size3 = sizeof(lst3) / sizeof(lst3[0]); int* result3 = func0(lst3, size3); int expected3[] = {35, 25, 55, 45, 95, 75}; for (int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } free(result1); free(result2); free(result3); return 0; }
O2
c
func0: endbr64 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx mov %rdi,%rbx shl $0x2,%rdi sub $0x8,%rsp callq 10b0 <malloc@plt> test %ebx,%ebx jle 1481 <func0+0x51> xor %edx,%edx jmp 146b <func0+0x3b> nopl 0x0(%rax) mov 0x4(%rbp,%rdx,4),%ecx mov %esi,0x4(%rax,%rdx,4) mov %ecx,(%rax,%rdx,4) add $0x2,%rdx cmp %edx,%ebx jle 1481 <func0+0x51> lea 0x1(%rdx),%ecx mov 0x0(%rbp,%rdx,4),%esi cmp %ecx,%ebx jg 1458 <func0+0x28> mov %esi,(%rax,%rdx,4) add $0x2,%rdx cmp %edx,%ebx jg 146b <func0+0x3b> add $0x8,%rsp pop %rbx pop %rbp retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp mov rbp, rdi movsxd rdi, esi push rbx mov rbx, rdi shl rdi, 2 sub rsp, 8 call _malloc test ebx, ebx jle short loc_1481 xor edx, edx jmp short loc_146B loc_1458: mov ecx, [rbp+rdx*4+4] mov [rax+rdx*4+4], esi mov [rax+rdx*4], ecx add rdx, 2 cmp ebx, edx jle short loc_1481 loc_146B: lea ecx, [rdx+1] mov esi, [rbp+rdx*4+0] cmp ecx, ebx jl short loc_1458 mov [rax+rdx*4], esi add rdx, 2 cmp ebx, edx jg short loc_146B loc_1481: add rsp, 8 pop rbx pop rbp retn
long long func0(long long a1, int a2) { long long result; // rax long long v4; // rdx int v5; // ecx int v6; // esi result = malloc(4LL * a2); if ( a2 > 0 ) { v4 = 0LL; do { while ( 1 ) { v6 = *(_DWORD *)(a1 + 4 * v4); if ( (int)v4 + 1 >= a2 ) break; v5 = *(_DWORD *)(a1 + 4 * v4 + 4); *(_DWORD *)(result + 4 * v4 + 4) = v6; *(_DWORD *)(result + 4 * v4) = v5; v4 += 2LL; if ( a2 <= (int)v4 ) return result; } *(_DWORD *)(result + 4 * v4) = v6; v4 += 2LL; } while ( a2 > (int)v4 ); } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RDI MOVSXD RDI,ESI PUSH RBX MOV RBX,RDI SHL RDI,0x2 SUB RSP,0x8 CALL 0x001010b0 TEST EBX,EBX JLE 0x00101481 XOR EDX,EDX JMP 0x0010146b LAB_00101458: MOV ECX,dword ptr [RBP + RDX*0x4 + 0x4] MOV dword ptr [RAX + RDX*0x4 + 0x4],ESI MOV dword ptr [RAX + RDX*0x4],ECX ADD RDX,0x2 CMP EBX,EDX JLE 0x00101481 LAB_0010146b: LEA ECX,[RDX + 0x1] MOV ESI,dword ptr [RBP + RDX*0x4] CMP ECX,EBX JL 0x00101458 MOV dword ptr [RAX + RDX*0x4],ESI ADD RDX,0x2 CMP EBX,EDX JG 0x0010146b LAB_00101481: ADD RSP,0x8 POP RBX POP RBP RET
void func0(long param_1,int param_2) { int4 uVar1; int4 uVar2; void *pvVar3; long lVar4; pvVar3 = malloc((long)param_2 << 2); if (0 < param_2) { lVar4 = 0; do { while (uVar2 = *(int4 *)(param_1 + lVar4 * 4), param_2 <= (int)lVar4 + 1) { *(int4 *)((long)pvVar3 + lVar4 * 4) = uVar2; lVar4 = lVar4 + 2; if (param_2 <= (int)lVar4) { return; } } uVar1 = *(int4 *)(param_1 + 4 + lVar4 * 4); *(int4 *)((long)pvVar3 + lVar4 * 4 + 4) = uVar2; *(int4 *)((long)pvVar3 + lVar4 * 4) = uVar1; lVar4 = lVar4 + 2; } while ((int)lVar4 < param_2); } return; }
6,487
func0
#include <assert.h> #include <stdlib.h>
int* func0(int lst[], int size) { int* result = malloc(size * sizeof(int)); int i; for (i = 0; i < size; i += 2) { if (i + 1 < size) { result[i] = lst[i + 1]; result[i + 1] = lst[i]; } else { result[i] = lst[i]; } } return result; }
int main() { int lst1[] = {0, 1, 2, 3, 4, 5}; int size1 = sizeof(lst1) / sizeof(lst1[0]); int* result1 = func0(lst1, size1); int expected1[] = {1, 0, 3, 2, 5, 4}; for (int i = 0; i < size1; i++) { assert(result1[i] == expected1[i]); } int lst2[] = {5, 6, 7, 8, 9, 10}; int size2 = sizeof(lst2) / sizeof(lst2[0]); int* result2 = func0(lst2, size2); int expected2[] = {6, 5, 8, 7, 10, 9}; for (int i = 0; i < size2; i++) { assert(result2[i] == expected2[i]); } int lst3[] = {25, 35, 45, 55, 75, 95}; int size3 = sizeof(lst3) / sizeof(lst3[0]); int* result3 = func0(lst3, size3); int expected3[] = {35, 25, 55, 45, 95, 75}; for (int i = 0; i < size3; i++) { assert(result3[i] == expected3[i]); } free(result1); free(result2); free(result3); return 0; }
O3
c
func0: endbr64 push %rbp mov %rdi,%rbp movslq %esi,%rdi push %rbx mov %rdi,%rbx shl $0x2,%rdi sub $0x8,%rsp callq 10b0 <malloc@plt> test %ebx,%ebx jle 1451 <func0+0x51> xor %edx,%edx jmp 143b <func0+0x3b> nopl 0x0(%rax) mov 0x4(%rbp,%rdx,4),%ecx mov %esi,0x4(%rax,%rdx,4) mov %ecx,(%rax,%rdx,4) add $0x2,%rdx cmp %edx,%ebx jle 1451 <func0+0x51> lea 0x1(%rdx),%ecx mov 0x0(%rbp,%rdx,4),%esi cmp %ebx,%ecx jl 1428 <func0+0x28> mov %esi,(%rax,%rdx,4) add $0x2,%rdx cmp %edx,%ebx jg 143b <func0+0x3b> add $0x8,%rsp pop %rbx pop %rbp retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push rbp mov rbp, rdi movsxd rdi, esi push rbx mov rbx, rdi shl rdi, 2; size sub rsp, 8 call _malloc test ebx, ebx jle short loc_13D9 xor edx, edx jmp short loc_13BF loc_13A8: movd xmm1, dword ptr [rbp+rdx*4+4] punpckldq xmm1, xmm0 movq qword ptr [rax+rdx*4], xmm1 add rdx, 2 cmp ebx, edx jle short loc_13D9 loc_13BF: lea ecx, [rdx+1] movd xmm0, dword ptr [rbp+rdx*4+0] cmp ebx, ecx jg short loc_13A8 movd dword ptr [rax+rdx*4], xmm0 add rdx, 2 cmp ebx, edx jg short loc_13BF loc_13D9: add rsp, 8 pop rbx pop rbp retn
_DWORD * func0(long long a1, int a2) { _DWORD *result; // rax long long v3; // rdx __m128i v4; // xmm0 result = malloc(4LL * a2); if ( a2 > 0 ) { v3 = 0LL; do { while ( 1 ) { v4 = _mm_cvtsi32_si128(*(_DWORD *)(a1 + 4 * v3)); if ( a2 <= (int)v3 + 1 ) break; *(_QWORD *)&result[v3] = _mm_unpacklo_epi32(_mm_cvtsi32_si128(*(_DWORD *)(a1 + 4 * v3 + 4)), v4).m128i_u64[0]; v3 += 2LL; if ( a2 <= (int)v3 ) return result; } result[v3] = _mm_cvtsi128_si32(v4); v3 += 2LL; } while ( a2 > (int)v3 ); } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RDI MOVSXD RDI,ESI PUSH RBX MOV RBX,RDI SHL RDI,0x2 SUB RSP,0x8 CALL 0x001010b0 TEST EBX,EBX JLE 0x001013d9 XOR EDX,EDX JMP 0x001013bf LAB_001013a8: MOVD XMM1,dword ptr [RBP + RDX*0x4 + 0x4] PUNPCKLDQ XMM1,XMM0 MOVQ qword ptr [RAX + RDX*0x4],XMM1 ADD RDX,0x2 CMP EBX,EDX JLE 0x001013d9 LAB_001013bf: LEA ECX,[RDX + 0x1] MOVD XMM0,dword ptr [RBP + RDX*0x4] CMP EBX,ECX JG 0x001013a8 MOVD dword ptr [RAX + RDX*0x4],XMM0 ADD RDX,0x2 CMP EBX,EDX JG 0x001013bf LAB_001013d9: ADD RSP,0x8 POP RBX POP RBP RET
void func0(long param_1,int param_2) { int4 uVar1; void *pvVar2; long lVar3; pvVar2 = malloc((long)param_2 << 2); if (0 < param_2) { lVar3 = 0; do { while (uVar1 = *(int4 *)(param_1 + lVar3 * 4), param_2 <= (int)lVar3 + 1) { *(int4 *)((long)pvVar2 + lVar3 * 4) = uVar1; lVar3 = lVar3 + 2; if (param_2 <= (int)lVar3) { return; } } *(ulong *)((long)pvVar2 + lVar3 * 4) = CONCAT44(uVar1,*(int4 *)(param_1 + 4 + lVar3 * 4)); lVar3 = lVar3 + 2; } while ((int)lVar3 < param_2); } return; }
6,488
func0
#include <assert.h>
int func0(int nums[], int m, int n) { int sum_range = 0; for (int i = m; i <= n; i++) { sum_range += nums[i]; } return sum_range; }
int main() { int arr1[] = {2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12}; assert(func0(arr1, 8, 10) == 29); int arr2[] = {1, 2, 3, 4, 5}; assert(func0(arr2, 1, 2) == 5); int arr3[] = {1, 0, 1, 2, 5, 6}; assert(func0(arr3, 4, 5) == 11); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov %edx,-0x20(%rbp) movl $0x0,-0x8(%rbp) mov -0x1c(%rbp),%eax mov %eax,-0x4(%rbp) jmp 11a7 <func0+0x3e> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%eax add %eax,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x20(%rbp),%eax jle 118a <func0+0x21> mov -0x8(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov [rbp+var_20], edx mov [rbp+var_8], 0 mov eax, [rbp+var_1C] mov [rbp+var_4], eax jmp short loc_11A7 loc_118A: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov eax, [rax] add [rbp+var_8], eax add [rbp+var_4], 1 loc_11A7: mov eax, [rbp+var_4] cmp eax, [rbp+var_20] jle short loc_118A mov eax, [rbp+var_8] pop rbp retn
long long func0(long long a1, int a2, int a3) { unsigned int v4; // [rsp+18h] [rbp-8h] v4 = 0; while ( a2 <= a3 ) v4 += *(_DWORD *)(4LL * a2++ + a1); return v4; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV dword ptr [RBP + -0x20],EDX MOV dword ptr [RBP + -0x8],0x0 MOV EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RBP + -0x4],EAX JMP 0x001011a7 LAB_0010118a: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EAX,dword ptr [RAX] ADD dword ptr [RBP + -0x8],EAX ADD dword ptr [RBP + -0x4],0x1 LAB_001011a7: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x20] JLE 0x0010118a MOV EAX,dword ptr [RBP + -0x8] POP RBP RET
int func0(long param_1,int param_2,int param_3) { int4 local_10; int4 local_c; local_10 = 0; for (local_c = param_2; local_c <= param_3; local_c = local_c + 1) { local_10 = local_10 + *(int *)(param_1 + (long)local_c * 4); } return local_10; }
6,489
func0
#include <assert.h>
int func0(int nums[], int m, int n) { int sum_range = 0; for (int i = m; i <= n; i++) { sum_range += nums[i]; } return sum_range; }
int main() { int arr1[] = {2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12}; assert(func0(arr1, 8, 10) == 29); int arr2[] = {1, 2, 3, 4, 5}; assert(func0(arr2, 1, 2) == 5); int arr3[] = {1, 0, 1, 2, 5, 6}; assert(func0(arr3, 4, 5) == 11); return 0; }
O1
c
func0: endbr64 cmp %edx,%esi jg 1195 <func0+0x2c> movslq %esi,%rcx lea (%rdi,%rcx,4),%rax sub %esi,%edx add %rcx,%rdx lea 0x4(%rdi,%rdx,4),%rcx mov $0x0,%edx add (%rax),%edx add $0x4,%rax cmp %rcx,%rax jne 1187 <func0+0x1e> mov %edx,%eax retq mov $0x0,%edx jmp 1192 <func0+0x29>
func0: endbr64 cmp esi, edx jg short loc_1195 movsxd rcx, esi lea rax, [rdi+rcx*4] sub edx, esi add rdx, rcx lea rcx, [rdi+rdx*4+4] mov edx, 0 loc_1187: add edx, [rax] add rax, 4 cmp rax, rcx jnz short loc_1187 loc_1192: mov eax, edx retn loc_1195: mov edx, 0 jmp short loc_1192
long long func0(long long a1, int a2, int a3) { _DWORD *v3; // rax unsigned long long v4; // rcx unsigned int v5; // edx if ( a2 > a3 ) { return 0; } else { v3 = (_DWORD *)(a1 + 4LL * a2); v4 = a1 + 4 * (a2 + (unsigned long long)(unsigned int)(a3 - a2)) + 4; v5 = 0; do v5 += *v3++; while ( v3 != (_DWORD *)v4 ); } return v5; }
func0: ENDBR64 CMP ESI,EDX JG 0x00101195 MOVSXD RCX,ESI LEA RAX,[RDI + RCX*0x4] SUB EDX,ESI ADD RDX,RCX LEA RCX,[RDI + RDX*0x4 + 0x4] MOV EDX,0x0 LAB_00101187: ADD EDX,dword ptr [RAX] ADD RAX,0x4 CMP RAX,RCX JNZ 0x00101187 LAB_00101192: MOV EAX,EDX RET LAB_00101195: MOV EDX,0x0 JMP 0x00101192
int func0(long param_1,int param_2,int param_3) { int *piVar1; int iVar2; if (param_3 < param_2) { iVar2 = 0; } else { piVar1 = (int *)(param_1 + (long)param_2 * 4); iVar2 = 0; do { iVar2 = iVar2 + *piVar1; piVar1 = piVar1 + 1; } while (piVar1 != (int *)(param_1 + 4 + ((ulong)(uint)(param_3 - param_2) + (long)param_2) * 4) ); } return iVar2; }
6,490
func0
#include <assert.h>
int func0(int nums[], int m, int n) { int sum_range = 0; for (int i = m; i <= n; i++) { sum_range += nums[i]; } return sum_range; }
int main() { int arr1[] = {2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12}; assert(func0(arr1, 8, 10) == 29); int arr2[] = {1, 2, 3, 4, 5}; assert(func0(arr2, 1, 2) == 5); int arr3[] = {1, 0, 1, 2, 5, 6}; assert(func0(arr3, 4, 5) == 11); return 0; }
O2
c
func0: endbr64 cmp %edx,%esi jg 1170 <func0+0x30> movslq %esi,%rcx sub %esi,%edx xor %r8d,%r8d add %rcx,%rdx lea (%rdi,%rcx,4),%rax lea 0x4(%rdi,%rdx,4),%rdx nopl 0x0(%rax) add (%rax),%r8d add $0x4,%rax cmp %rdx,%rax jne 1160 <func0+0x20> mov %r8d,%eax retq xor %r8d,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 cmp esi, edx jg short loc_1170 movsxd rcx, esi sub edx, esi xor r8d, r8d add rdx, rcx lea rax, [rdi+rcx*4] lea rdx, [rdi+rdx*4+4] nop dword ptr [rax+00h] loc_1160: add r8d, [rax] add rax, 4 cmp rax, rdx jnz short loc_1160 mov eax, r8d retn loc_1170: xor r8d, r8d mov eax, r8d retn
long long func0(long long a1, int a2, int a3) { unsigned int v3; // r8d _DWORD *v4; // rax unsigned long long v5; // rdx if ( a2 > a3 ) return 0LL; v3 = 0; v4 = (_DWORD *)(a1 + 4LL * a2); v5 = a1 + 4 * (a2 + (unsigned long long)(unsigned int)(a3 - a2)) + 4; do v3 += *v4++; while ( v4 != (_DWORD *)v5 ); return v3; }
func0: ENDBR64 CMP ESI,EDX JG 0x00101170 MOVSXD RCX,ESI SUB EDX,ESI XOR R8D,R8D ADD RDX,RCX LEA RAX,[RDI + RCX*0x4] LEA RDX,[RDI + RDX*0x4 + 0x4] NOP dword ptr [RAX] LAB_00101160: ADD R8D,dword ptr [RAX] ADD RAX,0x4 CMP RAX,RDX JNZ 0x00101160 MOV EAX,R8D RET LAB_00101170: XOR R8D,R8D MOV EAX,R8D RET
int func0(long param_1,int param_2,int param_3) { int *piVar1; int iVar2; if (param_2 <= param_3) { iVar2 = 0; piVar1 = (int *)(param_1 + (long)param_2 * 4); do { iVar2 = iVar2 + *piVar1; piVar1 = piVar1 + 1; } while (piVar1 != (int *)(param_1 + 4 + ((ulong)(uint)(param_3 - param_2) + (long)param_2) * 4) ); return iVar2; } return 0; }
6,491
func0
#include <assert.h>
int func0(int nums[], int m, int n) { int sum_range = 0; for (int i = m; i <= n; i++) { sum_range += nums[i]; } return sum_range; }
int main() { int arr1[] = {2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12}; assert(func0(arr1, 8, 10) == 29); int arr2[] = {1, 2, 3, 4, 5}; assert(func0(arr2, 1, 2) == 5); int arr3[] = {1, 0, 1, 2, 5, 6}; assert(func0(arr3, 4, 5) == 11); return 0; }
O3
c
func0: endbr64 cmp %edx,%esi jg 11f0 <func0+0xb0> mov %edx,%eax lea 0x1(%rdx),%r8d sub %esi,%eax sub %esi,%r8d cmp $0x3,%eax jbe 11f9 <func0+0xb9> mov %r8d,%ecx movslq %esi,%rax pxor %xmm0,%xmm0 shr $0x2,%ecx lea (%rdi,%rax,4),%rax shl $0x4,%rcx add %rax,%rcx nopl 0x0(%rax,%rax,1) movdqu (%rax),%xmm2 add $0x10,%rax paddd %xmm2,%xmm0 cmp %rcx,%rax jne 1180 <func0+0x40> movdqa %xmm0,%xmm1 mov %r8d,%ecx psrldq $0x8,%xmm1 and $0xfffffffc,%ecx paddd %xmm1,%xmm0 add %ecx,%esi movdqa %xmm0,%xmm1 psrldq $0x4,%xmm1 paddd %xmm1,%xmm0 movd %xmm0,%eax cmp %ecx,%r8d je 11f8 <func0+0xb8> movslq %esi,%rcx add (%rdi,%rcx,4),%eax lea 0x1(%rsi),%ecx cmp %ecx,%edx jl 11f2 <func0+0xb2> movslq %ecx,%rcx add (%rdi,%rcx,4),%eax lea 0x2(%rsi),%ecx cmp %ecx,%edx jl 11f2 <func0+0xb2> movslq %ecx,%rcx add $0x3,%esi add (%rdi,%rcx,4),%eax cmp %esi,%edx jl 11f2 <func0+0xb2> movslq %esi,%rsi add (%rdi,%rsi,4),%eax retq nopw 0x0(%rax,%rax,1) xor %eax,%eax retq nopl 0x0(%rax,%rax,1) retq xor %eax,%eax jmp 11bc <func0+0x7c> nopl (%rax)
func0: endbr64 mov ecx, esi mov esi, edx cmp ecx, edx jg loc_11E0 mov eax, edx sub eax, ecx lea r8d, [rax+1] cmp eax, 2 jbe loc_11E3 mov edx, r8d movsxd rax, ecx pxor xmm0, xmm0 shr edx, 2 lea rax, [rdi+rax*4] shl rdx, 4 add rdx, rax nop dword ptr [rax+00000000h] loc_1180: movdqu xmm2, xmmword ptr [rax] add rax, 10h paddd xmm0, xmm2 cmp rax, rdx jnz short loc_1180 movdqa xmm1, xmm0 psrldq xmm1, 8 paddd xmm0, xmm1 movdqa xmm1, xmm0 psrldq xmm1, 4 paddd xmm0, xmm1 movd eax, xmm0 test r8b, 3 jz short locret_11E2 and r8d, 0FFFFFFFCh add ecx, r8d loc_11BC: movsxd rdx, ecx lea r8, ds:0[rdx*4] add eax, [rdi+rdx*4] cmp esi, ecx jle short locret_11E2 add ecx, 2 add eax, [rdi+r8+4] cmp esi, ecx jl short locret_11E2 add eax, [rdi+r8+8] retn loc_11E0: xor eax, eax locret_11E2: retn loc_11E3: xor eax, eax jmp short loc_11BC
long long func0(long long a1, int a2, int a3) { unsigned int v5; // r8d __m128i v6; // xmm0 const __m128i *v7; // rax const __m128i *v8; // rdx __m128i v9; // xmm2 __m128i v10; // xmm0 long long result; // rax long long v12; // r8 if ( a2 > a3 ) return 0LL; v5 = a3 - a2 + 1; if ( (unsigned int)(a3 - a2) <= 2 ) { LODWORD(result) = 0; } else { v6 = 0LL; v7 = (const __m128i *)(a1 + 4LL * a2); v8 = &v7[v5 >> 2]; do { v9 = _mm_loadu_si128(v7++); v6 = _mm_add_epi32(v6, v9); } while ( v7 != v8 ); v10 = _mm_add_epi32(v6, _mm_srli_si128(v6, 8)); result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v10, _mm_srli_si128(v10, 4))); if ( (v5 & 3) == 0 ) return result; a2 += v5 & 0xFFFFFFFC; } v12 = 4LL * a2; result = (unsigned int)(*(_DWORD *)(a1 + v12) + result); if ( a3 > a2 ) { result = (unsigned int)(*(_DWORD *)(a1 + v12 + 4) + result); if ( a3 >= a2 + 2 ) return (unsigned int)(*(_DWORD *)(a1 + v12 + 8) + result); } return result; }
func0: ENDBR64 MOV ECX,ESI MOV ESI,EDX CMP ECX,EDX JG 0x001011e0 MOV EAX,EDX SUB EAX,ECX LEA R8D,[RAX + 0x1] CMP EAX,0x2 JBE 0x001011e3 MOV EDX,R8D MOVSXD RAX,ECX PXOR XMM0,XMM0 SHR EDX,0x2 LEA RAX,[RDI + RAX*0x4] SHL RDX,0x4 ADD RDX,RAX NOP dword ptr [RAX] LAB_00101180: MOVDQU XMM2,xmmword ptr [RAX] ADD RAX,0x10 PADDD XMM0,XMM2 CMP RAX,RDX JNZ 0x00101180 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x8 PADDD XMM0,XMM1 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x4 PADDD XMM0,XMM1 MOVD EAX,XMM0 TEST R8B,0x3 JZ 0x001011e2 AND R8D,0xfffffffc ADD ECX,R8D LAB_001011bc: MOVSXD RDX,ECX LEA R8,[RDX*0x4] ADD EAX,dword ptr [RDI + RDX*0x4] CMP ESI,ECX JLE 0x001011e2 ADD ECX,0x2 ADD EAX,dword ptr [RDI + R8*0x1 + 0x4] CMP ESI,ECX JL 0x001011e2 ADD EAX,dword ptr [RDI + R8*0x1 + 0x8] RET LAB_001011e0: XOR EAX,EAX LAB_001011e2: RET LAB_001011e3: XOR EAX,EAX JMP 0x001011bc
int func0(long param_1,int param_2,int param_3) { uint uVar1; long lVar2; int iVar3; int *piVar4; int *piVar5; int *piVar6; int *piVar7; int *piVar8; int iVar9; int iVar10; int iVar11; int iVar12; if (param_3 < param_2) { iVar9 = 0; } else { uVar1 = (param_3 - param_2) + 1; if ((uint)(param_3 - param_2) < 3) { iVar9 = 0; } else { iVar9 = 0; iVar10 = 0; iVar11 = 0; iVar12 = 0; piVar7 = (int *)(param_1 + (long)param_2 * 4); piVar8 = piVar7 + (ulong)(uVar1 >> 2) * 4; do { iVar3 = *piVar7; piVar4 = piVar7 + 1; piVar5 = piVar7 + 2; piVar6 = piVar7 + 3; piVar7 = piVar7 + 4; iVar9 = iVar9 + iVar3; iVar10 = iVar10 + *piVar4; iVar11 = iVar11 + *piVar5; iVar12 = iVar12 + *piVar6; } while (piVar7 != piVar8); iVar9 = iVar9 + iVar11 + iVar10 + iVar12; if ((uVar1 & 3) == 0) { return iVar9; } param_2 = param_2 + (uVar1 & 0xfffffffc); } lVar2 = (long)param_2 * 4; iVar9 = iVar9 + *(int *)(param_1 + (long)param_2 * 4); if ((param_2 < param_3) && (iVar9 = iVar9 + *(int *)(param_1 + 4 + lVar2), param_2 + 2 <= param_3)) { return iVar9 + *(int *)(param_1 + 8 + lVar2); } } return iVar9; }
6,492
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int arr1[], int arr2[], int n, int m) { if (n != m) { return false; } // Bubble sort arr1 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr1[j] > arr1[j + 1]) { int temp = arr1[j]; arr1[j] = arr1[j + 1]; arr1[j + 1] = temp; } } } // Bubble sort arr2 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr2[j] > arr2[j + 1]) { int temp = arr2[j]; arr2[j] = arr2[j + 1]; arr2[j + 1] = temp; } } } for (int i = 0; i < n; i++) { if (arr1[i] != arr2[i]) { return false; } } return true; }
int main() { int arr1[] = {1, 2, 3}; int arr2[] = {3, 2, 1}; int arr3[] = {1, 1, 1}; int arr4[] = {2, 2, 2}; int arr5[] = {8, 9}; int arr6[] = {4, 5, 6}; assert(func0(arr1, arr2, 3, 3) == true); assert(func0(arr3, arr4, 3, 3) == false); assert(func0(arr5, arr6, 2, 3) == false); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x28(%rbp) mov %rsi,-0x30(%rbp) mov %edx,-0x34(%rbp) mov %ecx,-0x38(%rbp) mov -0x34(%rbp),%eax cmp -0x38(%rbp),%eax je 1191 <func0+0x28> mov $0x0,%eax jmpq 139a <func0+0x231> movl $0x0,-0x1c(%rbp) jmpq 125e <func0+0xf5> movl $0x0,-0x18(%rbp) jmpq 1248 <func0+0xdf> mov -0x18(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x18(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jle 1244 <func0+0xdb> mov -0x18(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x4(%rbp) mov -0x18(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov -0x18(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x28(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x18(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rax,%rdx mov -0x4(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x18(%rbp) mov -0x34(%rbp),%eax sub -0x1c(%rbp),%eax sub $0x1,%eax cmp %eax,-0x18(%rbp) jl 11a9 <func0+0x40> addl $0x1,-0x1c(%rbp) mov -0x34(%rbp),%eax sub $0x1,%eax cmp %eax,-0x1c(%rbp) jl 119d <func0+0x34> movl $0x0,-0x14(%rbp) jmpq 133a <func0+0x1d1> movl $0x0,-0x10(%rbp) jmpq 1324 <func0+0x1bb> mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x10(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rcx mov -0x30(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jle 1320 <func0+0x1b7> mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x8(%rbp) mov -0x10(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov -0x10(%rbp),%edx movslq %edx,%rdx lea 0x0(,%rdx,4),%rcx mov -0x30(%rbp),%rdx add %rcx,%rdx mov (%rax),%eax mov %eax,(%rdx) mov -0x10(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rdx mov -0x30(%rbp),%rax add %rax,%rdx mov -0x8(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x10(%rbp) mov -0x34(%rbp),%eax sub -0x14(%rbp),%eax sub $0x1,%eax cmp %eax,-0x10(%rbp) jl 1285 <func0+0x11c> addl $0x1,-0x14(%rbp) mov -0x34(%rbp),%eax sub $0x1,%eax cmp %eax,-0x14(%rbp) jl 1279 <func0+0x110> movl $0x0,-0xc(%rbp) jmp 138d <func0+0x224> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x30(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx je 1389 <func0+0x220> mov $0x0,%eax jmp 139a <func0+0x231> addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x34(%rbp),%eax jl 1352 <func0+0x1e9> mov $0x1,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_28], rdi mov [rbp+var_30], rsi mov [rbp+var_34], edx mov [rbp+var_38], ecx mov eax, [rbp+var_34] cmp eax, [rbp+var_38] jz short loc_1191 mov eax, 0 jmp loc_139A loc_1191: mov [rbp+var_1C], 0 jmp loc_125E loc_119D: mov [rbp+var_18], 0 jmp loc_1248 loc_11A9: mov eax, [rbp+var_18] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_18] cdqe add rax, 1 lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jle short loc_1244 mov eax, [rbp+var_18] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] mov [rbp+var_4], eax mov eax, [rbp+var_18] cdqe add rax, 1 lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rbp+var_18] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_28] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_18] cdqe add rax, 1 lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rdx, rax mov eax, [rbp+var_4] mov [rdx], eax loc_1244: add [rbp+var_18], 1 loc_1248: mov eax, [rbp+var_34] sub eax, [rbp+var_1C] sub eax, 1 cmp [rbp+var_18], eax jl loc_11A9 add [rbp+var_1C], 1 loc_125E: mov eax, [rbp+var_34] sub eax, 1 cmp [rbp+var_1C], eax jl loc_119D mov [rbp+var_14], 0 jmp loc_133A loc_1279: mov [rbp+var_10], 0 jmp loc_1324 loc_1285: mov eax, [rbp+var_10] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_30] add rax, rdx mov edx, [rax] mov eax, [rbp+var_10] cdqe add rax, 1 lea rcx, ds:0[rax*4] mov rax, [rbp+var_30] add rax, rcx mov eax, [rax] cmp edx, eax jle short loc_1320 mov eax, [rbp+var_10] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_30] add rax, rdx mov eax, [rax] mov [rbp+var_8], eax mov eax, [rbp+var_10] cdqe add rax, 1 lea rdx, ds:0[rax*4] mov rax, [rbp+var_30] add rax, rdx mov edx, [rbp+var_10] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_30] add rdx, rcx mov eax, [rax] mov [rdx], eax mov eax, [rbp+var_10] cdqe add rax, 1 lea rdx, ds:0[rax*4] mov rax, [rbp+var_30] add rdx, rax mov eax, [rbp+var_8] mov [rdx], eax loc_1320: add [rbp+var_10], 1 loc_1324: mov eax, [rbp+var_34] sub eax, [rbp+var_14] sub eax, 1 cmp [rbp+var_10], eax jl loc_1285 add [rbp+var_14], 1 loc_133A: mov eax, [rbp+var_34] sub eax, 1 cmp [rbp+var_14], eax jl loc_1279 mov [rbp+var_C], 0 jmp short loc_138D loc_1352: 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_C] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_30] add rax, rcx mov eax, [rax] cmp edx, eax jz short loc_1389 mov eax, 0 jmp short loc_139A loc_1389: add [rbp+var_C], 1 loc_138D: mov eax, [rbp+var_C] cmp eax, [rbp+var_34] jl short loc_1352 mov eax, 1 loc_139A: pop rbp retn
long long func0(long long a1, long long a2, int a3, int a4) { int i; // [rsp+1Ch] [rbp-1Ch] int j; // [rsp+20h] [rbp-18h] int k; // [rsp+24h] [rbp-14h] int m; // [rsp+28h] [rbp-10h] int n; // [rsp+2Ch] [rbp-Ch] int v10; // [rsp+30h] [rbp-8h] int v11; // [rsp+34h] [rbp-4h] if ( a3 != a4 ) return 0LL; for ( i = 0; i < a3 - 1; ++i ) { for ( j = 0; j < a3 - i - 1; ++j ) { if ( *(_DWORD *)(4LL * j + a1) > *(_DWORD *)(4 * (j + 1LL) + a1) ) { v11 = *(_DWORD *)(4LL * j + a1); *(_DWORD *)(4LL * j + a1) = *(_DWORD *)(4 * (j + 1LL) + a1); *(_DWORD *)(a1 + 4 * (j + 1LL)) = v11; } } } for ( k = 0; k < a3 - 1; ++k ) { for ( m = 0; m < a3 - k - 1; ++m ) { if ( *(_DWORD *)(4LL * m + a2) > *(_DWORD *)(4 * (m + 1LL) + a2) ) { v10 = *(_DWORD *)(4LL * m + a2); *(_DWORD *)(4LL * m + a2) = *(_DWORD *)(4 * (m + 1LL) + a2); *(_DWORD *)(a2 + 4 * (m + 1LL)) = v10; } } } for ( n = 0; n < a3; ++n ) { if ( *(_DWORD *)(4LL * n + a1) != *(_DWORD *)(4LL * n + a2) ) return 0LL; } return 1LL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x28],RDI MOV qword ptr [RBP + -0x30],RSI MOV dword ptr [RBP + -0x34],EDX MOV dword ptr [RBP + -0x38],ECX MOV EAX,dword ptr [RBP + -0x34] CMP EAX,dword ptr [RBP + -0x38] JZ 0x00101191 MOV EAX,0x0 JMP 0x0010139a LAB_00101191: MOV dword ptr [RBP + -0x1c],0x0 JMP 0x0010125e LAB_0010119d: MOV dword ptr [RBP + -0x18],0x0 JMP 0x00101248 LAB_001011a9: MOV EAX,dword ptr [RBP + -0x18] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x18] CDQE ADD RAX,0x1 LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JLE 0x00101244 MOV EAX,dword ptr [RBP + -0x18] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x18] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x18] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x28] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x18] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RDX],EAX LAB_00101244: ADD dword ptr [RBP + -0x18],0x1 LAB_00101248: MOV EAX,dword ptr [RBP + -0x34] SUB EAX,dword ptr [RBP + -0x1c] SUB EAX,0x1 CMP dword ptr [RBP + -0x18],EAX JL 0x001011a9 ADD dword ptr [RBP + -0x1c],0x1 LAB_0010125e: MOV EAX,dword ptr [RBP + -0x34] SUB EAX,0x1 CMP dword ptr [RBP + -0x1c],EAX JL 0x0010119d MOV dword ptr [RBP + -0x14],0x0 JMP 0x0010133a LAB_00101279: MOV dword ptr [RBP + -0x10],0x0 JMP 0x00101324 LAB_00101285: MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x10] CDQE ADD RAX,0x1 LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JLE 0x00101320 MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x8],EAX MOV EAX,dword ptr [RBP + -0x10] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RDX MOV EDX,dword ptr [RBP + -0x10] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x30] ADD RDX,RCX MOV EAX,dword ptr [RAX] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x10] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x8] MOV dword ptr [RDX],EAX LAB_00101320: ADD dword ptr [RBP + -0x10],0x1 LAB_00101324: MOV EAX,dword ptr [RBP + -0x34] SUB EAX,dword ptr [RBP + -0x14] SUB EAX,0x1 CMP dword ptr [RBP + -0x10],EAX JL 0x00101285 ADD dword ptr [RBP + -0x14],0x1 LAB_0010133a: MOV EAX,dword ptr [RBP + -0x34] SUB EAX,0x1 CMP dword ptr [RBP + -0x14],EAX JL 0x00101279 MOV dword ptr [RBP + -0xc],0x0 JMP 0x0010138d LAB_00101352: 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 + -0xc] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JZ 0x00101389 MOV EAX,0x0 JMP 0x0010139a LAB_00101389: ADD dword ptr [RBP + -0xc],0x1 LAB_0010138d: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x34] JL 0x00101352 MOV EAX,0x1 LAB_0010139a: POP RBP RET
int8 func0(long param_1,long param_2,int param_3,int param_4) { int4 uVar1; int8 uVar2; int local_24; int local_20; int local_1c; int local_18; int local_14; if (param_3 == param_4) { for (local_24 = 0; local_24 < param_3 + -1; local_24 = local_24 + 1) { for (local_20 = 0; local_20 < (param_3 - local_24) + -1; local_20 = local_20 + 1) { if (*(int *)(param_1 + ((long)local_20 + 1) * 4) < *(int *)(param_1 + (long)local_20 * 4)) { uVar1 = *(int4 *)(param_1 + (long)local_20 * 4); *(int4 *)(param_1 + (long)local_20 * 4) = *(int4 *)(param_1 + ((long)local_20 + 1) * 4); *(int4 *)(((long)local_20 + 1) * 4 + param_1) = uVar1; } } } for (local_1c = 0; local_1c < param_3 + -1; local_1c = local_1c + 1) { for (local_18 = 0; local_18 < (param_3 - local_1c) + -1; local_18 = local_18 + 1) { if (*(int *)(param_2 + ((long)local_18 + 1) * 4) < *(int *)(param_2 + (long)local_18 * 4)) { uVar1 = *(int4 *)(param_2 + (long)local_18 * 4); *(int4 *)(param_2 + (long)local_18 * 4) = *(int4 *)(param_2 + ((long)local_18 + 1) * 4); *(int4 *)(((long)local_18 + 1) * 4 + param_2) = uVar1; } } } for (local_14 = 0; local_14 < param_3; local_14 = local_14 + 1) { if (*(int *)(param_1 + (long)local_14 * 4) != *(int *)(param_2 + (long)local_14 * 4)) { return 0; } } uVar2 = 1; } else { uVar2 = 0; } return uVar2; }
6,493
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int arr1[], int arr2[], int n, int m) { if (n != m) { return false; } // Bubble sort arr1 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr1[j] > arr1[j + 1]) { int temp = arr1[j]; arr1[j] = arr1[j + 1]; arr1[j + 1] = temp; } } } // Bubble sort arr2 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr2[j] > arr2[j + 1]) { int temp = arr2[j]; arr2[j] = arr2[j + 1]; arr2[j + 1] = temp; } } } for (int i = 0; i < n; i++) { if (arr1[i] != arr2[i]) { return false; } } return true; }
int main() { int arr1[] = {1, 2, 3}; int arr2[] = {3, 2, 1}; int arr3[] = {1, 1, 1}; int arr4[] = {2, 2, 2}; int arr5[] = {8, 9}; int arr6[] = {4, 5, 6}; assert(func0(arr1, arr2, 3, 3) == true); assert(func0(arr3, arr4, 3, 3) == false); assert(func0(arr5, arr6, 2, 3) == false); return 0; }
O1
c
func0: endbr64 mov $0x0,%eax cmp %ecx,%edx jne 1235 <func0+0xcc> push %rbx lea -0x1(%rdx),%eax mov %eax,%r10d mov %eax,%r11d lea 0x4(%rdi),%rbx test %eax,%eax jg 11c0 <func0+0x57> test %edx,%edx jle 1227 <func0+0xbe> lea -0x1(%rdx),%ecx mov $0x0,%eax jmp 120f <func0+0xa6> add $0x4,%rax cmp %r9,%rax je 11ba <func0+0x51> mov (%rax),%ecx mov 0x4(%rax),%r8d cmp %r8d,%ecx jle 119e <func0+0x35> mov %r8d,(%rax) mov %ecx,0x4(%rax) jmp 119e <func0+0x35> sub $0x1,%r11d je 11d2 <func0+0x69> test %r11d,%r11d jle 11ba <func0+0x51> mov %rdi,%rax lea -0x1(%r11),%ecx lea (%rbx,%rcx,4),%r9 jmp 11a7 <func0+0x3e> lea 0x4(%rsi),%r11 jmp 11fa <func0+0x91> add $0x4,%rax cmp %r9,%rax je 11f4 <func0+0x8b> mov (%rax),%ecx mov 0x4(%rax),%r8d cmp %r8d,%ecx jle 11d8 <func0+0x6f> mov %r8d,(%rax) mov %ecx,0x4(%rax) jmp 11d8 <func0+0x6f> sub $0x1,%r10d je 118c <func0+0x23> test %r10d,%r10d jle 11f4 <func0+0x8b> mov %rsi,%rax lea -0x1(%r10),%ecx lea (%r11,%rcx,4),%r9 jmp 11e1 <func0+0x78> mov %rdx,%rax mov (%rsi,%rax,4),%ebx cmp %ebx,(%rdi,%rax,4) jne 122e <func0+0xc5> lea 0x1(%rax),%rdx cmp %rax,%rcx jne 120c <func0+0xa3> mov $0x1,%eax jmp 1233 <func0+0xca> mov $0x1,%eax jmp 1233 <func0+0xca> mov $0x0,%eax pop %rbx retq retq
func0: endbr64 mov eax, 0 cmp edx, ecx jnz locret_1238 push rbx mov r9, rdi mov r10, rsi mov r11d, edx lea eax, [rdx-1] mov edi, eax mov r8d, eax lea rbx, [r9+4] test eax, eax jg short loc_11C7 loc_1194: test r11d, r11d jle loc_122A lea ecx, [r11-1] mov eax, 0 jmp short loc_1210 loc_11A8: add rax, 4 cmp rax, rsi jz short loc_11C1 loc_11B1: mov edx, [rax] mov ecx, [rax+4] cmp edx, ecx jle short loc_11A8 mov [rax], ecx mov [rax+4], edx jmp short loc_11A8 loc_11C1: sub r8d, 1 jz short loc_11D9 loc_11C7: test r8d, r8d jle short loc_11C1 mov rax, r9 lea edx, [r8-1] lea rsi, [rbx+rdx*4] jmp short loc_11B1 loc_11D9: lea r8, [r10+4] jmp short loc_11FD loc_11DF: add rax, 4 cmp rax, rsi jz short loc_11F8 loc_11E8: mov edx, [rax] mov ecx, [rax+4] cmp edx, ecx jle short loc_11DF mov [rax], ecx mov [rax+4], edx jmp short loc_11DF loc_11F8: sub edi, 1 jz short loc_1194 loc_11FD: test edi, edi jle short loc_11F8 mov rax, r10 lea edx, [rdi-1] lea rsi, [r8+rdx*4] jmp short loc_11E8 loc_120D: mov rax, rdx loc_1210: mov ebx, [r10+rax*4] cmp [r9+rax*4], ebx jnz short loc_1231 lea rdx, [rax+1] cmp rcx, rax jnz short loc_120D mov eax, 1 jmp short loc_1236 loc_122A: mov eax, 1 jmp short loc_1236 loc_1231: mov eax, 0 loc_1236: pop rbx retn locret_1238: retn
long long func0(int *a1, int *a2, int a3, int a4) { long long result; // rax int v7; // edi int v8; // r8d long long i; // rax int *v10; // rax int v11; // edx int v12; // ecx int *v13; // rax int v14; // edx int v15; // ecx result = 0LL; if ( a3 == a4 ) { v7 = a3 - 1; v8 = a3 - 1; if ( a3 - 1 > 0 ) { do { if ( v8 > 0 ) { v10 = a1; do { v11 = *v10; v12 = v10[1]; if ( *v10 > v12 ) { *v10 = v12; v10[1] = v11; } ++v10; } while ( v10 != &a1[v8 - 1 + 1] ); } --v8; } while ( v8 ); do { if ( v7 > 0 ) { v13 = a2; do { v14 = *v13; v15 = v13[1]; if ( *v13 > v15 ) { *v13 = v15; v13[1] = v14; } ++v13; } while ( v13 != &a2[v7 - 1 + 1] ); } --v7; } while ( v7 ); } if ( a3 <= 0 ) { return 1LL; } else { for ( i = 0LL; a1[i] == a2[i]; ++i ) { if ( a3 - 1 == i ) return 1LL; } return 0LL; } } return result; }
func0: ENDBR64 MOV EAX,0x0 CMP EDX,ECX JNZ 0x00101238 PUSH RBX MOV R9,RDI MOV R10,RSI MOV R11D,EDX LEA EAX,[RDX + -0x1] MOV EDI,EAX MOV R8D,EAX LEA RBX,[R9 + 0x4] TEST EAX,EAX JG 0x001011c7 LAB_00101194: TEST R11D,R11D JLE 0x0010122a LEA ECX,[R11 + -0x1] MOV EAX,0x0 JMP 0x00101210 LAB_001011a8: ADD RAX,0x4 CMP RAX,RSI JZ 0x001011c1 LAB_001011b1: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [RAX + 0x4] CMP EDX,ECX JLE 0x001011a8 MOV dword ptr [RAX],ECX MOV dword ptr [RAX + 0x4],EDX JMP 0x001011a8 LAB_001011c1: SUB R8D,0x1 JZ 0x001011d9 LAB_001011c7: TEST R8D,R8D JLE 0x001011c1 MOV RAX,R9 LEA EDX,[R8 + -0x1] LEA RSI,[RBX + RDX*0x4] JMP 0x001011b1 LAB_001011d9: LEA R8,[R10 + 0x4] JMP 0x001011fd LAB_001011df: ADD RAX,0x4 CMP RAX,RSI JZ 0x001011f8 LAB_001011e8: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [RAX + 0x4] CMP EDX,ECX JLE 0x001011df MOV dword ptr [RAX],ECX MOV dword ptr [RAX + 0x4],EDX JMP 0x001011df LAB_001011f8: SUB EDI,0x1 JZ 0x00101194 LAB_001011fd: TEST EDI,EDI JLE 0x001011f8 MOV RAX,R10 LEA EDX,[RDI + -0x1] LEA RSI,[R8 + RDX*0x4] JMP 0x001011e8 LAB_0010120d: MOV RAX,RDX LAB_00101210: MOV EBX,dword ptr [R10 + RAX*0x4] CMP dword ptr [R9 + RAX*0x4],EBX JNZ 0x00101231 LEA RDX,[RAX + 0x1] CMP RCX,RAX JNZ 0x0010120d MOV EAX,0x1 JMP 0x00101236 LAB_0010122a: MOV EAX,0x1 JMP 0x00101236 LAB_00101231: MOV EAX,0x0 LAB_00101236: POP RBX RET LAB_00101238: RET
int8 func0(int *param_1,int *param_2,int param_3,int param_4) { int iVar1; int *piVar2; ulong uVar3; int iVar4; int iVar5; bool bVar6; if (param_3 != param_4) { return 0; } iVar4 = param_3 + -1; iVar5 = iVar4; if (0 < iVar4) { do { if (0 < iVar5) { piVar2 = param_1; do { iVar1 = *piVar2; if (piVar2[1] < iVar1) { *piVar2 = piVar2[1]; piVar2[1] = iVar1; } piVar2 = piVar2 + 1; } while (piVar2 != param_1 + (ulong)(iVar5 - 1) + 1); } iVar5 = iVar5 + -1; } while (iVar5 != 0); do { if (0 < iVar4) { piVar2 = param_2; do { iVar5 = *piVar2; if (piVar2[1] < iVar5) { *piVar2 = piVar2[1]; piVar2[1] = iVar5; } piVar2 = piVar2 + 1; } while (piVar2 != param_2 + (ulong)(iVar4 - 1) + 1); } iVar4 = iVar4 + -1; } while (iVar4 != 0); } if (0 < param_3) { uVar3 = 0; do { if (param_1[uVar3] != param_2[uVar3]) { return 0; } bVar6 = param_3 - 1 != uVar3; uVar3 = uVar3 + 1; } while (bVar6); } return 1; }
6,494
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int arr1[], int arr2[], int n, int m) { if (n != m) { return false; } // Bubble sort arr1 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr1[j] > arr1[j + 1]) { int temp = arr1[j]; arr1[j] = arr1[j + 1]; arr1[j + 1] = temp; } } } // Bubble sort arr2 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr2[j] > arr2[j + 1]) { int temp = arr2[j]; arr2[j] = arr2[j + 1]; arr2[j + 1] = temp; } } } for (int i = 0; i < n; i++) { if (arr1[i] != arr2[i]) { return false; } } return true; }
int main() { int arr1[] = {1, 2, 3}; int arr2[] = {3, 2, 1}; int arr3[] = {1, 1, 1}; int arr4[] = {2, 2, 2}; int arr5[] = {8, 9}; int arr6[] = {4, 5, 6}; assert(func0(arr1, arr2, 3, 3) == true); assert(func0(arr3, arr4, 3, 3) == false); assert(func0(arr5, arr6, 2, 3) == false); return 0; }
O2
c
func0: endbr64 cmp %ecx,%edx jne 1370 <func0+0x10> jmpq 1270 <func0.part.0> nopl (%rax) xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0_part_0: movsxd r11, edx mov r9, rdi push rbx mov r10, rsi lea edi, [r11-1] lea rbx, [r9+4] mov edx, edi test edi, edi jle short loc_12F3 nop dword ptr [rax+rax+00000000h] loc_1290: sub edx, 1 mov rax, r9 mov r8, rdx lea rsi, [rbx+rdx*4] nop dword ptr [rax] loc_12A0: mov edx, [rax] mov ecx, [rax+4] cmp edx, ecx jle short loc_12AE mov [rax], ecx mov [rax+4], edx loc_12AE: add rax, 4 cmp rax, rsi jnz short loc_12A0 mov edx, r8d test r8d, r8d jnz short loc_1290 lea r8, [r10+4] nop dword ptr [rax+rax+00h] loc_12C8: lea edx, [rdi-1] mov rax, r10 mov rdi, rdx lea rsi, [r8+rdx*4] nop dword ptr [rax] loc_12D8: mov edx, [rax] mov ecx, [rax+4] cmp edx, ecx jle short loc_12E6 mov [rax], ecx mov [rax+4], edx loc_12E6: add rax, 4 cmp rsi, rax jnz short loc_12D8 test edi, edi jnz short loc_12C8 loc_12F3: test r11d, r11d jle short loc_1317 xor eax, eax jmp short loc_1309 loc_1300: add rax, 1 cmp r11, rax jz short loc_1317 loc_1309: mov ebx, [r10+rax*4] cmp [r9+rax*4], ebx jz short loc_1300 xor eax, eax pop rbx retn loc_1317: mov eax, 1 pop rbx retn
long long func0_part_0(unsigned long long a1, int *a2, int a3) { long long v3; // r11 int *v4; // r9 int v6; // edx int *v7; // rax int v8; // r8d long long v9; // rsi int v10; // edx int v11; // ecx int *v12; // rax int v13; // edx int v14; // ecx long long v15; // rax v3 = a3; v4 = (int *)a1; LODWORD(a1) = a3 - 1; v6 = a1; if ( (int)a1 > 0 ) { do { v7 = v4; v8 = v6 - 1; v9 = (long long)&v4[v6 - 1 + 1]; do { v10 = *v7; v11 = v7[1]; if ( *v7 > v11 ) { *v7 = v11; v7[1] = v10; } ++v7; } while ( v7 != (int *)v9 ); v6 = v8; } while ( v8 ); do { v12 = a2; a1 = (unsigned int)(a1 - 1); do { v13 = *v12; v14 = v12[1]; if ( *v12 > v14 ) { *v12 = v14; v12[1] = v13; } ++v12; } while ( &a2[a1 + 1] != v12 ); } while ( (_DWORD)a1 ); } if ( (int)v3 <= 0 ) return 1LL; v15 = 0LL; while ( v4[v15] == a2[v15] ) { if ( v3 == ++v15 ) return 1LL; } return 0LL; }
func0.part.0: MOVSXD R11,EDX MOV R9,RDI PUSH RBX MOV R10,RSI LEA EDI,[R11 + -0x1] LEA RBX,[R9 + 0x4] MOV EDX,EDI TEST EDI,EDI JLE 0x001012f3 NOP dword ptr [RAX + RAX*0x1] LAB_00101290: SUB EDX,0x1 MOV RAX,R9 MOV R8,RDX LEA RSI,[RBX + RDX*0x4] NOP dword ptr [RAX] LAB_001012a0: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [RAX + 0x4] CMP EDX,ECX JLE 0x001012ae MOV dword ptr [RAX],ECX MOV dword ptr [RAX + 0x4],EDX LAB_001012ae: ADD RAX,0x4 CMP RAX,RSI JNZ 0x001012a0 MOV EDX,R8D TEST R8D,R8D JNZ 0x00101290 LEA R8,[R10 + 0x4] NOP dword ptr [RAX + RAX*0x1] LAB_001012c8: LEA EDX,[RDI + -0x1] MOV RAX,R10 MOV RDI,RDX LEA RSI,[R8 + RDX*0x4] NOP dword ptr [RAX] LAB_001012d8: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [RAX + 0x4] CMP EDX,ECX JLE 0x001012e6 MOV dword ptr [RAX],ECX MOV dword ptr [RAX + 0x4],EDX LAB_001012e6: ADD RAX,0x4 CMP RSI,RAX JNZ 0x001012d8 TEST EDI,EDI JNZ 0x001012c8 LAB_001012f3: TEST R11D,R11D JLE 0x00101317 XOR EAX,EAX JMP 0x00101309 LAB_00101300: ADD RAX,0x1 CMP R11,RAX JZ 0x00101317 LAB_00101309: MOV EBX,dword ptr [R10 + RAX*0x4] CMP dword ptr [R9 + RAX*0x4],EBX JZ 0x00101300 XOR EAX,EAX POP RBX RET LAB_00101317: MOV EAX,0x1 POP RBX RET
int8 func0_part_0(int *param_1,int *param_2,int param_3) { int iVar1; int *piVar2; long lVar3; uint uVar4; ulong uVar6; ulong uVar5; uVar6 = (ulong)(param_3 - 1U); uVar5 = uVar6; if (0 < (int)(param_3 - 1U)) { do { uVar4 = (int)uVar5 - 1; piVar2 = param_1; do { iVar1 = *piVar2; if (piVar2[1] < iVar1) { *piVar2 = piVar2[1]; piVar2[1] = iVar1; } piVar2 = piVar2 + 1; } while (piVar2 != param_1 + (ulong)uVar4 + 1); uVar5 = (ulong)uVar4; } while (uVar4 != 0); do { uVar4 = (int)uVar6 - 1; uVar6 = (ulong)uVar4; piVar2 = param_2; do { iVar1 = *piVar2; if (piVar2[1] < iVar1) { *piVar2 = piVar2[1]; piVar2[1] = iVar1; } piVar2 = piVar2 + 1; } while (param_2 + uVar6 + 1 != piVar2); } while (uVar4 != 0); } if (0 < param_3) { lVar3 = 0; do { if (param_1[lVar3] != param_2[lVar3]) { return 0; } lVar3 = lVar3 + 1; } while (param_3 != lVar3); } return 1; }
6,495
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int arr1[], int arr2[], int n, int m) { if (n != m) { return false; } // Bubble sort arr1 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr1[j] > arr1[j + 1]) { int temp = arr1[j]; arr1[j] = arr1[j + 1]; arr1[j + 1] = temp; } } } // Bubble sort arr2 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr2[j] > arr2[j + 1]) { int temp = arr2[j]; arr2[j] = arr2[j + 1]; arr2[j + 1] = temp; } } } for (int i = 0; i < n; i++) { if (arr1[i] != arr2[i]) { return false; } } return true; }
int main() { int arr1[] = {1, 2, 3}; int arr2[] = {3, 2, 1}; int arr3[] = {1, 1, 1}; int arr4[] = {2, 2, 2}; int arr5[] = {8, 9}; int arr6[] = {4, 5, 6}; assert(func0(arr1, arr2, 3, 3) == true); assert(func0(arr3, arr4, 3, 3) == false); assert(func0(arr5, arr6, 2, 3) == false); return 0; }
O3
c
func0: endbr64 cmp %ecx,%edx jne 1370 <func0+0x10> jmpq 1270 <func0.part.0> nopl (%rax) xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 cmp edx, ecx jz short loc_12E0 xor eax, eax retn loc_12E0: push rbx mov r8, rsi mov r10d, edx mov r9d, edx mov r11d, edx lea rbx, [rdi+4] cmp edx, 1 jle loc_13D6 nop word ptr [rax+rax+00h] loc_1300: lea edx, [r11-2] mov rax, rdi lea rsi, [rbx+rdx*4] nop dword ptr [rax+rax+00h] loc_1310: movq xmm0, qword ptr [rax] pshufd xmm1, xmm0, 0E5h movd edx, xmm0 movd ecx, xmm1 cmp ecx, edx jge short loc_132E pshufd xmm0, xmm0, 0E1h movq qword ptr [rax], xmm0 loc_132E: add rax, 4 cmp rax, rsi jnz short loc_1310 sub r11d, 1 cmp r11d, 1 jz short loc_1350 loc_1341: cmp r11d, 1 jg short loc_1300 sub r11d, 1 jmp short loc_1341 loc_1350: lea r11, [r8+4] nop dword ptr [rax+00h] loc_1358: cmp r9d, 1 jle short loc_13D0 lea edx, [r9-2] mov rax, r8 lea rsi, [r11+rdx*4] nop dword ptr [rax+00000000h] loc_1370: movq xmm0, qword ptr [rax] pshufd xmm2, xmm0, 0E5h movd edx, xmm0 movd ecx, xmm2 cmp ecx, edx jge short loc_138E pshufd xmm0, xmm0, 0E1h movq qword ptr [rax], xmm0 loc_138E: add rax, 4 cmp rax, rsi jnz short loc_1370 sub r9d, 1 cmp r9d, 1 jnz short loc_1358 loc_13A1: movsxd rdx, r10d xor eax, eax shl rdx, 2 jmp short loc_13B9 loc_13B0: add rax, 4 cmp rax, rdx jz short loc_13D8 loc_13B9: mov ebx, [r8+rax] cmp [rdi+rax], ebx jz short loc_13B0 xor eax, eax pop rbx retn loc_13D0: sub r9d, 1 jmp short loc_1358 loc_13D6: jz short loc_13A1 loc_13D8: mov eax, 1 pop rbx retn
long long func0(__m128i *a1, __m128i *a2, int a3, int a4) { int v5; // r9d int v6; // r11d __m128i *v7; // rax __m128i v8; // xmm0 __m128i *v9; // rax __m128i v10; // xmm0 unsigned long long v11; // rax long long v12; // rdx if ( a3 != a4 ) return 0LL; v5 = a3; v6 = a3; if ( a3 <= 1 ) { if ( a3 != 1 ) return 1LL; } else { while ( 1 ) { v7 = a1; do { v8 = _mm_loadl_epi64(v7); if ( _mm_cvtsi128_si32(_mm_shuffle_epi32(v8, 229)) < _mm_cvtsi128_si32(v8) ) v7->m128i_i64[0] = _mm_shuffle_epi32(v8, 225).m128i_u64[0]; v7 = (__m128i *)((char *)v7 + 4); } while ( v7 != (__m128i *)((char *)a1->m128i_i64 + 4 * (unsigned int)(v6 - 2) + 4) ); if ( --v6 == 1 ) break; while ( v6 <= 1 ) --v6; } do { while ( v5 <= 1 ) --v5; v9 = a2; do { v10 = _mm_loadl_epi64(v9); if ( _mm_cvtsi128_si32(_mm_shuffle_epi32(v10, 229)) < _mm_cvtsi128_si32(v10) ) v9->m128i_i64[0] = _mm_shuffle_epi32(v10, 225).m128i_u64[0]; v9 = (__m128i *)((char *)v9 + 4); } while ( v9 != (__m128i *)((char *)a2->m128i_i64 + 4 * (unsigned int)(v5 - 2) + 4) ); --v5; } while ( v5 != 1 ); } v11 = 0LL; v12 = 4LL * a3; while ( a1->m128i_i32[v11 / 4] == a2->m128i_i32[v11 / 4] ) { v11 += 4LL; if ( v11 == v12 ) return 1LL; } return 0LL; }
func0: ENDBR64 CMP EDX,ECX JZ 0x001012e0 XOR EAX,EAX RET LAB_001012e0: PUSH RBX MOV R8,RSI MOV R10D,EDX MOV R9D,EDX MOV R11D,EDX LEA RBX,[RDI + 0x4] CMP EDX,0x1 JLE 0x001013d6 NOP word ptr [RAX + RAX*0x1] LAB_00101300: LEA EDX,[R11 + -0x2] MOV RAX,RDI LEA RSI,[RBX + RDX*0x4] NOP dword ptr [RAX + RAX*0x1] LAB_00101310: MOVQ XMM0,qword ptr [RAX] PSHUFD XMM1,XMM0,0xe5 MOVD EDX,XMM0 MOVD ECX,XMM1 CMP ECX,EDX JGE 0x0010132e PSHUFD XMM0,XMM0,0xe1 MOVQ qword ptr [RAX],XMM0 LAB_0010132e: ADD RAX,0x4 CMP RAX,RSI JNZ 0x00101310 SUB R11D,0x1 CMP R11D,0x1 JZ 0x00101350 LAB_00101341: CMP R11D,0x1 JG 0x00101300 SUB R11D,0x1 JMP 0x00101341 LAB_00101350: LEA R11,[R8 + 0x4] NOP dword ptr [RAX] LAB_00101358: CMP R9D,0x1 JLE 0x001013d0 LEA EDX,[R9 + -0x2] MOV RAX,R8 LEA RSI,[R11 + RDX*0x4] NOP dword ptr [RAX] LAB_00101370: MOVQ XMM0,qword ptr [RAX] PSHUFD XMM2,XMM0,0xe5 MOVD EDX,XMM0 MOVD ECX,XMM2 CMP ECX,EDX JGE 0x0010138e PSHUFD XMM0,XMM0,0xe1 MOVQ qword ptr [RAX],XMM0 LAB_0010138e: ADD RAX,0x4 CMP RAX,RSI JNZ 0x00101370 SUB R9D,0x1 CMP R9D,0x1 JNZ 0x00101358 LAB_001013a1: MOVSXD RDX,R10D XOR EAX,EAX SHL RDX,0x2 JMP 0x001013b9 LAB_001013b0: ADD RAX,0x4 CMP RAX,RDX JZ 0x001013d8 LAB_001013b9: MOV EBX,dword ptr [R8 + RAX*0x1] CMP dword ptr [RDI + RAX*0x1],EBX JZ 0x001013b0 XOR EAX,EAX POP RBX RET LAB_001013d0: SUB R9D,0x1 JMP 0x00101358 LAB_001013d6: JZ 0x001013a1 LAB_001013d8: MOV EAX,0x1 POP RBX RET
int8 func0(int8 *param_1,int8 *param_2,int param_3,int param_4) { int8 *puVar1; long lVar2; int iVar3; int iVar4; int iVar5; if (param_3 != param_4) { return 0; } iVar4 = param_3; if (param_3 < 2) { if (param_3 != 1) { return 1; } } else { while( true ) { puVar1 = param_1; do { iVar3 = (int)*puVar1; iVar5 = (int)((ulong)*puVar1 >> 0x20); if (iVar5 < iVar3) { *puVar1 = CONCAT44(iVar3,iVar5); } puVar1 = (int8 *)((long)puVar1 + 4); } while (puVar1 != (int8 *)((long)param_1 + (ulong)(iVar4 - 2) * 4 + 4)); iVar4 = iVar4 + -1; iVar3 = param_3; if (iVar4 == 1) break; for (; iVar4 < 2; iVar4 = iVar4 + -1) { } } do { for (; iVar3 < 2; iVar3 = iVar3 + -1) { } puVar1 = param_2; do { iVar4 = (int)*puVar1; iVar5 = (int)((ulong)*puVar1 >> 0x20); if (iVar5 < iVar4) { *puVar1 = CONCAT44(iVar4,iVar5); } puVar1 = (int8 *)((long)puVar1 + 4); } while (puVar1 != (int8 *)((long)param_2 + (ulong)(iVar3 - 2) * 4 + 4)); iVar3 = iVar3 + -1; } while (iVar3 != 1); } lVar2 = 0; do { if (*(int *)((long)param_1 + lVar2) != *(int *)((long)param_2 + lVar2)) { return 0; } lVar2 = lVar2 + 4; } while (lVar2 != (long)param_3 * 4); return 1; }
6,496
func0
#include <stdbool.h> #include <assert.h>
bool func0(int test_tup1[], int n1, int test_tup2[], int n2) { for (int i = 0; i < n2; i++) { bool found = false; for (int j = 0; j < n1; j++) { if (test_tup2[i] == test_tup1[j]) { found = true; break; } } if (!found) { return false; } } return true; }
int main() { int set1[] = {10, 4, 5, 6}; int subset1[] = {5, 10}; assert(func0(set1, 4, subset1, 2) == true); int set2[] = {1, 2, 3, 4}; int subset2[] = {5, 6}; assert(func0(set2, 4, subset2, 2) == false); int set3[] = {7, 8, 9, 10}; int subset3[] = {10, 8}; assert(func0(set3, 4, subset3, 2) == true); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) mov %rdx,-0x28(%rbp) mov %ecx,-0x20(%rbp) movl $0x0,-0x8(%rbp) jmp 11ed <func0+0x84> movb $0x0,-0x9(%rbp) movl $0x0,-0x4(%rbp) jmp 11cf <func0+0x66> mov -0x8(%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 -0x18(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jne 11cb <func0+0x62> movb $0x1,-0x9(%rbp) jmp 11d7 <func0+0x6e> addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x1c(%rbp),%eax jl 1195 <func0+0x2c> movzbl -0x9(%rbp),%eax xor $0x1,%eax test %al,%al je 11e9 <func0+0x80> mov $0x0,%eax jmp 11fa <func0+0x91> addl $0x1,-0x8(%rbp) mov -0x8(%rbp),%eax cmp -0x20(%rbp),%eax jl 1188 <func0+0x1f> mov $0x1,%eax 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 [rbp+var_20], ecx mov [rbp+var_8], 0 jmp short loc_11ED loc_1188: mov [rbp+var_9], 0 mov [rbp+var_4], 0 jmp short loc_11CF loc_1195: mov eax, [rbp+var_8] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_4] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rcx mov eax, [rax] cmp edx, eax jnz short loc_11CB mov [rbp+var_9], 1 jmp short loc_11D7 loc_11CB: add [rbp+var_4], 1 loc_11CF: mov eax, [rbp+var_4] cmp eax, [rbp+var_1C] jl short loc_1195 loc_11D7: movzx eax, [rbp+var_9] xor eax, 1 test al, al jz short loc_11E9 mov eax, 0 jmp short loc_11FA loc_11E9: add [rbp+var_8], 1 loc_11ED: mov eax, [rbp+var_8] cmp eax, [rbp+var_20] jl short loc_1188 mov eax, 1 loc_11FA: pop rbp retn
long long func0(long long a1, int a2, long long a3, int a4) { char v5; // [rsp+1Fh] [rbp-9h] int i; // [rsp+20h] [rbp-8h] int j; // [rsp+24h] [rbp-4h] for ( i = 0; i < a4; ++i ) { v5 = 0; for ( j = 0; j < a2; ++j ) { if ( *(_DWORD *)(4LL * i + a3) == *(_DWORD *)(4LL * j + a1) ) { v5 = 1; break; } } if ( v5 != 1 ) return 0LL; } return 1LL; }
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 dword ptr [RBP + -0x20],ECX MOV dword ptr [RBP + -0x8],0x0 JMP 0x001011ed LAB_00101188: MOV byte ptr [RBP + -0x9],0x0 MOV dword ptr [RBP + -0x4],0x0 JMP 0x001011cf LAB_00101195: MOV EAX,dword ptr [RBP + -0x8] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JNZ 0x001011cb MOV byte ptr [RBP + -0x9],0x1 JMP 0x001011d7 LAB_001011cb: ADD dword ptr [RBP + -0x4],0x1 LAB_001011cf: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x1c] JL 0x00101195 LAB_001011d7: MOVZX EAX,byte ptr [RBP + -0x9] XOR EAX,0x1 TEST AL,AL JZ 0x001011e9 MOV EAX,0x0 JMP 0x001011fa LAB_001011e9: ADD dword ptr [RBP + -0x8],0x1 LAB_001011ed: MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x20] JL 0x00101188 MOV EAX,0x1 LAB_001011fa: POP RBP RET
int8 func0(long param_1,int param_2,long param_3,int param_4) { bool bVar1; int local_10; int local_c; local_10 = 0; do { if (param_4 <= local_10) { return 1; } bVar1 = false; for (local_c = 0; local_c < param_2; local_c = local_c + 1) { if (*(int *)(param_3 + (long)local_10 * 4) == *(int *)(param_1 + (long)local_c * 4)) { bVar1 = true; break; } } if (!bVar1) { return 0; } local_10 = local_10 + 1; } while( true ); }
6,497
func0
#include <stdbool.h> #include <assert.h>
bool func0(int test_tup1[], int n1, int test_tup2[], int n2) { for (int i = 0; i < n2; i++) { bool found = false; for (int j = 0; j < n1; j++) { if (test_tup2[i] == test_tup1[j]) { found = true; break; } } if (!found) { return false; } } return true; }
int main() { int set1[] = {10, 4, 5, 6}; int subset1[] = {5, 10}; assert(func0(set1, 4, subset1, 2) == true); int set2[] = {1, 2, 3, 4}; int subset2[] = {5, 6}; assert(func0(set2, 4, subset2, 2) == false); int set3[] = {7, 8, 9, 10}; int subset3[] = {10, 8}; assert(func0(set3, 4, subset3, 2) == true); return 0; }
O1
c
func0: endbr64 test %ecx,%ecx jle 1189 <func0+0x20> mov %rdx,%r8 lea -0x1(%rcx),%eax lea 0x4(%rdx,%rax,4),%r10 mov %rdi,%r9 lea -0x1(%rsi),%eax lea 0x4(%rdi,%rax,4),%rcx jmp 119e <func0+0x35> mov $0x1,%eax retq mov $0x0,%eax retq add $0x4,%r8 cmp %r10,%r8 je 11bb <func0+0x52> test %esi,%esi jle 118f <func0+0x26> mov (%r8),%edx mov %r9,%rax cmp (%rax),%edx je 1195 <func0+0x2c> add $0x4,%rax cmp %rcx,%rax jne 11a8 <func0+0x3f> mov $0x0,%eax retq mov $0x1,%eax retq
func0: endbr64 mov r8, rdi test ecx, ecx jle short loc_1189 mov rdi, rdx lea eax, [rcx-1] lea r9, [rdx+rax*4+4] lea eax, [rsi-1] lea rcx, [r8+rax*4+4] jmp short loc_119E loc_1189: mov eax, 1 retn loc_118F: mov eax, 0 retn loc_1195: add rdi, 4 cmp rdi, r9 jz short loc_11BA loc_119E: test esi, esi jle short loc_118F mov edx, [rdi] mov rax, r8 loc_11A7: cmp edx, [rax] jz short loc_1195 add rax, 4 cmp rax, rcx jnz short loc_11A7 mov eax, 0 retn loc_11BA: mov eax, 1 retn
long long func0(_DWORD *a1, int a2, _DWORD *a3, int a4) { _DWORD *v5; // rdi _DWORD *v7; // rax if ( a4 <= 0 ) return 1LL; v5 = a3; while ( 2 ) { if ( a2 <= 0 ) return 0LL; v7 = a1; while ( *v5 != *v7 ) { if ( ++v7 == &a1[a2 - 1 + 1] ) return 0LL; } if ( ++v5 != &a3[a4 - 1 + 1] ) continue; break; } return 1LL; }
6,498
func0
#include <stdbool.h> #include <assert.h>
bool func0(int test_tup1[], int n1, int test_tup2[], int n2) { for (int i = 0; i < n2; i++) { bool found = false; for (int j = 0; j < n1; j++) { if (test_tup2[i] == test_tup1[j]) { found = true; break; } } if (!found) { return false; } } return true; }
int main() { int set1[] = {10, 4, 5, 6}; int subset1[] = {5, 10}; assert(func0(set1, 4, subset1, 2) == true); int set2[] = {1, 2, 3, 4}; int subset2[] = {5, 6}; assert(func0(set2, 4, subset2, 2) == false); int set3[] = {7, 8, 9, 10}; int subset3[] = {10, 8}; assert(func0(set3, 4, subset3, 2) == true); return 0; }
O2
c
func0: endbr64 test %ecx,%ecx jle 1186 <func0+0x46> lea -0x1(%rcx),%eax mov %rdx,%r8 lea 0x4(%rdx,%rax,4),%r9 lea -0x1(%rsi),%eax lea 0x4(%rdi,%rax,4),%rcx nopl 0x0(%rax,%rax,1) test %esi,%esi jle 1190 <func0+0x50> mov (%r8),%edx mov %rdi,%rax jmp 1179 <func0+0x39> nopl 0x0(%rax) add $0x4,%rax cmp %rcx,%rax je 1190 <func0+0x50> cmp (%rax),%edx jne 1170 <func0+0x30> add $0x4,%r8 cmp %r9,%r8 jne 1160 <func0+0x20> mov $0x1,%eax retq nopl 0x0(%rax) xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 mov r8, rdi test ecx, ecx jle short loc_1326 lea eax, [rcx-1] lea r9, [rdx+rax*4+4] lea eax, [rsi-1] lea rdi, [rdi+rax*4+4] nop dword ptr [rax+rax+00h] loc_1300: test esi, esi jle short loc_1330 mov ecx, [rdx] mov rax, r8 jmp short loc_1319 loc_1310: add rax, 4 cmp rax, rdi jz short loc_1330 loc_1319: cmp ecx, [rax] jnz short loc_1310 add rdx, 4 cmp rdx, r9 jnz short loc_1300 loc_1326: mov eax, 1 retn loc_1330: xor eax, eax retn
long long func0(_DWORD *a1, int a2, _DWORD *a3, int a4) { long long v5; // r9 long long v6; // rdi _DWORD *v7; // rax if ( a4 <= 0 ) return 1LL; v5 = (long long)&a3[a4 - 1 + 1]; v6 = (long long)&a1[a2 - 1 + 1]; while ( a2 > 0 ) { v7 = a1; while ( *a3 != *v7 ) { if ( ++v7 == (_DWORD *)v6 ) return 0LL; } if ( ++a3 == (_DWORD *)v5 ) return 1LL; } return 0LL; }
func0: ENDBR64 MOV R8,RDI TEST ECX,ECX JLE 0x00101326 LEA EAX,[RCX + -0x1] LEA R9,[RDX + RAX*0x4 + 0x4] LEA EAX,[RSI + -0x1] LEA RDI,[RDI + RAX*0x4 + 0x4] NOP dword ptr [RAX + RAX*0x1] LAB_00101300: TEST ESI,ESI JLE 0x00101330 MOV ECX,dword ptr [RDX] MOV RAX,R8 JMP 0x00101319 LAB_00101310: ADD RAX,0x4 CMP RAX,RDI JZ 0x00101330 LAB_00101319: CMP ECX,dword ptr [RAX] JNZ 0x00101310 ADD RDX,0x4 CMP RDX,R9 JNZ 0x00101300 LAB_00101326: MOV EAX,0x1 RET LAB_00101330: XOR EAX,EAX RET
int8 func0(int *param_1,int param_2,int *param_3,int param_4) { int *piVar1; int *piVar2; if (0 < param_4) { piVar1 = param_3 + (ulong)(param_4 - 1) + 1; do { if (param_2 < 1) { return 0; } piVar2 = param_1; while (*param_3 != *piVar2) { piVar2 = piVar2 + 1; if (piVar2 == param_1 + (ulong)(param_2 - 1) + 1) { return 0; } } param_3 = param_3 + 1; } while (param_3 != piVar1); } return 1; }
6,499
func0
#include <stdbool.h> #include <assert.h>
bool func0(int test_tup1[], int n1, int test_tup2[], int n2) { for (int i = 0; i < n2; i++) { bool found = false; for (int j = 0; j < n1; j++) { if (test_tup2[i] == test_tup1[j]) { found = true; break; } } if (!found) { return false; } } return true; }
int main() { int set1[] = {10, 4, 5, 6}; int subset1[] = {5, 10}; assert(func0(set1, 4, subset1, 2) == true); int set2[] = {1, 2, 3, 4}; int subset2[] = {5, 6}; assert(func0(set2, 4, subset2, 2) == false); int set3[] = {7, 8, 9, 10}; int subset3[] = {10, 8}; assert(func0(set3, 4, subset3, 2) == true); return 0; }
O3
c
func0: endbr64 test %ecx,%ecx jle 1186 <func0+0x46> lea -0x1(%rcx),%eax mov %rdx,%r8 lea 0x4(%rdx,%rax,4),%r9 lea -0x1(%rsi),%eax lea 0x4(%rdi,%rax,4),%rcx nopl 0x0(%rax,%rax,1) test %esi,%esi jle 1190 <func0+0x50> mov (%r8),%edx mov %rdi,%rax jmp 1179 <func0+0x39> nopl 0x0(%rax) add $0x4,%rax cmp %rcx,%rax je 1190 <func0+0x50> cmp (%rax),%edx jne 1170 <func0+0x30> add $0x4,%r8 cmp %r9,%r8 jne 1160 <func0+0x20> mov $0x1,%eax retq nopl 0x0(%rax) xor %eax,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 mov r8, rdi test ecx, ecx jle short loc_1186 movsxd rcx, ecx movsxd rax, esi lea r9, [rdx+rcx*4] lea rdi, [rdi+rax*4] test esi, esi jle short loc_1190 nop dword ptr [rax] loc_1160: mov ecx, [rdx] mov rax, r8 jmp short loc_1179 loc_1170: add rax, 4 cmp rdi, rax jz short loc_1190 loc_1179: cmp ecx, [rax] jnz short loc_1170 add rdx, 4 cmp rdx, r9 jnz short loc_1160 loc_1186: mov eax, 1 retn loc_1190: xor eax, eax retn
long long func0(_DWORD *a1, int a2, _DWORD *a3, int a4) { _DWORD *v5; // r9 _DWORD *v6; // rdi _DWORD *v7; // rax if ( a4 <= 0 ) return 1LL; v5 = &a3[a4]; v6 = &a1[a2]; if ( a2 > 0 ) { do { v7 = a1; while ( *a3 != *v7 ) { if ( v6 == ++v7 ) return 0LL; } ++a3; } while ( a3 != v5 ); return 1LL; } return 0LL; }
func0: ENDBR64 MOV R8,RDI TEST ECX,ECX JLE 0x00101186 MOVSXD RCX,ECX MOVSXD RAX,ESI LEA R9,[RDX + RCX*0x4] LEA RDI,[RDI + RAX*0x4] TEST ESI,ESI JLE 0x00101190 NOP dword ptr [RAX] LAB_00101160: MOV ECX,dword ptr [RDX] MOV RAX,R8 JMP 0x00101179 LAB_00101170: ADD RAX,0x4 CMP RDI,RAX JZ 0x00101190 LAB_00101179: CMP ECX,dword ptr [RAX] JNZ 0x00101170 ADD RDX,0x4 CMP RDX,R9 JNZ 0x00101160 LAB_00101186: MOV EAX,0x1 RET LAB_00101190: XOR EAX,EAX RET
int8 func0(int *param_1,int param_2,int *param_3,int param_4) { int *piVar1; int *piVar2; if (0 < param_4) { piVar1 = param_3 + param_4; if (param_2 < 1) { return 0; } do { piVar2 = param_1; while (*param_3 != *piVar2) { piVar2 = piVar2 + 1; if (param_1 + param_2 == piVar2) { return 0; } } param_3 = param_3 + 1; } while (param_3 != piVar1); } return 1; }
6,500
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char* func0(int test_list[3][2][2], int rows, int cols, int pairs) { static char res[100]; int flat_list[6][2]; int f = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { flat_list[f][0] = test_list[i][j][0]; flat_list[f][1] = test_list[i][j][1]; f++; } } char temp1[50] = ""; char temp2[50] = ""; char part1[10], part2[10]; for (int k = 0; k < 6; k++) { sprintf(part1, "%d", flat_list[k][0]); sprintf(part2, "%d", flat_list[k][1]); strcat(temp1, part1); strcat(temp2, part2); if (k != 5) { strcat(temp1, ", "); strcat(temp2, ", "); } } sprintf(res, "[(%s), (%s)]", temp1, temp2); return res; }
int main() { int test1[3][2][2] = {{{4, 5}, {7, 8}}, {{10, 13}, {18, 17}}, {{0, 4}, {10, 1}}}; int test2[3][2][2] = {{{5, 6}, {8, 9}}, {{11, 14}, {19, 18}}, {{1, 5}, {11, 2}}}; int test3[3][2][2] = {{{6, 7}, {9, 10}}, {{12, 15}, {20, 21}}, {{23, 7}, {15, 8}}}; assert(strcmp(func0(test1, 3, 2, 2), "[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]") == 0); assert(strcmp(func0(test2, 3, 2, 2), "[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]") == 0); assert(strcmp(func0(test3, 3, 2, 2), "[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]") == 0); printf("All tests passed!\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x100,%rsp mov %rdi,-0xe8(%rbp) mov %esi,-0xec(%rbp) mov %edx,-0xf0(%rbp) mov %ecx,-0xf4(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movl $0x0,-0xe0(%rbp) movl $0x0,-0xdc(%rbp) jmpq 12d3 <func0+0xea> movl $0x0,-0xd8(%rbp) jmp 12ba <func0+0xd1> mov -0xdc(%rbp),%eax cltq shl $0x4,%rax mov %rax,%rdx mov -0xe8(%rbp),%rax add %rax,%rdx mov -0xd8(%rbp),%eax cltq mov (%rdx,%rax,8),%edx mov -0xe0(%rbp),%eax cltq mov %edx,-0xd0(%rbp,%rax,8) mov -0xdc(%rbp),%eax cltq shl $0x4,%rax mov %rax,%rdx mov -0xe8(%rbp),%rax add %rax,%rdx mov -0xd8(%rbp),%eax cltq mov 0x4(%rdx,%rax,8),%edx mov -0xe0(%rbp),%eax cltq mov %edx,-0xcc(%rbp,%rax,8) addl $0x1,-0xe0(%rbp) addl $0x1,-0xd8(%rbp) mov -0xd8(%rbp),%eax cmp -0xf0(%rbp),%eax jl 1245 <func0+0x5c> addl $0x1,-0xdc(%rbp) mov -0xdc(%rbp),%eax cmp -0xec(%rbp),%eax jl 1239 <func0+0x50> movq $0x0,-0x80(%rbp) movq $0x0,-0x78(%rbp) movq $0x0,-0x70(%rbp) movq $0x0,-0x68(%rbp) movq $0x0,-0x60(%rbp) movq $0x0,-0x58(%rbp) movw $0x0,-0x50(%rbp) movq $0x0,-0x40(%rbp) movq $0x0,-0x38(%rbp) movq $0x0,-0x30(%rbp) movq $0x0,-0x28(%rbp) movq $0x0,-0x20(%rbp) movq $0x0,-0x18(%rbp) movw $0x0,-0x10(%rbp) movl $0x0,-0xd4(%rbp) jmpq 1454 <func0+0x26b> mov -0xd4(%rbp),%eax cltq mov -0xd0(%rbp,%rax,8),%edx lea -0x94(%rbp),%rax lea 0xc8b(%rip),%rsi mov %rax,%rdi mov $0x0,%eax callq 10f0 <sprintf@plt> mov -0xd4(%rbp),%eax cltq mov -0xcc(%rbp,%rax,8),%edx lea -0x8a(%rbp),%rax lea 0xc61(%rip),%rsi mov %rax,%rdi mov $0x0,%eax callq 10f0 <sprintf@plt> lea -0x94(%rbp),%rdx lea -0x80(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 10e0 <strcat@plt> lea -0x8a(%rbp),%rdx lea -0x40(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 10e0 <strcat@plt> cmpl $0x5,-0xd4(%rbp) je 144d <func0+0x264> lea -0x80(%rbp),%rax mov $0xffffffffffffffff,%rcx mov %rax,%rdx mov $0x0,%eax mov %rdx,%rdi repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax lea -0x1(%rax),%rdx lea -0x80(%rbp),%rax add %rdx,%rax movw $0x202c,(%rax) movb $0x0,0x2(%rax) lea -0x40(%rbp),%rax mov $0xffffffffffffffff,%rcx mov %rax,%rdx mov $0x0,%eax mov %rdx,%rdi repnz scas %es:(%rdi),%al mov %rcx,%rax not %rax lea -0x1(%rax),%rdx lea -0x40(%rbp),%rax add %rdx,%rax movw $0x202c,(%rax) movb $0x0,0x2(%rax) addl $0x1,-0xd4(%rbp) cmpl $0x5,-0xd4(%rbp) jle 1360 <func0+0x177> lea -0x40(%rbp),%rdx lea -0x80(%rbp),%rax mov %rdx,%rcx mov %rax,%rdx lea 0xb95(%rip),%rsi lea 0x2bc3(%rip),%rdi mov $0x0,%eax callq 10f0 <sprintf@plt> lea 0x2bb2(%rip),%rax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi je 14a2 <func0+0x2b9> callq 10b0 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 100h mov [rbp+var_E8], rdi mov [rbp+var_EC], esi mov [rbp+var_F0], edx mov [rbp+var_F4], ecx mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov [rbp+var_E0], 0 mov [rbp+var_DC], 0 jmp loc_12F3 loc_1259: mov [rbp+var_D8], 0 jmp short loc_12DA loc_1265: mov eax, [rbp+var_DC] cdqe shl rax, 4 mov rdx, rax mov rax, [rbp+var_E8] add rdx, rax mov eax, [rbp+var_D8] cdqe mov edx, [rdx+rax*8] mov eax, [rbp+var_E0] cdqe mov [rbp+rax*8+var_D0], edx mov eax, [rbp+var_DC] cdqe shl rax, 4 mov rdx, rax mov rax, [rbp+var_E8] add rdx, rax mov eax, [rbp+var_D8] cdqe mov edx, [rdx+rax*8+4] mov eax, [rbp+var_E0] cdqe mov [rbp+rax*8+var_CC], edx add [rbp+var_E0], 1 add [rbp+var_D8], 1 loc_12DA: mov eax, [rbp+var_D8] cmp eax, [rbp+var_F0] jl loc_1265 add [rbp+var_DC], 1 loc_12F3: mov eax, [rbp+var_DC] cmp eax, [rbp+var_EC] jl loc_1259 mov qword ptr [rbp+dest], 0 mov [rbp+var_78], 0 mov [rbp+var_70], 0 mov [rbp+var_68], 0 mov [rbp+var_60], 0 mov [rbp+var_58], 0 mov [rbp+var_50], 0 mov qword ptr [rbp+var_40], 0 mov [rbp+var_38], 0 mov [rbp+var_30], 0 mov [rbp+var_28], 0 mov [rbp+var_20], 0 mov [rbp+var_18], 0 mov [rbp+var_10], 0 mov [rbp+var_D4], 0 jmp loc_1454 loc_1380: mov eax, [rbp+var_D4] cdqe mov edx, [rbp+rax*8+var_D0] lea rax, [rbp+s] lea rcx, format; "%d" mov rsi, rcx; format mov rdi, rax; s mov eax, 0 call _sprintf mov eax, [rbp+var_D4] cdqe mov edx, [rbp+rax*8+var_CC] lea rax, [rbp+src] lea rcx, format; "%d" mov rsi, rcx; format mov rdi, rax; s mov eax, 0 call _sprintf lea rdx, [rbp+s] lea rax, [rbp+dest] mov rsi, rdx; src mov rdi, rax; dest call _strcat lea rdx, [rbp+src] lea rax, [rbp+var_40] mov rsi, rdx; src mov rdi, rax; dest call _strcat cmp [rbp+var_D4], 5 jz short loc_144D lea rax, [rbp+dest] mov rdi, rax; s call _strlen mov rdx, rax lea rax, [rbp+dest] add rax, rdx mov word ptr [rax], 202Ch mov byte ptr [rax+2], 0 lea rax, [rbp+var_40] mov rdi, rax; s call _strlen mov rdx, rax lea rax, [rbp+var_40] add rax, rdx mov word ptr [rax], 202Ch mov byte ptr [rax+2], 0 loc_144D: add [rbp+var_D4], 1 loc_1454: cmp [rbp+var_D4], 5 jle loc_1380 lea rdx, [rbp+var_40] lea rax, [rbp+dest] mov rcx, rdx mov rdx, rax lea rax, aSS; "[(%s), (%s)]" mov rsi, rax; format lea rax, res_1 mov rdi, rax; s mov eax, 0 call _sprintf lea rax, res_1 mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_14A8 call ___stack_chk_fail locret_14A8: leave retn
char * func0(long long a1, int a2, int a3) { int v4; // [rsp+20h] [rbp-E0h] int i; // [rsp+24h] [rbp-DCh] int j; // [rsp+28h] [rbp-D8h] int k; // [rsp+2Ch] [rbp-D4h] _DWORD v8[15]; // [rsp+30h] [rbp-D0h] char s[10]; // [rsp+6Ch] [rbp-94h] BYREF char src[10]; // [rsp+76h] [rbp-8Ah] BYREF char dest[8]; // [rsp+80h] [rbp-80h] BYREF long long v12; // [rsp+88h] [rbp-78h] long long v13; // [rsp+90h] [rbp-70h] long long v14; // [rsp+98h] [rbp-68h] long long v15; // [rsp+A0h] [rbp-60h] long long v16; // [rsp+A8h] [rbp-58h] __int16 v17; // [rsp+B0h] [rbp-50h] char v18[8]; // [rsp+C0h] [rbp-40h] BYREF long long v19; // [rsp+C8h] [rbp-38h] long long v20; // [rsp+D0h] [rbp-30h] long long v21; // [rsp+D8h] [rbp-28h] long long v22; // [rsp+E0h] [rbp-20h] long long v23; // [rsp+E8h] [rbp-18h] __int16 v24; // [rsp+F0h] [rbp-10h] unsigned long long v25; // [rsp+F8h] [rbp-8h] v25 = __readfsqword(0x28u); v4 = 0; for ( i = 0; i < a2; ++i ) { for ( j = 0; j < a3; ++j ) { v8[2 * v4] = *(_DWORD *)(a1 + 16LL * i + 8LL * j); v8[2 * v4++ + 1] = *(_DWORD *)(a1 + 16LL * i + 8LL * j + 4); } } *(_QWORD *)dest = 0LL; v12 = 0LL; v13 = 0LL; v14 = 0LL; v15 = 0LL; v16 = 0LL; v17 = 0; *(_QWORD *)v18 = 0LL; v19 = 0LL; v20 = 0LL; v21 = 0LL; v22 = 0LL; v23 = 0LL; v24 = 0; for ( k = 0; k <= 5; ++k ) { sprintf(s, "%d", v8[2 * k]); sprintf(src, "%d", v8[2 * k + 1]); strcat(dest, s); strcat(v18, src); if ( k != 5 ) { strcpy(&dest[strlen(dest)], ", "); strcpy(&v18[strlen(v18)], ", "); } } sprintf(res_1, "[(%s), (%s)]", dest, v18); return res_1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x100 MOV qword ptr [RBP + -0xe8],RDI MOV dword ptr [RBP + -0xec],ESI MOV dword ptr [RBP + -0xf0],EDX MOV dword ptr [RBP + -0xf4],ECX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV dword ptr [RBP + -0xe0],0x0 MOV dword ptr [RBP + -0xdc],0x0 JMP 0x001012f3 LAB_00101259: MOV dword ptr [RBP + -0xd8],0x0 JMP 0x001012da LAB_00101265: MOV EAX,dword ptr [RBP + -0xdc] CDQE SHL RAX,0x4 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0xe8] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0xd8] CDQE MOV EDX,dword ptr [RDX + RAX*0x8] MOV EAX,dword ptr [RBP + -0xe0] CDQE MOV dword ptr [RBP + RAX*0x8 + -0xd0],EDX MOV EAX,dword ptr [RBP + -0xdc] CDQE SHL RAX,0x4 MOV RDX,RAX MOV RAX,qword ptr [RBP + -0xe8] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0xd8] CDQE MOV EDX,dword ptr [RDX + RAX*0x8 + 0x4] MOV EAX,dword ptr [RBP + -0xe0] CDQE MOV dword ptr [RBP + RAX*0x8 + -0xcc],EDX ADD dword ptr [RBP + -0xe0],0x1 ADD dword ptr [RBP + -0xd8],0x1 LAB_001012da: MOV EAX,dword ptr [RBP + -0xd8] CMP EAX,dword ptr [RBP + -0xf0] JL 0x00101265 ADD dword ptr [RBP + -0xdc],0x1 LAB_001012f3: MOV EAX,dword ptr [RBP + -0xdc] CMP EAX,dword ptr [RBP + -0xec] JL 0x00101259 MOV qword ptr [RBP + -0x80],0x0 MOV qword ptr [RBP + -0x78],0x0 MOV qword ptr [RBP + -0x70],0x0 MOV qword ptr [RBP + -0x68],0x0 MOV qword ptr [RBP + -0x60],0x0 MOV qword ptr [RBP + -0x58],0x0 MOV word ptr [RBP + -0x50],0x0 MOV qword ptr [RBP + -0x40],0x0 MOV qword ptr [RBP + -0x38],0x0 MOV qword ptr [RBP + -0x30],0x0 MOV qword ptr [RBP + -0x28],0x0 MOV qword ptr [RBP + -0x20],0x0 MOV qword ptr [RBP + -0x18],0x0 MOV word ptr [RBP + -0x10],0x0 MOV dword ptr [RBP + -0xd4],0x0 JMP 0x00101454 LAB_00101380: MOV EAX,dword ptr [RBP + -0xd4] CDQE MOV EDX,dword ptr [RBP + RAX*0x8 + -0xd0] LEA RAX,[RBP + -0x94] LEA RCX,[0x102008] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x00101110 MOV EAX,dword ptr [RBP + -0xd4] CDQE MOV EDX,dword ptr [RBP + RAX*0x8 + -0xcc] LEA RAX,[RBP + -0x8a] LEA RCX,[0x102008] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x00101110 LEA RDX,[RBP + -0x94] LEA RAX,[RBP + -0x80] MOV RSI,RDX MOV RDI,RAX CALL 0x00101100 LEA RDX,[RBP + -0x8a] LEA RAX,[RBP + -0x40] MOV RSI,RDX MOV RDI,RAX CALL 0x00101100 CMP dword ptr [RBP + -0xd4],0x5 JZ 0x0010144d LEA RAX,[RBP + -0x80] MOV RDI,RAX CALL 0x001010c0 MOV RDX,RAX LEA RAX,[RBP + -0x80] ADD RAX,RDX MOV word ptr [RAX],0x202c MOV byte ptr [RAX + 0x2],0x0 LEA RAX,[RBP + -0x40] MOV RDI,RAX CALL 0x001010c0 MOV RDX,RAX LEA RAX,[RBP + -0x40] ADD RAX,RDX MOV word ptr [RAX],0x202c MOV byte ptr [RAX + 0x2],0x0 LAB_0010144d: ADD dword ptr [RBP + -0xd4],0x1 LAB_00101454: CMP dword ptr [RBP + -0xd4],0x5 JLE 0x00101380 LEA RDX,[RBP + -0x40] LEA RAX,[RBP + -0x80] MOV RCX,RDX MOV RDX,RAX LEA RAX,[0x10200b] MOV RSI,RAX LEA RAX,[0x104040] MOV RDI,RAX MOV EAX,0x0 CALL 0x00101110 LEA RAX,[0x104040] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x001014a8 CALL 0x001010d0 LAB_001014a8: LEAVE RET
int1 * func0(long param_1,int param_2,int param_3) { size_t sVar1; long in_FS_OFFSET; int local_e8; int local_e4; int local_e0; int local_dc; uint auStack_d8 [15]; char local_9c [10]; char local_92 [10]; char local_88 [64]; char local_48 [56]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_e8 = 0; for (local_e4 = 0; local_e4 < param_2; local_e4 = local_e4 + 1) { for (local_e0 = 0; local_e0 < param_3; local_e0 = local_e0 + 1) { auStack_d8[(long)local_e8 * 2] = *(uint *)((long)local_e4 * 0x10 + param_1 + (long)local_e0 * 8); auStack_d8[(long)local_e8 * 2 + 1] = *(uint *)((long)local_e4 * 0x10 + param_1 + 4 + (long)local_e0 * 8); local_e8 = local_e8 + 1; } } local_88[0] = '\0'; local_88[1] = '\0'; local_88[2] = '\0'; local_88[3] = '\0'; local_88[4] = '\0'; local_88[5] = '\0'; local_88[6] = '\0'; local_88[7] = '\0'; local_88[8] = '\0'; local_88[9] = '\0'; local_88[10] = '\0'; local_88[0xb] = '\0'; local_88[0xc] = '\0'; local_88[0xd] = '\0'; local_88[0xe] = '\0'; local_88[0xf] = '\0'; local_88[0x10] = '\0'; local_88[0x11] = '\0'; local_88[0x12] = '\0'; local_88[0x13] = '\0'; local_88[0x14] = '\0'; local_88[0x15] = '\0'; local_88[0x16] = '\0'; local_88[0x17] = '\0'; local_88[0x18] = '\0'; local_88[0x19] = '\0'; local_88[0x1a] = '\0'; local_88[0x1b] = '\0'; local_88[0x1c] = '\0'; local_88[0x1d] = '\0'; local_88[0x1e] = '\0'; local_88[0x1f] = '\0'; local_88[0x20] = '\0'; local_88[0x21] = '\0'; local_88[0x22] = '\0'; local_88[0x23] = '\0'; local_88[0x24] = '\0'; local_88[0x25] = '\0'; local_88[0x26] = '\0'; local_88[0x27] = '\0'; local_88[0x28] = '\0'; local_88[0x29] = '\0'; local_88[0x2a] = '\0'; local_88[0x2b] = '\0'; local_88[0x2c] = '\0'; local_88[0x2d] = '\0'; local_88[0x2e] = '\0'; local_88[0x2f] = '\0'; local_88[0x30] = '\0'; local_88[0x31] = '\0'; local_48[0] = '\0'; local_48[1] = '\0'; local_48[2] = '\0'; local_48[3] = '\0'; local_48[4] = '\0'; local_48[5] = '\0'; local_48[6] = '\0'; local_48[7] = '\0'; local_48[8] = '\0'; local_48[9] = '\0'; local_48[10] = '\0'; local_48[0xb] = '\0'; local_48[0xc] = '\0'; local_48[0xd] = '\0'; local_48[0xe] = '\0'; local_48[0xf] = '\0'; local_48[0x10] = '\0'; local_48[0x11] = '\0'; local_48[0x12] = '\0'; local_48[0x13] = '\0'; local_48[0x14] = '\0'; local_48[0x15] = '\0'; local_48[0x16] = '\0'; local_48[0x17] = '\0'; local_48[0x18] = '\0'; local_48[0x19] = '\0'; local_48[0x1a] = '\0'; local_48[0x1b] = '\0'; local_48[0x1c] = '\0'; local_48[0x1d] = '\0'; local_48[0x1e] = '\0'; local_48[0x1f] = '\0'; local_48[0x20] = '\0'; local_48[0x21] = '\0'; local_48[0x22] = '\0'; local_48[0x23] = '\0'; local_48[0x24] = '\0'; local_48[0x25] = '\0'; local_48[0x26] = '\0'; local_48[0x27] = '\0'; local_48[0x28] = '\0'; local_48[0x29] = '\0'; local_48[0x2a] = '\0'; local_48[0x2b] = '\0'; local_48[0x2c] = '\0'; local_48[0x2d] = '\0'; local_48[0x2e] = '\0'; local_48[0x2f] = '\0'; local_48[0x30] = '\0'; local_48[0x31] = '\0'; for (local_dc = 0; local_dc < 6; local_dc = local_dc + 1) { sprintf(local_9c,"%d",(ulong)auStack_d8[(long)local_dc * 2]); sprintf(local_92,"%d",(ulong)auStack_d8[(long)local_dc * 2 + 1]); strcat(local_88,local_9c); strcat(local_48,local_92); if (local_dc != 5) { sVar1 = strlen(local_88); (local_88 + sVar1)[0] = ','; (local_88 + sVar1)[1] = ' '; local_88[sVar1 + 2] = '\0'; sVar1 = strlen(local_48); (local_48 + sVar1)[0] = ','; (local_48 + sVar1)[1] = ' '; local_48[sVar1 + 2] = '\0'; } } sprintf(res_1,"[(%s), (%s)]",local_88,local_48); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return res_1; }
6,501
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char* func0(int test_list[3][2][2], int rows, int cols, int pairs) { static char res[100]; int flat_list[6][2]; int f = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { flat_list[f][0] = test_list[i][j][0]; flat_list[f][1] = test_list[i][j][1]; f++; } } char temp1[50] = ""; char temp2[50] = ""; char part1[10], part2[10]; for (int k = 0; k < 6; k++) { sprintf(part1, "%d", flat_list[k][0]); sprintf(part2, "%d", flat_list[k][1]); strcat(temp1, part1); strcat(temp2, part2); if (k != 5) { strcat(temp1, ", "); strcat(temp2, ", "); } } sprintf(res, "[(%s), (%s)]", temp1, temp2); return res; }
int main() { int test1[3][2][2] = {{{4, 5}, {7, 8}}, {{10, 13}, {18, 17}}, {{0, 4}, {10, 1}}}; int test2[3][2][2] = {{{5, 6}, {8, 9}}, {{11, 14}, {19, 18}}, {{1, 5}, {11, 2}}}; int test3[3][2][2] = {{{6, 7}, {9, 10}}, {{12, 15}, {20, 21}}, {{23, 7}, {15, 8}}}; assert(strcmp(func0(test1, 3, 2, 2), "[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]") == 0); assert(strcmp(func0(test2, 3, 2, 2), "[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]") == 0); assert(strcmp(func0(test3, 3, 2, 2), "[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]") == 0); printf("All tests passed!\n"); return 0; }
O1
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0xd8,%rsp mov %fs:0x28,%rax mov %rax,0xc8(%rsp) xor %eax,%eax test %esi,%esi jle 1248 <func0+0x7f> mov %rdi,%r8 lea -0x1(%rsi),%eax shl $0x4,%rax lea 0x10(%rdi,%rax,1),%r10 mov $0x0,%r9d mov %rsp,%r11 jmp 1242 <func0+0x79> mov %r8,%rsi movslq %r9d,%rax lea (%r11,%rax,8),%rcx mov $0x0,%eax mov (%rsi,%rax,8),%edi mov %edi,(%rcx) mov 0x4(%rsi,%rax,8),%edi mov %edi,0x4(%rcx) add $0x1,%rax add $0x8,%rcx cmp %eax,%edx jg 121e <func0+0x55> add %edx,%r9d add $0x10,%r8 cmp %r10,%r8 je 1248 <func0+0x7f> test %edx,%edx jg 120f <func0+0x46> jmp 1239 <func0+0x70> movq $0x0,0x50(%rsp) movq $0x0,0x58(%rsp) movq $0x0,0x60(%rsp) movq $0x0,0x68(%rsp) movq $0x0,0x70(%rsp) movq $0x0,0x78(%rsp) movw $0x0,0x80(%rsp) movq $0x0,0x90(%rsp) movq $0x0,0x98(%rsp) movq $0x0,0xa0(%rsp) movq $0x0,0xa8(%rsp) movq $0x0,0xb0(%rsp) movq $0x0,0xb8(%rsp) movw $0x0,0xc0(%rsp) lea 0x3c(%rsp),%rbp mov (%rsp),%r8d lea 0xd1a(%rip),%rcx mov $0xa,%edx mov $0x1,%esi mov %rbp,%rdi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> lea 0x46(%rsp),%rbx mov 0x4(%rsp),%r8d lea 0xcf2(%rip),%rcx mov $0xa,%edx mov $0x1,%esi mov %rbx,%rdi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> lea 0x50(%rsp),%rdi mov $0x32,%edx mov %rbp,%rsi callq 1090 <__strcat_chk@plt> lea 0x90(%rsp),%rdi mov $0x32,%edx mov %rbx,%rsi callq 1090 <__strcat_chk@plt> mov %rsp,%rbx lea 0x28(%rsp),%r15 lea 0x50(%rsp),%r14 mov $0x32,%edx lea 0xc9e(%rip),%rsi mov %r14,%rdi callq 1090 <__strcat_chk@plt> lea 0x90(%rsp),%rbp mov $0x32,%edx lea 0xc82(%rip),%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> lea 0x3c(%rsp),%r13 mov 0x8(%rbx),%r8d lea 0xc67(%rip),%rcx mov $0xa,%edx mov $0x1,%esi mov %r13,%rdi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> lea 0x46(%rsp),%r12 mov 0xc(%rbx),%r8d lea 0xc40(%rip),%rcx mov $0xa,%edx mov $0x1,%esi mov %r12,%rdi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> mov $0x32,%edx mov %r13,%rsi mov %r14,%rdi callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r12,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> add $0x8,%rbx cmp %r15,%rbx jne 135d <func0+0x194> lea 0x90(%rsp),%r9 lea 0x50(%rsp),%r8 lea 0xbee(%rip),%rcx mov $0x64,%edx mov $0x1,%esi lea 0x2c13(%rip),%rdi mov $0x0,%eax callq 10d0 <__sprintf_chk@plt> mov 0xc8(%rsp),%rax xor %fs:0x28,%rax jne 1463 <func0+0x29a> lea 0x2bef(%rip),%rax add $0xd8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq callq 10b0 <__stack_chk_fail@plt>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 0E8h mov rax, fs:28h mov [rsp+118h+var_40], rax xor eax, eax test esi, esi jle short loc_126E mov r8d, edx mov r9, rdi lea eax, [rsi-1] shl rax, 4 lea r10, [rdi+rax+10h] mov edi, 0 lea r11, [rsp+118h+var_108] jmp short loc_1267 loc_1233: mov rcx, r9 movsxd rax, edi lea rdx, [r11+rax*8] mov eax, 0 loc_1242: mov esi, [rcx+rax*8] mov [rdx], esi mov esi, [rcx+rax*8+4] mov [rdx+4], esi add rax, 1 add rdx, 8 cmp r8d, eax jg short loc_1242 add edi, r8d loc_125E: add r9, 10h cmp r9, r10 jz short loc_126E loc_1267: test r8d, r8d jg short loc_1233 jmp short loc_125E loc_126E: mov [rsp+118h+var_B8], 0 mov [rsp+118h+var_B0], 0 mov [rsp+118h+var_A8], 0 mov [rsp+118h+var_A0], 0 mov [rsp+118h+var_98], 0 mov [rsp+118h+var_90], 0 mov [rsp+118h+var_88], 0 mov [rsp+118h+var_78], 0 mov [rsp+118h+var_70], 0 mov [rsp+118h+var_68], 0 mov [rsp+118h+var_60], 0 mov [rsp+118h+var_58], 0 mov [rsp+118h+var_50], 0 mov [rsp+118h+var_48], 0 lea rbp, [rsp+118h+var_CC] mov r8d, [rsp+118h+var_108] lea r12, unk_2004 mov rcx, r12 mov edx, 0Ah mov esi, 1 mov rdi, rbp mov eax, 0 call ___sprintf_chk lea rbx, [rsp+118h+var_C2] mov r8d, [rsp+118h+var_104] mov rcx, r12 mov edx, 0Ah mov esi, 1 mov rdi, rbx mov eax, 0 call ___sprintf_chk lea rdi, [rsp+118h+var_B8] mov edx, 32h ; '2' mov rsi, rbp call ___strcat_chk lea rdi, [rsp+118h+var_78] mov edx, 32h ; '2' mov rsi, rbx call ___strcat_chk lea rbx, [rsp+118h+var_108] lea rax, [rsp+118h+var_E0] mov [rsp+118h+var_110], rax lea r15, [rsp+118h+var_B8] lea r14, unk_2007 lea r13, [rsp+118h+var_78] loc_139F: mov edx, 32h ; '2' mov rsi, r14 mov rdi, r15 call ___strcat_chk mov edx, 32h ; '2' mov rsi, r14 mov rdi, r13 call ___strcat_chk lea r12, [rsp+118h+var_CC] mov r8d, [rbx+8] lea rcx, unk_2004 mov edx, 0Ah mov esi, 1 mov rdi, r12 mov eax, 0 call ___sprintf_chk lea rbp, [rsp+118h+var_C2] mov r8d, [rbx+0Ch] lea rcx, unk_2004 mov edx, 0Ah mov esi, 1 mov rdi, rbp mov eax, 0 call ___sprintf_chk mov edx, 32h ; '2' mov rsi, r12 mov rdi, r15 call ___strcat_chk mov edx, 32h ; '2' mov rsi, rbp mov rdi, r13 call ___strcat_chk add rbx, 8 cmp rbx, [rsp+118h+var_110] jnz loc_139F lea r9, [rsp+118h+var_78] lea r8, [rsp+118h+var_B8] lea rcx, aSS; "[(%s), (%s)]" mov edx, 64h ; 'd' mov esi, 1 lea rbx, res_1 mov rdi, rbx mov eax, 0 call ___sprintf_chk mov rax, [rsp+118h+var_40] sub rax, fs:28h jnz short loc_1496 mov rax, rbx add rsp, 0E8h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1496: call ___stack_chk_fail
void * func0(long long a1, int a2, int a3) { long long v4; // r9 long long v5; // r10 int v6; // edi _DWORD *v7; // rdx long long v8; // rax char *v9; // rbx _DWORD v11[10]; // [rsp+10h] [rbp-108h] BYREF char v12; // [rsp+38h] [rbp-E0h] BYREF _BYTE v13[10]; // [rsp+4Ch] [rbp-CCh] BYREF _BYTE v14[10]; // [rsp+56h] [rbp-C2h] BYREF _QWORD v15[6]; // [rsp+60h] [rbp-B8h] BYREF __int16 v16; // [rsp+90h] [rbp-88h] _QWORD v17[6]; // [rsp+A0h] [rbp-78h] BYREF __int16 v18; // [rsp+D0h] [rbp-48h] unsigned long long v19; // [rsp+D8h] [rbp-40h] v19 = __readfsqword(0x28u); if ( a2 > 0 ) { v4 = a1; v5 = a1 + 16LL * (unsigned int)(a2 - 1) + 16; v6 = 0; do { if ( a3 > 0 ) { v7 = &v11[2 * v6]; v8 = 0LL; do { *v7 = *(_DWORD *)(v4 + 8 * v8); v7[1] = *(_DWORD *)(v4 + 8 * v8++ + 4); v7 += 2; } while ( a3 > (int)v8 ); v6 += a3; } v4 += 16LL; } while ( v4 != v5 ); } memset(v15, 0, sizeof(v15)); v16 = 0; memset(v17, 0, sizeof(v17)); v18 = 0; __sprintf_chk(v13, 1LL, 10LL, &unk_2004, v11[0]); __sprintf_chk(v14, 1LL, 10LL, &unk_2004, v11[1]); __strcat_chk(v15, v13, 50LL); __strcat_chk(v17, v14, 50LL); v9 = (char *)v11; do { __strcat_chk(v15, &unk_2007, 50LL); __strcat_chk(v17, &unk_2007, 50LL); __sprintf_chk(v13, 1LL, 10LL, &unk_2004, *((unsigned int *)v9 + 2)); __sprintf_chk(v14, 1LL, 10LL, &unk_2004, *((unsigned int *)v9 + 3)); __strcat_chk(v15, v13, 50LL); __strcat_chk(v17, v14, 50LL); v9 += 8; } while ( v9 != &v12 ); __sprintf_chk(&res_1, 1LL, 100LL, "[(%s), (%s)]", v15); return &res_1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0xe8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xd8],RAX XOR EAX,EAX TEST ESI,ESI JLE 0x0010126e MOV R8D,EDX MOV R9,RDI LEA EAX,[RSI + -0x1] SHL RAX,0x4 LEA R10,[RDI + RAX*0x1 + 0x10] MOV EDI,0x0 LEA R11,[RSP + 0x10] JMP 0x00101267 LAB_00101233: MOV RCX,R9 MOVSXD RAX,EDI LEA RDX,[R11 + RAX*0x8] MOV EAX,0x0 LAB_00101242: MOV ESI,dword ptr [RCX + RAX*0x8] MOV dword ptr [RDX],ESI MOV ESI,dword ptr [RCX + RAX*0x8 + 0x4] MOV dword ptr [RDX + 0x4],ESI ADD RAX,0x1 ADD RDX,0x8 CMP R8D,EAX JG 0x00101242 ADD EDI,R8D LAB_0010125e: ADD R9,0x10 CMP R9,R10 JZ 0x0010126e LAB_00101267: TEST R8D,R8D JG 0x00101233 JMP 0x0010125e LAB_0010126e: MOV qword ptr [RSP + 0x60],0x0 MOV qword ptr [RSP + 0x68],0x0 MOV qword ptr [RSP + 0x70],0x0 MOV qword ptr [RSP + 0x78],0x0 MOV qword ptr [RSP + 0x80],0x0 MOV qword ptr [RSP + 0x88],0x0 MOV word ptr [RSP + 0x90],0x0 MOV qword ptr [RSP + 0xa0],0x0 MOV qword ptr [RSP + 0xa8],0x0 MOV qword ptr [RSP + 0xb0],0x0 MOV qword ptr [RSP + 0xb8],0x0 MOV qword ptr [RSP + 0xc0],0x0 MOV qword ptr [RSP + 0xc8],0x0 MOV word ptr [RSP + 0xd0],0x0 LEA RBP,[RSP + 0x4c] MOV R8D,dword ptr [RSP + 0x10] LEA R12,[0x102004] MOV RCX,R12 MOV EDX,0xa MOV ESI,0x1 MOV RDI,RBP MOV EAX,0x0 CALL 0x001010f0 LEA RBX,[RSP + 0x56] MOV R8D,dword ptr [RSP + 0x14] MOV RCX,R12 MOV EDX,0xa MOV ESI,0x1 MOV RDI,RBX MOV EAX,0x0 CALL 0x001010f0 LEA RDI,[RSP + 0x60] MOV EDX,0x32 MOV RSI,RBP CALL 0x001010a0 LEA RDI,[RSP + 0xa0] MOV EDX,0x32 MOV RSI,RBX CALL 0x001010a0 LEA RBX,[RSP + 0x10] LEA RAX,[RSP + 0x38] MOV qword ptr [RSP + 0x8],RAX LEA R15,[RSP + 0x60] LEA R14,[0x102007] LEA R13,[RSP + 0xa0] LAB_0010139f: MOV EDX,0x32 MOV RSI,R14 MOV RDI,R15 CALL 0x001010a0 MOV EDX,0x32 MOV RSI,R14 MOV RDI,R13 CALL 0x001010a0 LEA R12,[RSP + 0x4c] MOV R8D,dword ptr [RBX + 0x8] LEA RCX,[0x102004] MOV EDX,0xa MOV ESI,0x1 MOV RDI,R12 MOV EAX,0x0 CALL 0x001010f0 LEA RBP,[RSP + 0x56] MOV R8D,dword ptr [RBX + 0xc] LEA RCX,[0x102004] MOV EDX,0xa MOV ESI,0x1 MOV RDI,RBP MOV EAX,0x0 CALL 0x001010f0 MOV EDX,0x32 MOV RSI,R12 MOV RDI,R15 CALL 0x001010a0 MOV EDX,0x32 MOV RSI,RBP MOV RDI,R13 CALL 0x001010a0 ADD RBX,0x8 CMP RBX,qword ptr [RSP + 0x8] JNZ 0x0010139f LEA R9,[RSP + 0xa0] LEA R8,[RSP + 0x60] LEA RCX,[0x10200a] MOV EDX,0x64 MOV ESI,0x1 LEA RBX,[0x104040] MOV RDI,RBX MOV EAX,0x0 CALL 0x001010f0 MOV RAX,qword ptr [RSP + 0xd8] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101496 MOV RAX,RBX ADD RSP,0xe8 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101496: CALL 0x001010c0
int1 * func0(long param_1,int param_2,int param_3) { long lVar1; long lVar2; int4 *puVar3; int iVar4; long in_FS_OFFSET; int4 local_108 [10]; int4 local_e0 [5]; int1 local_cc [10]; int1 local_c2 [10]; int8 local_b8; int8 local_b0; int8 local_a8; int8 local_a0; int8 local_98; int8 local_90; int2 local_88; int8 local_78; int8 local_70; int8 local_68; int8 local_60; int8 local_58; int8 local_50; int2 local_48; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); if (0 < param_2) { lVar1 = param_1 + 0x10; iVar4 = 0; do { if (0 < param_3) { puVar3 = local_108 + (long)iVar4 * 2; lVar2 = 0; do { *puVar3 = *(int4 *)(param_1 + lVar2 * 8); puVar3[1] = *(int4 *)(param_1 + 4 + lVar2 * 8); lVar2 = lVar2 + 1; puVar3 = puVar3 + 2; } while ((int)lVar2 < param_3); iVar4 = iVar4 + param_3; } param_1 = param_1 + 0x10; } while (param_1 != lVar1 + (ulong)(param_2 - 1) * 0x10); } local_b8 = 0; local_b0 = 0; local_a8 = 0; local_a0 = 0; local_98 = 0; local_90 = 0; local_88 = 0; local_78 = 0; local_70 = 0; local_68 = 0; local_60 = 0; local_58 = 0; local_50 = 0; local_48 = 0; __sprintf_chk(local_cc,1,10,&DAT_00102004,local_108[0]); __sprintf_chk(local_c2,1,10,&DAT_00102004,local_108[1]); __strcat_chk(&local_b8,local_cc,0x32); __strcat_chk(&local_78,local_c2,0x32); puVar3 = local_108; do { __strcat_chk(&local_b8,&DAT_00102007,0x32); __strcat_chk(&local_78,&DAT_00102007,0x32); __sprintf_chk(local_cc,1,10,&DAT_00102004,puVar3[2]); __sprintf_chk(local_c2,1,10,&DAT_00102004,puVar3[3]); __strcat_chk(&local_b8,local_cc,0x32); __strcat_chk(&local_78,local_c2,0x32); puVar3 = puVar3 + 2; } while (puVar3 != local_e0); __sprintf_chk(res_1,1,100,"[(%s), (%s)]",&local_b8,&local_78); if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return res_1; }
6,502
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char* func0(int test_list[3][2][2], int rows, int cols, int pairs) { static char res[100]; int flat_list[6][2]; int f = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { flat_list[f][0] = test_list[i][j][0]; flat_list[f][1] = test_list[i][j][1]; f++; } } char temp1[50] = ""; char temp2[50] = ""; char part1[10], part2[10]; for (int k = 0; k < 6; k++) { sprintf(part1, "%d", flat_list[k][0]); sprintf(part2, "%d", flat_list[k][1]); strcat(temp1, part1); strcat(temp2, part2); if (k != 5) { strcat(temp1, ", "); strcat(temp2, ", "); } } sprintf(res, "[(%s), (%s)]", temp1, temp2); return res; }
int main() { int test1[3][2][2] = {{{4, 5}, {7, 8}}, {{10, 13}, {18, 17}}, {{0, 4}, {10, 1}}}; int test2[3][2][2] = {{{5, 6}, {8, 9}}, {{11, 14}, {19, 18}}, {{1, 5}, {11, 2}}}; int test3[3][2][2] = {{{6, 7}, {9, 10}}, {{12, 15}, {20, 21}}, {{23, 7}, {15, 8}}}; assert(strcmp(func0(test1, 3, 2, 2), "[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]") == 0); assert(strcmp(func0(test2, 3, 2, 2), "[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]") == 0); assert(strcmp(func0(test3, 3, 2, 2), "[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]") == 0); printf("All tests passed!\n"); return 0; }
O2
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0xe8,%rsp mov %fs:0x28,%rax mov %rax,0xd8(%rsp) xor %eax,%eax lea 0x10(%rsp),%rbx test %esi,%esi jle 14aa <func0+0x7a> lea -0x1(%rsi),%eax xor %r8d,%r8d lea 0x10(%rsp),%rbx shl $0x4,%rax lea 0x10(%rdi,%rax,1),%r9 nopl (%rax) test %edx,%edx jle 14a1 <func0+0x71> movslq %r8d,%rax lea (%rbx,%rax,8),%rcx xor %eax,%eax mov (%rdi,%rax,8),%esi add $0x8,%rcx mov %esi,-0x8(%rcx) mov 0x4(%rdi,%rax,8),%esi add $0x1,%rax mov %esi,-0x4(%rcx) cmp %eax,%edx jg 1485 <func0+0x55> add %edx,%r8d add $0x10,%rdi cmp %r9,%rdi jne 1478 <func0+0x48> mov 0x10(%rsp),%r8d xor %eax,%eax xor %edx,%edx lea 0x4c(%rsp),%r13 pxor %xmm0,%xmm0 mov $0x1,%esi mov %r13,%rdi mov %ax,0x90(%rsp) mov %dx,0xd0(%rsp) lea 0xb29(%rip),%rcx mov $0xa,%edx xor %eax,%eax movaps %xmm0,0x60(%rsp) lea 0x56(%rsp),%r12 lea 0x60(%rsp),%r15 movaps %xmm0,0x70(%rsp) lea 0xa0(%rsp),%rbp lea 0xb0f(%rip),%r14 movaps %xmm0,0x80(%rsp) movaps %xmm0,0xa0(%rsp) movaps %xmm0,0xb0(%rsp) movaps %xmm0,0xc0(%rsp) callq 10d0 <__sprintf_chk@plt> mov 0x14(%rsp),%r8d mov %r12,%rdi xor %eax,%eax lea 0xac9(%rip),%rcx mov $0xa,%edx mov $0x1,%esi callq 10d0 <__sprintf_chk@plt> mov $0x32,%edx mov %r13,%rsi mov %r15,%rdi callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r12,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> lea 0x38(%rsp),%rax mov %rax,0x8(%rsp) mov $0x32,%edx mov %r14,%rsi mov %r15,%rdi add $0x8,%rbx callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r14,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> mov (%rbx),%r8d mov $0xa,%edx mov %r13,%rdi lea 0xa5a(%rip),%rcx mov $0x1,%esi xor %eax,%eax callq 10d0 <__sprintf_chk@plt> mov 0x4(%rbx),%r8d mov $0xa,%edx xor %eax,%eax lea 0xa3c(%rip),%rcx mov $0x1,%esi mov %r12,%rdi callq 10d0 <__sprintf_chk@plt> mov $0x32,%edx mov %r13,%rsi mov %r15,%rdi callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r12,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> cmp 0x8(%rsp),%rbx jne 1574 <func0+0x144> xor %eax,%eax mov %rbp,%r9 mov %r15,%r8 mov $0x64,%edx lea 0x9f3(%rip),%rcx mov $0x1,%esi lea 0x2a20(%rip),%rdi callq 10d0 <__sprintf_chk@plt> mov 0xd8(%rsp),%rax xor %fs:0x28,%rax jne 1651 <func0+0x221> add $0xe8,%rsp lea 0x29fa(%rip),%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq callq 10b0 <__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, 0E8h mov rax, fs:28h mov [rsp+118h+var_40], rax xor eax, eax lea rbx, [rsp+118h+var_108] test esi, esi jle short loc_14FA lea eax, [rsi-1] xor r8d, r8d lea rbx, [rsp+118h+var_108] shl rax, 4 lea r9, [rdi+rax+10h] nop dword ptr [rax] loc_14C8: test edx, edx jle short loc_14F1 movsxd rax, r8d lea rcx, [rbx+rax*8] xor eax, eax loc_14D5: mov esi, [rdi+rax*8] add rcx, 8 mov [rcx-8], esi mov esi, [rdi+rax*8+4] add rax, 1 mov [rcx-4], esi cmp edx, eax jg short loc_14D5 add r8d, edx loc_14F1: add rdi, 10h cmp rdi, r9 jnz short loc_14C8 loc_14FA: mov r8d, [rsp+118h+var_108] xor eax, eax xor edx, edx lea r14, [rsp+118h+var_CC] lea r15, unk_2004 pxor xmm0, xmm0 mov rdi, r14 mov [rsp+118h+var_88], ax mov rcx, r15 mov esi, 1 xor eax, eax movaps [rsp+118h+var_B8], xmm0 movaps [rsp+118h+var_A8], xmm0 lea r13, [rsp+118h+var_C2] lea rbp, [rsp+118h+var_B8] mov [rsp+118h+var_48], dx mov edx, 0Ah lea r12, [rsp+118h+var_78] movaps [rsp+118h+var_98], xmm0 movaps [rsp+118h+var_78], xmm0 movaps [rsp+118h+var_68], xmm0 movaps [rsp+118h+var_58], xmm0 call ___sprintf_chk mov r8d, [rsp+118h+var_104] mov rcx, r15 mov rdi, r13 mov edx, 0Ah mov esi, 1 xor eax, eax call ___sprintf_chk mov edx, 32h ; '2' mov rsi, r14 mov rdi, rbp call ___strcat_chk mov edx, 32h ; '2' mov rsi, r13 mov rdi, r12 call ___strcat_chk lea rax, [rsp+118h+var_E0] mov [rsp+118h+var_110], rax loc_15BC: mov edx, 32h ; '2' lea rsi, asc_2014; ", " mov rdi, rbp add rbx, 8 call ___strcat_chk mov edx, 32h ; '2' lea rsi, asc_2014; ", " mov rdi, r12 call ___strcat_chk mov r8d, [rbx] mov rcx, r15 mov edx, 0Ah mov esi, 1 mov rdi, r14 xor eax, eax call ___sprintf_chk mov r8d, [rbx+4] mov rcx, r15 mov rdi, r13 mov edx, 0Ah mov esi, 1 xor eax, eax call ___sprintf_chk mov rdi, rbp call _strlen mov edx, 32h ; '2' mov rsi, r14 lea rdi, [rbp+rax+0] call ___strcpy_chk mov rdi, r12 call _strlen mov edx, 32h ; '2' mov rsi, r13 lea rdi, [r12+rax] call ___strcpy_chk cmp rbx, [rsp+118h+var_110] jnz loc_15BC mov r9, r12 lea r12, res_1 xor eax, eax mov r8, rbp lea rcx, aSS; "[(%s), (%s)]" mov edx, 64h ; 'd' mov esi, 1 mov rdi, r12 call ___sprintf_chk mov rax, [rsp+118h+var_40] sub rax, fs:28h jnz short loc_16AB add rsp, 0E8h mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_16AB: call ___stack_chk_fail
void * func0(long long a1, int a2, int a3) { char *v3; // rbx int v4; // r8d long long v5; // r9 _DWORD *v6; // rcx long long v7; // rax int v8; // esi long long v9; // rax long long v10; // rax _DWORD v12[10]; // [rsp+10h] [rbp-108h] BYREF char v13; // [rsp+38h] [rbp-E0h] BYREF _BYTE v14[10]; // [rsp+4Ch] [rbp-CCh] BYREF _BYTE v15[10]; // [rsp+56h] [rbp-C2h] BYREF _OWORD v16[3]; // [rsp+60h] [rbp-B8h] BYREF __int16 v17; // [rsp+90h] [rbp-88h] _OWORD v18[3]; // [rsp+A0h] [rbp-78h] BYREF __int16 v19; // [rsp+D0h] [rbp-48h] unsigned long long v20; // [rsp+D8h] [rbp-40h] v20 = __readfsqword(0x28u); v3 = (char *)v12; if ( a2 > 0 ) { v4 = 0; v3 = (char *)v12; v5 = a1 + 16LL * (unsigned int)(a2 - 1) + 16; do { if ( a3 > 0 ) { v6 = &v12[2 * v4]; v7 = 0LL; do { v6 += 2; *(v6 - 2) = *(_DWORD *)(a1 + 8 * v7); v8 = *(_DWORD *)(a1 + 8 * v7++ + 4); *(v6 - 1) = v8; } while ( a3 > (int)v7 ); v4 += a3; } a1 += 16LL; } while ( a1 != v5 ); } v17 = 0; memset(v16, 0, sizeof(v16)); v19 = 0; memset(v18, 0, sizeof(v18)); __sprintf_chk(v14, 1LL, 10LL, &unk_2004, v12[0]); __sprintf_chk(v15, 1LL, 10LL, &unk_2004, v12[1]); __strcat_chk(v16, v14, 50LL); __strcat_chk(v18, v15, 50LL); do { v3 += 8; __strcat_chk(v16, ", ", 50LL); __strcat_chk(v18, ", ", 50LL); __sprintf_chk(v14, 1LL, 10LL, &unk_2004, *(unsigned int *)v3); __sprintf_chk(v15, 1LL, 10LL, &unk_2004, *((unsigned int *)v3 + 1)); v9 = strlen(v16); __strcpy_chk((char *)v16 + v9, v14, 50LL); v10 = strlen(v18); __strcpy_chk((char *)v18 + v10, v15, 50LL); } while ( v3 != &v13 ); __sprintf_chk(&res_1, 1LL, 100LL, "[(%s), (%s)]", v16); return &res_1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0xe8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xd8],RAX XOR EAX,EAX LEA RBX,[RSP + 0x10] TEST ESI,ESI JLE 0x001014fa LEA EAX,[RSI + -0x1] XOR R8D,R8D LEA RBX,[RSP + 0x10] SHL RAX,0x4 LEA R9,[RDI + RAX*0x1 + 0x10] NOP dword ptr [RAX] LAB_001014c8: TEST EDX,EDX JLE 0x001014f1 MOVSXD RAX,R8D LEA RCX,[RBX + RAX*0x8] XOR EAX,EAX LAB_001014d5: MOV ESI,dword ptr [RDI + RAX*0x8] ADD RCX,0x8 MOV dword ptr [RCX + -0x8],ESI MOV ESI,dword ptr [RDI + RAX*0x8 + 0x4] ADD RAX,0x1 MOV dword ptr [RCX + -0x4],ESI CMP EDX,EAX JG 0x001014d5 ADD R8D,EDX LAB_001014f1: ADD RDI,0x10 CMP RDI,R9 JNZ 0x001014c8 LAB_001014fa: MOV R8D,dword ptr [RSP + 0x10] XOR EAX,EAX XOR EDX,EDX LEA R14,[RSP + 0x4c] LEA R15,[0x102004] PXOR XMM0,XMM0 MOV RDI,R14 MOV word ptr [RSP + 0x90],AX MOV RCX,R15 MOV ESI,0x1 XOR EAX,EAX MOVAPS xmmword ptr [RSP + 0x60],XMM0 MOVAPS xmmword ptr [RSP + 0x70],XMM0 LEA R13,[RSP + 0x56] LEA RBP,[RSP + 0x60] MOV word ptr [RSP + 0xd0],DX MOV EDX,0xa LEA R12,[RSP + 0xa0] MOVAPS xmmword ptr [RSP + 0x80],XMM0 MOVAPS xmmword ptr [RSP + 0xa0],XMM0 MOVAPS xmmword ptr [RSP + 0xb0],XMM0 MOVAPS xmmword ptr [RSP + 0xc0],XMM0 CALL 0x00101130 MOV R8D,dword ptr [RSP + 0x14] MOV RCX,R15 MOV RDI,R13 MOV EDX,0xa MOV ESI,0x1 XOR EAX,EAX CALL 0x00101130 MOV EDX,0x32 MOV RSI,R14 MOV RDI,RBP CALL 0x001010c0 MOV EDX,0x32 MOV RSI,R13 MOV RDI,R12 CALL 0x001010c0 LEA RAX,[RSP + 0x38] MOV qword ptr [RSP + 0x8],RAX LAB_001015bc: MOV EDX,0x32 LEA RSI,[0x102014] MOV RDI,RBP ADD RBX,0x8 CALL 0x001010c0 MOV EDX,0x32 LEA RSI,[0x102014] MOV RDI,R12 CALL 0x001010c0 MOV R8D,dword ptr [RBX] MOV RCX,R15 MOV EDX,0xa MOV ESI,0x1 MOV RDI,R14 XOR EAX,EAX CALL 0x00101130 MOV R8D,dword ptr [RBX + 0x4] MOV RCX,R15 MOV RDI,R13 MOV EDX,0xa MOV ESI,0x1 XOR EAX,EAX CALL 0x00101130 MOV RDI,RBP CALL 0x001010e0 MOV EDX,0x32 MOV RSI,R14 LEA RDI,[RBP + RAX*0x1] CALL 0x00101120 MOV RDI,R12 CALL 0x001010e0 MOV EDX,0x32 MOV RSI,R13 LEA RDI,[R12 + RAX*0x1] CALL 0x00101120 CMP RBX,qword ptr [RSP + 0x8] JNZ 0x001015bc MOV R9,R12 LEA R12,[0x104040] XOR EAX,EAX MOV R8,RBP LEA RCX,[0x102007] MOV EDX,0x64 MOV ESI,0x1 MOV RDI,R12 CALL 0x00101130 MOV RAX,qword ptr [RSP + 0xd8] SUB RAX,qword ptr FS:[0x28] JNZ 0x001016ab ADD RSP,0xe8 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001016ab: CALL 0x001010f0
int1 * func0(long param_1,int param_2,int param_3) { long lVar1; long lVar2; long lVar3; size_t sVar4; int4 *puVar5; int4 *puVar6; int iVar7; long in_FS_OFFSET; int4 local_108 [10]; int4 local_e0 [5]; int1 local_cc [10]; int1 local_c2 [10]; int1 local_b8 [16]; int1 local_a8 [16]; int1 local_98 [16]; int2 local_88; int1 local_78 [16]; int1 local_68 [16]; int1 local_58 [16]; int2 local_48; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); if (0 < param_2) { iVar7 = 0; lVar1 = param_1 + 0x10; do { if (0 < param_3) { lVar3 = 0; puVar5 = local_108 + (long)iVar7 * 2; do { *puVar5 = *(int4 *)(param_1 + lVar3 * 8); lVar2 = lVar3 * 8; lVar3 = lVar3 + 1; puVar5[1] = *(int4 *)(param_1 + 4 + lVar2); puVar5 = puVar5 + 2; } while ((int)lVar3 < param_3); iVar7 = iVar7 + param_3; } param_1 = param_1 + 0x10; } while (param_1 != lVar1 + (ulong)(param_2 - 1) * 0x10); } local_88 = 0; local_b8 = (int1 [16])0x0; local_a8 = (int1 [16])0x0; local_48 = 0; local_98 = (int1 [16])0x0; local_78 = (int1 [16])0x0; local_68 = (int1 [16])0x0; local_58 = (int1 [16])0x0; __sprintf_chk(local_cc,1,10,&DAT_00102004,local_108[0]); __sprintf_chk(local_c2,1,10,&DAT_00102004,local_108[1]); __strcat_chk(local_b8,local_cc,0x32); __strcat_chk(local_78,local_c2,0x32); puVar5 = local_108; do { puVar6 = puVar5 + 2; __strcat_chk(local_b8,&DAT_00102014,0x32); __strcat_chk(local_78,&DAT_00102014,0x32); __sprintf_chk(local_cc,1,10,&DAT_00102004,*puVar6); __sprintf_chk(local_c2,1,10,&DAT_00102004,puVar5[3]); sVar4 = strlen(local_b8); __strcpy_chk(local_b8 + sVar4,local_cc,0x32); sVar4 = strlen(local_78); __strcpy_chk(local_78 + sVar4,local_c2,0x32); puVar5 = puVar6; } while (puVar6 != local_e0); __sprintf_chk(res_1,1,100,"[(%s), (%s)]",local_b8,local_78); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return res_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,503
func0
#include <stdio.h> #include <assert.h> #include <string.h>
char* func0(int test_list[3][2][2], int rows, int cols, int pairs) { static char res[100]; int flat_list[6][2]; int f = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { flat_list[f][0] = test_list[i][j][0]; flat_list[f][1] = test_list[i][j][1]; f++; } } char temp1[50] = ""; char temp2[50] = ""; char part1[10], part2[10]; for (int k = 0; k < 6; k++) { sprintf(part1, "%d", flat_list[k][0]); sprintf(part2, "%d", flat_list[k][1]); strcat(temp1, part1); strcat(temp2, part2); if (k != 5) { strcat(temp1, ", "); strcat(temp2, ", "); } } sprintf(res, "[(%s), (%s)]", temp1, temp2); return res; }
int main() { int test1[3][2][2] = {{{4, 5}, {7, 8}}, {{10, 13}, {18, 17}}, {{0, 4}, {10, 1}}}; int test2[3][2][2] = {{{5, 6}, {8, 9}}, {{11, 14}, {19, 18}}, {{1, 5}, {11, 2}}}; int test3[3][2][2] = {{{6, 7}, {9, 10}}, {{12, 15}, {20, 21}}, {{23, 7}, {15, 8}}}; assert(strcmp(func0(test1, 3, 2, 2), "[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]") == 0); assert(strcmp(func0(test2, 3, 2, 2), "[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]") == 0); assert(strcmp(func0(test3, 3, 2, 2), "[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]") == 0); printf("All tests passed!\n"); return 0; }
O3
c
func0: endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0xe8,%rsp mov %fs:0x28,%rax mov %rax,0xd8(%rsp) xor %eax,%eax lea 0x10(%rsp),%rbx test %esi,%esi jle 1446 <func0+0xb6> test %edx,%edx jle 1446 <func0+0xb6> lea -0x1(%rsi),%eax mov %edx,%r10d mov %edx,%r9d xor %r8d,%r8d shl $0x4,%rax shr %r10d and $0xfffffffe,%r9d lea 0x10(%rdi,%rax,1),%r11 nopl (%rax) cmp $0x1,%edx je 15f0 <func0+0x260> movdqu (%rdi),%xmm1 movslq %r8d,%rax lea (%rbx,%rax,8),%rax movups %xmm1,(%rax) cmp $0x1,%r10d jbe 141d <func0+0x8d> movdqu 0x10(%rdi),%xmm2 movups %xmm2,0x10(%rax) cmp $0x2,%r10d je 141d <func0+0x8d> movdqu 0x20(%rdi),%xmm3 movups %xmm3,0x20(%rax) lea (%r8,%r9,1),%eax movslq %r9d,%rcx cmp %r9d,%edx je 143a <func0+0xaa> mov (%rdi,%rcx,8),%esi mov 0x4(%rdi,%rcx,8),%ecx cltq mov %esi,0x10(%rsp,%rax,8) mov %ecx,0x14(%rsp,%rax,8) add $0x10,%rdi add %edx,%r8d cmp %r11,%rdi jne 13e8 <func0+0x58> mov 0x10(%rsp),%r8d xor %eax,%eax xor %edx,%edx lea 0x4c(%rsp),%r13 pxor %xmm0,%xmm0 mov $0x1,%esi mov %r13,%rdi mov %ax,0x90(%rsp) mov %dx,0xd0(%rsp) lea 0xb8d(%rip),%rcx mov $0xa,%edx xor %eax,%eax movaps %xmm0,0x60(%rsp) lea 0x56(%rsp),%r12 lea 0x60(%rsp),%r15 movaps %xmm0,0x70(%rsp) lea 0xa0(%rsp),%rbp lea 0xb73(%rip),%r14 movaps %xmm0,0x80(%rsp) movaps %xmm0,0xa0(%rsp) movaps %xmm0,0xb0(%rsp) movaps %xmm0,0xc0(%rsp) callq 10d0 <__sprintf_chk@plt> mov 0x14(%rsp),%r8d mov %r12,%rdi xor %eax,%eax lea 0xb2d(%rip),%rcx mov $0xa,%edx mov $0x1,%esi callq 10d0 <__sprintf_chk@plt> mov $0x32,%edx mov %r13,%rsi mov %r15,%rdi callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r12,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> lea 0x38(%rsp),%rax mov %rax,0x8(%rsp) mov $0x32,%edx mov %r14,%rsi mov %r15,%rdi add $0x8,%rbx callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r14,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> mov (%rbx),%r8d mov $0xa,%edx mov %r13,%rdi lea 0xabe(%rip),%rcx mov $0x1,%esi xor %eax,%eax callq 10d0 <__sprintf_chk@plt> mov 0x4(%rbx),%r8d mov $0xa,%edx xor %eax,%eax lea 0xaa0(%rip),%rcx mov $0x1,%esi mov %r12,%rdi callq 10d0 <__sprintf_chk@plt> mov $0x32,%edx mov %r13,%rsi mov %r15,%rdi callq 1090 <__strcat_chk@plt> mov $0x32,%edx mov %r12,%rsi mov %rbp,%rdi callq 1090 <__strcat_chk@plt> cmp 0x8(%rsp),%rbx jne 1510 <func0+0x180> xor %eax,%eax mov %rbp,%r9 mov %r15,%r8 mov $0x64,%edx lea 0xa57(%rip),%rcx mov $0x1,%esi lea 0x2a84(%rip),%rdi callq 10d0 <__sprintf_chk@plt> mov 0xd8(%rsp),%rax xor %fs:0x28,%rax jne 15fa <func0+0x26a> add $0xe8,%rsp lea 0x2a5e(%rip),%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl (%rax) mov %r8d,%eax xor %ecx,%ecx jmpq 1429 <func0+0x99> callq 10b0 <__stack_chk_fail@plt>
func0: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 0F8h mov rax, fs:28h mov [rsp+128h+var_40], rax xor eax, eax lea rbx, [rsp+128h+var_108] test esi, esi jle loc_14B0 mov ecx, edx lea rbx, [rsp+128h+var_108] test edx, edx jle loc_14B0 movsxd rsi, esi mov r11d, edx mov r10d, edx xor eax, eax lea r9, [rsi+rsi] shr r11d, 1 and r10d, 0FFFFFFFEh xor r8d, r8d jmp short loc_145F loc_1440: mov esi, r10d loc_1443: lea rbp, [rax+rsi] add rdx, rsi add rax, 2 add r8d, ecx mov rbp, [rdi+rbp*8] mov [rsp+rdx*8+128h+var_108], rbp cmp r9, rax jz short loc_14B0 loc_145F: cmp ecx, 1 jz loc_1640 loc_1468: movdqu xmm1, xmmword ptr [rdi+rax*8] movsxd rdx, r8d lea rsi, [rbx+rdx*8] movups xmmword ptr [rsi], xmm1 cmp r11d, 1 jz short loc_1497 movdqu xmm2, xmmword ptr [rdi+rax*8+10h] movups xmmword ptr [rsi+10h], xmm2 cmp r11d, 2 jz short loc_1497 movdqu xmm3, xmmword ptr [rdi+rax*8+20h] movups xmmword ptr [rsi+20h], xmm3 loc_1497: cmp ecx, r10d jnz short loc_1440 add rax, 2 add r8d, ecx cmp r9, rax jnz short loc_1468 nop dword ptr [rax+rax+00000000h] loc_14B0: xor eax, eax pxor xmm0, xmm0 lea r15, [rsp+128h+var_CC] xor edx, edx mov [rsp+128h+var_88], ax lea rax, [rsp+128h+var_D8] lea r14, unk_2004 mov [rsp+128h+var_110], rax lea rax, [rsp+128h+var_C2] lea rbp, [rsp+128h+s] mov [rsp+128h+var_48], dx lea r12, [rsp+128h+var_78] mov [rsp+128h+var_120], rax movaps xmmword ptr [rsp+128h+s], xmm0 movaps [rsp+128h+var_A8], xmm0 movaps [rsp+128h+var_98], xmm0 movaps xmmword ptr [rsp+128h+var_78], xmm0 movaps [rsp+128h+var_68], xmm0 movaps [rsp+128h+var_58], xmm0 loc_1522: mov r8d, [rbx] mov rcx, r14 mov edx, 0Ah mov esi, 2 mov rdi, r15 xor eax, eax add rbx, 8 call ___sprintf_chk mov r8d, [rbx-4] mov rdi, [rsp+128h+var_120] xor eax, eax mov rcx, r14 mov edx, 0Ah mov esi, 2 call ___sprintf_chk mov rdi, rbp; s call _strlen mov edx, 32h ; '2' mov rsi, r15 lea rdi, [rbp+rax+0] call ___stpcpy_chk mov rdi, r12; s mov r13, rax call _strlen mov rsi, [rsp+128h+var_120] mov edx, 32h ; '2' lea rdi, [r12+rax] call ___stpcpy_chk mov r8, rax mov rax, [rsp+128h+var_110] cmp rbx, rax jz short loc_15F0 mov rcx, rbp mov rdi, r13 mov edx, 3 mov [rsp+128h+var_118], r8 sub rcx, r13 lea rsi, asc_2014; ", " add rcx, 32h ; '2' call ___memcpy_chk mov r8, [rsp+128h+var_118] mov rcx, r12 mov edx, 3 lea rsi, asc_2014; ", " sub rcx, r8 mov rdi, r8 add rcx, 32h ; '2' call ___memcpy_chk jmp loc_1522 loc_15F0: lea rbx, res_1 xor eax, eax mov r9, r12 mov r8, rbp lea rcx, aSS; "[(%s), (%s)]" mov edx, 64h ; 'd' mov esi, 2 mov rdi, rbx call ___sprintf_chk mov rax, [rsp+128h+var_40] sub rax, fs:28h jnz short loc_164A add rsp, 0F8h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1640: xor esi, esi movsxd rdx, r8d jmp loc_1443 loc_164A: call ___stack_chk_fail
void * func0(long long a1, int a2, int a3) { char *v3; // rbx long long v5; // rax long long v6; // r9 unsigned int v7; // r11d unsigned int v8; // r10d int v9; // r8d long long v10; // rsi long long v11; // rbp long long v12; // rdx __m128i *v13; // rsi long long v14; // r8 size_t v15; // rax long long v16; // r13 size_t v17; // rax long long v18; // r8 long long v20; // [rsp+10h] [rbp-118h] _QWORD v21[6]; // [rsp+20h] [rbp-108h] BYREF char v22; // [rsp+50h] [rbp-D8h] BYREF _BYTE v23[10]; // [rsp+5Ch] [rbp-CCh] BYREF char v24[10]; // [rsp+66h] [rbp-C2h] BYREF char s[16]; // [rsp+70h] [rbp-B8h] BYREF __int128 v26; // [rsp+80h] [rbp-A8h] __int128 v27; // [rsp+90h] [rbp-98h] __int16 v28; // [rsp+A0h] [rbp-88h] char v29[16]; // [rsp+B0h] [rbp-78h] BYREF __int128 v30; // [rsp+C0h] [rbp-68h] __int128 v31; // [rsp+D0h] [rbp-58h] __int16 v32; // [rsp+E0h] [rbp-48h] unsigned long long v33; // [rsp+E8h] [rbp-40h] v33 = __readfsqword(0x28u); v3 = (char *)v21; if ( a2 > 0 ) { v3 = (char *)v21; if ( a3 > 0 ) { v5 = 0LL; v6 = 2LL * a2; v7 = (unsigned int)a3 >> 1; v8 = a3 & 0xFFFFFFFE; v9 = 0; do { if ( a3 == 1 ) { v10 = 0LL; v12 = v9; } else { while ( 1 ) { v12 = v9; v13 = (__m128i *)&v21[v9]; *v13 = _mm_loadu_si128((const __m128i *)(a1 + 8 * v5)); if ( v7 != 1 ) { v13[1] = _mm_loadu_si128((const __m128i *)(a1 + 8 * v5 + 16)); if ( v7 != 2 ) v13[2] = _mm_loadu_si128((const __m128i *)(a1 + 8 * v5 + 32)); } if ( a3 != v8 ) break; v5 += 2LL; v9 += a3; if ( v6 == v5 ) goto LABEL_12; } v10 = v8; } v11 = v5 + v10; v5 += 2LL; v9 += a3; v21[v10 + v12] = *(_QWORD *)(a1 + 8 * v11); } while ( v6 != v5 ); } } LABEL_12: v28 = 0; v32 = 0; *(_OWORD *)s = 0LL; v26 = 0LL; v27 = 0LL; *(_OWORD *)v29 = 0LL; v30 = 0LL; v31 = 0LL; while ( 1 ) { v14 = *(unsigned int *)v3; v3 += 8; __sprintf_chk(v23, 2LL, 10LL, &unk_2004, v14); __sprintf_chk(v24, 2LL, 10LL, &unk_2004, *((unsigned int *)v3 - 1)); v15 = strlen(s); v16 = __stpcpy_chk(&s[v15], v23, 50LL); v17 = strlen(v29); v18 = __stpcpy_chk(&v29[v17], v24, 50LL); if ( v3 == &v22 ) break; v20 = v18; __memcpy_chk(v16, ", ", 3LL, &s[-v16 + 50]); __memcpy_chk(v20, ", ", 3LL, &v29[-v20 + 50]); } __sprintf_chk(&res_1, 2LL, 100LL, "[(%s), (%s)]", s); return &res_1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0xf8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xe8],RAX XOR EAX,EAX LEA RBX,[RSP + 0x20] TEST ESI,ESI JLE 0x001014b0 MOV ECX,EDX LEA RBX,[RSP + 0x20] TEST EDX,EDX JLE 0x001014b0 MOVSXD RSI,ESI MOV R11D,EDX MOV R10D,EDX XOR EAX,EAX LEA R9,[RSI + RSI*0x1] SHR R11D,0x1 AND R10D,0xfffffffe XOR R8D,R8D JMP 0x0010145f LAB_00101440: MOV ESI,R10D LAB_00101443: LEA RBP,[RAX + RSI*0x1] ADD RDX,RSI ADD RAX,0x2 ADD R8D,ECX MOV RBP,qword ptr [RDI + RBP*0x8] MOV qword ptr [RSP + RDX*0x8 + 0x20],RBP CMP R9,RAX JZ 0x001014b0 LAB_0010145f: CMP ECX,0x1 JZ 0x00101640 LAB_00101468: MOVDQU XMM1,xmmword ptr [RDI + RAX*0x8] MOVSXD RDX,R8D LEA RSI,[RBX + RDX*0x8] MOVUPS xmmword ptr [RSI],XMM1 CMP R11D,0x1 JZ 0x00101497 MOVDQU XMM2,xmmword ptr [RDI + RAX*0x8 + 0x10] MOVUPS xmmword ptr [RSI + 0x10],XMM2 CMP R11D,0x2 JZ 0x00101497 MOVDQU XMM3,xmmword ptr [RDI + RAX*0x8 + 0x20] MOVUPS xmmword ptr [RSI + 0x20],XMM3 LAB_00101497: CMP ECX,R10D JNZ 0x00101440 ADD RAX,0x2 ADD R8D,ECX CMP R9,RAX JNZ 0x00101468 NOP dword ptr [RAX + RAX*0x1] LAB_001014b0: XOR EAX,EAX PXOR XMM0,XMM0 LEA R15,[RSP + 0x5c] XOR EDX,EDX MOV word ptr [RSP + 0xa0],AX LEA RAX,[RSP + 0x50] LEA R14,[0x102004] MOV qword ptr [RSP + 0x18],RAX LEA RAX,[RSP + 0x66] LEA RBP,[RSP + 0x70] MOV word ptr [RSP + 0xe0],DX LEA R12,[RSP + 0xb0] MOV qword ptr [RSP + 0x8],RAX MOVAPS xmmword ptr [RSP + 0x70],XMM0 MOVAPS xmmword ptr [RSP + 0x80],XMM0 MOVAPS xmmword ptr [RSP + 0x90],XMM0 MOVAPS xmmword ptr [RSP + 0xb0],XMM0 MOVAPS xmmword ptr [RSP + 0xc0],XMM0 MOVAPS xmmword ptr [RSP + 0xd0],XMM0 LAB_00101522: MOV R8D,dword ptr [RBX] MOV RCX,R14 MOV EDX,0xa MOV ESI,0x2 MOV RDI,R15 XOR EAX,EAX ADD RBX,0x8 CALL 0x00101130 MOV R8D,dword ptr [RBX + -0x4] MOV RDI,qword ptr [RSP + 0x8] XOR EAX,EAX MOV RCX,R14 MOV EDX,0xa MOV ESI,0x2 CALL 0x00101130 MOV RDI,RBP CALL 0x001010d0 MOV EDX,0x32 MOV RSI,R15 LEA RDI,[RBP + RAX*0x1] CALL 0x00101120 MOV RDI,R12 MOV R13,RAX CALL 0x001010d0 MOV RSI,qword ptr [RSP + 0x8] MOV EDX,0x32 LEA RDI,[R12 + RAX*0x1] CALL 0x00101120 MOV R8,RAX MOV RAX,qword ptr [RSP + 0x18] CMP RBX,RAX JZ 0x001015f0 MOV RCX,RBP MOV RDI,R13 MOV EDX,0x3 MOV qword ptr [RSP + 0x10],R8 SUB RCX,R13 LEA RSI,[0x102014] ADD RCX,0x32 CALL 0x00101110 MOV R8,qword ptr [RSP + 0x10] MOV RCX,R12 MOV EDX,0x3 LEA RSI,[0x102014] SUB RCX,R8 MOV RDI,R8 ADD RCX,0x32 CALL 0x00101110 JMP 0x00101522 LAB_001015f0: LEA RBX,[0x104040] XOR EAX,EAX MOV R9,R12 MOV R8,RBP LEA RCX,[0x102007] MOV EDX,0x64 MOV ESI,0x2 MOV RDI,RBX CALL 0x00101130 MOV RAX,qword ptr [RSP + 0xe8] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010164a ADD RSP,0xf8 MOV RAX,RBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101640: XOR ESI,ESI MOVSXD RDX,R8D JMP 0x00101443 LAB_0010164a: CALL 0x001010e0
int1 * func0(long param_1,int param_2,ulong param_3) { long lVar1; int8 uVar2; long lVar3; size_t sVar4; uint uVar5; long lVar6; int8 *puVar7; ulong uVar8; int iVar9; uint uVar10; long in_FS_OFFSET; int8 local_108; int8 auStack_100 [5]; int8 local_d8; int local_cc [10]; int local_c2 [10]; int local_b8 [16]; int local_a8 [16]; int local_98 [16]; int2 local_88; int auStack_86 [14]; int local_78 [16]; int local_68 [16]; int local_58 [16]; int2 local_48; int auStack_46 [6]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); if (0 < param_2) { uVar5 = (uint)param_3; if (0 < (int)uVar5) { lVar3 = 0; uVar10 = (uint)(param_3 >> 1) & 0x7fffffff; iVar9 = 0; do { if (uVar5 == 1) { uVar8 = 0; lVar6 = (long)iVar9; } else { while( true ) { puVar7 = (int8 *)(param_1 + lVar3 * 8); uVar2 = puVar7[1]; lVar6 = (long)iVar9; (&local_108)[lVar6] = *puVar7; auStack_100[lVar6] = uVar2; if (uVar10 != 1) { puVar7 = (int8 *)(param_1 + 0x10 + lVar3 * 8); uVar2 = puVar7[1]; auStack_100[lVar6 + 1] = *puVar7; auStack_100[lVar6 + 2] = uVar2; if (uVar10 != 2) { puVar7 = (int8 *)(param_1 + 0x20 + lVar3 * 8); uVar2 = puVar7[1]; auStack_100[lVar6 + 3] = *puVar7; auStack_100[lVar6 + 4] = uVar2; } } if (uVar5 != (uVar5 & 0xfffffffe)) break; lVar3 = lVar3 + 2; iVar9 = iVar9 + uVar5; if ((long)param_2 * 2 == lVar3) goto LAB_001014b0; } uVar8 = (ulong)(uVar5 & 0xfffffffe); } lVar1 = lVar3 + uVar8; lVar3 = lVar3 + 2; iVar9 = iVar9 + uVar5; (&local_108)[lVar6 + uVar8] = *(int8 *)(param_1 + lVar1 * 8); } while ((long)param_2 * 2 != lVar3); } } LAB_001014b0: local_88 = 0; local_48 = 0; local_b8 = (int [16])0x0; local_a8 = (int [16])0x0; local_98 = (int [16])0x0; local_78 = (int [16])0x0; local_68 = (int [16])0x0; local_58 = (int [16])0x0; puVar7 = &local_108; while( true ) { __sprintf_chk(local_cc,2,10,&DAT_00102004,*(int4 *)puVar7); __sprintf_chk(local_c2,2,10,&DAT_00102004,*(int4 *)((long)puVar7 + 4)); sVar4 = strlen(local_b8); lVar3 = __stpcpy_chk(local_b8 + sVar4,local_cc,0x32); sVar4 = strlen(local_78); lVar6 = __stpcpy_chk(local_78 + sVar4,local_c2,0x32); if (puVar7 + 1 == auStack_100 + 5) break; __memcpy_chk(lVar3,&DAT_00102014,3,auStack_86 + -lVar3); __memcpy_chk(lVar6,&DAT_00102014,3,auStack_46 + -lVar6); puVar7 = puVar7 + 1; } __sprintf_chk(res_1,2,100,"[(%s), (%s)]",local_b8,local_78); if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return res_1; }
6,504
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct List { int *values; int size; int capacity; } List; typedef struct Map { char **keys; List *values; int size; int capacity; } Map; void initList(List *list) { list->values = malloc(10 * sizeof(int)); list->size = 0; list->capacity = 10; } void addToList(List *list, int value) { if (list->size >= list->capacity) { list->capacity *= 2; list->values = realloc(list->values, list->capacity * sizeof(int)); } list->values[list->size++] = value; } void initMap(Map *map) { map->keys = malloc(10 * sizeof(char*)); map->values = malloc(10 * sizeof(List)); map->size = 0; map->capacity = 10; } int findKeyIndex(Map *map, char *key) { for (int i = 0; i < map->size; i++) { if (strcmp(map->keys[i], key) == 0) { return i; } } return -1; } void addToMap(Map *map, char *key, int value) { int index = findKeyIndex(map, key); if (index == -1) { if (map->size >= map->capacity) { map->capacity *= 2; map->keys = realloc(map->keys, map->capacity * sizeof(char*)); map->values = realloc(map->values, map->capacity * sizeof(List)); } map->keys[map->size] = strdup(key); initList(&map->values[map->size]); addToList(&map->values[map->size], value); map->size++; } else { addToList(&map->values[index], value); } }
Map func0(const char *input[], int length) { Map map; initMap(&map); for (int i = 0; i < length; i += 2) { addToMap(&map, (char*)input[i], atoi(input[i + 1])); } return map; }
int main() { const char *data1[] = {"yellow", "1", "blue", "2", "yellow", "3", "blue", "4", "red", "1"}; const char *data2[] = {"yellow", "10", "blue", "20", "yellow", "30", "blue", "40", "red", "10"}; const char *data3[] = {"yellow", "15", "blue", "25", "yellow", "35", "blue", "45", "red", "15"}; Map result1 = func0(data1, 10); Map result2 = func0(data2, 10); Map result3 = func0(data3, 10); assert(result1.size == 3); assert(result2.size == 3); assert(result3.size == 3); // Additional asserts to compare the actual content of the dictionaries can be added here return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x50,%rsp mov %rdi,-0x38(%rbp) mov %rsi,-0x40(%rbp) mov %edx,-0x44(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax lea -0x20(%rbp),%rax mov %rax,%rdi callq 12d0 <initMap> movl $0x0,-0x24(%rbp) jmp 1568 <func0+0x8a> mov -0x24(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,8),%rdx mov -0x40(%rbp),%rax add %rdx,%rax mov (%rax),%rax mov %rax,%rdi callq 1100 <atoi@plt> mov %eax,%edx mov -0x24(%rbp),%eax cltq lea 0x0(,%rax,8),%rcx mov -0x40(%rbp),%rax add %rcx,%rax mov (%rax),%rcx lea -0x20(%rbp),%rax mov %rcx,%rsi mov %rax,%rdi callq 1385 <addToMap> addl $0x2,-0x24(%rbp) mov -0x24(%rbp),%eax cmp -0x44(%rbp),%eax jl 1519 <func0+0x3b> mov -0x38(%rbp),%rcx mov -0x20(%rbp),%rax mov -0x18(%rbp),%rdx mov %rax,(%rcx) mov %rdx,0x8(%rcx) mov -0x10(%rbp),%rax mov %rax,0x10(%rcx) mov -0x8(%rbp),%rax xor %fs:0x28,%rax je 159f <func0+0xc1> callq 10b0 <__stack_chk_fail@plt> mov -0x38(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 50h mov [rbp+var_38], rdi mov [rbp+var_40], rsi mov [rbp+var_44], edx mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax lea rax, [rbp+var_20] mov rdi, rax call initMap mov [rbp+var_24], 0 jmp short loc_1567 loc_1518: mov eax, [rbp+var_24] cdqe add rax, 1 lea rdx, ds:0[rax*8] mov rax, [rbp+var_40] add rax, rdx mov rax, [rax] mov rdi, rax; nptr call _atoi mov edx, eax mov eax, [rbp+var_24] cdqe lea rcx, ds:0[rax*8] mov rax, [rbp+var_40] add rax, rcx mov rcx, [rax] lea rax, [rbp+var_20] mov rsi, rcx mov rdi, rax call addToMap add [rbp+var_24], 2 loc_1567: mov eax, [rbp+var_24] cmp eax, [rbp+var_44] jl short loc_1518 mov rcx, [rbp+var_38] mov rax, [rbp+var_20] mov rdx, [rbp+var_18] mov [rcx], rax mov [rcx+8], rdx mov rax, [rbp+var_10] mov [rcx+10h], rax mov rax, [rbp+var_8] sub rax, fs:28h jz short loc_159E call ___stack_chk_fail loc_159E: mov rax, [rbp+var_38] leave retn
_QWORD * func0(_QWORD *a1, long long a2, int a3) { unsigned int v3; // eax long long v4; // rdx int i; // [rsp+2Ch] [rbp-24h] _QWORD v8[4]; // [rsp+30h] [rbp-20h] BYREF v8[3] = __readfsqword(0x28u); initMap(v8); for ( i = 0; i < a3; i += 2 ) { v3 = atoi(*(const char **)(8 * (i + 1LL) + a2)); addToMap(v8, *(_QWORD *)(8LL * i + a2), v3); } v4 = v8[1]; *a1 = v8[0]; a1[1] = v4; a1[2] = v8[2]; return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x50 MOV qword ptr [RBP + -0x38],RDI MOV qword ptr [RBP + -0x40],RSI MOV dword ptr [RBP + -0x44],EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX LEA RAX,[RBP + -0x20] MOV RDI,RAX CALL 0x001012d0 MOV dword ptr [RBP + -0x24],0x0 JMP 0x00101567 LAB_00101518: MOV EAX,dword ptr [RBP + -0x24] CDQE ADD RAX,0x1 LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x40] ADD RAX,RDX MOV RAX,qword ptr [RAX] MOV RDI,RAX CALL 0x00101100 MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x24] CDQE LEA RCX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x40] ADD RAX,RCX MOV RCX,qword ptr [RAX] LEA RAX,[RBP + -0x20] MOV RSI,RCX MOV RDI,RAX CALL 0x00101385 ADD dword ptr [RBP + -0x24],0x2 LAB_00101567: MOV EAX,dword ptr [RBP + -0x24] CMP EAX,dword ptr [RBP + -0x44] JL 0x00101518 MOV RCX,qword ptr [RBP + -0x38] MOV RAX,qword ptr [RBP + -0x20] MOV RDX,qword ptr [RBP + -0x18] MOV qword ptr [RCX],RAX MOV qword ptr [RCX + 0x8],RDX MOV RAX,qword ptr [RBP + -0x10] MOV qword ptr [RCX + 0x10],RAX MOV RAX,qword ptr [RBP + -0x8] SUB RAX,qword ptr FS:[0x28] JZ 0x0010159e CALL 0x001010b0 LAB_0010159e: MOV RAX,qword ptr [RBP + -0x38] LEAVE RET
int8 * func0(int8 *param_1,long param_2,int param_3) { int iVar1; long in_FS_OFFSET; int local_2c; int8 local_28; int8 local_20; int8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); initMap(&local_28); for (local_2c = 0; local_2c < param_3; local_2c = local_2c + 2) { iVar1 = atoi(*(char **)(param_2 + ((long)local_2c + 1) * 8)); addToMap(&local_28,*(int8 *)(param_2 + (long)local_2c * 8),iVar1); } *param_1 = local_28; param_1[1] = local_20; param_1[2] = local_18; if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
6,505
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct List { int *values; int size; int capacity; } List; typedef struct Map { char **keys; List *values; int size; int capacity; } Map; void initList(List *list) { list->values = malloc(10 * sizeof(int)); list->size = 0; list->capacity = 10; } void addToList(List *list, int value) { if (list->size >= list->capacity) { list->capacity *= 2; list->values = realloc(list->values, list->capacity * sizeof(int)); } list->values[list->size++] = value; } void initMap(Map *map) { map->keys = malloc(10 * sizeof(char*)); map->values = malloc(10 * sizeof(List)); map->size = 0; map->capacity = 10; } int findKeyIndex(Map *map, char *key) { for (int i = 0; i < map->size; i++) { if (strcmp(map->keys[i], key) == 0) { return i; } } return -1; } void addToMap(Map *map, char *key, int value) { int index = findKeyIndex(map, key); if (index == -1) { if (map->size >= map->capacity) { map->capacity *= 2; map->keys = realloc(map->keys, map->capacity * sizeof(char*)); map->values = realloc(map->values, map->capacity * sizeof(List)); } map->keys[map->size] = strdup(key); initList(&map->values[map->size]); addToList(&map->values[map->size], value); map->size++; } else { addToList(&map->values[index], value); } }
Map func0(const char *input[], int length) { Map map; initMap(&map); for (int i = 0; i < length; i += 2) { addToMap(&map, (char*)input[i], atoi(input[i + 1])); } return map; }
int main() { const char *data1[] = {"yellow", "1", "blue", "2", "yellow", "3", "blue", "4", "red", "1"}; const char *data2[] = {"yellow", "10", "blue", "20", "yellow", "30", "blue", "40", "red", "10"}; const char *data3[] = {"yellow", "15", "blue", "25", "yellow", "35", "blue", "45", "red", "15"}; Map result1 = func0(data1, 10); Map result2 = func0(data2, 10); Map result3 = func0(data3, 10); assert(result1.size == 3); assert(result2.size == 3); assert(result3.size == 3); // Additional asserts to compare the actual content of the dictionaries can be added here return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x28,%rsp mov %rdi,%r12 mov %rsi,%r13 mov %edx,%ebp mov %fs:0x28,%rax mov %rax,0x18(%rsp) xor %eax,%eax mov %rsp,%rdi callq 1276 <initMap> test %ebp,%ebp jle 1439 <func0+0x72> mov %r13,%rbx sub $0x1,%ebp shr %ebp mov %ebp,%ebp shl $0x4,%rbp lea 0x10(%r13,%rbp,1),%r13 mov %rsp,%rbp mov 0x8(%rbx),%rdi mov $0xa,%edx mov $0x0,%esi callq 10e0 <strtol@plt> mov %rax,%rdx mov (%rbx),%rsi mov %rbp,%rdi callq 1306 <addToMap> add $0x10,%rbx cmp %r13,%rbx jne 140f <func0+0x48> movdqa (%rsp),%xmm0 movups %xmm0,(%r12) mov 0x10(%rsp),%rax mov %rax,0x10(%r12) mov 0x18(%rsp),%rax xor %fs:0x28,%rax jne 146b <func0+0xa4> mov %r12,%rax add $0x28,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10b0 <__stack_chk_fail@plt>
func0: endbr64 push r13 push r12 push rbp push rbx sub rsp, 28h mov r12, rdi mov r13, rsi mov ebp, edx mov rax, fs:28h mov [rsp+48h+var_30], rax xor eax, eax mov rdi, rsp call initMap test ebp, ebp jle short loc_142C mov rbx, r13 sub ebp, 1 shr ebp, 1 mov ebp, ebp shl rbp, 4 lea r13, [r13+rbp+10h] mov rbp, rsp loc_1403: mov rdi, [rbx+8] mov edx, 0Ah mov esi, 0 call _strtol mov edx, eax mov rsi, [rbx] mov rdi, rbp call addToMap add rbx, 10h cmp rbx, r13 jnz short loc_1403 loc_142C: movdqa xmm0, [rsp+48h+var_48] movups xmmword ptr [r12], xmm0 mov rax, [rsp+48h+var_38] mov [r12+10h], rax mov rax, [rsp+48h+var_30] sub rax, fs:28h jnz short loc_145E mov rax, r12 add rsp, 28h pop rbx pop rbp pop r12 pop r13 retn loc_145E: call ___stack_chk_fail
__m128i * func0(__m128i *a1, _QWORD *a2, int a3) { _QWORD *v4; // rbx unsigned int v5; // eax __m128i v7; // [rsp+0h] [rbp-48h] BYREF long long v8; // [rsp+10h] [rbp-38h] unsigned long long v9; // [rsp+18h] [rbp-30h] v9 = __readfsqword(0x28u); initMap(&v7); if ( a3 > 0 ) { v4 = a2; do { v5 = strtol(v4[1], 0LL, 10LL); addToMap(&v7, *v4, v5); v4 += 2; } while ( v4 != &a2[2 * ((unsigned int)(a3 - 1) >> 1) + 2] ); } *a1 = _mm_load_si128(&v7); a1[1].m128i_i64[0] = v8; return a1; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x28 MOV R12,RDI MOV R13,RSI MOV EBP,EDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x18],RAX XOR EAX,EAX MOV RDI,RSP CALL 0x00101276 TEST EBP,EBP JLE 0x0010142c MOV RBX,R13 SUB EBP,0x1 SHR EBP,0x1 MOV EBP,EBP SHL RBP,0x4 LEA R13,[R13 + RBP*0x1 + 0x10] MOV RBP,RSP LAB_00101403: MOV RDI,qword ptr [RBX + 0x8] MOV EDX,0xa MOV ESI,0x0 CALL 0x001010e0 MOV EDX,EAX MOV RSI,qword ptr [RBX] MOV RDI,RBP CALL 0x00101300 ADD RBX,0x10 CMP RBX,R13 JNZ 0x00101403 LAB_0010142c: MOVDQA XMM0,xmmword ptr [RSP] MOVUPS xmmword ptr [R12],XMM0 MOV RAX,qword ptr [RSP + 0x10] MOV qword ptr [R12 + 0x10],RAX MOV RAX,qword ptr [RSP + 0x18] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010145e MOV RAX,R12 ADD RSP,0x28 POP RBX POP RBP POP R12 POP R13 RET LAB_0010145e: CALL 0x001010b0
int8 * func0(int8 *param_1,int8 *param_2,int param_3) { int8 *puVar1; ulong uVar2; long in_FS_OFFSET; int8 local_48; int8 uStack_40; int8 local_38; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); initMap(&local_48); if (0 < param_3) { puVar1 = param_2 + (ulong)(param_3 - 1U >> 1) * 2 + 2; do { uVar2 = strtol((char *)param_2[1],(char **)0x0,10); addToMap(&local_48,*param_2,uVar2 & 0xffffffff); param_2 = param_2 + 2; } while (param_2 != puVar1); } *param_1 = local_48; param_1[1] = uStack_40; param_1[2] = local_38; if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,506
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct List { int *values; int size; int capacity; } List; typedef struct Map { char **keys; List *values; int size; int capacity; } Map; void initList(List *list) { list->values = malloc(10 * sizeof(int)); list->size = 0; list->capacity = 10; } void addToList(List *list, int value) { if (list->size >= list->capacity) { list->capacity *= 2; list->values = realloc(list->values, list->capacity * sizeof(int)); } list->values[list->size++] = value; } void initMap(Map *map) { map->keys = malloc(10 * sizeof(char*)); map->values = malloc(10 * sizeof(List)); map->size = 0; map->capacity = 10; } int findKeyIndex(Map *map, char *key) { for (int i = 0; i < map->size; i++) { if (strcmp(map->keys[i], key) == 0) { return i; } } return -1; } void addToMap(Map *map, char *key, int value) { int index = findKeyIndex(map, key); if (index == -1) { if (map->size >= map->capacity) { map->capacity *= 2; map->keys = realloc(map->keys, map->capacity * sizeof(char*)); map->values = realloc(map->values, map->capacity * sizeof(List)); } map->keys[map->size] = strdup(key); initList(&map->values[map->size]); addToList(&map->values[map->size], value); map->size++; } else { addToList(&map->values[index], value); } }
Map func0(const char *input[], int length) { Map map; initMap(&map); for (int i = 0; i < length; i += 2) { addToMap(&map, (char*)input[i], atoi(input[i + 1])); } return map; }
int main() { const char *data1[] = {"yellow", "1", "blue", "2", "yellow", "3", "blue", "4", "red", "1"}; const char *data2[] = {"yellow", "10", "blue", "20", "yellow", "30", "blue", "40", "red", "10"}; const char *data3[] = {"yellow", "15", "blue", "25", "yellow", "35", "blue", "45", "red", "15"}; Map result1 = func0(data1, 10); Map result2 = func0(data2, 10); Map result3 = func0(data3, 10); assert(result1.size == 3); assert(result2.size == 3); assert(result3.size == 3); // Additional asserts to compare the actual content of the dictionaries can be added here return 0; }
O2
c
func0: endbr64 push %r13 mov %rdi,%r13 push %r12 mov %edx,%r12d push %rbp push %rbx mov %rsi,%rbx sub $0x28,%rsp mov %fs:0x28,%rax mov %rax,0x18(%rsp) xor %eax,%eax mov %rsp,%rbp mov %rbp,%rdi callq 14e0 <initMap> test %r12d,%r12d jle 16e8 <func0+0x78> sub $0x1,%r12d shr %r12d shl $0x4,%r12 lea 0x10(%rbx,%r12,1),%r12 nopw 0x0(%rax,%rax,1) mov 0x8(%rbx),%rdi mov $0xa,%edx xor %esi,%esi add $0x10,%rbx callq 10e0 <strtol@plt> mov -0x10(%rbx),%rsi mov %rbp,%rdi mov %rax,%rdx callq 1590 <addToMap> cmp %r12,%rbx jne 16c0 <func0+0x50> mov 0x10(%rsp),%rax movdqa (%rsp),%xmm0 mov %rax,0x10(%r13) movups %xmm0,0x0(%r13) mov 0x18(%rsp),%rax xor %fs:0x28,%rax jne 1719 <func0+0xa9> add $0x28,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10b0 <__stack_chk_fail@plt> xchg %ax,%ax
func0: endbr64 push r13 mov r13, rdi mov edi, 50h ; 'P' push r12 push rbp mov ebp, edx push rbx mov rbx, rsi sub rsp, 28h mov rax, fs:28h mov [rsp+48h+var_30], rax xor eax, eax call _malloc mov edi, 0A0h mov qword ptr [rsp+48h+var_48], rax call _malloc mov qword ptr [rsp+48h+var_48+8], rax mov rax, 0A00000000h mov [rsp+48h+var_38], rax test ebp, ebp jle short loc_1777 sub ebp, 1 shr ebp, 1 shl rbp, 4 lea r12, [rbx+rbp+10h] mov rbp, rsp nop word ptr [rax+rax+00000000h] loc_1750: mov rdi, [rbx+8] mov edx, 0Ah xor esi, esi add rbx, 10h call _strtol mov rsi, [rbx-10h] mov rdi, rbp mov edx, eax call addToMap cmp rbx, r12 jnz short loc_1750 loc_1777: mov rax, [rsp+48h+var_38] movdqa xmm0, [rsp+48h+var_48] mov [r13+10h], rax movups xmmword ptr [r13+0], xmm0 mov rax, [rsp+48h+var_30] sub rax, fs:28h jnz short loc_17A8 add rsp, 28h mov rax, r13 pop rbx pop rbp pop r12 pop r13 retn loc_17A8: call ___stack_chk_fail
__m128i * func0(__m128i *a1, long long a2, int a3) { long long v5; // rbx long long v6; // rdi unsigned int v7; // eax __m128i v8; // xmm0 __m128i v10; // [rsp+0h] [rbp-48h] BYREF long long v11; // [rsp+10h] [rbp-38h] unsigned long long v12; // [rsp+18h] [rbp-30h] v5 = a2; v12 = __readfsqword(0x28u); v10.m128i_i64[0] = malloc(80LL); v10.m128i_i64[1] = malloc(160LL); v11 = 0xA00000000LL; if ( a3 > 0 ) { do { v6 = *(_QWORD *)(v5 + 8); v5 += 16LL; v7 = strtol(v6, 0LL, 10LL); addToMap(&v10, *(_QWORD *)(v5 - 16), v7); } while ( v5 != a2 + 16LL * ((unsigned int)(a3 - 1) >> 1) + 16 ); } v8 = _mm_load_si128(&v10); a1[1].m128i_i64[0] = v11; *a1 = v8; return a1; }
func0: ENDBR64 PUSH R13 MOV R13,RDI MOV EDI,0x50 PUSH R12 PUSH RBP MOV EBP,EDX PUSH RBX MOV RBX,RSI SUB RSP,0x28 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x18],RAX XOR EAX,EAX CALL 0x001010f0 MOV EDI,0xa0 MOV qword ptr [RSP],RAX CALL 0x001010f0 MOV qword ptr [RSP + 0x8],RAX MOV RAX,0xa00000000 MOV qword ptr [RSP + 0x10],RAX TEST EBP,EBP JLE 0x00101777 SUB EBP,0x1 SHR EBP,0x1 SHL RBP,0x4 LEA R12,[RBX + RBP*0x1 + 0x10] MOV RBP,RSP NOP word ptr [RAX + RAX*0x1] LAB_00101750: MOV RDI,qword ptr [RBX + 0x8] MOV EDX,0xa XOR ESI,ESI ADD RBX,0x10 CALL 0x001010e0 MOV RSI,qword ptr [RBX + -0x10] MOV RDI,RBP MOV EDX,EAX CALL 0x00101590 CMP RBX,R12 JNZ 0x00101750 LAB_00101777: MOV RAX,qword ptr [RSP + 0x10] MOVDQA XMM0,xmmword ptr [RSP] MOV qword ptr [R13 + 0x10],RAX MOVUPS xmmword ptr [R13],XMM0 MOV RAX,qword ptr [RSP + 0x18] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017a8 ADD RSP,0x28 MOV RAX,R13 POP RBX POP RBP POP R12 POP R13 RET LAB_001017a8: CALL 0x001010b0
int8 * func0(int8 *param_1,int8 *param_2,int param_3) { ulong uVar1; int8 *puVar2; int8 *puVar3; long in_FS_OFFSET; void *local_48; void *pvStack_40; int8 local_38; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); local_48 = malloc(0x50); pvStack_40 = malloc(0xa0); local_38 = 0xa00000000; if (0 < param_3) { puVar2 = param_2; do { puVar3 = puVar2 + 2; uVar1 = strtol((char *)puVar2[1],(char **)0x0,10); addToMap(&local_48,*puVar2,uVar1 & 0xffffffff); puVar2 = puVar3; } while (puVar3 != param_2 + (ulong)(param_3 - 1U >> 1) * 2 + 2); } param_1[2] = local_38; *param_1 = local_48; param_1[1] = pvStack_40; if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,507
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> typedef struct List { int *values; int size; int capacity; } List; typedef struct Map { char **keys; List *values; int size; int capacity; } Map; void initList(List *list) { list->values = malloc(10 * sizeof(int)); list->size = 0; list->capacity = 10; } void addToList(List *list, int value) { if (list->size >= list->capacity) { list->capacity *= 2; list->values = realloc(list->values, list->capacity * sizeof(int)); } list->values[list->size++] = value; } void initMap(Map *map) { map->keys = malloc(10 * sizeof(char*)); map->values = malloc(10 * sizeof(List)); map->size = 0; map->capacity = 10; } int findKeyIndex(Map *map, char *key) { for (int i = 0; i < map->size; i++) { if (strcmp(map->keys[i], key) == 0) { return i; } } return -1; } void addToMap(Map *map, char *key, int value) { int index = findKeyIndex(map, key); if (index == -1) { if (map->size >= map->capacity) { map->capacity *= 2; map->keys = realloc(map->keys, map->capacity * sizeof(char*)); map->values = realloc(map->values, map->capacity * sizeof(List)); } map->keys[map->size] = strdup(key); initList(&map->values[map->size]); addToList(&map->values[map->size], value); map->size++; } else { addToList(&map->values[index], value); } }
Map func0(const char *input[], int length) { Map map; initMap(&map); for (int i = 0; i < length; i += 2) { addToMap(&map, (char*)input[i], atoi(input[i + 1])); } return map; }
int main() { const char *data1[] = {"yellow", "1", "blue", "2", "yellow", "3", "blue", "4", "red", "1"}; const char *data2[] = {"yellow", "10", "blue", "20", "yellow", "30", "blue", "40", "red", "10"}; const char *data3[] = {"yellow", "15", "blue", "25", "yellow", "35", "blue", "45", "red", "15"}; Map result1 = func0(data1, 10); Map result2 = func0(data2, 10); Map result3 = func0(data3, 10); assert(result1.size == 3); assert(result2.size == 3); assert(result3.size == 3); // Additional asserts to compare the actual content of the dictionaries can be added here return 0; }
O3
c
func0: endbr64 push %r13 mov %rdi,%r13 mov $0x50,%edi push %r12 push %rbp mov %edx,%ebp push %rbx mov %rsi,%rbx sub $0x28,%rsp mov %fs:0x28,%rax mov %rax,0x18(%rsp) xor %eax,%eax callq 10f0 <malloc@plt> mov $0xa0,%edi mov %rax,(%rsp) callq 10f0 <malloc@plt> mov %rax,0x8(%rsp) movabs $0xa00000000,%rax mov %rax,0x10(%rsp) test %ebp,%ebp jle 17b8 <func0+0x98> sub $0x1,%ebp shr %ebp shl $0x4,%rbp lea 0x10(%rbx,%rbp,1),%r12 mov %rsp,%rbp nopw 0x0(%rax,%rax,1) mov 0x8(%rbx),%rdi mov $0xa,%edx xor %esi,%esi add $0x10,%rbx callq 10e0 <strtol@plt> mov -0x10(%rbx),%rsi mov %rbp,%rdi mov %rax,%rdx callq 15d0 <addToMap> cmp %rbx,%r12 jne 1790 <func0+0x70> mov 0x10(%rsp),%rax movdqa (%rsp),%xmm0 mov %rax,0x10(%r13) movups %xmm0,0x0(%r13) mov 0x18(%rsp),%rax xor %fs:0x28,%rax jne 17e9 <func0+0xc9> add $0x28,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10b0 <__stack_chk_fail@plt> xchg %ax,%ax
func0: endbr64 push r13 push r12 mov r12, rdi mov edi, 50h ; 'P'; size push rbp mov ebp, edx push rbx mov rbx, rsi sub rsp, 28h mov rax, fs:28h mov [rsp+48h+var_30], rax xor eax, eax call _malloc mov edi, 0A0h; size mov qword ptr [rsp+48h+var_48], rax call _malloc mov qword ptr [rsp+48h+var_48+8], rax mov rax, cs:qword_2090 mov [rsp+48h+var_38], rax test ebp, ebp jle short loc_179F sub ebp, 1 shr ebp, 1 shl rbp, 4 lea r13, [rbx+rbp+10h] mov rbp, rsp nop dword ptr [rax+00h] loc_1778: mov rdi, [rbx+8]; nptr mov edx, 0Ah; base xor esi, esi; endptr add rbx, 10h call _strtol mov rsi, [rbx-10h] mov rdi, rbp mov edx, eax call addToMap cmp r13, rbx jnz short loc_1778 loc_179F: mov rax, [rsp+48h+var_38] movdqa xmm0, [rsp+48h+var_48] mov [r12+10h], rax movups xmmword ptr [r12], xmm0 mov rax, [rsp+48h+var_30] sub rax, fs:28h jnz short loc_17D1 add rsp, 28h mov rax, r12 pop rbx pop rbp pop r12 pop r13 retn loc_17D1: call ___stack_chk_fail
__m128i * func0(__m128i *a1, long long a2, int a3) { long long v5; // rbx const char *v6; // rdi unsigned int v7; // eax __m128i v8; // xmm0 __m128i v10; // [rsp+0h] [rbp-48h] BYREF long long v11; // [rsp+10h] [rbp-38h] unsigned long long v12; // [rsp+18h] [rbp-30h] v5 = a2; v12 = __readfsqword(0x28u); v10.m128i_i64[0] = (long long)malloc(0x50uLL); v10.m128i_i64[1] = (long long)malloc(0xA0uLL); v11 = 0xA00000000LL; if ( a3 > 0 ) { do { v6 = *(const char **)(v5 + 8); v5 += 16LL; v7 = strtol(v6, 0LL, 10); addToMap(&v10, *(_QWORD *)(v5 - 16), v7); } while ( a2 + 16LL * ((unsigned int)(a3 - 1) >> 1) + 16 != v5 ); } v8 = _mm_load_si128(&v10); a1[1].m128i_i64[0] = v11; *a1 = v8; return a1; }
func0: ENDBR64 PUSH R13 PUSH R12 MOV R12,RDI MOV EDI,0x50 PUSH RBP MOV EBP,EDX PUSH RBX MOV RBX,RSI SUB RSP,0x28 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x18],RAX XOR EAX,EAX CALL 0x001010f0 MOV EDI,0xa0 MOV qword ptr [RSP],RAX CALL 0x001010f0 MOV qword ptr [RSP + 0x8],RAX MOV RAX,qword ptr [0x00102090] MOV qword ptr [RSP + 0x10],RAX TEST EBP,EBP JLE 0x0010179f SUB EBP,0x1 SHR EBP,0x1 SHL RBP,0x4 LEA R13,[RBX + RBP*0x1 + 0x10] MOV RBP,RSP NOP dword ptr [RAX] LAB_00101778: MOV RDI,qword ptr [RBX + 0x8] MOV EDX,0xa XOR ESI,ESI ADD RBX,0x10 CALL 0x001010e0 MOV RSI,qword ptr [RBX + -0x10] MOV RDI,RBP MOV EDX,EAX CALL 0x001015c0 CMP R13,RBX JNZ 0x00101778 LAB_0010179f: MOV RAX,qword ptr [RSP + 0x10] MOVDQA XMM0,xmmword ptr [RSP] MOV qword ptr [R12 + 0x10],RAX MOVUPS xmmword ptr [R12],XMM0 MOV RAX,qword ptr [RSP + 0x18] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017d1 ADD RSP,0x28 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 RET LAB_001017d1: CALL 0x001010b0
int8 * func0(int8 *param_1,int8 *param_2,int param_3) { ulong uVar1; int8 *puVar2; int8 *puVar3; long in_FS_OFFSET; void *local_48; void *pvStack_40; int8 local_38; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); local_48 = malloc(0x50); pvStack_40 = malloc(0xa0); local_38 = DAT_00102090; if (0 < param_3) { puVar2 = param_2; do { puVar3 = puVar2 + 2; uVar1 = strtol((char *)puVar2[1],(char **)0x0,10); addToMap(&local_48,*puVar2,uVar1 & 0xffffffff); puVar2 = puVar3; } while (param_2 + (ulong)(param_3 - 1U >> 1) * 2 + 2 != puVar3); } param_1[2] = local_38; *param_1 = local_48; param_1[1] = pvStack_40; if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,508
func0
#include <assert.h>
int func0(int l, int b) { int perimeter = 2 * (l + b); return perimeter; }
int main() { assert(func0(10, 20) == 60); assert(func0(10, 5) == 30); assert(func0(4, 2) == 12); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov -0x14(%rbp),%edx mov -0x18(%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 edx, [rbp+var_14] mov eax, [rbp+var_18] 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) { return (unsigned int)(2 * (a1 + a2)); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV EDX,dword ptr [RBP + -0x14] MOV EAX,dword ptr [RBP + -0x18] 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) { return (param_2 + param_1) * 2; }
6,509
func0
#include <assert.h>
int func0(int l, int b) { int perimeter = 2 * (l + b); return perimeter; }
int main() { assert(func0(10, 20) == 60); assert(func0(10, 5) == 30); assert(func0(4, 2) == 12); return 0; }
O1
c
func0: endbr64 add %esi,%edi lea (%rdi,%rdi,1),%eax retq
func0: endbr64 add edi, esi lea eax, [rdi+rdi] retn
long long func0(int a1, int a2) { return (unsigned int)(2 * (a2 + a1)); }
func0: ENDBR64 ADD EDI,ESI LEA EAX,[RDI + RDI*0x1] RET
int func0(int param_1,int param_2) { return (param_1 + param_2) * 2; }
6,510
func0
#include <assert.h>
int func0(int l, int b) { int perimeter = 2 * (l + b); return perimeter; }
int main() { assert(func0(10, 20) == 60); assert(func0(10, 5) == 30); assert(func0(4, 2) == 12); return 0; }
O2
c
func0: endbr64 add %esi,%edi lea (%rdi,%rdi,1),%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 add edi, esi lea eax, [rdi+rdi] retn
long long func0(int a1, int a2) { return (unsigned int)(2 * (a2 + a1)); }
func0: ENDBR64 ADD EDI,ESI LEA EAX,[RDI + RDI*0x1] RET
int func0(int param_1,int param_2) { return (param_1 + param_2) * 2; }
6,511
func0
#include <assert.h>
int func0(int l, int b) { int perimeter = 2 * (l + b); return perimeter; }
int main() { assert(func0(10, 20) == 60); assert(func0(10, 5) == 30); assert(func0(4, 2) == 12); return 0; }
O3
c
func0: endbr64 add %esi,%edi lea (%rdi,%rdi,1),%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 add edi, esi lea eax, [rdi+rdi] retn
long long func0(int a1, int a2) { return (unsigned int)(2 * (a2 + a1)); }
func0: ENDBR64 ADD EDI,ESI LEA EAX,[RDI + RDI*0x1] RET
int func0(int param_1,int param_2) { return (param_1 + param_2) * 2; }
6,512
func0
#include <assert.h>
int func0(int n) { int sm = 0; for (int i = 1; i <= n; i++) { sm += i * i * i * i * i; } return sm; }
int main() { assert(func0(2) == 33); assert(func0(4) == 1300); assert(func0(3) == 276); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) movl $0x0,-0x8(%rbp) movl $0x1,-0x4(%rbp) jmp 117d <func0+0x34> mov -0x4(%rbp),%eax imul %eax,%eax imul -0x4(%rbp),%eax imul -0x4(%rbp),%eax imul -0x4(%rbp),%eax add %eax,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x14(%rbp),%eax jle 1164 <func0+0x1b> 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 [rbp+var_4], 1 jmp short loc_117D loc_1164: mov eax, [rbp+var_4] imul eax, eax imul eax, [rbp+var_4] imul eax, [rbp+var_4] imul eax, [rbp+var_4] add [rbp+var_8], eax add [rbp+var_4], 1 loc_117D: mov eax, [rbp+var_4] cmp eax, [rbp+var_14] jle short loc_1164 mov eax, [rbp+var_8] pop rbp retn
long long func0(int a1) { unsigned int v2; // [rsp+Ch] [rbp-8h] int i; // [rsp+10h] [rbp-4h] v2 = 0; for ( i = 1; i <= a1; ++i ) v2 += i * i * i * i * i; return v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x1 JMP 0x0010117d LAB_00101164: MOV EAX,dword ptr [RBP + -0x4] IMUL EAX,EAX IMUL EAX,dword ptr [RBP + -0x4] IMUL EAX,dword ptr [RBP + -0x4] IMUL EAX,dword ptr [RBP + -0x4] ADD dword ptr [RBP + -0x8],EAX ADD dword ptr [RBP + -0x4],0x1 LAB_0010117d: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x14] JLE 0x00101164 MOV EAX,dword ptr [RBP + -0x8] POP RBP RET
int func0(int param_1) { int4 local_10; int4 local_c; local_10 = 0; for (local_c = 1; local_c <= param_1; local_c = local_c + 1) { local_10 = local_10 + local_c * local_c * local_c * local_c * local_c; } return local_10; }
6,513
func0
#include <assert.h>
int func0(int n) { int sm = 0; for (int i = 1; i <= n; i++) { sm += i * i * i * i * i; } return sm; }
int main() { assert(func0(2) == 33); assert(func0(4) == 1300); assert(func0(3) == 276); return 0; }
O1
c
func0: endbr64 test %edi,%edi jle 1175 <func0+0x2c> add $0x1,%edi mov $0x1,%edx mov $0x0,%ecx mov %edx,%eax imul %edx,%eax imul %eax,%eax imul %edx,%eax add %eax,%ecx add $0x1,%edx cmp %edi,%edx jne 115e <func0+0x15> mov %ecx,%eax retq mov $0x0,%ecx jmp 1172 <func0+0x29>
func0: endbr64 test edi, edi jle short loc_1175 add edi, 1 mov edx, 1 mov ecx, 0 loc_115E: mov eax, edx imul eax, edx imul eax, eax imul eax, edx add ecx, eax add edx, 1 cmp edx, edi jnz short loc_115E loc_1172: mov eax, ecx retn loc_1175: mov ecx, 0 jmp short loc_1172
long long func0(int a1) { int v1; // edi int v2; // edx unsigned int v3; // ecx if ( a1 <= 0 ) { return 0; } else { v1 = a1 + 1; v2 = 1; v3 = 0; do { v3 += v2 * v2 * v2 * v2 * v2; ++v2; } while ( v2 != v1 ); } return v3; }
func0: ENDBR64 TEST EDI,EDI JLE 0x00101175 ADD EDI,0x1 MOV EDX,0x1 MOV ECX,0x0 LAB_0010115e: MOV EAX,EDX IMUL EAX,EDX IMUL EAX,EAX IMUL EAX,EDX ADD ECX,EAX ADD EDX,0x1 CMP EDX,EDI JNZ 0x0010115e LAB_00101172: MOV EAX,ECX RET LAB_00101175: MOV ECX,0x0 JMP 0x00101172
int func0(int param_1) { int iVar1; int iVar2; if (param_1 < 1) { iVar1 = 0; } else { iVar2 = 1; iVar1 = 0; do { iVar1 = iVar1 + iVar2 * iVar2 * iVar2 * iVar2 * iVar2; iVar2 = iVar2 + 1; } while (iVar2 != param_1 + 1); } return iVar1; }
6,514
func0
#include <assert.h>
int func0(int n) { int sm = 0; for (int i = 1; i <= n; i++) { sm += i * i * i * i * i; } return sm; }
int main() { assert(func0(2) == 33); assert(func0(4) == 1300); assert(func0(3) == 276); return 0; }
O2
c
func0: endbr64 test %edi,%edi jle 1178 <func0+0x38> add $0x1,%edi mov $0x1,%edx xor %r8d,%r8d nopl 0x0(%rax,%rax,1) mov %edx,%eax imul %edx,%eax imul %eax,%eax imul %edx,%eax add $0x1,%edx add %eax,%r8d cmp %edx,%edi jne 1158 <func0+0x18> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq
func0: endbr64 test edi, edi jle short loc_1178 add edi, 1 mov edx, 1 xor r8d, r8d nop dword ptr [rax+rax+00h] loc_1158: mov eax, edx imul eax, edx imul eax, eax imul eax, edx add edx, 1 add r8d, eax cmp edi, edx jnz short loc_1158 mov eax, r8d retn loc_1178: xor r8d, r8d mov eax, r8d retn
long long func0(int a1) { int v1; // edi int v2; // edx unsigned int v3; // r8d int v4; // eax if ( a1 <= 0 ) return 0LL; v1 = a1 + 1; v2 = 1; v3 = 0; do { v4 = v2 * v2 * v2 * v2 * v2; ++v2; v3 += v4; } while ( v1 != v2 ); return v3; }
func0: ENDBR64 TEST EDI,EDI JLE 0x00101178 ADD EDI,0x1 MOV EDX,0x1 XOR R8D,R8D NOP dword ptr [RAX + RAX*0x1] LAB_00101158: MOV EAX,EDX IMUL EAX,EDX IMUL EAX,EAX IMUL EAX,EDX ADD EDX,0x1 ADD R8D,EAX CMP EDI,EDX JNZ 0x00101158 MOV EAX,R8D RET LAB_00101178: XOR R8D,R8D MOV EAX,R8D RET
int func0(int param_1) { int iVar1; int iVar2; int iVar3; if (0 < param_1) { iVar2 = 1; iVar3 = 0; do { iVar1 = iVar2 * iVar2 * iVar2 * iVar2 * iVar2; iVar2 = iVar2 + 1; iVar3 = iVar3 + iVar1; } while (param_1 + 1 != iVar2); return iVar3; } return 0; }
6,515
func0
#include <assert.h>
int func0(int n) { int sm = 0; for (int i = 1; i <= n; i++) { sm += i * i * i * i * i; } return sm; }
int main() { assert(func0(2) == 33); assert(func0(4) == 1300); assert(func0(3) == 276); return 0; }
O3
c
func0: endbr64 test %edi,%edi jle 1178 <func0+0x38> add $0x1,%edi mov $0x1,%edx xor %r8d,%r8d nopl 0x0(%rax,%rax,1) mov %edx,%eax imul %edx,%eax imul %eax,%eax imul %edx,%eax add $0x1,%edx add %eax,%r8d cmp %edi,%edx jne 1158 <func0+0x18> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq
func0: endbr64 test edi, edi jle short loc_1170 add edi, 1 mov edx, 1 xor ecx, ecx nop word ptr [rax+rax+00h] loc_1158: mov eax, edx imul eax, edx imul eax, eax imul eax, edx add edx, 1 add ecx, eax cmp edx, edi jnz short loc_1158 mov eax, ecx retn loc_1170: xor ecx, ecx mov eax, ecx retn
long long func0(int a1) { int v1; // edi int v2; // edx unsigned int v3; // ecx int v4; // eax if ( a1 <= 0 ) return 0LL; v1 = a1 + 1; v2 = 1; v3 = 0; do { v4 = v2 * v2 * v2 * v2 * v2; ++v2; v3 += v4; } while ( v2 != v1 ); return v3; }
func0: ENDBR64 TEST EDI,EDI JLE 0x00101170 ADD EDI,0x1 MOV EDX,0x1 XOR ECX,ECX NOP word ptr [RAX + RAX*0x1] LAB_00101158: MOV EAX,EDX IMUL EAX,EDX IMUL EAX,EAX IMUL EAX,EDX ADD EDX,0x1 ADD ECX,EAX CMP EDX,EDI JNZ 0x00101158 MOV EAX,ECX RET LAB_00101170: XOR ECX,ECX MOV EAX,ECX RET
int func0(int param_1) { int iVar1; int iVar2; int iVar3; if (0 < param_1) { iVar3 = 1; iVar2 = 0; do { iVar1 = iVar3 * iVar3 * iVar3 * iVar3 * iVar3; iVar3 = iVar3 + 1; iVar2 = iVar2 + iVar1; } while (iVar3 != param_1 + 1); return iVar2; } return 0; }
6,516
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> void sort(int arr[], int n) { int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } }
int func0(int a[], int b[], int n) { sort(a, n); sort(b, n); int sum = 0; for (int i = 0; i < n; i++) { sum += abs(a[i] - b[i]); } return sum; }
int main() { int a1[] = {3, 2, 1}; int b1[] = {2, 1, 3}; assert(func0(a1, b1, 3) == 0); int a2[] = {1, 2, 3}; int b2[] = {4, 5, 6}; assert(func0(a2, b2, 3) == 9); int a3[] = {4, 1, 8, 7}; int b3[] = {2, 3, 6, 5}; assert(func0(a3, b3, 4) == 6); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x28,%rsp mov %rdi,-0x18(%rbp) mov %rsi,-0x20(%rbp) mov %edx,-0x24(%rbp) mov -0x24(%rbp),%edx mov -0x18(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 1169 <sort> mov -0x24(%rbp),%edx mov -0x20(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 1169 <sort> movl $0x0,-0x8(%rbp) movl $0x0,-0x4(%rbp) jmp 12dd <func0+0x85> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x20(%rbp),%rax add %rcx,%rax mov (%rax),%eax sub %eax,%edx mov %edx,%eax cltd xor %edx,%eax sub %edx,%eax add %eax,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x24(%rbp),%eax jl 12a1 <func0+0x49> mov -0x8(%rbp),%eax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 28h mov [rbp+var_18], rdi mov [rbp+var_20], rsi mov [rbp+var_24], edx mov edx, [rbp+var_24] mov rax, [rbp+var_18] mov esi, edx mov rdi, rax call sort mov edx, [rbp+var_24] mov rax, [rbp+var_20] mov esi, edx mov rdi, rax call sort mov [rbp+var_8], 0 mov [rbp+var_4], 0 jmp short loc_12DE loc_12A1: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov eax, [rax] mov edx, [rbp+var_4] movsxd rdx, edx lea rcx, ds:0[rdx*4] mov rdx, [rbp+var_20] add rdx, rcx mov edx, [rdx] sub eax, edx mov edx, eax neg edx cmovns eax, edx add [rbp+var_8], eax add [rbp+var_4], 1 loc_12DE: mov eax, [rbp+var_4] cmp eax, [rbp+var_24] jl short loc_12A1 mov eax, [rbp+var_8] leave retn
long long func0(long long a1, long long a2, unsigned int a3) { long long v3; // rcx int v4; // eax unsigned int v7; // [rsp+20h] [rbp-8h] int i; // [rsp+24h] [rbp-4h] sort(a1, a3); sort(a2, a3); v7 = 0; for ( i = 0; i < (int)a3; ++i ) { v3 = 4LL * i; v4 = *(_DWORD *)(v3 + a1) - *(_DWORD *)(v3 + a2); if ( *(_DWORD *)(v3 + a2) - *(_DWORD *)(v3 + a1) >= 0 ) v4 = *(_DWORD *)(v3 + a2) - *(_DWORD *)(4LL * i + a1); v7 += v4; } return v7; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x28 MOV qword ptr [RBP + -0x18],RDI MOV qword ptr [RBP + -0x20],RSI MOV dword ptr [RBP + -0x24],EDX MOV EDX,dword ptr [RBP + -0x24] MOV RAX,qword ptr [RBP + -0x18] MOV ESI,EDX MOV RDI,RAX CALL 0x00101169 MOV EDX,dword ptr [RBP + -0x24] MOV RAX,qword ptr [RBP + -0x20] MOV ESI,EDX MOV RDI,RAX CALL 0x00101169 MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x0 JMP 0x001012de LAB_001012a1: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV EDX,dword ptr [RBP + -0x4] MOVSXD RDX,EDX LEA RCX,[RDX*0x4] MOV RDX,qword ptr [RBP + -0x20] ADD RDX,RCX MOV EDX,dword ptr [RDX] SUB EAX,EDX MOV EDX,EAX NEG EDX CMOVNS EAX,EDX ADD dword ptr [RBP + -0x8],EAX ADD dword ptr [RBP + -0x4],0x1 LAB_001012de: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x24] JL 0x001012a1 MOV EAX,dword ptr [RBP + -0x8] LEAVE RET
int func0(long param_1,long param_2,int param_3) { int iVar1; int4 local_10; int4 local_c; sort(param_1,param_3); sort(param_2,param_3); local_10 = 0; for (local_c = 0; local_c < param_3; local_c = local_c + 1) { iVar1 = *(int *)(param_1 + (long)local_c * 4) - *(int *)(param_2 + (long)local_c * 4); if (iVar1 < 1) { iVar1 = -iVar1; } local_10 = local_10 + iVar1; } return local_10; }
6,517
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> void sort(int arr[], int n) { int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } }
int func0(int a[], int b[], int n) { sort(a, n); sort(b, n); int sum = 0; for (int i = 0; i < n; i++) { sum += abs(a[i] - b[i]); } return sum; }
int main() { int a1[] = {3, 2, 1}; int b1[] = {2, 1, 3}; assert(func0(a1, b1, 3) == 0); int a2[] = {1, 2, 3}; int b2[] = {4, 5, 6}; assert(func0(a2, b2, 3) == 9); int a3[] = {4, 1, 8, 7}; int b3[] = {2, 3, 6, 5}; assert(func0(a3, b3, 4) == 6); return 0; }
O1
c
func0: endbr64 push %r12 push %rbp push %rbx mov %rdi,%rbx mov %rsi,%rbp mov %edx,%r12d mov %edx,%esi callq 1169 <sort> mov %r12d,%esi mov %rbp,%rdi callq 1169 <sort> test %r12d,%r12d jle 120a <func0+0x5c> lea -0x1(%r12),%edi mov $0x0,%edx mov $0x0,%esi mov (%rbx,%rdx,4),%eax sub 0x0(%rbp,%rdx,4),%eax mov %eax,%ecx sar $0x1f,%ecx xor %ecx,%eax sub %ecx,%eax add %eax,%esi mov %rdx,%rax add $0x1,%rdx cmp %rdi,%rax jne 11e5 <func0+0x37> mov %esi,%eax pop %rbx pop %rbp pop %r12 retq mov $0x0,%esi jmp 1203 <func0+0x55>
func0: endbr64 push r12 push rbp push rbx mov rbx, rdi mov rbp, rsi mov r12d, edx mov esi, edx call sort mov esi, r12d mov rdi, rbp call sort test r12d, r12d jle short loc_1203 mov edx, r12d mov ecx, 0 mov edi, 0 loc_11E3: mov eax, [rbx+rcx*4] sub eax, [rbp+rcx*4+0] mov esi, eax neg esi cmovns eax, esi add edi, eax add rcx, 1 cmp rcx, rdx jnz short loc_11E3 loc_11FC: mov eax, edi pop rbx pop rbp pop r12 retn loc_1203: mov edi, 0 jmp short loc_11FC
long long func0(long long a1, long long a2, int a3) { long long v5; // rcx unsigned int v6; // edi int v7; // eax sort(a1, (unsigned int)a3); sort(a2, (unsigned int)a3); if ( a3 <= 0 ) { return 0; } else { v5 = 0LL; v6 = 0; do { v7 = *(_DWORD *)(a1 + 4 * v5) - *(_DWORD *)(a2 + 4 * v5); if ( *(_DWORD *)(a2 + 4 * v5) - *(_DWORD *)(a1 + 4 * v5) >= 0 ) v7 = *(_DWORD *)(a2 + 4 * v5) - *(_DWORD *)(a1 + 4 * v5); v6 += v7; ++v5; } while ( v5 != a3 ); } return v6; }
6,518
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> void sort(int arr[], int n) { int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } }
int func0(int a[], int b[], int n) { sort(a, n); sort(b, n); int sum = 0; for (int i = 0; i < n; i++) { sum += abs(a[i] - b[i]); } return sum; }
int main() { int a1[] = {3, 2, 1}; int b1[] = {2, 1, 3}; assert(func0(a1, b1, 3) == 0); int a2[] = {1, 2, 3}; int b2[] = {4, 5, 6}; assert(func0(a2, b2, 3) == 9); int a3[] = {4, 1, 8, 7}; int b3[] = {2, 3, 6, 5}; assert(func0(a3, b3, 4) == 6); return 0; }
O2
c
func0: endbr64 push %rbx mov %rsi,%r11 mov %edx,%esi mov %edx,%ebx mov %rdi,%r10 callq 12f0 <sort> mov %ebx,%esi mov %r11,%rdi callq 12f0 <sort> test %ebx,%ebx jle 1388 <func0+0x58> lea -0x1(%rbx),%esi xor %edx,%edx xor %r8d,%r8d nopw 0x0(%rax,%rax,1) mov (%r10,%rdx,4),%eax sub (%r11,%rdx,4),%eax mov %eax,%ecx sar $0x1f,%ecx xor %ecx,%eax sub %ecx,%eax add %eax,%r8d mov %rdx,%rax add $0x1,%rdx cmp %rax,%rsi jne 1360 <func0+0x30> mov %r8d,%eax pop %rbx retq nopl (%rax) xor %r8d,%r8d pop %rbx mov %r8d,%eax retq
func0: endbr64 push rbx mov r10d, edx mov rbx, rsi mov esi, edx mov r11, rdi call sort mov esi, r10d mov rdi, rbx call sort test r10d, r10d jle short loc_1380 movsxd rdx, r10d xor ecx, ecx xor r8d, r8d nop dword ptr [rax] loc_1360: mov eax, [r11+rcx*4] sub eax, [rbx+rcx*4] mov esi, eax neg esi cmovns eax, esi add rcx, 1 add r8d, eax cmp rdx, rcx jnz short loc_1360 mov eax, r8d pop rbx retn loc_1380: xor r8d, r8d pop rbx mov eax, r8d retn
long long func0(long long a1, long long a2, unsigned int a3) { unsigned int v3; // r10d int v4; // r10d long long v5; // r11 long long v6; // rcx unsigned int v7; // r8d int v8; // eax sort(a1, a3); sort(a2, v3); if ( v4 <= 0 ) return 0LL; v6 = 0LL; v7 = 0; do { v8 = *(_DWORD *)(v5 + 4 * v6) - *(_DWORD *)(a2 + 4 * v6); if ( *(_DWORD *)(a2 + 4 * v6) - *(_DWORD *)(v5 + 4 * v6) >= 0 ) v8 = *(_DWORD *)(a2 + 4 * v6) - *(_DWORD *)(v5 + 4 * v6); ++v6; v7 += v8; } while ( v4 != v6 ); return v7; }
func0: ENDBR64 PUSH RBX MOV R10D,EDX MOV RBX,RSI MOV ESI,EDX MOV R11,RDI CALL 0x001012f0 MOV ESI,R10D MOV RDI,RBX CALL 0x001012f0 TEST R10D,R10D JLE 0x00101380 MOVSXD RDX,R10D XOR ECX,ECX XOR R8D,R8D NOP dword ptr [RAX] LAB_00101360: MOV EAX,dword ptr [R11 + RCX*0x4] SUB EAX,dword ptr [RBX + RCX*0x4] MOV ESI,EAX NEG ESI CMOVNS EAX,ESI ADD RCX,0x1 ADD R8D,EAX CMP RDX,RCX JNZ 0x00101360 MOV EAX,R8D POP RBX RET LAB_00101380: XOR R8D,R8D POP RBX MOV EAX,R8D RET
int func0(long param_1,long param_2,ulong param_3) { int iVar1; long lVar2; int iVar3; int iVar4; ulong uVar5; uVar5 = param_3 & 0xffffffff; sort(param_1,param_3 & 0xffffffff); iVar4 = (int)uVar5; sort(param_2,uVar5 & 0xffffffff); if (0 < iVar4) { lVar2 = 0; iVar3 = 0; do { iVar1 = *(int *)(param_1 + lVar2 * 4) - *(int *)(param_2 + lVar2 * 4); if (iVar1 < 1) { iVar1 = -iVar1; } lVar2 = lVar2 + 1; iVar3 = iVar3 + iVar1; } while (iVar4 != lVar2); return iVar3; } return 0; }
6,519
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h> void sort(int arr[], int n) { int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } }
int func0(int a[], int b[], int n) { sort(a, n); sort(b, n); int sum = 0; for (int i = 0; i < n; i++) { sum += abs(a[i] - b[i]); } return sum; }
int main() { int a1[] = {3, 2, 1}; int b1[] = {2, 1, 3}; assert(func0(a1, b1, 3) == 0); int a2[] = {1, 2, 3}; int b2[] = {4, 5, 6}; assert(func0(a2, b2, 3) == 9); int a3[] = {4, 1, 8, 7}; int b3[] = {2, 3, 6, 5}; assert(func0(a3, b3, 4) == 6); return 0; }
O3
c
func0: endbr64 lea -0x1(%rdx),%r11d push %rbp lea 0x4(%rdi),%rbp push %rbx mov %r11d,%ecx mov %r11d,%r8d test %r11d,%r11d jle 13a0 <func0+0x90> nopl 0x0(%rax) lea -0x1(%r8),%r9d mov %rdi,%rax mov %r9,%r8 lea 0x0(%rbp,%r9,4),%rbx mov (%rax),%r9d mov 0x4(%rax),%r10d cmp %r10d,%r9d jle 1353 <func0+0x43> mov %r10d,(%rax) mov %r9d,0x4(%rax) add $0x4,%rax cmp %rax,%rbx jne 1340 <func0+0x30> test %r8d,%r8d jne 1330 <func0+0x20> lea 0x4(%rsi),%rbx nopl (%rax) lea -0x1(%rcx),%r8d mov %rsi,%rax mov %r8,%rcx lea (%rbx,%r8,4),%r10 nopw %cs:0x0(%rax,%rax,1) mov (%rax),%r8d mov 0x4(%rax),%r9d cmp %r9d,%r8d jle 1393 <func0+0x83> mov %r9d,(%rax) mov %r8d,0x4(%rax) add $0x4,%rax cmp %rax,%r10 jne 1380 <func0+0x70> test %ecx,%ecx jne 1368 <func0+0x58> test %edx,%edx jle 1480 <func0+0x170> cmp $0x2,%r11d jbe 1485 <func0+0x175> mov %edx,%ecx xor %eax,%eax pxor %xmm1,%xmm1 shr $0x2,%ecx shl $0x4,%rcx nopl 0x0(%rax) movdqu (%rdi,%rax,1),%xmm0 movdqu (%rsi,%rax,1),%xmm3 add $0x10,%rax psubd %xmm3,%xmm0 movdqa %xmm0,%xmm2 psrad $0x1f,%xmm2 pxor %xmm2,%xmm0 psubd %xmm2,%xmm0 paddd %xmm0,%xmm1 cmp %rax,%rcx jne 13c8 <func0+0xb8> movdqa %xmm1,%xmm0 mov %edx,%ecx psrldq $0x8,%xmm0 and $0xfffffffc,%ecx paddd %xmm0,%xmm1 movdqa %xmm1,%xmm0 psrldq $0x4,%xmm0 paddd %xmm0,%xmm1 movd %xmm1,%eax test $0x3,%dl je 1476 <func0+0x166> movslq %ecx,%r9 mov (%rdi,%r9,4),%r8d sub (%rsi,%r9,4),%r8d mov %r8d,%r9d sar $0x1f,%r9d xor %r9d,%r8d sub %r9d,%r8d add %r8d,%eax lea 0x1(%rcx),%r8d cmp %r8d,%edx jle 1476 <func0+0x166> movslq %r8d,%r9 add $0x2,%ecx mov (%rdi,%r9,4),%r8d sub (%rsi,%r9,4),%r8d mov %r8d,%r9d sar $0x1f,%r9d xor %r9d,%r8d sub %r9d,%r8d add %r8d,%eax cmp %ecx,%edx jle 1476 <func0+0x166> movslq %ecx,%rcx mov (%rdi,%rcx,4),%edx sub (%rsi,%rcx,4),%edx mov %edx,%ecx sar $0x1f,%ecx xor %ecx,%edx sub %ecx,%edx add %edx,%eax pop %rbx pop %rbp retq nopl 0x0(%rax) xor %eax,%eax pop %rbx pop %rbp retq xor %ecx,%ecx xor %eax,%eax jmp 141c <func0+0x10c> nopl 0x0(%rax,%rax,1)
func0: endbr64 mov r8, rdi mov r9, rsi mov r10d, edx mov edi, edx lea r11, [r8+4] cmp edx, 1 jle loc_14C0 nop dword ptr [rax+00h] loc_1340: lea edx, [rdi-2] mov rax, r8 lea rsi, [r11+rdx*4] nop word ptr [rax+rax+00h] loc_1350: movq xmm0, qword ptr [rax] pshufd xmm3, xmm0, 0E5h movd edx, xmm0 movd ecx, xmm3 cmp ecx, edx jge short loc_136E pshufd xmm0, xmm0, 0E1h movq qword ptr [rax], xmm0 loc_136E: add rax, 4 cmp rax, rsi jnz short loc_1350 sub edi, 1 cmp edi, 1 jz short loc_1390 loc_137F: cmp edi, 1 jg short loc_1340 sub edi, 1 jmp short loc_137F loc_1390: mov edi, r10d lea r11, [r9+4] nop word ptr [rax+rax+00000000h] loc_13A0: cmp edi, 1 jle loc_14B8 lea edx, [rdi-2] mov rax, r9 lea rsi, [r11+rdx*4] nop dword ptr [rax+rax+00h] loc_13B8: movq xmm0, qword ptr [rax] pshufd xmm4, xmm0, 0E5h movd edx, xmm0 movd ecx, xmm4 cmp ecx, edx jge short loc_13D6 pshufd xmm0, xmm0, 0E1h movq qword ptr [rax], xmm0 loc_13D6: add rax, 4 cmp rax, rsi jnz short loc_13B8 sub edi, 1 cmp edi, 1 jnz short loc_13A0 lea eax, [r10-1] cmp eax, 2 jbe loc_14CF mov edx, r10d xor eax, eax pxor xmm1, xmm1 shr edx, 2 shl rdx, 4 nop dword ptr [rax+00h] loc_1408: movdqu xmm0, xmmword ptr [r8+rax] movdqu xmm5, xmmword ptr [r9+rax] add rax, 10h psubd xmm0, xmm5 movdqa xmm2, xmm0 psrad xmm2, 1Fh pxor xmm0, xmm2 psubd xmm0, xmm2 paddd xmm1, xmm0 cmp rax, rdx jnz short loc_1408 movdqa xmm0, xmm1 psrldq xmm0, 8 paddd xmm1, xmm0 movdqa xmm0, xmm1 psrldq xmm0, 4 paddd xmm1, xmm0 movd eax, xmm1 test r10b, 3 jz short locret_14B3 mov edx, r10d and edx, 0FFFFFFFCh movsxd rdi, edx mov ecx, [r8+rdi*4] sub ecx, [r9+rdi*4] lea rsi, ds:0[rdi*4] mov edi, ecx neg edi cmovns ecx, edi add eax, ecx lea ecx, [rdx+1] cmp r10d, ecx jle short locret_14B3 loc_1484: mov ecx, [r8+rsi+4] sub ecx, [r9+rsi+4] mov edi, ecx neg edi cmovns ecx, edi add edx, 2 add eax, ecx cmp r10d, edx jle short locret_14B3 mov edx, [r8+rsi+8] sub edx, [r9+rsi+8] mov ecx, edx neg ecx cmovns edx, ecx add eax, edx retn locret_14B3: retn loc_14B8: sub edi, 1 jmp loc_13A0 loc_14C0: jnz short loc_14E2 mov edx, [r8] sub edx, [rsi] mov eax, edx neg eax cmovs eax, edx retn loc_14CF: mov edx, [r8] sub edx, [r9] mov eax, edx neg eax cmovs eax, edx xor edx, edx xor esi, esi jmp short loc_1484 loc_14E2: xor eax, eax retn
long long func0(__m128i *a1, __m128i *a2, int a3) { int v6; // edi __m128i *v7; // rax __m128i v8; // xmm0 int i; // edi __m128i *v10; // rax __m128i v11; // xmm0 unsigned long long v12; // rax __m128i v13; // xmm1 long long v14; // rdx __m128i v15; // xmm0 __m128i v16; // xmm5 __m128i v17; // xmm0 __m128i v18; // xmm2 __m128i v19; // xmm1 long long result; // rax signed int v21; // edx int v22; // ecx long long v23; // rsi int v24; // ecx int v25; // edx v6 = a3; if ( a3 <= 1 ) { if ( a3 == 1 ) { result = (unsigned int)(a2->m128i_i32[0] - a1->m128i_i32[0]); if ( a2->m128i_i32[0] - a1->m128i_i32[0] < 0 ) return (unsigned int)(a1->m128i_i32[0] - a2->m128i_i32[0]); } else { return 0LL; } } else { while ( 1 ) { v7 = a1; do { v8 = _mm_loadl_epi64(v7); if ( _mm_cvtsi128_si32(_mm_shuffle_epi32(v8, 229)) < _mm_cvtsi128_si32(v8) ) v7->m128i_i64[0] = _mm_shuffle_epi32(v8, 225).m128i_u64[0]; v7 = (__m128i *)((char *)v7 + 4); } while ( v7 != (__m128i *)((char *)a1->m128i_i64 + 4 * (unsigned int)(v6 - 2) + 4) ); if ( --v6 == 1 ) break; while ( v6 <= 1 ) --v6; } for ( i = a3; i != 1; --i ) { while ( i <= 1 ) --i; v10 = a2; do { v11 = _mm_loadl_epi64(v10); if ( _mm_cvtsi128_si32(_mm_shuffle_epi32(v11, 229)) < _mm_cvtsi128_si32(v11) ) v10->m128i_i64[0] = _mm_shuffle_epi32(v11, 225).m128i_u64[0]; v10 = (__m128i *)((char *)v10 + 4); } while ( v10 != (__m128i *)((char *)a2->m128i_i64 + 4 * (unsigned int)(i - 2) + 4) ); } if ( (unsigned int)(a3 - 1) <= 2 ) { LODWORD(result) = a2->m128i_i32[0] - a1->m128i_i32[0]; if ( (int)result < 0 ) LODWORD(result) = a1->m128i_i32[0] - a2->m128i_i32[0]; v21 = 0; v23 = 0LL; goto LABEL_23; } v12 = 0LL; v13 = 0LL; v14 = 16LL * ((unsigned int)a3 >> 2); do { v15 = _mm_loadu_si128(&a1[v12 / 0x10]); v16 = _mm_loadu_si128(&a2[v12 / 0x10]); v12 += 16LL; v17 = _mm_sub_epi32(v15, v16); v18 = _mm_srai_epi32(v17, 0x1Fu); v13 = _mm_add_epi32(v13, _mm_sub_epi32(_mm_xor_si128(v17, v18), v18)); } while ( v12 != v14 ); v19 = _mm_add_epi32(v13, _mm_srli_si128(v13, 8)); result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v19, _mm_srli_si128(v19, 4))); if ( (a3 & 3) != 0 ) { v21 = a3 & 0xFFFFFFFC; v22 = a1->m128i_i32[v21] - a2->m128i_i32[v21]; v23 = (int)(a3 & 0xFFFFFFFC); if ( a2->m128i_i32[v21] - a1->m128i_i32[v21] >= 0 ) v22 = a2->m128i_i32[v21] - a1->m128i_i32[v21]; result = (unsigned int)(v22 + result); if ( a3 > v21 + 1 ) { LABEL_23: v24 = a1->m128i_i32[v23 + 1] - a2->m128i_i32[v23 + 1]; if ( a2->m128i_i32[v23 + 1] - a1->m128i_i32[v23 + 1] >= 0 ) v24 = a2->m128i_i32[v23 + 1] - a1->m128i_i32[v23 + 1]; result = (unsigned int)(v24 + result); if ( a3 > v21 + 2 ) { v25 = a1->m128i_i32[v23 + 2] - a2->m128i_i32[v23 + 2]; if ( a2->m128i_i32[v23 + 2] - a1->m128i_i32[v23 + 2] >= 0 ) v25 = a2->m128i_i32[v23 + 2] - a1->m128i_i32[v23 + 2]; return (unsigned int)(v25 + result); } } } } return result; }
func0: ENDBR64 MOV R8,RDI MOV R9,RSI MOV R10D,EDX MOV EDI,EDX LEA R11,[R8 + 0x4] CMP EDX,0x1 JLE 0x001014c0 NOP dword ptr [RAX] LAB_00101340: LEA EDX,[RDI + -0x2] MOV RAX,R8 LEA RSI,[R11 + RDX*0x4] NOP word ptr [RAX + RAX*0x1] LAB_00101350: MOVQ XMM0,qword ptr [RAX] PSHUFD XMM3,XMM0,0xe5 MOVD EDX,XMM0 MOVD ECX,XMM3 CMP ECX,EDX JGE 0x0010136e PSHUFD XMM0,XMM0,0xe1 MOVQ qword ptr [RAX],XMM0 LAB_0010136e: ADD RAX,0x4 CMP RAX,RSI JNZ 0x00101350 SUB EDI,0x1 CMP EDI,0x1 JZ 0x00101390 LAB_0010137f: CMP EDI,0x1 JG 0x00101340 SUB EDI,0x1 JMP 0x0010137f LAB_00101390: MOV EDI,R10D LEA R11,[R9 + 0x4] NOP word ptr [RAX + RAX*0x1] LAB_001013a0: CMP EDI,0x1 JLE 0x001014b8 LEA EDX,[RDI + -0x2] MOV RAX,R9 LEA RSI,[R11 + RDX*0x4] NOP dword ptr [RAX + RAX*0x1] LAB_001013b8: MOVQ XMM0,qword ptr [RAX] PSHUFD XMM4,XMM0,0xe5 MOVD EDX,XMM0 MOVD ECX,XMM4 CMP ECX,EDX JGE 0x001013d6 PSHUFD XMM0,XMM0,0xe1 MOVQ qword ptr [RAX],XMM0 LAB_001013d6: ADD RAX,0x4 CMP RAX,RSI JNZ 0x001013b8 SUB EDI,0x1 CMP EDI,0x1 JNZ 0x001013a0 LEA EAX,[R10 + -0x1] CMP EAX,0x2 JBE 0x001014cf MOV EDX,R10D XOR EAX,EAX PXOR XMM1,XMM1 SHR EDX,0x2 SHL RDX,0x4 NOP dword ptr [RAX] LAB_00101408: MOVDQU XMM0,xmmword ptr [R8 + RAX*0x1] MOVDQU XMM5,xmmword ptr [R9 + RAX*0x1] ADD RAX,0x10 PSUBD XMM0,XMM5 MOVDQA XMM2,XMM0 PSRAD XMM2,0x1f PXOR XMM0,XMM2 PSUBD XMM0,XMM2 PADDD XMM1,XMM0 CMP RAX,RDX JNZ 0x00101408 MOVDQA XMM0,XMM1 PSRLDQ XMM0,0x8 PADDD XMM1,XMM0 MOVDQA XMM0,XMM1 PSRLDQ XMM0,0x4 PADDD XMM1,XMM0 MOVD EAX,XMM1 TEST R10B,0x3 JZ 0x001014b3 MOV EDX,R10D AND EDX,0xfffffffc MOVSXD RDI,EDX MOV ECX,dword ptr [R8 + RDI*0x4] SUB ECX,dword ptr [R9 + RDI*0x4] LEA RSI,[RDI*0x4] MOV EDI,ECX NEG EDI CMOVNS ECX,EDI ADD EAX,ECX LEA ECX,[RDX + 0x1] CMP R10D,ECX JLE 0x001014b3 LAB_00101484: MOV ECX,dword ptr [R8 + RSI*0x1 + 0x4] SUB ECX,dword ptr [R9 + RSI*0x1 + 0x4] MOV EDI,ECX NEG EDI CMOVNS ECX,EDI ADD EDX,0x2 ADD EAX,ECX CMP R10D,EDX JLE 0x001014b3 MOV EDX,dword ptr [R8 + RSI*0x1 + 0x8] SUB EDX,dword ptr [R9 + RSI*0x1 + 0x8] MOV ECX,EDX NEG ECX CMOVNS EDX,ECX ADD EAX,EDX RET LAB_001014b3: RET LAB_001014b8: SUB EDI,0x1 JMP 0x001013a0 LAB_001014c0: JNZ 0x001014e2 MOV EDX,dword ptr [R8] SUB EDX,dword ptr [RSI] MOV EAX,EDX NEG EAX CMOVS EAX,EDX RET LAB_001014cf: MOV EDX,dword ptr [R8] SUB EDX,dword ptr [R9] MOV EAX,EDX NEG EAX CMOVS EAX,EDX XOR EDX,EDX XOR ESI,ESI JMP 0x00101484 LAB_001014e2: XOR EAX,EAX RET
int func0(int *param_1,int *param_2,uint param_3) { int *piVar1; int *piVar2; long lVar3; uint uVar4; uint uVar5; int iVar6; int iVar7; int iVar8; int iVar9; uint uVar10; uint uVar11; uVar4 = param_3; if ((int)param_3 < 2) { if (param_3 == 1) { iVar7 = *param_1 - *param_2; iVar6 = -iVar7; if (0 < iVar7) { iVar6 = iVar7; } return iVar6; } return 0; } while( true ) { piVar2 = param_1; do { iVar6 = (int)*(int8 *)piVar2; iVar7 = (int)((ulong)*(int8 *)piVar2 >> 0x20); if (iVar7 < iVar6) { *(ulong *)piVar2 = CONCAT44(iVar6,iVar7); } piVar2 = piVar2 + 1; } while (piVar2 != param_1 + (ulong)(uVar4 - 2) + 1); uVar4 = uVar4 - 1; uVar5 = param_3; if (uVar4 == 1) break; for (; (int)uVar4 < 2; uVar4 = uVar4 - 1) { } } do { for (; (int)uVar5 < 2; uVar5 = uVar5 - 1) { } piVar2 = param_2; do { iVar6 = (int)*(int8 *)piVar2; iVar7 = (int)((ulong)*(int8 *)piVar2 >> 0x20); if (iVar7 < iVar6) { *(ulong *)piVar2 = CONCAT44(iVar6,iVar7); } piVar2 = piVar2 + 1; } while (piVar2 != param_2 + (ulong)(uVar5 - 2) + 1); uVar5 = uVar5 - 1; } while (uVar5 != 1); if (param_3 - 1 < 3) { iVar7 = *param_1 - *param_2; iVar6 = -iVar7; if (0 < iVar7) { iVar6 = iVar7; } uVar4 = 0; lVar3 = 0; } else { lVar3 = 0; iVar6 = 0; iVar7 = 0; iVar8 = 0; iVar9 = 0; do { piVar2 = (int *)((long)param_1 + lVar3); piVar1 = (int *)((long)param_2 + lVar3); lVar3 = lVar3 + 0x10; uVar4 = *piVar2 - *piVar1 >> 0x1f; uVar5 = piVar2[1] - piVar1[1] >> 0x1f; uVar10 = piVar2[2] - piVar1[2] >> 0x1f; uVar11 = piVar2[3] - piVar1[3] >> 0x1f; iVar6 = iVar6 + ((*piVar2 - *piVar1 ^ uVar4) - uVar4); iVar7 = iVar7 + ((piVar2[1] - piVar1[1] ^ uVar5) - uVar5); iVar8 = iVar8 + ((piVar2[2] - piVar1[2] ^ uVar10) - uVar10); iVar9 = iVar9 + ((piVar2[3] - piVar1[3] ^ uVar11) - uVar11); } while (lVar3 != (ulong)(param_3 >> 2) << 4); iVar6 = iVar6 + iVar8 + iVar7 + iVar9; if ((param_3 & 3) == 0) { return iVar6; } uVar4 = param_3 & 0xfffffffc; lVar3 = (long)(int)uVar4; iVar7 = param_1[lVar3] - param_2[lVar3]; lVar3 = lVar3 * 4; if (iVar7 < 1) { iVar7 = -iVar7; } iVar6 = iVar6 + iVar7; if ((int)param_3 <= (int)(uVar4 + 1)) { return iVar6; } } iVar7 = *(int *)((long)param_1 + lVar3 + 4) - *(int *)((long)param_2 + lVar3 + 4); if (iVar7 < 1) { iVar7 = -iVar7; } if ((int)(uVar4 + 2) < (int)param_3) { iVar8 = *(int *)((long)param_1 + lVar3 + 8) - *(int *)((long)param_2 + lVar3 + 8); if (iVar8 < 1) { iVar8 = -iVar8; } return iVar6 + iVar7 + iVar8; } return iVar6 + iVar7; }
6,520
func0
#include <stdio.h> #include <assert.h> #include <math.h>
int func0(int n) { int fact = 1; for (int i = 2; i <= n; i++) { fact = fact * i; while (fact % 10 == 0) { fact = fact / 10; } } while (fact >= 10) { fact = fact / 10; } return floor(fact); }
int main() { assert(func0(5) == 1); assert(func0(10) == 3); assert(func0(7) == 5); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) movl $0x1,-0x8(%rbp) movl $0x2,-0x4(%rbp) jmp 11c0 <func0+0x77> mov -0x8(%rbp),%eax imul -0x4(%rbp),%eax mov %eax,-0x8(%rbp) jmp 118e <func0+0x45> mov -0x8(%rbp),%eax movslq %eax,%rdx imul $0x66666667,%rdx,%rdx shr $0x20,%rdx sar $0x2,%edx sar $0x1f,%eax sub %eax,%edx mov %edx,%eax mov %eax,-0x8(%rbp) mov -0x8(%rbp),%ecx movslq %ecx,%rax imul $0x66666667,%rax,%rax shr $0x20,%rax mov %eax,%edx sar $0x2,%edx mov %ecx,%eax sar $0x1f,%eax sub %eax,%edx mov %edx,%eax shl $0x2,%eax add %edx,%eax add %eax,%eax sub %eax,%ecx mov %ecx,%edx test %edx,%edx je 1170 <func0+0x27> addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x14(%rbp),%eax jle 1164 <func0+0x1b> jmp 11e8 <func0+0x9f> mov -0x8(%rbp),%eax movslq %eax,%rdx imul $0x66666667,%rdx,%rdx shr $0x20,%rdx sar $0x2,%edx sar $0x1f,%eax sub %eax,%edx mov %edx,%eax mov %eax,-0x8(%rbp) cmpl $0x9,-0x8(%rbp) jg 11ca <func0+0x81> cvtsi2sdl -0x8(%rbp),%xmm0 cvttsd2si %xmm0,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_14], edi mov [rbp+var_8], 1 mov [rbp+var_4], 2 jmp short loc_11C0 loc_1164: mov eax, [rbp+var_8] imul eax, [rbp+var_4] mov [rbp+var_8], eax jmp short loc_118E loc_1170: mov eax, [rbp+var_8] movsxd rdx, eax imul rdx, 66666667h shr rdx, 20h mov ecx, edx sar ecx, 2 cdq mov eax, ecx sub eax, edx mov [rbp+var_8], eax loc_118E: mov ecx, [rbp+var_8] movsxd rax, ecx imul rax, 66666667h shr rax, 20h mov edx, eax sar edx, 2 mov eax, ecx sar eax, 1Fh sub edx, eax mov eax, edx shl eax, 2 add eax, edx add eax, eax sub ecx, eax mov edx, ecx test edx, edx jz short loc_1170 add [rbp+var_4], 1 loc_11C0: mov eax, [rbp+var_4] cmp eax, [rbp+var_14] jle short loc_1164 jmp short loc_11E8 loc_11CA: mov eax, [rbp+var_8] movsxd rdx, eax imul rdx, 66666667h shr rdx, 20h mov ecx, edx sar ecx, 2 cdq mov eax, ecx sub eax, edx mov [rbp+var_8], eax loc_11E8: cmp [rbp+var_8], 9 jg short loc_11CA pxor xmm0, xmm0 cvtsi2sd xmm0, [rbp+var_8] cvttsd2si eax, xmm0 pop rbp retn
long long func0(int a1) { int v2; // [rsp+Ch] [rbp-8h] int i; // [rsp+10h] [rbp-4h] v2 = 1; for ( i = 2; i <= a1; ++i ) { for ( v2 *= i; !(v2 % 10); v2 /= 10 ) ; } while ( v2 > 9 ) v2 /= 10; return (unsigned int)(int)(double)v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x8],0x1 MOV dword ptr [RBP + -0x4],0x2 JMP 0x001011c0 LAB_00101164: MOV EAX,dword ptr [RBP + -0x8] IMUL EAX,dword ptr [RBP + -0x4] MOV dword ptr [RBP + -0x8],EAX JMP 0x0010118e LAB_00101170: MOV EAX,dword ptr [RBP + -0x8] MOVSXD RDX,EAX IMUL RDX,RDX,0x66666667 SHR RDX,0x20 MOV ECX,EDX SAR ECX,0x2 CDQ MOV EAX,ECX SUB EAX,EDX MOV dword ptr [RBP + -0x8],EAX LAB_0010118e: MOV ECX,dword ptr [RBP + -0x8] MOVSXD RAX,ECX IMUL RAX,RAX,0x66666667 SHR RAX,0x20 MOV EDX,EAX SAR EDX,0x2 MOV EAX,ECX SAR EAX,0x1f SUB EDX,EAX MOV EAX,EDX SHL EAX,0x2 ADD EAX,EDX ADD EAX,EAX SUB ECX,EAX MOV EDX,ECX TEST EDX,EDX JZ 0x00101170 ADD dword ptr [RBP + -0x4],0x1 LAB_001011c0: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x14] JLE 0x00101164 JMP 0x001011e8 LAB_001011ca: MOV EAX,dword ptr [RBP + -0x8] MOVSXD RDX,EAX IMUL RDX,RDX,0x66666667 SHR RDX,0x20 MOV ECX,EDX SAR ECX,0x2 CDQ MOV EAX,ECX SUB EAX,EDX MOV dword ptr [RBP + -0x8],EAX LAB_001011e8: CMP dword ptr [RBP + -0x8],0x9 JG 0x001011ca PXOR XMM0,XMM0 CVTSI2SD XMM0,dword ptr [RBP + -0x8] CVTTSD2SI EAX,XMM0 POP RBP RET
int func0(int param_1) { int4 local_10; int4 local_c; local_10 = 1; for (local_c = 2; local_c <= param_1; local_c = local_c + 1) { for (local_10 = local_10 * local_c; local_10 % 10 == 0; local_10 = local_10 / 10) { } } for (; 9 < local_10; local_10 = local_10 / 10) { } return (int)(double)local_10; }
6,521
func0
#include <stdio.h> #include <assert.h> #include <math.h>
int func0(int n) { int fact = 1; for (int i = 2; i <= n; i++) { fact = fact * i; while (fact % 10 == 0) { fact = fact / 10; } } while (fact >= 10) { fact = fact / 10; } return floor(fact); }
int main() { assert(func0(5) == 1); assert(func0(10) == 3); assert(func0(7) == 5); return 0; }
O1
c
func0: endbr64 lea 0x1(%rdi),%r9d mov $0x2,%r8d mov $0x2,%eax cmp $0x1,%edi jle 11c1 <func0+0x78> add $0x1,%r8d cmp %r9d,%r8d je 11c7 <func0+0x7e> imul %r8d,%eax movslq %eax,%rdx imul $0x66666667,%rdx,%rdx sar $0x22,%rdx mov %eax,%ecx sar $0x1f,%ecx sub %ecx,%edx lea (%rdx,%rdx,4),%edx add %edx,%edx cmp %edx,%eax jne 1161 <func0+0x18> movslq %eax,%rdx imul $0x66666667,%rdx,%rdx sar $0x22,%rdx sar $0x1f,%eax sub %eax,%edx mov %edx,%eax movslq %edx,%rcx imul $0x66666667,%rcx,%rcx sar $0x22,%rcx mov %edx,%esi sar $0x1f,%esi sub %esi,%ecx lea (%rcx,%rcx,4),%ecx add %ecx,%ecx cmp %ecx,%edx je 118c <func0+0x43> jmp 1161 <func0+0x18> mov $0x1,%eax retq cmp $0x9,%eax jle 11e8 <func0+0x9f> mov %eax,%ecx movslq %eax,%rdx imul $0x66666667,%rdx,%rdx sar $0x22,%rdx sar $0x1f,%eax sub %eax,%edx mov %edx,%eax cmp $0x63,%ecx jg 11cc <func0+0x83> retq
func0: endbr64 lea r9d, [rdi+1] mov r8d, 2 mov ecx, 2 cmp edi, 1 jg short loc_11C0 mov ecx, 1 jmp loc_11EC loc_116B: imul ecx, r8d movsxd rax, ecx imul rax, 66666667h sar rax, 22h mov edx, ecx sar edx, 1Fh sub eax, edx lea eax, [rax+rax*4] add eax, eax cmp ecx, eax jnz short loc_11C0 loc_118D: movsxd rax, ecx imul rax, 66666667h sar rax, 22h sar ecx, 1Fh sub eax, ecx mov ecx, eax movsxd rdx, eax imul rdx, 66666667h sar rdx, 22h mov esi, eax sar esi, 1Fh sub edx, esi lea edx, [rdx+rdx*4] add edx, edx cmp eax, edx jz short loc_118D loc_11C0: add r8d, 1 cmp r8d, r9d jnz short loc_116B cmp ecx, 9 jle short loc_11EC loc_11CE: mov edx, ecx movsxd rax, ecx imul rax, 66666667h sar rax, 22h mov esi, ecx sar esi, 1Fh sub eax, esi mov ecx, eax cmp edx, 63h ; 'c' jg short loc_11CE loc_11EC: mov eax, ecx retn
long long func0(int a1) { int v1; // r8d int v2; // ecx int v3; // edx v1 = 2; v2 = 2; if ( a1 > 1 ) { while ( ++v1 != a1 + 1 ) { for ( v2 *= v1; v2 == 10 * (v2 / 10); v2 /= 10 ) ; } if ( v2 > 9 ) { do { v3 = v2; v2 /= 10; } while ( v3 > 99 ); } } else { return 1; } return (unsigned int)v2; }
func0: ENDBR64 LEA R9D,[RDI + 0x1] MOV R8D,0x2 MOV ECX,0x2 CMP EDI,0x1 JG 0x001011c0 MOV ECX,0x1 JMP 0x001011ec LAB_0010116b: IMUL ECX,R8D MOVSXD RAX,ECX IMUL RAX,RAX,0x66666667 SAR RAX,0x22 MOV EDX,ECX SAR EDX,0x1f SUB EAX,EDX LEA EAX,[RAX + RAX*0x4] ADD EAX,EAX CMP ECX,EAX JNZ 0x001011c0 LAB_0010118d: MOVSXD RAX,ECX IMUL RAX,RAX,0x66666667 SAR RAX,0x22 SAR ECX,0x1f SUB EAX,ECX MOV ECX,EAX MOVSXD RDX,EAX IMUL RDX,RDX,0x66666667 SAR RDX,0x22 MOV ESI,EAX SAR ESI,0x1f SUB EDX,ESI LEA EDX,[RDX + RDX*0x4] ADD EDX,EDX CMP EAX,EDX JZ 0x0010118d LAB_001011c0: ADD R8D,0x1 CMP R8D,R9D JNZ 0x0010116b CMP ECX,0x9 JLE 0x001011ec LAB_001011ce: MOV EDX,ECX MOVSXD RAX,ECX IMUL RAX,RAX,0x66666667 SAR RAX,0x22 MOV ESI,ECX SAR ESI,0x1f SUB EAX,ESI MOV ECX,EAX CMP EDX,0x63 JG 0x001011ce LAB_001011ec: MOV EAX,ECX RET
int func0(int param_1) { bool bVar1; int iVar2; int iVar3; iVar3 = 2; iVar2 = 2; if (param_1 < 2) { iVar2 = 1; } else { while (iVar3 = iVar3 + 1, iVar3 != param_1 + 1) { iVar2 = iVar2 * iVar3; if (iVar2 == (iVar2 / 10) * 10) { do { iVar2 = iVar2 / 10; } while (iVar2 == (iVar2 / 10) * 10); } } iVar3 = iVar2; if (9 < iVar2) { do { iVar2 = iVar3 / 10; bVar1 = 99 < iVar3; iVar3 = iVar2; } while (bVar1); } } return iVar2; }
6,522
func0
#include <stdio.h> #include <assert.h> #include <math.h>
int func0(int n) { int fact = 1; for (int i = 2; i <= n; i++) { fact = fact * i; while (fact % 10 == 0) { fact = fact / 10; } } while (fact >= 10) { fact = fact / 10; } return floor(fact); }
int main() { assert(func0(5) == 1); assert(func0(10) == 3); assert(func0(7) == 5); return 0; }
O2
c
func0: endbr64 lea 0x1(%rdi),%esi mov $0x2,%ecx mov $0x2,%eax cmp $0x1,%edi jle 13b3 <func0+0x83> nopw %cs:0x0(%rax,%rax,1) add $0x1,%ecx cmp %esi,%ecx je 1390 <func0+0x60> imul %ecx,%eax nopw 0x0(%rax,%rax,1) imul $0xcccccccd,%eax,%edx add $0x19999998,%edx ror %edx cmp $0x19999998,%edx ja 1350 <func0+0x20> movslq %eax,%rdx sar $0x1f,%eax imul $0x66666667,%rdx,%rdx sar $0x22,%rdx sub %eax,%edx mov %edx,%eax jmp 1360 <func0+0x30> nopl (%rax) cmp $0x9,%eax jle 13b2 <func0+0x82> mov $0xcccccccd,%ecx nopw 0x0(%rax,%rax,1) mov %eax,%eax mov %rax,%rdx imul %rcx,%rax shr $0x23,%rax cmp $0x63,%edx jg 13a0 <func0+0x70> retq mov $0x1,%eax retq nopl 0x0(%rax)
func0: endbr64 lea esi, [rdi+1] mov ecx, 2 mov r8d, 2 cmp edi, 1 jle short loc_1277 nop word ptr [rax+rax+00000000h] loc_1210: add ecx, 1 cmp ecx, esi jz short loc_1250 imul r8d, ecx nop dword ptr [rax+rax+00h] loc_1220: imul eax, r8d, 0CCCCCCCDh add eax, 19999998h ror eax, 1 cmp eax, 19999998h ja short loc_1210 movsxd rax, r8d mov edx, r8d imul rax, 66666667h sar edx, 1Fh sar rax, 22h sub eax, edx mov r8d, eax jmp short loc_1220 loc_1250: cmp r8d, 9 jle short loc_1273 mov edx, 0CCCCCCCDh nop dword ptr [rax+rax+00h] loc_1260: mov r8d, r8d mov rax, r8 imul r8, rdx shr r8, 23h cmp eax, 63h ; 'c' jg short loc_1260 loc_1273: mov eax, r8d retn loc_1277: mov r8d, 1 mov eax, r8d retn
long long func0(int a1) { int v1; // ecx int v2; // r8d int v3; // eax v1 = 2; v2 = 2; if ( a1 <= 1 ) return 1LL; while ( ++v1 != a1 + 1 ) { for ( v2 *= v1; __ROR4__(-858993459 * v2 + 429496728, 1) <= 0x19999998u; v2 /= 10 ) ; } if ( v2 > 9 ) { do { v3 = v2; v2 /= 0xAu; } while ( v3 > 99 ); } return (unsigned int)v2; }
func0: ENDBR64 LEA ESI,[RDI + 0x1] MOV ECX,0x2 MOV R8D,0x2 CMP EDI,0x1 JLE 0x00101277 NOP word ptr [RAX + RAX*0x1] LAB_00101210: ADD ECX,0x1 CMP ECX,ESI JZ 0x00101250 IMUL R8D,ECX NOP dword ptr [RAX + RAX*0x1] LAB_00101220: IMUL EAX,R8D,-0x33333333 ADD EAX,0x19999998 ROR EAX,0x1 CMP EAX,0x19999998 JA 0x00101210 MOVSXD RAX,R8D MOV EDX,R8D IMUL RAX,RAX,0x66666667 SAR EDX,0x1f SAR RAX,0x22 SUB EAX,EDX MOV R8D,EAX JMP 0x00101220 LAB_00101250: CMP R8D,0x9 JLE 0x00101273 MOV EDX,0xcccccccd NOP dword ptr [RAX + RAX*0x1] LAB_00101260: MOV R8D,R8D MOV RAX,R8 IMUL R8,RDX SHR R8,0x23 CMP EAX,0x63 JG 0x00101260 LAB_00101273: MOV EAX,R8D RET LAB_00101277: MOV R8D,0x1 MOV EAX,R8D RET
uint func0(int param_1) { bool bVar1; uint uVar2; int iVar3; uint uVar4; iVar3 = 2; uVar4 = 2; if (param_1 < 2) { return 1; } while (iVar3 = iVar3 + 1, iVar3 != param_1 + 1) { uVar4 = uVar4 * iVar3; while (uVar2 = uVar4 * -0x33333333 + 0x19999998, (uVar2 >> 1 | (uint)((uVar2 & 1) != 0) << 0x1f) < 0x19999999) { uVar4 = (int)uVar4 / 10; } } uVar2 = uVar4; if (9 < (int)uVar4) { do { uVar2 = uVar4 / 10; bVar1 = 99 < (int)uVar4; uVar4 = uVar2; } while (bVar1); } return uVar2; }
6,523
func0
#include <stdio.h> #include <assert.h> #include <math.h>
int func0(int n) { int fact = 1; for (int i = 2; i <= n; i++) { fact = fact * i; while (fact % 10 == 0) { fact = fact / 10; } } while (fact >= 10) { fact = fact / 10; } return floor(fact); }
int main() { assert(func0(5) == 1); assert(func0(10) == 3); assert(func0(7) == 5); return 0; }
O3
c
func0: endbr64 cmp $0x1,%edi jle 138c <func0+0x7c> lea 0x1(%rdi),%esi mov $0x2,%eax mov $0x3,%ecx cmp $0x2,%edi je 138b <func0+0x7b> nopl 0x0(%rax,%rax,1) imul %ecx,%eax jmp 134d <func0+0x3d> nopl (%rax) movslq %eax,%rdx sar $0x1f,%eax imul $0x66666667,%rdx,%rdx sar $0x22,%rdx sub %eax,%edx mov %edx,%eax imul $0xcccccccd,%eax,%edx add $0x19999998,%edx ror %edx cmp $0x19999998,%edx jbe 1338 <func0+0x28> add $0x1,%ecx cmp %ecx,%esi jne 1330 <func0+0x20> cmp $0x9,%eax jle 138b <func0+0x7b> mov $0xcccccccd,%ecx nopl 0x0(%rax) mov %eax,%eax mov %rax,%rdx imul %rcx,%rax shr $0x23,%rax cmp $0x63,%edx jg 1378 <func0+0x68> retq retq mov $0x1,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 cmp edi, 1 jle short loc_1393 add edi, 1 mov esi, 2 mov eax, 1 nop word ptr [rax+rax+00000000h] loc_1330: imul eax, esi jmp short loc_134F loc_1338: movsxd rdx, eax sar eax, 1Fh imul rdx, 66666667h mov ecx, eax sar rdx, 22h mov eax, edx sub eax, ecx loc_134F: imul edx, eax, 0CCCCCCCDh add edx, 19999998h ror edx, 1 cmp edx, 19999998h jbe short loc_1338 add esi, 1 cmp edi, esi jnz short loc_1330 cmp eax, 9 jle short locret_1398 mov ecx, 0CCCCCCCDh nop word ptr [rax+rax+00000000h] loc_1380: mov eax, eax mov rdx, rax imul rax, rcx shr rax, 23h cmp edx, 63h ; 'c' jg short loc_1380 retn loc_1393: mov eax, 1 locret_1398: retn
unsigned long long func0(int a1) { int v1; // edi int v2; // esi unsigned long long result; // rax int v4; // edx if ( a1 <= 1 ) return 1LL; v1 = a1 + 1; v2 = 2; LODWORD(result) = 1; do { for ( result = (unsigned int)(v2 * result); __ROR4__(-858993459 * result + 429496728, 1) <= 0x19999998u; result = (unsigned int)((int)result / 10) ) { ; } ++v2; } while ( v1 != v2 ); if ( (int)result > 9 ) { do { v4 = result; result = (unsigned int)result / 0xAuLL; } while ( v4 > 99 ); } return result; }
func0: ENDBR64 CMP EDI,0x1 JLE 0x00101393 ADD EDI,0x1 MOV ESI,0x2 MOV EAX,0x1 NOP word ptr CS:[RAX + RAX*0x1] LAB_00101330: IMUL EAX,ESI JMP 0x0010134f LAB_00101338: MOVSXD RDX,EAX SAR EAX,0x1f IMUL RDX,RDX,0x66666667 MOV ECX,EAX SAR RDX,0x22 MOV EAX,EDX SUB EAX,ECX LAB_0010134f: IMUL EDX,EAX,-0x33333333 ADD EDX,0x19999998 ROR EDX,0x1 CMP EDX,0x19999998 JBE 0x00101338 ADD ESI,0x1 CMP EDI,ESI JNZ 0x00101330 CMP EAX,0x9 JLE 0x00101398 MOV ECX,0xcccccccd NOP word ptr CS:[RAX + RAX*0x1] LAB_00101380: MOV EAX,EAX MOV RDX,RAX IMUL RAX,RCX SHR RAX,0x23 CMP EDX,0x63 JG 0x00101380 RET LAB_00101393: MOV EAX,0x1 LAB_00101398: RET
ulong func0(int param_1) { uint uVar1; ulong uVar2; ulong uVar3; uint uVar4; int iVar5; if (param_1 < 2) { uVar2 = 1; } else { iVar5 = 2; uVar2 = 1; do { uVar1 = (int)uVar2 * iVar5; while (uVar2 = (ulong)uVar1, uVar4 = uVar1 * -0x33333333 + 0x19999998, (uVar4 >> 1 | (uint)((uVar4 & 1) != 0) << 0x1f) < 0x19999999) { uVar1 = (int)uVar1 / 10; } iVar5 = iVar5 + 1; } while (param_1 + 1 != iVar5); if (9 < (int)uVar1) { do { uVar3 = uVar2 / 10; iVar5 = (int)uVar2; uVar2 = uVar3; } while (99 < iVar5); return uVar3; } } return uVar2; }
6,524
func0
#include <assert.h> #include <stdio.h>
int func0(int list1[], int length) { int max_val = 0; int result = list1[0]; for (int i = 0; i < length; i++) { int occu = 0; for (int j = 0; j < length; j++) { if (list1[j] == list1[i]) { occu++; } } if (occu > max_val) { max_val = occu; result = list1[i]; } } return result; }
int main() { int list1[] = {2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2}; int list2[] = {1, 3, 5, 7, 1, 3, 13, 15, 17, 5, 7, 9, 1, 11}; int list3[] = {1, 2, 3, 2, 4, 5, 1, 1, 1}; assert(func0(list1, sizeof(list1)/sizeof(list1[0])) == 2); assert(func0(list2, sizeof(list2)/sizeof(list2[0])) == 1); assert(func0(list3, sizeof(list3)/sizeof(list3[0])) == 1); printf("All tests passed successfully.\n"); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) movl $0x0,-0x14(%rbp) mov -0x28(%rbp),%rax mov (%rax),%eax mov %eax,-0x10(%rbp) movl $0x0,-0xc(%rbp) jmp 122c <func0+0xa3> movl $0x0,-0x8(%rbp) movl $0x0,-0x4(%rbp) jmp 11f9 <func0+0x70> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x28(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jne 11f5 <func0+0x6c> addl $0x1,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x2c(%rbp),%eax jl 11c1 <func0+0x38> mov -0x8(%rbp),%eax cmp -0x14(%rbp),%eax jle 1228 <func0+0x9f> mov -0x8(%rbp),%eax mov %eax,-0x14(%rbp) mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax mov %eax,-0x10(%rbp) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x2c(%rbp),%eax jl 11b1 <func0+0x28> mov -0x10(%rbp),%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 rax, [rbp+var_28] mov eax, [rax] mov [rbp+var_10], eax mov [rbp+var_C], 0 jmp short loc_122C loc_11B1: mov [rbp+var_8], 0 mov [rbp+var_4], 0 jmp short loc_11F9 loc_11C1: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov edx, [rax] mov eax, [rbp+var_C] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rcx mov eax, [rax] cmp edx, eax jnz short loc_11F5 add [rbp+var_8], 1 loc_11F5: add [rbp+var_4], 1 loc_11F9: mov eax, [rbp+var_4] cmp eax, [rbp+var_2C] jl short loc_11C1 mov eax, [rbp+var_8] cmp eax, [rbp+var_14] jle short loc_1228 mov eax, [rbp+var_8] mov [rbp+var_14], eax mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] mov [rbp+var_10], eax loc_1228: add [rbp+var_C], 1 loc_122C: mov eax, [rbp+var_C] cmp eax, [rbp+var_2C] jl loc_11B1 mov eax, [rbp+var_10] pop rbp retn
long long func0(unsigned int *a1, int a2) { int v3; // [rsp+18h] [rbp-14h] unsigned int v4; // [rsp+1Ch] [rbp-10h] int i; // [rsp+20h] [rbp-Ch] int v6; // [rsp+24h] [rbp-8h] int j; // [rsp+28h] [rbp-4h] v3 = 0; v4 = *a1; for ( i = 0; i < a2; ++i ) { v6 = 0; for ( j = 0; j < a2; ++j ) { if ( a1[j] == a1[i] ) ++v6; } if ( v6 > v3 ) { v3 = v6; v4 = a1[i]; } } return v4; }
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 RAX,qword ptr [RBP + -0x28] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x10],EAX MOV dword ptr [RBP + -0xc],0x0 JMP 0x0010122c LAB_001011b1: MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x0 JMP 0x001011f9 LAB_001011c1: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JNZ 0x001011f5 ADD dword ptr [RBP + -0x8],0x1 LAB_001011f5: ADD dword ptr [RBP + -0x4],0x1 LAB_001011f9: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001011c1 MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x14] JLE 0x00101228 MOV EAX,dword ptr [RBP + -0x8] MOV dword ptr [RBP + -0x14],EAX MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x10],EAX LAB_00101228: ADD dword ptr [RBP + -0xc],0x1 LAB_0010122c: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001011b1 MOV EAX,dword ptr [RBP + -0x10] POP RBP RET
int4 func0(int4 *param_1,int param_2) { int local_1c; int4 local_18; int local_14; int local_10; int local_c; local_1c = 0; local_18 = *param_1; for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 1) { local_10 = 0; for (local_c = 0; local_c < param_2; local_c = local_c + 1) { if (param_1[local_c] == param_1[local_14]) { local_10 = local_10 + 1; } } if (local_1c < local_10) { local_1c = local_10; local_18 = param_1[local_14]; } } return local_18; }
6,525
func0
#include <assert.h> #include <stdio.h>
int func0(int list1[], int length) { int max_val = 0; int result = list1[0]; for (int i = 0; i < length; i++) { int occu = 0; for (int j = 0; j < length; j++) { if (list1[j] == list1[i]) { occu++; } } if (occu > max_val) { max_val = occu; result = list1[i]; } } return result; }
int main() { int list1[] = {2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2}; int list2[] = {1, 3, 5, 7, 1, 3, 13, 15, 17, 5, 7, 9, 1, 11}; int list3[] = {1, 2, 3, 2, 4, 5, 1, 1, 1}; assert(func0(list1, sizeof(list1)/sizeof(list1[0])) == 2); assert(func0(list2, sizeof(list2)/sizeof(list2[0])) == 1); assert(func0(list3, sizeof(list3)/sizeof(list3[0])) == 1); printf("All tests passed successfully.\n"); return 0; }
O1
c
func0: endbr64 mov (%rdi),%r11d test %esi,%esi jle 11da <func0+0x51> mov %rdi,%r10 lea -0x1(%rsi),%eax lea 0x4(%rdi,%rax,4),%r8 mov $0x0,%r9d jmp 11b0 <func0+0x27> add $0x4,%rdi cmp %r8,%rdi je 11da <func0+0x51> mov (%rdi),%esi mov %r10,%rax mov $0x0,%edx cmp %esi,(%rax) sete %cl movzbl %cl,%ecx add %ecx,%edx add $0x4,%rax cmp %r8,%rax jne 11ba <func0+0x31> cmp %r9d,%edx jle 11a7 <func0+0x1e> mov %esi,%r11d mov %edx,%r9d jmp 11a7 <func0+0x1e> mov %r11d,%eax retq
func0: endbr64 mov r11d, [rdi] test esi, esi jle short loc_11DB lea eax, [rsi-1] lea r8, [rdi+rax*4+4] mov r9, rdi mov r10d, 0 jmp short loc_11B0 loc_11A7: add r9, 4 cmp r9, r8 jz short loc_11DB loc_11B0: mov esi, [r9] mov rax, rdi mov edx, 0 loc_11BB: cmp [rax], esi setz cl movzx ecx, cl add edx, ecx add rax, 4 cmp rax, r8 jnz short loc_11BB cmp edx, r10d jle short loc_11A7 mov r11d, esi mov r10d, edx jmp short loc_11A7 loc_11DB: mov eax, r11d retn
long long func0(unsigned int *a1, int a2) { unsigned int v2; // r11d long long v3; // r8 unsigned int *v4; // r9 int v5; // r10d unsigned int *v6; // rax int v7; // edx v2 = *a1; if ( a2 > 0 ) { v3 = (long long)&a1[a2 - 1 + 1]; v4 = a1; v5 = 0; do { v6 = a1; v7 = 0; do v7 += *v6++ == *v4; while ( v6 != (unsigned int *)v3 ); if ( v7 > v5 ) { v2 = *v4; v5 = v7; } ++v4; } while ( v4 != (unsigned int *)v3 ); } return v2; }
func0: ENDBR64 MOV R11D,dword ptr [RDI] TEST ESI,ESI JLE 0x001011db LEA EAX,[RSI + -0x1] LEA R8,[RDI + RAX*0x4 + 0x4] MOV R9,RDI MOV R10D,0x0 JMP 0x001011b0 LAB_001011a7: ADD R9,0x4 CMP R9,R8 JZ 0x001011db LAB_001011b0: MOV ESI,dword ptr [R9] MOV RAX,RDI MOV EDX,0x0 LAB_001011bb: CMP dword ptr [RAX],ESI SETZ CL MOVZX ECX,CL ADD EDX,ECX ADD RAX,0x4 CMP RAX,R8 JNZ 0x001011bb CMP EDX,R10D JLE 0x001011a7 MOV R11D,ESI MOV R10D,EDX JMP 0x001011a7 LAB_001011db: MOV EAX,R11D RET
int func0(int *param_1,int param_2) { int *piVar1; int iVar2; int *piVar3; int iVar4; int iVar5; iVar5 = *param_1; if (0 < param_2) { iVar4 = 0; piVar3 = param_1; do { iVar2 = 0; piVar1 = param_1; do { iVar2 = iVar2 + (uint)(*piVar1 == *piVar3); piVar1 = piVar1 + 1; } while (piVar1 != param_1 + (ulong)(param_2 - 1) + 1); if (iVar4 < iVar2) { iVar5 = *piVar3; iVar4 = iVar2; } piVar3 = piVar3 + 1; } while (piVar3 != param_1 + (ulong)(param_2 - 1) + 1); } return iVar5; }
6,526
func0
#include <assert.h> #include <stdio.h>
int func0(int list1[], int length) { int max_val = 0; int result = list1[0]; for (int i = 0; i < length; i++) { int occu = 0; for (int j = 0; j < length; j++) { if (list1[j] == list1[i]) { occu++; } } if (occu > max_val) { max_val = occu; result = list1[i]; } } return result; }
int main() { int list1[] = {2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2}; int list2[] = {1, 3, 5, 7, 1, 3, 13, 15, 17, 5, 7, 9, 1, 11}; int list3[] = {1, 2, 3, 2, 4, 5, 1, 1, 1}; assert(func0(list1, sizeof(list1)/sizeof(list1[0])) == 2); assert(func0(list2, sizeof(list2)/sizeof(list2[0])) == 1); assert(func0(list3, sizeof(list3)/sizeof(list3[0])) == 1); printf("All tests passed successfully.\n"); return 0; }
O2
c
func0: endbr64 push %r12 mov (%rdi),%r11d test %esi,%esi jle 1406 <func0+0x66> lea 0x4(%rdi),%r9 lea -0x1(%rsi),%eax mov %r11d,%r12d mov %r11d,%esi lea (%r9,%rax,4),%rdi mov %r9,%r8 xor %r10d,%r10d nopl 0x0(%rax) mov %r9,%rax mov %r11d,%ecx xor %edx,%edx jmp 13de <func0+0x3e> nopw 0x0(%rax,%rax,1) mov (%rax),%ecx add $0x4,%rax cmp %ecx,%esi sete %cl movzbl %cl,%ecx add %ecx,%edx cmp %rdi,%rax jne 13d8 <func0+0x38> cmp %r10d,%edx jle 13f8 <func0+0x58> mov %esi,%r12d mov %edx,%r10d cmp %rdi,%r8 je 1409 <func0+0x69> mov (%r8),%esi add $0x4,%r8 jmp 13c8 <func0+0x28> mov %r11d,%r12d mov %r12d,%eax pop %r12 retq
func0: endbr64 push r12 mov r11d, [rdi] test esi, esi jle short loc_1406 lea r9, [rdi+4] lea eax, [rsi-1] mov r12d, r11d mov esi, r11d lea rdi, [r9+rax*4] mov r8, r9 xor r10d, r10d nop dword ptr [rax+00h] loc_13C8: mov rax, r9 mov ecx, r11d xor edx, edx jmp short loc_13DE loc_13D8: mov ecx, [rax] add rax, 4 loc_13DE: cmp esi, ecx setz cl movzx ecx, cl add edx, ecx cmp rax, rdi jnz short loc_13D8 cmp edx, r10d jle short loc_13F8 mov r12d, esi mov r10d, edx loc_13F8: cmp r8, rdi jz short loc_1409 mov esi, [r8] add r8, 4 jmp short loc_13C8 loc_1406: mov r12d, r11d loc_1409: mov eax, r12d pop r12 retn
long long func0(unsigned int *a1, int a2) { unsigned int v2; // r11d unsigned int *v3; // r9 long long v4; // rax unsigned int v5; // r12d unsigned int v6; // esi long long v7; // rdi unsigned int *v8; // r8 int v9; // r10d unsigned int *v10; // rax unsigned int v11; // ecx int v12; // edx v2 = *a1; if ( a2 <= 0 ) { return *a1; } else { v3 = a1 + 1; v4 = (unsigned int)(a2 - 1); v5 = *a1; v6 = *a1; v7 = (long long)&a1[v4 + 1]; v8 = v3; v9 = 0; while ( 1 ) { v10 = v3; v11 = v2; v12 = 0; while ( 1 ) { v12 += v6 == v11; if ( v10 == (unsigned int *)v7 ) break; v11 = *v10++; } if ( v12 > v9 ) { v5 = v6; v9 = v12; } if ( v8 == (unsigned int *)v7 ) break; v6 = *v8++; } } return v5; }
func0: ENDBR64 PUSH R12 MOV R11D,dword ptr [RDI] TEST ESI,ESI JLE 0x00101406 LEA R9,[RDI + 0x4] LEA EAX,[RSI + -0x1] MOV R12D,R11D MOV ESI,R11D LEA RDI,[R9 + RAX*0x4] MOV R8,R9 XOR R10D,R10D NOP dword ptr [RAX] LAB_001013c8: MOV RAX,R9 MOV ECX,R11D XOR EDX,EDX JMP 0x001013de LAB_001013d8: MOV ECX,dword ptr [RAX] ADD RAX,0x4 LAB_001013de: CMP ESI,ECX SETZ CL MOVZX ECX,CL ADD EDX,ECX CMP RAX,RDI JNZ 0x001013d8 CMP EDX,R10D JLE 0x001013f8 MOV R12D,ESI MOV R10D,EDX LAB_001013f8: CMP R8,RDI JZ 0x00101409 MOV ESI,dword ptr [R8] ADD R8,0x4 JMP 0x001013c8 LAB_00101406: MOV R12D,R11D LAB_00101409: MOV EAX,R12D POP R12 RET
int func0(int *param_1,int param_2) { int iVar1; int *piVar2; int iVar3; int iVar4; int iVar5; int *piVar6; int iVar7; int iVar8; iVar1 = *param_1; iVar8 = iVar1; if (0 < param_2) { param_1 = param_1 + 1; iVar7 = 0; piVar6 = param_1; iVar5 = iVar1; while( true ) { iVar4 = 0; iVar3 = iVar1; for (piVar2 = param_1; iVar4 = iVar4 + (uint)(iVar5 == iVar3), piVar2 != param_1 + (param_2 - 1); piVar2 = piVar2 + 1) { iVar3 = *piVar2; } if (iVar7 < iVar4) { iVar8 = iVar5; iVar7 = iVar4; } if (piVar6 == param_1 + (param_2 - 1)) break; iVar5 = *piVar6; piVar6 = piVar6 + 1; } } return iVar8; }
6,527
func0
#include <assert.h> #include <stdio.h>
int func0(int list1[], int length) { int max_val = 0; int result = list1[0]; for (int i = 0; i < length; i++) { int occu = 0; for (int j = 0; j < length; j++) { if (list1[j] == list1[i]) { occu++; } } if (occu > max_val) { max_val = occu; result = list1[i]; } } return result; }
int main() { int list1[] = {2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2}; int list2[] = {1, 3, 5, 7, 1, 3, 13, 15, 17, 5, 7, 9, 1, 11}; int list3[] = {1, 2, 3, 2, 4, 5, 1, 1, 1}; assert(func0(list1, sizeof(list1)/sizeof(list1[0])) == 2); assert(func0(list2, sizeof(list2)/sizeof(list2[0])) == 1); assert(func0(list3, sizeof(list3)/sizeof(list3[0])) == 1); printf("All tests passed successfully.\n"); return 0; }
O3
c
func0: endbr64 push %r14 push %r13 mov (%rdi),%r13d push %r12 push %rbp push %rbx test %esi,%esi jle 1426 <func0+0x106> mov %esi,%edx lea -0x1(%rsi),%eax mov %esi,%r11d mov %rdi,%r9 shr $0x2,%edx mov %rax,%rbp lea 0x4(%rdi,%rax,4),%r12 and $0xfffffffc,%r11d shl $0x4,%rdx xor %ebx,%ebx add %rdi,%rdx nopw 0x0(%rax,%rax,1) mov (%r9),%ecx cmp $0x3,%ebp jbe 1438 <func0+0x118> movd %ecx,%xmm3 mov %rdi,%rax pxor %xmm1,%xmm1 pshufd $0x0,%xmm3,%xmm2 nopl 0x0(%rax) movdqu (%rax),%xmm0 add $0x10,%rax pcmpeqd %xmm2,%xmm0 psubd %xmm0,%xmm1 cmp %rax,%rdx jne 1380 <func0+0x60> movdqa %xmm1,%xmm0 mov %r11d,%r8d psrldq $0x8,%xmm0 paddd %xmm0,%xmm1 movdqa %xmm1,%xmm0 psrldq $0x4,%xmm0 paddd %xmm0,%xmm1 movd %xmm1,%eax cmp %esi,%r11d je 1410 <func0+0xf0> movslq %r8d,%r14 cmp %ecx,(%rdi,%r14,4) lea 0x0(,%r14,4),%r10 sete %r14b movzbl %r14b,%r14d add %r14d,%eax lea 0x1(%r8),%r14d cmp %esi,%r14d jge 1410 <func0+0xf0> cmp 0x4(%rdi,%r10,1),%ecx jne 13e8 <func0+0xc8> add $0x1,%eax lea 0x2(%r8),%r14d cmp %esi,%r14d jge 1410 <func0+0xf0> cmp 0x8(%rdi,%r10,1),%ecx jne 13fb <func0+0xdb> add $0x1,%eax add $0x3,%r8d cmp %r8d,%esi jle 1410 <func0+0xf0> cmp 0xc(%rdi,%r10,1),%ecx jne 1410 <func0+0xf0> add $0x1,%eax xchg %ax,%ax cmp %eax,%ebx jge 1419 <func0+0xf9> mov %ecx,%r13d mov %eax,%ebx add $0x4,%r9 cmp %r12,%r9 jne 1360 <func0+0x40> pop %rbx mov %r13d,%eax pop %rbp pop %r12 pop %r13 pop %r14 retq nopw 0x0(%rax,%rax,1) xor %r8d,%r8d xor %eax,%eax jmpq 13bb <func0+0x9b> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push r14 push r13 mov r13d, [rdi] push r12 push rbp push rbx test esi, esi jle loc_140A mov edx, esi movsxd rax, esi mov r11d, esi mov r8, rdi shr edx, 2 mov r9d, esi lea r12, [rdi+rax*4] and r11d, 0FFFFFFFCh shl rdx, 4 lea ebp, [rsi-1] xor ebx, ebx add rdx, rdi nop dword ptr [rax+00h] loc_1360: mov esi, [rdi] cmp ebp, 2 jbe loc_1420 movd xmm3, esi mov rax, r8 pxor xmm1, xmm1 pshufd xmm2, xmm3, 0 nop dword ptr [rax+rax+00h] loc_1380: movdqu xmm0, xmmword ptr [rax] add rax, 10h pcmpeqd xmm0, xmm2 psubd xmm1, xmm0 cmp rdx, rax jnz short loc_1380 movdqa xmm0, xmm1 mov ecx, r11d psrldq xmm0, 8 paddd xmm1, xmm0 movdqa xmm0, xmm1 psrldq xmm0, 4 paddd xmm1, xmm0 movd eax, xmm1 cmp r9d, r11d jz short loc_13F4 loc_13BB: movsxd r10, ecx lea r14, ds:0[r10*4] cmp [r8+r10*4], esi jnz short loc_13CF add eax, 1 loc_13CF: lea r10d, [rcx+1] cmp r9d, r10d jle short loc_13F4 cmp esi, [r8+r14+4] jnz short loc_13E2 add eax, 1 loc_13E2: add ecx, 2 cmp ecx, r9d jge short loc_13F4 cmp esi, [r8+r14+8] jnz short loc_13F4 add eax, 1 loc_13F4: cmp ebx, eax jge short loc_13FD mov r13d, esi mov ebx, eax loc_13FD: add rdi, 4 cmp r12, rdi jnz loc_1360 loc_140A: pop rbx mov eax, r13d pop rbp pop r12 pop r13 pop r14 retn loc_1420: xor ecx, ecx xor eax, eax jmp short loc_13BB
long long func0(unsigned int *a1, int a2) { unsigned int v2; // r13d const __m128i *v3; // r8 unsigned int *v5; // r12 unsigned int v6; // r11d unsigned int v7; // ebp int v8; // ebx const __m128i *v9; // rdx unsigned int v10; // esi const __m128i *v11; // rax __m128i v12; // xmm1 __m128i v13; // xmm2 __m128i v14; // xmm0 signed int v15; // ecx __m128i v16; // xmm1 int v17; // eax long long v18; // r14 v2 = *a1; if ( a2 > 0 ) { v3 = (const __m128i *)a1; v5 = &a1[a2]; v6 = a2 & 0xFFFFFFFC; v7 = a2 - 1; v8 = 0; v9 = (const __m128i *)&a1[4 * ((unsigned int)a2 >> 2)]; while ( 1 ) { v10 = *a1; if ( v7 <= 2 ) break; v11 = v3; v12 = 0LL; v13 = _mm_shuffle_epi32(_mm_cvtsi32_si128(v10), 0); do { v14 = _mm_loadu_si128(v11++); v12 = _mm_sub_epi32(v12, _mm_cmpeq_epi32(v14, v13)); } while ( v9 != v11 ); v15 = v6; v16 = _mm_add_epi32(v12, _mm_srli_si128(v12, 8)); v17 = _mm_cvtsi128_si32(_mm_add_epi32(v16, _mm_srli_si128(v16, 4))); if ( a2 != v6 ) goto LABEL_7; LABEL_15: if ( v8 < v17 ) { v2 = *a1; v8 = v17; } if ( v5 == ++a1 ) return v2; } v15 = 0; v17 = 0; LABEL_7: v18 = v15; if ( v3->m128i_i32[v18] == v10 ) ++v17; if ( a2 > v15 + 1 ) { if ( v10 == v3->m128i_i32[v18 + 1] ) ++v17; if ( v15 + 2 < a2 && v10 == v3->m128i_i32[v18 + 2] ) ++v17; } goto LABEL_15; } return v2; }
func0: ENDBR64 PUSH R14 PUSH R13 MOV R13D,dword ptr [RDI] PUSH R12 PUSH RBP PUSH RBX TEST ESI,ESI JLE 0x0010140a MOV EDX,ESI MOVSXD RAX,ESI MOV R11D,ESI MOV R8,RDI SHR EDX,0x2 MOV R9D,ESI LEA R12,[RDI + RAX*0x4] AND R11D,0xfffffffc SHL RDX,0x4 LEA EBP,[RSI + -0x1] XOR EBX,EBX ADD RDX,RDI NOP dword ptr [RAX] LAB_00101360: MOV ESI,dword ptr [RDI] CMP EBP,0x2 JBE 0x00101420 MOVD XMM3,ESI MOV RAX,R8 PXOR XMM1,XMM1 PSHUFD XMM2,XMM3,0x0 NOP dword ptr [RAX + RAX*0x1] LAB_00101380: MOVDQU XMM0,xmmword ptr [RAX] ADD RAX,0x10 PCMPEQD XMM0,XMM2 PSUBD XMM1,XMM0 CMP RDX,RAX JNZ 0x00101380 MOVDQA XMM0,XMM1 MOV ECX,R11D PSRLDQ XMM0,0x8 PADDD XMM1,XMM0 MOVDQA XMM0,XMM1 PSRLDQ XMM0,0x4 PADDD XMM1,XMM0 MOVD EAX,XMM1 CMP R9D,R11D JZ 0x001013f4 LAB_001013bb: MOVSXD R10,ECX LEA R14,[R10*0x4] CMP dword ptr [R8 + R10*0x4],ESI JNZ 0x001013cf ADD EAX,0x1 LAB_001013cf: LEA R10D,[RCX + 0x1] CMP R9D,R10D JLE 0x001013f4 CMP ESI,dword ptr [R8 + R14*0x1 + 0x4] JNZ 0x001013e2 ADD EAX,0x1 LAB_001013e2: ADD ECX,0x2 CMP ECX,R9D JGE 0x001013f4 CMP ESI,dword ptr [R8 + R14*0x1 + 0x8] JNZ 0x001013f4 ADD EAX,0x1 LAB_001013f4: CMP EBX,EAX JGE 0x001013fd MOV R13D,ESI MOV EBX,EAX LAB_001013fd: ADD RDI,0x4 CMP R12,RDI JNZ 0x00101360 LAB_0010140a: POP RBX MOV EAX,R13D POP RBP POP R12 POP R13 POP R14 RET LAB_00101420: XOR ECX,ECX XOR EAX,EAX JMP 0x001013bb
int func0(int *param_1,uint param_2) { int iVar1; int iVar2; int *piVar3; int *piVar4; int *piVar5; int *piVar6; uint uVar7; int iVar8; int *piVar9; int iVar10; int iVar11; int iVar12; int iVar13; int iVar14; iVar10 = *param_1; if (0 < (int)param_2) { iVar8 = 0; piVar9 = param_1; do { iVar1 = *piVar9; if (param_2 - 1 < 3) { uVar7 = 0; iVar11 = 0; LAB_001013bb: if (param_1[(int)uVar7] == iVar1) { iVar11 = iVar11 + 1; } if ((int)(uVar7 + 1) < (int)param_2) { if (iVar1 == param_1[(long)(int)uVar7 + 1]) { iVar11 = iVar11 + 1; } if (((int)(uVar7 + 2) < (int)param_2) && (iVar1 == param_1[(long)(int)uVar7 + 2])) { iVar11 = iVar11 + 1; } } } else { iVar11 = 0; iVar12 = 0; iVar13 = 0; iVar14 = 0; piVar6 = param_1; do { iVar2 = *piVar6; piVar3 = piVar6 + 1; piVar4 = piVar6 + 2; piVar5 = piVar6 + 3; piVar6 = piVar6 + 4; iVar11 = iVar11 + (uint)(iVar2 == iVar1); iVar12 = iVar12 + (uint)(*piVar3 == iVar1); iVar13 = iVar13 + (uint)(*piVar4 == iVar1); iVar14 = iVar14 + (uint)(*piVar5 == iVar1); } while (param_1 + (ulong)(param_2 >> 2) * 4 != piVar6); iVar11 = iVar11 + iVar13 + iVar12 + iVar14; uVar7 = param_2 & 0xfffffffc; if (param_2 != (param_2 & 0xfffffffc)) goto LAB_001013bb; } if (iVar8 < iVar11) { iVar10 = iVar1; iVar8 = iVar11; } piVar9 = piVar9 + 1; } while (param_1 + (int)param_2 != piVar9); } return iVar10; }
6,528
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <stdbool.h> void assertArrayEquals(int *expected, int expectedSize, int *actual, int actualSize) { assert(expectedSize == actualSize); for (int i = 0; i < expectedSize; i++) { assert(expected[i] == actual[i]); } }
int* func0(int x[], int size, int *returnSize) { int *repeated = malloc(sizeof(int) * size); int count = 0; bool found; for (int i = 0; i < size; i++) { found = false; for (int j = i + 1; j < size; j++) { if (x[i] == x[j]) { found = true; for (int k = 0; k < count; k++) { if (repeated[k] == x[i]) { found = false; break; } } if (found) { repeated[count++] = x[i]; break; } } } } *returnSize = count; return repeated; }
int main() { int arr1[] = {10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20}; int expected1[] = {20, 30, -20, 60}; int size1; int *result1 = func0(arr1, 13, &size1); assertArrayEquals(expected1, 4, result1, size1); free(result1); int arr2[] = {-1, 1, -1, 8}; int expected2[] = {-1}; int size2; int *result2 = func0(arr2, 4, &size2); assertArrayEquals(expected2, 1, result2, size2); free(result2); int arr3[] = {1, 2, 3, 1, 2}; int expected3[] = {1, 2}; int size3; int *result3 = func0(arr3, 5, &size3); assertArrayEquals(expected3, 2, result3, size3); free(result3); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x40,%rsp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) mov %rdx,-0x38(%rbp) mov -0x2c(%rbp),%eax cltq shl $0x2,%rax mov %rax,%rdi callq 10b0 <malloc@plt> mov %rax,-0x8(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) jmpq 1375 <func0+0x123> movb $0x0,-0x19(%rbp) mov -0x14(%rbp),%eax add $0x1,%eax mov %eax,-0x10(%rbp) jmpq 1365 <func0+0x113> 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 jne 1361 <func0+0x10f> movb $0x1,-0x19(%rbp) movl $0x0,-0xc(%rbp) jmp 131e <func0+0xcc> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x8(%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 jne 131a <func0+0xc8> movb $0x0,-0x19(%rbp) jmp 1326 <func0+0xd4> addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x18(%rbp),%eax jl 12e4 <func0+0x92> cmpb $0x0,-0x19(%rbp) je 1361 <func0+0x10f> mov -0x14(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x18(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x18(%rbp) cltq lea 0x0(,%rax,4),%rdx mov -0x8(%rbp),%rax add %rax,%rdx mov (%rcx),%eax mov %eax,(%rdx) jmp 1371 <func0+0x11f> addl $0x1,-0x10(%rbp) mov -0x10(%rbp),%eax cmp -0x2c(%rbp),%eax jl 12a3 <func0+0x51> addl $0x1,-0x14(%rbp) mov -0x14(%rbp),%eax cmp -0x2c(%rbp),%eax jl 1291 <func0+0x3f> mov -0x38(%rbp),%rax mov -0x18(%rbp),%edx mov %edx,(%rax) mov -0x8(%rbp),%rax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 40h mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov [rbp+var_38], rdx mov eax, [rbp+var_2C] cdqe shl rax, 2 mov rdi, rax; size call _malloc mov [rbp+var_8], rax mov [rbp+var_18], 0 mov [rbp+var_14], 0 jmp loc_1387 loc_12A3: mov [rbp+var_19], 0 mov eax, [rbp+var_14] add eax, 1 mov [rbp+var_10], eax jmp loc_1377 loc_12B5: 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 jnz loc_1373 mov [rbp+var_19], 1 mov [rbp+var_C], 0 jmp short loc_1330 loc_12F6: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] 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 jnz short loc_132C mov [rbp+var_19], 0 jmp short loc_1338 loc_132C: add [rbp+var_C], 1 loc_1330: mov eax, [rbp+var_C] cmp eax, [rbp+var_18] jl short loc_12F6 loc_1338: cmp [rbp+var_19], 0 jz short loc_1373 mov eax, [rbp+var_14] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] lea rcx, [rdx+rax] mov eax, [rbp+var_18] lea edx, [rax+1] mov [rbp+var_18], edx cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_8] add rdx, rax mov eax, [rcx] mov [rdx], eax jmp short loc_1383 loc_1373: add [rbp+var_10], 1 loc_1377: mov eax, [rbp+var_10] cmp eax, [rbp+var_2C] jl loc_12B5 loc_1383: add [rbp+var_14], 1 loc_1387: mov eax, [rbp+var_14] cmp eax, [rbp+var_2C] jl loc_12A3 mov rax, [rbp+var_38] mov edx, [rbp+var_18] mov [rax], edx mov rax, [rbp+var_8] leave retn
_DWORD * func0(long long a1, int a2, _DWORD *a3) { int v3; // eax char v6; // [rsp+27h] [rbp-19h] int v7; // [rsp+28h] [rbp-18h] int i; // [rsp+2Ch] [rbp-14h] int j; // [rsp+30h] [rbp-10h] int k; // [rsp+34h] [rbp-Ch] _DWORD *v11; // [rsp+38h] [rbp-8h] v11 = malloc(4LL * a2); v7 = 0; for ( i = 0; i < a2; ++i ) { for ( j = i + 1; j < a2; ++j ) { if ( *(_DWORD *)(4LL * i + a1) == *(_DWORD *)(4LL * j + a1) ) { v6 = 1; for ( k = 0; k < v7; ++k ) { if ( v11[k] == *(_DWORD *)(4LL * i + a1) ) { v6 = 0; break; } } if ( v6 ) { v3 = v7++; v11[v3] = *(_DWORD *)(4LL * i + a1); break; } } } } *a3 = v7; return v11; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 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,0x2 MOV RDI,RAX CALL 0x001010b0 MOV qword ptr [RBP + -0x8],RAX MOV dword ptr [RBP + -0x18],0x0 MOV dword ptr [RBP + -0x14],0x0 JMP 0x00101387 LAB_001012a3: MOV byte ptr [RBP + -0x19],0x0 MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 MOV dword ptr [RBP + -0x10],EAX JMP 0x00101377 LAB_001012b5: 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 JNZ 0x00101373 MOV byte ptr [RBP + -0x19],0x1 MOV dword ptr [RBP + -0xc],0x0 JMP 0x00101330 LAB_001012f6: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] 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 JNZ 0x0010132c MOV byte ptr [RBP + -0x19],0x0 JMP 0x00101338 LAB_0010132c: ADD dword ptr [RBP + -0xc],0x1 LAB_00101330: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x18] JL 0x001012f6 LAB_00101338: CMP byte ptr [RBP + -0x19],0x0 JZ 0x00101373 MOV EAX,dword ptr [RBP + -0x14] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] LEA RCX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x18] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x18],EDX CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x8] ADD RDX,RAX MOV EAX,dword ptr [RCX] MOV dword ptr [RDX],EAX JMP 0x00101383 LAB_00101373: ADD dword ptr [RBP + -0x10],0x1 LAB_00101377: MOV EAX,dword ptr [RBP + -0x10] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001012b5 LAB_00101383: ADD dword ptr [RBP + -0x14],0x1 LAB_00101387: MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001012a3 MOV RAX,qword ptr [RBP + -0x38] MOV EDX,dword ptr [RBP + -0x18] MOV dword ptr [RAX],EDX MOV RAX,qword ptr [RBP + -0x8] LEAVE RET
void * func0(long param_1,int param_2,int *param_3) { bool bVar1; void *pvVar2; int local_20; int local_1c; int local_18; int local_14; pvVar2 = malloc((long)param_2 << 2); local_20 = 0; local_1c = 0; do { local_18 = local_1c; if (param_2 <= local_1c) { *param_3 = local_20; return pvVar2; } do { do { local_18 = local_18 + 1; if (param_2 <= local_18) goto LAB_00101383; } while (*(int *)(param_1 + (long)local_1c * 4) != *(int *)(param_1 + (long)local_18 * 4)); bVar1 = true; for (local_14 = 0; local_14 < local_20; local_14 = local_14 + 1) { if (*(int *)((long)pvVar2 + (long)local_14 * 4) == *(int *)(param_1 + (long)local_1c * 4)) { bVar1 = false; break; } } } while (!bVar1); *(int4 *)((long)local_20 * 4 + (long)pvVar2) = *(int4 *)((long)local_1c * 4 + param_1); local_20 = local_20 + 1; LAB_00101383: local_1c = local_1c + 1; } while( true ); }
6,529
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <stdbool.h> void assertArrayEquals(int *expected, int expectedSize, int *actual, int actualSize) { assert(expectedSize == actualSize); for (int i = 0; i < expectedSize; i++) { assert(expected[i] == actual[i]); } }
int* func0(int x[], int size, int *returnSize) { int *repeated = malloc(sizeof(int) * size); int count = 0; bool found; for (int i = 0; i < size; i++) { found = false; for (int j = i + 1; j < size; j++) { if (x[i] == x[j]) { found = true; for (int k = 0; k < count; k++) { if (repeated[k] == x[i]) { found = false; break; } } if (found) { repeated[count++] = x[i]; break; } } } } *returnSize = count; return repeated; }
int main() { int arr1[] = {10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20}; int expected1[] = {20, 30, -20, 60}; int size1; int *result1 = func0(arr1, 13, &size1); assertArrayEquals(expected1, 4, result1, size1); free(result1); int arr2[] = {-1, 1, -1, 8}; int expected2[] = {-1}; int size2; int *result2 = func0(arr2, 4, &size2); assertArrayEquals(expected2, 1, result2, size2); free(result2); int arr3[] = {1, 2, 3, 1, 2}; int expected3[] = {1, 2}; int size3; int *result3 = func0(arr3, 5, &size3); assertArrayEquals(expected3, 2, result3, size3); free(result3); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov %rdi,%rbx mov %esi,%ebp mov %rdx,%r12 movslq %esi,%rdi shl $0x2,%rdi callq 10b0 <malloc@plt> mov %rax,%r13 test %ebp,%ebp jle 12a8 <func0+0x8d> lea -0x1(%rbp),%r10d add $0x1,%r10 mov $0x1,%edi mov $0x0,%r8d mov %rax,%r9 lea 0x4(%rax),%r11 jmp 1292 <func0+0x77> add $0x1,%rdx cmp %edx,%ebp jle 128e <func0+0x73> cmp (%rbx,%rdx,4),%ecx jne 1260 <func0+0x45> test %r8d,%r8d jle 1282 <func0+0x67> mov %r9,%rax cmp (%rax),%ecx je 1260 <func0+0x45> add $0x4,%rax cmp %rsi,%rax jne 1275 <func0+0x5a> movslq %r8d,%rax mov %ecx,0x0(%r13,%rax,4) lea 0x1(%r8),%r8d add $0x1,%rdi cmp %r10,%rdi je 12ae <func0+0x93> mov -0x4(%rbx,%rdi,4),%ecx lea -0x1(%r8),%eax lea (%r11,%rax,4),%rsi mov %rdi,%rdx jmp 1268 <func0+0x4d> mov $0x0,%r8d mov %r8d,(%r12) mov %r13,%rax add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq
func0: endbr64 push r12 push rbp push rbx mov rbx, rdi mov ebp, esi mov r12, rdx movsxd rdi, esi shl rdi, 2 call _malloc test ebp, ebp jle short loc_1297 mov r10d, ebp mov r8d, 1 mov r9d, 0 lea r11, [rax+4] jmp short loc_1280 loc_1250: add rcx, 1 cmp ebp, ecx jle short loc_127C loc_1258: cmp esi, [rbx+rcx*4] jnz short loc_1250 test r9d, r9d jle short loc_1272 mov rdx, rax loc_1265: cmp esi, [rdx] jz short loc_1250 add rdx, 4 cmp rdx, rdi jnz short loc_1265 loc_1272: movsxd rdx, r9d mov [rax+rdx*4], esi lea r9d, [r9+1] loc_127C: add r8, 1 loc_1280: cmp r8, r10 jz short loc_129D mov esi, [rbx+r8*4-4] lea edx, [r9-1] lea rdi, [r11+rdx*4] mov rcx, r8 jmp short loc_1258 loc_1297: mov r9d, 0 loc_129D: mov [r12], r9d pop rbx pop rbp pop r12 retn
long long func0(long long a1, int a2, int *a3) { long long result; // rax long long v6; // r8 int v7; // r9d long long v8; // rcx _DWORD *v9; // rdx int v10; // esi result = malloc(4LL * a2); if ( a2 > 0 ) { v6 = 1LL; v7 = 0; while ( 1 ) { if ( v6 == a2 ) goto LABEL_14; v10 = *(_DWORD *)(a1 + 4 * v6 - 4); v8 = v6; while ( v10 != *(_DWORD *)(a1 + 4 * v8) ) { LABEL_3: if ( a2 <= (int)++v8 ) goto LABEL_10; } if ( v7 > 0 ) break; LABEL_9: *(_DWORD *)(result + 4LL * v7++) = v10; LABEL_10: ++v6; } v9 = (_DWORD *)result; while ( v10 != *v9 ) { if ( ++v9 == (_DWORD *)(result + 4 + 4LL * (unsigned int)(v7 - 1)) ) goto LABEL_9; } goto LABEL_3; } v7 = 0; LABEL_14: *a3 = v7; return result; }
func0: ENDBR64 PUSH R12 PUSH RBP PUSH RBX MOV RBX,RDI MOV EBP,ESI MOV R12,RDX MOVSXD RDI,ESI SHL RDI,0x2 CALL 0x001010b0 TEST EBP,EBP JLE 0x00101297 MOV R10D,EBP MOV R8D,0x1 MOV R9D,0x0 LEA R11,[RAX + 0x4] JMP 0x00101280 LAB_00101250: ADD RCX,0x1 CMP EBP,ECX JLE 0x0010127c LAB_00101258: CMP ESI,dword ptr [RBX + RCX*0x4] JNZ 0x00101250 TEST R9D,R9D JLE 0x00101272 MOV RDX,RAX LAB_00101265: CMP ESI,dword ptr [RDX] JZ 0x00101250 ADD RDX,0x4 CMP RDX,RDI JNZ 0x00101265 LAB_00101272: MOVSXD RDX,R9D MOV dword ptr [RAX + RDX*0x4],ESI LEA R9D,[R9 + 0x1] LAB_0010127c: ADD R8,0x1 LAB_00101280: CMP R8,R10 JZ 0x0010129d MOV ESI,dword ptr [RBX + R8*0x4 + -0x4] LEA EDX,[R9 + -0x1] LEA RDI,[R11 + RDX*0x4] MOV RCX,R8 JMP 0x00101258 LAB_00101297: MOV R9D,0x0 LAB_0010129d: MOV dword ptr [R12],R9D POP RBX POP RBP POP R12 RET
void func0(long param_1,uint param_2,int *param_3) { int iVar1; int *piVar2; ulong uVar3; int *piVar4; ulong uVar5; int iVar6; piVar2 = (int *)malloc((long)(int)param_2 << 2); if ((int)param_2 < 1) { iVar6 = 0; } else { iVar6 = 0; for (uVar5 = 1; uVar5 != param_2; uVar5 = uVar5 + 1) { iVar1 = *(int *)(param_1 + -4 + uVar5 * 4); uVar3 = uVar5; do { if (iVar1 == *(int *)(param_1 + uVar3 * 4)) { piVar4 = piVar2; if (iVar6 < 1) { LAB_00101272: piVar2[iVar6] = iVar1; iVar6 = iVar6 + 1; break; } while (iVar1 != *piVar4) { piVar4 = piVar4 + 1; if (piVar4 == piVar2 + (ulong)(iVar6 - 1) + 1) goto LAB_00101272; } } uVar3 = uVar3 + 1; } while ((int)uVar3 < (int)param_2); } } *param_3 = iVar6; return; }
6,530
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <stdbool.h> void assertArrayEquals(int *expected, int expectedSize, int *actual, int actualSize) { assert(expectedSize == actualSize); for (int i = 0; i < expectedSize; i++) { assert(expected[i] == actual[i]); } }
int* func0(int x[], int size, int *returnSize) { int *repeated = malloc(sizeof(int) * size); int count = 0; bool found; for (int i = 0; i < size; i++) { found = false; for (int j = i + 1; j < size; j++) { if (x[i] == x[j]) { found = true; for (int k = 0; k < count; k++) { if (repeated[k] == x[i]) { found = false; break; } } if (found) { repeated[count++] = x[i]; break; } } } } *returnSize = count; return repeated; }
int main() { int arr1[] = {10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20}; int expected1[] = {20, 30, -20, 60}; int size1; int *result1 = func0(arr1, 13, &size1); assertArrayEquals(expected1, 4, result1, size1); free(result1); int arr2[] = {-1, 1, -1, 8}; int expected2[] = {-1}; int size2; int *result2 = func0(arr2, 4, &size2); assertArrayEquals(expected2, 1, result2, size2); free(result2); int arr3[] = {1, 2, 3, 1, 2}; int expected3[] = {1, 2}; int size3; int *result3 = func0(arr3, 5, &size3); assertArrayEquals(expected3, 2, result3, size3); free(result3); return 0; }
O2
c
func0: endbr64 push %r12 mov %rdx,%r12 push %rbp push %rbx mov %rdi,%rbx movslq %esi,%rdi mov %rdi,%rbp shl $0x2,%rdi callq 10b0 <malloc@plt> mov %rax,%r9 test %ebp,%ebp jle 1485 <func0+0xa5> lea -0x1(%rbp),%r10d mov $0x1,%edi lea 0x4(%rax),%r11 xor %r8d,%r8d add $0x1,%r10 cmp %r10,%rdi je 1479 <func0+0x99> nopl 0x0(%rax) lea -0x1(%r8),%eax mov -0x4(%rbx,%rdi,4),%ecx mov %rdi,%rdx lea (%r11,%rax,4),%rsi jmp 1448 <func0+0x68> nopl 0x0(%rax) add $0x1,%rdx cmp %edx,%ebp jle 1470 <func0+0x90> cmp (%rbx,%rdx,4),%ecx jne 1440 <func0+0x60> test %r8d,%r8d je 1465 <func0+0x85> mov %r9,%rax nopl (%rax) cmp (%rax),%ecx je 1440 <func0+0x60> add $0x4,%rax cmp %rsi,%rax jne 1458 <func0+0x78> movslq %r8d,%rax add $0x1,%r8d mov %ecx,(%r9,%rax,4) add $0x1,%rdi cmp %r10,%rdi jne 1428 <func0+0x48> pop %rbx mov %r9,%rax pop %rbp mov %r8d,(%r12) pop %r12 retq xor %r8d,%r8d pop %rbx mov %r9,%rax pop %rbp mov %r8d,(%r12) pop %r12 retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push r13 mov r13, rdx push r12 movsxd r12, esi push rbp push rbx mov rbx, rdi lea rdi, ds:0[r12*4] sub rsp, 8 call _malloc test r12d, r12d jle short loc_1468 mov r8d, 1 mov rbp, r12 lea r10, [rax+4] xor r9d, r9d cmp r8, r12 jz short loc_1459 xchg ax, ax loc_1400: lea edx, [r9-1] mov esi, [rbx+r8*4-4] mov rcx, r8 lea rdi, [r10+rdx*4] jmp short loc_1420 loc_1418: add rcx, 1 cmp ebp, ecx jle short loc_1450 loc_1420: cmp esi, [rbx+rcx*4] jnz short loc_1418 test r9d, r9d jz short loc_143D mov rdx, rax nop dword ptr [rax] loc_1430: cmp esi, [rdx] jz short loc_1418 add rdx, 4 cmp rdx, rdi jnz short loc_1430 loc_143D: movsxd rdx, r9d add r9d, 1 mov [rax+rdx*4], esi nop word ptr [rax+rax+00000000h] loc_1450: add r8, 1 cmp r8, r12 jnz short loc_1400 loc_1459: mov [r13+0], r9d add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn loc_1468: xor r9d, r9d mov [r13+0], r9d add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn
long long func0(long long a1, int a2, _DWORD *a3) { long long v4; // r12 long long result; // rax long long v6; // r8 int v7; // r9d int v8; // esi long long v9; // rcx _DWORD *v10; // rdx long long v11; // rdx v4 = a2; result = malloc(4LL * a2); if ( a2 > 0 ) { v6 = 1LL; v7 = 0; if ( a2 == 1LL ) goto LABEL_12; while ( 1 ) { v8 = *(_DWORD *)(a1 + 4 * v6 - 4); v9 = v6; while ( v8 != *(_DWORD *)(a1 + 4 * v9) ) { LABEL_4: if ( (int)v4 <= (int)++v9 ) goto LABEL_11; } if ( v7 ) break; LABEL_10: v11 = v7++; *(_DWORD *)(result + 4 * v11) = v8; LABEL_11: if ( ++v6 == v4 ) { LABEL_12: *a3 = v7; return result; } } v10 = (_DWORD *)result; while ( v8 != *v10 ) { if ( ++v10 == (_DWORD *)(result + 4 + 4LL * (unsigned int)(v7 - 1)) ) goto LABEL_10; } goto LABEL_4; } *a3 = 0; return result; }
func0: ENDBR64 PUSH R13 MOV R13,RDX PUSH R12 MOVSXD R12,ESI PUSH RBP PUSH RBX MOV RBX,RDI LEA RDI,[R12*0x4] SUB RSP,0x8 CALL 0x001010b0 TEST R12D,R12D JLE 0x00101468 MOV R8D,0x1 MOV RBP,R12 LEA R10,[RAX + 0x4] XOR R9D,R9D CMP R8,R12 JZ 0x00101459 NOP LAB_00101400: LEA EDX,[R9 + -0x1] MOV ESI,dword ptr [RBX + R8*0x4 + -0x4] MOV RCX,R8 LEA RDI,[R10 + RDX*0x4] JMP 0x00101420 LAB_00101418: ADD RCX,0x1 CMP EBP,ECX JLE 0x00101450 LAB_00101420: CMP ESI,dword ptr [RBX + RCX*0x4] JNZ 0x00101418 TEST R9D,R9D JZ 0x0010143d MOV RDX,RAX NOP dword ptr [RAX] LAB_00101430: CMP ESI,dword ptr [RDX] JZ 0x00101418 ADD RDX,0x4 CMP RDX,RDI JNZ 0x00101430 LAB_0010143d: MOVSXD RDX,R9D ADD R9D,0x1 MOV dword ptr [RAX + RDX*0x4],ESI NOP word ptr [RAX + RAX*0x1] LAB_00101450: ADD R8,0x1 CMP R8,R12 JNZ 0x00101400 LAB_00101459: MOV dword ptr [R13],R9D ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET LAB_00101468: XOR R9D,R9D MOV dword ptr [R13],R9D ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET
void func0(long param_1,int param_2,int *param_3) { int iVar1; int *piVar2; int *piVar3; long lVar4; long lVar5; int iVar6; long lVar7; lVar7 = (long)param_2; piVar2 = (int *)malloc(lVar7 * 4); if (param_2 < 1) { *param_3 = 0; return; } lVar5 = 1; iVar6 = 0; if (lVar7 != 1) { do { iVar1 = *(int *)(param_1 + -4 + lVar5 * 4); lVar4 = lVar5; do { if (iVar1 == *(int *)(param_1 + lVar4 * 4)) { piVar3 = piVar2; if (iVar6 == 0) { LAB_0010143d: lVar4 = (long)iVar6; iVar6 = iVar6 + 1; piVar2[lVar4] = iVar1; break; } while (iVar1 != *piVar3) { piVar3 = piVar3 + 1; if (piVar3 == piVar2 + (ulong)(iVar6 - 1) + 1) goto LAB_0010143d; } } lVar4 = lVar4 + 1; } while ((int)lVar4 < param_2); lVar5 = lVar5 + 1; } while (lVar5 != lVar7); } *param_3 = iVar6; return; }
6,531
func0
#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <stdbool.h> void assertArrayEquals(int *expected, int expectedSize, int *actual, int actualSize) { assert(expectedSize == actualSize); for (int i = 0; i < expectedSize; i++) { assert(expected[i] == actual[i]); } }
int* func0(int x[], int size, int *returnSize) { int *repeated = malloc(sizeof(int) * size); int count = 0; bool found; for (int i = 0; i < size; i++) { found = false; for (int j = i + 1; j < size; j++) { if (x[i] == x[j]) { found = true; for (int k = 0; k < count; k++) { if (repeated[k] == x[i]) { found = false; break; } } if (found) { repeated[count++] = x[i]; break; } } } } *returnSize = count; return repeated; }
int main() { int arr1[] = {10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20}; int expected1[] = {20, 30, -20, 60}; int size1; int *result1 = func0(arr1, 13, &size1); assertArrayEquals(expected1, 4, result1, size1); free(result1); int arr2[] = {-1, 1, -1, 8}; int expected2[] = {-1}; int size2; int *result2 = func0(arr2, 4, &size2); assertArrayEquals(expected2, 1, result2, size2); free(result2); int arr3[] = {1, 2, 3, 1, 2}; int expected3[] = {1, 2}; int size3; int *result3 = func0(arr3, 5, &size3); assertArrayEquals(expected3, 2, result3, size3); free(result3); return 0; }
O3
c
func0: endbr64 push %r12 mov %rdx,%r12 push %rbp push %rbx mov %rdi,%rbx movslq %esi,%rdi mov %rdi,%rbp shl $0x2,%rdi callq 10b0 <malloc@plt> mov %rax,%r9 test %ebp,%ebp jle 1435 <func0+0xa5> cmp $0x1,%ebp je 1435 <func0+0xa5> lea -0x2(%rbp),%r10d mov $0x1,%edi lea 0x4(%rax),%r11 xor %r8d,%r8d add $0x2,%r10 nopl 0x0(%rax) lea -0x1(%r8),%eax mov -0x4(%rbx,%rdi,4),%ecx mov %rdi,%rdx lea (%r11,%rax,4),%rsi jmp 13f8 <func0+0x68> nopl 0x0(%rax) add $0x1,%rdx cmp %edx,%ebp jle 1420 <func0+0x90> cmp (%rbx,%rdx,4),%ecx jne 13f0 <func0+0x60> test %r8d,%r8d je 1415 <func0+0x85> mov %r9,%rax nopl (%rax) cmp (%rax),%ecx je 13f0 <func0+0x60> add $0x4,%rax cmp %rsi,%rax jne 1408 <func0+0x78> movslq %r8d,%rax add $0x1,%r8d mov %ecx,(%r9,%rax,4) add $0x1,%rdi cmp %r10,%rdi jne 13d8 <func0+0x48> pop %rbx mov %r9,%rax pop %rbp mov %r8d,(%r12) pop %r12 retq xor %r8d,%r8d pop %rbx mov %r9,%rax pop %rbp mov %r8d,(%r12) pop %r12 retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push r12 mov r12, rdx push rbp push rbx mov rbx, rdi movsxd rdi, esi mov rbp, rdi shl rdi, 2; size call _malloc test ebp, ebp jle loc_1457 mov r11d, ebp mov r8d, 1 xor r9d, r9d cmp ebp, 1 jz short loc_1431 nop word ptr [rax+rax+00000000h] loc_13D0: movsxd r10, r9d mov esi, [rbx+r8*4-4] mov rcx, r8 lea rdi, [rax+r10*4] jmp short loc_13F0 loc_13E8: add rcx, 1 cmp ebp, ecx jle short loc_1428 loc_13F0: cmp esi, [rbx+rcx*4] jnz short loc_13E8 test r9d, r9d jle short loc_1440 loc_13FA: mov rdx, rax jmp short loc_1409 loc_1400: add rdx, 4 cmp rdi, rdx jz short loc_1440 loc_1409: cmp esi, [rdx] jnz short loc_1400 add rcx, 1 cmp ebp, ecx jle short loc_1428 cmp esi, [rbx+rcx*4] jz short loc_13FA add rcx, 1 cmp ebp, ecx jg short loc_13F0 nop word ptr [rax+rax+00h] loc_1428: add r8, 1 cmp r8, r11 jnz short loc_13D0 loc_1431: mov [r12], r9d pop rbx pop rbp pop r12 retn loc_1440: add r8, 1 mov [rax+r10*4], esi add r9d, 1 cmp r8, r11 jnz loc_13D0 jmp short loc_1431 loc_1457: xor r9d, r9d mov [r12], r9d pop rbx pop rbp pop r12 retn
_DWORD * func0(long long a1, int a2, int *a3) { _DWORD *result; // rax long long v6; // r8 int v7; // r9d int v8; // esi long long v9; // rcx _DWORD *v10; // rdx result = malloc(4LL * a2); if ( a2 <= 0 ) { *a3 = 0; } else { v6 = 1LL; v7 = 0; if ( a2 != 1 ) { while ( 2 ) { while ( 2 ) { v8 = *(_DWORD *)(a1 + 4 * v6 - 4); v9 = v6; LABEL_5: while ( v8 != *(_DWORD *)(a1 + 4 * v9) ) { if ( a2 <= (int)++v9 ) goto LABEL_13; } if ( v7 > 0 ) { while ( 1 ) { v10 = result; while ( v8 != *v10 ) { if ( &result[v7] == ++v10 ) goto LABEL_15; } if ( a2 <= (int)++v9 ) break; if ( v8 != *(_DWORD *)(a1 + 4 * v9) ) { if ( a2 > (int)++v9 ) goto LABEL_5; break; } } LABEL_13: if ( ++v6 != a2 ) continue; goto LABEL_14; } break; } LABEL_15: ++v6; result[v7++] = v8; if ( v6 != a2 ) continue; break; } } LABEL_14: *a3 = v7; } return result; }
func0: ENDBR64 PUSH R12 MOV R12,RDX PUSH RBP PUSH RBX MOV RBX,RDI MOVSXD RDI,ESI MOV RBP,RDI SHL RDI,0x2 CALL 0x001010b0 TEST EBP,EBP JLE 0x00101457 MOV R11D,EBP MOV R8D,0x1 XOR R9D,R9D CMP EBP,0x1 JZ 0x00101431 NOP word ptr CS:[RAX + RAX*0x1] LAB_001013d0: MOVSXD R10,R9D MOV ESI,dword ptr [RBX + R8*0x4 + -0x4] MOV RCX,R8 LEA RDI,[RAX + R10*0x4] JMP 0x001013f0 LAB_001013e8: ADD RCX,0x1 CMP EBP,ECX JLE 0x00101428 LAB_001013f0: CMP ESI,dword ptr [RBX + RCX*0x4] JNZ 0x001013e8 TEST R9D,R9D JLE 0x00101440 LAB_001013fa: MOV RDX,RAX JMP 0x00101409 LAB_00101400: ADD RDX,0x4 CMP RDI,RDX JZ 0x00101440 LAB_00101409: CMP ESI,dword ptr [RDX] JNZ 0x00101400 ADD RCX,0x1 CMP EBP,ECX JLE 0x00101428 CMP ESI,dword ptr [RBX + RCX*0x4] JZ 0x001013fa ADD RCX,0x1 CMP EBP,ECX JG 0x001013f0 NOP word ptr [RAX + RAX*0x1] LAB_00101428: ADD R8,0x1 CMP R8,R11 JNZ 0x001013d0 LAB_00101431: MOV dword ptr [R12],R9D POP RBX POP RBP POP R12 RET LAB_00101440: ADD R8,0x1 MOV dword ptr [RAX + R10*0x4],ESI ADD R9D,0x1 CMP R8,R11 JNZ 0x001013d0 JMP 0x00101431 LAB_00101457: XOR R9D,R9D MOV dword ptr [R12],R9D POP RBX POP RBP POP R12 RET
void func0(long param_1,uint param_2,int *param_3) { int iVar1; int *piVar2; ulong uVar3; ulong uVar4; int *piVar5; ulong uVar6; int iVar7; piVar2 = (int *)malloc((long)(int)param_2 << 2); if ((int)param_2 < 1) { *param_3 = 0; return; } uVar6 = 1; iVar7 = 0; if (param_2 != 1) { LAB_001013d0: do { iVar1 = *(int *)(param_1 + -4 + uVar6 * 4); uVar4 = uVar6; do { while (iVar1 == *(int *)(param_1 + uVar4 * 4)) { piVar5 = piVar2; if (iVar7 < 1) { LAB_00101440: uVar6 = uVar6 + 1; piVar2[iVar7] = iVar1; iVar7 = iVar7 + 1; if (uVar6 == param_2) goto LAB_00101431; goto LAB_001013d0; } do { while (uVar3 = uVar4, iVar1 != *piVar5) { piVar5 = piVar5 + 1; uVar4 = uVar3; if (piVar2 + iVar7 == piVar5) goto LAB_00101440; } uVar4 = uVar3 + 1; if ((int)param_2 <= (int)uVar4) goto LAB_00101428; piVar5 = piVar2; } while (iVar1 == *(int *)(param_1 + uVar4 * 4)); uVar4 = uVar3 + 2; if ((int)param_2 <= (int)uVar4) goto LAB_00101428; } uVar4 = uVar4 + 1; } while ((int)uVar4 < (int)param_2); LAB_00101428: uVar6 = uVar6 + 1; } while (uVar6 != param_2); } LAB_00101431: *param_3 = iVar7; return; }
6,532
func0
#include <assert.h>
int func0(int l1, int r1, int l2, int r2, int *x, int *y) { *x = (l1 != l2) ? ((l1 < l2) ? l1 : l2) : -1; *y = (r1 != r2) ? ((r1 > r2) ? r1 : r2) : -1; return 0; }
int main() { int x, y; func0(5, 10, 1, 5, &x, &y); assert(x == 1 && y == 10); func0(3, 5, 7, 9, &x, &y); assert(x == 3 && y == 9); func0(1, 5, 2, 8, &x, &y); assert(x == 1 && y == 8); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x4(%rbp) mov %esi,-0x8(%rbp) mov %edx,-0xc(%rbp) mov %ecx,-0x10(%rbp) mov %r8,-0x18(%rbp) mov %r9,-0x20(%rbp) mov -0x4(%rbp),%eax cmp -0xc(%rbp),%eax je 1199 <func0+0x30> mov -0x4(%rbp),%eax cmp %eax,-0xc(%rbp) cmovle -0xc(%rbp),%eax jmp 119e <func0+0x35> mov $0xffffffff,%eax mov -0x18(%rbp),%rdx mov %eax,(%rdx) mov -0x8(%rbp),%eax cmp -0x10(%rbp),%eax je 11b8 <func0+0x4f> mov -0x8(%rbp),%eax cmp %eax,-0x10(%rbp) cmovge -0x10(%rbp),%eax jmp 11bd <func0+0x54> mov $0xffffffff,%eax mov -0x20(%rbp),%rdx mov %eax,(%rdx) mov $0x0,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_4], edi mov [rbp+var_8], esi mov [rbp+var_C], edx mov [rbp+var_10], ecx mov [rbp+var_18], r8 mov [rbp+var_20], r9 mov eax, [rbp+var_4] cmp eax, [rbp+var_C] jz short loc_119A mov edx, [rbp+var_C] mov eax, [rbp+var_4] cmp edx, eax cmovle eax, edx jmp short loc_119F loc_119A: mov eax, 0FFFFFFFFh loc_119F: mov rdx, [rbp+var_18] mov [rdx], eax mov eax, [rbp+var_8] cmp eax, [rbp+var_10] jz short loc_11BA mov edx, [rbp+var_10] mov eax, [rbp+var_8] cmp edx, eax cmovge eax, edx jmp short loc_11BF loc_11BA: mov eax, 0FFFFFFFFh loc_11BF: mov rdx, [rbp+var_20] mov [rdx], eax mov eax, 0 pop rbp retn
long long func0(int a1, int a2, int a3, int a4, int *a5, int *a6) { int v6; // eax int v7; // eax if ( a1 == a3 ) { v6 = -1; } else { v6 = a1; if ( a3 <= a1 ) v6 = a3; } *a5 = v6; if ( a2 == a4 ) { v7 = -1; } else { v7 = a2; if ( a4 >= a2 ) v7 = a4; } *a6 = v7; return 0LL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x4],EDI MOV dword ptr [RBP + -0x8],ESI MOV dword ptr [RBP + -0xc],EDX MOV dword ptr [RBP + -0x10],ECX MOV qword ptr [RBP + -0x18],R8 MOV qword ptr [RBP + -0x20],R9 MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0xc] JZ 0x0010119a MOV EDX,dword ptr [RBP + -0xc] MOV EAX,dword ptr [RBP + -0x4] CMP EDX,EAX CMOVLE EAX,EDX JMP 0x0010119f LAB_0010119a: MOV EAX,0xffffffff LAB_0010119f: MOV RDX,qword ptr [RBP + -0x18] MOV dword ptr [RDX],EAX MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x10] JZ 0x001011ba MOV EDX,dword ptr [RBP + -0x10] MOV EAX,dword ptr [RBP + -0x8] CMP EDX,EAX CMOVGE EAX,EDX JMP 0x001011bf LAB_001011ba: MOV EAX,0xffffffff LAB_001011bf: MOV RDX,qword ptr [RBP + -0x20] MOV dword ptr [RDX],EAX MOV EAX,0x0 POP RBP RET
int8 func0(int param_1,int param_2,int param_3,int param_4,int *param_5,int *param_6) { if (param_1 == param_3) { param_1 = -1; } else if (param_3 <= param_1) { param_1 = param_3; } *param_5 = param_1; if (param_2 == param_4) { param_2 = -1; } else if (param_2 <= param_4) { param_2 = param_4; } *param_6 = param_2; return 0; }
6,533
func0
#include <assert.h>
int func0(int l1, int r1, int l2, int r2, int *x, int *y) { *x = (l1 != l2) ? ((l1 < l2) ? l1 : l2) : -1; *y = (r1 != r2) ? ((r1 > r2) ? r1 : r2) : -1; return 0; }
int main() { int x, y; func0(5, 10, 1, 5, &x, &y); assert(x == 1 && y == 10); func0(3, 5, 7, 9, &x, &y); assert(x == 3 && y == 9); func0(1, 5, 2, 8, &x, &y); assert(x == 1 && y == 8); return 0; }
O1
c
func0: endbr64 mov $0xffffffff,%eax cmp %edx,%edi je 113b <func0+0x12> mov %edx,%eax cmovle %edi,%eax mov %eax,(%r8) mov $0xffffffff,%eax cmp %ecx,%esi je 114c <func0+0x23> mov %ecx,%eax cmovge %esi,%eax mov %eax,(%r9) mov $0x0,%eax retq
func0: endbr64 mov eax, esi cmp edi, edx mov esi, edx cmovle esi, edi mov edx, 0FFFFFFFFh cmovnz edx, esi mov [r8], edx cmp eax, ecx mov edx, ecx cmovge edx, eax mov eax, 0FFFFFFFFh cmovnz eax, edx mov [r9], eax mov eax, 0 retn
long long func0(int a1, int a2, int a3, int a4, int *a5, int *a6) { bool v7; // zf int v8; // esi int v9; // edx bool v10; // zf int v11; // edx int v12; // eax v7 = a1 == a3; v8 = a3; if ( a1 <= a3 ) v8 = a1; v9 = -1; if ( !v7 ) v9 = v8; *a5 = v9; v10 = a2 == a4; v11 = a4; if ( a2 >= a4 ) v11 = a2; v12 = -1; if ( !v10 ) v12 = v11; *a6 = v12; return 0LL; }
func0: ENDBR64 MOV EAX,ESI CMP EDI,EDX MOV ESI,EDX CMOVLE ESI,EDI MOV EDX,0xffffffff CMOVNZ EDX,ESI MOV dword ptr [R8],EDX CMP EAX,ECX MOV EDX,ECX CMOVGE EDX,EAX MOV EAX,0xffffffff CMOVNZ EAX,EDX MOV dword ptr [R9],EAX MOV EAX,0x0 RET
int8 func0(int param_1,int param_2,int param_3,int param_4,int *param_5,int *param_6) { int iVar1; int iVar2; iVar2 = param_3; if (param_1 == param_3 || param_1 < param_3) { iVar2 = param_1; } iVar1 = -1; if (param_1 != param_3) { iVar1 = iVar2; } *param_5 = iVar1; iVar2 = param_4; if (param_4 <= param_2) { iVar2 = param_2; } iVar1 = -1; if (param_2 != param_4) { iVar1 = iVar2; } *param_6 = iVar1; return 0; }
6,534
func0
#include <assert.h>
int func0(int l1, int r1, int l2, int r2, int *x, int *y) { *x = (l1 != l2) ? ((l1 < l2) ? l1 : l2) : -1; *y = (r1 != r2) ? ((r1 > r2) ? r1 : r2) : -1; return 0; }
int main() { int x, y; func0(5, 10, 1, 5, &x, &y); assert(x == 1 && y == 10); func0(3, 5, 7, 9, &x, &y); assert(x == 3 && y == 9); func0(1, 5, 2, 8, &x, &y); assert(x == 1 && y == 8); return 0; }
O2
c
func0: endbr64 mov $0xffffffff,%eax cmp %edx,%edi je 1152 <func0+0x12> mov %edx,%eax cmovle %edi,%eax mov %eax,(%r8) mov $0xffffffff,%eax cmp %ecx,%esi je 1163 <func0+0x23> mov %ecx,%eax cmovge %esi,%eax mov %eax,(%r9) xor %eax,%eax retq nopl 0x0(%rax)
func0: endbr64 cmp edi, edx mov eax, esi mov esi, edx mov r10d, 0FFFFFFFFh cmovle esi, edi mov edx, ecx cmovz esi, r10d cmp eax, ecx cmovge edx, eax mov eax, r10d mov [r8], esi cmovnz eax, edx mov [r9], eax xor eax, eax retn
long long func0(int a1, int a2, int a3, int a4, int *a5, int *a6) { bool v6; // zf int v8; // esi int v9; // edx bool v10; // zf int v11; // eax v6 = a1 == a3; v8 = a3; if ( a1 <= a3 ) v8 = a1; v9 = a4; if ( v6 ) v8 = -1; v10 = a2 == a4; if ( a2 >= a4 ) v9 = a2; v11 = -1; *a5 = v8; if ( !v10 ) v11 = v9; *a6 = v11; return 0LL; }
func0: ENDBR64 CMP EDI,EDX MOV EAX,ESI MOV ESI,EDX MOV R10D,0xffffffff CMOVLE ESI,EDI MOV EDX,ECX CMOVZ ESI,R10D CMP EAX,ECX CMOVGE EDX,EAX MOV EAX,R10D MOV dword ptr [R8],ESI CMOVNZ EAX,EDX MOV dword ptr [R9],EAX XOR EAX,EAX RET
int8 func0(int param_1,int param_2,int param_3,int param_4,int *param_5,int *param_6) { int iVar1; int iVar2; iVar2 = param_3; if (param_1 <= param_3) { iVar2 = param_1; } if (param_1 == param_3) { iVar2 = -1; } iVar1 = param_4; if (param_4 <= param_2) { iVar1 = param_2; } *param_5 = iVar2; iVar2 = -1; if (param_2 != param_4) { iVar2 = iVar1; } *param_6 = iVar2; return 0; }
6,535
func0
#include <assert.h>
int func0(int l1, int r1, int l2, int r2, int *x, int *y) { *x = (l1 != l2) ? ((l1 < l2) ? l1 : l2) : -1; *y = (r1 != r2) ? ((r1 > r2) ? r1 : r2) : -1; return 0; }
int main() { int x, y; func0(5, 10, 1, 5, &x, &y); assert(x == 1 && y == 10); func0(3, 5, 7, 9, &x, &y); assert(x == 3 && y == 9); func0(1, 5, 2, 8, &x, &y); assert(x == 1 && y == 8); return 0; }
O3
c
func0: endbr64 mov $0xffffffff,%eax cmp %edx,%edi je 1152 <func0+0x12> mov %edx,%eax cmovle %edi,%eax mov %eax,(%r8) mov $0xffffffff,%eax cmp %ecx,%esi je 1163 <func0+0x23> mov %ecx,%eax cmovge %esi,%eax mov %eax,(%r9) xor %eax,%eax retq nopl 0x0(%rax)
func0: endbr64 cmp edi, edx mov eax, esi mov esi, edx mov r10d, 0FFFFFFFFh cmovle esi, edi mov edx, ecx cmovz esi, r10d cmp eax, ecx cmovge edx, eax mov eax, r10d mov [r8], esi cmovnz eax, edx mov [r9], eax xor eax, eax retn
long long func0(int a1, int a2, int a3, int a4, int *a5, int *a6) { bool v6; // zf int v8; // esi int v9; // edx bool v10; // zf int v11; // eax v6 = a1 == a3; v8 = a3; if ( a1 <= a3 ) v8 = a1; v9 = a4; if ( v6 ) v8 = -1; v10 = a2 == a4; if ( a2 >= a4 ) v9 = a2; v11 = -1; *a5 = v8; if ( !v10 ) v11 = v9; *a6 = v11; return 0LL; }
func0: ENDBR64 CMP EDI,EDX MOV EAX,ESI MOV ESI,EDX MOV R10D,0xffffffff CMOVLE ESI,EDI MOV EDX,ECX CMOVZ ESI,R10D CMP EAX,ECX CMOVGE EDX,EAX MOV EAX,R10D MOV dword ptr [R8],ESI CMOVNZ EAX,EDX MOV dword ptr [R9],EAX XOR EAX,EAX RET
int8 func0(int param_1,int param_2,int param_3,int param_4,int *param_5,int *param_6) { int iVar1; int iVar2; iVar2 = param_3; if (param_1 <= param_3) { iVar2 = param_1; } if (param_1 == param_3) { iVar2 = -1; } iVar1 = param_4; if (param_4 <= param_2) { iVar1 = param_2; } *param_5 = iVar2; iVar2 = -1; if (param_2 != param_4) { iVar2 = iVar1; } *param_6 = iVar2; return 0; }
6,536
func0
#include <stdio.h> #include <assert.h>
int func0(int arr[], int n) { int sum[n]; if (n >= 1) sum[0] = arr[0]; if (n >= 2) sum[1] = arr[0] + arr[1]; if (n > 2) sum[2] = (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) > (arr[0] + arr[2]) ? (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) : (arr[0] + arr[2]); for (int i = 3; i < n; i++) { int max1 = sum[i - 1]; int max2 = sum[i - 2] + arr[i]; int max3 = arr[i] + arr[i - 1] + sum[i - 3]; sum[i] = (max1 > max2 ? max1 : max2) > max3 ? (max1 > max2 ? max1 : max2) : max3; } return sum[n - 1]; }
int main() { assert(func0((int[]){100, 1000, 100, 1000, 1}, 5) == 2101); assert(func0((int[]){3000, 2000, 1000, 3, 10}, 5) == 5013); assert(func0((int[]){1, 2, 3, 4, 5, 6, 7, 8}, 8) == 27); printf("All tests passed.\n"); 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 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 1228 <func0+0x9f> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 1211 <func0+0x88> mov %rax,%rdx and $0xfff,%edx sub %rdx,%rsp mov %rax,%rdx and $0xfff,%edx test %rdx,%rdx je 1252 <func0+0xc9> 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) cmpl $0x0,-0x4c(%rbp) jle 1277 <func0+0xee> mov -0x48(%rbp),%rax mov (%rax),%edx mov -0x20(%rbp),%rax mov %edx,(%rax) cmpl $0x1,-0x4c(%rbp) jle 1296 <func0+0x10d> mov -0x48(%rbp),%rax mov (%rax),%edx mov -0x48(%rbp),%rax add $0x4,%rax mov (%rax),%eax add %eax,%edx mov -0x20(%rbp),%rax mov %edx,0x4(%rax) cmpl $0x2,-0x4c(%rbp) jle 12dc <func0+0x153> mov -0x48(%rbp),%rax mov (%rax),%edx mov -0x48(%rbp),%rax add $0x8,%rax mov (%rax),%eax add %eax,%edx mov -0x48(%rbp),%rax add $0x4,%rax mov (%rax),%ecx mov -0x48(%rbp),%rax add $0x8,%rax mov (%rax),%eax add %eax,%ecx mov -0x20(%rbp),%rax mov 0x4(%rax),%eax cmp %eax,%ecx cmovge %ecx,%eax cmp %eax,%edx cmovl %eax,%edx mov -0x20(%rbp),%rax mov %edx,0x8(%rax) movl $0x3,-0x38(%rbp) jmpq 138e <func0+0x205> mov -0x38(%rbp),%eax lea -0x1(%rax),%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax mov %eax,-0x34(%rbp) mov -0x38(%rbp),%eax lea -0x2(%rax),%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%edx mov -0x38(%rbp),%eax cltq lea 0x0(,%rax,4),%rcx mov -0x48(%rbp),%rax add %rcx,%rax mov (%rax),%eax add %edx,%eax mov %eax,-0x30(%rbp) mov -0x38(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x48(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x38(%rbp),%eax cltq shl $0x2,%rax lea -0x4(%rax),%rcx mov -0x48(%rbp),%rax add %rcx,%rax mov (%rax),%eax lea (%rdx,%rax,1),%ecx mov -0x38(%rbp),%eax lea -0x3(%rax),%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax add %ecx,%eax mov %eax,-0x2c(%rbp) mov -0x34(%rbp),%eax cmp %eax,-0x30(%rbp) cmovge -0x30(%rbp),%eax cmp %eax,-0x2c(%rbp) cmovge -0x2c(%rbp),%eax mov %eax,%ecx mov -0x20(%rbp),%rax mov -0x38(%rbp),%edx movslq %edx,%rdx mov %ecx,(%rax,%rdx,4) addl $0x1,-0x38(%rbp) mov -0x38(%rbp),%eax cmp -0x4c(%rbp),%eax jl 12e8 <func0+0x15f> mov -0x4c(%rbp),%eax lea -0x1(%rax),%edx mov -0x20(%rbp),%rax movslq %edx,%rdx mov (%rax,%rdx,4),%eax mov %rsi,%rsp mov -0x18(%rbp),%rdi xor %fs:0x28,%rdi je 13c1 <func0+0x238> callq 1080 <__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 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_11F6: cmp rsp, rdx jz short loc_120D sub rsp, 1000h or [rsp+1040h+var_48], 0 jmp short loc_11F6 loc_120D: mov rdx, rax and edx, 0FFFh sub rsp, rdx mov rdx, rax and edx, 0FFFh test rdx, rdx jz short loc_1237 and eax, 0FFFh sub rax, 8 add rax, rsp or qword ptr [rax], 0 loc_1237: mov rax, rsp add rax, 3 shr rax, 2 shl rax, 2 mov [rbp+var_10], rax cmp [rbp+var_3C], 0 jle short loc_125C mov rax, [rbp+var_38] mov edx, [rax] mov rax, [rbp+var_10] mov [rax], edx loc_125C: cmp [rbp+var_3C], 1 jle short loc_127B mov rax, [rbp+var_38] mov edx, [rax] mov rax, [rbp+var_38] add rax, 4 mov eax, [rax] add edx, eax mov rax, [rbp+var_10] mov [rax+4], edx loc_127B: cmp [rbp+var_3C], 2 jle short loc_12C1 mov rax, [rbp+var_38] mov edx, [rax] mov rax, [rbp+var_38] add rax, 8 mov eax, [rax] add edx, eax mov rax, [rbp+var_38] add rax, 4 mov ecx, [rax] mov rax, [rbp+var_38] add rax, 8 mov eax, [rax] add ecx, eax mov rax, [rbp+var_10] mov eax, [rax+4] cmp ecx, eax cmovge eax, ecx cmp edx, eax cmovl edx, eax mov rax, [rbp+var_10] mov [rax+8], edx loc_12C1: mov [rbp+var_28], 3 jmp loc_1375 loc_12CD: mov eax, [rbp+var_28] lea edx, [rax-1] mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] mov [rbp+var_24], eax mov eax, [rbp+var_28] lea edx, [rax-2] mov rax, [rbp+var_10] movsxd rdx, edx mov edx, [rax+rdx*4] mov eax, [rbp+var_28] cdqe lea rcx, ds:0[rax*4] mov rax, [rbp+var_38] add rax, rcx mov eax, [rax] add eax, edx mov [rbp+var_20], eax mov eax, [rbp+var_28] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] add rax, rdx mov edx, [rax] mov eax, [rbp+var_28] cdqe shl rax, 2 lea rcx, [rax-4] mov rax, [rbp+var_38] add rax, rcx mov eax, [rax] lea ecx, [rdx+rax] mov eax, [rbp+var_28] lea edx, [rax-3] mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] add eax, ecx mov [rbp+var_1C], eax mov edx, [rbp+var_20] mov eax, [rbp+var_24] cmp edx, eax cmovl edx, eax mov eax, [rbp+var_1C] cmp edx, eax cmovge eax, edx mov ecx, eax mov rax, [rbp+var_10] mov edx, [rbp+var_28] movsxd rdx, edx mov [rax+rdx*4], ecx add [rbp+var_28], 1 loc_1375: mov eax, [rbp+var_28] cmp eax, [rbp+var_3C] jl loc_12CD mov eax, [rbp+var_3C] lea edx, [rax-1] mov rax, [rbp+var_10] movsxd rdx, edx mov eax, [rax+rdx*4] mov rsp, rsi mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_13A8 call ___stack_chk_fail locret_13A8: leave retn
long long func0(_DWORD *a1, int a2) { unsigned long long v2; // rax void *v3; // rsp int v4; // edx int v5; // eax int v6; // edx int v7; // eax _BYTE v9[4]; // [rsp+8h] [rbp-40h] BYREF int v10; // [rsp+Ch] [rbp-3Ch] _DWORD *v11; // [rsp+10h] [rbp-38h] int i; // [rsp+20h] [rbp-28h] int v13; // [rsp+24h] [rbp-24h] int v14; // [rsp+28h] [rbp-20h] int v15; // [rsp+2Ch] [rbp-1Ch] long long v16; // [rsp+30h] [rbp-18h] _DWORD *v17; // [rsp+38h] [rbp-10h] unsigned long long v18; // [rsp+40h] [rbp-8h] v11 = a1; v10 = a2; v18 = __readfsqword(0x28u); v16 = a2 - 1LL; v2 = 16 * ((4LL * a2 + 15) / 0x10uLL); while ( v9 != &v9[-(v2 & 0xFFFFFFFFFFFFF000LL)] ) ; v3 = alloca(v2 & 0xFFF); if ( (v2 & 0xFFF) != 0 ) *(_QWORD *)&v9[(v2 & 0xFFF) - 8] = *(_QWORD *)&v9[(v2 & 0xFFF) - 8]; v17 = v9; if ( v10 > 0 ) *v17 = *v11; if ( v10 > 1 ) v17[1] = v11[1] + *v11; if ( v10 > 2 ) { v4 = v11[2] + *v11; v5 = v17[1]; if ( v11[2] + v11[1] >= v5 ) v5 = v11[2] + v11[1]; if ( v4 < v5 ) v4 = v5; v17[2] = v4; } for ( i = 3; i < v10; ++i ) { v13 = v17[i - 1]; v14 = v17[i - 2] + v11[i]; v15 = v11[i] + v11[i - 1] + v17[i - 3]; v6 = v14; if ( v14 < v13 ) v6 = v13; v7 = v15; if ( v6 >= v15 ) v7 = v6; v17[i] = v7; } return (unsigned int)v17[v10 - 1]; }
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 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_001011f6: CMP RSP,RDX JZ 0x0010120d SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011f6 LAB_0010120d: MOV RDX,RAX AND EDX,0xfff SUB RSP,RDX MOV RDX,RAX AND EDX,0xfff TEST RDX,RDX JZ 0x00101237 AND EAX,0xfff SUB RAX,0x8 ADD RAX,RSP OR qword ptr [RAX],0x0 LAB_00101237: MOV RAX,RSP ADD RAX,0x3 SHR RAX,0x2 SHL RAX,0x2 MOV qword ptr [RBP + -0x10],RAX CMP dword ptr [RBP + -0x3c],0x0 JLE 0x0010125c MOV RAX,qword ptr [RBP + -0x38] MOV EDX,dword ptr [RAX] MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX],EDX LAB_0010125c: CMP dword ptr [RBP + -0x3c],0x1 JLE 0x0010127b MOV RAX,qword ptr [RBP + -0x38] MOV EDX,dword ptr [RAX] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,0x4 MOV EAX,dword ptr [RAX] ADD EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX + 0x4],EDX LAB_0010127b: CMP dword ptr [RBP + -0x3c],0x2 JLE 0x001012c1 MOV RAX,qword ptr [RBP + -0x38] MOV EDX,dword ptr [RAX] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,0x8 MOV EAX,dword ptr [RAX] ADD EDX,EAX MOV RAX,qword ptr [RBP + -0x38] ADD RAX,0x4 MOV ECX,dword ptr [RAX] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,0x8 MOV EAX,dword ptr [RAX] ADD ECX,EAX MOV RAX,qword ptr [RBP + -0x10] MOV EAX,dword ptr [RAX + 0x4] CMP ECX,EAX CMOVGE EAX,ECX CMP EDX,EAX CMOVL EDX,EAX MOV RAX,qword ptr [RBP + -0x10] MOV dword ptr [RAX + 0x8],EDX LAB_001012c1: MOV dword ptr [RBP + -0x28],0x3 JMP 0x00101375 LAB_001012cd: MOV EAX,dword ptr [RBP + -0x28] LEA EDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV EAX,dword ptr [RAX + RDX*0x4] MOV dword ptr [RBP + -0x24],EAX MOV EAX,dword ptr [RBP + -0x28] LEA EDX,[RAX + -0x2] MOV RAX,qword ptr [RBP + -0x10] MOVSXD RDX,EDX MOV EDX,dword ptr [RAX + RDX*0x4] MOV EAX,dword ptr [RBP + -0x28] CDQE LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RCX MOV EAX,dword ptr [RAX] ADD EAX,EDX MOV dword ptr [RBP + -0x20],EAX MOV EAX,dword ptr [RBP + -0x28] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x28] CDQE SHL RAX,0x2 LEA RCX,[RAX + -0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RAX,RCX MOV EAX,dword ptr [RAX] LEA ECX,[RDX + RAX*0x1] MOV EAX,dword ptr [RBP + -0x28] LEA EDX,[RAX + -0x3] 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 EDX,dword ptr [RBP + -0x20] MOV EAX,dword ptr [RBP + -0x24] CMP EDX,EAX CMOVL EDX,EAX MOV EAX,dword ptr [RBP + -0x1c] CMP EDX,EAX CMOVGE EAX,EDX MOV ECX,EAX MOV RAX,qword ptr [RBP + -0x10] MOV EDX,dword ptr [RBP + -0x28] MOVSXD RDX,EDX MOV dword ptr [RAX + RDX*0x4],ECX ADD dword ptr [RBP + -0x28],0x1 LAB_00101375: MOV EAX,dword ptr [RBP + -0x28] CMP EAX,dword ptr [RBP + -0x3c] JL 0x001012cd MOV EAX,dword ptr [RBP + -0x3c] LEA EDX,[RAX + -0x1] MOV RAX,qword ptr [RBP + -0x10] 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 0x001013a8 CALL 0x00101080 LAB_001013a8: LEAVE RET
int4 func0(int *param_1,int param_2) { long lVar1; int iVar2; int iVar3; ulong uVar4; int *puVar5; long in_FS_OFFSET; int auStack_48 [4]; int local_44; int *local_40; 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_20 = (long)param_2 + -1; uVar4 = (((long)param_2 * 4 + 0xfU) / 0x10) * 0x10; for (puVar5 = auStack_48; puVar5 != auStack_48 + -(uVar4 & 0xfffffffffffff000); puVar5 = puVar5 + -0x1000) { *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); } lVar1 = -(ulong)((uint)uVar4 & 0xfff); if ((uVar4 & 0xfff) != 0) { *(int8 *)(puVar5 + ((ulong)((uint)uVar4 & 0xfff) - 8) + lVar1) = *(int8 *)(puVar5 + ((ulong)((uint)uVar4 & 0xfff) - 8) + lVar1); } if (0 < local_44) { *(int *)(puVar5 + lVar1) = *local_40; } if (1 < local_44) { *(int *)(puVar5 + lVar1 + 4) = *local_40 + local_40[1]; } if (2 < local_44) { iVar2 = *(int *)(puVar5 + lVar1 + 4); if (*(int *)(puVar5 + lVar1 + 4) <= local_40[1] + local_40[2]) { iVar2 = local_40[1] + local_40[2]; } iVar3 = *local_40 + local_40[2]; if (*local_40 + local_40[2] < iVar2) { iVar3 = iVar2; } *(int *)(puVar5 + lVar1 + 8) = iVar3; } for (local_30 = 3; local_30 < local_44; local_30 = local_30 + 1) { local_2c = *(int *)(puVar5 + (long)(local_30 + -1) * 4 + lVar1); local_28 = local_40[local_30] + *(int *)(puVar5 + (long)(local_30 + -2) * 4 + lVar1); local_24 = *(int *)(puVar5 + (long)(local_30 + -3) * 4 + lVar1) + local_40[local_30] + local_40[(long)local_30 + -1]; iVar2 = local_28; if (local_28 < local_2c) { iVar2 = local_2c; } iVar3 = local_24; if (local_24 <= iVar2) { iVar3 = iVar2; } *(int *)(puVar5 + (long)local_30 * 4 + lVar1) = iVar3; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { local_18 = puVar5 + lVar1; /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return *(int4 *)(puVar5 + (long)(local_44 + -1) * 4 + lVar1); }
6,537
func0
#include <stdio.h> #include <assert.h>
int func0(int arr[], int n) { int sum[n]; if (n >= 1) sum[0] = arr[0]; if (n >= 2) sum[1] = arr[0] + arr[1]; if (n > 2) sum[2] = (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) > (arr[0] + arr[2]) ? (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) : (arr[0] + arr[2]); for (int i = 3; i < n; i++) { int max1 = sum[i - 1]; int max2 = sum[i - 2] + arr[i]; int max3 = arr[i] + arr[i - 1] + sum[i - 3]; sum[i] = (max1 > max2 ? max1 : max2) > max3 ? (max1 > max2 ? max1 : max2) : max3; } return sum[n - 1]; }
int main() { assert(func0((int[]){100, 1000, 100, 1000, 1}, 5) == 2101); assert(func0((int[]){3000, 2000, 1000, 3, 10}, 5) == 5013); assert(func0((int[]){1, 2, 3, 4, 5, 6, 7, 8}, 8) == 27); printf("All tests passed.\n"); 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 movslq %esi,%rax lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffffff0,%rdx and $0xfffffffffffff000,%rax mov %rsp,%rcx sub %rax,%rcx mov %rcx,%rax cmp %rax,%rsp je 11dc <func0+0x53> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) jmp 11c5 <func0+0x3c> mov %rdx,%rax and $0xfff,%eax sub %rax,%rsp test %rax,%rax je 11f2 <func0+0x69> orq $0x0,-0x8(%rsp,%rax,1) lea 0x3(%rsp),%r9 mov %r9,%rcx shr $0x2,%rcx and $0xfffffffffffffffc,%r9 test %esi,%esi jle 120f <func0+0x86> mov (%rdi),%eax mov %eax,0x0(,%rcx,4) cmp $0x1,%esi jle 1220 <func0+0x97> mov 0x4(%rdi),%eax add (%rdi),%eax mov %eax,0x4(,%rcx,4) cmp $0x2,%esi jle 1247 <func0+0xbe> mov 0x8(%rdi),%edx mov %edx,%eax add (%rdi),%eax add 0x4(%rdi),%edx cmp %edx,%eax cmovl %edx,%eax mov 0x4(,%rcx,4),%edx cmp %edx,%eax cmovl %edx,%eax mov %eax,0x8(,%rcx,4) cmp $0x3,%esi jle 1287 <func0+0xfe> mov %r9,%rcx add $0x8,%rdi lea -0x4(%rsi),%eax lea 0x4(%r9,%rax,4),%r10 mov 0x4(%rdi),%edx mov %edx,%eax add 0x4(%rcx),%eax mov 0x8(%rcx),%r8d cmp %r8d,%eax cmovl %r8d,%eax add (%rdi),%edx add (%rcx),%edx cmp %edx,%eax cmovl %edx,%eax mov %eax,0xc(%rcx) add $0x4,%rcx add $0x4,%rdi cmp %r10,%rcx jne 125b <func0+0xd2> sub $0x1,%esi movslq %esi,%rsi mov (%r9,%rsi,4),%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi jne 12a2 <func0+0x119> leaveq retq callq 1080 <__stack_chk_fail@plt>
func0: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov rax, rdi mov r8d, esi mov rdx, fs:28h mov [rbp+var_8], rdx xor edx, edx movsxd rdx, esi lea rdx, ds:0Fh[rdx*4] mov rsi, rdx and rsi, 0FFFFFFFFFFFFFFF0h and rdx, 0FFFFFFFFFFFFF000h mov rcx, rsp sub rcx, rdx loc_11C9: cmp rsp, rcx jz short loc_11E0 sub rsp, 1000h or [rsp+1010h+var_18], 0 jmp short loc_11C9 loc_11E0: mov rdx, rsi and edx, 0FFFh sub rsp, rdx test rdx, rdx jz short loc_11F7 or [rsp+rdx+10h+var_18], 0 loc_11F7: lea r9, [rsp+10h+var_D] mov rsi, r9 shr rsi, 2 and r9, 0FFFFFFFFFFFFFFFCh test r8d, r8d jle short loc_1215 mov edx, [rax] mov ds:dword_0[rsi*4], edx loc_1215: cmp r8d, 1 jle short loc_1227 mov edx, [rax+4] add edx, [rax] mov dword ptr ds:byte_4[rsi*4], edx loc_1227: cmp r8d, 2 jle short loc_124F mov ecx, [rax+8] mov edx, ecx add edx, [rax] add ecx, [rax+4] cmp edx, ecx cmovl edx, ecx mov ecx, dword ptr ds:byte_4[rsi*4] cmp edx, ecx cmovl edx, ecx mov dword ptr ds:byte_8[rsi*4], edx loc_124F: cmp r8d, 3 jle short loc_128D mov rcx, r9 lea rsi, [rax+8] lea eax, [r8-3] lea r10, [r9+rax*4] loc_1264: mov edx, [rsi+4] mov eax, edx add eax, [rcx+4] mov edi, [rcx+8] cmp eax, edi cmovl eax, edi add edx, [rsi] add edx, [rcx] cmp eax, edx cmovl eax, edx mov [rcx+0Ch], eax add rcx, 4 add rsi, 4 cmp rcx, r10 jnz short loc_1264 loc_128D: sub r8d, 1 movsxd r8, r8d mov eax, [r9+r8*4] mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_12A9 leave retn loc_12A9: call ___stack_chk_fail
long long func0(int *a1, int a2) { long long v3; // rdx __int16 v4; // si signed long long v5; // rdx void *v6; // rsp int v7; // edx int *v8; // rcx _DWORD *v9; // rsi int v10; // eax long long v12; // [rsp+0h] [rbp-18h] int v13; // [rsp+8h] [rbp-10h] BYREF int v14; // [rsp+Ch] [rbp-Ch] unsigned long long v15; // [rsp+10h] [rbp-8h] v15 = __readfsqword(0x28u); v3 = 4LL * a2 + 15; v4 = (4 * a2 + 15) & 0xFFF0; while ( &v13 != (int *)((char *)&v13 - (v3 & 0xFFFFFFFFFFFFF000LL)) ) ; v5 = v4 & 0xFFF; v6 = alloca(v5); if ( (v4 & 0xFFF) != 0 ) *(long long *)((char *)&v12 + v5) = *(long long *)((char *)&v12 + v5); if ( a2 > 0 ) v13 = *a1; if ( a2 > 1 ) v14 = *a1 + a1[1]; if ( a2 > 2 ) { v7 = *a1 + a1[2]; if ( v7 < a1[1] + a1[2] ) v7 = a1[1] + a1[2]; if ( v7 < v14 ) v7 = v14; LODWORD(v15) = v7; } if ( a2 > 3 ) { v8 = &v13; v9 = a1 + 2; do { v10 = v8[1] + v9[1]; if ( v10 < v8[2] ) v10 = v8[2]; if ( v10 < *v8 + *v9 + v9[1] ) v10 = *v8 + *v9 + v9[1]; v8[3] = v10; ++v8; ++v9; } while ( v8 != &v13 + (unsigned int)(a2 - 3) ); } return (unsigned int)*(&v13 + a2 - 1); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV RAX,RDI MOV R8D,ESI MOV RDX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RDX XOR EDX,EDX MOVSXD RDX,ESI LEA RDX,[0xf + RDX*0x4] MOV RSI,RDX AND RSI,-0x10 AND RDX,-0x1000 MOV RCX,RSP SUB RCX,RDX LAB_001011c9: CMP RSP,RCX JZ 0x001011e0 SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 JMP 0x001011c9 LAB_001011e0: MOV RDX,RSI AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JZ 0x001011f7 OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 LAB_001011f7: LEA R9,[RSP + 0x3] MOV RSI,R9 SHR RSI,0x2 AND R9,-0x4 TEST R8D,R8D JLE 0x00101215 MOV EDX,dword ptr [RAX] MOV dword ptr [RSI*0x4],EDX LAB_00101215: CMP R8D,0x1 JLE 0x00101227 MOV EDX,dword ptr [RAX + 0x4] ADD EDX,dword ptr [RAX] MOV dword ptr [0x4 + RSI*0x4],EDX LAB_00101227: CMP R8D,0x2 JLE 0x0010124f MOV ECX,dword ptr [RAX + 0x8] MOV EDX,ECX ADD EDX,dword ptr [RAX] ADD ECX,dword ptr [RAX + 0x4] CMP EDX,ECX CMOVL EDX,ECX MOV ECX,dword ptr [0x4 + RSI*0x4] CMP EDX,ECX CMOVL EDX,ECX MOV dword ptr [0x8 + RSI*0x4],EDX LAB_0010124f: CMP R8D,0x3 JLE 0x0010128d MOV RCX,R9 LEA RSI,[RAX + 0x8] LEA EAX,[R8 + -0x3] LEA R10,[R9 + RAX*0x4] LAB_00101264: MOV EDX,dword ptr [RSI + 0x4] MOV EAX,EDX ADD EAX,dword ptr [RCX + 0x4] MOV EDI,dword ptr [RCX + 0x8] CMP EAX,EDI CMOVL EAX,EDI ADD EDX,dword ptr [RSI] ADD EDX,dword ptr [RCX] CMP EAX,EDX CMOVL EAX,EDX MOV dword ptr [RCX + 0xc],EAX ADD RCX,0x4 ADD RSI,0x4 CMP RCX,R10 JNZ 0x00101264 LAB_0010128d: SUB R8D,0x1 MOVSXD R8,R8D MOV EAX,dword ptr [R9 + R8*0x4] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x001012a9 LEAVE RET LAB_001012a9: CALL 0x00101080
int4 func0(int *param_1,int param_2) { long lVar1; int iVar2; int *piVar3; int iVar4; int1 *puVar5; ulong uVar6; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar6 = (long)param_2 * 4 + 0xf; for (puVar5 = auStack_18; puVar5 != auStack_18 + -(uVar6 & 0xfffffffffffff000); puVar5 = puVar5 + -0x1000) { *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); } uVar6 = (ulong)((uint)uVar6 & 0xff0); lVar1 = -uVar6; piVar3 = (int *)(puVar5 + lVar1); if (uVar6 != 0) { *(int8 *)(puVar5 + -8) = *(int8 *)(puVar5 + -8); } uVar6 = (ulong)(puVar5 + lVar1 + 3) >> 2; if (0 < param_2) { *(int *)(uVar6 * 4) = *param_1; } if (1 < param_2) { *(int *)(uVar6 * 4 + 4) = param_1[1] + *param_1; } if (2 < param_2) { iVar4 = param_1[2] + *param_1; iVar2 = param_1[2] + param_1[1]; if (iVar4 < iVar2) { iVar4 = iVar2; } iVar2 = *(int *)(uVar6 * 4 + 4); if (iVar4 < iVar2) { iVar4 = iVar2; } *(int *)(uVar6 * 4 + 8) = iVar4; } if (3 < param_2) { param_1 = param_1 + 2; do { iVar4 = param_1[1] + piVar3[1]; if (iVar4 < piVar3[2]) { iVar4 = piVar3[2]; } iVar2 = param_1[1] + *param_1 + *piVar3; if (iVar4 < iVar2) { iVar4 = iVar2; } piVar3[3] = iVar4; piVar3 = piVar3 + 1; param_1 = param_1 + 1; } while (piVar3 != (int *)(puVar5 + (ulong)(param_2 - 3) * 4 + lVar1)); } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return *(int4 *)(puVar5 + (long)(param_2 + -1) * 4 + lVar1); } /* WARNING: Subroutine does not return */ *(code **)(puVar5 + lVar1 + -8) = main; __stack_chk_fail(); }
6,538
func0
#include <stdio.h> #include <assert.h>
int func0(int arr[], int n) { int sum[n]; if (n >= 1) sum[0] = arr[0]; if (n >= 2) sum[1] = arr[0] + arr[1]; if (n > 2) sum[2] = (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) > (arr[0] + arr[2]) ? (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) : (arr[0] + arr[2]); for (int i = 3; i < n; i++) { int max1 = sum[i - 1]; int max2 = sum[i - 2] + arr[i]; int max3 = arr[i] + arr[i - 1] + sum[i - 3]; sum[i] = (max1 > max2 ? max1 : max2) > max3 ? (max1 > max2 ? max1 : max2) : max3; } return sum[n - 1]; }
int main() { assert(func0((int[]){100, 1000, 100, 1000, 1}, 5) == 2101); assert(func0((int[]){3000, 2000, 1000, 3, 10}, 5) == 5013); assert(func0((int[]){1, 2, 3, 4, 5, 6, 7, 8}, 8) == 27); printf("All tests passed.\n"); 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 1346 <func0+0x56> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1331 <func0+0x41> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 1410 <func0+0x120> lea 0x3(%rsp),%r9 mov %r9,%r8 and $0xfffffffffffffffc,%r9 shr $0x2,%r8 test %esi,%esi jle 13aa <func0+0xba> mov (%rdi),%eax mov %eax,0x0(,%r8,4) cmp $0x1,%esi je 13ec <func0+0xfc> mov 0x4(%rdi),%edx lea (%rax,%rdx,1),%ecx mov %ecx,0x4(,%r8,4) cmp $0x2,%esi je 13ec <func0+0xfc> mov 0x8(%rdi),%r10d add %r10d,%eax cmp %ecx,%eax cmovl %ecx,%eax add %r10d,%edx cmp %edx,%eax cmovl %edx,%eax mov %eax,0x8(,%r8,4) cmp $0x3,%esi jle 13ec <func0+0xfc> lea -0x4(%rsi),%eax mov %r9,%rcx add $0x8,%rdi lea 0x4(%r9,%rax,4),%r10 xchg %ax,%ax mov 0x4(%rdi),%edx mov 0x4(%rcx),%eax mov 0x8(%rcx),%r8d add %edx,%eax cmp %r8d,%eax cmovl %r8d,%eax add (%rdi),%edx add (%rcx),%edx cmp %edx,%eax cmovl %edx,%eax add $0x4,%rcx add $0x4,%rdi mov %eax,0x8(%rcx) cmp %rcx,%r10 jne 13c0 <func0+0xd0> sub $0x1,%esi movslq %esi,%rsi mov (%r9,%rsi,4),%eax mov -0x8(%rbp),%rsi xor %fs:0x28,%rsi jne 141b <func0+0x12b> leaveq retq nopw 0x0(%rax,%rax,1) orq $0x0,-0x8(%rsp,%rdx,1) jmpq 1358 <func0+0x68> callq 1080 <__stack_chk_fail@plt>
func0: endbr64 push rbp mov r8d, esi mov rax, rdi mov rbp, rsp sub rsp, 10h mov rdx, fs:28h mov [rbp+var_8], rdx xor edx, edx movsxd rdx, esi mov rsi, rsp lea rdx, ds:0Fh[rdx*4] mov rcx, rdx and rdx, 0FFFFFFFFFFFFF000h sub rsi, rdx and rcx, 0FFFFFFFFFFFFFFF0h cmp rsp, rsi jz short loc_134A loc_1335: sub rsp, 1000h or [rsp+1010h+var_18], 0 cmp rsp, rsi jnz short loc_1335 loc_134A: and ecx, 0FFFh sub rsp, rcx test rcx, rcx jnz loc_1408 loc_135C: lea r9, [rsp+1010h+var_100D] mov rdi, r9 and r9, 0FFFFFFFFFFFFFFFCh shr rdi, 2 test r8d, r8d jle short loc_13AA mov edx, [rax] mov ds:dword_0[rdi*4], edx cmp r8d, 1 jz short loc_13E9 mov ecx, [rax+4] lea esi, [rdx+rcx] mov dword ptr ds:byte_4[rdi*4], esi cmp r8d, 2 jz short loc_13E9 add edx, [rax+8] cmp edx, esi cmovl edx, esi add ecx, [rax+8] cmp edx, ecx cmovl edx, ecx mov dword ptr ds:byte_8[rdi*4], edx loc_13AA: cmp r8d, 3 jle short loc_13E9 lea rsi, [rax+8] lea eax, [r8-3] mov rcx, r9 lea r10, [r9+rax*4] nop loc_13C0: mov edx, [rsi+4] mov eax, [rcx+4] mov edi, [rcx+8] add eax, edx cmp eax, edi cmovl eax, edi add edx, [rsi] add edx, [rcx] cmp eax, edx cmovl eax, edx add rcx, 4 add rsi, 4 mov [rcx+8], eax cmp r10, rcx jnz short loc_13C0 loc_13E9: sub r8d, 1 movsxd r8, r8d mov eax, [r9+r8*4] mov rdx, [rbp+var_8] sub rdx, fs:28h jnz short loc_1413 leave retn loc_1408: or [rsp+rcx+1010h+var_1018], 0 jmp loc_135C loc_1413: call ___stack_chk_fail
long long func0(int *a1, int a2) { long long v3; // rcx _DWORD *v4; // rsi __int16 v5; // cx signed long long v6; // rcx void *v7; // rsp int v8; // edx int v9; // ecx int v10; // esi int v11; // edx int v12; // ecx _DWORD *v13; // rsi _DWORD *v14; // rcx int v15; // edx int v16; // eax int v17; // edx _DWORD v20[1022]; // [rsp+8h] [rbp-1010h] BYREF _QWORD v21[2]; // [rsp+1008h] [rbp-10h] BYREF v21[1] = __readfsqword(0x28u); v3 = 4LL * a2 + 15; v4 = (_DWORD *)((char *)v21 - (v3 & 0xFFFFFFFFFFFFF000LL)); v5 = v3 & 0xFFF0; if ( v21 != (_QWORD *)v4 ) { while ( v20 != v4 ) ; } v6 = v5 & 0xFFF; v7 = alloca(v6); if ( v6 ) *(_QWORD *)((char *)&v20[-2] + v6) = *(_QWORD *)((char *)&v20[-2] + v6); if ( a2 > 0 ) { v8 = *a1; v20[0] = *a1; if ( a2 == 1 ) return (unsigned int)v20[a2 - 1]; v9 = a1[1]; v10 = v8 + v9; v20[1] = v8 + v9; if ( a2 == 2 ) return (unsigned int)v20[a2 - 1]; v11 = a1[2] + v8; if ( v11 < v10 ) v11 = v10; v12 = a1[2] + v9; if ( v11 < v12 ) v11 = v12; v20[2] = v11; } if ( a2 > 3 ) { v13 = a1 + 2; v14 = v20; do { v15 = v13[1]; v16 = v15 + v14[1]; if ( v16 < v14[2] ) v16 = v14[2]; v17 = *v14 + *v13 + v15; if ( v16 < v17 ) v16 = v17; ++v14; ++v13; v14[2] = v16; } while ( &v20[a2 - 3] != v14 ); } return (unsigned int)v20[a2 - 1]; }
func0: ENDBR64 PUSH RBP MOV R8D,ESI MOV RAX,RDI MOV RBP,RSP SUB RSP,0x10 MOV RDX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RDX XOR EDX,EDX MOVSXD RDX,ESI MOV RSI,RSP LEA RDX,[0xf + RDX*0x4] MOV RCX,RDX AND RDX,-0x1000 SUB RSI,RDX AND RCX,-0x10 CMP RSP,RSI JZ 0x0010134a LAB_00101335: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RSI JNZ 0x00101335 LAB_0010134a: AND ECX,0xfff SUB RSP,RCX TEST RCX,RCX JNZ 0x00101408 LAB_0010135c: LEA R9,[RSP + 0x3] MOV RDI,R9 AND R9,-0x4 SHR RDI,0x2 TEST R8D,R8D JLE 0x001013aa MOV EDX,dword ptr [RAX] MOV dword ptr [RDI*0x4],EDX CMP R8D,0x1 JZ 0x001013e9 MOV ECX,dword ptr [RAX + 0x4] LEA ESI,[RDX + RCX*0x1] MOV dword ptr [0x4 + RDI*0x4],ESI CMP R8D,0x2 JZ 0x001013e9 ADD EDX,dword ptr [RAX + 0x8] CMP EDX,ESI CMOVL EDX,ESI ADD ECX,dword ptr [RAX + 0x8] CMP EDX,ECX CMOVL EDX,ECX MOV dword ptr [0x8 + RDI*0x4],EDX LAB_001013aa: CMP R8D,0x3 JLE 0x001013e9 LEA RSI,[RAX + 0x8] LEA EAX,[R8 + -0x3] MOV RCX,R9 LEA R10,[R9 + RAX*0x4] NOP LAB_001013c0: MOV EDX,dword ptr [RSI + 0x4] MOV EAX,dword ptr [RCX + 0x4] MOV EDI,dword ptr [RCX + 0x8] ADD EAX,EDX CMP EAX,EDI CMOVL EAX,EDI ADD EDX,dword ptr [RSI] ADD EDX,dword ptr [RCX] CMP EAX,EDX CMOVL EAX,EDX ADD RCX,0x4 ADD RSI,0x4 MOV dword ptr [RCX + 0x8],EAX CMP R10,RCX JNZ 0x001013c0 LAB_001013e9: SUB R8D,0x1 MOVSXD R8,R8D MOV EAX,dword ptr [R9 + R8*0x4] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x00101413 LEAVE RET LAB_00101408: OR qword ptr [RSP + RCX*0x1 + -0x8],0x0 JMP 0x0010135c LAB_00101413: CALL 0x00101080
int4 func0(int *param_1,int param_2) { long lVar1; int1 *puVar2; int iVar3; int iVar4; int *piVar5; int *piVar6; int iVar7; int1 *puVar8; int iVar10; ulong uVar11; long in_FS_OFFSET; int1 auStack_18 [8]; long local_10; int1 *puVar9; puVar8 = auStack_18; local_10 = *(long *)(in_FS_OFFSET + 0x28); uVar11 = (long)param_2 * 4 + 0xf; puVar9 = auStack_18; puVar2 = auStack_18; while (puVar9 != auStack_18 + -(uVar11 & 0xfffffffffffff000)) { puVar8 = puVar2 + -0x1000; *(int8 *)(puVar2 + -8) = *(int8 *)(puVar2 + -8); puVar9 = puVar2 + -0x1000; puVar2 = puVar2 + -0x1000; } uVar11 = (ulong)((uint)uVar11 & 0xff0); lVar1 = -uVar11; if (uVar11 != 0) { *(int8 *)(puVar8 + -8) = *(int8 *)(puVar8 + -8); } uVar11 = (ulong)(puVar8 + lVar1 + 3) >> 2; if (0 < param_2) { iVar3 = *param_1; *(int *)(uVar11 * 4) = iVar3; if (param_2 == 1) goto LAB_001013e9; iVar4 = param_1[1]; iVar10 = iVar3 + iVar4; *(int *)(uVar11 * 4 + 4) = iVar10; if (param_2 == 2) goto LAB_001013e9; iVar7 = iVar3 + param_1[2]; if (iVar3 + param_1[2] < iVar10) { iVar7 = iVar10; } iVar4 = iVar4 + param_1[2]; if (iVar7 < iVar4) { iVar7 = iVar4; } *(int *)(uVar11 * 4 + 8) = iVar7; } if (3 < param_2) { param_1 = param_1 + 2; piVar5 = (int *)(puVar8 + lVar1); do { iVar3 = piVar5[1] + param_1[1]; if (iVar3 < piVar5[2]) { iVar3 = piVar5[2]; } iVar4 = param_1[1] + *param_1 + *piVar5; if (iVar3 < iVar4) { iVar3 = iVar4; } piVar6 = piVar5 + 1; param_1 = param_1 + 1; piVar5[3] = iVar3; piVar5 = piVar6; } while ((int *)(puVar8 + (ulong)(param_2 - 3) * 4 + lVar1) != piVar6); } LAB_001013e9: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ *(code **)(puVar8 + lVar1 + -8) = _fini; __stack_chk_fail(); } return *(int4 *)(puVar8 + (long)(param_2 + -1) * 4 + lVar1); }
6,539
func0
#include <stdio.h> #include <assert.h>
int func0(int arr[], int n) { int sum[n]; if (n >= 1) sum[0] = arr[0]; if (n >= 2) sum[1] = arr[0] + arr[1]; if (n > 2) sum[2] = (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) > (arr[0] + arr[2]) ? (sum[1] > (arr[1] + arr[2]) ? sum[1] : (arr[1] + arr[2])) : (arr[0] + arr[2]); for (int i = 3; i < n; i++) { int max1 = sum[i - 1]; int max2 = sum[i - 2] + arr[i]; int max3 = arr[i] + arr[i - 1] + sum[i - 3]; sum[i] = (max1 > max2 ? max1 : max2) > max3 ? (max1 > max2 ? max1 : max2) : max3; } return sum[n - 1]; }
int main() { assert(func0((int[]){100, 1000, 100, 1000, 1}, 5) == 2101); assert(func0((int[]){3000, 2000, 1000, 3, 10}, 5) == 5013); assert(func0((int[]){1, 2, 3, 4, 5, 6, 7, 8}, 8) == 27); printf("All tests passed.\n"); return 0; }
O3
c
func0: endbr64 push %rbp mov %rsp,%rbp push %r14 push %r13 push %r12 push %rbx sub $0x10,%rsp mov %fs:0x28,%rax mov %rax,-0x28(%rbp) xor %eax,%eax movslq %esi,%rax mov %rsp,%rbx lea 0xf(,%rax,4),%rax mov %rax,%rdx and $0xfffffffffffff000,%rax sub %rax,%rbx and $0xfffffffffffffff0,%rdx mov %rbx,%rax cmp %rax,%rsp je 131d <func0+0x5d> sub $0x1000,%rsp orq $0x0,0xff8(%rsp) cmp %rax,%rsp jne 1308 <func0+0x48> and $0xfff,%edx sub %rdx,%rsp test %rdx,%rdx jne 1500 <func0+0x240> lea 0x3(%rsp),%r8 mov %r8,%rdx and $0xfffffffffffffffc,%r8 shr $0x2,%rdx test %esi,%esi jle 138a <func0+0xca> mov (%rdi),%eax mov %eax,0x0(,%rdx,4) cmp $0x1,%esi je 14d8 <func0+0x218> mov 0x4(%rdi),%ecx lea (%rax,%rcx,1),%r9d mov %r9d,0x4(,%rdx,4) cmp $0x2,%esi je 14d8 <func0+0x218> mov 0x8(%rdi),%r10d add %r10d,%eax cmp %r9d,%eax cmovl %r9d,%eax add %r10d,%ecx cmp %ecx,%eax cmovl %ecx,%eax mov %eax,0x8(,%rdx,4) cmp $0x3,%esi jle 14d8 <func0+0x218> lea -0x5(%rsi),%r13d cmp $0x9,%esi jle 150b <func0+0x24b> mov 0x0(,%rdx,4),%r10d mov 0x8(%rdi),%r11d lea 0xc(%rdi),%r12 lea 0xc(%r8),%rbx mov 0x4(,%rdx,4),%r9d mov 0x8(,%rdx,4),%edx mov $0x3,%eax mov (%r12),%r14d lea (%r14,%r9,1),%ecx cmp %edx,%ecx cmovl %edx,%ecx add %r14d,%r11d add %r11d,%r10d mov 0x8(%r12),%r11d cmp %r10d,%ecx cmovge %ecx,%r10d mov 0x4(%r12),%ecx add %ecx,%r14d mov %r10d,(%rbx) add %r14d,%r9d lea (%rdx,%rcx,1),%r14d cmp %r14d,%r9d cmovl %r14d,%r9d lea (%r10,%r11,1),%r14d cmp %r10d,%r9d cmovl %r10d,%r9d add %r11d,%ecx add %ecx,%edx mov 0x10(%r12),%ecx cmp %r14d,%edx mov %r9d,0x4(%rbx) cmovl %r14d,%edx cmp %r9d,%edx cmovl %r9d,%edx mov %edx,%r14d mov %edx,0x8(%rbx) mov 0xc(%r12),%edx add %edx,%r11d add %r11d,%r10d lea (%r9,%rdx,1),%r11d cmp %r11d,%r10d cmovl %r11d,%r10d mov 0x14(%r12),%r11d cmp %r14d,%r10d cmovl %r14d,%r10d add %ecx,%edx add %edx,%r9d lea (%r14,%rcx,1),%edx cmp %edx,%r9d mov %r10d,0xc(%rbx) cmovl %edx,%r9d lea (%rcx,%r11,1),%edx lea (%r10,%r11,1),%ecx cmp %r10d,%r9d cmovl %r10d,%r9d add %r14d,%edx cmp %ecx,%edx cmovl %ecx,%edx mov %eax,%ecx mov %r9d,0x10(%rbx) cmp %r9d,%edx cmovl %r9d,%edx add $0x7,%ecx add $0x6,%eax add $0x18,%r12 add $0x18,%rbx mov %edx,-0x4(%rbx) cmp %ecx,%r13d jg 13c8 <func0+0x108> cltq nopl 0x0(%rax,%rax,1) mov (%rdi,%rax,4),%ecx mov -0x8(%r8,%rax,4),%edx mov -0x4(%r8,%rax,4),%r9d add %ecx,%edx cmp %r9d,%edx cmovl %r9d,%edx add -0x4(%rdi,%rax,4),%ecx add -0xc(%r8,%rax,4),%ecx cmp %ecx,%edx cmovl %ecx,%edx mov %edx,(%r8,%rax,4) add $0x1,%rax cmp %eax,%esi jg 14a8 <func0+0x1e8> sub $0x1,%esi mov -0x28(%rbp),%rbx xor %fs:0x28,%rbx movslq %esi,%rsi mov (%r8,%rsi,4),%eax jne 1512 <func0+0x252> lea -0x20(%rbp),%rsp pop %rbx pop %r12 pop %r13 pop %r14 pop %rbp retq xchg %ax,%ax orq $0x0,-0x8(%rsp,%rdx,1) jmpq 132f <func0+0x6f> mov $0x3,%eax jmp 14a1 <func0+0x1e1> callq 1080 <__stack_chk_fail@plt> nopw 0x0(%rax,%rax,1)
func0: endbr64 push rbp mov r9, rdi mov r8d, esi mov rbp, rsp push r14 push r13 push r12 push rbx sub rsp, 10h mov rax, fs:28h mov [rbp+var_28], 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_1320 loc_130B: sub rsp, 1000h or [rsp+1030h+var_38], 0 cmp rsp, rcx jnz short loc_130B loc_1320: and edx, 0FFFh sub rsp, rdx test rdx, rdx jnz loc_14E8 loc_1332: lea rsi, [rsp+1030h+var_102D] mov r11, rsi and rsi, 0FFFFFFFFFFFFFFFCh shr r11, 2 test r8d, r8d jle loc_14BD mov ecx, [r9] mov ds:dword_0[r11*4], ecx cmp r8d, 1 jz loc_14BD mov eax, [r9+4] lea edi, [rcx+rax] mov dword ptr ds:byte_4[r11*4], edi cmp r8d, 2 jz loc_14BD mov r10d, [r9+8] lea edx, [rcx+r10] cmp edx, edi cmovl edx, edi add eax, r10d cmp edx, eax cmovl edx, eax mov dword ptr ds:byte_8[r11*4], edx cmp r8d, 3 jz loc_14BD lea r12d, [r8-5] cmp r8d, 9 jle loc_14F3 lea rbx, [r9+0Ch] lea r11, [rsi+0Ch] mov eax, 3 loc_13BB: mov r13d, [rbx] lea r14d, [r13+rdi+0] cmp r14d, edx cmovl r14d, edx add r10d, r13d add r10d, ecx cmp r14d, r10d cmovl r14d, r10d mov r10d, [rbx+4] add r13d, r10d lea ecx, [rdx+r10] mov [r11], r14d add edi, r13d cmp ecx, r14d cmovl ecx, r14d cmp edi, ecx cmovl edi, ecx mov ecx, [rbx+8] lea r13d, [r10+rcx] mov r10d, [rbx+0Ch] mov [r11+4], edi add r13d, edx lea edx, [r14+rcx] cmp r13d, edx cmovl r13d, edx lea edx, [rdi+r10] cmp r13d, edi cmovl r13d, edi add ecx, r10d add ecx, r14d cmp ecx, edx mov [r11+8], r13d cmovl ecx, edx mov edx, [rbx+10h] cmp ecx, r13d cmovl ecx, r13d add r10d, edx add edi, r10d lea r10d, [r13+rdx+0] cmp edi, r10d mov [r11+0Ch], ecx cmovl edi, r10d mov r10d, [rbx+14h] cmp edi, ecx cmovl edi, ecx add edx, r10d add edx, r13d lea r13d, [rcx+r10] cmp edx, r13d mov [r11+10h], edi cmovl edx, r13d mov r13d, eax cmp edx, edi cmovl edx, edi add r13d, 7 add eax, 6 add rbx, 18h add r11, 18h mov [r11-4], edx cmp r12d, r13d jg loc_13BB loc_148D: cdqe nop loc_1490: mov ecx, [r9+rax*4] mov edx, [rsi+rax*4-8] mov edi, [rsi+rax*4-4] add edx, ecx cmp edx, edi cmovl edx, edi add ecx, [r9+rax*4-4] add ecx, [rsi+rax*4-0Ch] cmp edx, ecx cmovl edx, ecx mov [rsi+rax*4], edx add rax, 1 cmp r8d, eax jg short loc_1490 loc_14BD: sub r8d, 1 movsxd r8, r8d mov eax, [rsi+r8*4] mov rdx, [rbp+var_28] sub rdx, fs:28h jnz short loc_14FA lea rsp, [rbp-20h] pop rbx pop r12 pop r13 pop r14 pop rbp retn loc_14E8: or [rsp+rdx+1030h+var_1038], 0 jmp loc_1332 loc_14F3: mov eax, 3 jmp short loc_148D loc_14FA: call ___stack_chk_fail
long long func0(int *a1, int a2) { long long v3; // rdx _DWORD *v4; // rcx __int16 v5; // dx signed long long v6; // rdx void *v7; // rsp int v8; // ecx int v9; // eax int v10; // edi int v11; // r10d int v12; // edx int v13; // eax int *v14; // rbx int *v15; // r11 long long v16; // rax int v17; // r13d int v18; // r14d int v19; // r10d int v20; // r10d int v21; // ecx int v22; // edi int v23; // ecx int v24; // r13d int v25; // r10d int v26; // r13d int v27; // edx int v28; // r13d int v29; // ecx int v30; // edx int v31; // ecx _DWORD v34[3]; // [rsp+8h] [rbp-1030h] BYREF int v35; // [rsp+14h] [rbp-1024h] BYREF _QWORD v36[6]; // [rsp+1008h] [rbp-30h] BYREF v36[1] = __readfsqword(0x28u); v3 = 4LL * a2 + 15; v4 = (_DWORD *)((char *)v36 - (v3 & 0xFFFFFFFFFFFFF000LL)); v5 = v3 & 0xFFF0; if ( v36 != (_QWORD *)v4 ) { while ( v34 != v4 ) ; } v6 = v5 & 0xFFF; v7 = alloca(v6); if ( v6 ) *(_QWORD *)((char *)&v34[-2] + v6) = *(_QWORD *)((char *)&v34[-2] + v6); if ( a2 > 0 ) { v8 = *a1; v34[0] = *a1; if ( a2 != 1 ) { v9 = a1[1]; v10 = v8 + v9; v34[1] = v8 + v9; if ( a2 != 2 ) { v11 = a1[2]; v12 = v8 + v11; if ( v8 + v11 < v10 ) v12 = v8 + v9; v13 = v11 + v9; if ( v12 < v13 ) v12 = v13; v34[2] = v12; if ( a2 != 3 ) { if ( a2 <= 9 ) { LODWORD(v16) = 3; } else { v14 = a1 + 3; v15 = &v35; LODWORD(v16) = 3; do { v17 = *v14; v18 = *v14 + v10; if ( v18 < v12 ) v18 = v12; v19 = v8 + v17 + v11; if ( v18 < v19 ) v18 = v19; v20 = v14[1]; v21 = v12 + v20; *v15 = v18; v22 = v20 + v17 + v10; if ( v12 + v20 < v18 ) v21 = v18; if ( v22 < v21 ) v22 = v21; v23 = v14[2]; v24 = v20 + v23; v25 = v14[3]; v15[1] = v22; v26 = v12 + v24; if ( v26 < v18 + v23 ) v26 = v18 + v23; if ( v26 < v22 ) v26 = v22; v8 = v18 + v25 + v23; v15[2] = v26; if ( v8 < v22 + v25 ) v8 = v22 + v25; v27 = v14[4]; if ( v8 < v26 ) v8 = v26; v10 = v27 + v25 + v22; v15[3] = v8; if ( v10 < v26 + v27 ) v10 = v26 + v27; v11 = v14[5]; if ( v10 < v8 ) v10 = v8; v12 = v26 + v11 + v27; v15[4] = v10; if ( v12 < v8 + v11 ) v12 = v8 + v11; v28 = v16; if ( v12 < v10 ) v12 = v10; LODWORD(v16) = v16 + 6; v14 += 6; v15 += 6; *(v15 - 1) = v12; } while ( a2 - 5 > v28 + 7 ); } v16 = (int)v16; do { v29 = a1[v16]; v30 = v29 + v34[v16 - 2]; if ( v30 < v34[v16 - 1] ) v30 = v34[v16 - 1]; v31 = v34[v16 - 3] + a1[v16 - 1] + v29; if ( v30 < v31 ) v30 = v31; v34[v16++] = v30; } while ( a2 > (int)v16 ); } } } } return (unsigned int)v34[a2 - 1]; }
func0: ENDBR64 PUSH RBP MOV R9,RDI MOV R8D,ESI MOV RBP,RSP PUSH R14 PUSH R13 PUSH R12 PUSH RBX SUB RSP,0x10 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x28],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 0x00101320 LAB_0010130b: SUB RSP,0x1000 OR qword ptr [RSP + 0xff8],0x0 CMP RSP,RCX JNZ 0x0010130b LAB_00101320: AND EDX,0xfff SUB RSP,RDX TEST RDX,RDX JNZ 0x001014e8 LAB_00101332: LEA RSI,[RSP + 0x3] MOV R11,RSI AND RSI,-0x4 SHR R11,0x2 TEST R8D,R8D JLE 0x001014bd MOV ECX,dword ptr [R9] MOV dword ptr [R11*0x4],ECX CMP R8D,0x1 JZ 0x001014bd MOV EAX,dword ptr [R9 + 0x4] LEA EDI,[RCX + RAX*0x1] MOV dword ptr [0x4 + R11*0x4],EDI CMP R8D,0x2 JZ 0x001014bd MOV R10D,dword ptr [R9 + 0x8] LEA EDX,[RCX + R10*0x1] CMP EDX,EDI CMOVL EDX,EDI ADD EAX,R10D CMP EDX,EAX CMOVL EDX,EAX MOV dword ptr [0x8 + R11*0x4],EDX CMP R8D,0x3 JZ 0x001014bd LEA R12D,[R8 + -0x5] CMP R8D,0x9 JLE 0x001014f3 LEA RBX,[R9 + 0xc] LEA R11,[RSI + 0xc] MOV EAX,0x3 LAB_001013bb: MOV R13D,dword ptr [RBX] LEA R14D,[R13 + RDI*0x1] CMP R14D,EDX CMOVL R14D,EDX ADD R10D,R13D ADD R10D,ECX CMP R14D,R10D CMOVL R14D,R10D MOV R10D,dword ptr [RBX + 0x4] ADD R13D,R10D LEA ECX,[RDX + R10*0x1] MOV dword ptr [R11],R14D ADD EDI,R13D CMP ECX,R14D CMOVL ECX,R14D CMP EDI,ECX CMOVL EDI,ECX MOV ECX,dword ptr [RBX + 0x8] LEA R13D,[R10 + RCX*0x1] MOV R10D,dword ptr [RBX + 0xc] MOV dword ptr [R11 + 0x4],EDI ADD R13D,EDX LEA EDX,[R14 + RCX*0x1] CMP R13D,EDX CMOVL R13D,EDX LEA EDX,[RDI + R10*0x1] CMP R13D,EDI CMOVL R13D,EDI ADD ECX,R10D ADD ECX,R14D CMP ECX,EDX MOV dword ptr [R11 + 0x8],R13D CMOVL ECX,EDX MOV EDX,dword ptr [RBX + 0x10] CMP ECX,R13D CMOVL ECX,R13D ADD R10D,EDX ADD EDI,R10D LEA R10D,[R13 + RDX*0x1] CMP EDI,R10D MOV dword ptr [R11 + 0xc],ECX CMOVL EDI,R10D MOV R10D,dword ptr [RBX + 0x14] CMP EDI,ECX CMOVL EDI,ECX ADD EDX,R10D ADD EDX,R13D LEA R13D,[RCX + R10*0x1] CMP EDX,R13D MOV dword ptr [R11 + 0x10],EDI CMOVL EDX,R13D MOV R13D,EAX CMP EDX,EDI CMOVL EDX,EDI ADD R13D,0x7 ADD EAX,0x6 ADD RBX,0x18 ADD R11,0x18 MOV dword ptr [R11 + -0x4],EDX CMP R12D,R13D JG 0x001013bb LAB_0010148d: CDQE NOP LAB_00101490: MOV ECX,dword ptr [R9 + RAX*0x4] MOV EDX,dword ptr [RSI + RAX*0x4 + -0x8] MOV EDI,dword ptr [RSI + RAX*0x4 + -0x4] ADD EDX,ECX CMP EDX,EDI CMOVL EDX,EDI ADD ECX,dword ptr [R9 + RAX*0x4 + -0x4] ADD ECX,dword ptr [RSI + RAX*0x4 + -0xc] CMP EDX,ECX CMOVL EDX,ECX MOV dword ptr [RSI + RAX*0x4],EDX ADD RAX,0x1 CMP R8D,EAX JG 0x00101490 LAB_001014bd: SUB R8D,0x1 MOVSXD R8,R8D MOV EAX,dword ptr [RSI + R8*0x4] MOV RDX,qword ptr [RBP + -0x28] SUB RDX,qword ptr FS:[0x28] JNZ 0x001014fa LEA RSP,[RBP + -0x20] POP RBX POP R12 POP R13 POP R14 POP RBP RET LAB_001014e8: OR qword ptr [RSP + RDX*0x1 + -0x8],0x0 JMP 0x00101332 LAB_001014f3: MOV EAX,0x3 JMP 0x0010148d LAB_001014fa: CALL 0x00101080
int4 func0(int *param_1,int param_2) { long lVar1; int *puVar2; int iVar3; long lVar4; int iVar5; int *piVar6; int *puVar7; int iVar9; int iVar10; ulong uVar11; int *piVar12; int iVar13; int iVar14; int iVar15; long in_FS_OFFSET; int auStack_38 [8]; long local_30; int *puVar8; puVar7 = auStack_38; local_30 = *(long *)(in_FS_OFFSET + 0x28); uVar11 = (long)param_2 * 4 + 0xf; puVar8 = auStack_38; puVar2 = auStack_38; while (puVar8 != auStack_38 + -(uVar11 & 0xfffffffffffff000)) { puVar7 = puVar2 + -0x1000; *(int8 *)(puVar2 + -8) = *(int8 *)(puVar2 + -8); puVar8 = puVar2 + -0x1000; puVar2 = puVar2 + -0x1000; } uVar11 = (ulong)((uint)uVar11 & 0xff0); lVar1 = -uVar11; if (uVar11 != 0) { *(int8 *)(puVar7 + -8) = *(int8 *)(puVar7 + -8); } uVar11 = (ulong)(puVar7 + lVar1 + 3) >> 2; if (0 < param_2) { iVar10 = *param_1; *(int *)(uVar11 * 4) = iVar10; if (param_2 != 1) { iVar3 = param_1[1]; iVar9 = iVar10 + iVar3; *(int *)(uVar11 * 4 + 4) = iVar9; if (param_2 != 2) { iVar5 = param_1[2]; iVar13 = iVar10 + iVar5; if (iVar10 + iVar5 < iVar9) { iVar13 = iVar9; } iVar3 = iVar3 + iVar5; if (iVar13 < iVar3) { iVar13 = iVar3; } *(int *)(uVar11 * 4 + 8) = iVar13; if (param_2 != 3) { if (param_2 < 10) { iVar3 = 3; } else { piVar6 = param_1 + 3; iVar3 = 3; piVar12 = (int *)(puVar7 + lVar1 + 0xc); do { iVar14 = *piVar6; iVar15 = iVar14 + iVar9; if (iVar14 + iVar9 < iVar13) { iVar15 = iVar13; } iVar10 = iVar5 + iVar14 + iVar10; if (iVar15 < iVar10) { iVar15 = iVar10; } iVar10 = piVar6[1]; *piVar12 = iVar15; iVar9 = iVar9 + iVar14 + iVar10; iVar5 = iVar13 + iVar10; if (iVar13 + iVar10 < iVar15) { iVar5 = iVar15; } if (iVar9 < iVar5) { iVar9 = iVar5; } iVar5 = piVar6[2]; iVar14 = piVar6[3]; piVar12[1] = iVar9; iVar13 = iVar10 + iVar5 + iVar13; if (iVar13 < iVar15 + iVar5) { iVar13 = iVar15 + iVar5; } if (iVar13 < iVar9) { iVar13 = iVar9; } iVar10 = iVar5 + iVar14 + iVar15; piVar12[2] = iVar13; if (iVar10 < iVar9 + iVar14) { iVar10 = iVar9 + iVar14; } iVar15 = piVar6[4]; if (iVar10 < iVar13) { iVar10 = iVar13; } iVar9 = iVar9 + iVar14 + iVar15; piVar12[3] = iVar10; if (iVar9 < iVar13 + iVar15) { iVar9 = iVar13 + iVar15; } iVar5 = piVar6[5]; if (iVar9 < iVar10) { iVar9 = iVar10; } iVar13 = iVar15 + iVar5 + iVar13; piVar12[4] = iVar9; if (iVar13 < iVar10 + iVar5) { iVar13 = iVar10 + iVar5; } if (iVar13 < iVar9) { iVar13 = iVar9; } iVar14 = iVar3 + 7; iVar3 = iVar3 + 6; piVar6 = piVar6 + 6; piVar12[5] = iVar13; piVar12 = piVar12 + 6; } while (iVar14 < param_2 + -5); } lVar4 = (long)iVar3; do { iVar10 = *(int *)(puVar7 + lVar4 * 4 + lVar1 + -8) + param_1[lVar4]; if (iVar10 < *(int *)(puVar7 + lVar4 * 4 + lVar1 + -4)) { iVar10 = *(int *)(puVar7 + lVar4 * 4 + lVar1 + -4); } iVar3 = param_1[lVar4] + param_1[lVar4 + -1] + *(int *)(puVar7 + lVar4 * 4 + lVar1 + -0xc); if (iVar10 < iVar3) { iVar10 = iVar3; } *(int *)(puVar7 + lVar4 * 4 + lVar1) = iVar10; lVar4 = lVar4 + 1; } while ((int)lVar4 < param_2); } } } } if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ *(int8 *)(puVar7 + lVar1 + -8) = 0x1014ff; __stack_chk_fail(); } return *(int4 *)(puVar7 + (long)(param_2 + -1) * 4 + lVar1); }
6,540
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct { char* key; int* values; int size; } Item; typedef struct { Item* items; int size; } Dict; void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sortArray(int arr[], int size) { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { swap(&arr[j], &arr[j + 1]); } } } } int compareDicts(Dict dict1, Dict dict2) { if (dict1.size != dict2.size) return 0; for (int i = 0; i < dict1.size; i++) { if (strcmp(dict1.items[i].key, dict2.items[i].key) != 0) return 0; if (dict1.items[i].size != dict2.items[i].size) return 0; for (int j = 0; j < dict1.items[i].size; j++) { if (dict1.items[i].values[j] != dict2.items[i].values[j]) return 0; } } return 1; }
Dict func0(Dict dict) { for (int i = 0; i < dict.size; i++) { sortArray(dict.items[i].values, dict.items[i].size); } return dict; }
int main() { Item items1[3] = {{ "n1", (int[]){2, 3, 1}, 3 }, { "n2", (int[]){5, 1, 2}, 3 }, { "n3", (int[]){3, 2, 4}, 3 }}; Dict dict1 = { items1, 3 }; Dict expected1 = { (Item[]){ {"n1", (int[]){1, 2, 3}, 3}, {"n2", (int[]){1, 2, 5}, 3}, {"n3", (int[]){2, 3, 4}, 3} }, 3 }; Item items2[3] = {{ "n1", (int[]){25, 37, 41}, 3 }, { "n2", (int[]){41, 54, 63}, 3 }, { "n3", (int[]){29, 38, 93}, 3 }}; Dict dict2 = { items2, 3 }; Dict expected2 = { (Item[]){ {"n1", (int[]){25, 37, 41}, 3}, {"n2", (int[]){41, 54, 63}, 3}, {"n3", (int[]){29, 38, 93}, 3} }, 3 }; Item items3[3] = {{ "n1", (int[]){58, 44, 56}, 3 }, { "n2", (int[]){91, 34, 58}, 3 }, { "n3", (int[]){100, 200, 300}, 3 }}; Dict dict3 = { items3, 3 }; Dict expected3 = { (Item[]){ {"n1", (int[]){44, 56, 58}, 3}, {"n2", (int[]){34, 58, 91}, 3}, {"n3", (int[]){100, 200, 300}, 3} }, 3 }; assert(compareDicts(func0(dict1), expected1)); assert(compareDicts(func0(dict2), expected2)); assert(compareDicts(func0(dict3), expected3)); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %rdi,%rax mov %rsi,%rcx mov %rcx,%rdx mov %rax,-0x20(%rbp) mov %rdx,-0x18(%rbp) movl $0x0,-0x4(%rbp) jmp 147a <func0+0x6f> mov -0x20(%rbp),%rcx mov -0x4(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax add %rcx,%rax mov 0x10(%rax),%ecx mov -0x20(%rbp),%rsi mov -0x4(%rbp),%eax movslq %eax,%rdx mov %rdx,%rax add %rax,%rax add %rdx,%rax shl $0x3,%rax add %rsi,%rax mov 0x8(%rax),%rax mov %ecx,%esi mov %rax,%rdi callq 11ba <sortArray> addl $0x1,-0x4(%rbp) mov -0x18(%rbp),%eax cmp %eax,-0x4(%rbp) jl 1431 <func0+0x26> mov -0x20(%rbp),%rax mov -0x18(%rbp),%rdx leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov rax, rdi mov rcx, rsi mov rdx, rcx mov [rbp+var_20], rax mov [rbp+var_18], rdx mov [rbp+var_4], 0 jmp short loc_147A loc_1431: mov rcx, [rbp+var_20] mov eax, [rbp+var_4] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 add rax, rcx mov ecx, [rax+10h] mov rsi, [rbp+var_20] mov eax, [rbp+var_4] movsxd rdx, eax mov rax, rdx add rax, rax add rax, rdx shl rax, 3 add rax, rsi mov rax, [rax+8] mov esi, ecx mov rdi, rax call sortArray add [rbp+var_4], 1 loc_147A: mov eax, dword ptr [rbp+var_18] cmp [rbp+var_4], eax jl short loc_1431 mov rax, [rbp+var_20] mov rdx, [rbp+var_18] leave retn
long long func0(long long a1, int a2) { int i; // [rsp+1Ch] [rbp-4h] for ( i = 0; i < a2; ++i ) sortArray(*(_QWORD *)(a1 + 24LL * i + 8), *(unsigned int *)(a1 + 24LL * i + 16)); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV RAX,RDI MOV RCX,RSI MOV RDX,RCX MOV qword ptr [RBP + -0x20],RAX MOV qword ptr [RBP + -0x18],RDX MOV dword ptr [RBP + -0x4],0x0 JMP 0x0010147a LAB_00101431: MOV RCX,qword ptr [RBP + -0x20] MOV EAX,dword ptr [RBP + -0x4] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 ADD RAX,RCX MOV ECX,dword ptr [RAX + 0x10] MOV RSI,qword ptr [RBP + -0x20] MOV EAX,dword ptr [RBP + -0x4] MOVSXD RDX,EAX MOV RAX,RDX ADD RAX,RAX ADD RAX,RDX SHL RAX,0x3 ADD RAX,RSI MOV RAX,qword ptr [RAX + 0x8] MOV ESI,ECX MOV RDI,RAX CALL 0x001011ba ADD dword ptr [RBP + -0x4],0x1 LAB_0010147a: MOV EAX,dword ptr [RBP + -0x18] CMP dword ptr [RBP + -0x4],EAX JL 0x00101431 MOV RAX,qword ptr [RBP + -0x20] MOV RDX,qword ptr [RBP + -0x18] LEAVE RET
int [16] func0(long param_1,int8 param_2) { int auVar1 [16]; int4 local_20; int4 uStack_1c; int4 local_c; local_20 = (int)param_2; uStack_1c = (int4)((ulong)param_2 >> 0x20); for (local_c = 0; local_c < local_20; local_c = local_c + 1) { sortArray(*(int8 *)((long)local_c * 0x18 + param_1 + 8), *(int4 *)((long)local_c * 0x18 + param_1 + 0x10)); } auVar1._8_4_ = local_20; auVar1._0_8_ = param_1; auVar1._12_4_ = uStack_1c; return auVar1; }
6,541
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct { char* key; int* values; int size; } Item; typedef struct { Item* items; int size; } Dict; void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sortArray(int arr[], int size) { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { swap(&arr[j], &arr[j + 1]); } } } } int compareDicts(Dict dict1, Dict dict2) { if (dict1.size != dict2.size) return 0; for (int i = 0; i < dict1.size; i++) { if (strcmp(dict1.items[i].key, dict2.items[i].key) != 0) return 0; if (dict1.items[i].size != dict2.items[i].size) return 0; for (int j = 0; j < dict1.items[i].size; j++) { if (dict1.items[i].values[j] != dict2.items[i].values[j]) return 0; } } return 1; }
Dict func0(Dict dict) { for (int i = 0; i < dict.size; i++) { sortArray(dict.items[i].values, dict.items[i].size); } return dict; }
int main() { Item items1[3] = {{ "n1", (int[]){2, 3, 1}, 3 }, { "n2", (int[]){5, 1, 2}, 3 }, { "n3", (int[]){3, 2, 4}, 3 }}; Dict dict1 = { items1, 3 }; Dict expected1 = { (Item[]){ {"n1", (int[]){1, 2, 3}, 3}, {"n2", (int[]){1, 2, 5}, 3}, {"n3", (int[]){2, 3, 4}, 3} }, 3 }; Item items2[3] = {{ "n1", (int[]){25, 37, 41}, 3 }, { "n2", (int[]){41, 54, 63}, 3 }, { "n3", (int[]){29, 38, 93}, 3 }}; Dict dict2 = { items2, 3 }; Dict expected2 = { (Item[]){ {"n1", (int[]){25, 37, 41}, 3}, {"n2", (int[]){41, 54, 63}, 3}, {"n3", (int[]){29, 38, 93}, 3} }, 3 }; Item items3[3] = {{ "n1", (int[]){58, 44, 56}, 3 }, { "n2", (int[]){91, 34, 58}, 3 }, { "n3", (int[]){100, 200, 300}, 3 }}; Dict dict3 = { items3, 3 }; Dict expected3 = { (Item[]){ {"n1", (int[]){44, 56, 58}, 3}, {"n2", (int[]){34, 58, 91}, 3}, {"n3", (int[]){100, 200, 300}, 3} }, 3 }; assert(compareDicts(func0(dict1), expected1)); assert(compareDicts(func0(dict2), expected2)); assert(compareDicts(func0(dict3), expected3)); return 0; }
O1
c
func0: endbr64 push %r13 push %r12 push %rbp push %rbx mov %rdi,%r13 mov %rsi,%r12 test %esi,%esi jle 12be <func0+0x38> lea 0x8(%rdi),%rbx lea -0x1(%rsi),%eax lea (%rax,%rax,2),%rax lea 0x20(%rdi,%rax,8),%rbp mov 0x8(%rbx),%esi mov (%rbx),%rdi callq 1196 <sortArray> add $0x18,%rbx cmp %rbp,%rbx jne 12aa <func0+0x24> mov %r13,%rax mov %r12,%rdx pop %rbx pop %rbp pop %r12 pop %r13 retq
func0: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 mov r13, rdi mov r12, rsi test esi, esi jle short loc_12CD lea rbx, [rdi+8] lea eax, [rsi-1] lea rax, [rax+rax*2] lea rbp, [rdi+rax*8+20h] loc_12B9: mov esi, [rbx+8] mov rdi, [rbx] call sortArray add rbx, 18h cmp rbx, rbp jnz short loc_12B9 loc_12CD: mov rax, r13 mov rdx, r12 add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn
long long func0(long long a1, int a2) { long long v2; // rbx if ( a2 > 0 ) { v2 = a1 + 8; do { sortArray(*(_QWORD *)v2, *(unsigned int *)(v2 + 8)); v2 += 24LL; } while ( v2 != a1 + 24LL * (unsigned int)(a2 - 1) + 32 ); } return a1; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV R13,RDI MOV R12,RSI TEST ESI,ESI JLE 0x001012cd LEA RBX,[RDI + 0x8] LEA EAX,[RSI + -0x1] LEA RAX,[RAX + RAX*0x2] LEA RBP,[RDI + RAX*0x8 + 0x20] LAB_001012b9: MOV ESI,dword ptr [RBX + 0x8] MOV RDI,qword ptr [RBX] CALL 0x00101196 ADD RBX,0x18 CMP RBX,RBP JNZ 0x001012b9 LAB_001012cd: MOV RAX,R13 MOV RDX,R12 ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET
int1 [16] func0(long param_1,int8 param_2) { int8 *puVar1; int1 auVar2 [16]; if (0 < (int)param_2) { puVar1 = (int8 *)(param_1 + 8); do { sortArray(*puVar1,*(int4 *)(puVar1 + 1)); puVar1 = puVar1 + 3; } while (puVar1 != (int8 *)(param_1 + 0x20 + (ulong)((int)param_2 - 1) * 0x18)); } auVar2._8_8_ = param_2; auVar2._0_8_ = param_1; return auVar2; }
6,542
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct { char* key; int* values; int size; } Item; typedef struct { Item* items; int size; } Dict; void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sortArray(int arr[], int size) { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { swap(&arr[j], &arr[j + 1]); } } } } int compareDicts(Dict dict1, Dict dict2) { if (dict1.size != dict2.size) return 0; for (int i = 0; i < dict1.size; i++) { if (strcmp(dict1.items[i].key, dict2.items[i].key) != 0) return 0; if (dict1.items[i].size != dict2.items[i].size) return 0; for (int j = 0; j < dict1.items[i].size; j++) { if (dict1.items[i].values[j] != dict2.items[i].values[j]) return 0; } } return 1; }
Dict func0(Dict dict) { for (int i = 0; i < dict.size; i++) { sortArray(dict.items[i].values, dict.items[i].size); } return dict; }
int main() { Item items1[3] = {{ "n1", (int[]){2, 3, 1}, 3 }, { "n2", (int[]){5, 1, 2}, 3 }, { "n3", (int[]){3, 2, 4}, 3 }}; Dict dict1 = { items1, 3 }; Dict expected1 = { (Item[]){ {"n1", (int[]){1, 2, 3}, 3}, {"n2", (int[]){1, 2, 5}, 3}, {"n3", (int[]){2, 3, 4}, 3} }, 3 }; Item items2[3] = {{ "n1", (int[]){25, 37, 41}, 3 }, { "n2", (int[]){41, 54, 63}, 3 }, { "n3", (int[]){29, 38, 93}, 3 }}; Dict dict2 = { items2, 3 }; Dict expected2 = { (Item[]){ {"n1", (int[]){25, 37, 41}, 3}, {"n2", (int[]){41, 54, 63}, 3}, {"n3", (int[]){29, 38, 93}, 3} }, 3 }; Item items3[3] = {{ "n1", (int[]){58, 44, 56}, 3 }, { "n2", (int[]){91, 34, 58}, 3 }, { "n3", (int[]){100, 200, 300}, 3 }}; Dict dict3 = { items3, 3 }; Dict expected3 = { (Item[]){ {"n1", (int[]){44, 56, 58}, 3}, {"n2", (int[]){34, 58, 91}, 3}, {"n3", (int[]){100, 200, 300}, 3} }, 3 }; assert(compareDicts(func0(dict1), expected1)); assert(compareDicts(func0(dict2), expected2)); assert(compareDicts(func0(dict3), expected3)); return 0; }
O2
c
func0: endbr64 push %r13 mov %rdi,%r13 push %r12 mov %rsi,%r12 test %esi,%esi jle 181d <func0+0x3d> lea -0x1(%rsi),%eax lea 0x8(%rdi),%r10 lea (%rax,%rax,2),%rax lea 0x20(%rdi,%rax,8),%r11 nopw 0x0(%rax,%rax,1) mov 0x8(%r10),%esi mov (%r10),%rdi callq 1700 <sortArray> add $0x18,%r10 cmp %r11,%r10 jne 1808 <func0+0x28> mov %r13,%rax mov %r12,%rdx pop %r12 pop %r13 retq nopl 0x0(%rax,%rax,1)
func0: endbr64 push r13 mov r13, rdi push r12 mov r12, rsi sub rsp, 8 test esi, esi jle short loc_1825 lea eax, [rsi-1] lea r10, [rdi+8] lea rax, [rax+rax*2] lea r11, [rdi+rax*8+20h] nop word ptr [rax+rax+00000000h] loc_1810: mov esi, [r10+8] mov rdi, [r10] add r10, 18h call sortArray cmp r10, r11 jnz short loc_1810 loc_1825: add rsp, 8 mov rax, r13 mov rdx, r12 pop r12 pop r13 retn
long long func0(long long a1, int a2) { long long v2; // r10 long long v3; // r11 if ( a2 > 0 ) { v2 = a1 + 8; do sortArray(*(_QWORD *)v2, *(unsigned int *)(v2 + 8)); while ( v2 != v3 ); } return a1; }
func0: ENDBR64 PUSH R13 MOV R13,RDI PUSH R12 MOV R12,RSI SUB RSP,0x8 TEST ESI,ESI JLE 0x00101825 LEA EAX,[RSI + -0x1] LEA R10,[RDI + 0x8] LEA RAX,[RAX + RAX*0x2] LEA R11,[RDI + RAX*0x8 + 0x20] NOP word ptr CS:[RAX + RAX*0x1] LAB_00101810: MOV ESI,dword ptr [R10 + 0x8] MOV RDI,qword ptr [R10] ADD R10,0x18 CALL 0x00101700 CMP R10,R11 JNZ 0x00101810 LAB_00101825: ADD RSP,0x8 MOV RAX,R13 MOV RDX,R12 POP R12 POP R13 RET
int1 [16] func0(long param_1,int8 param_2) { int8 *puVar1; int8 uVar2; int8 *puVar3; int8 *puVar4; int1 auVar5 [16]; if (0 < (int)param_2) { puVar3 = (int8 *)(param_1 + 8); puVar4 = (int8 *)(param_1 + 0x20 + (ulong)((int)param_2 - 1) * 0x18); do { puVar1 = puVar3 + 1; uVar2 = *puVar3; puVar3 = puVar3 + 3; sortArray(uVar2,*(int4 *)puVar1); } while (puVar3 != puVar4); } auVar5._8_8_ = param_2; auVar5._0_8_ = param_1; return auVar5; }
6,543
func0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> typedef struct { char* key; int* values; int size; } Item; typedef struct { Item* items; int size; } Dict; void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sortArray(int arr[], int size) { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { swap(&arr[j], &arr[j + 1]); } } } } int compareDicts(Dict dict1, Dict dict2) { if (dict1.size != dict2.size) return 0; for (int i = 0; i < dict1.size; i++) { if (strcmp(dict1.items[i].key, dict2.items[i].key) != 0) return 0; if (dict1.items[i].size != dict2.items[i].size) return 0; for (int j = 0; j < dict1.items[i].size; j++) { if (dict1.items[i].values[j] != dict2.items[i].values[j]) return 0; } } return 1; }
Dict func0(Dict dict) { for (int i = 0; i < dict.size; i++) { sortArray(dict.items[i].values, dict.items[i].size); } return dict; }
int main() { Item items1[3] = {{ "n1", (int[]){2, 3, 1}, 3 }, { "n2", (int[]){5, 1, 2}, 3 }, { "n3", (int[]){3, 2, 4}, 3 }}; Dict dict1 = { items1, 3 }; Dict expected1 = { (Item[]){ {"n1", (int[]){1, 2, 3}, 3}, {"n2", (int[]){1, 2, 5}, 3}, {"n3", (int[]){2, 3, 4}, 3} }, 3 }; Item items2[3] = {{ "n1", (int[]){25, 37, 41}, 3 }, { "n2", (int[]){41, 54, 63}, 3 }, { "n3", (int[]){29, 38, 93}, 3 }}; Dict dict2 = { items2, 3 }; Dict expected2 = { (Item[]){ {"n1", (int[]){25, 37, 41}, 3}, {"n2", (int[]){41, 54, 63}, 3}, {"n3", (int[]){29, 38, 93}, 3} }, 3 }; Item items3[3] = {{ "n1", (int[]){58, 44, 56}, 3 }, { "n2", (int[]){91, 34, 58}, 3 }, { "n3", (int[]){100, 200, 300}, 3 }}; Dict dict3 = { items3, 3 }; Dict expected3 = { (Item[]){ {"n1", (int[]){44, 56, 58}, 3}, {"n2", (int[]){34, 58, 91}, 3}, {"n3", (int[]){100, 200, 300}, 3} }, 3 }; assert(compareDicts(func0(dict1), expected1)); assert(compareDicts(func0(dict2), expected2)); assert(compareDicts(func0(dict3), expected3)); return 0; }
O3
c
func0: endbr64 push %r13 mov %rdi,%r13 push %r12 mov %rsi,%r12 push %rbp push %rbx test %esi,%esi jle 18a9 <func0+0x79> lea -0x1(%rsi),%eax lea 0x8(%rdi),%r9 lea (%rax,%rax,2),%rax lea 0x20(%rdi,%rax,8),%rbp nopl 0x0(%rax) mov 0x8(%r9),%esi mov (%r9),%rax lea -0x1(%rsi),%ecx test %ecx,%ecx jle 18a0 <func0+0x70> lea 0x4(%rax),%rbx nopw 0x0(%rax,%rax,1) lea -0x1(%rcx),%r10d mov %rax,%r8 mov %r10,%rcx lea (%rbx,%r10,4),%rdx xchg %ax,%ax mov (%r8),%r10d mov 0x4(%r8),%r11d cmp %r11d,%r10d jle 1893 <func0+0x63> mov %r11d,(%r8) mov %r10d,0x4(%r8) add $0x4,%r8 cmp %r8,%rdx jne 1880 <func0+0x50> test %ecx,%ecx jne 1870 <func0+0x40> add $0x18,%r9 cmp %r9,%rbp jne 1858 <func0+0x28> pop %rbx mov %r13,%rax mov %r12,%rdx pop %rbp pop %r12 pop %r13 retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push rbp mov rbp, rdi push rbx mov rbx, rsi test esi, esi jle short loc_18B8 movsxd rax, esi lea r10, [rdi+8] lea rax, [rax+rax*2] lea r11, [r10+rax*8] nop loc_1860: mov edi, [r10+8] mov r8, [r10] cmp edi, 1 jle short loc_18AF lea r9, [r8+4] loc_1870: cmp edi, 1 jle short loc_18C8 lea edx, [rdi-2] mov rax, r8 lea rsi, [r9+rdx*4] nop loc_1880: movq xmm0, qword ptr [rax] pshufd xmm1, xmm0, 0E5h movd edx, xmm0 movd ecx, xmm1 cmp ecx, edx jge short loc_189E pshufd xmm0, xmm0, 0E1h movq qword ptr [rax], xmm0 loc_189E: add rax, 4 cmp rax, rsi jnz short loc_1880 sub edi, 1 cmp edi, 1 jnz short loc_1870 loc_18AF: add r10, 18h cmp r10, r11 jnz short loc_1860 loc_18B8: mov rax, rbp mov rdx, rbx pop rbx pop rbp retn loc_18C8: sub edi, 1 jmp short loc_1870
long long func0(long long a1, int a2) { long long v3; // r10 long long v4; // r11 int v5; // edi __m128i *v6; // r8 __m128i *v7; // rax __m128i v8; // xmm0 if ( a2 > 0 ) { v3 = a1 + 8; v4 = a1 + 8 + 24LL * a2; do { v5 = *(_DWORD *)(v3 + 8); v6 = *(__m128i **)v3; if ( v5 > 1 ) { do { while ( v5 <= 1 ) --v5; v7 = v6; do { v8 = _mm_loadl_epi64(v7); if ( _mm_cvtsi128_si32(_mm_shuffle_epi32(v8, 229)) < _mm_cvtsi128_si32(v8) ) v7->m128i_i64[0] = _mm_shuffle_epi32(v8, 225).m128i_u64[0]; v7 = (__m128i *)((char *)v7 + 4); } while ( v7 != (__m128i *)((char *)v6->m128i_i64 + 4 * (unsigned int)(v5 - 2) + 4) ); --v5; } while ( v5 != 1 ); } v3 += 24LL; } while ( v3 != v4 ); } return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RDI PUSH RBX MOV RBX,RSI TEST ESI,ESI JLE 0x001018b8 MOVSXD RAX,ESI LEA R10,[RDI + 0x8] LEA RAX,[RAX + RAX*0x2] LEA R11,[R10 + RAX*0x8] NOP LAB_00101860: MOV EDI,dword ptr [R10 + 0x8] MOV R8,qword ptr [R10] CMP EDI,0x1 JLE 0x001018af LEA R9,[R8 + 0x4] LAB_00101870: CMP EDI,0x1 JLE 0x001018c8 LEA EDX,[RDI + -0x2] MOV RAX,R8 LEA RSI,[R9 + RDX*0x4] NOP LAB_00101880: MOVQ XMM0,qword ptr [RAX] PSHUFD XMM1,XMM0,0xe5 MOVD EDX,XMM0 MOVD ECX,XMM1 CMP ECX,EDX JGE 0x0010189e PSHUFD XMM0,XMM0,0xe1 MOVQ qword ptr [RAX],XMM0 LAB_0010189e: ADD RAX,0x4 CMP RAX,RSI JNZ 0x00101880 SUB EDI,0x1 CMP EDI,0x1 JNZ 0x00101870 LAB_001018af: ADD R10,0x18 CMP R10,R11 JNZ 0x00101860 LAB_001018b8: MOV RAX,RBP MOV RDX,RBX POP RBX POP RBP RET LAB_001018c8: SUB EDI,0x1 JMP 0x00101870
int [16] func0(long param_1,int8 param_2) { int8 *puVar1; int8 *puVar2; int8 *puVar3; int iVar4; int8 *puVar5; int iVar6; int iVar7; int auVar8 [16]; if (0 < (int)param_2) { puVar5 = (int8 *)(param_1 + 8); puVar1 = puVar5 + (long)(int)param_2 * 3; do { iVar4 = *(int *)(puVar5 + 1); puVar2 = (int8 *)*puVar5; if (1 < iVar4) { do { for (; iVar4 < 2; iVar4 = iVar4 + -1) { } puVar3 = puVar2; do { iVar6 = (int)*puVar3; iVar7 = (int)((ulong)*puVar3 >> 0x20); if (iVar7 < iVar6) { *puVar3 = CONCAT44(iVar6,iVar7); } puVar3 = (int8 *)((long)puVar3 + 4); } while (puVar3 != (int8 *)((long)puVar2 + (ulong)(iVar4 - 2) * 4 + 4)); iVar4 = iVar4 + -1; } while (iVar4 != 1); } puVar5 = puVar5 + 3; } while (puVar5 != puVar1); } auVar8._8_8_ = param_2; auVar8._0_8_ = param_1; return auVar8; }
6,544
func0
#include <limits.h> #include <assert.h>
int func0(int n, int x, int y) { int ans = INT_MIN; for (int k = 0; k <= n; k++) { if (k % x == y) { if (ans < k) { ans = k; } } } return ((ans >= 0 && ans <= n) ? ans : -1); }
int main() { assert(func0(15, 10, 5) == 15); assert(func0(187, 10, 5) == 185); assert(func0(16, 11, 1) == 12); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) mov %edx,-0x1c(%rbp) movl $0x80000000,-0x8(%rbp) movl $0x0,-0x4(%rbp) jmp 118a <func0+0x41> mov -0x4(%rbp),%eax cltd idivl -0x18(%rbp) mov %edx,%eax cmp %eax,-0x1c(%rbp) jne 1186 <func0+0x3d> mov -0x8(%rbp),%eax cmp -0x4(%rbp),%eax jge 1186 <func0+0x3d> mov -0x4(%rbp),%eax mov %eax,-0x8(%rbp) addl $0x1,-0x4(%rbp) mov -0x4(%rbp),%eax cmp -0x14(%rbp),%eax jle 116a <func0+0x21> cmpl $0x0,-0x8(%rbp) js 11a5 <func0+0x5c> mov -0x8(%rbp),%eax cmp -0x14(%rbp),%eax jg 11a5 <func0+0x5c> mov -0x8(%rbp),%eax jmp 11aa <func0+0x61> mov $0xffffffff,%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 [rbp+var_8], 80000000h mov [rbp+var_4], 0 jmp short loc_118A loc_116A: mov eax, [rbp+var_4] cdq idiv [rbp+var_18] mov eax, edx cmp [rbp+var_1C], eax jnz short loc_1186 mov eax, [rbp+var_8] cmp eax, [rbp+var_4] jge short loc_1186 mov eax, [rbp+var_4] mov [rbp+var_8], eax loc_1186: add [rbp+var_4], 1 loc_118A: mov eax, [rbp+var_4] cmp eax, [rbp+var_14] jle short loc_116A cmp [rbp+var_8], 0 js short loc_11A5 mov eax, [rbp+var_8] cmp eax, [rbp+var_14] jg short loc_11A5 mov eax, [rbp+var_8] jmp short loc_11AA loc_11A5: mov eax, 0FFFFFFFFh loc_11AA: pop rbp retn
long long func0(int a1, int a2, int a3) { int v4; // [rsp+14h] [rbp-8h] int i; // [rsp+18h] [rbp-4h] v4 = 0x80000000; for ( i = 0; i <= a1; ++i ) { if ( a3 == i % a2 && v4 < i ) v4 = i; } if ( v4 < 0 || v4 > a1 ) return 0xFFFFFFFFLL; else return (unsigned int)v4; }
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 dword ptr [RBP + -0x8],0x80000000 MOV dword ptr [RBP + -0x4],0x0 JMP 0x0010118a LAB_0010116a: MOV EAX,dword ptr [RBP + -0x4] CDQ IDIV dword ptr [RBP + -0x18] MOV EAX,EDX CMP dword ptr [RBP + -0x1c],EAX JNZ 0x00101186 MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x4] JGE 0x00101186 MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RBP + -0x8],EAX LAB_00101186: ADD dword ptr [RBP + -0x4],0x1 LAB_0010118a: MOV EAX,dword ptr [RBP + -0x4] CMP EAX,dword ptr [RBP + -0x14] JLE 0x0010116a CMP dword ptr [RBP + -0x8],0x0 JS 0x001011a5 MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x14] JG 0x001011a5 MOV EAX,dword ptr [RBP + -0x8] JMP 0x001011aa LAB_001011a5: MOV EAX,0xffffffff LAB_001011aa: POP RBP RET
int func0(int param_1,int param_2,int param_3) { int local_10; int local_c; local_10 = -0x80000000; for (local_c = 0; local_c <= param_1; local_c = local_c + 1) { if ((param_3 == local_c % param_2) && (local_10 < local_c)) { local_10 = local_c; } } if ((local_10 < 0) || (param_1 < local_10)) { local_10 = -1; } return local_10; }
6,545
func0
#include <limits.h> #include <assert.h>
int func0(int n, int x, int y) { int ans = INT_MIN; for (int k = 0; k <= n; k++) { if (k % x == y) { if (ans < k) { ans = k; } } } return ((ans >= 0 && ans <= n) ? ans : -1); }
int main() { assert(func0(15, 10, 5) == 15); assert(func0(187, 10, 5) == 185); assert(func0(16, 11, 1) == 12); return 0; }
O1
c
func0: endbr64 mov %edx,%r9d test %edi,%edi js 118e <func0+0x45> lea 0x1(%rdi),%r10d mov $0x0,%ecx mov $0x80000000,%r8d jmp 116d <func0+0x24> add $0x1,%ecx cmp %ecx,%r10d je 1180 <func0+0x37> mov %ecx,%eax cltd idiv %esi cmp %r9d,%edx jne 1165 <func0+0x1c> cmp %ecx,%r8d cmovl %ecx,%r8d jmp 1165 <func0+0x1c> test %r8d,%r8d js 1196 <func0+0x4d> cmp %edi,%r8d jg 1196 <func0+0x4d> mov %r8d,%eax retq mov $0xffffffff,%r8d jmp 118a <func0+0x41> mov $0xffffffff,%r8d jmp 118a <func0+0x41>
func0: endbr64 mov r9d, edx test edi, edi js short loc_118E lea r10d, [rdi+1] mov ecx, 0 mov r8d, 80000000h loc_1163: mov eax, ecx cdq idiv esi cmp r8d, ecx mov eax, ecx cmovge eax, r8d cmp edx, r9d cmovz r8d, eax add ecx, 1 cmp r10d, ecx jnz short loc_1163 test r8d, r8d js short loc_1196 cmp r8d, edi jg short loc_1196 loc_118A: mov eax, r8d retn loc_118E: mov r8d, 0FFFFFFFFh jmp short loc_118A loc_1196: mov r8d, 0FFFFFFFFh jmp short loc_118A
long long func0(int a1, int a2, int a3) { int v3; // ecx int v4; // r8d int v5; // eax if ( a1 < 0 ) { return (unsigned int)-1; } else { v3 = 0; v4 = 0x80000000; do { v5 = v3; if ( v4 >= v3 ) v5 = v4; if ( v3 % a2 == a3 ) v4 = v5; ++v3; } while ( a1 + 1 != v3 ); if ( v4 < 0 || v4 > a1 ) return (unsigned int)-1; } return (unsigned int)v4; }
func0: ENDBR64 MOV R9D,EDX TEST EDI,EDI JS 0x0010118e LEA R10D,[RDI + 0x1] MOV ECX,0x0 MOV R8D,0x80000000 LAB_00101163: MOV EAX,ECX CDQ IDIV ESI CMP R8D,ECX MOV EAX,ECX CMOVGE EAX,R8D CMP EDX,R9D CMOVZ R8D,EAX ADD ECX,0x1 CMP R10D,ECX JNZ 0x00101163 TEST R8D,R8D JS 0x00101196 CMP R8D,EDI JG 0x00101196 LAB_0010118a: MOV EAX,R8D RET LAB_0010118e: MOV R8D,0xffffffff JMP 0x0010118a LAB_00101196: MOV R8D,0xffffffff JMP 0x0010118a
int func0(int param_1,int param_2,int param_3) { int iVar1; int iVar2; int iVar3; if (param_1 < 0) { iVar3 = -1; } else { iVar2 = 0; iVar3 = -0x80000000; do { iVar1 = iVar2; if (iVar2 <= iVar3) { iVar1 = iVar3; } if (iVar2 % param_2 == param_3) { iVar3 = iVar1; } iVar2 = iVar2 + 1; } while (param_1 + 1 != iVar2); if ((iVar3 < 0) || (param_1 < iVar3)) { iVar3 = -1; } } return iVar3; }
6,546
func0
#include <limits.h> #include <assert.h>
int func0(int n, int x, int y) { int ans = INT_MIN; for (int k = 0; k <= n; k++) { if (k % x == y) { if (ans < k) { ans = k; } } } return ((ans >= 0 && ans <= n) ? ans : -1); }
int main() { assert(func0(15, 10, 5) == 15); assert(func0(187, 10, 5) == 185); assert(func0(16, 11, 1) == 12); return 0; }
O2
c
func0: endbr64 mov %edx,%r9d test %edi,%edi js 12c0 <func0+0x50> lea 0x1(%rdi),%r10d xor %ecx,%ecx mov $0x80000000,%r8d nopw 0x0(%rax,%rax,1) mov %ecx,%eax cltd idiv %esi cmp %r9d,%edx jne 12a1 <func0+0x31> cmp %ecx,%r8d cmovl %ecx,%r8d add $0x1,%ecx cmp %ecx,%r10d jne 1290 <func0+0x20> test %r8d,%r8d js 12c0 <func0+0x50> cmp %edi,%r8d jg 12c0 <func0+0x50> mov %r8d,%eax retq nopw 0x0(%rax,%rax,1) mov $0xffffffff,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 mov r9d, edx test edi, edi js short loc_1260 lea r10d, [rdi+1] xor ecx, ecx mov r8d, 80000000h nop word ptr [rax+rax+00000000h] loc_1230: mov eax, ecx cdq idiv esi cmp r8d, ecx mov eax, ecx cmovge eax, r8d cmp edx, r9d cmovz r8d, eax add ecx, 1 cmp r10d, ecx jnz short loc_1230 test r8d, r8d js short loc_1260 cmp r8d, edi jg short loc_1260 mov eax, r8d retn loc_1260: mov r8d, 0FFFFFFFFh mov eax, r8d retn
long long func0(int a1, int a2, int a3) { int v3; // ecx int v4; // r8d int v5; // eax if ( a1 < 0 ) return 0xFFFFFFFFLL; v3 = 0; v4 = 0x80000000; do { v5 = v3; if ( v4 >= v3 ) v5 = v4; if ( v3 % a2 == a3 ) v4 = v5; ++v3; } while ( a1 + 1 != v3 ); if ( v4 < 0 || v4 > a1 ) return 0xFFFFFFFFLL; else return (unsigned int)v4; }
func0: ENDBR64 MOV R9D,EDX TEST EDI,EDI JS 0x00101260 LEA R10D,[RDI + 0x1] XOR ECX,ECX MOV R8D,0x80000000 NOP word ptr [RAX + RAX*0x1] LAB_00101230: MOV EAX,ECX CDQ IDIV ESI CMP R8D,ECX MOV EAX,ECX CMOVGE EAX,R8D CMP EDX,R9D CMOVZ R8D,EAX ADD ECX,0x1 CMP R10D,ECX JNZ 0x00101230 TEST R8D,R8D JS 0x00101260 CMP R8D,EDI JG 0x00101260 MOV EAX,R8D RET LAB_00101260: MOV R8D,0xffffffff MOV EAX,R8D RET
int func0(int param_1,int param_2,int param_3) { int iVar1; int iVar2; int iVar3; if (-1 < param_1) { iVar2 = 0; iVar3 = -0x80000000; do { iVar1 = iVar2; if (iVar2 <= iVar3) { iVar1 = iVar3; } if (iVar2 % param_2 == param_3) { iVar3 = iVar1; } iVar2 = iVar2 + 1; } while (param_1 + 1 != iVar2); if ((-1 < iVar3) && (iVar3 <= param_1)) { return iVar3; } } return -1; }
6,547
func0
#include <limits.h> #include <assert.h>
int func0(int n, int x, int y) { int ans = INT_MIN; for (int k = 0; k <= n; k++) { if (k % x == y) { if (ans < k) { ans = k; } } } return ((ans >= 0 && ans <= n) ? ans : -1); }
int main() { assert(func0(15, 10, 5) == 15); assert(func0(187, 10, 5) == 185); assert(func0(16, 11, 1) == 12); return 0; }
O3
c
func0: endbr64 mov %edx,%r9d test %edi,%edi js 1200 <func0+0x50> lea 0x1(%rdi),%r10d xor %ecx,%ecx mov $0x80000000,%r8d nopw 0x0(%rax,%rax,1) mov %ecx,%eax cltd idiv %esi cmp %edx,%r9d jne 11e1 <func0+0x31> cmp %ecx,%r8d cmovl %ecx,%r8d add $0x1,%ecx cmp %r10d,%ecx jne 11d0 <func0+0x20> test %r8d,%r8d js 1200 <func0+0x50> cmp %edi,%r8d jg 1200 <func0+0x50> mov %r8d,%eax retq nopw 0x0(%rax,%rax,1) mov $0xffffffff,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
func0: endbr64 mov r9d, edx test edi, edi js short loc_1200 lea r10d, [rdi+1] xor ecx, ecx mov r8d, 80000000h nop word ptr [rax+rax+00000000h] loc_11D0: mov eax, ecx cdq idiv esi cmp r8d, ecx mov eax, ecx cmovge eax, r8d cmp edx, r9d cmovz r8d, eax add ecx, 1 cmp r10d, ecx jnz short loc_11D0 test r8d, r8d js short loc_1200 cmp r8d, edi jg short loc_1200 mov eax, r8d retn loc_1200: mov r8d, 0FFFFFFFFh mov eax, r8d retn
long long func0(int a1, int a2, int a3) { int v3; // ecx int v4; // r8d int v5; // eax if ( a1 < 0 ) return 0xFFFFFFFFLL; v3 = 0; v4 = 0x80000000; do { v5 = v3; if ( v4 >= v3 ) v5 = v4; if ( v3 % a2 == a3 ) v4 = v5; ++v3; } while ( a1 + 1 != v3 ); if ( v4 < 0 || v4 > a1 ) return 0xFFFFFFFFLL; else return (unsigned int)v4; }
func0: ENDBR64 MOV R9D,EDX TEST EDI,EDI JS 0x00101200 LEA R10D,[RDI + 0x1] XOR ECX,ECX MOV R8D,0x80000000 NOP word ptr [RAX + RAX*0x1] LAB_001011d0: MOV EAX,ECX CDQ IDIV ESI CMP R8D,ECX MOV EAX,ECX CMOVGE EAX,R8D CMP EDX,R9D CMOVZ R8D,EAX ADD ECX,0x1 CMP R10D,ECX JNZ 0x001011d0 TEST R8D,R8D JS 0x00101200 CMP R8D,EDI JG 0x00101200 MOV EAX,R8D RET LAB_00101200: MOV R8D,0xffffffff MOV EAX,R8D RET
int func0(int param_1,int param_2,int param_3) { int iVar1; int iVar2; int iVar3; if (-1 < param_1) { iVar2 = 0; iVar3 = -0x80000000; do { iVar1 = iVar2; if (iVar2 <= iVar3) { iVar1 = iVar3; } if (iVar2 % param_2 == param_3) { iVar3 = iVar1; } iVar2 = iVar2 + 1; } while (param_1 + 1 != iVar2); if ((-1 < iVar3) && (iVar3 <= param_1)) { return iVar3; } } return -1; }
6,548
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { if (n % 2 != 0) { printf("Invalid Input\n"); return -1; } int sm = 0, count = 0; while (n >= 2) { count += 1; sm += n; n -= 2; } return sm / count; }
int main() { assert(func0(2) == 2); assert(func0(4) == 3); assert(func0(100) == 51); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %edi,-0x14(%rbp) mov -0x14(%rbp),%eax and $0x1,%eax test %eax,%eax je 1195 <func0+0x2c> lea 0xe7f(%rip),%rdi callq 1060 <puts@plt> mov $0xffffffff,%eax jmp 11c0 <func0+0x57> movl $0x0,-0x8(%rbp) movl $0x0,-0x4(%rbp) jmp 11b3 <func0+0x4a> addl $0x1,-0x4(%rbp) mov -0x14(%rbp),%eax add %eax,-0x8(%rbp) subl $0x2,-0x14(%rbp) cmpl $0x1,-0x14(%rbp) jg 11a5 <func0+0x3c> mov -0x8(%rbp),%eax cltd idivl -0x4(%rbp) leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_14], edi mov eax, [rbp+var_14] and eax, 1 test eax, eax jz short loc_1198 lea rax, s; "Invalid Input" mov rdi, rax; s call _puts mov eax, 0FFFFFFFFh jmp short locret_11C3 loc_1198: mov [rbp+var_8], 0 mov [rbp+var_4], 0 jmp short loc_11B6 loc_11A8: add [rbp+var_4], 1 mov eax, [rbp+var_14] add [rbp+var_8], eax sub [rbp+var_14], 2 loc_11B6: cmp [rbp+var_14], 1 jg short loc_11A8 mov eax, [rbp+var_8] cdq idiv [rbp+var_4] locret_11C3: leave retn
long long func0(int a1) { int v2; // [rsp+Ch] [rbp-14h] int v3; // [rsp+18h] [rbp-8h] int v4; // [rsp+1Ch] [rbp-4h] v2 = a1; if ( (a1 & 1) != 0 ) { puts("Invalid Input"); return 0xFFFFFFFFLL; } else { v3 = 0; v4 = 0; while ( v2 > 1 ) { ++v4; v3 += v2; v2 -= 2; } return (unsigned int)(v3 / v4); } }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV dword ptr [RBP + -0x14],EDI MOV EAX,dword ptr [RBP + -0x14] AND EAX,0x1 TEST EAX,EAX JZ 0x00101198 LEA RAX,[0x102004] MOV RDI,RAX CALL 0x00101060 MOV EAX,0xffffffff JMP 0x001011c3 LAB_00101198: MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x0 JMP 0x001011b6 LAB_001011a8: ADD dword ptr [RBP + -0x4],0x1 MOV EAX,dword ptr [RBP + -0x14] ADD dword ptr [RBP + -0x8],EAX SUB dword ptr [RBP + -0x14],0x2 LAB_001011b6: CMP dword ptr [RBP + -0x14],0x1 JG 0x001011a8 MOV EAX,dword ptr [RBP + -0x8] CDQ IDIV dword ptr [RBP + -0x4] LAB_001011c3: LEAVE RET
ulong func0(uint param_1) { ulong uVar1; uint local_1c; int local_10; int local_c; if ((param_1 & 1) == 0) { local_10 = 0; local_c = 0; for (local_1c = param_1; 1 < (int)local_1c; local_1c = local_1c - 2) { local_c = local_c + 1; local_10 = local_10 + local_1c; } uVar1 = (long)local_10 / (long)local_c & 0xffffffff; } else { puts("Invalid Input"); uVar1 = 0xffffffff; } return uVar1; }
6,549
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { if (n % 2 != 0) { printf("Invalid Input\n"); return -1; } int sm = 0, count = 0; while (n >= 2) { count += 1; sm += n; n -= 2; } return sm / count; }
int main() { assert(func0(2) == 2); assert(func0(4) == 3); assert(func0(100) == 51); return 0; }
O1
c
func0: endbr64 test $0x1,%dil jne 119c <func0+0x33> mov %edi,%ecx mov $0x0,%eax cmp $0x1,%edi jle 1195 <func0+0x2c> add %edi,%eax sub $0x2,%edi cmp $0x1,%edi jg 117f <func0+0x16> sub $0x2,%ecx shr %ecx add $0x1,%ecx cltd idiv %ecx retq mov $0x0,%ecx jmp 1191 <func0+0x28> sub $0x8,%rsp lea 0xe5d(%rip),%rdi callq 1060 <puts@plt> mov $0xffffffff,%eax add $0x8,%rsp retq
func0: endbr64 test dil, 1 jnz short loc_119C mov ecx, edi mov eax, 0 cmp edi, 1 jle short loc_1195 loc_117F: add eax, edi sub edi, 2 cmp edi, 1 jg short loc_117F sub ecx, 2 shr ecx, 1 add ecx, 1 loc_1191: cdq idiv ecx retn loc_1195: mov ecx, 0 jmp short loc_1191 loc_119C: sub rsp, 8 lea rdi, aInvalidInput; "Invalid Input" call _puts mov eax, 0FFFFFFFFh add rsp, 8 retn
long long func0(int a1) { int v1; // ecx int v2; // eax signed int v3; // ecx if ( (a1 & 1) != 0 ) { puts("Invalid Input"); return 0xFFFFFFFFLL; } else { v1 = a1; v2 = 0; if ( a1 <= 1 ) { v3 = 0; } else { do { v2 += a1; a1 -= 2; } while ( a1 > 1 ); v3 = ((unsigned int)(v1 - 2) >> 1) + 1; } return (unsigned int)(v2 / v3); } }
func0: ENDBR64 TEST DIL,0x1 JNZ 0x0010119c MOV ECX,EDI MOV EAX,0x0 CMP EDI,0x1 JLE 0x00101195 LAB_0010117f: ADD EAX,EDI SUB EDI,0x2 CMP EDI,0x1 JG 0x0010117f SUB ECX,0x2 SHR ECX,0x1 ADD ECX,0x1 LAB_00101191: CDQ IDIV ECX RET LAB_00101195: MOV ECX,0x0 JMP 0x00101191 LAB_0010119c: SUB RSP,0x8 LEA RDI,[0x102004] CALL 0x00101060 MOV EAX,0xffffffff ADD RSP,0x8 RET
int1 [16] func0(uint param_1) { int iVar1; int iVar2; int8 extraout_RDX; uint uVar3; int1 auVar4 [16]; int1 auVar5 [16]; if ((param_1 & 1) == 0) { iVar1 = 0; uVar3 = param_1; if ((int)param_1 < 2) { iVar2 = 0; } else { do { iVar1 = iVar1 + uVar3; uVar3 = uVar3 - 2; } while (1 < (int)uVar3); iVar2 = (param_1 - 2 >> 1) + 1; } auVar4._0_4_ = iVar1 / iVar2; auVar4._4_4_ = 0; auVar4._8_4_ = iVar1 % iVar2; auVar4._12_4_ = 0; return auVar4; } puts("Invalid Input"); auVar5._8_8_ = extraout_RDX; auVar5._0_8_ = 0xffffffff; return auVar5; }
6,550
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { if (n % 2 != 0) { printf("Invalid Input\n"); return -1; } int sm = 0, count = 0; while (n >= 2) { count += 1; sm += n; n -= 2; } return sm / count; }
int main() { assert(func0(2) == 2); assert(func0(4) == 3); assert(func0(100) == 51); return 0; }
O2
c
func0: endbr64 test $0x1,%dil jne 119e <func0+0x2e> cmp $0x1,%edi jle 11b8 <func0+0x48> mov %edi,%ecx xor %eax,%eax nopl 0x0(%rax,%rax,1) add %edi,%eax sub $0x2,%edi cmp $0x1,%edi jg 1188 <func0+0x18> sub $0x2,%ecx cltd shr %ecx add $0x1,%ecx idiv %ecx retq sub $0x8,%rsp lea 0xe5b(%rip),%rdi callq 1050 <puts@plt> mov $0xffffffff,%eax add $0x8,%rsp retq jmpq 1060 <func0.cold> nopl (%rax)
func0: endbr64 test dil, 1 jnz short loc_119E cmp edi, 1 jle short loc_11B8 mov ecx, edi xor eax, eax nop dword ptr [rax+rax+00h] loc_1188: add eax, edi sub edi, 2 cmp edi, 1 jg short loc_1188 sub ecx, 2 cdq shr ecx, 1 add ecx, 1 idiv ecx retn loc_119E: sub rsp, 8 lea rdi, aInvalidInput; "Invalid Input" call _puts mov eax, 0FFFFFFFFh add rsp, 8 retn loc_11B8: jmp func0_cold
long long func0(int a1) { int v1; // ecx int v2; // eax if ( (a1 & 1) != 0 ) { puts("Invalid Input"); return 0xFFFFFFFFLL; } else { if ( a1 <= 1 ) func0_cold(); v1 = a1; v2 = 0; do { v2 += a1; a1 -= 2; } while ( a1 > 1 ); return (unsigned int)(v2 / (int)(((unsigned int)(v1 - 2) >> 1) + 1)); } }
func0: ENDBR64 TEST DIL,0x1 JNZ 0x0010119e CMP EDI,0x1 JLE 0x001011b8 MOV ECX,EDI XOR EAX,EAX NOP dword ptr [RAX + RAX*0x1] LAB_00101188: ADD EAX,EDI SUB EDI,0x2 CMP EDI,0x1 JG 0x00101188 SUB ECX,0x2 CDQ SHR ECX,0x1 ADD ECX,0x1 IDIV ECX RET LAB_0010119e: SUB RSP,0x8 LEA RDI,[0x102004] CALL 0x00101050 MOV EAX,0xffffffff ADD RSP,0x8 RET LAB_001011b8: JMP 0x00101060
int1 [16] func0(uint param_1) { long lVar1; int iVar2; int8 extraout_RDX; uint uVar3; int1 auVar4 [16]; int1 auVar5 [16]; if ((param_1 & 1) != 0) { puts("Invalid Input"); auVar5._8_8_ = extraout_RDX; auVar5._0_8_ = 0xffffffff; return auVar5; } if (1 < (int)param_1) { iVar2 = 0; uVar3 = param_1; do { iVar2 = iVar2 + uVar3; uVar3 = uVar3 - 2; } while (1 < (int)uVar3); lVar1 = (long)(int)((param_1 - 2 >> 1) + 1); auVar4._0_8_ = (long)iVar2 / lVar1 & 0xffffffff; auVar4._8_8_ = (long)iVar2 % lVar1 & 0xffffffff; return auVar4; } auVar5 = func0_cold(); return auVar5; }
6,551
func0
#include <stdio.h> #include <assert.h>
int func0(int n) { if (n % 2 != 0) { printf("Invalid Input\n"); return -1; } int sm = 0, count = 0; while (n >= 2) { count += 1; sm += n; n -= 2; } return sm / count; }
int main() { assert(func0(2) == 2); assert(func0(4) == 3); assert(func0(100) == 51); return 0; }
O3
c
func0: endbr64 mov %edi,%eax and $0x1,%eax jne 1224 <func0+0xb4> cmp $0x1,%edi jle 123e <func0+0xce> lea -0x2(%rdi),%edx mov %edx,%ecx shr %ecx add $0x1,%ecx cmp $0x23,%edx jbe 1220 <func0+0xb0> movd %edi,%xmm4 mov %ecx,%edx movdqa 0xe87(%rip),%xmm3 pxor %xmm0,%xmm0 pshufd $0x0,%xmm4,%xmm1 paddd 0xe66(%rip),%xmm1 shr $0x2,%edx nopl (%rax) movdqa %xmm1,%xmm2 add $0x1,%eax paddd %xmm3,%xmm1 paddd %xmm2,%xmm0 cmp %edx,%eax jne 11c0 <func0+0x50> movdqa %xmm0,%xmm1 mov %ecx,%edx psrldq $0x8,%xmm1 and $0xfffffffc,%edx paddd %xmm1,%xmm0 mov %edx,%esi movdqa %xmm0,%xmm1 neg %esi psrldq $0x4,%xmm1 lea (%rdi,%rsi,2),%edi paddd %xmm1,%xmm0 movd %xmm0,%eax cmp %edx,%ecx je 121c <func0+0xac> lea -0x2(%rdi),%edx jmp 1213 <func0+0xa3> nopw %cs:0x0(%rax,%rax,1) sub $0x2,%edx add %edi,%eax mov %edx,%edi cmp $0x1,%edx jg 1210 <func0+0xa0> cltd idiv %ecx retq xor %eax,%eax jmp 1213 <func0+0xa3> sub $0x8,%rsp lea 0xdd5(%rip),%rdi callq 1050 <puts@plt> mov $0xffffffff,%eax add $0x8,%rsp retq jmpq 1060 <func0.cold> nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 mov eax, edi and eax, 1 jnz loc_1263 mov edx, edi cmp edi, 1 jle loc_127D lea ecx, [rdi-2] mov esi, ecx shr esi, 1 add esi, 1 cmp ecx, 13h jbe short loc_1204 movd xmm4, edi mov ecx, esi movdqa xmm3, cs:xmmword_2030 xor eax, eax pshufd xmm0, xmm4, 0 paddd xmm0, cs:xmmword_2020 shr ecx, 2 pxor xmm1, xmm1 nop dword ptr [rax] loc_11C0: movdqa xmm2, xmm0 add eax, 1 paddd xmm0, xmm3 paddd xmm1, xmm2 cmp eax, ecx jnz short loc_11C0 movdqa xmm0, xmm1 mov ecx, esi psrldq xmm0, 8 and ecx, 0FFFFFFFCh paddd xmm1, xmm0 neg ecx movdqa xmm0, xmm1 lea edx, [rdx+rcx*2] psrldq xmm0, 4 paddd xmm1, xmm0 movd eax, xmm1 test sil, 3 jz short loc_125F lea ecx, [rdx-2] loc_1204: add eax, edx cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-4] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-6] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-8] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-0Ah] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-0Ch] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-0Eh] cmp ecx, 1 jle short loc_125F add eax, ecx lea ecx, [rdx-10h] cmp ecx, 1 jle short loc_125F add eax, ecx sub edx, 12h lea ecx, [rax+rdx] cmp edx, 1 cmovg eax, ecx loc_125F: cdq idiv esi retn loc_1263: sub rsp, 8 lea rdi, s; "Invalid Input" call _puts mov eax, 0FFFFFFFFh add rsp, 8 retn loc_127D: jmp func0_cold
long long func0(long long a1, long long a2) { int v2; // eax int v3; // edx int v4; // ecx signed int v5; // esi __m128i si128; // xmm3 int v7; // eax __m128i v8; // xmm0 __m128i v9; // xmm1 __m128i v10; // xmm2 __m128i v11; // xmm1 int v12; // edx v2 = a1 & 1; if ( (a1 & 1) == 0 ) { v3 = a1; if ( (int)a1 <= 1 ) func0_cold(a1, a2, (unsigned int)a1); v4 = a1 - 2; v5 = ((unsigned int)(a1 - 2) >> 1) + 1; if ( (unsigned int)(a1 - 2) > 0x13 ) { si128 = _mm_load_si128((const __m128i *)&xmmword_2030); v7 = 0; v8 = _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(a1), 0), (__m128i)xmmword_2020); v9 = 0LL; do { v10 = v8; ++v7; v8 = _mm_add_epi32(v8, si128); v9 = _mm_add_epi32(v9, v10); } while ( v7 != (unsigned int)v5 >> 2 ); v11 = _mm_add_epi32(v9, _mm_srli_si128(v9, 8)); v3 = a1 - 2 * (v5 & 0xFFFFFFFC); v2 = _mm_cvtsi128_si32(_mm_add_epi32(v11, _mm_srli_si128(v11, 4))); if ( (v5 & 3) == 0 ) return (unsigned int)(v2 / v5); v4 = v3 - 2; } v2 += v3; if ( v4 > 1 ) { v2 += v4; if ( v3 - 4 > 1 ) { v2 += v3 - 4; if ( v3 - 6 > 1 ) { v2 += v3 - 6; if ( v3 - 8 > 1 ) { v2 += v3 - 8; if ( v3 - 10 > 1 ) { v2 += v3 - 10; if ( v3 - 12 > 1 ) { v2 += v3 - 12; if ( v3 - 14 > 1 ) { v2 += v3 - 14; if ( v3 - 16 > 1 ) { v2 += v3 - 16; v12 = v3 - 18; if ( v12 > 1 ) v2 += v12; } } } } } } } } return (unsigned int)(v2 / v5); } puts("Invalid Input"); return 0xFFFFFFFFLL; }
func0: ENDBR64 MOV EAX,EDI AND EAX,0x1 JNZ 0x00101263 MOV EDX,EDI CMP EDI,0x1 JLE 0x0010127d LEA ECX,[RDI + -0x2] MOV ESI,ECX SHR ESI,0x1 ADD ESI,0x1 CMP ECX,0x13 JBE 0x00101204 MOVD XMM4,EDI MOV ECX,ESI MOVDQA XMM3,xmmword ptr [0x00102030] XOR EAX,EAX PSHUFD XMM0,XMM4,0x0 PADDD XMM0,xmmword ptr [0x00102020] SHR ECX,0x2 PXOR XMM1,XMM1 NOP dword ptr [RAX] LAB_001011c0: MOVDQA XMM2,XMM0 ADD EAX,0x1 PADDD XMM0,XMM3 PADDD XMM1,XMM2 CMP EAX,ECX JNZ 0x001011c0 MOVDQA XMM0,XMM1 MOV ECX,ESI PSRLDQ XMM0,0x8 AND ECX,0xfffffffc PADDD XMM1,XMM0 NEG ECX MOVDQA XMM0,XMM1 LEA EDX,[RDX + RCX*0x2] PSRLDQ XMM0,0x4 PADDD XMM1,XMM0 MOVD EAX,XMM1 TEST SIL,0x3 JZ 0x0010125f LEA ECX,[RDX + -0x2] LAB_00101204: ADD EAX,EDX CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0x4] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0x6] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0x8] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0xa] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0xc] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0xe] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX LEA ECX,[RDX + -0x10] CMP ECX,0x1 JLE 0x0010125f ADD EAX,ECX SUB EDX,0x12 LEA ECX,[RAX + RDX*0x1] CMP EDX,0x1 CMOVG EAX,ECX LAB_0010125f: CDQ IDIV ESI RET LAB_00101263: SUB RSP,0x8 LEA RDI,[0x102004] CALL 0x00101050 MOV EAX,0xffffffff ADD RSP,0x8 RET LAB_0010127d: JMP 0x00101060
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ int [16] func0(uint param_1) { uint uVar1; uint uVar2; uint uVar3; int8 extraout_RDX; uint uVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; int iVar10; int iVar11; int iVar12; int auVar13 [16]; int auVar14 [16]; uVar1 = param_1 & 1; if ((param_1 & 1) != 0) { puts("Invalid Input"); auVar14._8_8_ = extraout_RDX; auVar14._0_8_ = 0xffffffff; return auVar14; } if ((int)param_1 < 2) { auVar14 = func0_cold(); return auVar14; } uVar3 = param_1 - 2; uVar4 = (uVar3 >> 1) + 1; if (0x13 < uVar3) { uVar1 = 0; iVar9 = 0; iVar10 = 0; iVar11 = 0; iVar12 = 0; iVar5 = param_1 + _DAT_00102020; iVar6 = param_1 + _UNK_00102024; iVar7 = param_1 + _UNK_00102028; iVar8 = param_1 + _UNK_0010202c; do { uVar1 = uVar1 + 1; iVar9 = iVar9 + iVar5; iVar10 = iVar10 + iVar6; iVar11 = iVar11 + iVar7; iVar12 = iVar12 + iVar8; iVar5 = iVar5 + _DAT_00102030; iVar6 = iVar6 + _UNK_00102034; iVar7 = iVar7 + _UNK_00102038; iVar8 = iVar8 + _UNK_0010203c; } while (uVar1 != uVar4 >> 2); param_1 = param_1 + (uVar4 & 0xfffffffc) * -2; uVar1 = iVar9 + iVar11 + iVar10 + iVar12; uVar2 = uVar1; if ((uVar4 & 3) == 0) goto LAB_0010125f; uVar3 = param_1 - 2; } uVar2 = uVar1 + param_1; if (1 < (int)uVar3) { uVar2 = uVar1 + param_1 + uVar3; if (1 < (int)(param_1 - 4)) { uVar2 = uVar2 + (param_1 - 4); if (1 < (int)(param_1 - 6)) { uVar2 = uVar2 + (param_1 - 6); if (1 < (int)(param_1 - 8)) { uVar2 = uVar2 + (param_1 - 8); if (1 < (int)(param_1 - 10)) { uVar2 = uVar2 + (param_1 - 10); if (1 < (int)(param_1 - 0xc)) { uVar2 = uVar2 + (param_1 - 0xc); if (1 < (int)(param_1 - 0xe)) { uVar2 = uVar2 + (param_1 - 0xe); if (1 < (int)(param_1 - 0x10)) { uVar2 = uVar2 + (param_1 - 0x10); if (1 < (int)(param_1 - 0x12)) { uVar2 = uVar2 + (param_1 - 0x12); } } } } } } } } } LAB_0010125f: auVar13._0_4_ = (int)uVar2 / (int)uVar4; auVar13._4_4_ = 0; auVar13._8_4_ = (int)uVar2 % (int)uVar4; auVar13._12_4_ = 0; return auVar13; }
6,552
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int *num_list, int n, int *output) { int first_element = num_list[0]; int count_first = 0; int output_index = 0; // count occurrences of the first element for (int i = 0; i < n; i++) { if (num_list[i] == first_element) { count_first++; } } // build the output after the first element occurrences for (int i = 0; i < n; i++) { if (num_list[i] != first_element) { output[output_index++] = num_list[i]; } } // Append all occurrences of the first element at the end for (int i = 0; i < count_first; i++) { output[output_index++] = first_element; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 2 && result1[1] == 3 && result1[2] == 4 && result1[3] == 1); int test2[] = {2, 3, 4, 1, 5, 0}; int result2[6]; func0(test2, 6, result2); assert(result2[0] == 3 && result2[1] == 4 && result2[2] == 1 && result2[3] == 5 && result2[4] == 0 && result2[5] == 2); int test3[] = {5, 4, 3, 2, 1}; int result3[5]; func0(test3, 5, result3); assert(result3[0] == 4 && result3[1] == 3 && result3[2] == 2 && result3[3] == 1 && result3[4] == 5); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) mov %rdx,-0x38(%rbp) mov -0x28(%rbp),%rax mov (%rax),%eax mov %eax,-0x4(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) movl $0x0,-0x10(%rbp) jmp 11bf <func0+0x56> mov -0x10(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax cmp %eax,-0x4(%rbp) jne 11bb <func0+0x52> addl $0x1,-0x18(%rbp) addl $0x1,-0x10(%rbp) mov -0x10(%rbp),%eax cmp -0x2c(%rbp),%eax jl 119c <func0+0x33> movl $0x0,-0xc(%rbp) jmp 1222 <func0+0xb9> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rdx,%rax mov (%rax),%eax cmp %eax,-0x4(%rbp) je 121e <func0+0xb5> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax lea (%rdx,%rax,1),%rcx mov -0x14(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x14(%rbp) cltq lea 0x0(,%rax,4),%rdx mov -0x38(%rbp),%rax add %rax,%rdx mov (%rcx),%eax mov %eax,(%rdx) addl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x2c(%rbp),%eax jl 11d0 <func0+0x67> movl $0x0,-0x8(%rbp) jmp 1256 <func0+0xed> mov -0x14(%rbp),%eax lea 0x1(%rax),%edx mov %edx,-0x14(%rbp) cltq lea 0x0(,%rax,4),%rdx mov -0x38(%rbp),%rax add %rax,%rdx mov -0x4(%rbp),%eax mov %eax,(%rdx) addl $0x1,-0x8(%rbp) mov -0x8(%rbp),%eax cmp -0x18(%rbp),%eax jl 1233 <func0+0xca> pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov [rbp+var_38], rdx mov rax, [rbp+var_28] mov eax, [rax] mov [rbp+var_4], eax mov [rbp+var_18], 0 mov [rbp+var_14], 0 mov [rbp+var_10], 0 jmp short loc_11BF loc_119C: mov eax, [rbp+var_10] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] cmp [rbp+var_4], eax jnz short loc_11BB add [rbp+var_18], 1 loc_11BB: add [rbp+var_10], 1 loc_11BF: mov eax, [rbp+var_10] cmp eax, [rbp+var_2C] jl short loc_119C mov [rbp+var_C], 0 jmp short loc_1222 loc_11D0: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rax, rdx mov eax, [rax] cmp [rbp+var_4], eax jz short loc_121E 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_14] lea edx, [rax+1] mov [rbp+var_14], edx cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] add rdx, rax mov eax, [rcx] mov [rdx], eax loc_121E: add [rbp+var_C], 1 loc_1222: mov eax, [rbp+var_C] cmp eax, [rbp+var_2C] jl short loc_11D0 mov [rbp+var_8], 0 jmp short loc_1256 loc_1233: mov eax, [rbp+var_14] lea edx, [rax+1] mov [rbp+var_14], edx cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_38] add rdx, rax mov eax, [rbp+var_4] mov [rdx], eax add [rbp+var_8], 1 loc_1256: mov eax, [rbp+var_8] cmp eax, [rbp+var_18] jl short loc_1233 nop nop pop rbp retn
long long func0(int *a1, int a2, long long a3) { int v3; // eax int v4; // eax long long result; // rax int v6; // [rsp+20h] [rbp-18h] int v7; // [rsp+24h] [rbp-14h] int i; // [rsp+28h] [rbp-10h] int j; // [rsp+2Ch] [rbp-Ch] unsigned int k; // [rsp+30h] [rbp-8h] int v11; // [rsp+34h] [rbp-4h] v11 = *a1; v6 = 0; v7 = 0; for ( i = 0; i < a2; ++i ) { if ( v11 == a1[i] ) ++v6; } for ( j = 0; j < a2; ++j ) { if ( v11 != a1[j] ) { v3 = v7++; *(_DWORD *)(a3 + 4LL * v3) = a1[j]; } } for ( k = 0; ; ++k ) { result = k; if ( (int)k >= v6 ) break; v4 = v7++; *(_DWORD *)(a3 + 4LL * v4) = v11; } return result; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV qword ptr [RBP + -0x38],RDX MOV RAX,qword ptr [RBP + -0x28] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x4],EAX MOV dword ptr [RBP + -0x18],0x0 MOV dword ptr [RBP + -0x14],0x0 MOV dword ptr [RBP + -0x10],0x0 JMP 0x001011bf LAB_0010119c: MOV EAX,dword ptr [RBP + -0x10] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0x4],EAX JNZ 0x001011bb ADD dword ptr [RBP + -0x18],0x1 LAB_001011bb: ADD dword ptr [RBP + -0x10],0x1 LAB_001011bf: MOV EAX,dword ptr [RBP + -0x10] CMP EAX,dword ptr [RBP + -0x2c] JL 0x0010119c MOV dword ptr [RBP + -0xc],0x0 JMP 0x00101222 LAB_001011d0: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RAX,RDX MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0x4],EAX JZ 0x0010121e 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 + -0x14] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x14],EDX CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RDX,RAX MOV EAX,dword ptr [RCX] MOV dword ptr [RDX],EAX LAB_0010121e: ADD dword ptr [RBP + -0xc],0x1 LAB_00101222: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001011d0 MOV dword ptr [RBP + -0x8],0x0 JMP 0x00101256 LAB_00101233: MOV EAX,dword ptr [RBP + -0x14] LEA EDX,[RAX + 0x1] MOV dword ptr [RBP + -0x14],EDX CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x38] ADD RDX,RAX MOV EAX,dword ptr [RBP + -0x4] MOV dword ptr [RDX],EAX ADD dword ptr [RBP + -0x8],0x1 LAB_00101256: MOV EAX,dword ptr [RBP + -0x8] CMP EAX,dword ptr [RBP + -0x18] JL 0x00101233 NOP NOP POP RBP RET
void func0(int *param_1,int param_2,long param_3) { int iVar1; int local_20; int local_1c; int local_18; int local_14; int local_10; iVar1 = *param_1; local_20 = 0; local_1c = 0; for (local_18 = 0; local_18 < param_2; local_18 = local_18 + 1) { if (iVar1 == param_1[local_18]) { local_20 = local_20 + 1; } } for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 1) { if (iVar1 != param_1[local_14]) { *(int *)((long)local_1c * 4 + param_3) = param_1[local_14]; local_1c = local_1c + 1; } } for (local_10 = 0; local_10 < local_20; local_10 = local_10 + 1) { *(int *)((long)local_1c * 4 + param_3) = iVar1; local_1c = local_1c + 1; } return; }
6,553
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int *num_list, int n, int *output) { int first_element = num_list[0]; int count_first = 0; int output_index = 0; // count occurrences of the first element for (int i = 0; i < n; i++) { if (num_list[i] == first_element) { count_first++; } } // build the output after the first element occurrences for (int i = 0; i < n; i++) { if (num_list[i] != first_element) { output[output_index++] = num_list[i]; } } // Append all occurrences of the first element at the end for (int i = 0; i < count_first; i++) { output[output_index++] = first_element; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 2 && result1[1] == 3 && result1[2] == 4 && result1[3] == 1); int test2[] = {2, 3, 4, 1, 5, 0}; int result2[6]; func0(test2, 6, result2); assert(result2[0] == 3 && result2[1] == 4 && result2[2] == 1 && result2[3] == 5 && result2[4] == 0 && result2[5] == 2); int test3[] = {5, 4, 3, 2, 1}; int result3[5]; func0(test3, 5, result3); assert(result3[0] == 4 && result3[1] == 3 && result3[2] == 2 && result3[3] == 1 && result3[4] == 5); return 0; }
O1
c
func0: endbr64 mov (%rdi),%ecx test %esi,%esi jle 11df <func0+0x76> mov %rdi,%rax lea -0x1(%rsi),%esi lea 0x4(%rdi,%rsi,4),%r9 mov $0x0,%r8d cmp %ecx,(%rdi) sete %sil movzbl %sil,%esi add %esi,%r8d add $0x4,%rdi cmp %r9,%rdi jne 1184 <func0+0x1b> mov $0x0,%edi jmp 11b4 <func0+0x4b> movslq %edi,%r10 mov %esi,(%rdx,%r10,4) lea 0x1(%rdi),%edi add $0x4,%rax cmp %r9,%rax je 11bc <func0+0x53> mov (%rax),%esi cmp %ecx,%esi jne 11a1 <func0+0x38> jmp 11ab <func0+0x42> test %r8d,%r8d jle 11df <func0+0x76> movslq %edi,%rdi lea (%rdx,%rdi,4),%rax lea -0x1(%r8),%esi add %rsi,%rdi lea 0x4(%rdx,%rdi,4),%rdx mov %ecx,(%rax) add $0x4,%rax cmp %rdx,%rax jne 11d4 <func0+0x6b> retq
func0: endbr64 mov r10, rdx mov edx, [rdi] test esi, esi jle short locret_11E0 mov rax, rdi lea ecx, [rsi-1] lea r9, [rdi+rcx*4+4] mov r8d, 0 loc_1187: cmp [rdi], edx setz cl movzx ecx, cl add r8d, ecx add rdi, 4 cmp rdi, r9 jnz short loc_1187 mov esi, 0 jmp short loc_11AB loc_11A2: add rax, 4 cmp rax, r9 jz short loc_11BD loc_11AB: mov ecx, [rax] cmp ecx, edx jz short loc_11A2 movsxd rdi, esi mov [r10+rdi*4], ecx lea esi, [rsi+1] jmp short loc_11A2 loc_11BD: test r8d, r8d jle short locret_11E0 movsxd rsi, esi lea rax, [r10+rsi*4] lea ecx, [r8-1] add rcx, rsi lea rcx, [r10+rcx*4+4] loc_11D5: mov [rax], edx add rax, 4 cmp rax, rcx jnz short loc_11D5 locret_11E0: retn
void func0(_DWORD *a1, int a2, long long a3) { int v4; // edx _DWORD *v5; // rax long long v6; // r9 int v7; // r8d int v8; // esi _DWORD *v9; // rax v4 = *a1; if ( a2 > 0 ) { v5 = a1; v6 = (long long)&a1[a2 - 1 + 1]; v7 = 0; do v7 += *a1++ == v4; while ( a1 != (_DWORD *)v6 ); v8 = 0; do { if ( *v5 != v4 ) *(_DWORD *)(a3 + 4LL * v8++) = *v5; ++v5; } while ( v5 != (_DWORD *)v6 ); if ( v7 > 0 ) { v9 = (_DWORD *)(a3 + 4LL * v8); do *v9++ = v4; while ( v9 != (_DWORD *)(a3 + 4 * (v8 + (unsigned long long)(unsigned int)(v7 - 1)) + 4) ); } } }
func0: ENDBR64 MOV R10,RDX MOV EDX,dword ptr [RDI] TEST ESI,ESI JLE 0x001011e0 MOV RAX,RDI LEA ECX,[RSI + -0x1] LEA R9,[RDI + RCX*0x4 + 0x4] MOV R8D,0x0 LAB_00101187: CMP dword ptr [RDI],EDX SETZ CL MOVZX ECX,CL ADD R8D,ECX ADD RDI,0x4 CMP RDI,R9 JNZ 0x00101187 MOV ESI,0x0 JMP 0x001011ab LAB_001011a2: ADD RAX,0x4 CMP RAX,R9 JZ 0x001011bd LAB_001011ab: MOV ECX,dword ptr [RAX] CMP ECX,EDX JZ 0x001011a2 MOVSXD RDI,ESI MOV dword ptr [R10 + RDI*0x4],ECX LEA ESI,[RSI + 0x1] JMP 0x001011a2 LAB_001011bd: TEST R8D,R8D JLE 0x001011e0 MOVSXD RSI,ESI LEA RAX,[R10 + RSI*0x4] LEA ECX,[R8 + -0x1] ADD RCX,RSI LEA RCX,[R10 + RCX*0x4 + 0x4] LAB_001011d5: MOV dword ptr [RAX],EDX ADD RAX,0x4 CMP RAX,RCX JNZ 0x001011d5 LAB_001011e0: RET
void func0(int *param_1,int param_2,long param_3) { int iVar1; int *piVar2; int iVar3; int *piVar4; int iVar5; iVar1 = *param_1; if (0 < param_2) { piVar2 = param_1 + (ulong)(param_2 - 1) + 1; iVar5 = 0; piVar4 = param_1; do { iVar5 = iVar5 + (uint)(*piVar4 == iVar1); piVar4 = piVar4 + 1; } while (piVar4 != piVar2); iVar3 = 0; do { if (*param_1 != iVar1) { *(int *)(param_3 + (long)iVar3 * 4) = *param_1; iVar3 = iVar3 + 1; } param_1 = param_1 + 1; } while (param_1 != piVar2); if (0 < iVar5) { piVar2 = (int *)(param_3 + (long)iVar3 * 4); do { *piVar2 = iVar1; piVar2 = piVar2 + 1; } while (piVar2 != (int *)(param_3 + 4 + ((ulong)(iVar5 - 1) + (long)iVar3) * 4)); } } return; }
6,554
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int *num_list, int n, int *output) { int first_element = num_list[0]; int count_first = 0; int output_index = 0; // count occurrences of the first element for (int i = 0; i < n; i++) { if (num_list[i] == first_element) { count_first++; } } // build the output after the first element occurrences for (int i = 0; i < n; i++) { if (num_list[i] != first_element) { output[output_index++] = num_list[i]; } } // Append all occurrences of the first element at the end for (int i = 0; i < count_first; i++) { output[output_index++] = first_element; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 2 && result1[1] == 3 && result1[2] == 4 && result1[3] == 1); int test2[] = {2, 3, 4, 1, 5, 0}; int result2[6]; func0(test2, 6, result2); assert(result2[0] == 3 && result2[1] == 4 && result2[2] == 1 && result2[3] == 5 && result2[4] == 0 && result2[5] == 2); int test3[] = {5, 4, 3, 2, 1}; int result3[5]; func0(test3, 5, result3); assert(result3[0] == 4 && result3[1] == 3 && result3[2] == 2 && result3[3] == 1 && result3[4] == 5); return 0; }
O2
c
func0: endbr64 mov (%rdi),%ecx test %esi,%esi jle 13e3 <func0+0x83> lea -0x1(%rsi),%eax add $0x4,%rdi mov %ecx,%esi xor %r9d,%r9d lea (%rdi,%rax,4),%r8 mov %rdi,%rax jmp 1386 <func0+0x26> mov (%rax),%esi add $0x4,%rax cmp %ecx,%esi sete %sil movzbl %sil,%esi add %esi,%r9d cmp %r8,%rax jne 1380 <func0+0x20> xor %esi,%esi jmp 13b6 <func0+0x56> nopl 0x0(%rax) mov (%rdi),%r8d cmp %ecx,%r8d je 13b2 <func0+0x52> movslq %esi,%r10 add $0x1,%esi mov %r8d,(%rdx,%r10,4) add $0x4,%rdi cmp %rax,%rdi jne 13a0 <func0+0x40> test %r9d,%r9d je 13e3 <func0+0x83> movslq %esi,%rsi lea -0x1(%r9),%edi lea (%rdx,%rsi,4),%rax add %rdi,%rsi lea 0x4(%rdx,%rsi,4),%rdx nopl 0x0(%rax,%rax,1) mov %ecx,(%rax) add $0x4,%rax cmp %rax,%rdx jne 13d8 <func0+0x78> retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 mov r10, rdx mov edx, [rdi] test esi, esi jle short locret_13EB lea eax, [rsi-1] add rdi, 4 mov ecx, edx xor esi, esi lea r8, [rdi+rax*4] mov rax, rdi jmp short loc_138E loc_1388: mov ecx, [rax] add rax, 4 loc_138E: cmp ecx, edx setz cl movzx ecx, cl add esi, ecx cmp rax, r8 jnz short loc_1388 xor eax, eax jmp short loc_13BC loc_13A8: mov ecx, [rdi] cmp ecx, edx jz short loc_13B8 movsxd r9, eax add eax, 1 mov [r10+r9*4], ecx loc_13B8: add rdi, 4 loc_13BC: cmp rdi, r8 jnz short loc_13A8 test esi, esi jz short locret_13EB movsxd rcx, eax sub esi, 1 lea rax, [r10+rcx*4] add rcx, rsi lea rcx, [r10+rcx*4+4] nop word ptr [rax+rax+00000000h] loc_13E0: mov [rax], edx add rax, 4 cmp rcx, rax jnz short loc_13E0 locret_13EB: retn
void func0(int *a1, int a2, long long a3) { int v4; // edx long long v5; // rax int *v6; // rdi int v7; // ecx int v8; // esi int *v9; // r8 int *i; // rax int v11; // eax long long v12; // r9 long long v13; // rcx _DWORD *v14; // rax long long v15; // rcx v4 = *a1; if ( a2 > 0 ) { v5 = (unsigned int)(a2 - 1); v6 = a1 + 1; v7 = v4; v8 = 0; v9 = &v6[v5]; for ( i = v6; ; ++i ) { v8 += v7 == v4; if ( i == v9 ) break; v7 = *i; } v11 = 0; while ( v6 != v9 ) { if ( *v6 != v4 ) { v12 = v11++; *(_DWORD *)(a3 + 4 * v12) = *v6; } ++v6; } if ( v8 ) { v13 = v11; v14 = (_DWORD *)(a3 + 4LL * v11); v15 = a3 + 4 * ((unsigned int)(v8 - 1) + v13) + 4; do *v14++ = v4; while ( (_DWORD *)v15 != v14 ); } } }
func0: ENDBR64 MOV R10,RDX MOV EDX,dword ptr [RDI] TEST ESI,ESI JLE 0x001013eb LEA EAX,[RSI + -0x1] ADD RDI,0x4 MOV ECX,EDX XOR ESI,ESI LEA R8,[RDI + RAX*0x4] MOV RAX,RDI JMP 0x0010138e LAB_00101388: MOV ECX,dword ptr [RAX] ADD RAX,0x4 LAB_0010138e: CMP ECX,EDX SETZ CL MOVZX ECX,CL ADD ESI,ECX CMP RAX,R8 JNZ 0x00101388 XOR EAX,EAX JMP 0x001013bc LAB_001013a8: MOV ECX,dword ptr [RDI] CMP ECX,EDX JZ 0x001013b8 MOVSXD R9,EAX ADD EAX,0x1 MOV dword ptr [R10 + R9*0x4],ECX LAB_001013b8: ADD RDI,0x4 LAB_001013bc: CMP RDI,R8 JNZ 0x001013a8 TEST ESI,ESI JZ 0x001013eb MOVSXD RCX,EAX SUB ESI,0x1 LEA RAX,[R10 + RCX*0x4] ADD RCX,RSI LEA RCX,[R10 + RCX*0x4 + 0x4] NOP word ptr [RAX + RAX*0x1] LAB_001013e0: MOV dword ptr [RAX],EDX ADD RAX,0x4 CMP RCX,RAX JNZ 0x001013e0 LAB_001013eb: RET
void func0(int *param_1,int param_2,long param_3) { int iVar1; int iVar2; int *piVar3; int *piVar4; int iVar5; long lVar6; iVar1 = *param_1; if (0 < param_2) { param_1 = param_1 + 1; iVar5 = 0; piVar4 = param_1 + (param_2 - 1); iVar2 = iVar1; for (piVar3 = param_1; iVar5 = iVar5 + (uint)(iVar2 == iVar1), piVar3 != piVar4; piVar3 = piVar3 + 1) { iVar2 = *piVar3; } iVar2 = 0; for (; param_1 != piVar4; param_1 = param_1 + 1) { if (*param_1 != iVar1) { lVar6 = (long)iVar2; iVar2 = iVar2 + 1; *(int *)(param_3 + lVar6 * 4) = *param_1; } } if (iVar5 != 0) { piVar4 = (int *)(param_3 + (long)iVar2 * 4); do { *piVar4 = iVar1; piVar4 = piVar4 + 1; } while ((int *)(param_3 + 4 + ((long)iVar2 + (ulong)(iVar5 - 1)) * 4) != piVar4); } } return; }
6,555
func0
#include <stdio.h> #include <stdlib.h> #include <assert.h>
void func0(int *num_list, int n, int *output) { int first_element = num_list[0]; int count_first = 0; int output_index = 0; // count occurrences of the first element for (int i = 0; i < n; i++) { if (num_list[i] == first_element) { count_first++; } } // build the output after the first element occurrences for (int i = 0; i < n; i++) { if (num_list[i] != first_element) { output[output_index++] = num_list[i]; } } // Append all occurrences of the first element at the end for (int i = 0; i < count_first; i++) { output[output_index++] = first_element; } }
int main() { int test1[] = {1, 2, 3, 4}; int result1[4]; func0(test1, 4, result1); assert(result1[0] == 2 && result1[1] == 3 && result1[2] == 4 && result1[3] == 1); int test2[] = {2, 3, 4, 1, 5, 0}; int result2[6]; func0(test2, 6, result2); assert(result2[0] == 3 && result2[1] == 4 && result2[2] == 1 && result2[3] == 5 && result2[4] == 0 && result2[5] == 2); int test3[] = {5, 4, 3, 2, 1}; int result3[5]; func0(test3, 5, result3); assert(result3[0] == 4 && result3[1] == 3 && result3[2] == 2 && result3[3] == 1 && result3[4] == 5); return 0; }
O3
c
func0: endbr64 mov (%rdi),%r9d test %esi,%esi jle 1497 <func0+0x177> lea -0x1(%rsi),%eax cmp $0x3,%eax jbe 14a9 <func0+0x189> mov %esi,%ecx movd %r9d,%xmm3 pxor %xmm1,%xmm1 mov %rdi,%rax shr $0x2,%ecx pshufd $0x0,%xmm3,%xmm2 shl $0x4,%rcx add %rdi,%rcx nopl 0x0(%rax,%rax,1) movdqu (%rax),%xmm0 add $0x10,%rax pcmpeqd %xmm2,%xmm0 psubd %xmm0,%xmm1 cmp %rcx,%rax jne 1360 <func0+0x40> movdqa %xmm1,%xmm0 mov %esi,%eax psrldq $0x8,%xmm0 and $0xfffffffc,%eax paddd %xmm0,%xmm1 movdqa %xmm1,%xmm0 psrldq $0x4,%xmm0 paddd %xmm0,%xmm1 movd %xmm1,%r8d test $0x3,%sil je 13eb <func0+0xcb> movslq %eax,%rcx cmp %r9d,(%rdi,%rcx,4) je 14ae <func0+0x18e> lea 0x1(%rax),%ecx cmp %esi,%ecx jge 14e9 <func0+0x1c9> movslq %ecx,%rcx cmp %r9d,(%rdi,%rcx,4) je 14a0 <func0+0x180> lea 0x2(%rax),%ecx cmp %ecx,%esi jle 13eb <func0+0xcb> movslq %ecx,%rcx cmp (%rdi,%rcx,4),%r9d je 14c8 <func0+0x1a8> add $0x3,%eax cmp %eax,%esi jle 13eb <func0+0xcb> cltq cmp (%rdi,%rax,4),%r9d je 14e0 <func0+0x1c0> lea -0x2(%rsi),%ecx lea 0x4(%rdi),%rax lea 0x8(%rdi,%rcx,4),%r10 xor %ecx,%ecx nopl 0x0(%rax) mov (%rax),%esi cmp %r9d,%esi je 1410 <func0+0xf0> movslq %ecx,%rdi add $0x1,%ecx mov %esi,(%rdx,%rdi,4) add $0x4,%rax cmp %r10,%rax jne 1400 <func0+0xe0> test %r8d,%r8d jle 1497 <func0+0x177> lea -0x1(%r8),%eax cmp $0x2,%eax jbe 14f9 <func0+0x1d9> mov %r8d,%esi movslq %ecx,%rax movd %r9d,%xmm4 shr $0x2,%esi lea (%rdx,%rax,4),%rax pshufd $0x0,%xmm4,%xmm0 shl $0x4,%rsi add %rax,%rsi nopl 0x0(%rax) movups %xmm0,(%rax) add $0x10,%rax cmp %rsi,%rax jne 1450 <func0+0x130> mov %r8d,%eax and $0xfffffffc,%eax add %eax,%ecx cmp %eax,%r8d je 14c0 <func0+0x1a0> lea 0x1(%rcx),%esi movslq %ecx,%rcx mov %r9d,(%rdx,%rcx,4) lea 0x1(%rax),%ecx cmp %r8d,%ecx jge 1497 <func0+0x177> movslq %esi,%rcx add $0x2,%eax mov %r9d,(%rdx,%rcx,4) lea 0x0(,%rcx,4),%rsi cmp %r8d,%eax jge 1497 <func0+0x177> mov %r9d,0x4(%rdx,%rsi,1) retq nopl 0x0(%rax,%rax,1) add $0x1,%r8d jmpq 13c4 <func0+0xa4> xor %eax,%eax xor %r8d,%r8d add $0x1,%r8d jmpq 13ac <func0+0x8c> nopw 0x0(%rax,%rax,1) retq nopl 0x0(%rax) add $0x3,%eax add $0x1,%r8d cmp %eax,%esi jg 13df <func0+0xbf> jmpq 13eb <func0+0xcb> nopl 0x0(%rax) add $0x1,%r8d jmpq 13eb <func0+0xcb> xor %ecx,%ecx cmp $0x1,%esi je 1419 <func0+0xf9> jmpq 13eb <func0+0xcb> xor %eax,%eax jmpq 1469 <func0+0x149>
func0: endbr64 mov rax, rdi mov r8d, esi mov edi, [rdi] mov r9, rdx test esi, esi jle locret_1484 lea edx, [rsi-1] cmp edx, 2 jbe loc_1490 mov ecx, esi movd xmm3, edi pxor xmm1, xmm1 mov rdx, rax shr ecx, 2 pshufd xmm2, xmm3, 0 shl rcx, 4 add rcx, rax nop loc_1360: movdqu xmm0, xmmword ptr [rdx] add rdx, 10h pcmpeqd xmm0, xmm2 psubd xmm1, xmm0 cmp rdx, rcx jnz short loc_1360 movdqa xmm0, xmm1 mov ecx, r8d psrldq xmm0, 8 and ecx, 0FFFFFFFCh paddd xmm1, xmm0 movdqa xmm0, xmm1 psrldq xmm0, 4 paddd xmm1, xmm0 movd esi, xmm1 test r8b, 3 jz short loc_13D9 movsxd r10, ecx lea rdx, ds:0[r10*4] cmp [rax+r10*4], edi jz loc_1496 loc_13B4: lea r10d, [rcx+1] cmp r8d, r10d jle short loc_13D9 cmp edi, [rax+rdx+4] jz loc_1488 loc_13C7: add ecx, 2 cmp r8d, ecx jle short loc_13D9 cmp edi, [rax+rdx+8] jz loc_14A0 loc_13D9: movsxd rdx, r8d lea r10, [rax+rdx*4] xor edx, edx nop word ptr [rax+rax+00h] loc_13E8: mov ecx, [rax] cmp ecx, edi jz short loc_13F8 movsxd r8, edx add edx, 1 mov [r9+r8*4], ecx loc_13F8: add rax, 4 cmp r10, rax jnz short loc_13E8 test esi, esi jle short locret_1484 lea eax, [rsi-1] cmp eax, 2 jbe loc_14A8 mov ecx, esi movsxd rax, edx movd xmm4, edi shr ecx, 2 lea rax, [r9+rax*4] pshufd xmm0, xmm4, 0 shl rcx, 4 lea r8, [rcx+rax] and ecx, 10h jz short loc_1440 movups xmmword ptr [rax], xmm0 add rax, 10h cmp r8, rax jz short loc_1450 nop loc_1440: movups xmmword ptr [rax], xmm0 add rax, 20h ; ' ' movups xmmword ptr [rax-10h], xmm0 cmp r8, rax jnz short loc_1440 loc_1450: mov eax, esi and eax, 0FFFFFFFCh add edx, eax test sil, 3 jz short locret_1484 loc_145D: movsxd rdx, edx mov [r9+rdx*4], edi lea rcx, ds:0[rdx*4] lea edx, [rax+1] cmp edx, esi jge short locret_1484 add eax, 2 mov [r9+rcx+4], edi cmp eax, esi jge short locret_1484 mov [r9+rcx+8], edi locret_1484: retn loc_1488: add esi, 1 jmp loc_13C7 loc_1490: xor ecx, ecx xor esi, esi xor edx, edx loc_1496: add esi, 1 jmp loc_13B4 loc_14A0: add esi, 1 jmp loc_13D9 loc_14A8: xor eax, eax jmp short loc_145D
const __m128i * func0(unsigned int *a1, int a2, long long a3) { const __m128i *result; // rax unsigned int v5; // edi __m128i v7; // xmm1 const __m128i *v8; // rdx __m128i v9; // xmm2 __m128i v10; // xmm0 signed int v11; // ecx __m128i v12; // xmm1 int v13; // esi long long v14; // rdx const __m128i *v15; // r10 int v16; // edx long long v17; // r8 __m128i *v18; // rax __m128i v19; // xmm0 long long v20; // rcx __m128i *v21; // r8 long long v22; // rcx result = (const __m128i *)a1; v5 = *a1; if ( a2 <= 0 ) return result; if ( (unsigned int)(a2 - 1) <= 2 ) { v11 = 0; v13 = 0; v14 = 0LL; LABEL_28: ++v13; goto LABEL_7; } v7 = 0LL; v8 = result; v9 = _mm_shuffle_epi32(_mm_cvtsi32_si128(v5), 0); do { v10 = _mm_loadu_si128(v8++); v7 = _mm_sub_epi32(v7, _mm_cmpeq_epi32(v10, v9)); } while ( v8 != &result[(unsigned int)a2 >> 2] ); v11 = a2 & 0xFFFFFFFC; v12 = _mm_add_epi32(v7, _mm_srli_si128(v7, 8)); v13 = _mm_cvtsi128_si32(_mm_add_epi32(v12, _mm_srli_si128(v12, 4))); if ( (a2 & 3) == 0 ) goto LABEL_13; v14 = v11; if ( result->m128i_i32[v14] == v5 ) goto LABEL_28; LABEL_7: if ( a2 > v11 + 1 ) { if ( v5 == result->m128i_i32[v14 + 1] ) ++v13; if ( a2 > v11 + 2 && v5 == result->m128i_i32[v14 + 2] ) ++v13; } LABEL_13: v15 = (const __m128i *)((char *)result + 4 * a2); v16 = 0; do { if ( result->m128i_i32[0] != v5 ) { v17 = v16++; *(_DWORD *)(a3 + 4 * v17) = result->m128i_i32[0]; } result = (const __m128i *)((char *)result + 4); } while ( v15 != result ); if ( v13 > 0 ) { if ( (unsigned int)(v13 - 1) <= 2 ) { result = 0LL; LABEL_23: *(_DWORD *)(a3 + 4LL * v16) = v5; v22 = 4LL * v16; if ( (int)result + 1 < v13 ) { result = (const __m128i *)(unsigned int)((_DWORD)result + 2); *(_DWORD *)(a3 + v22 + 4) = v5; if ( (int)result < v13 ) *(_DWORD *)(a3 + v22 + 8) = v5; } return result; } v18 = (__m128i *)(a3 + 4LL * v16); v19 = _mm_shuffle_epi32(_mm_cvtsi32_si128(v5), 0); v20 = (unsigned int)v13 >> 2; v21 = &v18[v20]; if ( ((v20 * 16) & 0x10) == 0 || (*v18 = v19, ++v18, v21 != v18) ) { do { *v18 = v19; v18 += 2; v18[-1] = v19; } while ( v21 != v18 ); } result = (const __m128i *)(v13 & 0xFFFFFFFC); v16 += (int)result; if ( (v13 & 3) != 0 ) goto LABEL_23; } return result; }
func0: ENDBR64 MOV RAX,RDI MOV R8D,ESI MOV EDI,dword ptr [RDI] MOV R9,RDX TEST ESI,ESI JLE 0x00101484 LEA EDX,[RSI + -0x1] CMP EDX,0x2 JBE 0x00101490 MOV ECX,ESI MOVD XMM3,EDI PXOR XMM1,XMM1 MOV RDX,RAX SHR ECX,0x2 PSHUFD XMM2,XMM3,0x0 SHL RCX,0x4 ADD RCX,RAX NOP LAB_00101360: MOVDQU XMM0,xmmword ptr [RDX] ADD RDX,0x10 PCMPEQD XMM0,XMM2 PSUBD XMM1,XMM0 CMP RDX,RCX JNZ 0x00101360 MOVDQA XMM0,XMM1 MOV ECX,R8D PSRLDQ XMM0,0x8 AND ECX,0xfffffffc PADDD XMM1,XMM0 MOVDQA XMM0,XMM1 PSRLDQ XMM0,0x4 PADDD XMM1,XMM0 MOVD ESI,XMM1 TEST R8B,0x3 JZ 0x001013d9 MOVSXD R10,ECX LEA RDX,[R10*0x4] CMP dword ptr [RAX + R10*0x4],EDI JZ 0x00101496 LAB_001013b4: LEA R10D,[RCX + 0x1] CMP R8D,R10D JLE 0x001013d9 CMP EDI,dword ptr [RAX + RDX*0x1 + 0x4] JZ 0x00101488 LAB_001013c7: ADD ECX,0x2 CMP R8D,ECX JLE 0x001013d9 CMP EDI,dword ptr [RAX + RDX*0x1 + 0x8] JZ 0x001014a0 LAB_001013d9: MOVSXD RDX,R8D LEA R10,[RAX + RDX*0x4] XOR EDX,EDX NOP word ptr [RAX + RAX*0x1] LAB_001013e8: MOV ECX,dword ptr [RAX] CMP ECX,EDI JZ 0x001013f8 MOVSXD R8,EDX ADD EDX,0x1 MOV dword ptr [R9 + R8*0x4],ECX LAB_001013f8: ADD RAX,0x4 CMP R10,RAX JNZ 0x001013e8 TEST ESI,ESI JLE 0x00101484 LEA EAX,[RSI + -0x1] CMP EAX,0x2 JBE 0x001014a8 MOV ECX,ESI MOVSXD RAX,EDX MOVD XMM4,EDI SHR ECX,0x2 LEA RAX,[R9 + RAX*0x4] PSHUFD XMM0,XMM4,0x0 SHL RCX,0x4 LEA R8,[RCX + RAX*0x1] AND ECX,0x10 JZ 0x00101440 MOVUPS xmmword ptr [RAX],XMM0 ADD RAX,0x10 CMP R8,RAX JZ 0x00101450 NOP LAB_00101440: MOVUPS xmmword ptr [RAX],XMM0 ADD RAX,0x20 MOVUPS xmmword ptr [RAX + -0x10],XMM0 CMP R8,RAX JNZ 0x00101440 LAB_00101450: MOV EAX,ESI AND EAX,0xfffffffc ADD EDX,EAX TEST SIL,0x3 JZ 0x00101484 LAB_0010145d: MOVSXD RDX,EDX MOV dword ptr [R9 + RDX*0x4],EDI LEA RCX,[RDX*0x4] LEA EDX,[RAX + 0x1] CMP EDX,ESI JGE 0x00101484 ADD EAX,0x2 MOV dword ptr [R9 + RCX*0x1 + 0x4],EDI CMP EAX,ESI JGE 0x00101484 MOV dword ptr [R9 + RCX*0x1 + 0x8],EDI LAB_00101484: RET LAB_00101488: ADD ESI,0x1 JMP 0x001013c7 LAB_00101490: XOR ECX,ECX XOR ESI,ESI XOR EDX,EDX LAB_00101496: ADD ESI,0x1 JMP 0x001013b4 LAB_001014a0: ADD ESI,0x1 JMP 0x001013d9 LAB_001014a8: XOR EAX,EAX JMP 0x0010145d
void func0(int *param_1,uint param_2,long param_3) { int iVar1; int iVar2; int *piVar3; int *piVar4; int *piVar5; int *piVar6; uint uVar7; long lVar8; int iVar9; uint uVar10; int iVar11; int iVar12; int iVar13; iVar1 = *param_1; if ((int)param_2 < 1) { return; } if (param_2 - 1 < 3) { uVar7 = 0; uVar10 = 0; lVar8 = 0; LAB_00101496: uVar10 = uVar10 + 1; } else { iVar9 = 0; iVar11 = 0; iVar12 = 0; iVar13 = 0; piVar6 = param_1; do { iVar2 = *piVar6; piVar3 = piVar6 + 1; piVar4 = piVar6 + 2; piVar5 = piVar6 + 3; piVar6 = piVar6 + 4; iVar9 = iVar9 + (uint)(iVar2 == iVar1); iVar11 = iVar11 + (uint)(*piVar3 == iVar1); iVar12 = iVar12 + (uint)(*piVar4 == iVar1); iVar13 = iVar13 + (uint)(*piVar5 == iVar1); } while (piVar6 != param_1 + (ulong)(param_2 >> 2) * 4); uVar7 = param_2 & 0xfffffffc; uVar10 = iVar9 + iVar12 + iVar11 + iVar13; if ((param_2 & 3) == 0) goto LAB_001013d9; lVar8 = (long)(int)uVar7 * 4; if (param_1[(int)uVar7] == iVar1) goto LAB_00101496; } if ((int)(uVar7 + 1) < (int)param_2) { if (iVar1 == *(int *)((long)param_1 + lVar8 + 4)) { uVar10 = uVar10 + 1; } if (((int)(uVar7 + 2) < (int)param_2) && (iVar1 == *(int *)((long)param_1 + lVar8 + 8))) { uVar10 = uVar10 + 1; } } LAB_001013d9: piVar6 = param_1 + (int)param_2; iVar9 = 0; do { if (*param_1 != iVar1) { lVar8 = (long)iVar9; iVar9 = iVar9 + 1; *(int *)(param_3 + lVar8 * 4) = *param_1; } param_1 = param_1 + 1; } while (piVar6 != param_1); if (0 < (int)uVar10) { if (uVar10 - 1 < 3) { uVar7 = 0; } else { piVar6 = (int *)(param_3 + (long)iVar9 * 4); piVar3 = piVar6 + (ulong)(uVar10 >> 2) * 4; if (((ulong)(uVar10 >> 2) * 0x10 & 0x10) == 0) goto LAB_00101440; *piVar6 = iVar1; piVar6[1] = iVar1; piVar6[2] = iVar1; piVar6[3] = iVar1; for (piVar6 = piVar6 + 4; piVar3 != piVar6; piVar6 = piVar6 + 8) { LAB_00101440: *piVar6 = iVar1; piVar6[1] = iVar1; piVar6[2] = iVar1; piVar6[3] = iVar1; piVar6[4] = iVar1; piVar6[5] = iVar1; piVar6[6] = iVar1; piVar6[7] = iVar1; } uVar7 = uVar10 & 0xfffffffc; iVar9 = iVar9 + uVar7; if ((uVar10 & 3) == 0) { return; } } *(int *)(param_3 + (long)iVar9 * 4) = iVar1; lVar8 = (long)iVar9 * 4; if (((int)(uVar7 + 1) < (int)uVar10) && (*(int *)(param_3 + 4 + lVar8) = iVar1, (int)(uVar7 + 2) < (int)uVar10)) { *(int *)(param_3 + 8 + lVar8) = iVar1; } } return; }
6,556
func0
#include <assert.h> #include <string.h>
int func0(const char *string, char c) { int count = 0; for (int i = 0; i < strlen(string); i++) { if (string[i] == c) { count++; } } return count; }
int main() { assert(func0("Python", 'o') == 1); assert(func0("little", 't') == 2); assert(func0("assert", 's') == 2); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x28,%rsp mov %rdi,-0x28(%rbp) mov %esi,%eax mov %al,-0x2c(%rbp) movl $0x0,-0x18(%rbp) movl $0x0,-0x14(%rbp) jmp 11ac <func0+0x43> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax add %rdx,%rax movzbl (%rax),%eax cmp %al,-0x2c(%rbp) jne 11a8 <func0+0x3f> addl $0x1,-0x18(%rbp) addl $0x1,-0x14(%rbp) mov -0x14(%rbp),%eax movslq %eax,%rbx mov -0x28(%rbp),%rax mov %rax,%rdi callq 1060 <strlen@plt> cmp %rax,%rbx jb 118f <func0+0x26> mov -0x18(%rbp),%eax add $0x28,%rsp pop %rbx pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 28h 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_11AC loc_118F: 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_11A8 add [rbp+var_18], 1 loc_11A8: add [rbp+var_14], 1 loc_11AC: mov eax, [rbp+var_14] movsxd rbx, eax mov rax, [rbp+s] mov rdi, rax; s call _strlen cmp rbx, rax jb short loc_118F mov eax, [rbp+var_18] mov rbx, [rbp+var_8] leave retn
long long func0(const char *a1, char a2) { unsigned int v3; // [rsp+18h] [rbp-18h] int i; // [rsp+1Ch] [rbp-14h] v3 = 0; for ( i = 0; i < strlen(a1); ++i ) { if ( a2 == a1[i] ) ++v3; } return v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x28 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 0x001011ac LAB_0010118f: 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 0x001011a8 ADD dword ptr [RBP + -0x18],0x1 LAB_001011a8: ADD dword ptr [RBP + -0x14],0x1 LAB_001011ac: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RBX,EAX MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x00101060 CMP RBX,RAX JC 0x0010118f MOV EAX,dword ptr [RBP + -0x18] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
int func0(char *param_1,char param_2) { size_t sVar1; int local_20; int local_1c; local_20 = 0; local_1c = 0; while( true ) { sVar1 = strlen(param_1); if (sVar1 <= (ulong)(long)local_1c) break; if (param_2 == param_1[local_1c]) { local_20 = local_20 + 1; } local_1c = local_1c + 1; } return local_20; }
6,557
func0
#include <assert.h> #include <string.h>
int func0(const char *string, char c) { int count = 0; for (int i = 0; i < strlen(string); i++) { if (string[i] == c) { count++; } } return count; }
int main() { assert(func0("Python", 'o') == 1); assert(func0("little", 't') == 2); assert(func0("assert", 's') == 2); return 0; }
O1
c
func0: endbr64 mov %rdi,%r8 mov $0xffffffffffffffff,%rcx mov $0x0,%eax repnz scas %es:(%rdi),%al not %rcx mov %r8,%rdx lea -0x1(%r8,%rcx,1),%rdi mov $0x0,%eax cmp %rdi,%rdx je 1184 <func0+0x3b> cmp %sil,(%rdx) sete %cl movzbl %cl,%ecx add %ecx,%eax add $0x1,%rdx jmp 116e <func0+0x25> retq
func0: endbr64 push rbp push rbx sub rsp, 8 mov rbx, rdi mov ebp, esi call _strlen mov rdi, rax mov rax, rbx add rdi, rbx mov edx, 0 jmp short loc_119C loc_118D: cmp [rax], bpl setz cl movzx ecx, cl add edx, ecx add rax, 1 loc_119C: cmp rax, rdi jnz short loc_118D mov eax, edx add rsp, 8 pop rbx pop rbp retn
long long func0(_BYTE *a1, unsigned __int8 a2) { long long v3; // rdi _BYTE *v4; // rax _BYTE *v5; // rdi unsigned int v6; // edx v3 = strlen(); v4 = a1; v5 = &a1[v3]; v6 = 0; while ( v4 != v5 ) v6 += *v4++ == a2; return v6; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x8 MOV RBX,RDI MOV EBP,ESI CALL 0x00101060 MOV RDI,RAX MOV RAX,RBX ADD RDI,RBX MOV EDX,0x0 JMP 0x0010119c LAB_0010118d: CMP byte ptr [RAX],BPL SETZ CL MOVZX ECX,CL ADD EDX,ECX ADD RAX,0x1 LAB_0010119c: CMP RAX,RDI JNZ 0x0010118d MOV EAX,EDX ADD RSP,0x8 POP RBX POP RBP RET
int func0(char *param_1,char param_2) { size_t sVar1; int iVar2; char *pcVar3; sVar1 = strlen(param_1); pcVar3 = param_1 + sVar1; iVar2 = 0; for (; param_1 != pcVar3; param_1 = param_1 + 1) { iVar2 = iVar2 + (uint)(*param_1 == param_2); } return iVar2; }
6,558
func0
#include <assert.h> #include <string.h>
int func0(const char *string, char c) { int count = 0; for (int i = 0; i < strlen(string); i++) { if (string[i] == c) { count++; } } return count; }
int main() { assert(func0("Python", 'o') == 1); assert(func0("little", 't') == 2); assert(func0("assert", 's') == 2); return 0; }
O2
c
func0: endbr64 push %rbp mov %esi,%ebp push %rbx mov %rdi,%rbx sub $0x8,%rsp callq 1060 <strlen@plt> mov %rbx,%rdi lea (%rbx,%rax,1),%rcx xor %eax,%eax jmp 129e <func0+0x2e> xor %edx,%edx cmp %bpl,(%rdi) sete %dl add $0x1,%rdi add %edx,%eax cmp %rcx,%rdi jne 1290 <func0+0x20> add $0x8,%rsp pop %rbx pop %rbp retq nopw 0x0(%rax,%rax,1)
func0: endbr64 push rbp mov ebp, esi push rbx mov rbx, rdi sub rsp, 8 call _strlen mov rdi, rbx lea rcx, [rbx+rax] xor eax, eax jmp short loc_124E loc_1240: xor edx, edx cmp [rdi], bpl setz dl add rdi, 1 add eax, edx loc_124E: cmp rdi, rcx jnz short loc_1240 add rsp, 8 pop rbx pop rbp retn
long long func0(_BYTE *a1, unsigned __int8 a2) { _BYTE *v2; // rcx long long result; // rax BOOL v4; // edx v2 = &a1[strlen()]; result = 0LL; while ( a1 != v2 ) { v4 = *a1++ == a2; result = (unsigned int)(v4 + result); } return result; }
func0: ENDBR64 PUSH RBP MOV EBP,ESI PUSH RBX MOV RBX,RDI SUB RSP,0x8 CALL 0x00101060 MOV RDI,RBX LEA RCX,[RBX + RAX*0x1] XOR EAX,EAX JMP 0x0010124e LAB_00101240: XOR EDX,EDX CMP byte ptr [RDI],BPL SETZ DL ADD RDI,0x1 ADD EAX,EDX LAB_0010124e: CMP RDI,RCX JNZ 0x00101240 ADD RSP,0x8 POP RBX POP RBP RET
int func0(char *param_1,char param_2) { char *pcVar1; int iVar2; size_t sVar3; sVar3 = strlen(param_1); pcVar1 = param_1 + sVar3; iVar2 = 0; for (; param_1 != pcVar1; param_1 = param_1 + 1) { iVar2 = iVar2 + (uint)(*param_1 == param_2); } return iVar2; }
6,559
func0
#include <assert.h> #include <string.h>
int func0(const char *string, char c) { int count = 0; for (int i = 0; i < strlen(string); i++) { if (string[i] == c) { count++; } } return count; }
int main() { assert(func0("Python", 'o') == 1); assert(func0("little", 't') == 2); assert(func0("assert", 's') == 2); return 0; }
O3
c
func0: endbr64 push %rbp mov %esi,%ebp push %rbx mov %rdi,%rbx sub $0x8,%rsp callq 1050 <strlen@plt> test %rax,%rax je 13f0 <func0+0x290> mov %rax,%rcx lea -0x1(%rax),%rax cmp $0xe,%rax jbe 13f9 <func0+0x299> movd %ebp,%xmm4 mov %rcx,%rax pxor %xmm1,%xmm1 mov %rbx,%rdx punpcklbw %xmm4,%xmm4 pxor %xmm6,%xmm6 pxor %xmm5,%xmm5 and $0xfffffffffffffff0,%rax punpcklwd %xmm4,%xmm4 movdqa 0xe58(%rip),%xmm7 add %rbx,%rax pshufd $0x0,%xmm4,%xmm4 movdqu (%rdx),%xmm0 movdqa %xmm6,%xmm3 add $0x10,%rdx pcmpeqb %xmm4,%xmm0 pand %xmm7,%xmm0 pcmpgtb %xmm0,%xmm3 movdqa %xmm0,%xmm2 punpcklbw %xmm3,%xmm2 punpckhbw %xmm3,%xmm0 movdqa %xmm5,%xmm3 pcmpgtw %xmm2,%xmm3 movdqa %xmm2,%xmm8 punpcklwd %xmm3,%xmm8 punpckhwd %xmm3,%xmm2 movdqa %xmm0,%xmm3 paddd %xmm8,%xmm1 paddd %xmm2,%xmm1 movdqa %xmm5,%xmm2 pcmpgtw %xmm0,%xmm2 punpcklwd %xmm2,%xmm3 punpckhwd %xmm2,%xmm0 paddd %xmm3,%xmm1 paddd %xmm0,%xmm1 cmp %rax,%rdx jne 11c0 <func0+0x60> movdqa %xmm1,%xmm0 mov %rcx,%rsi psrldq $0x8,%xmm0 and $0xfffffffffffffff0,%rsi paddd %xmm1,%xmm0 mov %esi,%edx movdqa %xmm0,%xmm1 psrldq $0x4,%xmm1 paddd %xmm1,%xmm0 movd %xmm0,%eax cmp %rsi,%rcx je 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x1(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x2(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x3(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x4(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x5(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x6(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x7(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x8(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0x9(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0xa(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0xb(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0xc(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil movzbl %sil,%esi add %esi,%eax lea 0xd(%rdx),%esi movslq %esi,%rsi cmp %rsi,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rsi,1) sete %sil add $0xe,%edx movzbl %sil,%esi movslq %edx,%rdx add %esi,%eax cmp %rdx,%rcx jbe 13e2 <func0+0x282> cmp %bpl,(%rbx,%rdx,1) sete %dl movzbl %dl,%edx add %edx,%eax add $0x8,%rsp pop %rbx pop %rbp retq nopl 0x0(%rax) add $0x8,%rsp xor %eax,%eax pop %rbx pop %rbp retq xor %edx,%edx xor %eax,%eax xor %esi,%esi jmpq 1254 <func0+0xf4> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
func0: endbr64 push rbp mov ebp, esi push rbx mov rbx, rdi sub rsp, 8 call _strlen test rax, rax jz loc_13D0 mov rdx, rax lea rax, [rax-1] cmp rax, 0Eh jbe loc_13D9 movd xmm4, ebp mov rcx, rdx pxor xmm1, xmm1 mov rax, rbx punpcklbw xmm4, xmm4 pxor xmm6, xmm6 pxor xmm5, xmm5 and rcx, 0FFFFFFFFFFFFFFF0h punpcklwd xmm4, xmm4 lea rsi, [rcx+rbx] pshufd xmm4, xmm4, 0 nop dword ptr [rax+00000000h] loc_11C0: movdqu xmm0, xmmword ptr [rax] movdqa xmm3, xmm6 add rax, 10h pcmpeqb xmm0, xmm4 pcmpgtb xmm3, xmm0 movdqa xmm2, xmm0 punpcklbw xmm2, xmm3 punpckhbw xmm0, xmm3 movdqa xmm3, xmm5 pcmpgtw xmm3, xmm2 movdqa xmm7, xmm2 punpcklwd xmm7, xmm3 punpckhwd xmm2, xmm3 movdqa xmm3, xmm0 psubd xmm1, xmm7 psubd xmm1, xmm2 movdqa xmm2, xmm5 pcmpgtw xmm2, xmm0 punpcklwd xmm3, xmm2 punpckhwd xmm0, xmm2 psubd xmm1, xmm3 psubd xmm1, xmm0 cmp rsi, rax jnz short loc_11C0 movdqa xmm0, xmm1 mov esi, ecx psrldq xmm0, 8 paddd xmm0, xmm1 movdqa xmm2, xmm0 psrldq xmm2, 4 paddd xmm0, xmm2 movd eax, xmm0 movdqa xmm0, xmm1 psrldq xmm1, 8 paddd xmm0, xmm1 cmp rdx, rcx jz loc_136F loc_1253: mov rdi, rdx sub rdi, rcx lea r8, [rdi-1] cmp r8, 6 jbe loc_12FD movzx eax, bpl movq xmm1, qword ptr [rbx+rcx] mov ah, al movd xmm6, eax pshuflw xmm2, xmm6, 0 pcmpeqb xmm1, xmm2 pxor xmm2, xmm2 pcmpgtb xmm2, xmm1 movdqa xmm3, xmm1 punpcklbw xmm3, xmm2 punpcklbw xmm1, xmm2 pxor xmm2, xmm2 movdqa xmm4, xmm2 movdqa xmm5, xmm3 pshufd xmm1, xmm1, 4Eh ; 'N' pcmpgtw xmm4, xmm3 pcmpgtw xmm2, xmm1 punpcklwd xmm5, xmm4 punpcklwd xmm3, xmm4 psubd xmm0, xmm5 pshufd xmm3, xmm3, 4Eh ; 'N' psubd xmm0, xmm3 movdqa xmm3, xmm1 punpcklwd xmm1, xmm2 punpcklwd xmm3, xmm2 pshufd xmm1, xmm1, 4Eh ; 'N' psubd xmm0, xmm3 psubd xmm0, xmm1 movd r8d, xmm0 pshufd xmm6, xmm0, 0E5h movd eax, xmm6 add eax, r8d mov r8, rdi and r8, 0FFFFFFFFFFFFFFF8h add rcx, r8 add esi, r8d and edi, 7 jz short loc_136F loc_12FD: cmp [rbx+rcx], bpl jz short loc_1380 loc_1303: lea ecx, [rsi+1] movsxd rcx, ecx cmp rcx, rdx jnb short loc_136F cmp bpl, [rbx+rcx] jz short loc_1390 loc_1314: lea ecx, [rsi+2] movsxd rcx, ecx cmp rcx, rdx jnb short loc_136F cmp bpl, [rbx+rcx] jz short loc_13A0 loc_1325: lea ecx, [rsi+3] movsxd rcx, ecx cmp rcx, rdx jnb short loc_136F cmp bpl, [rbx+rcx] jz short loc_13A8 lea ecx, [rsi+4] movsxd rcx, ecx cmp rcx, rdx jnb short loc_136F loc_1341: cmp bpl, [rbx+rcx] jnz short loc_134A add eax, 1 loc_134A: lea ecx, [rsi+5] movsxd rcx, ecx cmp rcx, rdx jnb short loc_136F cmp bpl, [rbx+rcx] jnz short loc_135E add eax, 1 loc_135E: add esi, 6 movsxd rsi, esi cmp rsi, rdx jnb short loc_136F cmp bpl, [rbx+rsi] jz short loc_13C0 loc_136F: add rsp, 8 pop rbx pop rbp retn loc_1380: add eax, 1 jmp loc_1303 loc_1390: add eax, 1 jmp loc_1314 loc_13A0: add eax, 1 jmp short loc_1325 loc_13A8: lea ecx, [rsi+4] add eax, 1 movsxd rcx, ecx cmp rcx, rdx jb short loc_1341 jmp short loc_136F loc_13C0: add rsp, 8 add eax, 1 pop rbx pop rbp retn loc_13D0: add rsp, 8 xor eax, eax pop rbx pop rbp retn loc_13D9: pxor xmm0, xmm0 xor esi, esi xor eax, eax xor ecx, ecx jmp loc_1253
long long func0(const char *a1, unsigned __int8 a2) { size_t v4; // rax size_t v5; // rdx __m128i v6; // xmm4 __m128i v7; // xmm1 const __m128i *v8; // rax __m128i v9; // xmm4 unsigned long long v10; // rcx __m128i v11; // xmm4 __m128i v12; // xmm0 __m128i v13; // xmm0 __m128i v14; // xmm3 __m128i v15; // xmm2 __m128i v16; // xmm0 __m128i v17; // xmm3 __m128i v18; // xmm1 __m128i v19; // xmm2 int v20; // esi __m128i v21; // xmm0 long long result; // rax __m128i v23; // xmm0 size_t v24; // rdi unsigned int v25; // eax __m128i v26; // xmm1 __m128i v27; // xmm3 __m128i v28; // xmm1 __m128i v29; // xmm2 __m128i v30; // xmm3 __m128i v31; // xmm0 size_t v32; // rcx size_t v33; // rcx size_t v34; // rcx size_t v35; // rcx size_t v36; // rcx size_t v37; // rsi v4 = strlen(a1); if ( !v4 ) return 0LL; v5 = v4; if ( v4 - 1 <= 0xE ) { v23 = 0LL; v20 = 0; result = 0LL; v10 = 0LL; } else { v6 = _mm_cvtsi32_si128(a2); v7 = 0LL; v8 = (const __m128i *)a1; v9 = _mm_unpacklo_epi8(v6, v6); v10 = v5 & 0xFFFFFFFFFFFFFFF0LL; v11 = _mm_shuffle_epi32(_mm_unpacklo_epi16(v9, v9), 0); do { v12 = _mm_loadu_si128(v8++); v13 = _mm_cmpeq_epi8(v12, v11); v14 = _mm_cmpgt_epi8((__m128i)0LL, v13); v15 = _mm_unpacklo_epi8(v13, v14); v16 = _mm_unpackhi_epi8(v13, v14); v17 = _mm_cmpgt_epi16((__m128i)0LL, v15); v18 = _mm_sub_epi32(_mm_sub_epi32(v7, _mm_unpacklo_epi16(v15, v17)), _mm_unpackhi_epi16(v15, v17)); v19 = _mm_cmpgt_epi16((__m128i)0LL, v16); v7 = _mm_sub_epi32(_mm_sub_epi32(v18, _mm_unpacklo_epi16(v16, v19)), _mm_unpackhi_epi16(v16, v19)); } while ( &a1[v5 & 0xFFFFFFFFFFFFFFF0LL] != (const char *)v8 ); v20 = v5 & 0xFFFFFFF0; v21 = _mm_add_epi32(_mm_srli_si128(v7, 8), v7); result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v21, _mm_srli_si128(v21, 4))); v23 = _mm_add_epi32(v7, _mm_srli_si128(v7, 8)); if ( v5 == v10 ) return result; } v24 = v5 - v10; if ( v5 - v10 - 1 <= 6 ) goto LABEL_34; v25 = a2; BYTE1(v25) = a2; v26 = _mm_cmpeq_epi8(_mm_loadl_epi64((const __m128i *)&a1[v10]), _mm_shufflelo_epi16(_mm_cvtsi32_si128(v25), 0)); v27 = _mm_unpacklo_epi8(v26, _mm_cmpgt_epi8((__m128i)0LL, v26)); v28 = _mm_shuffle_epi32(v27, 78); v29 = _mm_cmpgt_epi16((__m128i)0LL, v28); v30 = _mm_unpacklo_epi16(v27, _mm_cmpgt_epi16((__m128i)0LL, v27)); v31 = _mm_sub_epi32( _mm_sub_epi32( _mm_sub_epi32(_mm_sub_epi32(v23, v30), _mm_shuffle_epi32(v30, 78)), _mm_unpacklo_epi16(v28, v29)), _mm_shuffle_epi32(_mm_unpacklo_epi16(v28, v29), 78)); result = (unsigned int)(_mm_cvtsi128_si32(v31) + _mm_cvtsi128_si32(_mm_shuffle_epi32(v31, 229))); v10 += v24 & 0xFFFFFFFFFFFFFFF8LL; v20 += v24 & 0xFFFFFFF8; if ( (v24 & 7) != 0 ) { LABEL_34: if ( a1[v10] == a2 ) result = (unsigned int)(result + 1); v32 = v20 + 1; if ( v32 < v5 ) { if ( a2 == a1[v32] ) result = (unsigned int)(result + 1); v33 = v20 + 2; if ( v33 < v5 ) { if ( a2 == a1[v33] ) result = (unsigned int)(result + 1); v34 = v20 + 3; if ( v34 < v5 ) { if ( a2 == a1[v34] ) { result = (unsigned int)(result + 1); v35 = v20 + 4; if ( v35 >= v5 ) return result; } else { v35 = v20 + 4; if ( v35 >= v5 ) return result; } if ( a2 == a1[v35] ) result = (unsigned int)(result + 1); v36 = v20 + 5; if ( v36 < v5 ) { if ( a2 == a1[v36] ) result = (unsigned int)(result + 1); v37 = v20 + 6; if ( v37 < v5 && a2 == a1[v37] ) return (unsigned int)(result + 1); } } } } } return result; }
func0: ENDBR64 PUSH RBP MOV EBP,ESI PUSH RBX MOV RBX,RDI SUB RSP,0x8 CALL 0x00101050 TEST RAX,RAX JZ 0x001013d0 MOV RDX,RAX LEA RAX,[RAX + -0x1] CMP RAX,0xe JBE 0x001013d9 MOVD XMM4,EBP MOV RCX,RDX PXOR XMM1,XMM1 MOV RAX,RBX PUNPCKLBW XMM4,XMM4 PXOR XMM6,XMM6 PXOR XMM5,XMM5 AND RCX,-0x10 PUNPCKLWD XMM4,XMM4 LEA RSI,[RCX + RBX*0x1] PSHUFD XMM4,XMM4,0x0 NOP dword ptr [RAX] LAB_001011c0: MOVDQU XMM0,xmmword ptr [RAX] MOVDQA XMM3,XMM6 ADD RAX,0x10 PCMPEQB XMM0,XMM4 PCMPGTB XMM3,XMM0 MOVDQA XMM2,XMM0 PUNPCKLBW XMM2,XMM3 PUNPCKHBW XMM0,XMM3 MOVDQA XMM3,XMM5 PCMPGTW XMM3,XMM2 MOVDQA XMM7,XMM2 PUNPCKLWD XMM7,XMM3 PUNPCKHWD XMM2,XMM3 MOVDQA XMM3,XMM0 PSUBD XMM1,XMM7 PSUBD XMM1,XMM2 MOVDQA XMM2,XMM5 PCMPGTW XMM2,XMM0 PUNPCKLWD XMM3,XMM2 PUNPCKHWD XMM0,XMM2 PSUBD XMM1,XMM3 PSUBD XMM1,XMM0 CMP RSI,RAX JNZ 0x001011c0 MOVDQA XMM0,XMM1 MOV ESI,ECX PSRLDQ XMM0,0x8 PADDD XMM0,XMM1 MOVDQA XMM2,XMM0 PSRLDQ XMM2,0x4 PADDD XMM0,XMM2 MOVD EAX,XMM0 MOVDQA XMM0,XMM1 PSRLDQ XMM1,0x8 PADDD XMM0,XMM1 CMP RDX,RCX JZ 0x0010136f LAB_00101253: MOV RDI,RDX SUB RDI,RCX LEA R8,[RDI + -0x1] CMP R8,0x6 JBE 0x001012fd MOVZX EAX,BPL MOVQ XMM1,qword ptr [RBX + RCX*0x1] MOV AH,AL MOVD XMM6,EAX PSHUFLW XMM2,XMM6,0x0 PCMPEQB XMM1,XMM2 PXOR XMM2,XMM2 PCMPGTB XMM2,XMM1 MOVDQA XMM3,XMM1 PUNPCKLBW XMM3,XMM2 PUNPCKLBW XMM1,XMM2 PXOR XMM2,XMM2 MOVDQA XMM4,XMM2 MOVDQA XMM5,XMM3 PSHUFD XMM1,XMM1,0x4e PCMPGTW XMM4,XMM3 PCMPGTW XMM2,XMM1 PUNPCKLWD XMM5,XMM4 PUNPCKLWD XMM3,XMM4 PSUBD XMM0,XMM5 PSHUFD XMM3,XMM3,0x4e PSUBD XMM0,XMM3 MOVDQA XMM3,XMM1 PUNPCKLWD XMM1,XMM2 PUNPCKLWD XMM3,XMM2 PSHUFD XMM1,XMM1,0x4e PSUBD XMM0,XMM3 PSUBD XMM0,XMM1 MOVD R8D,XMM0 PSHUFD XMM6,XMM0,0xe5 MOVD EAX,XMM6 ADD EAX,R8D MOV R8,RDI AND R8,-0x8 ADD RCX,R8 ADD ESI,R8D AND EDI,0x7 JZ 0x0010136f LAB_001012fd: CMP byte ptr [RBX + RCX*0x1],BPL JZ 0x00101380 LAB_00101303: LEA ECX,[RSI + 0x1] MOVSXD RCX,ECX CMP RCX,RDX JNC 0x0010136f CMP BPL,byte ptr [RBX + RCX*0x1] JZ 0x00101390 LAB_00101314: LEA ECX,[RSI + 0x2] MOVSXD RCX,ECX CMP RCX,RDX JNC 0x0010136f CMP BPL,byte ptr [RBX + RCX*0x1] JZ 0x001013a0 LAB_00101325: LEA ECX,[RSI + 0x3] MOVSXD RCX,ECX CMP RCX,RDX JNC 0x0010136f CMP BPL,byte ptr [RBX + RCX*0x1] JZ 0x001013a8 LEA ECX,[RSI + 0x4] MOVSXD RCX,ECX CMP RCX,RDX JNC 0x0010136f LAB_00101341: CMP BPL,byte ptr [RBX + RCX*0x1] JNZ 0x0010134a ADD EAX,0x1 LAB_0010134a: LEA ECX,[RSI + 0x5] MOVSXD RCX,ECX CMP RCX,RDX JNC 0x0010136f CMP BPL,byte ptr [RBX + RCX*0x1] JNZ 0x0010135e ADD EAX,0x1 LAB_0010135e: ADD ESI,0x6 MOVSXD RSI,ESI CMP RSI,RDX JNC 0x0010136f CMP BPL,byte ptr [RBX + RSI*0x1] JZ 0x001013c0 LAB_0010136f: ADD RSP,0x8 POP RBX POP RBP RET LAB_00101380: ADD EAX,0x1 JMP 0x00101303 LAB_00101390: ADD EAX,0x1 JMP 0x00101314 LAB_001013a0: ADD EAX,0x1 JMP 0x00101325 LAB_001013a8: LEA ECX,[RSI + 0x4] ADD EAX,0x1 MOVSXD RCX,ECX CMP RCX,RDX JC 0x00101341 JMP 0x0010136f LAB_001013c0: ADD RSP,0x8 ADD EAX,0x1 POP RBX POP RBP RET LAB_001013d0: ADD RSP,0x8 XOR EAX,EAX POP RBX POP RBP RET LAB_001013d9: PXOR XMM0,XMM0 XOR ESI,ESI XOR EAX,EAX XOR ECX,ECX JMP 0x00101253
int func0(char *param_1,char param_2) { bool bVar1; bool bVar2; bool bVar3; bool bVar4; bool bVar5; bool bVar6; bool bVar7; bool bVar8; char *pcVar9; char *pcVar10; char *pcVar11; char *pcVar12; char *pcVar13; char *pcVar14; char *pcVar15; char *pcVar16; char *pcVar17; char *pcVar18; char *pcVar19; char *pcVar20; char *pcVar21; char *pcVar22; char *pcVar23; int auVar24 [14]; int auVar25 [12]; unkbyte10 Var26; int auVar27 [12]; int auVar28 [14]; int auVar29 [12]; int auVar30 [16]; int auVar31 [16]; int auVar32 [16]; int auVar33 [12]; unkbyte9 Var34; int6 uVar35; int4 uVar36; int2 uVar37; size_t sVar38; char *pcVar39; ulong uVar40; uint uVar41; ulong uVar42; int4 uVar43; int iVar44; char cVar52; short sVar53; int auVar48 [12]; int auVar51 [16]; int iVar54; int auVar55 [12]; char cVar60; short sVar61; char cVar64; int iVar62; char cVar63; char cVar65; int iVar66; int iVar68; int auVar56 [16]; int auVar57 [16]; int iVar69; char cVar74; char cVar75; char cVar76; char cVar77; char cVar78; char cVar79; short sVar80; short sVar81; int in_XMM2 [16]; int auVar71 [16]; int auVar73 [16]; int auVar82 [16]; int auVar87 [16]; int auVar88 [16]; int auVar91 [16]; int auVar95 [16]; int auVar98 [16]; int6 uVar45; int8 uVar46; int auVar47 [12]; int auVar49 [14]; int auVar50 [16]; int auVar58 [16]; int auVar59 [16]; long lVar67; int auVar70 [12]; int auVar72 [16]; int auVar83 [16]; int auVar84 [16]; int auVar92 [16]; int auVar85 [16]; int auVar89 [16]; int auVar93 [16]; int auVar86 [16]; int auVar90 [16]; int auVar94 [16]; int auVar96 [16]; int auVar97 [16]; int auVar99 [16]; int auVar100 [16]; sVar38 = strlen(param_1); if (sVar38 == 0) { return 0; } if (sVar38 - 1 < 0xf) { iVar54 = 0; iVar62 = 0; uVar41 = 0; iVar44 = 0; uVar40 = 0; } else { iVar54 = 0; iVar62 = 0; iVar66 = 0; iVar68 = 0; uVar40 = sVar38 & 0xfffffffffffffff0; pcVar39 = param_1; do { cVar52 = *pcVar39; pcVar9 = pcVar39 + 1; pcVar10 = pcVar39 + 2; pcVar11 = pcVar39 + 3; pcVar12 = pcVar39 + 4; pcVar13 = pcVar39 + 5; pcVar14 = pcVar39 + 6; pcVar15 = pcVar39 + 7; pcVar16 = pcVar39 + 8; pcVar17 = pcVar39 + 9; pcVar18 = pcVar39 + 10; pcVar19 = pcVar39 + 0xb; pcVar20 = pcVar39 + 0xc; pcVar21 = pcVar39 + 0xd; pcVar22 = pcVar39 + 0xe; pcVar23 = pcVar39 + 0xf; pcVar39 = pcVar39 + 0x10; bVar1 = cVar52 == param_2; cVar52 = -(*pcVar15 == param_2); bVar5 = *pcVar16 == param_2; bVar6 = *pcVar17 == param_2; bVar7 = *pcVar18 == param_2; bVar8 = *pcVar19 == param_2; uVar37 = CONCAT11(-(*pcVar15 == param_2),cVar52); uVar36 = CONCAT31(CONCAT21(uVar37,-(*pcVar14 == param_2)),-(*pcVar14 == param_2)); uVar35 = CONCAT51(CONCAT41(uVar36,-(*pcVar13 == param_2)),-(*pcVar13 == param_2)); Var34 = CONCAT72(CONCAT61(uVar35,-(*pcVar12 == param_2)), CONCAT11(-(*pcVar12 == param_2),cVar52)); lVar67 = (long)((unkuint9)Var34 >> 8); Var26 = CONCAT91(CONCAT81(lVar67,-(*pcVar11 == param_2)),-(*pcVar11 == param_2)); auVar25._2_10_ = Var26; auVar25[1] = -(*pcVar10 == param_2); auVar25[0] = -(*pcVar10 == param_2); auVar24._2_12_ = auVar25; auVar24[1] = -(*pcVar9 == param_2); auVar24[0] = -(*pcVar9 == param_2); auVar71._0_2_ = CONCAT11(-bVar1,-bVar1); auVar71._2_14_ = auVar24; uVar43 = CONCAT13(-bVar6,CONCAT12(-bVar6,CONCAT11(-bVar5,-bVar5))); uVar45 = CONCAT15(-bVar7,CONCAT14(-bVar7,uVar43)); uVar46 = CONCAT17(-bVar8,CONCAT16(-bVar8,uVar45)); auVar47._0_10_ = CONCAT19(-(*pcVar20 == param_2),CONCAT18(-(*pcVar20 == param_2),uVar46)); auVar47[10] = -(*pcVar21 == param_2); auVar47[0xb] = -(*pcVar21 == param_2); auVar49[0xc] = -(*pcVar22 == param_2); auVar49._0_12_ = auVar47; auVar49[0xd] = -(*pcVar22 == param_2); auVar73[0xe] = -(*pcVar23 == param_2); auVar73._0_14_ = auVar49; auVar73[0xf] = -(*pcVar23 == param_2); sVar53 = (short)Var26; sVar61 = (short)((unkuint9)Var34 >> 8); sVar80 = (short)uVar35; sVar81 = (short)uVar36; auVar100._0_12_ = auVar71._0_12_; auVar100._12_2_ = sVar53; auVar100._14_2_ = -(ushort)(sVar53 < 0); auVar99._12_4_ = auVar100._12_4_; auVar99._0_10_ = auVar71._0_10_; auVar99._10_2_ = -(ushort)(auVar25._0_2_ < 0); auVar98._10_6_ = auVar99._10_6_; auVar98._0_8_ = auVar71._0_8_; auVar98._8_2_ = auVar25._0_2_; auVar27._4_8_ = auVar98._8_8_; auVar27._2_2_ = -(ushort)(auVar24._0_2_ < 0); auVar27._0_2_ = auVar24._0_2_; iVar69 = CONCAT22(-(ushort)(sVar61 < 0),sVar61); auVar70._0_8_ = CONCAT26(-(ushort)(sVar80 < 0),CONCAT24(sVar80,iVar69)); auVar70._8_2_ = sVar81; auVar70._10_2_ = -(ushort)(sVar81 < 0); auVar72._12_2_ = uVar37; auVar72._0_12_ = auVar70; auVar72._14_2_ = -(ushort)(lVar67 < 0); sVar53 = (short)((unkuint10)auVar47._0_10_ >> 0x40); auVar86._12_2_ = (short)((ulong)uVar46 >> 0x30); auVar86._0_12_ = auVar47; auVar86._14_2_ = -(ushort)bVar8; auVar85._12_4_ = auVar86._12_4_; auVar85._10_2_ = -(ushort)bVar7; auVar85._0_10_ = auVar47._0_10_; auVar84._10_6_ = auVar85._10_6_; auVar84._8_2_ = (short)((uint6)uVar45 >> 0x20); auVar84._0_8_ = uVar46; auVar83._8_8_ = auVar84._8_8_; auVar83._6_2_ = -(ushort)bVar6; auVar83._0_6_ = uVar45; auVar82._6_10_ = auVar83._6_10_; auVar82._4_2_ = (short)((uint)uVar43 >> 0x10); auVar82._0_4_ = uVar43; iVar44 = CONCAT22(-(ushort)(sVar53 < 0),sVar53); auVar48._0_8_ = CONCAT26(-(ushort)(auVar47._10_2_ < 0),CONCAT24(auVar47._10_2_,iVar44)); auVar48._8_2_ = auVar49._12_2_; auVar48._10_2_ = -(ushort)(auVar49._12_2_ < 0); auVar50._12_2_ = auVar73._14_2_; auVar50._0_12_ = auVar48; auVar50._14_2_ = -(ushort)(auVar73._14_2_ < 0); iVar54 = (((iVar54 - CONCAT22(-(ushort)bVar1,auVar71._0_2_)) - iVar69) - CONCAT22(-(ushort)bVar5,CONCAT11(-bVar5,-bVar5))) - iVar44; iVar62 = (((iVar62 - auVar27._0_4_) - (int)((ulong)auVar70._0_8_ >> 0x20)) - auVar82._4_4_) - (int)((ulong)auVar48._0_8_ >> 0x20); iVar66 = (((iVar66 - auVar98._8_4_) - auVar70._8_4_) - auVar84._8_4_) - auVar48._8_4_; iVar68 = (((iVar68 - auVar99._12_4_) - auVar72._12_4_) - auVar85._12_4_) - auVar50._12_4_; } while (param_1 + uVar40 != pcVar39); uVar41 = (uint)sVar38 & 0xfffffff0; auVar51._0_4_ = iVar66 + iVar54; auVar51._4_4_ = iVar68 + iVar62; auVar51._8_4_ = iVar66; auVar51._12_4_ = iVar68; in_XMM2 = auVar51 >> 0x20; iVar44 = auVar51._0_4_ + auVar51._4_4_; iVar54 = iVar54 + iVar66; iVar62 = iVar62 + iVar68; if (sVar38 == uVar40) { return iVar44; } } uVar42 = sVar38 - uVar40; if (6 < uVar42 - 1) { uVar46 = *(int8 *)(param_1 + uVar40); auVar73 = pshuflw(in_XMM2,ZEXT216(CONCAT11(param_2,param_2)),0); bVar1 = (char)uVar46 == auVar73[0]; auVar56[0] = -bVar1; bVar5 = (char)((ulong)uVar46 >> 8) == auVar73[1]; cVar52 = -bVar5; bVar6 = (char)((ulong)uVar46 >> 0x10) == auVar73[2]; bVar7 = (char)((ulong)uVar46 >> 0x18) == auVar73[3]; bVar8 = (char)((ulong)uVar46 >> 0x20) == auVar73[4]; cVar60 = -bVar8; bVar2 = (char)((ulong)uVar46 >> 0x28) == auVar73[5]; cVar63 = -bVar2; bVar3 = (char)((ulong)uVar46 >> 0x30) == auVar73[6]; cVar64 = -bVar3; bVar4 = (char)((ulong)uVar46 >> 0x38) == auVar73[7]; cVar65 = -bVar4; cVar74 = -bVar5; cVar75 = -bVar7; cVar76 = -bVar8; cVar77 = -bVar2; cVar78 = -bVar3; cVar79 = -bVar4; Var26 = CONCAT91(CONCAT81((long)(CONCAT72(CONCAT61(CONCAT51(CONCAT41(CONCAT31(CONCAT21(CONCAT11( cVar79,cVar65),cVar78),cVar64),cVar77),cVar63), cVar76),CONCAT11(cVar60,cVar65)) >> 8),cVar75), -bVar7); auVar29._2_10_ = Var26; auVar29[1] = -bVar6; auVar29[0] = -bVar6; auVar28._2_12_ = auVar29; auVar28[1] = cVar74; auVar28[0] = cVar52; auVar87._0_2_ = CONCAT11(-bVar1,auVar56[0]); auVar87._2_14_ = auVar28; uVar37 = CONCAT11(cVar79,cVar65); uVar36 = CONCAT31(CONCAT21(uVar37,cVar78),cVar64); uVar35 = CONCAT51(CONCAT41(uVar36,cVar77),cVar63); Var34 = CONCAT72(CONCAT61(uVar35,cVar76),CONCAT11(cVar60,cVar65)); lVar67 = (long)((unkuint9)Var34 >> 8); auVar32._1_8_ = lVar67; auVar32[0] = cVar75; auVar32._9_7_ = 0; auVar31._10_6_ = 0; auVar31._0_10_ = SUB1610(auVar32 << 0x38,6); auVar30._11_5_ = 0; auVar30._0_11_ = SUB1611(auVar31 << 0x30,5); auVar56._4_12_ = SUB1612(auVar30 << 0x28,4); auVar56[3] = cVar74; auVar56[2] = cVar52; auVar56[1] = -bVar1; iVar44 = (int)((unkuint9)Var34 >> 8); auVar55._8_4_ = auVar56._0_4_; auVar55._0_8_ = lVar67; sVar80 = auVar29._0_2_; sVar81 = (short)Var26; sVar53 = (short)((unkuint9)Var34 >> 8); sVar61 = (short)uVar36; auVar97._0_12_ = auVar87._0_12_; auVar97._12_2_ = sVar81; auVar97._14_2_ = -(ushort)(sVar81 < 0); auVar96._12_4_ = auVar97._12_4_; auVar96._0_10_ = auVar87._0_10_; auVar96._10_2_ = -(ushort)(sVar80 < 0); auVar95._10_6_ = auVar96._10_6_; auVar95._0_8_ = auVar87._0_8_; auVar95._8_2_ = sVar80; auVar33._4_8_ = auVar95._8_8_; auVar33._2_2_ = -(ushort)(auVar28._0_2_ < 0); auVar33._0_2_ = auVar28._0_2_; auVar90._12_2_ = sVar81; auVar90._0_12_ = auVar97._0_12_; auVar90._14_2_ = -(ushort)(sVar81 < 0); auVar89._12_4_ = auVar90._12_4_; auVar89._10_2_ = -(ushort)(sVar80 < 0); auVar89._0_10_ = auVar96._0_10_; auVar88._10_6_ = auVar89._10_6_; auVar88._8_2_ = sVar80; auVar88._0_8_ = auVar95._0_8_; auVar59._12_2_ = uVar37; auVar59._0_12_ = auVar55; auVar59._14_2_ = -(ushort)(lVar67 < 0); auVar58._12_4_ = auVar59._12_4_; auVar58._0_10_ = auVar55._0_10_; auVar58._10_2_ = -(ushort)(sVar61 < 0); auVar57._10_6_ = auVar58._10_6_; auVar57._8_2_ = sVar61; auVar57._0_8_ = lVar67; auVar94._12_2_ = uVar37; auVar94._0_12_ = auVar55; auVar94._14_2_ = -(ushort)(lVar67 < 0); auVar93._12_4_ = auVar94._12_4_; auVar93._10_2_ = -(ushort)(sVar61 < 0); auVar93._0_10_ = auVar58._0_10_; auVar92._10_6_ = auVar93._10_6_; auVar92._8_2_ = sVar61; auVar92._0_8_ = lVar67; auVar91._8_8_ = auVar92._8_8_; auVar91._6_2_ = -(ushort)(iVar44 < 0); auVar91._4_2_ = (short)uVar35; auVar91._0_4_ = iVar44; iVar44 = ((((iVar62 - auVar33._0_4_) - auVar89._12_4_) - auVar91._4_4_) - auVar58._12_4_) + ((((iVar54 - CONCAT22(-(ushort)bVar1,auVar87._0_2_)) - auVar88._8_4_) - CONCAT22(-(ushort)(sVar53 < 0),sVar53)) - auVar57._8_4_); uVar40 = uVar40 + (uVar42 & 0xfffffffffffffff8); uVar41 = uVar41 + (int)(uVar42 & 0xfffffffffffffff8); if ((uVar42 & 7) == 0) { return iVar44; } } if (param_1[uVar40] == param_2) { iVar44 = iVar44 + 1; } if ((ulong)(long)(int)(uVar41 + 1) < sVar38) { if (param_2 == param_1[(int)(uVar41 + 1)]) { iVar44 = iVar44 + 1; } if ((ulong)(long)(int)(uVar41 + 2) < sVar38) { if (param_2 == param_1[(int)(uVar41 + 2)]) { iVar44 = iVar44 + 1; } if ((ulong)(long)(int)(uVar41 + 3) < sVar38) { if (param_2 == param_1[(int)(uVar41 + 3)]) { iVar44 = iVar44 + 1; } if ((ulong)(long)(int)(uVar41 + 4) < sVar38) { if (param_2 == param_1[(int)(uVar41 + 4)]) { iVar44 = iVar44 + 1; } if ((ulong)(long)(int)(uVar41 + 5) < sVar38) { if (param_2 == param_1[(int)(uVar41 + 5)]) { iVar44 = iVar44 + 1; } if (((ulong)(long)(int)(uVar41 + 6) < sVar38) && (param_2 == param_1[(int)(uVar41 + 6)]) ) { return iVar44 + 1; } } } } } } return iVar44; }
6,560
func0
#include <stdio.h> #include <assert.h>
int func0(const char *string, const char *vowels) { int count = 0; const char *s = string; const char *v; while (*s) { v = vowels; while (*v) { if (*s == *v) { count++; break; } v++; } s++; } return count; }
int main() { assert(func0("corner", "AaEeIiOoUu") == 2); assert(func0("valid", "AaEeIiOoUu") == 2); assert(func0("true", "AaEeIiOoUu") == 2); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x28(%rbp) mov %rsi,-0x30(%rbp) movl $0x0,-0x14(%rbp) mov -0x28(%rbp),%rax mov %rax,-0x10(%rbp) jmp 11a1 <func0+0x58> mov -0x30(%rbp),%rax mov %rax,-0x8(%rbp) jmp 1191 <func0+0x48> mov -0x10(%rbp),%rax movzbl (%rax),%edx mov -0x8(%rbp),%rax movzbl (%rax),%eax cmp %al,%dl jne 118c <func0+0x43> addl $0x1,-0x14(%rbp) jmp 119c <func0+0x53> addq $0x1,-0x8(%rbp) mov -0x8(%rbp),%rax movzbl (%rax),%eax test %al,%al jne 1174 <func0+0x2b> addq $0x1,-0x10(%rbp) mov -0x10(%rbp),%rax movzbl (%rax),%eax test %al,%al jne 116a <func0+0x21> mov -0x14(%rbp),%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_28], rdi mov [rbp+var_30], rsi mov [rbp+var_14], 0 mov rax, [rbp+var_28] mov [rbp+var_10], rax jmp short loc_11A1 loc_116A: mov rax, [rbp+var_30] mov [rbp+var_8], rax jmp short loc_1191 loc_1174: mov rax, [rbp+var_10] movzx edx, byte ptr [rax] mov rax, [rbp+var_8] movzx eax, byte ptr [rax] cmp dl, al jnz short loc_118C add [rbp+var_14], 1 jmp short loc_119C loc_118C: add [rbp+var_8], 1 loc_1191: mov rax, [rbp+var_8] movzx eax, byte ptr [rax] test al, al jnz short loc_1174 loc_119C: add [rbp+var_10], 1 loc_11A1: mov rax, [rbp+var_10] movzx eax, byte ptr [rax] test al, al jnz short loc_116A mov eax, [rbp+var_14] pop rbp retn
long long func0(_BYTE *a1, _BYTE *a2) { unsigned int v3; // [rsp+1Ch] [rbp-14h] _BYTE *i; // [rsp+28h] [rbp-8h] v3 = 0; while ( *a1 ) { for ( i = a2; *i; ++i ) { if ( *a1 == *i ) { ++v3; break; } } ++a1; } return v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x28],RDI MOV qword ptr [RBP + -0x30],RSI MOV dword ptr [RBP + -0x14],0x0 MOV RAX,qword ptr [RBP + -0x28] MOV qword ptr [RBP + -0x10],RAX JMP 0x001011a1 LAB_0010116a: MOV RAX,qword ptr [RBP + -0x30] MOV qword ptr [RBP + -0x8],RAX JMP 0x00101191 LAB_00101174: MOV RAX,qword ptr [RBP + -0x10] MOVZX EDX,byte ptr [RAX] MOV RAX,qword ptr [RBP + -0x8] MOVZX EAX,byte ptr [RAX] CMP DL,AL JNZ 0x0010118c ADD dword ptr [RBP + -0x14],0x1 JMP 0x0010119c LAB_0010118c: ADD qword ptr [RBP + -0x8],0x1 LAB_00101191: MOV RAX,qword ptr [RBP + -0x8] MOVZX EAX,byte ptr [RAX] TEST AL,AL JNZ 0x00101174 LAB_0010119c: ADD qword ptr [RBP + -0x10],0x1 LAB_001011a1: MOV RAX,qword ptr [RBP + -0x10] MOVZX EAX,byte ptr [RAX] TEST AL,AL JNZ 0x0010116a MOV EAX,dword ptr [RBP + -0x14] POP RBP RET
int func0(char *param_1,char *param_2) { int local_1c; char *local_18; char *local_10; local_1c = 0; local_18 = param_1; do { local_10 = param_2; if (*local_18 == '\0') { return local_1c; } for (; *local_10 != '\0'; local_10 = local_10 + 1) { if (*local_18 == *local_10) { local_1c = local_1c + 1; break; } } local_18 = local_18 + 1; } while( true ); }
6,561
func0
#include <stdio.h> #include <assert.h>
int func0(const char *string, const char *vowels) { int count = 0; const char *s = string; const char *v; while (*s) { v = vowels; while (*v) { if (*s == *v) { count++; break; } v++; } s++; } return count; }
int main() { assert(func0("corner", "AaEeIiOoUu") == 2); assert(func0("valid", "AaEeIiOoUu") == 2); assert(func0("true", "AaEeIiOoUu") == 2); return 0; }
O1
c
func0: endbr64 movzbl (%rdi),%ecx test %cl,%cl je 118e <func0+0x45> movzbl (%rsi),%r9d mov $0x0,%r8d mov %r9d,%r10d jmp 1172 <func0+0x29> add $0x1,%r8d add $0x1,%rdi movzbl (%rdi),%ecx test %cl,%cl je 1194 <func0+0x4b> mov %rsi,%rdx mov %r10d,%eax test %r9b,%r9b je 1167 <func0+0x1e> cmp %cl,%al je 1163 <func0+0x1a> add $0x1,%rdx movzbl (%rdx),%eax test %al,%al jne 117d <func0+0x34> jmp 1167 <func0+0x1e> mov $0x0,%r8d mov %r8d,%eax retq
func0: endbr64 movzx ecx, byte ptr [rdi] test cl, cl jz short loc_118B movzx r8d, byte ptr [rsi] mov r9d, 0 jmp short loc_116F loc_1160: add r9d, 1 loc_1164: add rdi, 1 movzx ecx, byte ptr [rdi] test cl, cl jz short loc_1191 loc_116F: mov rdx, rsi mov eax, r8d test r8b, r8b jz short loc_1164 loc_117A: cmp al, cl jz short loc_1160 add rdx, 1 movzx eax, byte ptr [rdx] test al, al jnz short loc_117A jmp short loc_1164 loc_118B: mov r9d, 0 loc_1191: mov eax, r9d retn
long long func0(char *a1, _BYTE *a2) { char v2; // cl unsigned int v3; // r9d _BYTE *v4; // rdx char v5; // al v2 = *a1; if ( *a1 ) { v3 = 0; do { v4 = a2; v5 = *a2; if ( *a2 ) { while ( v5 != v2 ) { v5 = *++v4; if ( !*v4 ) goto LABEL_4; } ++v3; } LABEL_4: v2 = *++a1; } while ( *a1 ); } else { return 0; } return v3; }
func0: ENDBR64 MOVZX ECX,byte ptr [RDI] TEST CL,CL JZ 0x0010118b MOVZX R8D,byte ptr [RSI] MOV R9D,0x0 JMP 0x0010116f LAB_00101160: ADD R9D,0x1 LAB_00101164: ADD RDI,0x1 MOVZX ECX,byte ptr [RDI] TEST CL,CL JZ 0x00101191 LAB_0010116f: MOV RDX,RSI MOV EAX,R8D TEST R8B,R8B JZ 0x00101164 LAB_0010117a: CMP AL,CL JZ 0x00101160 ADD RDX,0x1 MOVZX EAX,byte ptr [RDX] TEST AL,AL JNZ 0x0010117a JMP 0x00101164 LAB_0010118b: MOV R9D,0x0 LAB_00101191: MOV EAX,R9D RET
int func0(char *param_1,char *param_2) { char cVar1; char *pcVar2; char cVar3; int iVar4; cVar3 = *param_1; if (cVar3 == '\0') { iVar4 = 0; } else { iVar4 = 0; cVar1 = *param_2; pcVar2 = param_2; joined_r0x00101178: do { if (cVar1 != '\0') { if (cVar1 != cVar3) { cVar1 = pcVar2[1]; pcVar2 = pcVar2 + 1; goto joined_r0x00101178; } iVar4 = iVar4 + 1; } param_1 = param_1 + 1; cVar3 = *param_1; cVar1 = *param_2; pcVar2 = param_2; } while (cVar3 != '\0'); } return iVar4; }
6,562
func0
#include <stdio.h> #include <assert.h>
int func0(const char *string, const char *vowels) { int count = 0; const char *s = string; const char *v; while (*s) { v = vowels; while (*v) { if (*s == *v) { count++; break; } v++; } s++; } return count; }
int main() { assert(func0("corner", "AaEeIiOoUu") == 2); assert(func0("valid", "AaEeIiOoUu") == 2); assert(func0("true", "AaEeIiOoUu") == 2); return 0; }
O2
c
func0: endbr64 movzbl (%rdi),%ecx test %cl,%cl je 132c <func0+0x4c> movzbl (%rsi),%r8d xor %r9d,%r9d nopw 0x0(%rax,%rax,1) mov %rsi,%rdx mov %r8d,%eax test %r8b,%r8b jne 1314 <func0+0x34> jmp 131c <func0+0x3c> nopl (%rax) movzbl 0x1(%rdx),%eax add $0x1,%rdx test %al,%al je 131c <func0+0x3c> cmp %cl,%al jne 1308 <func0+0x28> add $0x1,%r9d movzbl 0x1(%rdi),%ecx add $0x1,%rdi test %cl,%cl jne 12f8 <func0+0x18> mov %r9d,%eax retq xor %r9d,%r9d mov %r9d,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 movzx ecx, byte ptr [rdi] test cl, cl jz short loc_124C movzx r8d, byte ptr [rsi] xor r9d, r9d nop word ptr [rax+rax+00h] loc_1218: mov rdx, rsi mov eax, r8d test r8b, r8b jnz short loc_1234 jmp short loc_123C loc_1228: movzx eax, byte ptr [rdx+1] add rdx, 1 test al, al jz short loc_123C loc_1234: cmp al, cl jnz short loc_1228 add r9d, 1 loc_123C: movzx ecx, byte ptr [rdi+1] add rdi, 1 test cl, cl jnz short loc_1218 mov eax, r9d retn loc_124C: xor r9d, r9d mov eax, r9d retn
long long func0(char *a1, _BYTE *a2) { char v2; // cl unsigned int v3; // r9d _BYTE *v4; // rdx char v5; // al v2 = *a1; if ( !*a1 ) return 0LL; v3 = 0; do { v4 = a2; v5 = *a2; if ( *a2 ) { while ( v5 != v2 ) { v5 = *++v4; if ( !v5 ) goto LABEL_8; } ++v3; } LABEL_8: v2 = *++a1; } while ( v2 ); return v3; }
func0: ENDBR64 MOVZX ECX,byte ptr [RDI] TEST CL,CL JZ 0x0010124c MOVZX R8D,byte ptr [RSI] XOR R9D,R9D NOP word ptr [RAX + RAX*0x1] LAB_00101218: MOV RDX,RSI MOV EAX,R8D TEST R8B,R8B JNZ 0x00101234 JMP 0x0010123c LAB_00101228: MOVZX EAX,byte ptr [RDX + 0x1] ADD RDX,0x1 TEST AL,AL JZ 0x0010123c LAB_00101234: CMP AL,CL JNZ 0x00101228 ADD R9D,0x1 LAB_0010123c: MOVZX ECX,byte ptr [RDI + 0x1] ADD RDI,0x1 TEST CL,CL JNZ 0x00101218 MOV EAX,R9D RET LAB_0010124c: XOR R9D,R9D MOV EAX,R9D RET
int func0(char *param_1,char *param_2) { char cVar1; char *pcVar2; char cVar3; int iVar4; cVar3 = *param_1; if (cVar3 == '\0') { return 0; } iVar4 = 0; cVar1 = *param_2; pcVar2 = param_2; joined_r0x00101221: do { if (cVar1 != '\0') { if (cVar1 != cVar3) { cVar1 = pcVar2[1]; pcVar2 = pcVar2 + 1; goto joined_r0x00101221; } iVar4 = iVar4 + 1; } cVar3 = param_1[1]; param_1 = param_1 + 1; cVar1 = *param_2; pcVar2 = param_2; if (cVar3 == '\0') { return iVar4; } } while( true ); }
6,563
func0
#include <stdio.h> #include <assert.h>
int func0(const char *string, const char *vowels) { int count = 0; const char *s = string; const char *v; while (*s) { v = vowels; while (*v) { if (*s == *v) { count++; break; } v++; } s++; } return count; }
int main() { assert(func0("corner", "AaEeIiOoUu") == 2); assert(func0("valid", "AaEeIiOoUu") == 2); assert(func0("true", "AaEeIiOoUu") == 2); return 0; }
O3
c
func0: endbr64 movzbl (%rdi),%ecx test %cl,%cl je 12fc <func0+0x4c> movzbl (%rsi),%r8d xor %r9d,%r9d nopw 0x0(%rax,%rax,1) mov %rsi,%rdx mov %r8d,%eax test %r8b,%r8b jne 12e4 <func0+0x34> jmp 12ec <func0+0x3c> nopl (%rax) movzbl 0x1(%rdx),%eax add $0x1,%rdx test %al,%al je 12ec <func0+0x3c> cmp %cl,%al jne 12d8 <func0+0x28> add $0x1,%r9d movzbl 0x1(%rdi),%ecx add $0x1,%rdi test %cl,%cl jne 12c8 <func0+0x18> mov %r9d,%eax retq xor %r9d,%r9d mov %r9d,%eax retq nopw %cs:0x0(%rax,%rax,1) nopl (%rax)
func0: endbr64 movzx ecx, byte ptr [rdi] test cl, cl jz short loc_12FC movzx r8d, byte ptr [rsi] xor r9d, r9d nop word ptr [rax+rax+00h] loc_12C8: mov rdx, rsi mov eax, r8d test r8b, r8b jnz short loc_12E4 jmp short loc_12EC loc_12D8: movzx eax, byte ptr [rdx+1] add rdx, 1 test al, al jz short loc_12EC loc_12E4: cmp al, cl jnz short loc_12D8 add r9d, 1 loc_12EC: movzx ecx, byte ptr [rdi+1] add rdi, 1 test cl, cl jnz short loc_12C8 mov eax, r9d retn loc_12FC: xor r9d, r9d mov eax, r9d retn
long long func0(char *a1, _BYTE *a2) { char v2; // cl unsigned int v3; // r9d _BYTE *v4; // rdx char v5; // al v2 = *a1; if ( !*a1 ) return 0LL; v3 = 0; do { v4 = a2; v5 = *a2; if ( *a2 ) { while ( v5 != v2 ) { v5 = *++v4; if ( !v5 ) goto LABEL_8; } ++v3; } LABEL_8: v2 = *++a1; } while ( v2 ); return v3; }
func0: ENDBR64 MOVZX ECX,byte ptr [RDI] TEST CL,CL JZ 0x001012fc MOVZX R8D,byte ptr [RSI] XOR R9D,R9D NOP word ptr [RAX + RAX*0x1] LAB_001012c8: MOV RDX,RSI MOV EAX,R8D TEST R8B,R8B JNZ 0x001012e4 JMP 0x001012ec LAB_001012d8: MOVZX EAX,byte ptr [RDX + 0x1] ADD RDX,0x1 TEST AL,AL JZ 0x001012ec LAB_001012e4: CMP AL,CL JNZ 0x001012d8 ADD R9D,0x1 LAB_001012ec: MOVZX ECX,byte ptr [RDI + 0x1] ADD RDI,0x1 TEST CL,CL JNZ 0x001012c8 MOV EAX,R9D RET LAB_001012fc: XOR R9D,R9D MOV EAX,R9D RET
int func0(char *param_1,char *param_2) { char cVar1; char *pcVar2; char cVar3; int iVar4; cVar3 = *param_1; if (cVar3 == '\0') { return 0; } iVar4 = 0; cVar1 = *param_2; pcVar2 = param_2; joined_r0x001012d1: do { if (cVar1 != '\0') { if (cVar1 != cVar3) { cVar1 = pcVar2[1]; pcVar2 = pcVar2 + 1; goto joined_r0x001012d1; } iVar4 = iVar4 + 1; } cVar3 = param_1[1]; param_1 = param_1 + 1; cVar1 = *param_2; pcVar2 = param_2; if (cVar3 == '\0') { return iVar4; } } while( true ); }
6,564
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <regex.h> #include <stdlib.h>
char* func0(char* string, const char* charToReplace) { regex_t regex; char pattern[10]; sprintf(pattern, "%s{2,}", charToReplace); if (regcomp(&regex, pattern, REG_EXTENDED) != 0) { return NULL; // Failed to compile regex } regmatch_t match; size_t offset = 0; char* result = strdup(string); while (regexec(&regex, result + offset, 1, &match, 0) == 0) { size_t pos = offset + match.rm_so; memmove(result + pos + 1, result + pos + match.rm_eo - match.rm_so, strlen(result) - pos - match.rm_eo + match.rm_so + 1); offset = pos + 1; } regfree(&regex); return result; }
int main() { char* result; result = func0("peep", "e"); assert(strcmp(result, "pep") == 0); free(result); result = func0("Greek", "e"); assert(strcmp(result, "Grek") == 0); free(result); result = func0("Moon", "o"); assert(strcmp(result, "Mon") == 0); free(result); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x90,%rsp mov %rdi,-0x88(%rbp) mov %rsi,-0x90(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax mov -0x90(%rbp),%rdx lea -0x12(%rbp),%rax lea 0xd41(%rip),%rsi mov %rax,%rdi mov $0x0,%eax callq 1180 <sprintf@plt> lea -0x12(%rbp),%rcx lea -0x60(%rbp),%rax mov $0x1,%edx mov %rcx,%rsi mov %rax,%rdi callq 1140 <regcomp@plt> test %eax,%eax je 12fa <func0+0x71> mov $0x0,%eax jmpq 13d3 <func0+0x14a> movq $0x0,-0x80(%rbp) mov -0x88(%rbp),%rax mov %rax,%rdi callq 1190 <strdup@plt> mov %rax,-0x78(%rbp) jmp 1391 <func0+0x108> mov -0x68(%rbp),%eax movslq %eax,%rdx mov -0x80(%rbp),%rax add %rdx,%rax mov %rax,-0x70(%rbp) mov -0x78(%rbp),%rax mov %rax,%rdi callq 1110 <strlen@plt> sub -0x70(%rbp),%rax mov %rax,%rdx mov -0x64(%rbp),%eax cltq sub %rax,%rdx mov -0x68(%rbp),%eax cltq add %rdx,%rax lea 0x1(%rax),%rdx mov -0x64(%rbp),%eax movslq %eax,%rcx mov -0x70(%rbp),%rax add %rax,%rcx mov -0x68(%rbp),%eax cltq sub %rax,%rcx mov -0x78(%rbp),%rax add %rax,%rcx mov -0x70(%rbp),%rax lea 0x1(%rax),%rsi mov -0x78(%rbp),%rax add %rsi,%rax mov %rcx,%rsi mov %rax,%rdi callq 1170 <memmove@plt> mov -0x70(%rbp),%rax add $0x1,%rax mov %rax,-0x80(%rbp) mov -0x78(%rbp),%rdx mov -0x80(%rbp),%rax lea (%rdx,%rax,1),%rsi lea -0x68(%rbp),%rdx lea -0x60(%rbp),%rax mov $0x0,%r8d mov %rdx,%rcx mov $0x1,%edx mov %rax,%rdi callq 1160 <regexec@plt> test %eax,%eax je 1317 <func0+0x8e> lea -0x60(%rbp),%rax mov %rax,%rdi callq 1100 <regfree@plt> mov -0x78(%rbp),%rax mov -0x8(%rbp),%rdi xor %fs:0x28,%rdi je 13e7 <func0+0x15e> callq 1120 <__stack_chk_fail@plt> leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 90h mov [rbp+var_88], rdi mov [rbp+var_90], rsi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rdx, [rbp+var_90] lea rax, [rbp+s] lea rcx, format; "%s{2,}" mov rsi, rcx; format mov rdi, rax; s mov eax, 0 call _sprintf lea rcx, [rbp+s] lea rax, [rbp+preg] mov edx, 1; cflags mov rsi, rcx; pattern mov rdi, rax; preg call _regcomp test eax, eax jz short loc_12FD mov eax, 0 jmp loc_13D6 loc_12FD: mov [rbp+var_80], 0 mov rax, [rbp+var_88] mov rdi, rax; s call _strdup mov [rbp+var_78], rax jmp short loc_1394 loc_131A: mov eax, [rbp+pmatch.rm_so] movsxd rdx, eax mov rax, [rbp+var_80] add rax, rdx mov [rbp+var_70], rax mov rax, [rbp+var_78] mov rdi, rax; s call _strlen sub rax, [rbp+var_70] mov rdx, rax mov eax, [rbp+pmatch.rm_eo] cdqe sub rdx, rax mov eax, [rbp+pmatch.rm_so] cdqe add rax, rdx lea rdx, [rax+1]; n mov eax, [rbp+pmatch.rm_eo] movsxd rcx, eax mov rax, [rbp+var_70] add rcx, rax mov eax, [rbp+pmatch.rm_so] cdqe sub rcx, rax mov rax, [rbp+var_78] add rcx, rax mov rax, [rbp+var_70] lea rsi, [rax+1] mov rax, [rbp+var_78] add rax, rsi mov rsi, rcx; src mov rdi, rax; dest call _memmove mov rax, [rbp+var_70] add rax, 1 mov [rbp+var_80], rax loc_1394: mov rdx, [rbp+var_78] mov rax, [rbp+var_80] lea rsi, [rdx+rax]; string lea rdx, [rbp+pmatch] lea rax, [rbp+preg] mov r8d, 0; eflags mov rcx, rdx; pmatch mov edx, 1; nmatch mov rdi, rax; preg call _regexec test eax, eax jz loc_131A lea rax, [rbp+preg] mov rdi, rax; preg call _regfree mov rax, [rbp+var_78] loc_13D6: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_13EA call ___stack_chk_fail locret_13EA: leave retn
const char * func0(const char *a1, const char *a2) { size_t v3; // rax long long v4; // [rsp+10h] [rbp-80h] const char *v5; // [rsp+18h] [rbp-78h] long long v6; // [rsp+20h] [rbp-70h] regmatch_t pmatch; // [rsp+28h] [rbp-68h] BYREF regex_t preg; // [rsp+30h] [rbp-60h] BYREF char s[10]; // [rsp+7Eh] [rbp-12h] BYREF unsigned long long v10; // [rsp+88h] [rbp-8h] v10 = __readfsqword(0x28u); sprintf(s, "%s{2,}", a2); if ( regcomp(&preg, s, 1) ) return 0LL; v4 = 0LL; v5 = strdup(a1); while ( !regexec(&preg, &v5[v4], 1uLL, &pmatch, 0) ) { v6 = pmatch.rm_so + v4; v3 = strlen(v5); memmove((void *)&v5[v6 + 1], &v5[v6 + pmatch.rm_eo - pmatch.rm_so], v3 - v6 - pmatch.rm_eo + pmatch.rm_so + 1); v4 = v6 + 1; } regfree(&preg); return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x90 MOV qword ptr [RBP + -0x88],RDI MOV qword ptr [RBP + -0x90],RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RDX,qword ptr [RBP + -0x90] LEA RAX,[RBP + -0x12] LEA RCX,[0x102004] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x00101180 LEA RCX,[RBP + -0x12] LEA RAX,[RBP + -0x60] MOV EDX,0x1 MOV RSI,RCX MOV RDI,RAX CALL 0x00101140 TEST EAX,EAX JZ 0x001012fd MOV EAX,0x0 JMP 0x001013d6 LAB_001012fd: MOV qword ptr [RBP + -0x80],0x0 MOV RAX,qword ptr [RBP + -0x88] MOV RDI,RAX CALL 0x00101190 MOV qword ptr [RBP + -0x78],RAX JMP 0x00101394 LAB_0010131a: MOV EAX,dword ptr [RBP + -0x68] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x80] ADD RAX,RDX MOV qword ptr [RBP + -0x70],RAX MOV RAX,qword ptr [RBP + -0x78] MOV RDI,RAX CALL 0x00101110 SUB RAX,qword ptr [RBP + -0x70] MOV RDX,RAX MOV EAX,dword ptr [RBP + -0x64] CDQE SUB RDX,RAX MOV EAX,dword ptr [RBP + -0x68] CDQE ADD RAX,RDX LEA RDX,[RAX + 0x1] MOV EAX,dword ptr [RBP + -0x64] MOVSXD RCX,EAX MOV RAX,qword ptr [RBP + -0x70] ADD RCX,RAX MOV EAX,dword ptr [RBP + -0x68] CDQE SUB RCX,RAX MOV RAX,qword ptr [RBP + -0x78] ADD RCX,RAX MOV RAX,qword ptr [RBP + -0x70] LEA RSI,[RAX + 0x1] MOV RAX,qword ptr [RBP + -0x78] ADD RAX,RSI MOV RSI,RCX MOV RDI,RAX CALL 0x00101170 MOV RAX,qword ptr [RBP + -0x70] ADD RAX,0x1 MOV qword ptr [RBP + -0x80],RAX LAB_00101394: MOV RDX,qword ptr [RBP + -0x78] MOV RAX,qword ptr [RBP + -0x80] LEA RSI,[RDX + RAX*0x1] LEA RDX,[RBP + -0x68] LEA RAX,[RBP + -0x60] MOV R8D,0x0 MOV RCX,RDX MOV EDX,0x1 MOV RDI,RAX CALL 0x00101160 TEST EAX,EAX JZ 0x0010131a LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x00101100 MOV RAX,qword ptr [RBP + -0x78] LAB_001013d6: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x001013ea CALL 0x00101120 LAB_001013ea: LEAVE RET
char * func0(char *param_1,int8 param_2) { int iVar1; char *__s; size_t sVar2; long in_FS_OFFSET; long local_88; regmatch_t local_70; regex_t local_68; char local_1a [10]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); sprintf(local_1a,"%s{2,}",param_2); iVar1 = regcomp(&local_68,local_1a,1); if (iVar1 == 0) { local_88 = 0; __s = strdup(param_1); while( true ) { iVar1 = regexec(&local_68,__s + local_88,1,&local_70,0); if (iVar1 != 0) break; local_88 = local_88 + local_70.rm_so; sVar2 = strlen(__s); memmove(__s + local_88 + 1,__s + ((local_70.rm_eo + local_88) - (long)local_70.rm_so), (long)local_70.rm_so + ((sVar2 - local_88) - (long)local_70.rm_eo) + 1); local_88 = local_88 + 1; } regfree(&local_68); } else { __s = (char *)0x0; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return __s; }
6,565
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <regex.h> #include <stdlib.h>
char* func0(char* string, const char* charToReplace) { regex_t regex; char pattern[10]; sprintf(pattern, "%s{2,}", charToReplace); if (regcomp(&regex, pattern, REG_EXTENDED) != 0) { return NULL; // Failed to compile regex } regmatch_t match; size_t offset = 0; char* result = strdup(string); while (regexec(&regex, result + offset, 1, &match, 0) == 0) { size_t pos = offset + match.rm_so; memmove(result + pos + 1, result + pos + match.rm_eo - match.rm_so, strlen(result) - pos - match.rm_eo + match.rm_so + 1); offset = pos + 1; } regfree(&regex); return result; }
int main() { char* result; result = func0("peep", "e"); assert(strcmp(result, "pep") == 0); free(result); result = func0("Greek", "e"); assert(strcmp(result, "Grek") == 0); free(result); result = func0("Moon", "o"); assert(strcmp(result, "Mon") == 0); free(result); return 0; }
O1
c
func0: endbr64 push %r12 push %rbp push %rbx sub $0x70,%rsp mov %rdi,%rbx mov %rsi,%r8 mov %fs:0x28,%rax mov %rax,0x68(%rsp) xor %eax,%eax lea 0x5e(%rsp),%rbp lea 0xd8d(%rip),%rcx mov $0xa,%edx mov $0x1,%esi mov %rbp,%rdi callq 1150 <__sprintf_chk@plt> lea 0x10(%rsp),%rdi mov $0x1,%edx mov %rbp,%rsi callq 1110 <regcomp@plt> mov $0x0,%ebp test %eax,%eax jne 1330 <func0+0xe7> mov %rbx,%rdi callq 1140 <strdup@plt> mov %rax,%rbp mov $0x0,%ebx lea 0x8(%rsp),%r12 lea 0x0(%rbp,%rbx,1),%rsi lea 0x10(%rsp),%rdi mov $0x0,%r8d mov %r12,%rcx mov $0x1,%edx callq 1120 <regexec@plt> test %eax,%eax jne 1326 <func0+0xdd> movslq 0x8(%rsp),%rdx lea (%rdx,%rbx,1),%r8 mov $0xffffffffffffffff,%rcx mov $0x0,%eax mov %rbp,%rdi repnz scas %es:(%rdi),%al not %rcx movslq 0xc(%rsp),%rax lea (%rax,%rbx,1),%rsi add %rbp,%rsi lea 0x1(%r8),%rbx add $0x1,%rdx sub %rax,%rdx sub %r8,%rdx lea -0x1(%rcx,%rdx,1),%rdx lea 0x0(%rbp,%rbx,1),%rdi callq 1130 <memmove@plt> jmp 12bd <func0+0x74> lea 0x10(%rsp),%rdi callq 10e0 <regfree@plt> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 134c <func0+0x103> mov %rbp,%rax add $0x70,%rsp pop %rbx pop %rbp pop %r12 retq callq 10f0 <__stack_chk_fail@plt>
func0: endbr64 push r14 push r13 push r12 push rbp push rbx sub rsp, 70h mov rbx, rdi mov r8, rsi mov rax, fs:28h mov [rsp+98h+var_30], rax xor eax, eax lea rbp, [rsp+98h+var_3A] lea rcx, aS2; "%s{2,}" mov edx, 0Ah mov esi, 1 mov rdi, rbp call ___sprintf_chk lea rdi, [rsp+98h+var_88] mov edx, 1 mov rsi, rbp call _regcomp mov r12d, 0 test eax, eax jnz short loc_1364 mov rdi, rbx call _strdup mov r12, rax mov ebp, 0 lea r13, [rsp+98h+var_90] jmp short loc_133A loc_1300: movsxd rbx, [rsp+98h+var_90] lea r14, [rbx+rbp] mov rdi, r12 call _strlen mov rcx, rax movsxd rax, [rsp+98h+var_8C] lea rsi, [rax+rbp] add rsi, r12 lea rbp, [r14+1] lea rdx, [rbx+1] sub rdx, rax sub rdx, r14 add rdx, rcx lea rdi, [r12+rbp] call _memmove loc_133A: lea rsi, [r12+rbp] lea rdi, [rsp+98h+var_88] mov r8d, 0 mov rcx, r13 mov edx, 1 call _regexec test eax, eax jz short loc_1300 lea rdi, [rsp+98h+var_88] call _regfree loc_1364: mov rax, [rsp+98h+var_30] sub rax, fs:28h jnz short loc_1384 mov rax, r12 add rsp, 70h pop rbx pop rbp pop r12 pop r13 pop r14 retn loc_1384: call ___stack_chk_fail
long long func0(long long a1, const char *a2) { long long v2; // r12 long long v3; // rbp long long v4; // rbx long long v5; // r14 long long v6; // rax long long v7; // rsi int v9; // [rsp+8h] [rbp-90h] BYREF int v10; // [rsp+Ch] [rbp-8Ch] _BYTE v11[78]; // [rsp+10h] [rbp-88h] BYREF _BYTE v12[10]; // [rsp+5Eh] [rbp-3Ah] BYREF unsigned long long v13; // [rsp+68h] [rbp-30h] v13 = __readfsqword(0x28u); __sprintf_chk(v12, 1LL, 10LL, "%s{2,}", a2); v2 = 0LL; if ( !(unsigned int)regcomp(v11, v12, 1LL) ) { v2 = strdup(a1); v3 = 0LL; while ( !(unsigned int)regexec(v11, v2 + v3, 1LL, &v9, 0LL) ) { v4 = v9; v5 = v9 + v3; v6 = strlen(v2); v7 = v2 + v10 + v3; v3 = v5 + 1; memmove(v2 + v5 + 1, v7, v6 + v4 + 1 - v10 - v5); } regfree(v11); } return v2; }
func0: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x70 MOV RBX,RDI MOV R8,RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX LEA RBP,[RSP + 0x5e] LEA RCX,[0x102004] MOV EDX,0xa MOV ESI,0x1 MOV RDI,RBP CALL 0x00101190 LEA RDI,[RSP + 0x10] MOV EDX,0x1 MOV RSI,RBP CALL 0x00101140 MOV R12D,0x0 TEST EAX,EAX JNZ 0x00101364 MOV RDI,RBX CALL 0x00101180 MOV R12,RAX MOV EBP,0x0 LEA R13,[RSP + 0x8] JMP 0x0010133a LAB_00101300: MOVSXD RBX,dword ptr [RSP + 0x8] LEA R14,[RBX + RBP*0x1] MOV RDI,R12 CALL 0x00101110 MOV RCX,RAX MOVSXD RAX,dword ptr [RSP + 0xc] LEA RSI,[RAX + RBP*0x1] ADD RSI,R12 LEA RBP,[R14 + 0x1] LEA RDX,[RBX + 0x1] SUB RDX,RAX SUB RDX,R14 ADD RDX,RCX LEA RDI,[R12 + RBP*0x1] CALL 0x00101170 LAB_0010133a: LEA RSI,[R12 + RBP*0x1] LEA RDI,[RSP + 0x10] MOV R8D,0x0 MOV RCX,R13 MOV EDX,0x1 CALL 0x00101160 TEST EAX,EAX JZ 0x00101300 LEA RDI,[RSP + 0x10] CALL 0x00101100 LAB_00101364: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101384 MOV RAX,R12 ADD RSP,0x70 POP RBX POP RBP POP R12 POP R13 POP R14 RET LAB_00101384: CALL 0x00101120
char * func0(char *param_1,int8 param_2) { long lVar1; long lVar2; int iVar3; size_t sVar4; long lVar5; long lVar6; char *__s; long in_FS_OFFSET; regmatch_t local_90; regex_t local_88; char local_3a [10]; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); __sprintf_chk(local_3a,1,10,"%s{2,}",param_2); iVar3 = regcomp(&local_88,local_3a,1); __s = (char *)0x0; if (iVar3 == 0) { __s = strdup(param_1); lVar6 = 0; while( true ) { iVar3 = regexec(&local_88,__s + lVar6,1,&local_90,0); if (iVar3 != 0) break; lVar5 = (long)local_90.rm_so; lVar1 = lVar5 + lVar6; sVar4 = strlen(__s); lVar2 = local_90.rm_eo + lVar6; lVar6 = lVar1 + 1; memmove(__s + lVar6,__s + lVar2,(((lVar5 + 1) - (long)local_90.rm_eo) - lVar1) + sVar4); } regfree(&local_88); } if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return __s; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,566
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <regex.h> #include <stdlib.h>
char* func0(char* string, const char* charToReplace) { regex_t regex; char pattern[10]; sprintf(pattern, "%s{2,}", charToReplace); if (regcomp(&regex, pattern, REG_EXTENDED) != 0) { return NULL; // Failed to compile regex } regmatch_t match; size_t offset = 0; char* result = strdup(string); while (regexec(&regex, result + offset, 1, &match, 0) == 0) { size_t pos = offset + match.rm_so; memmove(result + pos + 1, result + pos + match.rm_eo - match.rm_so, strlen(result) - pos - match.rm_eo + match.rm_so + 1); offset = pos + 1; } regfree(&regex); return result; }
int main() { char* result; result = func0("peep", "e"); assert(strcmp(result, "pep") == 0); free(result); result = func0("Greek", "e"); assert(strcmp(result, "Grek") == 0); free(result); result = func0("Moon", "o"); assert(strcmp(result, "Mon") == 0); free(result); return 0; }
O2
c
func0: endbr64 push %r13 mov %rsi,%r8 mov $0xa,%edx mov %rdi,%r13 push %r12 lea 0xc7a(%rip),%rcx mov $0x1,%esi push %rbp push %rbx sub $0x78,%rsp mov %fs:0x28,%rax mov %rax,0x68(%rsp) xor %eax,%eax lea 0x5e(%rsp),%r12 lea 0x10(%rsp),%rbp mov %r12,%rdi callq 1150 <__sprintf_chk@plt> mov %r12,%rsi mov $0x1,%edx mov %rbp,%rdi callq 1110 <regcomp@plt> xor %r12d,%r12d test %eax,%eax jne 1486 <func0+0x116> mov %r13,%rdi xor %ebx,%ebx lea 0x8(%rsp),%r13 callq 1140 <strdup@plt> mov %rax,%r12 mov %rax,%r9 jmp 1460 <func0+0xf0> nopl 0x0(%rax) movslq 0x8(%rsp),%rcx mov %r12,%rdx lea (%rcx,%rbx,1),%rdi mov (%rdx),%esi add $0x4,%rdx lea -0x1010101(%rsi),%eax not %esi and %esi,%eax and $0x80808080,%eax je 13fc <func0+0x8c> mov %eax,%esi shr $0x10,%esi test $0x8080,%eax cmove %esi,%eax lea 0x2(%rdx),%rsi cmove %rsi,%rdx mov %eax,%esi add %al,%sil movslq 0xc(%rsp),%rax sbb $0x3,%rdx add $0x1,%rcx lea (%rax,%rbx,1),%rsi sub %rax,%rcx lea 0x1(%rdi),%rbx sub %r12,%rdx sub %rdi,%rcx lea (%r12,%rbx,1),%r9 add %r12,%rsi mov %r9,%rdi add %rcx,%rdx callq 1130 <memmove@plt> mov %rax,%r9 xor %r8d,%r8d mov %r13,%rcx mov $0x1,%edx mov %r9,%rsi mov %rbp,%rdi callq 1120 <regexec@plt> test %eax,%eax je 13f0 <func0+0x80> mov %rbp,%rdi callq 10e0 <regfree@plt> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 14a4 <func0+0x134> add $0x78,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10f0 <__stack_chk_fail@plt> nopl 0x0(%rax)
func0: endbr64 push r15 mov r8, rsi mov edx, 0Ah lea rcx, aS2; "%s{2,}" push r14 mov esi, 1 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 78h mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax lea r12, [rsp+0A8h+var_4A] lea r13, [rsp+0A8h+var_98] mov rdi, r12 call ___sprintf_chk mov rsi, r12 mov edx, 1 mov rdi, r13 call _regcomp xor r12d, r12d test eax, eax jnz loc_1483 mov rdi, rbp lea r14, [rsp+0A8h+var_A0] xor ebp, ebp call _strdup mov r12, rax mov r9, rax jmp short loc_1461 loc_1420: mov rdi, r12 movsxd rbx, [rsp+0A8h+var_A0] call _strlen mov r8, rax movsxd rax, [rsp+0A8h+var_9C] lea r15, [rbx+rbp] add rbx, 1 lea rsi, [rax+rbp] sub rbx, rax lea rbp, [r15+1] lea r9, [r12+rbp] sub rbx, r15 add rsi, r12 mov rdi, r9 lea rdx, [rbx+r8] call _memmove mov r9, rax loc_1461: xor r8d, r8d mov rcx, r14 mov edx, 1 mov rsi, r9 mov rdi, r13 call _regexec test eax, eax jz short loc_1420 mov rdi, r13 call _regfree loc_1483: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_14A5 add rsp, 78h mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_14A5: call ___stack_chk_fail
long long func0(long long a1, const char *a2) { long long v2; // r12 long long v3; // rbp long long i; // r9 long long v5; // rbx long long v6; // rax long long v7; // r15 long long v8; // rsi int v10; // [rsp+8h] [rbp-A0h] BYREF int v11; // [rsp+Ch] [rbp-9Ch] _BYTE v12[78]; // [rsp+10h] [rbp-98h] BYREF _BYTE v13[10]; // [rsp+5Eh] [rbp-4Ah] BYREF unsigned long long v14; // [rsp+68h] [rbp-40h] v14 = __readfsqword(0x28u); __sprintf_chk(v13, 1LL, 10LL, "%s{2,}", a2); v2 = 0LL; if ( !(unsigned int)regcomp(v12, v13, 1LL) ) { v3 = 0LL; v2 = strdup(a1); for ( i = v2; !(unsigned int)regexec(v12, i, 1LL, &v10, 0LL); i = memmove( v2 + v7 + 1, v2 + v8, v5 + 1 - v11 - v7 + v6) ) { v5 = v10; v6 = strlen(v2); v7 = v5 + v3; v8 = v11 + v3; v3 += v5 + 1; } regfree(v12); } return v2; }
func0: ENDBR64 PUSH R15 MOV R8,RSI MOV EDX,0xa LEA RCX,[0x102004] PUSH R14 MOV ESI,0x1 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x78 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX LEA R12,[RSP + 0x5e] LEA R13,[RSP + 0x10] MOV RDI,R12 CALL 0x00101190 MOV RSI,R12 MOV EDX,0x1 MOV RDI,R13 CALL 0x00101140 XOR R12D,R12D TEST EAX,EAX JNZ 0x00101483 MOV RDI,RBP LEA R14,[RSP + 0x8] XOR EBP,EBP CALL 0x00101180 MOV R12,RAX MOV R9,RAX JMP 0x00101461 LAB_00101420: MOV RDI,R12 MOVSXD RBX,dword ptr [RSP + 0x8] CALL 0x00101110 MOV R8,RAX MOVSXD RAX,dword ptr [RSP + 0xc] LEA R15,[RBX + RBP*0x1] ADD RBX,0x1 LEA RSI,[RAX + RBP*0x1] SUB RBX,RAX LEA RBP,[R15 + 0x1] LEA R9,[R12 + RBP*0x1] SUB RBX,R15 ADD RSI,R12 MOV RDI,R9 LEA RDX,[RBX + R8*0x1] CALL 0x00101170 MOV R9,RAX LAB_00101461: XOR R8D,R8D MOV RCX,R14 MOV EDX,0x1 MOV RSI,R9 MOV RDI,R13 CALL 0x00101160 TEST EAX,EAX JZ 0x00101420 MOV RDI,R13 CALL 0x00101100 LAB_00101483: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x001014a5 ADD RSP,0x78 MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001014a5: CALL 0x00101120
char * func0(char *param_1) { long lVar1; long lVar2; int iVar3; char *__s; size_t sVar4; char *__string; long lVar5; long lVar6; long in_FS_OFFSET; regmatch_t local_a0; regex_t local_98; char local_4a [10]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); __sprintf_chk(local_4a,1,10,"%s{2,}"); iVar3 = regcomp(&local_98,local_4a,1); __s = (char *)0x0; if (iVar3 == 0) { lVar6 = 0; __s = strdup(param_1); __string = __s; while( true ) { iVar3 = regexec(&local_98,__string,1,&local_a0,0); if (iVar3 != 0) break; lVar5 = (long)local_a0.rm_so; sVar4 = strlen(__s); lVar1 = lVar5 + lVar6; lVar2 = local_a0.rm_eo + lVar6; lVar6 = lVar1 + 1; __string = (char *)memmove(__s + lVar6,__s + lVar2, (((lVar5 + 1) - (long)local_a0.rm_eo) - lVar1) + sVar4); } regfree(&local_98); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return __s; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,567
func0
#include <stdio.h> #include <assert.h> #include <string.h> #include <regex.h> #include <stdlib.h>
char* func0(char* string, const char* charToReplace) { regex_t regex; char pattern[10]; sprintf(pattern, "%s{2,}", charToReplace); if (regcomp(&regex, pattern, REG_EXTENDED) != 0) { return NULL; // Failed to compile regex } regmatch_t match; size_t offset = 0; char* result = strdup(string); while (regexec(&regex, result + offset, 1, &match, 0) == 0) { size_t pos = offset + match.rm_so; memmove(result + pos + 1, result + pos + match.rm_eo - match.rm_so, strlen(result) - pos - match.rm_eo + match.rm_so + 1); offset = pos + 1; } regfree(&regex); return result; }
int main() { char* result; result = func0("peep", "e"); assert(strcmp(result, "pep") == 0); free(result); result = func0("Greek", "e"); assert(strcmp(result, "Grek") == 0); free(result); result = func0("Moon", "o"); assert(strcmp(result, "Mon") == 0); free(result); return 0; }
O3
c
func0: endbr64 push %r13 mov %rsi,%r8 mov $0xa,%edx mov %rdi,%r13 push %r12 lea 0xc7a(%rip),%rcx mov $0x1,%esi push %rbp push %rbx sub $0x78,%rsp mov %fs:0x28,%rax mov %rax,0x68(%rsp) xor %eax,%eax lea 0x5e(%rsp),%r12 lea 0x10(%rsp),%rbp mov %r12,%rdi callq 1150 <__sprintf_chk@plt> mov %r12,%rsi mov $0x1,%edx mov %rbp,%rdi callq 1110 <regcomp@plt> xor %r12d,%r12d test %eax,%eax jne 1486 <func0+0x116> mov %r13,%rdi xor %ebx,%ebx lea 0x8(%rsp),%r13 callq 1140 <strdup@plt> mov %rax,%r12 mov %rax,%r9 jmp 1460 <func0+0xf0> nopl 0x0(%rax) movslq 0x8(%rsp),%rcx mov %r12,%rdx lea (%rcx,%rbx,1),%rdi mov (%rdx),%esi add $0x4,%rdx lea -0x1010101(%rsi),%eax not %esi and %esi,%eax and $0x80808080,%eax je 13fc <func0+0x8c> mov %eax,%esi shr $0x10,%esi test $0x8080,%eax cmove %esi,%eax lea 0x2(%rdx),%rsi cmove %rsi,%rdx mov %eax,%esi add %al,%sil movslq 0xc(%rsp),%rax sbb $0x3,%rdx add $0x1,%rcx lea (%rax,%rbx,1),%rsi sub %rax,%rcx lea 0x1(%rdi),%rbx sub %r12,%rdx sub %rdi,%rcx lea (%r12,%rbx,1),%r9 add %r12,%rsi mov %r9,%rdi add %rcx,%rdx callq 1130 <memmove@plt> mov %rax,%r9 xor %r8d,%r8d mov %r13,%rcx mov $0x1,%edx mov %r9,%rsi mov %rbp,%rdi callq 1120 <regexec@plt> test %eax,%eax je 13f0 <func0+0x80> mov %rbp,%rdi callq 10e0 <regfree@plt> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 14a4 <func0+0x134> add $0x78,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10f0 <__stack_chk_fail@plt> nopl 0x0(%rax)
func0: endbr64 push r15 mov r8, rsi mov edx, 0Ah lea rcx, aS2; "%s{2,}" push r14 mov esi, 2 push r13 push r12 push rbp push rbx mov rbx, rdi sub rsp, 88h mov rax, fs:28h mov [rsp+0B8h+var_40], rax xor eax, eax lea rbp, [rsp+0B8h+pattern] lea r13, [rsp+0B8h+preg] mov rdi, rbp call ___sprintf_chk mov rsi, rbp; pattern mov edx, 1; cflags mov rdi, r13; preg call _regcomp xor ebp, ebp test eax, eax jnz loc_14A7 mov rdi, rbx; s xor r15d, r15d call _strlen mov rdi, rbx; s lea r12, [rax+1] call _strdup mov rbp, rax mov rdi, rax lea rax, [rsp+0B8h+var_A0] mov [rsp+0B8h+pmatch], rax jmp short loc_1483 loc_1438: mov rdi, rbp; s movsxd rbx, [rsp+0B8h+var_A0] call _strlen mov rcx, r12 mov rdi, rax movsxd rax, [rsp+0B8h+var_9C] lea r14, [rbx+r15] lea rdx, [rbx+1] lea rsi, [rax+r15] lea r15, [r14+1] add rsi, rbp cmp r15, r12 cmovnb rcx, r15 sub rdx, rax sub rdx, r14 add rdx, rdi sub rcx, r15 lea rdi, [rbp+r15+0] call ___memmove_chk mov rdi, rax loc_1483: mov rcx, [rsp+0B8h+pmatch]; pmatch xor r8d, r8d; eflags mov rsi, rdi; string mov edx, 1; nmatch mov rdi, r13; preg call _regexec test eax, eax jz short loc_1438 mov rdi, r13; preg call _regfree loc_14A7: mov rax, [rsp+0B8h+var_40] sub rax, fs:28h jnz short loc_14CC add rsp, 88h mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_14CC: call ___stack_chk_fail
char * func0(char *s, const char *a2) { char *v2; // rbp size_t v3; // r15 size_t v4; // r12 int i; // eax long long rm_so; // rbx size_t v7; // rax size_t v8; // rcx size_t v9; // r14 size_t v10; // rsi char *v11; // rsi const char *v12; // rdi regmatch_t v14; // [rsp+18h] [rbp-A0h] BYREF regex_t preg; // [rsp+20h] [rbp-98h] BYREF char pattern[10]; // [rsp+6Eh] [rbp-4Ah] BYREF unsigned long long v17; // [rsp+78h] [rbp-40h] v17 = __readfsqword(0x28u); __sprintf_chk(pattern, 2LL, 10LL, "%s{2,}", a2); v2 = 0LL; if ( !regcomp(&preg, pattern, 1) ) { v3 = 0LL; v4 = strlen(s) + 1; v2 = strdup(s); for ( i = regexec(&preg, v2, 1uLL, &v14, 0); !i; i = regexec(&preg, v12, 1uLL, &v14, 0) ) { rm_so = v14.rm_so; v7 = strlen(v2); v8 = v4; v9 = rm_so + v3; v10 = v14.rm_eo + v3; v3 += rm_so + 1; v11 = &v2[v10]; if ( v3 >= v4 ) v8 = v3; v12 = (const char *)__memmove_chk(&v2[v3], v11, v7 + rm_so + 1 - v14.rm_eo - v9, v8 - v3); } regfree(&preg); } return v2; }
func0: ENDBR64 PUSH R15 MOV R8,RSI MOV EDX,0xa LEA RCX,[0x102004] PUSH R14 MOV ESI,0x2 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV RBX,RDI SUB RSP,0x88 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x78],RAX XOR EAX,EAX LEA RBP,[RSP + 0x6e] LEA R13,[RSP + 0x20] MOV RDI,RBP CALL 0x00101190 MOV RSI,RBP MOV EDX,0x1 MOV RDI,R13 CALL 0x00101140 XOR EBP,EBP TEST EAX,EAX JNZ 0x001014a7 MOV RDI,RBX XOR R15D,R15D CALL 0x00101110 MOV RDI,RBX LEA R12,[RAX + 0x1] CALL 0x00101180 MOV RBP,RAX MOV RDI,RAX LEA RAX,[RSP + 0x18] MOV qword ptr [RSP + 0x8],RAX JMP 0x00101483 LAB_00101438: MOV RDI,RBP MOVSXD RBX,dword ptr [RSP + 0x18] CALL 0x00101110 MOV RCX,R12 MOV RDI,RAX MOVSXD RAX,dword ptr [RSP + 0x1c] LEA R14,[RBX + R15*0x1] LEA RDX,[RBX + 0x1] LEA RSI,[RAX + R15*0x1] LEA R15,[R14 + 0x1] ADD RSI,RBP CMP R15,R12 CMOVNC RCX,R15 SUB RDX,RAX SUB RDX,R14 ADD RDX,RDI SUB RCX,R15 LEA RDI,[RBP + R15*0x1] CALL 0x00101160 MOV RDI,RAX LAB_00101483: MOV RCX,qword ptr [RSP + 0x8] XOR R8D,R8D MOV RSI,RDI MOV EDX,0x1 MOV RDI,R13 CALL 0x00101170 TEST EAX,EAX JZ 0x00101438 MOV RDI,R13 CALL 0x00101100 LAB_001014a7: MOV RAX,qword ptr [RSP + 0x78] SUB RAX,qword ptr FS:[0x28] JNZ 0x001014cc ADD RSP,0x88 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001014cc: CALL 0x00101120
char * func0(char *param_1) { long lVar1; long lVar2; int iVar3; size_t sVar4; char *__s; size_t sVar5; char *__string; ulong uVar6; long lVar7; ulong uVar8; long in_FS_OFFSET; regmatch_t local_a0; regex_t local_98; char local_4a [10]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); __sprintf_chk(local_4a,2,10,"%s{2,}"); iVar3 = regcomp(&local_98,local_4a,1); __s = (char *)0x0; if (iVar3 == 0) { uVar8 = 0; sVar4 = strlen(param_1); __s = strdup(param_1); __string = __s; while( true ) { iVar3 = regexec(&local_98,__string,1,&local_a0,0); if (iVar3 != 0) break; lVar7 = (long)local_a0.rm_so; sVar5 = strlen(__s); lVar1 = lVar7 + uVar8; lVar2 = (long)local_a0.rm_eo + uVar8; uVar8 = lVar1 + 1; uVar6 = sVar4 + 1; if (sVar4 + 1 <= uVar8) { uVar6 = uVar8; } __string = (char *)__memmove_chk(__s + uVar8,__s + lVar2, (((lVar7 + 1) - (long)local_a0.rm_eo) - lVar1) + sVar5, uVar6 - uVar8); } regfree(&local_98); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return __s; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,568
func0
#include <stdio.h> #include <regex.h> #include <assert.h>
int func0(const char *Ip) { regex_t regex; int reti; char msgbuf[100]; const char *pattern = "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"; // Compile regex reti = regcomp(&regex, pattern, REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return -1; } // Execute regex reti = regexec(&regex, Ip, 0, NULL, 0); if (!reti) { return 1; // Valid IP address } else if (reti == REG_NOMATCH) { return 0; // Invalid IP address } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); return -1; } // Free regex memory regfree(&regex); }
int main() { assert(func0("192.168.0.1") == 1); // Valid IP address assert(func0("110.234.52.124") == 1); // Valid IP address assert(func0("366.1.2.2") == 0); // Invalid IP address 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 0xdd3(%rip),%rax mov %rax,-0xb8(%rbp) mov -0xb8(%rbp),%rcx lea -0xb0(%rbp),%rax mov $0x1,%edx mov %rcx,%rsi mov %rax,%rdi callq 10d0 <regcomp@plt> mov %eax,-0xbc(%rbp) cmpl $0x0,-0xbc(%rbp) je 1293 <func0+0x8a> mov 0x2db0(%rip),%rax mov %rax,%rcx mov $0x18,%edx mov $0x1,%esi lea 0xe29(%rip),%rdi callq 1110 <fwrite@plt> mov $0xffffffff,%eax jmpq 1320 <func0+0x117> mov -0xc8(%rbp),%rsi lea -0xb0(%rbp),%rax mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rax,%rdi callq 1100 <regexec@plt> mov %eax,-0xbc(%rbp) cmpl $0x0,-0xbc(%rbp) jne 12cf <func0+0xc6> mov $0x1,%eax jmp 1320 <func0+0x117> cmpl $0x1,-0xbc(%rbp) jne 12df <func0+0xd6> mov $0x0,%eax jmp 1320 <func0+0x117> lea -0x70(%rbp),%rdx lea -0xb0(%rbp),%rsi mov -0xbc(%rbp),%eax mov $0x64,%ecx mov %eax,%edi callq 10f0 <regerror@plt> mov 0x2d1d(%rip),%rax lea -0x70(%rbp),%rdx lea 0xdb8(%rip),%rsi mov %rax,%rdi mov $0x0,%eax callq 10e0 <fprintf@plt> mov $0xffffffff,%eax mov -0x8(%rbp),%rcx xor %fs:0x28,%rcx je 1334 <func0+0x12b> callq 10b0 <__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, a25052040901090; "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?"... mov [rbp+pattern], rax mov rcx, [rbp+pattern] lea rax, [rbp+preg] mov edx, 1; cflags mov rsi, rcx; pattern mov rdi, rax; preg call _regcomp mov [rbp+errcode], eax cmp [rbp+errcode], 0 jz short loc_1296 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 mov eax, 0FFFFFFFFh jmp loc_1326 loc_1296: 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_12D2 mov eax, 1 jmp short loc_1326 loc_12D2: cmp [rbp+errcode], 1 jnz short loc_12E2 mov eax, 0 jmp short loc_1326 loc_12E2: 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 mov eax, 0FFFFFFFFh loc_1326: mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_133A call ___stack_chk_fail locret_133A: leave retn
long long func0(const char *a1) { int errcode; // [rsp+14h] [rbp-BCh] 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, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]" "?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$", 1) ) { fwrite("Could not compile regex\n", 1uLL, 0x18uLL, _bss_start); return 0xFFFFFFFFLL; } else { errcode = regexec(&preg, a1, 0LL, 0LL, 0); if ( errcode ) { if ( errcode == 1 ) { return 0LL; } else { regerror(errcode, &preg, errbuf, 0x64uLL); fprintf(_bss_start, "Regex match failed: %s\n", errbuf); return 0xFFFFFFFFLL; } } else { return 1LL; } } }
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,[0x102008] MOV qword ptr [RBP + -0xb8],RAX MOV RCX,qword ptr [RBP + -0xb8] LEA RAX,[RBP + -0xb0] MOV EDX,0x1 MOV RSI,RCX MOV RDI,RAX CALL 0x001010d0 MOV dword ptr [RBP + -0xbc],EAX CMP dword ptr [RBP + -0xbc],0x0 JZ 0x00101296 MOV RAX,qword ptr [0x00104020] MOV RCX,RAX MOV EDX,0x18 MOV ESI,0x1 LEA RAX,[0x1020ad] MOV RDI,RAX CALL 0x00101110 MOV EAX,0xffffffff JMP 0x00101326 LAB_00101296: MOV RSI,qword ptr [RBP + -0xc8] LEA RAX,[RBP + -0xb0] MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RDI,RAX CALL 0x00101100 MOV dword ptr [RBP + -0xbc],EAX CMP dword ptr [RBP + -0xbc],0x0 JNZ 0x001012d2 MOV EAX,0x1 JMP 0x00101326 LAB_001012d2: CMP dword ptr [RBP + -0xbc],0x1 JNZ 0x001012e2 MOV EAX,0x0 JMP 0x00101326 LAB_001012e2: LEA RDX,[RBP + -0x70] LEA RSI,[RBP + -0xb0] MOV EAX,dword ptr [RBP + -0xbc] MOV ECX,0x64 MOV EDI,EAX CALL 0x001010f0 MOV RAX,qword ptr [0x00104020] LEA RDX,[RBP + -0x70] LEA RCX,[0x1020c6] MOV RSI,RCX MOV RDI,RAX MOV EAX,0x0 CALL 0x001010e0 MOV EAX,0xffffffff LAB_00101326: MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x0010133a CALL 0x001010b0 LAB_0010133a: LEAVE RET
int8 func0(char *param_1) { int iVar1; int8 uVar2; 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, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$" ,1); if (iVar1 == 0) { iVar1 = regexec(&local_b8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { uVar2 = 1; } else if (iVar1 == 1) { uVar2 = 0; } else { regerror(iVar1,&local_b8,local_78,100); fprintf(stderr,"Regex match failed: %s\n",local_78); uVar2 = 0xffffffff; } } else { fwrite("Could not compile regex\n",1,0x18,stderr); uVar2 = 0xffffffff; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar2; }
6,569
func0
#include <stdio.h> #include <regex.h> #include <assert.h>
int func0(const char *Ip) { regex_t regex; int reti; char msgbuf[100]; const char *pattern = "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"; // Compile regex reti = regcomp(&regex, pattern, REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return -1; } // Execute regex reti = regexec(&regex, Ip, 0, NULL, 0); if (!reti) { return 1; // Valid IP address } else if (reti == REG_NOMATCH) { return 0; // Invalid IP address } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); return -1; } // Free regex memory regfree(&regex); }
int main() { assert(func0("192.168.0.1") == 1); // Valid IP address assert(func0("110.234.52.124") == 1); // Valid IP address assert(func0("366.1.2.2") == 0); // Invalid IP address return 0; }
O1
c
func0: endbr64 push %rbp push %rbx sub $0xb8,%rsp mov %rdi,%rbp mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%rdi mov $0x1,%edx lea 0xdcd(%rip),%rsi callq 10d0 <regcomp@plt> test %eax,%eax jne 12ac <func0+0xa3> mov %eax,%ebx mov %rsp,%rdi mov $0x0,%r8d mov $0x0,%ecx mov $0x0,%edx mov %rbp,%rsi callq 10f0 <regexec@plt> test %eax,%eax je 12ed <func0+0xe4> cmp $0x1,%eax je 12ce <func0+0xc5> lea 0x40(%rsp),%rbx mov %rsp,%rsi mov $0x64,%ecx mov %rbx,%rdx mov %eax,%edi callq 10e0 <regerror@plt> mov %rbx,%rcx lea 0xe76(%rip),%rdx mov $0x1,%esi mov 0x2d85(%rip),%rdi mov $0x0,%eax callq 1110 <__fprintf_chk@plt> mov $0xffffffff,%ebx jmp 12ce <func0+0xc5> mov 0x2d6d(%rip),%rcx mov $0x18,%edx mov $0x1,%esi lea 0xe28(%rip),%rdi callq 1100 <fwrite@plt> mov $0xffffffff,%ebx mov 0xa8(%rsp),%rax xor %fs:0x28,%rax jne 12f4 <func0+0xeb> mov %ebx,%eax add $0xb8,%rsp pop %rbx pop %rbp retq mov $0x1,%ebx jmp 12ce <func0+0xc5> callq 10b0 <__stack_chk_fail@plt>
func0: endbr64 push rbp push rbx sub rsp, 0B8h mov rbp, rdi mov rax, fs:28h mov [rsp+0C8h+var_20], rax xor eax, eax mov rdi, rsp mov edx, 1 lea rsi, a25052040901090; "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?"... call _regcomp test eax, eax jnz short loc_12AC mov ebx, eax mov rdi, rsp mov r8d, 0 mov ecx, 0 mov edx, 0 mov rsi, rbp call _regexec test eax, eax jz loc_12ED cmp eax, 1 jz short loc_12CE lea rbx, [rsp+0C8h+var_88] mov rsi, rsp mov ecx, 64h ; 'd' mov rdx, rbx mov edi, eax call _regerror mov rcx, rbx 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 ebx, 0FFFFFFFFh jmp short loc_12CE loc_12AC: mov rcx, cs:stderr@GLIBC_2_2_5 mov edx, 18h mov esi, 1 lea rdi, aCouldNotCompil; "Could not compile regex\n" call _fwrite mov ebx, 0FFFFFFFFh loc_12CE: mov rax, [rsp+0C8h+var_20] sub rax, fs:28h jnz short loc_12F4 mov eax, ebx add rsp, 0B8h pop rbx pop rbp retn loc_12ED: mov ebx, 1 jmp short loc_12CE loc_12F4: call ___stack_chk_fail
long long func0(long long a1) { unsigned int v1; // ebx unsigned int v2; // eax _BYTE v4[64]; // [rsp+0h] [rbp-C8h] BYREF char v5[104]; // [rsp+40h] [rbp-88h] BYREF unsigned long long v6; // [rsp+A8h] [rbp-20h] v6 = __readfsqword(0x28u); if ( (unsigned int)regcomp( v4, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0" "-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$", 1LL) ) { fwrite("Could not compile regex\n", 1LL, 24LL, stderr); return (unsigned int)-1; } else { v1 = 0; v2 = regexec(v4, a1, 0LL, 0LL, 0LL); if ( v2 ) { if ( v2 != 1 ) { regerror(v2, v4, v5, 100LL); __fprintf_chk(stderr, 1LL, "Regex match failed: %s\n", v5); return (unsigned int)-1; } } else { return 1; } } return v1; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0xb8 MOV RBP,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV RDI,RSP MOV EDX,0x1 LEA RSI,[0x102008] CALL 0x001010d0 TEST EAX,EAX JNZ 0x001012ac MOV EBX,EAX MOV RDI,RSP MOV R8D,0x0 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,RBP CALL 0x001010f0 TEST EAX,EAX JZ 0x001012ed CMP EAX,0x1 JZ 0x001012ce LEA RBX,[RSP + 0x40] MOV RSI,RSP MOV ECX,0x64 MOV RDX,RBX MOV EDI,EAX CALL 0x001010e0 MOV RCX,RBX LEA RDX,[0x1020c6] MOV ESI,0x1 MOV RDI,qword ptr [0x00104020] MOV EAX,0x0 CALL 0x00101110 MOV EBX,0xffffffff JMP 0x001012ce LAB_001012ac: MOV RCX,qword ptr [0x00104020] MOV EDX,0x18 MOV ESI,0x1 LEA RDI,[0x1020ad] CALL 0x00101100 MOV EBX,0xffffffff LAB_001012ce: MOV RAX,qword ptr [RSP + 0xa8] SUB RAX,qword ptr FS:[0x28] JNZ 0x001012f4 MOV EAX,EBX ADD RSP,0xb8 POP RBX POP RBP RET LAB_001012ed: MOV EBX,0x1 JMP 0x001012ce LAB_001012f4: CALL 0x001010b0
int4 func0(char *param_1) { int iVar1; int4 uVar2; 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, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$" ,1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { uVar2 = 1; } else { uVar2 = 0; if (iVar1 != 1) { regerror(iVar1,&rStack_c8,local_88,100); __fprintf_chk(stderr,1,"Regex match failed: %s\n",local_88); uVar2 = 0xffffffff; } } } else { fwrite("Could not compile regex\n",1,0x18,stderr); uVar2 = 0xffffffff; } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,570
func0
#include <stdio.h> #include <regex.h> #include <assert.h>
int func0(const char *Ip) { regex_t regex; int reti; char msgbuf[100]; const char *pattern = "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"; // Compile regex reti = regcomp(&regex, pattern, REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return -1; } // Execute regex reti = regexec(&regex, Ip, 0, NULL, 0); if (!reti) { return 1; // Valid IP address } else if (reti == REG_NOMATCH) { return 0; // Invalid IP address } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); return -1; } // Free regex memory regfree(&regex); }
int main() { assert(func0("192.168.0.1") == 1); // Valid IP address assert(func0("110.234.52.124") == 1); // Valid IP address assert(func0("366.1.2.2") == 0); // Invalid IP address return 0; }
O2
c
func0: endbr64 push %r13 mov $0x1,%edx lea 0xd46(%rip),%rsi push %r12 push %rbp mov %rdi,%rbp sub $0xb0,%rsp mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%r13 mov %r13,%rdi callq 10d0 <regcomp@plt> test %eax,%eax jne 1380 <func0+0xd0> xor %r8d,%r8d xor %ecx,%ecx xor %edx,%edx mov %rbp,%rsi mov %r13,%rdi mov %eax,%r12d callq 10f0 <regexec@plt> test %eax,%eax je 1370 <func0+0xc0> cmp $0x1,%eax je 134d <func0+0x9d> lea 0x40(%rsp),%r12 mov $0x64,%ecx mov %r13,%rsi mov %eax,%edi mov %r12,%rdx callq 10e0 <regerror@plt> mov %r12,%rcx mov $0x1,%esi xor %eax,%eax mov 0x2ce5(%rip),%rdi lea 0xdc3(%rip),%rdx mov $0xffffffff,%r12d callq 1110 <__fprintf_chk@plt> mov 0xa8(%rsp),%rax xor %fs:0x28,%rax jne 13a5 <func0+0xf5> add $0xb0,%rsp mov %r12d,%eax pop %rbp pop %r12 pop %r13 retq mov $0x1,%r12d jmp 134d <func0+0x9d> nopl 0x0(%rax,%rax,1) mov $0x18,%edx mov 0x2c94(%rip),%rcx mov $0x1,%esi lea 0xd54(%rip),%rdi mov $0xffffffff,%r12d callq 1100 <fwrite@plt> jmp 134d <func0+0x9d> callq 10b0 <__stack_chk_fail@plt> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r13 mov edx, 1 lea rsi, a25052040901090; "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?"... push r12 push rbp mov rbp, rdi sub rsp, 0B0h mov rax, fs:28h mov [rsp+0C8h+var_20], rax xor eax, eax mov r13, rsp mov rdi, r13 call _regcomp test eax, eax jnz loc_1380 xor r8d, r8d xor ecx, ecx xor edx, edx mov rsi, rbp mov rdi, r13 mov r12d, eax call _regexec test eax, eax jz short loc_1370 cmp eax, 1 jz short loc_134D lea r12, [rsp+0C8h+var_88] mov ecx, 64h ; 'd' mov rsi, r13 mov edi, eax 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" mov r12d, 0FFFFFFFFh call ___fprintf_chk loc_134D: mov rax, [rsp+0C8h+var_20] sub rax, fs:28h jnz short loc_13A5 add rsp, 0B0h mov eax, r12d pop rbp pop r12 pop r13 retn loc_1370: mov r12d, 1 jmp short loc_134D loc_1380: mov edx, 18h mov rcx, cs:stderr@GLIBC_2_2_5 mov esi, 1 lea rdi, aCouldNotCompil; "Could not compile regex\n" mov r12d, 0FFFFFFFFh call _fwrite jmp short loc_134D loc_13A5: call ___stack_chk_fail
long long func0(long long a1) { unsigned int v1; // r12d unsigned int v2; // eax _BYTE v4[64]; // [rsp+0h] [rbp-C8h] BYREF char v5[104]; // [rsp+40h] [rbp-88h] BYREF unsigned long long v6; // [rsp+A8h] [rbp-20h] v6 = __readfsqword(0x28u); if ( (unsigned int)regcomp( v4, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0" "-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$", 1LL) ) { v1 = -1; fwrite("Could not compile regex\n", 1LL, 24LL, stderr); } else { v1 = 0; v2 = regexec(v4, a1, 0LL, 0LL, 0LL); if ( v2 ) { if ( v2 != 1 ) { regerror(v2, v4, v5, 100LL); v1 = -1; __fprintf_chk(stderr, 1LL, "Regex match failed: %s\n", v5); } } else { return 1; } } return v1; }
func0: ENDBR64 PUSH R13 MOV EDX,0x1 LEA RSI,[0x102008] PUSH R12 PUSH RBP MOV RBP,RDI SUB RSP,0xb0 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV R13,RSP MOV RDI,R13 CALL 0x001010d0 TEST EAX,EAX JNZ 0x00101380 XOR R8D,R8D XOR ECX,ECX XOR EDX,EDX MOV RSI,RBP MOV RDI,R13 MOV R12D,EAX CALL 0x001010f0 TEST EAX,EAX JZ 0x00101370 CMP EAX,0x1 JZ 0x0010134d LEA R12,[RSP + 0x40] MOV ECX,0x64 MOV RSI,R13 MOV EDI,EAX MOV RDX,R12 CALL 0x001010e0 MOV RCX,R12 MOV ESI,0x1 XOR EAX,EAX MOV RDI,qword ptr [0x00104020] LEA RDX,[0x1020c6] MOV R12D,0xffffffff CALL 0x00101110 LAB_0010134d: MOV RAX,qword ptr [RSP + 0xa8] SUB RAX,qword ptr FS:[0x28] JNZ 0x001013a5 ADD RSP,0xb0 MOV EAX,R12D POP RBP POP R12 POP R13 RET LAB_00101370: MOV R12D,0x1 JMP 0x0010134d LAB_00101380: MOV EDX,0x18 MOV RCX,qword ptr [0x00104020] MOV ESI,0x1 LEA RDI,[0x1020ad] MOV R12D,0xffffffff CALL 0x00101100 JMP 0x0010134d LAB_001013a5: CALL 0x001010b0
int4 func0(char *param_1) { int iVar1; int4 uVar2; 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, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$" ,1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { uVar2 = 1; } else { uVar2 = 0; if (iVar1 != 1) { regerror(iVar1,&rStack_c8,local_88,100); uVar2 = 0xffffffff; __fprintf_chk(stderr,1,"Regex match failed: %s\n",local_88); } } } else { uVar2 = 0xffffffff; fwrite("Could not compile regex\n",1,0x18,stderr); } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,571
func0
#include <stdio.h> #include <regex.h> #include <assert.h>
int func0(const char *Ip) { regex_t regex; int reti; char msgbuf[100]; const char *pattern = "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"; // Compile regex reti = regcomp(&regex, pattern, REG_EXTENDED); if (reti) { fprintf(stderr, "Could not compile regex\n"); return -1; } // Execute regex reti = regexec(&regex, Ip, 0, NULL, 0); if (!reti) { return 1; // Valid IP address } else if (reti == REG_NOMATCH) { return 0; // Invalid IP address } else { regerror(reti, &regex, msgbuf, sizeof(msgbuf)); fprintf(stderr, "Regex match failed: %s\n", msgbuf); return -1; } // Free regex memory regfree(&regex); }
int main() { assert(func0("192.168.0.1") == 1); // Valid IP address assert(func0("110.234.52.124") == 1); // Valid IP address assert(func0("366.1.2.2") == 0); // Invalid IP address return 0; }
O3
c
func0: endbr64 push %r13 mov $0x1,%edx lea 0xd46(%rip),%rsi push %r12 push %rbp mov %rdi,%rbp sub $0xb0,%rsp mov %fs:0x28,%rax mov %rax,0xa8(%rsp) xor %eax,%eax mov %rsp,%r13 mov %r13,%rdi callq 10d0 <regcomp@plt> test %eax,%eax jne 1380 <func0+0xd0> xor %r8d,%r8d xor %ecx,%ecx xor %edx,%edx mov %rbp,%rsi mov %r13,%rdi mov %eax,%r12d callq 10f0 <regexec@plt> test %eax,%eax je 1370 <func0+0xc0> cmp $0x1,%eax je 134d <func0+0x9d> lea 0x40(%rsp),%r12 mov $0x64,%ecx mov %r13,%rsi mov %eax,%edi mov %r12,%rdx callq 10e0 <regerror@plt> mov %r12,%rcx mov $0x1,%esi xor %eax,%eax mov 0x2ce5(%rip),%rdi lea 0xdc3(%rip),%rdx mov $0xffffffff,%r12d callq 1110 <__fprintf_chk@plt> mov 0xa8(%rsp),%rax xor %fs:0x28,%rax jne 13a5 <func0+0xf5> add $0xb0,%rsp mov %r12d,%eax pop %rbp pop %r12 pop %r13 retq mov $0x1,%r12d jmp 134d <func0+0x9d> nopl 0x0(%rax,%rax,1) mov $0x18,%edx mov 0x2c94(%rip),%rcx mov $0x1,%esi lea 0xd54(%rip),%rdi mov $0xffffffff,%r12d callq 1100 <fwrite@plt> jmp 134d <func0+0x9d> callq 10b0 <__stack_chk_fail@plt> nopw 0x0(%rax,%rax,1)
func0: endbr64 push r12 mov edx, 1; cflags lea rsi, pattern; "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?"... push rbp mov rbp, rdi push rbx sub rsp, 0B0h mov rax, fs:28h mov [rsp+0C8h+var_20], rax xor eax, eax mov r12, rsp mov rdi, r12; preg call _regcomp test eax, eax jnz loc_1380 xor r8d, r8d; eflags xor ecx, ecx; pmatch xor edx, edx; nmatch mov rsi, rbp; string mov rdi, r12; preg mov ebx, eax call _regexec test eax, eax jz short loc_1370 cmp eax, 1 jz short loc_134A lea rbx, [rsp+0C8h+errbuf] mov ecx, 64h ; 'd'; errbuf_size mov rsi, r12; preg mov edi, eax; errcode mov rdx, rbx; errbuf call _regerror mov rcx, rbx mov esi, 2 xor eax, eax mov rdi, cs:__bss_start lea rdx, aRegexMatchFail; "Regex match failed: %s\n" call ___fprintf_chk loc_1345: mov ebx, 0FFFFFFFFh loc_134A: mov rax, [rsp+0C8h+var_20] sub rax, fs:28h jnz short loc_139F add rsp, 0B0h mov eax, ebx pop rbx pop rbp pop r12 retn loc_1370: mov ebx, 1 jmp short loc_134A loc_1380: 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_1345 loc_139F: call ___stack_chk_fail
long long func0(char *string) { unsigned int v1; // ebx int v2; // eax regex_t v4; // [rsp+0h] [rbp-C8h] BYREF char errbuf[104]; // [rsp+40h] [rbp-88h] BYREF unsigned long long v6; // [rsp+A8h] [rbp-20h] v6 = __readfsqword(0x28u); if ( regcomp( &v4, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]" "?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$", 1) ) { fwrite("Could not compile regex\n", 1uLL, 0x18uLL, _bss_start); return (unsigned int)-1; } v1 = 0; v2 = regexec(&v4, string, 0LL, 0LL, 0); if ( !v2 ) return 1; if ( v2 != 1 ) { regerror(v2, &v4, errbuf, 0x64uLL); __fprintf_chk(_bss_start, 2LL, "Regex match failed: %s\n", errbuf); return (unsigned int)-1; } return v1; }
func0: ENDBR64 PUSH R12 MOV EDX,0x1 LEA RSI,[0x102008] PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0xb0 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0xa8],RAX XOR EAX,EAX MOV R12,RSP MOV RDI,R12 CALL 0x001010d0 TEST EAX,EAX JNZ 0x00101380 XOR R8D,R8D XOR ECX,ECX XOR EDX,EDX MOV RSI,RBP MOV RDI,R12 MOV EBX,EAX CALL 0x001010f0 TEST EAX,EAX JZ 0x00101370 CMP EAX,0x1 JZ 0x0010134a LEA RBX,[RSP + 0x40] MOV ECX,0x64 MOV RSI,R12 MOV EDI,EAX MOV RDX,RBX CALL 0x001010e0 MOV RCX,RBX MOV ESI,0x2 XOR EAX,EAX MOV RDI,qword ptr [0x00104020] LEA RDX,[0x1020c6] CALL 0x00101110 LAB_00101345: MOV EBX,0xffffffff LAB_0010134a: MOV RAX,qword ptr [RSP + 0xa8] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010139f ADD RSP,0xb0 MOV EAX,EBX POP RBX POP RBP POP R12 RET LAB_00101370: MOV EBX,0x1 JMP 0x0010134a LAB_00101380: MOV RCX,qword ptr [0x00104020] MOV EDX,0x18 MOV ESI,0x1 LEA RDI,[0x1020ad] CALL 0x00101100 JMP 0x00101345 LAB_0010139f: CALL 0x001010b0
int4 func0(char *param_1) { int iVar1; int4 uVar2; 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, "^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$" ,1); if (iVar1 == 0) { iVar1 = regexec(&rStack_c8,param_1,0,(regmatch_t *)0x0,0); if (iVar1 == 0) { uVar2 = 1; goto LAB_0010134a; } uVar2 = 0; if (iVar1 == 1) goto LAB_0010134a; regerror(iVar1,&rStack_c8,local_88,100); __fprintf_chk(stderr,2,"Regex match failed: %s\n",local_88); } else { fwrite("Could not compile regex\n",1,0x18,stderr); } uVar2 = 0xffffffff; LAB_0010134a: if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar2; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
6,572
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int nums[], int size) { for(int i = 0; i < size - 1; i++) { if(nums[i] >= nums[i+1]) return false; } return true; }
int main() { int arr1[] = {-4, -3, -2, -1}; int size1 = sizeof(arr1)/sizeof(arr1[0]); assert(func0(arr1, size1) == true); int arr2[] = {1, 2, 3}; int size2 = sizeof(arr2)/sizeof(arr2[0]); assert(func0(arr2, size2) == true); int arr3[] = {3, 2, 1}; int size3 = sizeof(arr3)/sizeof(arr3[0]); assert(func0(arr3, size3) == false); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp mov %rdi,-0x18(%rbp) mov %esi,-0x1c(%rbp) movl $0x0,-0x4(%rbp) jmp 11c0 <func0+0x57> mov -0x4(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x18(%rbp),%rax add %rdx,%rax mov (%rax),%edx mov -0x4(%rbp),%eax cltq add $0x1,%rax lea 0x0(,%rax,4),%rcx mov -0x18(%rbp),%rax add %rcx,%rax mov (%rax),%eax cmp %eax,%edx jl 11bc <func0+0x53> mov $0x0,%eax jmp 11d0 <func0+0x67> addl $0x1,-0x4(%rbp) mov -0x1c(%rbp),%eax sub $0x1,%eax cmp %eax,-0x4(%rbp) jl 1181 <func0+0x18> mov $0x1,%eax pop %rbp retq
func0: endbr64 push rbp mov rbp, rsp mov [rbp+var_18], rdi mov [rbp+var_1C], esi mov [rbp+var_4], 0 jmp short loc_11C0 loc_1181: mov eax, [rbp+var_4] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rdx mov edx, [rax] mov eax, [rbp+var_4] cdqe add rax, 1 lea rcx, ds:0[rax*4] mov rax, [rbp+var_18] add rax, rcx mov eax, [rax] cmp edx, eax jl short loc_11BC mov eax, 0 jmp short loc_11D0 loc_11BC: add [rbp+var_4], 1 loc_11C0: mov eax, [rbp+var_1C] sub eax, 1 cmp [rbp+var_4], eax jl short loc_1181 mov eax, 1 loc_11D0: pop rbp retn
long long func0(long long a1, int a2) { int i; // [rsp+18h] [rbp-4h] for ( i = 0; i < a2 - 1; ++i ) { if ( *(_DWORD *)(4LL * i + a1) >= *(_DWORD *)(4 * (i + 1LL) + a1) ) return 0LL; } return 1LL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV qword ptr [RBP + -0x18],RDI MOV dword ptr [RBP + -0x1c],ESI MOV dword ptr [RBP + -0x4],0x0 JMP 0x001011c0 LAB_00101181: MOV EAX,dword ptr [RBP + -0x4] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RDX MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x4] CDQE ADD RAX,0x1 LEA RCX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x18] ADD RAX,RCX MOV EAX,dword ptr [RAX] CMP EDX,EAX JL 0x001011bc MOV EAX,0x0 JMP 0x001011d0 LAB_001011bc: ADD dword ptr [RBP + -0x4],0x1 LAB_001011c0: MOV EAX,dword ptr [RBP + -0x1c] SUB EAX,0x1 CMP dword ptr [RBP + -0x4],EAX JL 0x00101181 MOV EAX,0x1 LAB_001011d0: POP RBP RET
int8 func0(long param_1,int param_2) { int local_c; local_c = 0; while( true ) { if (param_2 + -1 <= local_c) { return 1; } if (*(int *)(param_1 + ((long)local_c + 1) * 4) <= *(int *)(param_1 + (long)local_c * 4)) break; local_c = local_c + 1; } return 0; }
6,573
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int nums[], int size) { for(int i = 0; i < size - 1; i++) { if(nums[i] >= nums[i+1]) return false; } return true; }
int main() { int arr1[] = {-4, -3, -2, -1}; int size1 = sizeof(arr1)/sizeof(arr1[0]); assert(func0(arr1, size1) == true); int arr2[] = {1, 2, 3}; int size2 = sizeof(arr2)/sizeof(arr2[0]); assert(func0(arr2, size2) == true); int arr3[] = {3, 2, 1}; int size3 = sizeof(arr3)/sizeof(arr3[0]); assert(func0(arr3, size3) == false); return 0; }
O1
c
func0: endbr64 cmp $0x1,%esi jle 1193 <func0+0x2a> mov %rdi,%rax lea -0x2(%rsi),%edx lea 0x4(%rdi,%rdx,4),%rdx mov 0x4(%rax),%ecx cmp %ecx,(%rax) jge 1199 <func0+0x30> add $0x4,%rax cmp %rdx,%rax jne 117d <func0+0x14> mov $0x1,%eax retq mov $0x1,%eax retq mov $0x0,%eax retq
func0: endbr64 cmp esi, 1 jle short loc_1193 mov rax, rdi lea edx, [rsi-2] lea rdx, [rdi+rdx*4+4] loc_117D: mov ecx, [rax+4] cmp [rax], ecx jge short loc_1199 add rax, 4 cmp rax, rdx jnz short loc_117D mov eax, 1 retn loc_1193: mov eax, 1 retn loc_1199: mov eax, 0 retn
long long func0(_DWORD *a1, int a2) { _DWORD *v2; // rax if ( a2 <= 1 ) return 1LL; v2 = a1; while ( *v2 < v2[1] ) { if ( ++v2 == &a1[a2 - 2 + 1] ) return 1LL; } return 0LL; }
func0: ENDBR64 CMP ESI,0x1 JLE 0x00101193 MOV RAX,RDI LEA EDX,[RSI + -0x2] LEA RDX,[RDI + RDX*0x4 + 0x4] LAB_0010117d: MOV ECX,dword ptr [RAX + 0x4] CMP dword ptr [RAX],ECX JGE 0x00101199 ADD RAX,0x4 CMP RAX,RDX JNZ 0x0010117d MOV EAX,0x1 RET LAB_00101193: MOV EAX,0x1 RET LAB_00101199: MOV EAX,0x0 RET
int8 func0(int *param_1,int param_2) { int *piVar1; if (param_2 < 2) { return 1; } piVar1 = param_1 + (ulong)(param_2 - 2) + 1; do { if (param_1[1] <= *param_1) { return 0; } param_1 = param_1 + 1; } while (param_1 != piVar1); return 1; }
6,574
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int nums[], int size) { for(int i = 0; i < size - 1; i++) { if(nums[i] >= nums[i+1]) return false; } return true; }
int main() { int arr1[] = {-4, -3, -2, -1}; int size1 = sizeof(arr1)/sizeof(arr1[0]); assert(func0(arr1, size1) == true); int arr2[] = {1, 2, 3}; int size2 = sizeof(arr2)/sizeof(arr2[0]); assert(func0(arr2, size2) == true); int arr3[] = {3, 2, 1}; int size3 = sizeof(arr3)/sizeof(arr3[0]); assert(func0(arr3, size3) == false); return 0; }
O2
c
func0: endbr64 cmp $0x1,%esi jle 1170 <func0+0x30> lea -0x2(%rsi),%eax lea 0x4(%rdi,%rax,4),%rax jmp 1161 <func0+0x21> nopl 0x0(%rax,%rax,1) add $0x4,%rdi cmp %rax,%rdi je 1170 <func0+0x30> mov 0x4(%rdi),%edx cmp %edx,(%rdi) jl 1158 <func0+0x18> xor %eax,%eax retq nopl 0x0(%rax,%rax,1) mov $0x1,%eax retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 cmp esi, 1 jle short loc_12C0 lea eax, [rsi-2] lea rax, [rdi+rax*4+4] jmp short loc_12B1 loc_12A8: add rdi, 4 cmp rdi, rax jz short loc_12C0 loc_12B1: mov edx, [rdi+4] cmp [rdi], edx jl short loc_12A8 xor eax, eax retn loc_12C0: mov eax, 1 retn
long long func0(_DWORD *a1, int a2) { long long v2; // rax if ( a2 <= 1 ) return 1LL; v2 = (long long)&a1[a2 - 2 + 1]; while ( *a1 < a1[1] ) { if ( ++a1 == (_DWORD *)v2 ) return 1LL; } return 0LL; }
func0: ENDBR64 CMP ESI,0x1 JLE 0x001012c0 LEA EAX,[RSI + -0x2] LEA RAX,[RDI + RAX*0x4 + 0x4] JMP 0x001012b1 LAB_001012a8: ADD RDI,0x4 CMP RDI,RAX JZ 0x001012c0 LAB_001012b1: MOV EDX,dword ptr [RDI + 0x4] CMP dword ptr [RDI],EDX JL 0x001012a8 XOR EAX,EAX RET LAB_001012c0: MOV EAX,0x1 RET
int8 func0(int *param_1,int param_2) { int *piVar1; if (1 < param_2) { piVar1 = param_1 + (ulong)(param_2 - 2) + 1; do { if (param_1[1] <= *param_1) { return 0; } param_1 = param_1 + 1; } while (param_1 != piVar1); } return 1; }
6,575
func0
#include <stdio.h> #include <stdbool.h> #include <assert.h>
bool func0(int nums[], int size) { for(int i = 0; i < size - 1; i++) { if(nums[i] >= nums[i+1]) return false; } return true; }
int main() { int arr1[] = {-4, -3, -2, -1}; int size1 = sizeof(arr1)/sizeof(arr1[0]); assert(func0(arr1, size1) == true); int arr2[] = {1, 2, 3}; int size2 = sizeof(arr2)/sizeof(arr2[0]); assert(func0(arr2, size2) == true); int arr3[] = {3, 2, 1}; int size3 = sizeof(arr3)/sizeof(arr3[0]); assert(func0(arr3, size3) == false); return 0; }
O3
c
func0: endbr64 cmp $0x1,%esi jle 1178 <func0+0x38> lea -0x2(%rsi),%ecx mov (%rdi),%edx lea 0x4(%rdi),%rax lea 0x8(%rdi,%rcx,4),%rsi jmp 1169 <func0+0x29> nopl 0x0(%rax) add $0x4,%rax cmp %rsi,%rax je 1178 <func0+0x38> mov %edx,%ecx mov (%rax),%edx cmp %ecx,%edx jg 1160 <func0+0x20> xor %eax,%eax retq nopl 0x0(%rax) mov $0x1,%eax retq xchg %ax,%ax
func0: endbr64 cmp esi, 1 jle short loc_1178 lea ecx, [rsi-2] mov edx, [rdi] lea rax, [rdi+4] lea rsi, [rdi+rcx*4+8] jmp short loc_1169 loc_1160: add rax, 4 cmp rax, rsi jz short loc_1178 loc_1169: mov ecx, edx mov edx, [rax] cmp edx, ecx jg short loc_1160 xor eax, eax retn loc_1178: mov eax, 1 retn
long long func0(int *a1, int a2) { int v2; // edx int *v3; // rax long long v4; // rsi int v5; // ecx if ( a2 <= 1 ) return 1LL; v2 = *a1; v3 = a1 + 1; v4 = (long long)&a1[a2 - 2 + 2]; while ( 1 ) { v5 = v2; v2 = *v3; if ( *v3 <= v5 ) break; if ( ++v3 == (int *)v4 ) return 1LL; } return 0LL; }
func0: ENDBR64 CMP ESI,0x1 JLE 0x00101178 LEA ECX,[RSI + -0x2] MOV EDX,dword ptr [RDI] LEA RAX,[RDI + 0x4] LEA RSI,[RDI + RCX*0x4 + 0x8] JMP 0x00101169 LAB_00101160: ADD RAX,0x4 CMP RAX,RSI JZ 0x00101178 LAB_00101169: MOV ECX,EDX MOV EDX,dword ptr [RAX] CMP EDX,ECX JG 0x00101160 XOR EAX,EAX RET LAB_00101178: MOV EAX,0x1 RET
int8 func0(int *param_1,int param_2) { int iVar1; int *piVar2; int iVar3; if (1 < param_2) { piVar2 = param_1 + 1; iVar3 = *param_1; do { iVar1 = *piVar2; if (iVar1 <= iVar3) { return 0; } piVar2 = piVar2 + 1; iVar3 = iVar1; } while (piVar2 != param_1 + (ulong)(param_2 - 2) + 2); } return 1; }
6,576
func0
#include <math.h> #include <assert.h>
int func0(int n) { if (n == 0) { return 1; } if ((n & (n + 1)) == 0) { return n; } int pos = (int)(log2((~n) & -(~n)) + 1); return ((1 << (pos - 1)) | n); }
int main() { assert(func0(21) == 23); assert(func0(11) == 15); assert(func0(15) == 15); return 0; }
O0
c
func0: endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %edi,-0x14(%rbp) cmpl $0x0,-0x14(%rbp) jne 1185 <func0+0x1c> mov $0x1,%eax jmp 11d6 <func0+0x6d> mov -0x14(%rbp),%eax add $0x1,%eax and -0x14(%rbp),%eax test %eax,%eax jne 1197 <func0+0x2e> mov -0x14(%rbp),%eax jmp 11d6 <func0+0x6d> mov -0x14(%rbp),%eax not %eax mov %eax,%edx mov -0x14(%rbp),%eax add $0x1,%eax and %edx,%eax cvtsi2sd %eax,%xmm0 callq 1060 <log2@plt> movsd 0xec9(%rip),%xmm1 addsd %xmm1,%xmm0 cvttsd2si %xmm0,%eax mov %eax,-0x4(%rbp) mov -0x4(%rbp),%eax sub $0x1,%eax mov $0x1,%edx mov %eax,%ecx shl %cl,%edx mov %edx,%eax or -0x14(%rbp),%eax leaveq retq
func0: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_14], edi cmp [rbp+var_14], 0 jnz short loc_1185 mov eax, 1 jmp short locret_11E4 loc_1185: mov eax, [rbp+var_14] add eax, 1 and eax, [rbp+var_14] test eax, eax jnz short loc_1197 mov eax, [rbp+var_14] jmp short locret_11E4 loc_1197: mov eax, [rbp+var_14] not eax mov edx, eax mov eax, [rbp+var_14] add eax, 1 and eax, edx pxor xmm2, xmm2 cvtsi2sd xmm2, eax movq rax, xmm2 movq xmm0, rax; x call _log2 movsd xmm1, cs:qword_2060 addsd xmm0, xmm1 cvttsd2si eax, xmm0 mov [rbp+var_4], eax mov eax, [rbp+var_4] sub eax, 1 mov edx, 1 mov ecx, eax shl edx, cl mov eax, edx or eax, [rbp+var_14] locret_11E4: leave retn
long long func0(unsigned int a1) { if ( !a1 ) return 1LL; if ( (a1 & (a1 + 1)) != 0 ) return a1 | (1 << ((int)(log2((double)(int)(~a1 & (a1 + 1))) + 1.0) - 1)); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV dword ptr [RBP + -0x14],EDI CMP dword ptr [RBP + -0x14],0x0 JNZ 0x00101185 MOV EAX,0x1 JMP 0x001011e4 LAB_00101185: MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 AND EAX,dword ptr [RBP + -0x14] TEST EAX,EAX JNZ 0x00101197 MOV EAX,dword ptr [RBP + -0x14] JMP 0x001011e4 LAB_00101197: MOV EAX,dword ptr [RBP + -0x14] NOT EAX MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x14] ADD EAX,0x1 AND EAX,EDX PXOR XMM2,XMM2 CVTSI2SD XMM2,EAX MOVQ RAX,XMM2 MOVQ XMM0,RAX CALL 0x00101060 MOVSD XMM1,qword ptr [0x00102060] ADDSD XMM0,XMM1 CVTTSD2SI EAX,XMM0 MOV dword ptr [RBP + -0x4],EAX MOV EAX,dword ptr [RBP + -0x4] SUB EAX,0x1 MOV EDX,0x1 MOV ECX,EAX SHL EDX,CL MOV EAX,EDX OR EAX,dword ptr [RBP + -0x14] LAB_001011e4: LEAVE RET
uint func0(uint param_1) { double dVar1; if (param_1 == 0) { param_1 = 1; } else if ((param_1 + 1 & param_1) != 0) { dVar1 = log2((double)(int)(param_1 + 1 & ~param_1)); param_1 = 1 << ((char)(int)(dVar1 + DAT_00102060) - 1U & 0x1f) | param_1; } return param_1; }
6,577
func0
#include <math.h> #include <assert.h>
int func0(int n) { if (n == 0) { return 1; } if ((n & (n + 1)) == 0) { return n; } int pos = (int)(log2((~n) & -(~n)) + 1); return ((1 << (pos - 1)) | n); }
int main() { assert(func0(21) == 23); assert(func0(11) == 15); assert(func0(15) == 15); return 0; }
O1
c
func0: endbr64 mov $0x1,%eax test %edi,%edi je 11ab <func0+0x42> push %rbx mov %edi,%ebx lea 0x1(%rdi),%edx mov %edi,%eax test %edi,%edx jne 1184 <func0+0x1b> pop %rbx retq not %eax and %edx,%eax pxor %xmm0,%xmm0 cvtsi2sd %eax,%xmm0 callq 1060 <log2@plt> addsd 0xee3(%rip),%xmm0 cvttsd2si %xmm0,%eax sub $0x1,%eax bts %eax,%ebx mov %ebx,%eax jmp 1182 <func0+0x19> retq
func0: endbr64 mov eax, 1 test edi, edi jz short locret_11AB push rbx mov ebx, edi lea edx, [rdi+1] mov eax, edi test edx, edi jnz short loc_1184 loc_1182: pop rbx retn loc_1184: not eax and eax, edx pxor xmm0, xmm0 cvtsi2sd xmm0, eax call _log2 addsd xmm0, cs:qword_2058 cvttsd2si edx, xmm0 sub edx, 1 mov eax, ebx bts eax, edx jmp short loc_1182 locret_11AB: retn
int func0(int a1) { int result; // eax double v2; // xmm0_8 result = 1; if ( a1 ) { result = a1; if ( (a1 & (a1 + 1)) != 0 ) { v2 = log2((double)((a1 + 1) & ~a1)); result = a1; _bittestandset(&result, (int)(v2 + 1.0) - 1); } } return result; }
func0: ENDBR64 MOV EAX,0x1 TEST EDI,EDI JZ 0x001011ab PUSH RBX MOV EBX,EDI LEA EDX,[RDI + 0x1] MOV EAX,EDI TEST EDX,EDI JNZ 0x00101184 LAB_00101182: POP RBX RET LAB_00101184: NOT EAX AND EAX,EDX PXOR XMM0,XMM0 CVTSI2SD XMM0,EAX CALL 0x00101060 ADDSD XMM0,qword ptr [0x00102058] CVTTSD2SI EDX,XMM0 SUB EDX,0x1 MOV EAX,EBX BTS EAX,EDX JMP 0x00101182 LAB_001011ab: RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ uint func0(uint param_1) { double dVar1; if (param_1 != 0) { if ((param_1 + 1 & param_1) != 0) { dVar1 = log2((double)(int)(~param_1 & param_1 + 1)); param_1 = param_1 | 1 << ((int)(dVar1 + _DAT_00102058) - 1U & 0x1f); } return param_1; } return 1; }
6,578
func0
#include <math.h> #include <assert.h>
int func0(int n) { if (n == 0) { return 1; } if ((n & (n + 1)) == 0) { return n; } int pos = (int)(log2((~n) & -(~n)) + 1); return ((1 << (pos - 1)) | n); }
int main() { assert(func0(21) == 23); assert(func0(11) == 15); assert(func0(15) == 15); return 0; }
O2
c
func0: endbr64 test %edi,%edi je 1260 <func0+0x10> jmp 1210 <func0.part.0> nopw 0x0(%rax,%rax,1) mov $0x1,%eax retq nopw %cs:0x0(%rax,%rax,1)
func0: endbr64 push r12 mov r12d, 1 test edi, edi jz short loc_117A lea eax, [rdi+1] mov r12d, edi test edi, eax jnz short loc_1180 loc_117A: mov eax, r12d pop r12 retn loc_1180: mov edx, edi pxor xmm0, xmm0 not edx and eax, edx cvtsi2sd xmm0, eax call _log2 addsd xmm0, cs:qword_2008 mov eax, 1 cvttsd2si ecx, xmm0 sub ecx, 1 shl eax, cl or r12d, eax mov eax, r12d pop r12 retn
long long func0(unsigned int a1) { unsigned int v1; // r12d v1 = 1; if ( a1 && (v1 = a1, ((a1 + 1) & a1) != 0) ) return (1 << ((int)(log2((double)(int)(~a1 & (a1 + 1))) + 1.0) - 1)) | a1; else return v1; }
func0: ENDBR64 PUSH R12 MOV R12D,0x1 TEST EDI,EDI JZ 0x0010117a LEA EAX,[RDI + 0x1] MOV R12D,EDI TEST EDI,EAX JNZ 0x00101180 LAB_0010117a: MOV EAX,R12D POP R12 RET LAB_00101180: MOV EDX,EDI PXOR XMM0,XMM0 NOT EDX AND EAX,EDX CVTSI2SD XMM0,EAX CALL 0x00101050 ADDSD XMM0,qword ptr [0x00102008] MOV EAX,0x1 CVTTSD2SI ECX,XMM0 SUB ECX,0x1 SHL EAX,CL OR R12D,EAX MOV EAX,R12D POP R12 RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ uint func0(uint param_1) { uint uVar1; double dVar2; uVar1 = 1; if ((param_1 != 0) && (uVar1 = param_1, (param_1 & param_1 + 1) != 0)) { dVar2 = log2((double)(int)(param_1 + 1 & ~param_1)); return param_1 | 1 << ((char)(int)(dVar2 + _DAT_00102008) - 1U & 0x1f); } return uVar1; }
6,579
func0
#include <math.h> #include <assert.h>
int func0(int n) { if (n == 0) { return 1; } if ((n & (n + 1)) == 0) { return n; } int pos = (int)(log2((~n) & -(~n)) + 1); return ((1 << (pos - 1)) | n); }
int main() { assert(func0(21) == 23); assert(func0(11) == 15); assert(func0(15) == 15); return 0; }
O3
c
func0: endbr64 push %r12 mov $0x1,%r12d test %edi,%edi je 117a <func0+0x1a> lea 0x1(%rdi),%edx mov %edi,%r12d test %edx,%edi jne 1180 <func0+0x20> mov %r12d,%eax pop %r12 retq mov %edi,%eax pxor %xmm0,%xmm0 not %eax and %edx,%eax cvtsi2sd %eax,%xmm0 callq 1050 <log2@plt> addsd 0xe6d(%rip),%xmm0 mov $0x1,%eax cvttsd2si %xmm0,%ecx sub $0x1,%ecx shl %cl,%eax or %eax,%r12d mov %r12d,%eax pop %r12 retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
func0: endbr64 push rbx mov ebx, 1 test edi, edi jz short loc_1177 lea eax, [rdi+1] mov ebx, edi test edi, eax jnz short loc_1180 loc_1177: mov eax, ebx pop rbx retn loc_1180: mov edx, edi pxor xmm0, xmm0 not edx and eax, edx cvtsi2sd xmm0, eax; x call _log2 addsd xmm0, cs:qword_2008 mov eax, 1 cvttsd2si ecx, xmm0 sub ecx, 1 shl eax, cl or ebx, eax mov eax, ebx pop rbx retn
long long func0(unsigned int a1) { unsigned int v1; // ebx v1 = 1; if ( a1 && (v1 = a1, ((a1 + 1) & a1) != 0) ) return (1 << ((int)(log2((double)(int)(~a1 & (a1 + 1))) + 1.0) - 1)) | a1; else return v1; }
func0: ENDBR64 PUSH RBX MOV EBX,0x1 TEST EDI,EDI JZ 0x00101177 LEA EAX,[RDI + 0x1] MOV EBX,EDI TEST EDI,EAX JNZ 0x00101180 LAB_00101177: MOV EAX,EBX POP RBX RET LAB_00101180: MOV EDX,EDI PXOR XMM0,XMM0 NOT EDX AND EAX,EDX CVTSI2SD XMM0,EAX CALL 0x00101050 ADDSD XMM0,qword ptr [0x00102008] MOV EAX,0x1 CVTTSD2SI ECX,XMM0 SUB ECX,0x1 SHL EAX,CL OR EBX,EAX MOV EAX,EBX POP RBX RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ uint func0(uint param_1) { uint uVar1; double dVar2; uVar1 = 1; if ((param_1 != 0) && (uVar1 = param_1, (param_1 & param_1 + 1) != 0)) { dVar2 = log2((double)(int)(param_1 + 1 & ~param_1)); return param_1 | 1 << ((char)(int)(dVar2 + _DAT_00102008) - 1U & 0x1f); } return uVar1; }
6,580
func0
#include <assert.h>
int func0(int num1, int num2, int num3) { int lnum; if ((num1 >= num2) && (num1 >= num3)) { lnum = num1; } else if ((num2 >= num1) && (num2 >= num3)) { lnum = num2; } else { lnum = num3; } return lnum; }
int main() { assert(func0(10, 20, 30) == 30); assert(func0(55, 47, 39) == 55); assert(func0(10, 49, 30) == 49); 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 jl 1172 <func0+0x29> mov -0x14(%rbp),%eax cmp -0x1c(%rbp),%eax jl 1172 <func0+0x29> mov -0x14(%rbp),%eax mov %eax,-0x4(%rbp) jmp 1190 <func0+0x47> mov -0x18(%rbp),%eax cmp -0x14(%rbp),%eax jl 118a <func0+0x41> mov -0x18(%rbp),%eax cmp -0x1c(%rbp),%eax jl 118a <func0+0x41> mov -0x18(%rbp),%eax mov %eax,-0x4(%rbp) jmp 1190 <func0+0x47> 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] jl short loc_1172 mov eax, [rbp+var_14] cmp eax, [rbp+var_1C] jl short loc_1172 mov eax, [rbp+var_14] mov [rbp+var_4], eax jmp short loc_1190 loc_1172: mov eax, [rbp+var_18] cmp eax, [rbp+var_14] jl short loc_118A mov eax, [rbp+var_18] cmp eax, [rbp+var_1C] jl short loc_118A mov eax, [rbp+var_18] mov [rbp+var_4], eax jmp short loc_1190 loc_118A: mov eax, [rbp+var_1C] mov [rbp+var_4], eax loc_1190: mov eax, [rbp+var_4] pop rbp retn
long long func0(signed int a1, signed int a2, signed int a3) { if ( a1 < a2 || a1 < a3 ) { if ( a2 < a1 || 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] JL 0x00101172 MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x1c] JL 0x00101172 MOV EAX,dword ptr [RBP + -0x14] MOV dword ptr [RBP + -0x4],EAX JMP 0x00101190 LAB_00101172: MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x14] JL 0x0010118a MOV EAX,dword ptr [RBP + -0x18] CMP EAX,dword ptr [RBP + -0x1c] JL 0x0010118a MOV EAX,dword ptr [RBP + -0x18] MOV dword ptr [RBP + -0x4],EAX JMP 0x00101190 LAB_0010118a: MOV EAX,dword ptr [RBP + -0x1c] MOV dword ptr [RBP + -0x4],EAX LAB_00101190: MOV EAX,dword ptr [RBP + -0x4] POP RBP RET
int func0(int param_1,int param_2,int param_3) { int local_c; if ((((param_1 < param_2) || (local_c = param_1, param_1 < param_3)) && (local_c = param_3, param_1 <= param_2)) && (param_3 <= param_2)) { local_c = param_2; } return local_c; }
6,581
func0
#include <assert.h>
int func0(int num1, int num2, int num3) { int lnum; if ((num1 >= num2) && (num1 >= num3)) { lnum = num1; } else if ((num2 >= num1) && (num2 >= num3)) { lnum = num2; } else { lnum = num3; } return lnum; }
int main() { assert(func0(10, 20, 30) == 30); assert(func0(55, 47, 39) == 55); assert(func0(10, 49, 30) == 49); return 0; }
O1
c
func0: endbr64 mov %edi,%eax cmp %edx,%esi mov %edx,%ecx cmovge %esi,%ecx cmp %ecx,%edi jge 1146 <func0+0x1d> cmp %edx,%edi cmovl %edx,%eax cmp %eax,%esi mov %edx,%eax cmovge %esi,%eax retq
func0: endbr64 mov eax, edi cmp esi, edx mov ecx, edx cmovge ecx, esi cmp edi, ecx jge short locret_1146 cmp edi, edx cmovl eax, edx cmp esi, eax mov eax, edx cmovge eax, esi locret_1146: retn
long long func0(int a1, int a2, int a3) { long long result; // rax int v4; // ecx bool v5; // cc result = (unsigned int)a1; v4 = a3; if ( a2 >= a3 ) v4 = a2; if ( a1 < v4 ) { if ( a1 < a3 ) LODWORD(result) = a3; v5 = a2 < (int)result; result = (unsigned int)a3; if ( !v5 ) return (unsigned int)a2; } return result; }
func0: ENDBR64 MOV EAX,EDI CMP ESI,EDX MOV ECX,EDX CMOVGE ECX,ESI CMP EDI,ECX JGE 0x00101146 CMP EDI,EDX CMOVL EAX,EDX CMP ESI,EAX MOV EAX,EDX CMOVGE EAX,ESI LAB_00101146: RET
int func0(int param_1,int param_2,int param_3) { int iVar1; iVar1 = param_3; if (param_3 <= param_2) { iVar1 = param_2; } if (param_1 < iVar1) { iVar1 = param_1; if (param_1 < param_3) { iVar1 = param_3; } param_1 = param_3; if (iVar1 <= param_2) { param_1 = param_2; } } return param_1; }