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,682 | func0 |
#include <assert.h>
| int func0(int array_nums[], int size) {
int count_even = 0;
for (int i = 0; i < size; i++) {
if (array_nums[i] % 2 == 0) {
count_even++;
}
}
return count_even;
}
| int main() {
int array1[] = {1, 2, 3, 5, 7, 8, 9, 10};
int size1 = sizeof(array1) / sizeof(array1[0]);
assert(func0(array1, size1) == 3);
int array2[] = {10, 15, 14, 13, -18, 12, -20};
int size2 = sizeof(array2) / sizeof(array2[0]);
assert(func0(array2, size2) == 5);
int array3[] = {1, 2, 4, 8, 9};
int size3 = sizeof(array3) / sizeof(array3[0]);
assert(func0(array3, size3) == 3);
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 1368 <func0+0x38>
lea -0x1(%rsi),%eax
xor %r8d,%r8d
lea 0x4(%rdi,%rax,4),%rdx
nopl 0x0(%rax,%rax,1)
mov (%rdi),%eax
and $0x1,%eax
cmp $0x1,%eax
adc $0x0,%r8d
add $0x4,%rdi
cmp %rdx,%rdi
jne 1348 <func0+0x18>
mov %r8d,%eax
retq
nopl 0x0(%rax)
xor %r8d,%r8d
mov %r8d,%eax
retq
| func0:
endbr64
test esi, esi
jle short loc_1358
lea eax, [rsi-1]
xor r8d, r8d
lea rdx, [rdi+rax*4+4]
nop dword ptr [rax+rax+00h]
loc_1338:
mov eax, [rdi]
and eax, 1
cmp eax, 1
adc r8d, 0
add rdi, 4
cmp rdi, rdx
jnz short loc_1338
mov eax, r8d
retn
loc_1358:
xor r8d, r8d
mov eax, r8d
retn | long long func0(_DWORD *a1, int a2)
{
unsigned int v2; // r8d
long long v3; // rdx
if ( a2 <= 0 )
return 0LL;
v2 = 0;
v3 = (long long)&a1[a2 - 1 + 1];
do
v2 += (*a1++ & 1) == 0;
while ( a1 != (_DWORD *)v3 );
return v2;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x00101358
LEA EAX,[RSI + -0x1]
XOR R8D,R8D
LEA RDX,[RDI + RAX*0x4 + 0x4]
NOP dword ptr [RAX + RAX*0x1]
LAB_00101338:
MOV EAX,dword ptr [RDI]
AND EAX,0x1
CMP EAX,0x1
ADC R8D,0x0
ADD RDI,0x4
CMP RDI,RDX
JNZ 0x00101338
MOV EAX,R8D
RET
LAB_00101358:
XOR R8D,R8D
MOV EAX,R8D
RET | int func0(uint *param_1,int param_2)
{
uint *puVar1;
int iVar2;
if (0 < param_2) {
iVar2 = 0;
puVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
iVar2 = iVar2 + (uint)((*param_1 & 1) == 0);
param_1 = param_1 + 1;
} while (param_1 != puVar1);
return iVar2;
}
return 0;
} |
6,683 | func0 |
#include <assert.h>
| int func0(int array_nums[], int size) {
int count_even = 0;
for (int i = 0; i < size; i++) {
if (array_nums[i] % 2 == 0) {
count_even++;
}
}
return count_even;
}
| int main() {
int array1[] = {1, 2, 3, 5, 7, 8, 9, 10};
int size1 = sizeof(array1) / sizeof(array1[0]);
assert(func0(array1, size1) == 3);
int array2[] = {10, 15, 14, 13, -18, 12, -20};
int size2 = sizeof(array2) / sizeof(array2[0]);
assert(func0(array2, size2) == 5);
int array3[] = {1, 2, 4, 8, 9};
int size3 = sizeof(array3) / sizeof(array3[0]);
assert(func0(array3, size3) == 3);
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 13b8 <func0+0xd8>
lea -0x1(%rsi),%eax
cmp $0x3,%eax
jbe 13c1 <func0+0xe1>
mov %esi,%edx
pxor %xmm1,%xmm1
movdqa 0xd7a(%rip),%xmm3
mov %rdi,%rax
shr $0x2,%edx
movdqa %xmm1,%xmm2
shl $0x4,%rdx
add %rdi,%rdx
nopw 0x0(%rax,%rax,1)
movdqu (%rax),%xmm0
add $0x10,%rax
pand %xmm3,%xmm0
pcmpeqd %xmm2,%xmm0
psubd %xmm0,%xmm1
cmp %rdx,%rax
jne 1320 <func0+0x40>
movdqa %xmm1,%xmm0
mov %esi,%edx
psrldq $0x8,%xmm0
and $0xfffffffc,%edx
paddd %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrldq $0x4,%xmm0
paddd %xmm0,%xmm1
movd %xmm1,%eax
test $0x3,%sil
je 13c0 <func0+0xe0>
movslq %edx,%rcx
mov (%rdi,%rcx,4),%ecx
and $0x1,%ecx
cmp $0x1,%ecx
lea 0x1(%rdx),%ecx
adc $0x0,%eax
cmp %esi,%ecx
jge 13ba <func0+0xda>
movslq %ecx,%rcx
mov (%rdi,%rcx,4),%ecx
and $0x1,%ecx
cmp $0x1,%ecx
lea 0x2(%rdx),%ecx
adc $0x0,%eax
cmp %ecx,%esi
jle 13ba <func0+0xda>
movslq %ecx,%rcx
mov (%rdi,%rcx,4),%ecx
and $0x1,%ecx
cmp $0x1,%ecx
adc $0x0,%eax
add $0x3,%edx
cmp %edx,%esi
jle 13ba <func0+0xda>
movslq %edx,%rdx
mov (%rdi,%rdx,4),%edx
and $0x1,%edx
cmp $0x1,%edx
adc $0x0,%eax
retq
nopl 0x0(%rax)
xor %eax,%eax
retq
nopl 0x0(%rax,%rax,1)
retq
xor %edx,%edx
xor %eax,%eax
jmp 1362 <func0+0x82>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov ecx, esi
test esi, esi
jle loc_1208
lea eax, [rsi-1]
cmp eax, 2
jbe loc_1211
mov edx, esi
pxor xmm1, xmm1
movdqa xmm3, cs:xmmword_2010
mov rax, rdi
shr edx, 2
movdqa xmm2, xmm1
shl rdx, 4
add rdx, rdi
nop dword ptr [rax+00000000h]
loc_1180:
movdqu xmm0, xmmword ptr [rax]
add rax, 10h
pand xmm0, xmm3
pcmpeqd xmm0, xmm2
psubd xmm1, xmm0
cmp rdx, rax
jnz short loc_1180
movdqa xmm0, xmm1
mov edx, ecx
psrldq xmm0, 8
and edx, 0FFFFFFFCh
paddd xmm1, xmm0
movdqa xmm0, xmm1
psrldq xmm0, 4
paddd xmm1, xmm0
movd eax, xmm1
test cl, 3
jz short locret_1210
loc_11C1:
movsxd rsi, edx
lea r8, ds:0[rsi*4]
mov esi, [rdi+rsi*4]
and esi, 1
cmp esi, 1
lea esi, [rdx+1]
adc eax, 0
cmp ecx, esi
jle short locret_120A
mov esi, [rdi+r8+4]
and esi, 1
cmp esi, 1
adc eax, 0
add edx, 2
cmp ecx, edx
jle short locret_120A
mov edx, [rdi+r8+8]
and edx, 1
cmp edx, 1
adc eax, 0
retn
loc_1208:
xor eax, eax
locret_120A:
retn
locret_1210:
retn
loc_1211:
xor edx, edx
xor eax, eax
jmp short loc_11C1 | long long func0(const __m128i *a1, int a2)
{
__m128i v2; // xmm1
__m128i si128; // xmm3
const __m128i *v4; // rax
__m128i v5; // xmm0
signed int v6; // edx
__m128i v7; // xmm1
long long result; // rax
long long v9; // r8
if ( a2 <= 0 )
return 0LL;
if ( (unsigned int)(a2 - 1) <= 2 )
{
v6 = 0;
LODWORD(result) = 0;
}
else
{
v2 = 0LL;
si128 = _mm_load_si128((const __m128i *)&xmmword_2010);
v4 = a1;
do
{
v5 = _mm_loadu_si128(v4++);
v2 = _mm_sub_epi32(v2, _mm_cmpeq_epi32(_mm_and_si128(v5, si128), (__m128i)0LL));
}
while ( &a1[(unsigned int)a2 >> 2] != v4 );
v6 = a2 & 0xFFFFFFFC;
v7 = _mm_add_epi32(v2, _mm_srli_si128(v2, 8));
result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v7, _mm_srli_si128(v7, 4)));
if ( (a2 & 3) == 0 )
return result;
}
v9 = v6;
result = ((a1->m128i_i32[v9] & 1) == 0) + (unsigned int)result;
if ( a2 > v6 + 1 )
{
result = ((a1->m128i_i32[v9 + 1] & 1) == 0) + (unsigned int)result;
if ( a2 > v6 + 2 )
return ((a1->m128i_i32[v9 + 2] & 1) == 0) + (unsigned int)result;
}
return result;
} | func0:
ENDBR64
MOV ECX,ESI
TEST ESI,ESI
JLE 0x00101208
LEA EAX,[RSI + -0x1]
CMP EAX,0x2
JBE 0x00101211
MOV EDX,ESI
PXOR XMM1,XMM1
MOVDQA XMM3,xmmword ptr [0x00102010]
MOV RAX,RDI
SHR EDX,0x2
MOVDQA XMM2,XMM1
SHL RDX,0x4
ADD RDX,RDI
NOP dword ptr [RAX]
LAB_00101180:
MOVDQU XMM0,xmmword ptr [RAX]
ADD RAX,0x10
PAND XMM0,XMM3
PCMPEQD XMM0,XMM2
PSUBD XMM1,XMM0
CMP RDX,RAX
JNZ 0x00101180
MOVDQA XMM0,XMM1
MOV EDX,ECX
PSRLDQ XMM0,0x8
AND EDX,0xfffffffc
PADDD XMM1,XMM0
MOVDQA XMM0,XMM1
PSRLDQ XMM0,0x4
PADDD XMM1,XMM0
MOVD EAX,XMM1
TEST CL,0x3
JZ 0x00101210
LAB_001011c1:
MOVSXD RSI,EDX
LEA R8,[RSI*0x4]
MOV ESI,dword ptr [RDI + RSI*0x4]
AND ESI,0x1
CMP ESI,0x1
LEA ESI,[RDX + 0x1]
ADC EAX,0x0
CMP ECX,ESI
JLE 0x0010120a
MOV ESI,dword ptr [RDI + R8*0x1 + 0x4]
AND ESI,0x1
CMP ESI,0x1
ADC EAX,0x0
ADD EDX,0x2
CMP ECX,EDX
JLE 0x0010120a
MOV EDX,dword ptr [RDI + R8*0x1 + 0x8]
AND EDX,0x1
CMP EDX,0x1
ADC EAX,0x0
RET
LAB_00101208:
XOR EAX,EAX
LAB_0010120a:
RET
LAB_00101210:
RET
LAB_00101211:
XOR EDX,EDX
XOR EAX,EAX
JMP 0x001011c1 | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
int func0(uint *param_1,uint param_2)
{
uint *puVar1;
uint *puVar2;
uint *puVar3;
uint *puVar4;
uint uVar5;
int iVar6;
int iVar7;
int iVar8;
int iVar9;
if ((int)param_2 < 1) {
iVar6 = 0;
}
else {
if (param_2 - 1 < 3) {
uVar5 = 0;
iVar6 = 0;
}
else {
iVar6 = 0;
iVar7 = 0;
iVar8 = 0;
iVar9 = 0;
puVar4 = param_1;
do {
uVar5 = *puVar4;
puVar1 = puVar4 + 1;
puVar2 = puVar4 + 2;
puVar3 = puVar4 + 3;
puVar4 = puVar4 + 4;
iVar6 = iVar6 + (uint)((uVar5 & _DAT_00102010) == 0);
iVar7 = iVar7 + (uint)((*puVar1 & _UNK_00102014) == 0);
iVar8 = iVar8 + (uint)((*puVar2 & _UNK_00102018) == 0);
iVar9 = iVar9 + (uint)((*puVar3 & _UNK_0010201c) == 0);
} while (param_1 + (ulong)(param_2 >> 2) * 4 != puVar4);
uVar5 = param_2 & 0xfffffffc;
iVar6 = iVar6 + iVar8 + iVar7 + iVar9;
if ((param_2 & 3) == 0) {
return iVar6;
}
}
iVar6 = iVar6 + (uint)((param_1[(int)uVar5] & 1) == 0);
if ((int)(uVar5 + 1) < (int)param_2) {
iVar6 = iVar6 + (uint)((param_1[(long)(int)uVar5 + 1] & 1) == 0);
if ((int)(uVar5 + 2) < (int)param_2) {
return iVar6 + (uint)((param_1[(long)(int)uVar5 + 2] & 1) == 0);
}
}
}
return iVar6;
} |
6,684 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key1;
int key2;
int value;
} dictItem;
int compare(const void *a, const void *b) {
dictItem *itemA = (dictItem *)a;
dictItem *itemB = (dictItem *)b;
int mulA = itemA->key1 * itemA->key2;
int mulB = itemB->key1 * itemB->key2;
return mulA - mulB;
}
| dictItem* func0(dictItem arr[], int size) {
qsort(arr, size, sizeof(dictItem), compare);
return arr;
}
| int main() {
dictItem arr1[] = {{5, 6, 3}, {2, 3, 9}, {8, 4, 10}, {6, 4, 12}};
dictItem sorted1[] = {{2, 3, 9}, {6, 4, 12}, {5, 6, 3}, {8, 4, 10}};
func0(arr1, 4);
for (int i = 0; i < 4; i++) {
assert(arr1[i].key1 == sorted1[i].key1 && arr1[i].key2 == sorted1[i].key2 && arr1[i].value == sorted1[i].value);
}
dictItem arr2[] = {{6, 7, 4}, {3, 4, 10}, {9, 5, 11}, {7, 5, 13}};
dictItem sorted2[] = {{3, 4, 10}, {7, 5, 13}, {6, 7, 4}, {9, 5, 11}};
func0(arr2, 4);
for (int i = 0; i < 4; i++) {
assert(arr2[i].key1 == sorted2[i].key1 && arr2[i].key2 == sorted2[i].key2 && arr2[i].value == sorted2[i].value);
}
dictItem arr3[] = {{7, 8, 5}, {4, 5, 11}, {10, 6, 12}, {8, 6, 14}};
dictItem sorted3[] = {{4, 5, 11}, {8, 6, 14}, {7, 8, 5}, {10, 6, 12}};
func0(arr3, 4);
for (int i = 0; i < 4; i++) {
assert(arr3[i].key1 == sorted3[i].key1 && arr3[i].key2 == sorted3[i].key2 && arr3[i].value == sorted3[i].value);
}
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
mov %rdi,-0x8(%rbp)
mov %esi,-0xc(%rbp)
mov -0xc(%rbp),%eax
movslq %eax,%rsi
mov -0x8(%rbp),%rax
lea -0x72(%rip),%rcx
mov $0xc,%edx
mov %rax,%rdi
callq 1070 <qsort@plt>
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 10h
mov [rbp+base], rdi
mov [rbp+var_C], esi
mov eax, [rbp+var_C]
movsxd rsi, eax; nmemb
mov rax, [rbp+base]
lea rdx, compare
mov rcx, rdx; compar
mov edx, 0Ch; size
mov rdi, rax; base
call _qsort
mov rax, [rbp+base]
leave
retn | void * func0(void *a1, int a2)
{
qsort(a1, a2, 0xCuLL, compare);
return a1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x10
MOV qword ptr [RBP + -0x8],RDI
MOV dword ptr [RBP + -0xc],ESI
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x8]
LEA RDX,[0x101189]
MOV RCX,RDX
MOV EDX,0xc
MOV RDI,RAX
CALL 0x00101070
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(void *param_1,int param_2)
{
qsort(param_1,(long)param_2,0xc,compare);
return param_1;
} |
6,685 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key1;
int key2;
int value;
} dictItem;
int compare(const void *a, const void *b) {
dictItem *itemA = (dictItem *)a;
dictItem *itemB = (dictItem *)b;
int mulA = itemA->key1 * itemA->key2;
int mulB = itemB->key1 * itemB->key2;
return mulA - mulB;
}
| dictItem* func0(dictItem arr[], int size) {
qsort(arr, size, sizeof(dictItem), compare);
return arr;
}
| int main() {
dictItem arr1[] = {{5, 6, 3}, {2, 3, 9}, {8, 4, 10}, {6, 4, 12}};
dictItem sorted1[] = {{2, 3, 9}, {6, 4, 12}, {5, 6, 3}, {8, 4, 10}};
func0(arr1, 4);
for (int i = 0; i < 4; i++) {
assert(arr1[i].key1 == sorted1[i].key1 && arr1[i].key2 == sorted1[i].key2 && arr1[i].value == sorted1[i].value);
}
dictItem arr2[] = {{6, 7, 4}, {3, 4, 10}, {9, 5, 11}, {7, 5, 13}};
dictItem sorted2[] = {{3, 4, 10}, {7, 5, 13}, {6, 7, 4}, {9, 5, 11}};
func0(arr2, 4);
for (int i = 0; i < 4; i++) {
assert(arr2[i].key1 == sorted2[i].key1 && arr2[i].key2 == sorted2[i].key2 && arr2[i].value == sorted2[i].value);
}
dictItem arr3[] = {{7, 8, 5}, {4, 5, 11}, {10, 6, 12}, {8, 6, 14}};
dictItem sorted3[] = {{4, 5, 11}, {8, 6, 14}, {7, 8, 5}, {10, 6, 12}};
func0(arr3, 4);
for (int i = 0; i < 4; i++) {
assert(arr3[i].key1 == sorted3[i].key1 && arr3[i].key2 == sorted3[i].key2 && arr3[i].value == sorted3[i].value);
}
return 0;
}
| O1 | c | func0:
endbr64
push %rbx
mov %rdi,%rbx
movslq %esi,%rsi
lea -0x25(%rip),%rcx
mov $0xc,%edx
callq 1070 <qsort@plt>
mov %rbx,%rax
pop %rbx
retq
| func0:
endbr64
push rbx
mov rbx, rdi
movsxd rsi, esi
lea rcx, compare
mov edx, 0Ch
call _qsort
mov rax, rbx
pop rbx
retn | long long func0(long long a1, int a2)
{
qsort(a1, a2, 12LL, compare);
return a1;
} | func0:
ENDBR64
PUSH RBX
MOV RBX,RDI
MOVSXD RSI,ESI
LEA RCX,[0x101189]
MOV EDX,0xc
CALL 0x00101070
MOV RAX,RBX
POP RBX
RET | void * func0(void *param_1,int param_2)
{
qsort(param_1,(long)param_2,0xc,compare);
return param_1;
} |
6,686 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key1;
int key2;
int value;
} dictItem;
int compare(const void *a, const void *b) {
dictItem *itemA = (dictItem *)a;
dictItem *itemB = (dictItem *)b;
int mulA = itemA->key1 * itemA->key2;
int mulB = itemB->key1 * itemB->key2;
return mulA - mulB;
}
| dictItem* func0(dictItem arr[], int size) {
qsort(arr, size, sizeof(dictItem), compare);
return arr;
}
| int main() {
dictItem arr1[] = {{5, 6, 3}, {2, 3, 9}, {8, 4, 10}, {6, 4, 12}};
dictItem sorted1[] = {{2, 3, 9}, {6, 4, 12}, {5, 6, 3}, {8, 4, 10}};
func0(arr1, 4);
for (int i = 0; i < 4; i++) {
assert(arr1[i].key1 == sorted1[i].key1 && arr1[i].key2 == sorted1[i].key2 && arr1[i].value == sorted1[i].value);
}
dictItem arr2[] = {{6, 7, 4}, {3, 4, 10}, {9, 5, 11}, {7, 5, 13}};
dictItem sorted2[] = {{3, 4, 10}, {7, 5, 13}, {6, 7, 4}, {9, 5, 11}};
func0(arr2, 4);
for (int i = 0; i < 4; i++) {
assert(arr2[i].key1 == sorted2[i].key1 && arr2[i].key2 == sorted2[i].key2 && arr2[i].value == sorted2[i].value);
}
dictItem arr3[] = {{7, 8, 5}, {4, 5, 11}, {10, 6, 12}, {8, 6, 14}};
dictItem sorted3[] = {{4, 5, 11}, {8, 6, 14}, {7, 8, 5}, {10, 6, 12}};
func0(arr3, 4);
for (int i = 0; i < 4; i++) {
assert(arr3[i].key1 == sorted3[i].key1 && arr3[i].key2 == sorted3[i].key2 && arr3[i].value == sorted3[i].value);
}
return 0;
}
| O2 | c | func0:
endbr64
push %r12
movslq %esi,%rsi
mov %rdi,%r12
mov $0xc,%edx
lea -0x38(%rip),%rcx
callq 1070 <qsort@plt>
mov %r12,%rax
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
push r12
movsxd rsi, esi
mov r12, rdi
mov edx, 0Ch
lea rcx, compare
call _qsort
mov rax, r12
pop r12
retn | long long func0(long long a1, int a2)
{
qsort(a1, a2, 12LL, compare);
return a1;
} | func0:
ENDBR64
PUSH R12
MOVSXD RSI,ESI
MOV R12,RDI
MOV EDX,0xc
LEA RCX,[0x101550]
CALL 0x00101070
MOV RAX,R12
POP R12
RET | void * func0(void *param_1,int param_2)
{
qsort(param_1,(long)param_2,0xc,compare);
return param_1;
} |
6,687 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key1;
int key2;
int value;
} dictItem;
int compare(const void *a, const void *b) {
dictItem *itemA = (dictItem *)a;
dictItem *itemB = (dictItem *)b;
int mulA = itemA->key1 * itemA->key2;
int mulB = itemB->key1 * itemB->key2;
return mulA - mulB;
}
| dictItem* func0(dictItem arr[], int size) {
qsort(arr, size, sizeof(dictItem), compare);
return arr;
}
| int main() {
dictItem arr1[] = {{5, 6, 3}, {2, 3, 9}, {8, 4, 10}, {6, 4, 12}};
dictItem sorted1[] = {{2, 3, 9}, {6, 4, 12}, {5, 6, 3}, {8, 4, 10}};
func0(arr1, 4);
for (int i = 0; i < 4; i++) {
assert(arr1[i].key1 == sorted1[i].key1 && arr1[i].key2 == sorted1[i].key2 && arr1[i].value == sorted1[i].value);
}
dictItem arr2[] = {{6, 7, 4}, {3, 4, 10}, {9, 5, 11}, {7, 5, 13}};
dictItem sorted2[] = {{3, 4, 10}, {7, 5, 13}, {6, 7, 4}, {9, 5, 11}};
func0(arr2, 4);
for (int i = 0; i < 4; i++) {
assert(arr2[i].key1 == sorted2[i].key1 && arr2[i].key2 == sorted2[i].key2 && arr2[i].value == sorted2[i].value);
}
dictItem arr3[] = {{7, 8, 5}, {4, 5, 11}, {10, 6, 12}, {8, 6, 14}};
dictItem sorted3[] = {{4, 5, 11}, {8, 6, 14}, {7, 8, 5}, {10, 6, 12}};
func0(arr3, 4);
for (int i = 0; i < 4; i++) {
assert(arr3[i].key1 == sorted3[i].key1 && arr3[i].key2 == sorted3[i].key2 && arr3[i].value == sorted3[i].value);
}
return 0;
}
| O3 | c | func0:
endbr64
push %r12
movslq %esi,%rsi
mov %rdi,%r12
mov $0xc,%edx
lea -0x38(%rip),%rcx
callq 1070 <qsort@plt>
mov %r12,%rax
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
push rbx
movsxd rsi, esi; nmemb
mov rbx, rdi
lea rcx, compare; compar
mov edx, 0Ch; size
call _qsort
mov rax, rbx
pop rbx
retn | void * func0(void *a1, int a2)
{
qsort(a1, a2, 0xCuLL, compare);
return a1;
} | func0:
ENDBR64
PUSH RBX
MOVSXD RSI,ESI
MOV RBX,RDI
LEA RCX,[0x101470]
MOV EDX,0xc
CALL 0x00101070
MOV RAX,RBX
POP RBX
RET | void * func0(void *param_1,int param_2)
{
qsort(param_1,(long)param_2,0xc,compare);
return param_1;
} |
6,688 | func0 | #include <assert.h>
#include <string.h>
| int func0(const char* str1, const char* str2) {
int count = 0;
int length = strlen(str1);
for (int i = 0; i < length; i++) {
if (str1[i] != str2[i]) {
count++;
}
}
if (count % 2 == 0) {
return (count / 2);
} else {
return -1; // Used -1 to indicate "Not Possible"
}
}
| int main() {
assert(func0("1101", "1110") == 1);
assert(func0("1111", "0100") == -1);
assert(func0("1110000", "0001101") == 3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
movl $0x0,-0xc(%rbp)
mov -0x18(%rbp),%rax
mov %rax,%rdi
callq 1060 <strlen@plt>
mov %eax,-0x4(%rbp)
movl $0x0,-0x8(%rbp)
jmp 11c8 <func0+0x5f>
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%edx
mov -0x8(%rbp),%eax
movslq %eax,%rcx
mov -0x20(%rbp),%rax
add %rcx,%rax
movzbl (%rax),%eax
cmp %al,%dl
je 11c4 <func0+0x5b>
addl $0x1,-0xc(%rbp)
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
cmp -0x4(%rbp),%eax
jl 119c <func0+0x33>
mov -0xc(%rbp),%eax
and $0x1,%eax
test %eax,%eax
jne 11e8 <func0+0x7f>
mov -0xc(%rbp),%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
jmp 11ed <func0+0x84>
mov $0xffffffff,%eax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+s], rdi
mov [rbp+var_20], rsi
mov [rbp+var_C], 0
mov rax, [rbp+s]
mov rdi, rax; s
call _strlen
mov [rbp+var_4], eax
mov [rbp+var_8], 0
jmp short loc_11C8
loc_119C:
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx edx, byte ptr [rax]
mov eax, [rbp+var_8]
movsxd rcx, eax
mov rax, [rbp+var_20]
add rax, rcx
movzx eax, byte ptr [rax]
cmp dl, al
jz short loc_11C4
add [rbp+var_C], 1
loc_11C4:
add [rbp+var_8], 1
loc_11C8:
mov eax, [rbp+var_8]
cmp eax, [rbp+var_4]
jl short loc_119C
mov eax, [rbp+var_C]
and eax, 1
test eax, eax
jnz short loc_11E8
mov eax, [rbp+var_C]
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
jmp short locret_11ED
loc_11E8:
mov eax, 0FFFFFFFFh
locret_11ED:
leave
retn | long long func0(const char *a1, long long a2)
{
int v3; // [rsp+14h] [rbp-Ch]
int i; // [rsp+18h] [rbp-8h]
int v5; // [rsp+1Ch] [rbp-4h]
v3 = 0;
v5 = strlen(a1);
for ( i = 0; i < v5; ++i )
{
if ( a1[i] != *(_BYTE *)(i + a2) )
++v3;
}
if ( (v3 & 1) != 0 )
return 0xFFFFFFFFLL;
else
return (unsigned int)(v3 / 2);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOV qword ptr [RBP + -0x18],RDI
MOV qword ptr [RBP + -0x20],RSI
MOV dword ptr [RBP + -0xc],0x0
MOV RAX,qword ptr [RBP + -0x18]
MOV RDI,RAX
CALL 0x00101060
MOV dword ptr [RBP + -0x4],EAX
MOV dword ptr [RBP + -0x8],0x0
JMP 0x001011c8
LAB_0010119c:
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EDX,byte ptr [RAX]
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RCX,EAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RCX
MOVZX EAX,byte ptr [RAX]
CMP DL,AL
JZ 0x001011c4
ADD dword ptr [RBP + -0xc],0x1
LAB_001011c4:
ADD dword ptr [RBP + -0x8],0x1
LAB_001011c8:
MOV EAX,dword ptr [RBP + -0x8]
CMP EAX,dword ptr [RBP + -0x4]
JL 0x0010119c
MOV EAX,dword ptr [RBP + -0xc]
AND EAX,0x1
TEST EAX,EAX
JNZ 0x001011e8
MOV EAX,dword ptr [RBP + -0xc]
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
JMP 0x001011ed
LAB_001011e8:
MOV EAX,0xffffffff
LAB_001011ed:
LEAVE
RET | int func0(char *param_1,long param_2)
{
int iVar1;
size_t sVar2;
uint local_14;
int local_10;
local_14 = 0;
sVar2 = strlen(param_1);
for (local_10 = 0; local_10 < (int)sVar2; local_10 = local_10 + 1) {
if (param_1[local_10] != *(char *)(param_2 + local_10)) {
local_14 = local_14 + 1;
}
}
if ((local_14 & 1) == 0) {
iVar1 = (int)local_14 / 2;
}
else {
iVar1 = -1;
}
return iVar1;
} |
6,689 | func0 | #include <assert.h>
#include <string.h>
| int func0(const char* str1, const char* str2) {
int count = 0;
int length = strlen(str1);
for (int i = 0; i < length; i++) {
if (str1[i] != str2[i]) {
count++;
}
}
if (count % 2 == 0) {
return (count / 2);
} else {
return -1; // Used -1 to indicate "Not Possible"
}
}
| int main() {
assert(func0("1101", "1110") == 1);
assert(func0("1111", "0100") == -1);
assert(func0("1110000", "0001101") == 3);
return 0;
}
| O1 | c | func0:
endbr64
mov %rdi,%r8
mov $0xffffffffffffffff,%rcx
mov $0x0,%eax
repnz scas %es:(%rdi),%al
not %rcx
sub $0x1,%rcx
test %ecx,%ecx
jle 11a3 <func0+0x5a>
lea -0x1(%rcx),%edi
mov $0x0,%eax
mov $0x0,%edx
jmp 117b <func0+0x32>
mov %rcx,%rax
movzbl (%rsi,%rax,1),%ecx
cmp %cl,(%r8,%rax,1)
setne %cl
movzbl %cl,%ecx
add %ecx,%edx
lea 0x1(%rax),%rcx
cmp %rdi,%rax
jne 1178 <func0+0x2f>
test $0x1,%dl
jne 11aa <func0+0x61>
mov %edx,%eax
shr $0x1f,%eax
add %edx,%eax
sar %eax
retq
mov $0x0,%edx
jmp 1199 <func0+0x50>
mov $0xffffffff,%eax
retq
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
mov rbx, rdi
mov rbp, rsi
call _strlen
test eax, eax
jle short loc_11C3
lea esi, [rax-1]
mov eax, 0
mov edx, 0
jmp short loc_1194
loc_1191:
mov rax, rcx
loc_1194:
movzx edi, byte ptr [rbp+rax+0]
cmp [rbx+rax], dil
setnz cl
movzx ecx, cl
add edx, ecx
lea rcx, [rax+1]
cmp rax, rsi
jnz short loc_1191
test dl, 1
jnz short loc_11CA
loc_11B3:
mov eax, edx
shr eax, 1Fh
add eax, edx
sar eax, 1
loc_11BC:
add rsp, 8
pop rbx
pop rbp
retn
loc_11C3:
mov edx, 0
jmp short loc_11B3
loc_11CA:
mov eax, 0FFFFFFFFh
jmp short loc_11BC | long long func0(long long a1, long long a2)
{
int v3; // eax
long long v4; // rsi
long long v5; // rax
int v6; // edx
v3 = strlen();
if ( v3 <= 0 )
{
v6 = 0;
return (unsigned int)(v6 / 2);
}
v4 = (unsigned int)(v3 - 1);
v5 = 0LL;
v6 = 0;
while ( 1 )
{
v6 += *(_BYTE *)(a1 + v5) != *(_BYTE *)(a2 + v5);
if ( v5 == v4 )
break;
++v5;
}
if ( (v6 & 1) == 0 )
return (unsigned int)(v6 / 2);
return 0xFFFFFFFFLL;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBX,RDI
MOV RBP,RSI
CALL 0x00101060
TEST EAX,EAX
JLE 0x001011c3
LEA ESI,[RAX + -0x1]
MOV EAX,0x0
MOV EDX,0x0
JMP 0x00101194
LAB_00101191:
MOV RAX,RCX
LAB_00101194:
MOVZX EDI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],DIL
SETNZ CL
MOVZX ECX,CL
ADD EDX,ECX
LEA RCX,[RAX + 0x1]
CMP RAX,RSI
JNZ 0x00101191
TEST DL,0x1
JNZ 0x001011ca
LAB_001011b3:
MOV EAX,EDX
SHR EAX,0x1f
ADD EAX,EDX
SAR EAX,0x1
LAB_001011bc:
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_001011c3:
MOV EDX,0x0
JMP 0x001011b3
LAB_001011ca:
MOV EAX,0xffffffff
JMP 0x001011bc | int func0(char *param_1,long param_2)
{
size_t sVar1;
ulong uVar2;
uint uVar3;
bool bVar4;
sVar1 = strlen(param_1);
if ((int)sVar1 < 1) {
uVar3 = 0;
}
else {
uVar3 = 0;
uVar2 = 0;
do {
uVar3 = uVar3 + (param_1[uVar2] != *(char *)(param_2 + uVar2));
bVar4 = uVar2 != (int)sVar1 - 1;
uVar2 = uVar2 + 1;
} while (bVar4);
if ((uVar3 & 1) != 0) {
return -1;
}
}
return (int)uVar3 / 2;
} |
6,690 | func0 | #include <assert.h>
#include <string.h>
| int func0(const char* str1, const char* str2) {
int count = 0;
int length = strlen(str1);
for (int i = 0; i < length; i++) {
if (str1[i] != str2[i]) {
count++;
}
}
if (count % 2 == 0) {
return (count / 2);
} else {
return -1; // Used -1 to indicate "Not Possible"
}
}
| int main() {
assert(func0("1101", "1110") == 1);
assert(func0("1111", "0100") == -1);
assert(func0("1110000", "0001101") == 3);
return 0;
}
| O2 | c | func0:
endbr64
push %rbp
mov %rsi,%rbp
push %rbx
mov %rdi,%rbx
sub $0x8,%rsp
callq 1060 <strlen@plt>
test %eax,%eax
jle 1290 <func0+0x60>
lea -0x1(%rax),%esi
xor %edx,%edx
xor %eax,%eax
jmp 125b <func0+0x2b>
nopw 0x0(%rax,%rax,1)
mov %rcx,%rax
xor %ecx,%ecx
movzbl 0x0(%rbp,%rax,1),%edi
cmp %dil,(%rbx,%rax,1)
setne %cl
add %ecx,%edx
lea 0x1(%rax),%rcx
cmp %rax,%rsi
jne 1258 <func0+0x28>
mov %edx,%eax
sar %eax
and $0x1,%edx
mov $0xffffffff,%edx
cmovne %edx,%eax
add $0x8,%rsp
pop %rbx
pop %rbp
retq
nopw 0x0(%rax,%rax,1)
add $0x8,%rsp
xor %eax,%eax
pop %rbx
pop %rbp
retq
nopl 0x0(%rax)
| func0:
endbr64
push rbp
mov rbp, rsi
push rbx
mov rbx, rdi
sub rsp, 8
call _strlen
test eax, eax
jle short loc_1290
lea esi, [rax-1]
xor edx, edx
xor eax, eax
jmp short loc_125B
loc_1258:
mov rax, rcx
loc_125B:
xor ecx, ecx
movzx edi, byte ptr [rbp+rax+0]
cmp [rbx+rax], dil
setnz cl
add edx, ecx
lea rcx, [rax+1]
cmp rsi, rax
jnz short loc_1258
mov eax, edx
sar eax, 1
and edx, 1
mov edx, 0FFFFFFFFh
cmovnz eax, edx
add rsp, 8
pop rbx
pop rbp
retn
loc_1290:
add rsp, 8
xor eax, eax
pop rbx
pop rbp
retn | long long func0(long long a1, long long a2)
{
int v3; // eax
long long v4; // rsi
int v5; // edx
long long i; // rax
long long result; // rax
v3 = strlen();
if ( v3 <= 0 )
return 0LL;
v4 = (unsigned int)(v3 - 1);
v5 = 0;
for ( i = 0LL; ; ++i )
{
v5 += *(_BYTE *)(a1 + i) != *(_BYTE *)(a2 + i);
if ( v4 == i )
break;
}
result = (unsigned int)(v5 >> 1);
if ( (v5 & 1) != 0 )
return 0xFFFFFFFFLL;
return result;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSI
PUSH RBX
MOV RBX,RDI
SUB RSP,0x8
CALL 0x00101060
TEST EAX,EAX
JLE 0x00101290
LEA ESI,[RAX + -0x1]
XOR EDX,EDX
XOR EAX,EAX
JMP 0x0010125b
LAB_00101258:
MOV RAX,RCX
LAB_0010125b:
XOR ECX,ECX
MOVZX EDI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],DIL
SETNZ CL
ADD EDX,ECX
LEA RCX,[RAX + 0x1]
CMP RSI,RAX
JNZ 0x00101258
MOV EAX,EDX
SAR EAX,0x1
AND EDX,0x1
MOV EDX,0xffffffff
CMOVNZ EAX,EDX
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_00101290:
ADD RSP,0x8
XOR EAX,EAX
POP RBX
POP RBP
RET | int func0(char *param_1,long param_2)
{
int iVar1;
size_t sVar2;
ulong uVar3;
uint uVar4;
bool bVar5;
sVar2 = strlen(param_1);
if ((int)sVar2 < 1) {
return 0;
}
uVar4 = 0;
uVar3 = 0;
do {
uVar4 = uVar4 + (param_1[uVar3] != *(char *)(param_2 + uVar3));
bVar5 = (int)sVar2 - 1 != uVar3;
uVar3 = uVar3 + 1;
} while (bVar5);
iVar1 = (int)uVar4 >> 1;
if ((uVar4 & 1) != 0) {
iVar1 = -1;
}
return iVar1;
} |
6,691 | func0 | #include <assert.h>
#include <string.h>
| int func0(const char* str1, const char* str2) {
int count = 0;
int length = strlen(str1);
for (int i = 0; i < length; i++) {
if (str1[i] != str2[i]) {
count++;
}
}
if (count % 2 == 0) {
return (count / 2);
} else {
return -1; // Used -1 to indicate "Not Possible"
}
}
| int main() {
assert(func0("1101", "1110") == 1);
assert(func0("1111", "0100") == -1);
assert(func0("1110000", "0001101") == 3);
return 0;
}
| O3 | c | func0:
endbr64
push %rbp
mov %rsi,%rbp
push %rbx
mov %rdi,%rbx
sub $0x8,%rsp
callq 1060 <strlen@plt>
test %eax,%eax
jle 1500 <func0+0x2d0>
lea -0x1(%rax),%edx
cmp $0xe,%edx
jbe 1509 <func0+0x2d9>
mov %eax,%ecx
movdqa 0xe6d(%rip),%xmm6
xor %edx,%edx
pxor %xmm1,%xmm1
shr $0x4,%ecx
pxor %xmm5,%xmm5
pxor %xmm4,%xmm4
shl $0x4,%rcx
nopl 0x0(%rax,%rax,1)
movdqu 0x0(%rbp,%rdx,1),%xmm7
movdqu (%rbx,%rdx,1),%xmm0
movdqa %xmm5,%xmm3
add $0x10,%rdx
pcmpeqb %xmm7,%xmm0
pandn %xmm6,%xmm0
pcmpgtb %xmm0,%xmm3
movdqa %xmm0,%xmm2
punpcklbw %xmm3,%xmm2
punpckhbw %xmm3,%xmm0
movdqa %xmm4,%xmm3
pcmpgtw %xmm2,%xmm3
movdqa %xmm2,%xmm7
punpcklwd %xmm3,%xmm7
punpckhwd %xmm3,%xmm2
movdqa %xmm0,%xmm3
paddd %xmm7,%xmm1
paddd %xmm2,%xmm1
movdqa %xmm4,%xmm2
pcmpgtw %xmm0,%xmm2
punpcklwd %xmm2,%xmm3
punpckhwd %xmm2,%xmm0
paddd %xmm3,%xmm1
paddd %xmm0,%xmm1
cmp %rcx,%rdx
jne 1280 <func0+0x50>
movdqa %xmm1,%xmm0
mov %eax,%ecx
psrldq $0x8,%xmm0
and $0xfffffff0,%ecx
paddd %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrldq $0x4,%xmm1
paddd %xmm1,%xmm0
movd %xmm0,%edx
test $0xf,%al
je 14e4 <func0+0x2b4>
movslq %ecx,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x1(%rcx),%esi
cmp %eax,%esi
jge 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl (%rbx,%rsi,1),%edi
cmp %dil,0x0(%rbp,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x2(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x3(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x4(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x5(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x6(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x7(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x8(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0x9(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0xa(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0xb(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0xc(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
movzbl %sil,%esi
add %esi,%edx
lea 0xd(%rcx),%esi
cmp %esi,%eax
jle 14e4 <func0+0x2b4>
movslq %esi,%rsi
movzbl 0x0(%rbp,%rsi,1),%edi
cmp %dil,(%rbx,%rsi,1)
setne %sil
add $0xe,%ecx
movzbl %sil,%esi
add %esi,%edx
cmp %ecx,%eax
jle 14e4 <func0+0x2b4>
movslq %ecx,%rcx
movzbl 0x0(%rbp,%rcx,1),%eax
cmp %al,(%rbx,%rcx,1)
setne %al
movzbl %al,%eax
add %eax,%edx
mov %edx,%eax
sar %eax
and $0x1,%edx
mov $0xffffffff,%edx
cmovne %edx,%eax
add $0x8,%rsp
pop %rbx
pop %rbp
retq
nopw 0x0(%rax,%rax,1)
add $0x8,%rsp
xor %eax,%eax
pop %rbx
pop %rbp
retq
xor %ecx,%ecx
xor %edx,%edx
jmpq 1313 <func0+0xe3>
nopw %cs:0x0(%rax,%rax,1)
nopl 0x0(%rax)
| func0:
endbr64
push rbp
mov rbp, rsi
push rbx
mov rbx, rdi
sub rsp, 8
call _strlen
test eax, eax
jle loc_1470
mov rdx, rax
lea eax, [rax-1]
cmp eax, 0Eh
jbe loc_1479
mov ecx, edx
pxor xmm1, xmm1
pxor xmm5, xmm5
xor eax, eax
shr ecx, 4
pxor xmm4, xmm4
shl rcx, 4
nop dword ptr [rax+rax+00h]
loc_1278:
movdqu xmm0, xmmword ptr [rbx+rax]
movdqu xmm7, xmmword ptr [rbp+rax+0]
movdqa xmm3, xmm5
add rax, 10h
pcmpeqb xmm0, xmm7
pcmpeqb xmm0, xmm5
pcmpgtb xmm3, xmm0
movdqa xmm2, xmm0
punpcklbw xmm2, xmm3
punpckhbw xmm0, xmm3
movdqa xmm3, xmm4
pcmpgtw xmm3, xmm2
movdqa xmm6, xmm2
punpcklwd xmm6, xmm3
punpckhwd xmm2, xmm3
movdqa xmm3, xmm0
psubd xmm1, xmm6
psubd xmm1, xmm2
movdqa xmm2, xmm4
pcmpgtw xmm2, xmm0
punpcklwd xmm3, xmm2
punpckhwd xmm0, xmm2
psubd xmm1, xmm3
psubd xmm1, xmm0
cmp rax, rcx
jnz short loc_1278
movdqa xmm0, xmm1
mov eax, edx
psrldq xmm0, 8
and eax, 0FFFFFFF0h
paddd xmm0, xmm1
mov ecx, eax
movdqa xmm2, xmm0
psrldq xmm2, 4
paddd xmm0, xmm2
movd edi, xmm0
movdqa xmm0, xmm1
psrldq xmm1, 8
paddd xmm1, xmm0
test dl, 0Fh
jz loc_1459
loc_131B:
mov esi, edx
sub esi, eax
lea r8d, [rsi-1]
cmp r8d, 6
jbe loc_13BA
movq xmm2, qword ptr [rbp+rax+0]
movq xmm0, qword ptr [rbx+rax]
pcmpeqb xmm0, xmm2
pxor xmm2, xmm2
pcmpeqb xmm0, xmm2
pcmpgtb xmm2, xmm0
movdqa xmm3, xmm0
punpcklbw xmm3, xmm2
punpcklbw xmm0, xmm2
pxor xmm2, xmm2
movdqa xmm4, xmm2
movdqa xmm5, xmm3
pshufd xmm0, xmm0, 4Eh ; 'N'
pcmpgtw xmm4, xmm3
pcmpgtw xmm2, xmm0
punpcklwd xmm5, xmm4
punpcklwd xmm3, xmm4
psubd xmm1, xmm5
pshufd xmm3, xmm3, 4Eh ; 'N'
psubd xmm1, xmm3
movdqa xmm3, xmm0
punpcklwd xmm0, xmm2
punpcklwd xmm3, xmm2
pshufd xmm0, xmm0, 4Eh ; 'N'
psubd xmm1, xmm3
psubd xmm1, xmm0
movd edi, xmm1
pshufd xmm7, xmm1, 0E5h
movd eax, xmm7
add edi, eax
mov eax, esi
and eax, 0FFFFFFF8h
add ecx, eax
and esi, 7
jz loc_1459
loc_13BA:
movsxd rax, ecx
movzx esi, byte ptr [rbp+rax+0]
cmp [rbx+rax], sil
jz short loc_13CB
add edi, 1
loc_13CB:
lea eax, [rcx+1]
cmp edx, eax
jle loc_1459
cdqe
movzx esi, byte ptr [rbp+rax+0]
cmp [rbx+rax], sil
jz short loc_13E6
add edi, 1
loc_13E6:
lea eax, [rcx+2]
cmp edx, eax
jle short loc_1459
cdqe
movzx esi, byte ptr [rbx+rax]
cmp [rbp+rax+0], sil
jz short loc_13FD
add edi, 1
loc_13FD:
lea eax, [rcx+3]
cmp edx, eax
jle short loc_1459
cdqe
movzx esi, byte ptr [rbp+rax+0]
cmp [rbx+rax], sil
jz short loc_1414
add edi, 1
loc_1414:
lea eax, [rcx+4]
cmp edx, eax
jle short loc_1459
cdqe
movzx esi, byte ptr [rbx+rax]
cmp [rbp+rax+0], sil
jz short loc_142B
add edi, 1
loc_142B:
lea eax, [rcx+5]
cmp edx, eax
jle short loc_1459
cdqe
movzx esi, byte ptr [rbp+rax+0]
cmp [rbx+rax], sil
jz short loc_1442
add edi, 1
loc_1442:
add ecx, 6
cmp edx, ecx
jle short loc_1459
movsxd rcx, ecx
movzx eax, byte ptr [rbp+rcx+0]
cmp [rbx+rcx], al
jz short loc_1459
add edi, 1
loc_1459:
test dil, 1
jnz short loc_1488
mov eax, edi
shr eax, 1Fh
add eax, edi
sar eax, 1
loc_1468:
add rsp, 8
pop rbx
pop rbp
retn
loc_1470:
add rsp, 8
xor eax, eax
pop rbx
pop rbp
retn
loc_1479:
pxor xmm1, xmm1
xor eax, eax
xor ecx, ecx
xor edi, edi
jmp loc_131B
loc_1488:
mov eax, 0FFFFFFFFh
jmp short loc_1468 | long long func0(const char *a1, long long a2)
{
int v4; // eax
int v5; // edx
__m128i v6; // xmm1
long long v7; // rax
__m128i v8; // xmm0
__m128i v9; // xmm7
__m128i v10; // xmm0
__m128i v11; // xmm3
__m128i v12; // xmm2
__m128i v13; // xmm0
__m128i v14; // xmm3
__m128i v15; // xmm1
__m128i v16; // xmm2
long long v17; // rax
__m128i v18; // xmm0
signed int v19; // ecx
int v20; // edi
__m128i v21; // xmm1
int v22; // esi
__m128i v23; // xmm0
__m128i v24; // xmm3
__m128i v25; // xmm0
__m128i v26; // xmm2
__m128i v27; // xmm3
__m128i v28; // xmm1
int v29; // ecx
v4 = strlen(a1);
if ( v4 <= 0 )
return 0LL;
v5 = v4;
if ( (unsigned int)(v4 - 1) <= 0xE )
{
v21 = 0LL;
v17 = 0LL;
v19 = 0;
v20 = 0;
goto LABEL_6;
}
v6 = 0LL;
v7 = 0LL;
do
{
v8 = _mm_loadu_si128((const __m128i *)&a1[v7]);
v9 = _mm_loadu_si128((const __m128i *)(a2 + v7));
v7 += 16LL;
v10 = _mm_cmpeq_epi8(_mm_cmpeq_epi8(v8, v9), (__m128i)0LL);
v11 = _mm_cmpgt_epi8((__m128i)0LL, v10);
v12 = _mm_unpacklo_epi8(v10, v11);
v13 = _mm_unpackhi_epi8(v10, v11);
v14 = _mm_cmpgt_epi16((__m128i)0LL, v12);
v15 = _mm_sub_epi32(_mm_sub_epi32(v6, _mm_unpacklo_epi16(v12, v14)), _mm_unpackhi_epi16(v12, v14));
v16 = _mm_cmpgt_epi16((__m128i)0LL, v13);
v6 = _mm_sub_epi32(_mm_sub_epi32(v15, _mm_unpacklo_epi16(v13, v16)), _mm_unpackhi_epi16(v13, v16));
}
while ( v7 != 16LL * ((unsigned int)v5 >> 4) );
v17 = v5 & 0xFFFFFFF0;
v18 = _mm_add_epi32(_mm_srli_si128(v6, 8), v6);
v19 = v5 & 0xFFFFFFF0;
v20 = _mm_cvtsi128_si32(_mm_add_epi32(v18, _mm_srli_si128(v18, 4)));
v21 = v18;
if ( (v5 & 0xF) != 0 )
{
LABEL_6:
v22 = v5 - v17;
if ( (unsigned int)(v5 - v17 - 1) <= 6 )
goto LABEL_8;
v23 = _mm_cmpeq_epi8(
_mm_cmpeq_epi8(_mm_loadl_epi64((const __m128i *)&a1[v17]), _mm_loadl_epi64((const __m128i *)(a2 + v17))),
(__m128i)0LL);
v24 = _mm_unpacklo_epi8(v23, _mm_cmpgt_epi8((__m128i)0LL, v23));
v25 = _mm_shuffle_epi32(v24, 78);
v26 = _mm_cmpgt_epi16((__m128i)0LL, v25);
v27 = _mm_unpacklo_epi16(v24, _mm_cmpgt_epi16((__m128i)0LL, v24));
v28 = _mm_sub_epi32(
_mm_sub_epi32(
_mm_sub_epi32(_mm_sub_epi32(v21, v27), _mm_shuffle_epi32(v27, 78)),
_mm_unpacklo_epi16(v25, v26)),
_mm_shuffle_epi32(_mm_unpacklo_epi16(v25, v26), 78));
v20 = _mm_cvtsi128_si32(_mm_shuffle_epi32(v28, 229)) + _mm_cvtsi128_si32(v28);
v19 += v22 & 0xFFFFFFF8;
if ( (v22 & 7) != 0 )
{
LABEL_8:
if ( a1[v19] != *(_BYTE *)(a2 + v19) )
++v20;
if ( v5 > v19 + 1 )
{
if ( a1[v19 + 1] != *(_BYTE *)(a2 + v19 + 1) )
++v20;
if ( v5 > v19 + 2 )
{
if ( *(_BYTE *)(a2 + v19 + 2) != a1[v19 + 2] )
++v20;
if ( v5 > v19 + 3 )
{
if ( a1[v19 + 3] != *(_BYTE *)(a2 + v19 + 3) )
++v20;
if ( v5 > v19 + 4 )
{
if ( *(_BYTE *)(a2 + v19 + 4) != a1[v19 + 4] )
++v20;
if ( v5 > v19 + 5 )
{
if ( a1[v19 + 5] != *(_BYTE *)(a2 + v19 + 5) )
++v20;
v29 = v19 + 6;
if ( v5 > v29 && a1[v29] != *(_BYTE *)(a2 + v29) )
++v20;
}
}
}
}
}
}
}
if ( (v20 & 1) != 0 )
return 0xFFFFFFFFLL;
else
return (unsigned int)(v20 / 2);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSI
PUSH RBX
MOV RBX,RDI
SUB RSP,0x8
CALL 0x00101060
TEST EAX,EAX
JLE 0x00101470
MOV RDX,RAX
LEA EAX,[RAX + -0x1]
CMP EAX,0xe
JBE 0x00101479
MOV ECX,EDX
PXOR XMM1,XMM1
PXOR XMM5,XMM5
XOR EAX,EAX
SHR ECX,0x4
PXOR XMM4,XMM4
SHL RCX,0x4
NOP dword ptr [RAX + RAX*0x1]
LAB_00101278:
MOVDQU XMM0,xmmword ptr [RBX + RAX*0x1]
MOVDQU XMM7,xmmword ptr [RBP + RAX*0x1]
MOVDQA XMM3,XMM5
ADD RAX,0x10
PCMPEQB XMM0,XMM7
PCMPEQB XMM0,XMM5
PCMPGTB XMM3,XMM0
MOVDQA XMM2,XMM0
PUNPCKLBW XMM2,XMM3
PUNPCKHBW XMM0,XMM3
MOVDQA XMM3,XMM4
PCMPGTW XMM3,XMM2
MOVDQA XMM6,XMM2
PUNPCKLWD XMM6,XMM3
PUNPCKHWD XMM2,XMM3
MOVDQA XMM3,XMM0
PSUBD XMM1,XMM6
PSUBD XMM1,XMM2
MOVDQA XMM2,XMM4
PCMPGTW XMM2,XMM0
PUNPCKLWD XMM3,XMM2
PUNPCKHWD XMM0,XMM2
PSUBD XMM1,XMM3
PSUBD XMM1,XMM0
CMP RAX,RCX
JNZ 0x00101278
MOVDQA XMM0,XMM1
MOV EAX,EDX
PSRLDQ XMM0,0x8
AND EAX,0xfffffff0
PADDD XMM0,XMM1
MOV ECX,EAX
MOVDQA XMM2,XMM0
PSRLDQ XMM2,0x4
PADDD XMM0,XMM2
MOVD EDI,XMM0
MOVDQA XMM0,XMM1
PSRLDQ XMM1,0x8
PADDD XMM1,XMM0
TEST DL,0xf
JZ 0x00101459
LAB_0010131b:
MOV ESI,EDX
SUB ESI,EAX
LEA R8D,[RSI + -0x1]
CMP R8D,0x6
JBE 0x001013ba
MOVQ XMM2,qword ptr [RBP + RAX*0x1]
MOVQ XMM0,qword ptr [RBX + RAX*0x1]
PCMPEQB XMM0,XMM2
PXOR XMM2,XMM2
PCMPEQB XMM0,XMM2
PCMPGTB XMM2,XMM0
MOVDQA XMM3,XMM0
PUNPCKLBW XMM3,XMM2
PUNPCKLBW XMM0,XMM2
PXOR XMM2,XMM2
MOVDQA XMM4,XMM2
MOVDQA XMM5,XMM3
PSHUFD XMM0,XMM0,0x4e
PCMPGTW XMM4,XMM3
PCMPGTW XMM2,XMM0
PUNPCKLWD XMM5,XMM4
PUNPCKLWD XMM3,XMM4
PSUBD XMM1,XMM5
PSHUFD XMM3,XMM3,0x4e
PSUBD XMM1,XMM3
MOVDQA XMM3,XMM0
PUNPCKLWD XMM0,XMM2
PUNPCKLWD XMM3,XMM2
PSHUFD XMM0,XMM0,0x4e
PSUBD XMM1,XMM3
PSUBD XMM1,XMM0
MOVD EDI,XMM1
PSHUFD XMM7,XMM1,0xe5
MOVD EAX,XMM7
ADD EDI,EAX
MOV EAX,ESI
AND EAX,0xfffffff8
ADD ECX,EAX
AND ESI,0x7
JZ 0x00101459
LAB_001013ba:
MOVSXD RAX,ECX
MOVZX ESI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],SIL
JZ 0x001013cb
ADD EDI,0x1
LAB_001013cb:
LEA EAX,[RCX + 0x1]
CMP EDX,EAX
JLE 0x00101459
CDQE
MOVZX ESI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],SIL
JZ 0x001013e6
ADD EDI,0x1
LAB_001013e6:
LEA EAX,[RCX + 0x2]
CMP EDX,EAX
JLE 0x00101459
CDQE
MOVZX ESI,byte ptr [RBX + RAX*0x1]
CMP byte ptr [RBP + RAX*0x1],SIL
JZ 0x001013fd
ADD EDI,0x1
LAB_001013fd:
LEA EAX,[RCX + 0x3]
CMP EDX,EAX
JLE 0x00101459
CDQE
MOVZX ESI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],SIL
JZ 0x00101414
ADD EDI,0x1
LAB_00101414:
LEA EAX,[RCX + 0x4]
CMP EDX,EAX
JLE 0x00101459
CDQE
MOVZX ESI,byte ptr [RBX + RAX*0x1]
CMP byte ptr [RBP + RAX*0x1],SIL
JZ 0x0010142b
ADD EDI,0x1
LAB_0010142b:
LEA EAX,[RCX + 0x5]
CMP EDX,EAX
JLE 0x00101459
CDQE
MOVZX ESI,byte ptr [RBP + RAX*0x1]
CMP byte ptr [RBX + RAX*0x1],SIL
JZ 0x00101442
ADD EDI,0x1
LAB_00101442:
ADD ECX,0x6
CMP EDX,ECX
JLE 0x00101459
MOVSXD RCX,ECX
MOVZX EAX,byte ptr [RBP + RCX*0x1]
CMP byte ptr [RBX + RCX*0x1],AL
JZ 0x00101459
ADD EDI,0x1
LAB_00101459:
TEST DIL,0x1
JNZ 0x00101488
MOV EAX,EDI
SHR EAX,0x1f
ADD EAX,EDI
SAR EAX,0x1
LAB_00101468:
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_00101470:
ADD RSP,0x8
XOR EAX,EAX
POP RBX
POP RBP
RET
LAB_00101479:
PXOR XMM1,XMM1
XOR EAX,EAX
XOR ECX,ECX
XOR EDI,EDI
JMP 0x0010131b
LAB_00101488:
MOV EAX,0xffffffff
JMP 0x00101468 | int func0(char *param_1,long param_2)
{
char *pcVar1;
char *pcVar2;
int8 uVar3;
bool bVar4;
bool bVar5;
bool bVar6;
bool bVar7;
bool bVar8;
bool bVar9;
bool bVar10;
bool bVar11;
int auVar12 [14];
int auVar13 [12];
unkbyte10 Var14;
int auVar15 [12];
int auVar16 [14];
int auVar17 [12];
int auVar18 [16];
int auVar19 [16];
int auVar20 [16];
int auVar21 [12];
unkbyte9 Var22;
int6 uVar23;
int4 uVar24;
int2 uVar25;
uint uVar26;
uint uVar27;
size_t sVar28;
long lVar29;
uint uVar30;
short sVar31;
int4 uVar32;
int iVar33;
uint uVar34;
int auVar39 [12];
char cVar53;
short sVar54;
char cVar55;
char cVar56;
char cVar57;
byte bVar58;
int auVar43 [16];
int auVar50 [16];
int iVar59;
int iVar60;
int iVar61;
int iVar62;
int iVar63;
char cVar67;
char cVar68;
char cVar69;
char cVar70;
char cVar71;
char cVar72;
short sVar74;
short sVar75;
int auVar65 [16];
int auVar76 [16];
int auVar81 [16];
int auVar88 [16];
int auVar91 [16];
int auVar95 [16];
int auVar98 [16];
int6 uVar35;
int8 uVar36;
int auVar38 [12];
int auVar44 [16];
int auVar37 [12];
int auVar45 [16];
int auVar51 [16];
int auVar46 [16];
int auVar40 [14];
int auVar42 [16];
int auVar47 [16];
int auVar52 [16];
int auVar48 [16];
int auVar41 [16];
int auVar49 [16];
int auVar64 [12];
int auVar66 [16];
long lVar73;
int auVar77 [16];
int auVar78 [16];
int auVar92 [16];
int auVar82 [16];
int auVar79 [16];
int auVar83 [16];
int auVar89 [16];
int auVar93 [16];
int auVar84 [16];
int auVar80 [16];
int auVar85 [16];
int auVar90 [16];
int auVar94 [16];
int auVar86 [16];
int auVar87 [16];
int auVar96 [16];
int auVar97 [16];
int auVar99 [16];
int auVar100 [16];
sVar28 = strlen(param_1);
uVar26 = (uint)sVar28;
if ((int)uVar26 < 1) {
return 0;
}
if (uVar26 - 1 < 0xf) {
iVar61 = 0;
iVar62 = 0;
uVar27 = 0;
uVar34 = 0;
}
else {
iVar59 = 0;
iVar60 = 0;
iVar61 = 0;
iVar62 = 0;
lVar29 = 0;
do {
pcVar1 = param_1 + lVar29;
pcVar2 = (char *)(param_2 + lVar29);
lVar29 = lVar29 + 0x10;
bVar4 = *pcVar1 != *pcVar2;
bVar8 = pcVar1[8] != pcVar2[8];
bVar9 = pcVar1[9] != pcVar2[9];
bVar10 = pcVar1[10] != pcVar2[10];
bVar11 = pcVar1[0xb] != pcVar2[0xb];
cVar57 = -(pcVar1[7] != pcVar2[7]);
uVar25 = CONCAT11(-(pcVar1[7] != pcVar2[7]),cVar57);
uVar24 = CONCAT31(CONCAT21(uVar25,-(pcVar1[6] != pcVar2[6])),-(pcVar1[6] != pcVar2[6]));
uVar23 = CONCAT51(CONCAT41(uVar24,-(pcVar1[5] != pcVar2[5])),-(pcVar1[5] != pcVar2[5]));
Var22 = CONCAT72(CONCAT61(uVar23,-(pcVar1[4] != pcVar2[4])),
CONCAT11(-(pcVar1[4] != pcVar2[4]),cVar57));
lVar73 = (long)((unkuint9)Var22 >> 8);
Var14 = CONCAT91(CONCAT81(lVar73,-(pcVar1[3] != pcVar2[3])),-(pcVar1[3] != pcVar2[3]));
auVar13._2_10_ = Var14;
auVar13[1] = -(pcVar1[2] != pcVar2[2]);
auVar13[0] = -(pcVar1[2] != pcVar2[2]);
auVar12._2_12_ = auVar13;
auVar12[1] = -(pcVar1[1] != pcVar2[1]);
auVar12[0] = -(pcVar1[1] != pcVar2[1]);
auVar65._0_2_ = CONCAT11(-bVar4,-bVar4);
auVar65._2_14_ = auVar12;
uVar32 = CONCAT13(-bVar9,CONCAT12(-bVar9,CONCAT11(-bVar8,-bVar8)));
uVar35 = CONCAT15(-bVar10,CONCAT14(-bVar10,uVar32));
uVar36 = CONCAT17(-bVar11,CONCAT16(-bVar11,uVar35));
auVar37._0_10_ =
CONCAT19(-(pcVar1[0xc] != pcVar2[0xc]),CONCAT18(-(pcVar1[0xc] != pcVar2[0xc]),uVar36));
auVar37[10] = -(pcVar1[0xd] != pcVar2[0xd]);
auVar37[0xb] = -(pcVar1[0xd] != pcVar2[0xd]);
auVar40[0xc] = -(pcVar1[0xe] != pcVar2[0xe]);
auVar40._0_12_ = auVar37;
auVar40[0xd] = -(pcVar1[0xe] != pcVar2[0xe]);
auVar41[0xe] = -(pcVar1[0xf] != pcVar2[0xf]);
auVar41._0_14_ = auVar40;
auVar41[0xf] = -(pcVar1[0xf] != pcVar2[0xf]);
sVar31 = (short)Var14;
sVar54 = (short)((unkuint9)Var22 >> 8);
sVar74 = (short)uVar23;
sVar75 = (short)uVar24;
auVar100._0_12_ = auVar65._0_12_;
auVar100._12_2_ = sVar31;
auVar100._14_2_ = -(ushort)(sVar31 < 0);
auVar99._12_4_ = auVar100._12_4_;
auVar99._0_10_ = auVar65._0_10_;
auVar99._10_2_ = -(ushort)(auVar13._0_2_ < 0);
auVar98._10_6_ = auVar99._10_6_;
auVar98._0_8_ = auVar65._0_8_;
auVar98._8_2_ = auVar13._0_2_;
auVar15._4_8_ = auVar98._8_8_;
auVar15._2_2_ = -(ushort)(auVar12._0_2_ < 0);
auVar15._0_2_ = auVar12._0_2_;
iVar63 = CONCAT22(-(ushort)(sVar54 < 0),sVar54);
auVar64._0_8_ = CONCAT26(-(ushort)(sVar74 < 0),CONCAT24(sVar74,iVar63));
auVar64._8_2_ = sVar75;
auVar64._10_2_ = -(ushort)(sVar75 < 0);
auVar66._12_2_ = uVar25;
auVar66._0_12_ = auVar64;
auVar66._14_2_ = -(ushort)(lVar73 < 0);
sVar31 = (short)((unkuint10)auVar37._0_10_ >> 0x40);
auVar80._12_2_ = (short)((ulong)uVar36 >> 0x30);
auVar80._0_12_ = auVar37;
auVar80._14_2_ = -(ushort)bVar11;
auVar79._12_4_ = auVar80._12_4_;
auVar79._10_2_ = -(ushort)bVar10;
auVar79._0_10_ = auVar37._0_10_;
auVar78._10_6_ = auVar79._10_6_;
auVar78._8_2_ = (short)((uint6)uVar35 >> 0x20);
auVar78._0_8_ = uVar36;
auVar77._8_8_ = auVar78._8_8_;
auVar77._6_2_ = -(ushort)bVar9;
auVar77._0_6_ = uVar35;
auVar76._6_10_ = auVar77._6_10_;
auVar76._4_2_ = (short)((uint)uVar32 >> 0x10);
auVar76._0_4_ = uVar32;
iVar33 = CONCAT22(-(ushort)(sVar31 < 0),sVar31);
auVar38._0_8_ = CONCAT26(-(ushort)(auVar37._10_2_ < 0),CONCAT24(auVar37._10_2_,iVar33));
auVar38._8_2_ = auVar40._12_2_;
auVar38._10_2_ = -(ushort)(auVar40._12_2_ < 0);
auVar42._12_2_ = auVar41._14_2_;
auVar42._0_12_ = auVar38;
auVar42._14_2_ = -(ushort)(auVar41._14_2_ < 0);
iVar59 = (((iVar59 - CONCAT22(-(ushort)bVar4,auVar65._0_2_)) - iVar63) -
CONCAT22(-(ushort)bVar8,CONCAT11(-bVar8,-bVar8))) - iVar33;
iVar60 = (((iVar60 - auVar15._0_4_) - (int)((ulong)auVar64._0_8_ >> 0x20)) - auVar76._4_4_) -
(int)((ulong)auVar38._0_8_ >> 0x20);
iVar61 = (((iVar61 - auVar98._8_4_) - auVar64._8_4_) - auVar78._8_4_) - auVar38._8_4_;
iVar62 = (((iVar62 - auVar99._12_4_) - auVar66._12_4_) - auVar79._12_4_) - auVar42._12_4_;
} while (lVar29 != (sVar28 >> 4 & 0xfffffff) << 4);
uVar27 = uVar26 & 0xfffffff0;
uVar34 = iVar61 + iVar59 + iVar62 + iVar60;
iVar61 = iVar61 + iVar59;
iVar62 = iVar62 + iVar60;
if ((sVar28 & 0xf) == 0) goto LAB_00101459;
}
uVar30 = uVar26 - uVar27;
if (6 < uVar30 - 1) {
uVar36 = *(int8 *)(param_2 + (ulong)uVar27);
uVar3 = *(int8 *)(param_1 + uVar27);
bVar4 = (char)uVar3 != (char)uVar36;
bVar8 = (char)((ulong)uVar3 >> 8) != (char)((ulong)uVar36 >> 8);
bVar9 = (char)((ulong)uVar3 >> 0x10) != (char)((ulong)uVar36 >> 0x10);
bVar10 = (char)((ulong)uVar3 >> 0x18) != (char)((ulong)uVar36 >> 0x18);
bVar11 = (char)((ulong)uVar3 >> 0x20) != (char)((ulong)uVar36 >> 0x20);
bVar5 = (char)((ulong)uVar3 >> 0x28) != (char)((ulong)uVar36 >> 0x28);
bVar6 = (char)((ulong)uVar3 >> 0x30) != (char)((ulong)uVar36 >> 0x30);
bVar7 = (char)((ulong)uVar3 >> 0x38) != (char)((ulong)uVar36 >> 0x38);
auVar43[0] = -bVar4;
cVar57 = -bVar8;
cVar53 = -bVar11;
cVar55 = -bVar5;
cVar56 = -bVar6;
bVar58 = -bVar7;
auVar44._0_9_ = (unkuint9)bVar58 << 0x38;
auVar45._0_10_ = (unkuint10)bVar58 << 0x38;
auVar46._0_11_ = ZEXT111(bVar58) << 0x38;
auVar47._0_12_ = ZEXT112(bVar58) << 0x38;
auVar48._0_13_ = ZEXT113(bVar58) << 0x38;
auVar49._0_14_ = ZEXT114(bVar58) << 0x38;
cVar67 = -bVar8;
cVar68 = -bVar10;
cVar69 = -bVar11;
cVar70 = -bVar5;
cVar71 = -bVar6;
cVar72 = -bVar7;
auVar87[0xe] = bVar58;
auVar87._0_14_ = auVar49._0_14_;
auVar87[0xf] = cVar72;
auVar86._14_2_ = auVar87._14_2_;
auVar86[0xd] = cVar71;
auVar86._0_13_ = auVar48._0_13_;
auVar85._13_3_ = auVar86._13_3_;
auVar85[0xc] = cVar56;
auVar85._0_12_ = auVar47._0_12_;
auVar84._12_4_ = auVar85._12_4_;
auVar84[0xb] = cVar70;
auVar84._0_11_ = auVar46._0_11_;
auVar83._11_5_ = auVar84._11_5_;
auVar83[10] = cVar55;
auVar83._0_10_ = auVar45._0_10_;
auVar82._10_6_ = auVar83._10_6_;
auVar82[9] = cVar69;
auVar82._0_9_ = auVar44._0_9_;
Var14 = CONCAT91(CONCAT81((long)(CONCAT72(auVar82._9_7_,CONCAT11(cVar53,bVar58)) >> 8),cVar68),
-bVar10);
auVar17._2_10_ = Var14;
auVar17[1] = -bVar9;
auVar17[0] = -bVar9;
auVar16._2_12_ = auVar17;
auVar16[1] = cVar67;
auVar16[0] = cVar57;
auVar81._0_2_ = CONCAT11(-bVar4,auVar43[0]);
auVar81._2_14_ = auVar16;
auVar49[0xe] = bVar58;
auVar49[0xf] = cVar72;
auVar48._14_2_ = auVar49._14_2_;
auVar48[0xd] = cVar71;
auVar47._13_3_ = auVar48._13_3_;
auVar47[0xc] = cVar56;
auVar46._12_4_ = auVar47._12_4_;
auVar46[0xb] = cVar70;
auVar45._11_5_ = auVar46._11_5_;
auVar45[10] = cVar55;
auVar44._10_6_ = auVar45._10_6_;
auVar44[9] = cVar69;
Var22 = CONCAT72(auVar44._9_7_,CONCAT11(cVar53,bVar58));
lVar29 = (long)((unkuint9)Var22 >> 8);
auVar20._1_8_ = lVar29;
auVar20[0] = cVar68;
auVar20._9_7_ = 0;
auVar19._10_6_ = 0;
auVar19._0_10_ = SUB1610(auVar20 << 0x38,6);
auVar18._11_5_ = 0;
auVar18._0_11_ = SUB1611(auVar19 << 0x30,5);
auVar43._4_12_ = SUB1612(auVar18 << 0x28,4);
auVar43[3] = cVar67;
auVar43[2] = cVar57;
auVar43[1] = -bVar4;
iVar59 = (int)((unkuint9)Var22 >> 8);
auVar39._8_4_ = auVar43._0_4_;
auVar39._0_8_ = lVar29;
sVar74 = auVar17._0_2_;
sVar75 = (short)Var14;
sVar31 = (short)((unkuint9)Var22 >> 8);
sVar54 = auVar47._12_2_;
auVar97._0_12_ = auVar81._0_12_;
auVar97._12_2_ = sVar75;
auVar97._14_2_ = -(ushort)(sVar75 < 0);
auVar96._12_4_ = auVar97._12_4_;
auVar96._0_10_ = auVar81._0_10_;
auVar96._10_2_ = -(ushort)(sVar74 < 0);
auVar95._10_6_ = auVar96._10_6_;
auVar95._0_8_ = auVar81._0_8_;
auVar95._8_2_ = sVar74;
auVar21._4_8_ = auVar95._8_8_;
auVar21._2_2_ = -(ushort)(auVar16._0_2_ < 0);
auVar21._0_2_ = auVar16._0_2_;
auVar90._12_2_ = sVar75;
auVar90._0_12_ = auVar97._0_12_;
auVar90._14_2_ = -(ushort)(sVar75 < 0);
auVar89._12_4_ = auVar90._12_4_;
auVar89._10_2_ = -(ushort)(sVar74 < 0);
auVar89._0_10_ = auVar96._0_10_;
auVar88._10_6_ = auVar89._10_6_;
auVar88._8_2_ = sVar74;
auVar88._0_8_ = auVar95._0_8_;
auVar52._12_2_ = auVar48._14_2_;
auVar52._0_12_ = auVar39;
auVar52._14_2_ = -(ushort)(lVar29 < 0);
auVar51._12_4_ = auVar52._12_4_;
auVar51._0_10_ = auVar39._0_10_;
auVar51._10_2_ = -(ushort)(sVar54 < 0);
auVar50._10_6_ = auVar51._10_6_;
auVar50._8_2_ = sVar54;
auVar50._0_8_ = lVar29;
auVar94._12_2_ = auVar48._14_2_;
auVar94._0_12_ = auVar39;
auVar94._14_2_ = -(ushort)(lVar29 < 0);
auVar93._12_4_ = auVar94._12_4_;
auVar93._10_2_ = -(ushort)(sVar54 < 0);
auVar93._0_10_ = auVar51._0_10_;
auVar92._10_6_ = auVar93._10_6_;
auVar92._8_2_ = sVar54;
auVar92._0_8_ = lVar29;
auVar91._8_8_ = auVar92._8_8_;
auVar91._6_2_ = -(ushort)(iVar59 < 0);
auVar91._4_2_ = auVar45._10_2_;
auVar91._0_4_ = iVar59;
uVar34 = ((((iVar61 - CONCAT22(-(ushort)bVar4,auVar81._0_2_)) - auVar88._8_4_) -
CONCAT22(-(ushort)(sVar31 < 0),sVar31)) - auVar50._8_4_) +
((((iVar62 - auVar21._0_4_) - auVar89._12_4_) - auVar91._4_4_) - auVar51._12_4_);
uVar27 = uVar27 + (uVar30 & 0xfffffff8);
if ((uVar30 & 7) == 0) goto LAB_00101459;
}
if (param_1[(int)uVar27] != *(char *)(param_2 + (int)uVar27)) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 1;
if (iVar61 < (int)uVar26) {
if (param_1[iVar61] != *(char *)(param_2 + iVar61)) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 2;
if (iVar61 < (int)uVar26) {
if (*(char *)(param_2 + iVar61) != param_1[iVar61]) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 3;
if (iVar61 < (int)uVar26) {
if (param_1[iVar61] != *(char *)(param_2 + iVar61)) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 4;
if (iVar61 < (int)uVar26) {
if (*(char *)(param_2 + iVar61) != param_1[iVar61]) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 5;
if (iVar61 < (int)uVar26) {
if (param_1[iVar61] != *(char *)(param_2 + iVar61)) {
uVar34 = uVar34 + 1;
}
iVar61 = uVar27 + 6;
if ((iVar61 < (int)uVar26) && (param_1[iVar61] != *(char *)(param_2 + iVar61))) {
uVar34 = uVar34 + 1;
}
}
}
}
}
}
LAB_00101459:
if ((uVar34 & 1) == 0) {
iVar61 = (int)uVar34 / 2;
}
else {
iVar61 = -1;
}
return iVar61;
} |
6,692 | func0 | #include <assert.h>
| int func0(int li[], int size, int min, int max) {
int ctr = 0;
for (int i = 0; i < size; i++) {
if (li[i] >= min && li[i] <= max) {
ctr++;
}
}
return ctr;
}
| int main() {
int list1[] = {10, 20, 30, 40, 40, 40, 70, 80, 99};
int list1_size = sizeof(list1) / sizeof(list1[0]);
assert(func0(list1, list1_size, 40, 100) == 6);
int list3[] = {7, 8, 9, 15, 17, 19, 45};
int list3_size = sizeof(list3) / sizeof(list3[0]);
assert(func0(list3, list3_size, 15, 20) == 3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov %edx,-0x20(%rbp)
mov %ecx,-0x24(%rbp)
movl $0x0,-0x8(%rbp)
movl $0x0,-0x4(%rbp)
jmp 11cc <func0+0x63>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x20(%rbp)
jg 11c8 <func0+0x5f>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x24(%rbp)
jl 11c8 <func0+0x5f>
addl $0x1,-0x8(%rbp)
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 118e <func0+0x25>
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_24], ecx
mov [rbp+var_8], 0
mov [rbp+var_4], 0
jmp short loc_11CC
loc_118E:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_20], eax
jg short loc_11C8
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_24], eax
jl short loc_11C8
add [rbp+var_8], 1
loc_11C8:
add [rbp+var_4], 1
loc_11CC:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_1C]
jl short loc_118E
mov eax, [rbp+var_8]
pop rbp
retn | long long func0(long long a1, int a2, int a3, int a4)
{
unsigned int v5; // [rsp+1Ch] [rbp-8h]
int i; // [rsp+20h] [rbp-4h]
v5 = 0;
for ( i = 0; i < a2; ++i )
{
if ( a3 <= *(_DWORD *)(4LL * i + a1) && a4 >= *(_DWORD *)(4LL * i + a1) )
++v5;
}
return v5;
} | 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 + -0x24],ECX
MOV dword ptr [RBP + -0x8],0x0
MOV dword ptr [RBP + -0x4],0x0
JMP 0x001011cc
LAB_0010118e:
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]
CMP dword ptr [RBP + -0x20],EAX
JG 0x001011c8
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]
CMP dword ptr [RBP + -0x24],EAX
JL 0x001011c8
ADD dword ptr [RBP + -0x8],0x1
LAB_001011c8:
ADD dword ptr [RBP + -0x4],0x1
LAB_001011cc:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x0010118e
MOV EAX,dword ptr [RBP + -0x8]
POP RBP
RET | int func0(long param_1,int param_2,int param_3,int param_4)
{
int4 local_10;
int4 local_c;
local_10 = 0;
for (local_c = 0; local_c < param_2; local_c = local_c + 1) {
if ((param_3 <= *(int *)(param_1 + (long)local_c * 4)) &&
(*(int *)(param_1 + (long)local_c * 4) <= param_4)) {
local_10 = local_10 + 1;
}
}
return local_10;
} |
6,693 | func0 | #include <assert.h>
| int func0(int li[], int size, int min, int max) {
int ctr = 0;
for (int i = 0; i < size; i++) {
if (li[i] >= min && li[i] <= max) {
ctr++;
}
}
return ctr;
}
| int main() {
int list1[] = {10, 20, 30, 40, 40, 40, 70, 80, 99};
int list1_size = sizeof(list1) / sizeof(list1[0]);
assert(func0(list1, list1_size, 40, 100) == 6);
int list3[] = {7, 8, 9, 15, 17, 19, 45};
int list3_size = sizeof(list3) / sizeof(list3[0]);
assert(func0(list3, list3_size, 15, 20) == 3);
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 11a1 <func0+0x38>
mov %rdi,%rax
lea -0x1(%rsi),%esi
lea 0x4(%rdi,%rsi,4),%r8
mov $0x0,%edi
jmp 118c <func0+0x23>
add $0x4,%rax
cmp %r8,%rax
je 11a6 <func0+0x3d>
mov (%rax),%esi
cmp %ecx,%esi
jg 1183 <func0+0x1a>
cmp %edx,%esi
setge %sil
cmp $0x1,%sil
sbb $0xffffffff,%edi
jmp 1183 <func0+0x1a>
mov $0x0,%edi
mov %edi,%eax
retq
| func0:
endbr64
test esi, esi
jle short loc_11A1
mov rax, rdi
lea esi, [rsi-1]
lea r8, [rdi+rsi*4+4]
mov edi, 0
jmp short loc_118C
loc_1183:
add rax, 4
cmp rax, r8
jz short loc_11A6
loc_118C:
mov esi, [rax]
cmp esi, ecx
jg short loc_1183
cmp esi, edx
setnl sil
cmp sil, 1
sbb edi, 0FFFFFFFFh
jmp short loc_1183
loc_11A1:
mov edi, 0
loc_11A6:
mov eax, edi
retn | long long func0(_DWORD *a1, int a2, int a3, int a4)
{
_DWORD *v4; // rax
long long v5; // r8
unsigned int v6; // edi
if ( a2 <= 0 )
{
return 0;
}
else
{
v4 = a1;
v5 = (long long)&a1[a2 - 1 + 1];
v6 = 0;
do
{
if ( *v4 <= a4 )
v6 -= (*v4 < a3) - 1;
++v4;
}
while ( v4 != (_DWORD *)v5 );
}
return v6;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001011a1
MOV RAX,RDI
LEA ESI,[RSI + -0x1]
LEA R8,[RDI + RSI*0x4 + 0x4]
MOV EDI,0x0
JMP 0x0010118c
LAB_00101183:
ADD RAX,0x4
CMP RAX,R8
JZ 0x001011a6
LAB_0010118c:
MOV ESI,dword ptr [RAX]
CMP ESI,ECX
JG 0x00101183
CMP ESI,EDX
SETGE SIL
CMP SIL,0x1
SBB EDI,-0x1
JMP 0x00101183
LAB_001011a1:
MOV EDI,0x0
LAB_001011a6:
MOV EAX,EDI
RET | int func0(int *param_1,int param_2,int param_3,int param_4)
{
int *piVar1;
int iVar2;
if (param_2 < 1) {
iVar2 = 0;
}
else {
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
iVar2 = 0;
do {
if (*param_1 <= param_4) {
iVar2 = (iVar2 + 1) - (uint)(*param_1 < param_3);
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
}
return iVar2;
} |
6,694 | func0 | #include <assert.h>
| int func0(int li[], int size, int min, int max) {
int ctr = 0;
for (int i = 0; i < size; i++) {
if (li[i] >= min && li[i] <= max) {
ctr++;
}
}
return ctr;
}
| int main() {
int list1[] = {10, 20, 30, 40, 40, 40, 70, 80, 99};
int list1_size = sizeof(list1) / sizeof(list1[0]);
assert(func0(list1, list1_size, 40, 100) == 6);
int list3[] = {7, 8, 9, 15, 17, 19, 45};
int list3_size = sizeof(list3) / sizeof(list3[0]);
assert(func0(list3, list3_size, 15, 20) == 3);
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 12f0 <func0+0x40>
lea -0x1(%rsi),%eax
xor %r8d,%r8d
lea 0x4(%rdi,%rax,4),%rsi
nopl 0x0(%rax,%rax,1)
mov (%rdi),%eax
cmp %ecx,%eax
jg 12d9 <func0+0x29>
cmp %edx,%eax
setge %al
cmp $0x1,%al
sbb $0xffffffff,%r8d
add $0x4,%rdi
cmp %rsi,%rdi
jne 12c8 <func0+0x18>
mov %r8d,%eax
retq
nopw %cs:0x0(%rax,%rax,1)
xor %r8d,%r8d
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short loc_12F0
lea eax, [rsi-1]
xor r8d, r8d
lea rsi, [rdi+rax*4+4]
nop dword ptr [rax+rax+00h]
loc_12C8:
mov eax, [rdi]
cmp eax, ecx
jg short loc_12D9
cmp eax, edx
setnl al
cmp al, 1
sbb r8d, 0FFFFFFFFh
loc_12D9:
add rdi, 4
cmp rdi, rsi
jnz short loc_12C8
mov eax, r8d
retn
loc_12F0:
xor r8d, r8d
mov eax, r8d
retn | long long func0(_DWORD *a1, int a2, int a3, int a4)
{
unsigned int v4; // r8d
long long v5; // rsi
if ( a2 <= 0 )
return 0LL;
v4 = 0;
v5 = (long long)&a1[a2 - 1 + 1];
do
{
if ( *a1 <= a4 )
v4 -= (*a1 < a3) - 1;
++a1;
}
while ( a1 != (_DWORD *)v5 );
return v4;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001012f0
LEA EAX,[RSI + -0x1]
XOR R8D,R8D
LEA RSI,[RDI + RAX*0x4 + 0x4]
NOP dword ptr [RAX + RAX*0x1]
LAB_001012c8:
MOV EAX,dword ptr [RDI]
CMP EAX,ECX
JG 0x001012d9
CMP EAX,EDX
SETGE AL
CMP AL,0x1
SBB R8D,-0x1
LAB_001012d9:
ADD RDI,0x4
CMP RDI,RSI
JNZ 0x001012c8
MOV EAX,R8D
RET
LAB_001012f0:
XOR R8D,R8D
MOV EAX,R8D
RET | int func0(int *param_1,int param_2,int param_3,int param_4)
{
int *piVar1;
int iVar2;
if (0 < param_2) {
iVar2 = 0;
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
if (*param_1 <= param_4) {
iVar2 = (iVar2 + 1) - (uint)(*param_1 < param_3);
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
return iVar2;
}
return 0;
} |
6,695 | func0 | #include <assert.h>
| int func0(int li[], int size, int min, int max) {
int ctr = 0;
for (int i = 0; i < size; i++) {
if (li[i] >= min && li[i] <= max) {
ctr++;
}
}
return ctr;
}
| int main() {
int list1[] = {10, 20, 30, 40, 40, 40, 70, 80, 99};
int list1_size = sizeof(list1) / sizeof(list1[0]);
assert(func0(list1, list1_size, 40, 100) == 6);
int list3[] = {7, 8, 9, 15, 17, 19, 45};
int list3_size = sizeof(list3) / sizeof(list3[0]);
assert(func0(list3, list3_size, 15, 20) == 3);
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 13f0 <func0+0x100>
lea -0x1(%rsi),%eax
cmp $0x2,%eax
jbe 13f9 <func0+0x109>
mov %esi,%r8d
movd %ecx,%xmm7
pxor %xmm2,%xmm2
mov %rdi,%rax
shr $0x2,%r8d
pshufd $0x0,%xmm7,%xmm5
movd %edx,%xmm7
shl $0x4,%r8
pshufd $0x0,%xmm7,%xmm4
movdqa %xmm2,%xmm3
add %rdi,%r8
nopl 0x0(%rax,%rax,1)
movdqu (%rax),%xmm0
movdqu (%rax),%xmm6
movdqa %xmm4,%xmm1
add $0x10,%rax
pcmpgtd %xmm5,%xmm0
pcmpgtd %xmm6,%xmm1
pcmpeqd %xmm3,%xmm0
pcmpeqd %xmm3,%xmm1
pand %xmm1,%xmm0
psubd %xmm0,%xmm2
cmp %r8,%rax
jne 1338 <func0+0x48>
movdqa %xmm2,%xmm0
mov %esi,%r8d
psrldq $0x8,%xmm0
and $0xfffffffc,%r8d
paddd %xmm0,%xmm2
movdqa %xmm2,%xmm0
psrldq $0x4,%xmm0
paddd %xmm0,%xmm2
movd %xmm2,%eax
test $0x3,%sil
je 13f8 <func0+0x108>
movslq %r8d,%r9
mov (%rdi,%r9,4),%r9d
cmp %ecx,%r9d
jg 13aa <func0+0xba>
cmp %edx,%r9d
setge %r9b
cmp $0x1,%r9b
sbb $0xffffffff,%eax
lea 0x1(%r8),%r9d
cmp %esi,%r9d
jge 13f2 <func0+0x102>
movslq %r9d,%r9
mov (%rdi,%r9,4),%r9d
cmp %r9d,%edx
jg 13cd <func0+0xdd>
cmp %r9d,%ecx
setge %r9b
cmp $0x1,%r9b
sbb $0xffffffff,%eax
add $0x2,%r8d
cmp %r8d,%esi
jle 13f2 <func0+0x102>
movslq %r8d,%r8
mov (%rdi,%r8,4),%esi
cmp %esi,%ecx
jl 13f2 <func0+0x102>
cmp %esi,%edx
setle %dl
cmp $0x1,%dl
sbb $0xffffffff,%eax
retq
nopl (%rax)
xor %eax,%eax
retq
nopl 0x0(%rax,%rax,1)
retq
xor %r8d,%r8d
xor %eax,%eax
jmp 1390 <func0+0xa0>
| func0:
endbr64
mov r9d, edx
test esi, esi
jle loc_1240
lea eax, [rsi-1]
cmp eax, 2
jbe loc_1249
movd xmm7, ecx
pxor xmm2, xmm2
mov rax, rdi
pshufd xmm5, xmm7, 0
movd xmm7, edx
movdqa xmm3, xmm2
mov edx, esi
shr edx, 2
pshufd xmm4, xmm7, 0
shl rdx, 4
add rdx, rdi
nop dword ptr [rax+00h]
loc_1188:
movdqu xmm0, xmmword ptr [rax]
movdqu xmm6, xmmword ptr [rax]
movdqa xmm1, xmm4
add rax, 10h
pcmpgtd xmm0, xmm5
pcmpgtd xmm1, xmm6
pcmpeqd xmm0, xmm3
pcmpeqd xmm1, xmm3
pand xmm0, xmm1
psubd xmm2, xmm0
cmp rdx, rax
jnz short loc_1188
movdqa xmm0, xmm2
mov edx, esi
psrldq xmm0, 8
and edx, 0FFFFFFFCh
paddd xmm2, xmm0
movdqa xmm0, xmm2
psrldq xmm0, 4
paddd xmm2, xmm0
movd eax, xmm2
test sil, 3
jz short locret_1248
loc_11DE:
movsxd r8, edx
lea r10, ds:0[r8*4]
mov r8d, [rdi+r8*4]
cmp r8d, ecx
jg short loc_1200
cmp r8d, r9d
setnl r8b
cmp r8b, 1
sbb eax, 0FFFFFFFFh
loc_1200:
lea r8d, [rdx+1]
cmp esi, r8d
jle short locret_1242
mov r8d, [rdi+r10+4]
cmp r9d, r8d
jg short loc_1221
cmp ecx, r8d
setnl r8b
cmp r8b, 1
sbb eax, 0FFFFFFFFh
loc_1221:
add edx, 2
cmp edx, esi
jge short locret_1242
mov edx, [rdi+r10+8]
cmp ecx, edx
jl short locret_1242
cmp r9d, edx
setle dl
cmp dl, 1
sbb eax, 0FFFFFFFFh
retn
loc_1240:
xor eax, eax
locret_1242:
retn
locret_1248:
retn
loc_1249:
xor edx, edx
xor eax, eax
jmp short loc_11DE | long long func0(const __m128i *a1, int a2, signed int a3, signed int a4)
{
__m128i v5; // xmm2
const __m128i *v6; // rax
__m128i v7; // xmm5
__m128i v8; // xmm4
__m128i v9; // xmm0
int v10; // edx
__m128i v11; // xmm2
long long result; // rax
long long v13; // r10
signed int v14; // r8d
signed int v15; // r8d
signed int v16; // edx
if ( a2 <= 0 )
return 0LL;
if ( (unsigned int)(a2 - 1) <= 2 )
{
v10 = 0;
result = 0LL;
}
else
{
v5 = 0LL;
v6 = a1;
v7 = _mm_shuffle_epi32(_mm_cvtsi32_si128(a4), 0);
v8 = _mm_shuffle_epi32(_mm_cvtsi32_si128(a3), 0);
do
{
v9 = _mm_loadu_si128(v6++);
v5 = _mm_sub_epi32(
v5,
_mm_and_si128(
_mm_cmpeq_epi32(_mm_cmpgt_epi32(v9, v7), (__m128i)0LL),
_mm_cmpeq_epi32(_mm_cmpgt_epi32(v8, v9), (__m128i)0LL)));
}
while ( &a1[(unsigned int)a2 >> 2] != v6 );
v10 = a2 & 0x7FFFFFFC;
v11 = _mm_add_epi32(v5, _mm_srli_si128(v5, 8));
result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v11, _mm_srli_si128(v11, 4)));
if ( (a2 & 3) == 0 )
return result;
}
v13 = v10;
v14 = a1->m128i_i32[v13];
if ( v14 <= a4 )
result = (unsigned int)result - ((v14 < a3) - 1);
if ( a2 > v10 + 1 )
{
v15 = a1->m128i_i32[v13 + 1];
if ( a3 <= v15 )
result = (unsigned int)result - ((a4 < v15) - 1);
if ( v10 + 2 < a2 )
{
v16 = a1->m128i_i32[v13 + 2];
if ( a4 >= v16 )
return (unsigned int)result - ((a3 > v16) - 1);
}
}
return result;
} | func0:
ENDBR64
MOV R9D,EDX
TEST ESI,ESI
JLE 0x00101240
LEA EAX,[RSI + -0x1]
CMP EAX,0x2
JBE 0x00101249
MOVD XMM7,ECX
PXOR XMM2,XMM2
MOV RAX,RDI
PSHUFD XMM5,XMM7,0x0
MOVD XMM7,EDX
MOVDQA XMM3,XMM2
MOV EDX,ESI
SHR EDX,0x2
PSHUFD XMM4,XMM7,0x0
SHL RDX,0x4
ADD RDX,RDI
NOP dword ptr [RAX]
LAB_00101188:
MOVDQU XMM0,xmmword ptr [RAX]
MOVDQU XMM6,xmmword ptr [RAX]
MOVDQA XMM1,XMM4
ADD RAX,0x10
PCMPGTD XMM0,XMM5
PCMPGTD XMM1,XMM6
PCMPEQD XMM0,XMM3
PCMPEQD XMM1,XMM3
PAND XMM0,XMM1
PSUBD XMM2,XMM0
CMP RDX,RAX
JNZ 0x00101188
MOVDQA XMM0,XMM2
MOV EDX,ESI
PSRLDQ XMM0,0x8
AND EDX,0xfffffffc
PADDD XMM2,XMM0
MOVDQA XMM0,XMM2
PSRLDQ XMM0,0x4
PADDD XMM2,XMM0
MOVD EAX,XMM2
TEST SIL,0x3
JZ 0x00101248
LAB_001011de:
MOVSXD R8,EDX
LEA R10,[R8*0x4]
MOV R8D,dword ptr [RDI + R8*0x4]
CMP R8D,ECX
JG 0x00101200
CMP R8D,R9D
SETGE R8B
CMP R8B,0x1
SBB EAX,-0x1
LAB_00101200:
LEA R8D,[RDX + 0x1]
CMP ESI,R8D
JLE 0x00101242
MOV R8D,dword ptr [RDI + R10*0x1 + 0x4]
CMP R9D,R8D
JG 0x00101221
CMP ECX,R8D
SETGE R8B
CMP R8B,0x1
SBB EAX,-0x1
LAB_00101221:
ADD EDX,0x2
CMP EDX,ESI
JGE 0x00101242
MOV EDX,dword ptr [RDI + R10*0x1 + 0x8]
CMP ECX,EDX
JL 0x00101242
CMP R9D,EDX
SETLE DL
CMP DL,0x1
SBB EAX,-0x1
RET
LAB_00101240:
XOR EAX,EAX
LAB_00101242:
RET
LAB_00101248:
RET
LAB_00101249:
XOR EDX,EDX
XOR EAX,EAX
JMP 0x001011de | int func0(int *param_1,uint param_2,int param_3,int param_4)
{
int iVar1;
int *piVar2;
int *piVar3;
int *piVar4;
int iVar5;
int *piVar6;
int *piVar7;
int *piVar8;
int *piVar9;
uint uVar10;
int iVar11;
int iVar12;
int iVar13;
int iVar14;
if ((int)param_2 < 1) {
iVar11 = 0;
}
else {
if (param_2 - 1 < 3) {
uVar10 = 0;
iVar11 = 0;
}
else {
iVar11 = 0;
iVar12 = 0;
iVar13 = 0;
iVar14 = 0;
piVar9 = param_1;
do {
iVar1 = *piVar9;
piVar2 = piVar9 + 1;
piVar3 = piVar9 + 2;
piVar4 = piVar9 + 3;
iVar5 = *piVar9;
piVar6 = piVar9 + 1;
piVar7 = piVar9 + 2;
piVar8 = piVar9 + 3;
piVar9 = piVar9 + 4;
iVar11 = iVar11 + (uint)(iVar1 <= param_4 && param_3 <= iVar5);
iVar12 = iVar12 + (uint)(*piVar2 <= param_4 && param_3 <= *piVar6);
iVar13 = iVar13 + (uint)(*piVar3 <= param_4 && param_3 <= *piVar7);
iVar14 = iVar14 + (uint)(*piVar4 <= param_4 && param_3 <= *piVar8);
} while (param_1 + (ulong)(param_2 >> 2) * 4 != piVar9);
uVar10 = param_2 & 0xfffffffc;
iVar11 = iVar11 + iVar13 + iVar12 + iVar14;
if ((param_2 & 3) == 0) {
return iVar11;
}
}
if (param_1[(int)uVar10] <= param_4) {
iVar11 = (iVar11 + 1) - (uint)(param_1[(int)uVar10] < param_3);
}
if ((int)(uVar10 + 1) < (int)param_2) {
if (param_3 <= param_1[(long)(int)uVar10 + 1]) {
iVar11 = (iVar11 + 1) - (uint)(param_4 < param_1[(long)(int)uVar10 + 1]);
}
if (((int)(uVar10 + 2) < (int)param_2) && (param_1[(long)(int)uVar10 + 2] <= param_4)) {
return (iVar11 + 1) - (uint)(param_1[(long)(int)uVar10 + 2] < param_3);
}
}
}
return iVar11;
} |
6,696 | func0 |
#include <assert.h>
| int func0(int arr[], int n) {
int total_sum = 0;
for (int i = 0; i < n; i++) {
total_sum += arr[i];
}
int left_sum = 0;
for (int i = 0; i < n; i++) {
total_sum -= arr[i];
if (left_sum == total_sum) {
return i;
}
left_sum += arr[i];
}
return -1;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 1, 2, 3};
int arr2[] = {-7, 1, 5, 2, -4, 3, 0};
int arr3[] = {1, 2, 3};
assert(func0(arr1, 7) == 3);
assert(func0(arr2, 7) == 3);
assert(func0(arr3, 3) == -1);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x0,-0x10(%rbp)
movl $0x0,-0xc(%rbp)
jmp 11a5 <func0+0x3c>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
add %eax,-0x10(%rbp)
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 1188 <func0+0x1f>
movl $0x0,-0x8(%rbp)
movl $0x0,-0x4(%rbp)
jmp 1200 <func0+0x97>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
sub %eax,-0x10(%rbp)
mov -0x8(%rbp),%eax
cmp -0x10(%rbp),%eax
jne 11e3 <func0+0x7a>
mov -0x4(%rbp),%eax
jmp 120d <func0+0xa4>
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 -0x1c(%rbp),%eax
jl 11bd <func0+0x54>
mov $0xffffffff,%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_18], rdi
mov [rbp+var_1C], esi
mov [rbp+var_10], 0
mov [rbp+var_C], 0
jmp short loc_11A5
loc_1188:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
add [rbp+var_10], eax
add [rbp+var_C], 1
loc_11A5:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_1C]
jl short loc_1188
mov [rbp+var_8], 0
mov [rbp+var_4], 0
jmp short loc_1200
loc_11BD:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
sub [rbp+var_10], eax
mov eax, [rbp+var_8]
cmp eax, [rbp+var_10]
jnz short loc_11E3
mov eax, [rbp+var_4]
jmp short loc_120D
loc_11E3:
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_1200:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_1C]
jl short loc_11BD
mov eax, 0FFFFFFFFh
loc_120D:
pop rbp
retn | long long func0(long long a1, int a2)
{
int v3; // [rsp+Ch] [rbp-10h]
int i; // [rsp+10h] [rbp-Ch]
int v5; // [rsp+14h] [rbp-8h]
unsigned int j; // [rsp+18h] [rbp-4h]
v3 = 0;
for ( i = 0; i < a2; ++i )
v3 += *(_DWORD *)(4LL * i + a1);
v5 = 0;
for ( j = 0; (int)j < a2; ++j )
{
v3 -= *(_DWORD *)(4LL * (int)j + a1);
if ( v5 == v3 )
return j;
v5 += *(_DWORD *)(4LL * (int)j + a1);
}
return 0xFFFFFFFFLL;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0x10],0x0
MOV dword ptr [RBP + -0xc],0x0
JMP 0x001011a5
LAB_00101188:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
ADD dword ptr [RBP + -0x10],EAX
ADD dword ptr [RBP + -0xc],0x1
LAB_001011a5:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x00101188
MOV dword ptr [RBP + -0x8],0x0
MOV dword ptr [RBP + -0x4],0x0
JMP 0x00101200
LAB_001011bd:
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]
SUB dword ptr [RBP + -0x10],EAX
MOV EAX,dword ptr [RBP + -0x8]
CMP EAX,dword ptr [RBP + -0x10]
JNZ 0x001011e3
MOV EAX,dword ptr [RBP + -0x4]
JMP 0x0010120d
LAB_001011e3:
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_00101200:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x001011bd
MOV EAX,0xffffffff
LAB_0010120d:
POP RBP
RET | int func0(long param_1,int param_2)
{
int local_18;
int local_14;
int local_10;
int local_c;
local_18 = 0;
for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 1) {
local_18 = local_18 + *(int *)(param_1 + (long)local_14 * 4);
}
local_10 = 0;
local_c = 0;
while( true ) {
if (param_2 <= local_c) {
return -1;
}
local_18 = local_18 - *(int *)(param_1 + (long)local_c * 4);
if (local_10 == local_18) break;
local_10 = local_10 + *(int *)(param_1 + (long)local_c * 4);
local_c = local_c + 1;
}
return local_c;
} |
6,697 | func0 |
#include <assert.h>
| int func0(int arr[], int n) {
int total_sum = 0;
for (int i = 0; i < n; i++) {
total_sum += arr[i];
}
int left_sum = 0;
for (int i = 0; i < n; i++) {
total_sum -= arr[i];
if (left_sum == total_sum) {
return i;
}
left_sum += arr[i];
}
return -1;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 1, 2, 3};
int arr2[] = {-7, 1, 5, 2, -4, 3, 0};
int arr3[] = {1, 2, 3};
assert(func0(arr1, 7) == 3);
assert(func0(arr2, 7) == 3);
assert(func0(arr3, 3) == -1);
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 11c4 <func0+0x5b>
mov %rdi,%rdx
lea -0x1(%rsi),%r8d
lea 0x4(%rdi,%r8,4),%rcx
mov $0x0,%eax
add (%rdx),%eax
add $0x4,%rdx
cmp %rcx,%rdx
jne 1182 <func0+0x19>
mov (%rdi),%ecx
sub %ecx,%eax
je 11cc <func0+0x63>
add $0x1,%r8
mov $0x1,%edx
mov $0x0,%esi
add %ecx,%esi
mov %edx,%r9d
cmp %rdx,%r8
je 11ba <func0+0x51>
mov (%rdi,%rdx,4),%ecx
sub %ecx,%eax
add $0x1,%rdx
cmp %esi,%eax
jne 11a1 <func0+0x38>
jmp 11c0 <func0+0x57>
mov $0xffffffff,%r9d
mov %r9d,%eax
retq
mov $0xffffffff,%r9d
jmp 11c0 <func0+0x57>
mov %eax,%r9d
jmp 11c0 <func0+0x57>
| func0:
endbr64
test esi, esi
jle short loc_11C4
mov rdx, rdi
lea eax, [rsi-1]
lea rcx, [rdi+rax*4+4]
mov eax, 0
loc_1181:
add eax, [rdx]
add rdx, 4
cmp rdx, rcx
jnz short loc_1181
mov ecx, [rdi]
sub eax, ecx
jz short loc_11CC
mov esi, esi
mov edx, 1
mov r8d, 0
loc_119F:
add r8d, ecx
mov r9d, edx
cmp rsi, rdx
jz short loc_11BA
mov ecx, [rdi+rdx*4]
sub eax, ecx
add rdx, 1
cmp eax, r8d
jnz short loc_119F
jmp short loc_11C0
loc_11BA:
mov r9d, 0FFFFFFFFh
loc_11C0:
mov eax, r9d
retn
loc_11C4:
mov r9d, 0FFFFFFFFh
jmp short loc_11C0
loc_11CC:
mov r9d, eax
jmp short loc_11C0 | long long func0(_DWORD *a1, int a2)
{
_DWORD *v2; // rdx
int v3; // eax
int v4; // ecx
int v5; // eax
long long v6; // rdx
int v7; // r8d
unsigned int v8; // r9d
if ( a2 <= 0 )
{
return (unsigned int)-1;
}
else
{
v2 = a1;
v3 = 0;
do
v3 += *v2++;
while ( v2 != &a1[a2 - 1 + 1] );
v4 = *a1;
v5 = v3 - *a1;
if ( v5 )
{
v6 = 1LL;
v7 = 0;
while ( 1 )
{
v7 += v4;
v8 = v6;
if ( a2 == v6 )
break;
v4 = a1[v6];
v5 -= v4;
++v6;
if ( v5 == v7 )
return v8;
}
return (unsigned int)-1;
}
else
{
return 0;
}
}
} | ||
6,698 | func0 |
#include <assert.h>
| int func0(int arr[], int n) {
int total_sum = 0;
for (int i = 0; i < n; i++) {
total_sum += arr[i];
}
int left_sum = 0;
for (int i = 0; i < n; i++) {
total_sum -= arr[i];
if (left_sum == total_sum) {
return i;
}
left_sum += arr[i];
}
return -1;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 1, 2, 3};
int arr2[] = {-7, 1, 5, 2, -4, 3, 0};
int arr3[] = {1, 2, 3};
assert(func0(arr1, 7) == 3);
assert(func0(arr2, 7) == 3);
assert(func0(arr3, 3) == -1);
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 12f7 <func0+0x57>
lea -0x1(%rsi),%r8d
mov %rdi,%rdx
xor %eax,%eax
lea 0x4(%rdi,%r8,4),%rcx
nopw %cs:0x0(%rax,%rax,1)
add (%rdx),%eax
add $0x4,%rdx
cmp %rcx,%rdx
jne 12c0 <func0+0x20>
mov (%rdi),%ecx
sub %ecx,%eax
je 1301 <func0+0x61>
add $0x1,%r8
mov $0x1,%edx
xor %esi,%esi
jmp 12ed <func0+0x4d>
xchg %ax,%ax
mov (%rdi,%rdx,4),%ecx
add $0x1,%rdx
sub %ecx,%eax
cmp %esi,%eax
je 12fd <func0+0x5d>
add %ecx,%esi
mov %edx,%r9d
cmp %r8,%rdx
jne 12e0 <func0+0x40>
mov $0xffffffff,%r9d
mov %r9d,%eax
retq
xor %r9d,%r9d
jmp 12fd <func0+0x5d>
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short loc_1301
lea eax, [rsi-1]
mov rdx, rdi
lea rcx, [rdi+rax*4+4]
xor eax, eax
nop dword ptr [rax]
loc_12C8:
add eax, [rdx]
add rdx, 4
cmp rdx, rcx
jnz short loc_12C8
mov ecx, [rdi]
sub eax, ecx
jz short loc_130B
mov esi, esi
mov edx, 1
xor r8d, r8d
jmp short loc_12F6
loc_12E8:
mov ecx, [rdi+rdx*4]
add rdx, 1
sub eax, ecx
cmp eax, r8d
jz short loc_1307
loc_12F6:
add r8d, ecx
mov r9d, edx
cmp rdx, rsi
jnz short loc_12E8
loc_1301:
mov r9d, 0FFFFFFFFh
loc_1307:
mov eax, r9d
retn
loc_130B:
xor r9d, r9d
jmp short loc_1307 | long long func0(_DWORD *a1, int a2)
{
_DWORD *v2; // rdx
int v3; // eax
int v4; // ecx
int v5; // eax
long long v6; // rdx
int v7; // r8d
unsigned int v8; // r9d
if ( a2 > 0 )
{
v2 = a1;
v3 = 0;
do
v3 += *v2++;
while ( v2 != &a1[a2 - 1 + 1] );
v4 = *a1;
v5 = v3 - *a1;
if ( !v5 )
return 0;
v6 = 1LL;
v7 = 0;
while ( 1 )
{
v7 += v4;
v8 = v6;
if ( v6 == a2 )
break;
v4 = a1[v6++];
v5 -= v4;
if ( v5 == v7 )
return v8;
}
}
return (unsigned int)-1;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x00101301
LEA EAX,[RSI + -0x1]
MOV RDX,RDI
LEA RCX,[RDI + RAX*0x4 + 0x4]
XOR EAX,EAX
NOP dword ptr [RAX]
LAB_001012c8:
ADD EAX,dword ptr [RDX]
ADD RDX,0x4
CMP RDX,RCX
JNZ 0x001012c8
MOV ECX,dword ptr [RDI]
SUB EAX,ECX
JZ 0x0010130b
MOV ESI,ESI
MOV EDX,0x1
XOR R8D,R8D
JMP 0x001012f6
LAB_001012e8:
MOV ECX,dword ptr [RDI + RDX*0x4]
ADD RDX,0x1
SUB EAX,ECX
CMP EAX,R8D
JZ 0x00101307
LAB_001012f6:
ADD R8D,ECX
MOV R9D,EDX
CMP RDX,RSI
JNZ 0x001012e8
LAB_00101301:
MOV R9D,0xffffffff
LAB_00101307:
MOV EAX,R9D
RET
LAB_0010130b:
XOR R9D,R9D
JMP 0x00101307 | ulong func0(int *param_1,uint param_2)
{
int iVar1;
int iVar2;
int *piVar3;
ulong uVar4;
int iVar5;
ulong uVar6;
if ((int)param_2 < 1) {
LAB_00101301:
uVar6 = 0xffffffff;
}
else {
iVar1 = 0;
piVar3 = param_1;
do {
iVar1 = iVar1 + *piVar3;
piVar3 = piVar3 + 1;
} while (piVar3 != param_1 + (ulong)(param_2 - 1) + 1);
iVar2 = *param_1;
iVar1 = iVar1 - iVar2;
if (iVar1 == 0) {
uVar6 = 0;
}
else {
uVar4 = 1;
iVar5 = 0;
do {
iVar5 = iVar5 + iVar2;
uVar6 = uVar4 & 0xffffffff;
if (uVar4 == param_2) goto LAB_00101301;
iVar2 = param_1[uVar4];
uVar4 = uVar4 + 1;
iVar1 = iVar1 - iVar2;
} while (iVar1 != iVar5);
}
}
return uVar6;
} |
6,699 | func0 |
#include <assert.h>
| int func0(int arr[], int n) {
int total_sum = 0;
for (int i = 0; i < n; i++) {
total_sum += arr[i];
}
int left_sum = 0;
for (int i = 0; i < n; i++) {
total_sum -= arr[i];
if (left_sum == total_sum) {
return i;
}
left_sum += arr[i];
}
return -1;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 1, 2, 3};
int arr2[] = {-7, 1, 5, 2, -4, 3, 0};
int arr3[] = {1, 2, 3};
assert(func0(arr1, 7) == 3);
assert(func0(arr2, 7) == 3);
assert(func0(arr3, 3) == -1);
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 1357 <func0+0xc7>
lea -0x1(%rsi),%r8d
cmp $0x3,%r8d
jbe 1361 <func0+0xd1>
mov %esi,%edx
mov %rdi,%rax
pxor %xmm0,%xmm0
shr $0x2,%edx
shl $0x4,%rdx
add %rdi,%rdx
nopl (%rax)
movdqu (%rax),%xmm2
add $0x10,%rax
paddd %xmm2,%xmm0
cmp %rdx,%rax
jne 12c0 <func0+0x30>
movdqa %xmm0,%xmm1
mov %esi,%edx
psrldq $0x8,%xmm1
and $0xfffffffc,%edx
paddd %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrldq $0x4,%xmm1
paddd %xmm1,%xmm0
movd %xmm0,%eax
test $0x3,%sil
je 1327 <func0+0x97>
movslq %edx,%rcx
add (%rdi,%rcx,4),%eax
lea 0x1(%rdx),%ecx
cmp %ecx,%esi
jle 1327 <func0+0x97>
movslq %ecx,%rcx
add (%rdi,%rcx,4),%eax
lea 0x2(%rdx),%ecx
cmp %ecx,%esi
jle 1327 <func0+0x97>
movslq %ecx,%rcx
add $0x3,%edx
add (%rdi,%rcx,4),%eax
cmp %edx,%esi
jle 1327 <func0+0x97>
movslq %edx,%rdx
add (%rdi,%rdx,4),%eax
mov (%rdi),%ecx
sub %ecx,%eax
je 1367 <func0+0xd7>
mov %r8d,%r8d
mov $0x1,%edx
xor %esi,%esi
add $0x1,%r8
jmp 134d <func0+0xbd>
nopl (%rax)
mov (%rdi,%rdx,4),%ecx
add $0x1,%rdx
sub %ecx,%eax
cmp %esi,%eax
je 135d <func0+0xcd>
add %ecx,%esi
mov %edx,%r9d
cmp %r8,%rdx
jne 1340 <func0+0xb0>
mov $0xffffffff,%r9d
mov %r9d,%eax
retq
xor %edx,%edx
xor %eax,%eax
jmp 12fa <func0+0x6a>
xor %r9d,%r9d
jmp 135d <func0+0xcd>
nopl 0x0(%rax)
| func0:
endbr64
mov r9, rdi
mov edi, esi
test edi, edi
jle loc_1200
lea eax, [rdi-1]
cmp eax, 2
jbe loc_1213
mov edx, edi
mov rax, r9
pxor xmm0, xmm0
shr edx, 2
shl rdx, 4
add rdx, r9
loc_1170:
movdqu xmm2, xmmword ptr [rax]
add rax, 10h
paddd xmm0, xmm2
cmp rax, rdx
jnz short loc_1170
movdqa xmm1, xmm0
mov edx, edi
psrldq xmm1, 8
and edx, 0FFFFFFFCh
paddd xmm0, xmm1
movdqa xmm1, xmm0
psrldq xmm1, 4
paddd xmm0, xmm1
movd eax, xmm0
test dil, 3
jz short loc_11D1
loc_11AA:
movsxd rcx, edx
lea rsi, ds:0[rcx*4]
add eax, [r9+rcx*4]
lea ecx, [rdx+1]
cmp edi, ecx
jle short loc_11D1
add edx, 2
add eax, [r9+rsi+4]
cmp edi, edx
jle short loc_11D1
add eax, [r9+rsi+8]
loc_11D1:
mov ecx, [r9]
sub eax, ecx
jz short locret_1205
mov edx, 1
xor esi, esi
jmp short loc_11F9
loc_11E8:
mov ecx, [r9+rdx*4]
lea r8, [rdx+1]
sub eax, ecx
cmp eax, esi
jz short loc_1210
mov rdx, r8
loc_11F9:
add esi, ecx
cmp rdx, rdi
jnz short loc_11E8
loc_1200:
mov eax, 0FFFFFFFFh
locret_1205:
retn
loc_1210:
mov eax, edx
retn
loc_1213:
xor edx, edx
xor eax, eax
jmp short loc_11AA | long long func0(const __m128i *a1, int a2)
{
long long v3; // rdi
const __m128i *v4; // rax
__m128i v5; // xmm0
__m128i v6; // xmm2
int v7; // edx
__m128i v8; // xmm0
int v9; // eax
long long v10; // rsi
__int32 v11; // ecx
long long result; // rax
long long v13; // rdx
int v14; // esi
v3 = (unsigned int)a2;
if ( a2 <= 0 )
return 0xFFFFFFFFLL;
if ( (unsigned int)(a2 - 1) <= 2 )
{
v7 = 0;
v9 = 0;
goto LABEL_6;
}
v4 = a1;
v5 = 0LL;
do
{
v6 = _mm_loadu_si128(v4++);
v5 = _mm_add_epi32(v5, v6);
}
while ( v4 != &a1[(unsigned int)a2 >> 2] );
v7 = a2 & 0x7FFFFFFC;
v8 = _mm_add_epi32(v5, _mm_srli_si128(v5, 8));
v9 = _mm_cvtsi128_si32(_mm_add_epi32(v8, _mm_srli_si128(v8, 4)));
if ( (a2 & 3) != 0 )
{
LABEL_6:
v10 = v7;
v9 += a1->m128i_i32[v10];
if ( (int)v3 > v7 + 1 )
{
v9 += a1->m128i_i32[v10 + 1];
if ( (int)v3 > v7 + 2 )
v9 += a1->m128i_i32[v10 + 2];
}
}
v11 = a1->m128i_i32[0];
result = (unsigned int)(v9 - a1->m128i_i32[0]);
if ( !(_DWORD)result )
return result;
v13 = 1LL;
v14 = 0;
while ( 1 )
{
v14 += v11;
if ( v13 == v3 )
break;
v11 = a1->m128i_i32[v13];
LODWORD(result) = result - v11;
if ( (_DWORD)result == v14 )
return (unsigned int)v13;
++v13;
}
return 0xFFFFFFFFLL;
} | func0:
ENDBR64
MOV R9,RDI
MOV EDI,ESI
TEST EDI,EDI
JLE 0x00101200
LEA EAX,[RDI + -0x1]
CMP EAX,0x2
JBE 0x00101213
MOV EDX,EDI
MOV RAX,R9
PXOR XMM0,XMM0
SHR EDX,0x2
SHL RDX,0x4
ADD RDX,R9
LAB_00101170:
MOVDQU XMM2,xmmword ptr [RAX]
ADD RAX,0x10
PADDD XMM0,XMM2
CMP RAX,RDX
JNZ 0x00101170
MOVDQA XMM1,XMM0
MOV EDX,EDI
PSRLDQ XMM1,0x8
AND EDX,0xfffffffc
PADDD XMM0,XMM1
MOVDQA XMM1,XMM0
PSRLDQ XMM1,0x4
PADDD XMM0,XMM1
MOVD EAX,XMM0
TEST DIL,0x3
JZ 0x001011d1
LAB_001011aa:
MOVSXD RCX,EDX
LEA RSI,[RCX*0x4]
ADD EAX,dword ptr [R9 + RCX*0x4]
LEA ECX,[RDX + 0x1]
CMP EDI,ECX
JLE 0x001011d1
ADD EDX,0x2
ADD EAX,dword ptr [R9 + RSI*0x1 + 0x4]
CMP EDI,EDX
JLE 0x001011d1
ADD EAX,dword ptr [R9 + RSI*0x1 + 0x8]
LAB_001011d1:
MOV ECX,dword ptr [R9]
SUB EAX,ECX
JZ 0x00101205
MOV EDX,0x1
XOR ESI,ESI
JMP 0x001011f9
LAB_001011e8:
MOV ECX,dword ptr [R9 + RDX*0x4]
LEA R8,[RDX + 0x1]
SUB EAX,ECX
CMP EAX,ESI
JZ 0x00101210
MOV RDX,R8
LAB_001011f9:
ADD ESI,ECX
CMP RDX,RDI
JNZ 0x001011e8
LAB_00101200:
MOV EAX,0xffffffff
LAB_00101205:
RET
LAB_00101210:
MOV EAX,EDX
RET
LAB_00101213:
XOR EDX,EDX
XOR EAX,EAX
JMP 0x001011aa | ulong func0(int *param_1,uint param_2)
{
int iVar1;
int *piVar2;
int *piVar3;
int *piVar4;
ulong uVar5;
uint uVar6;
int *piVar7;
ulong uVar8;
uint uVar9;
ulong uVar10;
int iVar11;
int iVar12;
int iVar13;
int iVar14;
if ((int)param_2 < 1) {
return 0xffffffff;
}
if (param_2 - 1 < 3) {
uVar9 = 0;
iVar11 = 0;
}
else {
iVar11 = 0;
iVar12 = 0;
iVar13 = 0;
iVar14 = 0;
piVar7 = param_1;
do {
iVar1 = *piVar7;
piVar2 = piVar7 + 1;
piVar3 = piVar7 + 2;
piVar4 = piVar7 + 3;
piVar7 = piVar7 + 4;
iVar11 = iVar11 + iVar1;
iVar12 = iVar12 + *piVar2;
iVar13 = iVar13 + *piVar3;
iVar14 = iVar14 + *piVar4;
} while (piVar7 != param_1 + (ulong)(param_2 >> 2) * 4);
uVar9 = param_2 & 0xfffffffc;
iVar11 = iVar11 + iVar13 + iVar12 + iVar14;
if ((param_2 & 3) == 0) goto LAB_001011d1;
}
iVar11 = iVar11 + param_1[(int)uVar9];
if (((int)(uVar9 + 1) < (int)param_2) &&
(iVar11 = iVar11 + param_1[(long)(int)uVar9 + 1], (int)(uVar9 + 2) < (int)param_2)) {
iVar11 = iVar11 + param_1[(long)(int)uVar9 + 2];
}
LAB_001011d1:
iVar12 = *param_1;
uVar8 = (ulong)(uint)(iVar11 - iVar12);
if (iVar11 - iVar12 == 0) {
return uVar8;
}
uVar9 = 0;
uVar5 = 1;
do {
uVar10 = uVar5;
uVar9 = uVar9 + iVar12;
if (uVar10 == param_2) {
return 0xffffffff;
}
iVar12 = param_1[uVar10];
uVar6 = (int)uVar8 - iVar12;
uVar8 = (ulong)uVar6;
uVar5 = uVar10 + 1;
} while (uVar6 != uVar9);
return uVar10 & 0xffffffff;
} |
6,700 | func0 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int find_ind(int key, int i, int n, int k, int arr[]) {
int ind = -1;
int start = i + 1;
int end = n - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (arr[mid] - key <= k) {
ind = mid;
start = mid + 1;
} else {
end = mid;
}
}
return ind;
}
| int func0(int arr[], int n, int k) {
int ans = n - 1;
qsort(arr, n, sizeof(int), (int (*)(const void *, const void *))strcmp);
for (int i = 0; i < n; i++) {
int j = find_ind(arr[i], i, n, k, arr);
if (j != -1) {
ans = (ans < n - (j - i + 1) ? ans : n - (j - i + 1));
}
}
return ans;
}
| int main() {
int arr1[] = {1, 3, 4, 9, 10, 11, 12, 17, 20};
assert(func0(arr1, 9, 4) == 5);
int arr2[] = {1, 5, 6, 2, 8};
assert(func0(arr2, 5, 2) == 3);
int arr3[] = {1, 2, 3, 4, 5, 6};
assert(func0(arr3, 6, 3) == 2);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov %edx,-0x20(%rbp)
mov -0x1c(%rbp),%eax
sub $0x1,%eax
mov %eax,-0xc(%rbp)
mov -0x1c(%rbp),%eax
movslq %eax,%rsi
mov -0x18(%rbp),%rax
mov 0x2d99(%rip),%rdx
mov %rdx,%rcx
mov $0x4,%edx
mov %rax,%rdi
callq 1070 <qsort@plt>
movl $0x0,-0x8(%rbp)
jmp 12b2 <func0+0x9b>
mov -0x8(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov -0x18(%rbp),%rdi
mov -0x20(%rbp),%ecx
mov -0x1c(%rbp),%edx
mov -0x8(%rbp),%esi
mov %rdi,%r8
mov %eax,%edi
callq 1189 <find_ind>
mov %eax,-0x4(%rbp)
cmpl $0xffffffff,-0x4(%rbp)
je 12ae <func0+0x97>
mov -0x4(%rbp),%eax
sub -0x8(%rbp),%eax
lea 0x1(%rax),%edx
mov -0x1c(%rbp),%eax
sub %edx,%eax
cmp %eax,-0xc(%rbp)
cmovle -0xc(%rbp),%eax
mov %eax,-0xc(%rbp)
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 1260 <func0+0x49>
mov -0xc(%rbp),%eax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+base], rdi
mov [rbp+var_1C], esi
mov [rbp+var_20], edx
mov eax, [rbp+var_1C]
sub eax, 1
mov [rbp+var_C], eax
mov eax, [rbp+var_1C]
movsxd rsi, eax; nmemb
mov rax, [rbp+base]
mov rdx, cs:compar
mov rcx, rdx; compar
mov edx, 4; size
mov rdi, rax; base
call _qsort
mov [rbp+var_8], 0
jmp short loc_12B3
loc_1260:
mov eax, [rbp+var_8]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+base]
add rax, rdx
mov eax, [rax]
mov rdi, [rbp+base]
mov ecx, [rbp+var_20]
mov edx, [rbp+var_1C]
mov esi, [rbp+var_8]
mov r8, rdi
mov edi, eax
call find_ind
mov [rbp+var_4], eax
cmp [rbp+var_4], 0FFFFFFFFh
jz short loc_12AF
mov eax, [rbp+var_4]
sub eax, [rbp+var_8]
lea edx, [rax+1]
mov eax, [rbp+var_1C]
sub eax, edx
mov edx, [rbp+var_C]
cmp edx, eax
cmovle eax, edx
mov [rbp+var_C], eax
loc_12AF:
add [rbp+var_8], 1
loc_12B3:
mov eax, [rbp+var_8]
cmp eax, [rbp+var_1C]
jl short loc_1260
mov eax, [rbp+var_C]
leave
retn | long long func0(unsigned int *a1, unsigned int a2, unsigned int a3)
{
int v3; // eax
unsigned int v6; // [rsp+14h] [rbp-Ch]
unsigned int i; // [rsp+18h] [rbp-8h]
int ind; // [rsp+1Ch] [rbp-4h]
v6 = a2 - 1;
qsort(a1, (int)a2, 4uLL, (__compar_fn_t)&strcmp);
for ( i = 0; (int)i < (int)a2; ++i )
{
ind = find_ind(a1[i], i, a2, a3, a1);
if ( ind != -1 )
{
v3 = a2 - (ind - i + 1);
if ( (int)v6 <= v3 )
v3 = v6;
v6 = v3;
}
}
return v6;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0x20],EDX
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,0x1
MOV dword ptr [RBP + -0xc],EAX
MOV EAX,dword ptr [RBP + -0x1c]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x18]
MOV RDX,qword ptr [0x00103fe0]
MOV RCX,RDX
MOV EDX,0x4
MOV RDI,RAX
CALL 0x00101070
MOV dword ptr [RBP + -0x8],0x0
JMP 0x001012b3
LAB_00101260:
MOV EAX,dword ptr [RBP + -0x8]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV RDI,qword ptr [RBP + -0x18]
MOV ECX,dword ptr [RBP + -0x20]
MOV EDX,dword ptr [RBP + -0x1c]
MOV ESI,dword ptr [RBP + -0x8]
MOV R8,RDI
MOV EDI,EAX
CALL 0x00101189
MOV dword ptr [RBP + -0x4],EAX
CMP dword ptr [RBP + -0x4],-0x1
JZ 0x001012af
MOV EAX,dword ptr [RBP + -0x4]
SUB EAX,dword ptr [RBP + -0x8]
LEA EDX,[RAX + 0x1]
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,EDX
MOV EDX,dword ptr [RBP + -0xc]
CMP EDX,EAX
CMOVLE EAX,EDX
MOV dword ptr [RBP + -0xc],EAX
LAB_001012af:
ADD dword ptr [RBP + -0x8],0x1
LAB_001012b3:
MOV EAX,dword ptr [RBP + -0x8]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x00101260
MOV EAX,dword ptr [RBP + -0xc]
LEAVE
RET | int func0(void *param_1,int param_2,int4 param_3)
{
int iVar1;
int iVar2;
int local_14;
int local_10;
local_14 = param_2 + -1;
qsort(param_1,(long)param_2,4,(__compar_fn_t)PTR_strcmp_00103fe0);
for (local_10 = 0; local_10 < param_2; local_10 = local_10 + 1) {
iVar1 = find_ind(*(int4 *)((long)param_1 + (long)local_10 * 4),local_10,param_2,param_3,
param_1);
iVar2 = local_14;
if ((iVar1 != -1) && (iVar2 = param_2 - ((iVar1 - local_10) + 1), local_14 <= iVar2)) {
iVar2 = local_14;
}
local_14 = iVar2;
}
return local_14;
} |
6,701 | func0 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int find_ind(int key, int i, int n, int k, int arr[]) {
int ind = -1;
int start = i + 1;
int end = n - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (arr[mid] - key <= k) {
ind = mid;
start = mid + 1;
} else {
end = mid;
}
}
return ind;
}
| int func0(int arr[], int n, int k) {
int ans = n - 1;
qsort(arr, n, sizeof(int), (int (*)(const void *, const void *))strcmp);
for (int i = 0; i < n; i++) {
int j = find_ind(arr[i], i, n, k, arr);
if (j != -1) {
ans = (ans < n - (j - i + 1) ? ans : n - (j - i + 1));
}
}
return ans;
}
| int main() {
int arr1[] = {1, 3, 4, 9, 10, 11, 12, 17, 20};
assert(func0(arr1, 9, 4) == 5);
int arr2[] = {1, 5, 6, 2, 8};
assert(func0(arr2, 5, 2) == 3);
int arr3[] = {1, 2, 3, 4, 5, 6};
assert(func0(arr3, 6, 3) == 2);
return 0;
}
| O1 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%r12
mov %esi,%ebp
mov %edx,%r14d
lea -0x1(%rsi),%r13d
movslq %esi,%rsi
mov 0x2deb(%rip),%rcx
mov $0x4,%edx
callq 1070 <qsort@plt>
test %ebp,%ebp
jle 1244 <func0+0x77>
lea -0x1(%rbp),%r15d
mov $0x0,%ebx
jmp 122a <func0+0x5d>
sub %ebx,%eax
add $0x1,%eax
mov %ebp,%ecx
sub %eax,%ecx
cmp %ecx,%r13d
cmovg %ecx,%r13d
lea 0x1(%rbx),%rax
cmp %rbx,%r15
je 1244 <func0+0x77>
mov %rax,%rbx
mov (%r12,%rbx,4),%edi
mov %r12,%r8
mov %r14d,%ecx
mov %ebp,%edx
mov %ebx,%esi
callq 1189 <find_ind>
cmp $0xffffffff,%eax
jne 120e <func0+0x41>
jmp 121e <func0+0x51>
mov %r13d,%eax
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov r12, rdi
mov ebp, esi
mov r14d, edx
lea r13d, [rsi-1]
movsxd rsi, esi
mov rcx, cs:strcmp_ptr
mov edx, 4
call _qsort
test ebp, ebp
jle short loc_1240
mov r15d, ebp
mov ebx, 0
jmp short loc_1216
loc_120D:
add rbx, 1
cmp rbx, r15
jz short loc_1240
loc_1216:
mov esi, ebx
mov edi, [r12+rbx*4]
mov r8, r12
mov ecx, r14d
mov edx, ebp
call find_ind
cmp eax, 0FFFFFFFFh
jz short loc_120D
sub eax, ebx
add eax, 1
mov edx, ebp
sub edx, eax
cmp r13d, edx
cmovg r13d, edx
jmp short loc_120D
loc_1240:
mov eax, r13d
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | long long func0(long long a1, int a2, unsigned int a3)
{
int v4; // r13d
long long i; // rbx
int ind; // eax
v4 = a2 - 1;
qsort(a1, a2, 4LL, &strcmp);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
{
ind = find_ind(*(unsigned int *)(a1 + 4 * i), (unsigned int)i, (unsigned int)a2, a3, a1);
if ( ind != -1 && v4 > a2 - (ind - (int)i + 1) )
v4 = a2 - (ind - i + 1);
}
}
return (unsigned int)v4;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV R12,RDI
MOV EBP,ESI
MOV R14D,EDX
LEA R13D,[RSI + -0x1]
MOVSXD RSI,ESI
MOV RCX,qword ptr [0x00103fe0]
MOV EDX,0x4
CALL 0x00101070
TEST EBP,EBP
JLE 0x00101240
MOV R15D,EBP
MOV EBX,0x0
JMP 0x00101216
LAB_0010120d:
ADD RBX,0x1
CMP RBX,R15
JZ 0x00101240
LAB_00101216:
MOV ESI,EBX
MOV EDI,dword ptr [R12 + RBX*0x4]
MOV R8,R12
MOV ECX,R14D
MOV EDX,EBP
CALL 0x00101189
CMP EAX,-0x1
JZ 0x0010120d
SUB EAX,EBX
ADD EAX,0x1
MOV EDX,EBP
SUB EDX,EAX
CMP R13D,EDX
CMOVG R13D,EDX
JMP 0x0010120d
LAB_00101240:
MOV EAX,R13D
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | int func0(void *param_1,uint param_2,int4 param_3)
{
int iVar1;
ulong uVar2;
int iVar3;
iVar3 = param_2 - 1;
qsort(param_1,(long)(int)param_2,4,(__compar_fn_t)PTR_strcmp_00103fe0);
if (0 < (int)param_2) {
uVar2 = 0;
do {
iVar1 = find_ind(*(int4 *)((long)param_1 + uVar2 * 4),uVar2 & 0xffffffff,param_2,param_3
,param_1);
if ((iVar1 != -1) && (iVar1 = param_2 - ((iVar1 - (int)uVar2) + 1), iVar1 < iVar3)) {
iVar3 = iVar1;
}
uVar2 = uVar2 + 1;
} while (uVar2 != param_2);
}
return iVar3;
} |
6,702 | func0 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int find_ind(int key, int i, int n, int k, int arr[]) {
int ind = -1;
int start = i + 1;
int end = n - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (arr[mid] - key <= k) {
ind = mid;
start = mid + 1;
} else {
end = mid;
}
}
return ind;
}
| int func0(int arr[], int n, int k) {
int ans = n - 1;
qsort(arr, n, sizeof(int), (int (*)(const void *, const void *))strcmp);
for (int i = 0; i < n; i++) {
int j = find_ind(arr[i], i, n, k, arr);
if (j != -1) {
ans = (ans < n - (j - i + 1) ? ans : n - (j - i + 1));
}
}
return ans;
}
| int main() {
int arr1[] = {1, 3, 4, 9, 10, 11, 12, 17, 20};
assert(func0(arr1, 9, 4) == 5);
int arr2[] = {1, 5, 6, 2, 8};
assert(func0(arr2, 5, 2) == 3);
int arr3[] = {1, 2, 3, 4, 5, 6};
assert(func0(arr3, 6, 3) == 2);
return 0;
}
| O2 | c | func0:
endbr64
push %r14
movslq %esi,%rsi
mov 0x2c70(%rip),%rcx
push %r13
mov %rsi,%r13
push %r12
lea -0x1(%rsi),%r12d
push %rbp
mov %edx,%ebp
mov $0x4,%edx
push %rbx
mov %rdi,%rbx
callq 1070 <qsort@plt>
test %r13d,%r13d
jle 1410 <func0+0xb0>
mov %r12d,%r14d
mov %r12d,%r10d
xor %r9d,%r9d
nopw 0x0(%rax,%rax,1)
mov (%rbx,%r9,4),%edi
mov %r9d,%r11d
lea 0x1(%r9),%ecx
mov %r12d,%esi
mov $0xffffffff,%r8d
jmp 13d6 <func0+0x76>
nopw %cs:0x0(%rax,%rax,1)
mov %esi,%eax
sub %ecx,%eax
sar %eax
add %ecx,%eax
movslq %eax,%rdx
mov (%rbx,%rdx,4),%edx
sub %edi,%edx
cmp %edx,%ebp
jge 1408 <func0+0xa8>
mov %eax,%esi
cmp %ecx,%esi
jg 13c0 <func0+0x60>
cmp $0xffffffff,%r8d
je 13f4 <func0+0x94>
sub %r11d,%r8d
mov %r13d,%eax
add $0x1,%r8d
sub %r8d,%eax
cmp %eax,%r10d
cmovg %eax,%r10d
lea 0x1(%r9),%rax
cmp %r14,%r9
je 1413 <func0+0xb3>
mov %rax,%r9
jmp 13a0 <func0+0x40>
nopw 0x0(%rax,%rax,1)
lea 0x1(%rax),%ecx
mov %eax,%r8d
jmp 13d6 <func0+0x76>
mov %r12d,%r10d
pop %rbx
mov %r10d,%eax
pop %rbp
pop %r12
pop %r13
pop %r14
retq
| func0:
endbr64
push r14
mov rcx, cs:strcmp_ptr
movsxd r14, esi
push r13
mov rsi, r14
lea r13d, [r14-1]
push r12
push rbp
mov ebp, edx
mov edx, 4
push rbx
mov rbx, rdi
call _qsort
test r14d, r14d
jle loc_1418
mov r12, r14
mov r10d, r13d
xor r9d, r9d
xchg ax, ax
loc_13A0:
mov edi, [rbx+r9*4]
mov r11d, r9d
lea ecx, [r9+1]
mov esi, r13d
mov r8d, 0FFFFFFFFh
jmp short loc_13D6
loc_13C0:
mov eax, esi
sub eax, ecx
sar eax, 1
add eax, ecx
movsxd rdx, eax
mov edx, [rbx+rdx*4]
sub edx, edi
cmp ebp, edx
jge short loc_1410
mov esi, eax
loc_13D6:
cmp esi, ecx
jg short loc_13C0
cmp r8d, 0FFFFFFFFh
jz short loc_13F4
sub r8d, r11d
mov eax, r12d
add r8d, 1
sub eax, r8d
cmp r10d, eax
cmovg r10d, eax
loc_13F4:
add r9, 1
cmp r9, r14
jnz short loc_13A0
pop rbx
mov eax, r10d
pop rbp
pop r12
pop r13
pop r14
retn
loc_1410:
lea ecx, [rax+1]
mov r8d, eax
jmp short loc_13D6
loc_1418:
mov r10d, r13d
pop rbx
pop rbp
mov eax, r10d
pop r12
pop r13
pop r14
retn | long long func0(long long a1, int a2, int a3)
{
long long v3; // r14
unsigned int v4; // r13d
int v6; // r10d
long long v7; // r9
int v8; // ecx
signed int v9; // esi
int v10; // r8d
int v11; // eax
v3 = a2;
v4 = a2 - 1;
qsort(a1, a2, 4LL, &strcmp);
if ( a2 <= 0 )
return v4;
v6 = a2 - 1;
v7 = 0LL;
do
{
v8 = v7 + 1;
v9 = v4;
v10 = -1;
while ( v9 > v8 )
{
v11 = v8 + ((v9 - v8) >> 1);
if ( a3 >= *(_DWORD *)(a1 + 4LL * v11) - *(_DWORD *)(a1 + 4 * v7) )
{
v8 = v11 + 1;
v10 = v11;
}
else
{
v9 = v8 + ((v9 - v8) >> 1);
}
}
if ( v10 != -1 && v6 > (int)v3 - (v10 - (int)v7 + 1) )
v6 = v3 - (v10 - v7 + 1);
++v7;
}
while ( v7 != v3 );
return (unsigned int)v6;
} | func0:
ENDBR64
PUSH R14
MOV RCX,qword ptr [0x00103fe0]
MOVSXD R14,ESI
PUSH R13
MOV RSI,R14
LEA R13D,[R14 + -0x1]
PUSH R12
PUSH RBP
MOV EBP,EDX
MOV EDX,0x4
PUSH RBX
MOV RBX,RDI
CALL 0x00101070
TEST R14D,R14D
JLE 0x00101418
MOV R12,R14
MOV R10D,R13D
XOR R9D,R9D
NOP
LAB_001013a0:
MOV EDI,dword ptr [RBX + R9*0x4]
MOV R11D,R9D
LEA ECX,[R9 + 0x1]
MOV ESI,R13D
MOV R8D,0xffffffff
JMP 0x001013d6
LAB_001013c0:
MOV EAX,ESI
SUB EAX,ECX
SAR EAX,0x1
ADD EAX,ECX
MOVSXD RDX,EAX
MOV EDX,dword ptr [RBX + RDX*0x4]
SUB EDX,EDI
CMP EBP,EDX
JGE 0x00101410
MOV ESI,EAX
LAB_001013d6:
CMP ESI,ECX
JG 0x001013c0
CMP R8D,-0x1
JZ 0x001013f4
SUB R8D,R11D
MOV EAX,R12D
ADD R8D,0x1
SUB EAX,R8D
CMP R10D,EAX
CMOVG R10D,EAX
LAB_001013f4:
ADD R9,0x1
CMP R9,R14
JNZ 0x001013a0
POP RBX
MOV EAX,R10D
POP RBP
POP R12
POP R13
POP R14
RET
LAB_00101410:
LEA ECX,[RAX + 0x1]
MOV R8D,EAX
JMP 0x001013d6
LAB_00101418:
MOV R10D,R13D
POP RBX
POP RBP
MOV EAX,R10D
POP R12
POP R13
POP R14
RET | int func0(void *param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
size_t sVar6;
int iVar7;
int iVar8;
iVar8 = param_2 + -1;
qsort(param_1,(long)param_2,4,(__compar_fn_t)PTR_strcmp_00103fe0);
if (param_2 < 1) {
return iVar8;
}
sVar6 = 0;
iVar7 = iVar8;
do {
iVar3 = (int)sVar6 + 1;
iVar1 = iVar8;
iVar5 = -1;
while (iVar4 = iVar1, iVar3 < iVar4) {
iVar2 = (iVar4 - iVar3 >> 1) + iVar3;
iVar1 = iVar2;
if (*(int *)((long)param_1 + (long)iVar2 * 4) - *(int *)((long)param_1 + sVar6 * 4) <= param_3
) {
iVar3 = iVar2 + 1;
iVar1 = iVar4;
iVar5 = iVar2;
}
}
if ((iVar5 != -1) && (iVar3 = param_2 - ((iVar5 - (int)sVar6) + 1), iVar3 < iVar7)) {
iVar7 = iVar3;
}
sVar6 = sVar6 + 1;
} while (sVar6 != (long)param_2);
return iVar7;
} |
6,703 | func0 | #include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
int find_ind(int key, int i, int n, int k, int arr[]) {
int ind = -1;
int start = i + 1;
int end = n - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (arr[mid] - key <= k) {
ind = mid;
start = mid + 1;
} else {
end = mid;
}
}
return ind;
}
| int func0(int arr[], int n, int k) {
int ans = n - 1;
qsort(arr, n, sizeof(int), (int (*)(const void *, const void *))strcmp);
for (int i = 0; i < n; i++) {
int j = find_ind(arr[i], i, n, k, arr);
if (j != -1) {
ans = (ans < n - (j - i + 1) ? ans : n - (j - i + 1));
}
}
return ans;
}
| int main() {
int arr1[] = {1, 3, 4, 9, 10, 11, 12, 17, 20};
assert(func0(arr1, 9, 4) == 5);
int arr2[] = {1, 5, 6, 2, 8};
assert(func0(arr2, 5, 2) == 3);
int arr3[] = {1, 2, 3, 4, 5, 6};
assert(func0(arr3, 6, 3) == 2);
return 0;
}
| O3 | c | func0:
endbr64
push %r14
movslq %esi,%rsi
mov 0x2cc0(%rip),%rcx
push %r13
mov %rsi,%r13
push %r12
lea -0x1(%rsi),%r12d
push %rbp
mov %edx,%ebp
mov $0x4,%edx
push %rbx
mov %rdi,%rbx
callq 1070 <qsort@plt>
test %r13d,%r13d
jle 13c0 <func0+0xb0>
mov %r12d,%r14d
mov %r12d,%r10d
xor %r9d,%r9d
nopw 0x0(%rax,%rax,1)
mov (%rbx,%r9,4),%edi
mov %r9d,%r11d
lea 0x1(%r9),%ecx
mov %r12d,%esi
mov $0xffffffff,%r8d
jmp 1386 <func0+0x76>
nopw %cs:0x0(%rax,%rax,1)
mov %esi,%eax
sub %ecx,%eax
sar %eax
add %ecx,%eax
movslq %eax,%rdx
mov (%rbx,%rdx,4),%edx
sub %edi,%edx
cmp %edx,%ebp
jge 13b8 <func0+0xa8>
mov %eax,%esi
cmp %ecx,%esi
jg 1370 <func0+0x60>
cmp $0xffffffff,%r8d
je 13a4 <func0+0x94>
sub %r11d,%r8d
mov %r13d,%eax
add $0x1,%r8d
sub %r8d,%eax
cmp %eax,%r10d
cmovg %eax,%r10d
lea 0x1(%r9),%rax
cmp %r9,%r14
je 13c3 <func0+0xb3>
mov %rax,%r9
jmp 1350 <func0+0x40>
nopw 0x0(%rax,%rax,1)
lea 0x1(%rax),%ecx
mov %eax,%r8d
jmp 1386 <func0+0x76>
mov %r12d,%r10d
pop %rbx
mov %r10d,%eax
pop %rbp
pop %r12
pop %r13
pop %r14
retq
| func0:
endbr64
push r14
mov rcx, cs:compar; compar
movsxd r14, esi
push r13
mov rsi, r14; nmemb
lea r13d, [r14-1]
push r12
push rbp
mov ebp, edx
mov edx, 4; size
push rbx
mov rbx, rdi
call _qsort
test r14d, r14d
jle short loc_13C0
mov r12, r14
mov r10d, r13d
xor r9d, r9d
nop word ptr [rax+rax+00h]
loc_1350:
mov edi, [rbx+r9*4]
lea ecx, [r9+1]
mov esi, r13d
mov r8d, 0FFFFFFFFh
jmp short loc_137E
loc_1368:
mov eax, esi
sub eax, ecx
sar eax, 1
add eax, ecx
movsxd rdx, eax
mov edx, [rbx+rdx*4]
sub edx, edi
cmp ebp, edx
jge short loc_13B8
mov esi, eax
loc_137E:
cmp esi, ecx
jg short loc_1368
cmp r8d, 0FFFFFFFFh
jz short loc_139C
sub r8d, r9d
mov eax, r12d
add r8d, 1
sub eax, r8d
cmp r10d, eax
cmovg r10d, eax
loc_139C:
add r9, 1
cmp r14, r9
jnz short loc_1350
pop rbx
mov eax, r10d
pop rbp
pop r12
pop r13
pop r14
retn
loc_13B8:
lea ecx, [rax+1]
mov r8d, eax
jmp short loc_137E
loc_13C0:
mov r10d, r13d
pop rbx
pop rbp
mov eax, r10d
pop r12
pop r13
pop r14
retn | long long func0(void *a1, int a2, int a3)
{
long long v3; // r14
unsigned int v4; // r13d
int v6; // r10d
long long v7; // r9
int v8; // ecx
signed int v9; // esi
int v10; // r8d
int v11; // eax
v3 = a2;
v4 = a2 - 1;
qsort(a1, a2, 4uLL, (__compar_fn_t)&strcmp);
if ( a2 <= 0 )
return v4;
v6 = a2 - 1;
v7 = 0LL;
do
{
v8 = v7 + 1;
v9 = v4;
v10 = -1;
while ( v9 > v8 )
{
v11 = v8 + ((v9 - v8) >> 1);
if ( a3 >= *((_DWORD *)a1 + v11) - *((_DWORD *)a1 + v7) )
{
v8 = v11 + 1;
v10 = v11;
}
else
{
v9 = v8 + ((v9 - v8) >> 1);
}
}
if ( v10 != -1 && v6 > (int)v3 - (v10 - (int)v7 + 1) )
v6 = v3 - (v10 - v7 + 1);
++v7;
}
while ( v3 != v7 );
return (unsigned int)v6;
} | func0:
ENDBR64
PUSH R14
MOV RCX,qword ptr [0x00103fe0]
MOVSXD R14,ESI
PUSH R13
MOV RSI,R14
LEA R13D,[R14 + -0x1]
PUSH R12
PUSH RBP
MOV EBP,EDX
MOV EDX,0x4
PUSH RBX
MOV RBX,RDI
CALL 0x00101070
TEST R14D,R14D
JLE 0x001013c0
MOV R12,R14
MOV R10D,R13D
XOR R9D,R9D
NOP word ptr [RAX + RAX*0x1]
LAB_00101350:
MOV EDI,dword ptr [RBX + R9*0x4]
LEA ECX,[R9 + 0x1]
MOV ESI,R13D
MOV R8D,0xffffffff
JMP 0x0010137e
LAB_00101368:
MOV EAX,ESI
SUB EAX,ECX
SAR EAX,0x1
ADD EAX,ECX
MOVSXD RDX,EAX
MOV EDX,dword ptr [RBX + RDX*0x4]
SUB EDX,EDI
CMP EBP,EDX
JGE 0x001013b8
MOV ESI,EAX
LAB_0010137e:
CMP ESI,ECX
JG 0x00101368
CMP R8D,-0x1
JZ 0x0010139c
SUB R8D,R9D
MOV EAX,R12D
ADD R8D,0x1
SUB EAX,R8D
CMP R10D,EAX
CMOVG R10D,EAX
LAB_0010139c:
ADD R9,0x1
CMP R14,R9
JNZ 0x00101350
POP RBX
MOV EAX,R10D
POP RBP
POP R12
POP R13
POP R14
RET
LAB_001013b8:
LEA ECX,[RAX + 0x1]
MOV R8D,EAX
JMP 0x0010137e
LAB_001013c0:
MOV R10D,R13D
POP RBX
POP RBP
MOV EAX,R10D
POP R12
POP R13
POP R14
RET | int func0(void *param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
size_t sVar6;
int iVar7;
int iVar8;
iVar8 = param_2 + -1;
qsort(param_1,(long)param_2,4,(__compar_fn_t)PTR_strcmp_00103fe0);
if (param_2 < 1) {
return iVar8;
}
sVar6 = 0;
iVar7 = iVar8;
do {
iVar3 = (int)sVar6 + 1;
iVar1 = iVar8;
iVar5 = -1;
while (iVar4 = iVar1, iVar3 < iVar4) {
iVar2 = (iVar4 - iVar3 >> 1) + iVar3;
iVar1 = iVar2;
if (*(int *)((long)param_1 + (long)iVar2 * 4) - *(int *)((long)param_1 + sVar6 * 4) <= param_3
) {
iVar3 = iVar2 + 1;
iVar1 = iVar4;
iVar5 = iVar2;
}
}
if ((iVar5 != -1) && (iVar3 = param_2 - ((iVar5 - (int)sVar6) + 1), iVar3 < iVar7)) {
iVar7 = iVar3;
}
sVar6 = sVar6 + 1;
} while ((long)param_2 != sVar6);
return iVar7;
} |
6,704 | func0 | #include <stdio.h>
#include <stdbool.h>
#include <assert.h>
| bool func0(int *keys, int *values, int size, int x) {
for (int i = 0; i < size; i++) {
if (keys[i] == x) {
return true;
}
}
return false;
}
| int main() {
int keys[] = {1, 2, 3, 4, 5, 6};
int values[] = {10, 20, 30, 40, 50, 60};
int size = 6;
assert(func0(keys, values, size, 5) == true);
assert(func0(keys, values, size, 6) == true);
assert(func0(keys, values, size, 10) == false);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
mov %edx,-0x24(%rbp)
mov %ecx,-0x28(%rbp)
movl $0x0,-0x4(%rbp)
jmp 11ae <func0+0x45>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x28(%rbp)
jne 11aa <func0+0x41>
mov $0x1,%eax
jmp 11bb <func0+0x52>
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x24(%rbp),%eax
jl 1188 <func0+0x1f>
mov $0x0,%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_18], rdi
mov [rbp+var_20], rsi
mov [rbp+var_24], edx
mov [rbp+var_28], ecx
mov [rbp+var_4], 0
jmp short loc_11AE
loc_1188:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_28], eax
jnz short loc_11AA
mov eax, 1
jmp short loc_11BB
loc_11AA:
add [rbp+var_4], 1
loc_11AE:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_24]
jl short loc_1188
mov eax, 0
loc_11BB:
pop rbp
retn | long long func0(long long a1, long long a2, int a3, int a4)
{
int i; // [rsp+24h] [rbp-4h]
for ( i = 0; i < a3; ++i )
{
if ( a4 == *(_DWORD *)(4LL * i + a1) )
return 1LL;
}
return 0LL;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV qword ptr [RBP + -0x20],RSI
MOV dword ptr [RBP + -0x24],EDX
MOV dword ptr [RBP + -0x28],ECX
MOV dword ptr [RBP + -0x4],0x0
JMP 0x001011ae
LAB_00101188:
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]
CMP dword ptr [RBP + -0x28],EAX
JNZ 0x001011aa
MOV EAX,0x1
JMP 0x001011bb
LAB_001011aa:
ADD dword ptr [RBP + -0x4],0x1
LAB_001011ae:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x24]
JL 0x00101188
MOV EAX,0x0
LAB_001011bb:
POP RBP
RET | int8 func0(long param_1,int8 param_2,int param_3,int param_4)
{
int local_c;
local_c = 0;
while( true ) {
if (param_3 <= local_c) {
return 0;
}
if (param_4 == *(int *)(param_1 + (long)local_c * 4)) break;
local_c = local_c + 1;
}
return 1;
} |
6,705 | func0 | #include <stdio.h>
#include <stdbool.h>
#include <assert.h>
| bool func0(int *keys, int *values, int size, int x) {
for (int i = 0; i < size; i++) {
if (keys[i] == x) {
return true;
}
}
return false;
}
| int main() {
int keys[] = {1, 2, 3, 4, 5, 6};
int values[] = {10, 20, 30, 40, 50, 60};
int size = 6;
assert(func0(keys, values, size, 5) == true);
assert(func0(keys, values, size, 6) == true);
assert(func0(keys, values, size, 10) == false);
return 0;
}
| O1 | c | func0:
endbr64
test %edx,%edx
jle 118f <func0+0x26>
mov %rdi,%rax
lea -0x1(%rdx),%edx
lea 0x4(%rdi,%rdx,4),%rdx
cmp %ecx,(%rax)
je 1195 <func0+0x2c>
add $0x4,%rax
cmp %rdx,%rax
jne 117c <func0+0x13>
mov $0x0,%eax
retq
mov $0x0,%eax
retq
mov $0x1,%eax
retq
| func0:
endbr64
test edx, edx
jle short loc_118F
mov rax, rdi
lea edx, [rdx-1]
lea rdx, [rdi+rdx*4+4]
loc_117C:
cmp [rax], ecx
jz short loc_1195
add rax, 4
cmp rax, rdx
jnz short loc_117C
mov eax, 0
retn
loc_118F:
mov eax, 0
retn
loc_1195:
mov eax, 1
retn | long long func0(_DWORD *a1, long long a2, int a3, int a4)
{
_DWORD *v4; // rax
long long v5; // rdx
if ( a3 <= 0 )
return 0LL;
v4 = a1;
v5 = (long long)&a1[a3 - 1 + 1];
while ( *v4 != a4 )
{
if ( ++v4 == (_DWORD *)v5 )
return 0LL;
}
return 1LL;
} | func0:
ENDBR64
TEST EDX,EDX
JLE 0x0010118f
MOV RAX,RDI
LEA EDX,[RDX + -0x1]
LEA RDX,[RDI + RDX*0x4 + 0x4]
LAB_0010117c:
CMP dword ptr [RAX],ECX
JZ 0x00101195
ADD RAX,0x4
CMP RAX,RDX
JNZ 0x0010117c
MOV EAX,0x0
RET
LAB_0010118f:
MOV EAX,0x0
RET
LAB_00101195:
MOV EAX,0x1
RET | int8 func0(int *param_1,int8 param_2,int param_3,int param_4)
{
int *piVar1;
if (param_3 < 1) {
return 0;
}
piVar1 = param_1 + (ulong)(param_3 - 1) + 1;
do {
if (*param_1 == param_4) {
return 1;
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
return 0;
} |
6,706 | func0 | #include <stdio.h>
#include <stdbool.h>
#include <assert.h>
| bool func0(int *keys, int *values, int size, int x) {
for (int i = 0; i < size; i++) {
if (keys[i] == x) {
return true;
}
}
return false;
}
| int main() {
int keys[] = {1, 2, 3, 4, 5, 6};
int values[] = {10, 20, 30, 40, 50, 60};
int size = 6;
assert(func0(keys, values, size, 5) == true);
assert(func0(keys, values, size, 6) == true);
assert(func0(keys, values, size, 10) == false);
return 0;
}
| O2 | c | func0:
endbr64
test %edx,%edx
jle 1170 <func0+0x30>
lea -0x1(%rdx),%eax
lea 0x4(%rdi,%rax,4),%rax
jmp 1161 <func0+0x21>
nopw 0x0(%rax,%rax,1)
add $0x4,%rdi
cmp %rax,%rdi
je 1170 <func0+0x30>
cmp %ecx,(%rdi)
jne 1158 <func0+0x18>
mov $0x1,%eax
retq
nopl 0x0(%rax,%rax,1)
xor %eax,%eax
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
test edx, edx
jle short loc_12B0
lea eax, [rdx-1]
lea rax, [rdi+rax*4+4]
jmp short loc_12A1
loc_1298:
add rdi, 4
cmp rdi, rax
jz short loc_12B0
loc_12A1:
cmp [rdi], ecx
jnz short loc_1298
mov eax, 1
retn
loc_12B0:
xor eax, eax
retn | long long func0(_DWORD *a1, long long a2, int a3, int a4)
{
long long v4; // rax
if ( a3 <= 0 )
return 0LL;
v4 = (long long)&a1[a3 - 1 + 1];
while ( *a1 != a4 )
{
if ( ++a1 == (_DWORD *)v4 )
return 0LL;
}
return 1LL;
} | func0:
ENDBR64
TEST EDX,EDX
JLE 0x001012b0
LEA EAX,[RDX + -0x1]
LEA RAX,[RDI + RAX*0x4 + 0x4]
JMP 0x001012a1
LAB_00101298:
ADD RDI,0x4
CMP RDI,RAX
JZ 0x001012b0
LAB_001012a1:
CMP dword ptr [RDI],ECX
JNZ 0x00101298
MOV EAX,0x1
RET
LAB_001012b0:
XOR EAX,EAX
RET | int8 func0(int *param_1,int8 param_2,int param_3,int param_4)
{
int *piVar1;
if (0 < param_3) {
piVar1 = param_1 + (ulong)(param_3 - 1) + 1;
do {
if (*param_1 == param_4) {
return 1;
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
}
return 0;
} |
6,707 | func0 | #include <stdio.h>
#include <stdbool.h>
#include <assert.h>
| bool func0(int *keys, int *values, int size, int x) {
for (int i = 0; i < size; i++) {
if (keys[i] == x) {
return true;
}
}
return false;
}
| int main() {
int keys[] = {1, 2, 3, 4, 5, 6};
int values[] = {10, 20, 30, 40, 50, 60};
int size = 6;
assert(func0(keys, values, size, 5) == true);
assert(func0(keys, values, size, 6) == true);
assert(func0(keys, values, size, 10) == false);
return 0;
}
| O3 | c | func0:
endbr64
test %edx,%edx
jle 1210 <func0+0x30>
lea -0x1(%rdx),%eax
lea 0x4(%rdi,%rax,4),%rax
jmp 1201 <func0+0x21>
nopw 0x0(%rax,%rax,1)
add $0x4,%rdi
cmp %rax,%rdi
je 1210 <func0+0x30>
cmp %ecx,(%rdi)
jne 11f8 <func0+0x18>
mov $0x1,%eax
retq
nopl 0x0(%rax,%rax,1)
xor %eax,%eax
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
test edx, edx
jle short loc_1170
movsxd rdx, edx
lea rax, [rdi+rdx*4]
jmp short loc_1161
loc_1158:
add rdi, 4
cmp rdi, rax
jz short loc_1170
loc_1161:
cmp [rdi], ecx
jnz short loc_1158
mov eax, 1
retn
loc_1170:
xor eax, eax
retn | long long func0(_DWORD *a1, long long a2, int a3, int a4)
{
_DWORD *v4; // rax
if ( a3 <= 0 )
return 0LL;
v4 = &a1[a3];
while ( *a1 != a4 )
{
if ( ++a1 == v4 )
return 0LL;
}
return 1LL;
} | func0:
ENDBR64
TEST EDX,EDX
JLE 0x00101170
MOVSXD RDX,EDX
LEA RAX,[RDI + RDX*0x4]
JMP 0x00101161
LAB_00101158:
ADD RDI,0x4
CMP RDI,RAX
JZ 0x00101170
LAB_00101161:
CMP dword ptr [RDI],ECX
JNZ 0x00101158
MOV EAX,0x1
RET
LAB_00101170:
XOR EAX,EAX
RET | int8 func0(int *param_1,int8 param_2,int param_3,int param_4)
{
int *piVar1;
if (0 < param_3) {
piVar1 = param_1 + param_3;
do {
if (*param_1 == param_4) {
return 1;
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
}
return 0;
} |
6,708 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int n) {
if (n < 2)
return 1.0;
else
return 1.0 / n + func0(n - 1);
}
| int main() {
assert(func0(10) - 2.9289682539682538 < 1e-9);
assert(func0(4) - 2.083333333333333 < 1e-9);
assert(func0(7) - 2.5928571428571425 < 1e-9);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
mov %edi,-0x4(%rbp)
cmpl $0x1,-0x4(%rbp)
jg 1168 <func0+0x1f>
movsd 0xf62(%rip),%xmm0
jmp 1190 <func0+0x47>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd 0xf53(%rip),%xmm0
divsd %xmm1,%xmm0
movsd %xmm0,-0x10(%rbp)
mov -0x4(%rbp),%eax
sub $0x1,%eax
mov %eax,%edi
callq 1149 <func0>
addsd -0x10(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 10h
mov [rbp+var_4], edi
cmp [rbp+var_4], 1
jg short loc_1168
movsd xmm0, cs:qword_20A8
jmp short locret_1194
loc_1168:
pxor xmm1, xmm1
cvtsi2sd xmm1, [rbp+var_4]
movsd xmm0, cs:qword_20A8
divsd xmm0, xmm1
movsd [rbp+var_10], xmm0
mov eax, [rbp+var_4]
sub eax, 1
mov edi, eax
call func0
addsd xmm0, [rbp+var_10]
locret_1194:
leave
retn | double func0(int a1)
{
if ( a1 > 1 )
return func0((unsigned int)(a1 - 1)) + 1.0 / (double)a1;
else
return 1.0;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x10
MOV dword ptr [RBP + -0x4],EDI
CMP dword ptr [RBP + -0x4],0x1
JG 0x00101168
MOVSD XMM0,qword ptr [0x001020a8]
JMP 0x00101194
LAB_00101168:
PXOR XMM1,XMM1
CVTSI2SD XMM1,dword ptr [RBP + -0x4]
MOVSD XMM0,qword ptr [0x001020a8]
DIVSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x10],XMM0
MOV EAX,dword ptr [RBP + -0x4]
SUB EAX,0x1
MOV EDI,EAX
CALL 0x00101149
ADDSD XMM0,qword ptr [RBP + -0x10]
LAB_00101194:
LEAVE
RET | double func0(int param_1)
{
double dVar1;
double dVar2;
dVar1 = DAT_001020a8;
if (1 < param_1) {
dVar1 = DAT_001020a8 / (double)param_1;
dVar2 = (double)func0(param_1 + -1);
dVar1 = dVar2 + dVar1;
}
return dVar1;
} |
6,709 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int n) {
if (n < 2)
return 1.0;
else
return 1.0 / n + func0(n - 1);
}
| int main() {
assert(func0(10) - 2.9289682539682538 < 1e-9);
assert(func0(4) - 2.083333333333333 < 1e-9);
assert(func0(7) - 2.5928571428571425 < 1e-9);
return 0;
}
| O1 | c | func0:
endbr64
movsd 0xf73(%rip),%xmm0
cmp $0x1,%edi
jg 115b <func0+0x12>
retq
push %rbx
mov %edi,%ebx
lea -0x1(%rdi),%edi
callq 1149 <func0>
movapd %xmm0,%xmm2
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd 0xf4e(%rip),%xmm0
divsd %xmm1,%xmm0
addsd %xmm2,%xmm0
pop %rbx
retq
| func0:
endbr64
movsd xmm0, cs:qword_20A8
cmp edi, 1
jg short loc_115B
retn
loc_115B:
push rbx
mov ebx, edi
lea edi, [rdi-1]
call func0
movapd xmm1, xmm0
pxor xmm2, xmm2
cvtsi2sd xmm2, ebx
movsd xmm0, cs:qword_20A8
divsd xmm0, xmm2
addsd xmm0, xmm1
pop rbx
retn | double func0(int a1)
{
double result; // xmm0_8
result = 1.0;
if ( a1 > 1 )
return 1.0 / (double)a1 + func0((unsigned int)(a1 - 1), 1.0);
return result;
} | func0:
ENDBR64
MOVSD XMM0,qword ptr [0x001020a8]
CMP EDI,0x1
JG 0x0010115b
RET
LAB_0010115b:
PUSH RBX
MOV EBX,EDI
LEA EDI,[RDI + -0x1]
CALL 0x00101149
MOVAPD XMM1,XMM0
PXOR XMM2,XMM2
CVTSI2SD XMM2,EBX
MOVSD XMM0,qword ptr [0x001020a8]
DIVSD XMM0,XMM2
ADDSD XMM0,XMM1
POP RBX
RET | double func0(int param_1)
{
double dVar1;
if (param_1 < 2) {
return DAT_001020a8;
}
dVar1 = (double)func0(DAT_001020a8,param_1 + -1);
return DAT_001020a8 / (double)param_1 + dVar1;
} |
6,710 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int n) {
if (n < 2)
return 1.0;
else
return 1.0 / n + func0(n - 1);
}
| int main() {
assert(func0(10) - 2.9289682539682538 < 1e-9);
assert(func0(4) - 2.083333333333333 < 1e-9);
assert(func0(7) - 2.5928571428571425 < 1e-9);
return 0;
}
| O2 | c | func0:
endbr64
cmp $0x1,%edi
jg 1258 <func0+0x18>
movsd 0xe77(%rip),%xmm0
retq
nopw 0x0(%rax,%rax,1)
jmp 1260 <func0.part.0>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
movsd xmm0, cs:qword_20A8
cmp edi, 1
jg short loc_1248
retn
loc_1248:
pxor xmm1, xmm1
movapd xmm3, xmm0
lea eax, [rdi-1]
cvtsi2sd xmm1, edi
divsd xmm3, xmm1
cmp edi, 2
jnz short loc_1270
addsd xmm3, xmm0
movapd xmm0, xmm3
retn
loc_1270:
pxor xmm1, xmm1
push rbx
movapd xmm2, xmm0
lea ebx, [rdi-2]
cvtsi2sd xmm1, eax
sub rsp, 20h
divsd xmm2, xmm1
movapd xmm1, xmm0
cmp edi, 3
jz short loc_12CD
sub edi, 3
movsd [rsp+28h+var_18], xmm2
movsd [rsp+28h+var_20], xmm3
movsd [rsp+28h+var_10], xmm0
call func0
pxor xmm5, xmm5
movsd xmm1, [rsp+28h+var_10]
movsd xmm2, [rsp+28h+var_18]
cvtsi2sd xmm5, ebx
movsd xmm3, [rsp+28h+var_20]
divsd xmm1, xmm5
addsd xmm1, xmm0
loc_12CD:
addsd xmm1, xmm2
add rsp, 20h
pop rbx
addsd xmm3, xmm1
movapd xmm0, xmm3
retn | __int128 __usercall func0@<xmm0>(int a1@<edi>)
{
__int128 result; // xmm0
int v2; // eax
__int128 v3; // xmm3
double v4; // xmm2_8
double v5; // xmm1_8
result = 0x3FF0000000000000uLL;
if ( a1 > 1 )
{
*((_QWORD *)&v3 + 1) = 0LL;
v2 = a1 - 1;
*(double *)&v3 = 1.0 / (double)a1;
if ( a1 == 2 )
{
*(double *)&v3 = *(double *)&v3 + 1.0;
return v3;
}
else
{
v4 = 1.0 / (double)v2;
v5 = 1.0;
if ( a1 != 3 )
{
v4 = 1.0 / (double)v2;
v3 = (unsigned long long)v3;
v5 = 1.0 / (double)(a1 - 2) + func0((unsigned int)(a1 - 3), 1.0, 1.0);
}
*(double *)&v3 = *(double *)&v3 + v5 + v4;
return v3;
}
}
return result;
} | func0:
ENDBR64
MOVSD XMM0,qword ptr [0x001020a8]
CMP EDI,0x1
JG 0x00101248
RET
LAB_00101248:
PXOR XMM1,XMM1
MOVAPD XMM3,XMM0
LEA EAX,[RDI + -0x1]
CVTSI2SD XMM1,EDI
DIVSD XMM3,XMM1
CMP EDI,0x2
JNZ 0x00101270
ADDSD XMM3,XMM0
MOVAPD XMM0,XMM3
RET
LAB_00101270:
PXOR XMM1,XMM1
PUSH RBX
MOVAPD XMM2,XMM0
LEA EBX,[RDI + -0x2]
CVTSI2SD XMM1,EAX
SUB RSP,0x20
DIVSD XMM2,XMM1
MOVAPD XMM1,XMM0
CMP EDI,0x3
JZ 0x001012cd
SUB EDI,0x3
MOVSD qword ptr [RSP + 0x10],XMM2
MOVSD qword ptr [RSP + 0x8],XMM3
MOVSD qword ptr [RSP + 0x18],XMM0
CALL 0x00101230
PXOR XMM5,XMM5
MOVSD XMM1,qword ptr [RSP + 0x18]
MOVSD XMM2,qword ptr [RSP + 0x10]
CVTSI2SD XMM5,EBX
MOVSD XMM3,qword ptr [RSP + 0x8]
DIVSD XMM1,XMM5
ADDSD XMM1,XMM0
LAB_001012cd:
ADDSD XMM1,XMM2
ADD RSP,0x20
POP RBX
ADDSD XMM3,XMM1
MOVAPD XMM0,XMM3
RET | double func0(int param_1)
{
double dVar1;
double dVar2;
double dVar3;
double dVar4;
dVar1 = DAT_001020a8;
if (param_1 < 2) {
return DAT_001020a8;
}
dVar4 = DAT_001020a8 / (double)param_1;
if (param_1 == 2) {
return dVar4 + DAT_001020a8;
}
dVar3 = DAT_001020a8 / (double)(param_1 + -1);
dVar2 = DAT_001020a8;
if (param_1 != 3) {
dVar2 = (double)func0(param_1 + -3);
dVar2 = dVar1 / (double)(param_1 + -2) + dVar2;
}
return dVar4 + dVar2 + dVar3;
} |
6,711 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int n) {
if (n < 2)
return 1.0;
else
return 1.0 / n + func0(n - 1);
}
| int main() {
assert(func0(10) - 2.9289682539682538 < 1e-9);
assert(func0(4) - 2.083333333333333 < 1e-9);
assert(func0(7) - 2.5928571428571425 < 1e-9);
return 0;
}
| O3 | c | func0:
endbr64
movsd 0xe8c(%rip),%xmm1
cmp $0x1,%edi
jg 1250 <func0+0x20>
movapd %xmm1,%xmm0
retq
nopw %cs:0x0(%rax,%rax,1)
push %rbx
mov %edi,%ebx
lea -0x1(%rdi),%edi
sub $0x10,%rsp
movsd %xmm1,0x8(%rsp)
callq 1230 <func0>
movsd 0x8(%rsp),%xmm1
add $0x10,%rsp
movapd %xmm0,%xmm2
pxor %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
pop %rbx
divsd %xmm0,%xmm1
addsd %xmm2,%xmm1
movapd %xmm1,%xmm0
retq
nopl 0x0(%rax)
| func0:
endbr64
movsd xmm0, cs:qword_20B0
cmp edi, 1
jg short loc_1248
retn
loc_1248:
pxor xmm1, xmm1
movapd xmm2, xmm0
lea eax, [rdi-1]
cvtsi2sd xmm1, edi
divsd xmm2, xmm1
movapd xmm1, xmm0
cmp edi, 2
jnz short loc_1270
addsd xmm2, xmm1
movapd xmm0, xmm2
retn
loc_1270:
pxor xmm3, xmm3
cvtsi2sd xmm3, eax
lea eax, [rdi-2]
divsd xmm1, xmm3
cmp edi, 3
jnz short loc_1298
addsd xmm1, xmm0
addsd xmm2, xmm1
movapd xmm0, xmm2
retn
loc_1298:
pxor xmm3, xmm3
sub rsp, 28h
sub edi, 3
cvtsi2sd xmm3, eax
movsd [rsp+28h+var_10], xmm1
movsd [rsp+28h+var_18], xmm2
divsd xmm0, xmm3
movsd [rsp+28h+var_20], xmm0
call func0
addsd xmm0, [rsp+28h+var_20]
movsd xmm1, [rsp+28h+var_10]
movsd xmm2, [rsp+28h+var_18]
add rsp, 28h
addsd xmm1, xmm0
addsd xmm2, xmm1
movapd xmm0, xmm2
retn | __int128 __usercall func0@<xmm0>(int a1@<edi>)
{
__int128 result; // xmm0
__int128 v2; // xmm2
int v3; // eax
double v4; // xmm1_8
result = 0x3FF0000000000000uLL;
if ( a1 > 1 )
{
*((_QWORD *)&v2 + 1) = 0LL;
*(double *)&v2 = 1.0 / (double)a1;
if ( a1 == 2 )
{
*(double *)&v2 = *(double *)&v2 + 1.0;
return v2;
}
else
{
v4 = 1.0 / (double)(a1 - 1);
if ( a1 == 3 )
{
*(double *)&v2 = *(double *)&v2 + v4 + 1.0;
}
else
{
v2 = (unsigned long long)v2;
v3 = a1 - 2;
*(double *)&v2 = *(double *)&v2 + v4 + func0((unsigned int)(a1 - 3)) + 1.0 / (double)v3;
}
return v2;
}
}
return result;
} | func0:
ENDBR64
MOVSD XMM0,qword ptr [0x001020b0]
CMP EDI,0x1
JG 0x00101248
RET
LAB_00101248:
PXOR XMM1,XMM1
MOVAPD XMM2,XMM0
LEA EAX,[RDI + -0x1]
CVTSI2SD XMM1,EDI
DIVSD XMM2,XMM1
MOVAPD XMM1,XMM0
CMP EDI,0x2
JNZ 0x00101270
ADDSD XMM2,XMM1
MOVAPD XMM0,XMM2
RET
LAB_00101270:
PXOR XMM3,XMM3
CVTSI2SD XMM3,EAX
LEA EAX,[RDI + -0x2]
DIVSD XMM1,XMM3
CMP EDI,0x3
JNZ 0x00101298
ADDSD XMM1,XMM0
ADDSD XMM2,XMM1
MOVAPD XMM0,XMM2
RET
LAB_00101298:
PXOR XMM3,XMM3
SUB RSP,0x28
SUB EDI,0x3
CVTSI2SD XMM3,EAX
MOVSD qword ptr [RSP + 0x18],XMM1
MOVSD qword ptr [RSP + 0x10],XMM2
DIVSD XMM0,XMM3
MOVSD qword ptr [RSP + 0x8],XMM0
CALL 0x00101230
ADDSD XMM0,qword ptr [RSP + 0x8]
MOVSD XMM1,qword ptr [RSP + 0x18]
MOVSD XMM2,qword ptr [RSP + 0x10]
ADD RSP,0x28
ADDSD XMM1,XMM0
ADDSD XMM2,XMM1
MOVAPD XMM0,XMM2
RET | double func0(int param_1)
{
double dVar1;
double dVar2;
double dVar3;
double dVar4;
if (param_1 < 2) {
return DAT_001020b0;
}
dVar4 = DAT_001020b0 / (double)param_1;
if (param_1 == 2) {
return dVar4 + DAT_001020b0;
}
dVar3 = DAT_001020b0 / (double)(param_1 + -1);
if (param_1 == 3) {
return dVar4 + dVar3 + DAT_001020b0;
}
dVar1 = DAT_001020b0 / (double)(param_1 + -2);
dVar2 = (double)func0(param_1 + -3);
return dVar4 + dVar3 + dVar2 + dVar1;
} |
6,712 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *array;
size_t length;
} IntList;
typedef struct {
char **array;
size_t length;
} StrList;
// Comparison function for integers
int compare_ints(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
// Comparison function for strings
int compare_strings(const void *a, const void *b) {
StrList *listA = (StrList *)a;
StrList *listB = (StrList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
int cmp = strcmp(listA->array[i], listB->array[i]);
if (cmp != 0)
return cmp;
}
return 0;
}
int compare_ints_only(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
for (size_t i = 0; i < (listA->length < listB->length ? listA->length : listB->length); i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
void sort_sublists_str(StrList list[], size_t n) {
qsort(list, n, sizeof(StrList), compare_strings);
qsort(list, n, sizeof(StrList), compare_strings);
}
| void func0(IntList list[], size_t n) {
qsort(list, n, sizeof(IntList), compare_ints_only);
qsort(list, n, sizeof(IntList), compare_ints);
}
| int main() {
// First assert
IntList list1[] = {
{ (int[]){2}, 1 },
{ (int[]){0}, 1 },
{ (int[]){1, 3}, 2 },
{ (int[]){0, 7}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
size_t n1 = sizeof(list1) / sizeof(list1[0]);
func0(list1, n1);
IntList expected1[] = {
{ (int[]){0}, 1 },
{ (int[]){2}, 1 },
{ (int[]){0, 7}, 2 },
{ (int[]){1, 3}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
for (size_t i = 0; i < n1; i++) {
assert(list1[i].length == expected1[i].length);
for (size_t j = 0; j < list1[i].length; j++) {
assert(list1[i].array[j] == expected1[i].array[j]);
}
}
// Second assert
IntList list2[] = {
{ (int[]){1}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){4, 5, 6}, 3 },
{ (int[]){7}, 1 },
{ (int[]){10, 11}, 2 }
};
size_t n2 = sizeof(list2) / sizeof(list2[0]);
func0(list2, n2);
IntList expected2[] = {
{ (int[]){1}, 1 },
{ (int[]){7}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){10, 11}, 2 },
{ (int[]){4, 5, 6}, 3 }
};
for (size_t i = 0; i < n2; i++) {
assert(list2[i].length == expected2[i].length);
for (size_t j = 0; j < list2[i].length; j++) {
assert(list2[i].array[j] == expected2[i].array[j]);
}
}
// Third assert
StrList list3[] = {
{ (char*[]){"python"}, 1 },
{ (char*[]){"java", "C", "C++"}, 3 },
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 }
};
size_t n3 = sizeof(list3) / sizeof(list3[0]);
sort_sublists_str(list3, n3);
StrList expected3[] = {
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"python"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 },
{ (char*[]){"java", "C", "C++"}, 3 }
};
for (size_t i = 0; i < n3; i++) {
assert(list3[i].length == expected3[i].length);
for (size_t j = 0; j < list3[i].length; j++) {
assert(strcmp(list3[i].array[j], expected3[i].array[j]) == 0);
}
}
printf("All assertions passed.\n");
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
mov %rdi,-0x8(%rbp)
mov %rsi,-0x10(%rbp)
mov -0x10(%rbp),%rsi
mov -0x8(%rbp),%rax
lea -0x15e(%rip),%rcx
mov $0x10,%edx
mov %rax,%rdi
callq 10a0 <qsort@plt>
mov -0x10(%rbp),%rsi
mov -0x8(%rbp),%rax
lea -0x37f(%rip),%rcx
mov $0x10,%edx
mov %rax,%rdi
callq 10a0 <qsort@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 10h
mov [rbp+base], rdi
mov [rbp+nmemb], rsi
mov rsi, [rbp+nmemb]; nmemb
mov rax, [rbp+base]
lea rdx, compare_ints_only
mov rcx, rdx; compar
mov edx, 10h; size
mov rdi, rax; base
call _qsort
mov rsi, [rbp+nmemb]; nmemb
mov rax, [rbp+base]
lea rdx, compare_ints
mov rcx, rdx; compar
mov edx, 10h; size
mov rdi, rax; base
call _qsort
nop
leave
retn | void func0(void *a1, size_t a2)
{
qsort(a1, a2, 0x10uLL, compare_ints_only);
qsort(a1, a2, 0x10uLL, compare_ints);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x10
MOV qword ptr [RBP + -0x8],RDI
MOV qword ptr [RBP + -0x10],RSI
MOV RSI,qword ptr [RBP + -0x10]
MOV RAX,qword ptr [RBP + -0x8]
LEA RDX,[0x1013ce]
MOV RCX,RDX
MOV EDX,0x10
MOV RDI,RAX
CALL 0x001010a0
MOV RSI,qword ptr [RBP + -0x10]
MOV RAX,qword ptr [RBP + -0x8]
LEA RDX,[0x1011c9]
MOV RCX,RDX
MOV EDX,0x10
MOV RDI,RAX
CALL 0x001010a0
NOP
LEAVE
RET | void func0(void *param_1,size_t param_2)
{
qsort(param_1,param_2,0x10,compare_ints_only);
qsort(param_1,param_2,0x10,compare_ints);
return;
} |
6,713 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *array;
size_t length;
} IntList;
typedef struct {
char **array;
size_t length;
} StrList;
// Comparison function for integers
int compare_ints(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
// Comparison function for strings
int compare_strings(const void *a, const void *b) {
StrList *listA = (StrList *)a;
StrList *listB = (StrList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
int cmp = strcmp(listA->array[i], listB->array[i]);
if (cmp != 0)
return cmp;
}
return 0;
}
int compare_ints_only(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
for (size_t i = 0; i < (listA->length < listB->length ? listA->length : listB->length); i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
void sort_sublists_str(StrList list[], size_t n) {
qsort(list, n, sizeof(StrList), compare_strings);
qsort(list, n, sizeof(StrList), compare_strings);
}
| void func0(IntList list[], size_t n) {
qsort(list, n, sizeof(IntList), compare_ints_only);
qsort(list, n, sizeof(IntList), compare_ints);
}
| int main() {
// First assert
IntList list1[] = {
{ (int[]){2}, 1 },
{ (int[]){0}, 1 },
{ (int[]){1, 3}, 2 },
{ (int[]){0, 7}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
size_t n1 = sizeof(list1) / sizeof(list1[0]);
func0(list1, n1);
IntList expected1[] = {
{ (int[]){0}, 1 },
{ (int[]){2}, 1 },
{ (int[]){0, 7}, 2 },
{ (int[]){1, 3}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
for (size_t i = 0; i < n1; i++) {
assert(list1[i].length == expected1[i].length);
for (size_t j = 0; j < list1[i].length; j++) {
assert(list1[i].array[j] == expected1[i].array[j]);
}
}
// Second assert
IntList list2[] = {
{ (int[]){1}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){4, 5, 6}, 3 },
{ (int[]){7}, 1 },
{ (int[]){10, 11}, 2 }
};
size_t n2 = sizeof(list2) / sizeof(list2[0]);
func0(list2, n2);
IntList expected2[] = {
{ (int[]){1}, 1 },
{ (int[]){7}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){10, 11}, 2 },
{ (int[]){4, 5, 6}, 3 }
};
for (size_t i = 0; i < n2; i++) {
assert(list2[i].length == expected2[i].length);
for (size_t j = 0; j < list2[i].length; j++) {
assert(list2[i].array[j] == expected2[i].array[j]);
}
}
// Third assert
StrList list3[] = {
{ (char*[]){"python"}, 1 },
{ (char*[]){"java", "C", "C++"}, 3 },
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 }
};
size_t n3 = sizeof(list3) / sizeof(list3[0]);
sort_sublists_str(list3, n3);
StrList expected3[] = {
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"python"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 },
{ (char*[]){"java", "C", "C++"}, 3 }
};
for (size_t i = 0; i < n3; i++) {
assert(list3[i].length == expected3[i].length);
for (size_t j = 0; j < list3[i].length; j++) {
assert(strcmp(list3[i].array[j], expected3[i].array[j]) == 0);
}
}
printf("All assertions passed.\n");
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%rbx
mov %rsi,%rbp
lea -0x106(%rip),%rcx
mov $0x10,%edx
callq 10a0 <qsort@plt>
lea -0x170(%rip),%rcx
mov $0x10,%edx
mov %rbp,%rsi
mov %rbx,%rdi
callq 10a0 <qsort@plt>
add $0x8,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
mov rbx, rdi
mov rbp, rsi
lea rcx, compare_ints_only
mov edx, 10h
call _qsort
lea rcx, compare_ints
mov edx, 10h
mov rsi, rbp
mov rdi, rbx
call _qsort
add rsp, 8
pop rbx
pop rbp
retn | long long func0(long long a1, long long a2)
{
qsort(a1, a2, 16LL, compare_ints_only);
return qsort(a1, a2, 16LL, compare_ints);
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBX,RDI
MOV RBP,RSI
LEA RCX,[0x101222]
MOV EDX,0x10
CALL 0x001010a0
LEA RCX,[0x1011c9]
MOV EDX,0x10
MOV RSI,RBP
MOV RDI,RBX
CALL 0x001010a0
ADD RSP,0x8
POP RBX
POP RBP
RET | void func0(void *param_1,size_t param_2)
{
qsort(param_1,param_2,0x10,compare_ints_only);
qsort(param_1,param_2,0x10,compare_ints);
return;
} |
6,714 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *array;
size_t length;
} IntList;
typedef struct {
char **array;
size_t length;
} StrList;
// Comparison function for integers
int compare_ints(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
// Comparison function for strings
int compare_strings(const void *a, const void *b) {
StrList *listA = (StrList *)a;
StrList *listB = (StrList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
int cmp = strcmp(listA->array[i], listB->array[i]);
if (cmp != 0)
return cmp;
}
return 0;
}
int compare_ints_only(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
for (size_t i = 0; i < (listA->length < listB->length ? listA->length : listB->length); i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
void sort_sublists_str(StrList list[], size_t n) {
qsort(list, n, sizeof(StrList), compare_strings);
qsort(list, n, sizeof(StrList), compare_strings);
}
| void func0(IntList list[], size_t n) {
qsort(list, n, sizeof(IntList), compare_ints_only);
qsort(list, n, sizeof(IntList), compare_ints);
}
| int main() {
// First assert
IntList list1[] = {
{ (int[]){2}, 1 },
{ (int[]){0}, 1 },
{ (int[]){1, 3}, 2 },
{ (int[]){0, 7}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
size_t n1 = sizeof(list1) / sizeof(list1[0]);
func0(list1, n1);
IntList expected1[] = {
{ (int[]){0}, 1 },
{ (int[]){2}, 1 },
{ (int[]){0, 7}, 2 },
{ (int[]){1, 3}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
for (size_t i = 0; i < n1; i++) {
assert(list1[i].length == expected1[i].length);
for (size_t j = 0; j < list1[i].length; j++) {
assert(list1[i].array[j] == expected1[i].array[j]);
}
}
// Second assert
IntList list2[] = {
{ (int[]){1}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){4, 5, 6}, 3 },
{ (int[]){7}, 1 },
{ (int[]){10, 11}, 2 }
};
size_t n2 = sizeof(list2) / sizeof(list2[0]);
func0(list2, n2);
IntList expected2[] = {
{ (int[]){1}, 1 },
{ (int[]){7}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){10, 11}, 2 },
{ (int[]){4, 5, 6}, 3 }
};
for (size_t i = 0; i < n2; i++) {
assert(list2[i].length == expected2[i].length);
for (size_t j = 0; j < list2[i].length; j++) {
assert(list2[i].array[j] == expected2[i].array[j]);
}
}
// Third assert
StrList list3[] = {
{ (char*[]){"python"}, 1 },
{ (char*[]){"java", "C", "C++"}, 3 },
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 }
};
size_t n3 = sizeof(list3) / sizeof(list3[0]);
sort_sublists_str(list3, n3);
StrList expected3[] = {
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"python"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 },
{ (char*[]){"java", "C", "C++"}, 3 }
};
for (size_t i = 0; i < n3; i++) {
assert(list3[i].length == expected3[i].length);
for (size_t j = 0; j < list3[i].length; j++) {
assert(strcmp(list3[i].array[j], expected3[i].array[j]) == 0);
}
}
printf("All assertions passed.\n");
return 0;
}
| O2 | c | func0:
endbr64
push %r12
lea -0x11d(%rip),%rcx
mov $0x10,%edx
mov %rsi,%r12
push %rbp
mov %rdi,%rbp
sub $0x8,%rsp
callq 10a0 <qsort@plt>
add $0x8,%rsp
mov %r12,%rsi
mov %rbp,%rdi
lea -0x1a3(%rip),%rcx
pop %rbp
mov $0x10,%edx
pop %r12
jmpq 10a0 <qsort@plt>
| func0:
endbr64
push r12
lea rcx, compare_ints_only
mov edx, 10h
mov r12, rsi
push rbp
mov rbp, rdi
sub rsp, 8
call _qsort
add rsp, 8
mov rsi, r12
mov rdi, rbp
lea rcx, compare_ints
pop rbp
mov edx, 10h
pop r12
jmp _qsort | long long func0(long long a1, long long a2)
{
qsort(a1, a2, 16LL, compare_ints_only);
return qsort(a1, a2, 16LL, compare_ints);
} | func0:
ENDBR64
PUSH R12
LEA RCX,[0x101970]
MOV EDX,0x10
MOV R12,RSI
PUSH RBP
MOV RBP,RDI
SUB RSP,0x8
CALL 0x001010a0
ADD RSP,0x8
MOV RSI,R12
MOV RDI,RBP
LEA RCX,[0x101910]
POP RBP
MOV EDX,0x10
POP R12
JMP 0x001010a0 | void func0(void *param_1,size_t param_2)
{
qsort(param_1,param_2,0x10,compare_ints_only);
qsort(param_1,param_2,0x10,compare_ints);
return;
} |
6,715 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *array;
size_t length;
} IntList;
typedef struct {
char **array;
size_t length;
} StrList;
// Comparison function for integers
int compare_ints(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
// Comparison function for strings
int compare_strings(const void *a, const void *b) {
StrList *listA = (StrList *)a;
StrList *listB = (StrList *)b;
if (listA->length != listB->length)
return (listA->length > listB->length) - (listA->length < listB->length);
for (size_t i = 0; i < listA->length; i++) {
int cmp = strcmp(listA->array[i], listB->array[i]);
if (cmp != 0)
return cmp;
}
return 0;
}
int compare_ints_only(const void *a, const void *b) {
IntList *listA = (IntList *)a;
IntList *listB = (IntList *)b;
for (size_t i = 0; i < (listA->length < listB->length ? listA->length : listB->length); i++) {
if (listA->array[i] != listB->array[i])
return (listA->array[i] > listB->array[i]) - (listA->array[i] < listB->array[i]);
}
return 0;
}
void sort_sublists_str(StrList list[], size_t n) {
qsort(list, n, sizeof(StrList), compare_strings);
qsort(list, n, sizeof(StrList), compare_strings);
}
| void func0(IntList list[], size_t n) {
qsort(list, n, sizeof(IntList), compare_ints_only);
qsort(list, n, sizeof(IntList), compare_ints);
}
| int main() {
// First assert
IntList list1[] = {
{ (int[]){2}, 1 },
{ (int[]){0}, 1 },
{ (int[]){1, 3}, 2 },
{ (int[]){0, 7}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
size_t n1 = sizeof(list1) / sizeof(list1[0]);
func0(list1, n1);
IntList expected1[] = {
{ (int[]){0}, 1 },
{ (int[]){2}, 1 },
{ (int[]){0, 7}, 2 },
{ (int[]){1, 3}, 2 },
{ (int[]){9, 11}, 2 },
{ (int[]){13, 15, 17}, 3 }
};
for (size_t i = 0; i < n1; i++) {
assert(list1[i].length == expected1[i].length);
for (size_t j = 0; j < list1[i].length; j++) {
assert(list1[i].array[j] == expected1[i].array[j]);
}
}
// Second assert
IntList list2[] = {
{ (int[]){1}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){4, 5, 6}, 3 },
{ (int[]){7}, 1 },
{ (int[]){10, 11}, 2 }
};
size_t n2 = sizeof(list2) / sizeof(list2[0]);
func0(list2, n2);
IntList expected2[] = {
{ (int[]){1}, 1 },
{ (int[]){7}, 1 },
{ (int[]){2, 3}, 2 },
{ (int[]){10, 11}, 2 },
{ (int[]){4, 5, 6}, 3 }
};
for (size_t i = 0; i < n2; i++) {
assert(list2[i].length == expected2[i].length);
for (size_t j = 0; j < list2[i].length; j++) {
assert(list2[i].array[j] == expected2[i].array[j]);
}
}
// Third assert
StrList list3[] = {
{ (char*[]){"python"}, 1 },
{ (char*[]){"java", "C", "C++"}, 3 },
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 }
};
size_t n3 = sizeof(list3) / sizeof(list3[0]);
sort_sublists_str(list3, n3);
StrList expected3[] = {
{ (char*[]){"DBMS"}, 1 },
{ (char*[]){"python"}, 1 },
{ (char*[]){"SQL", "HTML"}, 2 },
{ (char*[]){"java", "C", "C++"}, 3 }
};
for (size_t i = 0; i < n3; i++) {
assert(list3[i].length == expected3[i].length);
for (size_t j = 0; j < list3[i].length; j++) {
assert(strcmp(list3[i].array[j], expected3[i].array[j]) == 0);
}
}
printf("All assertions passed.\n");
return 0;
}
| O3 | c | func0:
endbr64
push %r12
lea -0x11d(%rip),%rcx
mov $0x10,%edx
mov %rsi,%r12
push %rbp
mov %rdi,%rbp
sub $0x8,%rsp
callq 10a0 <qsort@plt>
add $0x8,%rsp
mov %r12,%rsi
mov %rbp,%rdi
lea -0x1a3(%rip),%rcx
pop %rbp
mov $0x10,%edx
pop %r12
jmpq 10a0 <qsort@plt>
| func0:
endbr64
push rbp
lea rcx, compare_ints_only; compar
mov edx, 10h; size
mov rbp, rsi
push rbx
mov rbx, rdi
sub rsp, 8
call _qsort
add rsp, 8
mov rsi, rbp; nmemb
mov rdi, rbx; base
lea rcx, compare_ints; compar
pop rbx
mov edx, 10h; size
pop rbp
jmp _qsort | void func0(void *base, size_t nmemb)
{
qsort(base, nmemb, 0x10uLL, compare_ints_only);
qsort(base, nmemb, 0x10uLL, compare_ints);
} | func0:
ENDBR64
PUSH RBP
LEA RCX,[0x101960]
MOV EDX,0x10
MOV RBP,RSI
PUSH RBX
MOV RBX,RDI
SUB RSP,0x8
CALL 0x001010a0
ADD RSP,0x8
MOV RSI,RBP
MOV RDI,RBX
LEA RCX,[0x101900]
POP RBX
MOV EDX,0x10
POP RBP
JMP 0x001010a0 | void func0(void *param_1,size_t param_2)
{
qsort(param_1,param_2,0x10,compare_ints_only);
qsort(param_1,param_2,0x10,compare_ints);
return;
} |
6,716 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int arr1[], int m, int arr2[], int n) {
bool hashset[1000] = {false};
for (int i = 0; i < m; i++) {
hashset[arr1[i]] = true;
}
for (int i = 0; i < n; i++) {
if (hashset[arr2[i]]) {
continue;
} else {
return false;
}
}
return true;
}
| int main() {
int arr1[] = {11, 1, 13, 21, 3, 7};
int arr2[] = {11, 3, 7, 1};
assert(func0(arr1, 6, arr2, 4) == true);
int arr3[] = {1, 2, 3, 4, 5, 6};
int arr4[] = {1, 2, 4};
assert(func0(arr3, 6, arr4, 3) == true);
int arr5[] = {10, 5, 2, 23, 19};
int arr6[] = {19, 5, 3};
assert(func0(arr5, 5, arr6, 3) == false);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x420,%rsp
mov %rdi,-0x408(%rbp)
mov %esi,-0x40c(%rbp)
mov %rdx,-0x418(%rbp)
mov %ecx,-0x410(%rbp)
mov %fs:0x28,%rax
mov %rax,-0x8(%rbp)
xor %eax,%eax
lea -0x3f0(%rbp),%rdx
mov $0x0,%eax
mov $0x7d,%ecx
mov %rdx,%rdi
rep stos %rax,%es:(%rdi)
movl $0x0,-0x3f8(%rbp)
jmp 11f1 <func0+0x88>
mov -0x3f8(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x408(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cltq
movb $0x1,-0x3f0(%rbp,%rax,1)
addl $0x1,-0x3f8(%rbp)
mov -0x3f8(%rbp),%eax
cmp -0x40c(%rbp),%eax
jl 11c4 <func0+0x5b>
movl $0x0,-0x3f4(%rbp)
jmp 1245 <func0+0xdc>
mov -0x3f4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x418(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cltq
movzbl -0x3f0(%rbp,%rax,1),%eax
test %al,%al
je 123e <func0+0xd5>
addl $0x1,-0x3f4(%rbp)
jmp 1245 <func0+0xdc>
mov $0x0,%eax
jmp 1258 <func0+0xef>
mov -0x3f4(%rbp),%eax
cmp -0x410(%rbp),%eax
jl 120b <func0+0xa2>
mov $0x1,%eax
mov -0x8(%rbp),%rsi
xor %fs:0x28,%rsi
je 126c <func0+0x103>
callq 1060 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 420h
mov [rbp+var_408], rdi
mov [rbp+var_40C], esi
mov [rbp+var_418], rdx
mov [rbp+var_410], ecx
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
lea rdx, [rbp+var_3F0]
mov eax, 0
mov ecx, 7Dh ; '}'
mov rdi, rdx
rep stosq
mov [rbp+var_3F8], 0
jmp short loc_11F1
loc_11C4:
mov eax, [rbp+var_3F8]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_408]
add rax, rdx
mov eax, [rax]
cdqe
mov [rbp+rax+var_3F0], 1
add [rbp+var_3F8], 1
loc_11F1:
mov eax, [rbp+var_3F8]
cmp eax, [rbp+var_40C]
jl short loc_11C4
mov [rbp+var_3F4], 0
jmp short loc_1244
loc_120B:
mov eax, [rbp+var_3F4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_418]
add rax, rdx
mov eax, [rax]
cdqe
movzx eax, [rbp+rax+var_3F0]
test al, al
jnz short loc_123C
mov eax, 0
jmp short loc_1257
loc_123C:
nop
add [rbp+var_3F4], 1
loc_1244:
mov eax, [rbp+var_3F4]
cmp eax, [rbp+var_410]
jl short loc_120B
mov eax, 1
loc_1257:
mov rdx, [rbp+var_8]
sub rdx, fs:28h
jz short locret_126B
call ___stack_chk_fail
locret_126B:
leave
retn | long long func0(long long a1, int a2, long long a3, int a4)
{
int i; // [rsp+28h] [rbp-3F8h]
int j; // [rsp+2Ch] [rbp-3F4h]
_BYTE v7[1000]; // [rsp+30h] [rbp-3F0h] BYREF
unsigned long long v8; // [rsp+418h] [rbp-8h]
v8 = __readfsqword(0x28u);
memset(v7, 0, sizeof(v7));
for ( i = 0; i < a2; ++i )
v7[*(int *)(4LL * i + a1)] = 1;
for ( j = 0; j < a4; ++j )
{
if ( !v7[*(int *)(4LL * j + a3)] )
return 0LL;
}
return 1LL;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x420
MOV qword ptr [RBP + -0x408],RDI
MOV dword ptr [RBP + -0x40c],ESI
MOV qword ptr [RBP + -0x418],RDX
MOV dword ptr [RBP + -0x410],ECX
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RBP + -0x8],RAX
XOR EAX,EAX
LEA RDX,[RBP + -0x3f0]
MOV EAX,0x0
MOV ECX,0x7d
MOV RDI,RDX
STOSQ.REP RDI
MOV dword ptr [RBP + -0x3f8],0x0
JMP 0x001011f1
LAB_001011c4:
MOV EAX,dword ptr [RBP + -0x3f8]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x408]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
CDQE
MOV byte ptr [RBP + RAX*0x1 + -0x3f0],0x1
ADD dword ptr [RBP + -0x3f8],0x1
LAB_001011f1:
MOV EAX,dword ptr [RBP + -0x3f8]
CMP EAX,dword ptr [RBP + -0x40c]
JL 0x001011c4
MOV dword ptr [RBP + -0x3f4],0x0
JMP 0x00101244
LAB_0010120b:
MOV EAX,dword ptr [RBP + -0x3f4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x418]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
CDQE
MOVZX EAX,byte ptr [RBP + RAX*0x1 + -0x3f0]
TEST AL,AL
JNZ 0x0010123c
MOV EAX,0x0
JMP 0x00101257
LAB_0010123c:
NOP
ADD dword ptr [RBP + -0x3f4],0x1
LAB_00101244:
MOV EAX,dword ptr [RBP + -0x3f4]
CMP EAX,dword ptr [RBP + -0x410]
JL 0x0010120b
MOV EAX,0x1
LAB_00101257:
MOV RDX,qword ptr [RBP + -0x8]
SUB RDX,qword ptr FS:[0x28]
JZ 0x0010126b
CALL 0x00101060
LAB_0010126b:
LEAVE
RET | int8 func0(long param_1,int param_2,long param_3,int param_4)
{
int8 uVar1;
long lVar2;
char *pcVar3;
long in_FS_OFFSET;
int local_400;
int local_3fc;
char local_3f8 [1000];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
pcVar3 = local_3f8;
for (lVar2 = 0x7d; lVar2 != 0; lVar2 = lVar2 + -1) {
pcVar3[0] = '\0';
pcVar3[1] = '\0';
pcVar3[2] = '\0';
pcVar3[3] = '\0';
pcVar3[4] = '\0';
pcVar3[5] = '\0';
pcVar3[6] = '\0';
pcVar3[7] = '\0';
pcVar3 = pcVar3 + 8;
}
for (local_400 = 0; local_400 < param_2; local_400 = local_400 + 1) {
local_3f8[*(int *)(param_1 + (long)local_400 * 4)] = '\x01';
}
local_3fc = 0;
do {
if (param_4 <= local_3fc) {
uVar1 = 1;
LAB_00101257:
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return uVar1;
}
if (local_3f8[*(int *)(param_3 + (long)local_3fc * 4)] == '\0') {
uVar1 = 0;
goto LAB_00101257;
}
local_3fc = local_3fc + 1;
} while( true );
} |
6,717 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int arr1[], int m, int arr2[], int n) {
bool hashset[1000] = {false};
for (int i = 0; i < m; i++) {
hashset[arr1[i]] = true;
}
for (int i = 0; i < n; i++) {
if (hashset[arr2[i]]) {
continue;
} else {
return false;
}
}
return true;
}
| int main() {
int arr1[] = {11, 1, 13, 21, 3, 7};
int arr2[] = {11, 3, 7, 1};
assert(func0(arr1, 6, arr2, 4) == true);
int arr3[] = {1, 2, 3, 4, 5, 6};
int arr4[] = {1, 2, 4};
assert(func0(arr3, 6, arr4, 3) == true);
int arr5[] = {10, 5, 2, 23, 19};
int arr6[] = {19, 5, 3};
assert(func0(arr5, 5, arr6, 3) == false);
return 0;
}
| O1 | c | func0:
endbr64
sub $0x3f8,%rsp
mov %rdi,%r9
mov %ecx,%r8d
mov %fs:0x28,%rax
mov %rax,0x3e8(%rsp)
xor %eax,%eax
mov %rsp,%rdi
mov $0x7d,%ecx
rep stos %rax,%es:(%rdi)
test %esi,%esi
jle 11b7 <func0+0x4e>
mov %r9,%rax
lea -0x1(%rsi),%ecx
lea 0x4(%r9,%rcx,4),%rsi
movslq (%rax),%rcx
movb $0x1,(%rsp,%rcx,1)
add $0x4,%rax
cmp %rsi,%rax
jne 11a7 <func0+0x3e>
test %r8d,%r8d
jle 11fb <func0+0x92>
mov %rdx,%rax
lea -0x1(%r8),%ecx
lea 0x4(%rdx,%rcx,4),%rcx
movslq (%rax),%rdx
movzbl (%rsp,%rdx,1),%edx
test %dl,%dl
jne 11f0 <func0+0x87>
mov 0x3e8(%rsp),%rax
xor %fs:0x28,%rax
jne 1202 <func0+0x99>
mov %edx,%eax
add $0x3f8,%rsp
retq
add $0x4,%rax
cmp %rcx,%rax
jne 11c8 <func0+0x5f>
jmp 11d3 <func0+0x6a>
mov $0x1,%edx
jmp 11d3 <func0+0x6a>
callq 1060 <__stack_chk_fail@plt>
| func0:
endbr64
sub rsp, 3F8h
mov r10, rdi
mov r9, rdx
mov r8d, ecx
mov rax, fs:28h
mov [rsp+3F8h+var_10], rax
xor eax, eax
mov rdi, rsp
mov ecx, 7Dh ; '}'
rep stosq
test esi, esi
jle short loc_11BA
mov rax, r10
lea edx, [rsi-1]
lea rcx, [r10+rdx*4+4]
loc_11AA:
movsxd rdx, dword ptr [rax]
mov [rsp+rdx+3F8h+var_3F8], 1
add rax, 4
cmp rax, rcx
jnz short loc_11AA
loc_11BA:
test r8d, r8d
jle short loc_11FE
mov rax, r9
lea edx, [r8-1]
lea rcx, [r9+rdx*4+4]
loc_11CB:
movsxd rdx, dword ptr [rax]
movzx edx, [rsp+rdx+3F8h+var_3F8]
test dl, dl
jnz short loc_11F3
loc_11D6:
mov rax, [rsp+3F8h+var_10]
sub rax, fs:28h
jnz short loc_1205
mov eax, edx
add rsp, 3F8h
retn
loc_11F3:
add rax, 4
cmp rax, rcx
jnz short loc_11CB
jmp short loc_11D6
loc_11FE:
mov edx, 1
jmp short loc_11D6
loc_1205:
call ___stack_chk_fail | long long func0(int *a1, int a2, int *a3, int a4)
{
int *v5; // rax
int *v6; // rax
unsigned int v7; // edx
_BYTE v9[1000]; // [rsp+0h] [rbp-3F8h] BYREF
unsigned long long v10; // [rsp+3E8h] [rbp-10h]
v10 = __readfsqword(0x28u);
memset(v9, 0, sizeof(v9));
if ( a2 > 0 )
{
v5 = a1;
do
v9[*v5++] = 1;
while ( v5 != &a1[a2 - 1 + 1] );
}
if ( a4 <= 0 )
{
return 1;
}
else
{
v6 = a3;
do
{
v7 = (unsigned __int8)v9[*v6];
if ( !(_BYTE)v7 )
break;
++v6;
}
while ( v6 != &a3[a4 - 1 + 1] );
}
return v7;
} | func0:
ENDBR64
SUB RSP,0x3f8
MOV R10,RDI
MOV R9,RDX
MOV R8D,ECX
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x3e8],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV ECX,0x7d
STOSQ.REP RDI
TEST ESI,ESI
JLE 0x001011ba
MOV RAX,R10
LEA EDX,[RSI + -0x1]
LEA RCX,[R10 + RDX*0x4 + 0x4]
LAB_001011aa:
MOVSXD RDX,dword ptr [RAX]
MOV byte ptr [RSP + RDX*0x1],0x1
ADD RAX,0x4
CMP RAX,RCX
JNZ 0x001011aa
LAB_001011ba:
TEST R8D,R8D
JLE 0x001011fe
MOV RAX,R9
LEA EDX,[R8 + -0x1]
LEA RCX,[R9 + RDX*0x4 + 0x4]
LAB_001011cb:
MOVSXD RDX,dword ptr [RAX]
MOVZX EDX,byte ptr [RSP + RDX*0x1]
TEST DL,DL
JNZ 0x001011f3
LAB_001011d6:
MOV RAX,qword ptr [RSP + 0x3e8]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101205
MOV EAX,EDX
ADD RSP,0x3f8
RET
LAB_001011f3:
ADD RAX,0x4
CMP RAX,RCX
JNZ 0x001011cb
JMP 0x001011d6
LAB_001011fe:
MOV EDX,0x1
JMP 0x001011d6
LAB_00101205:
CALL 0x00101060 | char func0(int *param_1,int param_2,int *param_3,int param_4)
{
int *piVar1;
long lVar2;
char cVar3;
char *pcVar4;
long in_FS_OFFSET;
char acStack_3f8 [1000];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
pcVar4 = acStack_3f8;
for (lVar2 = 0x7d; lVar2 != 0; lVar2 = lVar2 + -1) {
*(int8 *)pcVar4 = 0;
pcVar4 = (char *)((long)pcVar4 + 8);
}
if (0 < param_2) {
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
acStack_3f8[*param_1] = '\x01';
param_1 = param_1 + 1;
} while (param_1 != piVar1);
}
if (param_4 < 1) {
cVar3 = '\x01';
}
else {
piVar1 = param_3 + (ulong)(param_4 - 1) + 1;
do {
cVar3 = acStack_3f8[*param_3];
if (cVar3 == '\0') break;
param_3 = param_3 + 1;
} while (param_3 != piVar1);
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return cVar3;
} |
6,718 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int arr1[], int m, int arr2[], int n) {
bool hashset[1000] = {false};
for (int i = 0; i < m; i++) {
hashset[arr1[i]] = true;
}
for (int i = 0; i < n; i++) {
if (hashset[arr2[i]]) {
continue;
} else {
return false;
}
}
return true;
}
| int main() {
int arr1[] = {11, 1, 13, 21, 3, 7};
int arr2[] = {11, 3, 7, 1};
assert(func0(arr1, 6, arr2, 4) == true);
int arr3[] = {1, 2, 3, 4, 5, 6};
int arr4[] = {1, 2, 4};
assert(func0(arr3, 6, arr4, 3) == true);
int arr5[] = {10, 5, 2, 23, 19};
int arr6[] = {19, 5, 3};
assert(func0(arr5, 5, arr6, 3) == false);
return 0;
}
| O2 | c | func0:
endbr64
sub $0x3f8,%rsp
mov %rdi,%r8
mov %ecx,%r9d
mov $0x7d,%ecx
mov %fs:0x28,%rax
mov %rax,0x3e8(%rsp)
xor %eax,%eax
mov %rsp,%rdi
rep stos %rax,%es:(%rdi)
test %esi,%esi
jle 11b0 <func0+0x50>
lea -0x1(%rsi),%eax
mov %r8,%rdi
lea 0x4(%r8,%rax,4),%rcx
xchg %ax,%ax
movslq (%rdi),%rax
add $0x4,%rdi
movb $0x1,(%rsp,%rax,1)
cmp %rcx,%rdi
jne 11a0 <func0+0x40>
test %r9d,%r9d
jle 11f3 <func0+0x93>
lea -0x1(%r9),%eax
lea 0x4(%rdx,%rax,4),%rcx
movslq (%rdx),%rax
movzbl (%rsp,%rax,1),%eax
test %al,%al
je 11d8 <func0+0x78>
add $0x4,%rdx
cmp %rcx,%rdx
jne 11be <func0+0x5e>
nopw 0x0(%rax,%rax,1)
mov 0x3e8(%rsp),%rsi
xor %fs:0x28,%rsi
jne 11fa <func0+0x9a>
add $0x3f8,%rsp
retq
mov $0x1,%eax
jmp 11d8 <func0+0x78>
callq 1050 <__stack_chk_fail@plt>
| func0:
endbr64
sub rsp, 3F8h
mov r10, rdi
mov r8d, ecx
mov r9, rdx
mov rax, fs:28h
mov [rsp+3F8h+var_10], rax
xor eax, eax
mov rdi, rsp
mov ecx, 7Dh ; '}'
rep stosq
test esi, esi
jle short loc_1388
lea edx, [rsi-1]
mov rax, r10
lea rcx, [r10+rdx*4+4]
nop dword ptr [rax+00000000h]
loc_1378:
movsxd rdx, dword ptr [rax]
add rax, 4
mov [rsp+rdx+3F8h+var_3F8], 1
cmp rax, rcx
jnz short loc_1378
loc_1388:
test r8d, r8d
jle short loc_13CE
lea edx, [r8-1]
mov rax, r9
lea rcx, [r9+rdx*4+4]
loc_1399:
movsxd rdx, dword ptr [rax]
movzx r8d, [rsp+rdx+3F8h+var_3F8]
test r8b, r8b
jz short loc_13B0
add rax, 4
cmp rax, rcx
jnz short loc_1399
nop
loc_13B0:
mov rax, [rsp+3F8h+var_10]
sub rax, fs:28h
jnz short loc_13D6
mov eax, r8d
add rsp, 3F8h
retn
loc_13CE:
mov r8d, 1
jmp short loc_13B0
loc_13D6:
call ___stack_chk_fail | long long func0(int *a1, int a2, int *a3, int a4)
{
int *v5; // rax
long long v6; // rdx
int *v7; // rax
long long v8; // rcx
unsigned int v9; // r8d
_BYTE v11[1000]; // [rsp+0h] [rbp-3F8h] BYREF
unsigned long long v12; // [rsp+3E8h] [rbp-10h]
v12 = __readfsqword(0x28u);
memset(v11, 0, sizeof(v11));
if ( a2 > 0 )
{
v5 = a1;
do
{
v6 = *v5++;
v11[v6] = 1;
}
while ( v5 != &a1[a2 - 1 + 1] );
}
if ( a4 <= 0 )
{
return 1;
}
else
{
v7 = a3;
v8 = (long long)&a3[a4 - 1 + 1];
do
{
v9 = (unsigned __int8)v11[*v7];
if ( !(_BYTE)v9 )
break;
++v7;
}
while ( v7 != (int *)v8 );
}
return v9;
} | func0:
ENDBR64
SUB RSP,0x3f8
MOV R10,RDI
MOV R8D,ECX
MOV R9,RDX
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x3e8],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV ECX,0x7d
STOSQ.REP RDI
TEST ESI,ESI
JLE 0x00101388
LEA EDX,[RSI + -0x1]
MOV RAX,R10
LEA RCX,[R10 + RDX*0x4 + 0x4]
NOP dword ptr [RAX]
LAB_00101378:
MOVSXD RDX,dword ptr [RAX]
ADD RAX,0x4
MOV byte ptr [RSP + RDX*0x1],0x1
CMP RAX,RCX
JNZ 0x00101378
LAB_00101388:
TEST R8D,R8D
JLE 0x001013ce
LEA EDX,[R8 + -0x1]
MOV RAX,R9
LEA RCX,[R9 + RDX*0x4 + 0x4]
LAB_00101399:
MOVSXD RDX,dword ptr [RAX]
MOVZX R8D,byte ptr [RSP + RDX*0x1]
TEST R8B,R8B
JZ 0x001013b0
ADD RAX,0x4
CMP RAX,RCX
JNZ 0x00101399
NOP
LAB_001013b0:
MOV RAX,qword ptr [RSP + 0x3e8]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x001013d6
MOV EAX,R8D
ADD RSP,0x3f8
RET
LAB_001013ce:
MOV R8D,0x1
JMP 0x001013b0
LAB_001013d6:
CALL 0x00101060 | char func0(int *param_1,int param_2,int *param_3,int param_4)
{
int *piVar1;
int iVar2;
long lVar3;
char *pcVar4;
char cVar5;
long in_FS_OFFSET;
char acStack_3f8 [1000];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
pcVar4 = acStack_3f8;
for (lVar3 = 0x7d; lVar3 != 0; lVar3 = lVar3 + -1) {
*(int8 *)pcVar4 = 0;
pcVar4 = (char *)((long)pcVar4 + 8);
}
if (0 < param_2) {
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
iVar2 = *param_1;
param_1 = param_1 + 1;
acStack_3f8[iVar2] = '\x01';
} while (param_1 != piVar1);
}
if (param_4 < 1) {
cVar5 = '\x01';
}
else {
piVar1 = param_3 + (ulong)(param_4 - 1) + 1;
do {
cVar5 = acStack_3f8[*param_3];
if (cVar5 == '\0') break;
param_3 = param_3 + 1;
} while (param_3 != piVar1);
}
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return cVar5;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,719 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int arr1[], int m, int arr2[], int n) {
bool hashset[1000] = {false};
for (int i = 0; i < m; i++) {
hashset[arr1[i]] = true;
}
for (int i = 0; i < n; i++) {
if (hashset[arr2[i]]) {
continue;
} else {
return false;
}
}
return true;
}
| int main() {
int arr1[] = {11, 1, 13, 21, 3, 7};
int arr2[] = {11, 3, 7, 1};
assert(func0(arr1, 6, arr2, 4) == true);
int arr3[] = {1, 2, 3, 4, 5, 6};
int arr4[] = {1, 2, 4};
assert(func0(arr3, 6, arr4, 3) == true);
int arr5[] = {10, 5, 2, 23, 19};
int arr6[] = {19, 5, 3};
assert(func0(arr5, 5, arr6, 3) == false);
return 0;
}
| O3 | c | func0:
endbr64
sub $0x3f8,%rsp
mov %rdi,%r8
mov %ecx,%r9d
mov $0x7d,%ecx
mov %fs:0x28,%rax
mov %rax,0x3e8(%rsp)
xor %eax,%eax
mov %rsp,%rdi
rep stos %rax,%es:(%rdi)
test %esi,%esi
jle 11b0 <func0+0x50>
lea -0x1(%rsi),%eax
mov %r8,%rdi
lea 0x4(%r8,%rax,4),%rcx
xchg %ax,%ax
movslq (%rdi),%rax
add $0x4,%rdi
movb $0x1,(%rsp,%rax,1)
cmp %rcx,%rdi
jne 11a0 <func0+0x40>
test %r9d,%r9d
jle 11f3 <func0+0x93>
lea -0x1(%r9),%eax
lea 0x4(%rdx,%rax,4),%rcx
movslq (%rdx),%rax
movzbl (%rsp,%rax,1),%eax
test %al,%al
je 11d8 <func0+0x78>
add $0x4,%rdx
cmp %rdx,%rcx
jne 11be <func0+0x5e>
nopw 0x0(%rax,%rax,1)
mov 0x3e8(%rsp),%rsi
xor %fs:0x28,%rsi
jne 11fa <func0+0x9a>
add $0x3f8,%rsp
retq
mov $0x1,%eax
jmp 11d8 <func0+0x78>
callq 1050 <__stack_chk_fail@plt>
| func0:
endbr64
sub rsp, 3F8h
mov r10, rdi
movsxd r8, ecx
mov r9, rdx
mov rax, fs:28h
mov [rsp+3F8h+var_10], rax
xor eax, eax
mov rdi, rsp
mov ecx, 7Dh ; '}'
rep stosq
test esi, esi
jle short loc_1340
movsxd rsi, esi
mov rax, r10
lea rcx, [r10+rsi*4]
loc_1330:
movsxd rdx, dword ptr [rax]
add rax, 4
mov [rsp+rdx+3F8h+var_3F8], 1
cmp rax, rcx
jnz short loc_1330
loc_1340:
test r8d, r8d
jle short loc_137D
mov rax, r9
lea rcx, [r9+r8*4]
loc_134C:
movsxd rdx, dword ptr [rax]
movzx edx, [rsp+rdx+3F8h+var_3F8]
test dl, dl
jz short loc_1360
add rax, 4
cmp rcx, rax
jnz short loc_134C
loc_1360:
mov rax, [rsp+3F8h+var_10]
sub rax, fs:28h
jnz short loc_1384
mov eax, edx
add rsp, 3F8h
retn
loc_137D:
mov edx, 1
jmp short loc_1360
loc_1384:
call ___stack_chk_fail | long long func0(int *a1, int a2, int *a3, int a4)
{
int *v5; // rax
long long v6; // rdx
int *v7; // rax
unsigned int v8; // edx
_BYTE v10[1000]; // [rsp+0h] [rbp-3F8h] BYREF
unsigned long long v11; // [rsp+3E8h] [rbp-10h]
v11 = __readfsqword(0x28u);
memset(v10, 0, sizeof(v10));
if ( a2 > 0 )
{
v5 = a1;
do
{
v6 = *v5++;
v10[v6] = 1;
}
while ( v5 != &a1[a2] );
}
if ( a4 <= 0 )
{
return 1;
}
else
{
v7 = a3;
do
{
v8 = (unsigned __int8)v10[*v7];
if ( !(_BYTE)v8 )
break;
++v7;
}
while ( &a3[a4] != v7 );
}
return v8;
} | func0:
ENDBR64
SUB RSP,0x3f8
MOV R10,RDI
MOVSXD R8,ECX
MOV R9,RDX
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x3e8],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV ECX,0x7d
STOSQ.REP RDI
TEST ESI,ESI
JLE 0x00101340
MOVSXD RSI,ESI
MOV RAX,R10
LEA RCX,[R10 + RSI*0x4]
LAB_00101330:
MOVSXD RDX,dword ptr [RAX]
ADD RAX,0x4
MOV byte ptr [RSP + RDX*0x1],0x1
CMP RAX,RCX
JNZ 0x00101330
LAB_00101340:
TEST R8D,R8D
JLE 0x0010137d
MOV RAX,R9
LEA RCX,[R9 + R8*0x4]
LAB_0010134c:
MOVSXD RDX,dword ptr [RAX]
MOVZX EDX,byte ptr [RSP + RDX*0x1]
TEST DL,DL
JZ 0x00101360
ADD RAX,0x4
CMP RCX,RAX
JNZ 0x0010134c
LAB_00101360:
MOV RAX,qword ptr [RSP + 0x3e8]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101384
MOV EAX,EDX
ADD RSP,0x3f8
RET
LAB_0010137d:
MOV EDX,0x1
JMP 0x00101360
LAB_00101384:
CALL 0x00101060 | char func0(int *param_1,int param_2,int *param_3,int param_4)
{
int *piVar1;
int iVar2;
long lVar3;
char cVar4;
char *pcVar5;
long in_FS_OFFSET;
char acStack_3f8 [1000];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
pcVar5 = acStack_3f8;
for (lVar3 = 0x7d; lVar3 != 0; lVar3 = lVar3 + -1) {
*(int8 *)pcVar5 = 0;
pcVar5 = (char *)((long)pcVar5 + 8);
}
if (0 < param_2) {
piVar1 = param_1 + param_2;
do {
iVar2 = *param_1;
param_1 = param_1 + 1;
acStack_3f8[iVar2] = '\x01';
} while (param_1 != piVar1);
}
if (param_4 < 1) {
cVar4 = '\x01';
}
else {
piVar1 = param_3 + param_4;
do {
cVar4 = acStack_3f8[*param_3];
if (cVar4 == '\0') break;
param_3 = param_3 + 1;
} while (piVar1 != param_3);
}
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return cVar4;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,720 | func0 |
#include <assert.h>
| int func0(int n) {
n += 1;
int powerOf2 = 2;
int cnt = n / 2;
while (powerOf2 <= n) {
int totalPairs = n / powerOf2;
cnt += (totalPairs / 2) * powerOf2;
if (totalPairs & 1) {
cnt += (n % powerOf2);
}
powerOf2 <<= 1;
}
return cnt;
}
| int main() {
assert(func0(16) == 33);
assert(func0(2) == 2);
assert(func0(14) == 28);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x14(%rbp)
addl $0x1,-0x14(%rbp)
movl $0x2,-0xc(%rbp)
mov -0x14(%rbp),%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
mov %eax,-0x8(%rbp)
jmp 11a6 <func0+0x5d>
mov -0x14(%rbp),%eax
cltd
idivl -0xc(%rbp)
mov %eax,-0x4(%rbp)
mov -0x4(%rbp),%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
imul -0xc(%rbp),%eax
add %eax,-0x8(%rbp)
mov -0x4(%rbp),%eax
and $0x1,%eax
test %eax,%eax
je 11a3 <func0+0x5a>
mov -0x14(%rbp),%eax
cltd
idivl -0xc(%rbp)
mov %edx,%eax
add %eax,-0x8(%rbp)
shll -0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x14(%rbp),%eax
jle 1170 <func0+0x27>
mov -0x8(%rbp),%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_14], edi
add [rbp+var_14], 1
mov [rbp+var_C], 2
mov eax, [rbp+var_14]
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
mov [rbp+var_8], eax
jmp short loc_11A6
loc_1170:
mov eax, [rbp+var_14]
cdq
idiv [rbp+var_C]
mov [rbp+var_4], eax
mov eax, [rbp+var_4]
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
imul eax, [rbp+var_C]
add [rbp+var_8], eax
mov eax, [rbp+var_4]
and eax, 1
test eax, eax
jz short loc_11A3
mov eax, [rbp+var_14]
cdq
idiv [rbp+var_C]
mov eax, edx
add [rbp+var_8], eax
loc_11A3:
shl [rbp+var_C], 1
loc_11A6:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_14]
jle short loc_1170
mov eax, [rbp+var_8]
pop rbp
retn | long long func0(int a1)
{
int v2; // [rsp+0h] [rbp-14h]
int v3; // [rsp+8h] [rbp-Ch]
unsigned int v4; // [rsp+Ch] [rbp-8h]
v2 = a1 + 1;
v3 = 2;
v4 = (a1 + 1) / 2;
while ( v3 <= v2 )
{
v4 += v3 * (v2 / v3 / 2);
if ( ((v2 / v3) & 1) != 0 )
v4 += v2 % v3;
v3 *= 2;
}
return v4;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x14],EDI
ADD dword ptr [RBP + -0x14],0x1
MOV dword ptr [RBP + -0xc],0x2
MOV EAX,dword ptr [RBP + -0x14]
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
MOV dword ptr [RBP + -0x8],EAX
JMP 0x001011a6
LAB_00101170:
MOV EAX,dword ptr [RBP + -0x14]
CDQ
IDIV dword ptr [RBP + -0xc]
MOV dword ptr [RBP + -0x4],EAX
MOV EAX,dword ptr [RBP + -0x4]
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
IMUL EAX,dword ptr [RBP + -0xc]
ADD dword ptr [RBP + -0x8],EAX
MOV EAX,dword ptr [RBP + -0x4]
AND EAX,0x1
TEST EAX,EAX
JZ 0x001011a3
MOV EAX,dword ptr [RBP + -0x14]
CDQ
IDIV dword ptr [RBP + -0xc]
MOV EAX,EDX
ADD dword ptr [RBP + -0x8],EAX
LAB_001011a3:
SHL dword ptr [RBP + -0xc],0x1
LAB_001011a6:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x14]
JLE 0x00101170
MOV EAX,dword ptr [RBP + -0x8]
POP RBP
RET | int func0(int param_1)
{
int4 local_14;
int4 local_10;
param_1 = param_1 + 1;
local_10 = param_1 / 2;
for (local_14 = 2; local_14 <= param_1; local_14 = local_14 << 1) {
local_10 = local_10 + ((param_1 / local_14) / 2) * local_14;
if ((param_1 / local_14 & 1U) != 0) {
local_10 = local_10 + param_1 % local_14;
}
}
return local_10;
} |
6,721 | func0 |
#include <assert.h>
| int func0(int n) {
n += 1;
int powerOf2 = 2;
int cnt = n / 2;
while (powerOf2 <= n) {
int totalPairs = n / powerOf2;
cnt += (totalPairs / 2) * powerOf2;
if (totalPairs & 1) {
cnt += (n % powerOf2);
}
powerOf2 <<= 1;
}
return cnt;
}
| int main() {
assert(func0(16) == 33);
assert(func0(2) == 2);
assert(func0(14) == 28);
return 0;
}
| O1 | c | func0:
endbr64
add $0x1,%edi
mov %edi,%esi
shr $0x1f,%esi
add %edi,%esi
sar %esi
cmp $0x1,%edi
jle 118b <func0+0x42>
mov $0x2,%ecx
jmp 116b <func0+0x22>
add %ecx,%ecx
cmp %ecx,%edi
jl 118b <func0+0x42>
mov %edi,%eax
cltd
idiv %ecx
mov %eax,%edx
shr $0x1f,%edx
add %eax,%edx
sar %edx
imul %ecx,%edx
add %edx,%esi
test $0x1,%al
je 1165 <func0+0x1c>
mov %edi,%eax
cltd
idiv %ecx
add %edx,%esi
jmp 1165 <func0+0x1c>
mov %esi,%eax
retq
| func0:
endbr64
add edi, 1
mov esi, edi
shr esi, 1Fh
add esi, edi
sar esi, 1
cmp edi, 1
jle short loc_118B
mov ecx, 2
jmp short loc_116B
loc_1165:
add ecx, ecx
cmp edi, ecx
jl short loc_118B
loc_116B:
mov eax, edi
cdq
idiv ecx
mov edx, eax
shr edx, 1Fh
add edx, eax
sar edx, 1
imul edx, ecx
add esi, edx
test al, 1
jz short loc_1165
mov eax, edi
cdq
idiv ecx
add esi, edx
jmp short loc_1165
loc_118B:
mov eax, esi
retn | long long func0(int a1)
{
int v1; // edi
unsigned int v2; // esi
int i; // ecx
v1 = a1 + 1;
v2 = v1 / 2;
if ( v1 > 1 )
{
for ( i = 2; i <= v1; i *= 2 )
{
v2 += i * (v1 / i / 2);
if ( ((v1 / i) & 1) != 0 )
v2 += v1 % i;
}
}
return v2;
} | func0:
ENDBR64
ADD EDI,0x1
MOV ESI,EDI
SHR ESI,0x1f
ADD ESI,EDI
SAR ESI,0x1
CMP EDI,0x1
JLE 0x0010118b
MOV ECX,0x2
JMP 0x0010116b
LAB_00101165:
ADD ECX,ECX
CMP EDI,ECX
JL 0x0010118b
LAB_0010116b:
MOV EAX,EDI
CDQ
IDIV ECX
MOV EDX,EAX
SHR EDX,0x1f
ADD EDX,EAX
SAR EDX,0x1
IMUL EDX,ECX
ADD ESI,EDX
TEST AL,0x1
JZ 0x00101165
MOV EAX,EDI
CDQ
IDIV ECX
ADD ESI,EDX
JMP 0x00101165
LAB_0010118b:
MOV EAX,ESI
RET | int func0(int param_1)
{
ulong uVar1;
int iVar2;
int iVar3;
param_1 = param_1 + 1;
iVar3 = param_1 / 2;
if (1 < param_1) {
iVar2 = 2;
do {
uVar1 = (long)param_1 / (long)iVar2;
iVar3 = iVar3 + ((int)(((uint)(uVar1 >> 0x1f) & 1) + (int)uVar1) >> 1) * iVar2;
if ((uVar1 & 1) != 0) {
iVar3 = iVar3 + param_1 % iVar2;
}
iVar2 = iVar2 * 2;
} while (iVar2 <= param_1);
}
return iVar3;
} |
6,722 | func0 |
#include <assert.h>
| int func0(int n) {
n += 1;
int powerOf2 = 2;
int cnt = n / 2;
while (powerOf2 <= n) {
int totalPairs = n / powerOf2;
cnt += (totalPairs / 2) * powerOf2;
if (totalPairs & 1) {
cnt += (n % powerOf2);
}
powerOf2 <<= 1;
}
return cnt;
}
| int main() {
assert(func0(16) == 33);
assert(func0(2) == 2);
assert(func0(14) == 28);
return 0;
}
| O2 | c | func0:
endbr64
add $0x1,%edi
mov %edi,%r8d
shr $0x1f,%r8d
add %edi,%r8d
sar %r8d
cmp $0x1,%edi
jle 1263 <func0+0x43>
mov $0x2,%esi
xchg %ax,%ax
mov %edi,%eax
cltd
idiv %esi
mov %eax,%ecx
shr $0x1f,%ecx
add %eax,%ecx
sar %ecx
imul %esi,%ecx
add %ecx,%r8d
add %r8d,%edx
test $0x1,%al
cmovne %edx,%r8d
add %esi,%esi
cmp %esi,%edi
jge 1240 <func0+0x20>
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
add edi, 1
mov r8d, edi
shr r8d, 1Fh
add r8d, edi
sar r8d, 1
cmp edi, 1
jle short loc_1233
mov esi, 2
xchg ax, ax
loc_1210:
mov eax, edi
cdq
idiv esi
mov ecx, eax
shr ecx, 1Fh
add ecx, eax
sar ecx, 1
imul ecx, esi
add r8d, ecx
add edx, r8d
test al, 1
cmovnz r8d, edx
add esi, esi
cmp edi, esi
jge short loc_1210
loc_1233:
mov eax, r8d
retn | long long func0(int a1)
{
int v1; // edi
unsigned int v2; // r8d
int i; // esi
v1 = a1 + 1;
v2 = v1 / 2;
if ( v1 > 1 )
{
for ( i = 2; i <= v1; i *= 2 )
{
v2 += i * (v1 / i / 2);
if ( ((v1 / i) & 1) != 0 )
v2 += v1 % i;
}
}
return v2;
} | func0:
ENDBR64
ADD EDI,0x1
MOV R8D,EDI
SHR R8D,0x1f
ADD R8D,EDI
SAR R8D,0x1
CMP EDI,0x1
JLE 0x00101233
MOV ESI,0x2
NOP
LAB_00101210:
MOV EAX,EDI
CDQ
IDIV ESI
MOV ECX,EAX
SHR ECX,0x1f
ADD ECX,EAX
SAR ECX,0x1
IMUL ECX,ESI
ADD R8D,ECX
ADD EDX,R8D
TEST AL,0x1
CMOVNZ R8D,EDX
ADD ESI,ESI
CMP EDI,ESI
JGE 0x00101210
LAB_00101233:
MOV EAX,R8D
RET | int func0(int param_1)
{
ulong uVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
param_1 = param_1 + 1;
iVar5 = param_1 / 2;
if (1 < param_1) {
iVar4 = 2;
do {
uVar1 = (long)param_1 / (long)iVar4;
iVar5 = iVar5 + ((int)(((uint)(uVar1 >> 0x1f) & 1) + (int)uVar1) >> 1) * iVar4;
if ((uVar1 & 1) != 0) {
iVar5 = param_1 % iVar4 + iVar5;
}
iVar2 = iVar4 * 2;
iVar3 = iVar4 * -2;
iVar4 = iVar2;
} while (SBORROW4(param_1,iVar2) == param_1 + iVar3 < 0);
}
return iVar5;
} |
6,723 | func0 |
#include <assert.h>
| int func0(int n) {
n += 1;
int powerOf2 = 2;
int cnt = n / 2;
while (powerOf2 <= n) {
int totalPairs = n / powerOf2;
cnt += (totalPairs / 2) * powerOf2;
if (totalPairs & 1) {
cnt += (n % powerOf2);
}
powerOf2 <<= 1;
}
return cnt;
}
| int main() {
assert(func0(16) == 33);
assert(func0(2) == 2);
assert(func0(14) == 28);
return 0;
}
| O3 | c | func0:
endbr64
add $0x1,%edi
mov %edi,%r8d
shr $0x1f,%r8d
add %edi,%r8d
sar %r8d
cmp $0x1,%edi
jle 1183 <func0+0x43>
mov $0x2,%esi
xchg %ax,%ax
mov %edi,%eax
cltd
idiv %esi
mov %eax,%ecx
shr $0x1f,%ecx
add %eax,%ecx
sar %ecx
imul %esi,%ecx
add %ecx,%r8d
add %r8d,%edx
test $0x1,%al
cmovne %edx,%r8d
add %esi,%esi
cmp %esi,%edi
jge 1160 <func0+0x20>
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
add edi, 1
mov r8d, edi
shr r8d, 1Fh
add r8d, edi
sar r8d, 1
cmp edi, 1
jle short loc_1183
mov esi, 2
xchg ax, ax
loc_1160:
mov eax, edi
cdq
idiv esi
mov ecx, eax
shr ecx, 1Fh
add ecx, eax
sar ecx, 1
imul ecx, esi
add r8d, ecx
add edx, r8d
test al, 1
cmovnz r8d, edx
add esi, esi
cmp edi, esi
jge short loc_1160
loc_1183:
mov eax, r8d
retn | long long func0(int a1)
{
int v1; // edi
unsigned int v2; // r8d
int i; // esi
v1 = a1 + 1;
v2 = v1 / 2;
if ( v1 > 1 )
{
for ( i = 2; i <= v1; i *= 2 )
{
v2 += i * (v1 / i / 2);
if ( ((v1 / i) & 1) != 0 )
v2 += v1 % i;
}
}
return v2;
} | func0:
ENDBR64
ADD EDI,0x1
MOV R8D,EDI
SHR R8D,0x1f
ADD R8D,EDI
SAR R8D,0x1
CMP EDI,0x1
JLE 0x00101183
MOV ESI,0x2
NOP
LAB_00101160:
MOV EAX,EDI
CDQ
IDIV ESI
MOV ECX,EAX
SHR ECX,0x1f
ADD ECX,EAX
SAR ECX,0x1
IMUL ECX,ESI
ADD R8D,ECX
ADD EDX,R8D
TEST AL,0x1
CMOVNZ R8D,EDX
ADD ESI,ESI
CMP EDI,ESI
JGE 0x00101160
LAB_00101183:
MOV EAX,R8D
RET | int func0(int param_1)
{
ulong uVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
param_1 = param_1 + 1;
iVar5 = param_1 / 2;
if (1 < param_1) {
iVar4 = 2;
do {
uVar1 = (long)param_1 / (long)iVar4;
iVar5 = iVar5 + ((int)(((uint)(uVar1 >> 0x1f) & 1) + (int)uVar1) >> 1) * iVar4;
if ((uVar1 & 1) != 0) {
iVar5 = param_1 % iVar4 + iVar5;
}
iVar2 = iVar4 * 2;
iVar3 = iVar4 * -2;
iVar4 = iVar2;
} while (SBORROW4(param_1,iVar2) == param_1 + iVar3 < 0);
}
return iVar5;
} |
6,724 | func0 |
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
| char** func0(const char* string){
int count = 1;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') count++;
}
char** list = malloc(count * sizeof(char*));
int start = 0, idx = 0;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') {
int len = i - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
idx++;
start = i + 1;
}
}
// Last word
int len = strlen(string) - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
return list;
}
| int main(){
char** res1 = func0("python program");
assert(strcmp(res1[0], "python") == 0);
assert(strcmp(res1[1], "program") == 0);
char** res2 = func0("Data Analysis");
assert(strcmp(res2[0], "Data") == 0);
assert(strcmp(res2[1], "Analysis") == 0);
char** res3 = func0("Hadoop Training");
assert(strcmp(res3[0], "Hadoop") == 0);
assert(strcmp(res3[1], "Training") == 0);
// Free allocated memory
for(int i = 0; i < 2; i++) {
free(res1[i]);
free(res2[i]);
free(res3[i]);
}
free(res1);
free(res2);
free(res3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
push %rbx
sub $0x48,%rsp
mov %rdi,-0x48(%rbp)
movl $0x1,-0x34(%rbp)
movl $0x0,-0x30(%rbp)
jmp 1226 <func0+0x3d>
mov -0x30(%rbp),%eax
movslq %eax,%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
cmp $0x20,%al
jne 1222 <func0+0x39>
addl $0x1,-0x34(%rbp)
addl $0x1,-0x30(%rbp)
mov -0x30(%rbp),%eax
movslq %eax,%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
test %al,%al
jne 120a <func0+0x21>
mov -0x34(%rbp),%eax
cltq
shl $0x3,%rax
mov %rax,%rdi
callq 10f0 <malloc@plt>
mov %rax,-0x18(%rbp)
movl $0x0,-0x2c(%rbp)
movl $0x0,-0x28(%rbp)
movl $0x0,-0x24(%rbp)
jmpq 131b <func0+0x132>
mov -0x24(%rbp),%eax
movslq %eax,%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
cmp $0x20,%al
jne 1317 <func0+0x12e>
mov -0x24(%rbp),%eax
sub -0x2c(%rbp),%eax
mov %eax,-0x1c(%rbp)
mov -0x1c(%rbp),%eax
add $0x1,%eax
cltq
mov -0x28(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x18(%rbp),%rdx
lea (%rcx,%rdx,1),%rbx
mov %rax,%rdi
callq 10f0 <malloc@plt>
mov %rax,(%rbx)
mov -0x1c(%rbp),%eax
movslq %eax,%rdx
mov -0x2c(%rbp),%eax
movslq %eax,%rcx
mov -0x48(%rbp),%rax
add %rax,%rcx
mov -0x28(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rsi
mov -0x18(%rbp),%rax
add %rsi,%rax
mov (%rax),%rax
mov %rcx,%rsi
mov %rax,%rdi
callq 10b0 <strncpy@plt>
mov -0x28(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%rdx
mov -0x1c(%rbp),%eax
cltq
add %rdx,%rax
movb $0x0,(%rax)
addl $0x1,-0x28(%rbp)
mov -0x24(%rbp),%eax
add $0x1,%eax
mov %eax,-0x2c(%rbp)
addl $0x1,-0x24(%rbp)
mov -0x24(%rbp),%eax
movslq %eax,%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
test %al,%al
jne 1269 <func0+0x80>
mov -0x48(%rbp),%rax
mov %rax,%rdi
callq 10c0 <strlen@plt>
mov %eax,%edx
mov -0x2c(%rbp),%eax
sub %eax,%edx
mov %edx,%eax
mov %eax,-0x20(%rbp)
mov -0x20(%rbp),%eax
add $0x1,%eax
cltq
mov -0x28(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x18(%rbp),%rdx
lea (%rcx,%rdx,1),%rbx
mov %rax,%rdi
callq 10f0 <malloc@plt>
mov %rax,(%rbx)
mov -0x20(%rbp),%eax
movslq %eax,%rdx
mov -0x2c(%rbp),%eax
movslq %eax,%rcx
mov -0x48(%rbp),%rax
add %rax,%rcx
mov -0x28(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rsi
mov -0x18(%rbp),%rax
add %rsi,%rax
mov (%rax),%rax
mov %rcx,%rsi
mov %rax,%rdi
callq 10b0 <strncpy@plt>
mov -0x28(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%rdx
mov -0x20(%rbp),%eax
cltq
add %rdx,%rax
movb $0x0,(%rax)
mov -0x18(%rbp),%rax
add $0x48,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
push rbx
sub rsp, 48h
mov [rbp+s], rdi
mov [rbp+var_34], 1
mov [rbp+var_30], 0
jmp short loc_1226
loc_120A:
mov eax, [rbp+var_30]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
cmp al, 20h ; ' '
jnz short loc_1222
add [rbp+var_34], 1
loc_1222:
add [rbp+var_30], 1
loc_1226:
mov eax, [rbp+var_30]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
test al, al
jnz short loc_120A
mov eax, [rbp+var_34]
cdqe
shl rax, 3
mov rdi, rax; size
call _malloc
mov [rbp+var_18], rax
mov [rbp+var_2C], 0
mov [rbp+var_28], 0
mov [rbp+var_24], 0
jmp loc_131B
loc_1269:
mov eax, [rbp+var_24]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
cmp al, 20h ; ' '
jnz loc_1317
mov eax, [rbp+var_24]
sub eax, [rbp+var_2C]
mov [rbp+var_1C], eax
mov eax, [rbp+var_1C]
add eax, 1
cdqe
mov edx, [rbp+var_28]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+var_18]
lea rbx, [rcx+rdx]
mov rdi, rax; size
call _malloc
mov [rbx], rax
mov eax, [rbp+var_1C]
movsxd rdx, eax; n
mov eax, [rbp+var_2C]
movsxd rcx, eax
mov rax, [rbp+s]
add rcx, rax
mov eax, [rbp+var_28]
cdqe
lea rsi, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rsi
mov rax, [rax]
mov rsi, rcx; src
mov rdi, rax; dest
call _strncpy
mov eax, [rbp+var_28]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov rdx, [rax]
mov eax, [rbp+var_1C]
cdqe
add rax, rdx
mov byte ptr [rax], 0
add [rbp+var_28], 1
mov eax, [rbp+var_24]
add eax, 1
mov [rbp+var_2C], eax
loc_1317:
add [rbp+var_24], 1
loc_131B:
mov eax, [rbp+var_24]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
test al, al
jnz loc_1269
mov rax, [rbp+s]
mov rdi, rax; s
call _strlen
mov edx, eax
mov eax, [rbp+var_2C]
sub edx, eax
mov [rbp+var_20], edx
mov eax, [rbp+var_20]
add eax, 1
cdqe
mov edx, [rbp+var_28]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+var_18]
lea rbx, [rcx+rdx]
mov rdi, rax; size
call _malloc
mov [rbx], rax
mov eax, [rbp+var_20]
movsxd rdx, eax; n
mov eax, [rbp+var_2C]
movsxd rcx, eax
mov rax, [rbp+s]
add rcx, rax
mov eax, [rbp+var_28]
cdqe
lea rsi, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rsi
mov rax, [rax]
mov rsi, rcx; src
mov rdi, rax; dest
call _strncpy
mov eax, [rbp+var_28]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov rdx, [rax]
mov eax, [rbp+var_20]
cdqe
add rax, rdx
mov byte ptr [rax], 0
mov rax, [rbp+var_18]
mov rbx, [rbp+var_8]
leave
retn | _QWORD * func0(const char *a1)
{
int v2; // [rsp+1Ch] [rbp-34h]
int i; // [rsp+20h] [rbp-30h]
int v4; // [rsp+24h] [rbp-2Ch]
int v5; // [rsp+28h] [rbp-28h]
int j; // [rsp+2Ch] [rbp-24h]
int v7; // [rsp+30h] [rbp-20h]
_QWORD *v8; // [rsp+38h] [rbp-18h]
v2 = 1;
for ( i = 0; a1[i]; ++i )
{
if ( a1[i] == 32 )
++v2;
}
v8 = malloc(8LL * v2);
v4 = 0;
v5 = 0;
for ( j = 0; a1[j]; ++j )
{
if ( a1[j] == 32 )
{
v8[v5] = malloc(j - v4 + 1);
strncpy((char *)v8[v5], &a1[v4], j - v4);
*(_BYTE *)(v8[v5++] + j - v4) = 0;
v4 = j + 1;
}
}
v7 = strlen(a1) - v4;
v8[v5] = malloc(v7 + 1);
strncpy((char *)v8[v5], &a1[v4], v7);
*(_BYTE *)(v8[v5] + v7) = 0;
return v8;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
PUSH RBX
SUB RSP,0x48
MOV qword ptr [RBP + -0x48],RDI
MOV dword ptr [RBP + -0x34],0x1
MOV dword ptr [RBP + -0x30],0x0
JMP 0x00101226
LAB_0010120a:
MOV EAX,dword ptr [RBP + -0x30]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
CMP AL,0x20
JNZ 0x00101222
ADD dword ptr [RBP + -0x34],0x1
LAB_00101222:
ADD dword ptr [RBP + -0x30],0x1
LAB_00101226:
MOV EAX,dword ptr [RBP + -0x30]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x0010120a
MOV EAX,dword ptr [RBP + -0x34]
CDQE
SHL RAX,0x3
MOV RDI,RAX
CALL 0x001010f0
MOV qword ptr [RBP + -0x18],RAX
MOV dword ptr [RBP + -0x2c],0x0
MOV dword ptr [RBP + -0x28],0x0
MOV dword ptr [RBP + -0x24],0x0
JMP 0x0010131b
LAB_00101269:
MOV EAX,dword ptr [RBP + -0x24]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
CMP AL,0x20
JNZ 0x00101317
MOV EAX,dword ptr [RBP + -0x24]
SUB EAX,dword ptr [RBP + -0x2c]
MOV dword ptr [RBP + -0x1c],EAX
MOV EAX,dword ptr [RBP + -0x1c]
ADD EAX,0x1
CDQE
MOV EDX,dword ptr [RBP + -0x28]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x18]
LEA RBX,[RCX + RDX*0x1]
MOV RDI,RAX
CALL 0x001010f0
MOV qword ptr [RBX],RAX
MOV EAX,dword ptr [RBP + -0x1c]
MOVSXD RDX,EAX
MOV EAX,dword ptr [RBP + -0x2c]
MOVSXD RCX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RCX,RAX
MOV EAX,dword ptr [RBP + -0x28]
CDQE
LEA RSI,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RSI
MOV RAX,qword ptr [RAX]
MOV RSI,RCX
MOV RDI,RAX
CALL 0x001010b0
MOV EAX,dword ptr [RBP + -0x28]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV RDX,qword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x1c]
CDQE
ADD RAX,RDX
MOV byte ptr [RAX],0x0
ADD dword ptr [RBP + -0x28],0x1
MOV EAX,dword ptr [RBP + -0x24]
ADD EAX,0x1
MOV dword ptr [RBP + -0x2c],EAX
LAB_00101317:
ADD dword ptr [RBP + -0x24],0x1
LAB_0010131b:
MOV EAX,dword ptr [RBP + -0x24]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x00101269
MOV RAX,qword ptr [RBP + -0x48]
MOV RDI,RAX
CALL 0x001010c0
MOV EDX,EAX
MOV EAX,dword ptr [RBP + -0x2c]
SUB EDX,EAX
MOV dword ptr [RBP + -0x20],EDX
MOV EAX,dword ptr [RBP + -0x20]
ADD EAX,0x1
CDQE
MOV EDX,dword ptr [RBP + -0x28]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x18]
LEA RBX,[RCX + RDX*0x1]
MOV RDI,RAX
CALL 0x001010f0
MOV qword ptr [RBX],RAX
MOV EAX,dword ptr [RBP + -0x20]
MOVSXD RDX,EAX
MOV EAX,dword ptr [RBP + -0x2c]
MOVSXD RCX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RCX,RAX
MOV EAX,dword ptr [RBP + -0x28]
CDQE
LEA RSI,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RSI
MOV RAX,qword ptr [RAX]
MOV RSI,RCX
MOV RDI,RAX
CALL 0x001010b0
MOV EAX,dword ptr [RBP + -0x28]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV RDX,qword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x20]
CDQE
ADD RAX,RDX
MOV byte ptr [RAX],0x0
MOV RAX,qword ptr [RBP + -0x18]
MOV RBX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(char *param_1)
{
void *pvVar1;
size_t sVar2;
void *pvVar3;
int iVar4;
int local_3c;
int local_38;
int local_34;
int local_30;
int local_2c;
local_3c = 1;
for (local_38 = 0; param_1[local_38] != '\0'; local_38 = local_38 + 1) {
if (param_1[local_38] == ' ') {
local_3c = local_3c + 1;
}
}
pvVar1 = malloc((long)local_3c << 3);
local_34 = 0;
local_30 = 0;
for (local_2c = 0; param_1[local_2c] != '\0'; local_2c = local_2c + 1) {
if (param_1[local_2c] == ' ') {
iVar4 = local_2c - local_34;
pvVar3 = malloc((long)(iVar4 + 1));
*(void **)((long)local_30 * 8 + (long)pvVar1) = pvVar3;
strncpy(*(char **)((long)pvVar1 + (long)local_30 * 8),param_1 + local_34,(long)iVar4);
*(int *)((long)iVar4 + *(long *)((long)pvVar1 + (long)local_30 * 8)) = 0;
local_30 = local_30 + 1;
local_34 = local_2c + 1;
}
}
sVar2 = strlen(param_1);
iVar4 = (int)sVar2 - local_34;
pvVar3 = malloc((long)(iVar4 + 1));
*(void **)((long)local_30 * 8 + (long)pvVar1) = pvVar3;
strncpy(*(char **)((long)pvVar1 + (long)local_30 * 8),param_1 + local_34,(long)iVar4);
*(int *)((long)iVar4 + *(long *)((long)pvVar1 + (long)local_30 * 8)) = 0;
return pvVar1;
} |
6,725 | func0 |
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
| char** func0(const char* string){
int count = 1;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') count++;
}
char** list = malloc(count * sizeof(char*));
int start = 0, idx = 0;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') {
int len = i - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
idx++;
start = i + 1;
}
}
// Last word
int len = strlen(string) - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
return list;
}
| int main(){
char** res1 = func0("python program");
assert(strcmp(res1[0], "python") == 0);
assert(strcmp(res1[1], "program") == 0);
char** res2 = func0("Data Analysis");
assert(strcmp(res2[0], "Data") == 0);
assert(strcmp(res2[1], "Analysis") == 0);
char** res3 = func0("Hadoop Training");
assert(strcmp(res3[0], "Hadoop") == 0);
assert(strcmp(res3[1], "Training") == 0);
// Free allocated memory
for(int i = 0; i < 2; i++) {
free(res1[i]);
free(res2[i]);
free(res3[i]);
}
free(res1);
free(res2);
free(res3);
return 0;
}
| O1 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x18,%rsp
mov %rdi,%r12
movzbl (%rdi),%r13d
test %r13b,%r13b
je 1267 <func0+0xbe>
lea 0x1(%rdi),%rdx
mov %r13d,%eax
mov $0x1,%edi
cmp $0x20,%al
sete %al
movzbl %al,%eax
add %eax,%edi
add $0x1,%rdx
movzbl -0x1(%rdx),%eax
test %al,%al
jne 11d7 <func0+0x2e>
movslq %edi,%rdi
shl $0x3,%rdi
callq 10b0 <malloc@plt>
mov %rax,0x8(%rsp)
mov $0x0,%ebx
mov $0x0,%r15d
mov $0x0,%ebp
jmp 125f <func0+0xb6>
mov %ebx,%r13d
sub %ebp,%r13d
lea 0x1(%r13),%edi
movslq %edi,%rdi
callq 10b0 <malloc@plt>
mov %rax,%r14
movslq %r15d,%rax
mov 0x8(%rsp),%rcx
mov %r14,(%rcx,%rax,8)
movslq %r13d,%r13
movslq %ebp,%rsi
add %r12,%rsi
mov %r13,%rdx
mov %r14,%rdi
callq 1090 <strncpy@plt>
movb $0x0,(%r14,%r13,1)
add $0x1,%r15d
lea 0x1(%rbx),%ebp
add $0x1,%rbx
movzbl (%r12,%rbx,1),%r13d
test %r13b,%r13b
je 1281 <func0+0xd8>
cmp $0x20,%r13b
jne 1251 <func0+0xa8>
jmp 1210 <func0+0x67>
mov $0x8,%edi
callq 10b0 <malloc@plt>
mov %rax,0x8(%rsp)
mov $0x0,%r15d
mov $0x0,%ebp
mov $0xffffffffffffffff,%rcx
mov $0x0,%eax
mov %r12,%rdi
repnz scas %es:(%rdi),%al
not %rcx
lea -0x1(%rcx),%rbx
sub %ebp,%ebx
lea 0x1(%rbx),%edi
movslq %edi,%rdi
callq 10b0 <malloc@plt>
mov %rax,%r13
movslq %r15d,%r15
mov 0x8(%rsp),%rax
mov %r13,(%rax,%r15,8)
movslq %ebx,%rbx
movslq %ebp,%rsi
add %r12,%rsi
mov %rbx,%rdx
mov %r13,%rdi
callq 1090 <strncpy@plt>
movb $0x0,0x0(%r13,%rbx,1)
mov 0x8(%rsp),%rax
add $0x18,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 18h
mov r12, rdi
movzx r13d, byte ptr [rdi]
test r13b, r13b
jz loc_12A8
lea rdx, [rdi+1]
mov eax, r13d
mov edi, 1
loc_1217:
cmp al, 20h ; ' '
setz al
movzx eax, al
add edi, eax
add rdx, 1
movzx eax, byte ptr [rdx-1]
test al, al
jnz short loc_1217
movsxd rdi, edi
shl rdi, 3
call _malloc
mov r15, rax
mov ebx, 1
mov r14d, 0
mov [rsp+48h+var_3C], 0
jmp short loc_1260
loc_1251:
add rbx, 1
movzx r13d, byte ptr [r12+rbx-1]
test r13b, r13b
jz short loc_12C3
loc_1260:
lea ebp, [rbx-1]
cmp r13b, 20h ; ' '
jnz short loc_1251
sub ebp, [rsp+48h+var_3C]
lea edi, [rbp+1]
movsxd rdi, edi
call _malloc
mov r13, rax
movsxd rax, r14d
mov [r15+rax*8], r13
movsxd rbp, ebp
movsxd rsi, [rsp+48h+var_3C]
add rsi, r12
mov rdx, rbp
mov rdi, r13
call _strncpy
mov byte ptr [r13+rbp+0], 0
add r14d, 1
mov [rsp+48h+var_3C], ebx
jmp short loc_1251
loc_12A8:
mov edi, 8
call _malloc
mov r15, rax
mov r14d, 0
mov [rsp+48h+var_3C], 0
loc_12C3:
mov rdi, r12
call _strlen
mov ebx, eax
mov r13d, [rsp+48h+var_3C]
sub ebx, r13d
lea edi, [rbx+1]
movsxd rdi, edi
call _malloc
mov rbp, rax
movsxd r14, r14d
mov [r15+r14*8], rax
movsxd rbx, ebx
movsxd rsi, r13d
add rsi, r12
mov rdx, rbx
mov rdi, rax
call _strncpy
mov byte ptr [rbp+rbx+0], 0
mov rax, r15
add rsp, 18h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | long long func0(char *a1)
{
char v2; // r13
char *v3; // rdx
char v4; // al
int v5; // edi
long long v6; // r15
long long v7; // rbx
int v8; // r14d
int v9; // ebp
long long v10; // r13
int v11; // ebx
long long v12; // rbp
int v14; // [rsp+Ch] [rbp-3Ch]
v2 = *a1;
if ( *a1 )
{
v3 = a1 + 1;
v4 = *a1;
v5 = 1;
do
{
v5 += v4 == 32;
v4 = *v3++;
}
while ( v4 );
v6 = malloc(8LL * v5);
v7 = 1LL;
v8 = 0;
v14 = 0;
do
{
if ( v2 == 32 )
{
v9 = v7 - 1 - v14;
v10 = malloc((int)v7 - v14);
*(_QWORD *)(v6 + 8LL * v8) = v10;
strncpy(v10, &a1[v14], v9);
*(_BYTE *)(v10 + v9) = 0;
++v8;
v14 = v7;
}
v2 = a1[v7++];
}
while ( v2 );
}
else
{
v6 = malloc(8LL);
v8 = 0;
v14 = 0;
}
v11 = strlen(a1) - v14;
v12 = malloc(v11 + 1);
*(_QWORD *)(v6 + 8LL * v8) = v12;
strncpy(v12, &a1[v14], v11);
*(_BYTE *)(v12 + v11) = 0;
return v6;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x18
MOV R12,RDI
MOVZX R13D,byte ptr [RDI]
TEST R13B,R13B
JZ 0x001012a8
LEA RDX,[RDI + 0x1]
MOV EAX,R13D
MOV EDI,0x1
LAB_00101217:
CMP AL,0x20
SETZ AL
MOVZX EAX,AL
ADD EDI,EAX
ADD RDX,0x1
MOVZX EAX,byte ptr [RDX + -0x1]
TEST AL,AL
JNZ 0x00101217
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010f0
MOV R15,RAX
MOV EBX,0x1
MOV R14D,0x0
MOV dword ptr [RSP + 0xc],0x0
JMP 0x00101260
LAB_00101251:
ADD RBX,0x1
MOVZX R13D,byte ptr [R12 + RBX*0x1 + -0x1]
TEST R13B,R13B
JZ 0x001012c3
LAB_00101260:
LEA EBP,[RBX + -0x1]
CMP R13B,0x20
JNZ 0x00101251
SUB EBP,dword ptr [RSP + 0xc]
LEA EDI,[RBP + 0x1]
MOVSXD RDI,EDI
CALL 0x001010f0
MOV R13,RAX
MOVSXD RAX,R14D
MOV qword ptr [R15 + RAX*0x8],R13
MOVSXD RBP,EBP
MOVSXD RSI,dword ptr [RSP + 0xc]
ADD RSI,R12
MOV RDX,RBP
MOV RDI,R13
CALL 0x001010b0
MOV byte ptr [R13 + RBP*0x1],0x0
ADD R14D,0x1
MOV dword ptr [RSP + 0xc],EBX
JMP 0x00101251
LAB_001012a8:
MOV EDI,0x8
CALL 0x001010f0
MOV R15,RAX
MOV R14D,0x0
MOV dword ptr [RSP + 0xc],0x0
LAB_001012c3:
MOV RDI,R12
CALL 0x001010c0
MOV EBX,EAX
MOV R13D,dword ptr [RSP + 0xc]
SUB EBX,R13D
LEA EDI,[RBX + 0x1]
MOVSXD RDI,EDI
CALL 0x001010f0
MOV RBP,RAX
MOVSXD R14,R14D
MOV qword ptr [R15 + R14*0x8],RAX
MOVSXD RBX,EBX
MOVSXD RSI,R13D
ADD RSI,R12
MOV RDX,RBX
MOV RDI,RAX
CALL 0x001010b0
MOV byte ptr [RBP + RBX*0x1],0x0
MOV RAX,R15
ADD RSP,0x18
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | void * func0(char *param_1)
{
char cVar1;
void *pvVar2;
char *pcVar3;
size_t sVar4;
long lVar5;
int iVar6;
int iVar7;
char cVar8;
int local_3c;
cVar8 = *param_1;
if (cVar8 == '\0') {
pvVar2 = malloc(8);
iVar7 = 0;
local_3c = 0;
}
else {
iVar7 = 1;
pcVar3 = param_1 + 1;
cVar1 = cVar8;
do {
iVar7 = iVar7 + (uint)(cVar1 == ' ');
cVar1 = *pcVar3;
pcVar3 = pcVar3 + 1;
} while (cVar1 != '\0');
pvVar2 = malloc((long)iVar7 << 3);
iVar7 = 0;
local_3c = 0;
lVar5 = 1;
do {
if (cVar8 == ' ') {
iVar6 = ((int)lVar5 + -1) - local_3c;
pcVar3 = (char *)malloc((long)(iVar6 + 1));
*(char **)((long)pvVar2 + (long)iVar7 * 8) = pcVar3;
strncpy(pcVar3,param_1 + local_3c,(long)iVar6);
pcVar3[iVar6] = '\0';
iVar7 = iVar7 + 1;
local_3c = (int)lVar5;
}
cVar8 = param_1[lVar5];
lVar5 = lVar5 + 1;
} while (cVar8 != '\0');
}
sVar4 = strlen(param_1);
iVar6 = (int)sVar4 - local_3c;
pcVar3 = (char *)malloc((long)(iVar6 + 1));
*(char **)((long)pvVar2 + (long)iVar7 * 8) = pcVar3;
strncpy(pcVar3,param_1 + local_3c,(long)iVar6);
pcVar3[iVar6] = '\0';
return pvVar2;
} |
6,726 | func0 |
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
| char** func0(const char* string){
int count = 1;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') count++;
}
char** list = malloc(count * sizeof(char*));
int start = 0, idx = 0;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') {
int len = i - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
idx++;
start = i + 1;
}
}
// Last word
int len = strlen(string) - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
return list;
}
| int main(){
char** res1 = func0("python program");
assert(strcmp(res1[0], "python") == 0);
assert(strcmp(res1[1], "program") == 0);
char** res2 = func0("Data Analysis");
assert(strcmp(res2[0], "Data") == 0);
assert(strcmp(res2[1], "Analysis") == 0);
char** res3 = func0("Hadoop Training");
assert(strcmp(res3[0], "Hadoop") == 0);
assert(strcmp(res3[1], "Training") == 0);
// Free allocated memory
for(int i = 0; i < 2; i++) {
free(res1[i]);
free(res2[i]);
free(res3[i]);
}
free(res1);
free(res2);
free(res3);
return 0;
}
| O2 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
mov %rdi,%r12
push %rbp
push %rbx
sub $0x28,%rsp
movzbl (%rdi),%r13d
test %r13b,%r13b
je 1510 <func0+0x140>
lea 0x1(%rdi),%rdx
mov %r13d,%eax
mov $0x1,%edi
xchg %ax,%ax
cmp $0x20,%al
sete %al
add $0x1,%rdx
movzbl %al,%eax
add %eax,%edi
movzbl -0x1(%rdx),%eax
test %al,%al
jne 1400 <func0+0x30>
movslq %edi,%rdi
mov $0x1,%ebx
shl $0x3,%rdi
callq 10d0 <malloc@plt>
xor %ecx,%ecx
xor %edx,%edx
mov %rax,%r15
jmp 143f <func0+0x6f>
add $0x1,%rbx
movzbl -0x1(%r12,%rbx,1),%r13d
test %r13b,%r13b
je 14bd <func0+0xed>
movslq %ecx,%rbp
lea -0x1(%rbx),%eax
lea (%r12,%rbx,1),%r8
movslq %edx,%rsi
shl $0x3,%rbp
lea (%r12,%rsi,1),%r14
lea (%r15,%rbp,1),%r9
cmp $0x20,%r13b
jne 1430 <func0+0x60>
sub %edx,%eax
mov %r8,0x10(%rsp)
movslq %eax,%r13
mov %ecx,0x8(%rsp)
lea 0x1(%r13),%edi
mov %r9,0x18(%rsp)
movslq %edi,%rdi
callq 10d0 <malloc@plt>
mov 0x18(%rsp),%r9
mov %r13,%rdx
mov %r14,%rsi
mov %rax,%rdi
mov %rax,(%r9)
callq 10a0 <strncpy@plt>
mov %ebx,%edx
add $0x1,%rbx
mov 0x8(%rsp),%ecx
movb $0x0,(%rax,%r13,1)
mov 0x10(%rsp),%r8
lea 0x8(%r15,%rbp,1),%r9
movzbl -0x1(%r12,%rbx,1),%r13d
add $0x1,%ecx
mov %r8,%r14
test %r13b,%r13b
jne 143f <func0+0x6f>
mov %edx,%ebx
mov %r12,%rdi
mov %r9,0x8(%rsp)
callq 10b0 <strlen@plt>
sub %ebx,%eax
movslq %eax,%rbx
lea 0x1(%rbx),%edi
movslq %edi,%rdi
callq 10d0 <malloc@plt>
mov 0x8(%rsp),%r9
mov %rbx,%rdx
mov %r14,%rsi
mov %rax,%rdi
mov %rax,(%r9)
callq 10a0 <strncpy@plt>
movb $0x0,(%rax,%rbx,1)
add $0x28,%rsp
mov %r15,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopl 0x0(%rax,%rax,1)
mov $0x8,%edi
mov %r12,%r14
xor %ebx,%ebx
callq 10d0 <malloc@plt>
mov %rax,%r15
mov %rax,%r9
jmp 14bf <func0+0xef>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push r15
push r14
push r13
push r12
mov r12, rdi
push rbp
push rbx
sub rsp, 8
movzx ebp, byte ptr [rdi]
test bpl, bpl
jz loc_14F0
lea rdx, [rdi+1]
mov eax, ebp
mov edi, 1
nop dword ptr [rax+00h]
loc_1400:
cmp al, 20h ; ' '
setz al
add rdx, 1
movzx eax, al
add edi, eax
movzx eax, byte ptr [rdx-1]
test al, al
jnz short loc_1400
movsxd rdi, edi
mov ebx, 1
xor r13d, r13d
xor r15d, r15d
shl rdi, 3
call _malloc
mov r14, rax
jmp short loc_1447
loc_1438:
add rbx, 1
movzx ebp, byte ptr [r12+rbx-1]
test bpl, bpl
jz short loc_1496
loc_1447:
lea eax, [rbx-1]
cmp bpl, 20h ; ' '
jnz short loc_1438
sub eax, r15d
movsxd rbp, eax
lea edi, [rbp+1]
movsxd rdi, edi
call _malloc
movsxd rsi, r15d
mov rdx, rbp
mov r15d, ebx
mov rcx, rax
movsxd rax, r13d
add rsi, r12
add rbx, 1
mov [r14+rax*8], rcx
mov rdi, rcx
add r13d, 1
call _strncpy
mov byte ptr [rax+rbp], 0
movzx ebp, byte ptr [r12+rbx-1]
test bpl, bpl
jnz short loc_1447
loc_1496:
movsxd r13, r13d
lea rbp, [r14+r13*8]
movsxd r13, r15d
add r13, r12
loc_14A3:
mov rdi, r12
call _strlen
mov ebx, eax
sub ebx, r15d
lea edi, [rbx+1]
movsxd rbx, ebx
movsxd rdi, edi
call _malloc
mov rdx, rbx
mov rsi, r13
mov [rbp+0], rax
mov rdi, rax
call _strncpy
mov byte ptr [rax+rbx], 0
add rsp, 8
mov rax, r14
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_14F0:
mov edi, 8
mov r13, r12
xor r15d, r15d
call _malloc
mov r14, rax
mov rbp, rax
jmp short loc_14A3 | long long func0(_BYTE *a1)
{
char v2; // bp
_BYTE *v3; // rdx
char v4; // al
int v5; // edi
long long v6; // rbx
int v7; // r13d
int v8; // r15d
long long v9; // r14
long long v10; // rbp
long long v11; // rax
long long v12; // rsi
_QWORD *v13; // rbp
_BYTE *v14; // r13
int v15; // eax
long long v16; // rbx
long long v17; // rax
v2 = *a1;
if ( *a1 )
{
v3 = a1 + 1;
v4 = *a1;
v5 = 1;
do
{
++v3;
v5 += v4 == 32;
v4 = *(v3 - 1);
}
while ( v4 );
v6 = 1LL;
v7 = 0;
v8 = 0;
v9 = malloc(8LL * v5);
do
{
while ( v2 != 32 )
{
v2 = a1[v6++];
if ( !v2 )
goto LABEL_8;
}
v10 = (int)v6 - 1 - v8;
v11 = malloc((int)v6 - v8);
v12 = v8;
v8 = v6++;
*(_QWORD *)(v9 + 8LL * v7++) = v11;
*(_BYTE *)(strncpy(v11, &a1[v12], v10) + v10) = 0;
v2 = a1[v6 - 1];
}
while ( v2 );
LABEL_8:
v13 = (_QWORD *)(v9 + 8LL * v7);
v14 = &a1[v8];
}
else
{
v14 = a1;
v8 = 0;
v9 = malloc(8LL);
v13 = (_QWORD *)v9;
}
v15 = strlen(a1);
v16 = v15 - v8;
v17 = malloc(v15 - v8 + 1);
*v13 = v17;
*(_BYTE *)(strncpy(v17, v14, v16) + v16) = 0;
return v9;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
MOV R12,RDI
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOVZX EBP,byte ptr [RDI]
TEST BPL,BPL
JZ 0x001014f0
LEA RDX,[RDI + 0x1]
MOV EAX,EBP
MOV EDI,0x1
NOP dword ptr [RAX]
LAB_00101400:
CMP AL,0x20
SETZ AL
ADD RDX,0x1
MOVZX EAX,AL
ADD EDI,EAX
MOVZX EAX,byte ptr [RDX + -0x1]
TEST AL,AL
JNZ 0x00101400
MOVSXD RDI,EDI
MOV EBX,0x1
XOR R13D,R13D
XOR R15D,R15D
SHL RDI,0x3
CALL 0x001010f0
MOV R14,RAX
JMP 0x00101447
LAB_00101438:
ADD RBX,0x1
MOVZX EBP,byte ptr [R12 + RBX*0x1 + -0x1]
TEST BPL,BPL
JZ 0x00101496
LAB_00101447:
LEA EAX,[RBX + -0x1]
CMP BPL,0x20
JNZ 0x00101438
SUB EAX,R15D
MOVSXD RBP,EAX
LEA EDI,[RBP + 0x1]
MOVSXD RDI,EDI
CALL 0x001010f0
MOVSXD RSI,R15D
MOV RDX,RBP
MOV R15D,EBX
MOV RCX,RAX
MOVSXD RAX,R13D
ADD RSI,R12
ADD RBX,0x1
MOV qword ptr [R14 + RAX*0x8],RCX
MOV RDI,RCX
ADD R13D,0x1
CALL 0x001010b0
MOV byte ptr [RAX + RBP*0x1],0x0
MOVZX EBP,byte ptr [R12 + RBX*0x1 + -0x1]
TEST BPL,BPL
JNZ 0x00101447
LAB_00101496:
MOVSXD R13,R13D
LEA RBP,[R14 + R13*0x8]
MOVSXD R13,R15D
ADD R13,R12
LAB_001014a3:
MOV RDI,R12
CALL 0x001010c0
MOV EBX,EAX
SUB EBX,R15D
LEA EDI,[RBX + 0x1]
MOVSXD RBX,EBX
MOVSXD RDI,EDI
CALL 0x001010f0
MOV RDX,RBX
MOV RSI,R13
MOV qword ptr [RBP],RAX
MOV RDI,RAX
CALL 0x001010b0
MOV byte ptr [RAX + RBX*0x1],0x0
ADD RSP,0x8
MOV RAX,R14
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001014f0:
MOV EDI,0x8
MOV R13,R12
XOR R15D,R15D
CALL 0x001010f0
MOV R14,RAX
MOV RBP,RAX
JMP 0x001014a3 | int8 * func0(char *param_1)
{
int iVar1;
char cVar2;
int iVar3;
int8 *puVar4;
char *pcVar5;
size_t sVar6;
char *__dest;
int8 *puVar7;
long lVar8;
char cVar9;
int iVar10;
int iVar11;
cVar9 = *param_1;
if (cVar9 == '\0') {
iVar10 = 0;
puVar7 = (int8 *)malloc(8);
pcVar5 = param_1;
puVar4 = puVar7;
}
else {
iVar10 = 1;
pcVar5 = param_1 + 1;
cVar2 = cVar9;
do {
iVar10 = iVar10 + (uint)(cVar2 == ' ');
cVar2 = *pcVar5;
pcVar5 = pcVar5 + 1;
} while (cVar2 != '\0');
iVar11 = 0;
puVar4 = (int8 *)malloc((long)iVar10 << 3);
lVar8 = 1;
iVar10 = 0;
do {
while (iVar1 = (int)lVar8, cVar9 == ' ') {
iVar3 = (iVar1 + -1) - iVar10;
pcVar5 = (char *)malloc((long)(iVar3 + 1));
puVar4[iVar11] = pcVar5;
iVar11 = iVar11 + 1;
pcVar5 = strncpy(pcVar5,param_1 + iVar10,(long)iVar3);
pcVar5[iVar3] = '\0';
cVar9 = param_1[lVar8];
lVar8 = lVar8 + 1;
iVar10 = iVar1;
if (cVar9 == '\0') goto LAB_00101496;
}
cVar9 = param_1[lVar8];
lVar8 = lVar8 + 1;
} while (cVar9 != '\0');
LAB_00101496:
puVar7 = puVar4 + iVar11;
pcVar5 = param_1 + iVar10;
}
sVar6 = strlen(param_1);
iVar10 = (int)sVar6 - iVar10;
__dest = (char *)malloc((long)(iVar10 + 1));
*puVar7 = __dest;
pcVar5 = strncpy(__dest,pcVar5,(long)iVar10);
pcVar5[iVar10] = '\0';
return puVar4;
} |
6,727 | func0 |
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
| char** func0(const char* string){
int count = 1;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') count++;
}
char** list = malloc(count * sizeof(char*));
int start = 0, idx = 0;
for(int i = 0; string[i] != '\0'; i++) {
if(string[i] == ' ') {
int len = i - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
idx++;
start = i + 1;
}
}
// Last word
int len = strlen(string) - start;
list[idx] = malloc(len + 1);
strncpy(list[idx], string + start, len);
list[idx][len] = '\0';
return list;
}
| int main(){
char** res1 = func0("python program");
assert(strcmp(res1[0], "python") == 0);
assert(strcmp(res1[1], "program") == 0);
char** res2 = func0("Data Analysis");
assert(strcmp(res2[0], "Data") == 0);
assert(strcmp(res2[1], "Analysis") == 0);
char** res3 = func0("Hadoop Training");
assert(strcmp(res3[0], "Hadoop") == 0);
assert(strcmp(res3[1], "Training") == 0);
// Free allocated memory
for(int i = 0; i < 2; i++) {
free(res1[i]);
free(res2[i]);
free(res3[i]);
}
free(res1);
free(res2);
free(res3);
return 0;
}
| O3 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
push %rbp
mov %rdi,%rbp
push %rbx
sub $0x28,%rsp
movzbl (%rdi),%r12d
test %r12b,%r12b
je 1548 <func0+0x178>
lea 0x1(%rdi),%rdx
mov %r12d,%eax
mov $0x1,%edi
xchg %ax,%ax
cmp $0x20,%al
sete %al
add $0x1,%rdx
movzbl %al,%eax
add %eax,%edi
movzbl -0x1(%rdx),%eax
test %al,%al
jne 1400 <func0+0x30>
movslq %edi,%rdi
mov $0x1,%ebx
shl $0x3,%rdi
callq 10d0 <malloc@plt>
xor %r8d,%r8d
xor %r10d,%r10d
xor %edx,%edx
mov %rax,%r14
xor %eax,%eax
nopl 0x0(%rax)
lea 0x0(,%rdx,8),%r13
lea -0x1(%rbx),%edi
mov %ebx,%r15d
lea (%r14,%r13,1),%r9
lea 0x0(%rbp,%rax,1),%rsi
lea 0x0(%rbp,%rbx,1),%rcx
cmp $0x20,%r12b
je 14c0 <func0+0xf0>
add $0x1,%rbx
movzbl -0x1(%rbp,%rbx,1),%r12d
test %r12b,%r12b
jne 1438 <func0+0x68>
mov %r10d,%ebx
mov %rbp,%rdi
mov %r9,0x8(%rsp)
mov %rsi,(%rsp)
callq 10b0 <strlen@plt>
sub %ebx,%eax
movslq %eax,%rbx
lea 0x1(%rbx),%edi
movslq %edi,%rdi
callq 10d0 <malloc@plt>
mov 0x8(%rsp),%r9
mov (%rsp),%rsi
mov %rbx,%rdx
mov %rax,%rdi
mov %rax,(%r9)
callq 10a0 <strncpy@plt>
movb $0x0,(%rax,%rbx,1)
add $0x28,%rsp
mov %r14,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopw 0x0(%rax,%rax,1)
sub %r10d,%edi
mov %r8d,0x8(%rsp)
add $0x1,%rbx
movslq %edi,%r12
mov %rcx,(%rsp)
lea 0x1(%r12),%edi
mov %r9,0x18(%rsp)
movslq %edi,%rdi
mov %rsi,0x10(%rsp)
callq 10d0 <malloc@plt>
mov 0x18(%rsp),%r9
mov 0x10(%rsp),%rsi
mov %r12,%rdx
mov %rax,%rdi
mov %rax,(%r9)
callq 10a0 <strncpy@plt>
mov 0x8(%rsp),%r8d
mov (%rsp),%rcx
lea 0x8(%r14,%r13,1),%r9
movb $0x0,(%rax,%r12,1)
movzbl -0x1(%rbp,%rbx,1),%r12d
add $0x1,%r8d
test %r12b,%r12b
je 1538 <func0+0x168>
movslq %r15d,%rax
movslq %r8d,%rdx
mov %rax,%r10
jmpq 1438 <func0+0x68>
nopw 0x0(%rax,%rax,1)
mov %rcx,%rsi
mov %r15d,%r10d
jmpq 1469 <func0+0x99>
nopl 0x0(%rax,%rax,1)
mov $0x8,%edi
xor %ebx,%ebx
callq 10d0 <malloc@plt>
mov %rbp,%rsi
mov %rax,%r14
mov %rax,%r9
jmpq 146c <func0+0x9c>
nopw %cs:0x0(%rax,%rax,1)
nopl 0x0(%rax)
| func0:
endbr64
push r15
push r14
push r13
push r12
mov r12, rdi
push rbp
push rbx
sub rsp, 18h
movzx ebp, byte ptr [rdi]
test bpl, bpl
jz loc_14F8
lea rdx, [rdi+1]
mov eax, ebp
mov edi, 1
nop dword ptr [rax+00h]
loc_13F0:
cmp al, 20h ; ' '
setz al
add rdx, 1
movzx eax, al
add edi, eax
movzx eax, byte ptr [rdx-1]
test al, al
jnz short loc_13F0
movsxd rdi, edi
mov ebx, 1
xor r13d, r13d
xor r15d, r15d
shl rdi, 3; size
call _malloc
mov r14, rax
loc_1420:
cmp bpl, 20h ; ' '
jz short loc_1490
add rbx, 1
movzx ebp, byte ptr [r12+rbx-1]
test bpl, bpl
jnz short loc_1420
loc_1435:
mov ebx, r15d
movsxd r13, r13d
lea r15, [r14+r13*8]
movsxd r13, ebx
add r13, r12
loc_1445:
mov rdi, r12; s
call _strlen
mov ebp, eax
sub ebp, ebx
lea r12d, [rbp+1]
movsxd rbp, ebp
movsxd r12, r12d
mov rdi, r12; size
call _malloc
mov rcx, r12
mov rdx, rbp
mov rsi, r13
mov [r15], rax
mov rdi, rax
call ___strncpy_chk
mov byte ptr [rax+rbp], 0
add rsp, 18h
mov rax, r14
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_1490:
lea ebp, [rbx-1]
mov [rsp+48h+var_3C], ebx
add rbx, 1
sub ebp, r15d
lea ecx, [rbp+1]
movsxd rbp, ebp
movsxd rcx, ecx
mov rdi, rcx; size
mov [rsp+48h+var_48], rcx
call _malloc
movsxd rdx, r15d
mov rcx, [rsp+48h+var_48]
mov rdi, rax
movsxd rax, r13d
lea rsi, [r12+rdx]
mov rdx, rbp
mov [r14+rax*8], rdi
add r13d, 1
call ___strncpy_chk
mov r15d, [rsp+48h+var_3C]
mov byte ptr [rax+rbp], 0
movzx ebp, byte ptr [r12+rbx-1]
test bpl, bpl
jnz loc_1420
jmp loc_1435
loc_14F8:
mov edi, 8; size
mov r13, r12
xor ebx, ebx
call _malloc
mov r14, rax
mov r15, rax
jmp loc_1445 | _QWORD * func0(char *s)
{
char v2; // bp
char *v3; // rdx
char v4; // al
int v5; // edi
long long v6; // rbx
int v7; // r13d
int v8; // r15d
_QWORD *v9; // r14
int v10; // ebx
_QWORD *v11; // r15
char *v12; // r13
int v13; // eax
long long v14; // rbp
size_t v15; // r12
void *v16; // rax
int v18; // ebp
int v19; // ebp
void *v20; // rax
long long v21; // rax
int v22; // [rsp+Ch] [rbp-3Ch]
v2 = *s;
if ( *s )
{
v3 = s + 1;
v4 = *s;
v5 = 1;
do
{
++v3;
v5 += v4 == 32;
v4 = *(v3 - 1);
}
while ( v4 );
v6 = 1LL;
v7 = 0;
v8 = 0;
v9 = malloc(8LL * v5);
do
{
while ( v2 != 32 )
{
v2 = s[v6++];
if ( !v2 )
goto LABEL_7;
}
v18 = v6 - 1;
v22 = v6++;
v19 = v18 - v8;
v20 = malloc(v19 + 1);
v9[v7++] = v20;
v21 = __strncpy_chk(v20, &s[v8], v19, v19 + 1);
v8 = v22;
*(_BYTE *)(v21 + v19) = 0;
v2 = s[v6 - 1];
}
while ( v2 );
LABEL_7:
v10 = v8;
v11 = &v9[v7];
v12 = &s[v10];
}
else
{
v12 = s;
v10 = 0;
v9 = malloc(8uLL);
v11 = v9;
}
v13 = strlen(s);
v14 = v13 - v10;
v15 = v13 - v10 + 1;
v16 = malloc(v15);
*v11 = v16;
*(_BYTE *)(__strncpy_chk(v16, v12, v14, v15) + v14) = 0;
return v9;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
MOV R12,RDI
PUSH RBP
PUSH RBX
SUB RSP,0x18
MOVZX EBP,byte ptr [RDI]
TEST BPL,BPL
JZ 0x001014f8
LEA RDX,[RDI + 0x1]
MOV EAX,EBP
MOV EDI,0x1
NOP dword ptr [RAX]
LAB_001013f0:
CMP AL,0x20
SETZ AL
ADD RDX,0x1
MOVZX EAX,AL
ADD EDI,EAX
MOVZX EAX,byte ptr [RDX + -0x1]
TEST AL,AL
JNZ 0x001013f0
MOVSXD RDI,EDI
MOV EBX,0x1
XOR R13D,R13D
XOR R15D,R15D
SHL RDI,0x3
CALL 0x001010e0
MOV R14,RAX
LAB_00101420:
CMP BPL,0x20
JZ 0x00101490
ADD RBX,0x1
MOVZX EBP,byte ptr [R12 + RBX*0x1 + -0x1]
TEST BPL,BPL
JNZ 0x00101420
LAB_00101435:
MOV EBX,R15D
MOVSXD R13,R13D
LEA R15,[R14 + R13*0x8]
MOVSXD R13,EBX
ADD R13,R12
LAB_00101445:
MOV RDI,R12
CALL 0x001010b0
MOV EBP,EAX
SUB EBP,EBX
LEA R12D,[RBP + 0x1]
MOVSXD RBP,EBP
MOVSXD R12,R12D
MOV RDI,R12
CALL 0x001010e0
MOV RCX,R12
MOV RDX,RBP
MOV RSI,R13
MOV qword ptr [R15],RAX
MOV RDI,RAX
CALL 0x001010f0
MOV byte ptr [RAX + RBP*0x1],0x0
ADD RSP,0x18
MOV RAX,R14
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_00101490:
LEA EBP,[RBX + -0x1]
MOV dword ptr [RSP + 0xc],EBX
ADD RBX,0x1
SUB EBP,R15D
LEA ECX,[RBP + 0x1]
MOVSXD RBP,EBP
MOVSXD RCX,ECX
MOV RDI,RCX
MOV qword ptr [RSP],RCX
CALL 0x001010e0
MOVSXD RDX,R15D
MOV RCX,qword ptr [RSP]
MOV RDI,RAX
MOVSXD RAX,R13D
LEA RSI,[R12 + RDX*0x1]
MOV RDX,RBP
MOV qword ptr [R14 + RAX*0x8],RDI
ADD R13D,0x1
CALL 0x001010f0
MOV R15D,dword ptr [RSP + 0xc]
MOV byte ptr [RAX + RBP*0x1],0x0
MOVZX EBP,byte ptr [R12 + RBX*0x1 + -0x1]
TEST BPL,BPL
JNZ 0x00101420
JMP 0x00101435
LAB_001014f8:
MOV EDI,0x8
MOV R13,R12
XOR EBX,EBX
CALL 0x001010e0
MOV R14,RAX
MOV R15,RAX
JMP 0x00101445 | int8 * func0(char *param_1)
{
char cVar1;
int8 *puVar2;
size_t sVar3;
void *pvVar4;
long lVar5;
long lVar6;
char *pcVar7;
char cVar8;
int iVar9;
int iVar10;
int iVar11;
int iVar12;
int8 *puVar13;
cVar8 = *param_1;
if (cVar8 == '\0') {
iVar10 = 0;
puVar2 = (int8 *)malloc(8);
pcVar7 = param_1;
puVar13 = puVar2;
}
else {
iVar10 = 1;
pcVar7 = param_1 + 1;
cVar1 = cVar8;
do {
iVar10 = iVar10 + (uint)(cVar1 == ' ');
cVar1 = *pcVar7;
pcVar7 = pcVar7 + 1;
} while (cVar1 != '\0');
iVar11 = 0;
puVar2 = (int8 *)malloc((long)iVar10 << 3);
lVar5 = 1;
iVar12 = 0;
do {
while (cVar8 == ' ') {
iVar10 = (int)lVar5;
iVar9 = (iVar10 + -1) - iVar12;
pvVar4 = malloc((long)(iVar9 + 1));
puVar2[iVar11] = pvVar4;
iVar11 = iVar11 + 1;
lVar6 = __strncpy_chk(pvVar4,param_1 + iVar12,(long)iVar9,(long)(iVar9 + 1));
*(int *)(lVar6 + iVar9) = 0;
cVar8 = param_1[lVar5];
lVar5 = lVar5 + 1;
iVar12 = iVar10;
if (cVar8 == '\0') goto LAB_00101435;
}
cVar8 = param_1[lVar5];
lVar5 = lVar5 + 1;
iVar10 = iVar12;
} while (cVar8 != '\0');
LAB_00101435:
pcVar7 = param_1 + iVar10;
puVar13 = puVar2 + iVar11;
}
sVar3 = strlen(param_1);
iVar10 = (int)sVar3 - iVar10;
pvVar4 = malloc((long)(iVar10 + 1));
*puVar13 = pvVar4;
lVar5 = __strncpy_chk(pvVar4,pcVar7,(long)iVar10,(long)(iVar10 + 1));
*(int *)(lVar5 + iVar10) = 0;
return puVar2;
} |
6,728 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key;
int *values;
int size;
int capacity;
} MapEntry;
typedef struct {
MapEntry *entries;
int size;
int capacity;
} Map;
void init_map(Map *map) {
map->entries = malloc(sizeof(MapEntry) * 10);
map->size = 0;
map->capacity = 10;
}
void add_to_map(Map *map, int key, int value) {
for (int i = 0; i < map->size; i++) {
if (map->entries[i].key == key) {
for (int j = 0; j < map->entries[i].size; j++) {
if (map->entries[i].values[j] == value)
return;
}
if (map->entries[i].size == map->entries[i].capacity) {
map->entries[i].capacity *= 2;
map->entries[i].values = realloc(map->entries[i].values, sizeof(int) * map->entries[i].capacity);
}
map->entries[i].values[map->entries[i].size++] = value;
return;
}
}
if (map->size == map->capacity) {
map->capacity *= 2;
map->entries = realloc(map->entries, sizeof(MapEntry) * map->capacity);
}
map->entries[map->size].key = key;
map->entries[map->size].values = malloc(sizeof(int) * 10);
map->entries[map->size].values[0] = value;
map->entries[map->size].size = 1;
map->entries[map->size].capacity = 10;
map->size++;
}
| char *func0(int arr[][2], int len) {
Map map;
init_map(&map);
for (int i = 0; i < len; i++) {
add_to_map(&map, arr[i][1], arr[i][0]);
}
char *result = malloc(1024);
strcpy(result, "{");
for (int i = 0; i < map.size; i++) {
char entry[32];
sprintf(entry, "%d: %d, ", map.entries[i].key, map.entries[i].size);
strcat(result, entry);
}
int index = strlen(result) - 2;
result[index] = '}';
result[index + 1] = '\0';
for (int i = 0; i < map.size; i++) {
free(map.entries[i].values);
}
free(map.entries);
return result;
}
| int main() {
int test1[][2] = {{3, 4}, {1, 2}, {2, 4}, {8, 2}, {7, 2}, {8, 1}, {9, 1}, {8, 4}, {10, 4}};
int test2[][2] = {{4, 5}, {2, 3}, {3, 5}, {9, 3}, {8, 3}, {9, 2}, {10, 2}, {9, 5}, {11, 5}};
int test3[][2] = {{6, 5}, {3, 4}, {2, 6}, {11, 1}, {8, 22}, {8, 11}, {4, 3}, {14, 3}, {11, 6}};
assert(strcmp(func0(test1, 9), "{4: 4, 2: 3, 1: 2}") == 0);
assert(strcmp(func0(test2, 9), "{5: 4, 3: 3, 2: 2}") == 0);
assert(strcmp(func0(test3, 9), "{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x70,%rsp
mov %rdi,-0x68(%rbp)
mov %esi,-0x6c(%rbp)
mov %fs:0x28,%rax
mov %rax,-0x8(%rbp)
xor %eax,%eax
lea -0x40(%rbp),%rax
mov %rax,%rdi
callq 1249 <init_map>
movl $0x0,-0x58(%rbp)
jmp 1664 <func0+0x76>
mov -0x58(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x68(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x58(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x68(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%ecx
lea -0x40(%rbp),%rax
mov %ecx,%esi
mov %rax,%rdi
callq 1286 <add_to_map>
addl $0x1,-0x58(%rbp)
mov -0x58(%rbp),%eax
cmp -0x6c(%rbp),%eax
jl 1625 <func0+0x37>
mov $0x400,%edi
callq 1120 <malloc@plt>
mov %rax,-0x48(%rbp)
mov -0x48(%rbp),%rax
movw $0x7b,(%rax)
movl $0x0,-0x54(%rbp)
jmp 16f4 <func0+0x106>
mov -0x40(%rbp),%rcx
mov -0x54(%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 -0x40(%rbp),%rsi
mov -0x54(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
add %rax,%rax
add %rdx,%rax
shl $0x3,%rax
add %rsi,%rax
mov (%rax),%edx
lea -0x30(%rbp),%rax
lea 0x938(%rip),%rsi
mov %rax,%rdi
mov $0x0,%eax
callq 1150 <sprintf@plt>
lea -0x30(%rbp),%rdx
mov -0x48(%rbp),%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 1140 <strcat@plt>
addl $0x1,-0x54(%rbp)
mov -0x38(%rbp),%eax
cmp %eax,-0x54(%rbp)
jl 168c <func0+0x9e>
mov -0x48(%rbp),%rax
mov %rax,%rdi
callq 10e0 <strlen@plt>
sub $0x2,%eax
mov %eax,-0x4c(%rbp)
mov -0x4c(%rbp),%eax
movslq %eax,%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movb $0x7d,(%rax)
mov -0x4c(%rbp),%eax
cltq
lea 0x1(%rax),%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
movb $0x0,(%rax)
movl $0x0,-0x50(%rbp)
jmp 1764 <func0+0x176>
mov -0x40(%rbp),%rcx
mov -0x50(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
add %rax,%rax
add %rdx,%rax
shl $0x3,%rax
add %rcx,%rax
mov 0x8(%rax),%rax
mov %rax,%rdi
callq 10d0 <free@plt>
addl $0x1,-0x50(%rbp)
mov -0x38(%rbp),%eax
cmp %eax,-0x50(%rbp)
jl 173a <func0+0x14c>
mov -0x40(%rbp),%rax
mov %rax,%rdi
callq 10d0 <free@plt>
mov -0x48(%rbp),%rax
mov -0x8(%rbp),%rsi
xor %fs:0x28,%rsi
je 1790 <func0+0x1a2>
callq 10f0 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 70h
mov [rbp+var_68], rdi
mov [rbp+var_6C], esi
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
lea rax, [rbp+ptr]
mov rdi, rax
call init_map
mov [rbp+var_58], 0
jmp short loc_1663
loc_1624:
mov eax, [rbp+var_58]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_68]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_58]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_68]
add rax, rcx
mov ecx, [rax+4]
lea rax, [rbp+ptr]
mov esi, ecx
mov rdi, rax
call add_to_map
add [rbp+var_58], 1
loc_1663:
mov eax, [rbp+var_58]
cmp eax, [rbp+var_6C]
jl short loc_1624
mov edi, 400h; size
call _malloc
mov [rbp+dest], rax
mov rax, [rbp+dest]
mov word ptr [rax], 7Bh ; '{'
mov [rbp+var_54], 0
jmp short loc_16F3
loc_168B:
mov rcx, [rbp+ptr]
mov eax, [rbp+var_54]
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+ptr]
mov eax, [rbp+var_54]
movsxd rdx, eax
mov rax, rdx
add rax, rax
add rax, rdx
shl rax, 3
add rax, rsi
mov edx, [rax]
lea rax, [rbp+s]
lea rsi, format; "%d: %d, "
mov rdi, rax; s
mov eax, 0
call _sprintf
lea rdx, [rbp+s]
mov rax, [rbp+dest]
mov rsi, rdx; src
mov rdi, rax; dest
call _strcat
add [rbp+var_54], 1
loc_16F3:
mov eax, [rbp+var_38]
cmp [rbp+var_54], eax
jl short loc_168B
mov rax, [rbp+dest]
mov rdi, rax; s
call _strlen
sub eax, 2
mov [rbp+var_4C], eax
mov eax, [rbp+var_4C]
movsxd rdx, eax
mov rax, [rbp+dest]
add rax, rdx
mov byte ptr [rax], 7Dh ; '}'
mov eax, [rbp+var_4C]
cdqe
lea rdx, [rax+1]
mov rax, [rbp+dest]
add rax, rdx
mov byte ptr [rax], 0
mov [rbp+var_50], 0
jmp short loc_1763
loc_1739:
mov rcx, [rbp+ptr]
mov eax, [rbp+var_50]
movsxd rdx, eax
mov rax, rdx
add rax, rax
add rax, rdx
shl rax, 3
add rax, rcx
mov rax, [rax+8]
mov rdi, rax; ptr
call _free
add [rbp+var_50], 1
loc_1763:
mov eax, [rbp+var_38]
cmp [rbp+var_50], eax
jl short loc_1739
mov rax, [rbp+ptr]
mov rdi, rax; ptr
call _free
mov rax, [rbp+dest]
mov rdx, [rbp+var_8]
sub rdx, fs:28h
jz short locret_178F
call ___stack_chk_fail
locret_178F:
leave
retn | char * func0(long long a1, int a2)
{
int i; // [rsp+18h] [rbp-58h]
int j; // [rsp+1Ch] [rbp-54h]
int k; // [rsp+20h] [rbp-50h]
int v6; // [rsp+24h] [rbp-4Ch]
char *dest; // [rsp+28h] [rbp-48h]
void *ptr; // [rsp+30h] [rbp-40h] BYREF
int v9; // [rsp+38h] [rbp-38h]
char s[40]; // [rsp+40h] [rbp-30h] BYREF
unsigned long long v11; // [rsp+68h] [rbp-8h]
v11 = __readfsqword(0x28u);
init_map(&ptr);
for ( i = 0; i < a2; ++i )
add_to_map(&ptr, *(unsigned int *)(8LL * i + a1 + 4), *(unsigned int *)(8LL * i + a1));
dest = (char *)malloc(0x400uLL);
*(_WORD *)dest = 123;
for ( j = 0; j < v9; ++j )
{
sprintf(s, "%d: %d, ", *((_DWORD *)ptr + 6 * j), *((_DWORD *)ptr + 6 * j + 4));
strcat(dest, s);
}
v6 = strlen(dest) - 2;
dest[v6] = 125;
dest[v6 + 1] = 0;
for ( k = 0; k < v9; ++k )
free(*((void **)ptr + 3 * k + 1));
free(ptr);
return dest;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x70
MOV qword ptr [RBP + -0x68],RDI
MOV dword ptr [RBP + -0x6c],ESI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RBP + -0x8],RAX
XOR EAX,EAX
LEA RAX,[RBP + -0x40]
MOV RDI,RAX
CALL 0x00101249
MOV dword ptr [RBP + -0x58],0x0
JMP 0x00101663
LAB_00101624:
MOV EAX,dword ptr [RBP + -0x58]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x68]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x58]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x68]
ADD RAX,RCX
MOV ECX,dword ptr [RAX + 0x4]
LEA RAX,[RBP + -0x40]
MOV ESI,ECX
MOV RDI,RAX
CALL 0x00101286
ADD dword ptr [RBP + -0x58],0x1
LAB_00101663:
MOV EAX,dword ptr [RBP + -0x58]
CMP EAX,dword ptr [RBP + -0x6c]
JL 0x00101624
MOV EDI,0x400
CALL 0x00101120
MOV qword ptr [RBP + -0x48],RAX
MOV RAX,qword ptr [RBP + -0x48]
MOV word ptr [RAX],0x7b
MOV dword ptr [RBP + -0x54],0x0
JMP 0x001016f3
LAB_0010168b:
MOV RCX,qword ptr [RBP + -0x40]
MOV EAX,dword ptr [RBP + -0x54]
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 + -0x40]
MOV EAX,dword ptr [RBP + -0x54]
MOVSXD RDX,EAX
MOV RAX,RDX
ADD RAX,RAX
ADD RAX,RDX
SHL RAX,0x3
ADD RAX,RSI
MOV EDX,dword ptr [RAX]
LEA RAX,[RBP + -0x30]
LEA RSI,[0x102008]
MOV RDI,RAX
MOV EAX,0x0
CALL 0x00101150
LEA RDX,[RBP + -0x30]
MOV RAX,qword ptr [RBP + -0x48]
MOV RSI,RDX
MOV RDI,RAX
CALL 0x00101140
ADD dword ptr [RBP + -0x54],0x1
LAB_001016f3:
MOV EAX,dword ptr [RBP + -0x38]
CMP dword ptr [RBP + -0x54],EAX
JL 0x0010168b
MOV RAX,qword ptr [RBP + -0x48]
MOV RDI,RAX
CALL 0x001010e0
SUB EAX,0x2
MOV dword ptr [RBP + -0x4c],EAX
MOV EAX,dword ptr [RBP + -0x4c]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOV byte ptr [RAX],0x7d
MOV EAX,dword ptr [RBP + -0x4c]
CDQE
LEA RDX,[RAX + 0x1]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOV byte ptr [RAX],0x0
MOV dword ptr [RBP + -0x50],0x0
JMP 0x00101763
LAB_00101739:
MOV RCX,qword ptr [RBP + -0x40]
MOV EAX,dword ptr [RBP + -0x50]
MOVSXD RDX,EAX
MOV RAX,RDX
ADD RAX,RAX
ADD RAX,RDX
SHL RAX,0x3
ADD RAX,RCX
MOV RAX,qword ptr [RAX + 0x8]
MOV RDI,RAX
CALL 0x001010d0
ADD dword ptr [RBP + -0x50],0x1
LAB_00101763:
MOV EAX,dword ptr [RBP + -0x38]
CMP dword ptr [RBP + -0x50],EAX
JL 0x00101739
MOV RAX,qword ptr [RBP + -0x40]
MOV RDI,RAX
CALL 0x001010d0
MOV RAX,qword ptr [RBP + -0x48]
MOV RDX,qword ptr [RBP + -0x8]
SUB RDX,qword ptr FS:[0x28]
JZ 0x0010178f
CALL 0x001010f0
LAB_0010178f:
LEAVE
RET | char * func0(long param_1,int param_2)
{
int iVar1;
char *__dest;
size_t sVar2;
long in_FS_OFFSET;
int local_60;
int local_5c;
int local_58;
void *local_48;
int local_40;
char local_38 [40];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
init_map(&local_48);
for (local_60 = 0; local_60 < param_2; local_60 = local_60 + 1) {
add_to_map(&local_48,*(int4 *)(param_1 + (long)local_60 * 8 + 4),
*(int4 *)(param_1 + (long)local_60 * 8));
}
__dest = (char *)malloc(0x400);
__dest[0] = '{';
__dest[1] = '\0';
for (local_5c = 0; local_5c < local_40; local_5c = local_5c + 1) {
sprintf(local_38,"%d: %d, ",(ulong)*(uint *)((long)local_5c * 0x18 + (long)local_48),
(ulong)*(uint *)((long)local_48 + (long)local_5c * 0x18 + 0x10));
strcat(__dest,local_38);
}
sVar2 = strlen(__dest);
iVar1 = (int)sVar2 + -2;
__dest[iVar1] = '}';
__dest[(long)iVar1 + 1] = '\0';
for (local_58 = 0; local_58 < local_40; local_58 = local_58 + 1) {
free(*(void **)((long)local_48 + (long)local_58 * 0x18 + 8));
}
free(local_48);
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return __dest;
} |
6,729 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key;
int *values;
int size;
int capacity;
} MapEntry;
typedef struct {
MapEntry *entries;
int size;
int capacity;
} Map;
void init_map(Map *map) {
map->entries = malloc(sizeof(MapEntry) * 10);
map->size = 0;
map->capacity = 10;
}
void add_to_map(Map *map, int key, int value) {
for (int i = 0; i < map->size; i++) {
if (map->entries[i].key == key) {
for (int j = 0; j < map->entries[i].size; j++) {
if (map->entries[i].values[j] == value)
return;
}
if (map->entries[i].size == map->entries[i].capacity) {
map->entries[i].capacity *= 2;
map->entries[i].values = realloc(map->entries[i].values, sizeof(int) * map->entries[i].capacity);
}
map->entries[i].values[map->entries[i].size++] = value;
return;
}
}
if (map->size == map->capacity) {
map->capacity *= 2;
map->entries = realloc(map->entries, sizeof(MapEntry) * map->capacity);
}
map->entries[map->size].key = key;
map->entries[map->size].values = malloc(sizeof(int) * 10);
map->entries[map->size].values[0] = value;
map->entries[map->size].size = 1;
map->entries[map->size].capacity = 10;
map->size++;
}
| char *func0(int arr[][2], int len) {
Map map;
init_map(&map);
for (int i = 0; i < len; i++) {
add_to_map(&map, arr[i][1], arr[i][0]);
}
char *result = malloc(1024);
strcpy(result, "{");
for (int i = 0; i < map.size; i++) {
char entry[32];
sprintf(entry, "%d: %d, ", map.entries[i].key, map.entries[i].size);
strcat(result, entry);
}
int index = strlen(result) - 2;
result[index] = '}';
result[index + 1] = '\0';
for (int i = 0; i < map.size; i++) {
free(map.entries[i].values);
}
free(map.entries);
return result;
}
| int main() {
int test1[][2] = {{3, 4}, {1, 2}, {2, 4}, {8, 2}, {7, 2}, {8, 1}, {9, 1}, {8, 4}, {10, 4}};
int test2[][2] = {{4, 5}, {2, 3}, {3, 5}, {9, 3}, {8, 3}, {9, 2}, {10, 2}, {9, 5}, {11, 5}};
int test3[][2] = {{6, 5}, {3, 4}, {2, 6}, {11, 1}, {8, 22}, {8, 11}, {4, 3}, {14, 3}, {11, 6}};
assert(strcmp(func0(test1, 9), "{4: 4, 2: 3, 1: 2}") == 0);
assert(strcmp(func0(test2, 9), "{5: 4, 3: 3, 2: 2}") == 0);
assert(strcmp(func0(test3, 9), "{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}") == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
sub $0x40,%rsp
mov %rdi,%r12
mov %esi,%ebp
mov %fs:0x28,%rax
mov %rax,0x38(%rsp)
xor %eax,%eax
mov %rsp,%rdi
callq 1209 <init_map>
test %ebp,%ebp
jle 13dd <func0+0x51>
mov %r12,%rbx
lea -0x1(%rbp),%eax
lea 0x8(%r12,%rax,8),%r12
mov %rsp,%rbp
mov 0x4(%rbx),%esi
mov (%rbx),%edx
mov %rbp,%rdi
callq 122e <add_to_map>
add $0x8,%rbx
cmp %r12,%rbx
jne 13c7 <func0+0x3b>
mov $0x400,%edi
callq 10f0 <malloc@plt>
mov %rax,%r12
movw $0x7b,(%rax)
cmpl $0x0,0x8(%rsp)
jle 144b <func0+0xbf>
mov $0x0,%ebx
lea 0x10(%rsp),%rbp
lea (%rbx,%rbx,2),%rdx
mov (%rsp),%rax
lea (%rax,%rdx,8),%rax
mov 0x10(%rax),%r9d
mov (%rax),%r8d
lea 0xbea(%rip),%rcx
mov $0x20,%edx
mov $0x1,%esi
mov %rbp,%rdi
mov $0x0,%eax
callq 1110 <__sprintf_chk@plt>
mov $0x400,%edx
mov %rbp,%rsi
mov %r12,%rdi
callq 10b0 <__strcat_chk@plt>
add $0x1,%rbx
cmp %ebx,0x8(%rsp)
jg 1400 <func0+0x74>
mov $0xffffffffffffffff,%rcx
mov $0x0,%eax
mov %r12,%rdi
repnz scas %es:(%rdi),%al
mov %rcx,%rax
not %rax
sub $0x3,%eax
cltq
movb $0x7d,(%r12,%rax,1)
movb $0x0,0x1(%r12,%rax,1)
cmpl $0x0,0x8(%rsp)
jle 149e <func0+0x112>
mov $0x0,%ebp
mov $0x0,%ebx
mov (%rsp),%rax
mov 0x8(%rax,%rbp,1),%rdi
callq 10c0 <free@plt>
add $0x1,%ebx
add $0x18,%rbp
cmp %ebx,0x8(%rsp)
jg 1483 <func0+0xf7>
mov (%rsp),%rdi
callq 10c0 <free@plt>
mov 0x38(%rsp),%rax
xor %fs:0x28,%rax
jne 14c3 <func0+0x137>
mov %r12,%rax
add $0x40,%rsp
pop %rbx
pop %rbp
pop %r12
retq
callq 10d0 <__stack_chk_fail@plt>
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 48h
mov r12, rdi
mov ebp, esi
mov rax, fs:28h
mov [rsp+78h+var_40], rax
xor eax, eax
mov rdi, rsp
call init_map
test ebp, ebp
jle short loc_1421
mov rbx, r12
lea eax, [rbp-1]
lea r12, [r12+rax*8+8]
mov rbp, rsp
loc_140B:
mov esi, [rbx+4]
mov edx, [rbx]
mov rdi, rbp
call add_to_map
add rbx, 8
cmp rbx, r12
jnz short loc_140B
loc_1421:
mov edi, 400h
call _malloc
mov r14, rax
mov word ptr [rax], 7Bh ; '{'
mov eax, [rsp+78h+var_70]
test eax, eax
jle loc_14F8
mov eax, eax
lea r13, [rax+rax*2]
shl r13, 3
mov ebx, 0
lea r15, aDD; "%d: %d, "
loc_1455:
mov rbp, [rsp+78h+var_78]
lea rax, [rbp+rbx+0]
lea r12, [rsp+78h+var_68]
mov r9d, [rax+10h]
mov r8d, [rax]
mov rcx, r15
mov edx, 20h ; ' '
mov esi, 1
mov rdi, r12
mov eax, 0
call ___sprintf_chk
mov edx, 400h
mov rsi, r12
mov rdi, r14
call ___strcat_chk
add rbx, 18h
cmp r13, rbx
jnz short loc_1455
mov rdi, r14
call _strlen
sub eax, 2
cdqe
mov byte ptr [r14+rax], 7Dh ; '}'
mov byte ptr [r14+rax+1], 0
mov ebx, 0
loc_14BA:
mov rdi, [rbp+rbx+8]
call _free
add rbx, 18h
cmp r13, rbx
jnz short loc_14BA
loc_14CD:
mov rdi, [rsp+78h+var_78]
call _free
mov rax, [rsp+78h+var_40]
sub rax, fs:28h
jnz short loc_1512
mov rax, r14
add rsp, 48h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_14F8:
mov rdi, r14
call _strlen
sub eax, 2
cdqe
mov byte ptr [r14+rax], 7Dh ; '}'
mov byte ptr [r14+rax+1], 0
jmp short loc_14CD
loc_1512:
call ___stack_chk_fail | _WORD * func0(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx
_WORD *v3; // r14
long long v4; // r13
long long v5; // rbx
long long v6; // rbp
int v7; // eax
long long v8; // rbx
int v10; // eax
long long v11; // [rsp+0h] [rbp-78h] BYREF
int v12; // [rsp+8h] [rbp-70h]
_BYTE v13[40]; // [rsp+10h] [rbp-68h] BYREF
unsigned long long v14; // [rsp+38h] [rbp-40h]
v14 = __readfsqword(0x28u);
init_map(&v11);
if ( a2 > 0 )
{
v2 = a1;
do
{
add_to_map(&v11, v2[1], *v2);
v2 += 2;
}
while ( v2 != &a1[2 * (a2 - 1) + 2] );
}
v3 = (_WORD *)malloc(1024LL);
*v3 = 123;
if ( v12 <= 0 )
{
v10 = strlen(v3) - 2;
*((_BYTE *)v3 + v10) = 125;
*((_BYTE *)v3 + v10 + 1) = 0;
}
else
{
v4 = 24LL * (unsigned int)v12;
v5 = 0LL;
do
{
v6 = v11;
__sprintf_chk(v13, 1LL, 32LL, "%d: %d, ", *(_DWORD *)(v11 + v5), *(_DWORD *)(v11 + v5 + 16));
__strcat_chk(v3, v13, 1024LL);
v5 += 24LL;
}
while ( v4 != v5 );
v7 = strlen(v3) - 2;
*((_BYTE *)v3 + v7) = 125;
*((_BYTE *)v3 + v7 + 1) = 0;
v8 = 0LL;
do
{
free(*(_QWORD *)(v6 + v8 + 8));
v8 += 24LL;
}
while ( v4 != v8 );
}
free(v11);
return v3;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x48
MOV R12,RDI
MOV EBP,ESI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x38],RAX
XOR EAX,EAX
MOV RDI,RSP
CALL 0x00101249
TEST EBP,EBP
JLE 0x00101421
MOV RBX,R12
LEA EAX,[RBP + -0x1]
LEA R12,[R12 + RAX*0x8 + 0x8]
MOV RBP,RSP
LAB_0010140b:
MOV ESI,dword ptr [RBX + 0x4]
MOV EDX,dword ptr [RBX]
MOV RDI,RBP
CALL 0x0010126e
ADD RBX,0x8
CMP RBX,R12
JNZ 0x0010140b
LAB_00101421:
MOV EDI,0x400
CALL 0x00101130
MOV R14,RAX
MOV word ptr [RAX],0x7b
MOV EAX,dword ptr [RSP + 0x8]
TEST EAX,EAX
JLE 0x001014f8
MOV EAX,EAX
LEA R13,[RAX + RAX*0x2]
SHL R13,0x3
MOV EBX,0x0
LEA R15,[0x102004]
LAB_00101455:
MOV RBP,qword ptr [RSP]
LEA RAX,[RBP + RBX*0x1]
LEA R12,[RSP + 0x10]
MOV R9D,dword ptr [RAX + 0x10]
MOV R8D,dword ptr [RAX]
MOV RCX,R15
MOV EDX,0x20
MOV ESI,0x1
MOV RDI,R12
MOV EAX,0x0
CALL 0x00101150
MOV EDX,0x400
MOV RSI,R12
MOV RDI,R14
CALL 0x001010d0
ADD RBX,0x18
CMP R13,RBX
JNZ 0x00101455
MOV RDI,R14
CALL 0x001010f0
SUB EAX,0x2
CDQE
MOV byte ptr [R14 + RAX*0x1],0x7d
MOV byte ptr [R14 + RAX*0x1 + 0x1],0x0
MOV EBX,0x0
LAB_001014ba:
MOV RDI,qword ptr [RBP + RBX*0x1 + 0x8]
CALL 0x001010e0
ADD RBX,0x18
CMP R13,RBX
JNZ 0x001014ba
LAB_001014cd:
MOV RDI,qword ptr [RSP]
CALL 0x001010e0
MOV RAX,qword ptr [RSP + 0x38]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101512
MOV RAX,R14
ADD RSP,0x48
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001014f8:
MOV RDI,R14
CALL 0x001010f0
SUB EAX,0x2
CDQE
MOV byte ptr [R14 + RAX*0x1],0x7d
MOV byte ptr [R14 + RAX*0x1 + 0x1],0x0
JMP 0x001014cd
LAB_00101512:
CALL 0x00101100 | char * func0(int4 *param_1,int param_2)
{
int4 *puVar1;
void *pvVar2;
char *__s;
size_t sVar3;
long lVar4;
long in_FS_OFFSET;
void *local_78;
uint local_70;
int1 local_68 [40];
long local_40;
local_40 = *(long *)(in_FS_OFFSET + 0x28);
init_map(&local_78);
if (0 < param_2) {
puVar1 = param_1 + (ulong)(param_2 - 1) * 2 + 2;
do {
add_to_map(&local_78,param_1[1],*param_1);
param_1 = param_1 + 2;
} while (param_1 != puVar1);
}
__s = (char *)malloc(0x400);
__s[0] = '{';
__s[1] = '\0';
if ((int)local_70 < 1) {
sVar3 = strlen(__s);
lVar4 = (long)((int)sVar3 + -2);
__s[lVar4] = '}';
__s[lVar4 + 1] = '\0';
}
else {
lVar4 = 0;
do {
pvVar2 = local_78;
__sprintf_chk(local_68,1,0x20,"%d: %d, ",*(int4 *)((long)local_78 + lVar4),
((int4 *)((long)local_78 + lVar4))[4]);
__strcat_chk(__s,local_68,0x400);
lVar4 = lVar4 + 0x18;
} while ((ulong)local_70 * 0x18 != lVar4);
sVar3 = strlen(__s);
lVar4 = (long)((int)sVar3 + -2);
__s[lVar4] = '}';
__s[lVar4 + 1] = '\0';
lVar4 = 0;
do {
free(*(void **)((long)pvVar2 + lVar4 + 8));
lVar4 = lVar4 + 0x18;
} while ((ulong)local_70 * 0x18 != lVar4);
}
free(local_78);
if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) {
return __s;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,730 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key;
int *values;
int size;
int capacity;
} MapEntry;
typedef struct {
MapEntry *entries;
int size;
int capacity;
} Map;
void init_map(Map *map) {
map->entries = malloc(sizeof(MapEntry) * 10);
map->size = 0;
map->capacity = 10;
}
void add_to_map(Map *map, int key, int value) {
for (int i = 0; i < map->size; i++) {
if (map->entries[i].key == key) {
for (int j = 0; j < map->entries[i].size; j++) {
if (map->entries[i].values[j] == value)
return;
}
if (map->entries[i].size == map->entries[i].capacity) {
map->entries[i].capacity *= 2;
map->entries[i].values = realloc(map->entries[i].values, sizeof(int) * map->entries[i].capacity);
}
map->entries[i].values[map->entries[i].size++] = value;
return;
}
}
if (map->size == map->capacity) {
map->capacity *= 2;
map->entries = realloc(map->entries, sizeof(MapEntry) * map->capacity);
}
map->entries[map->size].key = key;
map->entries[map->size].values = malloc(sizeof(int) * 10);
map->entries[map->size].values[0] = value;
map->entries[map->size].size = 1;
map->entries[map->size].capacity = 10;
map->size++;
}
| char *func0(int arr[][2], int len) {
Map map;
init_map(&map);
for (int i = 0; i < len; i++) {
add_to_map(&map, arr[i][1], arr[i][0]);
}
char *result = malloc(1024);
strcpy(result, "{");
for (int i = 0; i < map.size; i++) {
char entry[32];
sprintf(entry, "%d: %d, ", map.entries[i].key, map.entries[i].size);
strcat(result, entry);
}
int index = strlen(result) - 2;
result[index] = '}';
result[index + 1] = '\0';
for (int i = 0; i < map.size; i++) {
free(map.entries[i].values);
}
free(map.entries);
return result;
}
| int main() {
int test1[][2] = {{3, 4}, {1, 2}, {2, 4}, {8, 2}, {7, 2}, {8, 1}, {9, 1}, {8, 4}, {10, 4}};
int test2[][2] = {{4, 5}, {2, 3}, {3, 5}, {9, 3}, {8, 3}, {9, 2}, {10, 2}, {9, 5}, {11, 5}};
int test3[][2] = {{6, 5}, {3, 4}, {2, 6}, {11, 1}, {8, 22}, {8, 11}, {4, 3}, {14, 3}, {11, 6}};
assert(strcmp(func0(test1, 9), "{4: 4, 2: 3, 1: 2}") == 0);
assert(strcmp(func0(test2, 9), "{5: 4, 3: 3, 2: 2}") == 0);
assert(strcmp(func0(test3, 9), "{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}") == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
mov %esi,%ebp
push %rbx
mov %rdi,%rbx
mov $0xf0,%edi
sub $0x40,%rsp
mov %fs:0x28,%rax
mov %rax,0x38(%rsp)
xor %eax,%eax
callq 10f0 <malloc@plt>
mov %rax,(%rsp)
mov %rax,%r14
movabs $0xa00000000,%rax
mov %rax,0x8(%rsp)
test %ebp,%ebp
jle 17e0 <func0+0x190>
lea -0x1(%rbp),%eax
mov %rsp,%rbp
lea 0x8(%rbx,%rax,8),%r12
nopl 0x0(%rax,%rax,1)
mov 0x4(%rbx),%esi
mov (%rbx),%edx
mov %rbp,%rdi
add $0x8,%rbx
callq 1500 <add_to_map>
cmp %rbx,%r12
jne 16b0 <func0+0x60>
mov 0x8(%rsp),%ebx
mov $0x400,%edi
mov (%rsp),%r14
callq 10f0 <malloc@plt>
mov $0x7b,%edx
mov %dx,(%rax)
mov %rax,%r12
test %ebx,%ebx
jle 17f7 <func0+0x1a7>
xor %r13d,%r13d
lea 0x10(%rsp),%rbx
lea 0x90a(%rip),%rbp
nopw 0x0(%rax,%rax,1)
lea 0x0(%r13,%r13,2),%rax
mov %rbx,%rdi
mov %rbp,%rcx
mov $0x20,%edx
lea (%r14,%rax,8),%rax
mov $0x1,%esi
mov 0x10(%rax),%r9d
mov (%rax),%r8d
xor %eax,%eax
callq 1110 <__sprintf_chk@plt>
mov %r12,%rdi
mov (%rdi),%edx
add $0x4,%rdi
lea -0x1010101(%rdx),%eax
not %edx
and %edx,%eax
and $0x80808080,%eax
je 172a <func0+0xda>
mov %eax,%edx
mov %rbx,%rsi
shr $0x10,%edx
test $0x8080,%eax
cmove %edx,%eax
lea 0x2(%rdi),%rdx
cmove %rdx,%rdi
mov $0x400,%edx
mov %eax,%ecx
add %al,%cl
sbb $0x3,%rdi
add $0x1,%r13
callq 10e0 <__stpcpy_chk@plt>
mov 0x8(%rsp),%edx
mov (%rsp),%r14
cmp %r13d,%edx
jg 1700 <func0+0xb0>
sub %r12,%rax
sub $0x2,%eax
cltq
movb $0x7d,(%r12,%rax,1)
movb $0x0,0x1(%r12,%rax,1)
test %edx,%edx
jle 17b4 <func0+0x164>
xor %ebx,%ebx
nopl (%rax)
lea (%rbx,%rbx,2),%rax
add $0x1,%rbx
mov 0x8(%r14,%rax,8),%rdi
callq 10b0 <free@plt>
mov (%rsp),%r14
cmp %ebx,0x8(%rsp)
jg 1798 <func0+0x148>
mov %r14,%rdi
callq 10b0 <free@plt>
mov 0x38(%rsp),%rax
xor %fs:0x28,%rax
jne 1848 <func0+0x1f8>
add $0x40,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
retq
nopl 0x0(%rax)
mov $0x400,%edi
callq 10f0 <malloc@plt>
mov %rax,%r12
mov $0x7b,%eax
mov %ax,(%r12)
mov %r12,%rax
mov (%rax),%ecx
add $0x4,%rax
lea -0x1010101(%rcx),%edx
not %ecx
and %ecx,%edx
and $0x80808080,%edx
je 17fa <func0+0x1aa>
mov %edx,%ecx
shr $0x10,%ecx
test $0x8080,%edx
cmove %ecx,%edx
lea 0x2(%rax),%rcx
cmove %rcx,%rax
mov %edx,%ecx
add %dl,%cl
sbb $0x3,%rax
sub %r12,%rax
sub $0x2,%eax
cltq
movb $0x7d,(%r12,%rax,1)
movb $0x0,0x1(%r12,%rax,1)
jmpq 17b4 <func0+0x164>
callq 10c0 <__stack_chk_fail@plt>
nopl (%rax)
| func0:
endbr64
push r15
push r14
push r13
push r12
mov r12d, esi
push rbp
push rbx
mov rbx, rdi
mov edi, 0F0h
sub rsp, 58h
mov rax, fs:28h
mov [rsp+88h+var_40], rax
xor eax, eax
call _malloc
mov [rsp+88h+var_78], rax
mov rbp, rax
mov rax, 0A00000000h
mov [rsp+88h+var_70], rax
test r12d, r12d
jle loc_17E8
lea eax, [r12-1]
lea rbp, [rsp+88h+var_78]
lea r12, [rbx+rax*8+8]
nop dword ptr [rax+00000000h]
loc_16D8:
mov esi, [rbx+4]
mov edx, [rbx]
mov rdi, rbp
add rbx, 8
call add_to_map
cmp rbx, r12
jnz short loc_16D8
mov ebx, dword ptr [rsp+88h+var_70]
mov edi, 400h
mov rbp, [rsp+88h+var_78]
call _malloc
mov edx, 7Bh ; '{'
mov [rax], dx
mov r12, rax
test ebx, ebx
jle loc_17FF
lea eax, [rbx-1]
lea r13, aDD; "%d: %d, "
lea r15, [rax+rax*2]
lea rbx, [rsp+88h+var_68]
lea rax, ds:0[r15*8]
mov r15, rbp
mov [rsp+88h+var_80], rax
lea r14, [rbp+rax+18h]
nop dword ptr [rax+00h]
loc_1740:
mov r9d, [r15+10h]
mov r8d, [r15]
mov rcx, r13
mov edx, 20h ; ' '
mov esi, 1
mov rdi, rbx
xor eax, eax
add r15, 18h
call ___sprintf_chk
mov rdi, r12
call _strlen
mov edx, 400h
mov rsi, rbx
lea rdi, [r12+rax]
call ___stpcpy_chk
cmp r15, r14
jnz short loc_1740
sub rax, r12
lea rbx, [rbp+8]
sub eax, 2
cdqe
mov byte ptr [r12+rax], 7Dh ; '}'
mov byte ptr [r12+rax+1], 0
mov rax, [rsp+88h+var_80]
lea r13, [rbp+rax+20h]
nop dword ptr [rax+00000000h]
loc_17A8:
mov rdi, [rbx]
add rbx, 18h
call _free
cmp r13, rbx
jnz short loc_17A8
loc_17B9:
mov rdi, rbp
call _free
mov rax, [rsp+88h+var_40]
sub rax, fs:28h
jnz short loc_1819
add rsp, 58h
mov rax, r12
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_17E8:
mov edi, 400h
call _malloc
mov r12, rax
mov eax, 7Bh ; '{'
mov [r12], ax
loc_17FF:
mov rdi, r12
call _strlen
sub eax, 2
cdqe
mov byte ptr [r12+rax], 7Dh ; '}'
mov byte ptr [r12+rax+1], 0
jmp short loc_17B9
loc_1819:
call ___stack_chk_fail | _WORD * func0(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx
long long v3; // rbp
long long v4; // r12
long long v5; // rsi
long long v6; // rdx
int v7; // ebx
_WORD *v8; // rax
_WORD *v9; // r12
int *v10; // r15
int v11; // r9d
int v12; // r8d
long long v13; // rax
int v14; // eax
long long *v15; // rbx
int v16; // eax
long long v17; // rdi
int v19; // eax
long long v20; // [rsp+8h] [rbp-80h]
long long v21; // [rsp+10h] [rbp-78h] BYREF
long long v22; // [rsp+18h] [rbp-70h]
_BYTE v23[40]; // [rsp+20h] [rbp-68h] BYREF
unsigned long long v24; // [rsp+48h] [rbp-40h]
v2 = a1;
v24 = __readfsqword(0x28u);
v21 = malloc(240LL);
v3 = v21;
v22 = 0xA00000000LL;
if ( a2 <= 0 )
{
v9 = (_WORD *)malloc(1024LL);
*v9 = 123;
LABEL_11:
v19 = strlen(v9) - 2;
*((_BYTE *)v9 + v19) = 125;
*((_BYTE *)v9 + v19 + 1) = 0;
goto LABEL_9;
}
v4 = (long long)&a1[2 * (a2 - 1) + 2];
do
{
v5 = v2[1];
v6 = *v2;
v2 += 2;
add_to_map(&v21, v5, v6);
}
while ( v2 != (unsigned int *)v4 );
v7 = v22;
v3 = v21;
v8 = (_WORD *)malloc(1024LL);
*v8 = 123;
v9 = v8;
if ( v7 <= 0 )
goto LABEL_11;
v10 = (int *)v3;
v20 = 24LL * (unsigned int)(v7 - 1);
do
{
v11 = v10[4];
v12 = *v10;
v10 += 6;
__sprintf_chk(v23, 1LL, 32LL, "%d: %d, ", v12, v11);
v13 = strlen(v9);
v14 = __stpcpy_chk((char *)v9 + v13, v23, 1024LL);
}
while ( v10 != (int *)(v3 + v20 + 24) );
v15 = (long long *)(v3 + 8);
v16 = v14 - (_DWORD)v9 - 2;
*((_BYTE *)v9 + v16) = 125;
*((_BYTE *)v9 + v16 + 1) = 0;
do
{
v17 = *v15;
v15 += 3;
free(v17);
}
while ( (long long *)(v3 + v20 + 32) != v15 );
LABEL_9:
free(v3);
return v9;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
MOV R12D,ESI
PUSH RBP
PUSH RBX
MOV RBX,RDI
MOV EDI,0xf0
SUB RSP,0x58
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
CALL 0x00101130
MOV qword ptr [RSP + 0x10],RAX
MOV RBP,RAX
MOV RAX,0xa00000000
MOV qword ptr [RSP + 0x18],RAX
TEST R12D,R12D
JLE 0x001017e8
LEA EAX,[R12 + -0x1]
LEA RBP,[RSP + 0x10]
LEA R12,[RBX + RAX*0x8 + 0x8]
NOP dword ptr [RAX]
LAB_001016d8:
MOV ESI,dword ptr [RBX + 0x4]
MOV EDX,dword ptr [RBX]
MOV RDI,RBP
ADD RBX,0x8
CALL 0x00101520
CMP RBX,R12
JNZ 0x001016d8
MOV EBX,dword ptr [RSP + 0x18]
MOV EDI,0x400
MOV RBP,qword ptr [RSP + 0x10]
CALL 0x00101130
MOV EDX,0x7b
MOV word ptr [RAX],DX
MOV R12,RAX
TEST EBX,EBX
JLE 0x001017ff
LEA EAX,[RBX + -0x1]
LEA R13,[0x102004]
LEA R15,[RAX + RAX*0x2]
LEA RBX,[RSP + 0x20]
LEA RAX,[R15*0x8]
MOV R15,RBP
MOV qword ptr [RSP + 0x8],RAX
LEA R14,[RBP + RAX*0x1 + 0x18]
NOP dword ptr [RAX]
LAB_00101740:
MOV R9D,dword ptr [R15 + 0x10]
MOV R8D,dword ptr [R15]
MOV RCX,R13
MOV EDX,0x20
MOV ESI,0x1
MOV RDI,RBX
XOR EAX,EAX
ADD R15,0x18
CALL 0x00101150
MOV RDI,R12
CALL 0x001010e0
MOV EDX,0x400
MOV RSI,RBX
LEA RDI,[R12 + RAX*0x1]
CALL 0x00101120
CMP R15,R14
JNZ 0x00101740
SUB RAX,R12
LEA RBX,[RBP + 0x8]
SUB EAX,0x2
CDQE
MOV byte ptr [R12 + RAX*0x1],0x7d
MOV byte ptr [R12 + RAX*0x1 + 0x1],0x0
MOV RAX,qword ptr [RSP + 0x8]
LEA R13,[RBP + RAX*0x1 + 0x20]
NOP dword ptr [RAX]
LAB_001017a8:
MOV RDI,qword ptr [RBX]
ADD RBX,0x18
CALL 0x001010d0
CMP R13,RBX
JNZ 0x001017a8
LAB_001017b9:
MOV RDI,RBP
CALL 0x001010d0
MOV RAX,qword ptr [RSP + 0x48]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101819
ADD RSP,0x58
MOV RAX,R12
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001017e8:
MOV EDI,0x400
CALL 0x00101130
MOV R12,RAX
MOV EAX,0x7b
MOV word ptr [R12],AX
LAB_001017ff:
MOV RDI,R12
CALL 0x001010e0
SUB EAX,0x2
CDQE
MOV byte ptr [R12 + RAX*0x1],0x7d
MOV byte ptr [R12 + RAX*0x1 + 0x1],0x0
JMP 0x001017b9
LAB_00101819:
CALL 0x001010f0 | char * func0(int4 *param_1,int param_2)
{
int4 *puVar1;
int4 uVar2;
void *__ptr;
int iVar3;
int4 *puVar4;
char *__s;
ulong uVar5;
size_t sVar6;
long lVar7;
int8 *puVar8;
int4 *puVar9;
long in_FS_OFFSET;
int4 *local_78;
int8 local_70;
int1 local_68 [40];
long local_40;
local_40 = *(long *)(in_FS_OFFSET + 0x28);
puVar4 = (int4 *)malloc(0xf0);
local_70 = 0xa00000000;
local_78 = puVar4;
if (param_2 < 1) {
__s = (char *)malloc(0x400);
__s[0] = '{';
__s[1] = '\0';
}
else {
puVar9 = param_1 + (ulong)(param_2 - 1) * 2 + 2;
do {
puVar4 = param_1 + 1;
uVar2 = *param_1;
param_1 = param_1 + 2;
add_to_map(&local_78,*puVar4,uVar2);
puVar4 = local_78;
} while (param_1 != puVar9);
iVar3 = (int)local_70;
__s = (char *)malloc(0x400);
__s[0] = '{';
__s[1] = '\0';
if (0 < iVar3) {
uVar5 = (ulong)(iVar3 - 1);
puVar9 = puVar4;
do {
puVar1 = puVar9 + 4;
uVar2 = *puVar9;
puVar9 = puVar9 + 6;
__sprintf_chk(local_68,1,0x20,"%d: %d, ",uVar2,*puVar1);
sVar6 = strlen(__s);
iVar3 = __stpcpy_chk(__s + sVar6,local_68,0x400);
} while (puVar9 != puVar4 + uVar5 * 6 + 6);
puVar8 = (int8 *)(puVar4 + 2);
lVar7 = (long)((iVar3 - (int)__s) + -2);
__s[lVar7] = '}';
__s[lVar7 + 1] = '\0';
do {
__ptr = (void *)*puVar8;
puVar8 = puVar8 + 3;
free(__ptr);
} while ((int8 *)(puVar4 + uVar5 * 6 + 8) != puVar8);
goto LAB_001017b9;
}
}
sVar6 = strlen(__s);
lVar7 = (long)((int)sVar6 + -2);
__s[lVar7] = '}';
__s[lVar7 + 1] = '\0';
LAB_001017b9:
free(puVar4);
if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) {
return __s;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,731 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
int key;
int *values;
int size;
int capacity;
} MapEntry;
typedef struct {
MapEntry *entries;
int size;
int capacity;
} Map;
void init_map(Map *map) {
map->entries = malloc(sizeof(MapEntry) * 10);
map->size = 0;
map->capacity = 10;
}
void add_to_map(Map *map, int key, int value) {
for (int i = 0; i < map->size; i++) {
if (map->entries[i].key == key) {
for (int j = 0; j < map->entries[i].size; j++) {
if (map->entries[i].values[j] == value)
return;
}
if (map->entries[i].size == map->entries[i].capacity) {
map->entries[i].capacity *= 2;
map->entries[i].values = realloc(map->entries[i].values, sizeof(int) * map->entries[i].capacity);
}
map->entries[i].values[map->entries[i].size++] = value;
return;
}
}
if (map->size == map->capacity) {
map->capacity *= 2;
map->entries = realloc(map->entries, sizeof(MapEntry) * map->capacity);
}
map->entries[map->size].key = key;
map->entries[map->size].values = malloc(sizeof(int) * 10);
map->entries[map->size].values[0] = value;
map->entries[map->size].size = 1;
map->entries[map->size].capacity = 10;
map->size++;
}
| char *func0(int arr[][2], int len) {
Map map;
init_map(&map);
for (int i = 0; i < len; i++) {
add_to_map(&map, arr[i][1], arr[i][0]);
}
char *result = malloc(1024);
strcpy(result, "{");
for (int i = 0; i < map.size; i++) {
char entry[32];
sprintf(entry, "%d: %d, ", map.entries[i].key, map.entries[i].size);
strcat(result, entry);
}
int index = strlen(result) - 2;
result[index] = '}';
result[index + 1] = '\0';
for (int i = 0; i < map.size; i++) {
free(map.entries[i].values);
}
free(map.entries);
return result;
}
| int main() {
int test1[][2] = {{3, 4}, {1, 2}, {2, 4}, {8, 2}, {7, 2}, {8, 1}, {9, 1}, {8, 4}, {10, 4}};
int test2[][2] = {{4, 5}, {2, 3}, {3, 5}, {9, 3}, {8, 3}, {9, 2}, {10, 2}, {9, 5}, {11, 5}};
int test3[][2] = {{6, 5}, {3, 4}, {2, 6}, {11, 1}, {8, 22}, {8, 11}, {4, 3}, {14, 3}, {11, 6}};
assert(strcmp(func0(test1, 9), "{4: 4, 2: 3, 1: 2}") == 0);
assert(strcmp(func0(test2, 9), "{5: 4, 3: 3, 2: 2}") == 0);
assert(strcmp(func0(test3, 9), "{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}") == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
mov %esi,%ebp
push %rbx
mov %rdi,%rbx
mov $0xf0,%edi
sub $0x40,%rsp
mov %fs:0x28,%rax
mov %rax,0x38(%rsp)
xor %eax,%eax
callq 10f0 <malloc@plt>
mov %rax,(%rsp)
mov %rax,%r14
movabs $0xa00000000,%rax
mov %rax,0x8(%rsp)
test %ebp,%ebp
jle 1720 <func0+0x190>
lea -0x1(%rbp),%eax
mov %rsp,%rbp
lea 0x8(%rbx,%rax,8),%r12
nopl 0x0(%rax,%rax,1)
mov 0x4(%rbx),%esi
mov (%rbx),%edx
mov %rbp,%rdi
add $0x8,%rbx
callq 1440 <add_to_map>
cmp %rbx,%r12
jne 15f0 <func0+0x60>
mov 0x8(%rsp),%ebx
mov $0x400,%edi
mov (%rsp),%r14
callq 10f0 <malloc@plt>
mov $0x7b,%edx
mov %dx,(%rax)
mov %rax,%r12
test %ebx,%ebx
jle 1737 <func0+0x1a7>
xor %r13d,%r13d
lea 0x10(%rsp),%rbx
lea 0x9ca(%rip),%rbp
nopw 0x0(%rax,%rax,1)
lea 0x0(%r13,%r13,2),%rax
mov %rbx,%rdi
mov %rbp,%rcx
mov $0x20,%edx
lea (%r14,%rax,8),%rax
mov $0x1,%esi
mov 0x10(%rax),%r9d
mov (%rax),%r8d
xor %eax,%eax
callq 1110 <__sprintf_chk@plt>
mov %r12,%rdi
mov (%rdi),%edx
add $0x4,%rdi
lea -0x1010101(%rdx),%eax
not %edx
and %edx,%eax
and $0x80808080,%eax
je 166a <func0+0xda>
mov %eax,%edx
mov %rbx,%rsi
shr $0x10,%edx
test $0x8080,%eax
cmove %edx,%eax
lea 0x2(%rdi),%rdx
cmove %rdx,%rdi
mov $0x400,%edx
mov %eax,%ecx
add %al,%cl
sbb $0x3,%rdi
add $0x1,%r13
callq 10e0 <__stpcpy_chk@plt>
mov 0x8(%rsp),%edx
mov (%rsp),%r14
cmp %r13d,%edx
jg 1640 <func0+0xb0>
sub %r12,%rax
sub $0x2,%eax
cltq
movb $0x7d,(%r12,%rax,1)
movb $0x0,0x1(%r12,%rax,1)
test %edx,%edx
jle 16f4 <func0+0x164>
xor %ebx,%ebx
nopl (%rax)
lea (%rbx,%rbx,2),%rax
add $0x1,%rbx
mov 0x8(%r14,%rax,8),%rdi
callq 10b0 <free@plt>
mov (%rsp),%r14
cmp %ebx,0x8(%rsp)
jg 16d8 <func0+0x148>
mov %r14,%rdi
callq 10b0 <free@plt>
mov 0x38(%rsp),%rax
xor %fs:0x28,%rax
jne 1788 <func0+0x1f8>
add $0x40,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
retq
nopl 0x0(%rax)
mov $0x400,%edi
callq 10f0 <malloc@plt>
mov %rax,%r12
mov $0x7b,%eax
mov %ax,(%r12)
mov %r12,%rax
mov (%rax),%ecx
add $0x4,%rax
lea -0x1010101(%rcx),%edx
not %ecx
and %ecx,%edx
and $0x80808080,%edx
je 173a <func0+0x1aa>
mov %edx,%ecx
shr $0x10,%ecx
test $0x8080,%edx
cmove %ecx,%edx
lea 0x2(%rax),%rcx
cmove %rcx,%rax
mov %edx,%ecx
add %dl,%cl
sbb $0x3,%rax
sub %r12,%rax
sub $0x2,%eax
cltq
movb $0x7d,(%r12,%rax,1)
movb $0x0,0x1(%r12,%rax,1)
jmpq 16f4 <func0+0x164>
callq 10c0 <__stack_chk_fail@plt>
nopl (%rax)
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
movsxd rbp, esi
push rbx
mov rbx, rdi
mov edi, 0F0h; size
sub rsp, 58h
mov rax, fs:28h
mov [rsp+88h+var_40], rax
xor eax, eax
call _malloc
mov [rsp+88h+ptr], rax
mov r15, rax
mov rax, cs:qword_2150
mov [rsp+88h+var_70], rax
test ebp, ebp
jle loc_1700
lea r12, [rbx+rbp*8]
lea rbp, [rsp+88h+ptr]
nop word ptr [rax+rax+00000000h]
loc_15F0:
mov edx, [rbx]
mov esi, [rbx+4]
mov rdi, rbp
add rbx, 8
call add_to_map
cmp rbx, r12
jnz short loc_15F0
movsxd rbp, dword ptr [rsp+88h+var_70]
mov edi, 400h; size
mov r15, [rsp+88h+ptr]
call _malloc
mov esi, 7Bh ; '{'
mov [rax], si
mov rbx, rax
test ebp, ebp
jle loc_1715
lea r12, [rbp+rbp*2+0]
lea r13, aDD; "%d: %d, "
lea rax, ds:0[r12*8]
lea rbp, [rsp+88h+var_68]
mov r12, r15
mov [rsp+88h+var_80], rax
lea r14, [r15+rax]
nop word ptr [rax+rax+00h]
loc_1658:
mov r9d, [r12+10h]
mov r8d, [r12]
mov rcx, r13
mov rdi, rbp
mov edx, 20h ; ' '
mov esi, 2
xor eax, eax
add r12, 18h
call ___sprintf_chk
mov rdi, rbx; s
call _strlen
mov edx, 400h
mov rsi, rbp
lea rdi, [rbx+rax]
call ___stpcpy_chk
cmp r14, r12
jnz short loc_1658
sub rax, rbx
mov ecx, 7Dh ; '}'
mov r12, [rsp+88h+var_80]
lea rbp, [r15+8]
sub eax, 2
cdqe
add r12, rbp
mov [rbx+rax], cx
nop word ptr [rax+rax+00000000h]
loc_16C0:
mov rdi, [rbp+0]; ptr
add rbp, 18h
call _free
cmp r12, rbp
jnz short loc_16C0
loc_16D2:
mov rdi, r15; ptr
call _free
mov rax, [rsp+88h+var_40]
sub rax, fs:28h
jnz short loc_172D
add rsp, 58h
mov rax, rbx
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_1700:
mov edi, 400h; size
call _malloc
mov rbx, rax
mov eax, 7Bh ; '{'
mov [rbx], ax
loc_1715:
mov rdi, rbx; s
call _strlen
mov edx, 7Dh ; '}'
sub eax, 2
cdqe
mov [rbx+rax], dx
jmp short loc_16D2
loc_172D:
call ___stack_chk_fail | char * func0(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx
char *v3; // r15
unsigned int *v4; // r12
long long v5; // rdx
long long v6; // rsi
long long v7; // rbp
char *v8; // rax
char *v9; // rbx
char *v10; // r12
int v11; // r9d
int v12; // r8d
size_t v13; // rax
int v14; // eax
void **v15; // rbp
void *v16; // rdi
long long v18; // [rsp+8h] [rbp-80h]
void *ptr; // [rsp+10h] [rbp-78h] BYREF
long long v20; // [rsp+18h] [rbp-70h]
_BYTE v21[40]; // [rsp+20h] [rbp-68h] BYREF
unsigned long long v22; // [rsp+48h] [rbp-40h]
v2 = a1;
v22 = __readfsqword(0x28u);
ptr = malloc(0xF0uLL);
v3 = (char *)ptr;
v20 = 0xA00000000LL;
if ( a2 <= 0 )
{
v9 = (char *)malloc(0x400uLL);
*(_WORD *)v9 = 123;
LABEL_11:
*(_WORD *)&v9[(int)(strlen(v9) - 2)] = 125;
goto LABEL_9;
}
v4 = &a1[2 * a2];
do
{
v5 = *v2;
v6 = v2[1];
v2 += 2;
add_to_map(&ptr, v6, v5);
}
while ( v2 != v4 );
v7 = (int)v20;
v3 = (char *)ptr;
v8 = (char *)malloc(0x400uLL);
*(_WORD *)v8 = 123;
v9 = v8;
if ( (int)v7 <= 0 )
goto LABEL_11;
v10 = v3;
v18 = 24 * v7;
do
{
v11 = *((_DWORD *)v10 + 4);
v12 = *(_DWORD *)v10;
v10 += 24;
__sprintf_chk(v21, 2LL, 32LL, "%d: %d, ", v12, v11);
v13 = strlen(v9);
v14 = __stpcpy_chk(&v9[v13], v21, 1024LL);
}
while ( &v3[24 * v7] != v10 );
v15 = (void **)(v3 + 8);
*(_WORD *)&v9[v14 - (int)v9 - 2] = 125;
do
{
v16 = *v15;
v15 += 3;
free(v16);
}
while ( &v3[v18 + 8] != (char *)v15 );
LABEL_9:
free(v3);
return v9;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
MOVSXD RBP,ESI
PUSH RBX
MOV RBX,RDI
MOV EDI,0xf0
SUB RSP,0x58
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
CALL 0x00101130
MOV qword ptr [RSP + 0x10],RAX
MOV R15,RAX
MOV RAX,qword ptr [0x00102150]
MOV qword ptr [RSP + 0x18],RAX
TEST EBP,EBP
JLE 0x00101700
LEA R12,[RBX + RBP*0x8]
LEA RBP,[RSP + 0x10]
NOP word ptr [RAX + RAX*0x1]
LAB_001015f0:
MOV EDX,dword ptr [RBX]
MOV ESI,dword ptr [RBX + 0x4]
MOV RDI,RBP
ADD RBX,0x8
CALL 0x00101460
CMP RBX,R12
JNZ 0x001015f0
MOVSXD RBP,dword ptr [RSP + 0x18]
MOV EDI,0x400
MOV R15,qword ptr [RSP + 0x10]
CALL 0x00101130
MOV ESI,0x7b
MOV word ptr [RAX],SI
MOV RBX,RAX
TEST EBP,EBP
JLE 0x00101715
LEA R12,[RBP + RBP*0x2]
LEA R13,[0x102004]
LEA RAX,[R12*0x8]
LEA RBP,[RSP + 0x20]
MOV R12,R15
MOV qword ptr [RSP + 0x8],RAX
LEA R14,[R15 + RAX*0x1]
NOP word ptr [RAX + RAX*0x1]
LAB_00101658:
MOV R9D,dword ptr [R12 + 0x10]
MOV R8D,dword ptr [R12]
MOV RCX,R13
MOV RDI,RBP
MOV EDX,0x20
MOV ESI,0x2
XOR EAX,EAX
ADD R12,0x18
CALL 0x00101150
MOV RDI,RBX
CALL 0x001010e0
MOV EDX,0x400
MOV RSI,RBP
LEA RDI,[RBX + RAX*0x1]
CALL 0x00101120
CMP R14,R12
JNZ 0x00101658
SUB RAX,RBX
MOV ECX,0x7d
MOV R12,qword ptr [RSP + 0x8]
LEA RBP,[R15 + 0x8]
SUB EAX,0x2
CDQE
ADD R12,RBP
MOV word ptr [RBX + RAX*0x1],CX
NOP word ptr [RAX + RAX*0x1]
LAB_001016c0:
MOV RDI,qword ptr [RBP]
ADD RBP,0x18
CALL 0x001010d0
CMP R12,RBP
JNZ 0x001016c0
LAB_001016d2:
MOV RDI,R15
CALL 0x001010d0
MOV RAX,qword ptr [RSP + 0x48]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x0010172d
ADD RSP,0x58
MOV RAX,RBX
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_00101700:
MOV EDI,0x400
CALL 0x00101130
MOV RBX,RAX
MOV EAX,0x7b
MOV word ptr [RBX],AX
LAB_00101715:
MOV RDI,RBX
CALL 0x001010e0
MOV EDX,0x7d
SUB EAX,0x2
CDQE
MOV word ptr [RBX + RAX*0x1],DX
JMP 0x001016d2
LAB_0010172d:
CALL 0x001010f0 | char * func0(int4 *param_1,int param_2)
{
int4 *puVar1;
int4 uVar2;
void *__ptr;
int iVar3;
int4 *puVar4;
char *__s;
size_t sVar5;
long lVar6;
int8 *puVar7;
int4 *puVar8;
int8 *puVar9;
long in_FS_OFFSET;
int4 *local_78;
int8 local_70;
int local_68 [40];
long local_40;
local_40 = *(long *)(in_FS_OFFSET + 0x28);
puVar4 = (int4 *)malloc(0xf0);
local_70 = DAT_00102150;
local_78 = puVar4;
if (param_2 < 1) {
__s = (char *)malloc(0x400);
__s[0] = '{';
__s[1] = '\0';
}
else {
puVar8 = param_1 + (long)param_2 * 2;
do {
uVar2 = *param_1;
puVar4 = param_1 + 1;
param_1 = param_1 + 2;
add_to_map(&local_78,*puVar4,uVar2);
puVar4 = local_78;
} while (param_1 != puVar8);
iVar3 = (int)local_70;
lVar6 = (long)(int)local_70;
__s = (char *)malloc(0x400);
__s[0] = '{';
__s[1] = '\0';
if (0 < iVar3) {
puVar8 = puVar4;
do {
puVar1 = puVar8 + 4;
uVar2 = *puVar8;
puVar8 = puVar8 + 6;
__sprintf_chk(local_68,2,0x20,"%d: %d, ",uVar2,*puVar1);
sVar5 = strlen(__s);
iVar3 = __stpcpy_chk(__s + sVar5,local_68,0x400);
} while (puVar4 + lVar6 * 6 != puVar8);
puVar7 = (int8 *)(puVar4 + 2);
puVar9 = puVar7 + lVar6 * 3;
(__s + ((iVar3 - (int)__s) + -2))[0] = '}';
(__s + ((iVar3 - (int)__s) + -2))[1] = '\0';
do {
__ptr = (void *)*puVar7;
puVar7 = puVar7 + 3;
free(__ptr);
} while (puVar9 != puVar7);
goto LAB_001016d2;
}
}
sVar5 = strlen(__s);
(__s + ((int)sVar5 + -2))[0] = '}';
(__s + ((int)sVar5 + -2))[1] = '\0';
LAB_001016d2:
free(puVar4);
if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) {
return __s;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,732 | func0 |
#include <assert.h>
typedef struct tuple {
int first;
int last;
} tuple;
| tuple func0(int arr[], int n) {
tuple res;
res.first = arr[0];
res.last = arr[n - 1];
return res;
}
| int main() {
int arr1[] = {10, 4, 5, 6, 7};
tuple result1 = func0(arr1, 5);
assert(result1.first == 10 && result1.last == 7);
int arr2[] = {1, 2, 3, 4, 5};
tuple result2 = func0(arr2, 5);
assert(result2.first == 1 && result2.last == 5);
int arr3[] = {6, 7, 8, 9, 10};
tuple result3 = func0(arr3, 5);
assert(result3.first == 6 && result3.last == 10);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov -0x18(%rbp),%rax
mov (%rax),%eax
mov %eax,-0x8(%rbp)
mov -0x1c(%rbp),%eax
cltq
shl $0x2,%rax
lea -0x4(%rax),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0x4(%rbp)
mov -0x8(%rbp),%rax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_18], rdi
mov [rbp+var_1C], esi
mov rax, [rbp+var_18]
mov eax, [rax]
mov dword ptr [rbp+var_8], eax
mov eax, [rbp+var_1C]
cdqe
shl rax, 2
lea rdx, [rax-4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
mov dword ptr [rbp+var_8+4], eax
mov rax, [rbp+var_8]
pop rbp
retn | long long func0(_DWORD *a1, int a2)
{
long long v3; // [rsp+14h] [rbp-8h]
LODWORD(v3) = *a1;
HIDWORD(v3) = a1[a2 - 1];
return v3;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV RAX,qword ptr [RBP + -0x18]
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x8],EAX
MOV EAX,dword ptr [RBP + -0x1c]
CDQE
SHL RAX,0x2
LEA RDX,[RAX + -0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x4],EAX
MOV RAX,qword ptr [RBP + -0x8]
POP RBP
RET | int8 func0(int4 *param_1,int param_2)
{
return CONCAT44(param_1[(long)param_2 + -1],*param_1);
} |
6,733 | func0 |
#include <assert.h>
typedef struct tuple {
int first;
int last;
} tuple;
| tuple func0(int arr[], int n) {
tuple res;
res.first = arr[0];
res.last = arr[n - 1];
return res;
}
| int main() {
int arr1[] = {10, 4, 5, 6, 7};
tuple result1 = func0(arr1, 5);
assert(result1.first == 10 && result1.last == 7);
int arr2[] = {1, 2, 3, 4, 5};
tuple result2 = func0(arr2, 5);
assert(result2.first == 1 && result2.last == 5);
int arr3[] = {6, 7, 8, 9, 10};
tuple result3 = func0(arr3, 5);
assert(result3.first == 6 && result3.last == 10);
return 0;
}
| O1 | c | func0:
endbr64
movslq %esi,%rsi
mov -0x4(%rdi,%rsi,4),%eax
shl $0x20,%rax
mov %rax,%rdx
mov (%rdi),%eax
or %rdx,%rax
retq
| func0:
endbr64
movsxd rsi, esi
mov edx, [rdi+rsi*4-4]
shl rdx, 20h
mov eax, [rdi]
or rax, rdx
retn | unsigned long long func0(unsigned int *a1, int a2)
{
return ((unsigned long long)a1[a2 - 1] << 32) | *a1;
} | func0:
ENDBR64
MOVSXD RSI,ESI
MOV EDX,dword ptr [RDI + RSI*0x4 + -0x4]
SHL RDX,0x20
MOV EAX,dword ptr [RDI]
OR RAX,RDX
RET | int8 func0(int4 *param_1,int param_2)
{
return CONCAT44(param_1[(long)param_2 + -1],*param_1);
} |
6,734 | func0 |
#include <assert.h>
typedef struct tuple {
int first;
int last;
} tuple;
| tuple func0(int arr[], int n) {
tuple res;
res.first = arr[0];
res.last = arr[n - 1];
return res;
}
| int main() {
int arr1[] = {10, 4, 5, 6, 7};
tuple result1 = func0(arr1, 5);
assert(result1.first == 10 && result1.last == 7);
int arr2[] = {1, 2, 3, 4, 5};
tuple result2 = func0(arr2, 5);
assert(result2.first == 1 && result2.last == 5);
int arr3[] = {6, 7, 8, 9, 10};
tuple result3 = func0(arr3, 5);
assert(result3.first == 6 && result3.last == 10);
return 0;
}
| O2 | c | func0:
endbr64
movslq %esi,%rsi
mov -0x4(%rdi,%rsi,4),%eax
shl $0x20,%rax
mov %rax,%rdx
mov (%rdi),%eax
or %rdx,%rax
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
movsxd rsi, esi
mov eax, [rdi]
mov edx, [rdi+rsi*4-4]
shl rdx, 20h
or rax, rdx
retn | unsigned long long func0(unsigned int *a1, int a2)
{
return ((unsigned long long)a1[a2 - 1] << 32) | *a1;
} | func0:
ENDBR64
MOVSXD RSI,ESI
MOV EAX,dword ptr [RDI]
MOV EDX,dword ptr [RDI + RSI*0x4 + -0x4]
SHL RDX,0x20
OR RAX,RDX
RET | int8 func0(int4 *param_1,int param_2)
{
return CONCAT44(param_1[(long)param_2 + -1],*param_1);
} |
6,735 | func0 |
#include <assert.h>
typedef struct tuple {
int first;
int last;
} tuple;
| tuple func0(int arr[], int n) {
tuple res;
res.first = arr[0];
res.last = arr[n - 1];
return res;
}
| int main() {
int arr1[] = {10, 4, 5, 6, 7};
tuple result1 = func0(arr1, 5);
assert(result1.first == 10 && result1.last == 7);
int arr2[] = {1, 2, 3, 4, 5};
tuple result2 = func0(arr2, 5);
assert(result2.first == 1 && result2.last == 5);
int arr3[] = {6, 7, 8, 9, 10};
tuple result3 = func0(arr3, 5);
assert(result3.first == 6 && result3.last == 10);
return 0;
}
| O3 | c | func0:
endbr64
movslq %esi,%rsi
mov -0x4(%rdi,%rsi,4),%eax
shl $0x20,%rax
mov %rax,%rdx
mov (%rdi),%eax
or %rdx,%rax
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
movsxd rsi, esi
movd xmm1, dword ptr [rdi]
movd xmm0, dword ptr [rdi+rsi*4-4]
punpckldq xmm1, xmm0
movq rax, xmm1
retn | unsigned long long func0(unsigned int *a1, int a2)
{
return _mm_unpacklo_epi32(_mm_cvtsi32_si128(*a1), _mm_cvtsi32_si128(a1[a2 - 1])).m128i_u64[0];
} | func0:
ENDBR64
MOVSXD RSI,ESI
MOVD XMM1,dword ptr [RDI]
MOVD XMM0,dword ptr [RDI + RSI*0x4 + -0x4]
PUNPCKLDQ XMM1,XMM0
MOVQ RAX,XMM1
RET | int8 func0(int4 *param_1,int param_2)
{
return CONCAT44(param_1[(long)param_2 + -1],*param_1);
} |
6,736 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int n) {
if (n < 10) {
return false;
}
int prodOdd = 1, prodEven = 1;
while (n > 0) {
int digit = n % 10;
prodOdd *= digit;
n = n / 10;
if (n == 0) {
break;
}
digit = n % 10;
prodEven *= digit;
n = n / 10;
}
if (prodOdd == prodEven) {
return true;
}
return false;
}
| int main() {
assert(func0(2841) == true);
assert(func0(1234) == false);
assert(func0(1212) == false);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x14(%rbp)
cmpl $0x9,-0x14(%rbp)
jg 1164 <func0+0x1b>
mov $0x0,%eax
jmpq 1248 <func0+0xff>
movl $0x1,-0xc(%rbp)
movl $0x1,-0x8(%rbp)
jmpq 1227 <func0+0xde>
mov -0x14(%rbp),%edx
movslq %edx,%rax
imul $0x66666667,%rax,%rax
shr $0x20,%rax
mov %eax,%ecx
sar $0x2,%ecx
mov %edx,%eax
sar $0x1f,%eax
sub %eax,%ecx
mov %ecx,%eax
shl $0x2,%eax
add %ecx,%eax
add %eax,%eax
sub %eax,%edx
mov %edx,%eax
mov %eax,-0x4(%rbp)
mov -0xc(%rbp),%eax
imul -0x4(%rbp),%eax
mov %eax,-0xc(%rbp)
mov -0x14(%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,-0x14(%rbp)
cmpl $0x0,-0x14(%rbp)
je 1233 <func0+0xea>
mov -0x14(%rbp),%edx
movslq %edx,%rax
imul $0x66666667,%rax,%rax
shr $0x20,%rax
mov %eax,%ecx
sar $0x2,%ecx
mov %edx,%eax
sar $0x1f,%eax
sub %eax,%ecx
mov %ecx,%eax
shl $0x2,%eax
add %ecx,%eax
add %eax,%eax
sub %eax,%edx
mov %edx,%eax
mov %eax,-0x4(%rbp)
mov -0x8(%rbp),%eax
imul -0x4(%rbp),%eax
mov %eax,-0x8(%rbp)
mov -0x14(%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,-0x14(%rbp)
cmpl $0x0,-0x14(%rbp)
jg 1177 <func0+0x2e>
jmp 1234 <func0+0xeb>
mov -0xc(%rbp),%eax
cmp -0x8(%rbp),%eax
jne 1243 <func0+0xfa>
mov $0x1,%eax
jmp 1248 <func0+0xff>
mov $0x0,%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_14], edi
cmp [rbp+var_14], 9
jg short loc_1164
mov eax, 0
jmp loc_1244
loc_1164:
mov [rbp+var_C], 1
mov [rbp+var_8], 1
jmp loc_1223
loc_1177:
mov edx, [rbp+var_14]
movsxd rax, edx
imul rax, 66666667h
shr rax, 20h
mov ecx, eax
sar ecx, 2
mov eax, edx
sar eax, 1Fh
sub ecx, eax
mov eax, ecx
shl eax, 2
add eax, ecx
add eax, eax
sub edx, eax
mov [rbp+var_4], edx
mov eax, [rbp+var_C]
imul eax, [rbp+var_4]
mov [rbp+var_C], eax
mov eax, [rbp+var_14]
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_14], eax
cmp [rbp+var_14], 0
jz short loc_122F
mov edx, [rbp+var_14]
movsxd rax, edx
imul rax, 66666667h
shr rax, 20h
mov ecx, eax
sar ecx, 2
mov eax, edx
sar eax, 1Fh
sub ecx, eax
mov eax, ecx
shl eax, 2
add eax, ecx
add eax, eax
sub edx, eax
mov [rbp+var_4], edx
mov eax, [rbp+var_8]
imul eax, [rbp+var_4]
mov [rbp+var_8], eax
mov eax, [rbp+var_14]
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_14], eax
loc_1223:
cmp [rbp+var_14], 0
jg loc_1177
jmp short loc_1230
loc_122F:
nop
loc_1230:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_8]
jnz short loc_123F
mov eax, 1
jmp short loc_1244
loc_123F:
mov eax, 0
loc_1244:
pop rbp
retn | _BOOL8 func0(int a1)
{
int v2; // [rsp+0h] [rbp-14h]
int v3; // [rsp+0h] [rbp-14h]
int v4; // [rsp+8h] [rbp-Ch]
int v5; // [rsp+Ch] [rbp-8h]
v2 = a1;
if ( a1 <= 9 )
return 0LL;
v4 = 1;
v5 = 1;
while ( v2 > 0 )
{
v4 *= v2 % 10;
v3 = v2 / 10;
if ( !v3 )
break;
v5 *= v3 % 10;
v2 = v3 / 10;
}
return v4 == v5;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x14],EDI
CMP dword ptr [RBP + -0x14],0x9
JG 0x00101164
MOV EAX,0x0
JMP 0x00101244
LAB_00101164:
MOV dword ptr [RBP + -0xc],0x1
MOV dword ptr [RBP + -0x8],0x1
JMP 0x00101223
LAB_00101177:
MOV EDX,dword ptr [RBP + -0x14]
MOVSXD RAX,EDX
IMUL RAX,RAX,0x66666667
SHR RAX,0x20
MOV ECX,EAX
SAR ECX,0x2
MOV EAX,EDX
SAR EAX,0x1f
SUB ECX,EAX
MOV EAX,ECX
SHL EAX,0x2
ADD EAX,ECX
ADD EAX,EAX
SUB EDX,EAX
MOV dword ptr [RBP + -0x4],EDX
MOV EAX,dword ptr [RBP + -0xc]
IMUL EAX,dword ptr [RBP + -0x4]
MOV dword ptr [RBP + -0xc],EAX
MOV EAX,dword ptr [RBP + -0x14]
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 + -0x14],EAX
CMP dword ptr [RBP + -0x14],0x0
JZ 0x0010122f
MOV EDX,dword ptr [RBP + -0x14]
MOVSXD RAX,EDX
IMUL RAX,RAX,0x66666667
SHR RAX,0x20
MOV ECX,EAX
SAR ECX,0x2
MOV EAX,EDX
SAR EAX,0x1f
SUB ECX,EAX
MOV EAX,ECX
SHL EAX,0x2
ADD EAX,ECX
ADD EAX,EAX
SUB EDX,EAX
MOV dword ptr [RBP + -0x4],EDX
MOV EAX,dword ptr [RBP + -0x8]
IMUL EAX,dword ptr [RBP + -0x4]
MOV dword ptr [RBP + -0x8],EAX
MOV EAX,dword ptr [RBP + -0x14]
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 + -0x14],EAX
LAB_00101223:
CMP dword ptr [RBP + -0x14],0x0
JG 0x00101177
JMP 0x00101230
LAB_0010122f:
NOP
LAB_00101230:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x8]
JNZ 0x0010123f
MOV EAX,0x1
JMP 0x00101244
LAB_0010123f:
MOV EAX,0x0
LAB_00101244:
POP RBP
RET | int8 func0(int param_1)
{
int8 uVar1;
int4 local_1c;
int4 local_14;
int4 local_10;
if (param_1 < 10) {
uVar1 = 0;
}
else {
local_14 = 1;
local_10 = 1;
for (local_1c = param_1; 0 < local_1c; local_1c = local_1c / 10) {
local_14 = local_14 * (local_1c % 10);
local_1c = local_1c / 10;
if (local_1c == 0) break;
local_10 = local_10 * (local_1c % 10);
}
if (local_14 == local_10) {
uVar1 = 1;
}
else {
uVar1 = 0;
}
}
return uVar1;
} |
6,737 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int n) {
if (n < 10) {
return false;
}
int prodOdd = 1, prodEven = 1;
while (n > 0) {
int digit = n % 10;
prodOdd *= digit;
n = n / 10;
if (n == 0) {
break;
}
digit = n % 10;
prodEven *= digit;
n = n / 10;
}
if (prodOdd == prodEven) {
return true;
}
return false;
}
| int main() {
assert(func0(2841) == true);
assert(func0(1234) == false);
assert(func0(1212) == false);
return 0;
}
| O1 | c | func0:
endbr64
mov $0x0,%eax
cmp $0x9,%edi
jle 11cf <func0+0x86>
movslq %edi,%rsi
imul $0x66666667,%rsi,%rsi
sar $0x22,%rsi
mov %edi,%eax
sar $0x1f,%eax
sub %eax,%esi
mov %esi,%ecx
lea (%rsi,%rsi,4),%eax
add %eax,%eax
mov %edi,%esi
sub %eax,%esi
mov $0x1,%edi
movslq %ecx,%rax
imul $0x66666667,%rax,%rax
sar $0x22,%rax
mov %ecx,%edx
sar $0x1f,%edx
sub %edx,%eax
lea (%rax,%rax,4),%edx
add %edx,%edx
mov %ecx,%r8d
sub %edx,%r8d
imul %r8d,%edi
cmp $0x9,%ecx
jle 11ca <func0+0x81>
movslq %eax,%rdx
imul $0x66666667,%rdx,%rdx
sar $0x22,%rdx
mov %eax,%ecx
sar $0x1f,%ecx
sub %ecx,%edx
lea (%rdx,%rdx,4),%ecx
add %ecx,%ecx
sub %ecx,%eax
imul %eax,%esi
mov %edx,%ecx
test %edx,%edx
jne 117c <func0+0x33>
cmp %edi,%esi
sete %al
retq
| func0:
endbr64
mov eax, 0
cmp edi, 9
jle short locret_11CF
movsxd rsi, edi
imul rsi, 66666667h
sar rsi, 22h
mov eax, edi
sar eax, 1Fh
sub esi, eax
mov ecx, esi
lea eax, [rsi+rsi*4]
add eax, eax
mov esi, edi
sub esi, eax
mov edi, 1
loc_117C:
movsxd rax, ecx
imul rax, 66666667h
sar rax, 22h
mov edx, ecx
sar edx, 1Fh
sub eax, edx
lea edx, [rax+rax*4]
add edx, edx
mov r8d, ecx
sub r8d, edx
imul edi, r8d
cmp ecx, 9
jle short loc_11CA
movsxd rdx, eax
imul rdx, 66666667h
sar rdx, 22h
mov ecx, eax
sar ecx, 1Fh
sub edx, ecx
lea ecx, [rdx+rdx*4]
add ecx, ecx
sub eax, ecx
imul esi, eax
mov ecx, edx
test edx, edx
jnz short loc_117C
loc_11CA:
cmp esi, edi
setz al
locret_11CF:
retn | bool func0(int a1)
{
bool result; // al
int v2; // ecx
int v3; // esi
int v4; // edi
int v5; // eax
result = 0;
if ( a1 > 9 )
{
v2 = a1 / 10;
v3 = a1 % 10;
v4 = 1;
do
{
v5 = v2 / 10;
v4 *= v2 % 10;
if ( v2 <= 9 )
break;
v3 *= v5 % 10;
v2 = v5 / 10;
}
while ( v5 / 10 );
return v3 == v4;
}
return result;
} | func0:
ENDBR64
MOV EAX,0x0
CMP EDI,0x9
JLE 0x001011cf
MOVSXD RSI,EDI
IMUL RSI,RSI,0x66666667
SAR RSI,0x22
MOV EAX,EDI
SAR EAX,0x1f
SUB ESI,EAX
MOV ECX,ESI
LEA EAX,[RSI + RSI*0x4]
ADD EAX,EAX
MOV ESI,EDI
SUB ESI,EAX
MOV EDI,0x1
LAB_0010117c:
MOVSXD RAX,ECX
IMUL RAX,RAX,0x66666667
SAR RAX,0x22
MOV EDX,ECX
SAR EDX,0x1f
SUB EAX,EDX
LEA EDX,[RAX + RAX*0x4]
ADD EDX,EDX
MOV R8D,ECX
SUB R8D,EDX
IMUL EDI,R8D
CMP ECX,0x9
JLE 0x001011ca
MOVSXD RDX,EAX
IMUL RDX,RDX,0x66666667
SAR RDX,0x22
MOV ECX,EAX
SAR ECX,0x1f
SUB EDX,ECX
LEA ECX,[RDX + RDX*0x4]
ADD ECX,ECX
SUB EAX,ECX
IMUL ESI,EAX
MOV ECX,EDX
TEST EDX,EDX
JNZ 0x0010117c
LAB_001011ca:
CMP ESI,EDI
SETZ AL
LAB_001011cf:
RET | int4 func0(int param_1)
{
int iVar1;
int4 uVar2;
int iVar3;
int iVar4;
uVar2 = 0;
if (9 < param_1) {
iVar3 = param_1 / 10;
param_1 = param_1 % 10;
iVar4 = 1;
do {
iVar1 = iVar3 / 10;
iVar4 = iVar4 * (iVar3 % 10);
if (iVar3 < 10) break;
iVar3 = iVar1 / 10;
iVar1 = iVar1 % 10;
param_1 = param_1 * iVar1;
} while (iVar3 != 0);
uVar2 = CONCAT31((int3)((uint)iVar1 >> 8),param_1 == iVar4);
}
return uVar2;
} |
6,738 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int n) {
if (n < 10) {
return false;
}
int prodOdd = 1, prodEven = 1;
while (n > 0) {
int digit = n % 10;
prodOdd *= digit;
n = n / 10;
if (n == 0) {
break;
}
digit = n % 10;
prodEven *= digit;
n = n / 10;
}
if (prodOdd == prodEven) {
return true;
}
return false;
}
| int main() {
assert(func0(2841) == true);
assert(func0(1234) == false);
assert(func0(1212) == false);
return 0;
}
| O2 | c | func0:
endbr64
cmp $0x9,%edi
jle 1290 <func0+0x10>
jmpq 11f0 <func0.part.0>
xchg %ax,%ax
xor %eax,%eax
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0_part_0:
test edi, edi
jz loc_127E
movsxd rsi, edi
mov eax, edi
imul rsi, 66666667h
sar eax, 1Fh
sar rsi, 22h
sub esi, eax
lea edx, [rsi+rsi*4]
mov eax, esi
mov esi, edi
mov edi, 1
add edx, edx
sub esi, edx
test eax, eax
jnz short loc_124B
jmp short loc_1284
loc_1228:
movsxd rax, edx
mov ecx, edx
imul rax, 66666667h
sar ecx, 1Fh
sar rax, 22h
sub eax, ecx
lea ecx, [rax+rax*4]
add ecx, ecx
sub edx, ecx
imul esi, edx
test eax, eax
jz short loc_1278
loc_124B:
movsxd rdx, eax
mov ecx, eax
imul rdx, 66666667h
sar ecx, 1Fh
sar rdx, 22h
sub edx, ecx
lea ecx, [rdx+rdx*4]
add ecx, ecx
sub eax, ecx
imul edi, eax
test edx, edx
jnz short loc_1228
cmp edi, esi
setz al
retn
loc_1278:
cmp esi, edi
setz al
retn
loc_127E:
mov eax, 1
retn
loc_1284:
cmp esi, 1
setz al
retn | bool func0_part_0(int a1)
{
int v1; // edx
int v2; // eax
int v4; // edi
int v5; // esi
int v6; // edx
int v7; // eax
if ( a1 )
{
v1 = 5 * (a1 / 10);
v2 = a1 / 10;
v4 = 1;
v5 = a1 - 2 * v1;
if ( v2 )
{
do
{
v6 = v2 / 10;
v4 *= v2 % 10;
if ( !(v2 / 10) )
{
LOBYTE(v7) = v4 == v5;
return v7;
}
v2 = v6 / 10;
v5 *= v6 % 10;
}
while ( v6 / 10 );
LOBYTE(v7) = v5 == v4;
}
else
{
return v5 == 1;
}
}
else
{
LOBYTE(v7) = 1;
}
return v7;
} | func0.part.0:
TEST EDI,EDI
JZ 0x0010127e
MOVSXD RSI,EDI
MOV EAX,EDI
IMUL RSI,RSI,0x66666667
SAR EAX,0x1f
SAR RSI,0x22
SUB ESI,EAX
LEA EDX,[RSI + RSI*0x4]
MOV EAX,ESI
MOV ESI,EDI
MOV EDI,0x1
ADD EDX,EDX
SUB ESI,EDX
TEST EAX,EAX
JNZ 0x0010124b
JMP 0x00101284
LAB_00101228:
MOVSXD RAX,EDX
MOV ECX,EDX
IMUL RAX,RAX,0x66666667
SAR ECX,0x1f
SAR RAX,0x22
SUB EAX,ECX
LEA ECX,[RAX + RAX*0x4]
ADD ECX,ECX
SUB EDX,ECX
IMUL ESI,EDX
TEST EAX,EAX
JZ 0x00101278
LAB_0010124b:
MOVSXD RDX,EAX
MOV ECX,EAX
IMUL RDX,RDX,0x66666667
SAR ECX,0x1f
SAR RDX,0x22
SUB EDX,ECX
LEA ECX,[RDX + RDX*0x4]
ADD ECX,ECX
SUB EAX,ECX
IMUL EDI,EAX
TEST EDX,EDX
JNZ 0x00101228
CMP EDI,ESI
SETZ AL
RET
LAB_00101278:
CMP ESI,EDI
SETZ AL
RET
LAB_0010127e:
MOV EAX,0x1
RET
LAB_00101284:
CMP ESI,0x1
SETZ AL
RET | uint func0_part_0(int param_1)
{
int iVar1;
int iVar2;
int iVar3;
if (param_1 == 0) {
return 1;
}
iVar1 = param_1 / 10;
iVar3 = 1;
param_1 = param_1 % 10;
if (iVar1 == 0) {
return (uint)(param_1 == 1);
}
do {
iVar2 = iVar1 / 10;
iVar3 = iVar3 * (iVar1 % 10);
if (iVar2 == 0) {
return CONCAT31((int3)((uint)(iVar1 % 10) >> 8),iVar3 == param_1);
}
iVar1 = iVar2 / 10;
param_1 = param_1 * (iVar2 % 10);
} while (iVar1 != 0);
return (uint)(param_1 == iVar3);
} |
6,739 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int n) {
if (n < 10) {
return false;
}
int prodOdd = 1, prodEven = 1;
while (n > 0) {
int digit = n % 10;
prodOdd *= digit;
n = n / 10;
if (n == 0) {
break;
}
digit = n % 10;
prodEven *= digit;
n = n / 10;
}
if (prodOdd == prodEven) {
return true;
}
return false;
}
| int main() {
assert(func0(2841) == true);
assert(func0(1234) == false);
assert(func0(1212) == false);
return 0;
}
| O3 | c | func0:
endbr64
xor %eax,%eax
cmp $0x9,%edi
jle 1300 <func0+0x80>
movslq %edi,%rsi
mov %edi,%eax
mov $0xcccccccd,%r8d
imul $0x66666667,%rsi,%rsi
sar $0x1f,%eax
sar $0x22,%rsi
sub %eax,%esi
lea (%rsi,%rsi,4),%edx
mov %esi,%eax
mov %edi,%esi
mov $0x1,%edi
add %edx,%edx
sub %edx,%esi
jmp 12d8 <func0+0x58>
nopl 0x0(%rax,%rax,1)
mov %edx,%eax
imul %r8,%rax
shr $0x23,%rax
lea (%rax,%rax,4),%ecx
add %ecx,%ecx
sub %ecx,%edx
imul %edx,%esi
test %eax,%eax
je 12f0 <func0+0x70>
mov %eax,%edx
imul %r8,%rdx
shr $0x23,%rdx
lea (%rdx,%rdx,4),%ecx
add %ecx,%ecx
sub %ecx,%eax
imul %eax,%edi
test %edx,%edx
jne 12c0 <func0+0x40>
cmp %edi,%esi
sete %al
retq
nopw %cs:0x0(%rax,%rax,1)
retq
nopw %cs:0x0(%rax,%rax,1)
nopl 0x0(%rax,%rax,1)
| func0_part_0:
test edi, edi
jz short loc_1266
movsxd rsi, edi
mov eax, edi
mov r8d, 0CCCCCCCDh
imul rsi, 66666667h
sar eax, 1Fh
sar rsi, 22h
sub esi, eax
lea edx, [rsi+rsi*4]
mov eax, esi
mov esi, edi
mov edi, 1
add edx, edx
sub esi, edx
test eax, eax
jnz short loc_1240
jmp short loc_126C
loc_1228:
mov eax, edx
imul rax, r8
shr rax, 23h
lea ecx, [rax+rax*4]
add ecx, ecx
sub edx, ecx
imul esi, edx
test eax, eax
jz short loc_1260
loc_1240:
mov edx, eax
imul rdx, r8
shr rdx, 23h
lea ecx, [rdx+rdx*4]
add ecx, ecx
sub eax, ecx
imul edi, eax
test edx, edx
jnz short loc_1228
cmp edi, esi
setz al
retn
loc_1260:
cmp esi, edi
setz al
retn
loc_1266:
mov eax, 1
retn
loc_126C:
cmp esi, 1
setz al
retn | bool func0_part_0(int a1)
{
int v1; // edx
unsigned int v2; // eax
int v4; // edi
int v5; // esi
unsigned int v6; // edx
int v7; // eax
if ( a1 )
{
v1 = 5 * (a1 / 10);
v2 = a1 / 10;
v4 = 1;
v5 = a1 - 2 * v1;
if ( v2 )
{
do
{
v6 = v2 / 0xA;
v4 *= v2 % 0xA;
if ( !(v2 / 0xA) )
{
LOBYTE(v7) = v4 == v5;
return v7;
}
v2 = v6 / 0xA;
v5 *= v6 % 0xA;
}
while ( v6 / 0xA );
LOBYTE(v7) = v5 == v4;
}
else
{
return v5 == 1;
}
}
else
{
LOBYTE(v7) = 1;
}
return v7;
} | func0.part.0:
TEST EDI,EDI
JZ 0x00101266
MOVSXD RSI,EDI
MOV EAX,EDI
MOV R8D,0xcccccccd
IMUL RSI,RSI,0x66666667
SAR EAX,0x1f
SAR RSI,0x22
SUB ESI,EAX
LEA EDX,[RSI + RSI*0x4]
MOV EAX,ESI
MOV ESI,EDI
MOV EDI,0x1
ADD EDX,EDX
SUB ESI,EDX
TEST EAX,EAX
JNZ 0x00101240
JMP 0x0010126c
LAB_00101228:
MOV EAX,EDX
IMUL RAX,R8
SHR RAX,0x23
LEA ECX,[RAX + RAX*0x4]
ADD ECX,ECX
SUB EDX,ECX
IMUL ESI,EDX
TEST EAX,EAX
JZ 0x00101260
LAB_00101240:
MOV EDX,EAX
IMUL RDX,R8
SHR RDX,0x23
LEA ECX,[RDX + RDX*0x4]
ADD ECX,ECX
SUB EAX,ECX
IMUL EDI,EAX
TEST EDX,EDX
JNZ 0x00101228
CMP EDI,ESI
SETZ AL
RET
LAB_00101260:
CMP ESI,EDI
SETZ AL
RET
LAB_00101266:
MOV EAX,0x1
RET
LAB_0010126c:
CMP ESI,0x1
SETZ AL
RET | ulong func0_part_0(int param_1)
{
int iVar1;
ulong uVar2;
int iVar3;
ulong uVar4;
int iVar5;
int iVar6;
if (param_1 == 0) {
return 1;
}
uVar2 = (ulong)(uint)(param_1 / 10);
iVar6 = 1;
iVar5 = param_1 % 10;
if (param_1 / 10 == 0) {
return (ulong)(iVar5 == 1);
}
do {
uVar4 = uVar2 / 10;
iVar1 = (int)uVar2 + (int)(uVar2 / 10) * -10;
iVar6 = iVar6 * iVar1;
iVar3 = (int)(uVar2 / 10);
if (iVar3 == 0) {
return (ulong)CONCAT31((int3)((uint)iVar1 >> 8),iVar6 == iVar5);
}
uVar2 = uVar4 / 10;
iVar5 = iVar5 * (iVar3 + (int)(uVar4 / 10) * -10);
} while ((int)(uVar4 / 10) != 0);
return CONCAT71((int7)(uVar4 / 0xa00),iVar5 == iVar6);
} |
6,740 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// Function to compare integer arrays
int compare_int_arrays(const void *a, const void *b) {
int *arr1 = *(int **)a;
int *arr2 = *(int **)b;
size_t len1 = arr1[0];
size_t len2 = arr2[0];
if (len1 != len2) return len1 - len2;
for (size_t i = 1; i <= len1; i++) {
if (arr1[i] != arr2[i]) return arr1[i] - arr2[i];
}
return 0;
}
// Function to remove duplicates from list of integer arrays
int** remove_duplicate_lists(int **list, size_t *new_size) {
qsort(list, *new_size, sizeof(int*), compare_int_arrays);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (compare_int_arrays(&list[unique], &list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare strings
int compare_strings(const void *a, const void *b) {
char *const *sa = a;
char *const *sb = b;
return strcmp(*sa, *sb);
}
// Function to remove duplicates from strings
char** remove_duplicate_strings(char **list, size_t *new_size) {
qsort(list, *new_size, sizeof(char*), compare_strings);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (strcmp(list[unique], list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare integers
int compare_ints(const void *a, const void *b) {
int ia = *(int*)a;
int ib = *(int*)b;
return ia - ib;
}
// Function to remove duplicates from integers
| int* func0(int *list, size_t *new_size) {
qsort(list, *new_size, sizeof(int), compare_ints);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (list[unique] != list[i]) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
| int main() {
// Test case 1: List of integer arrays
int list1_item1[] = {2, 10, 20};
int list1_item2[] = {1, 40};
int list1_item3[] = {3, 25, 30, 56};
int list1_item4[] = {2, 10, 20};
int list1_item5[] = {1, 33};
int list1_item6[] = {1, 40};
int* list1[] = {list1_item1, list1_item2, list1_item3, list1_item4, list1_item5, list1_item6};
size_t size1 = 6;
remove_duplicate_lists(list1, &size1);
// Expected [[10, 20], [25, 30, 56], [33], [40]]
// Skipping deep comparison for simplicity
assert(size1 == 4);
// Test case 2: List of strings
char *list2[] = {"a", "b", "a", "c", "c"};
size_t size2 = 5;
remove_duplicate_strings(list2, &size2);
assert(size2 == 3);
assert(strcmp(list2[0], "a") == 0);
assert(strcmp(list2[1], "b") == 0);
assert(strcmp(list2[2], "c") == 0);
// Test case 3: List of integers
int list3[] = {1, 3, 5, 6, 3, 5, 6, 1};
size_t size3 = 8;
func0(list3, &size3);
assert(size3 == 4);
assert(list3[0] == 1);
assert(list3[1] == 3);
assert(list3[2] == 5);
assert(list3[3] == 6);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
mov -0x20(%rbp),%rax
mov (%rax),%rsi
mov -0x18(%rbp),%rax
lea -0x50(%rip),%rcx
mov $0x4,%edx
mov %rax,%rdi
callq 1080 <qsort@plt>
movq $0x0,-0x10(%rbp)
movq $0x1,-0x8(%rbp)
jmp 1539 <func0+0xa7>
mov -0x10(%rbp),%rax
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x8(%rbp),%rax
lea 0x0(,%rax,4),%rcx
mov -0x18(%rbp),%rax
add %rcx,%rax
mov (%rax),%eax
cmp %eax,%edx
je 1534 <func0+0xa2>
addq $0x1,-0x10(%rbp)
mov -0x8(%rbp),%rax
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov -0x10(%rbp),%rdx
lea 0x0(,%rdx,4),%rcx
mov -0x18(%rbp),%rdx
add %rcx,%rdx
mov (%rax),%eax
mov %eax,(%rdx)
addq $0x1,-0x8(%rbp)
mov -0x20(%rbp),%rax
mov (%rax),%rax
cmp %rax,-0x8(%rbp)
jb 14d7 <func0+0x45>
mov -0x10(%rbp),%rax
lea 0x1(%rax),%rdx
mov -0x20(%rbp),%rax
mov %rdx,(%rax)
mov -0x18(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+base], rdi
mov [rbp+var_20], rsi
mov rax, [rbp+var_20]
mov rsi, [rax]; nmemb
mov rax, [rbp+base]
lea rdx, compare_ints
mov rcx, rdx; compar
mov edx, 4; size
mov rdi, rax; base
call _qsort
mov [rbp+var_10], 0
mov [rbp+var_8], 1
jmp short loc_1542
loc_14E0:
mov rax, [rbp+var_10]
lea rdx, ds:0[rax*4]
mov rax, [rbp+base]
add rax, rdx
mov edx, [rax]
mov rax, [rbp+var_8]
lea rcx, ds:0[rax*4]
mov rax, [rbp+base]
add rax, rcx
mov eax, [rax]
cmp edx, eax
jz short loc_153D
add [rbp+var_10], 1
mov rax, [rbp+var_8]
lea rdx, ds:0[rax*4]
mov rax, [rbp+base]
add rax, rdx
mov rdx, [rbp+var_10]
lea rcx, ds:0[rdx*4]
mov rdx, [rbp+base]
add rdx, rcx
mov eax, [rax]
mov [rdx], eax
loc_153D:
add [rbp+var_8], 1
loc_1542:
mov rax, [rbp+var_20]
mov rax, [rax]
cmp [rbp+var_8], rax
jb short loc_14E0
mov rax, [rbp+var_10]
lea rdx, [rax+1]
mov rax, [rbp+var_20]
mov [rax], rdx
mov rax, [rbp+base]
leave
retn | void * func0(void *a1, size_t *a2)
{
long long v3; // [rsp+10h] [rbp-10h]
unsigned long long i; // [rsp+18h] [rbp-8h]
qsort(a1, *a2, 4uLL, compare_ints);
v3 = 0LL;
for ( i = 1LL; i < *a2; ++i )
{
if ( *((_DWORD *)a1 + v3) != *((_DWORD *)a1 + i) )
{
++v3;
*((_DWORD *)a1 + v3) = *((_DWORD *)a1 + i);
}
}
*a2 = v3 + 1;
return a1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOV qword ptr [RBP + -0x18],RDI
MOV qword ptr [RBP + -0x20],RSI
MOV RAX,qword ptr [RBP + -0x20]
MOV RSI,qword ptr [RAX]
MOV RAX,qword ptr [RBP + -0x18]
LEA RDX,[0x10146e]
MOV RCX,RDX
MOV EDX,0x4
MOV RDI,RAX
CALL 0x00101080
MOV qword ptr [RBP + -0x10],0x0
MOV qword ptr [RBP + -0x8],0x1
JMP 0x00101542
LAB_001014e0:
MOV RAX,qword ptr [RBP + -0x10]
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV RAX,qword ptr [RBP + -0x8]
LEA RCX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RCX
MOV EAX,dword ptr [RAX]
CMP EDX,EAX
JZ 0x0010153d
ADD qword ptr [RBP + -0x10],0x1
MOV RAX,qword ptr [RBP + -0x8]
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV RDX,qword ptr [RBP + -0x10]
LEA RCX,[RDX*0x4]
MOV RDX,qword ptr [RBP + -0x18]
ADD RDX,RCX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RDX],EAX
LAB_0010153d:
ADD qword ptr [RBP + -0x8],0x1
LAB_00101542:
MOV RAX,qword ptr [RBP + -0x20]
MOV RAX,qword ptr [RAX]
CMP qword ptr [RBP + -0x8],RAX
JC 0x001014e0
MOV RAX,qword ptr [RBP + -0x10]
LEA RDX,[RAX + 0x1]
MOV RAX,qword ptr [RBP + -0x20]
MOV qword ptr [RAX],RDX
MOV RAX,qword ptr [RBP + -0x18]
LEAVE
RET | void * func0(void *param_1,size_t *param_2)
{
long local_18;
ulong local_10;
qsort(param_1,*param_2,4,compare_ints);
local_18 = 0;
for (local_10 = 1; local_10 < *param_2; local_10 = local_10 + 1) {
if (*(int *)((long)param_1 + local_18 * 4) != *(int *)((long)param_1 + local_10 * 4)) {
local_18 = local_18 + 1;
*(int4 *)((long)param_1 + local_18 * 4) = *(int4 *)((long)param_1 + local_10 * 4);
}
}
*param_2 = local_18 + 1;
return param_1;
} |
6,741 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// Function to compare integer arrays
int compare_int_arrays(const void *a, const void *b) {
int *arr1 = *(int **)a;
int *arr2 = *(int **)b;
size_t len1 = arr1[0];
size_t len2 = arr2[0];
if (len1 != len2) return len1 - len2;
for (size_t i = 1; i <= len1; i++) {
if (arr1[i] != arr2[i]) return arr1[i] - arr2[i];
}
return 0;
}
// Function to remove duplicates from list of integer arrays
int** remove_duplicate_lists(int **list, size_t *new_size) {
qsort(list, *new_size, sizeof(int*), compare_int_arrays);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (compare_int_arrays(&list[unique], &list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare strings
int compare_strings(const void *a, const void *b) {
char *const *sa = a;
char *const *sb = b;
return strcmp(*sa, *sb);
}
// Function to remove duplicates from strings
char** remove_duplicate_strings(char **list, size_t *new_size) {
qsort(list, *new_size, sizeof(char*), compare_strings);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (strcmp(list[unique], list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare integers
int compare_ints(const void *a, const void *b) {
int ia = *(int*)a;
int ib = *(int*)b;
return ia - ib;
}
// Function to remove duplicates from integers
| int* func0(int *list, size_t *new_size) {
qsort(list, *new_size, sizeof(int), compare_ints);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (list[unique] != list[i]) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
| int main() {
// Test case 1: List of integer arrays
int list1_item1[] = {2, 10, 20};
int list1_item2[] = {1, 40};
int list1_item3[] = {3, 25, 30, 56};
int list1_item4[] = {2, 10, 20};
int list1_item5[] = {1, 33};
int list1_item6[] = {1, 40};
int* list1[] = {list1_item1, list1_item2, list1_item3, list1_item4, list1_item5, list1_item6};
size_t size1 = 6;
remove_duplicate_lists(list1, &size1);
// Expected [[10, 20], [25, 30, 56], [33], [40]]
// Skipping deep comparison for simplicity
assert(size1 == 4);
// Test case 2: List of strings
char *list2[] = {"a", "b", "a", "c", "c"};
size_t size2 = 5;
remove_duplicate_strings(list2, &size2);
assert(size2 == 3);
assert(strcmp(list2[0], "a") == 0);
assert(strcmp(list2[1], "b") == 0);
assert(strcmp(list2[2], "c") == 0);
// Test case 3: List of integers
int list3[] = {1, 3, 5, 6, 3, 5, 6, 1};
size_t size3 = 8;
func0(list3, &size3);
assert(size3 == 4);
assert(list3[0] == 1);
assert(list3[1] == 3);
assert(list3[2] == 5);
assert(list3[3] == 6);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%rbx
mov %rsi,%rbp
lea -0x14a(%rip),%rcx
mov $0x4,%edx
mov (%rsi),%rsi
callq 1080 <qsort@plt>
cmpq $0x1,0x0(%rbp)
jbe 1380 <func0+0x5b>
mov $0x1,%eax
mov $0x0,%edx
jmp 136e <func0+0x49>
add $0x1,%rdx
mov %ecx,0x4(%rbx,%rsi,1)
add $0x1,%rax
cmp %rax,0x0(%rbp)
jbe 1385 <func0+0x60>
lea 0x0(,%rdx,4),%rsi
mov (%rbx,%rax,4),%ecx
cmp %ecx,(%rbx,%rdx,4)
jne 135c <func0+0x37>
jmp 1364 <func0+0x3f>
mov $0x0,%edx
add $0x1,%rdx
mov %rdx,0x0(%rbp)
mov %rbx,%rax
add $0x8,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
mov rbx, rdi
mov rbp, rsi
lea rcx, compare_ints
mov edx, 4
mov rsi, [rsi]
call _qsort
cmp qword ptr [rbp+0], 1
jbe short loc_1380
mov eax, 1
mov edx, 0
jmp short loc_1366
loc_135C:
add rax, 1
cmp [rbp+0], rax
jbe short loc_1385
loc_1366:
lea rsi, ds:0[rdx*4]
mov ecx, [rbx+rax*4]
cmp [rbx+rdx*4], ecx
jz short loc_135C
add rdx, 1
mov [rbx+rsi+4], ecx
jmp short loc_135C
loc_1380:
mov edx, 0
loc_1385:
add rdx, 1
mov [rbp+0], rdx
mov rax, rbx
add rsp, 8
pop rbx
pop rbp
retn | long long func0(long long a1, unsigned long long *a2)
{
unsigned long long v3; // rax
long long v4; // rdx
long long v5; // rsi
int v6; // ecx
qsort(a1, *a2, 4LL, compare_ints);
if ( *a2 <= 1 )
{
v4 = 0LL;
}
else
{
v3 = 1LL;
v4 = 0LL;
do
{
v5 = 4 * v4;
v6 = *(_DWORD *)(a1 + 4 * v3);
if ( *(_DWORD *)(a1 + 4 * v4) != v6 )
{
++v4;
*(_DWORD *)(a1 + v5 + 4) = v6;
}
++v3;
}
while ( *a2 > v3 );
}
*a2 = v4 + 1;
return a1;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBX,RDI
MOV RBP,RSI
LEA RCX,[0x1011f2]
MOV EDX,0x4
MOV RSI,qword ptr [RSI]
CALL 0x00101080
CMP qword ptr [RBP],0x1
JBE 0x00101380
MOV EAX,0x1
MOV EDX,0x0
JMP 0x00101366
LAB_0010135c:
ADD RAX,0x1
CMP qword ptr [RBP],RAX
JBE 0x00101385
LAB_00101366:
LEA RSI,[RDX*0x4]
MOV ECX,dword ptr [RBX + RAX*0x4]
CMP dword ptr [RBX + RDX*0x4],ECX
JZ 0x0010135c
ADD RDX,0x1
MOV dword ptr [RBX + RSI*0x1 + 0x4],ECX
JMP 0x0010135c
LAB_00101380:
MOV EDX,0x0
LAB_00101385:
ADD RDX,0x1
MOV qword ptr [RBP],RDX
MOV RAX,RBX
ADD RSP,0x8
POP RBX
POP RBP
RET | void * func0(void *param_1,size_t *param_2)
{
long lVar1;
int iVar2;
ulong uVar3;
long lVar4;
qsort(param_1,*param_2,4,compare_ints);
if (*param_2 < 2) {
lVar4 = 0;
}
else {
uVar3 = 1;
lVar4 = 0;
do {
lVar1 = lVar4 * 4;
iVar2 = *(int *)((long)param_1 + uVar3 * 4);
if (*(int *)((long)param_1 + lVar4 * 4) != iVar2) {
lVar4 = lVar4 + 1;
*(int *)((long)param_1 + lVar1 + 4) = iVar2;
}
uVar3 = uVar3 + 1;
} while (uVar3 < *param_2);
}
*param_2 = lVar4 + 1;
return param_1;
} |
6,742 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// Function to compare integer arrays
int compare_int_arrays(const void *a, const void *b) {
int *arr1 = *(int **)a;
int *arr2 = *(int **)b;
size_t len1 = arr1[0];
size_t len2 = arr2[0];
if (len1 != len2) return len1 - len2;
for (size_t i = 1; i <= len1; i++) {
if (arr1[i] != arr2[i]) return arr1[i] - arr2[i];
}
return 0;
}
// Function to remove duplicates from list of integer arrays
int** remove_duplicate_lists(int **list, size_t *new_size) {
qsort(list, *new_size, sizeof(int*), compare_int_arrays);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (compare_int_arrays(&list[unique], &list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare strings
int compare_strings(const void *a, const void *b) {
char *const *sa = a;
char *const *sb = b;
return strcmp(*sa, *sb);
}
// Function to remove duplicates from strings
char** remove_duplicate_strings(char **list, size_t *new_size) {
qsort(list, *new_size, sizeof(char*), compare_strings);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (strcmp(list[unique], list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare integers
int compare_ints(const void *a, const void *b) {
int ia = *(int*)a;
int ib = *(int*)b;
return ia - ib;
}
// Function to remove duplicates from integers
| int* func0(int *list, size_t *new_size) {
qsort(list, *new_size, sizeof(int), compare_ints);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (list[unique] != list[i]) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
| int main() {
// Test case 1: List of integer arrays
int list1_item1[] = {2, 10, 20};
int list1_item2[] = {1, 40};
int list1_item3[] = {3, 25, 30, 56};
int list1_item4[] = {2, 10, 20};
int list1_item5[] = {1, 33};
int list1_item6[] = {1, 40};
int* list1[] = {list1_item1, list1_item2, list1_item3, list1_item4, list1_item5, list1_item6};
size_t size1 = 6;
remove_duplicate_lists(list1, &size1);
// Expected [[10, 20], [25, 30, 56], [33], [40]]
// Skipping deep comparison for simplicity
assert(size1 == 4);
// Test case 2: List of strings
char *list2[] = {"a", "b", "a", "c", "c"};
size_t size2 = 5;
remove_duplicate_strings(list2, &size2);
assert(size2 == 3);
assert(strcmp(list2[0], "a") == 0);
assert(strcmp(list2[1], "b") == 0);
assert(strcmp(list2[2], "c") == 0);
// Test case 3: List of integers
int list3[] = {1, 3, 5, 6, 3, 5, 6, 1};
size_t size3 = 8;
func0(list3, &size3);
assert(size3 == 4);
assert(list3[0] == 1);
assert(list3[1] == 3);
assert(list3[2] == 5);
assert(list3[3] == 6);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
lea -0x1ad(%rip),%rcx
mov $0x4,%edx
mov %rdi,%r12
push %rbx
mov %rsi,%rbx
sub $0x8,%rsp
mov (%rsi),%rsi
callq 1080 <qsort@plt>
mov (%rbx),%rax
cmp $0x1,%rax
jbe 17b0 <func0+0x80>
lea 0x4(%r12),%rcx
lea (%r12,%rax,4),%r8
xor %edx,%edx
nopl 0x0(%rax)
mov (%rcx),%esi
lea 0x0(,%rdx,4),%rdi
lea 0x1(%rdx),%rax
cmp %esi,(%r12,%rdx,4)
je 1793 <func0+0x63>
mov %esi,0x4(%r12,%rdi,1)
lea 0x2(%rdx),%rsi
mov %rax,%rdx
mov %rsi,%rax
add $0x4,%rcx
cmp %rcx,%r8
jne 1770 <func0+0x40>
mov %rax,(%rbx)
add $0x8,%rsp
mov %r12,%rax
pop %rbx
pop %r12
retq
nopw 0x0(%rax,%rax,1)
mov $0x1,%eax
mov %rax,(%rbx)
add $0x8,%rsp
mov %r12,%rax
pop %rbx
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
push r12
lea rcx, compare_ints
mov edx, 4
mov r12, rdi
push rbx
mov rbx, rsi
sub rsp, 8
mov rsi, [rsi]
call _qsort
mov rax, [rbx]
cmp rax, 1
jbe short loc_1798
lea rdx, [r12+4]
lea rdi, [r12+rax*4]
xor ecx, ecx
nop dword ptr [rax+00000000h]
loc_1760:
mov esi, [rdx]
lea rax, ds:0[rcx*4]
cmp [r12+rcx*4], esi
jz short loc_1779
mov [r12+rax+4], esi
add rcx, 1
loc_1779:
add rdx, 4
cmp rdx, rdi
jnz short loc_1760
add rcx, 1
mov rax, r12
mov [rbx], rcx
add rsp, 8
pop rbx
pop r12
retn
loc_1798:
mov ecx, 1
mov rax, r12
mov [rbx], rcx
add rsp, 8
pop rbx
pop r12
retn | long long func0(long long a1, _QWORD *a2)
{
_DWORD *v3; // rdx
_DWORD *v4; // rdi
long long v5; // rcx
long long result; // rax
qsort(a1, *a2, 4LL, compare_ints);
if ( *a2 <= 1uLL )
{
result = a1;
*a2 = 1LL;
}
else
{
v3 = (_DWORD *)(a1 + 4);
v4 = (_DWORD *)(a1 + 4LL * *a2);
v5 = 0LL;
do
{
if ( *(_DWORD *)(a1 + 4 * v5) != *v3 )
*(_DWORD *)(a1 + 4 * v5++ + 4) = *v3;
++v3;
}
while ( v3 != v4 );
result = a1;
*a2 = v5 + 1;
}
return result;
} | func0:
ENDBR64
PUSH R12
LEA RCX,[0x101590]
MOV EDX,0x4
MOV R12,RDI
PUSH RBX
MOV RBX,RSI
SUB RSP,0x8
MOV RSI,qword ptr [RSI]
CALL 0x00101080
MOV RAX,qword ptr [RBX]
CMP RAX,0x1
JBE 0x00101798
LEA RDX,[R12 + 0x4]
LEA RDI,[R12 + RAX*0x4]
XOR ECX,ECX
NOP dword ptr [RAX]
LAB_00101760:
MOV ESI,dword ptr [RDX]
LEA RAX,[RCX*0x4]
CMP dword ptr [R12 + RCX*0x4],ESI
JZ 0x00101779
MOV dword ptr [R12 + RAX*0x1 + 0x4],ESI
ADD RCX,0x1
LAB_00101779:
ADD RDX,0x4
CMP RDX,RDI
JNZ 0x00101760
ADD RCX,0x1
MOV RAX,R12
MOV qword ptr [RBX],RCX
ADD RSP,0x8
POP RBX
POP R12
RET
LAB_00101798:
MOV ECX,0x1
MOV RAX,R12
MOV qword ptr [RBX],RCX
ADD RSP,0x8
POP RBX
POP R12
RET | void * func0(void *param_1,size_t *param_2)
{
ulong uVar1;
long lVar2;
int *piVar3;
qsort(param_1,*param_2,4,compare_ints);
uVar1 = *param_2;
if (1 < uVar1) {
piVar3 = (int *)((long)param_1 + 4);
lVar2 = 0;
do {
if (*(int *)((long)param_1 + lVar2 * 4) != *piVar3) {
*(int *)((long)param_1 + lVar2 * 4 + 4) = *piVar3;
lVar2 = lVar2 + 1;
}
piVar3 = piVar3 + 1;
} while (piVar3 != (int *)((long)param_1 + uVar1 * 4));
*param_2 = lVar2 + 1;
return param_1;
}
*param_2 = 1;
return param_1;
} |
6,743 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// Function to compare integer arrays
int compare_int_arrays(const void *a, const void *b) {
int *arr1 = *(int **)a;
int *arr2 = *(int **)b;
size_t len1 = arr1[0];
size_t len2 = arr2[0];
if (len1 != len2) return len1 - len2;
for (size_t i = 1; i <= len1; i++) {
if (arr1[i] != arr2[i]) return arr1[i] - arr2[i];
}
return 0;
}
// Function to remove duplicates from list of integer arrays
int** remove_duplicate_lists(int **list, size_t *new_size) {
qsort(list, *new_size, sizeof(int*), compare_int_arrays);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (compare_int_arrays(&list[unique], &list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare strings
int compare_strings(const void *a, const void *b) {
char *const *sa = a;
char *const *sb = b;
return strcmp(*sa, *sb);
}
// Function to remove duplicates from strings
char** remove_duplicate_strings(char **list, size_t *new_size) {
qsort(list, *new_size, sizeof(char*), compare_strings);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (strcmp(list[unique], list[i]) != 0) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
// Function to compare integers
int compare_ints(const void *a, const void *b) {
int ia = *(int*)a;
int ib = *(int*)b;
return ia - ib;
}
// Function to remove duplicates from integers
| int* func0(int *list, size_t *new_size) {
qsort(list, *new_size, sizeof(int), compare_ints);
size_t unique = 0;
for (size_t i = 1; i < *new_size; i++) {
if (list[unique] != list[i]) {
unique++;
list[unique] = list[i];
}
}
*new_size = unique + 1;
return list;
}
| int main() {
// Test case 1: List of integer arrays
int list1_item1[] = {2, 10, 20};
int list1_item2[] = {1, 40};
int list1_item3[] = {3, 25, 30, 56};
int list1_item4[] = {2, 10, 20};
int list1_item5[] = {1, 33};
int list1_item6[] = {1, 40};
int* list1[] = {list1_item1, list1_item2, list1_item3, list1_item4, list1_item5, list1_item6};
size_t size1 = 6;
remove_duplicate_lists(list1, &size1);
// Expected [[10, 20], [25, 30, 56], [33], [40]]
// Skipping deep comparison for simplicity
assert(size1 == 4);
// Test case 2: List of strings
char *list2[] = {"a", "b", "a", "c", "c"};
size_t size2 = 5;
remove_duplicate_strings(list2, &size2);
assert(size2 == 3);
assert(strcmp(list2[0], "a") == 0);
assert(strcmp(list2[1], "b") == 0);
assert(strcmp(list2[2], "c") == 0);
// Test case 3: List of integers
int list3[] = {1, 3, 5, 6, 3, 5, 6, 1};
size_t size3 = 8;
func0(list3, &size3);
assert(size3 == 4);
assert(list3[0] == 1);
assert(list3[1] == 3);
assert(list3[2] == 5);
assert(list3[3] == 6);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
lea -0x1ad(%rip),%rcx
mov $0x4,%edx
mov %rdi,%r12
push %rbx
mov %rsi,%rbx
sub $0x8,%rsp
mov (%rsi),%rsi
callq 1080 <qsort@plt>
mov (%rbx),%rax
cmp $0x1,%rax
jbe 17a0 <func0+0x90>
mov (%r12),%r9d
lea 0x4(%r12),%rdx
lea (%r12,%rax,4),%rax
xor %r8d,%r8d
mov $0x1,%esi
mov (%rdx),%ecx
cmp %r9d,%ecx
je 177c <func0+0x6c>
add $0x4,%rdx
mov %ecx,(%r12,%rsi,4)
add $0x2,%r8
cmp %rax,%rdx
je 1788 <func0+0x78>
mov %ecx,%r9d
mov (%rdx),%ecx
mov %rsi,%r8
add $0x1,%rsi
cmp %r9d,%ecx
jne 175a <func0+0x4a>
add $0x4,%rdx
cmp %rax,%rdx
jne 1753 <func0+0x43>
mov %rsi,%r8
mov %r8,(%rbx)
add $0x8,%rsp
mov %r12,%rax
pop %rbx
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
mov $0x1,%r8d
mov %r12,%rax
mov %r8,(%rbx)
add $0x8,%rsp
pop %rbx
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
xchg %ax,%ax
| func0:
endbr64
push rbp
mov rbp, rsi
lea rcx, compare_ints; compar
mov edx, 4; size
push rbx
mov rbx, rdi
sub rsp, 8
mov rsi, [rsi]; nmemb
call _qsort
mov rax, [rbp+0]
cmp rax, 1
jbe short loc_1798
mov r8d, [rbx]
lea rdx, [rbx+4]
lea rax, [rbx+rax*4]
xor esi, esi
jmp short loc_1773
loc_1760:
add rsi, 1
add rdx, 4
mov [rbx+rsi*4], ecx
cmp rax, rdx
jz short loc_1783
loc_1770:
mov r8d, ecx
loc_1773:
mov ecx, [rdx]
cmp ecx, r8d
jnz short loc_1760
add rdx, 4
cmp rax, rdx
jnz short loc_1770
loc_1783:
add rsi, 1
mov rax, rbx
mov [rbp+0], rsi
add rsp, 8
pop rbx
pop rbp
retn
loc_1798:
mov esi, 1
mov rax, rbx
mov [rbp+0], rsi
add rsp, 8
pop rbx
pop rbp
retn | int * func0(int *a1, size_t *a2)
{
int v3; // r8d
int *v4; // rdx
int *v5; // rax
long long v6; // rsi
int v7; // ecx
int *result; // rax
qsort(a1, *a2, 4uLL, compare_ints);
if ( *a2 > 1 )
{
v3 = *a1;
v4 = a1 + 1;
v5 = &a1[*a2];
v6 = 0LL;
while ( 1 )
{
v7 = *v4;
if ( *v4 == v3 )
{
if ( v5 == ++v4 )
{
LABEL_7:
result = a1;
*a2 = v6 + 1;
return result;
}
}
else
{
++v6;
++v4;
a1[v6] = v7;
if ( v5 == v4 )
goto LABEL_7;
}
v3 = v7;
}
}
result = a1;
*a2 = 1LL;
return result;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSI
LEA RCX,[0x101590]
MOV EDX,0x4
PUSH RBX
MOV RBX,RDI
SUB RSP,0x8
MOV RSI,qword ptr [RSI]
CALL 0x00101080
MOV RAX,qword ptr [RBP]
CMP RAX,0x1
JBE 0x00101798
MOV R8D,dword ptr [RBX]
LEA RDX,[RBX + 0x4]
LEA RAX,[RBX + RAX*0x4]
XOR ESI,ESI
JMP 0x00101773
LAB_00101760:
ADD RSI,0x1
ADD RDX,0x4
MOV dword ptr [RBX + RSI*0x4],ECX
CMP RAX,RDX
JZ 0x00101783
LAB_00101770:
MOV R8D,ECX
LAB_00101773:
MOV ECX,dword ptr [RDX]
CMP ECX,R8D
JNZ 0x00101760
ADD RDX,0x4
CMP RAX,RDX
JNZ 0x00101770
LAB_00101783:
ADD RSI,0x1
MOV RAX,RBX
MOV qword ptr [RBP],RSI
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_00101798:
MOV ESI,0x1
MOV RAX,RBX
MOV qword ptr [RBP],RSI
ADD RSP,0x8
POP RBX
POP RBP
RET | int * func0(int *param_1,size_t *param_2)
{
int iVar1;
ulong uVar2;
int *piVar3;
long lVar4;
int iVar5;
qsort(param_1,*param_2,4,compare_ints);
uVar2 = *param_2;
if (uVar2 < 2) {
*param_2 = 1;
return param_1;
}
piVar3 = param_1 + 1;
lVar4 = 0;
iVar5 = *param_1;
while( true ) {
iVar1 = *piVar3;
if (iVar1 != iVar5) {
lVar4 = lVar4 + 1;
param_1[lVar4] = iVar1;
}
if (param_1 + uVar2 == piVar3 + 1) break;
piVar3 = piVar3 + 1;
iVar5 = iVar1;
}
*param_2 = lVar4 + 1;
return param_1;
} |
6,744 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(bool test_tup[], int size) {
for (int i = 0; i < size; i++) {
if (!test_tup[i]) return false;
}
return true;
}
| int main() {
bool arr1[] = {true, true, true, true};
bool arr2[] = {true, false, true, true};
bool arr3[] = {true, true, true, true};
assert(func0(arr1, 4) == true);
assert(func0(arr2, 4) == false);
assert(func0(arr3, 4) == true);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x0,-0x4(%rbp)
jmp 11a3 <func0+0x3a>
mov -0x4(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
xor $0x1,%eax
test %al,%al
je 119f <func0+0x36>
mov $0x0,%eax
jmp 11b0 <func0+0x47>
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x1c(%rbp),%eax
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_11A3
loc_1181:
mov eax, [rbp+var_4]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
xor eax, 1
test al, al
jz short loc_119F
mov eax, 0
jmp short loc_11B0
loc_119F:
add [rbp+var_4], 1
loc_11A3:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_1C]
jl short loc_1181
mov eax, 1
loc_11B0:
pop rbp
retn | long long func0(long long a1, int a2)
{
int i; // [rsp+18h] [rbp-4h]
for ( i = 0; i < a2; ++i )
{
if ( *(_BYTE *)(i + a1) != 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 dword ptr [RBP + -0x4],0x0
JMP 0x001011a3
LAB_00101181:
MOV EAX,dword ptr [RBP + -0x4]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
XOR EAX,0x1
TEST AL,AL
JZ 0x0010119f
MOV EAX,0x0
JMP 0x001011b0
LAB_0010119f:
ADD dword ptr [RBP + -0x4],0x1
LAB_001011a3:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x00101181
MOV EAX,0x1
LAB_001011b0:
POP RBP
RET | int8 func0(long param_1,int param_2)
{
int local_c;
local_c = 0;
while( true ) {
if (param_2 <= local_c) {
return 1;
}
if (*(char *)(param_1 + local_c) != '\x01') break;
local_c = local_c + 1;
}
return 0;
} |
6,745 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(bool test_tup[], int size) {
for (int i = 0; i < size; i++) {
if (!test_tup[i]) return false;
}
return true;
}
| int main() {
bool arr1[] = {true, true, true, true};
bool arr2[] = {true, false, true, true};
bool arr3[] = {true, true, true, true};
assert(func0(arr1, 4) == true);
assert(func0(arr2, 4) == false);
assert(func0(arr3, 4) == true);
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 118f <func0+0x26>
mov %rdi,%rax
lea -0x1(%rsi),%edx
lea 0x1(%rdi,%rdx,1),%rcx
movzbl (%rax),%edx
test %dl,%dl
je 118c <func0+0x23>
add $0x1,%rax
cmp %rcx,%rax
jne 117c <func0+0x13>
mov %edx,%eax
retq
mov $0x1,%edx
jmp 118c <func0+0x23>
| func0:
endbr64
test esi, esi
jle short loc_118F
mov rax, rdi
lea edx, [rsi-1]
lea rcx, [rdi+rdx+1]
loc_117C:
movzx edx, byte ptr [rax]
test dl, dl
jz short loc_118C
add rax, 1
cmp rax, rcx
jnz short loc_117C
loc_118C:
mov eax, edx
retn
loc_118F:
mov edx, 1
jmp short loc_118C | long long func0(unsigned __int8 *a1, int a2)
{
unsigned __int8 *v2; // rax
unsigned int v3; // edx
if ( a2 <= 0 )
{
return 1;
}
else
{
v2 = a1;
do
{
v3 = *v2;
if ( !(_BYTE)v3 )
break;
++v2;
}
while ( v2 != &a1[a2 - 1 + 1] );
}
return v3;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x0010118f
MOV RAX,RDI
LEA EDX,[RSI + -0x1]
LEA RCX,[RDI + RDX*0x1 + 0x1]
LAB_0010117c:
MOVZX EDX,byte ptr [RAX]
TEST DL,DL
JZ 0x0010118c
ADD RAX,0x1
CMP RAX,RCX
JNZ 0x0010117c
LAB_0010118c:
MOV EAX,EDX
RET
LAB_0010118f:
MOV EDX,0x1
JMP 0x0010118c | char func0(char *param_1,int param_2)
{
char *pcVar1;
char cVar2;
if (param_2 < 1) {
cVar2 = '\x01';
}
else {
pcVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
cVar2 = *param_1;
if (cVar2 == '\0') {
return '\0';
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
}
return cVar2;
} |
6,746 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(bool test_tup[], int size) {
for (int i = 0; i < size; i++) {
if (!test_tup[i]) return false;
}
return true;
}
| int main() {
bool arr1[] = {true, true, true, true};
bool arr2[] = {true, false, true, true};
bool arr3[] = {true, true, true, true};
assert(func0(arr1, 4) == true);
assert(func0(arr2, 4) == false);
assert(func0(arr3, 4) == true);
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 1171 <func0+0x31>
lea -0x1(%rsi),%eax
lea 0x1(%rdi,%rax,1),%rdx
jmp 1161 <func0+0x21>
nopw 0x0(%rax,%rax,1)
add $0x1,%rdi
cmp %rdx,%rdi
je 1170 <func0+0x30>
movzbl (%rdi),%eax
test %al,%al
jne 1158 <func0+0x18>
retq
nopl 0x0(%rax)
retq
mov $0x1,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short loc_1171
lea eax, [rsi-1]
lea rdx, [rdi+rax+1]
jmp short loc_1161
loc_1158:
add rdi, 1
cmp rdi, rdx
jz short locret_1170
loc_1161:
movzx eax, byte ptr [rdi]
test al, al
jnz short loc_1158
retn
locret_1170:
retn
loc_1171:
mov eax, 1
retn | long long func0(unsigned __int8 *a1, int a2)
{
long long v2; // rdx
long long result; // rax
if ( a2 <= 0 )
return 1LL;
v2 = (long long)&a1[a2 - 1 + 1];
do
{
result = *a1;
if ( !(_BYTE)result )
break;
++a1;
}
while ( a1 != (unsigned __int8 *)v2 );
return result;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x00101171
LEA EAX,[RSI + -0x1]
LEA RDX,[RDI + RAX*0x1 + 0x1]
JMP 0x00101161
LAB_00101158:
ADD RDI,0x1
CMP RDI,RDX
JZ 0x00101170
LAB_00101161:
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JNZ 0x00101158
RET
LAB_00101170:
RET
LAB_00101171:
MOV EAX,0x1
RET | char func0(char *param_1,int param_2)
{
char *pcVar1;
char cVar2;
if (param_2 < 1) {
return '\x01';
}
pcVar1 = param_1 + (ulong)(param_2 - 1) + 1;
do {
cVar2 = *param_1;
if (*param_1 == '\0') {
return cVar2;
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
return cVar2;
} |
6,747 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(bool test_tup[], int size) {
for (int i = 0; i < size; i++) {
if (!test_tup[i]) return false;
}
return true;
}
| int main() {
bool arr1[] = {true, true, true, true};
bool arr2[] = {true, false, true, true};
bool arr3[] = {true, true, true, true};
assert(func0(arr1, 4) == true);
assert(func0(arr2, 4) == false);
assert(func0(arr3, 4) == true);
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 1171 <func0+0x31>
lea -0x1(%rsi),%eax
lea 0x1(%rdi,%rax,1),%rdx
jmp 1161 <func0+0x21>
nopw 0x0(%rax,%rax,1)
add $0x1,%rdi
cmp %rdx,%rdi
je 1170 <func0+0x30>
movzbl (%rdi),%eax
test %al,%al
jne 1158 <func0+0x18>
retq
nopl 0x0(%rax)
retq
mov $0x1,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short loc_1171
movsxd rsi, esi
lea rdx, [rdi+rsi]
jmp short loc_1161
loc_1158:
add rdi, 1
cmp rdi, rdx
jz short locret_1170
loc_1161:
movzx eax, byte ptr [rdi]
test al, al
jnz short loc_1158
retn
locret_1170:
retn
loc_1171:
mov eax, 1
retn | long long func0(unsigned __int8 *a1, int a2)
{
unsigned __int8 *v2; // rdx
long long result; // rax
if ( a2 <= 0 )
return 1LL;
v2 = &a1[a2];
do
{
result = *a1;
if ( !(_BYTE)result )
break;
++a1;
}
while ( a1 != v2 );
return result;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x00101171
MOVSXD RSI,ESI
LEA RDX,[RDI + RSI*0x1]
JMP 0x00101161
LAB_00101158:
ADD RDI,0x1
CMP RDI,RDX
JZ 0x00101170
LAB_00101161:
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JNZ 0x00101158
RET
LAB_00101170:
RET
LAB_00101171:
MOV EAX,0x1
RET | char func0(char *param_1,int param_2)
{
char *pcVar1;
char cVar2;
if (param_2 < 1) {
return '\x01';
}
pcVar1 = param_1 + param_2;
do {
cVar2 = *param_1;
if (*param_1 == '\0') {
return cVar2;
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
return cVar2;
} |
6,748 | func0 |
#include <assert.h>
| int func0(int n) {
int m = n;
int count = 0;
int i = 2;
while((i * i) <= m) {
int total = 0;
while (n % i == 0) {
n /= i;
total += 1;
}
int temp = 0;
int j = 1;
while((temp + j) <= total) {
temp += j;
count += 1;
j += 1;
}
i += 1;
}
if (n != 1) {
count += 1;
}
return count;
}
| int main() {
assert(func0(24) == 3);
assert(func0(12) == 2);
assert(func0(4) == 1);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x24(%rbp)
mov -0x24(%rbp),%eax
mov %eax,-0x4(%rbp)
movl $0x0,-0x18(%rbp)
movl $0x2,-0x14(%rbp)
jmp 11bd <func0+0x74>
movl $0x0,-0x10(%rbp)
jmp 1181 <func0+0x38>
mov -0x24(%rbp),%eax
cltd
idivl -0x14(%rbp)
mov %eax,-0x24(%rbp)
addl $0x1,-0x10(%rbp)
mov -0x24(%rbp),%eax
cltd
idivl -0x14(%rbp)
mov %edx,%eax
test %eax,%eax
je 1173 <func0+0x2a>
movl $0x0,-0xc(%rbp)
movl $0x1,-0x8(%rbp)
jmp 11ac <func0+0x63>
mov -0x8(%rbp),%eax
add %eax,-0xc(%rbp)
addl $0x1,-0x18(%rbp)
addl $0x1,-0x8(%rbp)
mov -0xc(%rbp),%edx
mov -0x8(%rbp),%eax
add %edx,%eax
cmp %eax,-0x10(%rbp)
jge 119e <func0+0x55>
addl $0x1,-0x14(%rbp)
mov -0x14(%rbp),%eax
imul %eax,%eax
cmp %eax,-0x4(%rbp)
jge 116a <func0+0x21>
cmpl $0x1,-0x24(%rbp)
je 11d2 <func0+0x89>
addl $0x1,-0x18(%rbp)
mov -0x18(%rbp),%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_24], edi
mov eax, [rbp+var_24]
mov [rbp+var_4], eax
mov [rbp+var_18], 0
mov [rbp+var_14], 2
jmp short loc_11BD
loc_116A:
mov [rbp+var_10], 0
jmp short loc_1181
loc_1173:
mov eax, [rbp+var_24]
cdq
idiv [rbp+var_14]
mov [rbp+var_24], eax
add [rbp+var_10], 1
loc_1181:
mov eax, [rbp+var_24]
cdq
idiv [rbp+var_14]
mov eax, edx
test eax, eax
jz short loc_1173
mov [rbp+var_C], 0
mov [rbp+var_8], 1
jmp short loc_11AC
loc_119E:
mov eax, [rbp+var_8]
add [rbp+var_C], eax
add [rbp+var_18], 1
add [rbp+var_8], 1
loc_11AC:
mov edx, [rbp+var_C]
mov eax, [rbp+var_8]
add eax, edx
cmp [rbp+var_10], eax
jge short loc_119E
add [rbp+var_14], 1
loc_11BD:
mov eax, [rbp+var_14]
imul eax, eax
cmp [rbp+var_4], eax
jge short loc_116A
cmp [rbp+var_24], 1
jz short loc_11D2
add [rbp+var_18], 1
loc_11D2:
mov eax, [rbp+var_18]
pop rbp
retn | long long func0(int a1)
{
int v2; // [rsp+0h] [rbp-24h]
unsigned int v3; // [rsp+Ch] [rbp-18h]
int i; // [rsp+10h] [rbp-14h]
int v5; // [rsp+14h] [rbp-10h]
int v6; // [rsp+18h] [rbp-Ch]
int j; // [rsp+1Ch] [rbp-8h]
v2 = a1;
v3 = 0;
for ( i = 2; a1 >= i * i; ++i )
{
v5 = 0;
while ( !(v2 % i) )
{
v2 /= i;
++v5;
}
v6 = 0;
for ( j = 1; v5 >= v6 + j; ++j )
{
v6 += j;
++v3;
}
}
if ( v2 != 1 )
++v3;
return v3;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x24],EDI
MOV EAX,dword ptr [RBP + -0x24]
MOV dword ptr [RBP + -0x4],EAX
MOV dword ptr [RBP + -0x18],0x0
MOV dword ptr [RBP + -0x14],0x2
JMP 0x001011bd
LAB_0010116a:
MOV dword ptr [RBP + -0x10],0x0
JMP 0x00101181
LAB_00101173:
MOV EAX,dword ptr [RBP + -0x24]
CDQ
IDIV dword ptr [RBP + -0x14]
MOV dword ptr [RBP + -0x24],EAX
ADD dword ptr [RBP + -0x10],0x1
LAB_00101181:
MOV EAX,dword ptr [RBP + -0x24]
CDQ
IDIV dword ptr [RBP + -0x14]
MOV EAX,EDX
TEST EAX,EAX
JZ 0x00101173
MOV dword ptr [RBP + -0xc],0x0
MOV dword ptr [RBP + -0x8],0x1
JMP 0x001011ac
LAB_0010119e:
MOV EAX,dword ptr [RBP + -0x8]
ADD dword ptr [RBP + -0xc],EAX
ADD dword ptr [RBP + -0x18],0x1
ADD dword ptr [RBP + -0x8],0x1
LAB_001011ac:
MOV EDX,dword ptr [RBP + -0xc]
MOV EAX,dword ptr [RBP + -0x8]
ADD EAX,EDX
CMP dword ptr [RBP + -0x10],EAX
JGE 0x0010119e
ADD dword ptr [RBP + -0x14],0x1
LAB_001011bd:
MOV EAX,dword ptr [RBP + -0x14]
IMUL EAX,EAX
CMP dword ptr [RBP + -0x4],EAX
JGE 0x0010116a
CMP dword ptr [RBP + -0x24],0x1
JZ 0x001011d2
ADD dword ptr [RBP + -0x18],0x1
LAB_001011d2:
MOV EAX,dword ptr [RBP + -0x18]
POP RBP
RET | int func0(int param_1)
{
int4 local_2c;
int4 local_20;
int4 local_1c;
int4 local_18;
int4 local_14;
int4 local_10;
local_20 = 0;
local_2c = param_1;
for (local_1c = 2; local_1c * local_1c <= param_1; local_1c = local_1c + 1) {
local_18 = 0;
for (; local_2c % local_1c == 0; local_2c = local_2c / local_1c) {
local_18 = local_18 + 1;
}
local_14 = 0;
for (local_10 = 1; local_10 + local_14 <= local_18; local_10 = local_10 + 1) {
local_14 = local_14 + local_10;
local_20 = local_20 + 1;
}
}
if (local_2c != 1) {
local_20 = local_20 + 1;
}
return local_20;
} |
6,749 | func0 |
#include <assert.h>
| int func0(int n) {
int m = n;
int count = 0;
int i = 2;
while((i * i) <= m) {
int total = 0;
while (n % i == 0) {
n /= i;
total += 1;
}
int temp = 0;
int j = 1;
while((temp + j) <= total) {
temp += j;
count += 1;
j += 1;
}
i += 1;
}
if (n != 1) {
count += 1;
}
return count;
}
| int main() {
assert(func0(24) == 3);
assert(func0(12) == 2);
assert(func0(4) == 1);
return 0;
}
| O1 | c | func0:
endbr64
mov %edi,%ecx
mov $0x2,%esi
mov $0x0,%r10d
cmp $0x3,%edi
jg 11b1 <func0+0x68>
cmp $0x1,%ecx
setne %al
movzbl %al,%eax
add %eax,%r10d
mov %r10d,%eax
retq
mov %ecx,%eax
cltd
idiv %esi
mov %eax,%ecx
add $0x1,%r8d
cltd
idiv %esi
test %edx,%edx
je 116f <func0+0x26>
test %r8d,%r8d
jle 11a5 <func0+0x5c>
mov %r10d,%edx
mov $0x1,%r9d
mov %edx,%eax
add $0x1,%edx
add $0x2,%eax
sub %r10d,%eax
add %eax,%r9d
cmp %r8d,%r9d
jle 118f <func0+0x46>
mov %edx,%r10d
add $0x1,%esi
mov %esi,%eax
imul %esi,%eax
cmp %edi,%eax
jg 115f <func0+0x16>
mov %ecx,%eax
cltd
idiv %esi
mov %edx,%r8d
test %edx,%edx
je 116f <func0+0x26>
jmp 11a5 <func0+0x5c>
| func0:
endbr64
mov r10d, edi
mov ecx, edi
mov esi, 2
mov r9d, 0
cmp edi, 3
jg short loc_11B3
loc_1162:
cmp ecx, 1
setnz al
movzx eax, al
add r9d, eax
mov eax, r9d
retn
loc_1172:
mov eax, ecx
cdq
idiv esi
mov ecx, eax
add edi, 1
cdq
idiv esi
test edx, edx
jz short loc_1172
test edi, edi
jle short loc_11A6
mov edx, r9d
mov r8d, 1
loc_1190:
mov eax, edx
add edx, 1
add eax, 2
sub eax, r9d
add r8d, eax
cmp r8d, edi
jle short loc_1190
mov r9d, edx
loc_11A6:
add esi, 1
mov eax, esi
imul eax, esi
cmp eax, r10d
jg short loc_1162
loc_11B3:
mov eax, ecx
cdq
idiv esi
mov edi, edx
test edx, edx
jz short loc_1172
jmp short loc_11A6 | long long func0(int a1)
{
int v2; // ecx
int v3; // esi
int v4; // r9d
int v6; // edi
int v7; // edx
int i; // r8d
int v9; // eax
v2 = a1;
v3 = 2;
v4 = 0;
if ( a1 > 3 )
{
do
{
v6 = v2 % v3;
if ( !(v2 % v3) )
{
do
{
v2 /= v3;
++v6;
}
while ( !(v2 % v3) );
if ( v6 > 0 )
{
v7 = v4;
for ( i = 1; i <= v6; i += v9 + 2 - v4 )
v9 = v7++;
v4 = v7;
}
}
++v3;
}
while ( v3 * v3 <= a1 );
}
return (unsigned int)(v2 != 1) + v4;
} | func0:
ENDBR64
MOV R10D,EDI
MOV ECX,EDI
MOV ESI,0x2
MOV R9D,0x0
CMP EDI,0x3
JG 0x001011b3
LAB_00101162:
CMP ECX,0x1
SETNZ AL
MOVZX EAX,AL
ADD R9D,EAX
MOV EAX,R9D
RET
LAB_00101172:
MOV EAX,ECX
CDQ
IDIV ESI
MOV ECX,EAX
ADD EDI,0x1
CDQ
IDIV ESI
TEST EDX,EDX
JZ 0x00101172
TEST EDI,EDI
JLE 0x001011a6
MOV EDX,R9D
MOV R8D,0x1
LAB_00101190:
MOV EAX,EDX
ADD EDX,0x1
ADD EAX,0x2
SUB EAX,R9D
ADD R8D,EAX
CMP R8D,EDI
JLE 0x00101190
MOV R9D,EDX
LAB_001011a6:
ADD ESI,0x1
MOV EAX,ESI
IMUL EAX,ESI
CMP EAX,R10D
JG 0x00101162
LAB_001011b3:
MOV EAX,ECX
CDQ
IDIV ESI
MOV EDI,EDX
TEST EDX,EDX
JZ 0x00101172
JMP 0x001011a6 | int func0(uint param_1)
{
ulong uVar1;
uint uVar2;
ulong uVar3;
int iVar4;
int iVar5;
int iVar6;
int iVar7;
int iVar8;
int iVar9;
uVar3 = (ulong)param_1;
iVar7 = 2;
iVar5 = 0;
uVar2 = param_1;
iVar9 = 0;
if (3 < (int)param_1) {
do {
iVar6 = (int)uVar3 % iVar7;
iVar5 = iVar9;
if (iVar6 == 0) {
do {
uVar1 = (long)(int)uVar3 / (long)iVar7;
uVar3 = uVar1 & 0xffffffff;
iVar6 = iVar6 + 1;
} while ((int)((long)((ulong)(uint)((int)uVar1 >> 0x1f) << 0x20 | uVar1 & 0xffffffff) %
(long)iVar7) == 0);
if (0 < iVar6) {
iVar8 = 1;
iVar4 = iVar9;
do {
iVar5 = iVar4 + 1;
iVar8 = iVar8 + ((iVar4 + 2) - iVar9);
iVar4 = iVar5;
} while (iVar8 <= iVar6);
}
}
uVar2 = (uint)uVar3;
iVar7 = iVar7 + 1;
iVar9 = iVar5;
} while (iVar7 * iVar7 <= (int)param_1);
}
return iVar5 + (uint)(uVar2 != 1);
} |
6,750 | func0 |
#include <assert.h>
| int func0(int n) {
int m = n;
int count = 0;
int i = 2;
while((i * i) <= m) {
int total = 0;
while (n % i == 0) {
n /= i;
total += 1;
}
int temp = 0;
int j = 1;
while((temp + j) <= total) {
temp += j;
count += 1;
j += 1;
}
i += 1;
}
if (n != 1) {
count += 1;
}
return count;
}
| int main() {
assert(func0(24) == 3);
assert(func0(12) == 2);
assert(func0(4) == 1);
return 0;
}
| O2 | c | func0:
endbr64
mov %edi,%r10d
mov $0x2,%ecx
xor %r9d,%r9d
cmp $0x3,%edi
jle 12fb <func0+0x6b>
nopl 0x0(%rax)
mov %edi,%eax
cltd
idiv %ecx
mov %edx,%esi
test %edx,%edx
jne 12ee <func0+0x5e>
nopl 0x0(%rax,%rax,1)
mov %edi,%eax
add $0x1,%esi
cltd
idiv %ecx
cltd
mov %eax,%edi
idiv %ecx
test %edx,%edx
je 12b8 <func0+0x28>
mov %r9d,%edx
mov $0x1,%r8d
nopw 0x0(%rax,%rax,1)
mov %edx,%eax
add $0x1,%edx
add $0x2,%eax
sub %r9d,%eax
add %eax,%r8d
cmp %esi,%r8d
jle 12d8 <func0+0x48>
mov %edx,%r9d
add $0x1,%ecx
mov %ecx,%eax
imul %ecx,%eax
cmp %r10d,%eax
jle 12a8 <func0+0x18>
xor %eax,%eax
cmp $0x1,%edi
setne %al
add %eax,%r9d
mov %r9d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov ecx, edi
mov r10d, edi
mov esi, 2
xor r9d, r9d
cmp edi, 3
jle short loc_1263
nop word ptr [rax+rax+00000000h]
loc_1210:
mov eax, ecx
cdq
idiv esi
mov edi, edx
test edx, edx
jnz short loc_1256
nop dword ptr [rax+rax+00h]
loc_1220:
mov eax, ecx
add edi, 1
cdq
idiv esi
cdq
mov ecx, eax
idiv esi
test edx, edx
jz short loc_1220
mov eax, r9d
mov r8d, 1
nop word ptr [rax+rax+00h]
loc_1240:
mov edx, eax
add eax, 1
add edx, 2
sub edx, r9d
add r8d, edx
cmp r8d, edi
jle short loc_1240
mov r9d, eax
loc_1256:
add esi, 1
mov eax, esi
imul eax, esi
cmp eax, r10d
jle short loc_1210
loc_1263:
xor eax, eax
cmp ecx, 1
setnz al
add r9d, eax
mov eax, r9d
retn | long long func0(int a1)
{
int v1; // ecx
int v3; // esi
int v4; // r9d
int v5; // edi
int v6; // edx
int v7; // eax
int v8; // r8d
int v9; // edx
v1 = a1;
v3 = 2;
v4 = 0;
if ( a1 > 3 )
{
do
{
v5 = v1 % v3;
if ( !(v1 % v3) )
{
do
{
++v5;
v6 = (v1 / v3) >> 31;
v1 /= v3;
}
while ( !(unsigned int)(__SPAIR64__(v6, v1) % v3) );
v7 = v4;
v8 = 1;
do
{
v9 = v7++;
v8 += v9 + 2 - v4;
}
while ( v8 <= v5 );
v4 = v7;
}
++v3;
}
while ( v3 * v3 <= a1 );
}
return (unsigned int)(v1 != 1) + v4;
} | func0:
ENDBR64
MOV ECX,EDI
MOV R10D,EDI
MOV ESI,0x2
XOR R9D,R9D
CMP EDI,0x3
JLE 0x00101263
NOP word ptr CS:[RAX + RAX*0x1]
LAB_00101210:
MOV EAX,ECX
CDQ
IDIV ESI
MOV EDI,EDX
TEST EDX,EDX
JNZ 0x00101256
NOP dword ptr [RAX + RAX*0x1]
LAB_00101220:
MOV EAX,ECX
ADD EDI,0x1
CDQ
IDIV ESI
CDQ
MOV ECX,EAX
IDIV ESI
TEST EDX,EDX
JZ 0x00101220
MOV EAX,R9D
MOV R8D,0x1
NOP word ptr [RAX + RAX*0x1]
LAB_00101240:
MOV EDX,EAX
ADD EAX,0x1
ADD EDX,0x2
SUB EDX,R9D
ADD R8D,EDX
CMP R8D,EDI
JLE 0x00101240
MOV R9D,EAX
LAB_00101256:
ADD ESI,0x1
MOV EAX,ESI
IMUL EAX,ESI
CMP EAX,R10D
JLE 0x00101210
LAB_00101263:
XOR EAX,EAX
CMP ECX,0x1
SETNZ AL
ADD R9D,EAX
MOV EAX,R9D
RET | int func0(int param_1)
{
long lVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
uint uVar6;
ulong uVar7;
int iVar8;
int iVar9;
iVar5 = 2;
iVar9 = 0;
iVar2 = param_1;
if (3 < param_1) {
do {
uVar7 = (long)iVar2 % (long)iVar5 & 0xffffffff;
iVar4 = iVar9;
if ((int)((long)iVar2 % (long)iVar5) == 0) {
do {
uVar6 = (int)uVar7 + 1;
uVar7 = (ulong)uVar6;
lVar1 = (long)iVar2;
iVar2 = (int)(lVar1 / (long)iVar5);
} while ((int)((long)((ulong)(uint)(iVar2 >> 0x1f) << 0x20 |
lVar1 / (long)iVar5 & 0xffffffffU) % (long)iVar5) == 0);
iVar8 = 1;
iVar3 = iVar9;
do {
iVar4 = iVar3 + 1;
iVar8 = iVar8 + ((iVar3 + 2) - iVar9);
iVar3 = iVar4;
} while (iVar8 <= (int)uVar6);
}
iVar9 = iVar4;
iVar5 = iVar5 + 1;
} while (iVar5 * iVar5 <= param_1);
}
return iVar9 + (uint)(iVar2 != 1);
} |
6,751 | func0 |
#include <assert.h>
| int func0(int n) {
int m = n;
int count = 0;
int i = 2;
while((i * i) <= m) {
int total = 0;
while (n % i == 0) {
n /= i;
total += 1;
}
int temp = 0;
int j = 1;
while((temp + j) <= total) {
temp += j;
count += 1;
j += 1;
}
i += 1;
}
if (n != 1) {
count += 1;
}
return count;
}
| int main() {
assert(func0(24) == 3);
assert(func0(12) == 2);
assert(func0(4) == 1);
return 0;
}
| O3 | c | func0:
endbr64
mov %edi,%r10d
mov $0x2,%ecx
xor %r9d,%r9d
cmp $0x3,%edi
jle 12fb <func0+0x6b>
nopl 0x0(%rax)
mov %edi,%eax
cltd
idiv %ecx
mov %edx,%esi
test %edx,%edx
jne 12ee <func0+0x5e>
nopl 0x0(%rax,%rax,1)
mov %edi,%eax
add $0x1,%esi
cltd
idiv %ecx
cltd
mov %eax,%edi
idiv %ecx
test %edx,%edx
je 12b8 <func0+0x28>
mov %r9d,%edx
mov $0x1,%r8d
nopw 0x0(%rax,%rax,1)
mov %edx,%eax
add $0x1,%edx
add $0x2,%eax
sub %r9d,%eax
add %eax,%r8d
cmp %esi,%r8d
jle 12d8 <func0+0x48>
mov %edx,%r9d
add $0x1,%ecx
mov %ecx,%eax
imul %ecx,%eax
cmp %r10d,%eax
jle 12a8 <func0+0x18>
xor %eax,%eax
cmp $0x1,%edi
setne %al
add %eax,%r9d
mov %r9d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov ecx, edi
mov r10d, edi
mov esi, 2
xor edi, edi
mov r11d, 1
cmp ecx, 3
jle short loc_12FD
nop dword ptr [rax+rax+00h]
loc_12B0:
mov eax, ecx
cdq
idiv esi
mov r8d, edx
test edx, edx
jnz short loc_12F0
nop dword ptr [rax+00h]
loc_12C0:
mov eax, ecx
add r8d, 1
cdq
idiv esi
cdq
mov ecx, eax
idiv esi
test edx, edx
jz short loc_12C0
mov r9d, r11d
mov eax, edi
mov edx, 1
sub r9d, edi
nop
loc_12E0:
add eax, 1
lea edi, [r9+rax]
add edx, edi
cmp edx, r8d
jle short loc_12E0
mov edi, eax
loc_12F0:
add esi, 1
mov eax, esi
imul eax, esi
cmp eax, r10d
jle short loc_12B0
loc_12FD:
xor eax, eax
cmp ecx, 1
setnz al
add edi, eax
mov eax, edi
retn | long long func0(int a1)
{
int v1; // ecx
int v3; // esi
int v4; // edi
int v5; // r8d
int v6; // edx
int v7; // eax
int v8; // edx
v1 = a1;
v3 = 2;
v4 = 0;
if ( v1 > 3 )
{
do
{
v5 = v1 % v3;
if ( !(v1 % v3) )
{
do
{
++v5;
v6 = (v1 / v3) >> 31;
v1 /= v3;
}
while ( !(unsigned int)(__SPAIR64__(v6, v1) % v3) );
v7 = v4;
v8 = 1;
do
{
++v7;
v8 += 1 - v4 + v7;
}
while ( v8 <= v5 );
v4 = v7;
}
++v3;
}
while ( v3 * v3 <= a1 );
}
return (unsigned int)(v1 != 1) + v4;
} | func0:
ENDBR64
MOV ECX,EDI
MOV R10D,EDI
MOV ESI,0x2
XOR EDI,EDI
MOV R11D,0x1
CMP ECX,0x3
JLE 0x001012fd
NOP dword ptr [RAX + RAX*0x1]
LAB_001012b0:
MOV EAX,ECX
CDQ
IDIV ESI
MOV R8D,EDX
TEST EDX,EDX
JNZ 0x001012f0
NOP dword ptr [RAX]
LAB_001012c0:
MOV EAX,ECX
ADD R8D,0x1
CDQ
IDIV ESI
CDQ
MOV ECX,EAX
IDIV ESI
TEST EDX,EDX
JZ 0x001012c0
MOV R9D,R11D
MOV EAX,EDI
MOV EDX,0x1
SUB R9D,EDI
NOP
LAB_001012e0:
ADD EAX,0x1
LEA EDI,[R9 + RAX*0x1]
ADD EDX,EDI
CMP EDX,R8D
JLE 0x001012e0
MOV EDI,EAX
LAB_001012f0:
ADD ESI,0x1
MOV EAX,ESI
IMUL EAX,ESI
CMP EAX,R10D
JLE 0x001012b0
LAB_001012fd:
XOR EAX,EAX
CMP ECX,0x1
SETNZ AL
ADD EDI,EAX
MOV EAX,EDI
RET | int func0(int param_1)
{
long lVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
uint uVar6;
ulong uVar7;
int iVar8;
iVar4 = 2;
iVar5 = 0;
iVar2 = param_1;
if (3 < param_1) {
do {
uVar7 = (long)iVar2 % (long)iVar4 & 0xffffffff;
if ((int)((long)iVar2 % (long)iVar4) == 0) {
do {
uVar6 = (int)uVar7 + 1;
uVar7 = (ulong)uVar6;
lVar1 = (long)iVar2;
iVar2 = (int)(lVar1 / (long)iVar4);
} while ((int)((long)((ulong)(uint)(iVar2 >> 0x1f) << 0x20 |
lVar1 / (long)iVar4 & 0xffffffffU) % (long)iVar4) == 0);
iVar3 = 1;
iVar8 = 1 - iVar5;
do {
iVar5 = iVar5 + 1;
iVar3 = iVar3 + iVar8 + iVar5;
} while (iVar3 <= (int)uVar6);
}
iVar4 = iVar4 + 1;
} while (iVar4 * iVar4 <= param_1);
}
return iVar5 + (uint)(iVar2 != 1);
} |
6,752 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *data;
int size;
} str_to_tuple_result;
| str_to_tuple_result func0(const char *test_str) {
str_to_tuple_result result;
// Count the number of integers
int count = 1;
for (const char *p = test_str; *p; p++) {
if (*p == ',') count++;
}
result.size = count;
result.data = malloc(count * sizeof(int));
if (!result.data) {
perror("malloc failed");
exit(1);
}
// Split the string by ", "
char *copy = strdup(test_str);
char *token = strtok(copy, ", ");
int idx = 0;
while (token != NULL && idx < count) {
result.data[idx++] = atoi(token);
token = strtok(NULL, ", ");
}
free(copy);
return result;
}
| int main() {
// Test case 1
str_to_tuple_result t1 = func0("1, -5, 4, 6, 7");
int expected1[] = {1, -5, 4, 6, 7};
assert(t1.size == 5);
for(int i = 0; i < 5; i++) {
assert(t1.data[i] == expected1[i]);
}
free(t1.data);
// Test case 2
str_to_tuple_result t2 = func0("1, 2, 3, 4, 5");
int expected2[] = {1, 2, 3, 4, 5};
assert(t2.size == 5);
for(int i = 0; i < 5; i++) {
assert(t2.data[i] == expected2[i]);
}
free(t2.data);
// Test case 3
str_to_tuple_result t3 = func0("4, 6, 9, 11, 13, 14");
int expected3[] = {4, 6, 9, 11, 13, 14};
assert(t3.size == 6);
for(int i = 0; i < 6; i++) {
assert(t3.data[i] == expected3[i]);
}
free(t3.data);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
push %rbx
sub $0x48,%rsp
mov %rdi,-0x48(%rbp)
movl $0x1,-0x40(%rbp)
mov -0x48(%rbp),%rax
mov %rax,-0x38(%rbp)
jmp 127f <func0+0x36>
mov -0x38(%rbp),%rax
movzbl (%rax),%eax
cmp $0x2c,%al
jne 127a <func0+0x31>
addl $0x1,-0x40(%rbp)
addq $0x1,-0x38(%rbp)
mov -0x38(%rbp),%rax
movzbl (%rax),%eax
test %al,%al
jne 126b <func0+0x22>
mov -0x40(%rbp),%eax
mov %eax,-0x18(%rbp)
mov -0x40(%rbp),%eax
cltq
shl $0x2,%rax
mov %rax,%rdi
callq 1100 <malloc@plt>
mov %rax,-0x20(%rbp)
mov -0x20(%rbp),%rax
test %rax,%rax
jne 12c4 <func0+0x7b>
lea 0xd53(%rip),%rdi
callq 1110 <perror@plt>
mov $0x1,%edi
callq 1140 <exit@plt>
mov -0x48(%rbp),%rax
mov %rax,%rdi
callq 1150 <strdup@plt>
mov %rax,-0x28(%rbp)
mov -0x28(%rbp),%rax
lea 0xd37(%rip),%rsi
mov %rax,%rdi
callq 1120 <strtok@plt>
mov %rax,-0x30(%rbp)
movl $0x0,-0x3c(%rbp)
jmp 132e <func0+0xe5>
mov -0x20(%rbp),%rcx
mov -0x3c(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x3c(%rbp)
cltq
shl $0x2,%rax
lea (%rcx,%rax,1),%rbx
mov -0x30(%rbp),%rax
mov %rax,%rdi
callq 1130 <atoi@plt>
mov %eax,(%rbx)
lea 0xcf6(%rip),%rsi
mov $0x0,%edi
callq 1120 <strtok@plt>
mov %rax,-0x30(%rbp)
cmpq $0x0,-0x30(%rbp)
je 133d <func0+0xf4>
mov -0x3c(%rbp),%eax
cmp -0x40(%rbp),%eax
jl 12f4 <func0+0xab>
mov -0x28(%rbp),%rax
mov %rax,%rdi
callq 10d0 <free@plt>
mov -0x20(%rbp),%rax
mov -0x18(%rbp),%rdx
add $0x48,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
push rbx
sub rsp, 48h
mov [rbp+s], rdi
mov [rbp+var_40], 1
mov rax, [rbp+s]
mov [rbp+var_38], rax
jmp short loc_127F
loc_126B:
mov rax, [rbp+var_38]
movzx eax, byte ptr [rax]
cmp al, 2Ch ; ','
jnz short loc_127A
add [rbp+var_40], 1
loc_127A:
add [rbp+var_38], 1
loc_127F:
mov rax, [rbp+var_38]
movzx eax, byte ptr [rax]
test al, al
jnz short loc_126B
mov eax, [rbp+var_40]
mov dword ptr [rbp+var_18], eax
mov eax, [rbp+var_40]
cdqe
shl rax, 2
mov rdi, rax; size
call _malloc
mov [rbp+var_20], rax
mov rax, [rbp+var_20]
test rax, rax
jnz short loc_12C7
lea rax, s; "malloc failed"
mov rdi, rax; s
call _perror
mov edi, 1; status
call _exit
loc_12C7:
mov rax, [rbp+s]
mov rdi, rax; s
call _strdup
mov [rbp+var_28], rax
mov rax, [rbp+var_28]
lea rdx, delim; ", "
mov rsi, rdx; delim
mov rdi, rax; s
call _strtok
mov [rbp+nptr], rax
mov [rbp+var_3C], 0
jmp short loc_1337
loc_12FA:
mov rcx, [rbp+var_20]
mov eax, [rbp+var_3C]
lea edx, [rax+1]
mov [rbp+var_3C], edx
cdqe
shl rax, 2
lea rbx, [rcx+rax]
mov rax, [rbp+nptr]
mov rdi, rax; nptr
call _atoi
mov [rbx], eax
lea rax, delim; ", "
mov rsi, rax; delim
mov edi, 0; s
call _strtok
mov [rbp+nptr], rax
loc_1337:
cmp [rbp+nptr], 0
jz short loc_1346
mov eax, [rbp+var_3C]
cmp eax, [rbp+var_40]
jl short loc_12FA
loc_1346:
mov rax, [rbp+var_28]
mov rdi, rax; ptr
call _free
mov rax, [rbp+var_20]
mov rdx, [rbp+var_18]
mov rbx, [rbp+var_8]
leave
retn | _DWORD * func0(const char *a1)
{
int v1; // eax
int v3; // [rsp+10h] [rbp-40h]
int j; // [rsp+14h] [rbp-3Ch]
const char *i; // [rsp+18h] [rbp-38h]
const char *nptr; // [rsp+20h] [rbp-30h]
char *v7; // [rsp+28h] [rbp-28h]
_DWORD *v8; // [rsp+30h] [rbp-20h]
v3 = 1;
for ( i = a1; *i; ++i )
{
if ( *i == 44 )
++v3;
}
v8 = malloc(4LL * v3);
if ( !v8 )
{
perror("malloc failed");
exit(1);
}
v7 = strdup(a1);
nptr = strtok(v7, ", ");
for ( j = 0; nptr && j < v3; ++j )
{
v1 = j;
v8[v1] = atoi(nptr);
nptr = strtok(0LL, ", ");
}
free(v7);
return v8;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
PUSH RBX
SUB RSP,0x48
MOV qword ptr [RBP + -0x48],RDI
MOV dword ptr [RBP + -0x40],0x1
MOV RAX,qword ptr [RBP + -0x48]
MOV qword ptr [RBP + -0x38],RAX
JMP 0x0010127f
LAB_0010126b:
MOV RAX,qword ptr [RBP + -0x38]
MOVZX EAX,byte ptr [RAX]
CMP AL,0x2c
JNZ 0x0010127a
ADD dword ptr [RBP + -0x40],0x1
LAB_0010127a:
ADD qword ptr [RBP + -0x38],0x1
LAB_0010127f:
MOV RAX,qword ptr [RBP + -0x38]
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x0010126b
MOV EAX,dword ptr [RBP + -0x40]
MOV dword ptr [RBP + -0x18],EAX
MOV EAX,dword ptr [RBP + -0x40]
CDQE
SHL RAX,0x2
MOV RDI,RAX
CALL 0x00101100
MOV qword ptr [RBP + -0x20],RAX
MOV RAX,qword ptr [RBP + -0x20]
TEST RAX,RAX
JNZ 0x001012c7
LEA RAX,[0x102004]
MOV RDI,RAX
CALL 0x00101110
MOV EDI,0x1
CALL 0x00101140
LAB_001012c7:
MOV RAX,qword ptr [RBP + -0x48]
MOV RDI,RAX
CALL 0x00101150
MOV qword ptr [RBP + -0x28],RAX
MOV RAX,qword ptr [RBP + -0x28]
LEA RDX,[0x102012]
MOV RSI,RDX
MOV RDI,RAX
CALL 0x00101120
MOV qword ptr [RBP + -0x30],RAX
MOV dword ptr [RBP + -0x3c],0x0
JMP 0x00101337
LAB_001012fa:
MOV RCX,qword ptr [RBP + -0x20]
MOV EAX,dword ptr [RBP + -0x3c]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x3c],EDX
CDQE
SHL RAX,0x2
LEA RBX,[RCX + RAX*0x1]
MOV RAX,qword ptr [RBP + -0x30]
MOV RDI,RAX
CALL 0x00101130
MOV dword ptr [RBX],EAX
LEA RAX,[0x102012]
MOV RSI,RAX
MOV EDI,0x0
CALL 0x00101120
MOV qword ptr [RBP + -0x30],RAX
LAB_00101337:
CMP qword ptr [RBP + -0x30],0x0
JZ 0x00101346
MOV EAX,dword ptr [RBP + -0x3c]
CMP EAX,dword ptr [RBP + -0x40]
JL 0x001012fa
LAB_00101346:
MOV RAX,qword ptr [RBP + -0x28]
MOV RDI,RAX
CALL 0x001010d0
MOV RAX,qword ptr [RBP + -0x20]
MOV RDX,qword ptr [RBP + -0x18]
MOV RBX,qword ptr [RBP + -0x8]
LEAVE
RET | int [16] func0(char *param_1)
{
int auVar1 [16];
int iVar2;
void *pvVar3;
char *__s;
int local_48;
int local_44;
char *local_40;
char *local_38;
int4 uStack_1c;
local_48 = 1;
for (local_40 = param_1; *local_40 != '\0'; local_40 = local_40 + 1) {
if (*local_40 == ',') {
local_48 = local_48 + 1;
}
}
pvVar3 = malloc((long)local_48 << 2);
if (pvVar3 == (void *)0x0) {
perror("malloc failed");
/* WARNING: Subroutine does not return */
exit(1);
}
__s = strdup(param_1);
local_38 = strtok(__s,", ");
local_44 = 0;
while ((local_38 != (char *)0x0 && (local_44 < local_48))) {
iVar2 = atoi(local_38);
*(int *)((long)pvVar3 + (long)local_44 * 4) = iVar2;
local_38 = strtok((char *)0x0,", ");
local_44 = local_44 + 1;
}
free(__s);
auVar1._8_4_ = local_48;
auVar1._0_8_ = pvVar3;
auVar1._12_4_ = uStack_1c;
return auVar1;
} |
6,753 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *data;
int size;
} str_to_tuple_result;
| str_to_tuple_result func0(const char *test_str) {
str_to_tuple_result result;
// Count the number of integers
int count = 1;
for (const char *p = test_str; *p; p++) {
if (*p == ',') count++;
}
result.size = count;
result.data = malloc(count * sizeof(int));
if (!result.data) {
perror("malloc failed");
exit(1);
}
// Split the string by ", "
char *copy = strdup(test_str);
char *token = strtok(copy, ", ");
int idx = 0;
while (token != NULL && idx < count) {
result.data[idx++] = atoi(token);
token = strtok(NULL, ", ");
}
free(copy);
return result;
}
| int main() {
// Test case 1
str_to_tuple_result t1 = func0("1, -5, 4, 6, 7");
int expected1[] = {1, -5, 4, 6, 7};
assert(t1.size == 5);
for(int i = 0; i < 5; i++) {
assert(t1.data[i] == expected1[i]);
}
free(t1.data);
// Test case 2
str_to_tuple_result t2 = func0("1, 2, 3, 4, 5");
int expected2[] = {1, 2, 3, 4, 5};
assert(t2.size == 5);
for(int i = 0; i < 5; i++) {
assert(t2.data[i] == expected2[i]);
}
free(t2.data);
// Test case 3
str_to_tuple_result t3 = func0("4, 6, 9, 11, 13, 14");
int expected3[] = {4, 6, 9, 11, 13, 14};
assert(t3.size == 6);
for(int i = 0; i < 6; i++) {
assert(t3.data[i] == expected3[i]);
}
free(t3.data);
return 0;
}
| O1 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
push %rbx
mov %rdi,%rbx
movzbl (%rdi),%eax
test %al,%al
je 1317 <func0+0xce>
mov %rdi,%rdx
mov $0x1,%ebp
cmp $0x2c,%al
sete %al
movzbl %al,%eax
add %eax,%ebp
add $0x1,%rdx
movzbl (%rdx),%eax
test %al,%al
jne 126b <func0+0x22>
movslq %ebp,%rdi
shl $0x2,%rdi
callq 1110 <malloc@plt>
mov %rax,%r12
test %rax,%rax
je 1321 <func0+0xd8>
mov %rbx,%rdi
callq 1150 <strdup@plt>
mov %rax,%r14
lea 0xd68(%rip),%rsi
mov %rax,%rdi
callq 1130 <strtok@plt>
mov %rax,%rdi
test %rax,%rax
je 1301 <func0+0xb8>
test %ebp,%ebp
jle 1301 <func0+0xb8>
mov $0x1,%ebx
lea 0xd48(%rip),%r13
mov $0xa,%edx
mov $0x0,%esi
callq 1100 <strtol@plt>
mov %eax,-0x4(%r12,%rbx,4)
mov %r13,%rsi
mov $0x0,%edi
callq 1130 <strtok@plt>
mov %rax,%rdi
test %rax,%rax
setne %dl
cmp %ebx,%ebp
setg %al
add $0x1,%rbx
test %al,%dl
jne 12ca <func0+0x81>
mov %r14,%rdi
callq 10d0 <free@plt>
mov %ebp,%edx
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
retq
mov $0x1,%ebp
jmpq 1280 <func0+0x37>
lea 0xcdc(%rip),%rdi
callq 1120 <perror@plt>
mov $0x1,%edi
callq 1140 <exit@plt>
| func0:
endbr64
push r14
push r13
push r12
push rbp
push rbx
mov rbx, rdi
movzx eax, byte ptr [rdi]
test al, al
jz loc_1317
mov rdx, rdi
mov ebp, 1
loc_126B:
cmp al, 2Ch ; ','
setz al
movzx eax, al
add ebp, eax
add rdx, 1
movzx eax, byte ptr [rdx]
test al, al
jnz short loc_126B
loc_1280:
movsxd rdi, ebp
shl rdi, 2
call _malloc
mov r12, rax
test rax, rax
jz loc_1321
mov rdi, rbx
call _strdup
mov r14, rax
lea rsi, asc_2012; ", "
mov rdi, rax
call _strtok
mov rdi, rax
test rax, rax
jz short loc_1301
test ebp, ebp
jle short loc_1301
mov ebx, 1
lea r13, asc_2012; ", "
loc_12CA:
mov edx, 0Ah
mov esi, 0
call _strtol
mov [r12+rbx*4-4], eax
mov rsi, r13
mov edi, 0
call _strtok
mov rdi, rax
test rax, rax
setnz dl
cmp ebp, ebx
setnle al
add rbx, 1
test dl, al
jnz short loc_12CA
loc_1301:
mov rdi, r14
call _free
mov edx, ebp
mov rax, r12
pop rbx
pop rbp
pop r12
pop r13
pop r14
retn
loc_1317:
mov ebp, 1
jmp loc_1280
loc_1321:
lea rdi, aMallocFailed; "malloc failed"
call _perror
mov edi, 1
call _exit | long long func0(_BYTE *a1)
{
char v1; // al
_BYTE *v2; // rdx
int v3; // ebp
long long v4; // r12
long long v5; // r14
long long v6; // rdi
long long v7; // rbx
bool v8; // al
v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = 1;
do
{
v3 += v1 == 44;
v1 = *++v2;
}
while ( *v2 );
}
else
{
v3 = 1;
}
v4 = malloc(4LL * v3);
if ( !v4 )
{
perror("malloc failed");
exit(1LL);
}
v5 = strdup(a1);
v6 = strtok(v5, ", ");
if ( v6 && v3 > 0 )
{
v7 = 1LL;
do
{
*(_DWORD *)(v4 + 4 * v7 - 4) = strtol(v6, 0LL, 10LL);
v6 = strtok(0LL, ", ");
v8 = v3 > (int)v7++;
}
while ( v8 && v6 != 0 );
}
free(v5);
return v4;
} | func0:
ENDBR64
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
MOV RBX,RDI
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x00101317
MOV RDX,RDI
MOV EBP,0x1
LAB_0010126b:
CMP AL,0x2c
SETZ AL
MOVZX EAX,AL
ADD EBP,EAX
ADD RDX,0x1
MOVZX EAX,byte ptr [RDX]
TEST AL,AL
JNZ 0x0010126b
LAB_00101280:
MOVSXD RDI,EBP
SHL RDI,0x2
CALL 0x00101110
MOV R12,RAX
TEST RAX,RAX
JZ 0x00101321
MOV RDI,RBX
CALL 0x00101150
MOV R14,RAX
LEA RSI,[0x102012]
MOV RDI,RAX
CALL 0x00101130
MOV RDI,RAX
TEST RAX,RAX
JZ 0x00101301
TEST EBP,EBP
JLE 0x00101301
MOV EBX,0x1
LEA R13,[0x102012]
LAB_001012ca:
MOV EDX,0xa
MOV ESI,0x0
CALL 0x00101100
MOV dword ptr [R12 + RBX*0x4 + -0x4],EAX
MOV RSI,R13
MOV EDI,0x0
CALL 0x00101130
MOV RDI,RAX
TEST RAX,RAX
SETNZ DL
CMP EBP,EBX
SETG AL
ADD RBX,0x1
TEST DL,AL
JNZ 0x001012ca
LAB_00101301:
MOV RDI,R14
CALL 0x001010d0
MOV EDX,EBP
MOV RAX,R12
POP RBX
POP RBP
POP R12
POP R13
POP R14
RET
LAB_00101317:
MOV EBP,0x1
JMP 0x00101280
LAB_00101321:
LEA RDI,[0x102004]
CALL 0x00101120
MOV EDI,0x1
CALL 0x00101140 | int1 [16] func0(char *param_1)
{
char cVar1;
char *__nptr;
long lVar2;
char *pcVar3;
int iVar4;
long lVar5;
int iVar6;
int1 auVar7 [16];
cVar1 = *param_1;
if (cVar1 == '\0') {
iVar6 = 1;
}
else {
iVar6 = 1;
pcVar3 = param_1;
do {
iVar6 = iVar6 + (uint)(cVar1 == ',');
pcVar3 = pcVar3 + 1;
cVar1 = *pcVar3;
} while (cVar1 != '\0');
}
auVar7._0_8_ = malloc((long)iVar6 << 2);
if (auVar7._0_8_ != (void *)0x0) {
pcVar3 = strdup(param_1);
__nptr = strtok(pcVar3,", ");
if ((__nptr != (char *)0x0) && (0 < iVar6)) {
lVar5 = 1;
do {
lVar2 = strtol(__nptr,(char **)0x0,10);
*(int *)((long)auVar7._0_8_ + lVar5 * 4 + -4) = (int)lVar2;
__nptr = strtok((char *)0x0,", ");
iVar4 = (int)lVar5;
lVar5 = lVar5 + 1;
} while (__nptr != (char *)0x0 && iVar4 < iVar6);
}
free(pcVar3);
auVar7._8_4_ = iVar6;
auVar7._12_4_ = 0;
return auVar7;
}
perror("malloc failed");
/* WARNING: Subroutine does not return */
exit(1);
} |
6,754 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *data;
int size;
} str_to_tuple_result;
| str_to_tuple_result func0(const char *test_str) {
str_to_tuple_result result;
// Count the number of integers
int count = 1;
for (const char *p = test_str; *p; p++) {
if (*p == ',') count++;
}
result.size = count;
result.data = malloc(count * sizeof(int));
if (!result.data) {
perror("malloc failed");
exit(1);
}
// Split the string by ", "
char *copy = strdup(test_str);
char *token = strtok(copy, ", ");
int idx = 0;
while (token != NULL && idx < count) {
result.data[idx++] = atoi(token);
token = strtok(NULL, ", ");
}
free(copy);
return result;
}
| int main() {
// Test case 1
str_to_tuple_result t1 = func0("1, -5, 4, 6, 7");
int expected1[] = {1, -5, 4, 6, 7};
assert(t1.size == 5);
for(int i = 0; i < 5; i++) {
assert(t1.data[i] == expected1[i]);
}
free(t1.data);
// Test case 2
str_to_tuple_result t2 = func0("1, 2, 3, 4, 5");
int expected2[] = {1, 2, 3, 4, 5};
assert(t2.size == 5);
for(int i = 0; i < 5; i++) {
assert(t2.data[i] == expected2[i]);
}
free(t2.data);
// Test case 3
str_to_tuple_result t3 = func0("4, 6, 9, 11, 13, 14");
int expected3[] = {4, 6, 9, 11, 13, 14};
assert(t3.size == 6);
for(int i = 0; i < 6; i++) {
assert(t3.data[i] == expected3[i]);
}
free(t3.data);
return 0;
}
| O2 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
mov %rdi,%rbp
push %rbx
movzbl (%rdi),%eax
test %al,%al
je 1548 <func0+0xd8>
mov %rdi,%rdx
mov $0x1,%r14d
nopl 0x0(%rax,%rax,1)
cmp $0x2c,%al
sete %al
add $0x1,%rdx
movzbl %al,%eax
add %eax,%r14d
movzbl (%rdx),%eax
test %al,%al
jne 1498 <func0+0x28>
movslq %r14d,%rdi
shl $0x2,%rdi
callq 1110 <malloc@plt>
mov %rax,%r12
test %rax,%rax
je 1558 <func0+0xe8>
mov %rbp,%rdi
mov $0x1,%ebx
lea 0xb3d(%rip),%r13
callq 1150 <strdup@plt>
lea 0xb31(%rip),%rsi
mov %rax,%rdi
mov %rax,%rbp
callq 1130 <strtok@plt>
mov %rax,%rdi
test %rax,%rax
je 152a <func0+0xba>
nopl 0x0(%rax)
mov $0xa,%edx
xor %esi,%esi
callq 1100 <strtol@plt>
xor %edi,%edi
mov %r13,%rsi
mov %eax,-0x4(%r12,%rbx,4)
callq 1130 <strtok@plt>
test %rax,%rax
mov %rax,%rdi
setne %dl
cmp %ebx,%r14d
setg %al
add $0x1,%rbx
test %al,%dl
jne 14f8 <func0+0x88>
mov %rbp,%rdi
callq 10d0 <free@plt>
pop %rbx
mov %r14d,%edx
pop %rbp
mov %r12,%rax
pop %r12
pop %r13
pop %r14
retq
nopl 0x0(%rax)
mov $0x4,%edi
mov $0x1,%r14d
jmpq 14b5 <func0+0x45>
lea 0xaa5(%rip),%rdi
callq 1120 <perror@plt>
mov $0x1,%edi
callq 1140 <exit@plt>
xchg %ax,%ax
| func0:
endbr64
push r14
push r13
push r12
push rbp
mov rbp, rdi
push rbx
movzx eax, byte ptr [rdi]
test al, al
jz loc_1548
mov rdx, rdi
mov r14d, 1
nop dword ptr [rax+rax+00h]
loc_1498:
cmp al, 2Ch ; ','
setz al
add rdx, 1
movzx eax, al
add r14d, eax
movzx eax, byte ptr [rdx]
test al, al
jnz short loc_1498
movsxd rdi, r14d
shl rdi, 2
loc_14B5:
call _malloc
mov r12, rax
test rax, rax
jz loc_1558
mov rdi, rbp
lea rbx, asc_2012; ", "
mov r13d, 1
call _strdup
mov rsi, rbx
mov rdi, rax
mov rbp, rax
call _strtok
mov rdi, rax
test rax, rax
jz short loc_152A
nop dword ptr [rax+00000000h]
loc_14F8:
mov edx, 0Ah
xor esi, esi
call _strtol
xor edi, edi
mov rsi, rbx
mov [r12+r13*4-4], eax
call _strtok
test rax, rax
mov rdi, rax
setnz dl
cmp r14d, r13d
setnle al
add r13, 1
test dl, al
jnz short loc_14F8
loc_152A:
mov rdi, rbp
call _free
pop rbx
mov edx, r14d
pop rbp
mov rax, r12
pop r12
pop r13
pop r14
retn
loc_1548:
mov edi, 4
mov r14d, 1
jmp loc_14B5
loc_1558:
lea rdi, aMallocFailed; "malloc failed"
call _perror
mov edi, 1
call _exit | long long func0(char *a1)
{
char v2; // al
char *v3; // rdx
int v4; // r14d
long long v5; // rdi
long long v6; // r12
long long v7; // r13
long long v8; // rbp
long long v9; // rdi
bool v10; // al
v2 = *a1;
if ( *a1 )
{
v3 = a1;
v4 = 1;
do
{
++v3;
v4 += v2 == 44;
v2 = *v3;
}
while ( *v3 );
v5 = 4LL * v4;
}
else
{
v5 = 4LL;
v4 = 1;
}
v6 = malloc(v5);
if ( !v6 )
{
perror("malloc failed");
exit(1LL);
}
v7 = 1LL;
v8 = strdup(a1);
v9 = strtok(v8, ", ");
if ( v9 )
{
do
{
*(_DWORD *)(v6 + 4 * v7 - 4) = strtol(v9, 0LL, 10LL);
v9 = strtok(0LL, ", ");
v10 = v4 > (int)v7++;
}
while ( v10 && v9 != 0 );
}
free(v8);
return v6;
} | func0:
ENDBR64
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x00101548
MOV RDX,RDI
MOV R14D,0x1
NOP dword ptr [RAX + RAX*0x1]
LAB_00101498:
CMP AL,0x2c
SETZ AL
ADD RDX,0x1
MOVZX EAX,AL
ADD R14D,EAX
MOVZX EAX,byte ptr [RDX]
TEST AL,AL
JNZ 0x00101498
MOVSXD RDI,R14D
SHL RDI,0x2
LAB_001014b5:
CALL 0x00101110
MOV R12,RAX
TEST RAX,RAX
JZ 0x00101558
MOV RDI,RBP
LEA RBX,[0x102012]
MOV R13D,0x1
CALL 0x00101150
MOV RSI,RBX
MOV RDI,RAX
MOV RBP,RAX
CALL 0x00101130
MOV RDI,RAX
TEST RAX,RAX
JZ 0x0010152a
NOP dword ptr [RAX]
LAB_001014f8:
MOV EDX,0xa
XOR ESI,ESI
CALL 0x00101100
XOR EDI,EDI
MOV RSI,RBX
MOV dword ptr [R12 + R13*0x4 + -0x4],EAX
CALL 0x00101130
TEST RAX,RAX
MOV RDI,RAX
SETNZ DL
CMP R14D,R13D
SETG AL
ADD R13,0x1
TEST DL,AL
JNZ 0x001014f8
LAB_0010152a:
MOV RDI,RBP
CALL 0x001010d0
POP RBX
MOV EDX,R14D
POP RBP
MOV RAX,R12
POP R12
POP R13
POP R14
RET
LAB_00101548:
MOV EDI,0x4
MOV R14D,0x1
JMP 0x001014b5
LAB_00101558:
LEA RDI,[0x102004]
CALL 0x00101120
MOV EDI,0x1
CALL 0x00101140 | int1 [16] func0(char *param_1)
{
char cVar1;
char *__nptr;
long lVar2;
char *pcVar3;
size_t __size;
int iVar4;
long lVar5;
int iVar6;
int1 auVar7 [16];
cVar1 = *param_1;
if (cVar1 == '\0') {
__size = 4;
iVar6 = 1;
}
else {
iVar6 = 1;
pcVar3 = param_1;
do {
pcVar3 = pcVar3 + 1;
iVar6 = iVar6 + (uint)(cVar1 == ',');
cVar1 = *pcVar3;
} while (cVar1 != '\0');
__size = (long)iVar6 << 2;
}
auVar7._0_8_ = malloc(__size);
if (auVar7._0_8_ != (void *)0x0) {
lVar5 = 1;
pcVar3 = strdup(param_1);
__nptr = strtok(pcVar3,", ");
if (__nptr != (char *)0x0) {
do {
lVar2 = strtol(__nptr,(char **)0x0,10);
*(int *)((long)auVar7._0_8_ + lVar5 * 4 + -4) = (int)lVar2;
__nptr = strtok((char *)0x0,", ");
iVar4 = (int)lVar5;
lVar5 = lVar5 + 1;
} while (__nptr != (char *)0x0 && iVar4 < iVar6);
}
free(pcVar3);
auVar7._8_4_ = iVar6;
auVar7._12_4_ = 0;
return auVar7;
}
perror("malloc failed");
/* WARNING: Subroutine does not return */
exit(1);
} |
6,755 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int *data;
int size;
} str_to_tuple_result;
| str_to_tuple_result func0(const char *test_str) {
str_to_tuple_result result;
// Count the number of integers
int count = 1;
for (const char *p = test_str; *p; p++) {
if (*p == ',') count++;
}
result.size = count;
result.data = malloc(count * sizeof(int));
if (!result.data) {
perror("malloc failed");
exit(1);
}
// Split the string by ", "
char *copy = strdup(test_str);
char *token = strtok(copy, ", ");
int idx = 0;
while (token != NULL && idx < count) {
result.data[idx++] = atoi(token);
token = strtok(NULL, ", ");
}
free(copy);
return result;
}
| int main() {
// Test case 1
str_to_tuple_result t1 = func0("1, -5, 4, 6, 7");
int expected1[] = {1, -5, 4, 6, 7};
assert(t1.size == 5);
for(int i = 0; i < 5; i++) {
assert(t1.data[i] == expected1[i]);
}
free(t1.data);
// Test case 2
str_to_tuple_result t2 = func0("1, 2, 3, 4, 5");
int expected2[] = {1, 2, 3, 4, 5};
assert(t2.size == 5);
for(int i = 0; i < 5; i++) {
assert(t2.data[i] == expected2[i]);
}
free(t2.data);
// Test case 3
str_to_tuple_result t3 = func0("4, 6, 9, 11, 13, 14");
int expected3[] = {4, 6, 9, 11, 13, 14};
assert(t3.size == 6);
for(int i = 0; i < 6; i++) {
assert(t3.data[i] == expected3[i]);
}
free(t3.data);
return 0;
}
| O3 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
mov %rdi,%rbp
push %rbx
movzbl (%rdi),%eax
test %al,%al
je 1548 <func0+0xd8>
mov %rdi,%rdx
mov $0x1,%r14d
nopl 0x0(%rax,%rax,1)
cmp $0x2c,%al
sete %al
add $0x1,%rdx
movzbl %al,%eax
add %eax,%r14d
movzbl (%rdx),%eax
test %al,%al
jne 1498 <func0+0x28>
movslq %r14d,%rdi
shl $0x2,%rdi
callq 1110 <malloc@plt>
mov %rax,%r12
test %rax,%rax
je 1558 <func0+0xe8>
mov %rbp,%rdi
mov $0x1,%ebx
lea 0xb3d(%rip),%r13
callq 1150 <strdup@plt>
lea 0xb31(%rip),%rsi
mov %rax,%rdi
mov %rax,%rbp
callq 1130 <strtok@plt>
mov %rax,%rdi
test %rax,%rax
je 152a <func0+0xba>
nopl 0x0(%rax)
mov $0xa,%edx
xor %esi,%esi
callq 1100 <strtol@plt>
xor %edi,%edi
mov %r13,%rsi
mov %eax,-0x4(%r12,%rbx,4)
callq 1130 <strtok@plt>
test %rax,%rax
mov %rax,%rdi
setne %dl
cmp %ebx,%r14d
setg %al
add $0x1,%rbx
test %al,%dl
jne 14f8 <func0+0x88>
mov %rbp,%rdi
callq 10d0 <free@plt>
pop %rbx
mov %r14d,%edx
pop %rbp
mov %r12,%rax
pop %r12
pop %r13
pop %r14
retq
nopl 0x0(%rax)
mov $0x4,%edi
mov $0x1,%r14d
jmpq 14b5 <func0+0x45>
lea 0xaa5(%rip),%rdi
callq 1120 <perror@plt>
mov $0x1,%edi
callq 1140 <exit@plt>
xchg %ax,%ax
| func0:
endbr64
push r14
push r13
push r12
push rbp
mov rbp, rdi
push rbx
movzx eax, byte ptr [rdi]
test al, al
jz loc_14E0
mov rdx, rdi
mov r14d, 1
nop dword ptr [rax+rax+00h]
loc_1428:
cmp al, 2Ch ; ','
setz al
add rdx, 1
movzx eax, al
add r14d, eax
movzx eax, byte ptr [rdx]
test al, al
jnz short loc_1428
movsxd rdi, r14d
shl rdi, 2; size
loc_1445:
call _malloc
mov rbx, rax
test rax, rax
jz func0_cold
mov rdi, rbp; s
lea rbp, delim; ", "
call _strdup
mov rsi, rbp; delim
mov rdi, rax; s
mov r12, rax
call _strtok
mov rdi, rax; nptr
test rax, rax
jz short loc_14C2
mov r13d, 1
test r14d, r14d
jle short loc_14C2
nop word ptr [rax+rax+00000000h]
loc_1490:
mov edx, 0Ah; base
xor esi, esi; endptr
call _strtol
xor edi, edi; s
mov rsi, rbp; delim
mov [rbx+r13*4-4], eax
call _strtok
test rax, rax
mov rdi, rax
setnz dl
cmp r14d, r13d
setnle al
add r13, 1
test dl, al
jnz short loc_1490
loc_14C2:
mov rdi, r12; ptr
call _free
mov edx, r14d
mov rax, rbx
pop rbx
pop rbp
pop r12
pop r13
pop r14
retn
loc_14E0:
mov edi, 4
mov r14d, 1
jmp loc_1445 | _DWORD * func0(char *s)
{
char v2; // al
char *v3; // rdx
int v4; // r14d
size_t v5; // rdi
_DWORD *v6; // rbx
char *v7; // r12
char *v8; // rdi
long long v9; // r13
bool v10; // al
v2 = *s;
if ( *s )
{
v3 = s;
v4 = 1;
do
{
++v3;
v4 += v2 == 44;
v2 = *v3;
}
while ( *v3 );
v5 = 4LL * v4;
}
else
{
v5 = 4LL;
v4 = 1;
}
v6 = malloc(v5);
if ( !v6 )
func0_cold();
v7 = strdup(s);
v8 = strtok(v7, ", ");
if ( v8 )
{
v9 = 1LL;
if ( v4 > 0 )
{
do
{
v6[v9 - 1] = strtol(v8, 0LL, 10);
v8 = strtok(0LL, ", ");
v10 = v4 > (int)v9++;
}
while ( v10 && v8 != 0LL );
}
}
free(v7);
return v6;
} | func0:
ENDBR64
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x001014e0
MOV RDX,RDI
MOV R14D,0x1
NOP dword ptr [RAX + RAX*0x1]
LAB_00101428:
CMP AL,0x2c
SETZ AL
ADD RDX,0x1
MOVZX EAX,AL
ADD R14D,EAX
MOVZX EAX,byte ptr [RDX]
TEST AL,AL
JNZ 0x00101428
MOVSXD RDI,R14D
SHL RDI,0x2
LAB_00101445:
CALL 0x001010f0
MOV RBX,RAX
TEST RAX,RAX
JZ 0x00101140
MOV RDI,RBP
LEA RBP,[0x102012]
CALL 0x00101130
MOV RSI,RBP
MOV RDI,RAX
MOV R12,RAX
CALL 0x00101110
MOV RDI,RAX
TEST RAX,RAX
JZ 0x001014c2
MOV R13D,0x1
TEST R14D,R14D
JLE 0x001014c2
NOP word ptr CS:[RAX + RAX*0x1]
LAB_00101490:
MOV EDX,0xa
XOR ESI,ESI
CALL 0x001010e0
XOR EDI,EDI
MOV RSI,RBP
MOV dword ptr [RBX + R13*0x4 + -0x4],EAX
CALL 0x00101110
TEST RAX,RAX
MOV RDI,RAX
SETNZ DL
CMP R14D,R13D
SETG AL
ADD R13,0x1
TEST DL,AL
JNZ 0x00101490
LAB_001014c2:
MOV RDI,R12
CALL 0x001010c0
MOV EDX,R14D
MOV RAX,RBX
POP RBX
POP RBP
POP R12
POP R13
POP R14
RET
LAB_001014e0:
MOV EDI,0x4
MOV R14D,0x1
JMP 0x00101445 | int [16] func0(char *param_1)
{
char cVar1;
char *__nptr;
long lVar2;
char *pcVar3;
size_t __size;
int iVar4;
long lVar5;
int iVar6;
int auVar7 [16];
cVar1 = *param_1;
if (cVar1 == '\0') {
__size = 4;
iVar6 = 1;
}
else {
iVar6 = 1;
pcVar3 = param_1;
do {
pcVar3 = pcVar3 + 1;
iVar6 = iVar6 + (uint)(cVar1 == ',');
cVar1 = *pcVar3;
} while (cVar1 != '\0');
__size = (long)iVar6 << 2;
}
auVar7._0_8_ = malloc(__size);
if (auVar7._0_8_ == (void *)0x0) {
perror("malloc failed");
/* WARNING: Subroutine does not return */
exit(1);
}
pcVar3 = strdup(param_1);
__nptr = strtok(pcVar3,", ");
if ((__nptr != (char *)0x0) && (lVar5 = 1, 0 < iVar6)) {
do {
lVar2 = strtol(__nptr,(char **)0x0,10);
*(int *)((long)auVar7._0_8_ + lVar5 * 4 + -4) = (int)lVar2;
__nptr = strtok((char *)0x0,", ");
iVar4 = (int)lVar5;
lVar5 = lVar5 + 1;
} while (__nptr != (char *)0x0 && iVar4 < iVar6);
}
free(pcVar3);
auVar7._8_4_ = iVar6;
auVar7._12_4_ = 0;
return auVar7;
} |
6,756 | func0 | #include <assert.h>
| int func0(int a) {
int perimeter = 4 * a;
return perimeter;
}
| int main() {
assert(func0(10) == 40);
assert(func0(5) == 20);
assert(func0(4) == 16);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x14(%rbp)
mov -0x14(%rbp),%eax
shl $0x2,%eax
mov %eax,-0x4(%rbp)
mov -0x4(%rbp),%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_14], edi
mov eax, [rbp+var_14]
shl eax, 2
mov [rbp+var_4], eax
mov eax, [rbp+var_4]
pop rbp
retn | long long func0(int a1)
{
return (unsigned int)(4 * a1);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x14],EDI
MOV EAX,dword ptr [RBP + -0x14]
SHL EAX,0x2
MOV dword ptr [RBP + -0x4],EAX
MOV EAX,dword ptr [RBP + -0x4]
POP RBP
RET | int func0(int param_1)
{
return param_1 << 2;
} |
6,757 | func0 | #include <assert.h>
| int func0(int a) {
int perimeter = 4 * a;
return perimeter;
}
| int main() {
assert(func0(10) == 40);
assert(func0(5) == 20);
assert(func0(4) == 16);
return 0;
}
| O1 | c | func0:
endbr64
lea 0x0(,%rdi,4),%eax
retq
| func0:
endbr64
lea eax, ds:0[rdi*4]
retn | long long func0(int a1)
{
return (unsigned int)(4 * a1);
} | func0:
ENDBR64
LEA EAX,[RDI*0x4]
RET | int func0(int param_1)
{
return param_1 * 4;
} |
6,758 | func0 | #include <assert.h>
| int func0(int a) {
int perimeter = 4 * a;
return perimeter;
}
| int main() {
assert(func0(10) == 40);
assert(func0(5) == 20);
assert(func0(4) == 16);
return 0;
}
| O2 | c | func0:
endbr64
lea 0x0(,%rdi,4),%eax
retq
nopl 0x0(%rax)
| func0:
endbr64
lea eax, ds:0[rdi*4]
retn | long long func0(int a1)
{
return (unsigned int)(4 * a1);
} | func0:
ENDBR64
LEA EAX,[RDI*0x4]
RET | int func0(int param_1)
{
return param_1 * 4;
} |
6,759 | func0 | #include <assert.h>
| int func0(int a) {
int perimeter = 4 * a;
return perimeter;
}
| int main() {
assert(func0(10) == 40);
assert(func0(5) == 20);
assert(func0(4) == 16);
return 0;
}
| O3 | c | func0:
endbr64
lea 0x0(,%rdi,4),%eax
retq
nopl 0x0(%rax)
| func0:
endbr64
lea eax, ds:0[rdi*4]
retn | long long func0(int a1)
{
return (unsigned int)(4 * a1);
} | func0:
ENDBR64
LEA EAX,[RDI*0x4]
RET | int func0(int param_1)
{
return param_1 * 4;
} |
6,760 | func0 | #include <stdio.h>
#include <math.h>
#include <assert.h>
double avg_calc(double *ls, int len) {
double mean = 0.0;
if (len <= 1) {
return ls[0];
}
for (int i = 0; i < len; i++) {
mean += ls[i];
}
mean /= len;
return mean;
}
| double func0(double *data, int len) {
if (len <= 1) {
return 0.0;
}
double mean = avg_calc(data, len);
double sd = 0.0;
for (int i = 0; i < len; i++) {
sd += (data[i] - mean) * (data[i] - mean);
}
sd = sqrt(sd / (len - 1));
return sd;
}
| int main() {
double data1[] = {4, 2, 5, 8, 6};
double data2[] = {1, 2, 3, 4, 5, 6, 7};
double data3[] = {5, 9, 10, 15, 6, 4};
assert(fabs(func0(data1, 5) - 2.23606797749979) < 1e-9);
assert(fabs(func0(data2, 7) - 2.160246899469287) < 1e-9);
assert(fabs(func0(data3, 6) - 4.070217029430577) < 1e-9);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %rdi,-0x28(%rbp)
mov %esi,-0x2c(%rbp)
cmpl $0x1,-0x2c(%rbp)
jg 1228 <func0+0x22>
pxor %xmm0,%xmm0
jmpq 12d6 <func0+0xd0>
mov -0x2c(%rbp),%edx
mov -0x28(%rbp),%rax
mov %edx,%esi
mov %rax,%rdi
callq 1189 <avg_calc>
movq %xmm0,%rax
mov %rax,-0x8(%rbp)
pxor %xmm0,%xmm0
movsd %xmm0,-0x10(%rbp)
movl $0x0,-0x14(%rbp)
jmp 12a8 <func0+0xa2>
mov -0x14(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
add %rdx,%rax
movsd (%rax),%xmm0
movapd %xmm0,%xmm1
subsd -0x8(%rbp),%xmm1
mov -0x14(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
add %rdx,%rax
movsd (%rax),%xmm0
subsd -0x8(%rbp),%xmm0
mulsd %xmm1,%xmm0
movsd -0x10(%rbp),%xmm1
addsd %xmm1,%xmm0
movsd %xmm0,-0x10(%rbp)
addl $0x1,-0x14(%rbp)
mov -0x14(%rbp),%eax
cmp -0x2c(%rbp),%eax
jl 1254 <func0+0x4e>
mov -0x2c(%rbp),%eax
sub $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd -0x10(%rbp),%xmm0
divsd %xmm1,%xmm0
callq 1090 <sqrt@plt>
movq %xmm0,%rax
mov %rax,-0x10(%rbp)
movsd -0x10(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
mov [rbp+var_28], rdi
mov [rbp+var_2C], esi
cmp [rbp+var_2C], 1
jg short loc_122C
pxor xmm0, xmm0
jmp locret_12E8
loc_122C:
mov edx, [rbp+var_2C]
mov rax, [rbp+var_28]
mov esi, edx
mov rdi, rax
call avg_calc
movq rax, xmm0
mov [rbp+var_8], rax
pxor xmm0, xmm0
movsd [rbp+var_10], xmm0
mov [rbp+var_14], 0
jmp short loc_12AC
loc_1258:
mov eax, [rbp+var_14]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rdx
movsd xmm0, qword ptr [rax]
movapd xmm1, xmm0
subsd xmm1, [rbp+var_8]
mov eax, [rbp+var_14]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rdx
movsd xmm0, qword ptr [rax]
subsd xmm0, [rbp+var_8]
mulsd xmm0, xmm1
movsd xmm1, [rbp+var_10]
addsd xmm0, xmm1
movsd [rbp+var_10], xmm0
add [rbp+var_14], 1
loc_12AC:
mov eax, [rbp+var_14]
cmp eax, [rbp+var_2C]
jl short loc_1258
mov eax, [rbp+var_2C]
sub eax, 1
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
movsd xmm0, [rbp+var_10]
divsd xmm0, xmm1
movq rax, xmm0
movq xmm0, rax; x
call _sqrt
movq rax, xmm0
mov [rbp+var_10], rax
movsd xmm0, [rbp+var_10]
locret_12E8:
leave
retn | long long func0(long long a1, int a2)
{
long long result; // rax
int i; // [rsp+1Ch] [rbp-14h]
double v4; // [rsp+20h] [rbp-10h]
double v5; // [rsp+28h] [rbp-8h]
if ( a2 > 1 )
{
v5 = avg_calc(a1, (unsigned int)a2);
v4 = 0.0;
for ( i = 0; i < a2; ++i )
v4 = (*(double *)(8LL * i + a1) - v5) * (*(double *)(8LL * i + a1) - v5) + v4;
return sqrt(v4 / (double)(a2 - 1));
}
return result;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV qword ptr [RBP + -0x28],RDI
MOV dword ptr [RBP + -0x2c],ESI
CMP dword ptr [RBP + -0x2c],0x1
JG 0x0010122c
PXOR XMM0,XMM0
JMP 0x001012e8
LAB_0010122c:
MOV EDX,dword ptr [RBP + -0x2c]
MOV RAX,qword ptr [RBP + -0x28]
MOV ESI,EDX
MOV RDI,RAX
CALL 0x00101189
MOVQ RAX,XMM0
MOV qword ptr [RBP + -0x8],RAX
PXOR XMM0,XMM0
MOVSD qword ptr [RBP + -0x10],XMM0
MOV dword ptr [RBP + -0x14],0x0
JMP 0x001012ac
LAB_00101258:
MOV EAX,dword ptr [RBP + -0x14]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RDX
MOVSD XMM0,qword ptr [RAX]
MOVAPD XMM1,XMM0
SUBSD XMM1,qword ptr [RBP + -0x8]
MOV EAX,dword ptr [RBP + -0x14]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RDX
MOVSD XMM0,qword ptr [RAX]
SUBSD XMM0,qword ptr [RBP + -0x8]
MULSD XMM0,XMM1
MOVSD XMM1,qword ptr [RBP + -0x10]
ADDSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x10],XMM0
ADD dword ptr [RBP + -0x14],0x1
LAB_001012ac:
MOV EAX,dword ptr [RBP + -0x14]
CMP EAX,dword ptr [RBP + -0x2c]
JL 0x00101258
MOV EAX,dword ptr [RBP + -0x2c]
SUB EAX,0x1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
MOVSD XMM0,qword ptr [RBP + -0x10]
DIVSD XMM0,XMM1
MOVQ RAX,XMM0
MOVQ XMM0,RAX
CALL 0x00101090
MOVQ RAX,XMM0
MOV qword ptr [RBP + -0x10],RAX
MOVSD XMM0,qword ptr [RBP + -0x10]
LAB_001012e8:
LEAVE
RET | double func0(long param_1,int param_2)
{
double dVar1;
int4 local_1c;
int8 local_18;
if (param_2 < 2) {
dVar1 = 0.0;
}
else {
dVar1 = (double)avg_calc(param_1,param_2);
local_18 = 0.0;
for (local_1c = 0; local_1c < param_2; local_1c = local_1c + 1) {
local_18 = (*(double *)(param_1 + (long)local_1c * 8) - dVar1) *
(*(double *)(param_1 + (long)local_1c * 8) - dVar1) + local_18;
}
dVar1 = sqrt(local_18 / (double)(param_2 + -1));
}
return dVar1;
} |
6,761 | func0 | #include <stdio.h>
#include <math.h>
#include <assert.h>
double avg_calc(double *ls, int len) {
double mean = 0.0;
if (len <= 1) {
return ls[0];
}
for (int i = 0; i < len; i++) {
mean += ls[i];
}
mean /= len;
return mean;
}
| double func0(double *data, int len) {
if (len <= 1) {
return 0.0;
}
double mean = avg_calc(data, len);
double sd = 0.0;
for (int i = 0; i < len; i++) {
sd += (data[i] - mean) * (data[i] - mean);
}
sd = sqrt(sd / (len - 1));
return sd;
}
| int main() {
double data1[] = {4, 2, 5, 8, 6};
double data2[] = {1, 2, 3, 4, 5, 6, 7};
double data3[] = {5, 9, 10, 15, 6, 4};
assert(fabs(func0(data1, 5) - 2.23606797749979) < 1e-9);
assert(fabs(func0(data2, 7) - 2.160246899469287) < 1e-9);
assert(fabs(func0(data3, 6) - 4.070217029430577) < 1e-9);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x18,%rsp
cmp $0x1,%esi
jle 1240 <func0+0x80>
mov %rdi,%rbp
mov %esi,%ebx
callq 1189 <avg_calc>
movapd %xmm0,%xmm2
mov %rbp,%rax
lea -0x1(%rbx),%edx
lea 0x8(%rbp,%rdx,8),%rdx
pxor %xmm0,%xmm0
movsd (%rax),%xmm1
subsd %xmm2,%xmm1
mulsd %xmm1,%xmm1
addsd %xmm1,%xmm0
add $0x8,%rax
cmp %rdx,%rax
jne 11ec <func0+0x2c>
sub $0x1,%ebx
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd %xmm1,%xmm0
movapd %xmm0,%xmm3
sqrtsd %xmm3,%xmm3
movsd %xmm3,0x8(%rsp)
pxor %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja 1239 <func0+0x79>
movsd 0x8(%rsp),%xmm0
add $0x18,%rsp
pop %rbx
pop %rbp
retq
callq 1090 <sqrt@plt>
jmp 122c <func0+0x6c>
pxor %xmm4,%xmm4
movsd %xmm4,0x8(%rsp)
jmp 122c <func0+0x6c>
| func0:
endbr64
cmp esi, 1
jle short loc_1230
push rbp
push rbx
sub rsp, 8
mov rbp, rdi
mov ebx, esi
call avg_calc
movapd xmm2, xmm0
mov rax, rbp
lea edx, [rbx-1]
lea rdx, [rbp+rdx*8+8]
pxor xmm0, xmm0
loc_11EC:
movsd xmm1, qword ptr [rax]
subsd xmm1, xmm2
mulsd xmm1, xmm1
addsd xmm0, xmm1
add rax, 8
cmp rax, rdx
jnz short loc_11EC
sub ebx, 1
pxor xmm1, xmm1
cvtsi2sd xmm1, ebx
divsd xmm0, xmm1
pxor xmm1, xmm1
ucomisd xmm1, xmm0
ja short loc_1229
sqrtsd xmm0, xmm0
loc_1222:
add rsp, 8
pop rbx
pop rbp
retn
loc_1229:
call _sqrt
jmp short loc_1222
loc_1230:
pxor xmm0, xmm0
retn | double func0(double *a1, int a2)
{
double v2; // xmm2_8
double *v3; // rax
double v4; // xmm0_8
double v5; // xmm0_8
if ( a2 <= 1 )
return 0.0;
v2 = avg_calc();
v3 = a1;
v4 = 0.0;
do
{
v4 = v4 + (*v3 - v2) * (*v3 - v2);
++v3;
}
while ( v3 != &a1[(unsigned int)(a2 - 1) + 1] );
v5 = v4 / (double)(a2 - 1);
if ( v5 < 0.0 )
return sqrt(v5);
else
return sqrt(v5);
} | func0:
ENDBR64
CMP ESI,0x1
JLE 0x00101230
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBP,RDI
MOV EBX,ESI
CALL 0x00101189
MOVAPD XMM2,XMM0
MOV RAX,RBP
LEA EDX,[RBX + -0x1]
LEA RDX,[RBP + RDX*0x8 + 0x8]
PXOR XMM0,XMM0
LAB_001011ec:
MOVSD XMM1,qword ptr [RAX]
SUBSD XMM1,XMM2
MULSD XMM1,XMM1
ADDSD XMM0,XMM1
ADD RAX,0x8
CMP RAX,RDX
JNZ 0x001011ec
SUB EBX,0x1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EBX
DIVSD XMM0,XMM1
PXOR XMM1,XMM1
UCOMISD XMM1,XMM0
JA 0x00101229
SQRTSD XMM0,XMM0
LAB_00101222:
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_00101229:
CALL 0x00101090
JMP 0x00101222
LAB_00101230:
PXOR XMM0,XMM0
RET | double func0(double *param_1,int param_2)
{
double *pdVar1;
double dVar2;
double dVar3;
if (1 < param_2) {
dVar2 = (double)avg_calc();
pdVar1 = param_1 + (ulong)(param_2 - 1) + 1;
dVar3 = 0.0;
do {
dVar3 = dVar3 + (*param_1 - dVar2) * (*param_1 - dVar2);
param_1 = param_1 + 1;
} while (param_1 != pdVar1);
dVar3 = dVar3 / (double)(param_2 + -1);
if (dVar3 < 0.0) {
dVar3 = sqrt(dVar3);
}
else {
dVar3 = SQRT(dVar3);
}
return dVar3;
}
return 0.0;
} |
6,762 | func0 | #include <stdio.h>
#include <math.h>
#include <assert.h>
double avg_calc(double *ls, int len) {
double mean = 0.0;
if (len <= 1) {
return ls[0];
}
for (int i = 0; i < len; i++) {
mean += ls[i];
}
mean /= len;
return mean;
}
| double func0(double *data, int len) {
if (len <= 1) {
return 0.0;
}
double mean = avg_calc(data, len);
double sd = 0.0;
for (int i = 0; i < len; i++) {
sd += (data[i] - mean) * (data[i] - mean);
}
sd = sqrt(sd / (len - 1));
return sd;
}
| int main() {
double data1[] = {4, 2, 5, 8, 6};
double data2[] = {1, 2, 3, 4, 5, 6, 7};
double data3[] = {5, 9, 10, 15, 6, 4};
assert(fabs(func0(data1, 5) - 2.23606797749979) < 1e-9);
assert(fabs(func0(data2, 7) - 2.160246899469287) < 1e-9);
assert(fabs(func0(data3, 6) - 4.070217029430577) < 1e-9);
return 0;
}
| O2 | c | func0:
endbr64
cmp $0x1,%esi
jle 1450 <func0+0x80>
lea -0x1(%rsi),%eax
pxor %xmm3,%xmm3
mov %rax,%rcx
lea 0x8(%rdi,%rax,8),%rdx
movapd %xmm3,%xmm0
mov %rdi,%rax
addsd (%rax),%xmm0
add $0x8,%rax
cmp %rax,%rdx
jne 13f0 <func0+0x20>
pxor %xmm1,%xmm1
movapd %xmm3,%xmm2
cvtsi2sd %esi,%xmm1
divsd %xmm1,%xmm0
nopl (%rax)
movsd (%rdi),%xmm1
add $0x8,%rdi
subsd %xmm0,%xmm1
mulsd %xmm1,%xmm1
addsd %xmm1,%xmm2
cmp %rdi,%rdx
jne 1410 <func0+0x40>
pxor %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
divsd %xmm0,%xmm2
ucomisd %xmm2,%xmm3
movapd %xmm2,%xmm1
sqrtsd %xmm1,%xmm1
ja 1459 <func0+0x89>
movapd %xmm1,%xmm0
retq
nopl 0x0(%rax,%rax,1)
pxor %xmm1,%xmm1
movapd %xmm1,%xmm0
retq
sub $0x18,%rsp
movapd %xmm2,%xmm0
movsd %xmm1,0x8(%rsp)
callq 1090 <sqrt@plt>
movsd 0x8(%rsp),%xmm1
add $0x18,%rsp
movapd %xmm1,%xmm0
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
cmp esi, 1
jle short loc_1438
lea eax, [rsi-1]
pxor xmm3, xmm3
mov rcx, rax
lea rdx, [rdi+rax*8+8]
movapd xmm0, xmm3
mov rax, rdi
nop
loc_13E0:
addsd xmm0, qword ptr [rax]
add rax, 8
cmp rdx, rax
jnz short loc_13E0
pxor xmm1, xmm1
movapd xmm2, xmm3
cvtsi2sd xmm1, esi
divsd xmm0, xmm1
nop dword ptr [rax]
loc_1400:
movsd xmm1, qword ptr [rdi]
add rdi, 8
subsd xmm1, xmm0
mulsd xmm1, xmm1
addsd xmm2, xmm1
cmp rdx, rdi
jnz short loc_1400
pxor xmm0, xmm0
cvtsi2sd xmm0, ecx
divsd xmm2, xmm0
ucomisd xmm3, xmm2
ja short loc_143D
sqrtsd xmm2, xmm2
movapd xmm0, xmm2
retn
loc_1438:
pxor xmm0, xmm0
retn
loc_143D:
movapd xmm0, xmm2
jmp _sqrt | double func0(double *a1, int a2)
{
long long v2; // rcx
long long v3; // rdx
double v4; // xmm0_8
double *v5; // rax
double v6; // xmm2_8
double v7; // xmm0_8
double v8; // xmm1_8
double v9; // xmm2_8
if ( a2 <= 1 )
return 0.0;
v2 = (unsigned int)(a2 - 1);
v3 = (long long)&a1[v2 + 1];
v4 = 0.0;
v5 = a1;
do
v4 = v4 + *v5++;
while ( (double *)v3 != v5 );
v6 = 0.0;
v7 = v4 / (double)a2;
do
{
v8 = *a1++;
v6 = v6 + (v8 - v7) * (v8 - v7);
}
while ( (double *)v3 != a1 );
v9 = v6 / (double)(int)v2;
if ( v9 < 0.0 )
return sqrt(v9);
else
return sqrt(v9);
} | func0:
ENDBR64
CMP ESI,0x1
JLE 0x00101438
LEA EAX,[RSI + -0x1]
PXOR XMM3,XMM3
MOV RCX,RAX
LEA RDX,[RDI + RAX*0x8 + 0x8]
MOVAPD XMM0,XMM3
MOV RAX,RDI
NOP
LAB_001013e0:
ADDSD XMM0,qword ptr [RAX]
ADD RAX,0x8
CMP RDX,RAX
JNZ 0x001013e0
PXOR XMM1,XMM1
MOVAPD XMM2,XMM3
CVTSI2SD XMM1,ESI
DIVSD XMM0,XMM1
NOP dword ptr [RAX]
LAB_00101400:
MOVSD XMM1,qword ptr [RDI]
ADD RDI,0x8
SUBSD XMM1,XMM0
MULSD XMM1,XMM1
ADDSD XMM2,XMM1
CMP RDX,RDI
JNZ 0x00101400
PXOR XMM0,XMM0
CVTSI2SD XMM0,ECX
DIVSD XMM2,XMM0
UCOMISD XMM3,XMM2
JA 0x0010143d
SQRTSD XMM2,XMM2
MOVAPD XMM0,XMM2
RET
LAB_00101438:
PXOR XMM0,XMM0
RET
LAB_0010143d:
MOVAPD XMM0,XMM2
JMP 0x00101090 | double func0(double *param_1,int param_2)
{
double *pdVar1;
double *pdVar2;
double dVar3;
double dVar4;
double dVar5;
if (param_2 < 2) {
return 0.0;
}
pdVar1 = param_1 + (ulong)(param_2 - 1U) + 1;
dVar5 = 0.0;
pdVar2 = param_1;
dVar3 = dVar5;
do {
dVar3 = dVar3 + *pdVar2;
pdVar2 = pdVar2 + 1;
} while (pdVar1 != pdVar2);
do {
dVar4 = *param_1;
param_1 = param_1 + 1;
dVar4 = dVar4 - dVar3 / (double)param_2;
dVar5 = dVar5 + dVar4 * dVar4;
} while (pdVar1 != param_1);
dVar5 = dVar5 / (double)(int)(param_2 - 1U);
if (0.0 <= dVar5) {
return SQRT(dVar5);
}
dVar3 = sqrt(dVar5);
return dVar3;
} |
6,763 | func0 | #include <stdio.h>
#include <math.h>
#include <assert.h>
double avg_calc(double *ls, int len) {
double mean = 0.0;
if (len <= 1) {
return ls[0];
}
for (int i = 0; i < len; i++) {
mean += ls[i];
}
mean /= len;
return mean;
}
| double func0(double *data, int len) {
if (len <= 1) {
return 0.0;
}
double mean = avg_calc(data, len);
double sd = 0.0;
for (int i = 0; i < len; i++) {
sd += (data[i] - mean) * (data[i] - mean);
}
sd = sqrt(sd / (len - 1));
return sd;
}
| int main() {
double data1[] = {4, 2, 5, 8, 6};
double data2[] = {1, 2, 3, 4, 5, 6, 7};
double data3[] = {5, 9, 10, 15, 6, 4};
assert(fabs(func0(data1, 5) - 2.23606797749979) < 1e-9);
assert(fabs(func0(data2, 7) - 2.160246899469287) < 1e-9);
assert(fabs(func0(data3, 6) - 4.070217029430577) < 1e-9);
return 0;
}
| O3 | c | func0:
endbr64
cmp $0x1,%esi
jle 1490 <func0+0xf0>
mov %esi,%edx
pxor %xmm4,%xmm4
mov %rdi,%rax
shr %edx
movapd %xmm4,%xmm0
shl $0x4,%rdx
add %rdi,%rdx
nopl 0x0(%rax,%rax,1)
movsd (%rax),%xmm1
add $0x10,%rax
addsd %xmm1,%xmm0
movsd -0x8(%rax),%xmm1
addsd %xmm1,%xmm0
cmp %rax,%rdx
jne 13c8 <func0+0x28>
mov %esi,%eax
and $0xfffffffe,%eax
test $0x1,%sil
je 13f2 <func0+0x52>
addsd (%rdi,%rax,8),%xmm0
pxor %xmm1,%xmm1
movapd %xmm0,%xmm2
mov %esi,%edx
mov %rdi,%rax
cvtsi2sd %esi,%xmm1
shr %edx
movapd %xmm4,%xmm0
shl $0x4,%rdx
add %rdi,%rdx
divsd %xmm1,%xmm2
movapd %xmm2,%xmm5
unpcklpd %xmm5,%xmm5
nopl 0x0(%rax)
movupd (%rax),%xmm1
add $0x10,%rax
subpd %xmm5,%xmm1
mulpd %xmm1,%xmm1
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm1
addsd %xmm0,%xmm3
movapd %xmm1,%xmm0
addsd %xmm3,%xmm0
cmp %rax,%rdx
jne 1420 <func0+0x80>
mov %esi,%eax
and $0xfffffffe,%eax
test $0x1,%sil
je 1469 <func0+0xc9>
movsd (%rdi,%rax,8),%xmm3
subsd %xmm2,%xmm3
movapd %xmm3,%xmm2
mulsd %xmm3,%xmm2
addsd %xmm2,%xmm0
sub $0x1,%esi
pxor %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
divsd %xmm1,%xmm0
ucomisd %xmm0,%xmm4
movapd %xmm0,%xmm1
sqrtsd %xmm1,%xmm1
ja 1499 <func0+0xf9>
movapd %xmm1,%xmm0
retq
nopl 0x0(%rax,%rax,1)
pxor %xmm1,%xmm1
movapd %xmm1,%xmm0
retq
sub $0x18,%rsp
movsd %xmm1,0x8(%rsp)
callq 1090 <sqrt@plt>
movsd 0x8(%rsp),%xmm1
add $0x18,%rsp
movapd %xmm1,%xmm0
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
cmp esi, 1
jle loc_1468
mov ecx, esi
mov rdx, rdi
pxor xmm0, xmm0
mov rax, rdi
shr ecx, 1
shl rcx, 4
add rcx, rdi
nop word ptr [rax+rax+00h]
loc_13C8:
addsd xmm0, qword ptr [rax]
add rax, 10h
addsd xmm0, qword ptr [rax-8]
cmp rcx, rax
jnz short loc_13C8
mov eax, esi
and eax, 0FFFFFFFEh
test sil, 1
jz short loc_13EE
mov r8d, eax
addsd xmm0, qword ptr [rdi+r8*8]
loc_13EE:
pxor xmm1, xmm1
movapd xmm2, xmm0
pxor xmm0, xmm0
cvtsi2sd xmm1, esi
divsd xmm2, xmm1
movapd xmm4, xmm2
unpcklpd xmm4, xmm4
nop word ptr [rax+rax+00h]
loc_1410:
movupd xmm1, xmmword ptr [rdx]
add rdx, 10h
subpd xmm1, xmm4
mulpd xmm1, xmm1
addsd xmm0, xmm1
unpckhpd xmm1, xmm1
addsd xmm0, xmm1
cmp rcx, rdx
jnz short loc_1410
cmp esi, eax
jz short loc_1446
movsd xmm1, qword ptr [rdi+rax*8]
subsd xmm1, xmm2
mulsd xmm1, xmm1
addsd xmm0, xmm1
loc_1446:
sub esi, 1
pxor xmm1, xmm1
cvtsi2sd xmm1, esi
divsd xmm0, xmm1; x
pxor xmm1, xmm1
ucomisd xmm1, xmm0
ja short loc_146D
sqrtsd xmm0, xmm0
retn
loc_1468:
pxor xmm0, xmm0
retn
loc_146D:
jmp _sqrt | double func0(__m128d *a1, int a2)
{
__m128d *v2; // rdx
__m128d v3; // xmm0
double *v4; // rax
double *m128d_f64; // rcx
double v6; // xmm0_8
long long v7; // rax
double v8; // xmm0_8
__m128d v9; // xmm2
__m128d v10; // xmm4
__m128d v11; // xmm1
__m128d v12; // xmm1
__m128d v13; // xmm1
double v14; // xmm0_8
if ( a2 <= 1 )
return 0.0;
v2 = a1;
v3 = 0LL;
v4 = (double *)a1;
m128d_f64 = a1[(unsigned int)a2 >> 1].m128d_f64;
do
{
v6 = v3.m128d_f64[0] + *v4;
v4 += 2;
v3.m128d_f64[0] = v6 + *(v4 - 1);
}
while ( m128d_f64 != v4 );
v7 = a2 & 0xFFFFFFFE;
if ( (a2 & 1) != 0 )
v3.m128d_f64[0] = v3.m128d_f64[0] + a1->m128d_f64[(unsigned int)v7];
v9 = v3;
v8 = 0.0;
v9.m128d_f64[0] = v9.m128d_f64[0] / (double)a2;
v10 = _mm_unpacklo_pd(v9, v9);
do
{
v11 = *v2++;
v12 = _mm_sub_pd(v11, v10);
v13 = _mm_mul_pd(v12, v12);
v8 = v8 + v13.m128d_f64[0] + _mm_unpackhi_pd(v13, v13).m128d_f64[0];
}
while ( m128d_f64 != (double *)v2 );
if ( a2 != (_DWORD)v7 )
v8 = v8 + (a1->m128d_f64[v7] - v9.m128d_f64[0]) * (a1->m128d_f64[v7] - v9.m128d_f64[0]);
v14 = v8 / (double)(a2 - 1);
if ( v14 < 0.0 )
return sqrt(v14);
else
return sqrt(v14);
} | func0:
ENDBR64
CMP ESI,0x1
JLE 0x00101468
MOV ECX,ESI
MOV RDX,RDI
PXOR XMM0,XMM0
MOV RAX,RDI
SHR ECX,0x1
SHL RCX,0x4
ADD RCX,RDI
NOP word ptr [RAX + RAX*0x1]
LAB_001013c8:
ADDSD XMM0,qword ptr [RAX]
ADD RAX,0x10
ADDSD XMM0,qword ptr [RAX + -0x8]
CMP RCX,RAX
JNZ 0x001013c8
MOV EAX,ESI
AND EAX,0xfffffffe
TEST SIL,0x1
JZ 0x001013ee
MOV R8D,EAX
ADDSD XMM0,qword ptr [RDI + R8*0x8]
LAB_001013ee:
PXOR XMM1,XMM1
MOVAPD XMM2,XMM0
PXOR XMM0,XMM0
CVTSI2SD XMM1,ESI
DIVSD XMM2,XMM1
MOVAPD XMM4,XMM2
UNPCKLPD XMM4,XMM4
NOP word ptr [RAX + RAX*0x1]
LAB_00101410:
MOVUPD XMM1,xmmword ptr [RDX]
ADD RDX,0x10
SUBPD XMM1,XMM4
MULPD XMM1,XMM1
ADDSD XMM0,XMM1
UNPCKHPD XMM1,XMM1
ADDSD XMM0,XMM1
CMP RCX,RDX
JNZ 0x00101410
CMP ESI,EAX
JZ 0x00101446
MOVSD XMM1,qword ptr [RDI + RAX*0x8]
SUBSD XMM1,XMM2
MULSD XMM1,XMM1
ADDSD XMM0,XMM1
LAB_00101446:
SUB ESI,0x1
PXOR XMM1,XMM1
CVTSI2SD XMM1,ESI
DIVSD XMM0,XMM1
PXOR XMM1,XMM1
UCOMISD XMM1,XMM0
JA 0x0010146d
SQRTSD XMM0,XMM0
RET
LAB_00101468:
PXOR XMM0,XMM0
RET
LAB_0010146d:
JMP 0x00101090 | double func0(double *param_1,uint param_2)
{
double dVar1;
uint uVar2;
double *pdVar3;
double *pdVar4;
double dVar5;
double dVar6;
if ((int)param_2 < 2) {
return 0.0;
}
dVar5 = 0.0;
pdVar3 = param_1;
do {
pdVar4 = pdVar3 + 2;
dVar5 = dVar5 + *pdVar3 + pdVar3[1];
pdVar3 = pdVar4;
} while (param_1 + (ulong)(param_2 >> 1) * 2 != pdVar4);
uVar2 = param_2 & 0xfffffffe;
if ((param_2 & 1) != 0) {
dVar5 = dVar5 + param_1[uVar2];
}
dVar6 = 0.0;
dVar5 = dVar5 / (double)(int)param_2;
pdVar3 = param_1;
do {
dVar1 = *pdVar3;
pdVar4 = pdVar3 + 1;
pdVar3 = pdVar3 + 2;
dVar6 = dVar6 + (dVar1 - dVar5) * (dVar1 - dVar5) + (*pdVar4 - dVar5) * (*pdVar4 - dVar5);
} while (param_1 + (ulong)(param_2 >> 1) * 2 != pdVar3);
if (param_2 != uVar2) {
dVar6 = dVar6 + (param_1[uVar2] - dVar5) * (param_1[uVar2] - dVar5);
}
dVar6 = dVar6 / (double)(int)(param_2 - 1);
if (0.0 <= dVar6) {
return SQRT(dVar6);
}
dVar5 = sqrt(dVar6);
return dVar5;
} |
6,764 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
| int* func0(int* list1, int length, int* result_size) {
*result_size = (length + 1) / 2; // calculate size of the result array
int* result = (int *)malloc(*result_size * sizeof(int));
// Iterate taking every second element
int j = 0;
for (int i = 0; i < length; i += 2) {
result[j++] = list1[i];
}
return result;
}
| int main() {
int list1[] = {2, 0, 3, 4, 0, 2, 8, 3, 4, 2};
int list1_size = 10;
int* result1;
int result1_size;
result1 = func0(list1, list1_size, &result1_size);
int expected_result1[] = {2, 3, 0, 8, 4};
assert(result1_size == 5);
for (int i = 0; i < result1_size; i++) {
assert(result1[i] == expected_result1[i]);
}
int list2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int list2_size = 10;
int* result2;
int result2_size;
result2 = func0(list2, list2_size, &result2_size);
int expected_result2[] = {1, 3, 5, 7, 9};
assert(result2_size == 5);
for (int i = 0; i < result2_size; i++) {
assert(result2[i] == expected_result2[i]);
}
free(result1); // free allocated memory
free(result2);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov %rdx,-0x28(%rbp)
mov -0x1c(%rbp),%eax
add $0x1,%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
mov %eax,%edx
mov -0x28(%rbp),%rax
mov %edx,(%rax)
mov -0x28(%rbp),%rax
mov (%rax),%eax
cltq
shl $0x2,%rax
mov %rax,%rdi
callq 10b0 <malloc@plt>
mov %rax,-0x8(%rbp)
movl $0x0,-0x10(%rbp)
movl $0x0,-0xc(%rbp)
jmp 1236 <func0+0x8d>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x10(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x10(%rbp)
cltq
lea 0x0(,%rax,4),%rdx
mov -0x8(%rbp),%rax
add %rax,%rdx
mov (%rcx),%eax
mov %eax,(%rdx)
addl $0x2,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 11ff <func0+0x56>
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
mov [rbp+var_18], rdi
mov [rbp+var_1C], esi
mov [rbp+var_28], rdx
mov eax, [rbp+var_1C]
add eax, 1
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
mov edx, eax
mov rax, [rbp+var_28]
mov [rax], edx
mov rax, [rbp+var_28]
mov eax, [rax]
cdqe
shl rax, 2
mov rdi, rax; size
call _malloc
mov [rbp+var_8], rax
mov [rbp+var_10], 0
mov [rbp+var_C], 0
jmp short loc_1236
loc_11FF:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
lea rcx, [rdx+rax]
mov eax, [rbp+var_10]
lea edx, [rax+1]
mov [rbp+var_10], edx
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_8]
add rdx, rax
mov eax, [rcx]
mov [rdx], eax
add [rbp+var_C], 2
loc_1236:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_1C]
jl short loc_11FF
mov rax, [rbp+var_8]
leave
retn | _DWORD * func0(long long a1, int a2, int *a3)
{
int v3; // eax
int v5; // [rsp+20h] [rbp-10h]
int i; // [rsp+24h] [rbp-Ch]
_DWORD *v7; // [rsp+28h] [rbp-8h]
*a3 = (a2 + 1) / 2;
v7 = malloc(4LL * *a3);
v5 = 0;
for ( i = 0; i < a2; i += 2 )
{
v3 = v5++;
v7[v3] = *(_DWORD *)(4LL * i + a1);
}
return v7;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV qword ptr [RBP + -0x28],RDX
MOV EAX,dword ptr [RBP + -0x1c]
ADD EAX,0x1
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
MOV EDX,EAX
MOV RAX,qword ptr [RBP + -0x28]
MOV dword ptr [RAX],EDX
MOV RAX,qword ptr [RBP + -0x28]
MOV EAX,dword ptr [RAX]
CDQE
SHL RAX,0x2
MOV RDI,RAX
CALL 0x001010b0
MOV qword ptr [RBP + -0x8],RAX
MOV dword ptr [RBP + -0x10],0x0
MOV dword ptr [RBP + -0xc],0x0
JMP 0x00101236
LAB_001011ff:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x10]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x10],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
ADD dword ptr [RBP + -0xc],0x2
LAB_00101236:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x001011ff
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(long param_1,int param_2,int *param_3)
{
void *pvVar1;
int4 local_18;
int4 local_14;
*param_3 = (param_2 + 1) / 2;
pvVar1 = malloc((long)*param_3 << 2);
local_18 = 0;
for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 2) {
*(int4 *)((long)local_18 * 4 + (long)pvVar1) =
*(int4 *)((long)local_14 * 4 + param_1);
local_18 = local_18 + 1;
}
return pvVar1;
} |
6,765 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
| int* func0(int* list1, int length, int* result_size) {
*result_size = (length + 1) / 2; // calculate size of the result array
int* result = (int *)malloc(*result_size * sizeof(int));
// Iterate taking every second element
int j = 0;
for (int i = 0; i < length; i += 2) {
result[j++] = list1[i];
}
return result;
}
| int main() {
int list1[] = {2, 0, 3, 4, 0, 2, 8, 3, 4, 2};
int list1_size = 10;
int* result1;
int result1_size;
result1 = func0(list1, list1_size, &result1_size);
int expected_result1[] = {2, 3, 0, 8, 4};
assert(result1_size == 5);
for (int i = 0; i < result1_size; i++) {
assert(result1[i] == expected_result1[i]);
}
int list2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int list2_size = 10;
int* result2;
int result2_size;
result2 = func0(list2, list2_size, &result2_size);
int expected_result2[] = {1, 3, 5, 7, 9};
assert(result2_size == 5);
for (int i = 0; i < result2_size; i++) {
assert(result2[i] == expected_result2[i]);
}
free(result1); // free allocated memory
free(result2);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%rbp
mov %esi,%ebx
lea 0x1(%rsi),%eax
mov %eax,%edi
shr $0x1f,%edi
add %eax,%edi
sar %edi
mov %edi,(%rdx)
movslq %edi,%rdi
shl $0x2,%rdi
callq 10b0 <malloc@plt>
test %ebx,%ebx
jle 11ea <func0+0x41>
mov $0x0,%edx
mov 0x0(%rbp,%rdx,4),%ecx
mov %ecx,(%rax,%rdx,2)
add $0x2,%rdx
cmp %edx,%ebx
jg 11db <func0+0x32>
add $0x8,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
mov rbp, rdi
mov ebx, esi
lea eax, [rsi+1]
mov edi, eax
shr edi, 1Fh
add edi, eax
sar edi, 1
mov [rdx], edi
movsxd rdi, edi
shl rdi, 2
call _malloc
test ebx, ebx
jle short loc_11EA
mov edx, 0
loc_11DB:
mov ecx, [rbp+rdx*4+0]
mov [rax+rdx*2], ecx
add rdx, 2
cmp ebx, edx
jg short loc_11DB
loc_11EA:
add rsp, 8
pop rbx
pop rbp
retn | long long func0(long long a1, int a2, int *a3)
{
int v4; // edi
long long result; // rax
long long v6; // rdx
v4 = (a2 + 1) / 2;
*a3 = v4;
result = malloc(4LL * v4);
if ( a2 > 0 )
{
v6 = 0LL;
do
{
*(_DWORD *)(result + 2 * v6) = *(_DWORD *)(a1 + 4 * v6);
v6 += 2LL;
}
while ( a2 > (int)v6 );
}
return result;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBP,RDI
MOV EBX,ESI
LEA EAX,[RSI + 0x1]
MOV EDI,EAX
SHR EDI,0x1f
ADD EDI,EAX
SAR EDI,0x1
MOV dword ptr [RDX],EDI
MOVSXD RDI,EDI
SHL RDI,0x2
CALL 0x001010b0
TEST EBX,EBX
JLE 0x001011ea
MOV EDX,0x0
LAB_001011db:
MOV ECX,dword ptr [RBP + RDX*0x4]
MOV dword ptr [RAX + RDX*0x2],ECX
ADD RDX,0x2
CMP EBX,EDX
JG 0x001011db
LAB_001011ea:
ADD RSP,0x8
POP RBX
POP RBP
RET | void func0(long param_1,int param_2,int *param_3)
{
void *pvVar1;
long lVar2;
int iVar3;
iVar3 = (param_2 + 1) / 2;
*param_3 = iVar3;
pvVar1 = malloc((long)iVar3 << 2);
if (0 < param_2) {
lVar2 = 0;
do {
*(int4 *)((long)pvVar1 + lVar2 * 2) = *(int4 *)(param_1 + lVar2 * 4);
lVar2 = lVar2 + 2;
} while ((int)lVar2 < param_2);
}
return;
} |
6,766 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
| int* func0(int* list1, int length, int* result_size) {
*result_size = (length + 1) / 2; // calculate size of the result array
int* result = (int *)malloc(*result_size * sizeof(int));
// Iterate taking every second element
int j = 0;
for (int i = 0; i < length; i += 2) {
result[j++] = list1[i];
}
return result;
}
| int main() {
int list1[] = {2, 0, 3, 4, 0, 2, 8, 3, 4, 2};
int list1_size = 10;
int* result1;
int result1_size;
result1 = func0(list1, list1_size, &result1_size);
int expected_result1[] = {2, 3, 0, 8, 4};
assert(result1_size == 5);
for (int i = 0; i < result1_size; i++) {
assert(result1[i] == expected_result1[i]);
}
int list2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int list2_size = 10;
int* result2;
int result2_size;
result2 = func0(list2, list2_size, &result2_size);
int expected_result2[] = {1, 3, 5, 7, 9};
assert(result2_size == 5);
for (int i = 0; i < result2_size; i++) {
assert(result2[i] == expected_result2[i]);
}
free(result1); // free allocated memory
free(result2);
return 0;
}
| O2 | c | func0:
endbr64
lea 0x1(%rsi),%eax
push %rbp
mov %rdi,%rbp
mov %eax,%edi
push %rbx
mov %esi,%ebx
shr $0x1f,%edi
add %eax,%edi
sar %edi
sub $0x8,%rsp
mov %edi,(%rdx)
movslq %edi,%rdi
shl $0x2,%rdi
callq 10b0 <malloc@plt>
test %ebx,%ebx
jle 142f <func0+0x3f>
xor %edx,%edx
mov 0x0(%rbp,%rdx,4),%ecx
mov %ecx,(%rax,%rdx,2)
add $0x2,%rdx
cmp %edx,%ebx
jg 1420 <func0+0x30>
add $0x8,%rsp
pop %rbx
pop %rbp
retq
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
lea eax, [rsi+1]
push rbp
mov rbp, rdi
mov edi, eax
push rbx
mov ebx, esi
shr edi, 1Fh
add edi, eax
sar edi, 1
sub rsp, 8
mov [rdx], edi
movsxd rdi, edi
shl rdi, 2
call _malloc
test ebx, ebx
jle short loc_142F
xor edx, edx
nop
loc_1420:
mov ecx, [rbp+rdx*4+0]
mov [rax+rdx*2], ecx
add rdx, 2
cmp ebx, edx
jg short loc_1420
loc_142F:
add rsp, 8
pop rbx
pop rbp
retn | long long func0(long long a1, int a2, int *a3)
{
int v4; // edi
long long result; // rax
long long v6; // rdx
v4 = (a2 + 1) / 2;
*a3 = v4;
result = malloc(4LL * v4);
if ( a2 > 0 )
{
v6 = 0LL;
do
{
*(_DWORD *)(result + 2 * v6) = *(_DWORD *)(a1 + 4 * v6);
v6 += 2LL;
}
while ( a2 > (int)v6 );
}
return result;
} | func0:
ENDBR64
LEA EAX,[RSI + 0x1]
PUSH RBP
MOV RBP,RDI
MOV EDI,EAX
PUSH RBX
MOV EBX,ESI
SHR EDI,0x1f
ADD EDI,EAX
SAR EDI,0x1
SUB RSP,0x8
MOV dword ptr [RDX],EDI
MOVSXD RDI,EDI
SHL RDI,0x2
CALL 0x001010b0
TEST EBX,EBX
JLE 0x0010142f
XOR EDX,EDX
NOP
LAB_00101420:
MOV ECX,dword ptr [RBP + RDX*0x4]
MOV dword ptr [RAX + RDX*0x2],ECX
ADD RDX,0x2
CMP EBX,EDX
JG 0x00101420
LAB_0010142f:
ADD RSP,0x8
POP RBX
POP RBP
RET | void func0(long param_1,int param_2,int *param_3)
{
void *pvVar1;
long lVar2;
int iVar3;
iVar3 = (param_2 + 1) / 2;
*param_3 = iVar3;
pvVar1 = malloc((long)iVar3 << 2);
if (0 < param_2) {
lVar2 = 0;
do {
*(int4 *)((long)pvVar1 + lVar2 * 2) = *(int4 *)(param_1 + lVar2 * 4);
lVar2 = lVar2 + 2;
} while ((int)lVar2 < param_2);
}
return;
} |
6,767 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
| int* func0(int* list1, int length, int* result_size) {
*result_size = (length + 1) / 2; // calculate size of the result array
int* result = (int *)malloc(*result_size * sizeof(int));
// Iterate taking every second element
int j = 0;
for (int i = 0; i < length; i += 2) {
result[j++] = list1[i];
}
return result;
}
| int main() {
int list1[] = {2, 0, 3, 4, 0, 2, 8, 3, 4, 2};
int list1_size = 10;
int* result1;
int result1_size;
result1 = func0(list1, list1_size, &result1_size);
int expected_result1[] = {2, 3, 0, 8, 4};
assert(result1_size == 5);
for (int i = 0; i < result1_size; i++) {
assert(result1[i] == expected_result1[i]);
}
int list2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int list2_size = 10;
int* result2;
int result2_size;
result2 = func0(list2, list2_size, &result2_size);
int expected_result2[] = {1, 3, 5, 7, 9};
assert(result2_size == 5);
for (int i = 0; i < result2_size; i++) {
assert(result2[i] == expected_result2[i]);
}
free(result1); // free allocated memory
free(result2);
return 0;
}
| O3 | c | func0:
endbr64
lea 0x1(%rsi),%eax
push %rbp
mov %esi,%ebp
push %rbx
mov %rdi,%rbx
mov %eax,%edi
shr $0x1f,%edi
add %eax,%edi
sar %edi
sub $0x8,%rsp
mov %edi,(%rdx)
movslq %edi,%rdi
shl $0x2,%rdi
callq 10b0 <malloc@plt>
test %ebp,%ebp
jle 148d <func0+0xcd>
lea -0x1(%rbp),%edx
cmp $0x7,%edx
jbe 1494 <func0+0xd4>
mov %edx,%esi
xor %edx,%edx
shr $0x3,%esi
mov %esi,%ecx
shl $0x4,%rcx
nopw 0x0(%rax,%rax,1)
movdqu (%rbx,%rdx,2),%xmm0
movdqu 0x10(%rbx,%rdx,2),%xmm1
shufps $0x88,%xmm1,%xmm0
movups %xmm0,(%rax,%rdx,1)
add $0x10,%rdx
cmp %rcx,%rdx
jne 1410 <func0+0x50>
lea 0x0(,%rsi,4),%ecx
lea 0x0(,%rsi,8),%edx
movslq %edx,%r8
movslq %ecx,%rsi
lea 0x1(%rcx),%edi
mov (%rbx,%r8,4),%r8d
mov %r8d,(%rax,%rsi,4)
lea 0x2(%rdx),%esi
cmp %esi,%ebp
jle 148d <func0+0xcd>
movslq %esi,%rsi
movslq %edi,%rdi
add $0x2,%ecx
mov (%rbx,%rsi,4),%esi
mov %esi,(%rax,%rdi,4)
lea 0x4(%rdx),%esi
cmp %esi,%ebp
jle 148d <func0+0xcd>
movslq %esi,%rsi
movslq %ecx,%rcx
add $0x6,%edx
mov (%rbx,%rsi,4),%esi
lea 0x0(,%rcx,4),%rdi
mov %esi,(%rax,%rcx,4)
cmp %edx,%ebp
jle 148d <func0+0xcd>
movslq %edx,%rdx
mov (%rbx,%rdx,4),%edx
mov %edx,0x4(%rax,%rdi,1)
add $0x8,%rsp
pop %rbx
pop %rbp
retq
xor %edx,%edx
xor %ecx,%ecx
jmp 143a <func0+0x7a>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
lea eax, [rsi+1]
push rbp
mov ebp, esi
push rbx
mov rbx, rdi
mov edi, eax
shr edi, 1Fh
add edi, eax
sar edi, 1
sub rsp, 8
mov [rdx], edi
movsxd rdi, edi
shl rdi, 2; size
call _malloc
mov rdx, rax
test ebp, ebp
jle loc_1425
lea eax, [rbp-1]
cmp eax, 7
jbe loc_142F
shr eax, 3
mov esi, eax
xor eax, eax
mov rcx, rsi
shl rsi, 4
xchg ax, ax
loc_13B0:
movdqu xmm0, xmmword ptr [rbx+rax*2]
movdqu xmm1, xmmword ptr [rbx+rax*2+10h]
shufps xmm0, xmm1, 88h
movups xmmword ptr [rdx+rax], xmm0
add rax, 10h
cmp rsi, rax
jnz short loc_13B0
lea esi, ds:0[rcx*4]
lea eax, ds:0[rcx*8]
loc_13DA:
movsxd r8, eax
movsxd rcx, esi
lea rdi, ds:0[r8*4]
mov r8d, [rbx+r8*4]
lea rsi, ds:0[rcx*4]
mov [rdx+rcx*4], r8d
lea ecx, [rax+2]
cmp ebp, ecx
jle short loc_1425
mov ecx, [rbx+rdi+8]
mov [rdx+rsi+4], ecx
lea ecx, [rax+4]
cmp ebp, ecx
jle short loc_1425
mov ecx, [rbx+rdi+10h]
add eax, 6
mov [rdx+rsi+8], ecx
cmp ebp, eax
jle short loc_1425
mov eax, [rbx+rdi+18h]
mov [rdx+rsi+0Ch], eax
loc_1425:
add rsp, 8
mov rax, rdx
pop rbx
pop rbp
retn
loc_142F:
xor eax, eax
xor esi, esi
jmp short loc_13DA | char * func0(long long a1, int a2, int *a3)
{
int v5; // edi
char *v6; // rdx
long long v7; // rax
unsigned int v8; // ecx
int v9; // esi
int v10; // eax
long long v11; // rdi
long long v12; // rsi
v5 = (a2 + 1) / 2;
*a3 = v5;
v6 = (char *)malloc(4LL * v5);
if ( a2 > 0 )
{
if ( (unsigned int)(a2 - 1) <= 7 )
{
v10 = 0;
v9 = 0;
}
else
{
v7 = 0LL;
v8 = (unsigned int)(a2 - 1) >> 3;
do
{
*(__m128 *)&v6[v7] = _mm_shuffle_ps(
(__m128)_mm_loadu_si128((const __m128i *)(a1 + 2 * v7)),
(__m128)_mm_loadu_si128((const __m128i *)(a1 + 2 * v7 + 16)),
136);
v7 += 16LL;
}
while ( 16LL * ((unsigned int)(a2 - 1) >> 3) != v7 );
v9 = 4 * v8;
v10 = 8 * v8;
}
v11 = 4LL * v10;
v12 = 4LL * v9;
*(_DWORD *)&v6[v12] = *(_DWORD *)(a1 + v11);
if ( a2 > v10 + 2 )
{
*(_DWORD *)&v6[v12 + 4] = *(_DWORD *)(a1 + v11 + 8);
if ( a2 > v10 + 4 )
{
*(_DWORD *)&v6[v12 + 8] = *(_DWORD *)(a1 + v11 + 16);
if ( a2 > v10 + 6 )
*(_DWORD *)&v6[v12 + 12] = *(_DWORD *)(a1 + v11 + 24);
}
}
}
return v6;
} | func0:
ENDBR64
LEA EAX,[RSI + 0x1]
PUSH RBP
MOV EBP,ESI
PUSH RBX
MOV RBX,RDI
MOV EDI,EAX
SHR EDI,0x1f
ADD EDI,EAX
SAR EDI,0x1
SUB RSP,0x8
MOV dword ptr [RDX],EDI
MOVSXD RDI,EDI
SHL RDI,0x2
CALL 0x001010b0
MOV RDX,RAX
TEST EBP,EBP
JLE 0x00101425
LEA EAX,[RBP + -0x1]
CMP EAX,0x7
JBE 0x0010142f
SHR EAX,0x3
MOV ESI,EAX
XOR EAX,EAX
MOV RCX,RSI
SHL RSI,0x4
NOP
LAB_001013b0:
MOVDQU XMM0,xmmword ptr [RBX + RAX*0x2]
MOVDQU XMM1,xmmword ptr [RBX + RAX*0x2 + 0x10]
SHUFPS XMM0,XMM1,0x88
MOVUPS xmmword ptr [RDX + RAX*0x1],XMM0
ADD RAX,0x10
CMP RSI,RAX
JNZ 0x001013b0
LEA ESI,[RCX*0x4]
LEA EAX,[RCX*0x8]
LAB_001013da:
MOVSXD R8,EAX
MOVSXD RCX,ESI
LEA RDI,[R8*0x4]
MOV R8D,dword ptr [RBX + R8*0x4]
LEA RSI,[RCX*0x4]
MOV dword ptr [RDX + RCX*0x4],R8D
LEA ECX,[RAX + 0x2]
CMP EBP,ECX
JLE 0x00101425
MOV ECX,dword ptr [RBX + RDI*0x1 + 0x8]
MOV dword ptr [RDX + RSI*0x1 + 0x4],ECX
LEA ECX,[RAX + 0x4]
CMP EBP,ECX
JLE 0x00101425
MOV ECX,dword ptr [RBX + RDI*0x1 + 0x10]
ADD EAX,0x6
MOV dword ptr [RDX + RSI*0x1 + 0x8],ECX
CMP EBP,EAX
JLE 0x00101425
MOV EAX,dword ptr [RBX + RDI*0x1 + 0x18]
MOV dword ptr [RDX + RSI*0x1 + 0xc],EAX
LAB_00101425:
ADD RSP,0x8
MOV RAX,RDX
POP RBX
POP RBP
RET
LAB_0010142f:
XOR EAX,EAX
XOR ESI,ESI
JMP 0x001013da | void * func0(long param_1,int param_2,int *param_3)
{
int4 *puVar1;
long lVar2;
int4 *puVar3;
int4 uVar4;
int4 uVar5;
int4 uVar6;
uint uVar7;
void *pvVar8;
long lVar9;
int iVar10;
int iVar11;
iVar11 = (param_2 + 1) / 2;
*param_3 = iVar11;
pvVar8 = malloc((long)iVar11 << 2);
if (0 < param_2) {
if (param_2 - 1U < 8) {
iVar11 = 0;
iVar10 = 0;
}
else {
uVar7 = param_2 - 1U >> 3;
lVar9 = 0;
do {
puVar1 = (int4 *)(param_1 + lVar9 * 2);
uVar4 = puVar1[2];
puVar3 = (int4 *)(param_1 + 0x10 + lVar9 * 2);
uVar5 = *puVar3;
uVar6 = puVar3[2];
puVar3 = (int4 *)((long)pvVar8 + lVar9);
*puVar3 = *puVar1;
puVar3[1] = uVar4;
puVar3[2] = uVar5;
puVar3[3] = uVar6;
lVar9 = lVar9 + 0x10;
} while ((ulong)uVar7 << 4 != lVar9);
iVar10 = uVar7 * 4;
iVar11 = uVar7 * 8;
}
lVar9 = (long)iVar11 * 4;
lVar2 = (long)iVar10 * 4;
*(int4 *)((long)pvVar8 + (long)iVar10 * 4) = *(int4 *)(param_1 + (long)iVar11 * 4);
if (((iVar11 + 2 < param_2) &&
(*(int4 *)((long)pvVar8 + lVar2 + 4) = *(int4 *)(param_1 + 8 + lVar9),
iVar11 + 4 < param_2)) &&
(*(int4 *)((long)pvVar8 + lVar2 + 8) = *(int4 *)(param_1 + 0x10 + lVar9),
iVar11 + 6 < param_2)) {
*(int4 *)((long)pvVar8 + lVar2 + 0xc) = *(int4 *)(param_1 + 0x18 + lVar9);
}
}
return pvVar8;
} |
6,768 | func0 |
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <assert.h>
| const char* func0(const char* text) {
regex_t regex;
int ret;
const char* patterns = "ab*?";
ret = regcomp(®ex, patterns, REG_EXTENDED);
if (ret) {
return "Regex compilation failed";
}
ret = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if (!ret) {
return "Found a match!";
} else {
return "Not matched!";
}
}
| int main() {
assert(strcmp(func0("ac"), "Found a match!") == 0);
assert(strcmp(func0("dc"), "Not matched!") == 0);
assert(strcmp(func0("abba"), "Found a match!") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x70,%rsp
mov %rdi,-0x68(%rbp)
mov %fs:0x28,%rax
mov %rax,-0x8(%rbp)
xor %eax,%eax
lea 0xdf9(%rip),%rax
mov %rax,-0x58(%rbp)
mov -0x58(%rbp),%rcx
lea -0x50(%rbp),%rax
mov $0x1,%edx
mov %rcx,%rsi
mov %rax,%rdi
callq 10d0 <regcomp@plt>
mov %eax,-0x5c(%rbp)
cmpl $0x0,-0x5c(%rbp)
je 123d <func0+0x54>
lea 0xdd2(%rip),%rax
jmp 1282 <func0+0x99>
mov -0x68(%rbp),%rsi
lea -0x50(%rbp),%rax
mov $0x0,%r8d
mov $0x0,%ecx
mov $0x0,%edx
mov %rax,%rdi
callq 10f0 <regexec@plt>
mov %eax,-0x5c(%rbp)
lea -0x50(%rbp),%rax
mov %rax,%rdi
callq 10a0 <regfree@plt>
cmpl $0x0,-0x5c(%rbp)
jne 127b <func0+0x92>
lea 0xdad(%rip),%rax
jmp 1282 <func0+0x99>
lea 0xdb3(%rip),%rax
mov -0x8(%rbp),%rdx
xor %fs:0x28,%rdx
je 1296 <func0+0xad>
callq 10b0 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 70h
mov [rbp+string], rdi
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
lea rax, aAb; "ab*?"
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+var_5C], eax
cmp [rbp+var_5C], 0
jz short loc_123D
lea rax, aRegexCompilati; "Regex compilation failed"
jmp short loc_1282
loc_123D:
mov rsi, [rbp+string]; string
lea rax, [rbp+preg]
mov r8d, 0; eflags
mov ecx, 0; pmatch
mov edx, 0; nmatch
mov rdi, rax; preg
call _regexec
mov [rbp+var_5C], eax
lea rax, [rbp+preg]
mov rdi, rax; preg
call _regfree
cmp [rbp+var_5C], 0
jnz short loc_127B
lea rax, s2; "Found a match!"
jmp short loc_1282
loc_127B:
lea rax, aNotMatched; "Not matched!"
loc_1282:
mov rdx, [rbp+var_8]
sub rdx, fs:28h
jz short locret_1296
call ___stack_chk_fail
locret_1296:
leave
retn | const char * func0(const char *a1)
{
int v2; // [rsp+14h] [rbp-5Ch]
regex_t preg; // [rsp+20h] [rbp-50h] BYREF
unsigned long long v4; // [rsp+68h] [rbp-8h]
v4 = __readfsqword(0x28u);
if ( regcomp(&preg, "ab*?", 1) )
return "Regex compilation failed";
v2 = regexec(&preg, a1, 0LL, 0LL, 0);
regfree(&preg);
if ( v2 )
return "Not matched!";
else
return "Found a match!";
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x70
MOV qword ptr [RBP + -0x68],RDI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RBP + -0x8],RAX
XOR EAX,EAX
LEA RAX,[0x102008]
MOV qword ptr [RBP + -0x58],RAX
MOV RCX,qword ptr [RBP + -0x58]
LEA RAX,[RBP + -0x50]
MOV EDX,0x1
MOV RSI,RCX
MOV RDI,RAX
CALL 0x001010d0
MOV dword ptr [RBP + -0x5c],EAX
CMP dword ptr [RBP + -0x5c],0x0
JZ 0x0010123d
LEA RAX,[0x10200d]
JMP 0x00101282
LAB_0010123d:
MOV RSI,qword ptr [RBP + -0x68]
LEA RAX,[RBP + -0x50]
MOV R8D,0x0
MOV ECX,0x0
MOV EDX,0x0
MOV RDI,RAX
CALL 0x001010f0
MOV dword ptr [RBP + -0x5c],EAX
LEA RAX,[RBP + -0x50]
MOV RDI,RAX
CALL 0x001010a0
CMP dword ptr [RBP + -0x5c],0x0
JNZ 0x0010127b
LEA RAX,[0x102026]
JMP 0x00101282
LAB_0010127b:
LEA RAX,[0x102035]
LAB_00101282:
MOV RDX,qword ptr [RBP + -0x8]
SUB RDX,qword ptr FS:[0x28]
JZ 0x00101296
CALL 0x001010b0
LAB_00101296:
LEAVE
RET | char * func0(char *param_1)
{
int iVar1;
char *pcVar2;
long in_FS_OFFSET;
regex_t local_58;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
iVar1 = regcomp(&local_58,"ab*?",1);
if (iVar1 == 0) {
iVar1 = regexec(&local_58,param_1,0,(regmatch_t *)0x0,0);
regfree(&local_58);
if (iVar1 == 0) {
pcVar2 = "Found a match!";
}
else {
pcVar2 = "Not matched!";
}
}
else {
pcVar2 = "Regex compilation failed";
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return pcVar2;
} |
6,769 | func0 |
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <assert.h>
| const char* func0(const char* text) {
regex_t regex;
int ret;
const char* patterns = "ab*?";
ret = regcomp(®ex, patterns, REG_EXTENDED);
if (ret) {
return "Regex compilation failed";
}
ret = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if (!ret) {
return "Found a match!";
} else {
return "Not matched!";
}
}
| int main() {
assert(strcmp(func0("ac"), "Found a match!") == 0);
assert(strcmp(func0("dc"), "Not matched!") == 0);
assert(strcmp(func0("abba"), "Found a match!") == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x58,%rsp
mov %rdi,%rbx
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%rdi
mov $0x1,%edx
lea 0xe44(%rip),%rsi
callq 10c0 <regcomp@plt>
mov %eax,%edx
lea 0xe01(%rip),%rax
test %edx,%edx
je 121e <func0+0x55>
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 125c <func0+0x93>
add $0x58,%rsp
pop %rbx
pop %rbp
retq
mov %rsp,%rbp
mov $0x0,%r8d
mov $0x0,%ecx
mov $0x0,%edx
mov %rbx,%rsi
mov %rbp,%rdi
callq 10d0 <regexec@plt>
mov %eax,%ebx
mov %rbp,%rdi
callq 1090 <regfree@plt>
test %ebx,%ebx
lea 0xdce(%rip),%rax
lea 0xdd6(%rip),%rdx
cmovne %rdx,%rax
jmp 1207 <func0+0x3e>
callq 10a0 <__stack_chk_fail@plt>
| func0:
endbr64
push rbp
push rbx
sub rsp, 58h
mov rbx, rdi
mov rax, fs:28h
mov [rsp+68h+var_20], rax
xor eax, eax
mov rdi, rsp
mov edx, 1
lea rsi, aAb; "ab*?"
call _regcomp
mov edx, eax
lea rax, aRegexCompilati; "Regex compilation failed"
test edx, edx
jz short loc_123E
loc_1227:
mov rdx, [rsp+68h+var_20]
sub rdx, fs:28h
jnz short loc_127C
add rsp, 58h
pop rbx
pop rbp
retn
loc_123E:
mov rbp, rsp
mov r8d, 0
mov ecx, 0
mov edx, 0
mov rsi, rbx
mov rdi, rbp
call _regexec
mov ebx, eax
mov rdi, rbp
call _regfree
test ebx, ebx
lea rax, aFoundAMatch; "Found a match!"
lea rdx, aNotMatched; "Not matched!"
cmovnz rax, rdx
jmp short loc_1227
loc_127C:
call ___stack_chk_fail | const char * func0(long long a1)
{
int v1; // edx
const char *result; // rax
int v3; // ebx
_QWORD v4[13]; // [rsp+0h] [rbp-68h] BYREF
v4[9] = __readfsqword(0x28u);
v1 = regcomp(v4, "ab*?", 1LL);
result = "Regex compilation failed";
if ( !v1 )
{
v3 = regexec(v4, a1, 0LL, 0LL, 0LL);
regfree(v4);
result = "Found a match!";
if ( v3 )
return "Not matched!";
}
return result;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x58
MOV RBX,RDI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV EDX,0x1
LEA RSI,[0x102039]
CALL 0x001010d0
MOV EDX,EAX
LEA RAX,[0x102004]
TEST EDX,EDX
JZ 0x0010123e
LAB_00101227:
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x0010127c
ADD RSP,0x58
POP RBX
POP RBP
RET
LAB_0010123e:
MOV RBP,RSP
MOV R8D,0x0
MOV ECX,0x0
MOV EDX,0x0
MOV RSI,RBX
MOV RDI,RBP
CALL 0x001010f0
MOV EBX,EAX
MOV RDI,RBP
CALL 0x001010a0
TEST EBX,EBX
LEA RAX,[0x10201d]
LEA RDX,[0x10202c]
CMOVNZ RAX,RDX
JMP 0x00101227
LAB_0010127c:
CALL 0x001010b0 | char * func0(char *param_1)
{
int iVar1;
char *pcVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
iVar1 = regcomp(&rStack_68,"ab*?",1);
pcVar2 = "Regex compilation failed";
if (iVar1 == 0) {
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
pcVar2 = "Found a match!";
if (iVar1 != 0) {
pcVar2 = "Not matched!";
}
}
if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return pcVar2;
} |
6,770 | func0 |
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <assert.h>
| const char* func0(const char* text) {
regex_t regex;
int ret;
const char* patterns = "ab*?";
ret = regcomp(®ex, patterns, REG_EXTENDED);
if (ret) {
return "Regex compilation failed";
}
ret = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if (!ret) {
return "Found a match!";
} else {
return "Not matched!";
}
}
| int main() {
assert(strcmp(func0("ac"), "Found a match!") == 0);
assert(strcmp(func0("dc"), "Not matched!") == 0);
assert(strcmp(func0("abba"), "Found a match!") == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
mov $0x1,%edx
lea 0xd77(%rip),%rsi
push %rbp
mov %rdi,%rbp
sub $0x58,%rsp
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%r12
mov %r12,%rdi
callq 10c0 <regcomp@plt>
mov %eax,%r8d
lea 0xd15(%rip),%rax
test %r8d,%r8d
jne 1321 <func0+0x71>
xor %edx,%edx
xor %ecx,%ecx
mov %rbp,%rsi
mov %r12,%rdi
callq 10d0 <regexec@plt>
mov %r12,%rdi
mov %eax,%ebp
callq 1090 <regfree@plt>
test %ebp,%ebp
lea 0xd07(%rip),%rax
lea 0xd0f(%rip),%rdx
cmovne %rdx,%rax
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 1339 <func0+0x89>
add $0x58,%rsp
pop %rbp
pop %r12
retq
callq 10a0 <__stack_chk_fail@plt>
xchg %ax,%ax
| func0:
endbr64
push r12
mov edx, 1
lea rsi, aAb; "ab*?"
push rbp
mov rbp, rdi
sub rsp, 58h
mov rax, fs:28h
mov [rsp+68h+var_20], rax
xor eax, eax
mov r12, rsp
mov rdi, r12
call _regcomp
mov r8d, eax
lea rax, aRegexCompilati; "Regex compilation failed"
test r8d, r8d
jnz short loc_1331
xor edx, edx
xor ecx, ecx
mov rsi, rbp
mov rdi, r12
call _regexec
mov rdi, r12
mov ebp, eax
call _regfree
test ebp, ebp
lea rax, aFoundAMatch; "Found a match!"
lea rdx, aNotMatched; "Not matched!"
cmovnz rax, rdx
loc_1331:
mov rdx, [rsp+68h+var_20]
sub rdx, fs:28h
jnz short loc_1349
add rsp, 58h
pop rbp
pop r12
retn
loc_1349:
call ___stack_chk_fail | const char * func0(long long a1)
{
int v1; // r8d
const char *result; // rax
int v3; // ebp
_QWORD v4[13]; // [rsp+0h] [rbp-68h] BYREF
v4[9] = __readfsqword(0x28u);
v1 = regcomp(v4, "ab*?", 1LL);
result = "Regex compilation failed";
if ( !v1 )
{
v3 = regexec(v4, a1, 0LL, 0LL);
regfree(v4);
result = "Found a match!";
if ( v3 )
return "Not matched!";
}
return result;
} | func0:
ENDBR64
PUSH R12
MOV EDX,0x1
LEA RSI,[0x102039]
PUSH RBP
MOV RBP,RDI
SUB RSP,0x58
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
MOV R12,RSP
MOV RDI,R12
CALL 0x001010d0
MOV R8D,EAX
LEA RAX,[0x102004]
TEST R8D,R8D
JNZ 0x00101331
XOR EDX,EDX
XOR ECX,ECX
MOV RSI,RBP
MOV RDI,R12
CALL 0x001010f0
MOV RDI,R12
MOV EBP,EAX
CALL 0x001010a0
TEST EBP,EBP
LEA RAX,[0x10201d]
LEA RDX,[0x10202c]
CMOVNZ RAX,RDX
LAB_00101331:
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x00101349
ADD RSP,0x58
POP RBP
POP R12
RET
LAB_00101349:
CALL 0x001010b0 | char * func0(char *param_1)
{
int iVar1;
char *pcVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
iVar1 = regcomp(&rStack_68,"ab*?",1);
pcVar2 = "Regex compilation failed";
if (iVar1 == 0) {
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
pcVar2 = "Found a match!";
if (iVar1 != 0) {
pcVar2 = "Not matched!";
}
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return pcVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,771 | func0 |
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <assert.h>
| const char* func0(const char* text) {
regex_t regex;
int ret;
const char* patterns = "ab*?";
ret = regcomp(®ex, patterns, REG_EXTENDED);
if (ret) {
return "Regex compilation failed";
}
ret = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if (!ret) {
return "Found a match!";
} else {
return "Not matched!";
}
}
| int main() {
assert(strcmp(func0("ac"), "Found a match!") == 0);
assert(strcmp(func0("dc"), "Not matched!") == 0);
assert(strcmp(func0("abba"), "Found a match!") == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
mov $0x1,%edx
lea 0xd77(%rip),%rsi
push %rbp
mov %rdi,%rbp
sub $0x58,%rsp
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%r12
mov %r12,%rdi
callq 10c0 <regcomp@plt>
mov %eax,%r8d
lea 0xd15(%rip),%rax
test %r8d,%r8d
jne 1321 <func0+0x71>
xor %edx,%edx
xor %ecx,%ecx
mov %rbp,%rsi
mov %r12,%rdi
callq 10d0 <regexec@plt>
mov %r12,%rdi
mov %eax,%ebp
callq 1090 <regfree@plt>
test %ebp,%ebp
lea 0xd07(%rip),%rax
lea 0xd0f(%rip),%rdx
cmovne %rdx,%rax
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 1339 <func0+0x89>
add $0x58,%rsp
pop %rbp
pop %r12
retq
callq 10a0 <__stack_chk_fail@plt>
xchg %ax,%ax
| func0:
endbr64
push rbp
mov edx, 1; cflags
lea rsi, pattern; "ab*?"
push rbx
mov rbx, rdi
sub rsp, 58h
mov rax, fs:28h
mov [rsp+var_s48], rax
xor eax, eax
mov rbp, rsp
mov rdi, rbp; preg
call _regcomp
mov edx, eax
lea rax, aRegexCompilati; "Regex compilation failed"
test edx, edx
jnz short loc_1331
xor edx, edx; nmatch
xor r8d, r8d; eflags
xor ecx, ecx; pmatch
mov rsi, rbx; string
mov rdi, rbp; preg
call _regexec
mov rdi, rbp; preg
mov ebx, eax
call _regfree
test ebx, ebx
lea rax, aNotMatched; "Not matched!"
lea rdx, s2; "Found a match!"
cmovz rax, rdx
loc_1331:
mov rdx, [rsp+var_s48]
sub rdx, fs:28h
jnz short loc_1348
add rsp, 58h
pop rbx
pop rbp
retn
loc_1348:
call ___stack_chk_fail | const char * func0(char *string)
{
int v1; // edx
const char *result; // rax
int v3; // ebx
regex_t _0; // [rsp+0h] [rbp+0h] BYREF
unsigned long long vars48; // [rsp+48h] [rbp+48h]
vars48 = __readfsqword(0x28u);
v1 = regcomp(&_0, "ab*?", 1);
result = "Regex compilation failed";
if ( !v1 )
{
v3 = regexec(&_0, string, 0LL, 0LL, 0);
regfree(&_0);
result = "Not matched!";
if ( !v3 )
return "Found a match!";
}
return result;
} | func0:
ENDBR64
PUSH RBP
MOV EDX,0x1
LEA RSI,[0x102039]
PUSH RBX
MOV RBX,RDI
SUB RSP,0x58
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
MOV RBP,RSP
MOV RDI,RBP
CALL 0x001010d0
MOV EDX,EAX
LEA RAX,[0x102004]
TEST EDX,EDX
JNZ 0x00101331
XOR EDX,EDX
XOR R8D,R8D
XOR ECX,ECX
MOV RSI,RBX
MOV RDI,RBP
CALL 0x001010f0
MOV RDI,RBP
MOV EBX,EAX
CALL 0x001010a0
TEST EBX,EBX
LEA RAX,[0x10202c]
LEA RDX,[0x10201d]
CMOVZ RAX,RDX
LAB_00101331:
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x00101348
ADD RSP,0x58
POP RBX
POP RBP
RET
LAB_00101348:
CALL 0x001010b0 | char * func0(char *param_1)
{
int iVar1;
char *pcVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
iVar1 = regcomp(&rStack_68,"ab*?",1);
pcVar2 = "Regex compilation failed";
if (iVar1 == 0) {
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
pcVar2 = "Not matched!";
if (iVar1 == 0) {
pcVar2 = "Found a match!";
}
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return pcVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
6,772 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
const char* key;
int value;
} KeyValuePair;
typedef struct {
KeyValuePair* pairs;
int size;
} Dictionary;
typedef struct {
int* elements;
int size;
Dictionary* dict;
} Tuple;
| Tuple* func0(Tuple* test_tup, Dictionary* test_dict) {
int new_size = test_tup->size + 1;
Tuple* new_tuple = malloc(sizeof(Tuple));
new_tuple->elements = malloc(new_size * sizeof(int));
for (int i = 0; i < test_tup->size; i++) {
new_tuple->elements[i] = test_tup->elements[i];
}
new_tuple->elements[test_tup->size] = -1; // Placeholder since we cannot store dict in int array
new_tuple->size = new_size;
new_tuple->dict = test_dict;
return new_tuple;
}
| int main() {
int arr1[3] = {4, 5, 6};
KeyValuePair pairs1[3] = {{"MSAM", 1}, {"is", 2}, {"best", 3}};
Dictionary dict1 = {pairs1, 3};
Tuple tup1 = {arr1, 3, NULL};
Tuple* res_tup1 = func0(&tup1, &dict1);
assert(res_tup1->size == 4);
assert(res_tup1->elements[0] == 4);
assert(res_tup1->elements[1] == 5);
assert(res_tup1->elements[2] == 6);
assert(res_tup1->elements[3] == -1);
assert(res_tup1->dict->size == 3);
int arr2[3] = {1, 2, 3};
KeyValuePair pairs2[3] = {{"UTS", 2}, {"is", 3}, {"Worst", 4}};
Dictionary dict2 = {pairs2, 3};
Tuple tup2 = {arr2, 3, NULL};
Tuple* res_tup2 = func0(&tup2, &dict2);
assert(res_tup2->size == 4);
assert(res_tup2->elements[0] == 1);
assert(res_tup2->elements[1] == 2);
assert(res_tup2->elements[2] == 3);
assert(res_tup2->elements[3] == -1);
assert(res_tup2->dict->size == 3);
int arr3[3] = {8, 9, 10};
KeyValuePair pairs3[3] = {{"POS", 3}, {"is", 4}, {"Okay", 5}};
Dictionary dict3 = {pairs3, 3};
Tuple tup3 = {arr3, 3, NULL};
Tuple* res_tup3 = func0(&tup3, &dict3);
assert(res_tup3->size == 4);
assert(res_tup3->elements[0] == 8);
assert(res_tup3->elements[1] == 9);
assert(res_tup3->elements[2] == 10);
assert(res_tup3->elements[3] == -1);
assert(res_tup3->dict->size == 3);
printf("All tests passed successfully!\n");
free(res_tup1->elements);
free(res_tup1);
free(res_tup2->elements);
free(res_tup2);
free(res_tup3->elements);
free(res_tup3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
mov -0x18(%rbp),%rax
mov 0x8(%rax),%eax
add $0x1,%eax
mov %eax,-0xc(%rbp)
mov $0x18,%edi
callq 10d0 <malloc@plt>
mov %rax,-0x8(%rbp)
mov -0xc(%rbp),%eax
cltq
shl $0x2,%rax
mov %rax,%rdi
callq 10d0 <malloc@plt>
mov %rax,%rdx
mov -0x8(%rbp),%rax
mov %rdx,(%rax)
movl $0x0,-0x10(%rbp)
jmp 124d <func0+0x84>
mov -0x18(%rbp),%rax
mov (%rax),%rax
mov -0x10(%rbp),%edx
movslq %edx,%rdx
shl $0x2,%rdx
lea (%rax,%rdx,1),%rcx
mov -0x8(%rbp),%rax
mov (%rax),%rax
mov -0x10(%rbp),%edx
movslq %edx,%rdx
shl $0x2,%rdx
add %rax,%rdx
mov (%rcx),%eax
mov %eax,(%rdx)
addl $0x1,-0x10(%rbp)
mov -0x18(%rbp),%rax
mov 0x8(%rax),%eax
cmp %eax,-0x10(%rbp)
jl 121c <func0+0x53>
mov -0x8(%rbp),%rax
mov (%rax),%rdx
mov -0x18(%rbp),%rax
mov 0x8(%rax),%eax
cltq
shl $0x2,%rax
add %rdx,%rax
movl $0xffffffff,(%rax)
mov -0x8(%rbp),%rax
mov -0xc(%rbp),%edx
mov %edx,0x8(%rax)
mov -0x8(%rbp),%rax
mov -0x20(%rbp),%rdx
mov %rdx,0x10(%rax)
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+var_18], rdi
mov [rbp+var_20], rsi
mov rax, [rbp+var_18]
mov eax, [rax+8]
add eax, 1
mov [rbp+var_C], eax
mov edi, 18h; size
call _malloc
mov [rbp+var_8], rax
mov eax, [rbp+var_C]
cdqe
shl rax, 2
mov rdi, rax; size
call _malloc
mov rdx, rax
mov rax, [rbp+var_8]
mov [rax], rdx
mov [rbp+var_10], 0
jmp short loc_124D
loc_121C:
mov rax, [rbp+var_18]
mov rax, [rax]
mov edx, [rbp+var_10]
movsxd rdx, edx
shl rdx, 2
lea rcx, [rax+rdx]
mov rax, [rbp+var_8]
mov rax, [rax]
mov edx, [rbp+var_10]
movsxd rdx, edx
shl rdx, 2
add rdx, rax
mov eax, [rcx]
mov [rdx], eax
add [rbp+var_10], 1
loc_124D:
mov rax, [rbp+var_18]
mov eax, [rax+8]
cmp [rbp+var_10], eax
jl short loc_121C
mov rax, [rbp+var_8]
mov rdx, [rax]
mov rax, [rbp+var_18]
mov eax, [rax+8]
cdqe
shl rax, 2
add rax, rdx
mov dword ptr [rax], 0FFFFFFFFh
mov rax, [rbp+var_8]
mov edx, [rbp+var_C]
mov [rax+8], edx
mov rax, [rbp+var_8]
mov rdx, [rbp+var_20]
mov [rax+10h], rdx
mov rax, [rbp+var_8]
leave
retn | _DWORD * func0(long long a1, long long a2)
{
int i; // [rsp+10h] [rbp-10h]
int v4; // [rsp+14h] [rbp-Ch]
_DWORD *v5; // [rsp+18h] [rbp-8h]
v4 = *(_DWORD *)(a1 + 8) + 1;
v5 = malloc(0x18uLL);
*(_QWORD *)v5 = malloc(4LL * v4);
for ( i = 0; i < *(_DWORD *)(a1 + 8); ++i )
*(_DWORD *)(*(_QWORD *)v5 + 4LL * i) = *(_DWORD *)(*(_QWORD *)a1 + 4LL * i);
*(_DWORD *)(*(_QWORD *)v5 + 4LL * *(int *)(a1 + 8)) = -1;
v5[2] = v4;
*((_QWORD *)v5 + 2) = a2;
return v5;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOV qword ptr [RBP + -0x18],RDI
MOV qword ptr [RBP + -0x20],RSI
MOV RAX,qword ptr [RBP + -0x18]
MOV EAX,dword ptr [RAX + 0x8]
ADD EAX,0x1
MOV dword ptr [RBP + -0xc],EAX
MOV EDI,0x18
CALL 0x001010d0
MOV qword ptr [RBP + -0x8],RAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
SHL RAX,0x2
MOV RDI,RAX
CALL 0x001010d0
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x8]
MOV qword ptr [RAX],RDX
MOV dword ptr [RBP + -0x10],0x0
JMP 0x0010124d
LAB_0010121c:
MOV RAX,qword ptr [RBP + -0x18]
MOV RAX,qword ptr [RAX]
MOV EDX,dword ptr [RBP + -0x10]
MOVSXD RDX,EDX
SHL RDX,0x2
LEA RCX,[RAX + RDX*0x1]
MOV RAX,qword ptr [RBP + -0x8]
MOV RAX,qword ptr [RAX]
MOV EDX,dword ptr [RBP + -0x10]
MOVSXD RDX,EDX
SHL RDX,0x2
ADD RDX,RAX
MOV EAX,dword ptr [RCX]
MOV dword ptr [RDX],EAX
ADD dword ptr [RBP + -0x10],0x1
LAB_0010124d:
MOV RAX,qword ptr [RBP + -0x18]
MOV EAX,dword ptr [RAX + 0x8]
CMP dword ptr [RBP + -0x10],EAX
JL 0x0010121c
MOV RAX,qword ptr [RBP + -0x8]
MOV RDX,qword ptr [RAX]
MOV RAX,qword ptr [RBP + -0x18]
MOV EAX,dword ptr [RAX + 0x8]
CDQE
SHL RAX,0x2
ADD RAX,RDX
MOV dword ptr [RAX],0xffffffff
MOV RAX,qword ptr [RBP + -0x8]
MOV EDX,dword ptr [RBP + -0xc]
MOV dword ptr [RAX + 0x8],EDX
MOV RAX,qword ptr [RBP + -0x8]
MOV RDX,qword ptr [RBP + -0x20]
MOV qword ptr [RAX + 0x10],RDX
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | long * func0(long *param_1,long param_2)
{
int iVar1;
long *plVar2;
void *pvVar3;
int local_18;
iVar1 = *(int *)(param_1 + 1);
plVar2 = (long *)malloc(0x18);
pvVar3 = malloc((long)(iVar1 + 1) << 2);
*plVar2 = (long)pvVar3;
for (local_18 = 0; local_18 < *(int *)(param_1 + 1); local_18 = local_18 + 1) {
*(int4 *)((long)local_18 * 4 + *plVar2) = *(int4 *)(*param_1 + (long)local_18 * 4);
}
*(int4 *)((long)*(int *)(param_1 + 1) * 4 + *plVar2) = 0xffffffff;
*(int *)(plVar2 + 1) = iVar1 + 1;
plVar2[2] = param_2;
return plVar2;
} |
6,773 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
const char* key;
int value;
} KeyValuePair;
typedef struct {
KeyValuePair* pairs;
int size;
} Dictionary;
typedef struct {
int* elements;
int size;
Dictionary* dict;
} Tuple;
| Tuple* func0(Tuple* test_tup, Dictionary* test_dict) {
int new_size = test_tup->size + 1;
Tuple* new_tuple = malloc(sizeof(Tuple));
new_tuple->elements = malloc(new_size * sizeof(int));
for (int i = 0; i < test_tup->size; i++) {
new_tuple->elements[i] = test_tup->elements[i];
}
new_tuple->elements[test_tup->size] = -1; // Placeholder since we cannot store dict in int array
new_tuple->size = new_size;
new_tuple->dict = test_dict;
return new_tuple;
}
| int main() {
int arr1[3] = {4, 5, 6};
KeyValuePair pairs1[3] = {{"MSAM", 1}, {"is", 2}, {"best", 3}};
Dictionary dict1 = {pairs1, 3};
Tuple tup1 = {arr1, 3, NULL};
Tuple* res_tup1 = func0(&tup1, &dict1);
assert(res_tup1->size == 4);
assert(res_tup1->elements[0] == 4);
assert(res_tup1->elements[1] == 5);
assert(res_tup1->elements[2] == 6);
assert(res_tup1->elements[3] == -1);
assert(res_tup1->dict->size == 3);
int arr2[3] = {1, 2, 3};
KeyValuePair pairs2[3] = {{"UTS", 2}, {"is", 3}, {"Worst", 4}};
Dictionary dict2 = {pairs2, 3};
Tuple tup2 = {arr2, 3, NULL};
Tuple* res_tup2 = func0(&tup2, &dict2);
assert(res_tup2->size == 4);
assert(res_tup2->elements[0] == 1);
assert(res_tup2->elements[1] == 2);
assert(res_tup2->elements[2] == 3);
assert(res_tup2->elements[3] == -1);
assert(res_tup2->dict->size == 3);
int arr3[3] = {8, 9, 10};
KeyValuePair pairs3[3] = {{"POS", 3}, {"is", 4}, {"Okay", 5}};
Dictionary dict3 = {pairs3, 3};
Tuple tup3 = {arr3, 3, NULL};
Tuple* res_tup3 = func0(&tup3, &dict3);
assert(res_tup3->size == 4);
assert(res_tup3->elements[0] == 8);
assert(res_tup3->elements[1] == 9);
assert(res_tup3->elements[2] == 10);
assert(res_tup3->elements[3] == -1);
assert(res_tup3->dict->size == 3);
printf("All tests passed successfully!\n");
free(res_tup1->elements);
free(res_tup1);
free(res_tup2->elements);
free(res_tup2);
free(res_tup3->elements);
free(res_tup3);
return 0;
}
| O1 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
push %rbx
mov %rdi,%r14
mov %rsi,%r12
mov 0x8(%rdi),%ebx
lea 0x1(%rbx),%r13d
mov $0x18,%edi
callq 10d0 <malloc@plt>
mov %rax,%rbp
movslq %r13d,%rdi
shl $0x2,%rdi
callq 10d0 <malloc@plt>
mov %rax,0x0(%rbp)
test %ebx,%ebx
jle 1221 <func0+0x58>
mov $0x0,%eax
mov (%r14),%rdx
mov (%rdx,%rax,4),%ecx
mov 0x0(%rbp),%rdx
mov %ecx,(%rdx,%rax,4)
mov 0x8(%r14),%ebx
add $0x1,%rax
cmp %eax,%ebx
jg 1208 <func0+0x3f>
movslq %ebx,%rbx
mov 0x0(%rbp),%rax
movl $0xffffffff,(%rax,%rbx,4)
mov %r13d,0x8(%rbp)
mov %r12,0x10(%rbp)
mov %rbp,%rax
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
retq
| func0:
endbr64
push r14
push r13
push r12
push rbp
push rbx
mov r14, rdi
mov r12, rsi
mov ebx, [rdi+8]
lea r13d, [rbx+1]
mov edi, 18h
call _malloc
mov rbp, rax
movsxd rdi, r13d
shl rdi, 2
call _malloc
mov [rbp+0], rax
test ebx, ebx
jle short loc_1221
mov eax, 0
loc_1208:
mov rdx, [r14]
mov ecx, [rdx+rax*4]
mov rdx, [rbp+0]
mov [rdx+rax*4], ecx
mov ebx, [r14+8]
add rax, 1
cmp ebx, eax
jg short loc_1208
loc_1221:
movsxd rbx, ebx
mov rax, [rbp+0]
mov dword ptr [rax+rbx*4], 0FFFFFFFFh
mov [rbp+8], r13d
mov [rbp+10h], r12
mov rax, rbp
pop rbx
pop rbp
pop r12
pop r13
pop r14
retn | long long func0(long long a1, long long a2)
{
int v2; // ebx
int v3; // r13d
long long v4; // rbp
long long v5; // rax
v2 = *(_DWORD *)(a1 + 8);
v3 = v2 + 1;
v4 = malloc(24LL);
*(_QWORD *)v4 = malloc(4LL * (v2 + 1));
if ( v2 > 0 )
{
v5 = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)v4 + 4 * v5) = *(_DWORD *)(*(_QWORD *)a1 + 4 * v5);
v2 = *(_DWORD *)(a1 + 8);
++v5;
}
while ( v2 > (int)v5 );
}
*(_DWORD *)(*(_QWORD *)v4 + 4LL * v2) = -1;
*(_DWORD *)(v4 + 8) = v3;
*(_QWORD *)(v4 + 16) = a2;
return v4;
} | func0:
ENDBR64
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
MOV R14,RDI
MOV R12,RSI
MOV EBX,dword ptr [RDI + 0x8]
LEA R13D,[RBX + 0x1]
MOV EDI,0x18
CALL 0x001010d0
MOV RBP,RAX
MOVSXD RDI,R13D
SHL RDI,0x2
CALL 0x001010d0
MOV qword ptr [RBP],RAX
TEST EBX,EBX
JLE 0x00101221
MOV EAX,0x0
LAB_00101208:
MOV RDX,qword ptr [R14]
MOV ECX,dword ptr [RDX + RAX*0x4]
MOV RDX,qword ptr [RBP]
MOV dword ptr [RDX + RAX*0x4],ECX
MOV EBX,dword ptr [R14 + 0x8]
ADD RAX,0x1
CMP EBX,EAX
JG 0x00101208
LAB_00101221:
MOVSXD RBX,EBX
MOV RAX,qword ptr [RBP]
MOV dword ptr [RAX + RBX*0x4],0xffffffff
MOV dword ptr [RBP + 0x8],R13D
MOV qword ptr [RBP + 0x10],R12
MOV RAX,RBP
POP RBX
POP RBP
POP R12
POP R13
POP R14
RET | long * func0(long *param_1,long param_2)
{
int iVar1;
long *plVar2;
void *pvVar3;
long lVar4;
int iVar5;
iVar5 = (int)param_1[1];
iVar1 = iVar5 + 1;
plVar2 = (long *)malloc(0x18);
pvVar3 = malloc((long)iVar1 << 2);
*plVar2 = (long)pvVar3;
if (0 < iVar5) {
lVar4 = 0;
do {
*(int4 *)(*plVar2 + lVar4 * 4) = *(int4 *)(*param_1 + lVar4 * 4);
iVar5 = (int)param_1[1];
lVar4 = lVar4 + 1;
} while ((int)lVar4 < iVar5);
}
*(int4 *)(*plVar2 + (long)iVar5 * 4) = 0xffffffff;
*(int *)(plVar2 + 1) = iVar1;
plVar2[2] = param_2;
return plVar2;
} |
6,774 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
const char* key;
int value;
} KeyValuePair;
typedef struct {
KeyValuePair* pairs;
int size;
} Dictionary;
typedef struct {
int* elements;
int size;
Dictionary* dict;
} Tuple;
| Tuple* func0(Tuple* test_tup, Dictionary* test_dict) {
int new_size = test_tup->size + 1;
Tuple* new_tuple = malloc(sizeof(Tuple));
new_tuple->elements = malloc(new_size * sizeof(int));
for (int i = 0; i < test_tup->size; i++) {
new_tuple->elements[i] = test_tup->elements[i];
}
new_tuple->elements[test_tup->size] = -1; // Placeholder since we cannot store dict in int array
new_tuple->size = new_size;
new_tuple->dict = test_dict;
return new_tuple;
}
| int main() {
int arr1[3] = {4, 5, 6};
KeyValuePair pairs1[3] = {{"MSAM", 1}, {"is", 2}, {"best", 3}};
Dictionary dict1 = {pairs1, 3};
Tuple tup1 = {arr1, 3, NULL};
Tuple* res_tup1 = func0(&tup1, &dict1);
assert(res_tup1->size == 4);
assert(res_tup1->elements[0] == 4);
assert(res_tup1->elements[1] == 5);
assert(res_tup1->elements[2] == 6);
assert(res_tup1->elements[3] == -1);
assert(res_tup1->dict->size == 3);
int arr2[3] = {1, 2, 3};
KeyValuePair pairs2[3] = {{"UTS", 2}, {"is", 3}, {"Worst", 4}};
Dictionary dict2 = {pairs2, 3};
Tuple tup2 = {arr2, 3, NULL};
Tuple* res_tup2 = func0(&tup2, &dict2);
assert(res_tup2->size == 4);
assert(res_tup2->elements[0] == 1);
assert(res_tup2->elements[1] == 2);
assert(res_tup2->elements[2] == 3);
assert(res_tup2->elements[3] == -1);
assert(res_tup2->dict->size == 3);
int arr3[3] = {8, 9, 10};
KeyValuePair pairs3[3] = {{"POS", 3}, {"is", 4}, {"Okay", 5}};
Dictionary dict3 = {pairs3, 3};
Tuple tup3 = {arr3, 3, NULL};
Tuple* res_tup3 = func0(&tup3, &dict3);
assert(res_tup3->size == 4);
assert(res_tup3->elements[0] == 8);
assert(res_tup3->elements[1] == 9);
assert(res_tup3->elements[2] == 10);
assert(res_tup3->elements[3] == -1);
assert(res_tup3->dict->size == 3);
printf("All tests passed successfully!\n");
free(res_tup1->elements);
free(res_tup1);
free(res_tup2->elements);
free(res_tup2);
free(res_tup3->elements);
free(res_tup3);
return 0;
}
| O2 | c | func0:
endbr64
push %r15
push %r14
mov %rsi,%r14
push %r13
mov %rdi,%r13
push %r12
push %rbp
push %rbx
sub $0x8,%rsp
mov 0x8(%rdi),%r15d
mov $0x18,%edi
callq 10d0 <malloc@plt>
lea 0x1(%r15),%ebx
mov %rax,%r12
movslq %ebx,%rbp
shl $0x2,%rbp
mov %rbp,%rdi
callq 10d0 <malloc@plt>
mov %rax,(%r12)
test %r15d,%r15d
jle 17b3 <func0+0x63>
mov 0x0(%r13),%r8
lea -0x1(%r15),%edi
xor %edx,%edx
mov (%r8,%rdx,4),%ecx
mov %ecx,(%rax,%rdx,4)
mov %rdx,%rcx
add $0x1,%rdx
cmp %rdi,%rcx
jne 17a0 <func0+0x50>
movl $0xffffffff,-0x4(%rax,%rbp,1)
mov %r12,%rax
mov %ebx,0x8(%r12)
mov %r14,0x10(%r12)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push r15
mov r15, rdi
push r14
mov r14, rsi
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov ebp, [rdi+8]
mov edi, 18h
call _malloc
lea ebx, [rbp+1]
mov r12, rax
movsxd r13, ebx
shl r13, 2
mov rdi, r13
call _malloc
mov [r12], rax
test ebp, ebp
jle short loc_17AF
mov rdi, [r15]
movsxd rsi, ebp
xor edx, edx
nop word ptr [rax+rax+00h]
loc_17A0:
mov ecx, [rdi+rdx*4]
mov [rax+rdx*4], ecx
add rdx, 1
cmp rdx, rsi
jnz short loc_17A0
loc_17AF:
mov dword ptr [rax+r13-4], 0FFFFFFFFh
mov rax, r12
mov [r12+8], ebx
mov [r12+10h], r14
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | long long func0(long long *a1, long long a2)
{
int v2; // ebp
int v3; // ebx
long long v4; // r12
long long v5; // rax
long long v6; // rdi
long long i; // rdx
long long result; // rax
v2 = *((_DWORD *)a1 + 2);
v3 = v2 + 1;
v4 = malloc(24LL);
v5 = malloc(4LL * (v2 + 1));
*(_QWORD *)v4 = v5;
if ( v2 > 0 )
{
v6 = *a1;
for ( i = 0LL; i != v2; ++i )
*(_DWORD *)(v5 + 4 * i) = *(_DWORD *)(v6 + 4 * i);
}
*(_DWORD *)(v5 + 4LL * v3 - 4) = -1;
result = v4;
*(_DWORD *)(v4 + 8) = v3;
*(_QWORD *)(v4 + 16) = a2;
return result;
} | func0:
ENDBR64
PUSH R15
MOV R15,RDI
PUSH R14
MOV R14,RSI
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV EBP,dword ptr [RDI + 0x8]
MOV EDI,0x18
CALL 0x001010d0
LEA EBX,[RBP + 0x1]
MOV R12,RAX
MOVSXD R13,EBX
SHL R13,0x2
MOV RDI,R13
CALL 0x001010d0
MOV qword ptr [R12],RAX
TEST EBP,EBP
JLE 0x001017af
MOV RDI,qword ptr [R15]
MOVSXD RSI,EBP
XOR EDX,EDX
NOP word ptr [RAX + RAX*0x1]
LAB_001017a0:
MOV ECX,dword ptr [RDI + RDX*0x4]
MOV dword ptr [RAX + RDX*0x4],ECX
ADD RDX,0x1
CMP RDX,RSI
JNZ 0x001017a0
LAB_001017af:
MOV dword ptr [RAX + R13*0x1 + -0x4],0xffffffff
MOV RAX,R12
MOV dword ptr [R12 + 0x8],EBX
MOV qword ptr [R12 + 0x10],R14
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | int8 * func0(long *param_1,int8 param_2)
{
int iVar1;
long lVar2;
int8 *puVar3;
void *pvVar4;
long lVar5;
size_t __size;
iVar1 = (int)param_1[1];
puVar3 = (int8 *)malloc(0x18);
__size = (long)(iVar1 + 1) * 4;
pvVar4 = malloc(__size);
*puVar3 = pvVar4;
if (0 < iVar1) {
lVar2 = *param_1;
lVar5 = 0;
do {
*(int4 *)((long)pvVar4 + lVar5 * 4) = *(int4 *)(lVar2 + lVar5 * 4);
lVar5 = lVar5 + 1;
} while (lVar5 != iVar1);
}
*(int4 *)((long)pvVar4 + (__size - 4)) = 0xffffffff;
*(int *)(puVar3 + 1) = iVar1 + 1;
puVar3[2] = param_2;
return puVar3;
} |
6,775 | func0 | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
const char* key;
int value;
} KeyValuePair;
typedef struct {
KeyValuePair* pairs;
int size;
} Dictionary;
typedef struct {
int* elements;
int size;
Dictionary* dict;
} Tuple;
| Tuple* func0(Tuple* test_tup, Dictionary* test_dict) {
int new_size = test_tup->size + 1;
Tuple* new_tuple = malloc(sizeof(Tuple));
new_tuple->elements = malloc(new_size * sizeof(int));
for (int i = 0; i < test_tup->size; i++) {
new_tuple->elements[i] = test_tup->elements[i];
}
new_tuple->elements[test_tup->size] = -1; // Placeholder since we cannot store dict in int array
new_tuple->size = new_size;
new_tuple->dict = test_dict;
return new_tuple;
}
| int main() {
int arr1[3] = {4, 5, 6};
KeyValuePair pairs1[3] = {{"MSAM", 1}, {"is", 2}, {"best", 3}};
Dictionary dict1 = {pairs1, 3};
Tuple tup1 = {arr1, 3, NULL};
Tuple* res_tup1 = func0(&tup1, &dict1);
assert(res_tup1->size == 4);
assert(res_tup1->elements[0] == 4);
assert(res_tup1->elements[1] == 5);
assert(res_tup1->elements[2] == 6);
assert(res_tup1->elements[3] == -1);
assert(res_tup1->dict->size == 3);
int arr2[3] = {1, 2, 3};
KeyValuePair pairs2[3] = {{"UTS", 2}, {"is", 3}, {"Worst", 4}};
Dictionary dict2 = {pairs2, 3};
Tuple tup2 = {arr2, 3, NULL};
Tuple* res_tup2 = func0(&tup2, &dict2);
assert(res_tup2->size == 4);
assert(res_tup2->elements[0] == 1);
assert(res_tup2->elements[1] == 2);
assert(res_tup2->elements[2] == 3);
assert(res_tup2->elements[3] == -1);
assert(res_tup2->dict->size == 3);
int arr3[3] = {8, 9, 10};
KeyValuePair pairs3[3] = {{"POS", 3}, {"is", 4}, {"Okay", 5}};
Dictionary dict3 = {pairs3, 3};
Tuple tup3 = {arr3, 3, NULL};
Tuple* res_tup3 = func0(&tup3, &dict3);
assert(res_tup3->size == 4);
assert(res_tup3->elements[0] == 8);
assert(res_tup3->elements[1] == 9);
assert(res_tup3->elements[2] == 10);
assert(res_tup3->elements[3] == -1);
assert(res_tup3->dict->size == 3);
printf("All tests passed successfully!\n");
free(res_tup1->elements);
free(res_tup1);
free(res_tup2->elements);
free(res_tup2);
free(res_tup3->elements);
free(res_tup3);
return 0;
}
| O3 | c | func0:
endbr64
push %r15
mov %rsi,%r15
push %r14
mov %rdi,%r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x8,%rsp
mov 0x8(%rdi),%ebp
mov $0x18,%edi
callq 10d0 <malloc@plt>
lea 0x1(%rbp),%ebx
mov %rax,%r12
movslq %ebx,%r13
shl $0x2,%r13
mov %r13,%rdi
callq 10d0 <malloc@plt>
mov %rax,(%r12)
test %ebp,%ebp
jle 1805 <func0+0xb5>
mov (%r14),%rcx
lea 0xf(%rax),%rsi
lea -0x1(%rbp),%edx
sub %rcx,%rsi
cmp $0x1e,%rsi
jbe 1830 <func0+0xe0>
cmp $0x3,%edx
jbe 1830 <func0+0xe0>
mov %ebp,%edi
xor %edx,%edx
shr $0x2,%edi
shl $0x4,%rdi
nopl (%rax)
movdqu (%rcx,%rdx,1),%xmm0
movups %xmm0,(%rax,%rdx,1)
add $0x10,%rdx
cmp %rdi,%rdx
jne 17c0 <func0+0x70>
mov %ebp,%edx
and $0xfffffffc,%edx
test $0x3,%bpl
je 1805 <func0+0xb5>
mov %edx,%esi
mov (%rcx,%rsi,4),%edi
mov %edi,(%rax,%rsi,4)
lea 0x1(%rdx),%esi
cmp %esi,%ebp
jle 1805 <func0+0xb5>
movslq %esi,%rsi
add $0x2,%edx
mov (%rcx,%rsi,4),%edi
mov %edi,(%rax,%rsi,4)
cmp %edx,%ebp
jle 1805 <func0+0xb5>
movslq %edx,%rdx
mov (%rcx,%rdx,4),%ecx
mov %ecx,(%rax,%rdx,4)
movl $0xffffffff,-0x4(%rax,%r13,1)
mov %r12,%rax
mov %ebx,0x8(%r12)
mov %r15,0x10(%r12)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopw 0x0(%rax,%rax,1)
mov %edx,%esi
xor %edx,%edx
nopl 0x0(%rax)
mov (%rcx,%rdx,4),%edi
mov %edi,(%rax,%rdx,4)
mov %rdx,%rdi
add $0x1,%rdx
cmp %rsi,%rdi
jne 1838 <func0+0xe8>
jmp 1805 <func0+0xb5>
nopl 0x0(%rax)
| func0:
endbr64
push r15
push r14
mov r14, rsi
push r13
mov r13, rdi
push r12
push rbp
push rbx
sub rsp, 8
mov r15d, [rdi+8]
mov edi, 18h; size
call _malloc
lea ebx, [r15+1]
mov rbp, rax
movsxd r12, ebx
shl r12, 2
mov rdi, r12; size
call _malloc
mov [rbp+0], rax
mov rdx, rax
test r15d, r15d
jle short loc_17AF
lea eax, [r15-1]
mov rcx, [r13+0]
cmp eax, 2
jbe short loc_1795
lea rsi, [rcx+4]
mov rax, rdx
sub rax, rsi
cmp rax, 8
ja short loc_17D8
loc_1795:
lea rdi, [r12-4]
xor eax, eax
nop dword ptr [rax+00h]
loc_17A0:
mov esi, [rcx+rax]
mov [rdx+rax], esi
add rax, 4
cmp rdi, rax
jnz short loc_17A0
loc_17AF:
mov dword ptr [rdx+r12-4], 0FFFFFFFFh
mov rax, rbp
mov [rbp+8], ebx
mov [rbp+10h], r14
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_17D8:
mov esi, r15d
xor eax, eax
shr esi, 2
shl rsi, 4
nop dword ptr [rax+00h]
loc_17E8:
movdqu xmm0, xmmword ptr [rcx+rax]
movups xmmword ptr [rdx+rax], xmm0
add rax, 10h
cmp rax, rsi
jnz short loc_17E8
mov eax, r15d
and eax, 0FFFFFFFCh
test r15b, 3
jz short loc_17AF
mov edi, eax
mov r8d, [rcx+rdi*4]
lea rsi, ds:0[rdi*4]
mov [rdx+rdi*4], r8d
lea edi, [rax+1]
cmp r15d, edi
jle short loc_17AF
mov edi, [rcx+rsi+4]
add eax, 2
mov [rdx+rsi+4], edi
cmp r15d, eax
jle loc_17AF
mov eax, [rcx+rsi+8]
mov [rdx+rsi+8], eax
jmp loc_17AF | _DWORD * func0(long long *a1, long long a2)
{
int v3; // r15d
_DWORD *v4; // rbp
size_t v5; // r12
char *v6; // rax
char *v7; // rdx
long long v8; // rcx
long long v9; // rax
_DWORD *result; // rax
long long v11; // rax
unsigned int v12; // eax
long long v13; // rsi
v3 = *((_DWORD *)a1 + 2);
v4 = malloc(0x18uLL);
v5 = 4LL * (v3 + 1);
v6 = (char *)malloc(v5);
*(_QWORD *)v4 = v6;
v7 = v6;
if ( v3 > 0 )
{
v8 = *a1;
if ( (unsigned int)(v3 - 1) > 2 && (unsigned long long)&v6[-v8 - 4] > 8 )
{
v11 = 0LL;
do
{
*(__m128i *)&v7[v11] = _mm_loadu_si128((const __m128i *)(v8 + v11));
v11 += 16LL;
}
while ( v11 != 16LL * ((unsigned int)v3 >> 2) );
v12 = v3 & 0x7FFFFFFC;
if ( (v3 & 3) != 0 )
{
v13 = 4LL * v12;
*(_DWORD *)&v7[v13] = *(_DWORD *)(v8 + v13);
if ( v3 > (int)(v12 + 1) )
{
*(_DWORD *)&v7[v13 + 4] = *(_DWORD *)(v8 + v13 + 4);
if ( v3 > (int)(v12 + 2) )
*(_DWORD *)&v7[v13 + 8] = *(_DWORD *)(v8 + v13 + 8);
}
}
}
else
{
v9 = 0LL;
do
{
*(_DWORD *)&v7[v9] = *(_DWORD *)(v8 + v9);
v9 += 4LL;
}
while ( v5 - 4 != v9 );
}
}
*(_DWORD *)&v7[v5 - 4] = -1;
result = v4;
v4[2] = v3 + 1;
*((_QWORD *)v4 + 2) = a2;
return result;
} | func0:
ENDBR64
PUSH R15
PUSH R14
MOV R14,RSI
PUSH R13
MOV R13,RDI
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV R15D,dword ptr [RDI + 0x8]
MOV EDI,0x18
CALL 0x001010d0
LEA EBX,[R15 + 0x1]
MOV RBP,RAX
MOVSXD R12,EBX
SHL R12,0x2
MOV RDI,R12
CALL 0x001010d0
MOV qword ptr [RBP],RAX
MOV RDX,RAX
TEST R15D,R15D
JLE 0x001017af
LEA EAX,[R15 + -0x1]
MOV RCX,qword ptr [R13]
CMP EAX,0x2
JBE 0x00101795
LEA RSI,[RCX + 0x4]
MOV RAX,RDX
SUB RAX,RSI
CMP RAX,0x8
JA 0x001017d8
LAB_00101795:
LEA RDI,[R12 + -0x4]
XOR EAX,EAX
NOP dword ptr [RAX]
LAB_001017a0:
MOV ESI,dword ptr [RCX + RAX*0x1]
MOV dword ptr [RDX + RAX*0x1],ESI
ADD RAX,0x4
CMP RDI,RAX
JNZ 0x001017a0
LAB_001017af:
MOV dword ptr [RDX + R12*0x1 + -0x4],0xffffffff
MOV RAX,RBP
MOV dword ptr [RBP + 0x8],EBX
MOV qword ptr [RBP + 0x10],R14
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001017d8:
MOV ESI,R15D
XOR EAX,EAX
SHR ESI,0x2
SHL RSI,0x4
NOP dword ptr [RAX]
LAB_001017e8:
MOVDQU XMM0,xmmword ptr [RCX + RAX*0x1]
MOVUPS xmmword ptr [RDX + RAX*0x1],XMM0
ADD RAX,0x10
CMP RAX,RSI
JNZ 0x001017e8
MOV EAX,R15D
AND EAX,0xfffffffc
TEST R15B,0x3
JZ 0x001017af
MOV EDI,EAX
MOV R8D,dword ptr [RCX + RDI*0x4]
LEA RSI,[RDI*0x4]
MOV dword ptr [RDX + RDI*0x4],R8D
LEA EDI,[RAX + 0x1]
CMP R15D,EDI
JLE 0x001017af
MOV EDI,dword ptr [RCX + RSI*0x1 + 0x4]
ADD EAX,0x2
MOV dword ptr [RDX + RSI*0x1 + 0x4],EDI
CMP R15D,EAX
JLE 0x001017af
MOV EAX,dword ptr [RCX + RSI*0x1 + 0x8]
MOV dword ptr [RDX + RSI*0x1 + 0x8],EAX
JMP 0x001017af | int8 * func0(long *param_1,int8 param_2)
{
uint uVar1;
long lVar2;
int8 uVar3;
uint uVar4;
int8 *puVar5;
void *pvVar6;
long lVar7;
ulong uVar8;
size_t __size;
uVar1 = *(uint *)(param_1 + 1);
puVar5 = (int8 *)malloc(0x18);
__size = (long)(int)(uVar1 + 1) * 4;
pvVar6 = malloc(__size);
*puVar5 = pvVar6;
if (0 < (int)uVar1) {
lVar2 = *param_1;
if ((uVar1 - 1 < 3) || ((ulong)((long)pvVar6 - (lVar2 + 4)) < 9)) {
lVar7 = 0;
do {
*(int4 *)((long)pvVar6 + lVar7) = *(int4 *)(lVar2 + lVar7);
lVar7 = lVar7 + 4;
} while (__size - 4 != lVar7);
}
else {
lVar7 = 0;
do {
uVar3 = ((int8 *)(lVar2 + lVar7))[1];
*(int8 *)((long)pvVar6 + lVar7) = *(int8 *)(lVar2 + lVar7);
((int8 *)((long)pvVar6 + lVar7))[1] = uVar3;
lVar7 = lVar7 + 0x10;
} while (lVar7 != (ulong)(uVar1 >> 2) << 4);
uVar4 = uVar1 & 0xfffffffc;
if ((uVar1 & 3) != 0) {
uVar8 = (ulong)uVar4;
lVar7 = uVar8 * 4;
*(int4 *)((long)pvVar6 + uVar8 * 4) = *(int4 *)(lVar2 + uVar8 * 4);
if (((int)(uVar4 + 1) < (int)uVar1) &&
(*(int4 *)((long)pvVar6 + lVar7 + 4) = *(int4 *)(lVar2 + 4 + lVar7),
(int)(uVar4 + 2) < (int)uVar1)) {
*(int4 *)((long)pvVar6 + lVar7 + 8) = *(int4 *)(lVar2 + 8 + lVar7);
}
}
}
}
*(int4 *)((long)pvVar6 + (__size - 4)) = 0xffffffff;
*(uint *)(puVar5 + 1) = uVar1 + 1;
puVar5[2] = param_2;
return puVar5;
} |
6,776 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int cost[][100], int N) {
int dp[100][100] = {0};
dp[0][0] = cost[0][0];
for(int i = 1; i < N; i++) {
dp[i][0] = dp[i-1][0] + cost[i][0];
}
for(int j = 1; j < N; j++) {
dp[0][j] = dp[0][j-1] + cost[0][j];
}
for(int i = 1; i < N; i++) {
for(int j = 1; j < N; j++) {
dp[i][j] = (dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1]) + cost[i][j];
}
}
return (double)dp[N-1][N-1] / (2*N - 1);
}
| int main() {
int cost1[3][100] = { {1, 2, 3}, {6, 5, 4}, {7, 3, 9} };
assert(func0(cost1, 3) == 5.2);
int cost2[3][100] = { {2, 3, 4}, {7, 6, 5}, {8, 4, 10} };
assert(func0(cost2, 3) == 6.2);
int cost3[3][100] = { {3, 4, 5}, {8, 7, 6}, {9, 5, 11} };
assert(func0(cost3, 3) == 7.2);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
lea -0x9000(%rsp),%r11
sub $0x1000,%rsp
orq $0x0,(%rsp)
cmp %r11,%rsp
jne 1199 <func0+0x10>
sub $0xc70,%rsp
mov %rdi,-0x9c68(%rbp)
mov %esi,-0x9c6c(%rbp)
mov %fs:0x28,%rax
mov %rax,-0x8(%rbp)
xor %eax,%eax
lea -0x9c50(%rbp),%rax
mov $0x9c40,%edx
mov $0x0,%esi
mov %rax,%rdi
callq 1090 <memset@plt>
mov -0x9c68(%rbp),%rax
mov (%rax),%eax
mov %eax,-0x9c50(%rbp)
movl $0x1,-0x9c60(%rbp)
jmpq 129b <func0+0x112>
mov -0x9c60(%rbp),%eax
sub $0x1,%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x4,%rax
add %rbp,%rax
sub $0x9c50,%rax
mov (%rax),%ecx
mov -0x9c60(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x4,%rax
mov %rax,%rdx
mov -0x9c68(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
add %eax,%ecx
mov -0x9c60(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x4,%rax
add %rbp,%rax
sub $0x9c50,%rax
mov %ecx,(%rax)
addl $0x1,-0x9c60(%rbp)
mov -0x9c60(%rbp),%eax
cmp -0x9c6c(%rbp),%eax
jl 1204 <func0+0x7b>
movl $0x1,-0x9c5c(%rbp)
jmp 12f7 <func0+0x16e>
mov -0x9c5c(%rbp),%eax
sub $0x1,%eax
cltq
mov -0x9c50(%rbp,%rax,4),%ecx
mov -0x9c68(%rbp),%rax
mov -0x9c5c(%rbp),%edx
movslq %edx,%rdx
mov (%rax,%rdx,4),%eax
lea (%rcx,%rax,1),%edx
mov -0x9c5c(%rbp),%eax
cltq
mov %edx,-0x9c50(%rbp,%rax,4)
addl $0x1,-0x9c5c(%rbp)
mov -0x9c5c(%rbp),%eax
cmp -0x9c6c(%rbp),%eax
jl 12b9 <func0+0x130>
movl $0x1,-0x9c58(%rbp)
jmpq 142b <func0+0x2a2>
movl $0x1,-0x9c54(%rbp)
jmpq 1412 <func0+0x289>
mov -0x9c54(%rbp),%eax
sub $0x1,%eax
movslq %eax,%rcx
mov -0x9c58(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x2,%rax
add %rcx,%rax
mov -0x9c50(%rbp,%rax,4),%edx
mov -0x9c58(%rbp),%eax
lea -0x1(%rax),%ecx
mov -0x9c54(%rbp),%eax
movslq %eax,%rsi
movslq %ecx,%rcx
mov %rcx,%rax
shl $0x2,%rax
add %rcx,%rax
lea 0x0(,%rax,4),%rcx
add %rcx,%rax
shl $0x2,%rax
add %rsi,%rax
mov -0x9c50(%rbp,%rax,4),%eax
cmp %eax,%edx
cmovge %edx,%eax
mov %eax,%ecx
mov -0x9c58(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x4,%rax
mov %rax,%rdx
mov -0x9c68(%rbp),%rax
add %rax,%rdx
mov -0x9c54(%rbp),%eax
cltq
mov (%rdx,%rax,4),%eax
add %eax,%ecx
mov -0x9c54(%rbp),%eax
movslq %eax,%rsi
mov -0x9c58(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x2,%rax
add %rsi,%rax
mov %ecx,-0x9c50(%rbp,%rax,4)
addl $0x1,-0x9c54(%rbp)
mov -0x9c54(%rbp),%eax
cmp -0x9c6c(%rbp),%eax
jl 1323 <func0+0x19a>
addl $0x1,-0x9c58(%rbp)
mov -0x9c58(%rbp),%eax
cmp -0x9c6c(%rbp),%eax
jl 1314 <func0+0x18b>
mov -0x9c6c(%rbp),%eax
lea -0x1(%rax),%edx
mov -0x9c6c(%rbp),%eax
sub $0x1,%eax
movslq %eax,%rcx
movslq %edx,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
shl $0x2,%rax
add %rcx,%rax
mov -0x9c50(%rbp,%rax,4),%eax
cvtsi2sd %eax,%xmm0
mov -0x9c6c(%rbp),%eax
add %eax,%eax
sub $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd %xmm1,%xmm0
mov -0x8(%rbp),%rax
xor %fs:0x28,%rax
je 14a3 <func0+0x31a>
callq 1070 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
lea r11, [rsp+var_9000]
loc_1199:
sub rsp, 1000h
or [rsp+1000h+var_1000], 0
cmp rsp, r11
jnz short loc_1199
sub rsp, 0C70h
mov [rbp+var_9C68], rdi
mov [rbp+var_9C6C], esi
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
lea rax, [rbp+s]
mov edx, 9C40h; n
mov esi, 0; c
mov rdi, rax; s
call _memset
mov rax, [rbp+var_9C68]
mov eax, [rax]
mov [rbp+s], eax
mov [rbp+var_9C60], 1
jmp loc_129B
loc_1204:
mov eax, [rbp+var_9C60]
sub eax, 1
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 4
add rax, rbp
sub rax, 9C50h
mov ecx, [rax]
mov eax, [rbp+var_9C60]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_9C68]
add rax, rdx
mov eax, [rax]
add ecx, eax
mov eax, [rbp+var_9C60]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 4
add rax, rbp
sub rax, 9C50h
mov [rax], ecx
add [rbp+var_9C60], 1
loc_129B:
mov eax, [rbp+var_9C60]
cmp eax, [rbp+var_9C6C]
jl loc_1204
mov [rbp+var_9C5C], 1
jmp short loc_12F7
loc_12B9:
mov eax, [rbp+var_9C5C]
sub eax, 1
cdqe
mov ecx, [rbp+rax*4+s]
mov rax, [rbp+var_9C68]
mov edx, [rbp+var_9C5C]
movsxd rdx, edx
mov eax, [rax+rdx*4]
lea edx, [rcx+rax]
mov eax, [rbp+var_9C5C]
cdqe
mov [rbp+rax*4+s], edx
add [rbp+var_9C5C], 1
loc_12F7:
mov eax, [rbp+var_9C5C]
cmp eax, [rbp+var_9C6C]
jl short loc_12B9
mov [rbp+var_9C58], 1
jmp loc_142B
loc_1314:
mov [rbp+var_9C54], 1
jmp loc_1412
loc_1323:
mov eax, [rbp+var_9C54]
sub eax, 1
movsxd rcx, eax
mov eax, [rbp+var_9C58]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 2
add rax, rcx
mov edx, [rbp+rax*4+s]
mov eax, [rbp+var_9C58]
lea ecx, [rax-1]
mov eax, [rbp+var_9C54]
movsxd rsi, eax
movsxd rcx, ecx
mov rax, rcx
shl rax, 2
add rax, rcx
lea rcx, ds:0[rax*4]
add rax, rcx
shl rax, 2
add rax, rsi
mov eax, [rbp+rax*4+s]
cmp edx, eax
cmovge eax, edx
mov ecx, eax
mov eax, [rbp+var_9C58]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_9C68]
add rdx, rax
mov eax, [rbp+var_9C54]
cdqe
mov eax, [rdx+rax*4]
add ecx, eax
mov eax, [rbp+var_9C54]
movsxd rsi, eax
mov eax, [rbp+var_9C58]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 2
add rax, rsi
mov [rbp+rax*4+s], ecx
add [rbp+var_9C54], 1
loc_1412:
mov eax, [rbp+var_9C54]
cmp eax, [rbp+var_9C6C]
jl loc_1323
add [rbp+var_9C58], 1
loc_142B:
mov eax, [rbp+var_9C58]
cmp eax, [rbp+var_9C6C]
jl loc_1314
mov eax, [rbp+var_9C6C]
lea edx, [rax-1]
mov eax, [rbp+var_9C6C]
sub eax, 1
movsxd rcx, eax
movsxd rdx, edx
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
shl rax, 2
add rax, rcx
mov eax, [rbp+rax*4+s]
pxor xmm0, xmm0
cvtsi2sd xmm0, eax
mov eax, [rbp+var_9C6C]
add eax, eax
sub eax, 1
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
divsd xmm0, xmm1
mov rax, [rbp+var_8]
sub rax, fs:28h
jz short locret_14AB
call ___stack_chk_fail
locret_14AB:
leave
retn | // bad sp value at call has been detected, the output may be wrong!
unsigned long long func0(_DWORD *a1, int a2)
{
int v2; // eax
int i; // [rsp+Ch] [rbp-9C60h]
int j; // [rsp+10h] [rbp-9C5Ch]
int k; // [rsp+14h] [rbp-9C58h]
int m; // [rsp+18h] [rbp-9C54h]
_DWORD s[788]; // [rsp+1Ch] [rbp-9C50h] BYREF
char v9; // [rsp+C6Ch] [rbp-9000h] BYREF
long long v10; // [rsp+8C6Ch] [rbp-1000h] BYREF
unsigned long long v11; // [rsp+9C64h] [rbp-8h]
while ( &v10 != (long long *)&v9 )
;
v11 = __readfsqword(0x28u);
memset(s, 0, 0x9C40uLL);
s[0] = *a1;
for ( i = 1; i < a2; ++i )
s[100 * i] = a1[100 * i] + s[100 * i - 100];
for ( j = 1; j < a2; ++j )
s[j] = s[j - 1] + a1[j];
for ( k = 1; k < a2; ++k )
{
for ( m = 1; m < a2; ++m )
{
v2 = s[100 * k - 100 + m];
if ( s[100 * k - 1 + m] >= v2 )
v2 = s[100 * k - 1 + m];
s[100 * k + m] = a1[100 * k + m] + v2;
}
}
return v11 - __readfsqword(0x28u);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
LEA R11,[RSP + -0x9000]
LAB_00101199:
SUB RSP,0x1000
OR qword ptr [RSP],0x0
CMP RSP,R11
JNZ 0x00101199
SUB RSP,0xc70
MOV qword ptr [RBP + -0x9c68],RDI
MOV dword ptr [RBP + -0x9c6c],ESI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RBP + -0x8],RAX
XOR EAX,EAX
LEA RAX,[RBP + -0x9c50]
MOV EDX,0x9c40
MOV ESI,0x0
MOV RDI,RAX
CALL 0x00101090
MOV RAX,qword ptr [RBP + -0x9c68]
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x9c50],EAX
MOV dword ptr [RBP + -0x9c60],0x1
JMP 0x0010129b
LAB_00101204:
MOV EAX,dword ptr [RBP + -0x9c60]
SUB EAX,0x1
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x4
ADD RAX,RBP
SUB RAX,0x9c50
MOV ECX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x9c60]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x9c68]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
ADD ECX,EAX
MOV EAX,dword ptr [RBP + -0x9c60]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x4
ADD RAX,RBP
SUB RAX,0x9c50
MOV dword ptr [RAX],ECX
ADD dword ptr [RBP + -0x9c60],0x1
LAB_0010129b:
MOV EAX,dword ptr [RBP + -0x9c60]
CMP EAX,dword ptr [RBP + -0x9c6c]
JL 0x00101204
MOV dword ptr [RBP + -0x9c5c],0x1
JMP 0x001012f7
LAB_001012b9:
MOV EAX,dword ptr [RBP + -0x9c5c]
SUB EAX,0x1
CDQE
MOV ECX,dword ptr [RBP + RAX*0x4 + -0x9c50]
MOV RAX,qword ptr [RBP + -0x9c68]
MOV EDX,dword ptr [RBP + -0x9c5c]
MOVSXD RDX,EDX
MOV EAX,dword ptr [RAX + RDX*0x4]
LEA EDX,[RCX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x9c5c]
CDQE
MOV dword ptr [RBP + RAX*0x4 + -0x9c50],EDX
ADD dword ptr [RBP + -0x9c5c],0x1
LAB_001012f7:
MOV EAX,dword ptr [RBP + -0x9c5c]
CMP EAX,dword ptr [RBP + -0x9c6c]
JL 0x001012b9
MOV dword ptr [RBP + -0x9c58],0x1
JMP 0x0010142b
LAB_00101314:
MOV dword ptr [RBP + -0x9c54],0x1
JMP 0x00101412
LAB_00101323:
MOV EAX,dword ptr [RBP + -0x9c54]
SUB EAX,0x1
MOVSXD RCX,EAX
MOV EAX,dword ptr [RBP + -0x9c58]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x2
ADD RAX,RCX
MOV EDX,dword ptr [RBP + RAX*0x4 + -0x9c50]
MOV EAX,dword ptr [RBP + -0x9c58]
LEA ECX,[RAX + -0x1]
MOV EAX,dword ptr [RBP + -0x9c54]
MOVSXD RSI,EAX
MOVSXD RCX,ECX
MOV RAX,RCX
SHL RAX,0x2
ADD RAX,RCX
LEA RCX,[RAX*0x4]
ADD RAX,RCX
SHL RAX,0x2
ADD RAX,RSI
MOV EAX,dword ptr [RBP + RAX*0x4 + -0x9c50]
CMP EDX,EAX
CMOVGE EAX,EDX
MOV ECX,EAX
MOV EAX,dword ptr [RBP + -0x9c58]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x9c68]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x9c54]
CDQE
MOV EAX,dword ptr [RDX + RAX*0x4]
ADD ECX,EAX
MOV EAX,dword ptr [RBP + -0x9c54]
MOVSXD RSI,EAX
MOV EAX,dword ptr [RBP + -0x9c58]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x2
ADD RAX,RSI
MOV dword ptr [RBP + RAX*0x4 + -0x9c50],ECX
ADD dword ptr [RBP + -0x9c54],0x1
LAB_00101412:
MOV EAX,dword ptr [RBP + -0x9c54]
CMP EAX,dword ptr [RBP + -0x9c6c]
JL 0x00101323
ADD dword ptr [RBP + -0x9c58],0x1
LAB_0010142b:
MOV EAX,dword ptr [RBP + -0x9c58]
CMP EAX,dword ptr [RBP + -0x9c6c]
JL 0x00101314
MOV EAX,dword ptr [RBP + -0x9c6c]
LEA EDX,[RAX + -0x1]
MOV EAX,dword ptr [RBP + -0x9c6c]
SUB EAX,0x1
MOVSXD RCX,EAX
MOVSXD RDX,EDX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
SHL RAX,0x2
ADD RAX,RCX
MOV EAX,dword ptr [RBP + RAX*0x4 + -0x9c50]
PXOR XMM0,XMM0
CVTSI2SD XMM0,EAX
MOV EAX,dword ptr [RBP + -0x9c6c]
ADD EAX,EAX
SUB EAX,0x1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
DIVSD XMM0,XMM1
MOV RAX,qword ptr [RBP + -0x8]
SUB RAX,qword ptr FS:[0x28]
JZ 0x001014ab
CALL 0x00101070
LAB_001014ab:
LEAVE
RET | double func0(int *param_1,int param_2)
{
int *puVar1;
int iVar2;
int *puVar3;
long in_FS_OFFSET;
int local_9c68;
int local_9c64;
int local_9c60;
int local_9c5c;
int local_9c58 [788];
int local_9008 [36856];
long local_10;
puVar1 = &stack0xfffffffffffffff8;
do {
puVar3 = puVar1;
*(int8 *)(puVar3 + -0x1000) = *(int8 *)(puVar3 + -0x1000);
puVar1 = puVar3 + -0x1000;
} while (puVar3 + -0x1000 != local_9008);
local_10 = *(long *)(in_FS_OFFSET + 0x28);
*(int8 *)(puVar3 + -0x1c78) = 0x1011e6;
memset(local_9c58,0,40000);
local_9c58[0] = *param_1;
for (local_9c68 = 1; local_9c68 < param_2; local_9c68 = local_9c68 + 1) {
local_9c58[(long)local_9c68 * 100] =
local_9c58[(long)(local_9c68 + -1) * 100] + param_1[(long)local_9c68 * 100];
}
for (local_9c64 = 1; local_9c64 < param_2; local_9c64 = local_9c64 + 1) {
local_9c58[local_9c64] = local_9c58[local_9c64 + -1] + param_1[local_9c64];
}
for (local_9c60 = 1; local_9c60 < param_2; local_9c60 = local_9c60 + 1) {
for (local_9c5c = 1; local_9c5c < param_2; local_9c5c = local_9c5c + 1) {
iVar2 = local_9c58[(long)(local_9c60 + -1) * 100 + (long)local_9c5c];
if (local_9c58[(long)(local_9c60 + -1) * 100 + (long)local_9c5c] <=
local_9c58[(long)local_9c60 * 100 + (long)(local_9c5c + -1)]) {
iVar2 = local_9c58[(long)local_9c60 * 100 + (long)(local_9c5c + -1)];
}
local_9c58[(long)local_9c60 * 100 + (long)local_9c5c] =
iVar2 + param_1[(long)local_9c60 * 100 + (long)local_9c5c];
}
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
*(int8 *)(puVar3 + -0x1c78) = 0x1014ab;
__stack_chk_fail();
}
return (double)local_9c58[(long)(param_2 + -1) * 100 + (long)(param_2 + -1)] /
(double)(param_2 * 2 + -1);
} |
6,777 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int cost[][100], int N) {
int dp[100][100] = {0};
dp[0][0] = cost[0][0];
for(int i = 1; i < N; i++) {
dp[i][0] = dp[i-1][0] + cost[i][0];
}
for(int j = 1; j < N; j++) {
dp[0][j] = dp[0][j-1] + cost[0][j];
}
for(int i = 1; i < N; i++) {
for(int j = 1; j < N; j++) {
dp[i][j] = (dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1]) + cost[i][j];
}
}
return (double)dp[N-1][N-1] / (2*N - 1);
}
| int main() {
int cost1[3][100] = { {1, 2, 3}, {6, 5, 4}, {7, 3, 9} };
assert(func0(cost1, 3) == 5.2);
int cost2[3][100] = { {2, 3, 4}, {7, 6, 5}, {8, 4, 10} };
assert(func0(cost2, 3) == 6.2);
int cost3[3][100] = { {3, 4, 5}, {8, 7, 6}, {9, 5, 11} };
assert(func0(cost3, 3) == 7.2);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
lea -0x9000(%rsp),%r11
sub $0x1000,%rsp
orq $0x0,(%rsp)
cmp %r11,%rsp
jne 1197 <func0+0xe>
sub $0xc58,%rsp
mov %rdi,%rbp
mov %esi,%ebx
mov %fs:0x28,%rax
mov %rax,0x9c48(%rsp)
xor %eax,%eax
mov %rsp,%rdi
mov $0x9c40,%edx
mov $0x0,%esi
callq 1090 <memset@plt>
mov 0x0(%rbp),%eax
mov %eax,(%rsp)
cmp $0x1,%ebx
jle 12aa <func0+0x121>
lea 0x190(%rbp),%rdx
lea 0x190(%rsp),%rdi
lea -0x2(%rbx),%r8d
lea (%r8,%r8,4),%rax
lea (%rax,%rax,4),%r9
shl $0x4,%r9
lea 0x320(%rbp,%r9,1),%rsi
mov %rdi,%rax
mov (%rdx),%ecx
add -0x190(%rax),%ecx
mov %ecx,(%rax)
add $0x190,%rdx
add $0x190,%rax
cmp %rsi,%rdx
jne 1212 <func0+0x89>
lea 0x4(%rbp),%rdx
lea 0x4(%rsp),%rax
lea 0x0(,%r8,4),%r10
lea 0x8(%rbp,%r10,1),%rsi
mov (%rdx),%ecx
add -0x4(%rax),%ecx
mov %ecx,(%rax)
add $0x4,%rdx
add $0x4,%rax
cmp %rsi,%rdx
jne 1244 <func0+0xbb>
lea 0x198(%rbp,%r10,1),%rsi
lea 0x320(%rsp,%r9,1),%r9
not %r8
shl $0x2,%r8
jmp 1284 <func0+0xfb>
add $0x190,%rdi
add $0x190,%rsi
cmp %r9,%rdi
je 12aa <func0+0x121>
lea (%r8,%rsi,1),%rcx
mov %rdi,%rdx
mov -0x18c(%rdx),%eax
cmp %eax,(%rdx)
cmovge (%rdx),%eax
add (%rcx),%eax
mov %eax,0x4(%rdx)
add $0x4,%rdx
add $0x4,%rcx
cmp %rsi,%rcx
jne 128b <func0+0x102>
jmp 1271 <func0+0xe8>
lea -0x1(%rbx),%eax
cltq
imul $0x194,%rax,%rax
pxor %xmm0,%xmm0
cvtsi2sdl (%rsp,%rax,1),%xmm0
lea -0x1(%rbx,%rbx,1),%eax
pxor %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd %xmm1,%xmm0
mov 0x9c48(%rsp),%rax
xor %fs:0x28,%rax
jne 12ec <func0+0x163>
add $0x9c58,%rsp
pop %rbx
pop %rbp
retq
callq 1070 <__stack_chk_fail@plt>
| func0:
endbr64
push rbp
push rbx
lea r11, [rsp+10h+var_9010]
loc_1197:
sub rsp, 1000h
or [rsp+1010h+var_1010], 0
cmp rsp, r11
jnz short loc_1197
sub rsp, 0C58h
mov rbp, rdi
mov ebx, esi
mov rax, fs:28h
mov [rsp+1C68h+arg_7FD8], rax
xor eax, eax
mov rdi, rsp
mov edx, 9C40h
mov esi, 0
call _memset
mov eax, [rbp+0]
mov [rsp+1C68h+var_1C68], eax
cmp ebx, 1
jle loc_12A8
lea rdx, [rbp+190h]
lea r8, [rsp+1C68h+var_1AD8]
lea r9d, [rbx-2]
lea rax, [r9+r9*4]
lea r10, [rax+rax*4]
shl r10, 4
lea rsi, [rbp+r10+320h]
mov rax, r8
loc_1212:
mov ecx, [rdx]
add ecx, [rax-190h]
mov [rax], ecx
add rdx, 190h
add rax, 190h
cmp rdx, rsi
jnz short loc_1212
lea rdx, [rbp+4]
lea rax, [rsp+1C68h+var_1C64]
lea rdi, ds:0[r9*4]
lea rsi, [rbp+rdi+8]
loc_1244:
mov ecx, [rdx]
add ecx, [rax-4]
mov [rax], ecx
add rdx, 4
add rax, 4
cmp rdx, rsi
jnz short loc_1244
lea rdi, [rbp+rdi+198h]
lea r10, [rsp+r10+1C68h+var_1948]
not r9
shl r9, 2
loc_126F:
lea rcx, [r9+rdi]
mov rdx, r8
loc_1276:
mov eax, [rdx]
mov esi, [rdx-18Ch]
cmp eax, esi
cmovl eax, esi
add eax, [rcx]
mov [rdx+4], eax
add rdx, 4
add rcx, 4
cmp rcx, rdi
jnz short loc_1276
add r8, 190h
add rdi, 190h
cmp r8, r10
jnz short loc_126F
loc_12A8:
lea eax, [rbx-1]
cdqe
imul rax, 194h
pxor xmm0, xmm0
cvtsi2sd xmm0, [rsp+rax+1C68h+var_1C68]
lea eax, [rbx+rbx-1]
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
divsd xmm0, xmm1
mov rax, [rsp+1C68h+arg_7FD8]
sub rax, fs:28h
jnz short loc_12EA
add rsp, 9C58h
pop rbx
pop rbp
retn
loc_12EA:
call ___stack_chk_fail | // positive sp value has been detected, the output may be wrong!
unsigned long long func0(int *a1, int a2)
{
int *v2; // rdx
int *v3; // r8
long long v4; // r9
_DWORD *v5; // rax
int *v6; // rdx
int *v7; // rax
long long v8; // rdi
int *v9; // r10
long long v10; // r9
_DWORD *v11; // rcx
int *v12; // rdx
int v13; // eax
int v15; // [rsp-C58h] [rbp-9C68h] BYREF
int v16; // [rsp-C54h] [rbp-9C64h] BYREF
_BYTE v17[2760]; // [rsp-AC8h] [rbp-9AD8h] BYREF
char v18; // [rsp+0h] [rbp-9010h] BYREF
long long v19; // [rsp+1000h] [rbp-8010h] BYREF
unsigned long long v20; // [rsp+8FF0h] [rbp-20h]
while ( &v18 != (char *)(&v19 - 4608) )
;
v20 = __readfsqword(0x28u);
((void ( *)(int *, _QWORD, long long))memset)(&v15, 0LL, 40000LL);
v15 = *a1;
if ( a2 > 1 )
{
v2 = a1 + 100;
v3 = (int *)v17;
v4 = (unsigned int)(a2 - 2);
v5 = v17;
do
{
*v5 = *(v5 - 100) + *v2;
v2 += 100;
v5 += 100;
}
while ( v2 != &a1[100 * v4 + 200] );
v6 = a1 + 1;
v7 = &v16;
do
{
*v7 = *(v7 - 1) + *v6++;
++v7;
}
while ( v6 != &a1[v4 + 2] );
v8 = (long long)&a1[v4 + 102];
v9 = (int *)&v17[400 * v4 + 400];
v10 = 4 * ~v4;
do
{
v11 = (_DWORD *)(v10 + v8);
v12 = v3;
do
{
v13 = *v12;
if ( *v12 < *(v12 - 99) )
v13 = *(v12 - 99);
v12[1] = *v11 + v13;
++v12;
++v11;
}
while ( v11 != (_DWORD *)v8 );
v3 += 100;
v8 += 400LL;
}
while ( v3 != v9 );
}
return v20 - __readfsqword(0x28u);
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
LEA R11,[RSP + -0x9000]
LAB_00101197:
SUB RSP,0x1000
OR qword ptr [RSP],0x0
CMP RSP,R11
JNZ 0x00101197
SUB RSP,0xc58
MOV RBP,RDI
MOV EBX,ESI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x9c48],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV EDX,0x9c40
MOV ESI,0x0
CALL 0x00101090
MOV EAX,dword ptr [RBP]
MOV dword ptr [RSP],EAX
CMP EBX,0x1
JLE 0x001012a8
LEA RDX,[RBP + 0x190]
LEA R8,[RSP + 0x190]
LEA R9D,[RBX + -0x2]
LEA RAX,[R9 + R9*0x4]
LEA R10,[RAX + RAX*0x4]
SHL R10,0x4
LEA RSI,[RBP + R10*0x1 + 0x320]
MOV RAX,R8
LAB_00101212:
MOV ECX,dword ptr [RDX]
ADD ECX,dword ptr [RAX + -0x190]
MOV dword ptr [RAX],ECX
ADD RDX,0x190
ADD RAX,0x190
CMP RDX,RSI
JNZ 0x00101212
LEA RDX,[RBP + 0x4]
LEA RAX,[RSP + 0x4]
LEA RDI,[R9*0x4]
LEA RSI,[RBP + RDI*0x1 + 0x8]
LAB_00101244:
MOV ECX,dword ptr [RDX]
ADD ECX,dword ptr [RAX + -0x4]
MOV dword ptr [RAX],ECX
ADD RDX,0x4
ADD RAX,0x4
CMP RDX,RSI
JNZ 0x00101244
LEA RDI,[RBP + RDI*0x1 + 0x198]
LEA R10,[RSP + R10*0x1 + 0x320]
NOT R9
SHL R9,0x2
LAB_0010126f:
LEA RCX,[R9 + RDI*0x1]
MOV RDX,R8
LAB_00101276:
MOV EAX,dword ptr [RDX]
MOV ESI,dword ptr [RDX + -0x18c]
CMP EAX,ESI
CMOVL EAX,ESI
ADD EAX,dword ptr [RCX]
MOV dword ptr [RDX + 0x4],EAX
ADD RDX,0x4
ADD RCX,0x4
CMP RCX,RDI
JNZ 0x00101276
ADD R8,0x190
ADD RDI,0x190
CMP R8,R10
JNZ 0x0010126f
LAB_001012a8:
LEA EAX,[RBX + -0x1]
CDQE
IMUL RAX,RAX,0x194
PXOR XMM0,XMM0
CVTSI2SD XMM0,dword ptr [RSP + RAX*0x1]
LEA EAX,[RBX + RBX*0x1 + -0x1]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
DIVSD XMM0,XMM1
MOV RAX,qword ptr [RSP + 0x9c48]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x001012ea
ADD RSP,0x9c58
POP RBX
POP RBP
RET
LAB_001012ea:
CALL 0x00101070 | double func0(int4 *param_1,int param_2)
{
int1 *puVar1;
int iVar2;
int *piVar3;
int *piVar4;
int *piVar5;
int1 *puVar6;
int *piVar7;
ulong uVar8;
long in_FS_OFFSET;
int1 local_9010 [36864];
puVar1 = &stack0xfffffffffffffff0;
do {
puVar6 = puVar1;
*(int8 *)(puVar6 + -0x1000) = *(int8 *)(puVar6 + -0x1000);
puVar1 = puVar6 + -0x1000;
} while (puVar6 + -0x1000 != local_9010);
*(int8 *)(puVar6 + 0x7ff0) = *(int8 *)(in_FS_OFFSET + 0x28);
*(int8 *)(puVar6 + -0x1c60) = 0x1011d9;
memset(puVar6 + -0x1c58,0,40000);
*(int4 *)(puVar6 + -0x1c58) = *param_1;
if (1 < param_2) {
piVar4 = param_1 + 100;
piVar7 = (int *)(puVar6 + -0x1ac8);
uVar8 = (ulong)(param_2 - 2);
piVar3 = piVar7;
do {
*piVar3 = *piVar4 + piVar3[-100];
piVar4 = piVar4 + 100;
piVar3 = piVar3 + 100;
} while (piVar4 != param_1 + uVar8 * 100 + 200);
piVar4 = param_1 + 1;
piVar3 = (int *)(puVar6 + -0x1c58);
do {
piVar3[1] = *piVar4 + *piVar3;
piVar4 = piVar4 + 1;
piVar3 = piVar3 + 1;
} while (piVar4 != param_1 + uVar8 + 2);
piVar4 = param_1 + uVar8 + 0x66;
do {
piVar3 = piVar4 + ~uVar8;
piVar5 = piVar7;
do {
iVar2 = *piVar5;
if (*piVar5 < piVar5[-99]) {
iVar2 = piVar5[-99];
}
piVar5[1] = iVar2 + *piVar3;
piVar5 = piVar5 + 1;
piVar3 = piVar3 + 1;
} while (piVar3 != piVar4);
piVar7 = piVar7 + 100;
piVar4 = piVar4 + 100;
} while (piVar7 != (int *)(puVar6 + uVar8 * 400 + -0x1938));
}
if (*(long *)(puVar6 + 0x7ff0) == *(long *)(in_FS_OFFSET + 0x28)) {
return (double)*(int *)(puVar6 + (long)(param_2 + -1) * 0x194 + -0x1c58) /
(double)(param_2 * 2 + -1);
}
/* WARNING: Subroutine does not return */
*(code **)(puVar6 + -0x1c60) = main;
__stack_chk_fail();
} |
6,778 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int cost[][100], int N) {
int dp[100][100] = {0};
dp[0][0] = cost[0][0];
for(int i = 1; i < N; i++) {
dp[i][0] = dp[i-1][0] + cost[i][0];
}
for(int j = 1; j < N; j++) {
dp[0][j] = dp[0][j-1] + cost[0][j];
}
for(int i = 1; i < N; i++) {
for(int j = 1; j < N; j++) {
dp[i][j] = (dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1]) + cost[i][j];
}
}
return (double)dp[N-1][N-1] / (2*N - 1);
}
| int main() {
int cost1[3][100] = { {1, 2, 3}, {6, 5, 4}, {7, 3, 9} };
assert(func0(cost1, 3) == 5.2);
int cost2[3][100] = { {2, 3, 4}, {7, 6, 5}, {8, 4, 10} };
assert(func0(cost2, 3) == 6.2);
int cost3[3][100] = { {3, 4, 5}, {8, 7, 6}, {9, 5, 11} };
assert(func0(cost3, 3) == 7.2);
return 0;
}
| O2 | c | func0:
endbr64
push %rbp
push %rbx
lea -0x9000(%rsp),%r11
sub $0x1000,%rsp
orq $0x0,(%rsp)
cmp %r11,%rsp
jne 13de <func0+0xe>
sub $0xc58,%rsp
mov $0x9c40,%edx
mov %fs:0x28,%rax
mov %rax,0x9c48(%rsp)
xor %eax,%eax
mov %rdi,%rbp
mov %esi,%ebx
mov %rsp,%rdi
xor %esi,%esi
callq 1090 <memset@plt>
mov 0x0(%rbp),%edx
mov %edx,(%rsp)
cmp $0x1,%ebx
jle 151b <func0+0x14b>
lea -0x2(%rbx),%edi
lea 0x190(%rbp),%rax
lea (%rdi,%rdi,4),%rcx
lea 0x190(%rsp),%rsi
lea (%rcx,%rcx,4),%rcx
shl $0x4,%rcx
lea 0x320(%rbp,%rcx,1),%r8
mov %edx,%ecx
jmp 1467 <func0+0x97>
nopw %cs:0x0(%rax,%rax,1)
add $0x190,%rsi
add (%rax),%ecx
add $0x190,%rax
mov %ecx,(%rsi)
cmp %r8,%rax
jne 1460 <func0+0x90>
lea 0x4(%rbp),%r10
lea 0x4(%rsp),%r11
lea 0x0(,%rdi,4),%r8
mov %r10,%rax
mov %r11,%rcx
lea 0x8(%rbp,%r8,1),%rsi
jmp 149c <func0+0xcc>
nopl 0x0(%rax)
add $0x4,%rcx
add (%rax),%edx
add $0x4,%rax
mov %edx,(%rcx)
cmp %rsi,%rax
jne 1498 <func0+0xc8>
imul $0xfffffffffffffe70,%rdi,%rdi
lea 0x198(%rbp,%r8,1),%r9
mov $0xfffffffffffffe70,%r8
lea -0x320(%rdi),%rbp
xor %edi,%edi
nopl 0x0(%rax,%rax,1)
mov %r10,%rcx
mov %r11,%rdx
sub %r8,%rcx
sub %r8,%rdx
nopl 0x0(%rax)
lea (%r8,%rdx,1),%rsi
mov -0x4(%rdx),%eax
cmp %eax,(%rsi,%rdi,1)
cmovge (%rsi,%rdi,1),%eax
add $0x4,%rcx
add $0x4,%rdx
add -0x4(%rcx),%eax
mov %eax,-0x4(%rdx)
cmp %r9,%rcx
jne 14e0 <func0+0x110>
sub $0x190,%r8
add $0x190,%rdi
add $0x190,%r9
cmp %rbp,%r8
jne 14d0 <func0+0x100>
lea -0x1(%rbx),%eax
pxor %xmm0,%xmm0
pxor %xmm1,%xmm1
cltq
imul $0x194,%rax,%rax
cvtsi2sdl (%rsp,%rax,1),%xmm0
lea -0x1(%rbx,%rbx,1),%eax
cvtsi2sd %eax,%xmm1
mov 0x9c48(%rsp),%rax
xor %fs:0x28,%rax
divsd %xmm1,%xmm0
jne 155d <func0+0x18d>
add $0x9c58,%rsp
pop %rbx
pop %rbp
retq
callq 1070 <__stack_chk_fail@plt>
nopw %cs:0x0(%rax,%rax,1)
nopl 0x0(%rax)
| func0:
endbr64
push rbp
push rbx
lea r11, [rsp+10h+var_9010]
loc_13DE:
sub rsp, 1000h
or [rsp+1010h+var_1010], 0
cmp rsp, r11
jnz short loc_13DE
sub rsp, 0C58h
mov edx, 9C40h
mov rax, fs:28h
mov [rsp+1C68h+arg_7FD8], rax
xor eax, eax
mov rbp, rdi
mov ebx, esi
mov rdi, rsp
xor esi, esi
call _memset
mov edx, [rbp+0]
mov [rsp+1C68h+var_1C68], edx
cmp ebx, 1
jle loc_150D
lea r9d, [rbx-2]
lea rax, [rbp+190h]
lea rcx, [r9+r9*4]
lea rsi, [rsp+1C68h+var_1AD8]
lea rdi, [rcx+rcx*4]
mov ecx, edx
shl rdi, 4
lea r8, [rbp+rdi+320h]
jmp short loc_1467
loc_1460:
add rsi, 190h
loc_1467:
add ecx, [rax]
add rax, 190h
mov [rsi], ecx
cmp rax, r8
jnz short loc_1460
lea r10, [rbp+4]
lea r11, [rsp+1C68h+var_1C64]
shl r9, 2
mov rax, r10
mov rcx, r11
lea rsi, [rbp+r9+8]
jmp short loc_1494
loc_1490:
add rcx, 4
loc_1494:
add edx, [rax]
add rax, 4
mov [rcx], edx
cmp rax, rsi
jnz short loc_1490
lea r9, [rbp+r9+198h]
mov rbp, 0FFFFFFFFFFFFFCE0h
xor r8d, r8d
sub rbp, rdi
mov rdi, 0FFFFFFFFFFFFFE70h
nop dword ptr [rax]
loc_14C0:
mov rcx, r10
mov rdx, r11
sub rcx, rdi
sub rdx, rdi
nop dword ptr [rax+00h]
loc_14D0:
lea rax, [rdi+rdx]
mov esi, [rdx-4]
mov eax, [rax+r8]
cmp eax, esi
cmovl eax, esi
add rcx, 4
add eax, [rcx-4]
add rdx, 4
mov [rdx-4], eax
cmp rcx, r9
jnz short loc_14D0
sub rdi, 190h
add r8, 190h
add r9, 190h
cmp rdi, rbp
jnz short loc_14C0
loc_150D:
lea eax, [rbx-1]
pxor xmm0, xmm0
pxor xmm1, xmm1
cdqe
imul rax, 194h
cvtsi2sd xmm0, [rsp+rax+1C68h+var_1C68]
lea eax, [rbx+rbx-1]
cvtsi2sd xmm1, eax
divsd xmm0, xmm1
mov rax, [rsp+1C68h+arg_7FD8]
sub rax, fs:28h
jnz short loc_154F
add rsp, 9C58h
pop rbx
pop rbp
retn
loc_154F:
call ___stack_chk_fail | // positive sp value has been detected, the output may be wrong!
unsigned long long func0(int *a1, int a2)
{
int v3; // edx
long long v4; // r9
int *v5; // rax
long long *v6; // rsi
int v7; // ecx
long long v8; // rdi
_DWORD *v9; // r10
long long v10; // r9
int *v11; // rax
_DWORD *i; // rcx
long long v13; // r9
long long v14; // r8
long long v15; // rbp
long long v16; // rdi
_DWORD *v17; // rcx
_BYTE *v18; // rdx
int v19; // eax
int v21; // [rsp-C58h] [rbp-9C68h] BYREF
_BYTE v22[396]; // [rsp-C54h] [rbp-9C64h] BYREF
long long v23; // [rsp-AC8h] [rbp-9AD8h] BYREF
char v24; // [rsp+0h] [rbp-9010h] BYREF
long long v25; // [rsp+1000h] [rbp-8010h] BYREF
unsigned long long v26; // [rsp+8FF0h] [rbp-20h]
while ( &v24 != (char *)(&v25 - 4608) )
;
v26 = __readfsqword(0x28u);
((void ( *)(int *, _QWORD, long long))memset)(&v21, 0LL, 40000LL);
v3 = *a1;
v21 = *a1;
if ( a2 > 1 )
{
v4 = (unsigned int)(a2 - 2);
v5 = a1 + 100;
v6 = &v23;
v7 = v3;
v8 = 400 * v4;
while ( 1 )
{
v7 += *v5;
v5 += 100;
*(_DWORD *)v6 = v7;
if ( v5 == &a1[100 * v4 + 200] )
break;
v6 += 50;
}
v9 = a1 + 1;
v10 = v4;
v11 = a1 + 1;
for ( i = v22; ; ++i )
{
v3 += *v11++;
*i = v3;
if ( v11 == &a1[v10 + 2] )
break;
}
v13 = (long long)&a1[v10 + 102];
v14 = 0LL;
v15 = -800 - v8;
v16 = -400LL;
do
{
v17 = &v9[v16 / 0xFFFFFFFFFFFFFFFCLL];
v18 = &v22[-v16];
do
{
v19 = *(_DWORD *)&v18[v16 + v14];
if ( v19 < *((_DWORD *)v18 - 1) )
v19 = *((_DWORD *)v18 - 1);
++v17;
v18 += 4;
*((_DWORD *)v18 - 1) = *(v17 - 1) + v19;
}
while ( v17 != (_DWORD *)v13 );
v16 -= 400LL;
v14 += 400LL;
v13 += 400LL;
}
while ( v16 != v15 );
}
return v26 - __readfsqword(0x28u);
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
LEA R11,[RSP + -0x9000]
LAB_001013de:
SUB RSP,0x1000
OR qword ptr [RSP],0x0
CMP RSP,R11
JNZ 0x001013de
SUB RSP,0xc58
MOV EDX,0x9c40
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x9c48],RAX
XOR EAX,EAX
MOV RBP,RDI
MOV EBX,ESI
MOV RDI,RSP
XOR ESI,ESI
CALL 0x00101090
MOV EDX,dword ptr [RBP]
MOV dword ptr [RSP],EDX
CMP EBX,0x1
JLE 0x0010150d
LEA R9D,[RBX + -0x2]
LEA RAX,[RBP + 0x190]
LEA RCX,[R9 + R9*0x4]
LEA RSI,[RSP + 0x190]
LEA RDI,[RCX + RCX*0x4]
MOV ECX,EDX
SHL RDI,0x4
LEA R8,[RBP + RDI*0x1 + 0x320]
JMP 0x00101467
LAB_00101460:
ADD RSI,0x190
LAB_00101467:
ADD ECX,dword ptr [RAX]
ADD RAX,0x190
MOV dword ptr [RSI],ECX
CMP RAX,R8
JNZ 0x00101460
LEA R10,[RBP + 0x4]
LEA R11,[RSP + 0x4]
SHL R9,0x2
MOV RAX,R10
MOV RCX,R11
LEA RSI,[RBP + R9*0x1 + 0x8]
JMP 0x00101494
LAB_00101490:
ADD RCX,0x4
LAB_00101494:
ADD EDX,dword ptr [RAX]
ADD RAX,0x4
MOV dword ptr [RCX],EDX
CMP RAX,RSI
JNZ 0x00101490
LEA R9,[RBP + R9*0x1 + 0x198]
MOV RBP,-0x320
XOR R8D,R8D
SUB RBP,RDI
MOV RDI,-0x190
NOP dword ptr [RAX]
LAB_001014c0:
MOV RCX,R10
MOV RDX,R11
SUB RCX,RDI
SUB RDX,RDI
NOP dword ptr [RAX]
LAB_001014d0:
LEA RAX,[RDI + RDX*0x1]
MOV ESI,dword ptr [RDX + -0x4]
MOV EAX,dword ptr [RAX + R8*0x1]
CMP EAX,ESI
CMOVL EAX,ESI
ADD RCX,0x4
ADD EAX,dword ptr [RCX + -0x4]
ADD RDX,0x4
MOV dword ptr [RDX + -0x4],EAX
CMP RCX,R9
JNZ 0x001014d0
SUB RDI,0x190
ADD R8,0x190
ADD R9,0x190
CMP RDI,RBP
JNZ 0x001014c0
LAB_0010150d:
LEA EAX,[RBX + -0x1]
PXOR XMM0,XMM0
PXOR XMM1,XMM1
CDQE
IMUL RAX,RAX,0x194
CVTSI2SD XMM0,dword ptr [RSP + RAX*0x1]
LEA EAX,[RBX + RBX*0x1 + -0x1]
CVTSI2SD XMM1,EAX
DIVSD XMM0,XMM1
MOV RAX,qword ptr [RSP + 0x9c48]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x0010154f
ADD RSP,0x9c58
POP RBX
POP RBP
RET
LAB_0010154f:
CALL 0x00101070 | double func0(int *param_1,int param_2)
{
int1 *puVar1;
int *piVar2;
int *piVar3;
int iVar4;
int *piVar5;
int iVar6;
int *piVar7;
int1 *puVar8;
long lVar9;
long lVar10;
ulong uVar11;
long in_FS_OFFSET;
int1 local_9010 [36864];
puVar1 = &stack0xfffffffffffffff0;
do {
puVar8 = puVar1;
*(int8 *)(puVar8 + -0x1000) = *(int8 *)(puVar8 + -0x1000);
puVar1 = puVar8 + -0x1000;
} while (puVar8 + -0x1000 != local_9010);
piVar3 = (int *)(puVar8 + -0x1c58);
*(int8 *)(puVar8 + 0x7ff0) = *(int8 *)(in_FS_OFFSET + 0x28);
*(int8 *)(puVar8 + -0x1c60) = 0x10141d;
memset(puVar8 + -0x1c58,0,40000);
iVar6 = *param_1;
*(int *)(puVar8 + -0x1c58) = iVar6;
if (1 < param_2) {
uVar11 = (ulong)(param_2 - 2);
piVar2 = param_1 + 100;
iVar4 = iVar6;
do {
piVar3 = piVar3 + 100;
iVar4 = iVar4 + *piVar2;
piVar2 = piVar2 + 100;
*piVar3 = iVar4;
} while (piVar2 != param_1 + uVar11 * 100 + 200);
piVar3 = param_1 + 1;
piVar2 = (int *)(puVar8 + -0x1c54);
while( true ) {
iVar6 = iVar6 + *piVar3;
piVar3 = piVar3 + 1;
*piVar2 = iVar6;
if (piVar3 == param_1 + uVar11 + 2) break;
piVar2 = piVar2 + 1;
}
piVar3 = param_1 + uVar11 + 0x66;
lVar10 = 0;
lVar9 = -400;
do {
piVar2 = (int *)((long)(param_1 + 1) - lVar9);
piVar7 = (int *)((long)(puVar8 + -0x1c54) - lVar9);
do {
iVar6 = *(int *)((long)piVar7 + lVar10 + lVar9);
if (iVar6 < piVar7[-1]) {
iVar6 = piVar7[-1];
}
piVar5 = piVar2 + 1;
*piVar7 = iVar6 + *piVar2;
piVar2 = piVar5;
piVar7 = piVar7 + 1;
} while (piVar5 != piVar3);
lVar9 = lVar9 + -400;
lVar10 = lVar10 + 400;
piVar3 = piVar3 + 100;
} while (lVar9 != uVar11 * -400 + -800);
}
if (*(long *)(puVar8 + 0x7ff0) != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
*(code **)(puVar8 + -0x1c60) = _fini;
__stack_chk_fail();
}
return (double)*(int *)(puVar8 + (long)(param_2 + -1) * 0x194 + -0x1c58) /
(double)(param_2 * 2 + -1);
} |
6,779 | func0 |
#include <assert.h>
#include <stdio.h>
| double func0(int cost[][100], int N) {
int dp[100][100] = {0};
dp[0][0] = cost[0][0];
for(int i = 1; i < N; i++) {
dp[i][0] = dp[i-1][0] + cost[i][0];
}
for(int j = 1; j < N; j++) {
dp[0][j] = dp[0][j-1] + cost[0][j];
}
for(int i = 1; i < N; i++) {
for(int j = 1; j < N; j++) {
dp[i][j] = (dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1]) + cost[i][j];
}
}
return (double)dp[N-1][N-1] / (2*N - 1);
}
| int main() {
int cost1[3][100] = { {1, 2, 3}, {6, 5, 4}, {7, 3, 9} };
assert(func0(cost1, 3) == 5.2);
int cost2[3][100] = { {2, 3, 4}, {7, 6, 5}, {8, 4, 10} };
assert(func0(cost2, 3) == 6.2);
int cost3[3][100] = { {3, 4, 5}, {8, 7, 6}, {9, 5, 11} };
assert(func0(cost3, 3) == 7.2);
return 0;
}
| O3 | c | func0:
endbr64
push %rbp
push %rbx
lea -0x9000(%rsp),%r11
sub $0x1000,%rsp
orq $0x0,(%rsp)
cmp %r11,%rsp
jne 13de <func0+0xe>
sub $0xc58,%rsp
mov $0x9c40,%edx
mov %fs:0x28,%rax
mov %rax,0x9c48(%rsp)
xor %eax,%eax
mov %rsp,%rcx
mov %rdi,%rbx
mov %esi,%ebp
mov %rcx,%rdi
xor %esi,%esi
callq 1090 <memset@plt>
mov (%rbx),%edx
mov %edx,(%rsp)
cmp $0x1,%ebp
jle 14e0 <func0+0x110>
lea -0x2(%rbp),%r8d
mov %rax,%rcx
lea (%r8,%r8,4),%rax
lea (%rax,%rax,4),%r9
mov $0x190,%eax
shl $0x4,%r9
lea 0x320(%r9),%rsi
nopl (%rax)
add (%rbx,%rax,1),%edx
mov %edx,(%rcx,%rax,1)
add $0x190,%rax
cmp %rax,%rsi
jne 1450 <func0+0x80>
mov (%rsp),%edx
add $0x2,%r8
mov $0x1,%eax
nopl (%rax)
add (%rbx,%rax,4),%edx
mov %edx,(%rcx,%rax,4)
add $0x1,%rax
cmp %rax,%r8
jne 1470 <func0+0xa0>
lea 0x190(%rsp),%rdi
lea 0x190(%rbx),%rsi
lea 0x320(%rsp,%r9,1),%r9
nopw %cs:0x0(%rax,%rax,1)
mov (%rdi),%edx
mov $0x1,%eax
nopw 0x0(%rax,%rax,1)
cmp %edx,(%rcx,%rax,4)
cmovge (%rcx,%rax,4),%edx
add (%rsi,%rax,4),%edx
mov %edx,(%rdi,%rax,4)
add $0x1,%rax
cmp %r8,%rax
jne 14b0 <func0+0xe0>
add $0x190,%rdi
add $0x190,%rcx
add $0x190,%rsi
cmp %r9,%rdi
jne 14a0 <func0+0xd0>
lea -0x1(%rbp),%eax
pxor %xmm0,%xmm0
pxor %xmm1,%xmm1
cltq
imul $0x194,%rax,%rax
cvtsi2sdl (%rsp,%rax,1),%xmm0
lea -0x1(%rbp,%rbp,1),%eax
cvtsi2sd %eax,%xmm1
mov 0x9c48(%rsp),%rax
xor %fs:0x28,%rax
divsd %xmm1,%xmm0
jne 1522 <func0+0x152>
add $0x9c58,%rsp
pop %rbx
pop %rbp
retq
callq 1070 <__stack_chk_fail@plt>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push rbp
push rbx
lea r11, [rsp+10h+var_9010]
loc_13BE:
sub rsp, 1000h
or [rsp+1010h+var_1010], 0
cmp rsp, r11
jnz short loc_13BE
sub rsp, 0C58h
mov edx, 9C40h; n
mov rax, fs:28h
mov [rsp+1C68h+arg_7FD8], rax
xor eax, eax
mov rbx, rdi
mov ebp, esi
mov rdi, rsp; s
xor esi, esi; c
call _memset
mov edx, [rbx]
mov [rsp+1C68h+var_1C68], edx
cmp ebp, 1
jle loc_14C2
mov rdi, rax
lea eax, [rbp-2]
lea rax, [rax+rax*4]
lea r10, [rax+rax*4]
mov eax, 190h
shl r10, 4
lea rcx, [r10+320h]
nop dword ptr [rax+00000000h]
loc_1430:
add edx, [rbx+rax]
mov [rdi+rax], edx
add rax, 190h
cmp rax, rcx
jnz short loc_1430
mov edx, [rsp+1C68h+var_1C68]
mov r9d, ebp
mov eax, 1
nop dword ptr [rax+00h]
loc_1450:
add edx, [rbx+rax*4]
mov [rdi+rax*4], edx
add rax, 1
cmp r9, rax
jnz short loc_1450
lea r8, [rsp+1C68h+var_1AD8]
lea rsi, [rbx+190h]
lea r10, [rsp+r10+1C68h+var_1948]
nop word ptr [rax+rax+00000000h]
loc_1480:
mov edx, [r8]
mov eax, 1
nop dword ptr [rax+rax+00000000h]
loc_1490:
mov ecx, [rdi+rax*4]
cmp edx, ecx
cmovl edx, ecx
add edx, [rsi+rax*4]
mov [r8+rax*4], edx
add rax, 1
cmp r9, rax
jnz short loc_1490
add r8, 190h
add rdi, 190h
add rsi, 190h
cmp r8, r10
jnz short loc_1480
loc_14C2:
lea eax, [rbp-1]
pxor xmm0, xmm0
pxor xmm1, xmm1
cdqe
imul rax, 194h
cvtsi2sd xmm0, [rsp+rax+1C68h+var_1C68]
lea eax, [rbp+rbp-1]
cvtsi2sd xmm1, eax
divsd xmm0, xmm1
mov rax, [rsp+1C68h+arg_7FD8]
sub rax, fs:28h
jnz short loc_1504
add rsp, 9C58h
pop rbx
pop rbp
retn
loc_1504:
call ___stack_chk_fail | // positive sp value has been detected, the output may be wrong!
unsigned long long func0(int *a1, int a2)
{
_DWORD *v4; // rax
int v5; // edx
_DWORD *v6; // rdi
long long v7; // rax
long long v8; // r10
int v9; // edx
long long i; // rax
int *v11; // r8
_DWORD *v12; // rsi
int *v13; // r10
int v14; // edx
long long v15; // rax
int v17; // [rsp-C58h] [rbp-9C68h] BYREF
_BYTE v18[2760]; // [rsp-AC8h] [rbp-9AD8h] BYREF
char v19; // [rsp+0h] [rbp-9010h] BYREF
long long v20; // [rsp+1000h] [rbp-8010h] BYREF
unsigned long long v21; // [rsp+8FF0h] [rbp-20h]
while ( &v19 != (char *)(&v20 - 4608) )
;
v21 = __readfsqword(0x28u);
v4 = memset(&v17, 0, 0x9C40uLL);
v5 = *a1;
v17 = *a1;
if ( a2 > 1 )
{
v6 = v4;
v7 = 400LL;
v8 = 400LL * (unsigned int)(a2 - 2);
do
{
v5 += a1[(unsigned long long)v7 / 4];
v6[(unsigned long long)v7 / 4] = v5;
v7 += 400LL;
}
while ( v7 != v8 + 800 );
v9 = v17;
for ( i = 1LL; i != a2; v6[i++] = v9 )
v9 += a1[i];
v11 = (int *)v18;
v12 = a1 + 100;
v13 = (int *)&v18[v8 + 400];
do
{
v14 = *v11;
v15 = 1LL;
do
{
if ( v14 < v6[v15] )
v14 = v6[v15];
v14 += v12[v15];
v11[v15++] = v14;
}
while ( a2 != v15 );
v11 += 100;
v6 += 100;
v12 += 100;
}
while ( v11 != v13 );
}
return v21 - __readfsqword(0x28u);
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
LEA R11,[RSP + -0x9000]
LAB_001013be:
SUB RSP,0x1000
OR qword ptr [RSP],0x0
CMP RSP,R11
JNZ 0x001013be
SUB RSP,0xc58
MOV EDX,0x9c40
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x9c48],RAX
XOR EAX,EAX
MOV RBX,RDI
MOV EBP,ESI
MOV RDI,RSP
XOR ESI,ESI
CALL 0x00101090
MOV EDX,dword ptr [RBX]
MOV dword ptr [RSP],EDX
CMP EBP,0x1
JLE 0x001014c2
MOV RDI,RAX
LEA EAX,[RBP + -0x2]
LEA RAX,[RAX + RAX*0x4]
LEA R10,[RAX + RAX*0x4]
MOV EAX,0x190
SHL R10,0x4
LEA RCX,[R10 + 0x320]
NOP dword ptr [RAX]
LAB_00101430:
ADD EDX,dword ptr [RBX + RAX*0x1]
MOV dword ptr [RDI + RAX*0x1],EDX
ADD RAX,0x190
CMP RAX,RCX
JNZ 0x00101430
MOV EDX,dword ptr [RSP]
MOV R9D,EBP
MOV EAX,0x1
NOP dword ptr [RAX]
LAB_00101450:
ADD EDX,dword ptr [RBX + RAX*0x4]
MOV dword ptr [RDI + RAX*0x4],EDX
ADD RAX,0x1
CMP R9,RAX
JNZ 0x00101450
LEA R8,[RSP + 0x190]
LEA RSI,[RBX + 0x190]
LEA R10,[RSP + R10*0x1 + 0x320]
NOP word ptr CS:[RAX + RAX*0x1]
LAB_00101480:
MOV EDX,dword ptr [R8]
MOV EAX,0x1
NOP dword ptr [RAX + RAX*0x1]
LAB_00101490:
MOV ECX,dword ptr [RDI + RAX*0x4]
CMP EDX,ECX
CMOVL EDX,ECX
ADD EDX,dword ptr [RSI + RAX*0x4]
MOV dword ptr [R8 + RAX*0x4],EDX
ADD RAX,0x1
CMP R9,RAX
JNZ 0x00101490
ADD R8,0x190
ADD RDI,0x190
ADD RSI,0x190
CMP R8,R10
JNZ 0x00101480
LAB_001014c2:
LEA EAX,[RBP + -0x1]
PXOR XMM0,XMM0
PXOR XMM1,XMM1
CDQE
IMUL RAX,RAX,0x194
CVTSI2SD XMM0,dword ptr [RSP + RAX*0x1]
LEA EAX,[RBP + RBP*0x1 + -0x1]
CVTSI2SD XMM1,EAX
DIVSD XMM0,XMM1
MOV RAX,qword ptr [RSP + 0x9c48]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101504
ADD RSP,0x9c58
POP RBX
POP RBP
RET
LAB_00101504:
CALL 0x00101070 | double func0(int *param_1,uint param_2)
{
int iVar1;
int *puVar2;
void *pvVar3;
long lVar4;
ulong uVar5;
int iVar6;
int *puVar7;
int *piVar8;
long lVar9;
long in_FS_OFFSET;
int local_9010 [36864];
puVar2 = &stack0xfffffffffffffff0;
do {
puVar7 = puVar2;
*(int8 *)(puVar7 + -0x1000) = *(int8 *)(puVar7 + -0x1000);
puVar2 = puVar7 + -0x1000;
} while (puVar7 + -0x1000 != local_9010);
*(int8 *)(puVar7 + 0x7ff0) = *(int8 *)(in_FS_OFFSET + 0x28);
*(int8 *)(puVar7 + -0x1c60) = 0x1013fd;
pvVar3 = memset(puVar7 + -0x1c58,0,40000);
iVar6 = *param_1;
*(int *)(puVar7 + -0x1c58) = iVar6;
if (1 < (int)param_2) {
lVar4 = 400;
lVar9 = (ulong)(param_2 - 2) * 400;
do {
iVar6 = iVar6 + *(int *)((long)param_1 + lVar4);
*(int *)((long)pvVar3 + lVar4) = iVar6;
lVar4 = lVar4 + 400;
} while (lVar4 != lVar9 + 800);
iVar6 = *(int *)(puVar7 + -0x1c58);
uVar5 = 1;
do {
iVar6 = iVar6 + param_1[uVar5];
*(int *)((long)pvVar3 + uVar5 * 4) = iVar6;
uVar5 = uVar5 + 1;
} while (param_2 != uVar5);
piVar8 = (int *)(puVar7 + -0x1ac8);
param_1 = param_1 + 100;
do {
iVar6 = *piVar8;
uVar5 = 1;
do {
iVar1 = *(int *)((long)pvVar3 + uVar5 * 4);
if (iVar6 < iVar1) {
iVar6 = iVar1;
}
iVar6 = iVar6 + param_1[uVar5];
piVar8[uVar5] = iVar6;
uVar5 = uVar5 + 1;
} while (param_2 != uVar5);
piVar8 = piVar8 + 100;
pvVar3 = (void *)((long)pvVar3 + 400);
param_1 = param_1 + 100;
} while (piVar8 != (int *)(puVar7 + lVar9 + -0x1938));
}
if (*(long *)(puVar7 + 0x7ff0) == *(long *)(in_FS_OFFSET + 0x28)) {
return (double)*(int *)(puVar7 + (long)(int)(param_2 - 1) * 0x194 + -0x1c58) /
(double)(int)(param_2 * 2 + -1);
}
/* WARNING: Subroutine does not return */
*(int8 *)(puVar7 + -0x1c60) = 0x101509;
__stack_chk_fail();
} |
6,780 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
typedef struct {
double height;
double weight;
} StudentDetails;
typedef struct {
char name[50];
StudentDetails details;
} Student;
| int func0(Student students[], int count, double h, double w, Student result[]) {
int index = 0;
for (int i = 0; i < count; i++) {
if (students[i].details.height >= h && students[i].details.weight >= w) {
result[index++] = students[i];
}
}
return index;
}
| int main() {
Student students[] = {
{"Cierra Vega", {6.2, 70}},
{"Alden Cantrell", {5.9, 65}},
{"Kierra Gentry", {6.0, 68}},
{"Pierre Cox", {5.8, 66}}
};
Student result[4];
int count;
count = func0(students, 4, 6.0, 70, result);
assert(count == 1 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70);
count = func0(students, 4, 5.9, 67, result);
assert(count == 2 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70
&& strcmp(result[1].name, "Kierra Gentry") == 0 && result[1].details.height == 6.0 && result[1].details.weight == 68);
count = func0(students, 4, 5.7, 64, result);
assert(count == 4 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70
&& strcmp(result[1].name, "Alden Cantrell") == 0 && result[1].details.height == 5.9 && result[1].details.weight == 65
&& strcmp(result[2].name, "Kierra Gentry") == 0 && result[2].details.height == 6.0 && result[2].details.weight == 68
&& strcmp(result[3].name, "Pierre Cox") == 0 && result[3].details.height == 5.8 && result[3].details.weight == 66);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
push %rbx
mov %rdi,-0x20(%rbp)
mov %esi,-0x24(%rbp)
movsd %xmm0,-0x30(%rbp)
movsd %xmm1,-0x38(%rbp)
mov %rdx,-0x40(%rbp)
movl $0x0,-0x10(%rbp)
movl $0x0,-0xc(%rbp)
jmpq 12a2 <func0+0x119>
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
add %rdx,%rax
shl $0x3,%rax
mov %rax,%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
movsd 0x38(%rax),%xmm0
comisd -0x30(%rbp),%xmm0
jb 129e <func0+0x115>
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
add %rdx,%rax
shl $0x3,%rax
mov %rax,%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
movsd 0x40(%rax),%xmm0
comisd -0x38(%rbp),%xmm0
jb 129e <func0+0x115>
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
add %rdx,%rax
shl $0x3,%rax
mov %rax,%rdx
mov -0x20(%rbp),%rax
add %rax,%rdx
mov -0x10(%rbp),%eax
lea 0x1(%rax),%ecx
mov %ecx,-0x10(%rbp)
movslq %eax,%rcx
mov %rcx,%rax
shl $0x3,%rax
add %rcx,%rax
shl $0x3,%rax
mov %rax,%rcx
mov -0x40(%rbp),%rax
add %rcx,%rax
mov (%rdx),%rcx
mov 0x8(%rdx),%rbx
mov %rcx,(%rax)
mov %rbx,0x8(%rax)
mov 0x10(%rdx),%rcx
mov 0x18(%rdx),%rbx
mov %rcx,0x10(%rax)
mov %rbx,0x18(%rax)
mov 0x20(%rdx),%rcx
mov 0x28(%rdx),%rbx
mov %rcx,0x20(%rax)
mov %rbx,0x28(%rax)
mov 0x30(%rdx),%rcx
mov 0x38(%rdx),%rbx
mov %rcx,0x30(%rax)
mov %rbx,0x38(%rax)
mov 0x40(%rdx),%rdx
mov %rdx,0x40(%rax)
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x24(%rbp),%eax
jl 11ba <func0+0x31>
mov -0x10(%rbp),%eax
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
push rbx
mov [rbp+var_20], rdi
mov [rbp+var_24], esi
movsd [rbp+var_30], xmm0
movsd [rbp+var_38], xmm1
mov [rbp+var_40], rdx
mov [rbp+var_10], 0
mov [rbp+var_C], 0
jmp loc_12A2
loc_11BA:
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
add rax, rdx
shl rax, 3
mov rdx, rax
mov rax, [rbp+var_20]
add rax, rdx
movsd xmm0, qword ptr [rax+38h]
comisd xmm0, [rbp+var_30]
jb loc_129E
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
add rax, rdx
shl rax, 3
mov rdx, rax
mov rax, [rbp+var_20]
add rax, rdx
movsd xmm0, qword ptr [rax+40h]
comisd xmm0, [rbp+var_38]
jb loc_129E
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
add rax, rdx
shl rax, 3
mov rdx, rax
mov rax, [rbp+var_20]
add rdx, rax
mov eax, [rbp+var_10]
lea ecx, [rax+1]
mov [rbp+var_10], ecx
movsxd rcx, eax
mov rax, rcx
shl rax, 3
add rax, rcx
shl rax, 3
mov rcx, rax
mov rax, [rbp+var_40]
add rax, rcx
mov rcx, [rdx]
mov rbx, [rdx+8]
mov [rax], rcx
mov [rax+8], rbx
mov rcx, [rdx+10h]
mov rbx, [rdx+18h]
mov [rax+10h], rcx
mov [rax+18h], rbx
mov rcx, [rdx+20h]
mov rbx, [rdx+28h]
mov [rax+20h], rcx
mov [rax+28h], rbx
mov rcx, [rdx+30h]
mov rbx, [rdx+38h]
mov [rax+30h], rcx
mov [rax+38h], rbx
mov rdx, [rdx+40h]
mov [rax+40h], rdx
loc_129E:
add [rbp+var_C], 1
loc_12A2:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_24]
jl loc_11BA
mov eax, [rbp+var_10]
mov rbx, [rbp+var_8]
leave
retn | long long func0(long long a1, int a2, long long a3, double a4, double a5)
{
_QWORD *v5; // rdx
int v6; // eax
_QWORD *v7; // rax
long long v8; // rbx
long long v9; // rbx
long long v10; // rbx
long long v11; // rbx
unsigned int v14; // [rsp+30h] [rbp-10h]
int i; // [rsp+34h] [rbp-Ch]
v14 = 0;
for ( i = 0; i < a2; ++i )
{
if ( *(double *)(72LL * i + a1 + 56) >= a4 && *(double *)(72LL * i + a1 + 64) >= a5 )
{
v5 = (_QWORD *)(a1 + 72LL * i);
v6 = v14++;
v7 = (_QWORD *)(72LL * v6 + a3);
v8 = v5[1];
*v7 = *v5;
v7[1] = v8;
v9 = v5[3];
v7[2] = v5[2];
v7[3] = v9;
v10 = v5[5];
v7[4] = v5[4];
v7[5] = v10;
v11 = v5[7];
v7[6] = v5[6];
v7[7] = v11;
v7[8] = v5[8];
}
}
return v14;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
PUSH RBX
MOV qword ptr [RBP + -0x20],RDI
MOV dword ptr [RBP + -0x24],ESI
MOVSD qword ptr [RBP + -0x30],XMM0
MOVSD qword ptr [RBP + -0x38],XMM1
MOV qword ptr [RBP + -0x40],RDX
MOV dword ptr [RBP + -0x10],0x0
MOV dword ptr [RBP + -0xc],0x0
JMP 0x001012a2
LAB_001011ba:
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
ADD RAX,RDX
SHL RAX,0x3
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOVSD XMM0,qword ptr [RAX + 0x38]
COMISD XMM0,qword ptr [RBP + -0x30]
JC 0x0010129e
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
ADD RAX,RDX
SHL RAX,0x3
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOVSD XMM0,qword ptr [RAX + 0x40]
COMISD XMM0,qword ptr [RBP + -0x38]
JC 0x0010129e
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
ADD RAX,RDX
SHL RAX,0x3
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x10]
LEA ECX,[RAX + 0x1]
MOV dword ptr [RBP + -0x10],ECX
MOVSXD RCX,EAX
MOV RAX,RCX
SHL RAX,0x3
ADD RAX,RCX
SHL RAX,0x3
MOV RCX,RAX
MOV RAX,qword ptr [RBP + -0x40]
ADD RAX,RCX
MOV RCX,qword ptr [RDX]
MOV RBX,qword ptr [RDX + 0x8]
MOV qword ptr [RAX],RCX
MOV qword ptr [RAX + 0x8],RBX
MOV RCX,qword ptr [RDX + 0x10]
MOV RBX,qword ptr [RDX + 0x18]
MOV qword ptr [RAX + 0x10],RCX
MOV qword ptr [RAX + 0x18],RBX
MOV RCX,qword ptr [RDX + 0x20]
MOV RBX,qword ptr [RDX + 0x28]
MOV qword ptr [RAX + 0x20],RCX
MOV qword ptr [RAX + 0x28],RBX
MOV RCX,qword ptr [RDX + 0x30]
MOV RBX,qword ptr [RDX + 0x38]
MOV qword ptr [RAX + 0x30],RCX
MOV qword ptr [RAX + 0x38],RBX
MOV RDX,qword ptr [RDX + 0x40]
MOV qword ptr [RAX + 0x40],RDX
LAB_0010129e:
ADD dword ptr [RBP + -0xc],0x1
LAB_001012a2:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x24]
JL 0x001011ba
MOV EAX,dword ptr [RBP + -0x10]
MOV RBX,qword ptr [RBP + -0x8]
LEAVE
RET | int func0(double param_1,double param_2,long param_3,int param_4,long param_5)
{
int8 uVar1;
int8 *puVar2;
int8 *puVar3;
int local_18;
int local_14;
local_18 = 0;
for (local_14 = 0; local_14 < param_4; local_14 = local_14 + 1) {
if ((param_1 <= *(double *)(param_3 + (long)local_14 * 0x48 + 0x38)) &&
(param_2 <= *(double *)(param_3 + (long)local_14 * 0x48 + 0x40))) {
puVar3 = (int8 *)((long)local_14 * 0x48 + param_3);
puVar2 = (int8 *)(param_5 + (long)local_18 * 0x48);
uVar1 = puVar3[1];
*puVar2 = *puVar3;
puVar2[1] = uVar1;
uVar1 = puVar3[3];
puVar2[2] = puVar3[2];
puVar2[3] = uVar1;
uVar1 = puVar3[5];
puVar2[4] = puVar3[4];
puVar2[5] = uVar1;
uVar1 = puVar3[7];
puVar2[6] = puVar3[6];
puVar2[7] = uVar1;
puVar2[8] = puVar3[8];
local_18 = local_18 + 1;
}
}
return local_18;
} |
6,781 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
typedef struct {
double height;
double weight;
} StudentDetails;
typedef struct {
char name[50];
StudentDetails details;
} Student;
| int func0(Student students[], int count, double h, double w, Student result[]) {
int index = 0;
for (int i = 0; i < count; i++) {
if (students[i].details.height >= h && students[i].details.weight >= w) {
result[index++] = students[i];
}
}
return index;
}
| int main() {
Student students[] = {
{"Cierra Vega", {6.2, 70}},
{"Alden Cantrell", {5.9, 65}},
{"Kierra Gentry", {6.0, 68}},
{"Pierre Cox", {5.8, 66}}
};
Student result[4];
int count;
count = func0(students, 4, 6.0, 70, result);
assert(count == 1 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70);
count = func0(students, 4, 5.9, 67, result);
assert(count == 2 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70
&& strcmp(result[1].name, "Kierra Gentry") == 0 && result[1].details.height == 6.0 && result[1].details.weight == 68);
count = func0(students, 4, 5.7, 64, result);
assert(count == 4 && strcmp(result[0].name, "Cierra Vega") == 0 && result[0].details.height == 6.2 && result[0].details.weight == 70
&& strcmp(result[1].name, "Alden Cantrell") == 0 && result[1].details.height == 5.9 && result[1].details.weight == 65
&& strcmp(result[2].name, "Kierra Gentry") == 0 && result[2].details.height == 6.0 && result[2].details.weight == 68
&& strcmp(result[3].name, "Pierre Cox") == 0 && result[3].details.height == 5.8 && result[3].details.weight == 66);
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 11e2 <func0+0x79>
mov %rdi,%rax
lea -0x1(%rsi),%ecx
lea (%rcx,%rcx,8),%rcx
lea 0x48(%rdi,%rcx,8),%rdi
mov $0x0,%r8d
jmp 1191 <func0+0x28>
add $0x48,%rax
cmp %rdi,%rax
je 11e8 <func0+0x7f>
movsd 0x38(%rax),%xmm2
comisd %xmm0,%xmm2
jb 1188 <func0+0x1f>
movsd 0x40(%rax),%xmm2
comisd %xmm1,%xmm2
jb 1188 <func0+0x1f>
movslq %r8d,%rsi
lea (%rsi,%rsi,8),%rsi
lea (%rdx,%rsi,8),%rsi
movdqu (%rax),%xmm3
movups %xmm3,(%rsi)
movdqu 0x10(%rax),%xmm4
movups %xmm4,0x10(%rsi)
movdqu 0x20(%rax),%xmm5
movups %xmm5,0x20(%rsi)
movdqu 0x30(%rax),%xmm6
movups %xmm6,0x30(%rsi)
mov 0x40(%rax),%rcx
mov %rcx,0x40(%rsi)
lea 0x1(%r8),%r8d
jmp 1188 <func0+0x1f>
mov $0x0,%r8d
mov %r8d,%eax
retq
| func0:
endbr64
test esi, esi
jle short loc_1202
mov rax, rdi
lea ecx, [rsi-1]
lea rcx, [rcx+rcx*8]
lea rdi, [rdi+rcx*8+48h]
mov r8d, 0
jmp short loc_11B1
loc_11A8:
add rax, 48h ; 'H'
cmp rax, rdi
jz short loc_1208
loc_11B1:
movsd xmm2, qword ptr [rax+38h]
comisd xmm2, xmm0
jb short loc_11A8
movsd xmm2, qword ptr [rax+40h]
comisd xmm2, xmm1
jb short loc_11A8
movsxd rsi, r8d
lea rsi, [rsi+rsi*8]
lea rsi, [rdx+rsi*8]
movdqu xmm3, xmmword ptr [rax]
movups xmmword ptr [rsi], xmm3
movdqu xmm4, xmmword ptr [rax+10h]
movups xmmword ptr [rsi+10h], xmm4
movdqu xmm5, xmmword ptr [rax+20h]
movups xmmword ptr [rsi+20h], xmm5
movdqu xmm6, xmmword ptr [rax+30h]
movups xmmword ptr [rsi+30h], xmm6
mov rcx, [rax+40h]
mov [rsi+40h], rcx
lea r8d, [r8+1]
jmp short loc_11A8
loc_1202:
mov r8d, 0
loc_1208:
mov eax, r8d
retn | long long func0(long long a1, int a2, long long a3, double a4, double a5)
{
long long v5; // rax
long long v6; // rdi
unsigned int v7; // r8d
__m128i *v8; // rsi
if ( a2 <= 0 )
{
return 0;
}
else
{
v5 = a1;
v6 = a1 + 72LL * (unsigned int)(a2 - 1) + 72;
v7 = 0;
do
{
if ( *(double *)(v5 + 56) >= a4 && *(double *)(v5 + 64) >= a5 )
{
v8 = (__m128i *)(a3 + 72LL * (int)v7);
*v8 = _mm_loadu_si128((const __m128i *)v5);
v8[1] = _mm_loadu_si128((const __m128i *)(v5 + 16));
v8[2] = _mm_loadu_si128((const __m128i *)(v5 + 32));
v8[3] = _mm_loadu_si128((const __m128i *)(v5 + 48));
v8[4].m128i_i64[0] = *(_QWORD *)(v5 + 64);
++v7;
}
v5 += 72LL;
}
while ( v5 != v6 );
}
return v7;
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x00101202
MOV RAX,RDI
LEA ECX,[RSI + -0x1]
LEA RCX,[RCX + RCX*0x8]
LEA RDI,[RDI + RCX*0x8 + 0x48]
MOV R8D,0x0
JMP 0x001011b1
LAB_001011a8:
ADD RAX,0x48
CMP RAX,RDI
JZ 0x00101208
LAB_001011b1:
MOVSD XMM2,qword ptr [RAX + 0x38]
COMISD XMM2,XMM0
JC 0x001011a8
MOVSD XMM2,qword ptr [RAX + 0x40]
COMISD XMM2,XMM1
JC 0x001011a8
MOVSXD RSI,R8D
LEA RSI,[RSI + RSI*0x8]
LEA RSI,[RDX + RSI*0x8]
MOVDQU XMM3,xmmword ptr [RAX]
MOVUPS xmmword ptr [RSI],XMM3
MOVDQU XMM4,xmmword ptr [RAX + 0x10]
MOVUPS xmmword ptr [RSI + 0x10],XMM4
MOVDQU XMM5,xmmword ptr [RAX + 0x20]
MOVUPS xmmword ptr [RSI + 0x20],XMM5
MOVDQU XMM6,xmmword ptr [RAX + 0x30]
MOVUPS xmmword ptr [RSI + 0x30],XMM6
MOV RCX,qword ptr [RAX + 0x40]
MOV qword ptr [RSI + 0x40],RCX
LEA R8D,[R8 + 0x1]
JMP 0x001011a8
LAB_00101202:
MOV R8D,0x0
LAB_00101208:
MOV EAX,R8D
RET | int func0(double param_1,double param_2,int8 *param_3,int param_4,long param_5)
{
int8 *puVar1;
int8 *puVar2;
int8 uVar3;
int iVar4;
if (param_4 < 1) {
iVar4 = 0;
}
else {
puVar2 = param_3 + (ulong)(param_4 - 1) * 9 + 9;
iVar4 = 0;
do {
if ((param_1 <= (double)param_3[7]) && (param_2 <= (double)param_3[8])) {
puVar1 = (int8 *)(param_5 + (long)iVar4 * 0x48);
uVar3 = param_3[1];
*puVar1 = *param_3;
puVar1[1] = uVar3;
uVar3 = param_3[3];
puVar1[2] = param_3[2];
puVar1[3] = uVar3;
uVar3 = param_3[5];
puVar1[4] = param_3[4];
puVar1[5] = uVar3;
uVar3 = param_3[7];
puVar1[6] = param_3[6];
puVar1[7] = uVar3;
puVar1[8] = param_3[8];
iVar4 = iVar4 + 1;
}
param_3 = param_3 + 9;
} while (param_3 != puVar2);
}
return iVar4;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.