index
int64 0
66.5k
| func_name
stringlengths 2
5.36k
| func_dep
stringlengths 16
2.19k
| func
stringlengths 8
55.3k
| test
stringlengths 0
7.07k
| opt
stringclasses 4
values | language
stringclasses 2
values | asm
stringlengths 0
45.4k
| ida_asm
stringlengths 0
44.7k
| ida_pseudo
stringlengths 0
44.3k
| ghidra_asm
stringlengths 0
49.1k
| ghidra_pseudo
stringlengths 0
64.7k
|
---|---|---|---|---|---|---|---|---|---|---|---|
5,782 | func0 |
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
| bool func0(int *l, int size) {
int *sorted = malloc(size * sizeof(int));
for (int i = 0; i < size; i++) {
sorted[i] = l[i];
}
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if (sorted[i] > sorted[j]) {
int temp = sorted[i];
sorted[i] = sorted[j];
sorted[j] = temp;
}
}
}
bool result = true;
for (int i = 1; i < size; i++) {
if (sorted[i] != sorted[i - 1] + 1) {
result = false;
break;
}
}
free(sorted);
return result;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 5};
int arr2[] = {1, 2, 3, 5, 6};
int arr3[] = {1, 2, 1};
assert(func0(arr1, sizeof(arr1) / sizeof(arr1[0])) == true);
assert(func0(arr2, sizeof(arr2) / sizeof(arr2[0])) == false);
assert(func0(arr3, sizeof(arr3) / sizeof(arr3[0])) == false);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
push %rbp
mov %rdi,%rbp
movslq %esi,%rdi
push %rbx
mov %rdi,%rbx
shl $0x2,%rdi
callq 10b0 <malloc@plt>
mov %rax,%r9
test %ebx,%ebx
jle 1396 <func0+0xc6>
lea -0x1(%rbx),%ecx
xor %eax,%eax
lea 0x1(%rcx),%rsi
xchg %ax,%ax
mov 0x0(%rbp,%rax,4),%edx
mov %edx,(%r9,%rax,4)
mov %rax,%rdx
add $0x1,%rax
cmp %rcx,%rdx
jne 1300 <func0+0x30>
mov $0x1,%eax
mov %r9,%r8
cmp %rsi,%rax
je 1357 <func0+0x87>
nopl 0x0(%rax)
mov %rax,%rdx
nopl 0x0(%rax,%rax,1)
mov (%r8),%ecx
mov (%r9,%rdx,4),%edi
cmp %edi,%ecx
jle 1342 <func0+0x72>
mov %edi,(%r8)
mov %ecx,(%r9,%rdx,4)
add $0x1,%rdx
cmp %edx,%ebx
jg 1330 <func0+0x60>
add $0x1,%rax
add $0x4,%r8
cmp %rsi,%rax
jne 1328 <func0+0x58>
cmp $0x1,%ebx
jle 1396 <func0+0xc6>
lea -0x2(%rbx),%edx
mov %r9,%rax
lea 0x4(%r9,%rdx,4),%rcx
jmp 1379 <func0+0xa9>
nopl 0x0(%rax)
add $0x4,%rax
cmp %rax,%rcx
je 1396 <func0+0xc6>
mov (%rax),%esi
lea 0x1(%rsi),%edx
cmp %edx,0x4(%rax)
je 1370 <func0+0xa0>
xor %r12d,%r12d
mov %r9,%rdi
callq 1080 <free@plt>
mov %r12d,%eax
pop %rbx
pop %rbp
pop %r12
retq
mov $0x1,%r12d
mov %r9,%rdi
callq 1080 <free@plt>
mov %r12d,%eax
pop %rbx
pop %rbp
pop %r12
retq
nopl 0x0(%rax)
| func0:
endbr64
push r13
mov r13, rdi
movsxd rdi, esi
push r12
mov r12, rdi
shl rdi, 2
push rbp
push rbx
sub rsp, 8
call _malloc
mov r9, rax
test r12d, r12d
jle loc_13B8
mov ebp, r12d
mov rsi, r13
lea ebx, [r12-1]
mov rdi, rax
lea rdx, ds:0[rbp*4]
call _memcpy
mov r8d, 1
mov r9, rax
lea rsi, [rax+4]
lea r10, [rax+8]
cmp rbp, r8
jz short loc_138C
nop dword ptr [rax]
loc_1350:
mov eax, ebx
sub eax, r8d
lea rax, [r8+rax-1]
lea rdi, [r10+rax*4]
mov rax, rsi
nop dword ptr [rax+00000000h]
loc_1368:
mov edx, [rsi-4]
mov ecx, [rax]
cmp edx, ecx
jle short loc_1376
mov [rsi-4], ecx
mov [rax], edx
loc_1376:
add rax, 4
cmp rax, rdi
jnz short loc_1368
add r8, 1
add rsi, 4
cmp rbp, r8
jnz short loc_1350
loc_138C:
cmp r12d, 1
jle short loc_13B8
mov rax, r9
lea rcx, [r9+rbx*4]
jmp short loc_13A9
loc_13A0:
add rax, 4
cmp rcx, rax
jz short loc_13B8
loc_13A9:
mov ebx, [rax]
lea edx, [rbx+1]
cmp [rax+4], edx
jz short loc_13A0
xor r12d, r12d
jmp short loc_13BE
loc_13B8:
mov r12d, 1
loc_13BE:
mov rdi, r9
call _free
add rsp, 8
mov eax, r12d
pop rbx
pop rbp
pop r12
pop r13
retn | long long func0(long long a1, _DWORD *a2)
{
int v2; // r12d
long long v3; // rax
long long v4; // rdx
unsigned long long v5; // rcx
long long v6; // r8
_DWORD *v7; // r9
long long v8; // rbx
long long v9; // rax
long long v10; // r8
long long i; // r10
_DWORD *v12; // rax
_DWORD *v13; // rax
unsigned int v14; // r12d
v2 = (int)a2;
v3 = malloc(4LL * (int)a2);
v7 = (_DWORD *)v3;
if ( (int)a2 <= 0 )
goto LABEL_13;
v8 = (unsigned int)((_DWORD)a2 - 1);
v9 = memcpy(v3, a1, 4LL * (unsigned int)a2, v5, v6, v3);
v10 = 1LL;
v7 = (_DWORD *)v9;
a2 = (_DWORD *)(v9 + 4);
for ( i = v9 + 8; v2 != v10; ++a2 )
{
v12 = a2;
do
{
v4 = (unsigned int)*(a2 - 1);
v5 = (unsigned int)*v12;
if ( (int)v4 > (int)v5 )
{
*(a2 - 1) = v5;
*v12 = v4;
}
++v12;
}
while ( v12 != (_DWORD *)(i + 4 * (v10 + (unsigned int)(v8 - v10) - 1)) );
++v10;
}
if ( v2 <= 1 )
{
LABEL_13:
v14 = 1;
}
else
{
v13 = v7;
v5 = (unsigned long long)&v7[v8];
while ( 1 )
{
v4 = (unsigned int)(*v13 + 1);
if ( v13[1] != (_DWORD)v4 )
break;
if ( (_DWORD *)v5 == ++v13 )
goto LABEL_13;
}
v14 = 0;
}
free(v7, a2, v4, v5);
return v14;
} | func0:
ENDBR64
PUSH R13
MOV R13,RDI
MOVSXD RDI,ESI
PUSH R12
MOV R12,RDI
SHL RDI,0x2
PUSH RBP
PUSH RBX
SUB RSP,0x8
CALL 0x001010d0
MOV R9,RAX
TEST R12D,R12D
JLE 0x001013b8
MOV EBP,R12D
MOV RSI,R13
LEA EBX,[R12 + -0x1]
MOV RDI,RAX
LEA RDX,[RBP*0x4]
CALL 0x001010c0
MOV R8D,0x1
MOV R9,RAX
LEA RSI,[RAX + 0x4]
LEA R10,[RAX + 0x8]
CMP RBP,R8
JZ 0x0010138c
NOP dword ptr [RAX]
LAB_00101350:
MOV EAX,EBX
SUB EAX,R8D
LEA RAX,[R8 + RAX*0x1 + -0x1]
LEA RDI,[R10 + RAX*0x4]
MOV RAX,RSI
NOP dword ptr [RAX]
LAB_00101368:
MOV EDX,dword ptr [RSI + -0x4]
MOV ECX,dword ptr [RAX]
CMP EDX,ECX
JLE 0x00101376
MOV dword ptr [RSI + -0x4],ECX
MOV dword ptr [RAX],EDX
LAB_00101376:
ADD RAX,0x4
CMP RAX,RDI
JNZ 0x00101368
ADD R8,0x1
ADD RSI,0x4
CMP RBP,R8
JNZ 0x00101350
LAB_0010138c:
CMP R12D,0x1
JLE 0x001013b8
MOV RAX,R9
LEA RCX,[R9 + RBX*0x4]
JMP 0x001013a9
LAB_001013a0:
ADD RAX,0x4
CMP RCX,RAX
JZ 0x001013b8
LAB_001013a9:
MOV EBX,dword ptr [RAX]
LEA EDX,[RBX + 0x1]
CMP dword ptr [RAX + 0x4],EDX
JZ 0x001013a0
XOR R12D,R12D
JMP 0x001013be
LAB_001013b8:
MOV R12D,0x1
LAB_001013be:
MOV RDI,R9
CALL 0x00101090
ADD RSP,0x8
MOV EAX,R12D
POP RBX
POP RBP
POP R12
POP R13
RET | int8 func0(void *param_1,uint param_2)
{
int iVar1;
int *__dest;
int *piVar2;
int *piVar3;
ulong uVar4;
ulong uVar5;
int8 uVar6;
__dest = (int *)malloc((long)(int)param_2 << 2);
if (0 < (int)param_2) {
uVar4 = (ulong)param_2;
__dest = (int *)memcpy(__dest,param_1,uVar4 * 4);
uVar5 = 1;
piVar3 = __dest;
if (uVar4 != 1) {
do {
piVar2 = piVar3 + 1;
do {
iVar1 = *piVar3;
if (*piVar2 < iVar1) {
*piVar3 = *piVar2;
*piVar2 = iVar1;
}
piVar2 = piVar2 + 1;
} while (piVar2 != __dest + uVar5 + ((param_2 - 1) - (int)uVar5) + 1);
uVar5 = uVar5 + 1;
piVar3 = piVar3 + 1;
} while (uVar4 != uVar5);
}
if (1 < (int)param_2) {
piVar3 = __dest;
do {
if (piVar3[1] != *piVar3 + 1) {
uVar6 = 0;
goto LAB_001013be;
}
piVar3 = piVar3 + 1;
} while (__dest + (param_2 - 1) != piVar3);
}
}
uVar6 = 1;
LAB_001013be:
free(__dest);
return uVar6;
} |
5,783 | func0 |
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
| bool func0(int *l, int size) {
int *sorted = malloc(size * sizeof(int));
for (int i = 0; i < size; i++) {
sorted[i] = l[i];
}
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if (sorted[i] > sorted[j]) {
int temp = sorted[i];
sorted[i] = sorted[j];
sorted[j] = temp;
}
}
}
bool result = true;
for (int i = 1; i < size; i++) {
if (sorted[i] != sorted[i - 1] + 1) {
result = false;
break;
}
}
free(sorted);
return result;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 5};
int arr2[] = {1, 2, 3, 5, 6};
int arr3[] = {1, 2, 1};
assert(func0(arr1, sizeof(arr1) / sizeof(arr1[0])) == true);
assert(func0(arr2, sizeof(arr2) / sizeof(arr2[0])) == false);
assert(func0(arr3, sizeof(arr3) / sizeof(arr3[0])) == false);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
push %rbp
mov %rdi,%rbp
movslq %esi,%rdi
push %rbx
mov %rdi,%rbx
shl $0x2,%rdi
callq 10d0 <malloc@plt>
mov %rax,%rdi
test %ebx,%ebx
jle 1394 <func0+0xb4>
lea -0x1(%rbx),%eax
mov %rbp,%rsi
lea 0x4(,%rax,4),%rdx
callq 10c0 <memcpy@plt>
mov %rax,%rdi
cmp $0x1,%ebx
je 1394 <func0+0xb4>
lea -0x2(%rbx),%r9d
mov %rax,%rsi
mov $0x1,%r8d
mov %r9,%r10
add $0x2,%r9
nopl 0x0(%rax)
mov %r8,%rax
nopl 0x0(%rax,%rax,1)
mov (%rsi),%edx
mov (%rdi,%rax,4),%ecx
cmp %ecx,%edx
jle 134e <func0+0x6e>
mov %ecx,(%rsi)
mov %edx,(%rdi,%rax,4)
add $0x1,%rax
cmp %eax,%ebx
jg 1340 <func0+0x60>
add $0x1,%r8
add $0x4,%rsi
cmp %r9,%r8
jne 1338 <func0+0x58>
mov (%rdi),%ecx
lea 0x4(%rdi),%rdx
lea 0x8(%rdi,%r10,4),%rsi
jmp 1379 <func0+0x99>
add $0x4,%rdx
cmp %rsi,%rdx
je 1394 <func0+0xb4>
mov %ecx,%eax
mov (%rdx),%ecx
add $0x1,%eax
cmp %eax,%ecx
je 1370 <func0+0x90>
callq 1090 <free@plt>
xor %r12d,%r12d
pop %rbx
pop %rbp
mov %r12d,%eax
pop %r12
retq
callq 1090 <free@plt>
mov $0x1,%r12d
pop %rbx
pop %rbp
mov %r12d,%eax
pop %r12
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push r12
mov r12, rdi
movsxd rdi, esi
push rbp
push rbx
mov rbx, rdi
shl rdi, 2; size
call _malloc
mov rdi, rax; ptr
test ebx, ebx
jle loc_1392
mov ebp, ebx
mov rsi, r12; src
lea rdx, ds:0[rbp*4]; n
call _memcpy
mov rdi, rax; ptr
cmp ebx, 1
jz short loc_1392
lea r9d, [rbx-2]
mov rsi, rax
mov r8d, 1
nop dword ptr [rax+00h]
loc_1330:
mov rax, r8
nop dword ptr [rax+rax+00h]
loc_1338:
mov edx, [rsi]
mov ecx, [rdi+rax*4]
cmp edx, ecx
jle short loc_1346
mov [rsi], ecx
mov [rdi+rax*4], edx
loc_1346:
add rax, 1
cmp ebx, eax
jg short loc_1338
add r8, 1
add rsi, 4
cmp r8, rbp
jnz short loc_1330
mov ecx, [rdi]
lea rdx, [rdi+4]
lea rsi, [rdi+r9*4+8]
jmp short loc_1379
loc_1370:
add rdx, 4
cmp rsi, rdx
jz short loc_1392
loc_1379:
mov eax, ecx
mov ecx, [rdx]
add eax, 1
cmp ecx, eax
jz short loc_1370
call _free
xor ebx, ebx
mov eax, ebx
pop rbx
pop rbp
pop r12
retn
loc_1392:
call _free
mov ebx, 1
mov eax, ebx
pop rbx
pop rbp
pop r12
retn | long long func0(void *src, int a2)
{
int *v4; // rdi
int *v5; // rax
int *v6; // rsi
long long v7; // r8
long long v8; // rax
int v9; // edx
int v10; // ecx
int v11; // ecx
int *v12; // rdx
int v13; // eax
v4 = (int *)malloc(4LL * a2);
if ( a2 <= 0 || (v5 = (int *)memcpy(v4, src, 4LL * (unsigned int)a2), v4 = v5, a2 == 1) )
{
LABEL_13:
free(v4);
return 1LL;
}
else
{
v6 = v5;
v7 = 1LL;
do
{
v8 = v7;
do
{
v9 = *v6;
v10 = v4[v8];
if ( *v6 > v10 )
{
*v6 = v10;
v4[v8] = v9;
}
++v8;
}
while ( a2 > (int)v8 );
++v7;
++v6;
}
while ( v7 != a2 );
v11 = *v4;
v12 = v4 + 1;
while ( 1 )
{
v13 = v11;
v11 = *v12;
if ( *v12 != v13 + 1 )
break;
if ( &v4[a2 - 2 + 2] == ++v12 )
goto LABEL_13;
}
free(v4);
return 0LL;
}
} | func0:
ENDBR64
PUSH R12
MOV R12,RDI
MOVSXD RDI,ESI
PUSH RBP
PUSH RBX
MOV RBX,RDI
SHL RDI,0x2
CALL 0x001010d0
MOV RDI,RAX
TEST EBX,EBX
JLE 0x00101392
MOV EBP,EBX
MOV RSI,R12
LEA RDX,[RBP*0x4]
CALL 0x001010c0
MOV RDI,RAX
CMP EBX,0x1
JZ 0x00101392
LEA R9D,[RBX + -0x2]
MOV RSI,RAX
MOV R8D,0x1
NOP dword ptr [RAX]
LAB_00101330:
MOV RAX,R8
NOP dword ptr [RAX + RAX*0x1]
LAB_00101338:
MOV EDX,dword ptr [RSI]
MOV ECX,dword ptr [RDI + RAX*0x4]
CMP EDX,ECX
JLE 0x00101346
MOV dword ptr [RSI],ECX
MOV dword ptr [RDI + RAX*0x4],EDX
LAB_00101346:
ADD RAX,0x1
CMP EBX,EAX
JG 0x00101338
ADD R8,0x1
ADD RSI,0x4
CMP R8,RBP
JNZ 0x00101330
MOV ECX,dword ptr [RDI]
LEA RDX,[RDI + 0x4]
LEA RSI,[RDI + R9*0x4 + 0x8]
JMP 0x00101379
LAB_00101370:
ADD RDX,0x4
CMP RSI,RDX
JZ 0x00101392
LAB_00101379:
MOV EAX,ECX
MOV ECX,dword ptr [RDX]
ADD EAX,0x1
CMP ECX,EAX
JZ 0x00101370
CALL 0x00101090
XOR EBX,EBX
MOV EAX,EBX
POP RBX
POP RBP
POP R12
RET
LAB_00101392:
CALL 0x00101090
MOV EBX,0x1
MOV EAX,EBX
POP RBX
POP RBP
POP R12
RET | int8 func0(void *param_1,uint param_2)
{
int iVar1;
int *__dest;
int iVar2;
int *piVar3;
ulong uVar4;
ulong uVar5;
__dest = (int *)malloc((long)(int)param_2 << 2);
if (0 < (int)param_2) {
__dest = (int *)memcpy(__dest,param_1,(ulong)param_2 * 4);
if (param_2 != 1) {
uVar4 = 1;
uVar5 = uVar4;
piVar3 = __dest;
do {
do {
iVar2 = *piVar3;
if (__dest[uVar4] < iVar2) {
*piVar3 = __dest[uVar4];
__dest[uVar4] = iVar2;
}
uVar4 = uVar4 + 1;
} while ((int)uVar4 < (int)param_2);
uVar4 = uVar5 + 1;
piVar3 = piVar3 + 1;
uVar5 = uVar4;
} while (uVar4 != param_2);
piVar3 = __dest + 1;
iVar2 = *__dest;
do {
iVar1 = *piVar3;
if (iVar1 != iVar2 + 1) {
free(__dest);
return 0;
}
piVar3 = piVar3 + 1;
iVar2 = iVar1;
} while (__dest + (ulong)(param_2 - 2) + 2 != piVar3);
}
}
free(__dest);
return 1;
} |
5,784 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int first;
int second;
} tuple;
// Compare two tuples for qsort and bsearch
int tuple_compare(const void *a, const void *b) {
tuple *t1 = (tuple *)a;
tuple *t2 = (tuple *)b;
if (t1->first != t2->first)
return t1->first - t2->first;
return t1->second - t2->second;
}
// Function to perform tuple intersection
| tuple* func0(tuple *list1, int size1, tuple *list2, int size2, int *res_size) {
// Sort individual tuples
for(int i = 0; i < size1; i++) {
if(list1[i].first > list1[i].second){
int temp = list1[i].first;
list1[i].first = list1[i].second;
list1[i].second = temp;
}
}
for(int i = 0; i < size2; i++) {
if(list2[i].first > list2[i].second){
int temp = list2[i].first;
list2[i].first = list2[i].second;
list2[i].second = temp;
}
}
// Sort the lists
qsort(list1, size1, sizeof(tuple), tuple_compare);
qsort(list2, size2, sizeof(tuple), tuple_compare);
// Remove duplicates
int unique1 = 0;
for(int i = 0; i < size1; i++) {
if(i == 0 || tuple_compare(&list1[i], &list1[i-1]) != 0){
list1[unique1++] = list1[i];
}
}
int unique2 = 0;
for(int i = 0; i < size2; i++) {
if(i == 0 || tuple_compare(&list2[i], &list2[i-1]) != 0){
list2[unique2++] = list2[i];
}
}
// Find intersection
tuple *res = malloc(sizeof(tuple) * (unique1 < unique2 ? unique1 : unique2));
int count = 0, i_idx = 0, j_idx = 0;
while(i_idx < unique1 && j_idx < unique2){
int cmp = tuple_compare(&list1[i_idx], &list2[j_idx]);
if(cmp == 0){
res[count++] = list1[i_idx];
i_idx++;
j_idx++;
}
else if(cmp < 0)
i_idx++;
else
j_idx++;
}
*res_size = count;
return res;
}
| int main() {
// First test
tuple list1_1[] = { {3,4}, {5,6}, {9,10}, {4,5} };
int size1_1 = 4;
tuple list2_1[] = { {5,4}, {3,4}, {6,5}, {9,11} };
int size2_1 = 4;
int res_size_1;
tuple *res1 = func0(list1_1, size1_1, list2_1, size2_1, &res_size_1);
tuple expected1[] = { {3,4}, {4,5}, {5,6} };
int expected_size1 = 3;
assert(res_size_1 == expected_size1);
for(int i=0;i<expected_size1;i++) {
assert(res1[i].first == expected1[i].first);
assert(res1[i].second == expected1[i].second);
}
free(res1);
// Second test
tuple list1_2[] = { {4,1}, {7,4}, {11,13}, {17,14} };
int size1_2 = 4;
tuple list2_2[] = { {1,4}, {7,4}, {16,12}, {10,13} };
int size2_2 = 4;
int res_size_2;
tuple *res2 = func0(list1_2, size1_2, list2_2, size2_2, &res_size_2);
tuple expected2[] = { {1,4}, {4,7} };
int expected_size2 = 2;
assert(res_size_2 == expected_size2);
for(int i=0;i<expected_size2;i++) {
assert(res2[i].first == expected2[i].first);
assert(res2[i].second == expected2[i].second);
}
free(res2);
// Third test
tuple list1_3[] = { {2,1}, {3,2}, {1,3}, {1,4} };
int size1_3 = 4;
tuple list2_3[] = { {11,2}, {2,3}, {6,2}, {1,3} };
int size2_3 = 4;
int res_size_3;
tuple *res3 = func0(list1_3, size1_3, list2_3, size2_3, &res_size_3);
tuple expected3[] = { {1,3}, {2,3} };
int expected_size3 = 2;
assert(res_size_3 == expected_size3);
for(int i=0;i<expected_size3;i++) {
assert(res3[i].first == expected3[i].first);
assert(res3[i].second == expected3[i].second);
}
free(res3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x60,%rsp
mov %rdi,-0x48(%rbp)
mov %esi,-0x4c(%rbp)
mov %rdx,-0x58(%rbp)
mov %ecx,-0x50(%rbp)
mov %r8,-0x60(%rbp)
movl $0x0,-0x38(%rbp)
jmpq 12df <func0+0xc0>
mov -0x38(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x38(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x48(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%eax
cmp %eax,%edx
jle 12db <func0+0xbc>
mov -0x38(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0xc(%rbp)
mov -0x38(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
add %rdx,%rax
mov -0x38(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x48(%rbp),%rdx
add %rcx,%rdx
mov 0x4(%rax),%eax
mov %eax,(%rdx)
mov -0x38(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
add %rax,%rdx
mov -0xc(%rbp),%eax
mov %eax,0x4(%rdx)
addl $0x1,-0x38(%rbp)
mov -0x38(%rbp),%eax
cmp -0x4c(%rbp),%eax
jl 1249 <func0+0x2a>
movl $0x0,-0x34(%rbp)
jmpq 138d <func0+0x16e>
mov -0x34(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x34(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x58(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%eax
cmp %eax,%edx
jle 1389 <func0+0x16a>
mov -0x34(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0x10(%rbp)
mov -0x34(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rdx,%rax
mov -0x34(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x58(%rbp),%rdx
add %rcx,%rdx
mov 0x4(%rax),%eax
mov %eax,(%rdx)
mov -0x34(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rax,%rdx
mov -0x10(%rbp),%eax
mov %eax,0x4(%rdx)
addl $0x1,-0x34(%rbp)
mov -0x34(%rbp),%eax
cmp -0x50(%rbp),%eax
jl 12f7 <func0+0xd8>
mov -0x4c(%rbp),%eax
movslq %eax,%rsi
mov -0x48(%rbp),%rax
lea -0x1e1(%rip),%rcx
mov $0x8,%edx
mov %rax,%rdi
callq 10a0 <qsort@plt>
mov -0x50(%rbp),%eax
movslq %eax,%rsi
mov -0x58(%rbp),%rax
lea -0x1ff(%rip),%rcx
mov $0x8,%edx
mov %rax,%rdi
callq 10a0 <qsort@plt>
movl $0x0,-0x30(%rbp)
movl $0x0,-0x2c(%rbp)
jmp 145b <func0+0x23c>
cmpl $0x0,-0x2c(%rbp)
je 1422 <func0+0x203>
mov -0x2c(%rbp),%eax
cltq
shl $0x3,%rax
lea -0x8(%rax),%rdx
mov -0x48(%rbp),%rax
add %rax,%rdx
mov -0x2c(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x48(%rbp),%rax
add %rcx,%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 11c9 <tuple_compare>
test %eax,%eax
je 1457 <func0+0x238>
mov -0x2c(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x30(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x30(%rbp)
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
add %rax,%rdx
mov (%rcx),%rax
mov %rax,(%rdx)
addl $0x1,-0x2c(%rbp)
mov -0x2c(%rbp),%eax
cmp -0x4c(%rbp),%eax
jl 13e5 <func0+0x1c6>
movl $0x0,-0x28(%rbp)
movl $0x0,-0x24(%rbp)
jmp 14e9 <func0+0x2ca>
cmpl $0x0,-0x24(%rbp)
je 14b0 <func0+0x291>
mov -0x24(%rbp),%eax
cltq
shl $0x3,%rax
lea -0x8(%rax),%rdx
mov -0x58(%rbp),%rax
add %rax,%rdx
mov -0x24(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x58(%rbp),%rax
add %rcx,%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 11c9 <tuple_compare>
test %eax,%eax
je 14e5 <func0+0x2c6>
mov -0x24(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x28(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x28(%rbp)
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rax,%rdx
mov (%rcx),%rax
mov %rax,(%rdx)
addl $0x1,-0x24(%rbp)
mov -0x24(%rbp),%eax
cmp -0x50(%rbp),%eax
jl 1473 <func0+0x254>
mov -0x30(%rbp),%eax
cmp %eax,-0x28(%rbp)
cmovle -0x28(%rbp),%eax
cltq
shl $0x3,%rax
mov %rax,%rdi
callq 10d0 <malloc@plt>
mov %rax,-0x8(%rbp)
movl $0x0,-0x20(%rbp)
movl $0x0,-0x1c(%rbp)
movl $0x0,-0x18(%rbp)
jmpq 15b2 <func0+0x393>
mov -0x18(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x58(%rbp),%rax
add %rax,%rdx
mov -0x1c(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x48(%rbp),%rax
add %rcx,%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 11c9 <tuple_compare>
mov %eax,-0x14(%rbp)
cmpl $0x0,-0x14(%rbp)
jne 15a2 <func0+0x383>
mov -0x1c(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x48(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x20(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x20(%rbp)
cltq
lea 0x0(,%rax,8),%rdx
mov -0x8(%rbp),%rax
add %rax,%rdx
mov (%rcx),%rax
mov %rax,(%rdx)
addl $0x1,-0x1c(%rbp)
addl $0x1,-0x18(%rbp)
jmp 15b2 <func0+0x393>
cmpl $0x0,-0x14(%rbp)
jns 15ae <func0+0x38f>
addl $0x1,-0x1c(%rbp)
jmp 15b2 <func0+0x393>
addl $0x1,-0x18(%rbp)
mov -0x1c(%rbp),%eax
cmp -0x30(%rbp),%eax
jge 15c6 <func0+0x3a7>
mov -0x18(%rbp),%eax
cmp -0x28(%rbp),%eax
jl 1527 <func0+0x308>
mov -0x60(%rbp),%rax
mov -0x20(%rbp),%edx
mov %edx,(%rax)
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 60h
mov [rbp+base], rdi
mov [rbp+var_4C], esi
mov [rbp+var_58], rdx
mov [rbp+var_50], ecx
mov [rbp+var_60], r8
mov [rbp+var_38], 0
jmp loc_12DF
loc_1249:
mov eax, [rbp+var_38]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_38]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rcx
mov eax, [rax+4]
cmp edx, eax
jle short loc_12DB
mov eax, [rbp+var_38]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rdx
mov eax, [rax]
mov [rbp+var_C], eax
mov eax, [rbp+var_38]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rdx
mov edx, [rbp+var_38]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+base]
add rdx, rcx
mov eax, [rax+4]
mov [rdx], eax
mov eax, [rbp+var_38]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
add rdx, rax
mov eax, [rbp+var_C]
mov [rdx+4], eax
loc_12DB:
add [rbp+var_38], 1
loc_12DF:
mov eax, [rbp+var_38]
cmp eax, [rbp+var_4C]
jl loc_1249
mov [rbp+var_34], 0
jmp loc_138D
loc_12F7:
mov eax, [rbp+var_34]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_34]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rax, rcx
mov eax, [rax+4]
cmp edx, eax
jle short loc_1389
mov eax, [rbp+var_34]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rax, rdx
mov eax, [rax]
mov [rbp+var_10], eax
mov eax, [rbp+var_34]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rax, rdx
mov edx, [rbp+var_34]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+var_58]
add rdx, rcx
mov eax, [rax+4]
mov [rdx], eax
mov eax, [rbp+var_34]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rdx, rax
mov eax, [rbp+var_10]
mov [rdx+4], eax
loc_1389:
add [rbp+var_34], 1
loc_138D:
mov eax, [rbp+var_34]
cmp eax, [rbp+var_50]
jl loc_12F7
mov eax, [rbp+var_4C]
movsxd rsi, eax; nmemb
mov rax, [rbp+base]
lea rdx, tuple_compare
mov rcx, rdx; compar
mov edx, 8; size
mov rdi, rax; base
call _qsort
mov eax, [rbp+var_50]
movsxd rsi, eax; nmemb
mov rax, [rbp+var_58]
lea rdx, tuple_compare
mov rcx, rdx; compar
mov edx, 8; size
mov rdi, rax; base
call _qsort
mov [rbp+var_30], 0
mov [rbp+var_2C], 0
jmp short loc_1461
loc_13EB:
cmp [rbp+var_2C], 0
jz short loc_1428
mov eax, [rbp+var_2C]
cdqe
shl rax, 3
lea rdx, [rax-8]
mov rax, [rbp+base]
add rdx, rax
mov eax, [rbp+var_2C]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rcx
mov rsi, rdx; void *
mov rdi, rax; void *
call tuple_compare
test eax, eax
jz short loc_145D
loc_1428:
mov eax, [rbp+var_2C]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
lea rcx, [rdx+rax]
mov eax, [rbp+var_30]
lea edx, [rax+1]
mov [rbp+var_30], edx
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
add rdx, rax
mov rax, [rcx]
mov [rdx], rax
loc_145D:
add [rbp+var_2C], 1
loc_1461:
mov eax, [rbp+var_2C]
cmp eax, [rbp+var_4C]
jl short loc_13EB
mov [rbp+var_28], 0
mov [rbp+var_24], 0
jmp short loc_14EF
loc_1479:
cmp [rbp+var_24], 0
jz short loc_14B6
mov eax, [rbp+var_24]
cdqe
shl rax, 3
lea rdx, [rax-8]
mov rax, [rbp+var_58]
add rdx, rax
mov eax, [rbp+var_24]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rax, rcx
mov rsi, rdx; void *
mov rdi, rax; void *
call tuple_compare
test eax, eax
jz short loc_14EB
loc_14B6:
mov eax, [rbp+var_24]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
lea rcx, [rdx+rax]
mov eax, [rbp+var_28]
lea edx, [rax+1]
mov [rbp+var_28], edx
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rdx, rax
mov rax, [rcx]
mov [rdx], rax
loc_14EB:
add [rbp+var_24], 1
loc_14EF:
mov eax, [rbp+var_24]
cmp eax, [rbp+var_50]
jl short loc_1479
mov edx, [rbp+var_28]
mov eax, [rbp+var_30]
cmp edx, eax
cmovle eax, edx
cdqe
shl rax, 3
mov rdi, rax; size
call _malloc
mov [rbp+var_8], rax
mov [rbp+var_20], 0
mov [rbp+var_1C], 0
mov [rbp+var_18], 0
jmp loc_15B9
loc_152E:
mov eax, [rbp+var_18]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_58]
add rdx, rax
mov eax, [rbp+var_1C]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+base]
add rax, rcx
mov rsi, rdx; void *
mov rdi, rax; void *
call tuple_compare
mov [rbp+var_14], eax
cmp [rbp+var_14], 0
jnz short loc_15A9
mov eax, [rbp+var_1C]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+base]
lea rcx, [rdx+rax]
mov eax, [rbp+var_20]
lea edx, [rax+1]
mov [rbp+var_20], edx
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_8]
add rdx, rax
mov rax, [rcx]
mov [rdx], rax
add [rbp+var_1C], 1
add [rbp+var_18], 1
jmp short loc_15B9
loc_15A9:
cmp [rbp+var_14], 0
jns short loc_15B5
add [rbp+var_1C], 1
jmp short loc_15B9
loc_15B5:
add [rbp+var_18], 1
loc_15B9:
mov eax, [rbp+var_1C]
cmp eax, [rbp+var_30]
jge short loc_15CD
mov eax, [rbp+var_18]
cmp eax, [rbp+var_28]
jl loc_152E
loc_15CD:
mov rax, [rbp+var_60]
mov edx, [rbp+var_20]
mov [rax], edx
mov rax, [rbp+var_8]
leave
retn | _QWORD * func0(_DWORD *a1, int a2, _DWORD *a3, int a4, _DWORD *a5)
{
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int i; // [rsp+28h] [rbp-38h]
int j; // [rsp+2Ch] [rbp-34h]
int v15; // [rsp+30h] [rbp-30h]
int k; // [rsp+34h] [rbp-2Ch]
int v17; // [rsp+38h] [rbp-28h]
int m; // [rsp+3Ch] [rbp-24h]
int v19; // [rsp+40h] [rbp-20h]
int v20; // [rsp+44h] [rbp-1Ch]
int v21; // [rsp+48h] [rbp-18h]
int v22; // [rsp+4Ch] [rbp-14h]
int v23; // [rsp+50h] [rbp-10h]
int v24; // [rsp+54h] [rbp-Ch]
_QWORD *v25; // [rsp+58h] [rbp-8h]
for ( i = 0; i < a2; ++i )
{
if ( a1[2 * i] > a1[2 * i + 1] )
{
v24 = a1[2 * i];
a1[2 * i] = a1[2 * i + 1];
a1[2 * i + 1] = v24;
}
}
for ( j = 0; j < a4; ++j )
{
if ( a3[2 * j] > a3[2 * j + 1] )
{
v23 = a3[2 * j];
a3[2 * j] = a3[2 * j + 1];
a3[2 * j + 1] = v23;
}
}
qsort(a1, a2, 8uLL, tuple_compare);
qsort(a3, a4, 8uLL, tuple_compare);
v15 = 0;
for ( k = 0; k < a2; ++k )
{
if ( !k || tuple_compare(&a1[2 * k], &a1[2 * k - 2]) )
{
v5 = v15++;
*(_QWORD *)&a1[2 * v5] = *(_QWORD *)&a1[2 * k];
}
}
v17 = 0;
for ( m = 0; m < a4; ++m )
{
if ( !m || tuple_compare(&a3[2 * m], &a3[2 * m - 2]) )
{
v6 = v17++;
*(_QWORD *)&a3[2 * v6] = *(_QWORD *)&a3[2 * m];
}
}
v7 = v15;
if ( v17 <= v15 )
v7 = v17;
v25 = malloc(8LL * v7);
v19 = 0;
v20 = 0;
v21 = 0;
while ( v20 < v15 && v21 < v17 )
{
v22 = tuple_compare(&a1[2 * v20], &a3[2 * v21]);
if ( v22 )
{
if ( v22 >= 0 )
++v21;
else
++v20;
}
else
{
v8 = v19++;
v25[v8] = *(_QWORD *)&a1[2 * v20++];
++v21;
}
}
*a5 = v19;
return v25;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x60
MOV qword ptr [RBP + -0x48],RDI
MOV dword ptr [RBP + -0x4c],ESI
MOV qword ptr [RBP + -0x58],RDX
MOV dword ptr [RBP + -0x50],ECX
MOV qword ptr [RBP + -0x60],R8
MOV dword ptr [RBP + -0x38],0x0
JMP 0x001012df
LAB_00101249:
MOV EAX,dword ptr [RBP + -0x38]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x38]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RCX
MOV EAX,dword ptr [RAX + 0x4]
CMP EDX,EAX
JLE 0x001012db
MOV EAX,dword ptr [RBP + -0x38]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0xc],EAX
MOV EAX,dword ptr [RBP + -0x38]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0x38]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x48]
ADD RDX,RCX
MOV EAX,dword ptr [RAX + 0x4]
MOV dword ptr [RDX],EAX
MOV EAX,dword ptr [RBP + -0x38]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0xc]
MOV dword ptr [RDX + 0x4],EAX
LAB_001012db:
ADD dword ptr [RBP + -0x38],0x1
LAB_001012df:
MOV EAX,dword ptr [RBP + -0x38]
CMP EAX,dword ptr [RBP + -0x4c]
JL 0x00101249
MOV dword ptr [RBP + -0x34],0x0
JMP 0x0010138d
LAB_001012f7:
MOV EAX,dword ptr [RBP + -0x34]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x34]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RAX,RCX
MOV EAX,dword ptr [RAX + 0x4]
CMP EDX,EAX
JLE 0x00101389
MOV EAX,dword ptr [RBP + -0x34]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x10],EAX
MOV EAX,dword ptr [RBP + -0x34]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0x34]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x58]
ADD RDX,RCX
MOV EAX,dword ptr [RAX + 0x4]
MOV dword ptr [RDX],EAX
MOV EAX,dword ptr [RBP + -0x34]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x10]
MOV dword ptr [RDX + 0x4],EAX
LAB_00101389:
ADD dword ptr [RBP + -0x34],0x1
LAB_0010138d:
MOV EAX,dword ptr [RBP + -0x34]
CMP EAX,dword ptr [RBP + -0x50]
JL 0x001012f7
MOV EAX,dword ptr [RBP + -0x4c]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x48]
LEA RDX,[0x1011c9]
MOV RCX,RDX
MOV EDX,0x8
MOV RDI,RAX
CALL 0x001010a0
MOV EAX,dword ptr [RBP + -0x50]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x58]
LEA RDX,[0x1011c9]
MOV RCX,RDX
MOV EDX,0x8
MOV RDI,RAX
CALL 0x001010a0
MOV dword ptr [RBP + -0x30],0x0
MOV dword ptr [RBP + -0x2c],0x0
JMP 0x00101461
LAB_001013eb:
CMP dword ptr [RBP + -0x2c],0x0
JZ 0x00101428
MOV EAX,dword ptr [RBP + -0x2c]
CDQE
SHL RAX,0x3
LEA RDX,[RAX + -0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x2c]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RCX
MOV RSI,RDX
MOV RDI,RAX
CALL 0x001011c9
TEST EAX,EAX
JZ 0x0010145d
LAB_00101428:
MOV EAX,dword ptr [RBP + -0x2c]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x30]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x30],EDX
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RDX,RAX
MOV RAX,qword ptr [RCX]
MOV qword ptr [RDX],RAX
LAB_0010145d:
ADD dword ptr [RBP + -0x2c],0x1
LAB_00101461:
MOV EAX,dword ptr [RBP + -0x2c]
CMP EAX,dword ptr [RBP + -0x4c]
JL 0x001013eb
MOV dword ptr [RBP + -0x28],0x0
MOV dword ptr [RBP + -0x24],0x0
JMP 0x001014ef
LAB_00101479:
CMP dword ptr [RBP + -0x24],0x0
JZ 0x001014b6
MOV EAX,dword ptr [RBP + -0x24]
CDQE
SHL RAX,0x3
LEA RDX,[RAX + -0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x24]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RAX,RCX
MOV RSI,RDX
MOV RDI,RAX
CALL 0x001011c9
TEST EAX,EAX
JZ 0x001014eb
LAB_001014b6:
MOV EAX,dword ptr [RBP + -0x24]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x28]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x28],EDX
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RDX,RAX
MOV RAX,qword ptr [RCX]
MOV qword ptr [RDX],RAX
LAB_001014eb:
ADD dword ptr [RBP + -0x24],0x1
LAB_001014ef:
MOV EAX,dword ptr [RBP + -0x24]
CMP EAX,dword ptr [RBP + -0x50]
JL 0x00101479
MOV EDX,dword ptr [RBP + -0x28]
MOV EAX,dword ptr [RBP + -0x30]
CMP EDX,EAX
CMOVLE EAX,EDX
CDQE
SHL RAX,0x3
MOV RDI,RAX
CALL 0x001010d0
MOV qword ptr [RBP + -0x8],RAX
MOV dword ptr [RBP + -0x20],0x0
MOV dword ptr [RBP + -0x1c],0x0
MOV dword ptr [RBP + -0x18],0x0
JMP 0x001015b9
LAB_0010152e:
MOV EAX,dword ptr [RBP + -0x18]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x58]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x1c]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
ADD RAX,RCX
MOV RSI,RDX
MOV RDI,RAX
CALL 0x001011c9
MOV dword ptr [RBP + -0x14],EAX
CMP dword ptr [RBP + -0x14],0x0
JNZ 0x001015a9
MOV EAX,dword ptr [RBP + -0x1c]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x48]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x20]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x20],EDX
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x8]
ADD RDX,RAX
MOV RAX,qword ptr [RCX]
MOV qword ptr [RDX],RAX
ADD dword ptr [RBP + -0x1c],0x1
ADD dword ptr [RBP + -0x18],0x1
JMP 0x001015b9
LAB_001015a9:
CMP dword ptr [RBP + -0x14],0x0
JNS 0x001015b5
ADD dword ptr [RBP + -0x1c],0x1
JMP 0x001015b9
LAB_001015b5:
ADD dword ptr [RBP + -0x18],0x1
LAB_001015b9:
MOV EAX,dword ptr [RBP + -0x1c]
CMP EAX,dword ptr [RBP + -0x30]
JGE 0x001015cd
MOV EAX,dword ptr [RBP + -0x18]
CMP EAX,dword ptr [RBP + -0x28]
JL 0x0010152e
LAB_001015cd:
MOV RAX,qword ptr [RBP + -0x60]
MOV EDX,dword ptr [RBP + -0x20]
MOV dword ptr [RAX],EDX
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(void *param_1,int param_2,void *param_3,int param_4,int *param_5)
{
int4 uVar1;
int iVar2;
void *pvVar3;
int local_40;
int local_3c;
int local_38;
int local_34;
int local_30;
int local_2c;
int local_28;
int local_24;
int local_20;
for (local_40 = 0; local_40 < param_2; local_40 = local_40 + 1) {
if (*(int *)((long)param_1 + (long)local_40 * 8 + 4) <
*(int *)((long)param_1 + (long)local_40 * 8)) {
uVar1 = *(int4 *)((long)param_1 + (long)local_40 * 8);
*(int4 *)((long)param_1 + (long)local_40 * 8) =
*(int4 *)((long)param_1 + (long)local_40 * 8 + 4);
*(int4 *)((long)param_1 + (long)local_40 * 8 + 4) = uVar1;
}
}
for (local_3c = 0; local_3c < param_4; local_3c = local_3c + 1) {
if (*(int *)((long)param_3 + (long)local_3c * 8 + 4) <
*(int *)((long)param_3 + (long)local_3c * 8)) {
uVar1 = *(int4 *)((long)param_3 + (long)local_3c * 8);
*(int4 *)((long)param_3 + (long)local_3c * 8) =
*(int4 *)((long)param_3 + (long)local_3c * 8 + 4);
*(int4 *)((long)param_3 + (long)local_3c * 8 + 4) = uVar1;
}
}
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)param_4,8,tuple_compare);
local_38 = 0;
for (local_34 = 0; local_34 < param_2; local_34 = local_34 + 1) {
if (local_34 == 0) {
LAB_00101428:
*(int8 *)((long)local_38 * 8 + (long)param_1) =
*(int8 *)((long)local_34 * 8 + (long)param_1);
local_38 = local_38 + 1;
}
else {
iVar2 = tuple_compare((void *)((long)param_1 + (long)local_34 * 8),
(long)local_34 * 8 + -8 + (long)param_1);
if (iVar2 != 0) goto LAB_00101428;
}
}
local_30 = 0;
local_2c = 0;
do {
if (param_4 <= local_2c) {
iVar2 = local_38;
if (local_30 <= local_38) {
iVar2 = local_30;
}
pvVar3 = malloc((long)iVar2 << 3);
local_28 = 0;
local_24 = 0;
local_20 = 0;
while ((local_24 < local_38 && (local_20 < local_30))) {
iVar2 = tuple_compare((void *)((long)param_1 + (long)local_24 * 8),
(void *)((long)local_20 * 8 + (long)param_3));
if (iVar2 == 0) {
*(int8 *)((long)local_28 * 8 + (long)pvVar3) =
*(int8 *)((long)local_24 * 8 + (long)param_1);
local_24 = local_24 + 1;
local_20 = local_20 + 1;
local_28 = local_28 + 1;
}
else if (iVar2 < 0) {
local_24 = local_24 + 1;
}
else {
local_20 = local_20 + 1;
}
}
*param_5 = local_28;
return pvVar3;
}
if (local_2c == 0) {
LAB_001014b6:
*(int8 *)((long)local_30 * 8 + (long)param_3) =
*(int8 *)((long)local_2c * 8 + (long)param_3);
local_30 = local_30 + 1;
}
else {
iVar2 = tuple_compare((void *)((long)param_3 + (long)local_2c * 8),
(long)local_2c * 8 + -8 + (long)param_3);
if (iVar2 != 0) goto LAB_001014b6;
}
local_2c = local_2c + 1;
} while( true );
} |
5,785 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int first;
int second;
} tuple;
// Compare two tuples for qsort and bsearch
int tuple_compare(const void *a, const void *b) {
tuple *t1 = (tuple *)a;
tuple *t2 = (tuple *)b;
if (t1->first != t2->first)
return t1->first - t2->first;
return t1->second - t2->second;
}
// Function to perform tuple intersection
| tuple* func0(tuple *list1, int size1, tuple *list2, int size2, int *res_size) {
// Sort individual tuples
for(int i = 0; i < size1; i++) {
if(list1[i].first > list1[i].second){
int temp = list1[i].first;
list1[i].first = list1[i].second;
list1[i].second = temp;
}
}
for(int i = 0; i < size2; i++) {
if(list2[i].first > list2[i].second){
int temp = list2[i].first;
list2[i].first = list2[i].second;
list2[i].second = temp;
}
}
// Sort the lists
qsort(list1, size1, sizeof(tuple), tuple_compare);
qsort(list2, size2, sizeof(tuple), tuple_compare);
// Remove duplicates
int unique1 = 0;
for(int i = 0; i < size1; i++) {
if(i == 0 || tuple_compare(&list1[i], &list1[i-1]) != 0){
list1[unique1++] = list1[i];
}
}
int unique2 = 0;
for(int i = 0; i < size2; i++) {
if(i == 0 || tuple_compare(&list2[i], &list2[i-1]) != 0){
list2[unique2++] = list2[i];
}
}
// Find intersection
tuple *res = malloc(sizeof(tuple) * (unique1 < unique2 ? unique1 : unique2));
int count = 0, i_idx = 0, j_idx = 0;
while(i_idx < unique1 && j_idx < unique2){
int cmp = tuple_compare(&list1[i_idx], &list2[j_idx]);
if(cmp == 0){
res[count++] = list1[i_idx];
i_idx++;
j_idx++;
}
else if(cmp < 0)
i_idx++;
else
j_idx++;
}
*res_size = count;
return res;
}
| int main() {
// First test
tuple list1_1[] = { {3,4}, {5,6}, {9,10}, {4,5} };
int size1_1 = 4;
tuple list2_1[] = { {5,4}, {3,4}, {6,5}, {9,11} };
int size2_1 = 4;
int res_size_1;
tuple *res1 = func0(list1_1, size1_1, list2_1, size2_1, &res_size_1);
tuple expected1[] = { {3,4}, {4,5}, {5,6} };
int expected_size1 = 3;
assert(res_size_1 == expected_size1);
for(int i=0;i<expected_size1;i++) {
assert(res1[i].first == expected1[i].first);
assert(res1[i].second == expected1[i].second);
}
free(res1);
// Second test
tuple list1_2[] = { {4,1}, {7,4}, {11,13}, {17,14} };
int size1_2 = 4;
tuple list2_2[] = { {1,4}, {7,4}, {16,12}, {10,13} };
int size2_2 = 4;
int res_size_2;
tuple *res2 = func0(list1_2, size1_2, list2_2, size2_2, &res_size_2);
tuple expected2[] = { {1,4}, {4,7} };
int expected_size2 = 2;
assert(res_size_2 == expected_size2);
for(int i=0;i<expected_size2;i++) {
assert(res2[i].first == expected2[i].first);
assert(res2[i].second == expected2[i].second);
}
free(res2);
// Third test
tuple list1_3[] = { {2,1}, {3,2}, {1,3}, {1,4} };
int size1_3 = 4;
tuple list2_3[] = { {11,2}, {2,3}, {6,2}, {1,3} };
int size2_3 = 4;
int res_size_3;
tuple *res3 = func0(list1_3, size1_3, list2_3, size2_3, &res_size_3);
tuple expected3[] = { {1,3}, {2,3} };
int expected_size3 = 2;
assert(res_size_3 == expected_size3);
for(int i=0;i<expected_size3;i++) {
assert(res3[i].first == expected3[i].first);
assert(res3[i].second == expected3[i].second);
}
free(res3);
return 0;
}
| O1 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x28,%rsp
mov %rdi,%r14
mov %esi,%r13d
mov %rdx,(%rsp)
mov %ecx,%r15d
mov %r8,0x18(%rsp)
test %esi,%esi
jle 122d <func0+0x4e>
mov %rdi,%rax
lea -0x1(%rsi),%edx
lea 0x8(%rdi,%rdx,8),%rsi
jmp 121d <func0+0x3e>
add $0x8,%rax
cmp %rsi,%rax
je 122d <func0+0x4e>
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 1214 <func0+0x35>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
jmp 1214 <func0+0x35>
test %r15d,%r15d
jle 13d9 <func0+0x1fa>
mov (%rsp),%rdi
mov %rdi,%rax
lea -0x1(%r15),%edx
lea 0x8(%rdi,%rdx,8),%rsi
jmp 1255 <func0+0x76>
add $0x8,%rax
cmp %rsi,%rax
je 1388 <func0+0x1a9>
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 1248 <func0+0x69>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
jmp 1248 <func0+0x69>
movslq %r12d,%rax
mov 0x0(%rbp),%rdx
mov %rdx,(%r14,%rax,8)
lea 0x1(%r12),%r12d
add $0x1,%ebx
add $0x8,%rbp
cmp %ebx,%r13d
je 1297 <func0+0xb8>
test %ebx,%ebx
je 1265 <func0+0x86>
lea -0x8(%rbp),%rsi
mov %rbp,%rdi
callq 11c9 <tuple_compare>
test %eax,%eax
je 1275 <func0+0x96>
jmp 1265 <func0+0x86>
test %r15d,%r15d
jle 1413 <func0+0x234>
mov (%rsp),%rbp
mov $0x0,%ebx
mov $0x0,%r13d
jmp 12d0 <func0+0xf1>
movslq %r13d,%rax
mov 0x0(%rbp),%rdx
mov (%rsp),%rdi
mov %rdx,(%rdi,%rax,8)
lea 0x1(%r13),%r13d
add $0x1,%ebx
add $0x8,%rbp
cmp %ebx,%r15d
je 12e6 <func0+0x107>
test %ebx,%ebx
je 12b1 <func0+0xd2>
lea -0x8(%rbp),%rsi
mov %rbp,%rdi
callq 11c9 <tuple_compare>
test %eax,%eax
je 12c4 <func0+0xe5>
jmp 12b1 <func0+0xd2>
cmp %r13d,%r12d
mov %r13d,%edi
cmovle %r12d,%edi
movslq %edi,%rdi
shl $0x3,%rdi
callq 10d0 <malloc@plt>
mov %rax,0x10(%rsp)
test %r12d,%r12d
jle 137b <func0+0x19c>
test %r13d,%r13d
jle 137b <func0+0x19c>
mov $0x0,%ebx
mov $0x0,%ebp
movl $0x0,0xc(%rsp)
jmp 1336 <func0+0x157>
js 1376 <func0+0x197>
add $0x1,%ebx
cmp %ebp,%r12d
jle 1438 <func0+0x259>
cmp %r13d,%ebx
jge 1438 <func0+0x259>
movslq %ebp,%rax
lea (%r14,%rax,8),%r15
movslq %ebx,%rax
mov (%rsp),%rdi
lea (%rdi,%rax,8),%rsi
mov %r15,%rdi
callq 11c9 <tuple_compare>
test %eax,%eax
jne 131f <func0+0x140>
mov 0xc(%rsp),%ecx
movslq %ecx,%rax
mov (%r15),%rdx
mov 0x10(%rsp),%rdi
mov %rdx,(%rdi,%rax,8)
add $0x1,%ebp
add $0x1,%ebx
lea 0x1(%rcx),%eax
mov %eax,0xc(%rsp)
jmp 1324 <func0+0x145>
add $0x1,%ebp
jmp 1324 <func0+0x145>
movl $0x0,0xc(%rsp)
jmpq 1438 <func0+0x259>
movslq %r13d,%rsi
lea -0x1c9(%rip),%rcx
mov $0x8,%edx
mov %r14,%rdi
callq 10a0 <qsort@plt>
movslq %r15d,%rsi
lea -0x1e0(%rip),%rcx
mov $0x8,%edx
mov (%rsp),%rdi
callq 10a0 <qsort@plt>
mov $0x0,%r12d
test %r13d,%r13d
jle 12a0 <func0+0xc1>
mov %r14,%rbp
mov $0x0,%ebx
mov $0x0,%r12d
jmpq 1281 <func0+0xa2>
movslq %r13d,%rsi
lea -0x21a(%rip),%rcx
mov $0x8,%edx
mov %r14,%rdi
callq 10a0 <qsort@plt>
movslq %r15d,%rsi
lea -0x231(%rip),%rcx
mov $0x8,%edx
mov (%rsp),%rdi
callq 10a0 <qsort@plt>
mov $0x0,%r12d
test %r13d,%r13d
jg 13c6 <func0+0x1e7>
test %r12d,%r12d
mov $0x0,%edi
cmovle %r12d,%edi
movslq %edi,%rdi
shl $0x3,%rdi
callq 10d0 <malloc@plt>
mov %rax,0x10(%rsp)
movl $0x0,0xc(%rsp)
mov 0x18(%rsp),%rax
mov 0xc(%rsp),%edi
mov %edi,(%rax)
mov 0x10(%rsp),%rax
add $0x28,%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, 28h
mov [rsp+58h+var_58], rdi
mov r13d, esi
mov r14, rdx
mov r15d, ecx
mov [rsp+58h+var_40], r8
test esi, esi
jle short loc_122D
mov rax, rdi
lea edx, [rsi-1]
lea rsi, [rdi+rdx*8+8]
jmp short loc_121D
loc_1214:
add rax, 8
cmp rax, rsi
jz short loc_122D
loc_121D:
mov edx, [rax]
mov ecx, [rax+4]
cmp edx, ecx
jle short loc_1214
mov [rax], ecx
mov [rax+4], edx
jmp short loc_1214
loc_122D:
test r15d, r15d
jle loc_1380
mov rax, r14
lea edx, [r15-1]
lea rsi, [r14+rdx*8+8]
jmp short loc_1251
loc_1244:
add rax, 8
cmp rax, rsi
jz loc_1401
loc_1251:
mov edx, [rax]
mov ecx, [rax+4]
cmp edx, ecx
jle short loc_1244
mov [rax], ecx
mov [rax+4], edx
jmp short loc_1244
loc_1261:
movsxd rax, r12d
mov rdx, [rbp+0]
mov rdi, [rsp+58h+var_58]
mov [rdi+rax*8], rdx
lea r12d, [r12+1]
loc_1275:
add ebx, 1
add rbp, 8
cmp r13d, ebx
jz short loc_1297
loc_1281:
test ebx, ebx
jz short loc_1261
lea rsi, [rbp-8]
mov rdi, rbp
call tuple_compare
test eax, eax
jz short loc_1275
jmp short loc_1261
loc_1297:
test r15d, r15d
jle loc_13BD
loc_12A0:
mov rbp, r14
mov ebx, 0
mov r13d, 0
jmp short loc_12CB
loc_12B0:
movsxd rax, r13d
mov rdx, [rbp+0]
mov [r14+rax*8], rdx
lea r13d, [r13+1]
loc_12BF:
add ebx, 1
add rbp, 8
cmp r15d, ebx
jz short loc_12E1
loc_12CB:
test ebx, ebx
jz short loc_12B0
lea rsi, [rbp-8]
mov rdi, rbp
call tuple_compare
test eax, eax
jz short loc_12BF
jmp short loc_12B0
loc_12E1:
cmp r12d, r13d
mov edi, r13d
cmovle edi, r12d
movsxd rdi, edi
shl rdi, 3
call _malloc
mov [rsp+58h+var_48], rax
test r12d, r12d
jle short loc_1376
test r13d, r13d
jle short loc_1376
mov ebx, 0
mov ebp, 0
mov [rsp+58h+var_4C], 0
jmp short loc_1331
loc_131A:
js short loc_1371
add ebx, 1
loc_131F:
cmp r12d, ebp
jle loc_13E2
cmp ebx, r13d
jge loc_13E2
loc_1331:
movsxd rax, ebp
mov rdi, [rsp+58h+var_58]
lea r15, [rdi+rax*8]
movsxd rax, ebx
lea rsi, [r14+rax*8]
mov rdi, r15
call tuple_compare
test eax, eax
jnz short loc_131A
mov ecx, [rsp+58h+var_4C]
movsxd rax, ecx
mov rdx, [r15]
mov rdi, [rsp+58h+var_48]
mov [rdi+rax*8], rdx
add ebp, 1
add ebx, 1
lea eax, [rcx+1]
mov [rsp+58h+var_4C], eax
jmp short loc_131F
loc_1371:
add ebp, 1
jmp short loc_131F
loc_1376:
mov [rsp+58h+var_4C], 0
jmp short loc_13E2
loc_1380:
movsxd rsi, r13d
lea rbx, tuple_compare
mov rcx, rbx
mov edx, 8
mov rdi, [rsp+58h+var_58]
call _qsort
movsxd rsi, r15d
mov rcx, rbx
mov edx, 8
mov rdi, r14
call _qsort
mov r12d, 0
test r13d, r13d
jg loc_143E
loc_13BD:
test r12d, r12d
mov edi, 0
cmovle edi, r12d
movsxd rdi, edi
shl rdi, 3
call _malloc
mov [rsp+58h+var_48], rax
mov [rsp+58h+var_4C], 0
loc_13E2:
mov rax, [rsp+58h+var_40]
mov ecx, [rsp+58h+var_4C]
mov [rax], ecx
mov rax, [rsp+58h+var_48]
add rsp, 28h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_1401:
movsxd rsi, r13d
lea rbx, tuple_compare
mov rcx, rbx
mov edx, 8
mov rdi, [rsp+58h+var_58]
call _qsort
movsxd rsi, r15d
mov rcx, rbx
mov edx, 8
mov rdi, r14
call _qsort
mov r12d, 0
test r13d, r13d
jle loc_12A0
loc_143E:
mov rbp, [rsp+58h+var_58]
mov ebx, 0
mov r12d, 0
jmp loc_1281 | long long func0(int *a1, int a2, int *a3, int a4, _DWORD *a5)
{
int *v8; // rax
long long v9; // rsi
int v10; // edx
int v11; // ecx
int *v12; // rax
int v13; // edx
int v14; // ecx
int v15; // r12d
int v16; // ebx
int *v17; // rbp
int *v18; // rbp
int v19; // ebx
int v20; // r13d
int v21; // edi
int v22; // ebx
int v23; // ebp
int v24; // eax
int v25; // edi
int v28; // [rsp+Ch] [rbp-4Ch]
long long v29; // [rsp+10h] [rbp-48h]
if ( a2 > 0 )
{
v8 = a1;
v9 = (long long)&a1[2 * (a2 - 1) + 2];
do
{
v10 = *v8;
v11 = v8[1];
if ( *v8 > v11 )
{
*v8 = v11;
v8[1] = v10;
}
v8 += 2;
}
while ( v8 != (int *)v9 );
}
if ( a4 <= 0 )
{
qsort(a1, a2, 8LL, tuple_compare);
qsort(a3, a4, 8LL, tuple_compare);
v15 = 0;
if ( a2 <= 0 )
goto LABEL_37;
}
else
{
v12 = a3;
do
{
v13 = *v12;
v14 = v12[1];
if ( *v12 > v14 )
{
*v12 = v14;
v12[1] = v13;
}
v12 += 2;
}
while ( v12 != &a3[2 * (a4 - 1) + 2] );
qsort(a1, a2, 8LL, tuple_compare);
qsort(a3, a4, 8LL, tuple_compare);
v15 = 0;
if ( a2 <= 0 )
goto LABEL_17;
}
v17 = a1;
v16 = 0;
v15 = 0;
do
{
if ( !v16 || (unsigned int)tuple_compare(v17, v17 - 2) )
*(_QWORD *)&a1[2 * v15++] = *(_QWORD *)v17;
++v16;
v17 += 2;
}
while ( a2 != v16 );
if ( a4 > 0 )
{
LABEL_17:
v18 = a3;
v19 = 0;
v20 = 0;
do
{
if ( !v19 || (unsigned int)tuple_compare(v18, v18 - 2) )
*(_QWORD *)&a3[2 * v20++] = *(_QWORD *)v18;
++v19;
v18 += 2;
}
while ( a4 != v19 );
v21 = v20;
if ( v15 <= v20 )
v21 = v15;
v29 = malloc(8LL * v21);
if ( v15 <= 0 || v20 <= 0 )
{
v28 = 0;
}
else
{
v22 = 0;
v23 = 0;
v28 = 0;
do
{
v24 = tuple_compare(&a1[2 * v23], &a3[2 * v22]);
if ( v24 )
{
if ( v24 < 0 )
++v23;
else
++v22;
}
else
{
*(_QWORD *)(v29 + 8LL * v28) = *(_QWORD *)&a1[2 * v23++];
++v22;
++v28;
}
}
while ( v15 > v23 && v22 < v20 );
}
goto LABEL_40;
}
LABEL_37:
v25 = 0;
if ( v15 <= 0 )
v25 = v15;
v29 = malloc(8LL * v25);
v28 = 0;
LABEL_40:
*a5 = v28;
return v29;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x28
MOV qword ptr [RSP],RDI
MOV R13D,ESI
MOV R14,RDX
MOV R15D,ECX
MOV qword ptr [RSP + 0x18],R8
TEST ESI,ESI
JLE 0x0010122d
MOV RAX,RDI
LEA EDX,[RSI + -0x1]
LEA RSI,[RDI + RDX*0x8 + 0x8]
JMP 0x0010121d
LAB_00101214:
ADD RAX,0x8
CMP RAX,RSI
JZ 0x0010122d
LAB_0010121d:
MOV EDX,dword ptr [RAX]
MOV ECX,dword ptr [RAX + 0x4]
CMP EDX,ECX
JLE 0x00101214
MOV dword ptr [RAX],ECX
MOV dword ptr [RAX + 0x4],EDX
JMP 0x00101214
LAB_0010122d:
TEST R15D,R15D
JLE 0x00101380
MOV RAX,R14
LEA EDX,[R15 + -0x1]
LEA RSI,[R14 + RDX*0x8 + 0x8]
JMP 0x00101251
LAB_00101244:
ADD RAX,0x8
CMP RAX,RSI
JZ 0x00101401
LAB_00101251:
MOV EDX,dword ptr [RAX]
MOV ECX,dword ptr [RAX + 0x4]
CMP EDX,ECX
JLE 0x00101244
MOV dword ptr [RAX],ECX
MOV dword ptr [RAX + 0x4],EDX
JMP 0x00101244
LAB_00101261:
MOVSXD RAX,R12D
MOV RDX,qword ptr [RBP]
MOV RDI,qword ptr [RSP]
MOV qword ptr [RDI + RAX*0x8],RDX
LEA R12D,[R12 + 0x1]
LAB_00101275:
ADD EBX,0x1
ADD RBP,0x8
CMP R13D,EBX
JZ 0x00101297
LAB_00101281:
TEST EBX,EBX
JZ 0x00101261
LEA RSI,[RBP + -0x8]
MOV RDI,RBP
CALL 0x001011c9
TEST EAX,EAX
JZ 0x00101275
JMP 0x00101261
LAB_00101297:
TEST R15D,R15D
JLE 0x001013bd
LAB_001012a0:
MOV RBP,R14
MOV EBX,0x0
MOV R13D,0x0
JMP 0x001012cb
LAB_001012b0:
MOVSXD RAX,R13D
MOV RDX,qword ptr [RBP]
MOV qword ptr [R14 + RAX*0x8],RDX
LEA R13D,[R13 + 0x1]
LAB_001012bf:
ADD EBX,0x1
ADD RBP,0x8
CMP R15D,EBX
JZ 0x001012e1
LAB_001012cb:
TEST EBX,EBX
JZ 0x001012b0
LEA RSI,[RBP + -0x8]
MOV RDI,RBP
CALL 0x001011c9
TEST EAX,EAX
JZ 0x001012bf
JMP 0x001012b0
LAB_001012e1:
CMP R12D,R13D
MOV EDI,R13D
CMOVLE EDI,R12D
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010d0
MOV qword ptr [RSP + 0x10],RAX
TEST R12D,R12D
JLE 0x00101376
TEST R13D,R13D
JLE 0x00101376
MOV EBX,0x0
MOV EBP,0x0
MOV dword ptr [RSP + 0xc],0x0
JMP 0x00101331
LAB_0010131a:
JS 0x00101371
ADD EBX,0x1
LAB_0010131f:
CMP R12D,EBP
JLE 0x001013e2
CMP EBX,R13D
JGE 0x001013e2
LAB_00101331:
MOVSXD RAX,EBP
MOV RDI,qword ptr [RSP]
LEA R15,[RDI + RAX*0x8]
MOVSXD RAX,EBX
LEA RSI,[R14 + RAX*0x8]
MOV RDI,R15
CALL 0x001011c9
TEST EAX,EAX
JNZ 0x0010131a
MOV ECX,dword ptr [RSP + 0xc]
MOVSXD RAX,ECX
MOV RDX,qword ptr [R15]
MOV RDI,qword ptr [RSP + 0x10]
MOV qword ptr [RDI + RAX*0x8],RDX
ADD EBP,0x1
ADD EBX,0x1
LEA EAX,[RCX + 0x1]
MOV dword ptr [RSP + 0xc],EAX
JMP 0x0010131f
LAB_00101371:
ADD EBP,0x1
JMP 0x0010131f
LAB_00101376:
MOV dword ptr [RSP + 0xc],0x0
JMP 0x001013e2
LAB_00101380:
MOVSXD RSI,R13D
LEA RBX,[0x1011c9]
MOV RCX,RBX
MOV EDX,0x8
MOV RDI,qword ptr [RSP]
CALL 0x001010a0
MOVSXD RSI,R15D
MOV RCX,RBX
MOV EDX,0x8
MOV RDI,R14
CALL 0x001010a0
MOV R12D,0x0
TEST R13D,R13D
JG 0x0010143e
LAB_001013bd:
TEST R12D,R12D
MOV EDI,0x0
CMOVLE EDI,R12D
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010d0
MOV qword ptr [RSP + 0x10],RAX
MOV dword ptr [RSP + 0xc],0x0
LAB_001013e2:
MOV RAX,qword ptr [RSP + 0x18]
MOV ECX,dword ptr [RSP + 0xc]
MOV dword ptr [RAX],ECX
MOV RAX,qword ptr [RSP + 0x10]
ADD RSP,0x28
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_00101401:
MOVSXD RSI,R13D
LEA RBX,[0x1011c9]
MOV RCX,RBX
MOV EDX,0x8
MOV RDI,qword ptr [RSP]
CALL 0x001010a0
MOVSXD RSI,R15D
MOV RCX,RBX
MOV EDX,0x8
MOV RDI,R14
CALL 0x001010a0
MOV R12D,0x0
TEST R13D,R13D
JLE 0x001012a0
LAB_0010143e:
MOV RBP,qword ptr [RSP]
MOV EBX,0x0
MOV R12D,0x0
JMP 0x00101281 | void * func0(int *param_1,int param_2,int *param_3,int param_4,int *param_5)
{
int iVar1;
int iVar2;
int iVar3;
int *piVar4;
int iVar5;
int iVar6;
int local_4c;
void *local_48;
if (0 < param_2) {
piVar4 = param_1;
do {
iVar6 = *piVar4;
if (piVar4[1] < iVar6) {
*piVar4 = piVar4[1];
piVar4[1] = iVar6;
}
piVar4 = piVar4 + 2;
} while (piVar4 != param_1 + (ulong)(param_2 - 1) * 2 + 2);
}
if (param_4 < 1) {
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)param_4,8,tuple_compare);
iVar6 = 0;
if (0 < param_2) goto LAB_0010143e;
LAB_001013bd:
iVar5 = 0;
if (iVar6 < 1) {
iVar5 = iVar6;
}
local_48 = malloc((long)iVar5 << 3);
local_4c = 0;
}
else {
piVar4 = param_3;
do {
iVar6 = *piVar4;
if (piVar4[1] < iVar6) {
*piVar4 = piVar4[1];
piVar4[1] = iVar6;
}
piVar4 = piVar4 + 2;
} while (piVar4 != param_3 + (ulong)(param_4 - 1) * 2 + 2);
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)param_4,8,tuple_compare);
iVar6 = 0;
if (0 < param_2) {
LAB_0010143e:
iVar5 = 0;
iVar6 = 0;
piVar4 = param_1;
do {
if ((iVar5 == 0) || (iVar1 = tuple_compare(piVar4,piVar4 + -2), iVar1 != 0)) {
*(int8 *)(param_1 + (long)iVar6 * 2) = *(int8 *)piVar4;
iVar6 = iVar6 + 1;
}
iVar5 = iVar5 + 1;
piVar4 = piVar4 + 2;
} while (param_2 != iVar5);
if (param_4 < 1) goto LAB_001013bd;
}
iVar1 = 0;
iVar5 = 0;
piVar4 = param_3;
do {
if ((iVar1 == 0) || (iVar2 = tuple_compare(piVar4,piVar4 + -2), iVar2 != 0)) {
*(int8 *)(param_3 + (long)iVar5 * 2) = *(int8 *)piVar4;
iVar5 = iVar5 + 1;
}
iVar1 = iVar1 + 1;
piVar4 = piVar4 + 2;
} while (param_4 != iVar1);
iVar1 = iVar5;
if (iVar6 <= iVar5) {
iVar1 = iVar6;
}
local_48 = malloc((long)iVar1 << 3);
if ((iVar6 < 1) || (iVar5 < 1)) {
local_4c = 0;
}
else {
iVar1 = 0;
iVar2 = 0;
local_4c = 0;
do {
iVar3 = tuple_compare(param_1 + (long)iVar2 * 2,param_3 + (long)iVar1 * 2);
if (iVar3 == 0) {
*(int8 *)((long)local_48 + (long)local_4c * 8) =
*(int8 *)(param_1 + (long)iVar2 * 2);
iVar2 = iVar2 + 1;
iVar1 = iVar1 + 1;
local_4c = local_4c + 1;
}
else if (iVar3 < 0) {
iVar2 = iVar2 + 1;
}
else {
iVar1 = iVar1 + 1;
}
} while ((iVar2 < iVar6) && (iVar1 < iVar5));
}
}
*param_5 = local_4c;
return local_48;
} |
5,786 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int first;
int second;
} tuple;
// Compare two tuples for qsort and bsearch
int tuple_compare(const void *a, const void *b) {
tuple *t1 = (tuple *)a;
tuple *t2 = (tuple *)b;
if (t1->first != t2->first)
return t1->first - t2->first;
return t1->second - t2->second;
}
// Function to perform tuple intersection
| tuple* func0(tuple *list1, int size1, tuple *list2, int size2, int *res_size) {
// Sort individual tuples
for(int i = 0; i < size1; i++) {
if(list1[i].first > list1[i].second){
int temp = list1[i].first;
list1[i].first = list1[i].second;
list1[i].second = temp;
}
}
for(int i = 0; i < size2; i++) {
if(list2[i].first > list2[i].second){
int temp = list2[i].first;
list2[i].first = list2[i].second;
list2[i].second = temp;
}
}
// Sort the lists
qsort(list1, size1, sizeof(tuple), tuple_compare);
qsort(list2, size2, sizeof(tuple), tuple_compare);
// Remove duplicates
int unique1 = 0;
for(int i = 0; i < size1; i++) {
if(i == 0 || tuple_compare(&list1[i], &list1[i-1]) != 0){
list1[unique1++] = list1[i];
}
}
int unique2 = 0;
for(int i = 0; i < size2; i++) {
if(i == 0 || tuple_compare(&list2[i], &list2[i-1]) != 0){
list2[unique2++] = list2[i];
}
}
// Find intersection
tuple *res = malloc(sizeof(tuple) * (unique1 < unique2 ? unique1 : unique2));
int count = 0, i_idx = 0, j_idx = 0;
while(i_idx < unique1 && j_idx < unique2){
int cmp = tuple_compare(&list1[i_idx], &list2[j_idx]);
if(cmp == 0){
res[count++] = list1[i_idx];
i_idx++;
j_idx++;
}
else if(cmp < 0)
i_idx++;
else
j_idx++;
}
*res_size = count;
return res;
}
| int main() {
// First test
tuple list1_1[] = { {3,4}, {5,6}, {9,10}, {4,5} };
int size1_1 = 4;
tuple list2_1[] = { {5,4}, {3,4}, {6,5}, {9,11} };
int size2_1 = 4;
int res_size_1;
tuple *res1 = func0(list1_1, size1_1, list2_1, size2_1, &res_size_1);
tuple expected1[] = { {3,4}, {4,5}, {5,6} };
int expected_size1 = 3;
assert(res_size_1 == expected_size1);
for(int i=0;i<expected_size1;i++) {
assert(res1[i].first == expected1[i].first);
assert(res1[i].second == expected1[i].second);
}
free(res1);
// Second test
tuple list1_2[] = { {4,1}, {7,4}, {11,13}, {17,14} };
int size1_2 = 4;
tuple list2_2[] = { {1,4}, {7,4}, {16,12}, {10,13} };
int size2_2 = 4;
int res_size_2;
tuple *res2 = func0(list1_2, size1_2, list2_2, size2_2, &res_size_2);
tuple expected2[] = { {1,4}, {4,7} };
int expected_size2 = 2;
assert(res_size_2 == expected_size2);
for(int i=0;i<expected_size2;i++) {
assert(res2[i].first == expected2[i].first);
assert(res2[i].second == expected2[i].second);
}
free(res2);
// Third test
tuple list1_3[] = { {2,1}, {3,2}, {1,3}, {1,4} };
int size1_3 = 4;
tuple list2_3[] = { {11,2}, {2,3}, {6,2}, {1,3} };
int size2_3 = 4;
int res_size_3;
tuple *res3 = func0(list1_3, size1_3, list2_3, size2_3, &res_size_3);
tuple expected3[] = { {1,3}, {2,3} };
int expected_size3 = 2;
assert(res_size_3 == expected_size3);
for(int i=0;i<expected_size3;i++) {
assert(res3[i].first == expected3[i].first);
assert(res3[i].second == expected3[i].second);
}
free(res3);
return 0;
}
| O2 | c | func0:
endbr64
push %r15
push %r14
mov %ecx,%r14d
push %r13
mov %esi,%r13d
push %r12
mov %rdi,%r12
push %rbp
mov %rdx,%rbp
push %rbx
mov %r8,%rbx
sub $0x8,%rsp
test %esi,%esi
jle 1637 <func0+0x47>
lea -0x1(%rsi),%edx
mov %rdi,%rax
lea 0x8(%rdi,%rdx,8),%rsi
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 162e <func0+0x3e>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
add $0x8,%rax
cmp %rax,%rsi
jne 1620 <func0+0x30>
test %r14d,%r14d
jle 17f0 <func0+0x200>
lea -0x1(%r14),%edx
mov %rbp,%rax
mov %rdx,%r15
lea 0x8(%rbp,%rdx,8),%rsi
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 165e <func0+0x6e>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
add $0x8,%rax
cmp %rax,%rsi
jne 1650 <func0+0x60>
movslq %r13d,%rsi
lea -0xa1(%rip),%rcx
mov $0x8,%edx
mov %r12,%rdi
callq 10a0 <qsort@plt>
movslq %r14d,%rsi
mov $0x8,%edx
mov %rbp,%rdi
lea -0xc0(%rip),%rcx
callq 10a0 <qsort@plt>
test %r13d,%r13d
jle 1840 <func0+0x250>
lea -0x1(%r13),%esi
xor %eax,%eax
xor %r13d,%r13d
jmp 16d3 <func0+0xe3>
nopl 0x0(%rax)
mov -0x8(%r12,%rax,8),%edi
cmp %edi,(%r12,%rax,8)
jne 16d8 <func0+0xe8>
mov -0x4(%r12,%rax,8),%edi
cmp %edi,0x4(%r12,%rax,8)
jne 16d8 <func0+0xe8>
lea 0x1(%rax),%rdx
cmp %rax,%rsi
je 16f0 <func0+0x100>
mov %rdx,%rax
test %rax,%rax
jne 16b0 <func0+0xc0>
mov (%r12,%rax,8),%rcx
movslq %r13d,%rdx
add $0x1,%r13d
mov %rcx,(%r12,%rdx,8)
lea 0x1(%rax),%rdx
cmp %rax,%rsi
jne 16d0 <func0+0xe0>
test %r14d,%r14d
jle 1830 <func0+0x240>
lea -0x1(%r14),%r15d
mov %r15d,%esi
xor %eax,%eax
xor %r14d,%r14d
jmp 1730 <func0+0x140>
nopw 0x0(%rax,%rax,1)
mov -0x8(%rbp,%rax,8),%edi
cmp %edi,0x0(%rbp,%rax,8)
jne 1735 <func0+0x145>
mov -0x4(%rbp,%rax,8),%edi
cmp %edi,0x4(%rbp,%rax,8)
jne 1735 <func0+0x145>
lea 0x1(%rax),%rdx
cmp %rsi,%rax
je 174f <func0+0x15f>
mov %rdx,%rax
test %rax,%rax
jne 1710 <func0+0x120>
mov 0x0(%rbp,%rax,8),%rcx
movslq %r14d,%rdx
add $0x1,%r14d
mov %rcx,0x0(%rbp,%rdx,8)
lea 0x1(%rax),%rdx
cmp %rsi,%rax
jne 172d <func0+0x13d>
cmp %r14d,%r13d
mov %r14d,%edi
cmovle %r13d,%edi
movslq %edi,%rdi
shl $0x3,%rdi
callq 10d0 <malloc@plt>
test %r13d,%r13d
jle 1848 <func0+0x258>
test %r14d,%r14d
jle 1848 <func0+0x258>
xor %ecx,%ecx
xor %esi,%esi
xor %r10d,%r10d
jmp 1794 <func0+0x1a4>
sub %r9d,%edx
test %edx,%edx
js 17e8 <func0+0x1f8>
add $0x1,%ecx
cmp %esi,%r13d
jle 17cf <func0+0x1df>
cmp %r14d,%ecx
jge 17cf <func0+0x1df>
movslq %ecx,%rdx
lea 0x0(%rbp,%rdx,8),%r8
movslq %esi,%rdx
lea (%r12,%rdx,8),%rdi
mov (%r8),%r9d
mov (%rdi),%edx
cmp %r9d,%edx
jne 1780 <func0+0x190>
mov 0x4(%rdi),%edx
sub 0x4(%r8),%edx
jne 1783 <func0+0x193>
mov (%rdi),%rdi
movslq %r10d,%rdx
add $0x1,%esi
add $0x1,%ecx
add $0x1,%r10d
mov %rdi,(%rax,%rdx,8)
cmp %esi,%r13d
jg 178f <func0+0x19f>
mov %r10d,(%rbx)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopl 0x0(%rax)
add $0x1,%esi
jmp 178a <func0+0x19a>
nopl (%rax)
movslq %r13d,%rsi
lea -0x22a(%rip),%rcx
mov $0x8,%edx
mov %r12,%rdi
callq 10a0 <qsort@plt>
movslq %r14d,%rsi
mov $0x8,%edx
mov %rbp,%rdi
lea -0x249(%rip),%rcx
callq 10a0 <qsort@plt>
test %r13d,%r13d
jg 169e <func0+0xae>
nopw 0x0(%rax,%rax,1)
xor %edi,%edi
callq 10d0 <malloc@plt>
xor %r10d,%r10d
jmp 17cf <func0+0x1df>
nopl 0x0(%rax)
xor %r13d,%r13d
jmpq 16fd <func0+0x10d>
xor %r10d,%r10d
jmp 17cf <func0+0x1df>
nopl (%rax)
| func0:
endbr64
push r15
push r14
mov r14d, ecx
push r13
mov r13d, esi
push r12
mov r12, rdx
push rbp
mov rbp, rdi
push rbx
mov rbx, r8
sub rsp, 8
test esi, esi
jle short loc_1637
lea edx, [rsi-1]
mov rax, rdi
lea rsi, [rdi+rdx*8+8]
loc_1620:
mov edx, [rax]
mov ecx, [rax+4]
cmp edx, ecx
jle short loc_162E
mov [rax], ecx
mov [rax+4], edx
loc_162E:
add rax, 8
cmp rax, rsi
jnz short loc_1620
loc_1637:
test r14d, r14d
jle loc_17E8
lea edx, [r14-1]
mov rax, r12
lea rsi, [r12+rdx*8+8]
nop dword ptr [rax+00h]
loc_1650:
mov edx, [rax]
mov ecx, [rax+4]
cmp edx, ecx
jle short loc_165E
mov [rax], ecx
mov [rax+4], edx
loc_165E:
add rax, 8
cmp rsi, rax
jnz short loc_1650
movsxd r15, r13d
lea rcx, tuple_compare
mov edx, 8
mov rdi, rbp
mov rsi, r15
call _qsort
movsxd rsi, r14d
mov edx, 8
mov rdi, r12
lea rcx, tuple_compare
call _qsort
test r13d, r13d
jle loc_1840
loc_16A1:
xor eax, eax
xor r13d, r13d
jmp short loc_16CD
loc_16B0:
mov edi, [rbp+rax*8-8]
cmp [rbp+rax*8+0], edi
jnz short loc_16D2
mov edi, [rbp+rax*8-4]
cmp [rbp+rax*8+4], edi
jnz short loc_16D2
add rax, 1
cmp r15, rax
jz short loc_16EC
loc_16CD:
test rax, rax
jnz short loc_16B0
loc_16D2:
mov rcx, [rbp+rax*8+0]
movsxd rdx, r13d
add rax, 1
add r13d, 1
mov [rbp+rdx*8+0], rcx
cmp r15, rax
jnz short loc_16CD
loc_16EC:
test r14d, r14d
jle loc_1828
loc_16F5:
mov esi, r14d
xor eax, eax
xor r14d, r14d
jmp short loc_1720
loc_1700:
mov edi, [r12+rax*8-8]
cmp [r12+rax*8], edi
jnz short loc_1725
mov edi, [r12+rax*8-4]
cmp [r12+rax*8+4], edi
jnz short loc_1725
add rax, 1
cmp rsi, rax
jz short loc_173D
loc_1720:
test rax, rax
jnz short loc_1700
loc_1725:
mov rcx, [r12+rax*8]
movsxd rdx, r14d
add rax, 1
add r14d, 1
mov [r12+rdx*8], rcx
cmp rsi, rax
jnz short loc_1720
loc_173D:
cmp r14d, r13d
mov edi, r13d
cmovle edi, r14d
movsxd rdi, edi
shl rdi, 3
call _malloc
mov r10, rax
test r13d, r13d
jle loc_1832
test r14d, r14d
jle loc_1832
xor edx, edx
xor ecx, ecx
xor r9d, r9d
jmp short loc_178C
loc_1778:
sub eax, r8d
loc_177B:
test eax, eax
js short loc_17E0
add edx, 1
loc_1782:
cmp ecx, r13d
jge short loc_17C6
loc_1787:
cmp edx, r14d
jge short loc_17C6
loc_178C:
movsxd rax, edx
lea rdi, [r12+rax*8]
movsxd rax, ecx
lea rsi, [rbp+rax*8+0]
mov r8d, [rdi]
mov eax, [rsi]
cmp eax, r8d
jnz short loc_1778
mov eax, [rsi+4]
sub eax, [rdi+4]
jnz short loc_177B
mov rsi, [rsi]
movsxd rax, r9d
add ecx, 1
add edx, 1
add r9d, 1
mov [r10+rax*8], rsi
cmp ecx, r13d
jl short loc_1787
loc_17C6:
mov [rbx], r9d
add rsp, 8
mov rax, r10
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_17E0:
add ecx, 1
jmp short loc_1782
loc_17E8:
movsxd r15, r13d
lea rcx, tuple_compare
mov edx, 8
mov rdi, rbp
mov rsi, r15
call _qsort
movsxd rsi, r14d
mov edx, 8
mov rdi, r12
lea rcx, tuple_compare
call _qsort
test r13d, r13d
jg loc_16A1
nop word ptr [rax+rax+00h]
loc_1828:
xor edi, edi
call _malloc
mov r10, rax
loc_1832:
xor r9d, r9d
jmp short loc_17C6
loc_1840:
xor r13d, r13d
jmp loc_16F5 | long long func0(int *a1, int a2, int *a3, int a4, _DWORD *a5)
{
int *v10; // rax
long long v11; // rsi
int v12; // edx
int v13; // ecx
int *v14; // rax
int v15; // edx
int v16; // ecx
long long v17; // r15
long long v18; // rax
int v19; // r13d
long long v20; // rcx
long long v21; // rdx
long long v22; // rsi
long long v23; // rax
int v24; // r14d
long long v25; // rcx
long long v26; // rdx
int v27; // edi
long long v28; // r10
int v29; // edx
int v30; // ecx
int v31; // r9d
int v32; // eax
int *v33; // rdi
int *v34; // rsi
long long v35; // rax
if ( a2 > 0 )
{
v10 = a1;
v11 = (long long)&a1[2 * (a2 - 1) + 2];
do
{
v12 = *v10;
v13 = v10[1];
if ( *v10 > v13 )
{
*v10 = v13;
v10[1] = v12;
}
v10 += 2;
}
while ( v10 != (int *)v11 );
}
if ( a4 <= 0 )
{
v17 = a2;
qsort(a1, a2, 8LL, tuple_compare);
qsort(a3, a4, 8LL, tuple_compare);
if ( a2 <= 0 )
{
LABEL_41:
v28 = malloc(0LL);
goto LABEL_42;
}
}
else
{
v14 = a3;
do
{
v15 = *v14;
v16 = v14[1];
if ( *v14 > v16 )
{
*v14 = v16;
v14[1] = v15;
}
v14 += 2;
}
while ( &a3[2 * (a4 - 1) + 2] != v14 );
v17 = a2;
qsort(a1, a2, 8LL, tuple_compare);
qsort(a3, a4, 8LL, tuple_compare);
if ( a2 <= 0 )
{
v19 = 0;
goto LABEL_19;
}
}
v18 = 0LL;
v19 = 0;
do
{
while ( v18 && a1[2 * v18] == a1[2 * v18 - 2] && a1[2 * v18 + 1] == a1[2 * v18 - 1] )
{
if ( v17 == ++v18 )
goto LABEL_18;
}
v20 = *(_QWORD *)&a1[2 * v18];
v21 = v19;
++v18;
++v19;
*(_QWORD *)&a1[2 * v21] = v20;
}
while ( v17 != v18 );
LABEL_18:
if ( a4 <= 0 )
goto LABEL_41;
LABEL_19:
v22 = (unsigned int)a4;
v23 = 0LL;
v24 = 0;
do
{
while ( v23 && a3[2 * v23] == a3[2 * v23 - 2] && a3[2 * v23 + 1] == a3[2 * v23 - 1] )
{
if ( v22 == ++v23 )
goto LABEL_25;
}
v25 = *(_QWORD *)&a3[2 * v23];
v26 = v24;
++v23;
++v24;
*(_QWORD *)&a3[2 * v26] = v25;
}
while ( v22 != v23 );
LABEL_25:
v27 = v19;
if ( v24 <= v19 )
v27 = v24;
v28 = malloc(8LL * v27);
if ( v19 > 0 && v24 > 0 )
{
v29 = 0;
v30 = 0;
v31 = 0;
while ( 1 )
{
v33 = &a3[2 * v29];
v34 = &a1[2 * v30];
if ( *v34 == *v33 )
{
v32 = v34[1] - v33[1];
if ( !v32 )
{
v35 = v31;
++v30;
++v29;
++v31;
*(_QWORD *)(v28 + 8 * v35) = *(_QWORD *)v34;
if ( v30 >= v19 )
goto LABEL_38;
goto LABEL_34;
}
}
else
{
v32 = *v34 - *v33;
}
if ( v32 < 0 )
++v30;
else
++v29;
if ( v30 >= v19 )
goto LABEL_38;
LABEL_34:
if ( v29 >= v24 )
goto LABEL_38;
}
}
LABEL_42:
v31 = 0;
LABEL_38:
*a5 = v31;
return v28;
} | func0:
ENDBR64
PUSH R15
PUSH R14
MOV R14D,ECX
PUSH R13
MOV R13D,ESI
PUSH R12
MOV R12,RDX
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOV RBX,R8
SUB RSP,0x8
TEST ESI,ESI
JLE 0x00101637
LEA EDX,[RSI + -0x1]
MOV RAX,RDI
LEA RSI,[RDI + RDX*0x8 + 0x8]
LAB_00101620:
MOV EDX,dword ptr [RAX]
MOV ECX,dword ptr [RAX + 0x4]
CMP EDX,ECX
JLE 0x0010162e
MOV dword ptr [RAX],ECX
MOV dword ptr [RAX + 0x4],EDX
LAB_0010162e:
ADD RAX,0x8
CMP RAX,RSI
JNZ 0x00101620
LAB_00101637:
TEST R14D,R14D
JLE 0x001017e8
LEA EDX,[R14 + -0x1]
MOV RAX,R12
LEA RSI,[R12 + RDX*0x8 + 0x8]
NOP dword ptr [RAX]
LAB_00101650:
MOV EDX,dword ptr [RAX]
MOV ECX,dword ptr [RAX + 0x4]
CMP EDX,ECX
JLE 0x0010165e
MOV dword ptr [RAX],ECX
MOV dword ptr [RAX + 0x4],EDX
LAB_0010165e:
ADD RAX,0x8
CMP RSI,RAX
JNZ 0x00101650
MOVSXD R15,R13D
LEA RCX,[0x1015d0]
MOV EDX,0x8
MOV RDI,RBP
MOV RSI,R15
CALL 0x001010a0
MOVSXD RSI,R14D
MOV EDX,0x8
MOV RDI,R12
LEA RCX,[0x1015d0]
CALL 0x001010a0
TEST R13D,R13D
JLE 0x00101840
LAB_001016a1:
XOR EAX,EAX
XOR R13D,R13D
JMP 0x001016cd
LAB_001016b0:
MOV EDI,dword ptr [RBP + RAX*0x8 + -0x8]
CMP dword ptr [RBP + RAX*0x8],EDI
JNZ 0x001016d2
MOV EDI,dword ptr [RBP + RAX*0x8 + -0x4]
CMP dword ptr [RBP + RAX*0x8 + 0x4],EDI
JNZ 0x001016d2
ADD RAX,0x1
CMP R15,RAX
JZ 0x001016ec
LAB_001016cd:
TEST RAX,RAX
JNZ 0x001016b0
LAB_001016d2:
MOV RCX,qword ptr [RBP + RAX*0x8]
MOVSXD RDX,R13D
ADD RAX,0x1
ADD R13D,0x1
MOV qword ptr [RBP + RDX*0x8],RCX
CMP R15,RAX
JNZ 0x001016cd
LAB_001016ec:
TEST R14D,R14D
JLE 0x00101828
LAB_001016f5:
MOV ESI,R14D
XOR EAX,EAX
XOR R14D,R14D
JMP 0x00101720
LAB_00101700:
MOV EDI,dword ptr [R12 + RAX*0x8 + -0x8]
CMP dword ptr [R12 + RAX*0x8],EDI
JNZ 0x00101725
MOV EDI,dword ptr [R12 + RAX*0x8 + -0x4]
CMP dword ptr [R12 + RAX*0x8 + 0x4],EDI
JNZ 0x00101725
ADD RAX,0x1
CMP RSI,RAX
JZ 0x0010173d
LAB_00101720:
TEST RAX,RAX
JNZ 0x00101700
LAB_00101725:
MOV RCX,qword ptr [R12 + RAX*0x8]
MOVSXD RDX,R14D
ADD RAX,0x1
ADD R14D,0x1
MOV qword ptr [R12 + RDX*0x8],RCX
CMP RSI,RAX
JNZ 0x00101720
LAB_0010173d:
CMP R14D,R13D
MOV EDI,R13D
CMOVLE EDI,R14D
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010d0
MOV R10,RAX
TEST R13D,R13D
JLE 0x00101832
TEST R14D,R14D
JLE 0x00101832
XOR EDX,EDX
XOR ECX,ECX
XOR R9D,R9D
JMP 0x0010178c
LAB_00101778:
SUB EAX,R8D
LAB_0010177b:
TEST EAX,EAX
JS 0x001017e0
ADD EDX,0x1
LAB_00101782:
CMP ECX,R13D
JGE 0x001017c6
LAB_00101787:
CMP EDX,R14D
JGE 0x001017c6
LAB_0010178c:
MOVSXD RAX,EDX
LEA RDI,[R12 + RAX*0x8]
MOVSXD RAX,ECX
LEA RSI,[RBP + RAX*0x8]
MOV R8D,dword ptr [RDI]
MOV EAX,dword ptr [RSI]
CMP EAX,R8D
JNZ 0x00101778
MOV EAX,dword ptr [RSI + 0x4]
SUB EAX,dword ptr [RDI + 0x4]
JNZ 0x0010177b
MOV RSI,qword ptr [RSI]
MOVSXD RAX,R9D
ADD ECX,0x1
ADD EDX,0x1
ADD R9D,0x1
MOV qword ptr [R10 + RAX*0x8],RSI
CMP ECX,R13D
JL 0x00101787
LAB_001017c6:
MOV dword ptr [RBX],R9D
ADD RSP,0x8
MOV RAX,R10
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001017e0:
ADD ECX,0x1
JMP 0x00101782
LAB_001017e8:
MOVSXD R15,R13D
LEA RCX,[0x1015d0]
MOV EDX,0x8
MOV RDI,RBP
MOV RSI,R15
CALL 0x001010a0
MOVSXD RSI,R14D
MOV EDX,0x8
MOV RDI,R12
LEA RCX,[0x1015d0]
CALL 0x001010a0
TEST R13D,R13D
JG 0x001016a1
NOP word ptr [RAX + RAX*0x1]
LAB_00101828:
XOR EDI,EDI
CALL 0x001010d0
MOV R10,RAX
LAB_00101832:
XOR R9D,R9D
JMP 0x001017c6
LAB_00101840:
XOR R13D,R13D
JMP 0x001016f5 | void * func0(int *param_1,int param_2,int *param_3,uint param_4,int *param_5)
{
int iVar1;
int *piVar2;
long lVar3;
ulong uVar4;
void *pvVar5;
int iVar6;
int iVar7;
long lVar8;
long lVar9;
int iVar10;
int iVar11;
int iVar12;
if (0 < param_2) {
piVar2 = param_1;
do {
iVar11 = *piVar2;
if (piVar2[1] < iVar11) {
*piVar2 = piVar2[1];
piVar2[1] = iVar11;
}
piVar2 = piVar2 + 2;
} while (piVar2 != param_1 + (ulong)(param_2 - 1) * 2 + 2);
}
if ((int)param_4 < 1) {
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)(int)param_4,8,tuple_compare);
if (0 < param_2) goto LAB_001016a1;
LAB_00101828:
pvVar5 = malloc(0);
}
else {
piVar2 = param_3;
do {
iVar11 = *piVar2;
if (piVar2[1] < iVar11) {
*piVar2 = piVar2[1];
piVar2[1] = iVar11;
}
piVar2 = piVar2 + 2;
} while (param_3 + (ulong)(param_4 - 1) * 2 + 2 != piVar2);
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)(int)param_4,8,tuple_compare);
if (param_2 < 1) {
iVar11 = 0;
}
else {
LAB_001016a1:
lVar3 = 0;
iVar11 = 0;
do {
while (((lVar3 == 0 || (param_1[lVar3 * 2] != param_1[lVar3 * 2 + -2])) ||
(param_1[lVar3 * 2 + 1] != param_1[lVar3 * 2 + -1]))) {
lVar9 = lVar3 * 2;
lVar8 = (long)iVar11;
lVar3 = lVar3 + 1;
iVar11 = iVar11 + 1;
*(int8 *)(param_1 + lVar8 * 2) = *(int8 *)(param_1 + lVar9);
if (param_2 == lVar3) goto LAB_001016ec;
}
lVar3 = lVar3 + 1;
} while (param_2 != lVar3);
LAB_001016ec:
if ((int)param_4 < 1) goto LAB_00101828;
}
uVar4 = 0;
iVar12 = 0;
do {
while (((uVar4 == 0 || (param_3[uVar4 * 2] != param_3[uVar4 * 2 + -2])) ||
(param_3[uVar4 * 2 + 1] != param_3[uVar4 * 2 + -1]))) {
lVar3 = uVar4 * 2;
lVar9 = (long)iVar12;
uVar4 = uVar4 + 1;
iVar12 = iVar12 + 1;
*(int8 *)(param_3 + lVar9 * 2) = *(int8 *)(param_3 + lVar3);
if (param_4 == uVar4) goto LAB_0010173d;
}
uVar4 = uVar4 + 1;
} while (param_4 != uVar4);
LAB_0010173d:
iVar7 = iVar11;
if (iVar12 <= iVar11) {
iVar7 = iVar12;
}
pvVar5 = malloc((long)iVar7 << 3);
if ((0 < iVar11) && (0 < iVar12)) {
iVar7 = 0;
iVar6 = 0;
iVar10 = 0;
do {
piVar2 = param_1 + (long)iVar6 * 2;
iVar1 = param_3[(long)iVar7 * 2];
if (*piVar2 == iVar1) {
iVar1 = piVar2[1] - (param_3 + (long)iVar7 * 2)[1];
if (iVar1 != 0) goto LAB_0010177b;
lVar3 = (long)iVar10;
iVar6 = iVar6 + 1;
iVar7 = iVar7 + 1;
iVar10 = iVar10 + 1;
*(int8 *)((long)pvVar5 + lVar3 * 8) = *(int8 *)piVar2;
}
else {
iVar1 = *piVar2 - iVar1;
LAB_0010177b:
if (iVar1 < 0) {
iVar6 = iVar6 + 1;
}
else {
iVar7 = iVar7 + 1;
}
}
} while ((iVar6 < iVar11) && (iVar7 < iVar12));
goto LAB_001017c6;
}
}
iVar10 = 0;
LAB_001017c6:
*param_5 = iVar10;
return pvVar5;
} |
5,787 | func0 |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int first;
int second;
} tuple;
// Compare two tuples for qsort and bsearch
int tuple_compare(const void *a, const void *b) {
tuple *t1 = (tuple *)a;
tuple *t2 = (tuple *)b;
if (t1->first != t2->first)
return t1->first - t2->first;
return t1->second - t2->second;
}
// Function to perform tuple intersection
| tuple* func0(tuple *list1, int size1, tuple *list2, int size2, int *res_size) {
// Sort individual tuples
for(int i = 0; i < size1; i++) {
if(list1[i].first > list1[i].second){
int temp = list1[i].first;
list1[i].first = list1[i].second;
list1[i].second = temp;
}
}
for(int i = 0; i < size2; i++) {
if(list2[i].first > list2[i].second){
int temp = list2[i].first;
list2[i].first = list2[i].second;
list2[i].second = temp;
}
}
// Sort the lists
qsort(list1, size1, sizeof(tuple), tuple_compare);
qsort(list2, size2, sizeof(tuple), tuple_compare);
// Remove duplicates
int unique1 = 0;
for(int i = 0; i < size1; i++) {
if(i == 0 || tuple_compare(&list1[i], &list1[i-1]) != 0){
list1[unique1++] = list1[i];
}
}
int unique2 = 0;
for(int i = 0; i < size2; i++) {
if(i == 0 || tuple_compare(&list2[i], &list2[i-1]) != 0){
list2[unique2++] = list2[i];
}
}
// Find intersection
tuple *res = malloc(sizeof(tuple) * (unique1 < unique2 ? unique1 : unique2));
int count = 0, i_idx = 0, j_idx = 0;
while(i_idx < unique1 && j_idx < unique2){
int cmp = tuple_compare(&list1[i_idx], &list2[j_idx]);
if(cmp == 0){
res[count++] = list1[i_idx];
i_idx++;
j_idx++;
}
else if(cmp < 0)
i_idx++;
else
j_idx++;
}
*res_size = count;
return res;
}
| int main() {
// First test
tuple list1_1[] = { {3,4}, {5,6}, {9,10}, {4,5} };
int size1_1 = 4;
tuple list2_1[] = { {5,4}, {3,4}, {6,5}, {9,11} };
int size2_1 = 4;
int res_size_1;
tuple *res1 = func0(list1_1, size1_1, list2_1, size2_1, &res_size_1);
tuple expected1[] = { {3,4}, {4,5}, {5,6} };
int expected_size1 = 3;
assert(res_size_1 == expected_size1);
for(int i=0;i<expected_size1;i++) {
assert(res1[i].first == expected1[i].first);
assert(res1[i].second == expected1[i].second);
}
free(res1);
// Second test
tuple list1_2[] = { {4,1}, {7,4}, {11,13}, {17,14} };
int size1_2 = 4;
tuple list2_2[] = { {1,4}, {7,4}, {16,12}, {10,13} };
int size2_2 = 4;
int res_size_2;
tuple *res2 = func0(list1_2, size1_2, list2_2, size2_2, &res_size_2);
tuple expected2[] = { {1,4}, {4,7} };
int expected_size2 = 2;
assert(res_size_2 == expected_size2);
for(int i=0;i<expected_size2;i++) {
assert(res2[i].first == expected2[i].first);
assert(res2[i].second == expected2[i].second);
}
free(res2);
// Third test
tuple list1_3[] = { {2,1}, {3,2}, {1,3}, {1,4} };
int size1_3 = 4;
tuple list2_3[] = { {11,2}, {2,3}, {6,2}, {1,3} };
int size2_3 = 4;
int res_size_3;
tuple *res3 = func0(list1_3, size1_3, list2_3, size2_3, &res_size_3);
tuple expected3[] = { {1,3}, {2,3} };
int expected_size3 = 2;
assert(res_size_3 == expected_size3);
for(int i=0;i<expected_size3;i++) {
assert(res3[i].first == expected3[i].first);
assert(res3[i].second == expected3[i].second);
}
free(res3);
return 0;
}
| O3 | c | func0:
endbr64
push %r15
push %r14
mov %ecx,%r14d
push %r13
mov %esi,%r13d
push %r12
mov %rdi,%r12
push %rbp
mov %rdx,%rbp
push %rbx
mov %r8,%rbx
sub $0x8,%rsp
test %esi,%esi
jle 1587 <func0+0x47>
lea -0x1(%rsi),%edx
mov %rdi,%rax
lea 0x8(%rdi,%rdx,8),%rsi
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 157e <func0+0x3e>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
add $0x8,%rax
cmp %rsi,%rax
jne 1570 <func0+0x30>
test %r14d,%r14d
jle 1740 <func0+0x200>
lea -0x1(%r14),%edx
mov %rbp,%rax
mov %rdx,%r15
lea 0x8(%rbp,%rdx,8),%rsi
mov (%rax),%edx
mov 0x4(%rax),%ecx
cmp %ecx,%edx
jle 15ae <func0+0x6e>
mov %ecx,(%rax)
mov %edx,0x4(%rax)
add $0x8,%rax
cmp %rsi,%rax
jne 15a0 <func0+0x60>
movslq %r13d,%rsi
lea -0xa1(%rip),%rcx
mov $0x8,%edx
mov %r12,%rdi
callq 10a0 <qsort@plt>
movslq %r14d,%rsi
mov $0x8,%edx
mov %rbp,%rdi
lea -0xc0(%rip),%rcx
callq 10a0 <qsort@plt>
test %r13d,%r13d
jle 1790 <func0+0x250>
lea -0x1(%r13),%esi
xor %eax,%eax
xor %r13d,%r13d
jmp 1623 <func0+0xe3>
nopl 0x0(%rax)
mov -0x8(%r12,%rax,8),%edi
cmp %edi,(%r12,%rax,8)
jne 1628 <func0+0xe8>
mov -0x4(%r12,%rax,8),%edi
cmp %edi,0x4(%r12,%rax,8)
jne 1628 <func0+0xe8>
lea 0x1(%rax),%rdx
cmp %rsi,%rax
je 1640 <func0+0x100>
mov %rdx,%rax
test %rax,%rax
jne 1600 <func0+0xc0>
mov (%r12,%rax,8),%rcx
movslq %r13d,%rdx
add $0x1,%r13d
mov %rcx,(%r12,%rdx,8)
lea 0x1(%rax),%rdx
cmp %rsi,%rax
jne 1620 <func0+0xe0>
test %r14d,%r14d
jle 1780 <func0+0x240>
lea -0x1(%r14),%r15d
mov %r15d,%esi
xor %eax,%eax
xor %r14d,%r14d
jmp 1680 <func0+0x140>
nopw 0x0(%rax,%rax,1)
mov -0x8(%rbp,%rax,8),%edi
cmp %edi,0x0(%rbp,%rax,8)
jne 1685 <func0+0x145>
mov -0x4(%rbp,%rax,8),%edi
cmp %edi,0x4(%rbp,%rax,8)
jne 1685 <func0+0x145>
lea 0x1(%rax),%rdx
cmp %rsi,%rax
je 169f <func0+0x15f>
mov %rdx,%rax
test %rax,%rax
jne 1660 <func0+0x120>
mov 0x0(%rbp,%rax,8),%rcx
movslq %r14d,%rdx
add $0x1,%r14d
mov %rcx,0x0(%rbp,%rdx,8)
lea 0x1(%rax),%rdx
cmp %rsi,%rax
jne 167d <func0+0x13d>
cmp %r14d,%r13d
mov %r14d,%edi
cmovle %r13d,%edi
movslq %edi,%rdi
shl $0x3,%rdi
callq 10d0 <malloc@plt>
test %r13d,%r13d
jle 1798 <func0+0x258>
test %r14d,%r14d
jle 1798 <func0+0x258>
xor %ecx,%ecx
xor %esi,%esi
xor %r10d,%r10d
jmp 16e4 <func0+0x1a4>
sub %r9d,%edx
test %edx,%edx
js 1738 <func0+0x1f8>
add $0x1,%ecx
cmp %esi,%r13d
jle 171f <func0+0x1df>
cmp %r14d,%ecx
jge 171f <func0+0x1df>
movslq %ecx,%rdx
lea 0x0(%rbp,%rdx,8),%r8
movslq %esi,%rdx
lea (%r12,%rdx,8),%rdi
mov (%r8),%r9d
mov (%rdi),%edx
cmp %r9d,%edx
jne 16d0 <func0+0x190>
mov 0x4(%rdi),%edx
sub 0x4(%r8),%edx
jne 16d3 <func0+0x193>
mov (%rdi),%rdi
movslq %r10d,%rdx
add $0x1,%esi
add $0x1,%ecx
add $0x1,%r10d
mov %rdi,(%rax,%rdx,8)
cmp %esi,%r13d
jg 16df <func0+0x19f>
mov %r10d,(%rbx)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
nopl 0x0(%rax)
add $0x1,%esi
jmp 16da <func0+0x19a>
nopl (%rax)
movslq %r13d,%rsi
lea -0x22a(%rip),%rcx
mov $0x8,%edx
mov %r12,%rdi
callq 10a0 <qsort@plt>
movslq %r14d,%rsi
mov $0x8,%edx
mov %rbp,%rdi
lea -0x249(%rip),%rcx
callq 10a0 <qsort@plt>
test %r13d,%r13d
jg 15ee <func0+0xae>
nopw 0x0(%rax,%rax,1)
xor %edi,%edi
callq 10d0 <malloc@plt>
xor %r10d,%r10d
jmp 171f <func0+0x1df>
nopl 0x0(%rax)
xor %r13d,%r13d
jmpq 164d <func0+0x10d>
xor %r10d,%r10d
jmp 171f <func0+0x1df>
nopl (%rax)
| func0:
endbr64
push r15
push r14
mov r14d, esi
push r13
mov r13d, ecx
push r12
mov r12, rdx
push rbp
mov rbp, rdi
push rbx
sub rsp, 18h
mov [rsp+48h+var_48], r8
test esi, esi
jle loc_1748
movsxd r15, esi
mov rax, rdi
lea rsi, [rdi+r15*8]
nop dword ptr [rax+00h]
loc_1558:
movq xmm0, qword ptr [rax]
pshufd xmm1, xmm0, 0E5h
movd ecx, xmm0
movd edx, xmm1
cmp ecx, edx
jle short loc_1576
pshufd xmm0, xmm0, 0E1h
movq qword ptr [rax], xmm0
loc_1576:
add rax, 8
cmp rax, rsi
jnz short loc_1558
movsxd rbx, r13d
test r13d, r13d
jle short loc_15BF
loc_1587:
movsxd rbx, r13d
mov rax, r12
lea rsi, [r12+rbx*8]
nop dword ptr [rax+00000000h]
loc_1598:
movq xmm0, qword ptr [rax]
pshufd xmm2, xmm0, 0E5h
movd ecx, xmm0
movd edx, xmm2
cmp ecx, edx
jle short loc_15B6
pshufd xmm0, xmm0, 0E1h
movq qword ptr [rax], xmm0
loc_15B6:
add rax, 8
cmp rsi, rax
jnz short loc_1598
loc_15BF:
lea rcx, tuple_compare; compar
mov edx, 8; size
mov rsi, r15; nmemb
mov rdi, rbp; base
call _qsort
mov edx, 8; size
mov rsi, rbx; nmemb
mov rdi, r12; base
lea rcx, tuple_compare; compar
call _qsort
xor eax, eax
xor edx, edx
test r14d, r14d
jg short loc_161D
jmp short loc_163B
loc_1600:
mov edi, [rbp+rax*8-8]
cmp [rbp+rax*8+0], edi
jnz short loc_1622
mov edi, [rbp+rax*8-4]
cmp [rbp+rax*8+4], edi
jnz short loc_1622
add rax, 1
cmp r15, rax
jz short loc_163B
loc_161D:
test rax, rax
jnz short loc_1600
loc_1622:
mov rsi, [rbp+rax*8+0]
movsxd rcx, edx
add rax, 1
add edx, 1
mov [rbp+rcx*8+0], rsi
cmp r15, rax
jnz short loc_161D
loc_163B:
test r13d, r13d
jle loc_1788
xor eax, eax
xor r13d, r13d
jmp short loc_1670
loc_1650:
mov edi, [r12+rax*8-8]
cmp [r12+rax*8], edi
jnz short loc_1675
mov esi, [r12+rax*8-4]
cmp [r12+rax*8+4], esi
jnz short loc_1675
add rax, 1
cmp rbx, rax
jz short loc_168D
loc_1670:
test rax, rax
jnz short loc_1650
loc_1675:
mov rsi, [r12+rax*8]
movsxd rcx, r13d
add rax, 1
add r13d, 1
mov [r12+rcx*8], rsi
cmp rbx, rax
jnz short loc_1670
loc_168D:
cmp r13d, edx
mov edi, edx
mov [rsp+48h+var_3C], edx
cmovle edi, r13d
movsxd rdi, edi
shl rdi, 3; size
call _malloc
mov r11, rax
test r13d, r13d
jle loc_179E
mov edx, [rsp+48h+var_3C]
test edx, edx
jle loc_179E
xor ecx, ecx
xor esi, esi
xor r10d, r10d
jmp short loc_16E3
loc_16D0:
sub eax, r9d
loc_16D3:
test eax, eax
js short loc_1740
add ecx, 1
loc_16DA:
cmp esi, edx
jge short loc_171D
loc_16DE:
cmp ecx, r13d
jge short loc_171D
loc_16E3:
movsxd rax, ecx
lea r8, [r12+rax*8]
movsxd rax, esi
lea rdi, [rbp+rax*8+0]
mov r9d, [r8]
mov eax, [rdi]
cmp eax, r9d
jnz short loc_16D0
mov eax, [rdi+4]
sub eax, [r8+4]
jnz short loc_16D3
mov rdi, [rdi]
movsxd rax, r10d
add esi, 1
add ecx, 1
add r10d, 1
mov [r11+rax*8], rdi
cmp esi, edx
jl short loc_16DE
loc_171D:
mov rax, [rsp+48h+var_48]
mov [rax], r10d
add rsp, 18h
mov rax, r11
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_1740:
add esi, 1
jmp short loc_16DA
loc_1748:
movsxd r15, esi
test ecx, ecx
jg loc_1587
lea r14, tuple_compare
mov edx, 8; size
mov rsi, r15; nmemb
mov rdi, rbp; base
mov rcx, r14; compar
call _qsort
mov edx, 8; size
movsxd rsi, r13d; nmemb
mov rcx, r14; compar
mov rdi, r12; base
call _qsort
xor edx, edx
nop word ptr [rax+rax+00h]
loc_1788:
xor edi, edi
test edx, edx
cmovle edi, edx
movsxd rdi, edi
shl rdi, 3; size
call _malloc
mov r11, rax
loc_179E:
xor r10d, r10d
jmp loc_171D | _QWORD * func0(__m128i *base, int a2, __m128i *a3, int a4, _DWORD *a5)
{
size_t v9; // r15
__m128i *v10; // rax
__m128i *v11; // rsi
__m128i v12; // xmm0
size_t v13; // rbx
__m128i *v14; // rax
__m128i v15; // xmm0
long long v16; // rax
int v17; // edx
long long v18; // rsi
long long v19; // rcx
long long v20; // rax
int v21; // r13d
long long v22; // rsi
long long v23; // rcx
int v24; // edi
_QWORD *v25; // r11
int v26; // ecx
int v27; // esi
int v28; // r10d
int v29; // eax
__int32 *v30; // r8
char *v31; // rdi
long long v32; // rax
int v34; // edi
int v36; // [rsp+Ch] [rbp-3Ch]
if ( a2 <= 0 )
{
v9 = a2;
if ( a4 <= 0 )
{
qsort(base, a2, 8uLL, tuple_compare);
qsort(a3, a4, 8uLL, tuple_compare);
v17 = 0;
LABEL_42:
v34 = 0;
if ( v17 <= 0 )
v34 = v17;
v25 = malloc(8LL * v34);
goto LABEL_45;
}
goto LABEL_7;
}
v9 = a2;
v10 = base;
v11 = (__m128i *)((char *)base + 8 * a2);
do
{
v12 = _mm_loadl_epi64(v10);
if ( _mm_cvtsi128_si32(v12) > _mm_cvtsi128_si32(_mm_shuffle_epi32(v12, 229)) )
v10->m128i_i64[0] = _mm_shuffle_epi32(v12, 225).m128i_u64[0];
v10 = (__m128i *)((char *)v10 + 8);
}
while ( v10 != v11 );
v13 = a4;
if ( a4 > 0 )
{
LABEL_7:
v13 = a4;
v14 = a3;
do
{
v15 = _mm_loadl_epi64(v14);
if ( _mm_cvtsi128_si32(v15) > _mm_cvtsi128_si32(_mm_shuffle_epi32(v15, 229)) )
v14->m128i_i64[0] = _mm_shuffle_epi32(v15, 225).m128i_u64[0];
v14 = (__m128i *)((char *)v14 + 8);
}
while ( (__m128i *)((char *)a3 + 8 * a4) != v14 );
}
qsort(base, v9, 8uLL, tuple_compare);
qsort(a3, v13, 8uLL, tuple_compare);
v16 = 0LL;
v17 = 0;
if ( a2 > 0 )
{
do
{
while ( v16
&& base->m128i_i32[2 * v16] == base->m128i_i32[2 * v16 - 2]
&& base->m128i_i32[2 * v16 + 1] == base->m128i_i32[2 * v16 - 1] )
{
if ( v9 == ++v16 )
goto LABEL_18;
}
v18 = base->m128i_i64[v16];
v19 = v17;
++v16;
++v17;
base->m128i_i64[v19] = v18;
}
while ( v9 != v16 );
}
LABEL_18:
if ( a4 <= 0 )
goto LABEL_42;
v20 = 0LL;
v21 = 0;
do
{
while ( v20
&& a3->m128i_i32[2 * v20] == a3->m128i_i32[2 * v20 - 2]
&& a3->m128i_i32[2 * v20 + 1] == a3->m128i_i32[2 * v20 - 1] )
{
if ( v13 == ++v20 )
goto LABEL_25;
}
v22 = a3->m128i_i64[v20];
v23 = v21;
++v20;
++v21;
a3->m128i_i64[v23] = v22;
}
while ( v13 != v20 );
LABEL_25:
v24 = v17;
v36 = v17;
if ( v21 <= v17 )
v24 = v21;
v25 = malloc(8LL * v24);
if ( v21 > 0 && v36 > 0 )
{
v26 = 0;
v27 = 0;
v28 = 0;
while ( 1 )
{
v30 = &a3->m128i_i32[2 * v26];
v31 = &base->m128i_i8[8 * v27];
if ( *(_DWORD *)v31 == *v30 )
{
v29 = *((_DWORD *)v31 + 1) - v30[1];
if ( !v29 )
{
v32 = v28;
++v27;
++v26;
++v28;
v25[v32] = *(_QWORD *)v31;
if ( v27 >= v36 )
goto LABEL_38;
goto LABEL_34;
}
}
else
{
v29 = *(_DWORD *)v31 - *v30;
}
if ( v29 < 0 )
++v27;
else
++v26;
if ( v27 >= v36 )
goto LABEL_38;
LABEL_34:
if ( v26 >= v21 )
goto LABEL_38;
}
}
LABEL_45:
v28 = 0;
LABEL_38:
*a5 = v28;
return v25;
} | func0:
ENDBR64
PUSH R15
PUSH R14
MOV R14D,ESI
PUSH R13
MOV R13D,ECX
PUSH R12
MOV R12,RDX
PUSH RBP
MOV RBP,RDI
PUSH RBX
SUB RSP,0x18
MOV qword ptr [RSP],R8
TEST ESI,ESI
JLE 0x00101748
MOVSXD R15,ESI
MOV RAX,RDI
LEA RSI,[RDI + R15*0x8]
NOP dword ptr [RAX]
LAB_00101558:
MOVQ XMM0,qword ptr [RAX]
PSHUFD XMM1,XMM0,0xe5
MOVD ECX,XMM0
MOVD EDX,XMM1
CMP ECX,EDX
JLE 0x00101576
PSHUFD XMM0,XMM0,0xe1
MOVQ qword ptr [RAX],XMM0
LAB_00101576:
ADD RAX,0x8
CMP RAX,RSI
JNZ 0x00101558
MOVSXD RBX,R13D
TEST R13D,R13D
JLE 0x001015bf
LAB_00101587:
MOVSXD RBX,R13D
MOV RAX,R12
LEA RSI,[R12 + RBX*0x8]
NOP dword ptr [RAX]
LAB_00101598:
MOVQ XMM0,qword ptr [RAX]
PSHUFD XMM2,XMM0,0xe5
MOVD ECX,XMM0
MOVD EDX,XMM2
CMP ECX,EDX
JLE 0x001015b6
PSHUFD XMM0,XMM0,0xe1
MOVQ qword ptr [RAX],XMM0
LAB_001015b6:
ADD RAX,0x8
CMP RSI,RAX
JNZ 0x00101598
LAB_001015bf:
LEA RCX,[0x101500]
MOV EDX,0x8
MOV RSI,R15
MOV RDI,RBP
CALL 0x001010a0
MOV EDX,0x8
MOV RSI,RBX
MOV RDI,R12
LEA RCX,[0x101500]
CALL 0x001010a0
XOR EAX,EAX
XOR EDX,EDX
TEST R14D,R14D
JG 0x0010161d
JMP 0x0010163b
LAB_00101600:
MOV EDI,dword ptr [RBP + RAX*0x8 + -0x8]
CMP dword ptr [RBP + RAX*0x8],EDI
JNZ 0x00101622
MOV EDI,dword ptr [RBP + RAX*0x8 + -0x4]
CMP dword ptr [RBP + RAX*0x8 + 0x4],EDI
JNZ 0x00101622
ADD RAX,0x1
CMP R15,RAX
JZ 0x0010163b
LAB_0010161d:
TEST RAX,RAX
JNZ 0x00101600
LAB_00101622:
MOV RSI,qword ptr [RBP + RAX*0x8]
MOVSXD RCX,EDX
ADD RAX,0x1
ADD EDX,0x1
MOV qword ptr [RBP + RCX*0x8],RSI
CMP R15,RAX
JNZ 0x0010161d
LAB_0010163b:
TEST R13D,R13D
JLE 0x00101788
XOR EAX,EAX
XOR R13D,R13D
JMP 0x00101670
LAB_00101650:
MOV EDI,dword ptr [R12 + RAX*0x8 + -0x8]
CMP dword ptr [R12 + RAX*0x8],EDI
JNZ 0x00101675
MOV ESI,dword ptr [R12 + RAX*0x8 + -0x4]
CMP dword ptr [R12 + RAX*0x8 + 0x4],ESI
JNZ 0x00101675
ADD RAX,0x1
CMP RBX,RAX
JZ 0x0010168d
LAB_00101670:
TEST RAX,RAX
JNZ 0x00101650
LAB_00101675:
MOV RSI,qword ptr [R12 + RAX*0x8]
MOVSXD RCX,R13D
ADD RAX,0x1
ADD R13D,0x1
MOV qword ptr [R12 + RCX*0x8],RSI
CMP RBX,RAX
JNZ 0x00101670
LAB_0010168d:
CMP R13D,EDX
MOV EDI,EDX
MOV dword ptr [RSP + 0xc],EDX
CMOVLE EDI,R13D
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010d0
MOV R11,RAX
TEST R13D,R13D
JLE 0x0010179e
MOV EDX,dword ptr [RSP + 0xc]
TEST EDX,EDX
JLE 0x0010179e
XOR ECX,ECX
XOR ESI,ESI
XOR R10D,R10D
JMP 0x001016e3
LAB_001016d0:
SUB EAX,R9D
LAB_001016d3:
TEST EAX,EAX
JS 0x00101740
ADD ECX,0x1
LAB_001016da:
CMP ESI,EDX
JGE 0x0010171d
LAB_001016de:
CMP ECX,R13D
JGE 0x0010171d
LAB_001016e3:
MOVSXD RAX,ECX
LEA R8,[R12 + RAX*0x8]
MOVSXD RAX,ESI
LEA RDI,[RBP + RAX*0x8]
MOV R9D,dword ptr [R8]
MOV EAX,dword ptr [RDI]
CMP EAX,R9D
JNZ 0x001016d0
MOV EAX,dword ptr [RDI + 0x4]
SUB EAX,dword ptr [R8 + 0x4]
JNZ 0x001016d3
MOV RDI,qword ptr [RDI]
MOVSXD RAX,R10D
ADD ESI,0x1
ADD ECX,0x1
ADD R10D,0x1
MOV qword ptr [R11 + RAX*0x8],RDI
CMP ESI,EDX
JL 0x001016de
LAB_0010171d:
MOV RAX,qword ptr [RSP]
MOV dword ptr [RAX],R10D
ADD RSP,0x18
MOV RAX,R11
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_00101740:
ADD ESI,0x1
JMP 0x001016da
LAB_00101748:
MOVSXD R15,ESI
TEST ECX,ECX
JG 0x00101587
LEA R14,[0x101500]
MOV EDX,0x8
MOV RSI,R15
MOV RDI,RBP
MOV RCX,R14
CALL 0x001010a0
MOV EDX,0x8
MOVSXD RSI,R13D
MOV RCX,R14
MOV RDI,R12
CALL 0x001010a0
XOR EDX,EDX
NOP word ptr [RAX + RAX*0x1]
LAB_00101788:
XOR EDI,EDI
TEST EDX,EDX
CMOVLE EDI,EDX
MOVSXD RDI,EDI
SHL RDI,0x3
CALL 0x001010d0
MOV R11,RAX
LAB_0010179e:
XOR R10D,R10D
JMP 0x0010171d | void * func0(int8 *param_1,int param_2,int8 *param_3,int param_4,int *param_5)
{
int *piVar1;
int iVar2;
int8 *puVar3;
size_t sVar4;
void *pvVar5;
int iVar6;
long lVar7;
int iVar8;
size_t __nmemb;
int iVar9;
int iVar10;
int iVar11;
size_t __nmemb_00;
if (param_2 < 1) {
if (0 < param_4) goto LAB_00101587;
qsort(param_1,(long)param_2,8,tuple_compare);
qsort(param_3,(long)param_4,8,tuple_compare);
iVar8 = 0;
LAB_00101788:
iVar11 = 0;
if (iVar8 < 1) {
iVar11 = iVar8;
}
pvVar5 = malloc((long)iVar11 << 3);
}
else {
puVar3 = param_1;
do {
iVar8 = (int)*puVar3;
iVar11 = (int)((ulong)*puVar3 >> 0x20);
if (iVar11 < iVar8) {
*puVar3 = CONCAT44(iVar8,iVar11);
}
puVar3 = puVar3 + 1;
} while (puVar3 != param_1 + param_2);
if (0 < param_4) {
LAB_00101587:
puVar3 = param_3;
do {
iVar8 = (int)*puVar3;
iVar11 = (int)((ulong)*puVar3 >> 0x20);
if (iVar11 < iVar8) {
*puVar3 = CONCAT44(iVar8,iVar11);
}
puVar3 = puVar3 + 1;
} while (param_3 + param_4 != puVar3);
}
__nmemb_00 = (size_t)param_2;
__nmemb = (size_t)param_4;
qsort(param_1,__nmemb_00,8,tuple_compare);
qsort(param_3,__nmemb,8,tuple_compare);
sVar4 = 0;
iVar8 = 0;
if (0 < param_2) {
do {
while (((sVar4 == 0 || (*(int *)(param_1 + sVar4) != *(int *)(param_1 + (sVar4 - 1)))) ||
(*(int *)((long)param_1 + sVar4 * 8 + 4) != *(int *)((long)param_1 + sVar4 * 8 + -4))
)) {
puVar3 = param_1 + sVar4;
lVar7 = (long)iVar8;
sVar4 = sVar4 + 1;
iVar8 = iVar8 + 1;
param_1[lVar7] = *puVar3;
if (__nmemb_00 == sVar4) goto LAB_0010163b;
}
sVar4 = sVar4 + 1;
} while (__nmemb_00 != sVar4);
}
LAB_0010163b:
if (param_4 < 1) goto LAB_00101788;
sVar4 = 0;
iVar11 = 0;
do {
while (((sVar4 == 0 || (*(int *)(param_3 + sVar4) != *(int *)(param_3 + (sVar4 - 1)))) ||
(*(int *)((long)param_3 + sVar4 * 8 + 4) != *(int *)((long)param_3 + sVar4 * 8 + -4))))
{
puVar3 = param_3 + sVar4;
lVar7 = (long)iVar11;
sVar4 = sVar4 + 1;
iVar11 = iVar11 + 1;
param_3[lVar7] = *puVar3;
if (__nmemb == sVar4) goto LAB_0010168d;
}
sVar4 = sVar4 + 1;
} while (__nmemb != sVar4);
LAB_0010168d:
iVar6 = iVar8;
if (iVar11 <= iVar8) {
iVar6 = iVar11;
}
pvVar5 = malloc((long)iVar6 << 3);
if ((0 < iVar11) && (0 < iVar8)) {
iVar6 = 0;
iVar9 = 0;
iVar10 = 0;
do {
piVar1 = (int *)(param_1 + iVar9);
iVar2 = *(int *)(param_3 + iVar6);
if (*piVar1 == iVar2) {
iVar2 = piVar1[1] - *(int *)((long)(param_3 + iVar6) + 4);
if (iVar2 != 0) goto LAB_001016d3;
lVar7 = (long)iVar10;
iVar9 = iVar9 + 1;
iVar6 = iVar6 + 1;
iVar10 = iVar10 + 1;
*(int8 *)((long)pvVar5 + lVar7 * 8) = *(int8 *)piVar1;
}
else {
iVar2 = *piVar1 - iVar2;
LAB_001016d3:
if (iVar2 < 0) {
iVar9 = iVar9 + 1;
}
else {
iVar6 = iVar6 + 1;
}
}
} while ((iVar9 < iVar8) && (iVar6 < iVar11));
goto LAB_0010171d;
}
}
iVar10 = 0;
LAB_0010171d:
*param_5 = iVar10;
return pvVar5;
} |
5,788 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
| char* func0(char* str1, char ch, char newch) {
static char str2[100];
strcpy(str2, str1);
for (int i = 0; i < strlen(str2); i++) {
if (str2[i] == ch) {
str2[i] = newch;
}
}
return str2;
}
| int main() {
assert(strcmp(func0("polygon", 'y', 'l'), "pollgon") == 0);
assert(strcmp(func0("character", 'c', 'a'), "aharaater") == 0);
assert(strcmp(func0("python", 'l', 'a'), "python") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
push %rbx
sub $0x28,%rsp
mov %rdi,-0x28(%rbp)
mov %esi,%ecx
mov %edx,%eax
mov %ecx,%edx
mov %dl,-0x2c(%rbp)
mov %al,-0x30(%rbp)
mov -0x28(%rbp),%rax
mov %rax,%rsi
lea 0x2e6c(%rip),%rdi
callq 1080 <strcpy@plt>
movl $0x0,-0x14(%rbp)
jmp 120e <func0+0x65>
mov -0x14(%rbp),%eax
cltq
lea 0x2e52(%rip),%rdx
movzbl (%rax,%rdx,1),%eax
cmp %al,-0x2c(%rbp)
jne 120a <func0+0x61>
mov -0x14(%rbp),%eax
cltq
lea 0x2e3d(%rip),%rcx
movzbl -0x30(%rbp),%edx
mov %dl,(%rax,%rcx,1)
addl $0x1,-0x14(%rbp)
mov -0x14(%rbp),%eax
movslq %eax,%rbx
lea 0x2e25(%rip),%rdi
callq 1090 <strlen@plt>
cmp %rax,%rbx
jb 11e2 <func0+0x39>
lea 0x2e14(%rip),%rax
add $0x28,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
push rbx
sub rsp, 28h
mov [rbp+src], rdi
mov ecx, esi
mov eax, edx
mov edx, ecx
mov [rbp+var_2C], dl
mov [rbp+var_30], al
mov rax, [rbp+src]
mov rsi, rax; src
lea rax, str2_1
mov rdi, rax; dest
call _strcpy
mov [rbp+var_14], 0
jmp short loc_1211
loc_11E5:
mov eax, [rbp+var_14]
cdqe
lea rdx, str2_1
movzx eax, byte ptr [rax+rdx]
cmp [rbp+var_2C], al
jnz short loc_120D
mov eax, [rbp+var_14]
cdqe
lea rcx, str2_1
movzx edx, [rbp+var_30]
mov [rax+rcx], dl
loc_120D:
add [rbp+var_14], 1
loc_1211:
mov eax, [rbp+var_14]
movsxd rbx, eax
lea rax, str2_1
mov rdi, rax; s
call _strlen
cmp rbx, rax
jb short loc_11E5
lea rax, str2_1
mov rbx, [rbp+var_8]
leave
retn | char * func0(const char *a1, char a2, char a3)
{
int i; // [rsp+1Ch] [rbp-14h]
strcpy(str2_1, a1);
for ( i = 0; i < strlen(str2_1); ++i )
{
if ( a2 == str2_1[i] )
str2_1[i] = a3;
}
return str2_1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
PUSH RBX
SUB RSP,0x28
MOV qword ptr [RBP + -0x28],RDI
MOV ECX,ESI
MOV EAX,EDX
MOV EDX,ECX
MOV byte ptr [RBP + -0x2c],DL
MOV byte ptr [RBP + -0x30],AL
MOV RAX,qword ptr [RBP + -0x28]
MOV RSI,RAX
LEA RAX,[0x104040]
MOV RDI,RAX
CALL 0x00101080
MOV dword ptr [RBP + -0x14],0x0
JMP 0x00101211
LAB_001011e5:
MOV EAX,dword ptr [RBP + -0x14]
CDQE
LEA RDX,[0x104040]
MOVZX EAX,byte ptr [RAX + RDX*0x1]
CMP byte ptr [RBP + -0x2c],AL
JNZ 0x0010120d
MOV EAX,dword ptr [RBP + -0x14]
CDQE
LEA RCX,[0x104040]
MOVZX EDX,byte ptr [RBP + -0x30]
MOV byte ptr [RAX + RCX*0x1],DL
LAB_0010120d:
ADD dword ptr [RBP + -0x14],0x1
LAB_00101211:
MOV EAX,dword ptr [RBP + -0x14]
MOVSXD RBX,EAX
LEA RAX,[0x104040]
MOV RDI,RAX
CALL 0x00101090
CMP RBX,RAX
JC 0x001011e5
LEA RAX,[0x104040]
MOV RBX,qword ptr [RBP + -0x8]
LEAVE
RET | int1 * func0(char *param_1,char param_2,int param_3)
{
size_t sVar1;
int local_1c;
strcpy(str2_1,param_1);
local_1c = 0;
while( true ) {
sVar1 = strlen(str2_1);
if (sVar1 <= (ulong)(long)local_1c) break;
if (param_2 == str2_1[local_1c]) {
str2_1[local_1c] = param_3;
}
local_1c = local_1c + 1;
}
return str2_1;
} |
5,789 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
| char* func0(char* str1, char ch, char newch) {
static char str2[100];
strcpy(str2, str1);
for (int i = 0; i < strlen(str2); i++) {
if (str2[i] == ch) {
str2[i] = newch;
}
}
return str2;
}
| int main() {
assert(strcmp(func0("polygon", 'y', 'l'), "pollgon") == 0);
assert(strcmp(func0("character", 'c', 'a'), "aharaater") == 0);
assert(strcmp(func0("python", 'l', 'a'), "python") == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
mov %esi,%ebx
mov %edx,%ebp
mov $0x64,%edx
mov %rdi,%rsi
lea 0x2eba(%rip),%rdi
callq 1070 <__strcpy_chk@plt>
mov $0x0,%edx
lea 0x2ea9(%rip),%rsi
mov $0xffffffffffffffff,%r8
mov $0x0,%eax
jmp 11a9 <func0+0x40>
add $0x1,%rdx
mov %r8,%rcx
mov %rsi,%rdi
repnz scas %es:(%rdi),%al
not %rcx
sub $0x1,%rcx
cmp %rdx,%rcx
jbe 11c8 <func0+0x5f>
cmp %bl,(%rsi,%rdx,1)
jne 11a5 <func0+0x3c>
mov %bpl,(%rsi,%rdx,1)
jmp 11a5 <func0+0x3c>
lea 0x2e71(%rip),%rax
add $0x8,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov r12d, esi
mov r13d, edx
mov edx, 64h ; 'd'
mov rsi, rdi
lea rdi, str2_1
call ___strcpy_chk
mov ebx, 0
lea rbp, str2_1
jmp short loc_11E3
loc_11DF:
add rbx, 1
loc_11E3:
mov rdi, rbp
call _strlen
cmp rax, rbx
jbe short loc_11FE
cmp [rbp+rbx+0], r12b
jnz short loc_11DF
mov [rbp+rbx+0], r13b
jmp short loc_11DF
loc_11FE:
lea rax, str2_1
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn | _BYTE * func0(long long a1, char a2, char a3)
{
unsigned long long i; // rbx
__strcpy_chk(str2_1, a1, 100LL);
for ( i = 0LL; strlen(str2_1) > i; ++i )
{
if ( str2_1[i] == a2 )
str2_1[i] = a3;
}
return str2_1;
} | func0:
ENDBR64
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV R12D,ESI
MOV R13D,EDX
MOV EDX,0x64
MOV RSI,RDI
LEA RDI,[0x104040]
CALL 0x001010b0
MOV EBX,0x0
LEA RBP,[0x104040]
JMP 0x001011e3
LAB_001011df:
ADD RBX,0x1
LAB_001011e3:
MOV RDI,RBP
CALL 0x00101080
CMP RAX,RBX
JBE 0x001011fe
CMP byte ptr [RBP + RBX*0x1],R12B
JNZ 0x001011df
MOV byte ptr [RBP + RBX*0x1],R13B
JMP 0x001011df
LAB_001011fe:
LEA RAX,[0x104040]
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET | int1 * func0(int8 param_1,char param_2,int1 param_3)
{
size_t sVar1;
ulong uVar2;
__strcpy_chk(&str2_1,param_1,100);
uVar2 = 0;
while( true ) {
sVar1 = strlen(&str2_1);
if (sVar1 <= uVar2) break;
if ((&str2_1)[uVar2] == param_2) {
(&str2_1)[uVar2] = param_3;
}
uVar2 = uVar2 + 1;
}
return &str2_1;
} |
5,790 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
| char* func0(char* str1, char ch, char newch) {
static char str2[100];
strcpy(str2, str1);
for (int i = 0; i < strlen(str2); i++) {
if (str2[i] == ch) {
str2[i] = newch;
}
}
return str2;
}
| int main() {
assert(strcmp(func0("polygon", 'y', 'l'), "pollgon") == 0);
assert(strcmp(func0("character", 'c', 'a'), "aharaater") == 0);
assert(strcmp(func0("python", 'l', 'a'), "python") == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %rbp
mov %edx,%ebp
mov $0x64,%edx
push %rbx
mov %esi,%ebx
mov %rdi,%rsi
lea 0x2db7(%rip),%rdi
sub $0x8,%rsp
callq 1070 <__stpcpy_chk@plt>
lea 0x2da7(%rip),%rdi
xor %esi,%esi
sub %rdi,%rax
mov %rdi,%r8
jmp 12ac <func0+0x3c>
nopl 0x0(%rax,%rax,1)
add $0x1,%rsi
cmp %rax,%rsi
jae 1300 <func0+0x90>
cmp %bl,(%rdi,%rsi,1)
jne 12a8 <func0+0x38>
mov %bpl,(%rdi,%rsi,1)
lea 0x2d7f(%rip),%rax
mov %r8,%rdi
mov (%rax),%ecx
add $0x4,%rax
lea -0x1010101(%rcx),%edx
not %ecx
and %ecx,%edx
and $0x80808080,%edx
je 12c4 <func0+0x54>
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 %r8,%rax
jmp 12a8 <func0+0x38>
add $0x8,%rsp
lea 0x2d35(%rip),%rax
pop %rbx
pop %rbp
retq
xchg %ax,%ax
| func0:
endbr64
push r13
mov r13d, edx
mov edx, 64h ; 'd'
push r12
lea r12, str2_1
push rbp
mov ebp, esi
mov rsi, rdi
mov rdi, r12
push rbx
xor ebx, ebx
sub rsp, 8
call ___strcpy_chk
jmp short loc_12CE
loc_12C0:
cmp [r12+rbx], bpl
jnz short loc_12CA
mov [r12+rbx], r13b
loc_12CA:
add rbx, 1
loc_12CE:
mov rdi, r12
call _strlen
cmp rax, rbx
ja short loc_12C0
add rsp, 8
mov rax, r12
pop rbx
pop rbp
pop r12
pop r13
retn | _BYTE * func0(long long a1, char a2, char a3)
{
unsigned long long v4; // rbx
v4 = 0LL;
__strcpy_chk(str2_1, a1, 100LL);
while ( strlen(str2_1) > v4 )
{
if ( str2_1[v4] == a2 )
str2_1[v4] = a3;
++v4;
}
return str2_1;
} | func0:
ENDBR64
PUSH R13
MOV R13D,EDX
MOV EDX,0x64
PUSH R12
LEA R12,[0x104040]
PUSH RBP
MOV EBP,ESI
MOV RSI,RDI
MOV RDI,R12
PUSH RBX
XOR EBX,EBX
SUB RSP,0x8
CALL 0x001010b0
JMP 0x001012ce
LAB_001012c0:
CMP byte ptr [R12 + RBX*0x1],BPL
JNZ 0x001012ca
MOV byte ptr [R12 + RBX*0x1],R13B
LAB_001012ca:
ADD RBX,0x1
LAB_001012ce:
MOV RDI,R12
CALL 0x00101080
CMP RAX,RBX
JA 0x001012c0
ADD RSP,0x8
MOV RAX,R12
POP RBX
POP RBP
POP R12
POP R13
RET | int1 * func0(int8 param_1,char param_2,int1 param_3)
{
size_t sVar1;
ulong uVar2;
uVar2 = 0;
__strcpy_chk(&str2_1,param_1,100);
while( true ) {
sVar1 = strlen(&str2_1);
if (sVar1 <= uVar2) break;
if ((&str2_1)[uVar2] == param_2) {
(&str2_1)[uVar2] = param_3;
}
uVar2 = uVar2 + 1;
}
return &str2_1;
} |
5,791 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
| char* func0(char* str1, char ch, char newch) {
static char str2[100];
strcpy(str2, str1);
for (int i = 0; i < strlen(str2); i++) {
if (str2[i] == ch) {
str2[i] = newch;
}
}
return str2;
}
| int main() {
assert(strcmp(func0("polygon", 'y', 'l'), "pollgon") == 0);
assert(strcmp(func0("character", 'c', 'a'), "aharaater") == 0);
assert(strcmp(func0("python", 'l', 'a'), "python") == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %rbp
mov %edx,%ebp
mov $0x64,%edx
push %rbx
mov %esi,%ebx
mov %rdi,%rsi
lea 0x2db7(%rip),%rdi
sub $0x8,%rsp
callq 1070 <__stpcpy_chk@plt>
lea 0x2da7(%rip),%rdi
sub %rdi,%rax
je 12b6 <func0+0x46>
xor %esi,%esi
mov %rdi,%r8
nopl 0x0(%rax,%rax,1)
cmp %bl,(%rdi,%rsi,1)
je 12c8 <func0+0x58>
add $0x1,%rsi
cmp %rax,%rsi
jb 12a8 <func0+0x38>
add $0x8,%rsp
lea 0x2d7f(%rip),%rax
pop %rbx
pop %rbp
retq
nopl 0x0(%rax)
mov %bpl,(%rdi,%rsi,1)
lea 0x2d6d(%rip),%rax
mov %r8,%rdi
mov (%rax),%ecx
add $0x4,%rax
lea -0x1010101(%rcx),%edx
not %ecx
and %ecx,%edx
and $0x80808080,%edx
je 12d6 <func0+0x66>
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
add $0x1,%rsi
sub %r8,%rax
cmp %rax,%rsi
jb 12a8 <func0+0x38>
add $0x8,%rsp
lea 0x2d1d(%rip),%rax
pop %rbx
pop %rbp
retq
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
push r13
mov r13d, edx
mov edx, 64h ; 'd'
push r12
mov r12d, esi
mov rsi, rdi
push rbp
lea rbp, str2_1
push rbx
mov rdi, rbp
xor ebx, ebx
sub rsp, 8
call ___strcpy_chk
jmp short loc_12D0
loc_12C0:
cmp [rbp+rbx+0], r12b
jnz short loc_12CC
mov [rbp+rbx+0], r13b
loc_12CC:
add rbx, 1
loc_12D0:
mov rdi, rbp; s
call _strlen
cmp rbx, rax
jb short loc_12C0
add rsp, 8
mov rax, rbp
pop rbx
pop rbp
pop r12
pop r13
retn | char * func0(long long a1, char a2, char a3)
{
size_t v4; // rbx
v4 = 0LL;
__strcpy_chk(str2_1, a1, 100LL);
while ( v4 < strlen(str2_1) )
{
if ( str2_1[v4] == a2 )
str2_1[v4] = a3;
++v4;
}
return str2_1;
} | func0:
ENDBR64
PUSH R13
MOV R13D,EDX
MOV EDX,0x64
PUSH R12
MOV R12D,ESI
MOV RSI,RDI
PUSH RBP
LEA RBP,[0x104040]
PUSH RBX
MOV RDI,RBP
XOR EBX,EBX
SUB RSP,0x8
CALL 0x001010b0
JMP 0x001012d0
LAB_001012c0:
CMP byte ptr [RBP + RBX*0x1],R12B
JNZ 0x001012cc
MOV byte ptr [RBP + RBX*0x1],R13B
LAB_001012cc:
ADD RBX,0x1
LAB_001012d0:
MOV RDI,RBP
CALL 0x00101080
CMP RBX,RAX
JC 0x001012c0
ADD RSP,0x8
MOV RAX,RBP
POP RBX
POP RBP
POP R12
POP R13
RET | int1 * func0(int8 param_1,char param_2,int param_3)
{
size_t sVar1;
ulong uVar2;
uVar2 = 0;
__strcpy_chk(&str2_1,param_1,100);
while( true ) {
sVar1 = strlen(&str2_1);
if (sVar1 <= uVar2) break;
if ((&str2_1)[uVar2] == param_2) {
(&str2_1)[uVar2] = param_3;
}
uVar2 = uVar2 + 1;
}
return &str2_1;
} |
5,792 | func0 |
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char key[50];
int value;
} Item;
int cmp(const void *a, const void *b) {
Item *itemA = (Item *)a;
Item *itemB = (Item *)b;
return (itemB->value - itemA->value);
}
| Item* func0(char keys[][50], int values[], int length) {
Item *items = malloc(length * sizeof(Item));
for (int i = 0; i < length; i++) {
strcpy(items[i].key, keys[i]);
items[i].value = values[i];
}
qsort(items, length, sizeof(Item), cmp);
return items;
}
| int main() {
char keys1[][50] = {"Math", "Physics", "Chemistry"};
int values1[] = {81, 83, 87};
Item *result1 = func0(keys1, values1, 3);
assert(strcmp(result1[0].key, "Chemistry") == 0 && result1[0].value == 87);
assert(strcmp(result1[1].key, "Physics") == 0 && result1[1].value == 83);
assert(strcmp(result1[2].key, "Math") == 0 && result1[2].value == 81);
free(result1);
char keys2[][50] = {"Math", "Physics", "Chemistry"};
int values2[] = {400, 300, 250};
Item *result2 = func0(keys2, values2, 3);
assert(strcmp(result2[0].key, "Math") == 0 && result2[0].value == 400);
assert(strcmp(result2[1].key, "Physics") == 0 && result2[1].value == 300);
assert(strcmp(result2[2].key, "Chemistry") == 0 && result2[2].value == 250);
free(result2);
char keys3[][50] = {"Math", "Physics", "Chemistry"};
int values3[] = {900, 1000, 1250};
Item *result3 = func0(keys3, values3, 3);
assert(strcmp(result3[0].key, "Chemistry") == 0 && result3[0].value == 1250);
assert(strcmp(result3[1].key, "Physics") == 0 && result3[1].value == 1000);
assert(strcmp(result3[2].key, "Math") == 0 && result3[2].value == 900);
free(result3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
mov %edx,-0x24(%rbp)
mov -0x24(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
sub %rdx,%rax
shl $0x3,%rax
mov %rax,%rdi
callq 1110 <malloc@plt>
mov %rax,-0x8(%rbp)
movl $0x0,-0xc(%rbp)
jmpq 130e <func0+0xd1>
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x2,%rax
add %rdx,%rax
lea 0x0(,%rax,4),%rdx
add %rdx,%rax
add %rax,%rax
mov %rax,%rdx
mov -0x18(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
sub %rdx,%rax
shl $0x3,%rax
mov %rax,%rdx
mov -0x8(%rbp),%rax
add %rdx,%rax
mov %rcx,%rsi
mov %rax,%rdi
callq 10c0 <strcpy@plt>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x20(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0xc(%rbp),%eax
movslq %eax,%rdx
mov %rdx,%rax
shl $0x3,%rax
sub %rdx,%rax
shl $0x3,%rax
mov %rax,%rdx
mov -0x8(%rbp),%rax
add %rax,%rdx
mov (%rcx),%eax
mov %eax,0x34(%rdx)
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x24(%rbp),%eax
jl 1280 <func0+0x43>
mov -0x24(%rbp),%eax
movslq %eax,%rsi
mov -0x8(%rbp),%rax
lea -0x122(%rip),%rcx
mov $0x38,%edx
mov %rax,%rdi
callq 10d0 <qsort@plt>
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
mov [rbp+var_18], rdi
mov [rbp+var_20], rsi
mov [rbp+var_24], edx
mov eax, [rbp+var_24]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
sub rax, rdx
shl rax, 3
mov rdi, rax; size
call _malloc
mov [rbp+base], rax
mov [rbp+var_C], 0
jmp loc_130E
loc_1280:
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 2
add rax, rdx
lea rdx, ds:0[rax*4]
add rax, rdx
add rax, rax
mov rdx, rax
mov rax, [rbp+var_18]
lea rcx, [rdx+rax]
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
sub rax, rdx
shl rax, 3
mov rdx, rax
mov rax, [rbp+base]
add rax, rdx
mov rsi, rcx; src
mov rdi, rax; dest
call _strcpy
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_20]
lea rcx, [rdx+rax]
mov eax, [rbp+var_C]
movsxd rdx, eax
mov rax, rdx
shl rax, 3
sub rax, rdx
shl rax, 3
mov rdx, rax
mov rax, [rbp+base]
add rdx, rax
mov eax, [rcx]
mov [rdx+34h], eax
add [rbp+var_C], 1
loc_130E:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_24]
jl loc_1280
mov eax, [rbp+var_24]
movsxd rsi, eax; nmemb
mov rax, [rbp+base]
lea rdx, cmp
mov rcx, rdx; compar
mov edx, 38h ; '8'; size
mov rdi, rax; base
call _qsort
mov rax, [rbp+base]
leave
retn | char * func0(long long a1, long long a2, int a3)
{
int i; // [rsp+24h] [rbp-Ch]
char *base; // [rsp+28h] [rbp-8h]
base = (char *)malloc(56LL * a3);
for ( i = 0; i < a3; ++i )
{
strcpy(&base[56 * i], (const char *)(50LL * i + a1));
*(_DWORD *)&base[56 * i + 52] = *(_DWORD *)(4LL * i + a2);
}
qsort(base, a3, 0x38uLL, cmp);
return base;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV qword ptr [RBP + -0x18],RDI
MOV qword ptr [RBP + -0x20],RSI
MOV dword ptr [RBP + -0x24],EDX
MOV EAX,dword ptr [RBP + -0x24]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
SUB RAX,RDX
SHL RAX,0x3
MOV RDI,RAX
CALL 0x00101110
MOV qword ptr [RBP + -0x8],RAX
MOV dword ptr [RBP + -0xc],0x0
JMP 0x0010130e
LAB_00101280:
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x2
ADD RAX,RDX
LEA RDX,[RAX*0x4]
ADD RAX,RDX
ADD RAX,RAX
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x18]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
SUB RAX,RDX
SHL RAX,0x3
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,RDX
MOV RSI,RCX
MOV RDI,RAX
CALL 0x001010c0
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x20]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0xc]
MOVSXD RDX,EAX
MOV RAX,RDX
SHL RAX,0x3
SUB RAX,RDX
SHL RAX,0x3
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x8]
ADD RDX,RAX
MOV EAX,dword ptr [RCX]
MOV dword ptr [RDX + 0x34],EAX
ADD dword ptr [RBP + -0xc],0x1
LAB_0010130e:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x24]
JL 0x00101280
MOV EAX,dword ptr [RBP + -0x24]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x8]
LEA RDX,[0x101209]
MOV RCX,RDX
MOV EDX,0x38
MOV RDI,RAX
CALL 0x001010d0
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(long param_1,long param_2,int param_3)
{
void *__base;
int local_14;
__base = malloc((long)param_3 * 0x38);
for (local_14 = 0; local_14 < param_3; local_14 = local_14 + 1) {
strcpy((char *)((long)__base + (long)local_14 * 0x38),(char *)((long)local_14 * 0x32 + param_1))
;
*(int4 *)((long)__base + (long)local_14 * 0x38 + 0x34) =
*(int4 *)((long)local_14 * 4 + param_2);
}
qsort(__base,(long)param_3,0x38,cmp);
return __base;
} |
5,793 | func0 |
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char key[50];
int value;
} Item;
int cmp(const void *a, const void *b) {
Item *itemA = (Item *)a;
Item *itemB = (Item *)b;
return (itemB->value - itemA->value);
}
| Item* func0(char keys[][50], int values[], int length) {
Item *items = malloc(length * sizeof(Item));
for (int i = 0; i < length; i++) {
strcpy(items[i].key, keys[i]);
items[i].value = values[i];
}
qsort(items, length, sizeof(Item), cmp);
return items;
}
| int main() {
char keys1[][50] = {"Math", "Physics", "Chemistry"};
int values1[] = {81, 83, 87};
Item *result1 = func0(keys1, values1, 3);
assert(strcmp(result1[0].key, "Chemistry") == 0 && result1[0].value == 87);
assert(strcmp(result1[1].key, "Physics") == 0 && result1[1].value == 83);
assert(strcmp(result1[2].key, "Math") == 0 && result1[2].value == 81);
free(result1);
char keys2[][50] = {"Math", "Physics", "Chemistry"};
int values2[] = {400, 300, 250};
Item *result2 = func0(keys2, values2, 3);
assert(strcmp(result2[0].key, "Math") == 0 && result2[0].value == 400);
assert(strcmp(result2[1].key, "Physics") == 0 && result2[1].value == 300);
assert(strcmp(result2[2].key, "Chemistry") == 0 && result2[2].value == 250);
free(result2);
char keys3[][50] = {"Math", "Physics", "Chemistry"};
int values3[] = {900, 1000, 1250};
Item *result3 = func0(keys3, values3, 3);
assert(strcmp(result3[0].key, "Chemistry") == 0 && result3[0].value == 1250);
assert(strcmp(result3[1].key, "Physics") == 0 && result3[1].value == 1000);
assert(strcmp(result3[2].key, "Math") == 0 && result3[2].value == 900);
free(result3);
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 %rsi,%rbx
mov %edx,%r14d
movslq %edx,%r15
lea 0x0(,%r15,8),%rdi
sub %r15,%rdi
shl $0x3,%rdi
callq 10e0 <malloc@plt>
mov %rax,%r13
test %r14d,%r14d
jle 1260 <func0+0x6c>
mov %rax,%rbp
lea -0x1(%r14),%eax
lea 0x4(%rbx,%rax,4),%r14
mov $0x32,%edx
mov %r12,%rsi
mov %rbp,%rdi
callq 10f0 <__strcpy_chk@plt>
mov (%rbx),%eax
mov %eax,0x34(%rbp)
add $0x38,%rbp
add $0x32,%r12
add $0x4,%rbx
cmp %r14,%rbx
jne 123a <func0+0x46>
lea -0x7e(%rip),%rcx
mov $0x38,%edx
mov %r15,%rsi
mov %r13,%rdi
callq 10b0 <qsort@plt>
mov %r13,%rax
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 rbx, rsi
mov r14d, edx
movsxd r15, edx
lea rdi, ds:0[r15*8]
sub rdi, r15
shl rdi, 3
call _malloc
mov r13, rax
test r14d, r14d
jle short loc_1280
mov rbp, rax
lea eax, [r14-1]
lea r14, [rbx+rax*4+4]
loc_125A:
mov edx, 32h ; '2'
mov rsi, r12
mov rdi, rbp
call ___strcpy_chk
mov eax, [rbx]
mov [rbp+34h], eax
add rbp, 38h ; '8'
add r12, 32h ; '2'
add rbx, 4
cmp rbx, r14
jnz short loc_125A
loc_1280:
lea rcx, cmp
mov edx, 38h ; '8'
mov rsi, r15
mov rdi, r13
call _qsort
mov rax, r13
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | long long func0(long long a1, _DWORD *a2, int a3)
{
_DWORD *v4; // rbx
long long v6; // r15
long long v7; // rax
long long v8; // r13
long long v9; // rbp
long long v10; // r14
v4 = a2;
v6 = a3;
v7 = malloc(56LL * a3);
v8 = v7;
if ( a3 > 0 )
{
v9 = v7;
v10 = (long long)&a2[a3 - 1 + 1];
do
{
__strcpy_chk(v9, a1, 50LL);
*(_DWORD *)(v9 + 52) = *v4;
v9 += 56LL;
a1 += 50LL;
++v4;
}
while ( v4 != (_DWORD *)v10 );
}
qsort(v8, v6, 56LL, cmp);
return v8;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV R12,RDI
MOV RBX,RSI
MOV R14D,EDX
MOVSXD R15,EDX
LEA RDI,[R15*0x8]
SUB RDI,R15
SHL RDI,0x3
CALL 0x00101100
MOV R13,RAX
TEST R14D,R14D
JLE 0x00101280
MOV RBP,RAX
LEA EAX,[R14 + -0x1]
LEA R14,[RBX + RAX*0x4 + 0x4]
LAB_0010125a:
MOV EDX,0x32
MOV RSI,R12
MOV RDI,RBP
CALL 0x00101110
MOV EAX,dword ptr [RBX]
MOV dword ptr [RBP + 0x34],EAX
ADD RBP,0x38
ADD R12,0x32
ADD RBX,0x4
CMP RBX,R14
JNZ 0x0010125a
LAB_00101280:
LEA RCX,[0x101209]
MOV EDX,0x38
MOV RSI,R15
MOV RDI,R13
CALL 0x001010c0
MOV RAX,R13
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | void * func0(long param_1,int4 *param_2,int param_3)
{
int4 *puVar1;
void *__base;
void *pvVar2;
__base = malloc((long)param_3 * 0x38);
if (0 < param_3) {
puVar1 = param_2 + (ulong)(param_3 - 1) + 1;
pvVar2 = __base;
do {
__strcpy_chk(pvVar2,param_1,0x32);
*(int4 *)((long)pvVar2 + 0x34) = *param_2;
pvVar2 = (void *)((long)pvVar2 + 0x38);
param_1 = param_1 + 0x32;
param_2 = param_2 + 1;
} while (param_2 != puVar1);
}
qsort(__base,(long)param_3,0x38,cmp);
return __base;
} |
5,794 | func0 |
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char key[50];
int value;
} Item;
int cmp(const void *a, const void *b) {
Item *itemA = (Item *)a;
Item *itemB = (Item *)b;
return (itemB->value - itemA->value);
}
| Item* func0(char keys[][50], int values[], int length) {
Item *items = malloc(length * sizeof(Item));
for (int i = 0; i < length; i++) {
strcpy(items[i].key, keys[i]);
items[i].value = values[i];
}
qsort(items, length, sizeof(Item), cmp);
return items;
}
| int main() {
char keys1[][50] = {"Math", "Physics", "Chemistry"};
int values1[] = {81, 83, 87};
Item *result1 = func0(keys1, values1, 3);
assert(strcmp(result1[0].key, "Chemistry") == 0 && result1[0].value == 87);
assert(strcmp(result1[1].key, "Physics") == 0 && result1[1].value == 83);
assert(strcmp(result1[2].key, "Math") == 0 && result1[2].value == 81);
free(result1);
char keys2[][50] = {"Math", "Physics", "Chemistry"};
int values2[] = {400, 300, 250};
Item *result2 = func0(keys2, values2, 3);
assert(strcmp(result2[0].key, "Math") == 0 && result2[0].value == 400);
assert(strcmp(result2[1].key, "Physics") == 0 && result2[1].value == 300);
assert(strcmp(result2[2].key, "Chemistry") == 0 && result2[2].value == 250);
free(result2);
char keys3[][50] = {"Math", "Physics", "Chemistry"};
int values3[] = {900, 1000, 1250};
Item *result3 = func0(keys3, values3, 3);
assert(strcmp(result3[0].key, "Chemistry") == 0 && result3[0].value == 1250);
assert(strcmp(result3[1].key, "Physics") == 0 && result3[1].value == 1000);
assert(strcmp(result3[2].key, "Math") == 0 && result3[2].value == 900);
free(result3);
return 0;
}
| O2 | c | func0:
endbr64
push %r14
push %r13
movslq %edx,%r13
push %r12
push %rbp
mov %rdi,%rbp
lea 0x0(,%r13,8),%rdi
push %rbx
sub %r13,%rdi
mov %rsi,%rbx
shl $0x3,%rdi
callq 10e0 <malloc@plt>
mov %rax,%r12
test %r13d,%r13d
jle 16fa <func0+0x6a>
mov %rax,%rcx
lea -0x1(%r13),%eax
lea 0x4(%rbx,%rax,4),%r14
nopl (%rax)
mov %rbp,%rsi
mov %rcx,%rdi
mov $0x32,%edx
add $0x4,%rbx
callq 10f0 <__strcpy_chk@plt>
add $0x32,%rbp
mov %rax,%rcx
mov -0x4(%rbx),%eax
add $0x38,%rcx
mov %eax,-0x4(%rcx)
cmp %r14,%rbx
jne 16d0 <func0+0x40>
mov %r13,%rsi
mov %r12,%rdi
mov $0x38,%edx
lea -0x8c(%rip),%rcx
callq 10b0 <qsort@plt>
pop %rbx
mov %r12,%rax
pop %rbp
pop %r12
pop %r13
pop %r14
retq
nopl (%rax)
| func0:
endbr64
push r14
push r13
movsxd r13, edx
push r12
push rbp
mov rbp, rdi
lea rdi, ds:0[r13*8]
push rbx
sub rdi, r13
mov rbx, rsi
shl rdi, 3
call _malloc
mov r12, rax
test r13d, r13d
jle short loc_178A
mov rcx, rax
lea eax, [r13-1]
lea r14, [rbx+rax*4+4]
nop dword ptr [rax]
loc_1760:
mov rsi, rbp
mov rdi, rcx
mov edx, 32h ; '2'
add rbx, 4
call ___strcpy_chk
add rbp, 32h ; '2'
mov rcx, rax
mov eax, [rbx-4]
add rcx, 38h ; '8'
mov [rcx-4], eax
cmp rbx, r14
jnz short loc_1760
loc_178A:
mov rsi, r13
mov rdi, r12
mov edx, 38h ; '8'
lea rcx, cmp
call _qsort
pop rbx
mov rax, r12
pop rbp
pop r12
pop r13
pop r14
retn | long long func0(long long a1, long long a2, int a3)
{
long long v3; // r13
long long v5; // rbx
long long v6; // rax
long long v7; // r12
long long v8; // rcx
long long v9; // rax
v3 = a3;
v5 = a2;
v6 = malloc(56LL * a3);
v7 = v6;
if ( (int)v3 > 0 )
{
v8 = v6;
do
{
v5 += 4LL;
v9 = __strcpy_chk(v8, a1, 50LL);
a1 += 50LL;
v8 = v9 + 56;
*(_DWORD *)(v9 + 52) = *(_DWORD *)(v5 - 4);
}
while ( v5 != a2 + 4LL * (unsigned int)(v3 - 1) + 4 );
}
qsort(v7, v3, 56LL, cmp);
return v7;
} | func0:
ENDBR64
PUSH R14
PUSH R13
MOVSXD R13,EDX
PUSH R12
PUSH RBP
MOV RBP,RDI
LEA RDI,[R13*0x8]
PUSH RBX
SUB RDI,R13
MOV RBX,RSI
SHL RDI,0x3
CALL 0x00101100
MOV R12,RAX
TEST R13D,R13D
JLE 0x0010178a
MOV RCX,RAX
LEA EAX,[R13 + -0x1]
LEA R14,[RBX + RAX*0x4 + 0x4]
NOP dword ptr [RAX]
LAB_00101760:
MOV RSI,RBP
MOV RDI,RCX
MOV EDX,0x32
ADD RBX,0x4
CALL 0x00101110
ADD RBP,0x32
MOV RCX,RAX
MOV EAX,dword ptr [RBX + -0x4]
ADD RCX,0x38
MOV dword ptr [RCX + -0x4],EAX
CMP RBX,R14
JNZ 0x00101760
LAB_0010178a:
MOV RSI,R13
MOV RDI,R12
MOV EDX,0x38
LEA RCX,[0x101710]
CALL 0x001010c0
POP RBX
MOV RAX,R12
POP RBP
POP R12
POP R13
POP R14
RET | void * func0(long param_1,int4 *param_2,int param_3)
{
void *__base;
long lVar1;
void *pvVar2;
int4 *puVar3;
int4 *puVar4;
__base = malloc((long)param_3 * 0x38);
if (0 < param_3) {
pvVar2 = __base;
puVar3 = param_2;
do {
puVar4 = puVar3 + 1;
lVar1 = __strcpy_chk(pvVar2,param_1,0x32);
param_1 = param_1 + 0x32;
pvVar2 = (void *)(lVar1 + 0x38);
*(int4 *)(lVar1 + 0x34) = *puVar3;
puVar3 = puVar4;
} while (puVar4 != param_2 + (ulong)(param_3 - 1) + 1);
}
qsort(__base,(long)param_3,0x38,cmp);
return __base;
} |
5,795 | func0 |
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char key[50];
int value;
} Item;
int cmp(const void *a, const void *b) {
Item *itemA = (Item *)a;
Item *itemB = (Item *)b;
return (itemB->value - itemA->value);
}
| Item* func0(char keys[][50], int values[], int length) {
Item *items = malloc(length * sizeof(Item));
for (int i = 0; i < length; i++) {
strcpy(items[i].key, keys[i]);
items[i].value = values[i];
}
qsort(items, length, sizeof(Item), cmp);
return items;
}
| int main() {
char keys1[][50] = {"Math", "Physics", "Chemistry"};
int values1[] = {81, 83, 87};
Item *result1 = func0(keys1, values1, 3);
assert(strcmp(result1[0].key, "Chemistry") == 0 && result1[0].value == 87);
assert(strcmp(result1[1].key, "Physics") == 0 && result1[1].value == 83);
assert(strcmp(result1[2].key, "Math") == 0 && result1[2].value == 81);
free(result1);
char keys2[][50] = {"Math", "Physics", "Chemistry"};
int values2[] = {400, 300, 250};
Item *result2 = func0(keys2, values2, 3);
assert(strcmp(result2[0].key, "Math") == 0 && result2[0].value == 400);
assert(strcmp(result2[1].key, "Physics") == 0 && result2[1].value == 300);
assert(strcmp(result2[2].key, "Chemistry") == 0 && result2[2].value == 250);
free(result2);
char keys3[][50] = {"Math", "Physics", "Chemistry"};
int values3[] = {900, 1000, 1250};
Item *result3 = func0(keys3, values3, 3);
assert(strcmp(result3[0].key, "Chemistry") == 0 && result3[0].value == 1250);
assert(strcmp(result3[1].key, "Physics") == 0 && result3[1].value == 1000);
assert(strcmp(result3[2].key, "Math") == 0 && result3[2].value == 900);
free(result3);
return 0;
}
| O3 | c | func0:
endbr64
push %r14
push %r13
movslq %edx,%r13
push %r12
push %rbp
mov %rdi,%rbp
lea 0x0(,%r13,8),%rdi
push %rbx
sub %r13,%rdi
mov %rsi,%rbx
shl $0x3,%rdi
callq 10e0 <malloc@plt>
mov %rax,%r12
test %r13d,%r13d
jle 16fa <func0+0x6a>
mov %rax,%rcx
lea -0x1(%r13),%eax
lea 0x4(%rbx,%rax,4),%r14
nopl (%rax)
mov %rbp,%rsi
mov %rcx,%rdi
mov $0x32,%edx
add $0x4,%rbx
callq 10f0 <__strcpy_chk@plt>
add $0x32,%rbp
mov %rax,%rcx
mov -0x4(%rbx),%eax
add $0x38,%rcx
mov %eax,-0x4(%rcx)
cmp %r14,%rbx
jne 16d0 <func0+0x40>
mov %r13,%rsi
mov %r12,%rdi
mov $0x38,%edx
lea -0x8c(%rip),%rcx
callq 10b0 <qsort@plt>
pop %rbx
mov %r12,%rax
pop %rbp
pop %r12
pop %r13
pop %r14
retq
nopl (%rax)
| func0:
endbr64
push r15
mov r15, rsi
push r14
push r13
movsxd r13, edx
push r12
mov r12, rdi
push rbp
push rbx
lea rbx, ds:0[r13*8]
sub rbx, r13
shl rbx, 3
sub rsp, 18h
mov rdi, rbx; size
call _malloc
mov [rsp+48h+base], rax
test r13d, r13d
jle short loc_1743
mov rcx, rax
lea rbp, [r15+r13*4]
xor r14d, r14d
nop word ptr [rax+rax+00000000h]
loc_1700:
cmp rbx, r14
mov rdx, r14
mov eax, 32h ; '2'
mov rsi, r12
cmovnb rdx, rbx
mov rdi, rcx
sub rdx, r14
cmp rdx, rax
cmova rdx, rax
add r15, 4
add r14, 38h ; '8'
add r12, 32h ; '2'
call ___strcpy_chk
mov rcx, rax
mov eax, [r15-4]
add rcx, 38h ; '8'
mov [rcx-4], eax
cmp r15, rbp
jnz short loc_1700
loc_1743:
mov rbx, [rsp+48h+base]
mov rsi, r13; nmemb
mov edx, 38h ; '8'; size
lea rcx, cmp; compar
mov rdi, rbx; base
call _qsort
add rsp, 18h
mov rax, rbx
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | void * func0(long long a1, long long a2, int a3)
{
long long v3; // r15
size_t v4; // r13
size_t v6; // rbx
void *v7; // rax
void *v8; // rcx
size_t v9; // rbp
size_t v10; // r14
size_t v11; // rdx
long long v12; // rsi
unsigned long long v13; // rdx
long long v14; // rax
void *base; // [rsp+8h] [rbp-40h]
v3 = a2;
v4 = a3;
v6 = 56LL * a3;
v7 = malloc(v6);
base = v7;
if ( (int)v4 > 0 )
{
v8 = v7;
v9 = a2 + 4 * v4;
v10 = 0LL;
do
{
v11 = v10;
v12 = a1;
if ( v6 >= v10 )
v11 = v6;
v13 = v11 - v10;
if ( v13 > 0x32 )
v13 = 50LL;
v3 += 4LL;
v10 += 56LL;
a1 += 50LL;
v14 = __strcpy_chk(v8, v12, v13);
v8 = (void *)(v14 + 56);
*(_DWORD *)(v14 + 52) = *(_DWORD *)(v3 - 4);
}
while ( v3 != v9 );
}
qsort(base, v4, 0x38uLL, cmp);
return base;
} | func0:
ENDBR64
PUSH R15
MOV R15,RSI
PUSH R14
PUSH R13
MOVSXD R13,EDX
PUSH R12
MOV R12,RDI
PUSH RBP
PUSH RBX
LEA RBX,[R13*0x8]
SUB RBX,R13
SHL RBX,0x3
SUB RSP,0x18
MOV RDI,RBX
CALL 0x00101100
MOV qword ptr [RSP + 0x8],RAX
TEST R13D,R13D
JLE 0x00101743
MOV RCX,RAX
LEA RBP,[R15 + R13*0x4]
XOR R14D,R14D
NOP word ptr CS:[RAX + RAX*0x1]
LAB_00101700:
CMP RBX,R14
MOV RDX,R14
MOV EAX,0x32
MOV RSI,R12
CMOVNC RDX,RBX
MOV RDI,RCX
SUB RDX,R14
CMP RDX,RAX
CMOVA RDX,RAX
ADD R15,0x4
ADD R14,0x38
ADD R12,0x32
CALL 0x00101110
MOV RCX,RAX
MOV EAX,dword ptr [R15 + -0x4]
ADD RCX,0x38
MOV dword ptr [RCX + -0x4],EAX
CMP R15,RBP
JNZ 0x00101700
LAB_00101743:
MOV RBX,qword ptr [RSP + 0x8]
MOV RSI,R13
MOV EDX,0x38
LEA RCX,[0x1016a0]
MOV RDI,RBX
CALL 0x001010c0
ADD RSP,0x18
MOV RAX,RBX
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | void * func0(long param_1,int4 *param_2,int param_3)
{
void *__base;
long lVar1;
void *pvVar2;
ulong uVar3;
size_t __size;
size_t __nmemb;
ulong uVar4;
int4 *puVar5;
int4 *puVar6;
__nmemb = (size_t)param_3;
__size = __nmemb * 0x38;
__base = malloc(__size);
if (0 < param_3) {
uVar4 = 0;
pvVar2 = __base;
puVar5 = param_2;
do {
uVar3 = uVar4;
if (uVar4 <= __size) {
uVar3 = __size;
}
uVar3 = uVar3 - uVar4;
if (0x32 < uVar3) {
uVar3 = 0x32;
}
puVar6 = puVar5 + 1;
uVar4 = uVar4 + 0x38;
lVar1 = __strcpy_chk(pvVar2,param_1,uVar3);
pvVar2 = (void *)(lVar1 + 0x38);
*(int4 *)(lVar1 + 0x34) = *puVar5;
param_1 = param_1 + 0x32;
puVar5 = puVar6;
} while (puVar6 != param_2 + __nmemb);
}
qsort(__base,__nmemb,0x38,cmp);
return __base;
} |
5,796 | func0 |
#include <stdio.h>
#include <assert.h>
#include <limits.h>
| int func0(int nums[], int size) {
int max_num = INT_MIN;
int min_num = INT_MAX;
for(int i = 0; i < size; i++) {
if(nums[i] > max_num) {
max_num = nums[i];
}
if(nums[i] < min_num) {
min_num = nums[i];
}
}
return max_num + min_num;
}
| int main() {
int arr1[] = {1, 2, 3};
int arr2[] = {-1, 2, 3, 4};
int arr3[] = {2, 3, 6};
assert(func0(arr1, 3) == 4);
assert(func0(arr2, 4) == 3);
assert(func0(arr3, 3) == 8);
printf("All test cases passed!\n");
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x80000000,-0xc(%rbp)
movl $0x7fffffff,-0x8(%rbp)
movl $0x0,-0x4(%rbp)
jmp 121b <func0+0x92>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0xc(%rbp)
jge 11e3 <func0+0x5a>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0xc(%rbp)
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x8(%rbp)
jle 1217 <func0+0x8e>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0x8(%rbp)
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 11af <func0+0x26>
mov -0xc(%rbp),%edx
mov -0x8(%rbp),%eax
add %edx,%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_18], rdi
mov [rbp+var_1C], esi
mov [rbp+var_C], 80000000h
mov [rbp+var_8], 7FFFFFFFh
mov [rbp+var_4], 0
jmp short loc_121B
loc_11AF:
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_C], eax
jge short 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]
mov [rbp+var_C], eax
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]
cmp [rbp+var_8], eax
jle short loc_1217
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
mov [rbp+var_8], eax
loc_1217:
add [rbp+var_4], 1
loc_121B:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_1C]
jl short loc_11AF
mov edx, [rbp+var_C]
mov eax, [rbp+var_8]
add eax, edx
pop rbp
retn | long long func0(long long a1, int a2)
{
signed int v3; // [rsp+10h] [rbp-Ch]
int v4; // [rsp+14h] [rbp-8h]
int i; // [rsp+18h] [rbp-4h]
v3 = 0x80000000;
v4 = 0x7FFFFFFF;
for ( i = 0; i < a2; ++i )
{
if ( v3 < *(_DWORD *)(4LL * i + a1) )
v3 = *(_DWORD *)(4LL * i + a1);
if ( v4 > *(_DWORD *)(4LL * i + a1) )
v4 = *(_DWORD *)(4LL * i + a1);
}
return (unsigned int)(v3 + v4);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0xc],0x80000000
MOV dword ptr [RBP + -0x8],0x7fffffff
MOV dword ptr [RBP + -0x4],0x0
JMP 0x0010121b
LAB_001011af:
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 + -0xc],EAX
JGE 0x001011e3
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0xc],EAX
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]
CMP dword ptr [RBP + -0x8],EAX
JLE 0x00101217
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x8],EAX
LAB_00101217:
ADD dword ptr [RBP + -0x4],0x1
LAB_0010121b:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x001011af
MOV EDX,dword ptr [RBP + -0xc]
MOV EAX,dword ptr [RBP + -0x8]
ADD EAX,EDX
POP RBP
RET | int func0(long param_1,int param_2)
{
int4 local_14;
int4 local_10;
int4 local_c;
local_14 = -0x80000000;
local_10 = 0x7fffffff;
for (local_c = 0; local_c < param_2; local_c = local_c + 1) {
if (local_14 < *(int *)(param_1 + (long)local_c * 4)) {
local_14 = *(int *)(param_1 + (long)local_c * 4);
}
if (*(int *)(param_1 + (long)local_c * 4) < local_10) {
local_10 = *(int *)(param_1 + (long)local_c * 4);
}
}
return local_10 + local_14;
} |
5,797 | func0 |
#include <stdio.h>
#include <assert.h>
#include <limits.h>
| int func0(int nums[], int size) {
int max_num = INT_MIN;
int min_num = INT_MAX;
for(int i = 0; i < size; i++) {
if(nums[i] > max_num) {
max_num = nums[i];
}
if(nums[i] < min_num) {
min_num = nums[i];
}
}
return max_num + min_num;
}
| int main() {
int arr1[] = {1, 2, 3};
int arr2[] = {-1, 2, 3, 4};
int arr3[] = {2, 3, 6};
assert(func0(arr1, 3) == 4);
assert(func0(arr2, 4) == 3);
assert(func0(arr3, 3) == 8);
printf("All test cases passed!\n");
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 11be <func0+0x35>
mov %rdi,%rcx
lea -0x1(%rsi),%eax
lea 0x4(%rdi,%rax,4),%rdi
mov $0x7fffffff,%esi
mov $0x80000000,%eax
mov (%rcx),%edx
cmp %edx,%eax
cmovl %edx,%eax
cmp %edx,%esi
cmovg %edx,%esi
add $0x4,%rcx
cmp %rdi,%rcx
jne 11a6 <func0+0x1d>
add %esi,%eax
retq
mov $0x7fffffff,%esi
mov $0x80000000,%eax
jmp 11bb <func0+0x32>
| func0:
endbr64
test esi, esi
jle short loc_11BE
mov rcx, rdi
lea eax, [rsi-1]
lea rdi, [rdi+rax*4+4]
mov esi, 7FFFFFFFh
mov eax, 80000000h
loc_11A6:
mov edx, [rcx]
cmp eax, edx
cmovl eax, edx
cmp esi, edx
cmovg esi, edx
add rcx, 4
cmp rcx, rdi
jnz short loc_11A6
loc_11BB:
add eax, esi
retn
loc_11BE:
mov esi, 7FFFFFFFh
mov eax, 80000000h
jmp short loc_11BB | long long func0(signed int *a1, int a2)
{
signed int *v2; // rcx
long long v3; // rdi
int v4; // esi
signed int v5; // eax
if ( a2 <= 0 )
{
v4 = 0x7FFFFFFF;
v5 = 0x80000000;
}
else
{
v2 = a1;
v3 = (long long)&a1[a2 - 1 + 1];
v4 = 0x7FFFFFFF;
v5 = 0x80000000;
do
{
if ( v5 < *v2 )
v5 = *v2;
if ( v4 > *v2 )
v4 = *v2;
++v2;
}
while ( v2 != (signed int *)v3 );
}
return (unsigned int)(v4 + v5);
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001011be
MOV RCX,RDI
LEA EAX,[RSI + -0x1]
LEA RDI,[RDI + RAX*0x4 + 0x4]
MOV ESI,0x7fffffff
MOV EAX,0x80000000
LAB_001011a6:
MOV EDX,dword ptr [RCX]
CMP EAX,EDX
CMOVL EAX,EDX
CMP ESI,EDX
CMOVG ESI,EDX
ADD RCX,0x4
CMP RCX,RDI
JNZ 0x001011a6
LAB_001011bb:
ADD EAX,ESI
RET
LAB_001011be:
MOV ESI,0x7fffffff
MOV EAX,0x80000000
JMP 0x001011bb | int func0(int *param_1,int param_2)
{
int *piVar1;
int iVar2;
int iVar3;
int iVar4;
if (param_2 < 1) {
iVar4 = 0x7fffffff;
iVar3 = -0x80000000;
}
else {
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
iVar4 = 0x7fffffff;
iVar3 = -0x80000000;
do {
iVar2 = *param_1;
if (iVar3 < iVar2) {
iVar3 = iVar2;
}
if (iVar2 < iVar4) {
iVar4 = iVar2;
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
}
return iVar3 + iVar4;
} |
5,798 | func0 |
#include <stdio.h>
#include <assert.h>
#include <limits.h>
| int func0(int nums[], int size) {
int max_num = INT_MIN;
int min_num = INT_MAX;
for(int i = 0; i < size; i++) {
if(nums[i] > max_num) {
max_num = nums[i];
}
if(nums[i] < min_num) {
min_num = nums[i];
}
}
return max_num + min_num;
}
| int main() {
int arr1[] = {1, 2, 3};
int arr2[] = {-1, 2, 3, 4};
int arr3[] = {2, 3, 6};
assert(func0(arr1, 3) == 4);
assert(func0(arr2, 4) == 3);
assert(func0(arr3, 3) == 8);
printf("All test cases passed!\n");
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 11b0 <func0+0x40>
lea -0x1(%rsi),%eax
mov $0x80000000,%ecx
lea 0x4(%rdi,%rax,4),%rsi
mov $0x7fffffff,%eax
nopw 0x0(%rax,%rax,1)
mov (%rdi),%edx
cmp %edx,%ecx
cmovl %edx,%ecx
cmp %edx,%eax
cmovg %edx,%eax
add $0x4,%rdi
cmp %rsi,%rdi
jne 1190 <func0+0x20>
add %ecx,%eax
retq
nopl 0x0(%rax,%rax,1)
mov $0xffffffff,%eax
retq
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short loc_11B0
lea eax, [rsi-1]
mov ecx, 80000000h
lea rsi, [rdi+rax*4+4]
mov eax, 7FFFFFFFh
nop word ptr [rax+rax+00h]
loc_1190:
mov edx, [rdi]
cmp ecx, edx
cmovl ecx, edx
cmp eax, edx
cmovg eax, edx
add rdi, 4
cmp rdi, rsi
jnz short loc_1190
add eax, ecx
retn
loc_11B0:
mov eax, 0FFFFFFFFh
retn | long long func0(signed int *a1, int a2)
{
signed int v2; // ecx
long long v3; // rsi
int v4; // eax
if ( a2 <= 0 )
return 0xFFFFFFFFLL;
v2 = 0x80000000;
v3 = (long long)&a1[a2 - 1 + 1];
v4 = 0x7FFFFFFF;
do
{
if ( v2 < *a1 )
v2 = *a1;
if ( v4 > *a1 )
v4 = *a1;
++a1;
}
while ( a1 != (signed int *)v3 );
return (unsigned int)(v2 + v4);
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001011b0
LEA EAX,[RSI + -0x1]
MOV ECX,0x80000000
LEA RSI,[RDI + RAX*0x4 + 0x4]
MOV EAX,0x7fffffff
NOP word ptr [RAX + RAX*0x1]
LAB_00101190:
MOV EDX,dword ptr [RDI]
CMP ECX,EDX
CMOVL ECX,EDX
CMP EAX,EDX
CMOVG EAX,EDX
ADD RDI,0x4
CMP RDI,RSI
JNZ 0x00101190
ADD EAX,ECX
RET
LAB_001011b0:
MOV EAX,0xffffffff
RET | int func0(int *param_1,int param_2)
{
int *piVar1;
int iVar2;
int iVar3;
int iVar4;
if (0 < param_2) {
iVar4 = -0x80000000;
piVar1 = param_1 + (ulong)(param_2 - 1) + 1;
iVar3 = 0x7fffffff;
do {
iVar2 = *param_1;
if (iVar4 < iVar2) {
iVar4 = iVar2;
}
if (iVar2 < iVar3) {
iVar3 = iVar2;
}
param_1 = param_1 + 1;
} while (param_1 != piVar1);
return iVar3 + iVar4;
}
return -1;
} |
5,799 | func0 |
#include <stdio.h>
#include <assert.h>
#include <limits.h>
| int func0(int nums[], int size) {
int max_num = INT_MIN;
int min_num = INT_MAX;
for(int i = 0; i < size; i++) {
if(nums[i] > max_num) {
max_num = nums[i];
}
if(nums[i] < min_num) {
min_num = nums[i];
}
}
return max_num + min_num;
}
| int main() {
int arr1[] = {1, 2, 3};
int arr2[] = {-1, 2, 3, 4};
int arr3[] = {2, 3, 6};
assert(func0(arr1, 3) == 4);
assert(func0(arr2, 4) == 3);
assert(func0(arr3, 3) == 8);
printf("All test cases passed!\n");
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 12c8 <func0+0x158>
lea -0x1(%rsi),%eax
cmp $0x2,%eax
jbe 12ce <func0+0x15e>
mov %esi,%edx
movdqa 0xe8e(%rip),%xmm4
movdqa 0xe96(%rip),%xmm1
mov %rdi,%rax
shr $0x2,%edx
shl $0x4,%rdx
add %rdi,%rdx
nopw 0x0(%rax,%rax,1)
movdqu (%rax),%xmm0
movdqa %xmm1,%xmm3
movdqa %xmm4,%xmm2
add $0x10,%rax
pcmpgtd %xmm0,%xmm3
pcmpgtd %xmm0,%xmm2
pand %xmm3,%xmm1
pandn %xmm0,%xmm3
pand %xmm2,%xmm0
pandn %xmm4,%xmm2
por %xmm3,%xmm1
movdqa %xmm2,%xmm4
por %xmm0,%xmm4
cmp %rdx,%rax
jne 11b0 <func0+0x40>
movdqa %xmm4,%xmm3
mov %esi,%ecx
psrldq $0x8,%xmm3
and $0xfffffffc,%ecx
movdqa %xmm3,%xmm0
pcmpgtd %xmm4,%xmm0
pand %xmm0,%xmm4
pandn %xmm3,%xmm0
movdqa %xmm4,%xmm2
por %xmm0,%xmm2
movdqa %xmm2,%xmm3
psrldq $0x4,%xmm3
movdqa %xmm3,%xmm0
pcmpgtd %xmm2,%xmm0
pand %xmm0,%xmm2
pandn %xmm3,%xmm0
por %xmm2,%xmm0
movdqa %xmm1,%xmm2
psrldq $0x8,%xmm2
movd %xmm0,%eax
movdqa %xmm2,%xmm0
pcmpgtd %xmm1,%xmm0
pand %xmm0,%xmm2
pandn %xmm1,%xmm0
movdqa %xmm0,%xmm1
por %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrldq $0x4,%xmm2
movdqa %xmm2,%xmm0
pcmpgtd %xmm1,%xmm0
pand %xmm0,%xmm2
pandn %xmm1,%xmm0
por %xmm2,%xmm0
movd %xmm0,%edx
test $0x3,%sil
je 12c2 <func0+0x152>
movslq %ecx,%r8
mov (%rdi,%r8,4),%r8d
cmp %r8d,%edx
cmovl %r8d,%edx
cmp %r8d,%eax
cmovg %r8d,%eax
lea 0x1(%rcx),%r8d
cmp %r8d,%esi
jle 12c2 <func0+0x152>
movslq %r8d,%r8
mov (%rdi,%r8,4),%r8d
cmp %r8d,%edx
cmovl %r8d,%edx
cmp %r8d,%eax
cmovg %r8d,%eax
add $0x2,%ecx
cmp %ecx,%esi
jle 12c2 <func0+0x152>
movslq %ecx,%rcx
mov (%rdi,%rcx,4),%ecx
cmp %ecx,%edx
cmovl %ecx,%edx
cmp %ecx,%eax
cmovg %ecx,%eax
add %edx,%eax
retq
nopl (%rax)
mov $0xffffffff,%eax
retq
xor %ecx,%ecx
mov $0x7fffffff,%eax
mov $0x80000000,%edx
jmp 1278 <func0+0x108>
nopl 0x0(%rax)
| func0:
endbr64
mov ecx, esi
test esi, esi
jle loc_12C8
lea eax, [rsi-1]
cmp eax, 2
jbe loc_12CE
mov edx, esi
movdqa xmm3, cs:xmmword_2020
movdqa xmm1, cs:xmmword_2030
mov rax, rdi
shr edx, 2
shl rdx, 4
add rdx, rdi
nop dword ptr [rax+00000000h]
loc_11B0:
movdqu xmm0, xmmword ptr [rax]
movdqa xmm2, xmm1
add rax, 10h
pcmpgtd xmm2, xmm0
pand xmm1, xmm2
pandn xmm2, xmm0
por xmm1, xmm2
movdqa xmm2, xmm3
pcmpgtd xmm2, xmm0
pand xmm0, xmm2
pandn xmm2, xmm3
movdqa xmm3, xmm2
por xmm3, xmm0
cmp rdx, rax
jnz short loc_11B0
movdqa xmm0, xmm3
mov esi, ecx
psrldq xmm0, 8
and esi, 0FFFFFFFCh
movdqa xmm2, xmm0
pcmpgtd xmm2, xmm3
pand xmm3, xmm2
pandn xmm2, xmm0
por xmm2, xmm3
movdqa xmm3, xmm2
psrldq xmm3, 4
movdqa xmm0, xmm3
pcmpgtd xmm0, xmm2
pand xmm2, xmm0
pandn xmm0, xmm3
por xmm0, xmm2
movdqa xmm2, xmm1
psrldq xmm2, 8
movd eax, xmm0
movdqa xmm0, xmm2
pcmpgtd xmm0, xmm1
pand xmm2, xmm0
pandn xmm0, xmm1
movdqa xmm1, xmm0
por xmm1, xmm2
movdqa xmm2, xmm1
psrldq xmm2, 4
movdqa xmm0, xmm2
pcmpgtd xmm0, xmm1
pand xmm2, xmm0
pandn xmm0, xmm1
por xmm0, xmm2
movd edx, xmm0
test cl, 3
jz short loc_12C2
loc_1273:
movsxd r8, esi
lea r9, ds:0[r8*4]
mov r8d, [rdi+r8*4]
cmp edx, r8d
cmovl edx, r8d
cmp eax, r8d
cmovg eax, r8d
lea r8d, [rsi+1]
cmp ecx, r8d
jle short loc_12C2
mov r8d, [rdi+r9+4]
cmp edx, r8d
cmovl edx, r8d
cmp eax, r8d
cmovg eax, r8d
add esi, 2
cmp ecx, esi
jle short loc_12C2
mov ecx, [rdi+r9+8]
cmp edx, ecx
cmovl edx, ecx
cmp eax, ecx
cmovg eax, ecx
loc_12C2:
add eax, edx
retn
loc_12C8:
mov eax, 0FFFFFFFFh
retn
loc_12CE:
xor esi, esi
mov eax, 7FFFFFFFh
mov edx, 80000000h
jmp short loc_1273 | long long func0(const __m128i *a1, int a2)
{
__m128i si128; // xmm3
__m128i v4; // xmm1
const __m128i *v5; // rax
__m128i v6; // xmm0
__m128i v7; // xmm2
__m128i v8; // xmm2
__m128i v9; // xmm0
signed int v10; // esi
__m128i v11; // xmm2
__m128i v12; // xmm2
__m128i v13; // xmm3
__m128i v14; // xmm0
__m128i v15; // xmm0
__m128i v16; // xmm2
int v17; // eax
__m128i v18; // xmm0
__m128i v19; // xmm1
__m128i v20; // xmm2
__m128i v21; // xmm0
int v22; // edx
long long v23; // r9
int v24; // r8d
int v25; // r8d
int v26; // ecx
if ( a2 > 0 )
{
if ( (unsigned int)(a2 - 1) <= 2 )
{
v10 = 0;
v17 = 0x7FFFFFFF;
v22 = 0x80000000;
}
else
{
si128 = _mm_load_si128((const __m128i *)&xmmword_2020);
v4 = _mm_load_si128((const __m128i *)&xmmword_2030);
v5 = a1;
do
{
v6 = _mm_loadu_si128(v5++);
v7 = _mm_cmpgt_epi32(v4, v6);
v4 = _mm_or_si128(_mm_and_si128(v4, v7), _mm_andnot_si128(v7, v6));
v8 = _mm_cmpgt_epi32(si128, v6);
si128 = _mm_or_si128(_mm_andnot_si128(v8, si128), _mm_and_si128(v6, v8));
}
while ( &a1[(unsigned int)a2 >> 2] != v5 );
v9 = _mm_srli_si128(si128, 8);
v10 = a2 & 0xFFFFFFFC;
v11 = _mm_cmpgt_epi32(v9, si128);
v12 = _mm_or_si128(_mm_andnot_si128(v11, v9), _mm_and_si128(si128, v11));
v13 = _mm_srli_si128(v12, 4);
v14 = _mm_cmpgt_epi32(v13, v12);
v15 = _mm_or_si128(_mm_andnot_si128(v14, v13), _mm_and_si128(v12, v14));
v16 = _mm_srli_si128(v4, 8);
v17 = _mm_cvtsi128_si32(v15);
v18 = _mm_cmpgt_epi32(v16, v4);
v19 = _mm_or_si128(_mm_andnot_si128(v18, v4), _mm_and_si128(v16, v18));
v20 = _mm_srli_si128(v19, 4);
v21 = _mm_cmpgt_epi32(v20, v19);
v22 = _mm_cvtsi128_si32(_mm_or_si128(_mm_andnot_si128(v21, v19), _mm_and_si128(v20, v21)));
if ( (a2 & 3) == 0 )
return (unsigned int)(v22 + v17);
}
v23 = v10;
v24 = a1->m128i_i32[v23];
if ( v22 < v24 )
v22 = a1->m128i_i32[v10];
if ( v17 > v24 )
v17 = a1->m128i_i32[v10];
if ( a2 > v10 + 1 )
{
v25 = a1->m128i_i32[v23 + 1];
if ( v22 < v25 )
v22 = a1->m128i_i32[v23 + 1];
if ( v17 > v25 )
v17 = a1->m128i_i32[v23 + 1];
if ( a2 > v10 + 2 )
{
v26 = a1->m128i_i32[v23 + 2];
if ( v22 < v26 )
v22 = a1->m128i_i32[v23 + 2];
if ( v17 > v26 )
v17 = a1->m128i_i32[v23 + 2];
}
}
return (unsigned int)(v22 + v17);
}
return 0xFFFFFFFFLL;
} | func0:
ENDBR64
MOV ECX,ESI
TEST ESI,ESI
JLE 0x001012c8
LEA EAX,[RSI + -0x1]
CMP EAX,0x2
JBE 0x001012ce
MOV EDX,ESI
MOVDQA XMM3,xmmword ptr [0x00102020]
MOVDQA XMM1,xmmword ptr [0x00102030]
MOV RAX,RDI
SHR EDX,0x2
SHL RDX,0x4
ADD RDX,RDI
NOP dword ptr [RAX]
LAB_001011b0:
MOVDQU XMM0,xmmword ptr [RAX]
MOVDQA XMM2,XMM1
ADD RAX,0x10
PCMPGTD XMM2,XMM0
PAND XMM1,XMM2
PANDN XMM2,XMM0
POR XMM1,XMM2
MOVDQA XMM2,XMM3
PCMPGTD XMM2,XMM0
PAND XMM0,XMM2
PANDN XMM2,XMM3
MOVDQA XMM3,XMM2
POR XMM3,XMM0
CMP RDX,RAX
JNZ 0x001011b0
MOVDQA XMM0,XMM3
MOV ESI,ECX
PSRLDQ XMM0,0x8
AND ESI,0xfffffffc
MOVDQA XMM2,XMM0
PCMPGTD XMM2,XMM3
PAND XMM3,XMM2
PANDN XMM2,XMM0
POR XMM2,XMM3
MOVDQA XMM3,XMM2
PSRLDQ XMM3,0x4
MOVDQA XMM0,XMM3
PCMPGTD XMM0,XMM2
PAND XMM2,XMM0
PANDN XMM0,XMM3
POR XMM0,XMM2
MOVDQA XMM2,XMM1
PSRLDQ XMM2,0x8
MOVD EAX,XMM0
MOVDQA XMM0,XMM2
PCMPGTD XMM0,XMM1
PAND XMM2,XMM0
PANDN XMM0,XMM1
MOVDQA XMM1,XMM0
POR XMM1,XMM2
MOVDQA XMM2,XMM1
PSRLDQ XMM2,0x4
MOVDQA XMM0,XMM2
PCMPGTD XMM0,XMM1
PAND XMM2,XMM0
PANDN XMM0,XMM1
POR XMM0,XMM2
MOVD EDX,XMM0
TEST CL,0x3
JZ 0x001012c2
LAB_00101273:
MOVSXD R8,ESI
LEA R9,[R8*0x4]
MOV R8D,dword ptr [RDI + R8*0x4]
CMP EDX,R8D
CMOVL EDX,R8D
CMP EAX,R8D
CMOVG EAX,R8D
LEA R8D,[RSI + 0x1]
CMP ECX,R8D
JLE 0x001012c2
MOV R8D,dword ptr [RDI + R9*0x1 + 0x4]
CMP EDX,R8D
CMOVL EDX,R8D
CMP EAX,R8D
CMOVG EAX,R8D
ADD ESI,0x2
CMP ECX,ESI
JLE 0x001012c2
MOV ECX,dword ptr [RDI + R9*0x1 + 0x8]
CMP EDX,ECX
CMOVL EDX,ECX
CMP EAX,ECX
CMOVG EAX,ECX
LAB_001012c2:
ADD EAX,EDX
RET
LAB_001012c8:
MOV EAX,0xffffffff
RET
LAB_001012ce:
XOR ESI,ESI
MOV EAX,0x7fffffff
MOV EDX,0x80000000
JMP 0x00101273 | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
int func0(uint *param_1,uint param_2)
{
uint uVar1;
uint uVar2;
uint uVar3;
uint *puVar4;
uint uVar5;
uint uVar6;
uint uVar7;
uint uVar8;
uint uVar9;
uint uVar10;
uint uVar11;
uint uVar12;
uint uVar13;
if ((int)param_2 < 1) {
return -1;
}
if (param_2 - 1 < 3) {
uVar5 = 0;
uVar6 = 0x7fffffff;
uVar7 = 0x80000000;
}
else {
puVar4 = param_1;
uVar6 = _DAT_00102020;
uVar7 = _UNK_00102024;
uVar12 = _UNK_00102028;
uVar13 = _UNK_0010202c;
uVar8 = _DAT_00102030;
uVar9 = _UNK_00102034;
uVar10 = _UNK_00102038;
uVar11 = _UNK_0010203c;
do {
uVar5 = *puVar4;
uVar1 = puVar4[1];
uVar2 = puVar4[2];
uVar3 = puVar4[3];
puVar4 = puVar4 + 4;
uVar8 = uVar8 & -(uint)((int)uVar5 < (int)uVar8) | ~-(uint)((int)uVar5 < (int)uVar8) & uVar5;
uVar9 = uVar9 & -(uint)((int)uVar1 < (int)uVar9) | ~-(uint)((int)uVar1 < (int)uVar9) & uVar1;
uVar10 = uVar10 & -(uint)((int)uVar2 < (int)uVar10) |
~-(uint)((int)uVar2 < (int)uVar10) & uVar2;
uVar11 = uVar11 & -(uint)((int)uVar3 < (int)uVar11) |
~-(uint)((int)uVar3 < (int)uVar11) & uVar3;
uVar6 = ~-(uint)((int)uVar5 < (int)uVar6) & uVar6 | uVar5 & -(uint)((int)uVar5 < (int)uVar6);
uVar7 = ~-(uint)((int)uVar1 < (int)uVar7) & uVar7 | uVar1 & -(uint)((int)uVar1 < (int)uVar7);
uVar12 = ~-(uint)((int)uVar2 < (int)uVar12) & uVar12 |
uVar2 & -(uint)((int)uVar2 < (int)uVar12);
uVar13 = ~-(uint)((int)uVar3 < (int)uVar13) & uVar13 |
uVar3 & -(uint)((int)uVar3 < (int)uVar13);
} while (param_1 + (ulong)(param_2 >> 2) * 4 != puVar4);
uVar5 = param_2 & 0xfffffffc;
uVar12 = ~-(uint)((int)uVar6 < (int)uVar12) & uVar12 | uVar6 & -(uint)((int)uVar6 < (int)uVar12)
;
uVar7 = ~-(uint)((int)uVar7 < (int)uVar13) & uVar13 | uVar7 & -(uint)((int)uVar7 < (int)uVar13);
uVar6 = -(uint)((int)uVar12 < (int)uVar7);
uVar6 = ~uVar6 & uVar7 | uVar12 & uVar6;
uVar12 = ~-(uint)((int)uVar8 < (int)uVar10) & uVar8 | uVar10 & -(uint)((int)uVar8 < (int)uVar10)
;
uVar13 = ~-(uint)((int)uVar9 < (int)uVar11) & uVar9 | uVar11 & -(uint)((int)uVar9 < (int)uVar11)
;
uVar7 = -(uint)((int)uVar12 < (int)uVar13);
uVar7 = ~uVar7 & uVar12 | uVar13 & uVar7;
if ((param_2 & 3) == 0) goto LAB_001012c2;
}
uVar12 = param_1[(int)uVar5];
if ((int)uVar7 < (int)uVar12) {
uVar7 = uVar12;
}
if ((int)uVar12 < (int)uVar6) {
uVar6 = uVar12;
}
if ((int)(uVar5 + 1) < (int)param_2) {
uVar12 = param_1[(long)(int)uVar5 + 1];
if ((int)uVar7 < (int)uVar12) {
uVar7 = uVar12;
}
if ((int)uVar12 < (int)uVar6) {
uVar6 = uVar12;
}
if ((int)(uVar5 + 2) < (int)param_2) {
uVar5 = param_1[(long)(int)uVar5 + 2];
if ((int)uVar7 < (int)uVar5) {
uVar7 = uVar5;
}
if ((int)uVar5 < (int)uVar6) {
uVar6 = uVar5;
}
}
}
LAB_001012c2:
return uVar6 + uVar7;
} |
5,800 | func0 |
#include <assert.h>
#include <ctype.h>
#include <string.h>
| void func0(char* input, char* output) {
int i = 0;
while (input[i]) {
output[i] = tolower((unsigned char) input[i]);
i++;
}
output[i] = '\0';
}
| int main() {
char result[100];
func0("InValid", result);
assert(strcmp(result, "invalid") == 0);
func0("TruE", result);
assert(strcmp(result, "true") == 0);
func0("SenTenCE", result);
assert(strcmp(result, "sentence") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %rsi,-0x20(%rbp)
movl $0x0,-0x4(%rbp)
jmp 11f7 <func0+0x4e>
mov -0x4(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
movzbl %al,%eax
mov %eax,%edi
callq 10b0 <tolower@plt>
mov %eax,%ecx
mov -0x4(%rbp),%eax
movslq %eax,%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
mov %ecx,%edx
mov %dl,(%rax)
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
test %al,%al
jne 11c6 <func0+0x1d>
mov -0x4(%rbp),%eax
movslq %eax,%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
movb $0x0,(%rax)
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+var_18], rdi
mov [rbp+var_20], rsi
mov [rbp+var_4], 0
jmp short loc_11F7
loc_11C6:
mov eax, [rbp+var_4]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
movzx eax, al
mov edi, eax; c
call _tolower
mov ecx, eax
mov eax, [rbp+var_4]
movsxd rdx, eax
mov rax, [rbp+var_20]
add rax, rdx
mov edx, ecx
mov [rax], dl
add [rbp+var_4], 1
loc_11F7:
mov eax, [rbp+var_4]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
test al, al
jnz short loc_11C6
mov eax, [rbp+var_4]
movsxd rdx, eax
mov rax, [rbp+var_20]
add rax, rdx
mov byte ptr [rax], 0
nop
leave
retn | _BYTE * func0(long long a1, long long a2)
{
_BYTE *result; // rax
int i; // [rsp+1Ch] [rbp-4h]
for ( i = 0; *(_BYTE *)(i + a1); ++i )
*(_BYTE *)(i + a2) = tolower(*(unsigned __int8 *)(i + a1));
result = (_BYTE *)(i + a2);
*result = 0;
return result;
} | 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 + -0x4],0x0
JMP 0x001011f7
LAB_001011c6:
MOV EAX,dword ptr [RBP + -0x4]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
MOVZX EAX,AL
MOV EDI,EAX
CALL 0x001010b0
MOV ECX,EAX
MOV EAX,dword ptr [RBP + -0x4]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOV EDX,ECX
MOV byte ptr [RAX],DL
ADD dword ptr [RBP + -0x4],0x1
LAB_001011f7:
MOV EAX,dword ptr [RBP + -0x4]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x001011c6
MOV EAX,dword ptr [RBP + -0x4]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOV byte ptr [RAX],0x0
NOP
LEAVE
RET | void func0(long param_1,long param_2)
{
int iVar1;
int4 local_c;
for (local_c = 0; *(char *)(param_1 + local_c) != '\0'; local_c = local_c + 1) {
iVar1 = tolower((uint)*(byte *)(param_1 + local_c));
*(char *)(param_2 + local_c) = (char)iVar1;
}
*(int *)(param_2 + local_c) = 0;
return;
} |
5,801 | func0 |
#include <assert.h>
#include <ctype.h>
#include <string.h>
| void func0(char* input, char* output) {
int i = 0;
while (input[i]) {
output[i] = tolower((unsigned char) input[i]);
i++;
}
output[i] = '\0';
}
| int main() {
char result[100];
func0("InValid", result);
assert(strcmp(result, "invalid") == 0);
func0("TruE", result);
assert(strcmp(result, "true") == 0);
func0("SenTenCE", result);
assert(strcmp(result, "sentence") == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
mov %rsi,%rbp
movzbl (%rdi),%ebx
test %bl,%bl
je 11cc <func0+0x43>
mov %rdi,%r12
callq 1090 <__ctype_tolower_loc@plt>
mov $0x0,%edx
movzbl %bl,%ebx
mov (%rax),%rcx
mov (%rcx,%rbx,4),%ecx
mov %cl,0x0(%rbp,%rdx,1)
add $0x1,%rdx
movzbl (%r12,%rdx,1),%ebx
test %bl,%bl
jne 11a8 <func0+0x1f>
movb $0x0,0x0(%rbp,%rdx,1)
pop %rbx
pop %rbp
pop %r12
retq
mov $0x0,%edx
jmp 11c2 <func0+0x39>
| func0:
endbr64
push r12
push rbp
push rbx
mov rbp, rsi
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_11EC
mov r12, rdi
call ___ctype_tolower_loc
mov edx, 0
loc_11C8:
movzx ebx, bl
mov rcx, [rax]
mov ecx, [rcx+rbx*4]
mov [rbp+rdx+0], cl
add rdx, 1
movzx ebx, byte ptr [r12+rdx]
test bl, bl
jnz short loc_11C8
loc_11E2:
mov byte ptr [rbp+rdx+0], 0
pop rbx
pop rbp
pop r12
retn
loc_11EC:
mov edx, 0
jmp short loc_11E2 | void func0(unsigned __int8 *a1, long long a2)
{
unsigned __int8 v2; // bl
_QWORD *v3; // rax
long long v4; // rdx
v2 = *a1;
if ( *a1 )
{
v3 = (_QWORD *)__ctype_tolower_loc();
v4 = 0LL;
do
{
*(_BYTE *)(a2 + v4++) = *(_DWORD *)(*v3 + 4LL * v2);
v2 = a1[v4];
}
while ( v2 );
}
else
{
v4 = 0LL;
}
*(_BYTE *)(a2 + v4) = 0;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
PUSH RBX
MOV RBP,RSI
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001011ec
MOV R12,RDI
CALL 0x001010b0
MOV EDX,0x0
LAB_001011c8:
MOVZX EBX,BL
MOV RCX,qword ptr [RAX]
MOV ECX,dword ptr [RCX + RBX*0x4]
MOV byte ptr [RBP + RDX*0x1],CL
ADD RDX,0x1
MOVZX EBX,byte ptr [R12 + RDX*0x1]
TEST BL,BL
JNZ 0x001011c8
LAB_001011e2:
MOV byte ptr [RBP + RDX*0x1],0x0
POP RBX
POP RBP
POP R12
RET
LAB_001011ec:
MOV EDX,0x0
JMP 0x001011e2 | void func0(byte *param_1,long param_2)
{
__int32_t **pp_Var1;
long lVar2;
byte bVar3;
bVar3 = *param_1;
if (bVar3 == 0) {
lVar2 = 0;
}
else {
pp_Var1 = __ctype_tolower_loc();
lVar2 = 0;
do {
*(char *)(param_2 + lVar2) = (char)(*pp_Var1)[bVar3];
lVar2 = lVar2 + 1;
bVar3 = param_1[lVar2];
} while (bVar3 != 0);
}
*(int1 *)(param_2 + lVar2) = 0;
return;
} |
5,802 | func0 |
#include <assert.h>
#include <ctype.h>
#include <string.h>
| void func0(char* input, char* output) {
int i = 0;
while (input[i]) {
output[i] = tolower((unsigned char) input[i]);
i++;
}
output[i] = '\0';
}
| int main() {
char result[100];
func0("InValid", result);
assert(strcmp(result, "invalid") == 0);
func0("TruE", result);
assert(strcmp(result, "true") == 0);
func0("SenTenCE", result);
assert(strcmp(result, "sentence") == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
push %rbp
mov %rsi,%rbp
push %rbx
movzbl (%rdi),%ebx
test %bl,%bl
je 12cd <func0+0x3d>
mov %rdi,%r12
callq 1090 <__ctype_tolower_loc@plt>
xor %edx,%edx
nopl 0x0(%rax)
mov (%rax),%rcx
movzbl %bl,%ebx
mov (%rcx,%rbx,4),%ecx
mov %cl,0x0(%rbp,%rdx,1)
add $0x1,%rdx
movzbl (%r12,%rdx,1),%ebx
test %bl,%bl
jne 12b0 <func0+0x20>
add %rdx,%rbp
pop %rbx
movb $0x0,0x0(%rbp)
pop %rbp
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
push r12
push rbp
mov rbp, rsi
push rbx
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_12CA
mov r12, rdi
call ___ctype_tolower_loc
xor edx, edx
nop dword ptr [rax+00h]
loc_12B0:
mov rcx, [rax]
mov ecx, [rcx+rbx*4]
mov [rbp+rdx+0], cl
add rdx, 1
movzx ebx, byte ptr [r12+rdx]
test bl, bl
jnz short loc_12B0
add rbp, rdx
loc_12CA:
pop rbx
mov byte ptr [rbp+0], 0
pop rbp
pop r12
retn | void func0(unsigned __int8 *a1, _BYTE *a2)
{
_BYTE *v2; // rbp
long long v3; // rbx
_QWORD *v4; // rax
long long v5; // rdx
v2 = a2;
v3 = *a1;
if ( (_BYTE)v3 )
{
v4 = (_QWORD *)__ctype_tolower_loc();
v5 = 0LL;
do
{
a2[v5++] = *(_DWORD *)(*v4 + 4 * v3);
v3 = a1[v5];
}
while ( (_BYTE)v3 );
v2 = &a2[v5];
}
*v2 = 0;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
MOV RBP,RSI
PUSH RBX
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001012ca
MOV R12,RDI
CALL 0x00101090
XOR EDX,EDX
NOP dword ptr [RAX]
LAB_001012b0:
MOV RCX,qword ptr [RAX]
MOV ECX,dword ptr [RCX + RBX*0x4]
MOV byte ptr [RBP + RDX*0x1],CL
ADD RDX,0x1
MOVZX EBX,byte ptr [R12 + RDX*0x1]
TEST BL,BL
JNZ 0x001012b0
ADD RBP,RDX
LAB_001012ca:
POP RBX
MOV byte ptr [RBP],0x0
POP RBP
POP R12
RET | void func0(byte *param_1,int1 *param_2)
{
byte bVar1;
__int32_t **pp_Var2;
long lVar3;
bVar1 = *param_1;
if (bVar1 != 0) {
pp_Var2 = __ctype_tolower_loc();
lVar3 = 0;
do {
param_2[lVar3] = (char)(*pp_Var2)[bVar1];
lVar3 = lVar3 + 1;
bVar1 = param_1[lVar3];
} while (bVar1 != 0);
param_2 = param_2 + lVar3;
}
*param_2 = 0;
return;
} |
5,803 | func0 |
#include <assert.h>
#include <ctype.h>
#include <string.h>
| void func0(char* input, char* output) {
int i = 0;
while (input[i]) {
output[i] = tolower((unsigned char) input[i]);
i++;
}
output[i] = '\0';
}
| int main() {
char result[100];
func0("InValid", result);
assert(strcmp(result, "invalid") == 0);
func0("TruE", result);
assert(strcmp(result, "true") == 0);
func0("SenTenCE", result);
assert(strcmp(result, "sentence") == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
push %rbp
mov %rsi,%rbp
push %rbx
movzbl (%rdi),%ebx
test %bl,%bl
je 12cd <func0+0x3d>
mov %rdi,%r12
callq 1090 <__ctype_tolower_loc@plt>
xor %edx,%edx
nopl 0x0(%rax)
mov (%rax),%rcx
movzbl %bl,%ebx
mov (%rcx,%rbx,4),%ecx
mov %cl,0x0(%rbp,%rdx,1)
add $0x1,%rdx
movzbl (%r12,%rdx,1),%ebx
test %bl,%bl
jne 12b0 <func0+0x20>
add %rdx,%rbp
pop %rbx
movb $0x0,0x0(%rbp)
pop %rbp
pop %r12
retq
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
push r12
push rbp
mov rbp, rsi
push rbx
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_12CA
mov r12, rdi
call ___ctype_tolower_loc
xor edx, edx
nop dword ptr [rax+00h]
loc_12B0:
mov rcx, [rax]
mov ecx, [rcx+rbx*4]
mov [rbp+rdx+0], cl
add rdx, 1
movzx ebx, byte ptr [r12+rdx]
test bl, bl
jnz short loc_12B0
add rbp, rdx
loc_12CA:
mov byte ptr [rbp+0], 0
pop rbx
pop rbp
pop r12
retn | void func0(unsigned __int8 *a1, _BYTE *a2)
{
_BYTE *v2; // rbp
long long v3; // rbx
const __int32_t **v4; // rax
long long v5; // rdx
v2 = a2;
v3 = *a1;
if ( (_BYTE)v3 )
{
v4 = __ctype_tolower_loc();
v5 = 0LL;
do
{
a2[v5++] = (*v4)[v3];
v3 = a1[v5];
}
while ( (_BYTE)v3 );
v2 = &a2[v5];
}
*v2 = 0;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
MOV RBP,RSI
PUSH RBX
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001012ca
MOV R12,RDI
CALL 0x00101090
XOR EDX,EDX
NOP dword ptr [RAX]
LAB_001012b0:
MOV RCX,qword ptr [RAX]
MOV ECX,dword ptr [RCX + RBX*0x4]
MOV byte ptr [RBP + RDX*0x1],CL
ADD RDX,0x1
MOVZX EBX,byte ptr [R12 + RDX*0x1]
TEST BL,BL
JNZ 0x001012b0
ADD RBP,RDX
LAB_001012ca:
MOV byte ptr [RBP],0x0
POP RBX
POP RBP
POP R12
RET | void func0(byte *param_1,int *param_2)
{
byte bVar1;
__int32_t **pp_Var2;
long lVar3;
bVar1 = *param_1;
if (bVar1 != 0) {
pp_Var2 = __ctype_tolower_loc();
lVar3 = 0;
do {
param_2[lVar3] = (char)(*pp_Var2)[bVar1];
lVar3 = lVar3 + 1;
bVar1 = param_1[lVar3];
} while (bVar1 != 0);
param_2 = param_2 + lVar3;
}
*param_2 = 0;
return;
} |
5,804 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
| char* func0(char *str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (!islower(str1[i])) {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("PYTHon"), "PYTH") == 0);
assert(strcmp(func0("FInD"), "FID") == 0);
assert(strcmp(func0("STRinG"), "STRG") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
movl $0x0,-0x4(%rbp)
movl $0x0,-0x8(%rbp)
jmp 1204 <func0+0x7b>
callq 1090 <__ctype_b_loc@plt>
mov (%rax),%rax
mov -0x8(%rbp),%edx
movslq %edx,%rcx
mov -0x18(%rbp),%rdx
add %rcx,%rdx
movzbl (%rdx),%edx
movsbq %dl,%rdx
add %rdx,%rdx
add %rdx,%rax
movzwl (%rax),%eax
movzwl %ax,%eax
and $0x200,%eax
test %eax,%eax
jne 1200 <func0+0x77>
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x4(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x4(%rbp)
movzbl (%rcx),%edx
cltq
lea 0x2e43(%rip),%rcx
mov %dl,(%rax,%rcx,1)
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
test %al,%al
jne 11a9 <func0+0x20>
mov -0x4(%rbp),%eax
cltq
lea 0x2e1c(%rip),%rdx
movb $0x0,(%rax,%rdx,1)
lea 0x2e11(%rip),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+var_18], rdi
mov [rbp+var_4], 0
mov [rbp+var_8], 0
jmp short loc_1204
loc_11A9:
call ___ctype_b_loc
mov rax, [rax]
mov edx, [rbp+var_8]
movsxd rcx, edx
mov rdx, [rbp+var_18]
add rdx, rcx
movzx edx, byte ptr [rdx]
movsx rdx, dl
add rdx, rdx
add rax, rdx
movzx eax, word ptr [rax]
movzx eax, ax
and eax, 200h
test eax, eax
jnz short loc_1200
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
lea rcx, [rdx+rax]
mov eax, [rbp+var_4]
lea edx, [rax+1]
mov [rbp+var_4], edx
movzx edx, byte ptr [rcx]
cdqe
lea rcx, result_1
mov [rax+rcx], dl
loc_1200:
add [rbp+var_8], 1
loc_1204:
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
test al, al
jnz short loc_11A9
mov eax, [rbp+var_4]
cdqe
lea rdx, result_1
mov byte ptr [rax+rdx], 0
lea rax, result_1
leave
retn | _BYTE * func0(long long a1)
{
int v1; // eax
int i; // [rsp+18h] [rbp-8h]
int v4; // [rsp+1Ch] [rbp-4h]
v4 = 0;
for ( i = 0; *(_BYTE *)(i + a1); ++i )
{
if ( ((*__ctype_b_loc())[*(char *)(i + a1)] & 0x200) == 0 )
{
v1 = v4++;
result_1[v1] = *(_BYTE *)(i + a1);
}
}
result_1[v4] = 0;
return result_1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x4],0x0
MOV dword ptr [RBP + -0x8],0x0
JMP 0x00101204
LAB_001011a9:
CALL 0x00101090
MOV RAX,qword ptr [RAX]
MOV EDX,dword ptr [RBP + -0x8]
MOVSXD RCX,EDX
MOV RDX,qword ptr [RBP + -0x18]
ADD RDX,RCX
MOVZX EDX,byte ptr [RDX]
MOVSX RDX,DL
ADD RDX,RDX
ADD RAX,RDX
MOVZX EAX,word ptr [RAX]
MOVZX EAX,AX
AND EAX,0x200
TEST EAX,EAX
JNZ 0x00101200
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x4]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x4],EDX
MOVZX EDX,byte ptr [RCX]
CDQE
LEA RCX,[0x104040]
MOV byte ptr [RAX + RCX*0x1],DL
LAB_00101200:
ADD dword ptr [RBP + -0x8],0x1
LAB_00101204:
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x001011a9
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[0x104040]
MOV byte ptr [RAX + RDX*0x1],0x0
LEA RAX,[0x104040]
LEAVE
RET | int1 * func0(long param_1)
{
ushort **ppuVar1;
int local_10;
int local_c;
local_c = 0;
for (local_10 = 0; *(char *)(param_1 + local_10) != '\0'; local_10 = local_10 + 1) {
ppuVar1 = __ctype_b_loc();
if (((*ppuVar1)[*(char *)(param_1 + local_10)] & 0x200) == 0) {
result_1[local_c] = *(int *)(local_10 + param_1);
local_c = local_c + 1;
}
}
result_1[local_c] = 0;
return result_1;
} |
5,805 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
| char* func0(char *str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (!islower(str1[i])) {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("PYTHon"), "PYTH") == 0);
assert(strcmp(func0("FInD"), "FID") == 0);
assert(strcmp(func0("STRinG"), "STRG") == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
movzbl (%rdi),%ebx
test %bl,%bl
je 11ba <func0+0x51>
mov %rdi,%rbp
callq 1070 <__ctype_b_loc@plt>
lea 0x1(%rbp),%rdi
mov $0x0,%esi
lea 0x2eae(%rip),%r8
jmp 11a0 <func0+0x37>
add $0x1,%rdi
movzbl -0x1(%rdi),%ebx
test %bl,%bl
je 11bf <func0+0x56>
movsbq %bl,%rdx
mov (%rax),%rcx
testb $0x2,0x1(%rcx,%rdx,2)
jne 1194 <func0+0x2b>
movslq %esi,%rdx
mov %bl,(%r8,%rdx,1)
lea 0x1(%rsi),%esi
jmp 1194 <func0+0x2b>
mov $0x0,%esi
lea 0x2e7a(%rip),%rax
movslq %esi,%rsi
movb $0x0,(%rax,%rsi,1)
add $0x8,%rsp
pop %rbx
pop %rbp
retq
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_11DA
mov rbp, rdi
call ___ctype_b_loc
lea rdi, [rbp+1]
mov esi, 0
lea r8, result_1
jmp short loc_11C0
loc_11B4:
add rdi, 1
movzx ebx, byte ptr [rdi-1]
test bl, bl
jz short loc_11DF
loc_11C0:
movsx rdx, bl
mov rcx, [rax]
test byte ptr [rcx+rdx*2+1], 2
jnz short loc_11B4
movsxd rdx, esi
mov [r8+rdx], bl
lea esi, [rsi+1]
jmp short loc_11B4
loc_11DA:
mov esi, 0
loc_11DF:
lea rax, result_1
movsxd rsi, esi
mov byte ptr [rax+rsi], 0
add rsp, 8
pop rbx
pop rbp
retn | _BYTE * func0(char *a1)
{
char v1; // bl
_QWORD *v2; // rax
char *v3; // rdi
int v4; // esi
_BYTE *result; // rax
v1 = *a1;
if ( *a1 )
{
v2 = (_QWORD *)__ctype_b_loc();
v3 = a1 + 1;
v4 = 0;
do
{
if ( (*(_BYTE *)(*v2 + 2LL * v1 + 1) & 2) == 0 )
result_1[v4++] = v1;
v1 = *v3++;
}
while ( v1 );
}
else
{
v4 = 0;
}
result = result_1;
result_1[v4] = 0;
return result;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001011da
MOV RBP,RDI
CALL 0x00101090
LEA RDI,[RBP + 0x1]
MOV ESI,0x0
LEA R8,[0x104040]
JMP 0x001011c0
LAB_001011b4:
ADD RDI,0x1
MOVZX EBX,byte ptr [RDI + -0x1]
TEST BL,BL
JZ 0x001011df
LAB_001011c0:
MOVSX RDX,BL
MOV RCX,qword ptr [RAX]
TEST byte ptr [RCX + RDX*0x2 + 0x1],0x2
JNZ 0x001011b4
MOVSXD RDX,ESI
MOV byte ptr [R8 + RDX*0x1],BL
LEA ESI,[RSI + 0x1]
JMP 0x001011b4
LAB_001011da:
MOV ESI,0x0
LAB_001011df:
LEA RAX,[0x104040]
MOVSXD RSI,ESI
MOV byte ptr [RAX + RSI*0x1],0x0
ADD RSP,0x8
POP RBX
POP RBP
RET | void func0(char *param_1)
{
ushort **ppuVar1;
char cVar2;
int iVar3;
char *pcVar4;
cVar2 = *param_1;
if (cVar2 == '\0') {
iVar3 = 0;
}
else {
ppuVar1 = __ctype_b_loc();
iVar3 = 0;
pcVar4 = param_1 + 1;
do {
if ((*(byte *)((long)*ppuVar1 + (long)cVar2 * 2 + 1) & 2) == 0) {
(&result_1)[iVar3] = cVar2;
iVar3 = iVar3 + 1;
}
cVar2 = *pcVar4;
pcVar4 = pcVar4 + 1;
} while (cVar2 != '\0');
}
(&result_1)[iVar3] = 0;
return;
} |
5,806 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
| char* func0(char *str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (!islower(str1[i])) {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("PYTHon"), "PYTH") == 0);
assert(strcmp(func0("FInD"), "FID") == 0);
assert(strcmp(func0("STRinG"), "STRG") == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
movzbl (%rdi),%ebx
test %bl,%bl
je 12c0 <func0+0x70>
mov %rdi,%rbp
callq 1070 <__ctype_b_loc@plt>
lea 0x1(%rbp),%rdi
xor %esi,%esi
lea 0x2dca(%rip),%r8
nopw %cs:0x0(%rax,%rax,1)
mov (%rax),%rcx
movsbq %bl,%rdx
testb $0x2,0x1(%rcx,%rdx,2)
jne 1298 <func0+0x48>
movslq %esi,%rdx
add $0x1,%esi
mov %bl,(%r8,%rdx,1)
movzbl (%rdi),%ebx
add $0x1,%rdi
test %bl,%bl
jne 1280 <func0+0x30>
movslq %esi,%rsi
lea 0x2d93(%rip),%rax
movb $0x0,(%r8,%rsi,1)
add $0x8,%rsp
pop %rbx
pop %rbp
retq
nopl 0x0(%rax)
xor %esi,%esi
lea 0x2d77(%rip),%r8
jmp 12a3 <func0+0x53>
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_12C8
mov rbp, rdi
call ___ctype_b_loc
lea rdi, [rbp+1]
xor esi, esi
lea r8, result_1
nop word ptr [rax+rax+00000000h]
loc_1290:
mov rcx, [rax]
movsx rdx, bl
test byte ptr [rcx+rdx*2+1], 2
jnz short loc_12A8
movsxd rdx, esi
add esi, 1
mov [r8+rdx], bl
loc_12A8:
movzx ebx, byte ptr [rdi]
add rdi, 1
test bl, bl
jnz short loc_1290
loc_12B3:
movsxd rsi, esi
mov rax, r8
mov byte ptr [r8+rsi], 0
add rsp, 8
pop rbx
pop rbp
retn
loc_12C8:
xor esi, esi
lea r8, result_1
jmp short loc_12B3 | _BYTE * func0(char *a1)
{
char v1; // bl
_QWORD *v2; // rax
char *v3; // rdi
int v4; // esi
long long v5; // rdx
_BYTE *result; // rax
v1 = *a1;
if ( *a1 )
{
v2 = (_QWORD *)__ctype_b_loc();
v3 = a1 + 1;
v4 = 0;
do
{
if ( (*(_BYTE *)(*v2 + 2LL * v1 + 1) & 2) == 0 )
{
v5 = v4++;
result_1[v5] = v1;
}
v1 = *v3++;
}
while ( v1 );
}
else
{
v4 = 0;
}
result = result_1;
result_1[v4] = 0;
return result;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001012c8
MOV RBP,RDI
CALL 0x00101090
LEA RDI,[RBP + 0x1]
XOR ESI,ESI
LEA R8,[0x104040]
NOP word ptr CS:[RAX + RAX*0x1]
LAB_00101290:
MOV RCX,qword ptr [RAX]
MOVSX RDX,BL
TEST byte ptr [RCX + RDX*0x2 + 0x1],0x2
JNZ 0x001012a8
MOVSXD RDX,ESI
ADD ESI,0x1
MOV byte ptr [R8 + RDX*0x1],BL
LAB_001012a8:
MOVZX EBX,byte ptr [RDI]
ADD RDI,0x1
TEST BL,BL
JNZ 0x00101290
LAB_001012b3:
MOVSXD RSI,ESI
MOV RAX,R8
MOV byte ptr [R8 + RSI*0x1],0x0
ADD RSP,0x8
POP RBX
POP RBP
RET
LAB_001012c8:
XOR ESI,ESI
LEA R8,[0x104040]
JMP 0x001012b3 | int1 * func0(char *param_1)
{
ushort **ppuVar1;
long lVar2;
char cVar3;
int iVar4;
cVar3 = *param_1;
if (cVar3 == '\0') {
iVar4 = 0;
}
else {
ppuVar1 = __ctype_b_loc();
param_1 = param_1 + 1;
iVar4 = 0;
do {
if ((*(byte *)((long)*ppuVar1 + (long)cVar3 * 2 + 1) & 2) == 0) {
lVar2 = (long)iVar4;
iVar4 = iVar4 + 1;
(&result_1)[lVar2] = cVar3;
}
cVar3 = *param_1;
param_1 = param_1 + 1;
} while (cVar3 != '\0');
}
(&result_1)[iVar4] = 0;
return &result_1;
} |
5,807 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
| char* func0(char *str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (!islower(str1[i])) {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("PYTHon"), "PYTH") == 0);
assert(strcmp(func0("FInD"), "FID") == 0);
assert(strcmp(func0("STRinG"), "STRG") == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x8,%rsp
movzbl (%rdi),%ebx
test %bl,%bl
je 12d8 <func0+0x88>
mov %rdi,%rbp
callq 1070 <__ctype_b_loc@plt>
lea 0x1(%rbp),%rdi
xor %edx,%edx
lea 0x2dca(%rip),%r8
mov (%rax),%rsi
nopl 0x0(%rax)
movsbq %bl,%rcx
testb $0x2,0x1(%rsi,%rcx,2)
jne 12af <func0+0x5f>
add $0x1,%rdi
mov %bl,(%r8,%rdx,1)
lea 0x1(%rdx),%ecx
movzbl -0x1(%rdi),%ebx
test %bl,%bl
je 12bc <func0+0x6c>
mov (%rax),%rsi
movslq %ecx,%rdx
movsbq %bl,%rcx
testb $0x2,0x1(%rsi,%rcx,2)
je 128b <func0+0x3b>
movzbl (%rdi),%ebx
add $0x1,%rdi
test %bl,%bl
jne 1280 <func0+0x30>
mov %edx,%ecx
movslq %ecx,%rcx
lea 0x2d7a(%rip),%rax
movb $0x0,(%r8,%rcx,1)
add $0x8,%rsp
pop %rbx
pop %rbp
retq
nopw 0x0(%rax,%rax,1)
xor %ecx,%ecx
lea 0x2d5f(%rip),%r8
jmp 12bc <func0+0x6c>
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
push rbp
push rbx
sub rsp, 8
movzx ebx, byte ptr [rdi]
test bl, bl
jz short loc_12E0
mov rbp, rdi
call ___ctype_b_loc
lea rdi, [rbp+1]
xor edx, edx
lea r8, result_1
mov rsi, [rax]
nop dword ptr [rax+00000000h]
loc_1290:
movsx rcx, bl
test byte ptr [rsi+rcx*2+1], 2
jnz short loc_12BF
loc_129B:
add rdi, 1
mov [r8+rdx], bl
lea ecx, [rdx+1]
movzx ebx, byte ptr [rdi-1]
movsxd rdx, ecx
test bl, bl
jz short loc_12CA
mov rsi, [rax]
movsx rcx, bl
test byte ptr [rsi+rcx*2+1], 2
jz short loc_129B
loc_12BF:
movzx ebx, byte ptr [rdi]
add rdi, 1
test bl, bl
jnz short loc_1290
loc_12CA:
mov byte ptr [r8+rdx], 0
add rsp, 8
mov rax, r8
pop rbx
pop rbp
retn
loc_12E0:
lea r8, result_1
xor edx, edx
mov byte ptr [r8+rdx], 0
add rsp, 8
mov rax, r8
pop rbx
pop rbp
retn | _BYTE * func0(char *a1)
{
char v1; // bl
const unsigned __int16 **v2; // rax
char *v3; // rdi
long long v4; // rdx
const unsigned __int16 *v5; // rsi
v1 = *a1;
if ( *a1 )
{
v2 = __ctype_b_loc();
v3 = a1 + 1;
v4 = 0LL;
v5 = *v2;
while ( (v5[v1] & 0x200) != 0 )
{
LABEL_6:
v1 = *v3++;
if ( !v1 )
goto LABEL_7;
}
while ( 1 )
{
++v3;
result_1[v4] = v1;
v1 = *(v3 - 1);
v4 = (int)v4 + 1;
if ( !v1 )
break;
v5 = *v2;
if ( ((*v2)[v1] & 0x200) != 0 )
goto LABEL_6;
}
LABEL_7:
result_1[v4] = 0;
return result_1;
}
else
{
result_1[0] = 0;
return result_1;
}
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOVZX EBX,byte ptr [RDI]
TEST BL,BL
JZ 0x001012e0
MOV RBP,RDI
CALL 0x00101090
LEA RDI,[RBP + 0x1]
XOR EDX,EDX
LEA R8,[0x104040]
MOV RSI,qword ptr [RAX]
NOP dword ptr [RAX]
LAB_00101290:
MOVSX RCX,BL
TEST byte ptr [RSI + RCX*0x2 + 0x1],0x2
JNZ 0x001012bf
LAB_0010129b:
ADD RDI,0x1
MOV byte ptr [R8 + RDX*0x1],BL
LEA ECX,[RDX + 0x1]
MOVZX EBX,byte ptr [RDI + -0x1]
MOVSXD RDX,ECX
TEST BL,BL
JZ 0x001012ca
MOV RSI,qword ptr [RAX]
MOVSX RCX,BL
TEST byte ptr [RSI + RCX*0x2 + 0x1],0x2
JZ 0x0010129b
LAB_001012bf:
MOVZX EBX,byte ptr [RDI]
ADD RDI,0x1
TEST BL,BL
JNZ 0x00101290
LAB_001012ca:
MOV byte ptr [R8 + RDX*0x1],0x0
ADD RSP,0x8
MOV RAX,R8
POP RBX
POP RBP
RET
LAB_001012e0:
LEA R8,[0x104040]
XOR EDX,EDX
MOV byte ptr [R8 + RDX*0x1],0x0
ADD RSP,0x8
MOV RAX,R8
POP RBX
POP RBP
RET | int1 * func0(char *param_1)
{
byte bVar1;
ushort **ppuVar2;
long lVar3;
char cVar4;
ushort *puVar5;
cVar4 = *param_1;
if (cVar4 == '\0') {
result_1 = 0;
return &result_1;
}
ppuVar2 = __ctype_b_loc();
param_1 = param_1 + 1;
lVar3 = 0;
puVar5 = *ppuVar2;
do {
bVar1 = *(byte *)((long)puVar5 + (long)cVar4 * 2 + 1);
while ((bVar1 & 2) == 0) {
(&result_1)[lVar3] = cVar4;
cVar4 = *param_1;
lVar3 = (long)((int)lVar3 + 1);
if (cVar4 == '\0') goto LAB_001012ca;
puVar5 = *ppuVar2;
param_1 = param_1 + 1;
bVar1 = *(byte *)((long)puVar5 + (long)cVar4 * 2 + 1);
}
cVar4 = *param_1;
param_1 = param_1 + 1;
} while (cVar4 != '\0');
LAB_001012ca:
(&result_1)[lVar3] = 0;
return &result_1;
} |
5,808 | func0 |
#include <assert.h>
| int func0(int n) {
while (n >= 10) {
n = n / 10;
}
return n;
}
| int main() {
assert(func0(123) == 1);
assert(func0(456) == 4);
assert(func0(12) == 1);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x4(%rbp)
jmp 1174 <func0+0x2b>
mov -0x4(%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,-0x4(%rbp)
cmpl $0x9,-0x4(%rbp)
jg 1156 <func0+0xd>
mov -0x4(%rbp),%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_4], edi
jmp short loc_1174
loc_1156:
mov eax, [rbp+var_4]
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_4], eax
loc_1174:
cmp [rbp+var_4], 9
jg short loc_1156
mov eax, [rbp+var_4]
pop rbp
retn | long long func0(int a1)
{
while ( a1 > 9 )
a1 /= 10;
return (unsigned int)a1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x4],EDI
JMP 0x00101174
LAB_00101156:
MOV EAX,dword ptr [RBP + -0x4]
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 + -0x4],EAX
LAB_00101174:
CMP dword ptr [RBP + -0x4],0x9
JG 0x00101156
MOV EAX,dword ptr [RBP + -0x4]
POP RBP
RET | int func0(int param_1)
{
int4 local_c;
for (local_c = param_1; 9 < local_c; local_c = local_c / 10) {
}
return local_c;
} |
5,809 | func0 |
#include <assert.h>
| int func0(int n) {
while (n >= 10) {
n = n / 10;
}
return n;
}
| int main() {
assert(func0(123) == 1);
assert(func0(456) == 4);
assert(func0(12) == 1);
return 0;
}
| O1 | c | func0:
endbr64
mov %edi,%eax
cmp $0x9,%edi
jle 1150 <func0+0x27>
mov %eax,%ecx
movslq %eax,%rdx
imul $0x66666667,%rdx,%rdx
sar $0x22,%rdx
sar $0x1f,%eax
sub %eax,%edx
mov %edx,%eax
cmp $0x63,%ecx
jg 1134 <func0+0xb>
retq
| func0:
endbr64
mov eax, edi
cmp edi, 9
jle short locret_1152
loc_1134:
mov ecx, eax
movsxd rdx, eax
imul rdx, 66666667h
sar rdx, 22h
sar eax, 1Fh
mov esi, eax
mov eax, edx
sub eax, esi
cmp ecx, 63h ; 'c'
jg short loc_1134
locret_1152:
retn | long long func0(int a1)
{
long long result; // rax
int v2; // ecx
result = (unsigned int)a1;
if ( a1 > 9 )
{
do
{
v2 = result;
result = (unsigned int)((int)result / 10);
}
while ( v2 > 99 );
}
return result;
} | func0:
ENDBR64
MOV EAX,EDI
CMP EDI,0x9
JLE 0x00101152
LAB_00101134:
MOV ECX,EAX
MOVSXD RDX,EAX
IMUL RDX,RDX,0x66666667
SAR RDX,0x22
SAR EAX,0x1f
MOV ESI,EAX
MOV EAX,EDX
SUB EAX,ESI
CMP ECX,0x63
JG 0x00101134
LAB_00101152:
RET | void func0(int param_1)
{
bool bVar1;
if (9 < param_1) {
do {
bVar1 = 99 < param_1;
param_1 = param_1 / 10;
} while (bVar1);
}
return;
} |
5,810 | func0 |
#include <assert.h>
| int func0(int n) {
while (n >= 10) {
n = n / 10;
}
return n;
}
| int main() {
assert(func0(123) == 1);
assert(func0(456) == 4);
assert(func0(12) == 1);
return 0;
}
| O2 | c | func0:
endbr64
mov %edi,%eax
cmp $0x9,%edi
jle 1162 <func0+0x22>
mov $0xcccccccd,%ecx
mov %eax,%eax
mov %rax,%rdx
imul %rcx,%rax
shr $0x23,%rax
cmp $0x63,%edx
jg 1150 <func0+0x10>
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
mov eax, edi
cmp edi, 9
jle short locret_1162
mov ecx, 0CCCCCCCDh
loc_1150:
mov eax, eax
mov rdx, rax
imul rax, rcx
shr rax, 23h
cmp edx, 63h ; 'c'
jg short loc_1150
locret_1162:
retn | unsigned long long func0(int a1)
{
unsigned long long result; // rax
int v2; // edx
result = (unsigned int)a1;
if ( a1 > 9 )
{
do
{
v2 = result;
result = (unsigned int)result / 0xAuLL;
}
while ( v2 > 99 );
}
return result;
} | func0:
ENDBR64
MOV EAX,EDI
CMP EDI,0x9
JLE 0x00101162
MOV ECX,0xcccccccd
LAB_00101150:
MOV EAX,EAX
MOV RDX,RAX
IMUL RAX,RCX
SHR RAX,0x23
CMP EDX,0x63
JG 0x00101150
LAB_00101162:
RET | void func0(uint param_1)
{
bool bVar1;
if (9 < (int)param_1) {
do {
bVar1 = 99 < (int)param_1;
param_1 = param_1 / 10;
} while (bVar1);
}
return;
} |
5,811 | func0 |
#include <assert.h>
| int func0(int n) {
while (n >= 10) {
n = n / 10;
}
return n;
}
| int main() {
assert(func0(123) == 1);
assert(func0(456) == 4);
assert(func0(12) == 1);
return 0;
}
| O3 | c | func0:
endbr64
mov %edi,%eax
cmp $0x9,%edi
jle 1162 <func0+0x22>
mov $0xcccccccd,%ecx
mov %eax,%eax
mov %rax,%rdx
imul %rcx,%rax
shr $0x23,%rax
cmp $0x63,%edx
jg 1150 <func0+0x10>
retq
nopw %cs:0x0(%rax,%rax,1)
nopl (%rax)
| func0:
endbr64
mov eax, edi
cmp edi, 9
jle short locret_1162
mov ecx, 0CCCCCCCDh
loc_1150:
mov eax, eax
mov rdx, rax
imul rax, rcx
shr rax, 23h
cmp edx, 63h ; 'c'
jg short loc_1150
locret_1162:
retn | unsigned long long func0(int a1)
{
unsigned long long result; // rax
int v2; // edx
result = (unsigned int)a1;
if ( a1 > 9 )
{
do
{
v2 = result;
result = (unsigned int)result / 0xAuLL;
}
while ( v2 > 99 );
}
return result;
} | func0:
ENDBR64
MOV EAX,EDI
CMP EDI,0x9
JLE 0x00101162
MOV ECX,0xcccccccd
LAB_00101150:
MOV EAX,EAX
MOV RDX,RAX
IMUL RAX,RCX
SHR RAX,0x23
CMP EDX,0x63
JG 0x00101150
LAB_00101162:
RET | void func0(uint param_1)
{
ulong uVar1;
int iVar2;
uVar1 = (ulong)param_1;
if (9 < (int)param_1) {
do {
iVar2 = (int)uVar1;
uVar1 = uVar1 / 10;
} while (99 < iVar2);
}
return;
} |
5,812 | func0 |
#include <assert.h>
#include <string.h>
| char func0(const char* str1) {
int ASCII_SIZE = 256;
int ctr[256] = {0};
int max = -1;
char ch = '\0';
int length = strlen(str1);
for (int i = 0; i < length; i++) {
ctr[(int)str1[i]]++;
}
for (int i = 0; i < length; i++) {
if (max < ctr[(int)str1[i]]) {
max = ctr[(int)str1[i]];
ch = str1[i];
}
}
return ch;
}
| int main() {
assert(func0("data") == 'a');
assert(func0("create") == 'e');
assert(func0("brilliant girl") == 'i');
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x440,%rsp
mov %rdi,-0x438(%rbp)
mov %fs:0x28,%rax
mov %rax,-0x8(%rbp)
xor %eax,%eax
movl $0x100,-0x418(%rbp)
lea -0x410(%rbp),%rdx
mov $0x0,%eax
mov $0x80,%ecx
mov %rdx,%rdi
rep stos %rax,%es:(%rdi)
movl $0xffffffff,-0x424(%rbp)
movb $0x0,-0x425(%rbp)
mov -0x438(%rbp),%rax
mov %rax,%rdi
callq 1070 <strlen@plt>
mov %eax,-0x414(%rbp)
movl $0x0,-0x420(%rbp)
jmp 1237 <func0+0xae>
mov -0x420(%rbp),%eax
movslq %eax,%rdx
mov -0x438(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
movsbl %al,%eax
movslq %eax,%rdx
mov -0x410(%rbp,%rdx,4),%edx
add $0x1,%edx
cltq
mov %edx,-0x410(%rbp,%rax,4)
addl $0x1,-0x420(%rbp)
mov -0x420(%rbp),%eax
cmp -0x414(%rbp),%eax
jl 1201 <func0+0x78>
movl $0x0,-0x41c(%rbp)
jmp 12c6 <func0+0x13d>
mov -0x41c(%rbp),%eax
movslq %eax,%rdx
mov -0x438(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
movsbl %al,%eax
cltq
mov -0x410(%rbp,%rax,4),%eax
cmp %eax,-0x424(%rbp)
jge 12bf <func0+0x136>
mov -0x41c(%rbp),%eax
movslq %eax,%rdx
mov -0x438(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
movsbl %al,%eax
cltq
mov -0x410(%rbp,%rax,4),%eax
mov %eax,-0x424(%rbp)
mov -0x41c(%rbp),%eax
movslq %eax,%rdx
mov -0x438(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
mov %al,-0x425(%rbp)
addl $0x1,-0x41c(%rbp)
mov -0x41c(%rbp),%eax
cmp -0x414(%rbp),%eax
jl 1251 <func0+0xc8>
movzbl -0x425(%rbp),%eax
mov -0x8(%rbp),%rsi
xor %fs:0x28,%rsi
je 12f3 <func0+0x16a>
callq 1080 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 440h
mov [rbp+s], rdi
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
mov [rbp+var_418], 100h
lea rdx, [rbp+var_410]
mov eax, 0
mov ecx, 80h
mov rdi, rdx
rep stosq
mov [rbp+var_424], 0FFFFFFFFh
mov [rbp+var_425], 0
mov rax, [rbp+s]
mov rdi, rax; s
call _strlen
mov [rbp+var_414], eax
mov [rbp+var_420], 0
jmp short loc_1237
loc_1201:
mov eax, [rbp+var_420]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
movsx eax, al
movsxd rdx, eax
mov edx, [rbp+rdx*4+var_410]
add edx, 1
cdqe
mov [rbp+rax*4+var_410], edx
add [rbp+var_420], 1
loc_1237:
mov eax, [rbp+var_420]
cmp eax, [rbp+var_414]
jl short loc_1201
mov [rbp+var_41C], 0
jmp short loc_12C6
loc_1251:
mov eax, [rbp+var_41C]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
movsx eax, al
cdqe
mov eax, [rbp+rax*4+var_410]
cmp [rbp+var_424], eax
jge short loc_12BF
mov eax, [rbp+var_41C]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
movsx eax, al
cdqe
mov eax, [rbp+rax*4+var_410]
mov [rbp+var_424], eax
mov eax, [rbp+var_41C]
movsxd rdx, eax
mov rax, [rbp+s]
add rax, rdx
movzx eax, byte ptr [rax]
mov [rbp+var_425], al
loc_12BF:
add [rbp+var_41C], 1
loc_12C6:
mov eax, [rbp+var_41C]
cmp eax, [rbp+var_414]
jl loc_1251
movzx eax, [rbp+var_425]
mov rdx, [rbp+var_8]
sub rdx, fs:28h
jz short locret_12F3
call ___stack_chk_fail
locret_12F3:
leave
retn | long long func0(const char *a1)
{
unsigned __int8 v2; // [rsp+1Bh] [rbp-425h]
int v3; // [rsp+1Ch] [rbp-424h]
int i; // [rsp+20h] [rbp-420h]
int j; // [rsp+24h] [rbp-41Ch]
int v6; // [rsp+2Ch] [rbp-414h]
_DWORD v7[258]; // [rsp+30h] [rbp-410h] BYREF
unsigned long long v8; // [rsp+438h] [rbp-8h]
v8 = __readfsqword(0x28u);
memset(v7, 0, 0x400uLL);
v3 = -1;
v2 = 0;
v6 = strlen(a1);
for ( i = 0; i < v6; ++i )
++v7[a1[i]];
for ( j = 0; j < v6; ++j )
{
if ( v3 < v7[a1[j]] )
{
v3 = v7[a1[j]];
v2 = a1[j];
}
}
return v2;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x440
MOV qword ptr [RBP + -0x438],RDI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RBP + -0x8],RAX
XOR EAX,EAX
MOV dword ptr [RBP + -0x418],0x100
LEA RDX,[RBP + -0x410]
MOV EAX,0x0
MOV ECX,0x80
MOV RDI,RDX
STOSQ.REP RDI
MOV dword ptr [RBP + -0x424],0xffffffff
MOV byte ptr [RBP + -0x425],0x0
MOV RAX,qword ptr [RBP + -0x438]
MOV RDI,RAX
CALL 0x00101070
MOV dword ptr [RBP + -0x414],EAX
MOV dword ptr [RBP + -0x420],0x0
JMP 0x00101237
LAB_00101201:
MOV EAX,dword ptr [RBP + -0x420]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x438]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
MOVSX EAX,AL
MOVSXD RDX,EAX
MOV EDX,dword ptr [RBP + RDX*0x4 + -0x410]
ADD EDX,0x1
CDQE
MOV dword ptr [RBP + RAX*0x4 + -0x410],EDX
ADD dword ptr [RBP + -0x420],0x1
LAB_00101237:
MOV EAX,dword ptr [RBP + -0x420]
CMP EAX,dword ptr [RBP + -0x414]
JL 0x00101201
MOV dword ptr [RBP + -0x41c],0x0
JMP 0x001012c6
LAB_00101251:
MOV EAX,dword ptr [RBP + -0x41c]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x438]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
MOVSX EAX,AL
CDQE
MOV EAX,dword ptr [RBP + RAX*0x4 + -0x410]
CMP dword ptr [RBP + -0x424],EAX
JGE 0x001012bf
MOV EAX,dword ptr [RBP + -0x41c]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x438]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
MOVSX EAX,AL
CDQE
MOV EAX,dword ptr [RBP + RAX*0x4 + -0x410]
MOV dword ptr [RBP + -0x424],EAX
MOV EAX,dword ptr [RBP + -0x41c]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x438]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
MOV byte ptr [RBP + -0x425],AL
LAB_001012bf:
ADD dword ptr [RBP + -0x41c],0x1
LAB_001012c6:
MOV EAX,dword ptr [RBP + -0x41c]
CMP EAX,dword ptr [RBP + -0x414]
JL 0x00101251
MOVZX EAX,byte ptr [RBP + -0x425]
MOV RDX,qword ptr [RBP + -0x8]
SUB RDX,qword ptr FS:[0x28]
JZ 0x001012f3
CALL 0x00101080
LAB_001012f3:
LEAVE
RET | char func0(char *param_1)
{
size_t sVar1;
long lVar2;
int *piVar3;
long in_FS_OFFSET;
char local_42d;
int local_42c;
int local_428;
int local_424;
int local_418 [258];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
piVar3 = local_418;
for (lVar2 = 0x80; lVar2 != 0; lVar2 = lVar2 + -1) {
piVar3[0] = 0;
piVar3[1] = 0;
piVar3 = piVar3 + 2;
}
local_42c = -1;
local_42d = '\0';
sVar1 = strlen(param_1);
for (local_428 = 0; local_428 < (int)sVar1; local_428 = local_428 + 1) {
local_418[(int)param_1[local_428]] = local_418[(int)param_1[local_428]] + 1;
}
for (local_424 = 0; local_424 < (int)sVar1; local_424 = local_424 + 1) {
if (local_42c < local_418[(int)param_1[local_424]]) {
local_42c = local_418[(int)param_1[local_424]];
local_42d = param_1[local_424];
}
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return local_42d;
} |
5,813 | func0 |
#include <assert.h>
#include <string.h>
| char func0(const char* str1) {
int ASCII_SIZE = 256;
int ctr[256] = {0};
int max = -1;
char ch = '\0';
int length = strlen(str1);
for (int i = 0; i < length; i++) {
ctr[(int)str1[i]]++;
}
for (int i = 0; i < length; i++) {
if (max < ctr[(int)str1[i]]) {
max = ctr[(int)str1[i]];
ch = str1[i];
}
}
return ch;
}
| int main() {
assert(func0("data") == 'a');
assert(func0("create") == 'e');
assert(func0("brilliant girl") == 'i');
return 0;
}
| O1 | c | func0:
endbr64
sub $0x418,%rsp
mov %rdi,%rdx
mov %fs:0x28,%rax
mov %rax,0x408(%rsp)
xor %eax,%eax
mov %rsp,%rdi
mov $0x80,%ecx
rep stos %rax,%es:(%rdi)
mov $0xffffffffffffffff,%rcx
mov %rdx,%rdi
repnz scas %es:(%rdi),%al
not %rcx
sub $0x1,%rcx
test %ecx,%ecx
jle 11f6 <func0+0x8d>
mov %rdx,%rax
lea -0x1(%rcx),%ecx
lea 0x1(%rdx,%rcx,1),%rsi
mov %rdx,%rdi
movsbq (%rdi),%rdx
addl $0x1,(%rsp,%rdx,4)
add $0x1,%rdi
cmp %rsi,%rdi
jne 11ba <func0+0x51>
mov $0x0,%r8d
mov $0xffffffff,%edi
jmp 11e1 <func0+0x78>
add $0x1,%rax
cmp %rsi,%rax
je 11fc <func0+0x93>
movzbl (%rax),%ecx
movsbq %cl,%rdx
mov (%rsp,%rdx,4),%edx
cmp %edi,%edx
jle 11d8 <func0+0x6f>
mov %ecx,%r8d
mov %edx,%edi
jmp 11d8 <func0+0x6f>
mov $0x0,%r8d
mov 0x408(%rsp),%rax
xor %fs:0x28,%rax
jne 121a <func0+0xb1>
mov %r8d,%eax
add $0x418,%rsp
retq
callq 1060 <__stack_chk_fail@plt>
| func0:
endbr64
push rbx
sub rsp, 410h
mov rbx, rdi
mov rax, fs:28h
mov [rsp+418h+var_10], rax
xor eax, eax
mov rdi, rsp
mov ecx, 80h
rep stosq
mov rdi, rbx
call _strlen
test eax, eax
jle short loc_120C
mov rdx, rbx
lea eax, [rax-1]
lea rsi, [rbx+rax+1]
mov rax, rbx
loc_11D0:
movsx rcx, byte ptr [rax]
add [rsp+rcx*4+418h+var_418], 1
add rax, 1
cmp rax, rsi
jnz short loc_11D0
mov r8d, 0
mov edi, 0FFFFFFFFh
jmp short loc_11F7
loc_11EE:
add rdx, 1
cmp rdx, rsi
jz short loc_1212
loc_11F7:
movzx ecx, byte ptr [rdx]
movsx rax, cl
mov eax, [rsp+rax*4+418h+var_418]
cmp eax, edi
jle short loc_11EE
mov r8d, ecx
mov edi, eax
jmp short loc_11EE
loc_120C:
mov r8d, 0
loc_1212:
mov rax, [rsp+418h+var_10]
sub rax, fs:28h
jnz short loc_1231
mov eax, r8d
add rsp, 410h
pop rbx
retn
loc_1231:
call ___stack_chk_fail | long long func0(char *a1)
{
int v1; // eax
char *v2; // rdx
long long v3; // rsi
char *v4; // rax
unsigned int v5; // r8d
int v6; // edi
_DWORD v8[258]; // [rsp+0h] [rbp-418h] BYREF
unsigned long long v9; // [rsp+408h] [rbp-10h]
v9 = __readfsqword(0x28u);
memset(v8, 0, 0x400uLL);
v1 = strlen(a1);
if ( v1 <= 0 )
{
return 0;
}
else
{
v2 = a1;
v3 = (long long)&a1[v1 - 1 + 1];
v4 = a1;
do
++v8[*v4++];
while ( v4 != (char *)v3 );
v5 = 0;
v6 = -1;
do
{
if ( v8[*v2] > v6 )
{
v5 = (unsigned __int8)*v2;
v6 = v8[*v2];
}
++v2;
}
while ( v2 != (char *)v3 );
}
return v5;
} | func0:
ENDBR64
PUSH RBX
SUB RSP,0x410
MOV RBX,RDI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x408],RAX
XOR EAX,EAX
MOV RDI,RSP
MOV ECX,0x80
STOSQ.REP RDI
MOV RDI,RBX
CALL 0x00101070
TEST EAX,EAX
JLE 0x0010120c
MOV RDX,RBX
LEA EAX,[RAX + -0x1]
LEA RSI,[RBX + RAX*0x1 + 0x1]
MOV RAX,RBX
LAB_001011d0:
MOVSX RCX,byte ptr [RAX]
ADD dword ptr [RSP + RCX*0x4],0x1
ADD RAX,0x1
CMP RAX,RSI
JNZ 0x001011d0
MOV R8D,0x0
MOV EDI,0xffffffff
JMP 0x001011f7
LAB_001011ee:
ADD RDX,0x1
CMP RDX,RSI
JZ 0x00101212
LAB_001011f7:
MOVZX ECX,byte ptr [RDX]
MOVSX RAX,CL
MOV EAX,dword ptr [RSP + RAX*0x4]
CMP EAX,EDI
JLE 0x001011ee
MOV R8D,ECX
MOV EDI,EAX
JMP 0x001011ee
LAB_0010120c:
MOV R8D,0x0
LAB_00101212:
MOV RAX,qword ptr [RSP + 0x408]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x00101231
MOV EAX,R8D
ADD RSP,0x410
POP RBX
RET
LAB_00101231:
CALL 0x00101080 | char func0(char *param_1)
{
char *pcVar1;
size_t sVar2;
char *pcVar3;
long lVar4;
int iVar5;
int *piVar6;
char cVar7;
long in_FS_OFFSET;
int aiStack_418 [258];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
piVar6 = aiStack_418;
for (lVar4 = 0x80; lVar4 != 0; lVar4 = lVar4 + -1) {
*(int8 *)piVar6 = 0;
piVar6 = (int *)((long)piVar6 + 8);
}
sVar2 = strlen(param_1);
if ((int)sVar2 < 1) {
cVar7 = '\0';
}
else {
pcVar1 = param_1 + (ulong)((int)sVar2 - 1) + 1;
pcVar3 = param_1;
do {
aiStack_418[*pcVar3] = aiStack_418[*pcVar3] + 1;
pcVar3 = pcVar3 + 1;
} while (pcVar3 != pcVar1);
cVar7 = '\0';
iVar5 = -1;
do {
if (iVar5 < aiStack_418[*param_1]) {
iVar5 = aiStack_418[*param_1];
cVar7 = *param_1;
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
}
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return cVar7;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,814 | func0 |
#include <assert.h>
#include <string.h>
| char func0(const char* str1) {
int ASCII_SIZE = 256;
int ctr[256] = {0};
int max = -1;
char ch = '\0';
int length = strlen(str1);
for (int i = 0; i < length; i++) {
ctr[(int)str1[i]]++;
}
for (int i = 0; i < length; i++) {
if (max < ctr[(int)str1[i]]) {
max = ctr[(int)str1[i]];
ch = str1[i];
}
}
return ch;
}
| int main() {
assert(func0("data") == 'a');
assert(func0("create") == 'e');
assert(func0("brilliant girl") == 'i');
return 0;
}
| O2 | c | func0:
endbr64
push %rbx
mov $0x80,%ecx
mov %rdi,%rbx
sub $0x410,%rsp
mov %fs:0x28,%rax
mov %rax,0x408(%rsp)
xor %eax,%eax
mov %rsp,%rdi
rep stos %rax,%es:(%rdi)
mov %rbx,%rdi
callq 1070 <strlen@plt>
test %eax,%eax
jle 12e0 <func0+0xb0>
sub $0x1,%eax
mov %rbx,%rdi
lea 0x1(%rbx,%rax,1),%rcx
mov %rbx,%rax
nopw 0x0(%rax,%rax,1)
movsbq (%rax),%rdx
add $0x1,%rax
addl $0x1,(%rsp,%rdx,4)
cmp %rcx,%rax
jne 1280 <func0+0x50>
xor %r8d,%r8d
mov $0xffffffff,%esi
nopl 0x0(%rax)
movsbq (%rdi),%rax
mov %rax,%rdx
mov (%rsp,%rax,4),%eax
cmp %esi,%eax
jle 12b3 <func0+0x83>
mov %edx,%r8d
mov %eax,%esi
add $0x1,%rdi
cmp %rcx,%rdi
jne 12a0 <func0+0x70>
mov 0x408(%rsp),%rax
xor %fs:0x28,%rax
jne 12e5 <func0+0xb5>
add $0x410,%rsp
mov %r8d,%eax
pop %rbx
retq
nopl 0x0(%rax,%rax,1)
xor %r8d,%r8d
jmp 12bc <func0+0x8c>
callq 1080 <__stack_chk_fail@plt>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push rbx
mov ecx, 80h
mov rbx, rdi
sub rsp, 410h
mov rax, fs:28h
mov [rsp+418h+var_10], rax
xor eax, eax
mov rdi, rsp
rep stosq
mov rdi, rbx
call _strlen
test eax, eax
jle short loc_12E0
sub eax, 1
mov rdi, rbx
lea rcx, [rbx+rax+1]
mov rax, rbx
nop word ptr [rax+rax+00000000h]
loc_1280:
movsx rdx, byte ptr [rax]
add rax, 1
add [rsp+rdx*4+418h+var_418], 1
cmp rax, rcx
jnz short loc_1280
xor r8d, r8d
mov esi, 0FFFFFFFFh
nop dword ptr [rax+00000000h]
loc_12A0:
movsx rax, byte ptr [rdi]
mov rdx, rax
mov eax, [rsp+rax*4+418h+var_418]
cmp eax, esi
jle short loc_12B3
mov r8d, edx
mov esi, eax
loc_12B3:
add rdi, 1
cmp rdi, rcx
jnz short loc_12A0
loc_12BC:
mov rax, [rsp+418h+var_10]
sub rax, fs:28h
jnz short loc_12E5
add rsp, 410h
mov eax, r8d
pop rbx
retn
loc_12E0:
xor r8d, r8d
jmp short loc_12BC
loc_12E5:
call ___stack_chk_fail | long long func0(char *a1)
{
int v1; // eax
long long v2; // rcx
char *v3; // rax
long long v4; // rdx
unsigned int v5; // r8d
int v6; // esi
long long v7; // rdx
_DWORD v9[258]; // [rsp+0h] [rbp-418h] BYREF
unsigned long long v10; // [rsp+408h] [rbp-10h]
v10 = __readfsqword(0x28u);
memset(v9, 0, 0x400uLL);
v1 = strlen(a1);
if ( v1 <= 0 )
{
return 0;
}
else
{
v2 = (long long)&a1[v1 - 1 + 1];
v3 = a1;
do
{
v4 = *v3++;
++v9[v4];
}
while ( v3 != (char *)v2 );
v5 = 0;
v6 = -1;
do
{
v7 = *a1;
if ( v9[v7] > v6 )
{
v5 = *a1;
v6 = v9[v7];
}
++a1;
}
while ( a1 != (char *)v2 );
}
return v5;
} | func0:
ENDBR64
PUSH RBX
MOV ECX,0x80
MOV RBX,RDI
SUB RSP,0x410
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x408],RAX
XOR EAX,EAX
MOV RDI,RSP
STOSQ.REP RDI
MOV RDI,RBX
CALL 0x00101070
TEST EAX,EAX
JLE 0x001012e0
SUB EAX,0x1
MOV RDI,RBX
LEA RCX,[RBX + RAX*0x1 + 0x1]
MOV RAX,RBX
NOP word ptr [RAX + RAX*0x1]
LAB_00101280:
MOVSX RDX,byte ptr [RAX]
ADD RAX,0x1
ADD dword ptr [RSP + RDX*0x4],0x1
CMP RAX,RCX
JNZ 0x00101280
XOR R8D,R8D
MOV ESI,0xffffffff
NOP dword ptr [RAX]
LAB_001012a0:
MOVSX RAX,byte ptr [RDI]
MOV RDX,RAX
MOV EAX,dword ptr [RSP + RAX*0x4]
CMP EAX,ESI
JLE 0x001012b3
MOV R8D,EDX
MOV ESI,EAX
LAB_001012b3:
ADD RDI,0x1
CMP RDI,RCX
JNZ 0x001012a0
LAB_001012bc:
MOV RAX,qword ptr [RSP + 0x408]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x001012e5
ADD RSP,0x410
MOV EAX,R8D
POP RBX
RET
LAB_001012e0:
XOR R8D,R8D
JMP 0x001012bc
LAB_001012e5:
CALL 0x00101080 | int func0(char *param_1)
{
char *pcVar1;
char cVar2;
size_t sVar3;
char *pcVar4;
long lVar5;
int iVar6;
int iVar7;
int *piVar8;
long in_FS_OFFSET;
int aiStack_418 [258];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
piVar8 = aiStack_418;
for (lVar5 = 0x80; lVar5 != 0; lVar5 = lVar5 + -1) {
*(int8 *)piVar8 = 0;
piVar8 = (int *)((long)piVar8 + 8);
}
sVar3 = strlen(param_1);
if ((int)sVar3 < 1) {
iVar6 = 0;
}
else {
pcVar1 = param_1 + (ulong)((int)sVar3 - 1) + 1;
pcVar4 = param_1;
do {
cVar2 = *pcVar4;
pcVar4 = pcVar4 + 1;
aiStack_418[cVar2] = aiStack_418[cVar2] + 1;
} while (pcVar4 != pcVar1);
iVar6 = 0;
iVar7 = -1;
do {
if (iVar7 < aiStack_418[*param_1]) {
iVar6 = (int)*param_1;
iVar7 = aiStack_418[*param_1];
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
}
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return iVar6;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,815 | func0 |
#include <assert.h>
#include <string.h>
| char func0(const char* str1) {
int ASCII_SIZE = 256;
int ctr[256] = {0};
int max = -1;
char ch = '\0';
int length = strlen(str1);
for (int i = 0; i < length; i++) {
ctr[(int)str1[i]]++;
}
for (int i = 0; i < length; i++) {
if (max < ctr[(int)str1[i]]) {
max = ctr[(int)str1[i]];
ch = str1[i];
}
}
return ch;
}
| int main() {
assert(func0("data") == 'a');
assert(func0("create") == 'e');
assert(func0("brilliant girl") == 'i');
return 0;
}
| O3 | c | func0:
endbr64
push %rbx
mov $0x80,%ecx
mov %rdi,%rbx
sub $0x410,%rsp
mov %fs:0x28,%rax
mov %rax,0x408(%rsp)
xor %eax,%eax
mov %rsp,%rdi
rep stos %rax,%es:(%rdi)
mov %rbx,%rdi
callq 1070 <strlen@plt>
test %eax,%eax
jle 12e0 <func0+0xb0>
sub $0x1,%eax
mov %rbx,%rdi
lea 0x1(%rbx,%rax,1),%rcx
mov %rbx,%rax
nopw 0x0(%rax,%rax,1)
movsbq (%rax),%rdx
add $0x1,%rax
addl $0x1,(%rsp,%rdx,4)
cmp %rcx,%rax
jne 1280 <func0+0x50>
xor %r8d,%r8d
mov $0xffffffff,%esi
nopl 0x0(%rax)
movsbq (%rdi),%rax
mov %rax,%rdx
mov (%rsp,%rax,4),%eax
cmp %esi,%eax
jle 12b3 <func0+0x83>
mov %edx,%r8d
mov %eax,%esi
add $0x1,%rdi
cmp %rcx,%rdi
jne 12a0 <func0+0x70>
mov 0x408(%rsp),%rax
xor %fs:0x28,%rax
jne 12e5 <func0+0xb5>
add $0x410,%rsp
mov %r8d,%eax
pop %rbx
retq
nopl 0x0(%rax,%rax,1)
xor %r8d,%r8d
jmp 12bc <func0+0x8c>
callq 1080 <__stack_chk_fail@plt>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
push rbx
mov ecx, 80h
mov rbx, rdi
sub rsp, 410h
mov rax, fs:28h
mov [rsp+418h+var_10], rax
xor eax, eax
mov rdi, rsp
rep stosq
mov rdi, rbx; s
call _strlen
test eax, eax
jle short loc_12E0
sub eax, 1
mov rdi, rbx
lea rcx, [rbx+rax+1]
mov rax, rbx
nop word ptr [rax+rax+00000000h]
loc_1280:
movsx rdx, byte ptr [rax]
add rax, 1
add [rsp+rdx*4+418h+var_418], 1
cmp rax, rcx
jnz short loc_1280
xor r8d, r8d
mov esi, 0FFFFFFFFh
nop dword ptr [rax+00000000h]
loc_12A0:
movsx rax, byte ptr [rdi]
mov rdx, rax
mov eax, [rsp+rax*4+418h+var_418]
cmp eax, esi
jle short loc_12B3
mov r8d, edx
mov esi, eax
loc_12B3:
add rdi, 1
cmp rdi, rcx
jnz short loc_12A0
loc_12BC:
mov rax, [rsp+418h+var_10]
sub rax, fs:28h
jnz short loc_12E5
add rsp, 410h
mov eax, r8d
pop rbx
retn
loc_12E0:
xor r8d, r8d
jmp short loc_12BC
loc_12E5:
call ___stack_chk_fail | long long func0(char *s)
{
int v1; // eax
char *v2; // rcx
char *v3; // rax
long long v4; // rdx
unsigned int v5; // r8d
int v6; // esi
long long v7; // rdx
_DWORD v9[258]; // [rsp+0h] [rbp-418h] BYREF
unsigned long long v10; // [rsp+408h] [rbp-10h]
v10 = __readfsqword(0x28u);
memset(v9, 0, 0x400uLL);
v1 = strlen(s);
if ( v1 <= 0 )
{
return 0;
}
else
{
v2 = &s[v1 - 1 + 1];
v3 = s;
do
{
v4 = *v3++;
++v9[v4];
}
while ( v3 != v2 );
v5 = 0;
v6 = -1;
do
{
v7 = *s;
if ( v9[v7] > v6 )
{
v5 = *s;
v6 = v9[v7];
}
++s;
}
while ( s != v2 );
}
return v5;
} | func0:
ENDBR64
PUSH RBX
MOV ECX,0x80
MOV RBX,RDI
SUB RSP,0x410
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x408],RAX
XOR EAX,EAX
MOV RDI,RSP
STOSQ.REP RDI
MOV RDI,RBX
CALL 0x00101070
TEST EAX,EAX
JLE 0x001012e0
SUB EAX,0x1
MOV RDI,RBX
LEA RCX,[RBX + RAX*0x1 + 0x1]
MOV RAX,RBX
NOP word ptr [RAX + RAX*0x1]
LAB_00101280:
MOVSX RDX,byte ptr [RAX]
ADD RAX,0x1
ADD dword ptr [RSP + RDX*0x4],0x1
CMP RAX,RCX
JNZ 0x00101280
XOR R8D,R8D
MOV ESI,0xffffffff
NOP dword ptr [RAX]
LAB_001012a0:
MOVSX RAX,byte ptr [RDI]
MOV RDX,RAX
MOV EAX,dword ptr [RSP + RAX*0x4]
CMP EAX,ESI
JLE 0x001012b3
MOV R8D,EDX
MOV ESI,EAX
LAB_001012b3:
ADD RDI,0x1
CMP RDI,RCX
JNZ 0x001012a0
LAB_001012bc:
MOV RAX,qword ptr [RSP + 0x408]
SUB RAX,qword ptr FS:[0x28]
JNZ 0x001012e5
ADD RSP,0x410
MOV EAX,R8D
POP RBX
RET
LAB_001012e0:
XOR R8D,R8D
JMP 0x001012bc
LAB_001012e5:
CALL 0x00101080 | int func0(char *param_1)
{
char *pcVar1;
char cVar2;
size_t sVar3;
char *pcVar4;
long lVar5;
int iVar6;
int iVar7;
int *piVar8;
long in_FS_OFFSET;
int aiStack_418 [258];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
piVar8 = aiStack_418;
for (lVar5 = 0x80; lVar5 != 0; lVar5 = lVar5 + -1) {
*(int8 *)piVar8 = 0;
piVar8 = (int *)((long)piVar8 + 8);
}
sVar3 = strlen(param_1);
if ((int)sVar3 < 1) {
iVar6 = 0;
}
else {
pcVar1 = param_1 + (ulong)((int)sVar3 - 1) + 1;
pcVar4 = param_1;
do {
cVar2 = *pcVar4;
pcVar4 = pcVar4 + 1;
aiStack_418[cVar2] = aiStack_418[cVar2] + 1;
} while (pcVar4 != pcVar1);
iVar6 = 0;
iVar7 = -1;
do {
if (iVar7 < aiStack_418[*param_1]) {
iVar6 = (int)*param_1;
iVar7 = aiStack_418[*param_1];
}
param_1 = param_1 + 1;
} while (param_1 != pcVar1);
}
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return iVar6;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,816 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int set[], int n, int sum) {
if (sum == 0)
return true;
if (n == 0)
return false;
if (set[n - 1] > sum)
return func0(set, n - 1, sum);
return func0(set, n - 1, sum) || func0(set, n - 1, sum - set[n - 1]);
}
| int main() {
int set1[] = {3, 34, 4, 12, 5, 2};
int set2[] = {3, 34, 4, 12, 5, 2};
int set3[] = {3, 34, 4, 12, 5, 2};
assert(func0(set1, 6, 9) == true);
assert(func0(set2, 6, 30) == false);
assert(func0(set3, 6, 15) == true);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
mov %rdi,-0x8(%rbp)
mov %esi,-0xc(%rbp)
mov %edx,-0x10(%rbp)
cmpl $0x0,-0x10(%rbp)
jne 118f <func0+0x26>
mov $0x1,%eax
jmpq 1230 <func0+0xc7>
cmpl $0x0,-0xc(%rbp)
jne 119f <func0+0x36>
mov $0x0,%eax
jmpq 1230 <func0+0xc7>
mov -0xc(%rbp),%eax
cltq
shl $0x2,%rax
lea -0x4(%rax),%rdx
mov -0x8(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x10(%rbp)
jge 11d3 <func0+0x6a>
mov -0xc(%rbp),%eax
lea -0x1(%rax),%ecx
mov -0x10(%rbp),%edx
mov -0x8(%rbp),%rax
mov %ecx,%esi
mov %rax,%rdi
callq 1169 <func0>
jmp 1230 <func0+0xc7>
mov -0xc(%rbp),%eax
lea -0x1(%rax),%ecx
mov -0x10(%rbp),%edx
mov -0x8(%rbp),%rax
mov %ecx,%esi
mov %rax,%rdi
callq 1169 <func0>
test %al,%al
jne 1221 <func0+0xb8>
mov -0xc(%rbp),%eax
cltq
shl $0x2,%rax
lea -0x4(%rax),%rdx
mov -0x8(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov -0x10(%rbp),%edx
sub %eax,%edx
mov -0xc(%rbp),%eax
lea -0x1(%rax),%ecx
mov -0x8(%rbp),%rax
mov %ecx,%esi
mov %rax,%rdi
callq 1169 <func0>
test %al,%al
je 1228 <func0+0xbf>
mov $0x1,%eax
jmp 122d <func0+0xc4>
mov $0x0,%eax
and $0x1,%eax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 10h
mov [rbp+var_8], rdi
mov [rbp+var_C], esi
mov [rbp+var_10], edx
cmp [rbp+var_10], 0
jnz short loc_118F
mov eax, 1
jmp locret_1230
loc_118F:
cmp [rbp+var_C], 0
jnz short loc_119F
mov eax, 0
jmp locret_1230
loc_119F:
mov eax, [rbp+var_C]
cdqe
shl rax, 2
lea rdx, [rax-4]
mov rax, [rbp+var_8]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_10], eax
jge short loc_11D3
mov eax, [rbp+var_C]
lea ecx, [rax-1]
mov edx, [rbp+var_10]
mov rax, [rbp+var_8]
mov esi, ecx
mov rdi, rax
call func0
jmp short locret_1230
loc_11D3:
mov eax, [rbp+var_C]
lea ecx, [rax-1]
mov edx, [rbp+var_10]
mov rax, [rbp+var_8]
mov esi, ecx
mov rdi, rax
call func0
test al, al
jnz short loc_1221
mov eax, [rbp+var_C]
cdqe
shl rax, 2
lea rdx, [rax-4]
mov rax, [rbp+var_8]
add rax, rdx
mov eax, [rax]
mov edx, [rbp+var_10]
sub edx, eax
mov eax, [rbp+var_C]
lea ecx, [rax-1]
mov rax, [rbp+var_8]
mov esi, ecx
mov rdi, rax
call func0
test al, al
jz short loc_1228
loc_1221:
mov eax, 1
jmp short loc_122D
loc_1228:
mov eax, 0
loc_122D:
and eax, 1
locret_1230:
leave
retn | long long func0(long long a1, int a2, unsigned int a3)
{
if ( !a3 )
return 1LL;
if ( !a2 )
return 0LL;
if ( (signed int)a3 < *(_DWORD *)(4LL * a2 - 4 + a1) )
return func0(a1, (unsigned int)(a2 - 1), a3);
return (unsigned __int8)func0(a1, (unsigned int)(a2 - 1), a3)
|| (unsigned __int8)func0(a1, (unsigned int)(a2 - 1), a3 - *(_DWORD *)(4LL * a2 - 4 + a1));
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x10
MOV qword ptr [RBP + -0x8],RDI
MOV dword ptr [RBP + -0xc],ESI
MOV dword ptr [RBP + -0x10],EDX
CMP dword ptr [RBP + -0x10],0x0
JNZ 0x0010118f
MOV EAX,0x1
JMP 0x00101230
LAB_0010118f:
CMP dword ptr [RBP + -0xc],0x0
JNZ 0x0010119f
MOV EAX,0x0
JMP 0x00101230
LAB_0010119f:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
SHL RAX,0x2
LEA RDX,[RAX + -0x4]
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
CMP dword ptr [RBP + -0x10],EAX
JGE 0x001011d3
MOV EAX,dword ptr [RBP + -0xc]
LEA ECX,[RAX + -0x1]
MOV EDX,dword ptr [RBP + -0x10]
MOV RAX,qword ptr [RBP + -0x8]
MOV ESI,ECX
MOV RDI,RAX
CALL 0x00101169
JMP 0x00101230
LAB_001011d3:
MOV EAX,dword ptr [RBP + -0xc]
LEA ECX,[RAX + -0x1]
MOV EDX,dword ptr [RBP + -0x10]
MOV RAX,qword ptr [RBP + -0x8]
MOV ESI,ECX
MOV RDI,RAX
CALL 0x00101169
TEST AL,AL
JNZ 0x00101221
MOV EAX,dword ptr [RBP + -0xc]
CDQE
SHL RAX,0x2
LEA RDX,[RAX + -0x4]
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV EDX,dword ptr [RBP + -0x10]
SUB EDX,EAX
MOV EAX,dword ptr [RBP + -0xc]
LEA ECX,[RAX + -0x1]
MOV RAX,qword ptr [RBP + -0x8]
MOV ESI,ECX
MOV RDI,RAX
CALL 0x00101169
TEST AL,AL
JZ 0x00101228
LAB_00101221:
MOV EAX,0x1
JMP 0x0010122d
LAB_00101228:
MOV EAX,0x0
LAB_0010122d:
AND EAX,0x1
LAB_00101230:
LEAVE
RET | ulong func0(long param_1,int param_2,int param_3)
{
char cVar1;
uint uVar2;
ulong uVar3;
if (param_3 == 0) {
return 1;
}
if (param_2 != 0) {
if (*(int *)(param_1 + (long)param_2 * 4 + -4) <= param_3) {
cVar1 = func0(param_1,param_2 + -1,param_3);
if ((cVar1 == '\0') &&
(cVar1 = func0(param_1,param_2 + -1,param_3 - *(int *)(param_1 + (long)param_2 * 4 + -4)),
cVar1 == '\0')) {
uVar2 = 0;
}
else {
uVar2 = 1;
}
return (ulong)uVar2;
}
uVar3 = func0(param_1,param_2 + -1,param_3);
return uVar3;
}
return 0;
} |
5,817 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int set[], int n, int sum) {
if (sum == 0)
return true;
if (n == 0)
return false;
if (set[n - 1] > sum)
return func0(set, n - 1, sum);
return func0(set, n - 1, sum) || func0(set, n - 1, sum - set[n - 1]);
}
| int main() {
int set1[] = {3, 34, 4, 12, 5, 2};
int set2[] = {3, 34, 4, 12, 5, 2};
int set3[] = {3, 34, 4, 12, 5, 2};
assert(func0(set1, 6, 9) == true);
assert(func0(set2, 6, 30) == false);
assert(func0(set3, 6, 15) == true);
return 0;
}
| O1 | c | func0:
endbr64
mov $0x1,%eax
test %edx,%edx
je 11dc <func0+0x73>
push %r13
push %r12
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%r12
mov %edx,%ebp
mov $0x0,%eax
test %esi,%esi
je 11b3 <func0+0x4a>
movslq %esi,%rax
mov -0x4(%rdi,%rax,4),%r13d
cmp %edx,%r13d
jg 11be <func0+0x55>
lea -0x1(%rsi),%ebx
mov %ebx,%esi
callq 1169 <func0>
mov %eax,%edx
mov $0x1,%eax
test %dl,%dl
je 11c8 <func0+0x5f>
and $0x1,%eax
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
sub $0x1,%esi
callq 1169 <func0>
jmp 11b3 <func0+0x4a>
mov %ebp,%edx
sub %r13d,%edx
mov %ebx,%esi
mov %r12,%rdi
callq 1169 <func0>
movzbl %al,%eax
jmp 11b0 <func0+0x47>
retq
| func0:
endbr64
mov eax, 1
test edx, edx
jz short locret_11DC
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov r12, rdi
mov ebp, edx
mov eax, 0
test esi, esi
jz short loc_11B3
movsxd rax, esi
mov r13d, [rdi+rax*4-4]
cmp r13d, edx
jg short loc_11BE
lea ebx, [rsi-1]
mov esi, ebx
call func0
mov edx, eax
mov eax, 1
test dl, dl
jz short loc_11C8
loc_11B0:
and eax, 1
loc_11B3:
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn
loc_11BE:
sub esi, 1
call func0
jmp short loc_11B3
loc_11C8:
mov edx, ebp
sub edx, r13d
mov esi, ebx
mov rdi, r12
call func0
movzx eax, al
jmp short loc_11B0
locret_11DC:
retn | long long func0(long long a1, int a2, int a3)
{
long long result; // rax
char v4; // dl
char v5; // al
result = 1LL;
if ( a3 )
{
result = 0LL;
if ( a2 )
{
if ( *(_DWORD *)(a1 + 4LL * a2 - 4) > a3 )
{
return func0(a1, (unsigned int)(a2 - 1));
}
else
{
v4 = func0(a1, (unsigned int)(a2 - 1));
v5 = 1;
if ( !v4 )
v5 = func0(a1, (unsigned int)(a2 - 1));
return v5 & 1;
}
}
}
return result;
} | func0:
ENDBR64
MOV EAX,0x1
TEST EDX,EDX
JZ 0x001011dc
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV R12,RDI
MOV EBP,EDX
MOV EAX,0x0
TEST ESI,ESI
JZ 0x001011b3
MOVSXD RAX,ESI
MOV R13D,dword ptr [RDI + RAX*0x4 + -0x4]
CMP R13D,EDX
JG 0x001011be
LEA EBX,[RSI + -0x1]
MOV ESI,EBX
CALL 0x00101169
MOV EDX,EAX
MOV EAX,0x1
TEST DL,DL
JZ 0x001011c8
LAB_001011b0:
AND EAX,0x1
LAB_001011b3:
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET
LAB_001011be:
SUB ESI,0x1
CALL 0x00101169
JMP 0x001011b3
LAB_001011c8:
MOV EDX,EBP
SUB EDX,R13D
MOV ESI,EBX
MOV RDI,R12
CALL 0x00101169
MOVZX EAX,AL
JMP 0x001011b0
LAB_001011dc:
RET | ulong func0(long param_1,int param_2,int param_3)
{
int iVar1;
char cVar2;
byte bVar3;
uint uVar4;
ulong uVar5;
if (param_3 != 0) {
uVar5 = 0;
if (param_2 != 0) {
iVar1 = *(int *)(param_1 + -4 + (long)param_2 * 4);
if (param_3 < iVar1) {
uVar5 = func0(param_1,param_2 + -1);
}
else {
cVar2 = func0(param_1,param_2 + -1);
uVar4 = 1;
if (cVar2 == '\0') {
bVar3 = func0(param_1,param_2 + -1,param_3 - iVar1);
uVar4 = (uint)bVar3;
}
uVar5 = (ulong)(uVar4 & 1);
}
}
return uVar5;
}
return 1;
} |
5,818 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int set[], int n, int sum) {
if (sum == 0)
return true;
if (n == 0)
return false;
if (set[n - 1] > sum)
return func0(set, n - 1, sum);
return func0(set, n - 1, sum) || func0(set, n - 1, sum - set[n - 1]);
}
| int main() {
int set1[] = {3, 34, 4, 12, 5, 2};
int set2[] = {3, 34, 4, 12, 5, 2};
int set3[] = {3, 34, 4, 12, 5, 2};
assert(func0(set1, 6, 9) == true);
assert(func0(set2, 6, 30) == false);
assert(func0(set3, 6, 15) == true);
return 0;
}
| O2 | c | func0:
endbr64
push %r13
mov %rdi,%r13
push %r12
mov %edx,%r12d
push %rbp
movslq %esi,%rbp
push %rbx
sub $0x8,%rsp
test %r12d,%r12d
je 1325 <func0+0x85>
test %ebp,%ebp
je 1310 <func0+0x70>
lea -0x1(%rbp),%edx
lea -0x2(%rbp),%rax
movslq %edx,%rsi
mov %edx,%edx
sub %rdx,%rax
jmp 12e1 <func0+0x41>
nopl 0x0(%rax)
sub $0x1,%rsi
cmp %rsi,%rax
je 1310 <func0+0x70>
mov 0x0(%r13,%rsi,4),%ebx
movslq %esi,%rbp
cmp %r12d,%ebx
jg 12d8 <func0+0x38>
mov %r12d,%edx
mov %r13,%rdi
callq 12a0 <func0>
test %al,%al
je 1320 <func0+0x80>
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl 0x0(%rax,%rax,1)
add $0x8,%rsp
xor %eax,%eax
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl (%rax)
sub %ebx,%r12d
jmp 12b7 <func0+0x17>
mov $0x1,%eax
jmp 12fd <func0+0x5d>
nopl 0x0(%rax)
| func0:
endbr64
push r13
mov r13, rdi
push r12
mov r12d, edx
push rbp
movsxd rbp, esi
push rbx
sub rsp, 8
loc_12B7:
test r12d, r12d
jz short loc_1325
test ebp, ebp
jz short loc_1310
lea ecx, [rbp-1]
lea rdx, [rbp-2]
movsxd rax, ecx
mov ecx, ecx
sub rdx, rcx
jmp short loc_12E1
loc_12D8:
sub rax, 1
cmp rdx, rax
jz short loc_1310
loc_12E1:
mov ebx, [r13+rax*4+0]
movsxd rbp, eax
cmp ebx, r12d
jg short loc_12D8
mov edx, r12d
mov esi, ebp
mov rdi, r13
call func0
test al, al
jz short loc_1320
loc_12FF:
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn
loc_1310:
add rsp, 8
xor eax, eax
pop rbx
pop rbp
pop r12
pop r13
retn
loc_1320:
sub r12d, ebx
jmp short loc_12B7
loc_1325:
mov eax, 1
jmp short loc_12FF | long long func0(long long a1, int a2, unsigned int a3)
{
long long v4; // rbp
long long v5; // rax
long long v6; // rdx
int v7; // ebx
long long result; // rax
v4 = a2;
while ( a3 )
{
if ( !(_DWORD)v4 )
return 0LL;
v5 = (int)v4 - 1;
v6 = v4 - 2 - (unsigned int)(v4 - 1);
while ( 1 )
{
v7 = *(_DWORD *)(a1 + 4 * v5);
v4 = (int)v5;
if ( v7 <= (int)a3 )
break;
if ( v6 == --v5 )
return 0LL;
}
result = func0(a1, (unsigned int)v5, a3);
if ( (_BYTE)result )
return result;
a3 -= v7;
}
return 1LL;
} | func0:
ENDBR64
PUSH R13
MOV R13,RDI
PUSH R12
MOV R12D,EDX
PUSH RBP
MOVSXD RBP,ESI
PUSH RBX
SUB RSP,0x8
LAB_001012b7:
TEST R12D,R12D
JZ 0x00101325
TEST EBP,EBP
JZ 0x00101310
LEA ECX,[RBP + -0x1]
LEA RDX,[RBP + -0x2]
MOVSXD RAX,ECX
MOV ECX,ECX
SUB RDX,RCX
JMP 0x001012e1
LAB_001012d8:
SUB RAX,0x1
CMP RDX,RAX
JZ 0x00101310
LAB_001012e1:
MOV EBX,dword ptr [R13 + RAX*0x4]
MOVSXD RBP,EAX
CMP EBX,R12D
JG 0x001012d8
MOV EDX,R12D
MOV ESI,EBP
MOV RDI,R13
CALL 0x001012a0
TEST AL,AL
JZ 0x00101320
LAB_001012ff:
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET
LAB_00101310:
ADD RSP,0x8
XOR EAX,EAX
POP RBX
POP RBP
POP R12
POP R13
RET
LAB_00101320:
SUB R12D,EBX
JMP 0x001012b7
LAB_00101325:
MOV EAX,0x1
JMP 0x001012ff | int8 func0(long param_1,int param_2,int param_3)
{
long lVar1;
int iVar2;
ulong uVar3;
int8 uVar4;
uint uVar5;
long lVar6;
lVar6 = (long)param_2;
while( true ) {
if (param_3 == 0) {
return 1;
}
if ((int)lVar6 == 0) break;
uVar5 = (int)lVar6 - 1;
lVar1 = lVar6 + -2;
uVar3 = (ulong)(int)uVar5;
while( true ) {
iVar2 = *(int *)(param_1 + uVar3 * 4);
lVar6 = (long)(int)uVar3;
if (iVar2 <= param_3) break;
uVar3 = uVar3 - 1;
if (lVar1 - (ulong)uVar5 == uVar3) {
return 0;
}
}
uVar4 = func0(param_1,uVar3 & 0xffffffff,param_3);
if ((char)uVar4 != '\0') {
return uVar4;
}
param_3 = param_3 - iVar2;
}
return 0;
} |
5,819 | func0 |
#include <stdbool.h>
#include <assert.h>
| bool func0(int set[], int n, int sum) {
if (sum == 0)
return true;
if (n == 0)
return false;
if (set[n - 1] > sum)
return func0(set, n - 1, sum);
return func0(set, n - 1, sum) || func0(set, n - 1, sum - set[n - 1]);
}
| int main() {
int set1[] = {3, 34, 4, 12, 5, 2};
int set2[] = {3, 34, 4, 12, 5, 2};
int set3[] = {3, 34, 4, 12, 5, 2};
assert(func0(set1, 6, 9) == true);
assert(func0(set2, 6, 30) == false);
assert(func0(set3, 6, 15) == true);
return 0;
}
| O3 | c | func0:
endbr64
push %r13
mov %rdi,%r13
push %r12
mov %edx,%r12d
push %rbp
movslq %esi,%rbp
push %rbx
sub $0x8,%rsp
test %r12d,%r12d
je 1305 <func0+0x85>
test %ebp,%ebp
je 12f0 <func0+0x70>
lea -0x1(%rbp),%edx
lea -0x2(%rbp),%rax
movslq %edx,%rsi
mov %edx,%edx
sub %rdx,%rax
jmp 12c1 <func0+0x41>
nopl 0x0(%rax)
sub $0x1,%rsi
cmp %rsi,%rax
je 12f0 <func0+0x70>
mov 0x0(%r13,%rsi,4),%ebx
movslq %esi,%rbp
cmp %r12d,%ebx
jg 12b8 <func0+0x38>
mov %r12d,%edx
mov %r13,%rdi
callq 1280 <func0>
test %al,%al
je 1300 <func0+0x80>
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl 0x0(%rax,%rax,1)
add $0x8,%rsp
xor %eax,%eax
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl (%rax)
sub %ebx,%r12d
jmp 1297 <func0+0x17>
mov $0x1,%eax
jmp 12dd <func0+0x5d>
nopl 0x0(%rax)
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
mov ebp, edx
push rbx
mov ebx, esi
sub rsp, 18h
loc_1286:
test ebp, ebp
jz loc_13D1
test ebx, ebx
jz loc_13C0
movsxd rax, ebx
lea rax, [rdi+rax*4]
jmp short loc_12AC
loc_12A0:
sub rax, 4
test ebx, ebx
jz loc_13C0
loc_12AC:
mov r12d, [rax-4]
mov r14d, ebx
sub ebx, 1
cmp r12d, ebp
jg short loc_12A0
cmp r14d, 1
jz loc_13D8
movsxd r15, ebx
lea rax, [rdi+r15*4]
jmp short loc_12DC
loc_12D0:
sub rax, 4
test ebx, ebx
jz loc_1370
loc_12DC:
mov r13d, [rax-4]
mov edx, ebx
sub ebx, 1
cmp ebp, r13d
jl short loc_12D0
cmp edx, 1
jz short loc_1357
sub edx, 2
movsxd rsi, ebx
movsxd rax, edx
sub rsi, 2
mov edx, edx
sub rsi, rdx
jmp short loc_1311
loc_1308:
sub rax, 1
cmp rsi, rax
jz short loc_1357
loc_1311:
mov r8d, [rdi+rax*4]
cmp ebp, r8d
jl short loc_1308
mov esi, eax
mov edx, ebp
mov [rsp+48h+var_3C], r8d
mov [rsp+48h+var_48], rdi
mov [rsp+48h+var_40], eax
call func0
mov rdi, [rsp+48h+var_48]
mov esi, [rsp+48h+var_40]
test al, al
mov r8d, [rsp+48h+var_3C]
jnz loc_13C2
mov edx, ebp
sub edx, r8d
call func0
mov rdi, [rsp+48h+var_48]
test al, al
jnz short loc_13C2
loc_1357:
mov edx, ebp
mov esi, ebx
mov [rsp+48h+var_48], rdi
sub edx, r13d
call func0
mov rdi, [rsp+48h+var_48]
test al, al
jnz short loc_13C2
nop
loc_1370:
sub ebp, r12d
jz short loc_13D1
lea eax, [r14-2]
lea rcx, [r15-2]
movsxd rbx, eax
mov eax, eax
sub rcx, rax
jmp short loc_1399
loc_1390:
sub rbx, 1
cmp rcx, rbx
jz short loc_13C0
loc_1399:
mov r12d, [rdi+rbx*4]
cmp ebp, r12d
jl short loc_1390
mov edx, ebp
mov esi, ebx
mov [rsp+48h+var_48], rdi
call func0
mov rdi, [rsp+48h+var_48]
test al, al
jnz short loc_13C2
sub ebp, r12d
jmp loc_1286
loc_13C0:
xor eax, eax
loc_13C2:
add rsp, 18h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_13D1:
mov eax, 1
jmp short loc_13C2
loc_13D8:
cmp r12d, ebp
setz al
jmp short loc_13C2 | char func0(long long a1, int a2, signed int a3)
{
long long v4; // rbx
long long i; // rax
int v6; // r12d
int v7; // r14d
long long v8; // r15
long long v9; // rax
int v10; // r13d
int v11; // edx
unsigned int v12; // edx
long long v13; // rax
char result; // al
unsigned int v15; // ebp
int v16; // r12d
unsigned int v17; // [rsp+8h] [rbp-40h]
int v18; // [rsp+Ch] [rbp-3Ch]
LODWORD(v4) = a2;
while ( 2 )
{
if ( !a3 )
return 1;
if ( !(_DWORD)v4 )
return 0;
for ( i = a1 + 4LL * (int)v4; ; i -= 4LL )
{
v6 = *(_DWORD *)(i - 4);
v7 = v4;
LODWORD(v4) = v4 - 1;
if ( v6 <= a3 )
break;
if ( !(_DWORD)v4 )
return 0;
}
if ( v7 == 1 )
return v6 == a3;
v8 = (int)v4;
v9 = a1 + 4LL * (int)v4;
while ( 1 )
{
v10 = *(_DWORD *)(v9 - 4);
v11 = v4;
LODWORD(v4) = v4 - 1;
if ( a3 >= v10 )
break;
v9 -= 4LL;
if ( !(_DWORD)v4 )
goto LABEL_18;
}
if ( v11 != 1 )
{
v12 = v11 - 2;
v13 = (int)v12;
while ( a3 < *(_DWORD *)(a1 + 4 * v13) )
{
if ( (int)v4 - 2LL - v12 == --v13 )
goto LABEL_17;
}
v18 = *(_DWORD *)(a1 + 4 * v13);
v17 = v13;
result = func0(a1, (unsigned int)v13, (unsigned int)a3);
if ( result )
return result;
result = func0(a1, v17, (unsigned int)(a3 - v18));
if ( result )
return result;
}
LABEL_17:
result = func0(a1, (unsigned int)v4, (unsigned int)(a3 - v10));
if ( result )
return result;
LABEL_18:
v15 = a3 - v6;
if ( !v15 )
return 1;
v4 = v7 - 2;
while ( 1 )
{
v16 = *(_DWORD *)(a1 + 4 * v4);
if ( (int)v15 >= v16 )
break;
if ( v8 - 2 - (unsigned int)(v7 - 2) == --v4 )
return 0;
}
result = func0(a1, (unsigned int)v4, v15);
if ( !result )
{
a3 = v15 - v16;
continue;
}
return result;
}
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
MOV EBP,EDX
PUSH RBX
MOV EBX,ESI
SUB RSP,0x18
LAB_00101286:
TEST EBP,EBP
JZ 0x001013d1
TEST EBX,EBX
JZ 0x001013c0
MOVSXD RAX,EBX
LEA RAX,[RDI + RAX*0x4]
JMP 0x001012ac
LAB_001012a0:
SUB RAX,0x4
TEST EBX,EBX
JZ 0x001013c0
LAB_001012ac:
MOV R12D,dword ptr [RAX + -0x4]
MOV R14D,EBX
SUB EBX,0x1
CMP R12D,EBP
JG 0x001012a0
CMP R14D,0x1
JZ 0x001013d8
MOVSXD R15,EBX
LEA RAX,[RDI + R15*0x4]
JMP 0x001012dc
LAB_001012d0:
SUB RAX,0x4
TEST EBX,EBX
JZ 0x00101370
LAB_001012dc:
MOV R13D,dword ptr [RAX + -0x4]
MOV EDX,EBX
SUB EBX,0x1
CMP EBP,R13D
JL 0x001012d0
CMP EDX,0x1
JZ 0x00101357
SUB EDX,0x2
MOVSXD RSI,EBX
MOVSXD RAX,EDX
SUB RSI,0x2
MOV EDX,EDX
SUB RSI,RDX
JMP 0x00101311
LAB_00101308:
SUB RAX,0x1
CMP RSI,RAX
JZ 0x00101357
LAB_00101311:
MOV R8D,dword ptr [RDI + RAX*0x4]
CMP EBP,R8D
JL 0x00101308
MOV ESI,EAX
MOV EDX,EBP
MOV dword ptr [RSP + 0xc],R8D
MOV qword ptr [RSP],RDI
MOV dword ptr [RSP + 0x8],EAX
CALL 0x00101270
MOV RDI,qword ptr [RSP]
MOV ESI,dword ptr [RSP + 0x8]
TEST AL,AL
MOV R8D,dword ptr [RSP + 0xc]
JNZ 0x001013c2
MOV EDX,EBP
SUB EDX,R8D
CALL 0x00101270
MOV RDI,qword ptr [RSP]
TEST AL,AL
JNZ 0x001013c2
LAB_00101357:
MOV EDX,EBP
MOV ESI,EBX
MOV qword ptr [RSP],RDI
SUB EDX,R13D
CALL 0x00101270
MOV RDI,qword ptr [RSP]
TEST AL,AL
JNZ 0x001013c2
NOP
LAB_00101370:
SUB EBP,R12D
JZ 0x001013d1
LEA EAX,[R14 + -0x2]
LEA RCX,[R15 + -0x2]
MOVSXD RBX,EAX
MOV EAX,EAX
SUB RCX,RAX
JMP 0x00101399
LAB_00101390:
SUB RBX,0x1
CMP RCX,RBX
JZ 0x001013c0
LAB_00101399:
MOV R12D,dword ptr [RDI + RBX*0x4]
CMP EBP,R12D
JL 0x00101390
MOV EDX,EBP
MOV ESI,EBX
MOV qword ptr [RSP],RDI
CALL 0x00101270
MOV RDI,qword ptr [RSP]
TEST AL,AL
JNZ 0x001013c2
SUB EBP,R12D
JMP 0x00101286
LAB_001013c0:
XOR EAX,EAX
LAB_001013c2:
ADD RSP,0x18
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001013d1:
MOV EAX,0x1
JMP 0x001013c2
LAB_001013d8:
CMP R12D,EBP
SETZ AL
JMP 0x001013c2 | int8 func0(long param_1,ulong param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
long lVar4;
ulong uVar5;
int8 uVar6;
int iVar7;
uint uVar8;
int iVar9;
uint uVar10;
param_2 = param_2 & 0xffffffff;
LAB_00101286:
if (param_3 == 0) {
return 1;
}
if ((int)param_2 == 0) {
return 0;
}
lVar4 = param_1 + (long)(int)param_2 * 4;
while( true ) {
iVar1 = *(int *)(lVar4 + -4);
iVar7 = (int)param_2;
uVar8 = iVar7 - 1;
param_2 = (ulong)uVar8;
if (iVar1 <= param_3) break;
lVar4 = lVar4 + -4;
if (uVar8 == 0) {
return 0;
}
}
if (iVar7 == 1) {
return CONCAT71((int7)((ulong)lVar4 >> 8),iVar1 == param_3);
}
lVar4 = param_1 + (long)(int)uVar8 * 4;
do {
iVar2 = *(int *)(lVar4 + -4);
iVar9 = (int)param_2;
uVar10 = iVar9 - 1;
param_2 = (ulong)uVar10;
if (iVar2 <= param_3) {
if (iVar9 == 1) goto LAB_00101357;
uVar5 = (ulong)(int)(iVar9 - 2U);
goto LAB_00101311;
}
lVar4 = lVar4 + -4;
} while (uVar10 != 0);
goto LAB_00101370;
while (uVar5 = uVar5 - 1, ((long)(int)uVar10 + -2) - (ulong)(iVar9 - 2U) != uVar5) {
LAB_00101311:
iVar3 = *(int *)(param_1 + uVar5 * 4);
if (iVar3 <= param_3) {
uVar6 = func0(param_1,uVar5 & 0xffffffff,param_3);
if ((char)uVar6 != '\0') {
return uVar6;
}
uVar6 = func0(param_1,uVar5 & 0xffffffff,param_3 - iVar3);
if ((char)uVar6 != '\0') {
return uVar6;
}
break;
}
}
LAB_00101357:
uVar6 = func0(param_1,uVar10,param_3 - iVar2);
if ((char)uVar6 != '\0') {
return uVar6;
}
LAB_00101370:
param_3 = param_3 - iVar1;
if (param_3 == 0) {
return 1;
}
param_2 = (ulong)(int)(iVar7 - 2U);
while (iVar1 = *(int *)(param_1 + param_2 * 4), param_3 < iVar1) {
param_2 = param_2 - 1;
if (((long)(int)uVar8 + -2) - (ulong)(iVar7 - 2U) == param_2) {
return 0;
}
}
uVar6 = func0(param_1,param_2 & 0xffffffff,param_3);
if ((char)uVar6 != '\0') {
return uVar6;
}
param_3 = param_3 - iVar1;
goto LAB_00101286;
} |
5,820 | func0 |
#include <stdio.h>
#include <regex.h>
#include <assert.h>
| char* func0(char* text) {
regex_t regex;
int result;
char* pattern = "[A-Z]+[a-z]+$";
regcomp(®ex, pattern, REG_EXTENDED);
result = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if(result == 0) {
return "Yes";
} else {
return "No";
}
}
| int main() {
assert(func0("Geeks") == "Yes");
assert(func0("geeksforGeeks") == "Yes");
assert(func0("geeks") == "No");
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 0xe19(%rip),%rax
mov %rax,-0x58(%rbp)
mov -0x58(%rbp),%rcx
lea -0x50(%rbp),%rax
mov $0x1,%edx
mov %rcx,%rsi
mov %rax,%rdi
callq 10c0 <regcomp@plt>
mov -0x68(%rbp),%rsi
lea -0x50(%rbp),%rax
mov $0x0,%r8d
mov $0x0,%ecx
mov $0x0,%edx
mov %rax,%rdi
callq 10d0 <regexec@plt>
mov %eax,-0x5c(%rbp)
lea -0x50(%rbp),%rax
mov %rax,%rdi
callq 1090 <regfree@plt>
cmpl $0x0,-0x5c(%rbp)
jne 1249 <func0+0x80>
lea 0xdcf(%rip),%rax
jmp 1250 <func0+0x87>
lea 0xdca(%rip),%rax
mov -0x8(%rbp),%rdx
xor %fs:0x28,%rdx
je 1264 <func0+0x9b>
callq 10a0 <__stack_chk_fail@plt>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 70h
mov [rbp+string], rdi
mov rax, fs:28h
mov [rbp+var_8], rax
xor eax, eax
lea rax, aAZAZ; "[A-Z]+[a-z]+$"
mov [rbp+pattern], rax
mov rcx, [rbp+pattern]
lea rax, [rbp+preg]
mov edx, 1; cflags
mov rsi, rcx; pattern
mov rdi, rax; preg
call _regcomp
mov rsi, [rbp+string]; string
lea rax, [rbp+preg]
mov r8d, 0; eflags
mov ecx, 0; pmatch
mov edx, 0; nmatch
mov rdi, rax; preg
call _regexec
mov [rbp+var_5C], eax
lea rax, [rbp+preg]
mov rdi, rax; preg
call _regfree
cmp [rbp+var_5C], 0
jnz short loc_1249
lea rax, aYes; "Yes"
jmp short loc_1250
loc_1249:
lea rax, aNo; "No"
loc_1250:
mov rdx, [rbp+var_8]
sub rdx, fs:28h
jz short locret_1264
call ___stack_chk_fail
locret_1264:
leave
retn | const char * func0(const char *a1)
{
int v2; // [rsp+14h] [rbp-5Ch]
regex_t preg; // [rsp+20h] [rbp-50h] BYREF
unsigned long long v4; // [rsp+68h] [rbp-8h]
v4 = __readfsqword(0x28u);
regcomp(&preg, "[A-Z]+[a-z]+$", 1);
v2 = regexec(&preg, a1, 0LL, 0LL, 0);
regfree(&preg);
if ( v2 )
return "No";
else
return "Yes";
} | 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 0x001010c0
MOV RSI,qword ptr [RBP + -0x68]
LEA RAX,[RBP + -0x50]
MOV R8D,0x0
MOV ECX,0x0
MOV EDX,0x0
MOV RDI,RAX
CALL 0x001010d0
MOV dword ptr [RBP + -0x5c],EAX
LEA RAX,[RBP + -0x50]
MOV RDI,RAX
CALL 0x00101090
CMP dword ptr [RBP + -0x5c],0x0
JNZ 0x00101249
LEA RAX,[0x102016]
JMP 0x00101250
LAB_00101249:
LEA RAX,[0x10201a]
LAB_00101250:
MOV RDX,qword ptr [RBP + -0x8]
SUB RDX,qword ptr FS:[0x28]
JZ 0x00101264
CALL 0x001010a0
LAB_00101264:
LEAVE
RET | int * func0(char *param_1)
{
int iVar1;
int *puVar2;
long in_FS_OFFSET;
regex_t local_58;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
regcomp(&local_58,"[A-Z]+[a-z]+$",1);
iVar1 = regexec(&local_58,param_1,0,(regmatch_t *)0x0,0);
regfree(&local_58);
if (iVar1 == 0) {
puVar2 = &DAT_00102016;
}
else {
puVar2 = &DAT_0010201a;
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return puVar2;
} |
5,821 | func0 |
#include <stdio.h>
#include <regex.h>
#include <assert.h>
| char* func0(char* text) {
regex_t regex;
int result;
char* pattern = "[A-Z]+[a-z]+$";
regcomp(®ex, pattern, REG_EXTENDED);
result = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if(result == 0) {
return "Yes";
} else {
return "No";
}
}
| int main() {
assert(func0("Geeks") == "Yes");
assert(func0("geeksforGeeks") == "Yes");
assert(func0("geeks") == "No");
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x58,%rsp
mov %rdi,%rbx
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%rbp
mov $0x1,%edx
lea 0xe16(%rip),%rsi
mov %rbp,%rdi
callq 10c0 <regcomp@plt>
mov $0x0,%r8d
mov $0x0,%ecx
mov $0x0,%edx
mov %rbx,%rsi
mov %rbp,%rdi
callq 10d0 <regexec@plt>
mov %eax,%ebx
mov %rbp,%rdi
callq 1090 <regfree@plt>
test %ebx,%ebx
lea 0xdd9(%rip),%rax
lea 0xdd6(%rip),%rdx
cmovne %rdx,%rax
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 124d <func0+0x84>
add $0x58,%rsp
pop %rbx
pop %rbp
retq
callq 10a0 <__stack_chk_fail@plt>
| func0:
endbr64
push rbp
push rbx
sub rsp, 58h
mov rbx, rdi
mov rax, fs:28h
mov [rsp+var_s48], rax
xor eax, eax
mov rbp, rsp
mov edx, 1
lea rsi, aAZAZ; "[A-Z]+[a-z]+$"
mov rdi, rbp
call _regcomp
mov r8d, 0
mov ecx, 0
mov edx, 0
mov rsi, rbx
mov rdi, rbp
call _regexec
mov ebx, eax
mov rdi, rbp
call _regfree
test ebx, ebx
lea rax, unk_2004
lea rdx, unk_2008
cmovnz rax, rdx
mov rdx, [rsp+var_s48]
sub rdx, fs:28h
jnz short loc_124D
add rsp, 58h
pop rbx
pop rbp
retn
loc_124D:
call ___stack_chk_fail | void * func0(long long a1)
{
int v1; // ebx
void *result; // rax
_QWORD _0[13]; // [rsp+0h] [rbp+0h] BYREF
_0[9] = __readfsqword(0x28u);
regcomp(_0, "[A-Z]+[a-z]+$", 1LL);
v1 = regexec(_0, a1, 0LL, 0LL, 0LL);
regfree(_0);
result = &unk_2004;
if ( v1 )
return &unk_2008;
return result;
} | func0:
ENDBR64
PUSH RBP
PUSH RBX
SUB RSP,0x58
MOV RBX,RDI
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
MOV RBP,RSP
MOV EDX,0x1
LEA RSI,[0x10200b]
MOV RDI,RBP
CALL 0x001010c0
MOV R8D,0x0
MOV ECX,0x0
MOV EDX,0x0
MOV RSI,RBX
MOV RDI,RBP
CALL 0x001010d0
MOV EBX,EAX
MOV RDI,RBP
CALL 0x00101090
TEST EBX,EBX
LEA RAX,[0x102004]
LEA RDX,[0x102008]
CMOVNZ RAX,RDX
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x0010124d
ADD RSP,0x58
POP RBX
POP RBP
RET
LAB_0010124d:
CALL 0x001010a0 | int * func0(char *param_1)
{
int iVar1;
int *puVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
regcomp(&rStack_68,"[A-Z]+[a-z]+$",1);
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
puVar2 = &DAT_00102004;
if (iVar1 != 0) {
puVar2 = &DAT_00102008;
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return puVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,822 | func0 |
#include <stdio.h>
#include <regex.h>
#include <assert.h>
| char* func0(char* text) {
regex_t regex;
int result;
char* pattern = "[A-Z]+[a-z]+$";
regcomp(®ex, pattern, REG_EXTENDED);
result = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if(result == 0) {
return "Yes";
} else {
return "No";
}
}
| int main() {
assert(func0("Geeks") == "Yes");
assert(func0("geeksforGeeks") == "Yes");
assert(func0("geeks") == "No");
return 0;
}
| O2 | c | func0:
endbr64
push %r12
mov $0x1,%edx
mov %rdi,%r12
lea 0xd76(%rip),%rsi
push %rbp
push %rbx
sub $0x50,%rsp
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%rbp
mov %rbp,%rdi
callq 10c0 <regcomp@plt>
xor %ecx,%ecx
xor %edx,%edx
xor %r8d,%r8d
mov %r12,%rsi
mov %rbp,%rdi
callq 10d0 <regexec@plt>
mov %rbp,%rdi
mov %eax,%ebx
callq 1090 <regfree@plt>
test %ebx,%ebx
lea 0xd29(%rip),%rax
lea 0xd26(%rip),%rdx
cmovne %rdx,%rax
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 12ff <func0+0x7f>
add $0x50,%rsp
pop %rbx
pop %rbp
pop %r12
retq
callq 10a0 <__stack_chk_fail@plt>
nopw %cs:0x0(%rax,%rax,1)
xchg %ax,%ax
| func0:
endbr64
push r12
mov edx, 1
mov r12, rdi
lea rsi, aAZAZ; "[A-Z]+[a-z]+$"
push rbp
push rbx
sub rsp, 50h
mov rax, fs:28h
mov [rsp+var_s48], rax
xor eax, eax
mov rbp, rsp
mov rdi, rbp
call _regcomp
xor edx, edx
xor r8d, r8d
xor ecx, ecx
mov rsi, r12
mov rdi, rbp
call _regexec
mov rdi, rbp
mov ebx, eax
call _regfree
test ebx, ebx
lea rax, unk_2004
lea rdx, unk_2008
cmovnz rax, rdx
mov rdx, [rsp+var_s48]
sub rdx, fs:28h
jnz short loc_12FF
add rsp, 50h
pop rbx
pop rbp
pop r12
retn
loc_12FF:
call ___stack_chk_fail | void * func0(long long a1)
{
int v1; // ebx
void *result; // rax
_QWORD _0[13]; // [rsp+0h] [rbp+0h] BYREF
_0[9] = __readfsqword(0x28u);
regcomp(_0, "[A-Z]+[a-z]+$", 1LL);
v1 = regexec(_0, a1, 0LL, 0LL, 0LL);
regfree(_0);
result = &unk_2004;
if ( v1 )
return &unk_2008;
return result;
} | func0:
ENDBR64
PUSH R12
MOV EDX,0x1
MOV R12,RDI
LEA RSI,[0x10200b]
PUSH RBP
PUSH RBX
SUB RSP,0x50
MOV RAX,qword ptr FS:[0x28]
MOV qword ptr [RSP + 0x48],RAX
XOR EAX,EAX
MOV RBP,RSP
MOV RDI,RBP
CALL 0x001010c0
XOR EDX,EDX
XOR R8D,R8D
XOR ECX,ECX
MOV RSI,R12
MOV RDI,RBP
CALL 0x001010d0
MOV RDI,RBP
MOV EBX,EAX
CALL 0x00101090
TEST EBX,EBX
LEA RAX,[0x102004]
LEA RDX,[0x102008]
CMOVNZ RAX,RDX
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x001012ff
ADD RSP,0x50
POP RBX
POP RBP
POP R12
RET
LAB_001012ff:
CALL 0x001010a0 | int * func0(char *param_1)
{
int iVar1;
int *puVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
regcomp(&rStack_68,"[A-Z]+[a-z]+$",1);
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
puVar2 = &DAT_00102004;
if (iVar1 != 0) {
puVar2 = &DAT_00102008;
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return puVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,823 | func0 |
#include <stdio.h>
#include <regex.h>
#include <assert.h>
| char* func0(char* text) {
regex_t regex;
int result;
char* pattern = "[A-Z]+[a-z]+$";
regcomp(®ex, pattern, REG_EXTENDED);
result = regexec(®ex, text, 0, NULL, 0);
regfree(®ex);
if(result == 0) {
return "Yes";
} else {
return "No";
}
}
| int main() {
assert(func0("Geeks") == "Yes");
assert(func0("geeksforGeeks") == "Yes");
assert(func0("geeks") == "No");
return 0;
}
| O3 | c | func0:
endbr64
push %r12
mov $0x1,%edx
mov %rdi,%r12
lea 0xd76(%rip),%rsi
push %rbp
push %rbx
sub $0x50,%rsp
mov %fs:0x28,%rax
mov %rax,0x48(%rsp)
xor %eax,%eax
mov %rsp,%rbp
mov %rbp,%rdi
callq 10c0 <regcomp@plt>
xor %ecx,%ecx
xor %edx,%edx
xor %r8d,%r8d
mov %r12,%rsi
mov %rbp,%rdi
callq 10d0 <regexec@plt>
mov %rbp,%rdi
mov %eax,%ebx
callq 1090 <regfree@plt>
test %ebx,%ebx
lea 0xd29(%rip),%rax
lea 0xd26(%rip),%rdx
cmovne %rdx,%rax
mov 0x48(%rsp),%rcx
xor %fs:0x28,%rcx
jne 12ff <func0+0x7f>
add $0x50,%rsp
pop %rbx
pop %rbp
pop %r12
retq
callq 10a0 <__stack_chk_fail@plt>
nopw %cs:0x0(%rax,%rax,1)
xchg %ax,%ax
| func0:
endbr64
push rbp
mov edx, 1; cflags
lea rsi, pattern; "[A-Z]+[a-z]+$"
push rbx
mov rbx, rdi
sub rsp, 58h
mov rax, fs:28h
mov [rsp+var_s48], rax
xor eax, eax
mov rbp, rsp
mov rdi, rbp; preg
call _regcomp
xor edx, edx; nmatch
xor r8d, r8d; eflags
xor ecx, ecx; pmatch
mov rsi, rbx; string
mov rdi, rbp; preg
call _regexec
mov rdi, rbp; preg
mov ebx, eax
call _regfree
test ebx, ebx
lea rax, unk_2008
lea rdx, unk_2004
cmovz rax, rdx
mov rdx, [rsp+var_s48]
sub rdx, fs:28h
jnz short loc_12FB
add rsp, 58h
pop rbx
pop rbp
retn
loc_12FB:
call ___stack_chk_fail | void * func0(char *string)
{
int v1; // ebx
void *result; // rax
regex_t _0; // [rsp+0h] [rbp+0h] BYREF
unsigned long long vars48; // [rsp+48h] [rbp+48h]
vars48 = __readfsqword(0x28u);
regcomp(&_0, "[A-Z]+[a-z]+$", 1);
v1 = regexec(&_0, string, 0LL, 0LL, 0);
regfree(&_0);
result = &unk_2008;
if ( !v1 )
return &unk_2004;
return result;
} | func0:
ENDBR64
PUSH RBP
MOV EDX,0x1
LEA RSI,[0x10200b]
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 0x001010c0
XOR EDX,EDX
XOR R8D,R8D
XOR ECX,ECX
MOV RSI,RBX
MOV RDI,RBP
CALL 0x001010d0
MOV RDI,RBP
MOV EBX,EAX
CALL 0x00101090
TEST EBX,EBX
LEA RAX,[0x102008]
LEA RDX,[0x102004]
CMOVZ RAX,RDX
MOV RDX,qword ptr [RSP + 0x48]
SUB RDX,qword ptr FS:[0x28]
JNZ 0x001012fb
ADD RSP,0x58
POP RBX
POP RBP
RET
LAB_001012fb:
CALL 0x001010a0 | int * func0(char *param_1)
{
int iVar1;
int *puVar2;
long in_FS_OFFSET;
regex_t rStack_68;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
regcomp(&rStack_68,"[A-Z]+[a-z]+$",1);
iVar1 = regexec(&rStack_68,param_1,0,(regmatch_t *)0x0,0);
regfree(&rStack_68);
puVar2 = &DAT_00102008;
if (iVar1 == 0) {
puVar2 = &DAT_00102004;
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return puVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
} |
5,824 | func0 |
#include <assert.h>
| int func0(int x) {
int i = 1;
int fact = 1;
for (i = 1; i < x; i++) {
fact = fact * i;
if (fact % x == 0) {
return i;
}
}
return i - 1;
}
| int main() {
assert(func0(10) == 5);
assert(func0(15) == 5);
assert(func0(5) == 4);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x14(%rbp)
movl $0x1,-0x8(%rbp)
movl $0x1,-0x4(%rbp)
movl $0x1,-0x8(%rbp)
jmp 118b <func0+0x42>
mov -0x4(%rbp),%eax
imul -0x8(%rbp),%eax
mov %eax,-0x4(%rbp)
mov -0x4(%rbp),%eax
cltd
idivl -0x14(%rbp)
mov %edx,%eax
test %eax,%eax
jne 1187 <func0+0x3e>
mov -0x8(%rbp),%eax
jmp 1199 <func0+0x50>
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
cmp -0x14(%rbp),%eax
jl 116b <func0+0x22>
mov -0x8(%rbp),%eax
sub $0x1,%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_14], edi
mov [rbp+var_8], 1
mov [rbp+var_4], 1
mov [rbp+var_8], 1
jmp short loc_118B
loc_116B:
mov eax, [rbp+var_4]
imul eax, [rbp+var_8]
mov [rbp+var_4], eax
mov eax, [rbp+var_4]
cdq
idiv [rbp+var_14]
mov eax, edx
test eax, eax
jnz short loc_1187
mov eax, [rbp+var_8]
jmp short loc_1199
loc_1187:
add [rbp+var_8], 1
loc_118B:
mov eax, [rbp+var_8]
cmp eax, [rbp+var_14]
jl short loc_116B
mov eax, [rbp+var_8]
sub eax, 1
loc_1199:
pop rbp
retn | long long func0(int a1)
{
int i; // [rsp+Ch] [rbp-8h]
int v3; // [rsp+10h] [rbp-4h]
v3 = 1;
for ( i = 1; i < a1; ++i )
{
v3 *= i;
if ( !(v3 % a1) )
return (unsigned int)i;
}
return (unsigned int)(i - 1);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x14],EDI
MOV dword ptr [RBP + -0x8],0x1
MOV dword ptr [RBP + -0x4],0x1
MOV dword ptr [RBP + -0x8],0x1
JMP 0x0010118b
LAB_0010116b:
MOV EAX,dword ptr [RBP + -0x4]
IMUL EAX,dword ptr [RBP + -0x8]
MOV dword ptr [RBP + -0x4],EAX
MOV EAX,dword ptr [RBP + -0x4]
CDQ
IDIV dword ptr [RBP + -0x14]
MOV EAX,EDX
TEST EAX,EAX
JNZ 0x00101187
MOV EAX,dword ptr [RBP + -0x8]
JMP 0x00101199
LAB_00101187:
ADD dword ptr [RBP + -0x8],0x1
LAB_0010118b:
MOV EAX,dword ptr [RBP + -0x8]
CMP EAX,dword ptr [RBP + -0x14]
JL 0x0010116b
MOV EAX,dword ptr [RBP + -0x8]
SUB EAX,0x1
LAB_00101199:
POP RBP
RET | int func0(int param_1)
{
int local_10;
int local_c;
local_c = 1;
local_10 = 1;
while( true ) {
if (param_1 <= local_10) {
return local_10 + -1;
}
local_c = local_c * local_10;
if (local_c % param_1 == 0) break;
local_10 = local_10 + 1;
}
return local_10;
} |
5,825 | func0 |
#include <assert.h>
| int func0(int x) {
int i = 1;
int fact = 1;
for (i = 1; i < x; i++) {
fact = fact * i;
if (fact % x == 0) {
return i;
}
}
return i - 1;
}
| int main() {
assert(func0(10) == 5);
assert(func0(15) == 5);
assert(func0(5) == 4);
return 0;
}
| O1 | c | func0:
endbr64
cmp $0x1,%edi
jle 1177 <func0+0x2e>
mov $0x1,%eax
cltd
idiv %edi
mov %edx,%esi
test %edx,%edx
je 1182 <func0+0x39>
mov %edx,%ecx
add $0x1,%esi
cmp %esi,%edi
je 117c <func0+0x33>
imul %esi,%ecx
mov %ecx,%eax
cltd
idiv %edi
test %edx,%edx
jne 1162 <func0+0x19>
jmp 117f <func0+0x36>
mov $0x1,%esi
sub $0x1,%esi
mov %esi,%eax
retq
mov $0x1,%esi
jmp 117f <func0+0x36>
| func0:
endbr64
cmp edi, 1
jle short loc_1177
mov eax, 1
cdq
idiv edi
mov esi, edx
test edx, edx
jz short loc_1182
mov ecx, edx
loc_1162:
add esi, 1
cmp edi, esi
jz short loc_117C
imul ecx, esi
mov eax, ecx
cdq
idiv edi
test edx, edx
jnz short loc_1162
jmp short loc_117F
loc_1177:
mov edi, 1
loc_117C:
lea esi, [rdi-1]
loc_117F:
mov eax, esi
retn
loc_1182:
mov esi, 1
jmp short loc_117F | long long func0(int a1)
{
unsigned int v1; // esi
int v2; // ecx
if ( a1 <= 1 )
{
a1 = 1;
}
else
{
v1 = 1 % a1;
if ( !(1 % a1) )
return 1;
v2 = 1 % a1;
while ( a1 != ++v1 )
{
v2 *= v1;
if ( !(v2 % a1) )
return v1;
}
}
return (unsigned int)(a1 - 1);
} | func0:
ENDBR64
CMP EDI,0x1
JLE 0x00101177
MOV EAX,0x1
CDQ
IDIV EDI
MOV ESI,EDX
TEST EDX,EDX
JZ 0x00101182
MOV ECX,EDX
LAB_00101162:
ADD ESI,0x1
CMP EDI,ESI
JZ 0x0010117c
IMUL ECX,ESI
MOV EAX,ECX
CDQ
IDIV EDI
TEST EDX,EDX
JNZ 0x00101162
JMP 0x0010117f
LAB_00101177:
MOV EDI,0x1
LAB_0010117c:
LEA ESI,[RDI + -0x1]
LAB_0010117f:
MOV EAX,ESI
RET
LAB_00101182:
MOV ESI,0x1
JMP 0x0010117f | ulong func0(uint param_1)
{
ulong uVar1;
uint uVar2;
ulong uVar3;
if ((int)param_1 < 2) {
param_1 = 1;
LAB_0010117c:
uVar3 = (ulong)(param_1 - 1);
}
else {
uVar1 = 1 % (long)(int)param_1;
uVar3 = uVar1 & 0xffffffff;
if ((int)uVar1 == 0) {
uVar3 = 1;
}
else {
uVar1 = uVar1 & 0xffffffff;
do {
uVar2 = (int)uVar3 + 1;
uVar3 = (ulong)uVar2;
if (param_1 == uVar2) goto LAB_0010117c;
uVar2 = (int)uVar1 * uVar2;
uVar1 = (ulong)uVar2;
} while ((int)uVar2 % (int)param_1 != 0);
}
}
return uVar3;
} |
5,826 | func0 |
#include <assert.h>
| int func0(int x) {
int i = 1;
int fact = 1;
for (i = 1; i < x; i++) {
fact = fact * i;
if (fact % x == 0) {
return i;
}
}
return i - 1;
}
| int main() {
assert(func0(10) == 5);
assert(func0(15) == 5);
assert(func0(5) == 4);
return 0;
}
| O2 | c | func0:
endbr64
mov $0x1,%ecx
mov $0x1,%r8d
xor %eax,%eax
cmp $0x1,%edi
jg 123d <func0+0x2d>
jmp 1249 <func0+0x39>
nopl 0x0(%rax,%rax,1)
imul %r8d,%ecx
mov %ecx,%eax
cltd
idiv %edi
test %edx,%edx
je 124c <func0+0x3c>
mov %r8d,%eax
add $0x1,%r8d
cmp %r8d,%edi
jne 1230 <func0+0x20>
mov %eax,%r8d
mov %r8d,%eax
retq
| func0:
endbr64
mov ecx, 1
mov r8d, 1
xor eax, eax
cmp edi, 1
jg short loc_123D
jmp short loc_1249
loc_1230:
imul ecx, r8d
mov eax, ecx
cdq
idiv edi
test edx, edx
jz short loc_124C
loc_123D:
mov eax, r8d
add r8d, 1
cmp edi, r8d
jnz short loc_1230
loc_1249:
mov r8d, eax
loc_124C:
mov eax, r8d
retn | long long func0(int a1)
{
int v1; // ecx
unsigned int v2; // r8d
unsigned int v3; // eax
v1 = 1;
v2 = 1;
v3 = 0;
if ( a1 > 1 )
{
while ( 1 )
{
v3 = v2++;
if ( a1 == v2 )
break;
v1 *= v2;
if ( !(v1 % a1) )
return v2;
}
}
return v3;
} | func0:
ENDBR64
MOV ECX,0x1
MOV R8D,0x1
XOR EAX,EAX
CMP EDI,0x1
JG 0x0010123d
JMP 0x00101249
LAB_00101230:
IMUL ECX,R8D
MOV EAX,ECX
CDQ
IDIV EDI
TEST EDX,EDX
JZ 0x0010124c
LAB_0010123d:
MOV EAX,R8D
ADD R8D,0x1
CMP EDI,R8D
JNZ 0x00101230
LAB_00101249:
MOV R8D,EAX
LAB_0010124c:
MOV EAX,R8D
RET | int func0(int param_1)
{
int iVar1;
int iVar2;
int iVar3;
iVar1 = 1;
iVar3 = 0;
iVar2 = 1;
if (1 < param_1) {
do {
iVar3 = iVar2 + 1;
if (param_1 == iVar3) {
return iVar2;
}
iVar1 = iVar1 * iVar3;
iVar2 = iVar3;
} while (iVar1 % param_1 != 0);
}
return iVar3;
} |
5,827 | func0 |
#include <assert.h>
| int func0(int x) {
int i = 1;
int fact = 1;
for (i = 1; i < x; i++) {
fact = fact * i;
if (fact % x == 0) {
return i;
}
}
return i - 1;
}
| int main() {
assert(func0(10) == 5);
assert(func0(15) == 5);
assert(func0(5) == 4);
return 0;
}
| O3 | c | func0:
endbr64
mov $0x1,%ecx
mov $0x1,%r8d
xor %eax,%eax
cmp $0x1,%edi
jg 116d <func0+0x2d>
jmp 1179 <func0+0x39>
nopl 0x0(%rax,%rax,1)
imul %r8d,%ecx
mov %ecx,%eax
cltd
idiv %edi
test %edx,%edx
je 117c <func0+0x3c>
mov %r8d,%eax
add $0x1,%r8d
cmp %r8d,%edi
jne 1160 <func0+0x20>
mov %eax,%r8d
mov %r8d,%eax
retq
| func0:
endbr64
mov esi, 1
mov ecx, 1
xor eax, eax
cmp edi, 1
jg short loc_116C
jmp short loc_1175
loc_1160:
imul esi, ecx
mov eax, esi
cdq
idiv edi
test edx, edx
jz short loc_1177
loc_116C:
mov eax, ecx
add ecx, 1
cmp edi, ecx
jnz short loc_1160
loc_1175:
mov ecx, eax
loc_1177:
mov eax, ecx
retn | long long func0(int a1)
{
int v1; // esi
unsigned int v2; // ecx
unsigned int v3; // eax
v1 = 1;
v2 = 1;
v3 = 0;
if ( a1 > 1 )
{
while ( 1 )
{
v3 = v2++;
if ( a1 == v2 )
break;
v1 *= v2;
if ( !(v1 % a1) )
return v2;
}
}
return v3;
} | func0:
ENDBR64
MOV ESI,0x1
MOV ECX,0x1
XOR EAX,EAX
CMP EDI,0x1
JG 0x0010116c
JMP 0x00101175
LAB_00101160:
IMUL ESI,ECX
MOV EAX,ESI
CDQ
IDIV EDI
TEST EDX,EDX
JZ 0x00101177
LAB_0010116c:
MOV EAX,ECX
ADD ECX,0x1
CMP EDI,ECX
JNZ 0x00101160
LAB_00101175:
MOV ECX,EAX
LAB_00101177:
MOV EAX,ECX
RET | int func0(int param_1)
{
int iVar1;
int iVar2;
int iVar3;
iVar3 = 1;
iVar2 = 0;
iVar1 = 1;
if (1 < param_1) {
do {
iVar2 = iVar1 + 1;
if (param_1 == iVar2) {
return iVar1;
}
iVar3 = iVar3 * iVar2;
iVar1 = iVar2;
} while (iVar3 % param_1 != 0);
}
return iVar2;
} |
5,828 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
char* first;
char* second;
} Tuple;
| Tuple* func0(Tuple* test_list1, int size1, Tuple* test_list2, int size2, int* res_size) {
Tuple* res = malloc(size1 * sizeof(Tuple));
int count = 0;
for(int i = 0; i < size1; i++) {
int found = 0;
for(int j = 0; j < size2; j++) {
if(strcmp(test_list1[i].first, test_list2[j].first) == 0 &&
strcmp(test_list1[i].second, test_list2[j].second) == 0) {
found = 1;
break;
}
}
if(!found) {
res[count++] = test_list1[i];
}
}
*res_size = count;
return res;
}
| int main(){
// Test case 1
Tuple test1_1[] = { {"Hello", "dude"}, {"How", "are"}, {"you", "?"} };
Tuple test2_1[] = { {"Hello", "dude"}, {"How", "are"} };
int res_size1;
Tuple* res1 = func0(test1_1, 3, test2_1, 2, &res_size1);
Tuple expected1[] = { {"you", "?"} };
assert(res_size1 == 1);
assert(strcmp(res1[0].first, expected1[0].first) == 0);
assert(strcmp(res1[0].second, expected1[0].second) == 0);
free(res1);
// Test case 2
Tuple test1_2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
Tuple test2_2[] = { {"Journey", "the"}, {"is", "end"} };
int res_size2;
Tuple* res2 = func0(test1_2, 3, test2_2, 2, &res_size2);
Tuple expected2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
assert(res_size2 == 3);
for(int i = 0; i < res_size2; i++) {
assert(strcmp(res2[i].first, expected2[i].first) == 0);
assert(strcmp(res2[i].second, expected2[i].second) == 0);
}
free(res2);
// Test case 3
Tuple test1_3[] = { {"Its", "been"}, {"a", "long"}, {"day", "without"} };
Tuple test2_3[] = { {"a", "long"}, {"my", "friend"} };
int res_size3;
Tuple* res3 = func0(test1_3, 3, test2_3, 2, &res_size3);
Tuple expected3[] = { {"Its", "been"}, {"day", "without"} };
assert(res_size3 == 2);
for(int i = 0; i < res_size3; i++) {
assert(strcmp(res3[i].first, expected3[i].first) == 0);
assert(strcmp(res3[i].second, expected3[i].second) == 0);
}
free(res3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x40,%rsp
mov %rdi,-0x28(%rbp)
mov %esi,-0x2c(%rbp)
mov %rdx,-0x38(%rbp)
mov %ecx,-0x30(%rbp)
mov %r8,-0x40(%rbp)
mov -0x2c(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rdi
callq 10d0 <malloc@plt>
mov %rax,-0x8(%rbp)
movl $0x0,-0x18(%rbp)
movl $0x0,-0x14(%rbp)
jmpq 12f9 <func0+0x130>
movl $0x0,-0x10(%rbp)
movl $0x0,-0xc(%rbp)
jmpq 12a7 <func0+0xde>
mov -0xc(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rdx
mov -0x38(%rbp),%rax
add %rdx,%rax
mov (%rax),%rdx
mov -0x14(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rcx
mov -0x28(%rbp),%rax
add %rcx,%rax
mov (%rax),%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 12a3 <func0+0xda>
mov -0xc(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rdx
mov -0x38(%rbp),%rax
add %rdx,%rax
mov 0x8(%rax),%rdx
mov -0x14(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rcx
mov -0x28(%rbp),%rax
add %rcx,%rax
mov 0x8(%rax),%rax
mov %rdx,%rsi
mov %rax,%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 12a3 <func0+0xda>
movl $0x1,-0x10(%rbp)
jmp 12b3 <func0+0xea>
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x30(%rbp),%eax
jl 1222 <func0+0x59>
cmpl $0x0,-0x10(%rbp)
jne 12f5 <func0+0x12c>
mov -0x14(%rbp),%eax
cltq
shl $0x4,%rax
mov %rax,%rdx
mov -0x28(%rbp),%rax
lea (%rdx,%rax,1),%rsi
mov -0x18(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x18(%rbp)
cltq
shl $0x4,%rax
mov %rax,%rdx
mov -0x8(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov (%rsi),%rax
mov 0x8(%rsi),%rdx
mov %rax,(%rcx)
mov %rdx,0x8(%rcx)
addl $0x1,-0x14(%rbp)
mov -0x14(%rbp),%eax
cmp -0x2c(%rbp),%eax
jl 120f <func0+0x46>
mov -0x40(%rbp),%rax
mov -0x18(%rbp),%edx
mov %edx,(%rax)
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 40h
mov [rbp+var_28], rdi
mov [rbp+var_2C], esi
mov [rbp+var_38], rdx
mov [rbp+var_30], ecx
mov [rbp+var_40], r8
mov eax, [rbp+var_2C]
cdqe
shl rax, 4
mov rdi, rax; size
call _malloc
mov [rbp+var_8], rax
mov [rbp+var_18], 0
mov [rbp+var_14], 0
jmp loc_12F9
loc_120F:
mov [rbp+var_10], 0
mov [rbp+var_C], 0
jmp loc_12A7
loc_1222:
mov eax, [rbp+var_C]
cdqe
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_38]
add rax, rdx
mov rdx, [rax]
mov eax, [rbp+var_14]
cdqe
shl rax, 4
mov rcx, rax
mov rax, [rbp+var_28]
add rax, rcx
mov rax, [rax]
mov rsi, rdx; s2
mov rdi, rax; s1
call _strcmp
test eax, eax
jnz short loc_12A3
mov eax, [rbp+var_C]
cdqe
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_38]
add rax, rdx
mov rdx, [rax+8]
mov eax, [rbp+var_14]
cdqe
shl rax, 4
mov rcx, rax
mov rax, [rbp+var_28]
add rax, rcx
mov rax, [rax+8]
mov rsi, rdx; s2
mov rdi, rax; s1
call _strcmp
test eax, eax
jnz short loc_12A3
mov [rbp+var_10], 1
jmp short loc_12B3
loc_12A3:
add [rbp+var_C], 1
loc_12A7:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_30]
jl loc_1222
loc_12B3:
cmp [rbp+var_10], 0
jnz short loc_12F5
mov eax, [rbp+var_14]
cdqe
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_28]
lea rsi, [rdx+rax]
mov eax, [rbp+var_18]
lea edx, [rax+1]
mov [rbp+var_18], edx
cdqe
shl rax, 4
mov rdx, rax
mov rax, [rbp+var_8]
lea rcx, [rdx+rax]
mov rax, [rsi]
mov rdx, [rsi+8]
mov [rcx], rax
mov [rcx+8], rdx
loc_12F5:
add [rbp+var_14], 1
loc_12F9:
mov eax, [rbp+var_14]
cmp eax, [rbp+var_2C]
jl loc_120F
mov rax, [rbp+var_40]
mov edx, [rbp+var_18]
mov [rax], edx
mov rax, [rbp+var_8]
leave
retn | char * func0(long long a1, int a2, long long a3, int a4, _DWORD *a5)
{
_QWORD *v5; // rsi
int v6; // eax
char *v7; // rcx
long long v8; // rdx
int v14; // [rsp+28h] [rbp-18h]
int i; // [rsp+2Ch] [rbp-14h]
int v16; // [rsp+30h] [rbp-10h]
int j; // [rsp+34h] [rbp-Ch]
char *v18; // [rsp+38h] [rbp-8h]
v18 = (char *)malloc(16LL * a2);
v14 = 0;
for ( i = 0; i < a2; ++i )
{
v16 = 0;
for ( j = 0; j < a4; ++j )
{
if ( !strcmp(*(const char **)(16LL * i + a1), *(const char **)(16LL * j + a3))
&& !strcmp(*(const char **)(16LL * i + a1 + 8), *(const char **)(16LL * j + a3 + 8)) )
{
v16 = 1;
break;
}
}
if ( !v16 )
{
v5 = (_QWORD *)(16LL * i + a1);
v6 = v14++;
v7 = &v18[16 * v6];
v8 = v5[1];
*(_QWORD *)v7 = *v5;
*((_QWORD *)v7 + 1) = v8;
}
}
*a5 = v14;
return v18;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x40
MOV qword ptr [RBP + -0x28],RDI
MOV dword ptr [RBP + -0x2c],ESI
MOV qword ptr [RBP + -0x38],RDX
MOV dword ptr [RBP + -0x30],ECX
MOV qword ptr [RBP + -0x40],R8
MOV EAX,dword ptr [RBP + -0x2c]
CDQE
SHL RAX,0x4
MOV RDI,RAX
CALL 0x001010d0
MOV qword ptr [RBP + -0x8],RAX
MOV dword ptr [RBP + -0x18],0x0
MOV dword ptr [RBP + -0x14],0x0
JMP 0x001012f9
LAB_0010120f:
MOV dword ptr [RBP + -0x10],0x0
MOV dword ptr [RBP + -0xc],0x0
JMP 0x001012a7
LAB_00101222:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x38]
ADD RAX,RDX
MOV RDX,qword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x14]
CDQE
SHL RAX,0x4
MOV RCX,RAX
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RCX
MOV RAX,qword ptr [RAX]
MOV RSI,RDX
MOV RDI,RAX
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x001012a3
MOV EAX,dword ptr [RBP + -0xc]
CDQE
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x38]
ADD RAX,RDX
MOV RDX,qword ptr [RAX + 0x8]
MOV EAX,dword ptr [RBP + -0x14]
CDQE
SHL RAX,0x4
MOV RCX,RAX
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RCX
MOV RAX,qword ptr [RAX + 0x8]
MOV RSI,RDX
MOV RDI,RAX
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x001012a3
MOV dword ptr [RBP + -0x10],0x1
JMP 0x001012b3
LAB_001012a3:
ADD dword ptr [RBP + -0xc],0x1
LAB_001012a7:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x30]
JL 0x00101222
LAB_001012b3:
CMP dword ptr [RBP + -0x10],0x0
JNZ 0x001012f5
MOV EAX,dword ptr [RBP + -0x14]
CDQE
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x28]
LEA RSI,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x18]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x18],EDX
CDQE
SHL RAX,0x4
MOV RDX,RAX
MOV RAX,qword ptr [RBP + -0x8]
LEA RCX,[RDX + RAX*0x1]
MOV RAX,qword ptr [RSI]
MOV RDX,qword ptr [RSI + 0x8]
MOV qword ptr [RCX],RAX
MOV qword ptr [RCX + 0x8],RDX
LAB_001012f5:
ADD dword ptr [RBP + -0x14],0x1
LAB_001012f9:
MOV EAX,dword ptr [RBP + -0x14]
CMP EAX,dword ptr [RBP + -0x2c]
JL 0x0010120f
MOV RAX,qword ptr [RBP + -0x40]
MOV EDX,dword ptr [RBP + -0x18]
MOV dword ptr [RAX],EDX
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | void * func0(long param_1,int param_2,long param_3,int param_4,int *param_5)
{
int8 *puVar1;
int8 *puVar2;
int8 uVar3;
bool bVar4;
int iVar5;
void *pvVar6;
int local_20;
int local_1c;
int local_14;
pvVar6 = malloc((long)param_2 << 4);
local_20 = 0;
local_1c = 0;
do {
if (param_2 <= local_1c) {
*param_5 = local_20;
return pvVar6;
}
bVar4 = false;
for (local_14 = 0; local_14 < param_4; local_14 = local_14 + 1) {
iVar5 = strcmp(*(char **)(param_1 + (long)local_1c * 0x10),
*(char **)(param_3 + (long)local_14 * 0x10));
if (iVar5 == 0) {
iVar5 = strcmp(*(char **)(param_1 + (long)local_1c * 0x10 + 8),
*(char **)(param_3 + (long)local_14 * 0x10 + 8));
if (iVar5 == 0) {
bVar4 = true;
break;
}
}
}
if (!bVar4) {
puVar1 = (int8 *)((long)local_1c * 0x10 + param_1);
puVar2 = (int8 *)((long)local_20 * 0x10 + (long)pvVar6);
uVar3 = puVar1[1];
*puVar2 = *puVar1;
puVar2[1] = uVar3;
local_20 = local_20 + 1;
}
local_1c = local_1c + 1;
} while( true );
} |
5,829 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
char* first;
char* second;
} Tuple;
| Tuple* func0(Tuple* test_list1, int size1, Tuple* test_list2, int size2, int* res_size) {
Tuple* res = malloc(size1 * sizeof(Tuple));
int count = 0;
for(int i = 0; i < size1; i++) {
int found = 0;
for(int j = 0; j < size2; j++) {
if(strcmp(test_list1[i].first, test_list2[j].first) == 0 &&
strcmp(test_list1[i].second, test_list2[j].second) == 0) {
found = 1;
break;
}
}
if(!found) {
res[count++] = test_list1[i];
}
}
*res_size = count;
return res;
}
| int main(){
// Test case 1
Tuple test1_1[] = { {"Hello", "dude"}, {"How", "are"}, {"you", "?"} };
Tuple test2_1[] = { {"Hello", "dude"}, {"How", "are"} };
int res_size1;
Tuple* res1 = func0(test1_1, 3, test2_1, 2, &res_size1);
Tuple expected1[] = { {"you", "?"} };
assert(res_size1 == 1);
assert(strcmp(res1[0].first, expected1[0].first) == 0);
assert(strcmp(res1[0].second, expected1[0].second) == 0);
free(res1);
// Test case 2
Tuple test1_2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
Tuple test2_2[] = { {"Journey", "the"}, {"is", "end"} };
int res_size2;
Tuple* res2 = func0(test1_2, 3, test2_2, 2, &res_size2);
Tuple expected2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
assert(res_size2 == 3);
for(int i = 0; i < res_size2; i++) {
assert(strcmp(res2[i].first, expected2[i].first) == 0);
assert(strcmp(res2[i].second, expected2[i].second) == 0);
}
free(res2);
// Test case 3
Tuple test1_3[] = { {"Its", "been"}, {"a", "long"}, {"day", "without"} };
Tuple test2_3[] = { {"a", "long"}, {"my", "friend"} };
int res_size3;
Tuple* res3 = func0(test1_3, 3, test2_3, 2, &res_size3);
Tuple expected3[] = { {"Its", "been"}, {"day", "without"} };
assert(res_size3 == 2);
for(int i = 0; i < res_size3; i++) {
assert(strcmp(res3[i].first, expected3[i].first) == 0);
assert(strcmp(res3[i].second, expected3[i].second) == 0);
}
free(res3);
return 0;
}
| O1 | c | func0:
endbr64
push %r15
push %r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x38,%rsp
mov %rdi,%r12
mov %esi,%ebp
mov %rdx,%rbx
mov %ecx,%r15d
mov %ecx,0xc(%rsp)
mov %r8,0x28(%rsp)
movslq %esi,%rdi
shl $0x4,%rdi
callq 10d0 <malloc@plt>
mov %rax,0x20(%rsp)
test %ebp,%ebp
jle 125d <func0+0x94>
mov %r12,%r14
lea -0x1(%rbp),%eax
shl $0x4,%rax
lea 0x10(%r12,%rax,1),%rax
mov %rax,0x10(%rsp)
mov %rbx,0x18(%rsp)
lea -0x1(%r15),%eax
shl $0x4,%rax
lea 0x10(%rbx,%rax,1),%r12
mov $0x0,%r15d
jmp 12a3 <func0+0xda>
add $0x10,%rbx
cmp %r12,%rbx
je 127f <func0+0xb6>
mov (%rbx),%rsi
mov %rbp,%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 1232 <func0+0x69>
mov 0x8(%rbx),%rsi
mov 0x8(%r13),%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 1232 <func0+0x69>
jmp 1298 <func0+0xcf>
mov $0x0,%r15d
mov 0x28(%rsp),%rax
mov %r15d,(%rax)
mov 0x20(%rsp),%rax
add $0x38,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
movslq %r15d,%rax
shl $0x4,%rax
mov 0x20(%rsp),%rdx
movdqu (%r14),%xmm0
movups %xmm0,(%rdx,%rax,1)
lea 0x1(%r15),%r15d
add $0x10,%r14
cmp 0x10(%rsp),%r14
je 1263 <func0+0x9a>
cmpl $0x0,0xc(%rsp)
jle 127f <func0+0xb6>
mov %r14,%r13
mov (%r14),%rbp
mov 0x18(%rsp),%rbx
jmp 123b <func0+0x72>
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 38h
mov rbp, rdi
mov ebx, esi
mov r13, rdx
mov [rsp+68h+var_50], rdx
mov r15d, ecx
mov [rsp+68h+var_5C], ecx
mov [rsp+68h+var_40], r8
movsxd rdi, esi
shl rdi, 4
call _malloc
mov [rsp+68h+var_48], rax
test ebx, ebx
jle short loc_125D
mov r14, rbp
lea eax, [rbx-1]
shl rax, 4
lea rax, [rbp+rax+10h]
mov [rsp+68h+var_58], rax
lea eax, [r15-1]
shl rax, 4
lea r12, [r13+rax+10h]
mov r15d, 0
jmp short loc_12A3
loc_1232:
add rbx, 10h
cmp rbx, r12
jz short loc_127F
loc_123B:
mov rsi, [rbx]
mov rdi, rbp
call _strcmp
test eax, eax
jnz short loc_1232
mov rsi, [rbx+8]
mov rdi, [r13+8]
call _strcmp
test eax, eax
jnz short loc_1232
jmp short loc_1298
loc_125D:
mov r15d, 0
loc_1263:
mov rax, [rsp+68h+var_40]
mov [rax], r15d
mov rax, [rsp+68h+var_48]
add rsp, 38h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_127F:
movsxd rax, r15d
shl rax, 4
mov rdx, [rsp+68h+var_48]
movdqu xmm0, xmmword ptr [r14]
movups xmmword ptr [rdx+rax], xmm0
lea r15d, [r15+1]
loc_1298:
add r14, 10h
cmp r14, [rsp+68h+var_58]
jz short loc_1263
loc_12A3:
cmp [rsp+68h+var_5C], 0
jle short loc_127F
mov r13, r14
mov rbp, [r14]
mov rbx, [rsp+68h+var_50]
jmp short loc_123B | long long func0(const __m128i *a1, int a2, _QWORD *a3, int a4, _DWORD *a5)
{
const __m128i *v7; // r14
long long v8; // r12
int v9; // r15d
_QWORD *v10; // rbx
long long v12; // rbp
long long v15; // [rsp+20h] [rbp-48h]
v15 = malloc(16LL * a2);
if ( a2 <= 0 )
{
v9 = 0;
}
else
{
v7 = a1;
v8 = (long long)&a3[2 * (unsigned int)(a4 - 1) + 2];
v9 = 0;
do
{
if ( a4 <= 0 )
{
LABEL_9:
*(__m128i *)(v15 + 16LL * v9++) = _mm_loadu_si128(v7);
}
else
{
v12 = v7->m128i_i64[0];
v10 = a3;
while ( (unsigned int)strcmp(v12, *v10) || (unsigned int)strcmp(v7->m128i_i64[1], v10[1]) )
{
v10 += 2;
if ( v10 == (_QWORD *)v8 )
goto LABEL_9;
}
}
++v7;
}
while ( v7 != &a1[(unsigned int)(a2 - 1) + 1] );
}
*a5 = v9;
return v15;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x38
MOV RBP,RDI
MOV EBX,ESI
MOV R13,RDX
MOV qword ptr [RSP + 0x18],RDX
MOV R15D,ECX
MOV dword ptr [RSP + 0xc],ECX
MOV qword ptr [RSP + 0x28],R8
MOVSXD RDI,ESI
SHL RDI,0x4
CALL 0x001010d0
MOV qword ptr [RSP + 0x20],RAX
TEST EBX,EBX
JLE 0x0010125d
MOV R14,RBP
LEA EAX,[RBX + -0x1]
SHL RAX,0x4
LEA RAX,[RBP + RAX*0x1 + 0x10]
MOV qword ptr [RSP + 0x10],RAX
LEA EAX,[R15 + -0x1]
SHL RAX,0x4
LEA R12,[R13 + RAX*0x1 + 0x10]
MOV R15D,0x0
JMP 0x001012a3
LAB_00101232:
ADD RBX,0x10
CMP RBX,R12
JZ 0x0010127f
LAB_0010123b:
MOV RSI,qword ptr [RBX]
MOV RDI,RBP
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x00101232
MOV RSI,qword ptr [RBX + 0x8]
MOV RDI,qword ptr [R13 + 0x8]
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x00101232
JMP 0x00101298
LAB_0010125d:
MOV R15D,0x0
LAB_00101263:
MOV RAX,qword ptr [RSP + 0x28]
MOV dword ptr [RAX],R15D
MOV RAX,qword ptr [RSP + 0x20]
ADD RSP,0x38
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_0010127f:
MOVSXD RAX,R15D
SHL RAX,0x4
MOV RDX,qword ptr [RSP + 0x20]
MOVDQU XMM0,xmmword ptr [R14]
MOVUPS xmmword ptr [RDX + RAX*0x1],XMM0
LEA R15D,[R15 + 0x1]
LAB_00101298:
ADD R14,0x10
CMP R14,qword ptr [RSP + 0x10]
JZ 0x00101263
LAB_001012a3:
CMP dword ptr [RSP + 0xc],0x0
JLE 0x0010127f
MOV R13,R14
MOV RBP,qword ptr [R14]
MOV RBX,qword ptr [RSP + 0x18]
JMP 0x0010123b | void * func0(int8 *param_1,int param_2,int8 *param_3,int param_4,int *param_5)
{
int8 *puVar1;
char *__s1;
int8 uVar2;
int iVar3;
void *pvVar4;
int8 *puVar5;
int iVar6;
pvVar4 = malloc((long)param_2 << 4);
if (param_2 < 1) {
iVar6 = 0;
}
else {
puVar1 = param_1 + (ulong)(param_2 - 1) * 2 + 2;
iVar6 = 0;
do {
if (0 < param_4) {
__s1 = (char *)*param_1;
puVar5 = param_3;
do {
iVar3 = strcmp(__s1,(char *)*puVar5);
if ((iVar3 == 0) && (iVar3 = strcmp((char *)param_1[1],(char *)puVar5[1]), iVar3 == 0))
goto LAB_00101298;
puVar5 = puVar5 + 2;
} while (puVar5 != param_3 + (ulong)(param_4 - 1) * 2 + 2);
}
uVar2 = param_1[1];
puVar5 = (int8 *)((long)pvVar4 + (long)iVar6 * 0x10);
*puVar5 = *param_1;
puVar5[1] = uVar2;
iVar6 = iVar6 + 1;
LAB_00101298:
param_1 = param_1 + 2;
} while (param_1 != puVar1);
}
*param_5 = iVar6;
return pvVar4;
} |
5,830 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
char* first;
char* second;
} Tuple;
| Tuple* func0(Tuple* test_list1, int size1, Tuple* test_list2, int size2, int* res_size) {
Tuple* res = malloc(size1 * sizeof(Tuple));
int count = 0;
for(int i = 0; i < size1; i++) {
int found = 0;
for(int j = 0; j < size2; j++) {
if(strcmp(test_list1[i].first, test_list2[j].first) == 0 &&
strcmp(test_list1[i].second, test_list2[j].second) == 0) {
found = 1;
break;
}
}
if(!found) {
res[count++] = test_list1[i];
}
}
*res_size = count;
return res;
}
| int main(){
// Test case 1
Tuple test1_1[] = { {"Hello", "dude"}, {"How", "are"}, {"you", "?"} };
Tuple test2_1[] = { {"Hello", "dude"}, {"How", "are"} };
int res_size1;
Tuple* res1 = func0(test1_1, 3, test2_1, 2, &res_size1);
Tuple expected1[] = { {"you", "?"} };
assert(res_size1 == 1);
assert(strcmp(res1[0].first, expected1[0].first) == 0);
assert(strcmp(res1[0].second, expected1[0].second) == 0);
free(res1);
// Test case 2
Tuple test1_2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
Tuple test2_2[] = { {"Journey", "the"}, {"is", "end"} };
int res_size2;
Tuple* res2 = func0(test1_2, 3, test2_2, 2, &res_size2);
Tuple expected2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
assert(res_size2 == 3);
for(int i = 0; i < res_size2; i++) {
assert(strcmp(res2[i].first, expected2[i].first) == 0);
assert(strcmp(res2[i].second, expected2[i].second) == 0);
}
free(res2);
// Test case 3
Tuple test1_3[] = { {"Its", "been"}, {"a", "long"}, {"day", "without"} };
Tuple test2_3[] = { {"a", "long"}, {"my", "friend"} };
int res_size3;
Tuple* res3 = func0(test1_3, 3, test2_3, 2, &res_size3);
Tuple expected3[] = { {"Its", "been"}, {"day", "without"} };
assert(res_size3 == 2);
for(int i = 0; i < res_size3; i++) {
assert(strcmp(res3[i].first, expected3[i].first) == 0);
assert(strcmp(res3[i].second, expected3[i].second) == 0);
}
free(res3);
return 0;
}
| O2 | c | func0:
endbr64
push %r15
mov %rdx,%r15
push %r14
mov %ecx,%r14d
push %r13
push %r12
mov %rdi,%r12
movslq %esi,%rdi
push %rbp
push %rbx
mov %rdi,%rbx
shl $0x4,%rdi
sub $0x28,%rsp
mov %rdx,0x8(%rsp)
mov %r8,0x18(%rsp)
callq 10d0 <malloc@plt>
mov %rax,0x10(%rsp)
test %ebx,%ebx
jle 174a <func0+0xea>
lea -0x1(%rbx),%eax
xor %r13d,%r13d
shl $0x4,%rax
lea 0x10(%r12,%rax,1),%rax
mov %rax,(%rsp)
lea -0x1(%r14),%eax
shl $0x4,%rax
lea 0x10(%r15,%rax,1),%rbp
nopl 0x0(%rax)
test %r14d,%r14d
jle 170a <func0+0xaa>
mov (%r12),%rbx
mov 0x8(%rsp),%r15
nopw %cs:0x0(%rax,%rax,1)
mov (%r15),%rsi
mov %rbx,%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 1701 <func0+0xa1>
mov 0x8(%r15),%rsi
mov 0x8(%r12),%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
je 1724 <func0+0xc4>
add $0x10,%r15
cmp %rbp,%r15
jne 16e0 <func0+0x80>
movslq %r13d,%rax
mov 0x10(%rsp),%rdx
movdqu (%r12),%xmm0
add $0x1,%r13d
shl $0x4,%rax
movups %xmm0,(%rdx,%rax,1)
add $0x10,%r12
cmp (%rsp),%r12
jne 16c8 <func0+0x68>
mov 0x18(%rsp),%rax
mov %r13d,(%rax)
mov 0x10(%rsp),%rax
add $0x28,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
xor %r13d,%r13d
jmp 172e <func0+0xce>
| func0:
endbr64
push r15
mov r15, rdx
push r14
mov r14d, ecx
push r13
push r12
mov r12, rdi
movsxd rdi, esi
push rbp
push rbx
mov rbx, rdi
shl rdi, 4
sub rsp, 28h
mov [rsp+58h+var_50], rdx
mov [rsp+58h+var_40], r8
call _malloc
mov [rsp+58h+var_48], rax
test ebx, ebx
jle loc_172A
lea eax, [rbx-1]
xor r13d, r13d
shl rax, 4
lea rax, [r12+rax+10h]
mov [rsp+58h+var_58], rax
lea eax, [r14-1]
shl rax, 4
lea rbp, [r15+rax+10h]
nop dword ptr [rax+00000000h]
loc_16A8:
test r14d, r14d
jle short loc_16EA
mov rbx, [r12]
mov r15, [rsp+58h+var_50]
nop word ptr [rax+rax+00000000h]
loc_16C0:
mov rsi, [r15]
mov rdi, rbx
call _strcmp
test eax, eax
jnz short loc_16E1
mov rsi, [r15+8]
mov rdi, [r12+8]
call _strcmp
test eax, eax
jz short loc_1704
loc_16E1:
add r15, 10h
cmp rbp, r15
jnz short loc_16C0
loc_16EA:
movsxd rax, r13d
mov rdx, [rsp+58h+var_48]
movdqu xmm0, xmmword ptr [r12]
add r13d, 1
shl rax, 4
movups xmmword ptr [rdx+rax], xmm0
loc_1704:
add r12, 10h
cmp r12, [rsp+58h+var_58]
jnz short loc_16A8
loc_170E:
mov rax, [rsp+58h+var_40]
mov [rax], r13d
mov rax, [rsp+58h+var_48]
add rsp, 28h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_172A:
xor r13d, r13d
jmp short loc_170E | long long func0(const __m128i *a1, int a2, _QWORD *a3, int a4, _DWORD *a5)
{
const __m128i *v7; // r12
int v8; // r13d
long long v9; // rbp
long long v10; // rbx
_QWORD *v11; // r15
long long v12; // rax
long long v15; // [rsp+10h] [rbp-48h]
v7 = a1;
v15 = malloc(16LL * a2);
if ( a2 <= 0 )
{
v8 = 0;
}
else
{
v8 = 0;
v9 = (long long)&a3[2 * (unsigned int)(a4 - 1) + 2];
do
{
if ( a4 <= 0 )
{
LABEL_8:
v12 = v8++;
*(__m128i *)(v15 + 16 * v12) = _mm_loadu_si128(v7);
}
else
{
v10 = v7->m128i_i64[0];
v11 = a3;
while ( (unsigned int)strcmp(v10, *v11) || (unsigned int)strcmp(v7->m128i_i64[1], v11[1]) )
{
v11 += 2;
if ( (_QWORD *)v9 == v11 )
goto LABEL_8;
}
}
++v7;
}
while ( v7 != &a1[(unsigned int)(a2 - 1) + 1] );
}
*a5 = v8;
return v15;
} | func0:
ENDBR64
PUSH R15
MOV R15,RDX
PUSH R14
MOV R14D,ECX
PUSH R13
PUSH R12
MOV R12,RDI
MOVSXD RDI,ESI
PUSH RBP
PUSH RBX
MOV RBX,RDI
SHL RDI,0x4
SUB RSP,0x28
MOV qword ptr [RSP + 0x8],RDX
MOV qword ptr [RSP + 0x18],R8
CALL 0x001010d0
MOV qword ptr [RSP + 0x10],RAX
TEST EBX,EBX
JLE 0x0010172a
LEA EAX,[RBX + -0x1]
XOR R13D,R13D
SHL RAX,0x4
LEA RAX,[R12 + RAX*0x1 + 0x10]
MOV qword ptr [RSP],RAX
LEA EAX,[R14 + -0x1]
SHL RAX,0x4
LEA RBP,[R15 + RAX*0x1 + 0x10]
NOP dword ptr [RAX]
LAB_001016a8:
TEST R14D,R14D
JLE 0x001016ea
MOV RBX,qword ptr [R12]
MOV R15,qword ptr [RSP + 0x8]
NOP word ptr CS:[RAX + RAX*0x1]
LAB_001016c0:
MOV RSI,qword ptr [R15]
MOV RDI,RBX
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x001016e1
MOV RSI,qword ptr [R15 + 0x8]
MOV RDI,qword ptr [R12 + 0x8]
CALL 0x001010c0
TEST EAX,EAX
JZ 0x00101704
LAB_001016e1:
ADD R15,0x10
CMP RBP,R15
JNZ 0x001016c0
LAB_001016ea:
MOVSXD RAX,R13D
MOV RDX,qword ptr [RSP + 0x10]
MOVDQU XMM0,xmmword ptr [R12]
ADD R13D,0x1
SHL RAX,0x4
MOVUPS xmmword ptr [RDX + RAX*0x1],XMM0
LAB_00101704:
ADD R12,0x10
CMP R12,qword ptr [RSP]
JNZ 0x001016a8
LAB_0010170e:
MOV RAX,qword ptr [RSP + 0x18]
MOV dword ptr [RAX],R13D
MOV RAX,qword ptr [RSP + 0x10]
ADD RSP,0x28
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_0010172a:
XOR R13D,R13D
JMP 0x0010170e | void * func0(int8 *param_1,int param_2,int8 *param_3,int param_4,int *param_5)
{
int8 *puVar1;
char *__s1;
int8 uVar2;
int iVar3;
void *pvVar4;
long lVar5;
int iVar6;
int8 *puVar7;
pvVar4 = malloc((long)param_2 << 4);
if (param_2 < 1) {
iVar6 = 0;
}
else {
iVar6 = 0;
puVar1 = param_1 + (ulong)(param_2 - 1) * 2 + 2;
do {
if (0 < param_4) {
__s1 = (char *)*param_1;
puVar7 = param_3;
do {
iVar3 = strcmp(__s1,(char *)*puVar7);
if (iVar3 == 0) {
iVar3 = strcmp((char *)param_1[1],(char *)puVar7[1]);
if (iVar3 == 0) goto LAB_00101704;
}
puVar7 = puVar7 + 2;
} while (param_3 + (ulong)(param_4 - 1) * 2 + 2 != puVar7);
}
lVar5 = (long)iVar6;
uVar2 = param_1[1];
iVar6 = iVar6 + 1;
puVar7 = (int8 *)((long)pvVar4 + lVar5 * 0x10);
*puVar7 = *param_1;
puVar7[1] = uVar2;
LAB_00101704:
param_1 = param_1 + 2;
} while (param_1 != puVar1);
}
*param_5 = iVar6;
return pvVar4;
} |
5,831 | func0 |
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
typedef struct {
char* first;
char* second;
} Tuple;
| Tuple* func0(Tuple* test_list1, int size1, Tuple* test_list2, int size2, int* res_size) {
Tuple* res = malloc(size1 * sizeof(Tuple));
int count = 0;
for(int i = 0; i < size1; i++) {
int found = 0;
for(int j = 0; j < size2; j++) {
if(strcmp(test_list1[i].first, test_list2[j].first) == 0 &&
strcmp(test_list1[i].second, test_list2[j].second) == 0) {
found = 1;
break;
}
}
if(!found) {
res[count++] = test_list1[i];
}
}
*res_size = count;
return res;
}
| int main(){
// Test case 1
Tuple test1_1[] = { {"Hello", "dude"}, {"How", "are"}, {"you", "?"} };
Tuple test2_1[] = { {"Hello", "dude"}, {"How", "are"} };
int res_size1;
Tuple* res1 = func0(test1_1, 3, test2_1, 2, &res_size1);
Tuple expected1[] = { {"you", "?"} };
assert(res_size1 == 1);
assert(strcmp(res1[0].first, expected1[0].first) == 0);
assert(strcmp(res1[0].second, expected1[0].second) == 0);
free(res1);
// Test case 2
Tuple test1_2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
Tuple test2_2[] = { {"Journey", "the"}, {"is", "end"} };
int res_size2;
Tuple* res2 = func0(test1_2, 3, test2_2, 2, &res_size2);
Tuple expected2[] = { {"Part", "of"}, {"the", "journey"}, {"is ", "end"} };
assert(res_size2 == 3);
for(int i = 0; i < res_size2; i++) {
assert(strcmp(res2[i].first, expected2[i].first) == 0);
assert(strcmp(res2[i].second, expected2[i].second) == 0);
}
free(res2);
// Test case 3
Tuple test1_3[] = { {"Its", "been"}, {"a", "long"}, {"day", "without"} };
Tuple test2_3[] = { {"a", "long"}, {"my", "friend"} };
int res_size3;
Tuple* res3 = func0(test1_3, 3, test2_3, 2, &res_size3);
Tuple expected3[] = { {"Its", "been"}, {"day", "without"} };
assert(res_size3 == 2);
for(int i = 0; i < res_size3; i++) {
assert(strcmp(res3[i].first, expected3[i].first) == 0);
assert(strcmp(res3[i].second, expected3[i].second) == 0);
}
free(res3);
return 0;
}
| O3 | c | func0:
endbr64
push %r15
mov %rdx,%r15
push %r14
mov %ecx,%r14d
push %r13
push %r12
mov %rdi,%r12
movslq %esi,%rdi
push %rbp
push %rbx
mov %rdi,%rbx
shl $0x4,%rdi
sub $0x28,%rsp
mov %rdx,0x8(%rsp)
mov %r8,0x18(%rsp)
callq 10d0 <malloc@plt>
mov %rax,0x10(%rsp)
test %ebx,%ebx
jle 180a <func0+0xea>
lea -0x1(%rbx),%eax
xor %r13d,%r13d
shl $0x4,%rax
lea 0x10(%r12,%rax,1),%rax
mov %rax,(%rsp)
lea -0x1(%r14),%eax
shl $0x4,%rax
lea 0x10(%r15,%rax,1),%rbp
nopl 0x0(%rax)
test %r14d,%r14d
jle 17ca <func0+0xaa>
mov (%r12),%rbx
mov 0x8(%rsp),%r15
nopw %cs:0x0(%rax,%rax,1)
mov (%r15),%rsi
mov %rbx,%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
jne 17c1 <func0+0xa1>
mov 0x8(%r15),%rsi
mov 0x8(%r12),%rdi
callq 10c0 <strcmp@plt>
test %eax,%eax
je 17e4 <func0+0xc4>
add $0x10,%r15
cmp %r15,%rbp
jne 17a0 <func0+0x80>
movslq %r13d,%rax
mov 0x10(%rsp),%rdx
movdqu (%r12),%xmm0
add $0x1,%r13d
shl $0x4,%rax
movups %xmm0,(%rdx,%rax,1)
add $0x10,%r12
cmp %r12,(%rsp)
jne 1788 <func0+0x68>
mov 0x18(%rsp),%rax
mov %r13d,(%rax)
mov 0x10(%rsp),%rax
add $0x28,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
retq
xor %r13d,%r13d
jmp 17ee <func0+0xce>
| func0:
endbr64
push r15
mov r15, rdx
push r14
movsxd r14, esi
push r13
push r12
mov r12, rdi
push rbp
movsxd rbp, ecx
push rbx
mov rbx, r14
shl r14, 4
mov rdi, r14; size
sub rsp, 28h
mov [rsp+58h+var_44], ebp
mov [rsp+58h+var_40], r8
call _malloc
mov [rsp+58h+var_50], rax
test ebx, ebx
jle loc_17D0
lea rax, [r12+r14]
shl rbp, 4
xor r13d, r13d
mov [rsp+58h+var_58], rax
add rbp, r15
nop dword ptr [rax]
loc_1738:
mov eax, [rsp+58h+var_44]
test eax, eax
jle short loc_177A
loc_1740:
mov rbx, [r12]
mov r14, r15
nop word ptr [rax+rax+00000000h]
loc_1750:
mov rsi, [r14]; s2
mov rdi, rbx; s1
call _strcmp
test eax, eax
jnz short loc_1771
mov rsi, [r14+8]; s2
mov rdi, [r12+8]; s1
call _strcmp
test eax, eax
jz short loc_17A8
loc_1771:
add r14, 10h
cmp rbp, r14
jnz short loc_1750
loc_177A:
movdqu xmm0, xmmword ptr [r12]
mov rdx, [rsp+58h+var_50]
lea eax, [r13+1]
shl r13, 4
add r12, 10h
movups xmmword ptr [rdx+r13], xmm0
cmp [rsp+58h+var_58], r12
jz short loc_17B5
movsxd r13, eax
jmp short loc_1738
loc_17A8:
add r12, 10h
cmp [rsp+58h+var_58], r12
jnz short loc_1740
mov eax, r13d
loc_17B5:
mov rdx, [rsp+58h+var_40]
mov [rdx], eax
mov rax, [rsp+58h+var_50]
add rsp, 28h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn
loc_17D0:
xor eax, eax
jmp short loc_17B5 | __m128i * func0(long long a1, int a2, const char **a3, int a4, _DWORD *a5)
{
long long v6; // r12
long long v7; // rbp
long long v8; // r13
const char **v9; // rbp
const char *v10; // rbx
const char **v11; // r14
__m128i v12; // xmm0
int v13; // eax
long long v15; // [rsp+0h] [rbp-58h]
__m128i *v16; // [rsp+8h] [rbp-50h]
v6 = a1;
v7 = a4;
v16 = (__m128i *)malloc(16LL * a2);
if ( a2 <= 0 )
{
v13 = 0;
}
else
{
v8 = 0LL;
v15 = a1 + 16LL * a2;
v9 = &a3[2 * v7];
while ( a4 <= 0 )
{
LABEL_8:
v12 = _mm_loadu_si128((const __m128i *)v6);
v13 = v8 + 1;
v6 += 16LL;
v16[v8] = v12;
if ( v15 == v6 )
goto LABEL_12;
v8 = v13;
}
do
{
v10 = *(const char **)v6;
v11 = a3;
while ( strcmp(v10, *v11) || strcmp(*(const char **)(v6 + 8), v11[1]) )
{
v11 += 2;
if ( v9 == v11 )
goto LABEL_8;
}
v6 += 16LL;
}
while ( v15 != v6 );
v13 = v8;
}
LABEL_12:
*a5 = v13;
return v16;
} | func0:
ENDBR64
PUSH R15
MOV R15,RDX
PUSH R14
MOVSXD R14,ESI
PUSH R13
PUSH R12
MOV R12,RDI
PUSH RBP
MOVSXD RBP,ECX
PUSH RBX
MOV RBX,R14
SHL R14,0x4
MOV RDI,R14
SUB RSP,0x28
MOV dword ptr [RSP + 0x14],EBP
MOV qword ptr [RSP + 0x18],R8
CALL 0x001010d0
MOV qword ptr [RSP + 0x8],RAX
TEST EBX,EBX
JLE 0x001017d0
LEA RAX,[R12 + R14*0x1]
SHL RBP,0x4
XOR R13D,R13D
MOV qword ptr [RSP],RAX
ADD RBP,R15
NOP dword ptr [RAX]
LAB_00101738:
MOV EAX,dword ptr [RSP + 0x14]
TEST EAX,EAX
JLE 0x0010177a
LAB_00101740:
MOV RBX,qword ptr [R12]
MOV R14,R15
NOP word ptr [RAX + RAX*0x1]
LAB_00101750:
MOV RSI,qword ptr [R14]
MOV RDI,RBX
CALL 0x001010c0
TEST EAX,EAX
JNZ 0x00101771
MOV RSI,qword ptr [R14 + 0x8]
MOV RDI,qword ptr [R12 + 0x8]
CALL 0x001010c0
TEST EAX,EAX
JZ 0x001017a8
LAB_00101771:
ADD R14,0x10
CMP RBP,R14
JNZ 0x00101750
LAB_0010177a:
MOVDQU XMM0,xmmword ptr [R12]
MOV RDX,qword ptr [RSP + 0x8]
LEA EAX,[R13 + 0x1]
SHL R13,0x4
ADD R12,0x10
MOVUPS xmmword ptr [RDX + R13*0x1],XMM0
CMP qword ptr [RSP],R12
JZ 0x001017b5
MOVSXD R13,EAX
JMP 0x00101738
LAB_001017a8:
ADD R12,0x10
CMP qword ptr [RSP],R12
JNZ 0x00101740
MOV EAX,R13D
LAB_001017b5:
MOV RDX,qword ptr [RSP + 0x18]
MOV dword ptr [RDX],EAX
MOV RAX,qword ptr [RSP + 0x8]
ADD RSP,0x28
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET
LAB_001017d0:
XOR EAX,EAX
JMP 0x001017b5 | void * func0(int8 *param_1,int param_2,int8 *param_3,int param_4,int *param_5)
{
int8 *puVar1;
char *__s1;
int8 uVar2;
int8 uVar3;
int iVar4;
int iVar5;
void *pvVar6;
long lVar7;
int8 *puVar8;
pvVar6 = malloc((long)param_2 * 0x10);
if (param_2 < 1) {
iVar5 = 0;
}
else {
puVar1 = param_1 + (long)param_2 * 2;
lVar7 = 0;
while (iVar5 = (int)lVar7, param_4 < 1) {
LAB_0010177a:
uVar2 = *param_1;
uVar3 = param_1[1];
iVar5 = iVar5 + 1;
param_1 = param_1 + 2;
puVar8 = (int8 *)((long)pvVar6 + lVar7 * 0x10);
*puVar8 = uVar2;
puVar8[1] = uVar3;
if (puVar1 == param_1) goto LAB_001017b5;
lVar7 = (long)iVar5;
}
do {
__s1 = (char *)*param_1;
puVar8 = param_3;
while ((iVar4 = strcmp(__s1,(char *)*puVar8), iVar4 != 0 ||
(iVar4 = strcmp((char *)param_1[1],(char *)puVar8[1]), iVar4 != 0))) {
puVar8 = puVar8 + 2;
if (param_3 + (long)param_4 * 2 == puVar8) goto LAB_0010177a;
}
param_1 = param_1 + 2;
} while (puVar1 != param_1);
}
LAB_001017b5:
*param_5 = iVar5;
return pvVar6;
} |
5,832 | func0 |
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
bool is_palindrome(int n) {
int divisor = 1;
while (n / divisor >= 10) {
divisor *= 10;
}
while (n != 0) {
int leading = n / divisor;
int trailing = n % 10;
if (leading != trailing) {
return false;
}
n = (n % divisor) / 10;
divisor = divisor / 100;
}
return true;
}
| int func0(int A[], int n) {
int i, j, temp;
// Sorting the array A
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (A[i] > A[j]) {
temp = A[j];
A[j] = A[i];
A[i] = temp;
}
}
}
// Finding the largest palindrome
for (i = n - 1; i >= 0; i--) {
if (is_palindrome(A[i])) {
return A[i];
}
}
return -1;
}
| int main() {
int arr1[4] = {1, 232, 54545, 999991};
int arr2[6] = {1, 2, 3, 4, 5, 50};
int arr3[5] = {1, 3, 7, 9, 45};
assert(func0(arr1, 4) == 54545);
assert(func0(arr2, 6) == 5);
assert(func0(arr3, 5) == 9);
printf("All test cases passed.\n");
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x0,-0xc(%rbp)
jmpq 1326 <func0+0xd0>
mov -0xc(%rbp),%eax
add $0x1,%eax
mov %eax,-0x8(%rbp)
jmpq 1316 <func0+0xc0>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x8(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rcx
mov -0x18(%rbp),%rax
add %rcx,%rax
mov (%rax),%eax
cmp %eax,%edx
jle 1312 <func0+0xbc>
mov -0x8(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0x4(%rbp)
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov -0x8(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,4),%rcx
mov -0x18(%rbp),%rdx
add %rcx,%rdx
mov (%rax),%eax
mov %eax,(%rdx)
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rax,%rdx
mov -0x4(%rbp),%eax
mov %eax,(%rdx)
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 1283 <func0+0x2d>
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 1275 <func0+0x1f>
mov -0x1c(%rbp),%eax
sub $0x1,%eax
mov %eax,-0xc(%rbp)
jmp 137a <func0+0x124>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,%edi
callq 1189 <is_palindrome>
test %al,%al
je 1376 <func0+0x120>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
jmp 1385 <func0+0x12f>
subl $0x1,-0xc(%rbp)
cmpl $0x0,-0xc(%rbp)
jns 133d <func0+0xe7>
mov $0xffffffff,%eax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
mov [rbp+var_18], rdi
mov [rbp+var_1C], esi
mov [rbp+var_C], 0
jmp loc_1324
loc_1273:
mov eax, [rbp+var_C]
add eax, 1
mov [rbp+var_8], eax
jmp loc_1314
loc_1281:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_8]
cdqe
lea rcx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rcx
mov eax, [rax]
cmp edx, eax
jle short loc_1310
mov eax, [rbp+var_8]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
mov [rbp+var_4], eax
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov edx, [rbp+var_8]
movsxd rdx, edx
lea rcx, ds:0[rdx*4]
mov rdx, [rbp+var_18]
add rdx, rcx
mov eax, [rax]
mov [rdx], eax
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rdx, rax
mov eax, [rbp+var_4]
mov [rdx], eax
loc_1310:
add [rbp+var_8], 1
loc_1314:
mov eax, [rbp+var_8]
cmp eax, [rbp+var_1C]
jl loc_1281
add [rbp+var_C], 1
loc_1324:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_1C]
jl loc_1273
mov eax, [rbp+var_1C]
sub eax, 1
mov [rbp+var_C], eax
jmp short loc_1378
loc_133B:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
mov edi, eax
call is_palindrome
test al, al
jz short loc_1374
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
jmp short locret_1383
loc_1374:
sub [rbp+var_C], 1
loc_1378:
cmp [rbp+var_C], 0
jns short loc_133B
mov eax, 0FFFFFFFFh
locret_1383:
leave
retn | long long func0(long long a1, int a2)
{
int i; // [rsp+14h] [rbp-Ch]
int k; // [rsp+14h] [rbp-Ch]
int j; // [rsp+18h] [rbp-8h]
int v6; // [rsp+1Ch] [rbp-4h]
for ( i = 0; i < a2; ++i )
{
for ( j = i + 1; j < a2; ++j )
{
if ( *(_DWORD *)(4LL * i + a1) > *(_DWORD *)(4LL * j + a1) )
{
v6 = *(_DWORD *)(4LL * j + a1);
*(_DWORD *)(4LL * j + a1) = *(_DWORD *)(4LL * i + a1);
*(_DWORD *)(a1 + 4LL * i) = v6;
}
}
}
for ( k = a2 - 1; k >= 0; --k )
{
if ( (unsigned __int8)is_palindrome(*(unsigned int *)(4LL * k + a1)) )
return *(unsigned int *)(4LL * k + a1);
}
return 0xFFFFFFFFLL;
} | 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 + -0xc],0x0
JMP 0x00101324
LAB_00101273:
MOV EAX,dword ptr [RBP + -0xc]
ADD EAX,0x1
MOV dword ptr [RBP + -0x8],EAX
JMP 0x00101314
LAB_00101281:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x8]
CDQE
LEA RCX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RCX
MOV EAX,dword ptr [RAX]
CMP EDX,EAX
JLE 0x00101310
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 dword ptr [RBP + -0x4],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0x8]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x4]
MOV RDX,qword ptr [RBP + -0x18]
ADD RDX,RCX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RDX],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x4]
MOV dword ptr [RDX],EAX
LAB_00101310:
ADD dword ptr [RBP + -0x8],0x1
LAB_00101314:
MOV EAX,dword ptr [RBP + -0x8]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x00101281
ADD dword ptr [RBP + -0xc],0x1
LAB_00101324:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x00101273
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,0x1
MOV dword ptr [RBP + -0xc],EAX
JMP 0x00101378
LAB_0010133b:
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]
MOV EDI,EAX
CALL 0x00101189
TEST AL,AL
JZ 0x00101374
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]
JMP 0x00101383
LAB_00101374:
SUB dword ptr [RBP + -0xc],0x1
LAB_00101378:
CMP dword ptr [RBP + -0xc],0x0
JNS 0x0010133b
MOV EAX,0xffffffff
LAB_00101383:
LEAVE
RET | int4 func0(long param_1,int param_2)
{
int4 uVar1;
char cVar2;
int local_14;
int local_10;
for (local_14 = 0; local_10 = local_14, local_14 < param_2; local_14 = local_14 + 1) {
while (local_10 = local_10 + 1, local_10 < param_2) {
if (*(int *)(param_1 + (long)local_10 * 4) < *(int *)(param_1 + (long)local_14 * 4)) {
uVar1 = *(int4 *)(param_1 + (long)local_10 * 4);
*(int4 *)(param_1 + (long)local_10 * 4) =
*(int4 *)(param_1 + (long)local_14 * 4);
*(int4 *)((long)local_14 * 4 + param_1) = uVar1;
}
}
}
local_14 = param_2 + -1;
while( true ) {
if (local_14 < 0) {
return 0xffffffff;
}
cVar2 = is_palindrome(*(int4 *)(param_1 + (long)local_14 * 4));
if (cVar2 != '\0') break;
local_14 = local_14 + -1;
}
return *(int4 *)(param_1 + (long)local_14 * 4);
} |
5,833 | func0 |
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
bool is_palindrome(int n) {
int divisor = 1;
while (n / divisor >= 10) {
divisor *= 10;
}
while (n != 0) {
int leading = n / divisor;
int trailing = n % 10;
if (leading != trailing) {
return false;
}
n = (n % divisor) / 10;
divisor = divisor / 100;
}
return true;
}
| int func0(int A[], int n) {
int i, j, temp;
// Sorting the array A
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (A[i] > A[j]) {
temp = A[j];
A[j] = A[i];
A[i] = temp;
}
}
}
// Finding the largest palindrome
for (i = n - 1; i >= 0; i--) {
if (is_palindrome(A[i])) {
return A[i];
}
}
return -1;
}
| int main() {
int arr1[4] = {1, 232, 54545, 999991};
int arr2[6] = {1, 2, 3, 4, 5, 50};
int arr3[5] = {1, 3, 7, 9, 45};
assert(func0(arr1, 4) == 54545);
assert(func0(arr2, 6) == 5);
assert(func0(arr3, 5) == 9);
printf("All test cases passed.\n");
return 0;
}
| O1 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
test %esi,%esi
jle 1295 <func0+0x49>
mov %rdi,%rbx
lea -0x1(%rsi),%r9d
add $0x1,%r9
mov $0x1,%r8d
jmp 128b <func0+0x3f>
add $0x1,%rax
cmp %eax,%esi
jle 1283 <func0+0x37>
mov (%rdi),%ecx
mov (%rbx,%rax,4),%edx
cmp %edx,%ecx
jle 126b <func0+0x1f>
mov %ecx,(%rbx,%rax,4)
mov %edx,(%rdi)
jmp 126b <func0+0x1f>
add $0x1,%r8
add $0x4,%rdi
cmp %r9,%r8
je 129d <func0+0x51>
mov %r8,%rax
jmp 1273 <func0+0x27>
mov $0xffffffff,%r12d
jmp 12c1 <func0+0x75>
sub $0x1,%esi
movslq %esi,%rbp
mov (%rbx,%rbp,4),%r12d
mov %r12d,%edi
callq 1189 <is_palindrome>
test %al,%al
jne 12c1 <func0+0x75>
sub $0x1,%rbp
test %ebp,%ebp
jns 12a3 <func0+0x57>
mov $0xffffffff,%r12d
mov %r12d,%eax
pop %rbx
pop %rbp
pop %r12
retq
| func0:
endbr64
push r12
push rbp
push rbx
test esi, esi
jle short loc_12AE
mov rbx, rdi
lea rdi, [rdi+4]
lea ebp, [rsi-1]
mov r10d, esi
mov r9d, 1
lea r11, [rbx+8]
jmp short loc_1296
loc_1275:
add rax, 4
cmp rax, r8
jz short loc_128E
loc_127E:
mov ecx, [rdi-4]
mov edx, [rax]
cmp ecx, edx
jle short loc_1275
mov [rax], ecx
mov [rdi-4], edx
jmp short loc_1275
loc_128E:
add r9, 1
add rdi, 4
loc_1296:
cmp r9, r10
jz short loc_12B6
mov eax, ebp
sub eax, r9d
lea rax, [r9+rax-1]
lea r8, [r11+rax*4]
mov rax, rdi
jmp short loc_127E
loc_12AE:
mov r12d, 0FFFFFFFFh
jmp short loc_12DA
loc_12B6:
sub esi, 1
movsxd rbp, esi
loc_12BC:
mov r12d, [rbx+rbp*4]
mov edi, r12d
call is_palindrome
test al, al
jnz short loc_12DA
sub rbp, 1
test ebp, ebp
jns short loc_12BC
mov r12d, 0FFFFFFFFh
loc_12DA:
mov eax, r12d
pop rbx
pop rbp
pop r12
retn | long long func0(long long a1, int a2)
{
int *v3; // rdi
long long i; // r9
int *v5; // rax
int v6; // ecx
int v7; // edx
unsigned int v8; // r12d
long long v9; // rbp
if ( a2 <= 0 )
{
return (unsigned int)-1;
}
else
{
v3 = (int *)(a1 + 4);
for ( i = 1LL; i != a2; ++i )
{
v5 = v3;
do
{
v6 = *(v3 - 1);
v7 = *v5;
if ( v6 > *v5 )
{
*v5 = v6;
*(v3 - 1) = v7;
}
++v5;
}
while ( v5 != (int *)(a1 + 8 + 4 * (i + (unsigned int)(a2 - 1 - i) - 1)) );
++v3;
}
v9 = a2 - 1;
while ( 1 )
{
v8 = *(_DWORD *)(a1 + 4 * v9);
if ( (unsigned __int8)is_palindrome(v8) )
break;
if ( (int)--v9 < 0 )
return (unsigned int)-1;
}
}
return v8;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
PUSH RBX
TEST ESI,ESI
JLE 0x001012ae
MOV RBX,RDI
LEA RDI,[RDI + 0x4]
LEA EBP,[RSI + -0x1]
MOV R10D,ESI
MOV R9D,0x1
LEA R11,[RBX + 0x8]
JMP 0x00101296
LAB_00101275:
ADD RAX,0x4
CMP RAX,R8
JZ 0x0010128e
LAB_0010127e:
MOV ECX,dword ptr [RDI + -0x4]
MOV EDX,dword ptr [RAX]
CMP ECX,EDX
JLE 0x00101275
MOV dword ptr [RAX],ECX
MOV dword ptr [RDI + -0x4],EDX
JMP 0x00101275
LAB_0010128e:
ADD R9,0x1
ADD RDI,0x4
LAB_00101296:
CMP R9,R10
JZ 0x001012b6
MOV EAX,EBP
SUB EAX,R9D
LEA RAX,[R9 + RAX*0x1 + -0x1]
LEA R8,[R11 + RAX*0x4]
MOV RAX,RDI
JMP 0x0010127e
LAB_001012ae:
MOV R12D,0xffffffff
JMP 0x001012da
LAB_001012b6:
SUB ESI,0x1
MOVSXD RBP,ESI
LAB_001012bc:
MOV R12D,dword ptr [RBX + RBP*0x4]
MOV EDI,R12D
CALL 0x00101189
TEST AL,AL
JNZ 0x001012da
SUB RBP,0x1
TEST EBP,EBP
JNS 0x001012bc
MOV R12D,0xffffffff
LAB_001012da:
MOV EAX,R12D
POP RBX
POP RBP
POP R12
RET | int4 func0(long param_1,uint param_2)
{
int iVar1;
int4 uVar2;
char cVar3;
int *piVar4;
long lVar5;
int *piVar6;
ulong uVar7;
if (0 < (int)param_2) {
piVar6 = (int *)(param_1 + 4);
for (uVar7 = 1; uVar7 != param_2; uVar7 = uVar7 + 1) {
piVar4 = piVar6;
do {
iVar1 = *piVar4;
if (iVar1 < piVar6[-1]) {
*piVar4 = piVar6[-1];
piVar6[-1] = iVar1;
}
piVar4 = piVar4 + 1;
} while (piVar4 != (int *)(param_1 + 8 +
((uVar7 - 1) + (ulong)((param_2 - 1) - (int)uVar7)) * 4));
piVar6 = piVar6 + 1;
}
lVar5 = (long)(int)(param_2 - 1);
do {
uVar2 = *(int4 *)(param_1 + lVar5 * 4);
cVar3 = is_palindrome(uVar2);
if (cVar3 != '\0') {
return uVar2;
}
lVar5 = lVar5 + -1;
} while (-1 < (int)lVar5);
}
return 0xffffffff;
} |
5,834 | func0 |
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
bool is_palindrome(int n) {
int divisor = 1;
while (n / divisor >= 10) {
divisor *= 10;
}
while (n != 0) {
int leading = n / divisor;
int trailing = n % 10;
if (leading != trailing) {
return false;
}
n = (n % divisor) / 10;
divisor = divisor / 100;
}
return true;
}
| int func0(int A[], int n) {
int i, j, temp;
// Sorting the array A
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (A[i] > A[j]) {
temp = A[j];
A[j] = A[i];
A[i] = temp;
}
}
}
// Finding the largest palindrome
for (i = n - 1; i >= 0; i--) {
if (is_palindrome(A[i])) {
return A[i];
}
}
return -1;
}
| int main() {
int arr1[4] = {1, 232, 54545, 999991};
int arr2[6] = {1, 2, 3, 4, 5, 50};
int arr3[5] = {1, 3, 7, 9, 45};
assert(func0(arr1, 4) == 54545);
assert(func0(arr2, 6) == 5);
assert(func0(arr3, 5) == 9);
printf("All test cases passed.\n");
return 0;
}
| O2 | c | func0:
endbr64
lea -0x1(%rsi),%r10d
test %esi,%esi
jle 14ee <func0+0x13e>
mov %r10d,%r11d
mov $0x1,%r9d
mov %rdi,%r8
add $0x1,%r11
cmp %r11,%r9
je 1405 <func0+0x55>
nopl (%rax)
mov %r9,%rax
nopl 0x0(%rax,%rax,1)
mov (%r8),%ecx
mov (%rdi,%rax,4),%edx
cmp %edx,%ecx
jle 13f0 <func0+0x40>
mov %ecx,(%rdi,%rax,4)
mov %edx,(%r8)
add $0x1,%rax
cmp %eax,%esi
jg 13e0 <func0+0x30>
add $0x1,%r9
add $0x4,%r8
cmp %r11,%r9
jne 13d8 <func0+0x28>
movslq %r10d,%r10
mov $0xcccccccd,%r9d
xchg %ax,%ax
mov (%rdi,%r10,4),%r8d
cmp $0x9,%r8d
jle 14c0 <func0+0x110>
mov $0x1,%ecx
nopl 0x0(%rax,%rax,1)
mov %r8d,%eax
lea (%rcx,%rcx,4),%ecx
add %ecx,%ecx
cltd
idiv %ecx
cmp $0x9,%eax
jg 1428 <func0+0x78>
movslq %r8d,%rdx
mov %r8d,%esi
imul $0x66666667,%rdx,%rdx
sar $0x1f,%esi
sar $0x22,%rdx
sub %esi,%edx
mov %r8d,%esi
lea (%rdx,%rdx,4),%edx
add %edx,%edx
sub %edx,%esi
cmp %esi,%eax
jne 14a0 <func0+0xf0>
mov %r8d,%esi
mov %esi,%eax
cltd
idiv %ecx
mov %ecx,%ecx
imul $0x51eb851f,%rcx,%rcx
shr $0x25,%rcx
mov %rdx,%rsi
imul %r9,%rsi
shr $0x23,%rsi
test %esi,%esi
je 14b3 <func0+0x103>
mov %esi,%eax
mov %esi,%r11d
cltd
idiv %ecx
mov %esi,%edx
imul %r9,%rdx
shr $0x23,%rdx
lea (%rdx,%rdx,4),%edx
add %edx,%edx
sub %edx,%r11d
cmp %r11d,%eax
je 1460 <func0+0xb0>
sub $0x1,%r10
test %r10d,%r10d
jns 1410 <func0+0x60>
mov $0xffffffff,%r8d
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
test %r8d,%r8d
je 14b3 <func0+0x103>
movslq %r8d,%rax
mov %r8d,%edx
mov %r8d,%esi
imul $0x66666667,%rax,%rax
sar $0x1f,%edx
sar $0x22,%rax
sub %edx,%eax
lea (%rax,%rax,4),%eax
add %eax,%eax
sub %eax,%esi
cmp %r8d,%esi
jne 14a0 <func0+0xf0>
mov %r8d,%eax
retq
test %r10d,%r10d
jns 1405 <func0+0x55>
jmp 14ad <func0+0xfd>
nopl 0x0(%rax)
| func0:
endbr64
push rbx
lea r10d, [rsi-1]
test esi, esi
jle loc_14EF
mov r11d, esi
mov r9d, 1
lea r8, [rdi+4]
lea rbx, [rdi+8]
cmp r9, r11
jz short loc_13FE
nop word ptr [rax+rax+00000000h]
loc_13C0:
mov eax, r10d
sub eax, r9d
lea rax, [r9+rax-1]
lea rsi, [rbx+rax*4]
mov rax, r8
nop word ptr [rax+rax+00h]
loc_13D8:
mov ecx, [r8-4]
mov edx, [rax]
cmp ecx, edx
jle short loc_13E8
mov [rax], ecx
mov [r8-4], edx
loc_13E8:
add rax, 4
cmp rax, rsi
jnz short loc_13D8
add r9, 1
add r8, 4
cmp r9, r11
jnz short loc_13C0
loc_13FE:
movsxd r10, r10d
mov r9d, 0CCCCCCCDh
nop word ptr [rax+rax+00000000h]
loc_1410:
mov r8d, [rdi+r10*4]
cmp r8d, 9
jle loc_14C0
mov ecx, 1
nop dword ptr [rax+rax+00h]
loc_1428:
mov eax, r8d
lea ecx, [rcx+rcx*4]
add ecx, ecx
cdq
idiv ecx
cmp eax, 9
jg short loc_1428
movsxd rdx, r8d
mov esi, r8d
imul rdx, 66666667h
sar esi, 1Fh
sar rdx, 22h
sub edx, esi
mov esi, r8d
lea edx, [rdx+rdx*4]
add edx, edx
sub esi, edx
cmp eax, esi
jnz short loc_14A0
mov esi, r8d
nop
loc_1460:
mov eax, esi
cdq
idiv ecx
mov ecx, ecx
imul rcx, 51EB851Fh
shr rcx, 25h
imul rdx, r9
shr rdx, 23h
mov rsi, rdx
test edx, edx
jz short loc_14B3
mov eax, esi
mov r11d, esi
cdq
idiv ecx
mov edx, esi
imul rdx, r9
shr rdx, 23h
lea edx, [rdx+rdx*4]
add edx, edx
sub r11d, edx
cmp eax, r11d
jz short loc_1460
loc_14A0:
sub r10, 1
test r10d, r10d
jns loc_1410
loc_14AD:
mov r8d, 0FFFFFFFFh
loc_14B3:
mov eax, r8d
pop rbx
retn
loc_14C0:
test r8d, r8d
jz short loc_14B3
movsxd rax, r8d
mov edx, r8d
imul rax, 66666667h
sar edx, 1Fh
sar rax, 22h
sub eax, edx
mov edx, r8d
lea eax, [rax+rax*4]
add eax, eax
sub edx, eax
cmp r8d, edx
jnz short loc_14A0
mov eax, r8d
pop rbx
retn
loc_14EF:
test r10d, r10d
jns loc_13FE
jmp short loc_14AD | long long func0(long long a1, int a2)
{
long long j; // r10
long long v3; // r9
int *i; // r8
int *v5; // rax
int v6; // ecx
int v7; // edx
int v8; // r8d
int v9; // ecx
int v10; // esi
long long v11; // rdx
unsigned long long v12; // rdx
LODWORD(j) = a2 - 1;
if ( a2 > 0 )
{
v3 = 1LL;
for ( i = (int *)(a1 + 4); v3 != a2; ++i )
{
v5 = i;
do
{
v6 = *(i - 1);
v7 = *v5;
if ( v6 > *v5 )
{
*v5 = v6;
*(i - 1) = v7;
}
++v5;
}
while ( v5 != (int *)(a1 + 8 + 4 * (v3 + (unsigned int)(j - v3) - 1)) );
++v3;
}
goto LABEL_8;
}
if ( (int)j >= 0 )
{
LABEL_8:
for ( j = (int)j; (int)j >= 0; --j )
{
v8 = *(_DWORD *)(a1 + 4 * j);
if ( v8 <= 9 )
{
if ( !v8 )
return (unsigned int)v8;
if ( v8 == v8 % 10 )
return (unsigned int)v8;
}
else
{
v9 = 1;
do
v9 *= 10;
while ( v8 / v9 > 9 );
if ( v8 / v9 == v8 % 10 )
{
v10 = *(_DWORD *)(a1 + 4 * j);
do
{
v11 = (unsigned int)(v10 >> 31);
LODWORD(v11) = v10 % v9;
v9 /= 0x64u;
v12 = (unsigned long long)(3435973837LL * v11) >> 35;
v10 = v12;
if ( !(_DWORD)v12 )
return (unsigned int)v8;
}
while ( (int)v12 / v9 == (unsigned int)v12 % 0xA );
}
}
}
}
return (unsigned int)-1;
} | func0:
ENDBR64
PUSH RBX
LEA R10D,[RSI + -0x1]
TEST ESI,ESI
JLE 0x001014ef
MOV R11D,ESI
MOV R9D,0x1
LEA R8,[RDI + 0x4]
LEA RBX,[RDI + 0x8]
CMP R9,R11
JZ 0x001013fe
NOP word ptr [RAX + RAX*0x1]
LAB_001013c0:
MOV EAX,R10D
SUB EAX,R9D
LEA RAX,[R9 + RAX*0x1 + -0x1]
LEA RSI,[RBX + RAX*0x4]
MOV RAX,R8
NOP word ptr [RAX + RAX*0x1]
LAB_001013d8:
MOV ECX,dword ptr [R8 + -0x4]
MOV EDX,dword ptr [RAX]
CMP ECX,EDX
JLE 0x001013e8
MOV dword ptr [RAX],ECX
MOV dword ptr [R8 + -0x4],EDX
LAB_001013e8:
ADD RAX,0x4
CMP RAX,RSI
JNZ 0x001013d8
ADD R9,0x1
ADD R8,0x4
CMP R9,R11
JNZ 0x001013c0
LAB_001013fe:
MOVSXD R10,R10D
MOV R9D,0xcccccccd
NOP word ptr [RAX + RAX*0x1]
LAB_00101410:
MOV R8D,dword ptr [RDI + R10*0x4]
CMP R8D,0x9
JLE 0x001014c0
MOV ECX,0x1
NOP dword ptr [RAX + RAX*0x1]
LAB_00101428:
MOV EAX,R8D
LEA ECX,[RCX + RCX*0x4]
ADD ECX,ECX
CDQ
IDIV ECX
CMP EAX,0x9
JG 0x00101428
MOVSXD RDX,R8D
MOV ESI,R8D
IMUL RDX,RDX,0x66666667
SAR ESI,0x1f
SAR RDX,0x22
SUB EDX,ESI
MOV ESI,R8D
LEA EDX,[RDX + RDX*0x4]
ADD EDX,EDX
SUB ESI,EDX
CMP EAX,ESI
JNZ 0x001014a0
MOV ESI,R8D
NOP
LAB_00101460:
MOV EAX,ESI
CDQ
IDIV ECX
MOV ECX,ECX
IMUL RCX,RCX,0x51eb851f
SHR RCX,0x25
IMUL RDX,R9
SHR RDX,0x23
MOV RSI,RDX
TEST EDX,EDX
JZ 0x001014b3
MOV EAX,ESI
MOV R11D,ESI
CDQ
IDIV ECX
MOV EDX,ESI
IMUL RDX,R9
SHR RDX,0x23
LEA EDX,[RDX + RDX*0x4]
ADD EDX,EDX
SUB R11D,EDX
CMP EAX,R11D
JZ 0x00101460
LAB_001014a0:
SUB R10,0x1
TEST R10D,R10D
JNS 0x00101410
LAB_001014ad:
MOV R8D,0xffffffff
LAB_001014b3:
MOV EAX,R8D
POP RBX
RET
LAB_001014c0:
TEST R8D,R8D
JZ 0x001014b3
MOVSXD RAX,R8D
MOV EDX,R8D
IMUL RAX,RAX,0x66666667
SAR EDX,0x1f
SAR RAX,0x22
SUB EAX,EDX
MOV EDX,R8D
LEA EAX,[RAX + RAX*0x4]
ADD EAX,EAX
SUB EDX,EAX
CMP R8D,EDX
JNZ 0x001014a0
MOV EAX,R8D
POP RBX
RET
LAB_001014ef:
TEST R10D,R10D
JNS 0x001013fe
JMP 0x001014ad | uint func0(long param_1,uint param_2)
{
int iVar1;
uint uVar2;
uint uVar3;
int *piVar4;
uint uVar5;
ulong uVar6;
int *piVar7;
ulong uVar8;
int iVar9;
long lVar10;
iVar9 = param_2 - 1;
if ((int)param_2 < 1) {
if (iVar9 < 0) {
return 0xffffffff;
}
}
else {
uVar8 = 1;
piVar7 = (int *)(param_1 + 4);
if ((ulong)param_2 != 1) {
do {
piVar4 = piVar7;
do {
iVar1 = *piVar4;
if (iVar1 < piVar7[-1]) {
*piVar4 = piVar7[-1];
piVar7[-1] = iVar1;
}
piVar4 = piVar4 + 1;
} while (piVar4 != (int *)(param_1 + 8 +
((uVar8 - 1) + (ulong)(uint)(iVar9 - (int)uVar8)) * 4));
uVar8 = uVar8 + 1;
piVar7 = piVar7 + 1;
} while (uVar8 != param_2);
}
}
lVar10 = (long)iVar9;
do {
uVar2 = *(uint *)(param_1 + lVar10 * 4);
if ((int)uVar2 < 10) {
if (uVar2 == 0) {
return 0;
}
if (uVar2 == (int)uVar2 % 10) {
return uVar2;
}
}
else {
uVar5 = 1;
do {
uVar5 = uVar5 * 10;
} while (9 < (int)uVar2 / (int)uVar5);
if ((int)uVar2 / (int)uVar5 == (int)uVar2 % 10) {
uVar8 = (ulong)uVar2;
do {
uVar6 = (long)(int)uVar8 % (long)(int)uVar5 & 0xffffffff;
uVar8 = uVar6 / 10;
if ((int)(uVar6 / 10) == 0) {
return uVar2;
}
uVar3 = uVar5 / 100;
uVar5 = uVar5 / 100;
} while ((uint)(uVar6 / 10) / uVar3 == (int)(uVar6 / 10) + (int)(uVar8 / 10) * -10);
}
}
lVar10 = lVar10 + -1;
if ((int)lVar10 < 0) {
return 0xffffffff;
}
} while( true );
} |
5,835 | func0 |
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
bool is_palindrome(int n) {
int divisor = 1;
while (n / divisor >= 10) {
divisor *= 10;
}
while (n != 0) {
int leading = n / divisor;
int trailing = n % 10;
if (leading != trailing) {
return false;
}
n = (n % divisor) / 10;
divisor = divisor / 100;
}
return true;
}
| int func0(int A[], int n) {
int i, j, temp;
// Sorting the array A
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (A[i] > A[j]) {
temp = A[j];
A[j] = A[i];
A[i] = temp;
}
}
}
// Finding the largest palindrome
for (i = n - 1; i >= 0; i--) {
if (is_palindrome(A[i])) {
return A[i];
}
}
return -1;
}
| int main() {
int arr1[4] = {1, 232, 54545, 999991};
int arr2[6] = {1, 2, 3, 4, 5, 50};
int arr3[5] = {1, 3, 7, 9, 45};
assert(func0(arr1, 4) == 54545);
assert(func0(arr2, 6) == 5);
assert(func0(arr3, 5) == 9);
printf("All test cases passed.\n");
return 0;
}
| O3 | c | func0:
endbr64
lea -0x1(%rsi),%r10d
test %esi,%esi
jle 14be <func0+0x13e>
cmp $0x1,%esi
je 13d2 <func0+0x52>
lea -0x2(%rsi),%r9d
mov $0x1,%r8d
add $0x2,%r9
nopl 0x0(%rax,%rax,1)
mov -0x4(%rdi,%r8,4),%ecx
mov %r8,%rax
mov (%rdi,%rax,4),%edx
cmp %ecx,%edx
jge 13c1 <func0+0x41>
mov %ecx,(%rdi,%rax,4)
mov %edx,%ecx
mov %edx,-0x4(%rdi,%r8,4)
add $0x1,%rax
cmp %eax,%esi
jg 13b0 <func0+0x30>
add $0x1,%r8
cmp %r8,%r9
jne 13a8 <func0+0x28>
movslq %r10d,%r10
mov $0xcccccccd,%r9d
nopl 0x0(%rax,%rax,1)
mov (%rdi,%r10,4),%r8d
cmp $0x9,%r8d
jle 1490 <func0+0x110>
mov $0x1,%ecx
nopl 0x0(%rax,%rax,1)
mov %r8d,%eax
lea (%rcx,%rcx,4),%ecx
add %ecx,%ecx
cltd
idiv %ecx
cmp $0x9,%eax
jg 13f8 <func0+0x78>
movslq %r8d,%rdx
mov %r8d,%esi
imul $0x66666667,%rdx,%rdx
sar $0x1f,%esi
sar $0x22,%rdx
sub %esi,%edx
mov %r8d,%esi
lea (%rdx,%rdx,4),%edx
add %edx,%edx
sub %edx,%esi
cmp %esi,%eax
jne 1470 <func0+0xf0>
mov %r8d,%esi
mov %esi,%eax
cltd
idiv %ecx
mov %ecx,%ecx
imul $0x51eb851f,%rcx,%rcx
shr $0x25,%rcx
mov %rdx,%rsi
imul %r9,%rsi
shr $0x23,%rsi
test %esi,%esi
je 1483 <func0+0x103>
mov %esi,%eax
mov %esi,%r11d
cltd
idiv %ecx
mov %esi,%edx
imul %r9,%rdx
shr $0x23,%rdx
lea (%rdx,%rdx,4),%edx
add %edx,%edx
sub %edx,%r11d
cmp %r11d,%eax
je 1430 <func0+0xb0>
sub $0x1,%r10
test %r10d,%r10d
jns 13e0 <func0+0x60>
mov $0xffffffff,%r8d
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
test %r8d,%r8d
je 1483 <func0+0x103>
movslq %r8d,%rax
mov %r8d,%edx
mov %r8d,%esi
imul $0x66666667,%rax,%rax
sar $0x1f,%edx
sar $0x22,%rax
sub %edx,%eax
lea (%rax,%rax,4),%eax
add %eax,%eax
sub %eax,%esi
cmp %r8d,%esi
jne 1470 <func0+0xf0>
mov %r8d,%eax
retq
test %r10d,%r10d
jns 13d2 <func0+0x52>
jmp 147d <func0+0xfd>
nopl 0x0(%rax)
| func0:
endbr64
mov r8, rdi
test esi, esi
jle loc_149D
cmp esi, 1
jz short loc_13D4
mov r9d, esi
mov edi, 1
nop dword ptr [rax+00h]
loc_13A0:
mov ecx, [r8+rdi*4-4]
mov rax, rdi
nop dword ptr [rax+rax+00000000h]
loc_13B0:
mov edx, [r8+rax*4]
cmp edx, ecx
jge short loc_13C3
mov [r8+rax*4], ecx
mov ecx, edx
mov [r8+rdi*4-4], edx
loc_13C3:
add rax, 1
cmp esi, eax
jg short loc_13B0
add rdi, 1
cmp r9, rdi
jnz short loc_13A0
loc_13D4:
sub esi, 1
movsxd r9, esi
nop word ptr [rax+rax+00h]
loc_13E0:
mov edi, [r8+r9*4]
cmp edi, 9
jle loc_14A8
mov esi, 1
nop word ptr [rax+rax+00h]
loc_13F8:
mov eax, edi
lea esi, [rsi+rsi*4]
add esi, esi
cdq
idiv esi
cmp eax, 9
jg short loc_13F8
loc_1407:
movsxd rdx, edi
mov ecx, edi
imul rdx, 66666667h
sar ecx, 1Fh
sar rdx, 22h
sub edx, ecx
mov ecx, edi
lea edx, [rdx+rdx*4]
add edx, edx
sub ecx, edx
cmp ecx, eax
jnz short loc_1490
mov ecx, edi
jmp short loc_145D
loc_1430:
mov eax, ecx
mov r10d, ecx
cdq
sar r10d, 1Fh
idiv esi
movsxd rdx, ecx
imul rdx, 66666667h
sar rdx, 22h
sub edx, r10d
mov r10d, ecx
lea edx, [rdx+rdx*4]
add edx, edx
sub r10d, edx
cmp eax, r10d
jnz short loc_1490
loc_145D:
mov eax, ecx
cdq
idiv esi
movsxd rax, esi
sar esi, 1Fh
imul rax, 51EB851Fh
sar rax, 25h
sub eax, esi
mov esi, eax
movsxd rcx, edx
sar edx, 1Fh
imul rcx, 66666667h
sar rcx, 22h
sub ecx, edx
jnz short loc_1430
loc_148C:
mov eax, edi
retn
loc_1490:
sub r9, 1
test r9d, r9d
jns loc_13E0
loc_149D:
mov edi, 0FFFFFFFFh
mov eax, edi
retn
loc_14A8:
test edi, edi
jz short loc_148C
mov eax, edi
mov esi, 1
jmp loc_1407 | long long func0(long long a1, int a2)
{
long long i; // rdi
int v4; // ecx
long long v5; // rax
int v6; // edx
long long v7; // r9
int v8; // edi
int v9; // esi
int v10; // eax
int v11; // ecx
int v12; // edx
if ( a2 <= 0 )
return 0xFFFFFFFFLL;
if ( a2 != 1 )
{
for ( i = 1LL; i != a2; ++i )
{
v4 = *(_DWORD *)(a1 + 4 * i - 4);
v5 = i;
do
{
v6 = *(_DWORD *)(a1 + 4 * v5);
if ( v6 < v4 )
{
*(_DWORD *)(a1 + 4 * v5) = v4;
v4 = v6;
*(_DWORD *)(a1 + 4 * i - 4) = v6;
}
++v5;
}
while ( a2 > (int)v5 );
}
}
v7 = a2 - 1;
while ( 1 )
{
v8 = *(_DWORD *)(a1 + 4 * v7);
if ( v8 <= 9 )
{
if ( !v8 )
return (unsigned int)v8;
v10 = *(_DWORD *)(a1 + 4 * v7);
v9 = 1;
}
else
{
v9 = 1;
do
{
v9 *= 10;
v10 = v8 / v9;
}
while ( v8 / v9 > 9 );
}
if ( v8 % 10 == v10 )
break;
LABEL_18:
if ( (int)--v7 < 0 )
return 0xFFFFFFFFLL;
}
v11 = *(_DWORD *)(a1 + 4 * v7);
while ( 1 )
{
v12 = v11 % v9;
v9 /= 100;
v11 = v12 / 10;
if ( !(v12 / 10) )
return (unsigned int)v8;
if ( v11 / v9 != v11 % 10 )
goto LABEL_18;
}
} | func0:
ENDBR64
MOV R8,RDI
TEST ESI,ESI
JLE 0x0010149d
CMP ESI,0x1
JZ 0x001013d4
MOV R9D,ESI
MOV EDI,0x1
NOP dword ptr [RAX]
LAB_001013a0:
MOV ECX,dword ptr [R8 + RDI*0x4 + -0x4]
MOV RAX,RDI
NOP dword ptr [RAX + RAX*0x1]
LAB_001013b0:
MOV EDX,dword ptr [R8 + RAX*0x4]
CMP EDX,ECX
JGE 0x001013c3
MOV dword ptr [R8 + RAX*0x4],ECX
MOV ECX,EDX
MOV dword ptr [R8 + RDI*0x4 + -0x4],EDX
LAB_001013c3:
ADD RAX,0x1
CMP ESI,EAX
JG 0x001013b0
ADD RDI,0x1
CMP R9,RDI
JNZ 0x001013a0
LAB_001013d4:
SUB ESI,0x1
MOVSXD R9,ESI
NOP word ptr [RAX + RAX*0x1]
LAB_001013e0:
MOV EDI,dword ptr [R8 + R9*0x4]
CMP EDI,0x9
JLE 0x001014a8
MOV ESI,0x1
NOP word ptr [RAX + RAX*0x1]
LAB_001013f8:
MOV EAX,EDI
LEA ESI,[RSI + RSI*0x4]
ADD ESI,ESI
CDQ
IDIV ESI
CMP EAX,0x9
JG 0x001013f8
LAB_00101407:
MOVSXD RDX,EDI
MOV ECX,EDI
IMUL RDX,RDX,0x66666667
SAR ECX,0x1f
SAR RDX,0x22
SUB EDX,ECX
MOV ECX,EDI
LEA EDX,[RDX + RDX*0x4]
ADD EDX,EDX
SUB ECX,EDX
CMP ECX,EAX
JNZ 0x00101490
MOV ECX,EDI
JMP 0x0010145d
LAB_00101430:
MOV EAX,ECX
MOV R10D,ECX
CDQ
SAR R10D,0x1f
IDIV ESI
MOVSXD RDX,ECX
IMUL RDX,RDX,0x66666667
SAR RDX,0x22
SUB EDX,R10D
MOV R10D,ECX
LEA EDX,[RDX + RDX*0x4]
ADD EDX,EDX
SUB R10D,EDX
CMP EAX,R10D
JNZ 0x00101490
LAB_0010145d:
MOV EAX,ECX
CDQ
IDIV ESI
MOVSXD RAX,ESI
SAR ESI,0x1f
IMUL RAX,RAX,0x51eb851f
SAR RAX,0x25
SUB EAX,ESI
MOV ESI,EAX
MOVSXD RCX,EDX
SAR EDX,0x1f
IMUL RCX,RCX,0x66666667
SAR RCX,0x22
SUB ECX,EDX
JNZ 0x00101430
LAB_0010148c:
MOV EAX,EDI
RET
LAB_00101490:
SUB R9,0x1
TEST R9D,R9D
JNS 0x001013e0
LAB_0010149d:
MOV EDI,0xffffffff
MOV EAX,EDI
RET
LAB_001014a8:
TEST EDI,EDI
JZ 0x0010148c
MOV EAX,EDI
MOV ESI,0x1
JMP 0x00101407 | int func0(long param_1,uint param_2)
{
int iVar1;
ulong uVar2;
int iVar3;
int iVar4;
int iVar5;
ulong uVar6;
long lVar7;
if (0 < (int)param_2) {
if (param_2 != 1) {
uVar6 = 1;
do {
iVar3 = *(int *)(param_1 + -4 + uVar6 * 4);
uVar2 = uVar6;
do {
iVar5 = *(int *)(param_1 + uVar2 * 4);
if (iVar5 < iVar3) {
*(int *)(param_1 + uVar2 * 4) = iVar3;
*(int *)(param_1 + -4 + uVar6 * 4) = iVar5;
iVar3 = iVar5;
}
uVar2 = uVar2 + 1;
} while ((int)uVar2 < (int)param_2);
uVar6 = uVar6 + 1;
} while (param_2 != uVar6);
}
lVar7 = (long)(int)(param_2 - 1);
do {
iVar3 = *(int *)(param_1 + lVar7 * 4);
if (iVar3 < 10) {
if (iVar3 == 0) {
return 0;
}
iVar5 = 1;
iVar1 = iVar3;
}
else {
iVar5 = 1;
do {
iVar5 = iVar5 * 10;
iVar1 = iVar3 / iVar5;
} while (9 < iVar3 / iVar5);
}
iVar4 = iVar3;
if (iVar3 % 10 == iVar1) {
do {
iVar4 = iVar4 % iVar5;
iVar5 = iVar5 / 100;
iVar4 = iVar4 / 10;
if (iVar4 == 0) {
return iVar3;
}
} while (iVar4 / iVar5 == iVar4 % 10);
}
lVar7 = lVar7 + -1;
} while (-1 < (int)lVar7);
}
return -1;
} |
5,836 | func0 | #include <assert.h>
#include <math.h>
| double func0(int n, int r, double p) {
int r0 = r;
if (r > n / 2) r = n - r;
double answer = 1.0;
for (int i = 1; i <= r; i++) {
answer *= (n - r + i);
answer /= i;
}
return answer * pow(p, r0) * pow(1 - p, n - r0);
}
| int main() {
assert(fabs(func0(10, 5, 1.0 / 3) - 0.13656454808718185) < 0.0000001);
assert(fabs(func0(11, 6, 2.0 / 4) - 0.2255859375) < 0.0000001);
assert(fabs(func0(12, 7, 3.0 / 5) - 0.227030335488) < 0.0000001);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %edi,-0x14(%rbp)
mov %esi,-0x18(%rbp)
movsd %xmm0,-0x20(%rbp)
mov -0x18(%rbp),%eax
mov %eax,-0xc(%rbp)
mov -0x14(%rbp),%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
cmp %eax,-0x18(%rbp)
jle 11a0 <func0+0x37>
mov -0x14(%rbp),%eax
sub -0x18(%rbp),%eax
mov %eax,-0x18(%rbp)
movsd 0xf60(%rip),%xmm0
movsd %xmm0,-0x8(%rbp)
movl $0x1,-0x10(%rbp)
jmp 11ec <func0+0x83>
mov -0x14(%rbp),%eax
sub -0x18(%rbp),%eax
mov %eax,%edx
mov -0x10(%rbp),%eax
add %edx,%eax
cvtsi2sd %eax,%xmm0
movsd -0x8(%rbp),%xmm1
mulsd %xmm1,%xmm0
movsd %xmm0,-0x8(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd -0x8(%rbp),%xmm0
divsd %xmm1,%xmm0
movsd %xmm0,-0x8(%rbp)
addl $0x1,-0x10(%rbp)
mov -0x10(%rbp),%eax
cmp -0x18(%rbp),%eax
jle 11b6 <func0+0x4d>
cvtsi2sdl -0xc(%rbp),%xmm0
mov -0x20(%rbp),%rax
movapd %xmm0,%xmm1
movq %rax,%xmm0
callq 1060 <pow@plt>
mulsd -0x8(%rbp),%xmm0
movsd %xmm0,-0x28(%rbp)
mov -0x14(%rbp),%eax
sub -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd 0xee1(%rip),%xmm0
subsd -0x20(%rbp),%xmm0
callq 1060 <pow@plt>
mulsd -0x28(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
mov [rbp+var_14], edi
mov [rbp+var_18], esi
movsd [rbp+x], xmm0
mov eax, [rbp+var_18]
mov [rbp+var_C], eax
mov eax, [rbp+var_14]
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
cmp [rbp+var_18], eax
jle short loc_11A0
mov eax, [rbp+var_14]
sub eax, [rbp+var_18]
mov [rbp+var_18], eax
loc_11A0:
movsd xmm0, cs:qword_20E8
movsd [rbp+var_8], xmm0
mov [rbp+var_10], 1
jmp short loc_11F4
loc_11B6:
mov eax, [rbp+var_14]
sub eax, [rbp+var_18]
mov edx, eax
mov eax, [rbp+var_10]
add eax, edx
pxor xmm0, xmm0
cvtsi2sd xmm0, eax
movsd xmm1, [rbp+var_8]
mulsd xmm0, xmm1
movsd [rbp+var_8], xmm0
pxor xmm1, xmm1
cvtsi2sd xmm1, [rbp+var_10]
movsd xmm0, [rbp+var_8]
divsd xmm0, xmm1
movsd [rbp+var_8], xmm0
add [rbp+var_10], 1
loc_11F4:
mov eax, [rbp+var_10]
cmp eax, [rbp+var_18]
jle short loc_11B6
pxor xmm0, xmm0
cvtsi2sd xmm0, [rbp+var_C]
mov rax, [rbp+x]
movapd xmm1, xmm0; y
movq xmm0, rax; x
call _pow
movq rax, xmm0
movq xmm2, rax
mulsd xmm2, [rbp+var_8]
movsd [rbp+var_28], xmm2
mov eax, [rbp+var_14]
sub eax, [rbp+var_C]
pxor xmm1, xmm1
cvtsi2sd xmm1, eax; y
movsd xmm0, cs:qword_20E8
subsd xmm0, [rbp+x]
movq rax, xmm0
movq xmm0, rax; x
call _pow
mulsd xmm0, [rbp+var_28]
leave
retn | double func0(int a1, int a2, double a3)
{
double v4; // [rsp+8h] [rbp-28h]
int v6; // [rsp+18h] [rbp-18h]
int i; // [rsp+20h] [rbp-10h]
double v8; // [rsp+28h] [rbp-8h]
v6 = a2;
if ( a2 > a1 / 2 )
v6 = a1 - a2;
v8 = 1.0;
for ( i = 1; i <= v6; ++i )
v8 = (double)(a1 - v6 + i) * v8 / (double)i;
v4 = pow(a3, (double)a2) * v8;
return pow(1.0 - a3, (double)(a1 - a2)) * v4;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV dword ptr [RBP + -0x14],EDI
MOV dword ptr [RBP + -0x18],ESI
MOVSD qword ptr [RBP + -0x20],XMM0
MOV EAX,dword ptr [RBP + -0x18]
MOV dword ptr [RBP + -0xc],EAX
MOV EAX,dword ptr [RBP + -0x14]
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
CMP dword ptr [RBP + -0x18],EAX
JLE 0x001011a0
MOV EAX,dword ptr [RBP + -0x14]
SUB EAX,dword ptr [RBP + -0x18]
MOV dword ptr [RBP + -0x18],EAX
LAB_001011a0:
MOVSD XMM0,qword ptr [0x001020e8]
MOVSD qword ptr [RBP + -0x8],XMM0
MOV dword ptr [RBP + -0x10],0x1
JMP 0x001011f4
LAB_001011b6:
MOV EAX,dword ptr [RBP + -0x14]
SUB EAX,dword ptr [RBP + -0x18]
MOV EDX,EAX
MOV EAX,dword ptr [RBP + -0x10]
ADD EAX,EDX
PXOR XMM0,XMM0
CVTSI2SD XMM0,EAX
MOVSD XMM1,qword ptr [RBP + -0x8]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x8],XMM0
PXOR XMM1,XMM1
CVTSI2SD XMM1,dword ptr [RBP + -0x10]
MOVSD XMM0,qword ptr [RBP + -0x8]
DIVSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x8],XMM0
ADD dword ptr [RBP + -0x10],0x1
LAB_001011f4:
MOV EAX,dword ptr [RBP + -0x10]
CMP EAX,dword ptr [RBP + -0x18]
JLE 0x001011b6
PXOR XMM0,XMM0
CVTSI2SD XMM0,dword ptr [RBP + -0xc]
MOV RAX,qword ptr [RBP + -0x20]
MOVAPD XMM1,XMM0
MOVQ XMM0,RAX
CALL 0x00101060
MOVQ RAX,XMM0
MOVQ XMM2,RAX
MULSD XMM2,qword ptr [RBP + -0x8]
MOVSD qword ptr [RBP + -0x28],XMM2
MOV EAX,dword ptr [RBP + -0x14]
SUB EAX,dword ptr [RBP + -0xc]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
MOVSD XMM0,qword ptr [0x001020e8]
SUBSD XMM0,qword ptr [RBP + -0x20]
MOVQ RAX,XMM0
MOVQ XMM0,RAX
CALL 0x00101060
MULSD XMM0,qword ptr [RBP + -0x28]
LEAVE
RET | double func0(double param_1,int param_2,int param_3)
{
double dVar1;
double dVar2;
int4 local_20;
int4 local_18;
int8 local_10;
local_20 = param_3;
if (param_2 / 2 < param_3) {
local_20 = param_2 - param_3;
}
local_10 = DAT_001020e8;
for (local_18 = 1; local_18 <= local_20; local_18 = local_18 + 1) {
local_10 = ((double)(local_18 + (param_2 - local_20)) * local_10) / (double)local_18;
}
dVar1 = pow(param_1,(double)param_3);
dVar2 = pow(DAT_001020e8 - param_1,(double)(param_2 - param_3));
return dVar2 * dVar1 * local_10;
} |
5,837 | func0 | #include <assert.h>
#include <math.h>
| double func0(int n, int r, double p) {
int r0 = r;
if (r > n / 2) r = n - r;
double answer = 1.0;
for (int i = 1; i <= r; i++) {
answer *= (n - r + i);
answer /= i;
}
return answer * pow(p, r0) * pow(1 - p, n - r0);
}
| int main() {
assert(fabs(func0(10, 5, 1.0 / 3) - 0.13656454808718185) < 0.0000001);
assert(fabs(func0(11, 6, 2.0 / 4) - 0.2255859375) < 0.0000001);
assert(fabs(func0(12, 7, 3.0 / 5) - 0.227030335488) < 0.0000001);
return 0;
}
| O1 | c | func0:
endbr64
push %rbp
push %rbx
sub $0x28,%rsp
mov %edi,%ebx
mov %esi,%ebp
movsd %xmm0,0x10(%rsp)
mov %edi,%eax
shr $0x1f,%eax
add %edi,%eax
sar %eax
mov %edi,%edx
sub %esi,%edx
cmp %esi,%eax
mov %edx,%eax
cmovge %esi,%eax
test %eax,%eax
jle 122e <func0+0xc5>
lea 0x1(%rax),%esi
mov $0x1,%edx
movsd 0xf57(%rip),%xmm5
movsd %xmm5,0x8(%rsp)
mov %edi,%ecx
sub %eax,%ecx
lea (%rcx,%rdx,1),%eax
pxor %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd 0x8(%rsp),%xmm0
pxor %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd %xmm1,%xmm0
movsd %xmm0,0x8(%rsp)
add $0x1,%edx
cmp %esi,%edx
jne 11b3 <func0+0x4a>
pxor %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd 0x10(%rsp),%xmm0
callq 1060 <pow@plt>
movsd %xmm0,0x18(%rsp)
sub %ebp,%ebx
movsd 0xf00(%rip),%xmm0
subsd 0x10(%rsp),%xmm0
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
callq 1060 <pow@plt>
movapd %xmm0,%xmm1
movsd 0x18(%rsp),%xmm0
mulsd 0x8(%rsp),%xmm0
mulsd %xmm1,%xmm0
add $0x28,%rsp
pop %rbx
pop %rbp
retq
movsd 0xeca(%rip),%xmm6
movsd %xmm6,0x8(%rsp)
jmp 11dd <func0+0x74>
| func0:
endbr64
push r15
push r14
push rbp
push rbx
sub rsp, 18h
mov ebx, edi
mov ebp, esi
movq r14, xmm0
mov eax, edi
shr eax, 1Fh
add eax, edi
sar eax, 1
mov edx, edi
sub edx, esi
cmp eax, esi
cmovge edx, esi
test edx, edx
jle loc_1233
lea esi, [rdx+1]
mov eax, 1
movsd xmm5, cs:qword_20E0
movsd [rsp+38h+var_30], xmm5
mov ecx, edi
sub ecx, edx
loc_11B4:
lea edx, [rcx+rax]
pxor xmm0, xmm0
cvtsi2sd xmm0, edx
mulsd xmm0, [rsp+38h+var_30]
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
divsd xmm0, xmm1
movsd [rsp+38h+var_30], xmm0
add eax, 1
cmp eax, esi
jnz short loc_11B4
loc_11DE:
pxor xmm1, xmm1
cvtsi2sd xmm1, ebp
movq xmm0, r14
call _pow
movq r15, xmm0
sub ebx, ebp
movsd xmm0, cs:qword_20E0
movq xmm3, r14
subsd xmm0, xmm3
pxor xmm1, xmm1
cvtsi2sd xmm1, ebx
call _pow
movapd xmm1, xmm0
movq xmm0, r15
mulsd xmm0, [rsp+38h+var_30]
mulsd xmm0, xmm1
add rsp, 18h
pop rbx
pop rbp
pop r14
pop r15
retn
loc_1233:
movsd xmm6, cs:qword_20E0
movsd [rsp+38h+var_30], xmm6
jmp short loc_11DE | double func0(int a1, int a2, double a3)
{
int v4; // edx
int v5; // eax
double v6; // r15
double v8; // [rsp+8h] [rbp-30h]
v4 = a1 - a2;
if ( a1 / 2 >= a2 )
v4 = a2;
if ( v4 <= 0 )
{
v8 = 1.0;
}
else
{
v5 = 1;
v8 = 1.0;
do
{
v8 = (double)(a1 - v4 + v5) * v8 / (double)v5;
++v5;
}
while ( v5 != v4 + 1 );
}
v6 = pow(a3, (double)a2);
return v6 * v8 * pow(1.0 - a3, (double)(a1 - a2));
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH RBP
PUSH RBX
SUB RSP,0x18
MOV EBX,EDI
MOV EBP,ESI
MOVQ R14,XMM0
MOV EAX,EDI
SHR EAX,0x1f
ADD EAX,EDI
SAR EAX,0x1
MOV EDX,EDI
SUB EDX,ESI
CMP EAX,ESI
CMOVGE EDX,ESI
TEST EDX,EDX
JLE 0x00101233
LEA ESI,[RDX + 0x1]
MOV EAX,0x1
MOVSD XMM5,qword ptr [0x001020e0]
MOVSD qword ptr [RSP + 0x8],XMM5
MOV ECX,EDI
SUB ECX,EDX
LAB_001011b4:
LEA EDX,[RCX + RAX*0x1]
PXOR XMM0,XMM0
CVTSI2SD XMM0,EDX
MULSD XMM0,qword ptr [RSP + 0x8]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
DIVSD XMM0,XMM1
MOVSD qword ptr [RSP + 0x8],XMM0
ADD EAX,0x1
CMP EAX,ESI
JNZ 0x001011b4
LAB_001011de:
PXOR XMM1,XMM1
CVTSI2SD XMM1,EBP
MOVQ XMM0,R14
CALL 0x00101060
MOVQ R15,XMM0
SUB EBX,EBP
MOVSD XMM0,qword ptr [0x001020e0]
MOVQ XMM3,R14
SUBSD XMM0,XMM3
PXOR XMM1,XMM1
CVTSI2SD XMM1,EBX
CALL 0x00101060
MOVAPD XMM1,XMM0
MOVQ XMM0,R15
MULSD XMM0,qword ptr [RSP + 0x8]
MULSD XMM0,XMM1
ADD RSP,0x18
POP RBX
POP RBP
POP R14
POP R15
RET
LAB_00101233:
MOVSD XMM6,qword ptr [0x001020e0]
MOVSD qword ptr [RSP + 0x8],XMM6
JMP 0x001011de | double func0(double param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
double dVar3;
double dVar4;
int8 local_30;
iVar2 = param_2 - param_3;
if (param_3 <= param_2 / 2) {
iVar2 = param_3;
}
if (iVar2 < 1) {
local_30 = DAT_001020e0;
}
else {
iVar1 = 1;
local_30 = DAT_001020e0;
do {
local_30 = ((double)((param_2 - iVar2) + iVar1) * local_30) / (double)iVar1;
iVar1 = iVar1 + 1;
} while (iVar1 != iVar2 + 1);
}
dVar3 = pow(param_1,(double)param_3);
dVar4 = pow(DAT_001020e0 - param_1,(double)(param_2 - param_3));
return dVar3 * local_30 * dVar4;
} |
5,838 | func0 | #include <assert.h>
#include <math.h>
| double func0(int n, int r, double p) {
int r0 = r;
if (r > n / 2) r = n - r;
double answer = 1.0;
for (int i = 1; i <= r; i++) {
answer *= (n - r + i);
answer /= i;
}
return answer * pow(p, r0) * pow(1 - p, n - r0);
}
| int main() {
assert(fabs(func0(10, 5, 1.0 / 3) - 0.13656454808718185) < 0.0000001);
assert(fabs(func0(11, 6, 2.0 / 4) - 0.2255859375) < 0.0000001);
assert(fabs(func0(12, 7, 3.0 / 5) - 0.227030335488) < 0.0000001);
return 0;
}
| O2 | c | func0:
endbr64
mov %edi,%eax
push %rbx
mov %edi,%ebx
mov %esi,%ecx
shr $0x1f,%eax
sub %esi,%ebx
movapd %xmm0,%xmm3
add %edi,%eax
sar %eax
sub $0x20,%rsp
cmp %esi,%eax
cmovl %ebx,%ecx
test %ecx,%ecx
jle 1340 <func0+0xc0>
movsd 0xe4f(%rip),%xmm4
sub %ecx,%edi
mov $0x1,%eax
add $0x1,%ecx
movapd %xmm4,%xmm2
lea (%rax,%rdi,1),%edx
pxor %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd %xmm0,%xmm2
pxor %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add $0x1,%eax
divsd %xmm0,%xmm2
cmp %ecx,%eax
jne 12c0 <func0+0x40>
pxor %xmm1,%xmm1
movapd %xmm3,%xmm0
movsd %xmm2,0x10(%rsp)
cvtsi2sd %esi,%xmm1
movsd %xmm4,0x18(%rsp)
movsd %xmm3,0x8(%rsp)
callq 1060 <pow@plt>
movsd 0x18(%rsp),%xmm4
movsd 0x8(%rsp),%xmm3
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd %xmm0,(%rsp)
subsd %xmm3,%xmm4
movapd %xmm4,%xmm0
callq 1060 <pow@plt>
movsd 0x10(%rsp),%xmm2
mulsd (%rsp),%xmm2
add $0x20,%rsp
pop %rbx
mulsd %xmm2,%xmm0
retq
movsd 0xdb8(%rip),%xmm4
movapd %xmm4,%xmm2
jmp 12e2 <func0+0x62>
xchg %ax,%ax
| func0:
endbr64
mov eax, edi
push rbx
mov ebx, edi
mov ecx, esi
shr eax, 1Fh
sub ebx, esi
movapd xmm3, xmm0
add eax, edi
sar eax, 1
sub rsp, 20h
cmp eax, esi
cmovl ecx, ebx
test ecx, ecx
jle loc_1350
movsd xmm4, cs:qword_20E0
sub edi, ecx
mov eax, 1
add ecx, 1
movapd xmm2, xmm4
nop
loc_12C0:
lea edx, [rax+rdi]
pxor xmm1, xmm1
cvtsi2sd xmm1, edx
mulsd xmm2, xmm1
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
add eax, 1
divsd xmm2, xmm1
cmp ecx, eax
jnz short loc_12C0
loc_12E2:
pxor xmm1, xmm1
movapd xmm0, xmm3
movsd [rsp+28h+var_18], xmm2
cvtsi2sd xmm1, esi
movsd [rsp+28h+var_10], xmm4
movsd [rsp+28h+var_20], xmm3
call _pow
movsd xmm4, [rsp+28h+var_10]
movsd xmm3, [rsp+28h+var_20]
pxor xmm1, xmm1
cvtsi2sd xmm1, ebx
movsd [rsp+28h+var_28], xmm0
subsd xmm4, xmm3
movapd xmm0, xmm4
call _pow
movsd xmm2, [rsp+28h+var_18]
movapd xmm1, xmm0
movsd xmm0, [rsp+28h+var_28]
add rsp, 20h
pop rbx
mulsd xmm0, xmm2
mulsd xmm0, xmm1
retn
loc_1350:
movsd xmm4, cs:qword_20E0
movapd xmm2, xmm4
jmp short loc_12E2 | double func0(int a1, int a2, double a3)
{
int v3; // ecx
int v4; // ebx
int v5; // edi
int v6; // eax
int v7; // ecx
double v8; // xmm2_8
int v9; // edx
double v10; // xmm1_8
double v12; // [rsp+0h] [rbp-28h]
v3 = a2;
v4 = a1 - a2;
if ( a1 / 2 < a2 )
v3 = a1 - a2;
if ( v3 <= 0 )
{
v8 = 1.0;
}
else
{
v5 = a1 - v3;
v6 = 1;
v7 = v3 + 1;
v8 = 1.0;
do
{
v9 = v6 + v5;
v10 = (double)v6++;
v8 = v8 * (double)v9 / v10;
}
while ( v7 != v6 );
}
v12 = pow(a3, (double)a2);
return v12 * v8 * pow(1.0 - a3, (double)v4);
} | func0:
ENDBR64
MOV EAX,EDI
PUSH RBX
MOV EBX,EDI
MOV ECX,ESI
SHR EAX,0x1f
SUB EBX,ESI
MOVAPD XMM3,XMM0
ADD EAX,EDI
SAR EAX,0x1
SUB RSP,0x20
CMP EAX,ESI
CMOVL ECX,EBX
TEST ECX,ECX
JLE 0x00101350
MOVSD XMM4,qword ptr [0x001020e0]
SUB EDI,ECX
MOV EAX,0x1
ADD ECX,0x1
MOVAPD XMM2,XMM4
NOP
LAB_001012c0:
LEA EDX,[RAX + RDI*0x1]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EDX
MULSD XMM2,XMM1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
ADD EAX,0x1
DIVSD XMM2,XMM1
CMP ECX,EAX
JNZ 0x001012c0
LAB_001012e2:
PXOR XMM1,XMM1
MOVAPD XMM0,XMM3
MOVSD qword ptr [RSP + 0x10],XMM2
CVTSI2SD XMM1,ESI
MOVSD qword ptr [RSP + 0x18],XMM4
MOVSD qword ptr [RSP + 0x8],XMM3
CALL 0x00101060
MOVSD XMM4,qword ptr [RSP + 0x18]
MOVSD XMM3,qword ptr [RSP + 0x8]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EBX
MOVSD qword ptr [RSP],XMM0
SUBSD XMM4,XMM3
MOVAPD XMM0,XMM4
CALL 0x00101060
MOVSD XMM2,qword ptr [RSP + 0x10]
MOVAPD XMM1,XMM0
MOVSD XMM0,qword ptr [RSP]
ADD RSP,0x20
POP RBX
MULSD XMM0,XMM2
MULSD XMM0,XMM1
RET
LAB_00101350:
MOVSD XMM4,qword ptr [0x001020e0]
MOVAPD XMM2,XMM4
JMP 0x001012e2 | double func0(double param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
double dVar4;
double dVar5;
double dVar6;
dVar4 = DAT_001020e0;
iVar3 = param_3;
if (param_2 / 2 < param_3) {
iVar3 = param_2 - param_3;
}
dVar6 = DAT_001020e0;
if (0 < iVar3) {
iVar2 = 1;
do {
iVar1 = iVar2 + (param_2 - iVar3);
dVar5 = (double)iVar2;
iVar2 = iVar2 + 1;
dVar6 = (dVar6 * (double)iVar1) / dVar5;
} while (iVar3 + 1 != iVar2);
}
dVar5 = pow(param_1,(double)param_3);
dVar4 = pow(dVar4 - param_1,(double)(param_2 - param_3));
return dVar5 * dVar6 * dVar4;
} |
5,839 | func0 | #include <assert.h>
#include <math.h>
| double func0(int n, int r, double p) {
int r0 = r;
if (r > n / 2) r = n - r;
double answer = 1.0;
for (int i = 1; i <= r; i++) {
answer *= (n - r + i);
answer /= i;
}
return answer * pow(p, r0) * pow(1 - p, n - r0);
}
| int main() {
assert(fabs(func0(10, 5, 1.0 / 3) - 0.13656454808718185) < 0.0000001);
assert(fabs(func0(11, 6, 2.0 / 4) - 0.2255859375) < 0.0000001);
assert(fabs(func0(12, 7, 3.0 / 5) - 0.227030335488) < 0.0000001);
return 0;
}
| O3 | c | func0:
endbr64
push %rbx
mov %edi,%eax
mov %edi,%ebx
shr $0x1f,%edi
add %eax,%edi
movapd %xmm0,%xmm3
sub %esi,%ebx
sar %edi
sub $0x20,%rsp
cmp %esi,%edi
jl 1350 <func0+0xd0>
mov %esi,%ecx
mov %ebx,%edi
test %ecx,%ecx
jle 135c <func0+0xdc>
movsd 0xe4a(%rip),%xmm4
add $0x1,%ecx
mov $0x1,%eax
movapd %xmm4,%xmm2
nopw 0x0(%rax,%rax,1)
lea (%rax,%rdi,1),%edx
pxor %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd %xmm0,%xmm2
pxor %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add $0x1,%eax
divsd %xmm0,%xmm2
cmp %eax,%ecx
jne 12c8 <func0+0x48>
pxor %xmm1,%xmm1
movapd %xmm3,%xmm0
movsd %xmm2,0x10(%rsp)
cvtsi2sd %esi,%xmm1
movsd %xmm4,0x18(%rsp)
movsd %xmm3,0x8(%rsp)
callq 1060 <pow@plt>
movsd 0x18(%rsp),%xmm4
movsd 0x8(%rsp),%xmm3
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd %xmm0,(%rsp)
subsd %xmm3,%xmm4
movapd %xmm4,%xmm0
callq 1060 <pow@plt>
movsd 0x10(%rsp),%xmm2
mulsd (%rsp),%xmm2
add $0x20,%rsp
pop %rbx
mulsd %xmm2,%xmm0
retq
nopl 0x0(%rax,%rax,1)
mov %ebx,%ecx
mov %esi,%edi
test %ecx,%ecx
jg 12ae <func0+0x2e>
movsd 0xd9c(%rip),%xmm4
movapd %xmm4,%xmm2
jmp 12ea <func0+0x6a>
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov eax, edi
push rbx
mov ebx, edi
movapd xmm3, xmm0
shr eax, 1Fh
sub ebx, esi
add eax, edi
sar eax, 1
sub rsp, 20h
cmp eax, esi
jl loc_1350
mov ecx, esi
mov edi, ebx
test ecx, ecx
jle loc_135C
loc_12AE:
movsd xmm4, cs:qword_20E0
add ecx, 1
mov eax, 1
movapd xmm2, xmm4
nop word ptr [rax+rax+00h]
loc_12C8:
lea edx, [rax+rdi]
pxor xmm1, xmm1
cvtsi2sd xmm1, edx
mulsd xmm2, xmm1
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
add eax, 1
divsd xmm2, xmm1
cmp eax, ecx
jnz short loc_12C8
loc_12EA:
pxor xmm1, xmm1
movapd xmm0, xmm3; x
movsd [rsp+28h+var_18], xmm2
cvtsi2sd xmm1, esi; y
movsd [rsp+28h+var_10], xmm4
movsd [rsp+28h+var_20], xmm3
call _pow
movsd xmm4, [rsp+28h+var_10]
movsd xmm3, [rsp+28h+var_20]
pxor xmm1, xmm1
cvtsi2sd xmm1, ebx; y
movsd [rsp+28h+var_28], xmm0
subsd xmm4, xmm3
movapd xmm0, xmm4; x
call _pow
movsd xmm2, [rsp+28h+var_18]
movapd xmm1, xmm0
movsd xmm0, [rsp+28h+var_28]
add rsp, 20h
pop rbx
mulsd xmm0, xmm2
mulsd xmm0, xmm1
retn
loc_1350:
mov ecx, ebx
mov edi, esi
test ecx, ecx
jg loc_12AE
loc_135C:
movsd xmm4, cs:qword_20E0
movapd xmm2, xmm4
jmp short loc_12EA | double func0(int a1, int a2, double a3)
{
int v3; // ebx
int v4; // ecx
int v5; // edi
int v6; // ecx
int v7; // eax
double v8; // xmm2_8
int v9; // edx
double v10; // xmm1_8
double v12; // [rsp+0h] [rbp-28h]
v3 = a1 - a2;
if ( a1 / 2 >= a2 )
{
v4 = a2;
v5 = a1 - a2;
if ( a2 > 0 )
goto LABEL_3;
LABEL_7:
v8 = 1.0;
goto LABEL_5;
}
v4 = a1 - a2;
v5 = a2;
if ( v3 <= 0 )
goto LABEL_7;
LABEL_3:
v6 = v4 + 1;
v7 = 1;
v8 = 1.0;
do
{
v9 = v7 + v5;
v10 = (double)v7++;
v8 = v8 * (double)v9 / v10;
}
while ( v7 != v6 );
LABEL_5:
v12 = pow(a3, (double)a2);
return v12 * v8 * pow(1.0 - a3, (double)v3);
} | func0:
ENDBR64
MOV EAX,EDI
PUSH RBX
MOV EBX,EDI
MOVAPD XMM3,XMM0
SHR EAX,0x1f
SUB EBX,ESI
ADD EAX,EDI
SAR EAX,0x1
SUB RSP,0x20
CMP EAX,ESI
JL 0x00101350
MOV ECX,ESI
MOV EDI,EBX
TEST ECX,ECX
JLE 0x0010135c
LAB_001012ae:
MOVSD XMM4,qword ptr [0x001020e0]
ADD ECX,0x1
MOV EAX,0x1
MOVAPD XMM2,XMM4
NOP word ptr [RAX + RAX*0x1]
LAB_001012c8:
LEA EDX,[RAX + RDI*0x1]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EDX
MULSD XMM2,XMM1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
ADD EAX,0x1
DIVSD XMM2,XMM1
CMP EAX,ECX
JNZ 0x001012c8
LAB_001012ea:
PXOR XMM1,XMM1
MOVAPD XMM0,XMM3
MOVSD qword ptr [RSP + 0x10],XMM2
CVTSI2SD XMM1,ESI
MOVSD qword ptr [RSP + 0x18],XMM4
MOVSD qword ptr [RSP + 0x8],XMM3
CALL 0x00101060
MOVSD XMM4,qword ptr [RSP + 0x18]
MOVSD XMM3,qword ptr [RSP + 0x8]
PXOR XMM1,XMM1
CVTSI2SD XMM1,EBX
MOVSD qword ptr [RSP],XMM0
SUBSD XMM4,XMM3
MOVAPD XMM0,XMM4
CALL 0x00101060
MOVSD XMM2,qword ptr [RSP + 0x10]
MOVAPD XMM1,XMM0
MOVSD XMM0,qword ptr [RSP]
ADD RSP,0x20
POP RBX
MULSD XMM0,XMM2
MULSD XMM0,XMM1
RET
LAB_00101350:
MOV ECX,EBX
MOV EDI,ESI
TEST ECX,ECX
JG 0x001012ae
LAB_0010135c:
MOVSD XMM4,qword ptr [0x001020e0]
MOVAPD XMM2,XMM4
JMP 0x001012ea | double func0(double param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
int iVar4;
int iVar5;
double dVar6;
double dVar7;
double dVar8;
dVar6 = DAT_001020e0;
iVar4 = param_2 - param_3;
dVar8 = DAT_001020e0;
if (param_2 / 2 < param_3) {
iVar3 = iVar4;
iVar5 = param_3;
if (iVar4 < 1) goto LAB_001012ea;
}
else {
iVar3 = param_3;
iVar5 = iVar4;
if (param_3 < 1) goto LAB_001012ea;
}
iVar2 = 1;
do {
iVar1 = iVar2 + iVar5;
dVar7 = (double)iVar2;
iVar2 = iVar2 + 1;
dVar8 = (dVar8 * (double)iVar1) / dVar7;
} while (iVar2 != iVar3 + 1);
LAB_001012ea:
dVar7 = pow(param_1,(double)param_3);
dVar6 = pow(dVar6 - param_1,(double)iVar4);
return dVar7 * dVar8 * dVar6;
} |
5,840 | func0 |
#include <assert.h>
#include <string.h>
| void func0(int tuples[][2], int n) {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (tuples[j][1] > tuples[j + 1][1]) {
int temp0 = tuples[j][0], temp1 = tuples[j][1];
tuples[j][0] = tuples[j + 1][0];
tuples[j][1] = tuples[j + 1][1];
tuples[j + 1][0] = temp0;
tuples[j + 1][1] = temp1;
}
}
}
}
| int main() {
int t1[3][2] = {{1, 3}, {3, 2}, {2, 1}};
int r1[3][2] = {{2, 1}, {3, 2}, {1, 3}};
func0(t1, 3);
assert(memcmp(t1, r1, sizeof(t1)) == 0);
int t2[3][2] = {{2, 4}, {3, 3}, {1, 1}};
int r2[3][2] = {{1, 1}, {3, 3}, {2, 4}};
func0(t2, 3);
assert(memcmp(t2, r2, sizeof(t2)) == 0);
int t3[3][2] = {{3, 9}, {6, 7}, {4, 3}};
int r3[3][2] = {{4, 3}, {6, 7}, {3, 9}};
func0(t3, 3);
assert(memcmp(t3, r3, sizeof(t3)) == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x0,-0x10(%rbp)
jmpq 12d6 <func0+0x14d>
movl $0x0,-0xc(%rbp)
jmpq 12c0 <func0+0x137>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov 0x4(%rax),%edx
mov -0xc(%rbp),%eax
cltq
add $0x1,%rax
lea 0x0(,%rax,8),%rcx
mov -0x18(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%eax
cmp %eax,%edx
jle 12bc <func0+0x133>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0x8(%rbp)
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov 0x4(%rax),%eax
mov %eax,-0x4(%rbp)
mov -0xc(%rbp),%eax
cltq
add $0x1,%rax
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov -0xc(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x18(%rbp),%rdx
add %rcx,%rdx
mov (%rax),%eax
mov %eax,(%rdx)
mov -0xc(%rbp),%eax
cltq
add $0x1,%rax
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov -0xc(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,8),%rcx
mov -0x18(%rbp),%rdx
add %rcx,%rdx
mov 0x4(%rax),%eax
mov %eax,0x4(%rdx)
mov -0xc(%rbp),%eax
cltq
add $0x1,%rax
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rax,%rdx
mov -0x8(%rbp),%eax
mov %eax,(%rdx)
mov -0xc(%rbp),%eax
cltq
add $0x1,%rax
lea 0x0(,%rax,8),%rdx
mov -0x18(%rbp),%rax
add %rax,%rdx
mov -0x4(%rbp),%eax
mov %eax,0x4(%rdx)
addl $0x1,-0xc(%rbp)
mov -0x1c(%rbp),%eax
sub -0x10(%rbp),%eax
sub $0x1,%eax
cmp %eax,-0xc(%rbp)
jl 11b0 <func0+0x27>
addl $0x1,-0x10(%rbp)
mov -0x10(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 11a4 <func0+0x1b>
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
jmp loc_12D6
loc_11A4:
mov [rbp+var_C], 0
jmp loc_12C0
loc_11B0:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov edx, [rax+4]
mov eax, [rbp+var_C]
cdqe
add rax, 1
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rcx
mov eax, [rax+4]
cmp edx, eax
jle loc_12BC
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
mov [rbp+var_8], eax
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax+4]
mov [rbp+var_4], eax
mov eax, [rbp+var_C]
cdqe
add rax, 1
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov edx, [rbp+var_C]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+var_18]
add rdx, rcx
mov eax, [rax]
mov [rdx], eax
mov eax, [rbp+var_C]
cdqe
add rax, 1
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rax, rdx
mov edx, [rbp+var_C]
movsxd rdx, edx
lea rcx, ds:0[rdx*8]
mov rdx, [rbp+var_18]
add rdx, rcx
mov eax, [rax+4]
mov [rdx+4], eax
mov eax, [rbp+var_C]
cdqe
add rax, 1
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rdx, rax
mov eax, [rbp+var_8]
mov [rdx], eax
mov eax, [rbp+var_C]
cdqe
add rax, 1
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_18]
add rdx, rax
mov eax, [rbp+var_4]
mov [rdx+4], eax
loc_12BC:
add [rbp+var_C], 1
loc_12C0:
mov eax, [rbp+var_1C]
sub eax, [rbp+var_10]
sub eax, 1
cmp [rbp+var_C], eax
jl loc_11B0
add [rbp+var_10], 1
loc_12D6:
mov eax, [rbp+var_10]
cmp eax, [rbp+var_1C]
jl loc_11A4
nop
nop
pop rbp
retn | long long func0(long long a1, int a2)
{
long long result; // rax
unsigned int i; // [rsp+Ch] [rbp-10h]
int j; // [rsp+10h] [rbp-Ch]
int v5; // [rsp+14h] [rbp-8h]
int v6; // [rsp+18h] [rbp-4h]
for ( i = 0; ; ++i )
{
result = i;
if ( (int)i >= a2 )
break;
for ( j = 0; j < (int)(a2 - i - 1); ++j )
{
if ( *(_DWORD *)(8LL * j + a1 + 4) > *(_DWORD *)(8 * (j + 1LL) + a1 + 4) )
{
v5 = *(_DWORD *)(8LL * j + a1);
v6 = *(_DWORD *)(8LL * j + a1 + 4);
*(_DWORD *)(8LL * j + a1) = *(_DWORD *)(8 * (j + 1LL) + a1);
*(_DWORD *)(8LL * j + a1 + 4) = *(_DWORD *)(8 * (j + 1LL) + a1 + 4);
*(_DWORD *)(a1 + 8 * (j + 1LL)) = v5;
*(_DWORD *)(a1 + 8 * (j + 1LL) + 4) = v6;
}
}
}
return result;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0x10],0x0
JMP 0x001012d6
LAB_001011a4:
MOV dword ptr [RBP + -0xc],0x0
JMP 0x001012c0
LAB_001011b0:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RAX + 0x4]
MOV EAX,dword ptr [RBP + -0xc]
CDQE
ADD RAX,0x1
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RCX
MOV EAX,dword ptr [RAX + 0x4]
CMP EDX,EAX
JLE 0x001012bc
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0x8],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EAX,dword ptr [RAX + 0x4]
MOV dword ptr [RBP + -0x4],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
ADD RAX,0x1
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0xc]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x18]
ADD RDX,RCX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RDX],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
ADD RAX,0x1
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0xc]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x8]
MOV RDX,qword ptr [RBP + -0x18]
ADD RDX,RCX
MOV EAX,dword ptr [RAX + 0x4]
MOV dword ptr [RDX + 0x4],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
ADD RAX,0x1
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x8]
MOV dword ptr [RDX],EAX
MOV EAX,dword ptr [RBP + -0xc]
CDQE
ADD RAX,0x1
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x18]
ADD RDX,RAX
MOV EAX,dword ptr [RBP + -0x4]
MOV dword ptr [RDX + 0x4],EAX
LAB_001012bc:
ADD dword ptr [RBP + -0xc],0x1
LAB_001012c0:
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,dword ptr [RBP + -0x10]
SUB EAX,0x1
CMP dword ptr [RBP + -0xc],EAX
JL 0x001011b0
ADD dword ptr [RBP + -0x10],0x1
LAB_001012d6:
MOV EAX,dword ptr [RBP + -0x10]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x001011a4
NOP
NOP
POP RBP
RET | void func0(long param_1,int param_2)
{
int4 uVar1;
int4 uVar2;
int4 local_18;
int4 local_14;
for (local_18 = 0; local_18 < param_2; local_18 = local_18 + 1) {
for (local_14 = 0; local_14 < (param_2 - local_18) + -1; local_14 = local_14 + 1) {
if (*(int *)(param_1 + ((long)local_14 + 1) * 8 + 4) <
*(int *)(param_1 + (long)local_14 * 8 + 4)) {
uVar1 = *(int4 *)(param_1 + (long)local_14 * 8);
uVar2 = *(int4 *)(param_1 + (long)local_14 * 8 + 4);
*(int4 *)(param_1 + (long)local_14 * 8) =
*(int4 *)(param_1 + ((long)local_14 + 1) * 8);
*(int4 *)(param_1 + (long)local_14 * 8 + 4) =
*(int4 *)(param_1 + ((long)local_14 + 1) * 8 + 4);
*(int4 *)(((long)local_14 + 1) * 8 + param_1) = uVar1;
*(int4 *)(((long)local_14 + 1) * 8 + param_1 + 4) = uVar2;
}
}
}
return;
} |
5,841 | func0 |
#include <assert.h>
#include <string.h>
| void func0(int tuples[][2], int n) {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (tuples[j][1] > tuples[j + 1][1]) {
int temp0 = tuples[j][0], temp1 = tuples[j][1];
tuples[j][0] = tuples[j + 1][0];
tuples[j][1] = tuples[j + 1][1];
tuples[j + 1][0] = temp0;
tuples[j + 1][1] = temp1;
}
}
}
}
| int main() {
int t1[3][2] = {{1, 3}, {3, 2}, {2, 1}};
int r1[3][2] = {{2, 1}, {3, 2}, {1, 3}};
func0(t1, 3);
assert(memcmp(t1, r1, sizeof(t1)) == 0);
int t2[3][2] = {{2, 4}, {3, 3}, {1, 1}};
int r2[3][2] = {{1, 1}, {3, 3}, {2, 4}};
func0(t2, 3);
assert(memcmp(t2, r2, sizeof(t2)) == 0);
int t3[3][2] = {{3, 9}, {6, 7}, {4, 3}};
int r3[3][2] = {{4, 3}, {6, 7}, {3, 9}};
func0(t3, 3);
assert(memcmp(t3, r3, sizeof(t3)) == 0);
return 0;
}
| O1 | c | func0:
endbr64
test %esi,%esi
jle 11ce <func0+0x45>
lea -0x1(%rsi),%r10d
lea 0x8(%rdi),%r11
jmp 11d3 <func0+0x4a>
add $0x8,%rax
cmp %rsi,%rax
je 11cf <func0+0x46>
mov 0x4(%rax),%edx
mov 0xc(%rax),%ecx
cmp %ecx,%edx
jle 119b <func0+0x12>
mov (%rax),%r8d
mov 0x8(%rax),%r9d
mov %r9d,(%rax)
mov %ecx,0x4(%rax)
mov %r8d,0x8(%rax)
mov %edx,0xc(%rax)
jmp 119b <func0+0x12>
sub $0x1,%r10d
cmp $0xffffffff,%r10d
jne 11d3 <func0+0x4a>
retq
sub $0x1,%r10d
test %r10d,%r10d
jle 11c4 <func0+0x3b>
mov %rdi,%rax
lea -0x1(%r10),%edx
lea (%r11,%rdx,8),%rsi
jmp 11a4 <func0+0x1b>
| func0:
endbr64
test esi, esi
jle short locret_11CE
lea r10d, [rsi-1]
lea r11, [rdi+8]
jmp short loc_11D3
loc_119B:
add rax, 8
cmp rax, rsi
jz short loc_11CF
loc_11A4:
mov edx, [rax+4]
mov ecx, [rax+0Ch]
cmp edx, ecx
jle short loc_119B
mov r8d, [rax]
mov r9d, [rax+8]
mov [rax], r9d
mov [rax+4], ecx
mov [rax+8], r8d
mov [rax+0Ch], edx
jmp short loc_119B
loc_11C4:
sub r10d, 1
cmp r10d, 0FFFFFFFFh
jnz short loc_11D3
locret_11CE:
retn
loc_11CF:
sub r10d, 1
loc_11D3:
test r10d, r10d
jle short loc_11C4
mov rax, rdi
lea edx, [r10-1]
lea rsi, [r11+rdx*8]
jmp short loc_11A4 | void func0(int *a1, int a2)
{
int v2; // r10d
int *v3; // rax
int v4; // edx
int v5; // ecx
int v6; // r8d
if ( a2 > 0 )
{
v2 = a2 - 1;
do
{
while ( v2 > 0 )
{
v3 = a1;
do
{
v4 = v3[1];
v5 = v3[3];
if ( v4 > v5 )
{
v6 = *v3;
*v3 = v3[2];
v3[1] = v5;
v3[2] = v6;
v3[3] = v4;
}
v3 += 2;
}
while ( v3 != &a1[2 * (v2 - 1) + 2] );
--v2;
}
--v2;
}
while ( v2 != -1 );
}
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001011ce
LEA R10D,[RSI + -0x1]
LEA R11,[RDI + 0x8]
JMP 0x001011d3
LAB_0010119b:
ADD RAX,0x8
CMP RAX,RSI
JZ 0x001011cf
LAB_001011a4:
MOV EDX,dword ptr [RAX + 0x4]
MOV ECX,dword ptr [RAX + 0xc]
CMP EDX,ECX
JLE 0x0010119b
MOV R8D,dword ptr [RAX]
MOV R9D,dword ptr [RAX + 0x8]
MOV dword ptr [RAX],R9D
MOV dword ptr [RAX + 0x4],ECX
MOV dword ptr [RAX + 0x8],R8D
MOV dword ptr [RAX + 0xc],EDX
JMP 0x0010119b
LAB_001011c4:
SUB R10D,0x1
CMP R10D,-0x1
JNZ 0x001011d3
LAB_001011ce:
RET
LAB_001011cf:
SUB R10D,0x1
LAB_001011d3:
TEST R10D,R10D
JLE 0x001011c4
MOV RAX,RDI
LEA EDX,[R10 + -0x1]
LEA RSI,[R11 + RDX*0x8]
JMP 0x001011a4 | void func0(int4 *param_1,int param_2)
{
int iVar1;
int4 uVar2;
int4 *puVar3;
if (0 < param_2) {
param_2 = param_2 + -1;
do {
for (; 0 < param_2; param_2 = param_2 + -1) {
puVar3 = param_1;
do {
iVar1 = puVar3[1];
if ((int)puVar3[3] < iVar1) {
uVar2 = *puVar3;
*puVar3 = puVar3[2];
puVar3[1] = puVar3[3];
puVar3[2] = uVar2;
puVar3[3] = iVar1;
}
puVar3 = puVar3 + 2;
} while (puVar3 != param_1 + (ulong)(param_2 - 1) * 2 + 2);
}
param_2 = param_2 + -1;
} while (param_2 != -1);
}
return;
} |
5,842 | func0 |
#include <assert.h>
#include <string.h>
| void func0(int tuples[][2], int n) {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (tuples[j][1] > tuples[j + 1][1]) {
int temp0 = tuples[j][0], temp1 = tuples[j][1];
tuples[j][0] = tuples[j + 1][0];
tuples[j][1] = tuples[j + 1][1];
tuples[j + 1][0] = temp0;
tuples[j + 1][1] = temp1;
}
}
}
}
| int main() {
int t1[3][2] = {{1, 3}, {3, 2}, {2, 1}};
int r1[3][2] = {{2, 1}, {3, 2}, {1, 3}};
func0(t1, 3);
assert(memcmp(t1, r1, sizeof(t1)) == 0);
int t2[3][2] = {{2, 4}, {3, 3}, {1, 1}};
int r2[3][2] = {{1, 1}, {3, 3}, {2, 4}};
func0(t2, 3);
assert(memcmp(t2, r2, sizeof(t2)) == 0);
int t3[3][2] = {{3, 9}, {6, 7}, {4, 3}};
int r3[3][2] = {{4, 3}, {6, 7}, {3, 9}};
func0(t3, 3);
assert(memcmp(t3, r3, sizeof(t3)) == 0);
return 0;
}
| O2 | c | func0:
endbr64
test %esi,%esi
jle 13d7 <func0+0x57>
lea -0x1(%rsi),%edx
lea 0x8(%rdi),%r11
test %edx,%edx
je 13d6 <func0+0x56>
nopl 0x0(%rax,%rax,1)
sub $0x1,%edx
mov %rdi,%rax
mov %rdx,%r10
lea (%r11,%rdx,8),%rsi
nopl (%rax)
mov 0x4(%rax),%edx
mov 0xc(%rax),%ecx
cmp %ecx,%edx
jle 13c6 <func0+0x46>
mov (%rax),%r8d
mov 0x8(%rax),%r9d
mov %ecx,0x4(%rax)
mov %edx,0xc(%rax)
mov %r9d,(%rax)
mov %r8d,0x8(%rax)
add $0x8,%rax
cmp %rsi,%rax
jne 13a8 <func0+0x28>
mov %r10d,%edx
test %edx,%edx
jne 1398 <func0+0x18>
retq
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short locret_13D7
lea edx, [rsi-1]
lea r11, [rdi+8]
test edx, edx
jz short locret_13D6
nop dword ptr [rax+rax+00h]
loc_1398:
sub edx, 1
mov rax, rdi
mov r10, rdx
lea rsi, [r11+rdx*8]
nop dword ptr [rax]
loc_13A8:
mov edx, [rax+4]
mov ecx, [rax+0Ch]
cmp edx, ecx
jle short loc_13C6
mov r8d, [rax]
mov r9d, [rax+8]
mov [rax+4], ecx
mov [rax+0Ch], edx
mov [rax], r9d
mov [rax+8], r8d
loc_13C6:
add rax, 8
cmp rax, rsi
jnz short loc_13A8
mov edx, r10d
test edx, edx
jnz short loc_1398
locret_13D6:
retn
locret_13D7:
retn | void func0(int *a1, int a2)
{
int v2; // edx
int *v3; // rax
int v4; // r10d
long long v5; // rsi
int v6; // edx
int v7; // ecx
int v8; // r8d
int v9; // r9d
if ( a2 > 0 )
{
v2 = a2 - 1;
if ( a2 != 1 )
{
do
{
v3 = a1;
v4 = v2 - 1;
v5 = (long long)&a1[2 * (v2 - 1) + 2];
do
{
v6 = v3[1];
v7 = v3[3];
if ( v6 > v7 )
{
v8 = *v3;
v9 = v3[2];
v3[1] = v7;
v3[3] = v6;
*v3 = v9;
v3[2] = v8;
}
v3 += 2;
}
while ( v3 != (int *)v5 );
v2 = v4;
}
while ( v4 );
}
}
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001013d7
LEA EDX,[RSI + -0x1]
LEA R11,[RDI + 0x8]
TEST EDX,EDX
JZ 0x001013d6
NOP dword ptr [RAX + RAX*0x1]
LAB_00101398:
SUB EDX,0x1
MOV RAX,RDI
MOV R10,RDX
LEA RSI,[R11 + RDX*0x8]
NOP dword ptr [RAX]
LAB_001013a8:
MOV EDX,dword ptr [RAX + 0x4]
MOV ECX,dword ptr [RAX + 0xc]
CMP EDX,ECX
JLE 0x001013c6
MOV R8D,dword ptr [RAX]
MOV R9D,dword ptr [RAX + 0x8]
MOV dword ptr [RAX + 0x4],ECX
MOV dword ptr [RAX + 0xc],EDX
MOV dword ptr [RAX],R9D
MOV dword ptr [RAX + 0x8],R8D
LAB_001013c6:
ADD RAX,0x8
CMP RAX,RSI
JNZ 0x001013a8
MOV EDX,R10D
TEST EDX,EDX
JNZ 0x00101398
LAB_001013d6:
RET
LAB_001013d7:
RET | void func0(int4 *param_1,int param_2)
{
int iVar1;
int4 uVar2;
int4 *puVar3;
uint uVar4;
ulong uVar5;
if (param_2 < 1) {
return;
}
uVar4 = param_2 - 1;
uVar5 = (ulong)uVar4;
while (uVar4 != 0) {
uVar4 = (int)uVar5 - 1;
uVar5 = (ulong)uVar4;
puVar3 = param_1;
do {
iVar1 = puVar3[1];
if ((int)puVar3[3] < iVar1) {
uVar2 = *puVar3;
puVar3[1] = puVar3[3];
puVar3[3] = iVar1;
*puVar3 = puVar3[2];
puVar3[2] = uVar2;
}
puVar3 = puVar3 + 2;
} while (puVar3 != param_1 + uVar5 * 2 + 2);
}
return;
} |
5,843 | func0 |
#include <assert.h>
#include <string.h>
| void func0(int tuples[][2], int n) {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (tuples[j][1] > tuples[j + 1][1]) {
int temp0 = tuples[j][0], temp1 = tuples[j][1];
tuples[j][0] = tuples[j + 1][0];
tuples[j][1] = tuples[j + 1][1];
tuples[j + 1][0] = temp0;
tuples[j + 1][1] = temp1;
}
}
}
}
| int main() {
int t1[3][2] = {{1, 3}, {3, 2}, {2, 1}};
int r1[3][2] = {{2, 1}, {3, 2}, {1, 3}};
func0(t1, 3);
assert(memcmp(t1, r1, sizeof(t1)) == 0);
int t2[3][2] = {{2, 4}, {3, 3}, {1, 1}};
int r2[3][2] = {{1, 1}, {3, 3}, {2, 4}};
func0(t2, 3);
assert(memcmp(t2, r2, sizeof(t2)) == 0);
int t3[3][2] = {{3, 9}, {6, 7}, {4, 3}};
int r3[3][2] = {{4, 3}, {6, 7}, {3, 9}};
func0(t3, 3);
assert(memcmp(t3, r3, sizeof(t3)) == 0);
return 0;
}
| O3 | c | func0:
endbr64
test %esi,%esi
jle 13c7 <func0+0x57>
lea -0x1(%rsi),%edx
lea 0x8(%rdi),%r11
test %edx,%edx
je 13c6 <func0+0x56>
nopl 0x0(%rax,%rax,1)
sub $0x1,%edx
mov %rdi,%rax
mov %rdx,%r10
lea (%r11,%rdx,8),%rsi
nopl (%rax)
mov 0x4(%rax),%edx
mov 0xc(%rax),%ecx
cmp %ecx,%edx
jle 13b6 <func0+0x46>
mov (%rax),%r8d
mov 0x8(%rax),%r9d
mov %ecx,0x4(%rax)
mov %edx,0xc(%rax)
mov %r9d,(%rax)
mov %r8d,0x8(%rax)
add $0x8,%rax
cmp %rsi,%rax
jne 1398 <func0+0x28>
mov %r10d,%edx
test %edx,%edx
jne 1388 <func0+0x18>
retq
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
test esi, esi
jle short locret_13C8
lea r9, [rdi+8]
loc_136C:
cmp esi, 1
jle short loc_13C3
nop dword ptr [rax+00000000h]
loc_1378:
lea edx, [rsi-2]
mov rax, rdi
lea r8, [r9+rdx*8]
nop word ptr [rax+rax+00h]
loc_1388:
mov ecx, [rax+4]
mov edx, [rax+0Ch]
cmp ecx, edx
jle short loc_13B2
movd xmm1, dword ptr [rax]
movd xmm0, dword ptr [rax+8]
movd xmm2, ecx
movd xmm3, edx
punpckldq xmm1, xmm2
punpckldq xmm0, xmm3
punpcklqdq xmm0, xmm1
movups xmmword ptr [rax], xmm0
loc_13B2:
add rax, 8
cmp rax, r8
jnz short loc_1388
sub esi, 1
cmp esi, 1
jg short loc_1378
loc_13C3:
sub esi, 1
jnz short loc_136C
locret_13C8:
retn | void func0(unsigned int *a1, int a2)
{
unsigned int *v2; // rax
signed int v3; // ecx
signed int v4; // edx
if ( a2 > 0 )
{
do
{
for ( ; a2 > 1; --a2 )
{
v2 = a1;
do
{
v3 = v2[1];
v4 = v2[3];
if ( v3 > v4 )
*(__m128i *)v2 = _mm_unpacklo_epi64(
_mm_unpacklo_epi32(_mm_cvtsi32_si128(v2[2]), _mm_cvtsi32_si128(v4)),
_mm_unpacklo_epi32(_mm_cvtsi32_si128(*v2), _mm_cvtsi32_si128(v3)));
v2 += 2;
}
while ( v2 != &a1[2 * (a2 - 2) + 2] );
}
--a2;
}
while ( a2 );
}
} | func0:
ENDBR64
TEST ESI,ESI
JLE 0x001013c8
LEA R9,[RDI + 0x8]
LAB_0010136c:
CMP ESI,0x1
JLE 0x001013c3
NOP dword ptr [RAX]
LAB_00101378:
LEA EDX,[RSI + -0x2]
MOV RAX,RDI
LEA R8,[R9 + RDX*0x8]
NOP word ptr [RAX + RAX*0x1]
LAB_00101388:
MOV ECX,dword ptr [RAX + 0x4]
MOV EDX,dword ptr [RAX + 0xc]
CMP ECX,EDX
JLE 0x001013b2
MOVD XMM1,dword ptr [RAX]
MOVD XMM0,dword ptr [RAX + 0x8]
MOVD XMM2,ECX
MOVD XMM3,EDX
PUNPCKLDQ XMM1,XMM2
PUNPCKLDQ XMM0,XMM3
PUNPCKLQDQ XMM0,XMM1
MOVUPS xmmword ptr [RAX],XMM0
LAB_001013b2:
ADD RAX,0x8
CMP RAX,R8
JNZ 0x00101388
SUB ESI,0x1
CMP ESI,0x1
JG 0x00101378
LAB_001013c3:
SUB ESI,0x1
JNZ 0x0010136c
LAB_001013c8:
RET | void func0(int8 *param_1,int param_2)
{
int4 uVar1;
int8 *puVar2;
if (0 < param_2) {
do {
for (; 1 < param_2; param_2 = param_2 + -1) {
puVar2 = param_1;
do {
if (*(int *)((long)puVar2 + 0xc) < *(int *)((long)puVar2 + 4)) {
uVar1 = *(int4 *)puVar2;
*puVar2 = CONCAT44(*(int *)((long)puVar2 + 0xc),*(int4 *)(puVar2 + 1));
puVar2[1] = CONCAT44(*(int *)((long)puVar2 + 4),uVar1);
}
puVar2 = puVar2 + 1;
} while (puVar2 != param_1 + (ulong)(param_2 - 2) + 1);
}
param_2 = param_2 + -1;
} while (param_2 != 0);
}
return;
} |
5,844 | func0 | #include <math.h>
#include <assert.h>
| double func0(double a) {
double area = (sqrt(5 * (5 + 2 * sqrt(5))) * pow(a, 2)) / 4.0;
return area;
}
| int main() {
assert(func0(5) == 43.01193501472417);
assert(func0(10) == 172.0477400588967);
assert(func0(15) == 387.10741513251753);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
movsd %xmm0,-0x18(%rbp)
movsd 0xf2e(%rip),%xmm0
mov -0x18(%rbp),%rax
movapd %xmm0,%xmm1
movq %rax,%xmm0
callq 1060 <pow@plt>
movsd 0xf1c(%rip),%xmm1
mulsd %xmm1,%xmm0
movsd 0xf18(%rip),%xmm1
divsd %xmm1,%xmm0
movsd %xmm0,-0x8(%rbp)
movsd -0x8(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
movsd [rbp+x], xmm0
movsd xmm0, cs:y
mov rax, [rbp+x]
movapd xmm1, xmm0; y
movq xmm0, rax; x
call _pow
movsd xmm1, cs:qword_2098
mulsd xmm0, xmm1
movsd xmm1, cs:qword_20A0
divsd xmm0, xmm1
movsd [rbp+var_8], xmm0
movsd xmm0, [rbp+var_8]
leave
retn | double func0(double a1)
{
return pow(a1, 2.0) * 6.881909602355868 / 4.0;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOVSD qword ptr [RBP + -0x18],XMM0
MOVSD XMM0,qword ptr [0x00102090]
MOV RAX,qword ptr [RBP + -0x18]
MOVAPD XMM1,XMM0
MOVQ XMM0,RAX
CALL 0x00101060
MOVSD XMM1,qword ptr [0x00102098]
MULSD XMM0,XMM1
MOVSD XMM1,qword ptr [0x001020a0]
DIVSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x8],XMM0
MOVSD XMM0,qword ptr [RBP + -0x8]
LEAVE
RET | double func0(double param_1)
{
double dVar1;
dVar1 = pow(param_1,DAT_00102090);
return (dVar1 * DAT_00102098) / DAT_001020a0;
} |
5,845 | func0 | #include <math.h>
#include <assert.h>
| double func0(double a) {
double area = (sqrt(5 * (5 + 2 * sqrt(5))) * pow(a, 2)) / 4.0;
return area;
}
| int main() {
assert(func0(5) == 43.01193501472417);
assert(func0(10) == 172.0477400588967);
assert(func0(15) == 387.10741513251753);
return 0;
}
| O1 | c | func0:
endbr64
mulsd %xmm0,%xmm0
mulsd 0xecf(%rip),%xmm0
mulsd 0xecf(%rip),%xmm0
retq
| func0:
endbr64
mulsd xmm0, xmm0
mulsd xmm0, cs:qword_2008
mulsd xmm0, cs:qword_2010
retn | double func0(double a1)
{
return a1 * a1 * 6.881909602355868 * 0.25;
} | func0:
ENDBR64
MULSD XMM0,XMM0
MULSD XMM0,qword ptr [0x00102008]
MULSD XMM0,qword ptr [0x00102010]
RET | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
double func0(double param_1)
{
return param_1 * param_1 * _DAT_00102008 * _DAT_00102010;
} |
5,846 | func0 | #include <math.h>
#include <assert.h>
| double func0(double a) {
double area = (sqrt(5 * (5 + 2 * sqrt(5))) * pow(a, 2)) / 4.0;
return area;
}
| int main() {
assert(func0(5) == 43.01193501472417);
assert(func0(10) == 172.0477400588967);
assert(func0(15) == 387.10741513251753);
return 0;
}
| O2 | c | func0:
endbr64
mulsd %xmm0,%xmm0
mulsd 0xeb8(%rip),%xmm0
mulsd 0xeb8(%rip),%xmm0
retq
nopl 0x0(%rax)
| func0:
endbr64
mulsd xmm0, xmm0
mulsd xmm0, cs:qword_2008
mulsd xmm0, cs:qword_2010
retn | double func0(double a1)
{
return a1 * a1 * 6.881909602355868 * 0.25;
} | func0:
ENDBR64
MULSD XMM0,XMM0
MULSD XMM0,qword ptr [0x00102008]
MULSD XMM0,qword ptr [0x00102010]
RET | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
double func0(double param_1)
{
return param_1 * param_1 * _DAT_00102008 * _DAT_00102010;
} |
5,847 | func0 | #include <math.h>
#include <assert.h>
| double func0(double a) {
double area = (sqrt(5 * (5 + 2 * sqrt(5))) * pow(a, 2)) / 4.0;
return area;
}
| int main() {
assert(func0(5) == 43.01193501472417);
assert(func0(10) == 172.0477400588967);
assert(func0(15) == 387.10741513251753);
return 0;
}
| O3 | c | func0:
endbr64
mulsd %xmm0,%xmm0
mulsd 0xeb8(%rip),%xmm0
mulsd 0xeb8(%rip),%xmm0
retq
nopl 0x0(%rax)
| func0:
endbr64
mulsd xmm0, xmm0
mulsd xmm0, cs:qword_2008
mulsd xmm0, cs:qword_2010
retn | double func0(double a1)
{
return a1 * a1 * 6.881909602355868 * 0.25;
} | func0:
ENDBR64
MULSD XMM0,XMM0
MULSD XMM0,qword ptr [0x00102008]
MULSD XMM0,qword ptr [0x00102010]
RET | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
double func0(double param_1)
{
return param_1 * param_1 * _DAT_00102008 * _DAT_00102010;
} |
5,848 | func0 | #include <assert.h>
| int func0(int n, int arr[]) {
int mn = arr[0];
int freq = 1;
for (int i = 1; i < n; i++) {
if (arr[i] > mn) {
mn = arr[i];
freq = 1;
} else if (arr[i] == mn) {
freq += 1;
}
}
return freq;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 4};
int arr2[] = {5, 6, 5};
int arr3[] = {2, 7, 7, 7};
assert(func0(5, arr1) == 2);
assert(func0(3, arr2) == 1);
assert(func0(4, arr3) == 3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %edi,-0x14(%rbp)
mov %rsi,-0x20(%rbp)
mov -0x20(%rbp),%rax
mov (%rax),%eax
mov %eax,-0xc(%rbp)
movl $0x1,-0x8(%rbp)
movl $0x1,-0x4(%rbp)
jmp 11f1 <func0+0x88>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0xc(%rbp)
jge 11ce <func0+0x65>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
mov %eax,-0xc(%rbp)
movl $0x1,-0x8(%rbp)
jmp 11ed <func0+0x84>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x20(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0xc(%rbp)
jne 11ed <func0+0x84>
addl $0x1,-0x8(%rbp)
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x14(%rbp),%eax
jl 1191 <func0+0x28>
mov -0x8(%rbp),%eax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_14], edi
mov [rbp+var_20], rsi
mov rax, [rbp+var_20]
mov eax, [rax]
mov [rbp+var_C], eax
mov [rbp+var_8], 1
mov [rbp+var_4], 1
jmp short loc_11F1
loc_1191:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_20]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_C], eax
jge short loc_11CE
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_20]
add rax, rdx
mov eax, [rax]
mov [rbp+var_C], eax
mov [rbp+var_8], 1
jmp short loc_11ED
loc_11CE:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_20]
add rax, rdx
mov eax, [rax]
cmp [rbp+var_C], eax
jnz short loc_11ED
add [rbp+var_8], 1
loc_11ED:
add [rbp+var_4], 1
loc_11F1:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_14]
jl short loc_1191
mov eax, [rbp+var_8]
pop rbp
retn | long long func0(int a1, int *a2)
{
int v3; // [rsp+14h] [rbp-Ch]
unsigned int v4; // [rsp+18h] [rbp-8h]
int i; // [rsp+1Ch] [rbp-4h]
v3 = *a2;
v4 = 1;
for ( i = 1; i < a1; ++i )
{
if ( v3 >= a2[i] )
{
if ( v3 == a2[i] )
++v4;
}
else
{
v3 = a2[i];
v4 = 1;
}
}
return v4;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV dword ptr [RBP + -0x14],EDI
MOV qword ptr [RBP + -0x20],RSI
MOV RAX,qword ptr [RBP + -0x20]
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0xc],EAX
MOV dword ptr [RBP + -0x8],0x1
MOV dword ptr [RBP + -0x4],0x1
JMP 0x001011f1
LAB_00101191:
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
CMP dword ptr [RBP + -0xc],EAX
JGE 0x001011ce
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RBP + -0xc],EAX
MOV dword ptr [RBP + -0x8],0x1
JMP 0x001011ed
LAB_001011ce:
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x20]
ADD RAX,RDX
MOV EAX,dword ptr [RAX]
CMP dword ptr [RBP + -0xc],EAX
JNZ 0x001011ed
ADD dword ptr [RBP + -0x8],0x1
LAB_001011ed:
ADD dword ptr [RBP + -0x4],0x1
LAB_001011f1:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x14]
JL 0x00101191
MOV EAX,dword ptr [RBP + -0x8]
POP RBP
RET | int func0(int param_1,int *param_2)
{
int local_14;
int local_10;
int local_c;
local_14 = *param_2;
local_10 = 1;
for (local_c = 1; local_c < param_1; local_c = local_c + 1) {
if (local_14 < param_2[local_c]) {
local_14 = param_2[local_c];
local_10 = 1;
}
else if (local_14 == param_2[local_c]) {
local_10 = local_10 + 1;
}
}
return local_10;
} |
5,849 | func0 | #include <assert.h>
| int func0(int n, int arr[]) {
int mn = arr[0];
int freq = 1;
for (int i = 1; i < n; i++) {
if (arr[i] > mn) {
mn = arr[i];
freq = 1;
} else if (arr[i] == mn) {
freq += 1;
}
}
return freq;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 4};
int arr2[] = {5, 6, 5};
int arr3[] = {2, 7, 7, 7};
assert(func0(5, arr1) == 2);
assert(func0(3, arr2) == 1);
assert(func0(4, arr3) == 3);
return 0;
}
| O1 | c | func0:
endbr64
mov (%rsi),%ecx
cmp $0x1,%edi
jle 11a7 <func0+0x3e>
lea 0x4(%rsi),%rax
lea -0x2(%rdi),%edx
lea 0x8(%rsi,%rdx,4),%rdi
mov $0x1,%esi
jmp 1197 <func0+0x2e>
mov %edx,%ecx
mov $0x1,%esi
add $0x4,%rax
cmp %rdi,%rax
je 11ac <func0+0x43>
mov (%rax),%edx
cmp %ecx,%edx
jg 1187 <func0+0x1e>
sete %dl
movzbl %dl,%edx
add %edx,%esi
jmp 118e <func0+0x25>
mov $0x1,%esi
mov %esi,%eax
retq
| func0:
endbr64
mov ecx, [rsi]
cmp edi, 1
jle short loc_11A7
lea rax, [rsi+4]
lea edx, [rdi-2]
lea rdi, [rsi+rdx*4+8]
mov esi, 1
jmp short loc_1197
loc_1187:
mov ecx, edx
mov esi, 1
loc_118E:
add rax, 4
cmp rax, rdi
jz short loc_11AC
loc_1197:
mov edx, [rax]
cmp edx, ecx
jg short loc_1187
setz dl
movzx edx, dl
add esi, edx
jmp short loc_118E
loc_11A7:
mov esi, 1
loc_11AC:
mov eax, esi
retn | long long func0(int a1, int *a2)
{
int v2; // ecx
int *v3; // rax
long long v4; // rdi
unsigned int v5; // esi
v2 = *a2;
if ( a1 <= 1 )
{
return 1;
}
else
{
v3 = a2 + 1;
v4 = (long long)&a2[a1 - 2 + 2];
v5 = 1;
do
{
if ( *v3 > v2 )
{
v2 = *v3;
v5 = 1;
}
else
{
v5 += *v3 == v2;
}
++v3;
}
while ( v3 != (int *)v4 );
}
return v5;
} | func0:
ENDBR64
MOV ECX,dword ptr [RSI]
CMP EDI,0x1
JLE 0x001011a7
LEA RAX,[RSI + 0x4]
LEA EDX,[RDI + -0x2]
LEA RDI,[RSI + RDX*0x4 + 0x8]
MOV ESI,0x1
JMP 0x00101197
LAB_00101187:
MOV ECX,EDX
MOV ESI,0x1
LAB_0010118e:
ADD RAX,0x4
CMP RAX,RDI
JZ 0x001011ac
LAB_00101197:
MOV EDX,dword ptr [RAX]
CMP EDX,ECX
JG 0x00101187
SETZ DL
MOVZX EDX,DL
ADD ESI,EDX
JMP 0x0010118e
LAB_001011a7:
MOV ESI,0x1
LAB_001011ac:
MOV EAX,ESI
RET | int func0(int param_1,int *param_2)
{
int iVar1;
int *piVar2;
int iVar3;
int iVar4;
iVar3 = *param_2;
if (param_1 < 2) {
iVar4 = 1;
}
else {
piVar2 = param_2 + 1;
iVar4 = 1;
do {
iVar1 = *piVar2;
if (iVar1 == iVar3 || iVar1 < iVar3) {
iVar4 = iVar4 + (uint)(iVar1 == iVar3);
}
else {
iVar4 = 1;
iVar3 = iVar1;
}
piVar2 = piVar2 + 1;
} while (piVar2 != param_2 + (ulong)(param_1 - 2) + 2);
}
return iVar4;
} |
5,850 | func0 | #include <assert.h>
| int func0(int n, int arr[]) {
int mn = arr[0];
int freq = 1;
for (int i = 1; i < n; i++) {
if (arr[i] > mn) {
mn = arr[i];
freq = 1;
} else if (arr[i] == mn) {
freq += 1;
}
}
return freq;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 4};
int arr2[] = {5, 6, 5};
int arr3[] = {2, 7, 7, 7};
assert(func0(5, arr1) == 2);
assert(func0(3, arr2) == 1);
assert(func0(4, arr3) == 3);
return 0;
}
| O2 | c | func0:
endbr64
mov (%rsi),%ecx
cmp $0x1,%edi
jle 1280 <func0+0x50>
lea -0x2(%rdi),%edx
lea 0x4(%rsi),%rax
mov $0x1,%r8d
lea 0x8(%rsi,%rdx,4),%rsi
jmp 1262 <func0+0x32>
sete %dl
add $0x4,%rax
movzbl %dl,%edx
add %edx,%r8d
cmp %rsi,%rax
je 1279 <func0+0x49>
mov (%rax),%edx
cmp %ecx,%edx
jle 1250 <func0+0x20>
add $0x4,%rax
mov %edx,%ecx
mov $0x1,%r8d
cmp %rsi,%rax
jne 1262 <func0+0x32>
mov %r8d,%eax
retq
nopl (%rax)
mov $0x1,%r8d
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov ecx, [rsi]
cmp edi, 1
jle short loc_12E0
lea edx, [rdi-2]
lea rax, [rsi+4]
mov r8d, 1
lea rsi, [rsi+rdx*4+8]
jmp short loc_12C2
loc_12B0:
setz dl
add rax, 4
movzx edx, dl
add r8d, edx
cmp rax, rsi
jz short loc_12D9
loc_12C2:
mov edx, [rax]
cmp edx, ecx
jle short loc_12B0
add rax, 4
mov ecx, edx
mov r8d, 1
cmp rax, rsi
jnz short loc_12C2
loc_12D9:
mov eax, r8d
retn
loc_12E0:
mov r8d, 1
mov eax, r8d
retn | long long func0(int a1, int *a2)
{
int v2; // ecx
int *v3; // rax
unsigned int v4; // r8d
long long v5; // rsi
int v6; // edx
bool v7; // zf
v2 = *a2;
if ( a1 <= 1 )
return 1LL;
v3 = a2 + 1;
v4 = 1;
v5 = (long long)&a2[a1 - 2 + 2];
do
{
while ( 1 )
{
v6 = *v3;
v7 = *v3 == v2;
if ( *v3 > v2 )
break;
++v3;
v4 += v7;
if ( v3 == (int *)v5 )
return v4;
}
++v3;
v2 = v6;
v4 = 1;
}
while ( v3 != (int *)v5 );
return v4;
} | func0:
ENDBR64
MOV ECX,dword ptr [RSI]
CMP EDI,0x1
JLE 0x001012e0
LEA EDX,[RDI + -0x2]
LEA RAX,[RSI + 0x4]
MOV R8D,0x1
LEA RSI,[RSI + RDX*0x4 + 0x8]
JMP 0x001012c2
LAB_001012b0:
SETZ DL
ADD RAX,0x4
MOVZX EDX,DL
ADD R8D,EDX
CMP RAX,RSI
JZ 0x001012d9
LAB_001012c2:
MOV EDX,dword ptr [RAX]
CMP EDX,ECX
JLE 0x001012b0
ADD RAX,0x4
MOV ECX,EDX
MOV R8D,0x1
CMP RAX,RSI
JNZ 0x001012c2
LAB_001012d9:
MOV EAX,R8D
RET
LAB_001012e0:
MOV R8D,0x1
MOV EAX,R8D
RET | int func0(int param_1,int *param_2)
{
int iVar1;
int *piVar2;
int iVar3;
int iVar4;
if (param_1 < 2) {
return 1;
}
piVar2 = param_2 + 1;
iVar4 = 1;
iVar3 = *param_2;
do {
while( true ) {
iVar1 = *piVar2;
if (iVar3 < iVar1) break;
piVar2 = piVar2 + 1;
iVar4 = iVar4 + (uint)(iVar1 == iVar3);
if (piVar2 == param_2 + (ulong)(param_1 - 2) + 2) {
return iVar4;
}
}
piVar2 = piVar2 + 1;
iVar4 = 1;
iVar3 = iVar1;
} while (piVar2 != param_2 + (ulong)(param_1 - 2) + 2);
return 1;
} |
5,851 | func0 | #include <assert.h>
| int func0(int n, int arr[]) {
int mn = arr[0];
int freq = 1;
for (int i = 1; i < n; i++) {
if (arr[i] > mn) {
mn = arr[i];
freq = 1;
} else if (arr[i] == mn) {
freq += 1;
}
}
return freq;
}
| int main() {
int arr1[] = {1, 2, 3, 4, 4};
int arr2[] = {5, 6, 5};
int arr3[] = {2, 7, 7, 7};
assert(func0(5, arr1) == 2);
assert(func0(3, arr2) == 1);
assert(func0(4, arr3) == 3);
return 0;
}
| O3 | c | func0:
endbr64
mov (%rsi),%ecx
cmp $0x1,%edi
jle 1290 <func0+0x50>
lea -0x2(%rdi),%edx
lea 0x4(%rsi),%rax
mov $0x1,%r8d
lea 0x8(%rsi,%rdx,4),%rsi
jmp 1272 <func0+0x32>
sete %dl
add $0x4,%rax
movzbl %dl,%edx
add %edx,%r8d
cmp %rax,%rsi
je 1289 <func0+0x49>
mov (%rax),%edx
cmp %edx,%ecx
jge 1260 <func0+0x20>
add $0x4,%rax
mov %edx,%ecx
mov $0x1,%r8d
cmp %rax,%rsi
jne 1272 <func0+0x32>
mov %r8d,%eax
retq
nopl (%rax)
mov $0x1,%r8d
mov %r8d,%eax
retq
nopw 0x0(%rax,%rax,1)
| func0:
endbr64
mov r8d, [rsi]
cmp edi, 1
jle short loc_1190
lea edx, [rdi-2]
lea rax, [rsi+4]
mov ecx, 1
lea rsi, [rsi+rdx*4+8]
jmp short loc_1171
loc_1160:
setz dl
add rax, 4
movzx edx, dl
add ecx, edx
cmp rsi, rax
jz short loc_1189
loc_1171:
mov edx, [rax]
cmp r8d, edx
jge short loc_1160
add rax, 4
mov r8d, edx
mov ecx, 1
cmp rsi, rax
jnz short loc_1171
loc_1189:
mov eax, ecx
retn
loc_1190:
mov ecx, 1
mov eax, ecx
retn | long long func0(int a1, int *a2)
{
int v2; // r8d
int *v3; // rax
unsigned int v4; // ecx
long long v5; // rsi
int v6; // edx
bool v7; // zf
v2 = *a2;
if ( a1 <= 1 )
return 1LL;
v3 = a2 + 1;
v4 = 1;
v5 = (long long)&a2[a1 - 2 + 2];
do
{
while ( 1 )
{
v6 = *v3;
v7 = v2 == *v3;
if ( v2 < *v3 )
break;
++v3;
v4 += v7;
if ( (int *)v5 == v3 )
return v4;
}
++v3;
v2 = v6;
v4 = 1;
}
while ( (int *)v5 != v3 );
return v4;
} | func0:
ENDBR64
MOV R8D,dword ptr [RSI]
CMP EDI,0x1
JLE 0x00101190
LEA EDX,[RDI + -0x2]
LEA RAX,[RSI + 0x4]
MOV ECX,0x1
LEA RSI,[RSI + RDX*0x4 + 0x8]
JMP 0x00101171
LAB_00101160:
SETZ DL
ADD RAX,0x4
MOVZX EDX,DL
ADD ECX,EDX
CMP RSI,RAX
JZ 0x00101189
LAB_00101171:
MOV EDX,dword ptr [RAX]
CMP R8D,EDX
JGE 0x00101160
ADD RAX,0x4
MOV R8D,EDX
MOV ECX,0x1
CMP RSI,RAX
JNZ 0x00101171
LAB_00101189:
MOV EAX,ECX
RET
LAB_00101190:
MOV ECX,0x1
MOV EAX,ECX
RET | int func0(int param_1,int *param_2)
{
int iVar1;
int *piVar2;
int iVar3;
int iVar4;
if (param_1 < 2) {
return 1;
}
piVar2 = param_2 + 1;
iVar3 = 1;
iVar4 = *param_2;
do {
while( true ) {
iVar1 = *piVar2;
if (iVar4 < iVar1) break;
piVar2 = piVar2 + 1;
iVar3 = iVar3 + (uint)(iVar4 == iVar1);
if (param_2 + (ulong)(param_1 - 2) + 2 == piVar2) {
return iVar3;
}
}
piVar2 = piVar2 + 1;
iVar3 = 1;
iVar4 = iVar1;
} while (param_2 + (ulong)(param_1 - 2) + 2 != piVar2);
return 1;
} |
5,852 | func0 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
typedef struct Pair {
int first;
int second;
} Pair;
int pair_comparator(const void *v1, const void *v2) {
const Pair *p1 = (const Pair *)v1;
const Pair *p2 = (const Pair *)v2;
if (p1->first != p2->first)
return p1->first - p2->first;
return p1->second - p2->second;
}
| Pair* func0(Pair test_list[], size_t size, size_t *result_size) {
Pair *res = malloc(size * sizeof(Pair));
if (!res) return NULL; // memory allocation check
int res_count = 0;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (test_list[i].first == test_list[j].second && test_list[i].second == test_list[j].first) {
if (test_list[i].first < test_list[i].second) {
res[res_count++] = test_list[i];
}
}
}
}
*result_size = res_count;
return res;
}
| int main() {
Pair test1[] = {{6, 7}, {2, 3}, {7, 6}, {9, 8}, {10, 2}, {8, 9}};
Pair result1_exp[] = {{6, 7}, {8, 9}};
size_t res1_size;
Pair *result1 = func0(test1, 6, &res1_size);
qsort(result1, res1_size, sizeof(Pair), pair_comparator);
assert(res1_size == 2 && memcmp(result1, result1_exp, 2 * sizeof(Pair)) == 0);
free(result1);
Pair test2[] = {{7, 8}, {3, 4}, {8, 7}, {10, 9}, {11, 3}, {9, 10}};
Pair result2_exp[] = {{7, 8}, {9, 10}};
size_t res2_size;
Pair *result2 = func0(test2, 6, &res2_size);
qsort(result2, res2_size, sizeof(Pair), pair_comparator);
assert(res2_size == 2 && memcmp(result2, result2_exp, 2 * sizeof(Pair)) == 0);
free(result2);
Pair test3[] = {{8, 9}, {4, 5}, {9, 8}, {11, 10}, {12, 4}, {10, 11}};
Pair result3_exp[] = {{8, 9}, {10, 11}};
size_t res3_size;
Pair *result3 = func0(test3, 6, &res3_size);
qsort(result3, res3_size, sizeof(Pair), pair_comparator);
assert(res3_size == 2 && memcmp(result3, result3_exp, 2 * sizeof(Pair)) == 0);
free(result3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x40,%rsp
mov %rdi,-0x28(%rbp)
mov %rsi,-0x30(%rbp)
mov %rdx,-0x38(%rbp)
mov -0x30(%rbp),%rax
shl $0x3,%rax
mov %rax,%rdi
callq 10f0 <malloc@plt>
mov %rax,-0x8(%rbp)
cmpq $0x0,-0x8(%rbp)
jne 127c <func0+0x3d>
mov $0x0,%eax
jmpq 139e <func0+0x15f>
movl $0x0,-0x14(%rbp)
movl $0x0,-0x10(%rbp)
jmpq 137e <func0+0x13f>
movl $0x0,-0xc(%rbp)
jmpq 136b <func0+0x12c>
mov -0x10(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x28(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%eax
cmp %eax,%edx
jne 1367 <func0+0x128>
mov -0x10(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
add %rdx,%rax
mov 0x4(%rax),%edx
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x28(%rbp),%rax
add %rcx,%rax
mov (%rax),%eax
cmp %eax,%edx
jne 1367 <func0+0x128>
mov -0x10(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
add %rdx,%rax
mov (%rax),%edx
mov -0x10(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rcx
mov -0x28(%rbp),%rax
add %rcx,%rax
mov 0x4(%rax),%eax
cmp %eax,%edx
jge 1367 <func0+0x128>
mov -0x10(%rbp),%eax
cltq
lea 0x0(,%rax,8),%rdx
mov -0x28(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x14(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x14(%rbp)
cltq
lea 0x0(,%rax,8),%rdx
mov -0x8(%rbp),%rax
add %rax,%rdx
mov (%rcx),%rax
mov %rax,(%rdx)
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cltq
cmp %rax,-0x30(%rbp)
ja 129b <func0+0x5c>
addl $0x1,-0x10(%rbp)
mov -0x10(%rbp),%eax
cltq
cmp %rax,-0x30(%rbp)
ja 128f <func0+0x50>
mov -0x14(%rbp),%eax
movslq %eax,%rdx
mov -0x38(%rbp),%rax
mov %rdx,(%rax)
mov -0x8(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 40h
mov [rbp+var_28], rdi
mov [rbp+var_30], rsi
mov [rbp+var_38], rdx
mov rax, [rbp+var_30]
shl rax, 3
mov rdi, rax; size
call _malloc
mov [rbp+var_8], rax
cmp [rbp+var_8], 0
jnz short loc_127C
mov eax, 0
jmp locret_139E
loc_127C:
mov [rbp+var_14], 0
mov [rbp+var_10], 0
jmp loc_137E
loc_128F:
mov [rbp+var_C], 0
jmp loc_136B
loc_129B:
mov eax, [rbp+var_10]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_C]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rcx
mov eax, [rax+4]
cmp edx, eax
jnz loc_1367
mov eax, [rbp+var_10]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rdx
mov edx, [rax+4]
mov eax, [rbp+var_C]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rcx
mov eax, [rax]
cmp edx, eax
jnz short loc_1367
mov eax, [rbp+var_10]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rdx
mov edx, [rax]
mov eax, [rbp+var_10]
cdqe
lea rcx, ds:0[rax*8]
mov rax, [rbp+var_28]
add rax, rcx
mov eax, [rax+4]
cmp edx, eax
jge short loc_1367
mov eax, [rbp+var_10]
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_28]
lea rcx, [rdx+rax]
mov eax, [rbp+var_14]
lea edx, [rax+1]
mov [rbp+var_14], edx
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_8]
add rdx, rax
mov rax, [rcx]
mov [rdx], rax
loc_1367:
add [rbp+var_C], 1
loc_136B:
mov eax, [rbp+var_C]
cdqe
cmp rax, [rbp+var_30]
jb loc_129B
add [rbp+var_10], 1
loc_137E:
mov eax, [rbp+var_10]
cdqe
cmp rax, [rbp+var_30]
jb loc_128F
mov eax, [rbp+var_14]
movsxd rdx, eax
mov rax, [rbp+var_38]
mov [rax], rdx
mov rax, [rbp+var_8]
locret_139E:
leave
retn | _QWORD * func0(long long a1, unsigned long long a2, _QWORD *a3)
{
int v4; // eax
int v6; // [rsp+2Ch] [rbp-14h]
int i; // [rsp+30h] [rbp-10h]
int j; // [rsp+34h] [rbp-Ch]
_QWORD *v9; // [rsp+38h] [rbp-8h]
v9 = malloc(8 * a2);
if ( !v9 )
return 0LL;
v6 = 0;
for ( i = 0; i < a2; ++i )
{
for ( j = 0; j < a2; ++j )
{
if ( *(_DWORD *)(8LL * i + a1) == *(_DWORD *)(8LL * j + a1 + 4)
&& *(_DWORD *)(8LL * i + a1 + 4) == *(_DWORD *)(8LL * j + a1)
&& *(_DWORD *)(8LL * i + a1) < *(_DWORD *)(8LL * i + a1 + 4) )
{
v4 = v6++;
v9[v4] = *(_QWORD *)(8LL * i + a1);
}
}
}
*a3 = v6;
return v9;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x40
MOV qword ptr [RBP + -0x28],RDI
MOV qword ptr [RBP + -0x30],RSI
MOV qword ptr [RBP + -0x38],RDX
MOV RAX,qword ptr [RBP + -0x30]
SHL RAX,0x3
MOV RDI,RAX
CALL 0x001010f0
MOV qword ptr [RBP + -0x8],RAX
CMP qword ptr [RBP + -0x8],0x0
JNZ 0x0010127c
MOV EAX,0x0
JMP 0x0010139e
LAB_0010127c:
MOV dword ptr [RBP + -0x14],0x0
MOV dword ptr [RBP + -0x10],0x0
JMP 0x0010137e
LAB_0010128f:
MOV dword ptr [RBP + -0xc],0x0
JMP 0x0010136b
LAB_0010129b:
MOV EAX,dword ptr [RBP + -0x10]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RCX
MOV EAX,dword ptr [RAX + 0x4]
CMP EDX,EAX
JNZ 0x00101367
MOV EAX,dword ptr [RBP + -0x10]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RDX
MOV EDX,dword ptr [RAX + 0x4]
MOV EAX,dword ptr [RBP + -0xc]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RCX
MOV EAX,dword ptr [RAX]
CMP EDX,EAX
JNZ 0x00101367
MOV EAX,dword ptr [RBP + -0x10]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RDX
MOV EDX,dword ptr [RAX]
MOV EAX,dword ptr [RBP + -0x10]
CDQE
LEA RCX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
ADD RAX,RCX
MOV EAX,dword ptr [RAX + 0x4]
CMP EDX,EAX
JGE 0x00101367
MOV EAX,dword ptr [RBP + -0x10]
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x28]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x14]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x14],EDX
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x8]
ADD RDX,RAX
MOV RAX,qword ptr [RCX]
MOV qword ptr [RDX],RAX
LAB_00101367:
ADD dword ptr [RBP + -0xc],0x1
LAB_0010136b:
MOV EAX,dword ptr [RBP + -0xc]
CDQE
CMP RAX,qword ptr [RBP + -0x30]
JC 0x0010129b
ADD dword ptr [RBP + -0x10],0x1
LAB_0010137e:
MOV EAX,dword ptr [RBP + -0x10]
CDQE
CMP RAX,qword ptr [RBP + -0x30]
JC 0x0010128f
MOV EAX,dword ptr [RBP + -0x14]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x38]
MOV qword ptr [RAX],RDX
MOV RAX,qword ptr [RBP + -0x8]
LAB_0010139e:
LEAVE
RET | void * func0(long param_1,ulong param_2,long *param_3)
{
void *pvVar1;
int4 local_1c;
int4 local_18;
int4 local_14;
pvVar1 = malloc(param_2 << 3);
if (pvVar1 == (void *)0x0) {
pvVar1 = (void *)0x0;
}
else {
local_1c = 0;
for (local_18 = 0; (ulong)(long)local_18 < param_2; local_18 = local_18 + 1) {
for (local_14 = 0; (ulong)(long)local_14 < param_2; local_14 = local_14 + 1) {
if (((*(int *)(param_1 + (long)local_18 * 8) == *(int *)(param_1 + (long)local_14 * 8 + 4))
&& (*(int *)(param_1 + (long)local_18 * 8 + 4) == *(int *)(param_1 + (long)local_14 * 8)
)) && (*(int *)(param_1 + (long)local_18 * 8) <
*(int *)(param_1 + (long)local_18 * 8 + 4))) {
*(int8 *)((long)local_1c * 8 + (long)pvVar1) =
*(int8 *)((long)local_18 * 8 + param_1);
local_1c = local_1c + 1;
}
}
}
*param_3 = (long)local_1c;
}
return pvVar1;
} |
5,853 | func0 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
typedef struct Pair {
int first;
int second;
} Pair;
int pair_comparator(const void *v1, const void *v2) {
const Pair *p1 = (const Pair *)v1;
const Pair *p2 = (const Pair *)v2;
if (p1->first != p2->first)
return p1->first - p2->first;
return p1->second - p2->second;
}
| Pair* func0(Pair test_list[], size_t size, size_t *result_size) {
Pair *res = malloc(size * sizeof(Pair));
if (!res) return NULL; // memory allocation check
int res_count = 0;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (test_list[i].first == test_list[j].second && test_list[i].second == test_list[j].first) {
if (test_list[i].first < test_list[i].second) {
res[res_count++] = test_list[i];
}
}
}
}
*result_size = res_count;
return res;
}
| int main() {
Pair test1[] = {{6, 7}, {2, 3}, {7, 6}, {9, 8}, {10, 2}, {8, 9}};
Pair result1_exp[] = {{6, 7}, {8, 9}};
size_t res1_size;
Pair *result1 = func0(test1, 6, &res1_size);
qsort(result1, res1_size, sizeof(Pair), pair_comparator);
assert(res1_size == 2 && memcmp(result1, result1_exp, 2 * sizeof(Pair)) == 0);
free(result1);
Pair test2[] = {{7, 8}, {3, 4}, {8, 7}, {10, 9}, {11, 3}, {9, 10}};
Pair result2_exp[] = {{7, 8}, {9, 10}};
size_t res2_size;
Pair *result2 = func0(test2, 6, &res2_size);
qsort(result2, res2_size, sizeof(Pair), pair_comparator);
assert(res2_size == 2 && memcmp(result2, result2_exp, 2 * sizeof(Pair)) == 0);
free(result2);
Pair test3[] = {{8, 9}, {4, 5}, {9, 8}, {11, 10}, {12, 4}, {10, 11}};
Pair result3_exp[] = {{8, 9}, {10, 11}};
size_t res3_size;
Pair *result3 = func0(test3, 6, &res3_size);
qsort(result3, res3_size, sizeof(Pair), pair_comparator);
assert(res3_size == 2 && memcmp(result3, result3_exp, 2 * sizeof(Pair)) == 0);
free(result3);
return 0;
}
| O1 | c | func0:
endbr64
push %r13
push %r12
push %rbp
push %rbx
sub $0x8,%rsp
mov %rdi,%rbx
mov %rsi,%r13
mov %rdx,%rbp
lea 0x0(,%rsi,8),%r12
mov %r12,%rdi
callq 10f0 <malloc@plt>
test %rax,%rax
je 128b <func0+0x8c>
test %r13,%r13
je 127e <func0+0x7f>
mov %rbx,%r11
lea (%rbx,%r12,1),%rsi
mov %rbx,%rdi
mov $0x0,%r10d
jmp 1279 <func0+0x7a>
add $0x8,%rdx
cmp %rdx,%rsi
je 1270 <func0+0x71>
mov (%rdi),%ecx
cmp 0x4(%rdx),%ecx
jne 1242 <func0+0x43>
mov 0x4(%rdi),%r9d
cmp %r9d,(%rdx)
jne 1242 <func0+0x43>
cmp %r9d,%ecx
jge 1242 <func0+0x43>
movslq %r10d,%rcx
mov (%rdi),%r8
mov %r8,(%rax,%rcx,8)
lea 0x1(%r10),%r10d
jmp 1242 <func0+0x43>
add $0x8,%rdi
cmp %rdi,%rsi
je 1284 <func0+0x85>
mov %r11,%rdx
jmp 124b <func0+0x4c>
mov $0x0,%r10d
movslq %r10d,%r10
mov %r10,0x0(%rbp)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
| func0:
endbr64
push r13
push r12
push rbp
push rbx
sub rsp, 8
mov rbx, rdi
mov r13, rsi
mov rbp, rdx
lea r12, ds:0[rsi*8]
mov rdi, r12
call _malloc
test rax, rax
jz short loc_1288
test r13, r13
jz short loc_127B
lea rdi, [rbx+r12]
mov rcx, rbx
mov r10d, 0
jmp short loc_1276
loc_123F:
add rdx, 8
cmp rdi, rdx
jz short loc_126D
loc_1248:
mov esi, [rcx]
cmp esi, [rdx+4]
jnz short loc_123F
mov r9d, [rcx+4]
cmp [rdx], r9d
jnz short loc_123F
cmp esi, r9d
jge short loc_123F
movsxd rsi, r10d
mov r8, [rcx]
mov [rax+rsi*8], r8
lea r10d, [r10+1]
jmp short loc_123F
loc_126D:
add rcx, 8
cmp rdi, rcx
jz short loc_1281
loc_1276:
mov rdx, rbx
jmp short loc_1248
loc_127B:
mov r10d, 0
loc_1281:
movsxd r10, r10d
mov [rbp+0], r10
loc_1288:
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn | long long func0(_DWORD *a1, long long a2, _QWORD *a3)
{
long long result; // rax
_DWORD *v6; // rdi
_DWORD *v7; // rcx
int v8; // r10d
_DWORD *v9; // rdx
int v10; // r9d
result = malloc(8 * a2);
if ( result )
{
if ( a2 )
{
v6 = &a1[2 * a2];
v7 = a1;
v8 = 0;
do
{
v9 = a1;
do
{
if ( *v7 == v9[1] )
{
v10 = v7[1];
if ( *v9 == v10 && *v7 < v10 )
*(_QWORD *)(result + 8LL * v8++) = *(_QWORD *)v7;
}
v9 += 2;
}
while ( v6 != v9 );
v7 += 2;
}
while ( v6 != v7 );
}
else
{
v8 = 0;
}
*a3 = v8;
}
return result;
} | func0:
ENDBR64
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x8
MOV RBX,RDI
MOV R13,RSI
MOV RBP,RDX
LEA R12,[RSI*0x8]
MOV RDI,R12
CALL 0x001010f0
TEST RAX,RAX
JZ 0x00101288
TEST R13,R13
JZ 0x0010127b
LEA RDI,[RBX + R12*0x1]
MOV RCX,RBX
MOV R10D,0x0
JMP 0x00101276
LAB_0010123f:
ADD RDX,0x8
CMP RDI,RDX
JZ 0x0010126d
LAB_00101248:
MOV ESI,dword ptr [RCX]
CMP ESI,dword ptr [RDX + 0x4]
JNZ 0x0010123f
MOV R9D,dword ptr [RCX + 0x4]
CMP dword ptr [RDX],R9D
JNZ 0x0010123f
CMP ESI,R9D
JGE 0x0010123f
MOVSXD RSI,R10D
MOV R8,qword ptr [RCX]
MOV qword ptr [RAX + RSI*0x8],R8
LEA R10D,[R10 + 0x1]
JMP 0x0010123f
LAB_0010126d:
ADD RCX,0x8
CMP RDI,RCX
JZ 0x00101281
LAB_00101276:
MOV RDX,RBX
JMP 0x00101248
LAB_0010127b:
MOV R10D,0x0
LAB_00101281:
MOVSXD R10,R10D
MOV qword ptr [RBP],R10
LAB_00101288:
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET | void func0(int *param_1,long param_2,long *param_3)
{
void *pvVar1;
int *piVar2;
int *piVar3;
int iVar4;
pvVar1 = malloc(param_2 * 8);
if (pvVar1 != (void *)0x0) {
if (param_2 == 0) {
iVar4 = 0;
}
else {
iVar4 = 0;
piVar3 = param_1;
piVar2 = param_1;
do {
if (((*piVar2 == piVar3[1]) && (*piVar3 == piVar2[1])) && (*piVar2 < piVar2[1])) {
*(int8 *)((long)pvVar1 + (long)iVar4 * 8) = *(int8 *)piVar2;
iVar4 = iVar4 + 1;
}
piVar3 = piVar3 + 2;
} while ((param_1 + param_2 * 2 != piVar3) ||
(piVar2 = piVar2 + 2, piVar3 = param_1, param_1 + param_2 * 2 != piVar2));
}
*param_3 = (long)iVar4;
}
return;
} |
5,854 | func0 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
typedef struct Pair {
int first;
int second;
} Pair;
int pair_comparator(const void *v1, const void *v2) {
const Pair *p1 = (const Pair *)v1;
const Pair *p2 = (const Pair *)v2;
if (p1->first != p2->first)
return p1->first - p2->first;
return p1->second - p2->second;
}
| Pair* func0(Pair test_list[], size_t size, size_t *result_size) {
Pair *res = malloc(size * sizeof(Pair));
if (!res) return NULL; // memory allocation check
int res_count = 0;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (test_list[i].first == test_list[j].second && test_list[i].second == test_list[j].first) {
if (test_list[i].first < test_list[i].second) {
res[res_count++] = test_list[i];
}
}
}
}
*result_size = res_count;
return res;
}
| int main() {
Pair test1[] = {{6, 7}, {2, 3}, {7, 6}, {9, 8}, {10, 2}, {8, 9}};
Pair result1_exp[] = {{6, 7}, {8, 9}};
size_t res1_size;
Pair *result1 = func0(test1, 6, &res1_size);
qsort(result1, res1_size, sizeof(Pair), pair_comparator);
assert(res1_size == 2 && memcmp(result1, result1_exp, 2 * sizeof(Pair)) == 0);
free(result1);
Pair test2[] = {{7, 8}, {3, 4}, {8, 7}, {10, 9}, {11, 3}, {9, 10}};
Pair result2_exp[] = {{7, 8}, {9, 10}};
size_t res2_size;
Pair *result2 = func0(test2, 6, &res2_size);
qsort(result2, res2_size, sizeof(Pair), pair_comparator);
assert(res2_size == 2 && memcmp(result2, result2_exp, 2 * sizeof(Pair)) == 0);
free(result2);
Pair test3[] = {{8, 9}, {4, 5}, {9, 8}, {11, 10}, {12, 4}, {10, 11}};
Pair result3_exp[] = {{8, 9}, {10, 11}};
size_t res3_size;
Pair *result3 = func0(test3, 6, &res3_size);
qsort(result3, res3_size, sizeof(Pair), pair_comparator);
assert(res3_size == 2 && memcmp(result3, result3_exp, 2 * sizeof(Pair)) == 0);
free(result3);
return 0;
}
| O2 | c | func0:
endbr64
push %r13
mov %rdx,%r13
push %r12
mov %rdi,%r12
push %rbp
mov %rsi,%rbp
push %rbx
lea 0x0(,%rsi,8),%rbx
mov %rbx,%rdi
sub $0x8,%rsp
callq 10d0 <malloc@plt>
test %rax,%rax
je 158d <func0+0x9d>
test %rbp,%rbp
je 1589 <func0+0x99>
lea (%r12,%rbx,1),%r9
mov %r12,%rsi
xor %r11d,%r11d
xor %r8d,%r8d
xchg %ax,%ax
mov (%rsi),%edi
mov %r12,%rcx
jmp 1549 <func0+0x59>
nopw 0x0(%rax,%rax,1)
add $0x8,%rcx
cmp %r9,%rcx
je 1580 <func0+0x90>
mov %r8,%rbp
cmp %edi,0x4(%rcx)
jne 1540 <func0+0x50>
mov 0x4(%rsi),%r10d
cmp %r10d,(%rcx)
jne 1540 <func0+0x50>
cmp %edi,%r10d
jle 1540 <func0+0x50>
mov (%rsi),%rdx
add $0x1,%r11d
add $0x8,%rcx
mov %rdx,(%rax,%r8,8)
movslq %r11d,%r8
mov %r8,%rbp
cmp %r9,%rcx
jne 1549 <func0+0x59>
nopl 0x0(%rax)
add $0x8,%rsi
cmp %r9,%rsi
jne 1530 <func0+0x40>
mov %rbp,0x0(%r13)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
push r13
mov r13, rsi
push r12
mov r12, rdx
push rbp
mov rbp, rdi
push rbx
lea rbx, ds:0[rsi*8]
mov rdi, rbx
sub rsp, 8
call _malloc
test rax, rax
jz short loc_1578
lea rdi, [rbp+rbx+0]
mov r8, rbp
xor r9d, r9d
test r13, r13
jz short loc_1574
nop dword ptr [rax+00h]
loc_1520:
mov ecx, [r8]
mov rdx, rbp
jmp short loc_1539
loc_1530:
add rdx, 8
cmp rdx, rdi
jz short loc_1568
loc_1539:
cmp [rdx+4], ecx
jnz short loc_1530
mov esi, [r8+4]
cmp [rdx], esi
jnz short loc_1530
cmp esi, ecx
jle short loc_1530
mov r10, [r8]
movsxd rsi, r9d
add rdx, 8
add r9d, 1
mov [rax+rsi*8], r10
cmp rdx, rdi
jnz short loc_1539
nop dword ptr [rax+00000000h]
loc_1568:
add r8, 8
cmp r8, rdx
jnz short loc_1520
movsxd r13, r9d
loc_1574:
mov [r12], r13
loc_1578:
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn | long long func0(int *a1, long long a2, _QWORD *a3)
{
long long v3; // r13
long long result; // rax
int *v7; // rdi
int *v8; // r8
int v9; // r9d
int v10; // ecx
int *v11; // rdx
int v12; // esi
long long v13; // rsi
v3 = a2;
result = malloc(8 * a2);
if ( result )
{
v7 = &a1[2 * a2];
v8 = a1;
v9 = 0;
if ( a2 )
{
do
{
v10 = *v8;
v11 = a1;
do
{
while ( 1 )
{
if ( v11[1] == v10 )
{
v12 = v8[1];
if ( *v11 == v12 && v12 > v10 )
break;
}
v11 += 2;
if ( v11 == v7 )
goto LABEL_9;
}
v13 = v9;
v11 += 2;
++v9;
*(_QWORD *)(result + 8 * v13) = *(_QWORD *)v8;
}
while ( v11 != v7 );
LABEL_9:
v8 += 2;
}
while ( v8 != v11 );
v3 = v9;
}
*a3 = v3;
}
return result;
} | func0:
ENDBR64
PUSH R13
MOV R13,RSI
PUSH R12
MOV R12,RDX
PUSH RBP
MOV RBP,RDI
PUSH RBX
LEA RBX,[RSI*0x8]
MOV RDI,RBX
SUB RSP,0x8
CALL 0x001010d0
TEST RAX,RAX
JZ 0x00101578
LEA RDI,[RBP + RBX*0x1]
MOV R8,RBP
XOR R9D,R9D
TEST R13,R13
JZ 0x00101574
NOP dword ptr [RAX]
LAB_00101520:
MOV ECX,dword ptr [R8]
MOV RDX,RBP
JMP 0x00101539
LAB_00101530:
ADD RDX,0x8
CMP RDX,RDI
JZ 0x00101568
LAB_00101539:
CMP dword ptr [RDX + 0x4],ECX
JNZ 0x00101530
MOV ESI,dword ptr [R8 + 0x4]
CMP dword ptr [RDX],ESI
JNZ 0x00101530
CMP ESI,ECX
JLE 0x00101530
MOV R10,qword ptr [R8]
MOVSXD RSI,R9D
ADD RDX,0x8
ADD R9D,0x1
MOV qword ptr [RAX + RSI*0x8],R10
CMP RDX,RDI
JNZ 0x00101539
NOP dword ptr [RAX]
LAB_00101568:
ADD R8,0x8
CMP R8,RDX
JNZ 0x00101520
MOVSXD R13,R9D
LAB_00101574:
MOV qword ptr [R12],R13
LAB_00101578:
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET | void func0(int *param_1,long param_2,long *param_3)
{
int iVar1;
int *piVar2;
void *pvVar3;
int *piVar4;
long lVar5;
int *piVar6;
int iVar7;
pvVar3 = malloc(param_2 * 8);
if (pvVar3 != (void *)0x0) {
iVar7 = 0;
piVar6 = param_1;
if (param_2 != 0) {
do {
iVar1 = *piVar6;
piVar2 = param_1;
do {
while (((piVar4 = piVar2, piVar4[1] == iVar1 && (*piVar4 == piVar6[1])) &&
(iVar1 < piVar6[1]))) {
lVar5 = (long)iVar7;
iVar7 = iVar7 + 1;
*(int8 *)((long)pvVar3 + lVar5 * 8) = *(int8 *)piVar6;
piVar2 = piVar4 + 2;
if (piVar4 + 2 == param_1 + param_2 * 2) goto LAB_00101568;
}
piVar2 = piVar4 + 2;
} while (piVar4 + 2 != param_1 + param_2 * 2);
LAB_00101568:
piVar6 = piVar6 + 2;
} while (piVar6 != piVar4 + 2);
param_2 = (long)iVar7;
}
*param_3 = param_2;
}
return;
} |
5,855 | func0 | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
typedef struct Pair {
int first;
int second;
} Pair;
int pair_comparator(const void *v1, const void *v2) {
const Pair *p1 = (const Pair *)v1;
const Pair *p2 = (const Pair *)v2;
if (p1->first != p2->first)
return p1->first - p2->first;
return p1->second - p2->second;
}
| Pair* func0(Pair test_list[], size_t size, size_t *result_size) {
Pair *res = malloc(size * sizeof(Pair));
if (!res) return NULL; // memory allocation check
int res_count = 0;
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (test_list[i].first == test_list[j].second && test_list[i].second == test_list[j].first) {
if (test_list[i].first < test_list[i].second) {
res[res_count++] = test_list[i];
}
}
}
}
*result_size = res_count;
return res;
}
| int main() {
Pair test1[] = {{6, 7}, {2, 3}, {7, 6}, {9, 8}, {10, 2}, {8, 9}};
Pair result1_exp[] = {{6, 7}, {8, 9}};
size_t res1_size;
Pair *result1 = func0(test1, 6, &res1_size);
qsort(result1, res1_size, sizeof(Pair), pair_comparator);
assert(res1_size == 2 && memcmp(result1, result1_exp, 2 * sizeof(Pair)) == 0);
free(result1);
Pair test2[] = {{7, 8}, {3, 4}, {8, 7}, {10, 9}, {11, 3}, {9, 10}};
Pair result2_exp[] = {{7, 8}, {9, 10}};
size_t res2_size;
Pair *result2 = func0(test2, 6, &res2_size);
qsort(result2, res2_size, sizeof(Pair), pair_comparator);
assert(res2_size == 2 && memcmp(result2, result2_exp, 2 * sizeof(Pair)) == 0);
free(result2);
Pair test3[] = {{8, 9}, {4, 5}, {9, 8}, {11, 10}, {12, 4}, {10, 11}};
Pair result3_exp[] = {{8, 9}, {10, 11}};
size_t res3_size;
Pair *result3 = func0(test3, 6, &res3_size);
qsort(result3, res3_size, sizeof(Pair), pair_comparator);
assert(res3_size == 2 && memcmp(result3, result3_exp, 2 * sizeof(Pair)) == 0);
free(result3);
return 0;
}
| O3 | c | func0:
endbr64
push %r13
mov %rdx,%r13
push %r12
mov %rdi,%r12
push %rbp
mov %rsi,%rbp
push %rbx
lea 0x0(,%rsi,8),%rbx
mov %rbx,%rdi
sub $0x8,%rsp
callq 10d0 <malloc@plt>
test %rax,%rax
je 14ed <func0+0x9d>
test %rbp,%rbp
je 14e9 <func0+0x99>
lea (%r12,%rbx,1),%r9
mov %r12,%rsi
xor %r11d,%r11d
xor %r8d,%r8d
xchg %ax,%ax
mov (%rsi),%edi
mov %r12,%rcx
jmp 14a9 <func0+0x59>
nopw 0x0(%rax,%rax,1)
add $0x8,%rcx
cmp %rcx,%r9
je 14e0 <func0+0x90>
mov %r8,%rbp
cmp %edi,0x4(%rcx)
jne 14a0 <func0+0x50>
mov 0x4(%rsi),%r10d
cmp %r10d,(%rcx)
jne 14a0 <func0+0x50>
cmp %edi,%r10d
jle 14a0 <func0+0x50>
mov (%rsi),%rdx
add $0x1,%r11d
add $0x8,%rcx
mov %rdx,(%rax,%r8,8)
movslq %r11d,%r8
mov %r8,%rbp
cmp %rcx,%r9
jne 14a9 <func0+0x59>
nopl 0x0(%rax)
add $0x8,%rsi
cmp %rsi,%r9
jne 1490 <func0+0x40>
mov %rbp,0x0(%r13)
add $0x8,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
push r13
mov r13, rsi
push r12
mov r12, rdx
push rbp
mov rbp, rdi
push rbx
lea rbx, ds:0[rsi*8]
mov rdi, rbx; size
sub rsp, 8
call _malloc
test rax, rax
jz short loc_14E8
lea rdi, [rbp+rbx+0]
mov r8, rbp
xor r9d, r9d
test r13, r13
jz short loc_14E4
nop dword ptr [rax+00h]
loc_1490:
mov ecx, [r8]
mov rdx, rbp
jmp short loc_14A9
loc_14A0:
add rdx, 8
cmp rdx, rdi
jz short loc_14D8
loc_14A9:
cmp ecx, [rdx+4]
jnz short loc_14A0
mov esi, [r8+4]
cmp [rdx], esi
jnz short loc_14A0
cmp ecx, esi
jge short loc_14A0
mov r10, [r8]
movsxd rsi, r9d
add rdx, 8
add r9d, 1
mov [rax+rsi*8], r10
cmp rdx, rdi
jnz short loc_14A9
nop dword ptr [rax+00000000h]
loc_14D8:
add r8, 8
cmp r8, rdx
jnz short loc_1490
movsxd r13, r9d
loc_14E4:
mov [r12], r13
loc_14E8:
add rsp, 8
pop rbx
pop rbp
pop r12
pop r13
retn | _QWORD * func0(int *a1, long long a2, _QWORD *a3)
{
long long v3; // r13
_QWORD *result; // rax
int *v7; // rdi
int *v8; // r8
int v9; // r9d
int v10; // ecx
int *v11; // rdx
int v12; // esi
long long v13; // rsi
v3 = a2;
result = malloc(8 * a2);
if ( result )
{
v7 = &a1[2 * a2];
v8 = a1;
v9 = 0;
if ( a2 )
{
do
{
v10 = *v8;
v11 = a1;
do
{
while ( 1 )
{
if ( v10 == v11[1] )
{
v12 = v8[1];
if ( *v11 == v12 && v10 < v12 )
break;
}
v11 += 2;
if ( v11 == v7 )
goto LABEL_9;
}
v13 = v9;
v11 += 2;
++v9;
result[v13] = *(_QWORD *)v8;
}
while ( v11 != v7 );
LABEL_9:
v8 += 2;
}
while ( v8 != v11 );
v3 = v9;
}
*a3 = v3;
}
return result;
} | func0:
ENDBR64
PUSH R13
MOV R13,RSI
PUSH R12
MOV R12,RDX
PUSH RBP
MOV RBP,RDI
PUSH RBX
LEA RBX,[RSI*0x8]
MOV RDI,RBX
SUB RSP,0x8
CALL 0x001010d0
TEST RAX,RAX
JZ 0x001014e8
LEA RDI,[RBP + RBX*0x1]
MOV R8,RBP
XOR R9D,R9D
TEST R13,R13
JZ 0x001014e4
NOP dword ptr [RAX]
LAB_00101490:
MOV ECX,dword ptr [R8]
MOV RDX,RBP
JMP 0x001014a9
LAB_001014a0:
ADD RDX,0x8
CMP RDX,RDI
JZ 0x001014d8
LAB_001014a9:
CMP ECX,dword ptr [RDX + 0x4]
JNZ 0x001014a0
MOV ESI,dword ptr [R8 + 0x4]
CMP dword ptr [RDX],ESI
JNZ 0x001014a0
CMP ECX,ESI
JGE 0x001014a0
MOV R10,qword ptr [R8]
MOVSXD RSI,R9D
ADD RDX,0x8
ADD R9D,0x1
MOV qword ptr [RAX + RSI*0x8],R10
CMP RDX,RDI
JNZ 0x001014a9
NOP dword ptr [RAX]
LAB_001014d8:
ADD R8,0x8
CMP R8,RDX
JNZ 0x00101490
MOVSXD R13,R9D
LAB_001014e4:
MOV qword ptr [R12],R13
LAB_001014e8:
ADD RSP,0x8
POP RBX
POP RBP
POP R12
POP R13
RET | void func0(int *param_1,long param_2,long *param_3)
{
int iVar1;
int *piVar2;
void *pvVar3;
int *piVar4;
long lVar5;
int *piVar6;
int iVar7;
pvVar3 = malloc(param_2 * 8);
if (pvVar3 != (void *)0x0) {
iVar7 = 0;
piVar6 = param_1;
if (param_2 != 0) {
do {
iVar1 = *piVar6;
piVar2 = param_1;
do {
while (((piVar4 = piVar2, iVar1 == piVar4[1] && (*piVar4 == piVar6[1])) &&
(iVar1 < piVar6[1]))) {
lVar5 = (long)iVar7;
iVar7 = iVar7 + 1;
*(int8 *)((long)pvVar3 + lVar5 * 8) = *(int8 *)piVar6;
piVar2 = piVar4 + 2;
if (piVar4 + 2 == param_1 + param_2 * 2) goto LAB_001014d8;
}
piVar2 = piVar4 + 2;
} while (piVar4 + 2 != param_1 + param_2 * 2);
LAB_001014d8:
piVar6 = piVar6 + 2;
} while (piVar6 != piVar4 + 2);
param_2 = (long)iVar7;
}
*param_3 = param_2;
}
return;
} |
5,856 | func0 |
#include <stdio.h>
#include <assert.h>
#include <math.h>
| double func0(double a, int n, double r) {
double total = (a * (1 - pow(r, n))) / (1 - r);
return total;
}
| int main() {
assert(func0(1,5,2)==31);
assert(func0(1,5,4)==341);
assert(func0(2,6,3)==728);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
movsd %xmm0,-0x18(%rbp)
mov %edi,-0x1c(%rbp)
movsd %xmm1,-0x28(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mov -0x28(%rbp),%rax
movapd %xmm0,%xmm1
movq %rax,%xmm0
callq 1060 <pow@plt>
movsd 0xedf(%rip),%xmm1
subsd %xmm0,%xmm1
movapd %xmm1,%xmm0
mulsd -0x18(%rbp),%xmm0
movsd 0xeca(%rip),%xmm1
subsd -0x28(%rbp),%xmm1
divsd %xmm1,%xmm0
movsd %xmm0,-0x8(%rbp)
movsd -0x8(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
movsd [rbp+var_18], xmm0
mov [rbp+var_1C], edi
movsd [rbp+x], xmm1
pxor xmm0, xmm0
cvtsi2sd xmm0, [rbp+var_1C]
mov rax, [rbp+x]
movapd xmm1, xmm0; y
movq xmm0, rax; x
call _pow
movapd xmm1, xmm0
movsd xmm0, cs:qword_2060
subsd xmm0, xmm1
mulsd xmm0, [rbp+var_18]
movsd xmm1, cs:qword_2060
subsd xmm1, [rbp+x]
divsd xmm0, xmm1
movsd [rbp+var_8], xmm0
movsd xmm0, [rbp+var_8]
leave
retn | double func0(int a1, double a2, double a3)
{
return (1.0 - pow(a3, (double)a1)) * a2 / (1.0 - a3);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOVSD qword ptr [RBP + -0x18],XMM0
MOV dword ptr [RBP + -0x1c],EDI
MOVSD qword ptr [RBP + -0x28],XMM1
PXOR XMM0,XMM0
CVTSI2SD XMM0,dword ptr [RBP + -0x1c]
MOV RAX,qword ptr [RBP + -0x28]
MOVAPD XMM1,XMM0
MOVQ XMM0,RAX
CALL 0x00101060
MOVAPD XMM1,XMM0
MOVSD XMM0,qword ptr [0x00102060]
SUBSD XMM0,XMM1
MULSD XMM0,qword ptr [RBP + -0x18]
MOVSD XMM1,qword ptr [0x00102060]
SUBSD XMM1,qword ptr [RBP + -0x28]
DIVSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x8],XMM0
MOVSD XMM0,qword ptr [RBP + -0x8]
LEAVE
RET | double func0(double param_1,double param_2,int param_3)
{
double dVar1;
dVar1 = pow(param_2,(double)param_3);
return ((DAT_00102060 - dVar1) * param_1) / (DAT_00102060 - param_2);
} |
5,857 | func0 |
#include <stdio.h>
#include <assert.h>
#include <math.h>
| double func0(double a, int n, double r) {
double total = (a * (1 - pow(r, n))) / (1 - r);
return total;
}
| int main() {
assert(func0(1,5,2)==31);
assert(func0(1,5,4)==341);
assert(func0(2,6,3)==728);
return 0;
}
| O1 | c | func0:
endbr64
sub $0x18,%rsp
movsd %xmm0,(%rsp)
movapd %xmm1,%xmm3
pxor %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
movsd %xmm3,0x8(%rsp)
movapd %xmm3,%xmm0
callq 1060 <pow@plt>
movsd 0xee7(%rip),%xmm1
movapd %xmm1,%xmm2
subsd %xmm0,%xmm2
movapd %xmm2,%xmm0
mulsd (%rsp),%xmm0
subsd 0x8(%rsp),%xmm1
divsd %xmm1,%xmm0
add $0x18,%rsp
retq
| func0:
endbr64
push r14
push rbx
sub rsp, 8
movq r14, xmm0
movq rbx, xmm1
pxor xmm1, xmm1
cvtsi2sd xmm1, edi
movq xmm0, rbx
call _pow
movapd xmm2, xmm0
movsd xmm1, cs:qword_2060
movapd xmm0, xmm1
subsd xmm0, xmm2
movq xmm3, r14
mulsd xmm0, xmm3
movq xmm4, rbx
subsd xmm1, xmm4
divsd xmm0, xmm1
add rsp, 8
pop rbx
pop r14
retn | double func0(int a1, double a2, double a3)
{
return (1.0 - pow(a3, (double)a1)) * a2 / (1.0 - a3);
} | func0:
ENDBR64
PUSH R14
PUSH RBX
SUB RSP,0x8
MOVQ R14,XMM0
MOVQ RBX,XMM1
PXOR XMM1,XMM1
CVTSI2SD XMM1,EDI
MOVQ XMM0,RBX
CALL 0x00101060
MOVAPD XMM2,XMM0
MOVSD XMM1,qword ptr [0x00102060]
MOVAPD XMM0,XMM1
SUBSD XMM0,XMM2
MOVQ XMM3,R14
MULSD XMM0,XMM3
MOVQ XMM4,RBX
SUBSD XMM1,XMM4
DIVSD XMM0,XMM1
ADD RSP,0x8
POP RBX
POP R14
RET | double func0(double param_1,double param_2,int param_3)
{
double dVar1;
dVar1 = pow(param_2,(double)param_3);
return ((DAT_00102060 - dVar1) * param_1) / (DAT_00102060 - param_2);
} |
5,858 | func0 |
#include <stdio.h>
#include <assert.h>
#include <math.h>
| double func0(double a, int n, double r) {
double total = (a * (1 - pow(r, n))) / (1 - r);
return total;
}
| int main() {
assert(func0(1,5,2)==31);
assert(func0(1,5,4)==341);
assert(func0(2,6,3)==728);
return 0;
}
| O2 | c | func0:
endbr64
movapd %xmm1,%xmm3
pxor %xmm1,%xmm1
sub $0x18,%rsp
cvtsi2sd %edi,%xmm1
movsd %xmm0,(%rsp)
movapd %xmm3,%xmm0
movsd %xmm3,0x8(%rsp)
callq 1050 <pow@plt>
movsd 0xe78(%rip),%xmm2
movsd 0x8(%rsp),%xmm3
movapd %xmm2,%xmm4
subsd %xmm3,%xmm2
subsd %xmm0,%xmm4
movsd (%rsp),%xmm0
add $0x18,%rsp
mulsd %xmm4,%xmm0
divsd %xmm2,%xmm0
retq
nopw %cs:0x0(%rax,%rax,1)
xchg %ax,%ax
| func0:
endbr64
movapd xmm3, xmm1
pxor xmm1, xmm1
sub rsp, 18h
cvtsi2sd xmm1, edi
movsd [rsp+18h+var_18], xmm0
movapd xmm0, xmm3
movsd [rsp+18h+var_10], xmm3
call _pow
movsd xmm2, cs:qword_2008
movsd xmm3, [rsp+18h+var_10]
movapd xmm4, xmm2
subsd xmm2, xmm3
subsd xmm4, xmm0
movsd xmm0, [rsp+18h+var_18]
add rsp, 18h
mulsd xmm0, xmm4
divsd xmm0, xmm2
retn | double func0(int a1, double a2, double a3)
{
return a2 * (1.0 - pow(a3, (double)a1)) / (1.0 - a3);
} | func0:
ENDBR64
MOVAPD XMM3,XMM1
PXOR XMM1,XMM1
SUB RSP,0x18
CVTSI2SD XMM1,EDI
MOVSD qword ptr [RSP],XMM0
MOVAPD XMM0,XMM3
MOVSD qword ptr [RSP + 0x8],XMM3
CALL 0x00101050
MOVSD XMM2,qword ptr [0x00102008]
MOVSD XMM3,qword ptr [RSP + 0x8]
MOVAPD XMM4,XMM2
SUBSD XMM2,XMM3
SUBSD XMM4,XMM0
MOVSD XMM0,qword ptr [RSP]
ADD RSP,0x18
MULSD XMM0,XMM4
DIVSD XMM0,XMM2
RET | double func0(double param_1,double param_2,int param_3)
{
double dVar1;
dVar1 = pow(param_2,(double)param_3);
return (param_1 * (DAT_00102008 - dVar1)) / (DAT_00102008 - param_2);
} |
5,859 | func0 |
#include <stdio.h>
#include <assert.h>
#include <math.h>
| double func0(double a, int n, double r) {
double total = (a * (1 - pow(r, n))) / (1 - r);
return total;
}
| int main() {
assert(func0(1,5,2)==31);
assert(func0(1,5,4)==341);
assert(func0(2,6,3)==728);
return 0;
}
| O3 | c | func0:
endbr64
movapd %xmm1,%xmm3
pxor %xmm1,%xmm1
sub $0x18,%rsp
cvtsi2sd %edi,%xmm1
movsd %xmm0,(%rsp)
movapd %xmm3,%xmm0
movsd %xmm3,0x8(%rsp)
callq 1050 <pow@plt>
movsd 0xe78(%rip),%xmm2
movsd 0x8(%rsp),%xmm3
movapd %xmm2,%xmm4
subsd %xmm3,%xmm2
subsd %xmm0,%xmm4
movsd (%rsp),%xmm0
add $0x18,%rsp
mulsd %xmm4,%xmm0
divsd %xmm2,%xmm0
retq
nopw %cs:0x0(%rax,%rax,1)
xchg %ax,%ax
| func0:
endbr64
movapd xmm3, xmm1
pxor xmm1, xmm1
sub rsp, 18h
cvtsi2sd xmm1, edi; y
movsd [rsp+18h+var_18], xmm0
movapd xmm0, xmm3; x
movsd [rsp+18h+var_10], xmm3
call _pow
movsd xmm2, cs:qword_2008
movsd xmm3, [rsp+18h+var_10]
movapd xmm4, xmm2
subsd xmm2, xmm3
subsd xmm4, xmm0
movsd xmm0, [rsp+18h+var_18]
add rsp, 18h
mulsd xmm0, xmm4
divsd xmm0, xmm2
retn | double func0(int a1, double a2, double a3)
{
return a2 * (1.0 - pow(a3, (double)a1)) / (1.0 - a3);
} | func0:
ENDBR64
MOVAPD XMM3,XMM1
PXOR XMM1,XMM1
SUB RSP,0x18
CVTSI2SD XMM1,EDI
MOVSD qword ptr [RSP],XMM0
MOVAPD XMM0,XMM3
MOVSD qword ptr [RSP + 0x8],XMM3
CALL 0x00101050
MOVSD XMM2,qword ptr [0x00102008]
MOVSD XMM3,qword ptr [RSP + 0x8]
MOVAPD XMM4,XMM2
SUBSD XMM2,XMM3
SUBSD XMM4,XMM0
MOVSD XMM0,qword ptr [RSP]
ADD RSP,0x18
MULSD XMM0,XMM4
DIVSD XMM0,XMM2
RET | double func0(double param_1,double param_2,int param_3)
{
double dVar1;
dVar1 = pow(param_2,(double)param_3);
return (param_1 * (DAT_00102008 - dVar1)) / (DAT_00102008 - param_2);
} |
5,860 | func0 |
#include <assert.h>
| int func0(int item_list[], int size, int item) {
int first = 0;
int last = size - 1;
int found = 0;
while (first <= last && !found) {
int mid = (first + last) / 2;
if (item_list[mid] == item) {
found = 1;
} else {
if (item < item_list[mid]) {
last = mid - 1;
} else {
first = mid + 1;
}
}
}
return found;
}
| int main() {
int list1[] = {1, 2, 3, 5, 8};
int size1 = sizeof(list1) / sizeof(list1[0]);
int list2[] = {7, 8, 9, 10, 13};
int size2 = sizeof(list2) / sizeof(list2[0]);
int list3[] = {11, 13, 14, 19, 22, 36};
int size3 = sizeof(list3) / sizeof(list3[0]);
assert(func0(list1, size1, 6) == 0);
assert(func0(list2, size2, 10) == 1);
assert(func0(list3, size3, 23) == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov %edx,-0x20(%rbp)
movl $0x0,-0x10(%rbp)
mov -0x1c(%rbp),%eax
sub $0x1,%eax
mov %eax,-0xc(%rbp)
movl $0x0,-0x8(%rbp)
jmp 11fb <func0+0x92>
mov -0x10(%rbp),%edx
mov -0xc(%rbp),%eax
add %edx,%eax
mov %eax,%edx
shr $0x1f,%edx
add %edx,%eax
sar %eax
mov %eax,-0x4(%rbp)
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x20(%rbp)
jne 11cc <func0+0x63>
movl $0x1,-0x8(%rbp)
jmp 11fb <func0+0x92>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cmp %eax,-0x20(%rbp)
jge 11f2 <func0+0x89>
mov -0x4(%rbp),%eax
sub $0x1,%eax
mov %eax,-0xc(%rbp)
jmp 11fb <func0+0x92>
mov -0x4(%rbp),%eax
add $0x1,%eax
mov %eax,-0x10(%rbp)
mov -0x10(%rbp),%eax
cmp -0xc(%rbp),%eax
jg 1209 <func0+0xa0>
cmpl $0x0,-0x8(%rbp)
je 1194 <func0+0x2b>
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_10], 0
mov eax, [rbp+var_1C]
sub eax, 1
mov [rbp+var_C], eax
mov [rbp+var_8], 0
jmp short loc_11FB
loc_1194:
mov edx, [rbp+var_10]
mov eax, [rbp+var_C]
add eax, edx
mov edx, eax
shr edx, 1Fh
add eax, edx
sar eax, 1
mov [rbp+var_4], eax
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
jnz short loc_11CC
mov [rbp+var_8], 1
jmp short loc_11FB
loc_11CC:
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
jge short loc_11F2
mov eax, [rbp+var_4]
sub eax, 1
mov [rbp+var_C], eax
jmp short loc_11FB
loc_11F2:
mov eax, [rbp+var_4]
add eax, 1
mov [rbp+var_10], eax
loc_11FB:
mov eax, [rbp+var_10]
cmp eax, [rbp+var_C]
jg short loc_1209
cmp [rbp+var_8], 0
jz short loc_1194
loc_1209:
mov eax, [rbp+var_8]
pop rbp
retn | long long func0(long long a1, int a2, int a3)
{
int v4; // [rsp+10h] [rbp-10h]
int v5; // [rsp+14h] [rbp-Ch]
unsigned int v6; // [rsp+18h] [rbp-8h]
int v7; // [rsp+1Ch] [rbp-4h]
v4 = 0;
v5 = a2 - 1;
v6 = 0;
while ( v4 <= v5 && !v6 )
{
v7 = (v4 + v5) / 2;
if ( a3 == *(_DWORD *)(4LL * v7 + a1) )
{
v6 = 1;
}
else if ( a3 >= *(_DWORD *)(4LL * v7 + a1) )
{
v4 = v7 + 1;
}
else
{
v5 = v7 - 1;
}
}
return v6;
} | 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 + -0x10],0x0
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,0x1
MOV dword ptr [RBP + -0xc],EAX
MOV dword ptr [RBP + -0x8],0x0
JMP 0x001011fb
LAB_00101194:
MOV EDX,dword ptr [RBP + -0x10]
MOV EAX,dword ptr [RBP + -0xc]
ADD EAX,EDX
MOV EDX,EAX
SHR EDX,0x1f
ADD EAX,EDX
SAR EAX,0x1
MOV dword ptr [RBP + -0x4],EAX
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
JNZ 0x001011cc
MOV dword ptr [RBP + -0x8],0x1
JMP 0x001011fb
LAB_001011cc:
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
JGE 0x001011f2
MOV EAX,dword ptr [RBP + -0x4]
SUB EAX,0x1
MOV dword ptr [RBP + -0xc],EAX
JMP 0x001011fb
LAB_001011f2:
MOV EAX,dword ptr [RBP + -0x4]
ADD EAX,0x1
MOV dword ptr [RBP + -0x10],EAX
LAB_001011fb:
MOV EAX,dword ptr [RBP + -0x10]
CMP EAX,dword ptr [RBP + -0xc]
JG 0x00101209
CMP dword ptr [RBP + -0x8],0x0
JZ 0x00101194
LAB_00101209:
MOV EAX,dword ptr [RBP + -0x8]
POP RBP
RET | int func0(long param_1,int param_2,int param_3)
{
int iVar1;
int4 local_18;
int4 local_14;
int4 local_10;
local_18 = 0;
local_14 = param_2 + -1;
local_10 = 0;
while ((local_18 <= local_14 && (local_10 == 0))) {
iVar1 = (local_14 + local_18) / 2;
if (param_3 == *(int *)(param_1 + (long)iVar1 * 4)) {
local_10 = 1;
}
else if (param_3 < *(int *)(param_1 + (long)iVar1 * 4)) {
local_14 = iVar1 + -1;
}
else {
local_18 = iVar1 + 1;
}
}
return local_10;
} |
5,861 | func0 |
#include <assert.h>
| int func0(int item_list[], int size, int item) {
int first = 0;
int last = size - 1;
int found = 0;
while (first <= last && !found) {
int mid = (first + last) / 2;
if (item_list[mid] == item) {
found = 1;
} else {
if (item < item_list[mid]) {
last = mid - 1;
} else {
first = mid + 1;
}
}
}
return found;
}
| int main() {
int list1[] = {1, 2, 3, 5, 8};
int size1 = sizeof(list1) / sizeof(list1[0]);
int list2[] = {7, 8, 9, 10, 13};
int size2 = sizeof(list2) / sizeof(list2[0]);
int list3[] = {11, 13, 14, 19, 22, 36};
int size3 = sizeof(list3) / sizeof(list3[0]);
assert(func0(list1, size1, 6) == 0);
assert(func0(list2, size2, 10) == 1);
assert(func0(list3, size3, 23) == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %rbx
sub $0x1,%esi
mov $0x0,%r8d
mov $0x0,%ebx
mov $0x1,%r10d
lea (%r8,%rsi,1),%eax
mov %eax,%r11d
shr $0x1f,%r11d
add %eax,%r11d
sar %r11d
movslq %r11d,%rax
lea (%rdi,%rax,4),%r9
mov %ebx,%eax
cmp %esi,%r8d
jg 11bd <func0+0x54>
test %eax,%eax
jne 11bd <func0+0x54>
mov (%r9),%ecx
mov %r10d,%eax
cmp %edx,%ecx
je 119c <func0+0x33>
jle 11b7 <func0+0x4e>
lea -0x1(%r11),%esi
jmp 1182 <func0+0x19>
lea 0x1(%r11),%r8d
jmp 1182 <func0+0x19>
pop %rbx
retq
| func0:
endbr64
push rbx
mov r11, rdi
sub esi, 1
mov edi, 0
mov ebx, 0
mov r9d, 1
loc_1184:
lea eax, [rdi+rsi]
mov r10d, eax
shr r10d, 1Fh
add r10d, eax
sar r10d, 1
movsxd rax, r10d
lea r8, [r11+rax*4]
mov eax, ebx
loc_119D:
cmp edi, esi
jg short loc_11BD
test eax, eax
jnz short loc_11BD
mov ecx, [r8]
mov eax, r9d
cmp ecx, edx
jz short loc_119D
jle short loc_11B7
lea esi, [r10-1]
jmp short loc_1184
loc_11B7:
lea edi, [r10+1]
jmp short loc_1184
loc_11BD:
pop rbx
retn | long long func0(long long a1, int a2, int a3)
{
int v4; // esi
int v5; // edi
int v6; // r10d
long long result; // rax
int v8; // ecx
v4 = a2 - 1;
v5 = 0;
LABEL_2:
v6 = (v5 + v4) / 2;
result = 0LL;
while ( v5 <= v4 && !(_DWORD)result )
{
v8 = *(_DWORD *)(a1 + 4LL * v6);
result = 1LL;
if ( v8 != a3 )
{
if ( v8 <= a3 )
v5 = v6 + 1;
else
v4 = v6 - 1;
goto LABEL_2;
}
}
return result;
} | func0:
ENDBR64
PUSH RBX
MOV R11,RDI
SUB ESI,0x1
MOV EDI,0x0
MOV EBX,0x0
MOV R9D,0x1
LAB_00101184:
LEA EAX,[RDI + RSI*0x1]
MOV R10D,EAX
SHR R10D,0x1f
ADD R10D,EAX
SAR R10D,0x1
MOVSXD RAX,R10D
LEA R8,[R11 + RAX*0x4]
MOV EAX,EBX
LAB_0010119d:
CMP EDI,ESI
JG 0x001011bd
TEST EAX,EAX
JNZ 0x001011bd
MOV ECX,dword ptr [R8]
MOV EAX,R9D
CMP ECX,EDX
JZ 0x0010119d
JLE 0x001011b7
LEA ESI,[R10 + -0x1]
JMP 0x00101184
LAB_001011b7:
LEA EDI,[R10 + 0x1]
JMP 0x00101184
LAB_001011bd:
POP RBX
RET | void func0(long param_1,int param_2,int param_3)
{
int iVar1;
bool bVar2;
int iVar3;
int iVar4;
param_2 = param_2 + -1;
iVar3 = 0;
do {
iVar4 = (iVar3 + param_2) / 2;
bVar2 = false;
do {
if ((param_2 < iVar3) || (bVar2)) {
return;
}
iVar1 = *(int *)(param_1 + (long)iVar4 * 4);
bVar2 = true;
} while (iVar1 == param_3);
if (param_3 < iVar1) {
param_2 = iVar4 + -1;
}
else {
iVar3 = iVar4 + 1;
}
} while( true );
} |
5,862 | func0 |
#include <assert.h>
| int func0(int item_list[], int size, int item) {
int first = 0;
int last = size - 1;
int found = 0;
while (first <= last && !found) {
int mid = (first + last) / 2;
if (item_list[mid] == item) {
found = 1;
} else {
if (item < item_list[mid]) {
last = mid - 1;
} else {
first = mid + 1;
}
}
}
return found;
}
| int main() {
int list1[] = {1, 2, 3, 5, 8};
int size1 = sizeof(list1) / sizeof(list1[0]);
int list2[] = {7, 8, 9, 10, 13};
int size2 = sizeof(list2) / sizeof(list2[0]);
int list3[] = {11, 13, 14, 19, 22, 36};
int size3 = sizeof(list3) / sizeof(list3[0]);
assert(func0(list1, size1, 6) == 0);
assert(func0(list2, size2, 10) == 1);
assert(func0(list3, size3, 23) == 0);
return 0;
}
| O2 | c | func0:
endbr64
lea -0x1(%rsi),%r9d
xor %r10d,%r10d
lea (%r10,%r9,1),%r8d
sar %r8d
cmp %r10d,%r9d
movslq %r8d,%rax
setge %cl
lea (%rdi,%rax,4),%rsi
xor %eax,%eax
nopl 0x0(%rax)
test %eax,%eax
jne 13b8 <func0+0x48>
test %cl,%cl
je 13b8 <func0+0x48>
mov $0x1,%eax
cmp %edx,(%rsi)
je 1398 <func0+0x28>
jle 13c0 <func0+0x50>
lea -0x1(%r8),%r9d
jmp 137b <func0+0xb>
nopl 0x0(%rax)
retq
nopl 0x0(%rax)
lea 0x1(%r8),%r10d
jmp 137b <func0+0xb>
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
sub esi, 1
xor r10d, r10d
loc_12CA:
lea r9d, [rsi+r10]
sar r9d, 1
cmp r10d, esi
movsxd rax, r9d
setle cl
lea r8, [rdi+rax*4]
xor eax, eax
loc_12E0:
test eax, eax
jnz short locret_1300
test cl, cl
jz short locret_1300
mov eax, 1
cmp [r8], edx
jz short loc_12E0
jle short loc_1308
lea esi, [r9-1]
jmp short loc_12CA
locret_1300:
retn
loc_1308:
lea r10d, [r9+1]
jmp short loc_12CA | long long func0(long long a1, int a2, int a3)
{
int v3; // esi
int v4; // r10d
int v5; // r9d
_DWORD *v6; // r8
long long result; // rax
v3 = a2 - 1;
v4 = 0;
LABEL_2:
v5 = (v3 + v4) >> 1;
v6 = (_DWORD *)(a1 + 4LL * v5);
result = 0LL;
while ( !(_DWORD)result && v4 <= v3 )
{
result = 1LL;
if ( *v6 != a3 )
{
if ( *v6 <= a3 )
v4 = v5 + 1;
else
v3 = v5 - 1;
goto LABEL_2;
}
}
return result;
} | func0:
ENDBR64
SUB ESI,0x1
XOR R10D,R10D
LAB_001012ca:
LEA R9D,[RSI + R10*0x1]
SAR R9D,0x1
CMP R10D,ESI
MOVSXD RAX,R9D
SETLE CL
LEA R8,[RDI + RAX*0x4]
XOR EAX,EAX
LAB_001012e0:
TEST EAX,EAX
JNZ 0x00101300
TEST CL,CL
JZ 0x00101300
MOV EAX,0x1
CMP dword ptr [R8],EDX
JZ 0x001012e0
JLE 0x00101308
LEA ESI,[R9 + -0x1]
JMP 0x001012ca
LAB_00101300:
RET
LAB_00101308:
LEA R10D,[R9 + 0x1]
JMP 0x001012ca | void func0(long param_1,int param_2,int param_3)
{
int iVar1;
bool bVar2;
int iVar3;
int iVar4;
param_2 = param_2 + -1;
iVar4 = 0;
do {
iVar3 = param_2 + iVar4 >> 1;
bVar2 = false;
do {
if ((bVar2) || (param_2 < iVar4)) {
return;
}
bVar2 = true;
iVar1 = *(int *)(param_1 + (long)iVar3 * 4);
} while (iVar1 == param_3);
if (param_3 < iVar1) {
param_2 = iVar3 + -1;
}
else {
iVar4 = iVar3 + 1;
}
} while( true );
} |
5,863 | func0 |
#include <assert.h>
| int func0(int item_list[], int size, int item) {
int first = 0;
int last = size - 1;
int found = 0;
while (first <= last && !found) {
int mid = (first + last) / 2;
if (item_list[mid] == item) {
found = 1;
} else {
if (item < item_list[mid]) {
last = mid - 1;
} else {
first = mid + 1;
}
}
}
return found;
}
| int main() {
int list1[] = {1, 2, 3, 5, 8};
int size1 = sizeof(list1) / sizeof(list1[0]);
int list2[] = {7, 8, 9, 10, 13};
int size2 = sizeof(list2) / sizeof(list2[0]);
int list3[] = {11, 13, 14, 19, 22, 36};
int size3 = sizeof(list3) / sizeof(list3[0]);
assert(func0(list1, size1, 6) == 0);
assert(func0(list2, size2, 10) == 1);
assert(func0(list3, size3, 23) == 0);
return 0;
}
| O3 | c | func0:
endbr64
lea -0x1(%rsi),%r9d
xor %r10d,%r10d
lea (%r10,%r9,1),%r8d
sar %r8d
cmp %r10d,%r9d
movslq %r8d,%rax
setge %cl
lea (%rdi,%rax,4),%rsi
xor %eax,%eax
nopl 0x0(%rax)
test %eax,%eax
jne 1388 <func0+0x48>
test %cl,%cl
je 1388 <func0+0x48>
mov $0x1,%eax
cmp %edx,(%rsi)
je 1368 <func0+0x28>
jle 1390 <func0+0x50>
lea -0x1(%r8),%r9d
jmp 134b <func0+0xb>
nopl 0x0(%rax)
retq
nopl 0x0(%rax)
lea 0x1(%r8),%r10d
jmp 134b <func0+0xb>
nopw %cs:0x0(%rax,%rax,1)
| func0:
endbr64
sub esi, 1
xor r8d, r8d
loc_130A:
lea eax, [rsi+r8]
mov ecx, eax
shr ecx, 1Fh
add ecx, eax
sar ecx, 1
movsxd rax, ecx
lea rax, [rdi+rax*4]
cmp r8d, esi
jg short loc_1346
cmp [rax], edx
jnz short loc_1330
mov eax, 1
retn
loc_1330:
jle short loc_1340
lea esi, [rcx-1]
jmp short loc_130A
loc_1340:
lea r8d, [rcx+1]
jmp short loc_130A
loc_1346:
xor eax, eax
retn | long long func0(long long a1, int a2, int a3)
{
int v3; // esi
int v4; // r8d
int v5; // ecx
_DWORD *v6; // rax
v3 = a2 - 1;
v4 = 0;
while ( 1 )
{
v5 = (v3 + v4) / 2;
v6 = (_DWORD *)(a1 + 4LL * v5);
if ( v4 > v3 )
break;
if ( *v6 == a3 )
return 1LL;
if ( *v6 <= a3 )
v4 = v5 + 1;
else
v3 = v5 - 1;
}
return 0LL;
} | func0:
ENDBR64
SUB ESI,0x1
XOR R8D,R8D
LAB_0010130a:
LEA EAX,[RSI + R8*0x1]
MOV ECX,EAX
SHR ECX,0x1f
ADD ECX,EAX
SAR ECX,0x1
MOVSXD RAX,ECX
LEA RAX,[RDI + RAX*0x4]
CMP R8D,ESI
JG 0x00101346
CMP dword ptr [RAX],EDX
JNZ 0x00101330
MOV EAX,0x1
RET
LAB_00101330:
JLE 0x00101340
LEA ESI,[RCX + -0x1]
JMP 0x0010130a
LAB_00101340:
LEA R8D,[RCX + 0x1]
JMP 0x0010130a
LAB_00101346:
XOR EAX,EAX
RET | int8 func0(long param_1,int param_2,int param_3)
{
int iVar1;
int iVar2;
int iVar3;
param_2 = param_2 + -1;
iVar3 = 0;
while( true ) {
iVar2 = (param_2 + iVar3) / 2;
if (param_2 < iVar3) {
return 0;
}
iVar1 = *(int *)(param_1 + (long)iVar2 * 4);
if (iVar1 == param_3) break;
if (param_3 < iVar1) {
param_2 = iVar2 + -1;
}
else {
iVar3 = iVar2 + 1;
}
}
return 1;
} |
5,864 | func0 |
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
| double** func0(double startx, double starty, double endx, double endy, double radius) {
double sl = (2 * radius) * tan(M_PI / 6);
double p = sl * 0.5;
double b = sl * cos(M_PI / 6);
double w = b * 2;
double h = 2 * sl;
startx = startx - w;
starty = starty - h;
endx = endx + w;
endy = endy + h;
double origx = startx;
double origy = starty;
double xoffset = b;
double yoffset = 3 * p;
int index = 0;
int polygons_size = 100; // Suppose a maximum of 100 polygons
double** polygons = malloc(polygons_size * sizeof(double*));
int row = 1;
while (starty < endy) {
if (row % 2 == 0) {
startx = origx + xoffset;
} else {
startx = origx;
}
while (startx < endx) {
double* poly = (double*)malloc(14 * sizeof(double)); // 7 points (x,y) pairs
poly[0] = startx;
poly[1] = starty + p;
poly[2] = startx;
poly[3] = starty + (3 * p);
poly[4] = startx + b;
poly[5] = starty + h;
poly[6] = startx + w;
poly[7] = starty + (3 * p);
poly[8] = startx + w;
poly[9] = starty + p;
poly[10] = startx + b;
poly[11] = starty;
poly[12] = startx;
poly[13] = starty + p;
polygons[index++] = poly;
startx += w;
}
starty += yoffset;
row += 1;
}
return polygons;
}
| int main() {
double** res;
// Tests would compare the structures generated, which would require setup of expected values;
// for simplicity, I'm keeping the main just as a basic structure call.
res = func0(1, 1, 4, 4, 3);
// Assume a function `compare_polygons` to check if returned polygons are correct
res = func0(5, 4, 7, 9, 8);
// Assume a check
res = func0(9, 6, 4, 3, 2);
// Assume a check
printf("All tests passed successfully.\n");
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0xa0,%rsp
movsd %xmm0,-0x78(%rbp)
movsd %xmm1,-0x80(%rbp)
movsd %xmm2,-0x88(%rbp)
movsd %xmm3,-0x90(%rbp)
movsd %xmm4,-0x98(%rbp)
movsd -0x98(%rbp),%xmm0
movapd %xmm0,%xmm1
addsd %xmm0,%xmm1
movsd 0xe76(%rip),%xmm0
mulsd %xmm1,%xmm0
movsd %xmm0,-0x58(%rbp)
movsd -0x58(%rbp),%xmm1
movsd 0xe68(%rip),%xmm0
mulsd %xmm1,%xmm0
movsd %xmm0,-0x50(%rbp)
movsd -0x58(%rbp),%xmm1
movsd 0xe5a(%rip),%xmm0
mulsd %xmm1,%xmm0
movsd %xmm0,-0x48(%rbp)
movsd -0x48(%rbp),%xmm0
addsd %xmm0,%xmm0
movsd %xmm0,-0x40(%rbp)
movsd -0x58(%rbp),%xmm0
addsd %xmm0,%xmm0
movsd %xmm0,-0x38(%rbp)
movsd -0x78(%rbp),%xmm0
subsd -0x40(%rbp),%xmm0
movsd %xmm0,-0x78(%rbp)
movsd -0x80(%rbp),%xmm0
subsd -0x38(%rbp),%xmm0
movsd %xmm0,-0x80(%rbp)
movsd -0x88(%rbp),%xmm0
addsd -0x40(%rbp),%xmm0
movsd %xmm0,-0x88(%rbp)
movsd -0x90(%rbp),%xmm0
addsd -0x38(%rbp),%xmm0
movsd %xmm0,-0x90(%rbp)
movsd -0x78(%rbp),%xmm0
movsd %xmm0,-0x30(%rbp)
movsd -0x80(%rbp),%xmm0
movsd %xmm0,-0x28(%rbp)
movsd -0x48(%rbp),%xmm0
movsd %xmm0,-0x20(%rbp)
movsd -0x50(%rbp),%xmm1
movsd 0xdca(%rip),%xmm0
mulsd %xmm1,%xmm0
movsd %xmm0,-0x18(%rbp)
movl $0x0,-0x64(%rbp)
movl $0x64,-0x5c(%rbp)
mov -0x5c(%rbp),%eax
cltq
shl $0x3,%rax
mov %rax,%rdi
callq 1070 <malloc@plt>
mov %rax,-0x10(%rbp)
movl $0x1,-0x60(%rbp)
jmpq 1473 <func0+0x30a>
mov -0x60(%rbp),%eax
and $0x1,%eax
test %eax,%eax
jne 12cc <func0+0x163>
movsd -0x30(%rbp),%xmm0
addsd -0x20(%rbp),%xmm0
movsd %xmm0,-0x78(%rbp)
jmpq 144d <func0+0x2e4>
movsd -0x30(%rbp),%xmm0
movsd %xmm0,-0x78(%rbp)
jmpq 144d <func0+0x2e4>
mov $0x70,%edi
callq 1070 <malloc@plt>
mov %rax,-0x8(%rbp)
mov -0x8(%rbp),%rax
movsd -0x78(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x8,%rax
movsd -0x80(%rbp),%xmm0
addsd -0x50(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x10,%rax
movsd -0x78(%rbp),%xmm0
movsd %xmm0,(%rax)
movsd -0x50(%rbp),%xmm1
movsd 0xd16(%rip),%xmm0
mulsd %xmm1,%xmm0
mov -0x8(%rbp),%rax
add $0x18,%rax
addsd -0x80(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x20,%rax
movsd -0x78(%rbp),%xmm0
addsd -0x48(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x28,%rax
movsd -0x80(%rbp),%xmm0
addsd -0x38(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x30,%rax
movsd -0x78(%rbp),%xmm0
addsd -0x40(%rbp),%xmm0
movsd %xmm0,(%rax)
movsd -0x50(%rbp),%xmm1
movsd 0xcb2(%rip),%xmm0
mulsd %xmm1,%xmm0
mov -0x8(%rbp),%rax
add $0x38,%rax
addsd -0x80(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x40,%rax
movsd -0x78(%rbp),%xmm0
addsd -0x40(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x48,%rax
movsd -0x80(%rbp),%xmm0
addsd -0x50(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x50,%rax
movsd -0x78(%rbp),%xmm0
addsd -0x48(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x58,%rax
movsd -0x80(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x60,%rax
movsd -0x78(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x8(%rbp),%rax
add $0x68,%rax
movsd -0x80(%rbp),%xmm0
addsd -0x50(%rbp),%xmm0
movsd %xmm0,(%rax)
mov -0x64(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x64(%rbp)
cltq
lea 0x0(,%rax,8),%rdx
mov -0x10(%rbp),%rax
add %rax,%rdx
mov -0x8(%rbp),%rax
mov %rax,(%rdx)
movsd -0x78(%rbp),%xmm0
addsd -0x40(%rbp),%xmm0
movsd %xmm0,-0x78(%rbp)
movsd -0x88(%rbp),%xmm0
comisd -0x78(%rbp),%xmm0
ja 12db <func0+0x172>
movsd -0x80(%rbp),%xmm0
addsd -0x18(%rbp),%xmm0
movsd %xmm0,-0x80(%rbp)
addl $0x1,-0x60(%rbp)
movsd -0x90(%rbp),%xmm0
comisd -0x80(%rbp),%xmm0
ja 12ae <func0+0x145>
mov -0x10(%rbp),%rax
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 0A0h
movsd [rbp+var_78], xmm0
movsd [rbp+var_80], xmm1
movsd [rbp+var_88], xmm2
movsd [rbp+var_90], xmm3
movsd [rbp+var_98], xmm4
movsd xmm0, [rbp+var_98]
movapd xmm1, xmm0
addsd xmm1, xmm0
movsd xmm0, cs:qword_2028
mulsd xmm0, xmm1
movsd [rbp+var_58], xmm0
movsd xmm1, [rbp+var_58]
movsd xmm0, cs:qword_2030
mulsd xmm0, xmm1
movsd [rbp+var_50], xmm0
movsd xmm1, [rbp+var_58]
movsd xmm0, cs:qword_2038
mulsd xmm0, xmm1
movsd [rbp+var_48], xmm0
movsd xmm0, [rbp+var_48]
addsd xmm0, xmm0
movsd [rbp+var_40], xmm0
movsd xmm0, [rbp+var_58]
addsd xmm0, xmm0
movsd [rbp+var_38], xmm0
movsd xmm0, [rbp+var_78]
subsd xmm0, [rbp+var_40]
movsd [rbp+var_78], xmm0
movsd xmm0, [rbp+var_80]
subsd xmm0, [rbp+var_38]
movsd [rbp+var_80], xmm0
movsd xmm0, [rbp+var_88]
addsd xmm0, [rbp+var_40]
movsd [rbp+var_88], xmm0
movsd xmm0, [rbp+var_90]
addsd xmm0, [rbp+var_38]
movsd [rbp+var_90], xmm0
movsd xmm0, [rbp+var_78]
movsd [rbp+var_30], xmm0
movsd xmm0, [rbp+var_80]
movsd [rbp+var_28], xmm0
movsd xmm0, [rbp+var_48]
movsd [rbp+var_20], xmm0
movsd xmm1, [rbp+var_50]
movsd xmm0, cs:qword_2040
mulsd xmm0, xmm1
movsd [rbp+var_18], xmm0
mov [rbp+var_64], 0
mov [rbp+var_5C], 64h ; 'd'
mov eax, [rbp+var_5C]
cdqe
shl rax, 3
mov rdi, rax; size
call _malloc
mov [rbp+var_10], rax
mov [rbp+var_60], 1
jmp loc_1473
loc_12AE:
mov eax, [rbp+var_60]
and eax, 1
test eax, eax
jnz short loc_12CC
movsd xmm0, [rbp+var_30]
addsd xmm0, [rbp+var_20]
movsd [rbp+var_78], xmm0
jmp loc_144D
loc_12CC:
movsd xmm0, [rbp+var_30]
movsd [rbp+var_78], xmm0
jmp loc_144D
loc_12DB:
mov edi, 70h ; 'p'; size
call _malloc
mov [rbp+var_8], rax
mov rax, [rbp+var_8]
movsd xmm0, [rbp+var_78]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 8
movsd xmm0, [rbp+var_80]
addsd xmm0, [rbp+var_50]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 10h
movsd xmm0, [rbp+var_78]
movsd qword ptr [rax], xmm0
movsd xmm1, [rbp+var_50]
movsd xmm0, cs:qword_2040
mulsd xmm0, xmm1
mov rax, [rbp+var_8]
add rax, 18h
addsd xmm0, [rbp+var_80]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 20h ; ' '
movsd xmm0, [rbp+var_78]
addsd xmm0, [rbp+var_48]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 28h ; '('
movsd xmm0, [rbp+var_80]
addsd xmm0, [rbp+var_38]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 30h ; '0'
movsd xmm0, [rbp+var_78]
addsd xmm0, [rbp+var_40]
movsd qword ptr [rax], xmm0
movsd xmm1, [rbp+var_50]
movsd xmm0, cs:qword_2040
mulsd xmm0, xmm1
mov rax, [rbp+var_8]
add rax, 38h ; '8'
addsd xmm0, [rbp+var_80]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 40h ; '@'
movsd xmm0, [rbp+var_78]
addsd xmm0, [rbp+var_40]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 48h ; 'H'
movsd xmm0, [rbp+var_80]
addsd xmm0, [rbp+var_50]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 50h ; 'P'
movsd xmm0, [rbp+var_78]
addsd xmm0, [rbp+var_48]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 58h ; 'X'
movsd xmm0, [rbp+var_80]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 60h ; '`'
movsd xmm0, [rbp+var_78]
movsd qword ptr [rax], xmm0
mov rax, [rbp+var_8]
add rax, 68h ; 'h'
movsd xmm0, [rbp+var_80]
addsd xmm0, [rbp+var_50]
movsd qword ptr [rax], xmm0
mov eax, [rbp+var_64]
lea edx, [rax+1]
mov [rbp+var_64], edx
cdqe
lea rdx, ds:0[rax*8]
mov rax, [rbp+var_10]
add rdx, rax
mov rax, [rbp+var_8]
mov [rdx], rax
movsd xmm0, [rbp+var_78]
addsd xmm0, [rbp+var_40]
movsd [rbp+var_78], xmm0
loc_144D:
movsd xmm0, [rbp+var_88]
comisd xmm0, [rbp+var_78]
ja loc_12DB
movsd xmm0, [rbp+var_80]
addsd xmm0, [rbp+var_18]
movsd [rbp+var_80], xmm0
add [rbp+var_60], 1
loc_1473:
movsd xmm0, [rbp+var_90]
comisd xmm0, [rbp+var_80]
ja loc_12AE
mov rax, [rbp+var_10]
leave
retn | _QWORD * func0(double a1, double a2, double a3, double a4, double a5)
{
int v5; // eax
double v7; // [rsp+20h] [rbp-80h]
double v8; // [rsp+28h] [rbp-78h]
int v9; // [rsp+3Ch] [rbp-64h]
char v10; // [rsp+40h] [rbp-60h]
double v11; // [rsp+50h] [rbp-50h]
double v12; // [rsp+58h] [rbp-48h]
double v13; // [rsp+60h] [rbp-40h]
double v14; // [rsp+68h] [rbp-38h]
_QWORD *v15; // [rsp+90h] [rbp-10h]
double *v16; // [rsp+98h] [rbp-8h]
v11 = 0.5 * (0.5773502691896257 * (a5 + a5));
v12 = 0.8660254037844387 * (0.5773502691896257 * (a5 + a5));
v13 = v12 + v12;
v14 = 0.5773502691896257 * (a5 + a5) + 0.5773502691896257 * (a5 + a5);
v7 = a2 - v14;
v9 = 0;
v15 = malloc(0x320uLL);
v10 = 1;
while ( a4 + v14 > v7 )
{
if ( (v10 & 1) != 0 )
v8 = a1 - v13;
else
v8 = a1 - v13 + v12;
while ( a3 + v13 > v8 )
{
v16 = (double *)malloc(0x70uLL);
*v16 = v8;
v16[1] = v7 + v11;
v16[2] = v8;
v16[3] = 3.0 * v11 + v7;
v16[4] = v8 + v12;
v16[5] = v7 + v14;
v16[6] = v8 + v13;
v16[7] = 3.0 * v11 + v7;
v16[8] = v8 + v13;
v16[9] = v7 + v11;
v16[10] = v8 + v12;
v16[11] = v7;
v16[12] = v8;
v16[13] = v7 + v11;
v5 = v9++;
v15[v5] = v16;
v8 = v8 + v13;
}
v7 = v7 + 3.0 * v11;
++v10;
}
return v15;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0xa0
MOVSD qword ptr [RBP + -0x78],XMM0
MOVSD qword ptr [RBP + -0x80],XMM1
MOVSD qword ptr [RBP + -0x88],XMM2
MOVSD qword ptr [RBP + -0x90],XMM3
MOVSD qword ptr [RBP + -0x98],XMM4
MOVSD XMM0,qword ptr [RBP + -0x98]
MOVAPD XMM1,XMM0
ADDSD XMM1,XMM0
MOVSD XMM0,qword ptr [0x00102028]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x58],XMM0
MOVSD XMM1,qword ptr [RBP + -0x58]
MOVSD XMM0,qword ptr [0x00102030]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x50],XMM0
MOVSD XMM1,qword ptr [RBP + -0x58]
MOVSD XMM0,qword ptr [0x00102038]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x48],XMM0
MOVSD XMM0,qword ptr [RBP + -0x48]
ADDSD XMM0,XMM0
MOVSD qword ptr [RBP + -0x40],XMM0
MOVSD XMM0,qword ptr [RBP + -0x58]
ADDSD XMM0,XMM0
MOVSD qword ptr [RBP + -0x38],XMM0
MOVSD XMM0,qword ptr [RBP + -0x78]
SUBSD XMM0,qword ptr [RBP + -0x40]
MOVSD qword ptr [RBP + -0x78],XMM0
MOVSD XMM0,qword ptr [RBP + -0x80]
SUBSD XMM0,qword ptr [RBP + -0x38]
MOVSD qword ptr [RBP + -0x80],XMM0
MOVSD XMM0,qword ptr [RBP + -0x88]
ADDSD XMM0,qword ptr [RBP + -0x40]
MOVSD qword ptr [RBP + -0x88],XMM0
MOVSD XMM0,qword ptr [RBP + -0x90]
ADDSD XMM0,qword ptr [RBP + -0x38]
MOVSD qword ptr [RBP + -0x90],XMM0
MOVSD XMM0,qword ptr [RBP + -0x78]
MOVSD qword ptr [RBP + -0x30],XMM0
MOVSD XMM0,qword ptr [RBP + -0x80]
MOVSD qword ptr [RBP + -0x28],XMM0
MOVSD XMM0,qword ptr [RBP + -0x48]
MOVSD qword ptr [RBP + -0x20],XMM0
MOVSD XMM1,qword ptr [RBP + -0x50]
MOVSD XMM0,qword ptr [0x00102040]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x18],XMM0
MOV dword ptr [RBP + -0x64],0x0
MOV dword ptr [RBP + -0x5c],0x64
MOV EAX,dword ptr [RBP + -0x5c]
CDQE
SHL RAX,0x3
MOV RDI,RAX
CALL 0x00101070
MOV qword ptr [RBP + -0x10],RAX
MOV dword ptr [RBP + -0x60],0x1
JMP 0x00101473
LAB_001012ae:
MOV EAX,dword ptr [RBP + -0x60]
AND EAX,0x1
TEST EAX,EAX
JNZ 0x001012cc
MOVSD XMM0,qword ptr [RBP + -0x30]
ADDSD XMM0,qword ptr [RBP + -0x20]
MOVSD qword ptr [RBP + -0x78],XMM0
JMP 0x0010144d
LAB_001012cc:
MOVSD XMM0,qword ptr [RBP + -0x30]
MOVSD qword ptr [RBP + -0x78],XMM0
JMP 0x0010144d
LAB_001012db:
MOV EDI,0x70
CALL 0x00101070
MOV qword ptr [RBP + -0x8],RAX
MOV RAX,qword ptr [RBP + -0x8]
MOVSD XMM0,qword ptr [RBP + -0x78]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x8
MOVSD XMM0,qword ptr [RBP + -0x80]
ADDSD XMM0,qword ptr [RBP + -0x50]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x10
MOVSD XMM0,qword ptr [RBP + -0x78]
MOVSD qword ptr [RAX],XMM0
MOVSD XMM1,qword ptr [RBP + -0x50]
MOVSD XMM0,qword ptr [0x00102040]
MULSD XMM0,XMM1
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x18
ADDSD XMM0,qword ptr [RBP + -0x80]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x20
MOVSD XMM0,qword ptr [RBP + -0x78]
ADDSD XMM0,qword ptr [RBP + -0x48]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x28
MOVSD XMM0,qword ptr [RBP + -0x80]
ADDSD XMM0,qword ptr [RBP + -0x38]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x30
MOVSD XMM0,qword ptr [RBP + -0x78]
ADDSD XMM0,qword ptr [RBP + -0x40]
MOVSD qword ptr [RAX],XMM0
MOVSD XMM1,qword ptr [RBP + -0x50]
MOVSD XMM0,qword ptr [0x00102040]
MULSD XMM0,XMM1
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x38
ADDSD XMM0,qword ptr [RBP + -0x80]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x40
MOVSD XMM0,qword ptr [RBP + -0x78]
ADDSD XMM0,qword ptr [RBP + -0x40]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x48
MOVSD XMM0,qword ptr [RBP + -0x80]
ADDSD XMM0,qword ptr [RBP + -0x50]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x50
MOVSD XMM0,qword ptr [RBP + -0x78]
ADDSD XMM0,qword ptr [RBP + -0x48]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x58
MOVSD XMM0,qword ptr [RBP + -0x80]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x60
MOVSD XMM0,qword ptr [RBP + -0x78]
MOVSD qword ptr [RAX],XMM0
MOV RAX,qword ptr [RBP + -0x8]
ADD RAX,0x68
MOVSD XMM0,qword ptr [RBP + -0x80]
ADDSD XMM0,qword ptr [RBP + -0x50]
MOVSD qword ptr [RAX],XMM0
MOV EAX,dword ptr [RBP + -0x64]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x64],EDX
CDQE
LEA RDX,[RAX*0x8]
MOV RAX,qword ptr [RBP + -0x10]
ADD RDX,RAX
MOV RAX,qword ptr [RBP + -0x8]
MOV qword ptr [RDX],RAX
MOVSD XMM0,qword ptr [RBP + -0x78]
ADDSD XMM0,qword ptr [RBP + -0x40]
MOVSD qword ptr [RBP + -0x78],XMM0
LAB_0010144d:
MOVSD XMM0,qword ptr [RBP + -0x88]
COMISD XMM0,qword ptr [RBP + -0x78]
JA 0x001012db
MOVSD XMM0,qword ptr [RBP + -0x80]
ADDSD XMM0,qword ptr [RBP + -0x18]
MOVSD qword ptr [RBP + -0x80],XMM0
ADD dword ptr [RBP + -0x60],0x1
LAB_00101473:
MOVSD XMM0,qword ptr [RBP + -0x90]
COMISD XMM0,qword ptr [RBP + -0x80]
JA 0x001012ae
MOV RAX,qword ptr [RBP + -0x10]
LEAVE
RET | void * func0(double param_1,double param_2,double param_3,double param_4,double param_5)
{
bool bVar1;
void *pvVar2;
double *pdVar3;
double dVar4;
double dVar5;
double dVar6;
double dVar7;
double dVar8;
double local_88;
double local_80;
int local_6c;
dVar4 = DAT_00102028 * (param_5 + param_5);
dVar5 = DAT_00102030 * dVar4;
dVar6 = DAT_00102038 * dVar4;
dVar7 = dVar6 + dVar6;
dVar4 = dVar4 + dVar4;
dVar8 = DAT_00102040 * dVar5;
local_6c = 0;
pvVar2 = malloc(800);
bVar1 = true;
for (local_88 = param_2 - dVar4; local_88 < param_4 + dVar4; local_88 = local_88 + dVar8) {
local_80 = param_1 - dVar7;
if (!bVar1) {
local_80 = (param_1 - dVar7) + dVar6;
}
for (; local_80 < param_3 + dVar7; local_80 = local_80 + dVar7) {
pdVar3 = (double *)malloc(0x70);
*pdVar3 = local_80;
pdVar3[1] = local_88 + dVar5;
pdVar3[2] = local_80;
pdVar3[3] = DAT_00102040 * dVar5 + local_88;
pdVar3[4] = local_80 + dVar6;
pdVar3[5] = local_88 + dVar4;
pdVar3[6] = local_80 + dVar7;
pdVar3[7] = DAT_00102040 * dVar5 + local_88;
pdVar3[8] = local_80 + dVar7;
pdVar3[9] = local_88 + dVar5;
pdVar3[10] = local_80 + dVar6;
pdVar3[0xb] = local_88;
pdVar3[0xc] = local_80;
pdVar3[0xd] = local_88 + dVar5;
*(double **)((long)local_6c * 8 + (long)pvVar2) = pdVar3;
local_6c = local_6c + 1;
}
bVar1 = (bool)(bVar1 ^ 1);
}
return pvVar2;
} |
5,865 | func0 |
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
| double** func0(double startx, double starty, double endx, double endy, double radius) {
double sl = (2 * radius) * tan(M_PI / 6);
double p = sl * 0.5;
double b = sl * cos(M_PI / 6);
double w = b * 2;
double h = 2 * sl;
startx = startx - w;
starty = starty - h;
endx = endx + w;
endy = endy + h;
double origx = startx;
double origy = starty;
double xoffset = b;
double yoffset = 3 * p;
int index = 0;
int polygons_size = 100; // Suppose a maximum of 100 polygons
double** polygons = malloc(polygons_size * sizeof(double*));
int row = 1;
while (starty < endy) {
if (row % 2 == 0) {
startx = origx + xoffset;
} else {
startx = origx;
}
while (startx < endx) {
double* poly = (double*)malloc(14 * sizeof(double)); // 7 points (x,y) pairs
poly[0] = startx;
poly[1] = starty + p;
poly[2] = startx;
poly[3] = starty + (3 * p);
poly[4] = startx + b;
poly[5] = starty + h;
poly[6] = startx + w;
poly[7] = starty + (3 * p);
poly[8] = startx + w;
poly[9] = starty + p;
poly[10] = startx + b;
poly[11] = starty;
poly[12] = startx;
poly[13] = starty + p;
polygons[index++] = poly;
startx += w;
}
starty += yoffset;
row += 1;
}
return polygons;
}
| int main() {
double** res;
// Tests would compare the structures generated, which would require setup of expected values;
// for simplicity, I'm keeping the main just as a basic structure call.
res = func0(1, 1, 4, 4, 3);
// Assume a function `compare_polygons` to check if returned polygons are correct
res = func0(5, 4, 7, 9, 8);
// Assume a check
res = func0(9, 6, 4, 3, 2);
// Assume a check
printf("All tests passed successfully.\n");
return 0;
}
| O1 | c | func0:
endbr64
push %r13
push %r12
push %rbp
push %rbx
sub $0x58,%rsp
addsd %xmm4,%xmm4
mulsd 0xea5(%rip),%xmm4
movapd %xmm4,%xmm5
mulsd 0xea1(%rip),%xmm5
movsd %xmm5,0x28(%rsp)
movapd %xmm4,%xmm6
mulsd 0xe97(%rip),%xmm6
movsd %xmm6,0x20(%rsp)
addsd %xmm6,%xmm6
movsd %xmm6,0x30(%rsp)
addsd %xmm4,%xmm4
movsd %xmm4,0x38(%rsp)
subsd %xmm6,%xmm0
movsd %xmm0,0x48(%rsp)
subsd %xmm4,%xmm1
movsd %xmm1,0x8(%rsp)
addsd %xmm6,%xmm2
movsd %xmm2,0x10(%rsp)
addsd %xmm4,%xmm3
movsd %xmm3,0x40(%rsp)
mulsd 0xe55(%rip),%xmm5
movsd %xmm5,0x18(%rsp)
mov $0x320,%edi
callq 1070 <malloc@plt>
mov %rax,%r12
mov 0x48(%rsp),%rbx
mov $0x1,%r13d
mov $0x0,%edx
movsd 0x40(%rsp),%xmm3
comisd 0x8(%rsp),%xmm3
jbe 1337 <func0+0x1ce>
lea 0x1(%rdx),%ebp
movslq %ebp,%rbp
movsd 0x10(%rsp),%xmm7
movq %rbx,%xmm1
comisd %xmm1,%xmm7
jbe 12ec <func0+0x183>
mov $0x70,%edi
callq 1070 <malloc@plt>
mov %rbx,(%rax)
movsd 0x8(%rsp),%xmm5
movapd %xmm5,%xmm0
addsd 0x28(%rsp),%xmm0
movsd %xmm0,0x8(%rax)
mov %rbx,0x10(%rax)
movapd %xmm5,%xmm2
addsd 0x18(%rsp),%xmm2
movsd %xmm2,0x18(%rax)
movq %rbx,%xmm1
addsd 0x20(%rsp),%xmm1
movsd %xmm1,0x20(%rax)
movapd %xmm5,%xmm3
addsd 0x38(%rsp),%xmm3
movsd %xmm3,0x28(%rax)
movq %rbx,%xmm3
movq %rbx,%xmm6
addsd 0x30(%rsp),%xmm6
movq %xmm6,%rbx
movsd %xmm6,0x30(%rax)
movsd %xmm2,0x38(%rax)
movsd %xmm6,0x40(%rax)
movsd %xmm0,0x48(%rax)
movsd %xmm1,0x50(%rax)
movsd %xmm5,0x58(%rax)
movsd %xmm3,0x60(%rax)
movsd %xmm0,0x68(%rax)
mov %ebp,%edx
mov %rax,-0x8(%r12,%rbp,8)
add $0x1,%rbp
movsd 0x10(%rsp),%xmm6
movq %rbx,%xmm4
comisd %xmm4,%xmm6
ja 123b <func0+0xd2>
movsd 0x8(%rsp),%xmm6
addsd 0x18(%rsp),%xmm6
movsd %xmm6,0x8(%rsp)
add $0x1,%r13d
movsd 0x40(%rsp),%xmm4
comisd %xmm6,%xmm4
jbe 1337 <func0+0x1ce>
movsd 0x48(%rsp),%xmm6
movq %xmm6,%rbx
test $0x1,%r13b
jne 1220 <func0+0xb7>
movsd 0x20(%rsp),%xmm7
addsd %xmm6,%xmm7
movq %xmm7,%rbx
jmpq 1220 <func0+0xb7>
mov %r12,%rax
add $0x58,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
retq
| func0:
endbr64
push r15
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 48h
addsd xmm4, xmm4
mulsd xmm4, cs:qword_2028
movapd xmm5, xmm4
mulsd xmm5, cs:qword_2030
movsd [rsp+78h+var_58], xmm5
movapd xmm7, xmm4
mulsd xmm7, cs:qword_2038
movsd [rsp+78h+var_60], xmm7
addsd xmm7, xmm7
movsd [rsp+78h+var_50], xmm7
movapd xmm6, xmm4
addsd xmm6, xmm4
movsd [rsp+78h+var_48], xmm6
subsd xmm0, xmm7
movq r15, xmm0
subsd xmm1, xmm6
movq rbp, xmm1
addsd xmm2, xmm7
movsd [rsp+78h+var_70], xmm2
addsd xmm3, xmm6
movsd [rsp+78h+var_40], xmm3
mulsd xmm5, cs:qword_2040
movsd [rsp+78h+var_68], xmm5
mov edi, 320h
call _malloc
mov r13, rax
mov rbx, r15
mov r14d, 1
mov edx, 0
movsd xmm3, [rsp+78h+var_40]
movq xmm4, rbp
comisd xmm3, xmm4
jbe loc_1333
loc_1227:
lea r12d, [rdx+1]
movsxd r12, r12d
movsd xmm7, [rsp+78h+var_70]
movq xmm4, rbx
comisd xmm7, xmm4
jbe loc_12EC
loc_1243:
mov edi, 70h ; 'p'
call _malloc
mov [rax], rbx
movq xmm0, rbp
addsd xmm0, [rsp+78h+var_58]
movsd qword ptr [rax+8], xmm0
mov [rax+10h], rbx
movq xmm2, rbp
addsd xmm2, [rsp+78h+var_68]
movsd qword ptr [rax+18h], xmm2
movq xmm1, rbx
addsd xmm1, [rsp+78h+var_60]
movsd qword ptr [rax+20h], xmm1
movq xmm3, rbp
addsd xmm3, [rsp+78h+var_48]
movsd qword ptr [rax+28h], xmm3
movq xmm3, rbx
movq xmm5, rbx
addsd xmm5, [rsp+78h+var_50]
movq rbx, xmm5
movsd qword ptr [rax+30h], xmm5
movsd qword ptr [rax+38h], xmm2
movsd qword ptr [rax+40h], xmm5
movsd qword ptr [rax+48h], xmm0
movsd qword ptr [rax+50h], xmm1
mov [rax+58h], rbp
movsd qword ptr [rax+60h], xmm3
movsd qword ptr [rax+68h], xmm0
mov edx, r12d
mov [r13+r12*8-8], rax
add r12, 1
movsd xmm4, [rsp+78h+var_70]
comisd xmm4, xmm5
ja loc_1243
loc_12EC:
movq xmm6, rbp
addsd xmm6, [rsp+78h+var_68]
movq rbp, xmm6
add r14d, 1
movsd xmm6, [rsp+78h+var_40]
movq xmm4, rbp
comisd xmm6, xmm4
jbe short loc_1333
mov rbx, r15
test r14b, 1
jnz loc_1227
movq xmm7, r15
addsd xmm7, [rsp+78h+var_60]
movq rbx, xmm7
jmp loc_1227
loc_1333:
mov rax, r13
add rsp, 48h
pop rbx
pop rbp
pop r12
pop r13
pop r14
pop r15
retn | long long func0(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm4_8
double v6; // rbp
long long v7; // r13
double v8; // rbx
char v9; // r14
int v10; // edx
long long i; // r12
long long v12; // rax
double v13; // xmm1_8
double v14; // xmm3_8
double v16; // [rsp+8h] [rbp-70h]
double v17; // [rsp+10h] [rbp-68h]
double v18; // [rsp+18h] [rbp-60h]
double v19; // [rsp+20h] [rbp-58h]
double v20; // [rsp+30h] [rbp-48h]
double v21; // [rsp+38h] [rbp-40h]
v5 = (a5 + a5) * 0.5773502691896257;
v19 = v5 * 0.5;
v18 = v5 * 0.8660254037844387;
v20 = v5 + v5;
v6 = a2 - (v5 + v5);
v16 = a3 + v18 + v18;
v21 = a4 + v5 + v5;
v17 = v5 * 0.5 * 3.0;
v7 = malloc(800LL);
v8 = a1 - (v18 + v18);
v9 = 1;
v10 = 0;
if ( v21 > v6 )
{
while ( 1 )
{
for ( i = v10 + 1; v16 > v8; ++i )
{
v12 = malloc(112LL);
*(double *)v12 = v8;
*(double *)(v12 + 8) = v6 + v19;
*(double *)(v12 + 16) = v8;
*(double *)(v12 + 24) = v6 + v17;
v13 = v8 + v18;
*(double *)(v12 + 32) = v8 + v18;
*(double *)(v12 + 40) = v6 + v20;
v14 = v8;
v8 = v8 + v18 + v18;
*(double *)(v12 + 48) = v8;
*(double *)(v12 + 56) = v6 + v17;
*(double *)(v12 + 64) = v8;
*(double *)(v12 + 72) = v6 + v19;
*(double *)(v12 + 80) = v13;
*(double *)(v12 + 88) = v6;
*(double *)(v12 + 96) = v14;
*(double *)(v12 + 104) = v6 + v19;
v10 = i;
*(_QWORD *)(v7 + 8 * i - 8) = v12;
}
v6 = v6 + v17;
++v9;
if ( v21 <= v6 )
break;
v8 = a1 - (v18 + v18);
if ( (v9 & 1) == 0 )
v8 = a1 - (v18 + v18) + v18;
}
}
return v7;
} | func0:
ENDBR64
PUSH R15
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x48
ADDSD XMM4,XMM4
MULSD XMM4,qword ptr [0x00102028]
MOVAPD XMM5,XMM4
MULSD XMM5,qword ptr [0x00102030]
MOVSD qword ptr [RSP + 0x20],XMM5
MOVAPD XMM7,XMM4
MULSD XMM7,qword ptr [0x00102038]
MOVSD qword ptr [RSP + 0x18],XMM7
ADDSD XMM7,XMM7
MOVSD qword ptr [RSP + 0x28],XMM7
MOVAPD XMM6,XMM4
ADDSD XMM6,XMM4
MOVSD qword ptr [RSP + 0x30],XMM6
SUBSD XMM0,XMM7
MOVQ R15,XMM0
SUBSD XMM1,XMM6
MOVQ RBP,XMM1
ADDSD XMM2,XMM7
MOVSD qword ptr [RSP + 0x8],XMM2
ADDSD XMM3,XMM6
MOVSD qword ptr [RSP + 0x38],XMM3
MULSD XMM5,qword ptr [0x00102040]
MOVSD qword ptr [RSP + 0x10],XMM5
MOV EDI,0x320
CALL 0x00101070
MOV R13,RAX
MOV RBX,R15
MOV R14D,0x1
MOV EDX,0x0
MOVSD XMM3,qword ptr [RSP + 0x38]
MOVQ XMM4,RBP
COMISD XMM3,XMM4
JBE 0x00101333
LAB_00101227:
LEA R12D,[RDX + 0x1]
MOVSXD R12,R12D
MOVSD XMM7,qword ptr [RSP + 0x8]
MOVQ XMM4,RBX
COMISD XMM7,XMM4
JBE 0x001012ec
LAB_00101243:
MOV EDI,0x70
CALL 0x00101070
MOV qword ptr [RAX],RBX
MOVQ XMM0,RBP
ADDSD XMM0,qword ptr [RSP + 0x20]
MOVSD qword ptr [RAX + 0x8],XMM0
MOV qword ptr [RAX + 0x10],RBX
MOVQ XMM2,RBP
ADDSD XMM2,qword ptr [RSP + 0x10]
MOVSD qword ptr [RAX + 0x18],XMM2
MOVQ XMM1,RBX
ADDSD XMM1,qword ptr [RSP + 0x18]
MOVSD qword ptr [RAX + 0x20],XMM1
MOVQ XMM3,RBP
ADDSD XMM3,qword ptr [RSP + 0x30]
MOVSD qword ptr [RAX + 0x28],XMM3
MOVQ XMM3,RBX
MOVQ XMM5,RBX
ADDSD XMM5,qword ptr [RSP + 0x28]
MOVQ RBX,XMM5
MOVSD qword ptr [RAX + 0x30],XMM5
MOVSD qword ptr [RAX + 0x38],XMM2
MOVSD qword ptr [RAX + 0x40],XMM5
MOVSD qword ptr [RAX + 0x48],XMM0
MOVSD qword ptr [RAX + 0x50],XMM1
MOV qword ptr [RAX + 0x58],RBP
MOVSD qword ptr [RAX + 0x60],XMM3
MOVSD qword ptr [RAX + 0x68],XMM0
MOV EDX,R12D
MOV qword ptr [R13 + R12*0x8 + -0x8],RAX
ADD R12,0x1
MOVSD XMM4,qword ptr [RSP + 0x8]
COMISD XMM4,XMM5
JA 0x00101243
LAB_001012ec:
MOVQ XMM6,RBP
ADDSD XMM6,qword ptr [RSP + 0x10]
MOVQ RBP,XMM6
ADD R14D,0x1
MOVSD XMM6,qword ptr [RSP + 0x38]
MOVQ XMM4,RBP
COMISD XMM6,XMM4
JBE 0x00101333
MOV RBX,R15
TEST R14B,0x1
JNZ 0x00101227
MOVQ XMM7,R15
ADDSD XMM7,qword ptr [RSP + 0x18]
MOVQ RBX,XMM7
JMP 0x00101227
LAB_00101333:
MOV RAX,R13
ADD RSP,0x48
POP RBX
POP RBP
POP R12
POP R13
POP R14
POP R15
RET | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
void * func0(double param_1,double param_2,double param_3,double param_4,double param_5)
{
void *pvVar1;
double *pdVar2;
int iVar3;
long lVar4;
bool bVar5;
double dVar6;
double dVar7;
double dVar8;
double dVar9;
double dVar10;
double dVar11;
double dVar12;
double dVar13;
double dVar14;
dVar8 = (param_5 + param_5) * _DAT_00102028;
dVar9 = dVar8 * _DAT_00102030;
dVar12 = dVar8 * _DAT_00102038;
dVar13 = dVar12 + dVar12;
dVar8 = dVar8 + dVar8;
param_1 = param_1 - dVar13;
param_2 = param_2 - dVar8;
dVar10 = dVar9 * DAT_00102040;
pvVar1 = malloc(800);
bVar5 = true;
iVar3 = 0;
dVar14 = param_1;
if (param_2 < param_4 + dVar8) {
while( true ) {
lVar4 = (long)(iVar3 + 1);
while (dVar14 < param_3 + dVar13) {
pdVar2 = (double *)malloc(0x70);
*pdVar2 = dVar14;
dVar6 = param_2 + dVar9;
pdVar2[1] = dVar6;
pdVar2[2] = dVar14;
dVar7 = param_2 + dVar10;
pdVar2[3] = dVar7;
pdVar2[4] = dVar14 + dVar12;
pdVar2[5] = param_2 + dVar8;
dVar11 = dVar14 + dVar13;
pdVar2[6] = dVar11;
pdVar2[7] = dVar7;
pdVar2[8] = dVar11;
pdVar2[9] = dVar6;
pdVar2[10] = dVar14 + dVar12;
pdVar2[0xb] = param_2;
pdVar2[0xc] = dVar14;
pdVar2[0xd] = dVar6;
iVar3 = (int)lVar4;
*(double **)((long)pvVar1 + lVar4 * 8 + -8) = pdVar2;
lVar4 = lVar4 + 1;
dVar14 = dVar11;
}
param_2 = param_2 + dVar10;
bVar5 = (bool)(bVar5 ^ 1);
if (param_4 + dVar8 <= param_2) break;
dVar14 = param_1;
if (!bVar5) {
dVar14 = param_1 + dVar12;
}
}
}
return pvVar1;
} |
5,866 | func0 |
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
| double** func0(double startx, double starty, double endx, double endy, double radius) {
double sl = (2 * radius) * tan(M_PI / 6);
double p = sl * 0.5;
double b = sl * cos(M_PI / 6);
double w = b * 2;
double h = 2 * sl;
startx = startx - w;
starty = starty - h;
endx = endx + w;
endy = endy + h;
double origx = startx;
double origy = starty;
double xoffset = b;
double yoffset = 3 * p;
int index = 0;
int polygons_size = 100; // Suppose a maximum of 100 polygons
double** polygons = malloc(polygons_size * sizeof(double*));
int row = 1;
while (starty < endy) {
if (row % 2 == 0) {
startx = origx + xoffset;
} else {
startx = origx;
}
while (startx < endx) {
double* poly = (double*)malloc(14 * sizeof(double)); // 7 points (x,y) pairs
poly[0] = startx;
poly[1] = starty + p;
poly[2] = startx;
poly[3] = starty + (3 * p);
poly[4] = startx + b;
poly[5] = starty + h;
poly[6] = startx + w;
poly[7] = starty + (3 * p);
poly[8] = startx + w;
poly[9] = starty + p;
poly[10] = startx + b;
poly[11] = starty;
poly[12] = startx;
poly[13] = starty + p;
polygons[index++] = poly;
startx += w;
}
starty += yoffset;
row += 1;
}
return polygons;
}
| int main() {
double** res;
// Tests would compare the structures generated, which would require setup of expected values;
// for simplicity, I'm keeping the main just as a basic structure call.
res = func0(1, 1, 4, 4, 3);
// Assume a function `compare_polygons` to check if returned polygons are correct
res = func0(5, 4, 7, 9, 8);
// Assume a check
res = func0(9, 6, 4, 3, 2);
// Assume a check
printf("All tests passed successfully.\n");
return 0;
}
| O2 | c | func0:
endbr64
push %r12
addsd %xmm4,%xmm4
mov $0x320,%edi
push %rbp
mov $0x1,%ebp
push %rbx
sub $0x70,%rsp
movsd 0xde6(%rip),%xmm6
movsd 0xdd6(%rip),%xmm5
mulsd 0xdc6(%rip),%xmm4
mulsd %xmm4,%xmm6
mulsd %xmm4,%xmm5
addsd %xmm4,%xmm4
addsd %xmm4,%xmm3
subsd %xmm4,%xmm1
movsd %xmm4,0x68(%rsp)
movsd %xmm6,0x30(%rsp)
addsd %xmm6,%xmm6
movsd %xmm5,0x60(%rsp)
mulsd 0xdac(%rip),%xmm5
movsd %xmm3,0x48(%rsp)
subsd %xmm6,%xmm0
addsd %xmm6,%xmm2
movsd %xmm6,0x38(%rsp)
movsd %xmm1,0x18(%rsp)
movsd %xmm0,0x50(%rsp)
movsd %xmm2,0x20(%rsp)
movsd %xmm5,0x58(%rsp)
callq 1070 <malloc@plt>
movsd 0x48(%rsp),%xmm3
xor %edx,%edx
comisd 0x18(%rsp),%xmm3
movsd 0x50(%rsp),%xmm0
mov %rax,%r12
jbe 1440 <func0+0x210>
movsd 0x20(%rsp),%xmm4
comisd %xmm0,%xmm4
jbe 1423 <func0+0x1f3>
nopw 0x0(%rax,%rax,1)
movsd 0x18(%rsp),%xmm6
movsd 0x60(%rsp),%xmm1
lea 0x1(%rdx),%ebx
movsd 0x58(%rsp),%xmm3
movslq %ebx,%rbx
addsd %xmm6,%xmm1
addsd %xmm6,%xmm3
addsd 0x68(%rsp),%xmm6
movsd %xmm3,0x40(%rsp)
movsd %xmm6,0x28(%rsp)
nopw 0x0(%rax,%rax,1)
mov $0x70,%edi
movsd %xmm3,0x10(%rsp)
movsd %xmm1,0x8(%rsp)
movsd %xmm0,(%rsp)
callq 1070 <malloc@plt>
movsd (%rsp),%xmm0
movsd 0x30(%rsp),%xmm2
mov %ebx,%edx
movsd 0x28(%rsp),%xmm5
mov %rax,-0x8(%r12,%rbx,8)
add $0x1,%rbx
addsd %xmm0,%xmm2
movapd %xmm0,%xmm4
movsd %xmm0,(%rax)
movsd 0x8(%rsp),%xmm1
movsd %xmm0,0x10(%rax)
addsd 0x38(%rsp),%xmm0
movsd 0x10(%rsp),%xmm3
movsd %xmm5,0x28(%rax)
movsd 0x20(%rsp),%xmm5
movsd 0x18(%rsp),%xmm7
movsd %xmm1,0x8(%rax)
comisd %xmm0,%xmm5
movsd %xmm3,0x18(%rax)
movsd %xmm2,0x20(%rax)
movsd %xmm0,0x30(%rax)
movsd %xmm3,0x38(%rax)
movsd %xmm0,0x40(%rax)
movsd %xmm1,0x48(%rax)
movsd %xmm2,0x50(%rax)
movsd %xmm7,0x58(%rax)
movsd %xmm4,0x60(%rax)
movsd %xmm1,0x68(%rax)
ja 1330 <func0+0x100>
movsd 0x48(%rsp),%xmm4
add $0x1,%ebp
comisd 0x40(%rsp),%xmm4
jbe 1440 <func0+0x210>
movsd 0x50(%rsp),%xmm7
movapd %xmm7,%xmm0
test $0x1,%bpl
jne 1407 <func0+0x1d7>
movsd 0x30(%rsp),%xmm0
addsd %xmm7,%xmm0
movsd 0x40(%rsp),%xmm4
movsd %xmm4,0x18(%rsp)
movsd 0x20(%rsp),%xmm4
comisd %xmm0,%xmm4
ja 12f8 <func0+0xc8>
movsd 0x18(%rsp),%xmm7
addsd 0x58(%rsp),%xmm7
movsd %xmm7,0x40(%rsp)
jmp 13dc <func0+0x1ac>
nopw 0x0(%rax,%rax,1)
add $0x70,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
retq
nopl 0x0(%rax)
| func0:
endbr64
push r15
addsd xmm4, xmm4
mov edi, 320h
push r14
push r12
push rbp
push rbx
mov ebx, 1
sub rsp, 60h
movsd xmm6, cs:qword_2038
movsd xmm5, cs:qword_2030
mulsd xmm4, cs:qword_2028
mulsd xmm6, xmm4
mulsd xmm5, xmm4
addsd xmm4, xmm4
addsd xmm3, xmm4
subsd xmm1, xmm4
movsd [rsp+88h+var_30], xmm4
movsd [rsp+88h+var_68], xmm6
addsd xmm6, xmm6
movsd [rsp+88h+var_38], xmm5
mulsd xmm5, cs:qword_2040
movsd [rsp+88h+var_50], xmm3
subsd xmm0, xmm6
addsd xmm2, xmm6
movsd [rsp+88h+var_60], xmm6
movsd [rsp+88h+var_70], xmm1
movsd [rsp+88h+var_48], xmm0
movq r14, xmm2
movsd [rsp+88h+var_40], xmm5
call _malloc
movsd xmm3, [rsp+88h+var_50]
xor edx, edx
comisd xmm3, [rsp+88h+var_70]
movsd xmm0, [rsp+88h+var_48]
mov r12, rax
jbe loc_1430
movq xmm4, r14
comisd xmm4, xmm0
jbe loc_1419
nop dword ptr [rax+00h]
loc_12F8:
movsd xmm6, [rsp+88h+var_70]
movsd xmm1, [rsp+88h+var_38]
add edx, 1
movsd xmm3, [rsp+88h+var_40]
movsxd rbp, edx
addsd xmm1, xmm6
addsd xmm3, xmm6
addsd xmm6, [rsp+88h+var_30]
movsd [rsp+88h+var_58], xmm3
movq r15, xmm6
nop dword ptr [rax+00000000h]
loc_1330:
mov edi, 70h ; 'p'
movsd [rsp+88h+var_78], xmm3
movsd [rsp+88h+var_80], xmm1
movsd [rsp+88h+var_88], xmm0
call _malloc
movsd xmm0, [rsp+88h+var_88]
movsd xmm2, [rsp+88h+var_68]
mov edx, ebp
movq xmm5, r14
movsd xmm1, [rsp+88h+var_80]
mov [rax+28h], r15
addsd xmm2, xmm0
movapd xmm4, xmm0
movsd qword ptr [rax], xmm0
movsd xmm3, [rsp+88h+var_78]
movsd qword ptr [rax+10h], xmm0
addsd xmm0, [rsp+88h+var_60]
movsd xmm7, [rsp+88h+var_70]
mov [r12+rbp*8-8], rax
add rbp, 1
movsd qword ptr [rax+8], xmm1
comisd xmm5, xmm0
movsd qword ptr [rax+18h], xmm3
movsd qword ptr [rax+20h], xmm2
movsd qword ptr [rax+30h], xmm0
movsd qword ptr [rax+38h], xmm3
movsd qword ptr [rax+40h], xmm0
movsd qword ptr [rax+48h], xmm1
movsd qword ptr [rax+50h], xmm2
movsd qword ptr [rax+58h], xmm7
movsd qword ptr [rax+60h], xmm4
movsd qword ptr [rax+68h], xmm1
ja loc_1330
loc_13D4:
movsd xmm4, [rsp+88h+var_50]
add ebx, 1
comisd xmm4, [rsp+88h+var_58]
jbe short loc_1430
movsd xmm7, [rsp+88h+var_48]
movapd xmm0, xmm7
test bl, 1
jnz short loc_13FE
movsd xmm0, [rsp+88h+var_68]
addsd xmm0, xmm7
loc_13FE:
movsd xmm4, [rsp+88h+var_58]
movsd [rsp+88h+var_70], xmm4
movq xmm4, r14
comisd xmm4, xmm0
ja loc_12F8
loc_1419:
movsd xmm7, [rsp+88h+var_70]
addsd xmm7, [rsp+88h+var_40]
movsd [rsp+88h+var_58], xmm7
jmp short loc_13D4
loc_1430:
add rsp, 60h
mov rax, r12
pop rbx
pop rbp
pop r12
pop r14
pop r15
retn | long long func0(double a1, double a2, double a3, double a4, double a5)
{
char v5; // bl
double v6; // xmm4_8
double v7; // xmm2_8
long long v8; // rax
int v9; // edx
double v10; // xmm0_8
long long v11; // r12
long long v12; // rbp
long long v13; // rax
__int128 v15; // [rsp+0h] [rbp-88h]
double v16; // [rsp+18h] [rbp-70h]
double v17; // [rsp+20h] [rbp-68h]
double v18; // [rsp+28h] [rbp-60h]
double v19; // [rsp+30h] [rbp-58h]
double v20; // [rsp+38h] [rbp-50h]
double v21; // [rsp+40h] [rbp-48h]
double v22; // [rsp+48h] [rbp-40h]
double v23; // [rsp+50h] [rbp-38h]
double v24; // [rsp+58h] [rbp-30h]
v5 = 1;
v6 = (a5 + a5) * 0.5773502691896257;
v24 = v6 + v6;
v17 = 0.8660254037844387 * v6;
v23 = 0.5 * v6;
v20 = a4 + v6 + v6;
v7 = a3 + v17 + v17;
v18 = v17 + v17;
v16 = a2 - (v6 + v6);
v21 = a1 - (v17 + v17);
v22 = 0.5 * v6 * 3.0;
v8 = malloc(800LL);
v9 = 0;
v10 = v21;
v11 = v8;
if ( v20 > v16 )
{
if ( v7 <= v21 )
goto LABEL_9;
LABEL_3:
v12 = v9 + 1;
v19 = v22 + v16;
do
{
*((double *)&v15 + 1) = v23 + v16;
*(double *)&v15 = v10;
v13 = malloc(112LL);
v9 = v12;
*(double *)(v13 + 40) = v16 + v24;
*(double *)v13 = v10;
*(double *)(v13 + 16) = v10;
v10 = v10 + v18;
*(_QWORD *)(v11 + 8 * v12++ - 8) = v13;
*(double *)(v13 + 8) = v23 + v16;
*(double *)(v13 + 24) = v22 + v16;
*(double *)(v13 + 32) = v17 + *(double *)&v15;
*(double *)(v13 + 48) = *(double *)&v15 + v18;
*(double *)(v13 + 56) = v22 + v16;
*(double *)(v13 + 64) = *(double *)&v15 + v18;
*(double *)(v13 + 72) = v23 + v16;
*(double *)(v13 + 80) = v17 + *(double *)&v15;
*(double *)(v13 + 88) = v16;
*(_OWORD *)(v13 + 96) = v15;
}
while ( v7 > *(double *)&v15 + v18 );
while ( 1 )
{
++v5;
if ( v20 <= v19 )
break;
v10 = v21;
if ( (v5 & 1) == 0 )
v10 = v17 + v21;
v16 = v19;
if ( v7 > v10 )
goto LABEL_3;
LABEL_9:
v19 = v16 + v22;
}
}
return v11;
} | func0:
ENDBR64
PUSH R15
ADDSD XMM4,XMM4
MOV EDI,0x320
PUSH R14
PUSH R12
PUSH RBP
PUSH RBX
MOV EBX,0x1
SUB RSP,0x60
MOVSD XMM6,qword ptr [0x00102038]
MOVSD XMM5,qword ptr [0x00102030]
MULSD XMM4,qword ptr [0x00102028]
MULSD XMM6,XMM4
MULSD XMM5,XMM4
ADDSD XMM4,XMM4
ADDSD XMM3,XMM4
SUBSD XMM1,XMM4
MOVSD qword ptr [RSP + 0x58],XMM4
MOVSD qword ptr [RSP + 0x20],XMM6
ADDSD XMM6,XMM6
MOVSD qword ptr [RSP + 0x50],XMM5
MULSD XMM5,qword ptr [0x00102040]
MOVSD qword ptr [RSP + 0x38],XMM3
SUBSD XMM0,XMM6
ADDSD XMM2,XMM6
MOVSD qword ptr [RSP + 0x28],XMM6
MOVSD qword ptr [RSP + 0x18],XMM1
MOVSD qword ptr [RSP + 0x40],XMM0
MOVQ R14,XMM2
MOVSD qword ptr [RSP + 0x48],XMM5
CALL 0x00101070
MOVSD XMM3,qword ptr [RSP + 0x38]
XOR EDX,EDX
COMISD XMM3,qword ptr [RSP + 0x18]
MOVSD XMM0,qword ptr [RSP + 0x40]
MOV R12,RAX
JBE 0x00101430
MOVQ XMM4,R14
COMISD XMM4,XMM0
JBE 0x00101419
NOP dword ptr [RAX]
LAB_001012f8:
MOVSD XMM6,qword ptr [RSP + 0x18]
MOVSD XMM1,qword ptr [RSP + 0x50]
ADD EDX,0x1
MOVSD XMM3,qword ptr [RSP + 0x48]
MOVSXD RBP,EDX
ADDSD XMM1,XMM6
ADDSD XMM3,XMM6
ADDSD XMM6,qword ptr [RSP + 0x58]
MOVSD qword ptr [RSP + 0x30],XMM3
MOVQ R15,XMM6
NOP dword ptr [RAX]
LAB_00101330:
MOV EDI,0x70
MOVSD qword ptr [RSP + 0x10],XMM3
MOVSD qword ptr [RSP + 0x8],XMM1
MOVSD qword ptr [RSP],XMM0
CALL 0x00101070
MOVSD XMM0,qword ptr [RSP]
MOVSD XMM2,qword ptr [RSP + 0x20]
MOV EDX,EBP
MOVQ XMM5,R14
MOVSD XMM1,qword ptr [RSP + 0x8]
MOV qword ptr [RAX + 0x28],R15
ADDSD XMM2,XMM0
MOVAPD XMM4,XMM0
MOVSD qword ptr [RAX],XMM0
MOVSD XMM3,qword ptr [RSP + 0x10]
MOVSD qword ptr [RAX + 0x10],XMM0
ADDSD XMM0,qword ptr [RSP + 0x28]
MOVSD XMM7,qword ptr [RSP + 0x18]
MOV qword ptr [R12 + RBP*0x8 + -0x8],RAX
ADD RBP,0x1
MOVSD qword ptr [RAX + 0x8],XMM1
COMISD XMM5,XMM0
MOVSD qword ptr [RAX + 0x18],XMM3
MOVSD qword ptr [RAX + 0x20],XMM2
MOVSD qword ptr [RAX + 0x30],XMM0
MOVSD qword ptr [RAX + 0x38],XMM3
MOVSD qword ptr [RAX + 0x40],XMM0
MOVSD qword ptr [RAX + 0x48],XMM1
MOVSD qword ptr [RAX + 0x50],XMM2
MOVSD qword ptr [RAX + 0x58],XMM7
MOVSD qword ptr [RAX + 0x60],XMM4
MOVSD qword ptr [RAX + 0x68],XMM1
JA 0x00101330
LAB_001013d4:
MOVSD XMM4,qword ptr [RSP + 0x38]
ADD EBX,0x1
COMISD XMM4,qword ptr [RSP + 0x30]
JBE 0x00101430
MOVSD XMM7,qword ptr [RSP + 0x40]
MOVAPD XMM0,XMM7
TEST BL,0x1
JNZ 0x001013fe
MOVSD XMM0,qword ptr [RSP + 0x20]
ADDSD XMM0,XMM7
LAB_001013fe:
MOVSD XMM4,qword ptr [RSP + 0x30]
MOVSD qword ptr [RSP + 0x18],XMM4
MOVQ XMM4,R14
COMISD XMM4,XMM0
JA 0x001012f8
LAB_00101419:
MOVSD XMM7,qword ptr [RSP + 0x18]
ADDSD XMM7,qword ptr [RSP + 0x48]
MOVSD qword ptr [RSP + 0x30],XMM7
JMP 0x001013d4
LAB_00101430:
ADD RSP,0x60
MOV RAX,R12
POP RBX
POP RBP
POP R12
POP R14
POP R15
RET | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
void * func0(double param_1,double param_2,double param_3,double param_4,double param_5)
{
void *pvVar1;
double *pdVar2;
bool bVar3;
int iVar4;
long lVar5;
double dVar6;
double dVar7;
double dVar8;
double dVar9;
double dVar10;
double dVar11;
double dVar12;
double dVar13;
double local_70;
double local_58;
bVar3 = true;
dVar9 = (param_5 + param_5) * _DAT_00102028;
dVar12 = DAT_00102038 * dVar9;
dVar10 = DAT_00102030 * dVar9;
dVar9 = dVar9 + dVar9;
local_70 = param_2 - dVar9;
dVar13 = dVar12 + dVar12;
dVar11 = dVar10 * DAT_00102040;
param_1 = param_1 - dVar13;
param_3 = param_3 + dVar13;
pvVar1 = malloc(800);
iVar4 = 0;
if (param_4 + dVar9 <= local_70) {
return pvVar1;
}
dVar7 = param_1;
if (param_3 <= param_1) goto LAB_00101419;
do {
lVar5 = (long)(iVar4 + 1);
dVar8 = dVar10 + local_70;
local_58 = dVar11 + local_70;
do {
pdVar2 = (double *)malloc(0x70);
iVar4 = (int)lVar5;
pdVar2[5] = local_70 + dVar9;
*pdVar2 = dVar7;
pdVar2[2] = dVar7;
dVar6 = dVar7 + dVar13;
*(double **)((long)pvVar1 + lVar5 * 8 + -8) = pdVar2;
lVar5 = lVar5 + 1;
pdVar2[1] = dVar8;
pdVar2[3] = local_58;
pdVar2[4] = dVar12 + dVar7;
pdVar2[6] = dVar6;
pdVar2[7] = local_58;
pdVar2[8] = dVar6;
pdVar2[9] = dVar8;
pdVar2[10] = dVar12 + dVar7;
pdVar2[0xb] = local_70;
pdVar2[0xc] = dVar7;
pdVar2[0xd] = dVar8;
dVar7 = dVar6;
} while (dVar6 < param_3);
while( true ) {
bVar3 = (bool)(bVar3 ^ 1);
if (param_4 + dVar9 <= local_58) {
return pvVar1;
}
dVar7 = param_1;
if (!bVar3) {
dVar7 = dVar12 + param_1;
}
local_70 = local_58;
if (dVar7 < param_3) break;
LAB_00101419:
local_58 = local_70 + dVar11;
}
} while( true );
} |
5,867 | func0 |
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
| double** func0(double startx, double starty, double endx, double endy, double radius) {
double sl = (2 * radius) * tan(M_PI / 6);
double p = sl * 0.5;
double b = sl * cos(M_PI / 6);
double w = b * 2;
double h = 2 * sl;
startx = startx - w;
starty = starty - h;
endx = endx + w;
endy = endy + h;
double origx = startx;
double origy = starty;
double xoffset = b;
double yoffset = 3 * p;
int index = 0;
int polygons_size = 100; // Suppose a maximum of 100 polygons
double** polygons = malloc(polygons_size * sizeof(double*));
int row = 1;
while (starty < endy) {
if (row % 2 == 0) {
startx = origx + xoffset;
} else {
startx = origx;
}
while (startx < endx) {
double* poly = (double*)malloc(14 * sizeof(double)); // 7 points (x,y) pairs
poly[0] = startx;
poly[1] = starty + p;
poly[2] = startx;
poly[3] = starty + (3 * p);
poly[4] = startx + b;
poly[5] = starty + h;
poly[6] = startx + w;
poly[7] = starty + (3 * p);
poly[8] = startx + w;
poly[9] = starty + p;
poly[10] = startx + b;
poly[11] = starty;
poly[12] = startx;
poly[13] = starty + p;
polygons[index++] = poly;
startx += w;
}
starty += yoffset;
row += 1;
}
return polygons;
}
| int main() {
double** res;
// Tests would compare the structures generated, which would require setup of expected values;
// for simplicity, I'm keeping the main just as a basic structure call.
res = func0(1, 1, 4, 4, 3);
// Assume a function `compare_polygons` to check if returned polygons are correct
res = func0(5, 4, 7, 9, 8);
// Assume a check
res = func0(9, 6, 4, 3, 2);
// Assume a check
printf("All tests passed successfully.\n");
return 0;
}
| O3 | c | func0:
endbr64
push %r12
addsd %xmm4,%xmm4
mov $0x320,%edi
push %rbp
mov $0x1,%ebp
push %rbx
sub $0x70,%rsp
movsd 0xde6(%rip),%xmm6
movsd 0xdd6(%rip),%xmm5
mulsd 0xdc6(%rip),%xmm4
mulsd %xmm4,%xmm6
mulsd %xmm4,%xmm5
addsd %xmm4,%xmm4
addsd %xmm4,%xmm3
subsd %xmm4,%xmm1
movsd %xmm4,0x68(%rsp)
movsd %xmm6,0x30(%rsp)
addsd %xmm6,%xmm6
movsd %xmm5,0x60(%rsp)
mulsd 0xdac(%rip),%xmm5
movsd %xmm3,0x48(%rsp)
subsd %xmm6,%xmm0
addsd %xmm6,%xmm2
movsd %xmm6,0x38(%rsp)
movsd %xmm1,0x18(%rsp)
movsd %xmm0,0x50(%rsp)
movsd %xmm2,0x20(%rsp)
movsd %xmm5,0x58(%rsp)
callq 1070 <malloc@plt>
movsd 0x48(%rsp),%xmm3
xor %edx,%edx
comisd 0x18(%rsp),%xmm3
movsd 0x50(%rsp),%xmm0
mov %rax,%r12
jbe 1440 <func0+0x210>
movsd 0x20(%rsp),%xmm4
comisd %xmm0,%xmm4
jbe 1423 <func0+0x1f3>
nopw 0x0(%rax,%rax,1)
movsd 0x18(%rsp),%xmm6
movsd 0x60(%rsp),%xmm1
lea 0x1(%rdx),%ebx
movsd 0x58(%rsp),%xmm3
movslq %ebx,%rbx
addsd %xmm6,%xmm1
addsd %xmm6,%xmm3
addsd 0x68(%rsp),%xmm6
movsd %xmm3,0x40(%rsp)
movsd %xmm6,0x28(%rsp)
nopw 0x0(%rax,%rax,1)
mov $0x70,%edi
movsd %xmm3,0x10(%rsp)
movsd %xmm1,0x8(%rsp)
movsd %xmm0,(%rsp)
callq 1070 <malloc@plt>
movsd (%rsp),%xmm0
movsd 0x30(%rsp),%xmm2
mov %ebx,%edx
movsd 0x28(%rsp),%xmm5
mov %rax,-0x8(%r12,%rbx,8)
add $0x1,%rbx
addsd %xmm0,%xmm2
movapd %xmm0,%xmm4
movsd %xmm0,(%rax)
movsd 0x8(%rsp),%xmm1
movsd %xmm0,0x10(%rax)
addsd 0x38(%rsp),%xmm0
movsd 0x10(%rsp),%xmm3
movsd %xmm5,0x28(%rax)
movsd 0x20(%rsp),%xmm5
movsd 0x18(%rsp),%xmm7
movsd %xmm1,0x8(%rax)
comisd %xmm0,%xmm5
movsd %xmm3,0x18(%rax)
movsd %xmm2,0x20(%rax)
movsd %xmm0,0x30(%rax)
movsd %xmm3,0x38(%rax)
movsd %xmm0,0x40(%rax)
movsd %xmm1,0x48(%rax)
movsd %xmm2,0x50(%rax)
movsd %xmm7,0x58(%rax)
movsd %xmm4,0x60(%rax)
movsd %xmm1,0x68(%rax)
ja 1330 <func0+0x100>
movsd 0x48(%rsp),%xmm4
add $0x1,%ebp
comisd 0x40(%rsp),%xmm4
jbe 1440 <func0+0x210>
movsd 0x50(%rsp),%xmm7
movapd %xmm7,%xmm0
test $0x1,%bpl
jne 1407 <func0+0x1d7>
movsd 0x30(%rsp),%xmm0
addsd %xmm7,%xmm0
movsd 0x40(%rsp),%xmm4
movsd %xmm4,0x18(%rsp)
movsd 0x20(%rsp),%xmm4
comisd %xmm0,%xmm4
ja 12f8 <func0+0xc8>
movsd 0x18(%rsp),%xmm7
addsd 0x58(%rsp),%xmm7
movsd %xmm7,0x40(%rsp)
jmp 13dc <func0+0x1ac>
nopw 0x0(%rax,%rax,1)
add $0x70,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
retq
nopl 0x0(%rax)
| func0:
endbr64
push r15
addsd xmm4, xmm4
mov edi, 320h; size
push r14
push r12
push rbp
push rbx
sub rsp, 60h
movsd xmm7, cs:qword_2038
movsd xmm5, cs:qword_2030
mulsd xmm4, cs:qword_2028
mulsd xmm7, xmm4
movapd xmm6, xmm4
mulsd xmm5, xmm4
addsd xmm6, xmm4
addsd xmm3, xmm6
subsd xmm1, xmm6
movsd [rsp+88h+var_30], xmm6
movsd [rsp+88h+var_60], xmm7
addsd xmm7, xmm7
movsd [rsp+88h+var_38], xmm5
mulsd xmm5, cs:qword_2040
movsd [rsp+88h+var_50], xmm3
subsd xmm0, xmm7
addsd xmm2, xmm7
movsd [rsp+88h+var_58], xmm7
movsd [rsp+88h+var_68], xmm1
movsd [rsp+88h+var_48], xmm0
movq r14, xmm2
movsd [rsp+88h+var_40], xmm5
call _malloc
movsd xmm3, [rsp+88h+var_50]
comisd xmm3, [rsp+88h+var_68]
mov rbx, rax
jbe loc_13E2
mov ebp, 1
xor eax, eax
nop dword ptr [rax+rax+00h]
loc_12C8:
movsd xmm7, [rsp+88h+var_48]
movapd xmm0, xmm7
test bpl, 1
jnz short loc_12E2
movsd xmm0, [rsp+88h+var_60]
addsd xmm0, xmm7
loc_12E2:
movq xmm7, r14
comisd xmm7, xmm0
jbe loc_13F8
movsd xmm6, [rsp+88h+var_68]
movsd xmm7, [rsp+88h+var_30]
add eax, 1
movsd xmm4, [rsp+88h+var_38]
movsd xmm3, [rsp+88h+var_40]
movsxd r12, eax
addsd xmm7, xmm6
addsd xmm4, xmm6
addsd xmm3, xmm6
movq r15, xmm7
loc_1320:
mov edi, 70h ; 'p'; size
movsd [rsp+88h+var_70], xmm3
movsd [rsp+88h+var_78], xmm4
movsd [rsp+88h+var_80], xmm0
call _malloc
movsd xmm0, [rsp+88h+var_80]
movsd xmm1, [rsp+88h+var_60]
movq xmm6, r15
movsd xmm3, [rsp+88h+var_70]
movsd xmm4, [rsp+88h+var_78]
movq xmm7, r14
mov [rbx+r12*8-8], rax
addsd xmm1, xmm0
movapd xmm5, xmm0
movapd xmm2, xmm0
unpcklpd xmm5, xmm3
addsd xmm0, [rsp+88h+var_58]
unpcklpd xmm2, xmm4
movups xmmword ptr [rax+10h], xmm5
movapd xmm5, xmm1
movhpd xmm1, [rsp+88h+var_68]
movups xmmword ptr [rax], xmm2
unpcklpd xmm5, xmm6
movups xmmword ptr [rax+50h], xmm1
movups xmmword ptr [rax+20h], xmm5
movapd xmm5, xmm0
unpcklpd xmm5, xmm3
movups xmmword ptr [rax+60h], xmm2
movups xmmword ptr [rax+30h], xmm5
movapd xmm5, xmm0
unpcklpd xmm5, xmm4
movups xmmword ptr [rax+40h], xmm5
mov rax, r12
add r12, 1
comisd xmm7, xmm0
ja loc_1320
movsd [rsp+88h+var_68], xmm3
loc_13CD:
movsd xmm7, [rsp+88h+var_50]
add ebp, 1
comisd xmm7, [rsp+88h+var_68]
ja loc_12C8
loc_13E2:
add rsp, 60h
mov rax, rbx
pop rbx
pop rbp
pop r12
pop r14
pop r15
retn
loc_13F8:
movsd xmm7, [rsp+88h+var_68]
addsd xmm7, [rsp+88h+var_40]
movsd [rsp+88h+var_68], xmm7
jmp short loc_13CD | _QWORD * func0(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm4_8
double v6; // r14
_QWORD *v7; // rbx
char v8; // bp
int v9; // eax
__m128d v10; // xmm0
long long v11; // r12
double v12; // xmm4_8
double v13; // xmm3_8
__m128d *v14; // rax
__m128d v15; // xmm1
__m128d v16; // xmm2
__m128d v17; // xmm5
double v19; // [rsp+0h] [rbp-80h]
double v20; // [rsp+8h] [rbp-78h]
double v21; // [rsp+18h] [rbp-68h]
double v22; // [rsp+20h] [rbp-60h]
double v23; // [rsp+28h] [rbp-58h]
double v24; // [rsp+30h] [rbp-50h]
double v25; // [rsp+38h] [rbp-48h]
double v26; // [rsp+40h] [rbp-40h]
double v27; // [rsp+48h] [rbp-38h]
double v28; // [rsp+50h] [rbp-30h]
v5 = (a5 + a5) * 0.5773502691896257;
v28 = v5 + v5;
v22 = 0.8660254037844387 * v5;
v27 = 0.5 * v5;
v24 = a4 + v5 + v5;
v23 = v22 + v22;
v21 = a2 - (v5 + v5);
v25 = a1 - (v22 + v22);
v6 = a3 + v22 + v22;
v26 = 0.5 * v5 * 3.0;
v7 = malloc(0x320uLL);
if ( v24 > v21 )
{
v8 = 1;
v9 = 0;
do
{
v10.m128d_f64[0] = v25;
if ( (v8 & 1) == 0 )
v10.m128d_f64[0] = v22 + v25;
if ( v6 <= v10.m128d_f64[0] )
{
v21 = v21 + v26;
}
else
{
v11 = v9 + 1;
v12 = v27 + v21;
v13 = v26 + v21;
do
{
v20 = v12;
v19 = v10.m128d_f64[0];
v14 = (__m128d *)malloc(0x70uLL);
v10 = (__m128d)*(unsigned long long *)&v10.m128d_f64[0];
v15 = (__m128d)*(unsigned long long *)&v22;
v12 = v20;
v7[v11 - 1] = v14;
v15.m128d_f64[0] = v22 + v10.m128d_f64[0];
v10.m128d_f64[0] = v10.m128d_f64[0] + v23;
v16 = _mm_unpacklo_pd((__m128d)*(unsigned long long *)&v19, (__m128d)*(unsigned long long *)&v20);
v14[1] = _mm_unpacklo_pd((__m128d)*(unsigned long long *)&v19, (__m128d)*(unsigned long long *)&v13);
v17 = v15;
v15.m128d_f64[1] = v21;
*v14 = v16;
v14[5] = v15;
v14[2] = _mm_unpacklo_pd(v17, (__m128d)COERCE_UNSIGNED_INT64(v28 + v21));
v14[6] = v16;
v14[3] = _mm_unpacklo_pd(v10, (__m128d)*(unsigned long long *)&v13);
v14[4] = _mm_unpacklo_pd(v10, (__m128d)*(unsigned long long *)&v20);
v9 = v11++;
}
while ( v6 > v19 + v23 );
v21 = v26 + v21;
}
++v8;
}
while ( v24 > v21 );
}
return v7;
} | func0:
ENDBR64
PUSH R15
ADDSD XMM4,XMM4
MOV EDI,0x320
PUSH R14
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x60
MOVSD XMM7,qword ptr [0x00102038]
MOVSD XMM5,qword ptr [0x00102030]
MULSD XMM4,qword ptr [0x00102028]
MULSD XMM7,XMM4
MOVAPD XMM6,XMM4
MULSD XMM5,XMM4
ADDSD XMM6,XMM4
ADDSD XMM3,XMM6
SUBSD XMM1,XMM6
MOVSD qword ptr [RSP + 0x58],XMM6
MOVSD qword ptr [RSP + 0x28],XMM7
ADDSD XMM7,XMM7
MOVSD qword ptr [RSP + 0x50],XMM5
MULSD XMM5,qword ptr [0x00102040]
MOVSD qword ptr [RSP + 0x38],XMM3
SUBSD XMM0,XMM7
ADDSD XMM2,XMM7
MOVSD qword ptr [RSP + 0x30],XMM7
MOVSD qword ptr [RSP + 0x20],XMM1
MOVSD qword ptr [RSP + 0x40],XMM0
MOVQ R14,XMM2
MOVSD qword ptr [RSP + 0x48],XMM5
CALL 0x00101070
MOVSD XMM3,qword ptr [RSP + 0x38]
COMISD XMM3,qword ptr [RSP + 0x20]
MOV RBX,RAX
JBE 0x001013e2
MOV EBP,0x1
XOR EAX,EAX
NOP dword ptr [RAX + RAX*0x1]
LAB_001012c8:
MOVSD XMM7,qword ptr [RSP + 0x40]
MOVAPD XMM0,XMM7
TEST BPL,0x1
JNZ 0x001012e2
MOVSD XMM0,qword ptr [RSP + 0x28]
ADDSD XMM0,XMM7
LAB_001012e2:
MOVQ XMM7,R14
COMISD XMM7,XMM0
JBE 0x001013f8
MOVSD XMM6,qword ptr [RSP + 0x20]
MOVSD XMM7,qword ptr [RSP + 0x58]
ADD EAX,0x1
MOVSD XMM4,qword ptr [RSP + 0x50]
MOVSD XMM3,qword ptr [RSP + 0x48]
MOVSXD R12,EAX
ADDSD XMM7,XMM6
ADDSD XMM4,XMM6
ADDSD XMM3,XMM6
MOVQ R15,XMM7
LAB_00101320:
MOV EDI,0x70
MOVSD qword ptr [RSP + 0x18],XMM3
MOVSD qword ptr [RSP + 0x10],XMM4
MOVSD qword ptr [RSP + 0x8],XMM0
CALL 0x00101070
MOVSD XMM0,qword ptr [RSP + 0x8]
MOVSD XMM1,qword ptr [RSP + 0x28]
MOVQ XMM6,R15
MOVSD XMM3,qword ptr [RSP + 0x18]
MOVSD XMM4,qword ptr [RSP + 0x10]
MOVQ XMM7,R14
MOV qword ptr [RBX + R12*0x8 + -0x8],RAX
ADDSD XMM1,XMM0
MOVAPD XMM5,XMM0
MOVAPD XMM2,XMM0
UNPCKLPD XMM5,XMM3
ADDSD XMM0,qword ptr [RSP + 0x30]
UNPCKLPD XMM2,XMM4
MOVUPS xmmword ptr [RAX + 0x10],XMM5
MOVAPD XMM5,XMM1
MOVHPD XMM1,qword ptr [RSP + 0x20]
MOVUPS xmmword ptr [RAX],XMM2
UNPCKLPD XMM5,XMM6
MOVUPS xmmword ptr [RAX + 0x50],XMM1
MOVUPS xmmword ptr [RAX + 0x20],XMM5
MOVAPD XMM5,XMM0
UNPCKLPD XMM5,XMM3
MOVUPS xmmword ptr [RAX + 0x60],XMM2
MOVUPS xmmword ptr [RAX + 0x30],XMM5
MOVAPD XMM5,XMM0
UNPCKLPD XMM5,XMM4
MOVUPS xmmword ptr [RAX + 0x40],XMM5
MOV RAX,R12
ADD R12,0x1
COMISD XMM7,XMM0
JA 0x00101320
MOVSD qword ptr [RSP + 0x20],XMM3
LAB_001013cd:
MOVSD XMM7,qword ptr [RSP + 0x38]
ADD EBP,0x1
COMISD XMM7,qword ptr [RSP + 0x20]
JA 0x001012c8
LAB_001013e2:
ADD RSP,0x60
MOV RAX,RBX
POP RBX
POP RBP
POP R12
POP R14
POP R15
RET
LAB_001013f8:
MOVSD XMM7,qword ptr [RSP + 0x20]
ADDSD XMM7,qword ptr [RSP + 0x48]
MOVSD qword ptr [RSP + 0x20],XMM7
JMP 0x001013cd | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
void * func0(double param_1,double param_2,double param_3,double param_4,double param_5)
{
long lVar1;
void *pvVar2;
long lVar3;
double *pdVar4;
byte bVar5;
double dVar6;
double dVar7;
double dVar8;
double dVar9;
double dVar10;
double dVar11;
double dVar12;
double dVar13;
double dVar14;
double local_68;
dVar9 = (param_5 + param_5) * _DAT_00102028;
dVar13 = DAT_00102038 * dVar9;
dVar11 = DAT_00102030 * dVar9;
dVar9 = dVar9 + dVar9;
local_68 = param_2 - dVar9;
dVar14 = dVar13 + dVar13;
dVar12 = dVar11 * DAT_00102040;
pvVar2 = malloc(800);
if (local_68 < param_4 + dVar9) {
bVar5 = 1;
lVar3 = 0;
do {
dVar6 = param_1 - dVar14;
if (!(bool)(bVar5 & 1)) {
dVar6 = dVar13 + (param_1 - dVar14);
}
if (dVar6 < param_3 + dVar14) {
dVar10 = dVar11 + local_68;
dVar8 = dVar12 + local_68;
lVar1 = (long)((int)lVar3 + 1);
do {
lVar3 = lVar1;
pdVar4 = (double *)malloc(0x70);
*(double **)((long)pvVar2 + lVar3 * 8 + -8) = pdVar4;
dVar7 = dVar6 + dVar14;
pdVar4[2] = dVar6;
pdVar4[3] = dVar8;
*pdVar4 = dVar6;
pdVar4[1] = dVar10;
pdVar4[10] = dVar13 + dVar6;
pdVar4[0xb] = local_68;
pdVar4[4] = dVar13 + dVar6;
pdVar4[5] = dVar9 + local_68;
pdVar4[0xc] = dVar6;
pdVar4[0xd] = dVar10;
pdVar4[6] = dVar7;
pdVar4[7] = dVar8;
pdVar4[8] = dVar7;
pdVar4[9] = dVar10;
lVar1 = lVar3 + 1;
dVar6 = dVar7;
} while (dVar7 < param_3 + dVar14);
}
local_68 = dVar12 + local_68;
bVar5 = bVar5 + 1;
} while (local_68 < param_4 + dVar9);
}
return pvVar2;
} |
5,868 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
| char* func0(int* test_tup, int size) {
int res = 0;
for (int i = 0; i < size; i++) {
res += test_tup[i] * pow(2, size - 1 - i);
}
char* result_str = (char*) malloc(sizeof(char) * 12);
sprintf(result_str, "%d", res);
return result_str;
}
| int main() {
int arr1[] = {1, 1, 0, 1, 0, 0, 1};
int arr1_size = sizeof(arr1)/sizeof(arr1[0]);
char* result1 = func0(arr1, arr1_size);
assert(strcmp(result1, "105") == 0);
free(result1);
int arr2[] = {0, 1, 1, 0, 0, 1, 0, 1};
int arr2_size = sizeof(arr2)/sizeof(arr2[0]);
char* result2 = func0(arr2, arr2_size);
assert(strcmp(result2, "101") == 0);
free(result2);
int arr3[] = {1, 1, 0, 1, 0, 1};
int arr3_size = sizeof(arr3)/sizeof(arr3[0]);
char* result3 = func0(arr3, arr3_size);
assert(strcmp(result3, "53") == 0);
free(result3);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
movl $0x0,-0x10(%rbp)
movl $0x0,-0xc(%rbp)
jmp 128a <func0+0x81>
mov -0xc(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov (%rax),%eax
cvtsi2sd %eax,%xmm2
movsd %xmm2,-0x28(%rbp)
mov -0x1c(%rbp),%eax
sub $0x1,%eax
sub -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov 0xe51(%rip),%rax
movapd %xmm0,%xmm1
movq %rax,%xmm0
callq 10c0 <pow@plt>
movsd -0x28(%rbp),%xmm1
mulsd %xmm0,%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
addsd %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov %eax,-0x10(%rbp)
addl $0x1,-0xc(%rbp)
mov -0xc(%rbp),%eax
cmp -0x1c(%rbp),%eax
jl 122c <func0+0x23>
mov $0xc,%edi
callq 1100 <malloc@plt>
mov %rax,-0x8(%rbp)
mov -0x10(%rbp),%edx
mov -0x8(%rbp),%rax
lea 0xd5a(%rip),%rsi
mov %rax,%rdi
mov $0x0,%eax
callq 1110 <sprintf@plt>
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_10], 0
mov [rbp+var_C], 0
jmp short loc_1296
loc_122C:
mov eax, [rbp+var_C]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+var_18]
add rax, rdx
mov eax, [rax]
pxor xmm2, xmm2
cvtsi2sd xmm2, eax
movsd [rbp+var_28], xmm2
mov eax, [rbp+var_1C]
sub eax, 1
sub eax, [rbp+var_C]
pxor xmm0, xmm0
cvtsi2sd xmm0, eax
mov rax, cs:x
movapd xmm1, xmm0; y
movq xmm0, rax; x
call _pow
movsd xmm1, [rbp+var_28]
mulsd xmm1, xmm0
pxor xmm0, xmm0
cvtsi2sd xmm0, [rbp+var_10]
addsd xmm0, xmm1
cvttsd2si eax, xmm0
mov [rbp+var_10], eax
add [rbp+var_C], 1
loc_1296:
mov eax, [rbp+var_C]
cmp eax, [rbp+var_1C]
jl short loc_122C
mov edi, 0Ch; size
call _malloc
mov [rbp+s], rax
mov edx, [rbp+var_10]
mov rax, [rbp+s]
lea rcx, format; "%d"
mov rsi, rcx; format
mov rdi, rax; s
mov eax, 0
call _sprintf
mov rax, [rbp+s]
leave
retn | char * func0(long long a1, int a2)
{
double v3; // [rsp+8h] [rbp-28h]
int v4; // [rsp+20h] [rbp-10h]
int i; // [rsp+24h] [rbp-Ch]
char *s; // [rsp+28h] [rbp-8h]
v4 = 0;
for ( i = 0; i < a2; ++i )
{
v3 = (double)*(int *)(4LL * i + a1);
v4 = (int)((double)v4 + v3 * pow(2.0, (double)(a2 - 1 - i)));
}
s = (char *)malloc(0xCuLL);
sprintf(s, "%d", v4);
return s;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0x10],0x0
MOV dword ptr [RBP + -0xc],0x0
JMP 0x00101296
LAB_0010122c:
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]
PXOR XMM2,XMM2
CVTSI2SD XMM2,EAX
MOVSD qword ptr [RBP + -0x28],XMM2
MOV EAX,dword ptr [RBP + -0x1c]
SUB EAX,0x1
SUB EAX,dword ptr [RBP + -0xc]
PXOR XMM0,XMM0
CVTSI2SD XMM0,EAX
MOV RAX,qword ptr [0x00102090]
MOVAPD XMM1,XMM0
MOVQ XMM0,RAX
CALL 0x001010c0
MOVSD XMM1,qword ptr [RBP + -0x28]
MULSD XMM1,XMM0
PXOR XMM0,XMM0
CVTSI2SD XMM0,dword ptr [RBP + -0x10]
ADDSD XMM0,XMM1
CVTTSD2SI EAX,XMM0
MOV dword ptr [RBP + -0x10],EAX
ADD dword ptr [RBP + -0xc],0x1
LAB_00101296:
MOV EAX,dword ptr [RBP + -0xc]
CMP EAX,dword ptr [RBP + -0x1c]
JL 0x0010122c
MOV EDI,0xc
CALL 0x00101100
MOV qword ptr [RBP + -0x8],RAX
MOV EDX,dword ptr [RBP + -0x10]
MOV RAX,qword ptr [RBP + -0x8]
LEA RCX,[0x102008]
MOV RSI,RCX
MOV RDI,RAX
MOV EAX,0x0
CALL 0x00101110
MOV RAX,qword ptr [RBP + -0x8]
LEAVE
RET | char * func0(long param_1,int param_2)
{
int iVar1;
char *__s;
double dVar2;
uint local_18;
int local_14;
local_18 = 0;
for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 1) {
iVar1 = *(int *)(param_1 + (long)local_14 * 4);
dVar2 = pow(DAT_00102090,(double)((param_2 + -1) - local_14));
local_18 = (uint)((double)(int)local_18 + (double)iVar1 * dVar2);
}
__s = (char *)malloc(0xc);
sprintf(__s,"%d",(ulong)local_18);
return __s;
} |
5,869 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
| char* func0(int* test_tup, int size) {
int res = 0;
for (int i = 0; i < size; i++) {
res += test_tup[i] * pow(2, size - 1 - i);
}
char* result_str = (char*) malloc(sizeof(char) * 12);
sprintf(result_str, "%d", res);
return result_str;
}
| int main() {
int arr1[] = {1, 1, 0, 1, 0, 0, 1};
int arr1_size = sizeof(arr1)/sizeof(arr1[0]);
char* result1 = func0(arr1, arr1_size);
assert(strcmp(result1, "105") == 0);
free(result1);
int arr2[] = {0, 1, 1, 0, 0, 1, 0, 1};
int arr2_size = sizeof(arr2)/sizeof(arr2[0]);
char* result2 = func0(arr2, arr2_size);
assert(strcmp(result2, "101") == 0);
free(result2);
int arr3[] = {1, 1, 0, 1, 0, 1};
int arr3_size = sizeof(arr3)/sizeof(arr3[0]);
char* result3 = func0(arr3, arr3_size);
assert(strcmp(result3, "53") == 0);
free(result3);
return 0;
}
| O1 | c | func0:
endbr64
push %r14
push %r13
push %r12
push %rbp
push %rbx
sub $0x10,%rsp
test %esi,%esi
jle 12a5 <func0+0xbc>
mov %rdi,%r12
mov %esi,%r14d
lea -0x1(%rsi),%r13d
add $0x2,%r13
mov $0x1,%ebp
mov $0x0,%ebx
pxor %xmm2,%xmm2
cvtsi2sdl -0x4(%r12,%rbp,4),%xmm2
movsd %xmm2,0x8(%rsp)
mov %r14d,%eax
sub %ebp,%eax
pxor %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov 0xe72(%rip),%rax
movq %rax,%xmm0
callq 10b0 <pow@plt>
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd 0x8(%rsp),%xmm0
addsd %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
add $0x1,%rbp
cmp %r13,%rbp
jne 1219 <func0+0x30>
mov $0xc,%edi
callq 10e0 <malloc@plt>
mov %rax,%rbp
mov %ebx,%r8d
lea 0xd86(%rip),%rcx
mov $0xc,%edx
mov $0x1,%esi
mov %rax,%rdi
mov $0x0,%eax
callq 10f0 <__sprintf_chk@plt>
mov %rbp,%rax
add $0x10,%rsp
pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
retq
mov $0x0,%ebx
jmp 1267 <func0+0x7e>
| func0:
endbr64
push r14
push r13
push r12
push rbp
push rbx
sub rsp, 10h
test esi, esi
jle loc_12C5
mov r13, rdi
mov r12d, esi
lea r14d, [rsi+1]
mov ebx, 1
mov ebp, 0
loc_1235:
pxor xmm2, xmm2
cvtsi2sd xmm2, dword ptr [r13+rbx*4-4]
movsd [rsp+38h+var_30], xmm2
mov eax, r12d
sub eax, ebx
pxor xmm1, xmm1
cvtsi2sd xmm1, eax
mov rax, cs:qword_2088
movq xmm0, rax
call _pow
movapd xmm1, xmm0
pxor xmm0, xmm0
cvtsi2sd xmm0, ebp
mulsd xmm1, [rsp+38h+var_30]
addsd xmm0, xmm1
cvttsd2si ebp, xmm0
add rbx, 1
cmp rbx, r14
jnz short loc_1235
loc_1287:
mov edi, 0Ch
call _malloc
mov rbx, rax
mov r8d, ebp
lea rcx, unk_2004
mov edx, 0Ch
mov esi, 1
mov rdi, rax
mov eax, 0
call ___sprintf_chk
mov rax, rbx
add rsp, 10h
pop rbx
pop rbp
pop r12
pop r13
pop r14
retn
loc_12C5:
mov ebp, 0
jmp short loc_1287 | long long func0(long long a1, int a2)
{
long long v2; // rbx
int v3; // ebp
long long v4; // rbx
double v6; // [rsp+8h] [rbp-30h]
if ( a2 <= 0 )
{
v3 = 0;
}
else
{
v2 = 1LL;
v3 = 0;
do
{
v6 = (double)*(int *)(a1 + 4 * v2 - 4);
v3 = (int)((double)v3 + pow(2.0, (double)(a2 - (int)v2++)) * v6);
}
while ( v2 != a2 + 1 );
}
v4 = malloc(12LL);
__sprintf_chk(v4, 1LL, 12LL, &unk_2004, (unsigned int)v3);
return v4;
} | func0:
ENDBR64
PUSH R14
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x10
TEST ESI,ESI
JLE 0x001012c5
MOV R13,RDI
MOV R12D,ESI
LEA R14D,[RSI + 0x1]
MOV EBX,0x1
MOV EBP,0x0
LAB_00101235:
PXOR XMM2,XMM2
CVTSI2SD XMM2,dword ptr [R13 + RBX*0x4 + -0x4]
MOVSD qword ptr [RSP + 0x8],XMM2
MOV EAX,R12D
SUB EAX,EBX
PXOR XMM1,XMM1
CVTSI2SD XMM1,EAX
MOV RAX,qword ptr [0x00102088]
MOVQ XMM0,RAX
CALL 0x001010c0
MOVAPD XMM1,XMM0
PXOR XMM0,XMM0
CVTSI2SD XMM0,EBP
MULSD XMM1,qword ptr [RSP + 0x8]
ADDSD XMM0,XMM1
CVTTSD2SI EBP,XMM0
ADD RBX,0x1
CMP RBX,R14
JNZ 0x00101235
LAB_00101287:
MOV EDI,0xc
CALL 0x00101100
MOV RBX,RAX
MOV R8D,EBP
LEA RCX,[0x102004]
MOV EDX,0xc
MOV ESI,0x1
MOV RDI,RAX
MOV EAX,0x0
CALL 0x00101110
MOV RAX,RBX
ADD RSP,0x10
POP RBX
POP RBP
POP R12
POP R13
POP R14
RET
LAB_001012c5:
MOV EBP,0x0
JMP 0x00101287 | void * func0(long param_1,int param_2)
{
int iVar1;
void *pvVar2;
ulong uVar3;
int iVar4;
double dVar5;
if (param_2 < 1) {
iVar4 = 0;
}
else {
uVar3 = 1;
iVar4 = 0;
do {
iVar1 = *(int *)(param_1 + -4 + uVar3 * 4);
dVar5 = pow(DAT_00102088,(double)(param_2 - (int)uVar3));
iVar4 = (int)((double)iVar4 + dVar5 * (double)iVar1);
uVar3 = uVar3 + 1;
} while (uVar3 != param_2 + 1);
}
pvVar2 = malloc(0xc);
__sprintf_chk(pvVar2,1,0xc,&DAT_00102004,iVar4);
return pvVar2;
} |
5,870 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
| char* func0(int* test_tup, int size) {
int res = 0;
for (int i = 0; i < size; i++) {
res += test_tup[i] * pow(2, size - 1 - i);
}
char* result_str = (char*) malloc(sizeof(char) * 12);
sprintf(result_str, "%d", res);
return result_str;
}
| int main() {
int arr1[] = {1, 1, 0, 1, 0, 0, 1};
int arr1_size = sizeof(arr1)/sizeof(arr1[0]);
char* result1 = func0(arr1, arr1_size);
assert(strcmp(result1, "105") == 0);
free(result1);
int arr2[] = {0, 1, 1, 0, 0, 1, 0, 1};
int arr2_size = sizeof(arr2)/sizeof(arr2[0]);
char* result2 = func0(arr2, arr2_size);
assert(strcmp(result2, "101") == 0);
free(result2);
int arr3[] = {1, 1, 0, 1, 0, 1};
int arr3_size = sizeof(arr3)/sizeof(arr3[0]);
char* result3 = func0(arr3, arr3_size);
assert(strcmp(result3, "53") == 0);
free(result3);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
sub $0x10,%rsp
test %esi,%esi
jle 1418 <func0+0xa8>
mov %rdi,%r12
lea -0x1(%rsi),%ebp
xor %ebx,%ebx
nopl 0x0(%rax)
pxor %xmm2,%xmm2
pxor %xmm1,%xmm1
mov 0xd11(%rip),%rax
add $0x4,%r12
cvtsi2sd %ebp,%xmm1
sub $0x1,%ebp
cvtsi2sdl -0x4(%r12),%xmm2
movq %rax,%xmm0
movsd %xmm2,0x8(%rsp)
callq 10b0 <pow@plt>
mulsd 0x8(%rsp),%xmm0
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
cmp $0xffffffff,%ebp
jne 1390 <func0+0x20>
mov $0xc,%edi
callq 10e0 <malloc@plt>
mov %ebx,%r8d
mov $0xc,%edx
lea 0xc0f(%rip),%rcx
mov %rax,%r12
mov %rax,%rdi
mov $0x1,%esi
xor %eax,%eax
callq 10f0 <__sprintf_chk@plt>
add $0x10,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
retq
nopl 0x0(%rax,%rax,1)
xor %ebx,%ebx
jmp 13dc <func0+0x6c>
nopl 0x0(%rax)
| func0:
endbr64
push r13
push r12
push rbp
push rbx
sub rsp, 18h
test esi, esi
jle loc_1440
mov rbp, rdi
lea ebx, [rsi-1]
xor r12d, r12d
nop
loc_13B0:
pxor xmm2, xmm2
pxor xmm1, xmm1
mov rax, cs:qword_2088
add rbp, 4
cvtsi2sd xmm2, dword ptr [rbp-4]
cvtsi2sd xmm1, ebx
movq xmm0, rax
movsd [rsp+38h+var_30], xmm2
call _pow
movapd xmm1, xmm0
pxor xmm0, xmm0
mulsd xmm1, [rsp+38h+var_30]
cvtsi2sd xmm0, r12d
addsd xmm0, xmm1
cvttsd2si r12d, xmm0
sub ebx, 1
jnb short loc_13B0
loc_13FD:
mov edi, 0Ch
call _malloc
mov r8d, r12d
mov edx, 0Ch
lea rcx, unk_2004
mov r13, rax
mov rdi, rax
mov esi, 1
xor eax, eax
call ___sprintf_chk
add rsp, 18h
mov rax, r13
pop rbx
pop rbp
pop r12
pop r13
retn
loc_1440:
xor r12d, r12d
jmp short loc_13FD | long long func0(long long a1, int a2)
{
int v3; // ebx
int v4; // r12d
long long v6; // r13
double v8; // [rsp+8h] [rbp-30h]
if ( a2 <= 0 )
{
v4 = 0;
}
else
{
v3 = a2 - 1;
v4 = 0;
do
{
a1 += 4LL;
v8 = (double)*(int *)(a1 - 4);
v4 = (int)((double)v4 + pow(2.0, (double)v3) * v8);
}
while ( v3-- != 0 );
}
v6 = malloc(12LL);
__sprintf_chk(v6, 1LL, 12LL, &unk_2004, (unsigned int)v4);
return v6;
} | func0:
ENDBR64
PUSH R13
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x18
TEST ESI,ESI
JLE 0x00101440
MOV RBP,RDI
LEA EBX,[RSI + -0x1]
XOR R12D,R12D
NOP
LAB_001013b0:
PXOR XMM2,XMM2
PXOR XMM1,XMM1
MOV RAX,qword ptr [0x00102088]
ADD RBP,0x4
CVTSI2SD XMM2,dword ptr [RBP + -0x4]
CVTSI2SD XMM1,EBX
MOVQ XMM0,RAX
MOVSD qword ptr [RSP + 0x8],XMM2
CALL 0x001010c0
MOVAPD XMM1,XMM0
PXOR XMM0,XMM0
MULSD XMM1,qword ptr [RSP + 0x8]
CVTSI2SD XMM0,R12D
ADDSD XMM0,XMM1
CVTTSD2SI R12D,XMM0
SUB EBX,0x1
JNC 0x001013b0
LAB_001013fd:
MOV EDI,0xc
CALL 0x00101100
MOV R8D,R12D
MOV EDX,0xc
LEA RCX,[0x102004]
MOV R13,RAX
MOV RDI,RAX
MOV ESI,0x1
XOR EAX,EAX
CALL 0x00101110
ADD RSP,0x18
MOV RAX,R13
POP RBX
POP RBP
POP R12
POP R13
RET
LAB_00101440:
XOR R12D,R12D
JMP 0x001013fd | void * func0(int *param_1,int param_2)
{
int iVar1;
void *pvVar2;
int iVar3;
bool bVar4;
double dVar5;
if (param_2 < 1) {
iVar3 = 0;
}
else {
param_2 = param_2 + -1;
iVar3 = 0;
do {
iVar1 = *param_1;
dVar5 = pow(DAT_00102088,(double)param_2);
iVar3 = (int)((double)iVar3 + dVar5 * (double)iVar1);
bVar4 = param_2 != 0;
param_2 = param_2 + -1;
param_1 = param_1 + 1;
} while (bVar4);
}
pvVar2 = malloc(0xc);
__sprintf_chk(pvVar2,1,0xc,&DAT_00102004,iVar3);
return pvVar2;
} |
5,871 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <string.h>
| char* func0(int* test_tup, int size) {
int res = 0;
for (int i = 0; i < size; i++) {
res += test_tup[i] * pow(2, size - 1 - i);
}
char* result_str = (char*) malloc(sizeof(char) * 12);
sprintf(result_str, "%d", res);
return result_str;
}
| int main() {
int arr1[] = {1, 1, 0, 1, 0, 0, 1};
int arr1_size = sizeof(arr1)/sizeof(arr1[0]);
char* result1 = func0(arr1, arr1_size);
assert(strcmp(result1, "105") == 0);
free(result1);
int arr2[] = {0, 1, 1, 0, 0, 1, 0, 1};
int arr2_size = sizeof(arr2)/sizeof(arr2[0]);
char* result2 = func0(arr2, arr2_size);
assert(strcmp(result2, "101") == 0);
free(result2);
int arr3[] = {1, 1, 0, 1, 0, 1};
int arr3_size = sizeof(arr3)/sizeof(arr3[0]);
char* result3 = func0(arr3, arr3_size);
assert(strcmp(result3, "53") == 0);
free(result3);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
sub $0x10,%rsp
test %esi,%esi
jle 1418 <func0+0xa8>
mov %rdi,%r12
lea -0x1(%rsi),%ebp
xor %ebx,%ebx
nopl 0x0(%rax)
pxor %xmm2,%xmm2
pxor %xmm1,%xmm1
mov 0xd11(%rip),%rax
add $0x4,%r12
cvtsi2sd %ebp,%xmm1
sub $0x1,%ebp
cvtsi2sdl -0x4(%r12),%xmm2
movq %rax,%xmm0
movsd %xmm2,0x8(%rsp)
callq 10b0 <pow@plt>
mulsd 0x8(%rsp),%xmm0
pxor %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
cmp $0xffffffff,%ebp
jne 1390 <func0+0x20>
mov $0xc,%edi
callq 10e0 <malloc@plt>
mov %ebx,%r8d
mov $0xc,%edx
lea 0xc0f(%rip),%rcx
mov %rax,%r12
mov %rax,%rdi
mov $0x1,%esi
xor %eax,%eax
callq 10f0 <__sprintf_chk@plt>
add $0x10,%rsp
mov %r12,%rax
pop %rbx
pop %rbp
pop %r12
retq
nopl 0x0(%rax,%rax,1)
xor %ebx,%ebx
jmp 13dc <func0+0x6c>
nopl 0x0(%rax)
| func0:
endbr64
push r12
push rbp
push rbx
sub rsp, 10h
test esi, esi
jle loc_1420
mov rbp, rdi
lea ebx, [rsi-1]
xor r12d, r12d
nop dword ptr [rax]
loc_13A0:
pxor xmm2, xmm2
pxor xmm1, xmm1
movsd xmm0, cs:x; x
add rbp, 4
cvtsi2sd xmm2, dword ptr [rbp-4]
cvtsi2sd xmm1, ebx; y
movsd [rsp+28h+var_20], xmm2
call _pow
movapd xmm1, xmm0
pxor xmm0, xmm0
mulsd xmm1, [rsp+28h+var_20]
cvtsi2sd xmm0, r12d
addsd xmm0, xmm1
cvttsd2si r12d, xmm0
sub ebx, 1
jnb short loc_13A0
loc_13E9:
mov edi, 0Ch; size
call _malloc
mov r8d, r12d
mov edx, 0Ch
lea rcx, unk_2004
mov rbx, rax
mov rdi, rax
mov esi, 2
xor eax, eax
call ___sprintf_chk
add rsp, 10h
mov rax, rbx
pop rbx
pop rbp
pop r12
retn
loc_1420:
xor r12d, r12d
jmp short loc_13E9 | void * func0(long long a1, int a2)
{
int v3; // ebx
int v4; // r12d
void *v6; // rbx
double v8; // [rsp+8h] [rbp-20h]
if ( a2 <= 0 )
{
v4 = 0;
}
else
{
v3 = a2 - 1;
v4 = 0;
do
{
a1 += 4LL;
v8 = (double)*(int *)(a1 - 4);
v4 = (int)((double)v4 + pow(2.0, (double)v3) * v8);
}
while ( v3-- != 0 );
}
v6 = malloc(0xCuLL);
__sprintf_chk(v6, 2LL, 12LL, &unk_2004, (unsigned int)v4);
return v6;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
PUSH RBX
SUB RSP,0x10
TEST ESI,ESI
JLE 0x00101420
MOV RBP,RDI
LEA EBX,[RSI + -0x1]
XOR R12D,R12D
NOP dword ptr [RAX]
LAB_001013a0:
PXOR XMM2,XMM2
PXOR XMM1,XMM1
MOVSD XMM0,qword ptr [0x00102088]
ADD RBP,0x4
CVTSI2SD XMM2,dword ptr [RBP + -0x4]
CVTSI2SD XMM1,EBX
MOVSD qword ptr [RSP + 0x8],XMM2
CALL 0x001010c0
MOVAPD XMM1,XMM0
PXOR XMM0,XMM0
MULSD XMM1,qword ptr [RSP + 0x8]
CVTSI2SD XMM0,R12D
ADDSD XMM0,XMM1
CVTTSD2SI R12D,XMM0
SUB EBX,0x1
JNC 0x001013a0
LAB_001013e9:
MOV EDI,0xc
CALL 0x00101100
MOV R8D,R12D
MOV EDX,0xc
LEA RCX,[0x102004]
MOV RBX,RAX
MOV RDI,RAX
MOV ESI,0x2
XOR EAX,EAX
CALL 0x00101110
ADD RSP,0x10
MOV RAX,RBX
POP RBX
POP RBP
POP R12
RET
LAB_00101420:
XOR R12D,R12D
JMP 0x001013e9 | void * func0(int *param_1,int param_2)
{
int iVar1;
void *pvVar2;
int iVar3;
bool bVar4;
double dVar5;
if (param_2 < 1) {
iVar3 = 0;
}
else {
param_2 = param_2 + -1;
iVar3 = 0;
do {
iVar1 = *param_1;
dVar5 = pow(DAT_00102088,(double)param_2);
iVar3 = (int)((double)iVar3 + dVar5 * (double)iVar1);
bVar4 = param_2 != 0;
param_2 = param_2 + -1;
param_1 = param_1 + 1;
} while (bVar4);
}
pvVar2 = malloc(0xc);
__sprintf_chk(pvVar2,2,0xc,&DAT_00102004,iVar3);
return pvVar2;
} |
5,872 | func0 | #include <stdio.h>
#include <string.h>
#include <assert.h>
#include <regex.h>
| char* func0(const char* str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (str1[i] < 'a' || str1[i] > 'z') {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("KDeoALOklOOHserfLoAJSIskdsf"), "KDALOOOHLAJSI") == 0);
assert(strcmp(func0("ProducTnamEstreAmIngMediAplAYer"), "PTEAIMAAY") == 0);
assert(strcmp(func0("maNufacTuredbYSheZenTechNolOGIes"), "NTYSZTNOGI") == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
mov %rdi,-0x18(%rbp)
movl $0x0,-0x4(%rbp)
movl $0x0,-0x8(%rbp)
jmp 11d7 <func0+0x6e>
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
cmp $0x60,%al
jle 11ad <func0+0x44>
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
cmp $0x7a,%al
jle 11d3 <func0+0x6a>
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
lea (%rdx,%rax,1),%rcx
mov -0x4(%rbp),%eax
lea 0x1(%rax),%edx
mov %edx,-0x4(%rbp)
movzbl (%rcx),%edx
cltq
lea 0x2e70(%rip),%rcx
mov %dl,(%rax,%rcx,1)
addl $0x1,-0x8(%rbp)
mov -0x8(%rbp),%eax
movslq %eax,%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
movzbl (%rax),%eax
test %al,%al
jne 1185 <func0+0x1c>
mov -0x4(%rbp),%eax
cltq
lea 0x2e49(%rip),%rdx
movb $0x0,(%rax,%rdx,1)
lea 0x2e3e(%rip),%rax
pop %rbp
retq
| func0:
endbr64
push rbp
mov rbp, rsp
mov [rbp+var_18], rdi
mov [rbp+var_4], 0
mov [rbp+var_8], 0
jmp short loc_11D7
loc_1185:
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
cmp al, 60h ; '`'
jle short loc_11AD
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
cmp al, 7Ah ; 'z'
jle short loc_11D3
loc_11AD:
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
lea rcx, [rdx+rax]
mov eax, [rbp+var_4]
lea edx, [rax+1]
mov [rbp+var_4], edx
movzx edx, byte ptr [rcx]
cdqe
lea rcx, result_1
mov [rax+rcx], dl
loc_11D3:
add [rbp+var_8], 1
loc_11D7:
mov eax, [rbp+var_8]
movsxd rdx, eax
mov rax, [rbp+var_18]
add rax, rdx
movzx eax, byte ptr [rax]
test al, al
jnz short loc_1185
mov eax, [rbp+var_4]
cdqe
lea rdx, result_1
mov byte ptr [rax+rdx], 0
lea rax, result_1
pop rbp
retn | _BYTE * func0(long long a1)
{
int v1; // eax
int i; // [rsp+10h] [rbp-8h]
int v4; // [rsp+14h] [rbp-4h]
v4 = 0;
for ( i = 0; *(_BYTE *)(i + a1); ++i )
{
if ( *(char *)(i + a1) <= 96 || *(char *)(i + a1) > 122 )
{
v1 = v4++;
result_1[v1] = *(_BYTE *)(i + a1);
}
}
result_1[v4] = 0;
return result_1;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x4],0x0
MOV dword ptr [RBP + -0x8],0x0
JMP 0x001011d7
LAB_00101185:
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
CMP AL,0x60
JLE 0x001011ad
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
CMP AL,0x7a
JLE 0x001011d3
LAB_001011ad:
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
LEA RCX,[RDX + RAX*0x1]
MOV EAX,dword ptr [RBP + -0x4]
LEA EDX,[RAX + 0x1]
MOV dword ptr [RBP + -0x4],EDX
MOVZX EDX,byte ptr [RCX]
CDQE
LEA RCX,[0x104040]
MOV byte ptr [RAX + RCX*0x1],DL
LAB_001011d3:
ADD dword ptr [RBP + -0x8],0x1
LAB_001011d7:
MOV EAX,dword ptr [RBP + -0x8]
MOVSXD RDX,EAX
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOVZX EAX,byte ptr [RAX]
TEST AL,AL
JNZ 0x00101185
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[0x104040]
MOV byte ptr [RAX + RDX*0x1],0x0
LEA RAX,[0x104040]
POP RBP
RET | int1 * func0(long param_1)
{
int local_10;
int local_c;
local_c = 0;
for (local_10 = 0; *(char *)(param_1 + local_10) != '\0'; local_10 = local_10 + 1) {
if ((*(char *)(param_1 + local_10) < 'a') || ('z' < *(char *)(param_1 + local_10))) {
result_1[local_c] = *(int *)(local_10 + param_1);
local_c = local_c + 1;
}
}
result_1[local_c] = 0;
return result_1;
} |
5,873 | func0 | #include <stdio.h>
#include <string.h>
#include <assert.h>
#include <regex.h>
| char* func0(const char* str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (str1[i] < 'a' || str1[i] > 'z') {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("KDeoALOklOOHserfLoAJSIskdsf"), "KDALOOOHLAJSI") == 0);
assert(strcmp(func0("ProducTnamEstreAmIngMediAplAYer"), "PTEAIMAAY") == 0);
assert(strcmp(func0("maNufacTuredbYSheZenTechNolOGIes"), "NTYSZTNOGI") == 0);
return 0;
}
| O1 | c | func0:
endbr64
movzbl (%rdi),%eax
test %al,%al
je 1185 <func0+0x3c>
add $0x1,%rdi
mov $0x0,%ecx
lea 0x2edc(%rip),%rsi
jmp 1172 <func0+0x29>
add $0x1,%rdi
movzbl -0x1(%rdi),%eax
test %al,%al
je 118a <func0+0x41>
lea -0x61(%rax),%edx
cmp $0x19,%dl
jbe 1166 <func0+0x1d>
movslq %ecx,%rdx
mov %al,(%rsi,%rdx,1)
lea 0x1(%rcx),%ecx
jmp 1166 <func0+0x1d>
mov $0x0,%ecx
lea 0x2eaf(%rip),%rax
movslq %ecx,%rcx
movb $0x0,(%rax,%rcx,1)
retq
| func0:
endbr64
movzx eax, byte ptr [rdi]
test al, al
jz short loc_11A5
add rdi, 1
mov ecx, 0
lea rsi, result_1
jmp short loc_1192
loc_1186:
add rdi, 1
movzx eax, byte ptr [rdi-1]
test al, al
jz short loc_11AA
loc_1192:
lea edx, [rax-61h]
cmp dl, 19h
jbe short loc_1186
movsxd rdx, ecx
mov [rsi+rdx], al
lea ecx, [rcx+1]
jmp short loc_1186
loc_11A5:
mov ecx, 0
loc_11AA:
lea rax, result_1
movsxd rcx, ecx
mov byte ptr [rax+rcx], 0
retn | _BYTE * func0(char *a1)
{
char v1; // al
char *v2; // rdi
int v3; // ecx
_BYTE *result; // rax
v1 = *a1;
if ( *a1 )
{
v2 = a1 + 1;
v3 = 0;
do
{
if ( (unsigned __int8)(v1 - 97) > 0x19u )
result_1[v3++] = v1;
v1 = *v2++;
}
while ( v1 );
}
else
{
v3 = 0;
}
result = result_1;
result_1[v3] = 0;
return result;
} | func0:
ENDBR64
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x001011a5
ADD RDI,0x1
MOV ECX,0x0
LEA RSI,[0x104040]
JMP 0x00101192
LAB_00101186:
ADD RDI,0x1
MOVZX EAX,byte ptr [RDI + -0x1]
TEST AL,AL
JZ 0x001011aa
LAB_00101192:
LEA EDX,[RAX + -0x61]
CMP DL,0x19
JBE 0x00101186
MOVSXD RDX,ECX
MOV byte ptr [RSI + RDX*0x1],AL
LEA ECX,[RCX + 0x1]
JMP 0x00101186
LAB_001011a5:
MOV ECX,0x0
LAB_001011aa:
LEA RAX,[0x104040]
MOVSXD RCX,ECX
MOV byte ptr [RAX + RCX*0x1],0x0
RET | void func0(char *param_1)
{
char cVar1;
int iVar2;
char *pcVar3;
cVar1 = *param_1;
if (cVar1 == '\0') {
iVar2 = 0;
}
else {
iVar2 = 0;
pcVar3 = param_1 + 1;
do {
if (0x19 < (byte)(cVar1 + 0x9fU)) {
(&result_1)[iVar2] = cVar1;
iVar2 = iVar2 + 1;
}
cVar1 = *pcVar3;
pcVar3 = pcVar3 + 1;
} while (cVar1 != '\0');
}
(&result_1)[iVar2] = 0;
return;
} |
5,874 | func0 | #include <stdio.h>
#include <string.h>
#include <assert.h>
#include <regex.h>
| char* func0(const char* str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (str1[i] < 'a' || str1[i] > 'z') {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("KDeoALOklOOHserfLoAJSIskdsf"), "KDALOOOHLAJSI") == 0);
assert(strcmp(func0("ProducTnamEstreAmIngMediAplAYer"), "PTEAIMAAY") == 0);
assert(strcmp(func0("maNufacTuredbYSheZenTechNolOGIes"), "NTYSZTNOGI") == 0);
return 0;
}
| O2 | c | func0:
endbr64
movzbl (%rdi),%eax
test %al,%al
je 1330 <func0+0x50>
add $0x1,%rdi
xor %ecx,%ecx
lea 0x2d48(%rip),%rsi
nopl 0x0(%rax,%rax,1)
lea -0x61(%rax),%edx
cmp $0x19,%dl
jbe 1311 <func0+0x31>
movslq %ecx,%rdx
add $0x1,%ecx
mov %al,(%rsi,%rdx,1)
movzbl (%rdi),%eax
add $0x1,%rdi
test %al,%al
jne 1300 <func0+0x20>
movslq %ecx,%rcx
lea 0x2d1a(%rip),%rax
movb $0x0,(%rsi,%rcx,1)
retq
nopl 0x0(%rax,%rax,1)
xor %ecx,%ecx
lea 0x2d07(%rip),%rsi
lea 0x2d00(%rip),%rax
movslq %ecx,%rcx
movb $0x0,(%rsi,%rcx,1)
retq
nopl 0x0(%rax,%rax,1)
| func0:
endbr64
movzx eax, byte ptr [rdi]
test al, al
jz short loc_1290
add rdi, 1
xor ecx, ecx
lea r8, result_1
nop dword ptr [rax+rax+00000000h]
loc_1260:
lea edx, [rax-61h]
cmp dl, 19h
jbe short loc_1272
movsxd rdx, ecx
add ecx, 1
mov [r8+rdx], al
loc_1272:
movzx eax, byte ptr [rdi]
add rdi, 1
test al, al
jnz short loc_1260
movsxd rcx, ecx
mov rax, r8
mov byte ptr [r8+rcx], 0
retn
loc_1290:
xor ecx, ecx
lea r8, result_1
movsxd rcx, ecx
mov rax, r8
mov byte ptr [r8+rcx], 0
retn | _BYTE * func0(char *a1)
{
char v1; // al
char *v2; // rdi
int v3; // ecx
long long v4; // rdx
_BYTE *result; // rax
v1 = *a1;
if ( *a1 )
{
v2 = a1 + 1;
v3 = 0;
do
{
if ( (unsigned __int8)(v1 - 97) > 0x19u )
{
v4 = v3++;
result_1[v4] = v1;
}
v1 = *v2++;
}
while ( v1 );
result = result_1;
result_1[v3] = 0;
}
else
{
result = result_1;
result_1[0] = 0;
}
return result;
} | func0:
ENDBR64
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x00101290
ADD RDI,0x1
XOR ECX,ECX
LEA R8,[0x104040]
NOP dword ptr [RAX + RAX*0x1]
LAB_00101260:
LEA EDX,[RAX + -0x61]
CMP DL,0x19
JBE 0x00101272
MOVSXD RDX,ECX
ADD ECX,0x1
MOV byte ptr [R8 + RDX*0x1],AL
LAB_00101272:
MOVZX EAX,byte ptr [RDI]
ADD RDI,0x1
TEST AL,AL
JNZ 0x00101260
MOVSXD RCX,ECX
MOV RAX,R8
MOV byte ptr [R8 + RCX*0x1],0x0
RET
LAB_00101290:
XOR ECX,ECX
LEA R8,[0x104040]
MOVSXD RCX,ECX
MOV RAX,R8
MOV byte ptr [R8 + RCX*0x1],0x0
RET | int1 * func0(char *param_1)
{
char cVar1;
int iVar2;
long lVar3;
cVar1 = *param_1;
if (cVar1 != '\0') {
param_1 = param_1 + 1;
iVar2 = 0;
do {
if (0x19 < (byte)(cVar1 + 0x9fU)) {
lVar3 = (long)iVar2;
iVar2 = iVar2 + 1;
(&result_1)[lVar3] = cVar1;
}
cVar1 = *param_1;
param_1 = param_1 + 1;
} while (cVar1 != '\0');
(&result_1)[iVar2] = 0;
return &result_1;
}
result_1 = 0;
return &result_1;
} |
5,875 | func0 | #include <stdio.h>
#include <string.h>
#include <assert.h>
#include <regex.h>
| char* func0(const char* str1) {
static char result[100];
int i, j = 0;
for (i = 0; str1[i] != '\0'; i++) {
if (str1[i] < 'a' || str1[i] > 'z') {
result[j++] = str1[i];
}
}
result[j] = '\0';
return result;
}
| int main() {
assert(strcmp(func0("KDeoALOklOOHserfLoAJSIskdsf"), "KDALOOOHLAJSI") == 0);
assert(strcmp(func0("ProducTnamEstreAmIngMediAplAYer"), "PTEAIMAAY") == 0);
assert(strcmp(func0("maNufacTuredbYSheZenTechNolOGIes"), "NTYSZTNOGI") == 0);
return 0;
}
| O3 | c | func0:
endbr64
movzbl (%rdi),%eax
test %al,%al
je 1378 <func0+0x68>
add $0x1,%rdi
xor %edx,%edx
lea 0x2d18(%rip),%rsi
nopl 0x0(%rax,%rax,1)
lea -0x61(%rax),%ecx
cmp $0x19,%cl
jbe 1355 <func0+0x45>
add $0x1,%rdi
mov %al,(%rsi,%rdx,1)
lea 0x1(%rdx),%ecx
movzbl -0x1(%rdi),%eax
test %al,%al
je 1362 <func0+0x52>
movslq %ecx,%rdx
lea -0x61(%rax),%ecx
cmp $0x19,%cl
ja 1338 <func0+0x28>
movzbl (%rdi),%eax
add $0x1,%rdi
test %al,%al
jne 1330 <func0+0x20>
mov %edx,%ecx
movslq %ecx,%rcx
lea 0x2cd4(%rip),%rax
movb $0x0,(%rsi,%rcx,1)
retq
nopl 0x0(%rax)
xor %ecx,%ecx
lea 0x2cbf(%rip),%rsi
lea 0x2cb8(%rip),%rax
movslq %ecx,%rcx
movb $0x0,(%rsi,%rcx,1)
retq
| func0:
endbr64
movzx eax, byte ptr [rdi]
test al, al
jz short loc_1360
add rdi, 1
xor edx, edx
lea rsi, result_1
nop dword ptr [rax+rax+00000000h]
loc_1320:
lea ecx, [rax-61h]
cmp cl, 19h
jbe short loc_1348
add rdi, 1
mov [rsi+rdx], al
lea ecx, [rdx+1]
movzx eax, byte ptr [rdi-1]
movsxd rdx, ecx
test al, al
jnz short loc_1320
mov byte ptr [rsi+rdx], 0
mov rax, rsi
retn
loc_1348:
movzx eax, byte ptr [rdi]
add rdi, 1
test al, al
jnz short loc_1320
mov byte ptr [rsi+rdx], 0
mov rax, rsi
retn
loc_1360:
lea rsi, result_1
xor edx, edx
mov byte ptr [rsi+rdx], 0
mov rax, rsi
retn | long long * func0(char *a1)
{
char v1; // al
char *v2; // rdi
long long v3; // rdx
int v4; // ecx
v1 = *a1;
if ( *a1 )
{
v2 = a1 + 1;
v3 = 0LL;
do
{
while ( (unsigned __int8)(v1 - 97) > 0x19u )
{
++v2;
*((_BYTE *)&result_1 + v3) = v1;
v4 = v3 + 1;
v1 = *(v2 - 1);
v3 = (int)v3 + 1;
if ( !v1 )
{
*((_BYTE *)&result_1 + v4) = 0;
return &result_1;
}
}
v1 = *v2++;
}
while ( v1 );
*((_BYTE *)&result_1 + v3) = 0;
return &result_1;
}
else
{
LOBYTE(result_1) = 0;
return &result_1;
}
} | func0:
ENDBR64
MOVZX EAX,byte ptr [RDI]
TEST AL,AL
JZ 0x00101360
ADD RDI,0x1
XOR EDX,EDX
LEA RSI,[0x104040]
NOP dword ptr [RAX + RAX*0x1]
LAB_00101320:
LEA ECX,[RAX + -0x61]
CMP CL,0x19
JBE 0x00101348
ADD RDI,0x1
MOV byte ptr [RSI + RDX*0x1],AL
LEA ECX,[RDX + 0x1]
MOVZX EAX,byte ptr [RDI + -0x1]
MOVSXD RDX,ECX
TEST AL,AL
JNZ 0x00101320
MOV byte ptr [RSI + RDX*0x1],0x0
MOV RAX,RSI
RET
LAB_00101348:
MOVZX EAX,byte ptr [RDI]
ADD RDI,0x1
TEST AL,AL
JNZ 0x00101320
MOV byte ptr [RSI + RDX*0x1],0x0
MOV RAX,RSI
RET
LAB_00101360:
LEA RSI,[0x104040]
XOR EDX,EDX
MOV byte ptr [RSI + RDX*0x1],0x0
MOV RAX,RSI
RET | int8 * func0(char *param_1)
{
char cVar1;
long lVar2;
char *pcVar3;
cVar1 = *param_1;
if (cVar1 == '\0') {
result_1._0_1_ = 0;
return &result_1;
}
lVar2 = 0;
pcVar3 = param_1 + 1;
do {
while ((byte)(cVar1 + 0x9fU) < 0x1a) {
cVar1 = *pcVar3;
pcVar3 = pcVar3 + 1;
if (cVar1 == '\0') {
*(int *)((long)&result_1 + lVar2) = 0;
return &result_1;
}
}
*(char *)((long)&result_1 + lVar2) = cVar1;
cVar1 = *pcVar3;
lVar2 = (long)((int)lVar2 + 1);
pcVar3 = pcVar3 + 1;
} while (cVar1 != '\0');
*(int *)((long)&result_1 + lVar2) = 0;
return &result_1;
} |
5,876 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
int compare(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
}
| void func0(int nums[], int len, int n, int result[]) {
qsort(nums, len, sizeof(int), compare);
for (int i = 0; i < n; i++) {
result[i] = nums[i];
}
}
| int main() {
int nums1[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result1[3];
int expected1[3] = {14, 22, 25};
func0(nums1, 9, 3, result1);
assert(memcmp(result1, expected1, 3 * sizeof(int)) == 0);
int nums2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result2[2];
int expected2[2] = {14, 22};
func0(nums2, 9, 2, result2);
assert(memcmp(result2, expected2, 2 * sizeof(int)) == 0);
int nums3[] = {25, 35, 22, 85, 14, 65, 75, 22, 58};
int result3[5];
int expected3[5] = {14, 22, 22, 25, 35};
func0(nums3, 9, 5, result3);
assert(memcmp(result3, expected3, 5 * sizeof(int)) == 0);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x30,%rsp
mov %rdi,-0x18(%rbp)
mov %esi,-0x1c(%rbp)
mov %edx,-0x20(%rbp)
mov %rcx,-0x28(%rbp)
mov -0x1c(%rbp),%eax
movslq %eax,%rsi
mov -0x18(%rbp),%rax
lea -0x4d(%rip),%rcx
mov $0x4,%edx
mov %rax,%rdi
callq 1080 <qsort@plt>
movl $0x0,-0x4(%rbp)
jmp 123d <func0+0x72>
mov -0x4(%rbp),%eax
cltq
lea 0x0(,%rax,4),%rdx
mov -0x18(%rbp),%rax
add %rdx,%rax
mov -0x4(%rbp),%edx
movslq %edx,%rdx
lea 0x0(,%rdx,4),%rcx
mov -0x28(%rbp),%rdx
add %rcx,%rdx
mov (%rax),%eax
mov %eax,(%rdx)
addl $0x1,-0x4(%rbp)
mov -0x4(%rbp),%eax
cmp -0x20(%rbp),%eax
jl 120c <func0+0x41>
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 30h
mov [rbp+base], rdi
mov [rbp+var_1C], esi
mov [rbp+var_20], edx
mov [rbp+var_28], rcx
mov eax, [rbp+var_1C]
movsxd rsi, eax; nmemb
mov rax, [rbp+base]
lea rdx, compare
mov rcx, rdx; compar
mov edx, 4; size
mov rdi, rax; base
call _qsort
mov [rbp+var_4], 0
jmp short loc_1240
loc_120F:
mov eax, [rbp+var_4]
cdqe
lea rdx, ds:0[rax*4]
mov rax, [rbp+base]
add rax, rdx
mov edx, [rbp+var_4]
movsxd rdx, edx
lea rcx, ds:0[rdx*4]
mov rdx, [rbp+var_28]
add rdx, rcx
mov eax, [rax]
mov [rdx], eax
add [rbp+var_4], 1
loc_1240:
mov eax, [rbp+var_4]
cmp eax, [rbp+var_20]
jl short loc_120F
nop
nop
leave
retn | long long func0(void *a1, int a2, int a3, long long a4)
{
long long result; // rax
unsigned int i; // [rsp+2Ch] [rbp-4h]
qsort(a1, a2, 4uLL, compare);
for ( i = 0; ; ++i )
{
result = i;
if ( (int)i >= a3 )
break;
*(_DWORD *)(4LL * (int)i + a4) = *((_DWORD *)a1 + (int)i);
}
return result;
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x30
MOV qword ptr [RBP + -0x18],RDI
MOV dword ptr [RBP + -0x1c],ESI
MOV dword ptr [RBP + -0x20],EDX
MOV qword ptr [RBP + -0x28],RCX
MOV EAX,dword ptr [RBP + -0x1c]
MOVSXD RSI,EAX
MOV RAX,qword ptr [RBP + -0x18]
LEA RDX,[0x1011a9]
MOV RCX,RDX
MOV EDX,0x4
MOV RDI,RAX
CALL 0x00101080
MOV dword ptr [RBP + -0x4],0x0
JMP 0x00101240
LAB_0010120f:
MOV EAX,dword ptr [RBP + -0x4]
CDQE
LEA RDX,[RAX*0x4]
MOV RAX,qword ptr [RBP + -0x18]
ADD RAX,RDX
MOV EDX,dword ptr [RBP + -0x4]
MOVSXD RDX,EDX
LEA RCX,[RDX*0x4]
MOV RDX,qword ptr [RBP + -0x28]
ADD RDX,RCX
MOV EAX,dword ptr [RAX]
MOV dword ptr [RDX],EAX
ADD dword ptr [RBP + -0x4],0x1
LAB_00101240:
MOV EAX,dword ptr [RBP + -0x4]
CMP EAX,dword ptr [RBP + -0x20]
JL 0x0010120f
NOP
NOP
LEAVE
RET | void func0(void *param_1,int param_2,int param_3,long param_4)
{
int local_c;
qsort(param_1,(long)param_2,4,compare);
for (local_c = 0; local_c < param_3; local_c = local_c + 1) {
*(int4 *)(param_4 + (long)local_c * 4) =
*(int4 *)((long)param_1 + (long)local_c * 4);
}
return;
} |
5,877 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
int compare(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
}
| void func0(int nums[], int len, int n, int result[]) {
qsort(nums, len, sizeof(int), compare);
for (int i = 0; i < n; i++) {
result[i] = nums[i];
}
}
| int main() {
int nums1[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result1[3];
int expected1[3] = {14, 22, 25};
func0(nums1, 9, 3, result1);
assert(memcmp(result1, expected1, 3 * sizeof(int)) == 0);
int nums2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result2[2];
int expected2[2] = {14, 22};
func0(nums2, 9, 2, result2);
assert(memcmp(result2, expected2, 2 * sizeof(int)) == 0);
int nums3[] = {25, 35, 22, 85, 14, 65, 75, 22, 58};
int result3[5];
int expected3[5] = {14, 22, 22, 25, 35};
func0(nums3, 9, 5, result3);
assert(memcmp(result3, expected3, 5 * sizeof(int)) == 0);
return 0;
}
| O1 | c | func0:
endbr64
push %r12
push %rbp
push %rbx
mov %rdi,%rbx
mov %edx,%r12d
mov %rcx,%rbp
movslq %esi,%rsi
lea -0x24(%rip),%rcx
mov $0x4,%edx
callq 1080 <qsort@plt>
test %r12d,%r12d
jle 11f9 <func0+0x47>
lea -0x1(%r12),%ecx
mov $0x0,%eax
mov (%rbx,%rax,4),%edx
mov %edx,0x0(%rbp,%rax,4)
mov %rax,%rdx
add $0x1,%rax
cmp %rcx,%rdx
jne 11e6 <func0+0x34>
pop %rbx
pop %rbp
pop %r12
retq
| func0:
endbr64
push r12
push rbp
push rbx
mov rbp, rdi
mov ebx, edx
mov r12, rcx
movsxd rsi, esi
lea rcx, compare
mov edx, 4
call _qsort
test ebx, ebx
jle short loc_11F2
mov ecx, ebx
mov eax, 0
loc_11E1:
mov edx, [rbp+rax*4+0]
mov [r12+rax*4], edx
add rax, 1
cmp rax, rcx
jnz short loc_11E1
loc_11F2:
pop rbx
pop rbp
pop r12
retn | long long func0(long long a1, int a2, int a3, long long a4)
{
long long result; // rax
result = qsort(a1, a2, 4LL, compare);
if ( a3 > 0 )
{
result = 0LL;
do
{
*(_DWORD *)(a4 + 4 * result) = *(_DWORD *)(a1 + 4 * result);
++result;
}
while ( result != a3 );
}
return result;
} | func0:
ENDBR64
PUSH R12
PUSH RBP
PUSH RBX
MOV RBP,RDI
MOV EBX,EDX
MOV R12,RCX
MOVSXD RSI,ESI
LEA RCX,[0x1011a9]
MOV EDX,0x4
CALL 0x00101080
TEST EBX,EBX
JLE 0x001011f2
MOV ECX,EBX
MOV EAX,0x0
LAB_001011e1:
MOV EDX,dword ptr [RBP + RAX*0x4]
MOV dword ptr [R12 + RAX*0x4],EDX
ADD RAX,0x1
CMP RAX,RCX
JNZ 0x001011e1
LAB_001011f2:
POP RBX
POP RBP
POP R12
RET | void func0(void *param_1,int param_2,uint param_3,long param_4)
{
ulong uVar1;
qsort(param_1,(long)param_2,4,compare);
if (0 < (int)param_3) {
uVar1 = 0;
do {
*(int4 *)(param_4 + uVar1 * 4) = *(int4 *)((long)param_1 + uVar1 * 4);
uVar1 = uVar1 + 1;
} while (uVar1 != param_3);
}
return;
} |
5,878 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
int compare(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
}
| void func0(int nums[], int len, int n, int result[]) {
qsort(nums, len, sizeof(int), compare);
for (int i = 0; i < n; i++) {
result[i] = nums[i];
}
}
| int main() {
int nums1[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result1[3];
int expected1[3] = {14, 22, 25};
func0(nums1, 9, 3, result1);
assert(memcmp(result1, expected1, 3 * sizeof(int)) == 0);
int nums2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result2[2];
int expected2[2] = {14, 22};
func0(nums2, 9, 2, result2);
assert(memcmp(result2, expected2, 2 * sizeof(int)) == 0);
int nums3[] = {25, 35, 22, 85, 14, 65, 75, 22, 58};
int result3[5];
int expected3[5] = {14, 22, 22, 25, 35};
func0(nums3, 9, 5, result3);
assert(memcmp(result3, expected3, 5 * sizeof(int)) == 0);
return 0;
}
| O2 | c | func0:
endbr64
push %r12
movslq %esi,%rsi
mov %edx,%r12d
mov $0x4,%edx
push %rbp
mov %rcx,%rbp
lea -0x2c(%rip),%rcx
push %rbx
mov %rdi,%rbx
callq 1070 <qsort@plt>
test %r12d,%r12d
jle 141b <func0+0x4b>
lea -0x1(%r12),%ecx
xor %eax,%eax
nopl 0x0(%rax)
mov (%rbx,%rax,4),%edx
mov %edx,0x0(%rbp,%rax,4)
mov %rax,%rdx
add $0x1,%rax
cmp %rcx,%rdx
jne 1408 <func0+0x38>
pop %rbx
pop %rbp
pop %r12
retq
| func0:
endbr64
push r12
movsxd rsi, esi
mov r12, rcx
lea rcx, compare
push rbp
mov rbp, rdi
push rbx
mov ebx, edx
mov edx, 4
call _qsort
test ebx, ebx
jle short loc_1401
movsxd rdx, ebx
xor eax, eax
nop dword ptr [rax]
loc_13F0:
mov ecx, [rbp+rax*4+0]
mov [r12+rax*4], ecx
add rax, 1
cmp rax, rdx
jnz short loc_13F0
loc_1401:
pop rbx
pop rbp
pop r12
retn | long long func0(long long a1, int a2, int a3, long long a4)
{
long long result; // rax
result = qsort(a1, a2, 4LL, compare);
if ( a3 > 0 )
{
result = 0LL;
do
{
*(_DWORD *)(a4 + 4 * result) = *(_DWORD *)(a1 + 4 * result);
++result;
}
while ( result != a3 );
}
return result;
} | func0:
ENDBR64
PUSH R12
MOVSXD RSI,ESI
MOV R12,RCX
LEA RCX,[0x1013b0]
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOV EBX,EDX
MOV EDX,0x4
CALL 0x00101070
TEST EBX,EBX
JLE 0x00101401
MOVSXD RDX,EBX
XOR EAX,EAX
NOP dword ptr [RAX]
LAB_001013f0:
MOV ECX,dword ptr [RBP + RAX*0x4]
MOV dword ptr [R12 + RAX*0x4],ECX
ADD RAX,0x1
CMP RAX,RDX
JNZ 0x001013f0
LAB_00101401:
POP RBX
POP RBP
POP R12
RET | void func0(void *param_1,int param_2,int param_3,long param_4)
{
long lVar1;
qsort(param_1,(long)param_2,4,compare);
if (0 < param_3) {
lVar1 = 0;
do {
*(int4 *)(param_4 + lVar1 * 4) = *(int4 *)((long)param_1 + lVar1 * 4);
lVar1 = lVar1 + 1;
} while (lVar1 != param_3);
}
return;
} |
5,879 | func0 |
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
int compare(const void *a, const void *b) {
return (*(int*)a - *(int*)b);
}
| void func0(int nums[], int len, int n, int result[]) {
qsort(nums, len, sizeof(int), compare);
for (int i = 0; i < n; i++) {
result[i] = nums[i];
}
}
| int main() {
int nums1[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result1[3];
int expected1[3] = {14, 22, 25};
func0(nums1, 9, 3, result1);
assert(memcmp(result1, expected1, 3 * sizeof(int)) == 0);
int nums2[] = {25, 35, 22, 85, 14, 65, 75, 25, 58};
int result2[2];
int expected2[2] = {14, 22};
func0(nums2, 9, 2, result2);
assert(memcmp(result2, expected2, 2 * sizeof(int)) == 0);
int nums3[] = {25, 35, 22, 85, 14, 65, 75, 22, 58};
int result3[5];
int expected3[5] = {14, 22, 22, 25, 35};
func0(nums3, 9, 5, result3);
assert(memcmp(result3, expected3, 5 * sizeof(int)) == 0);
return 0;
}
| O3 | c | func0:
endbr64
push %r12
movslq %esi,%rsi
mov %edx,%r12d
mov $0x4,%edx
push %rbp
mov %rcx,%rbp
lea -0x2c(%rip),%rcx
push %rbx
mov %rdi,%rbx
callq 1070 <qsort@plt>
test %r12d,%r12d
jle 142b <func0+0x9b>
lea 0xf(%rbx),%rdx
lea -0x1(%r12),%eax
sub %rbp,%rdx
cmp $0x1e,%rdx
jbe 1430 <func0+0xa0>
cmp $0x3,%eax
jbe 1430 <func0+0xa0>
mov %r12d,%edx
xor %eax,%eax
shr $0x2,%edx
shl $0x4,%rdx
nopl (%rax)
movdqu (%rbx,%rax,1),%xmm0
movups %xmm0,0x0(%rbp,%rax,1)
add $0x10,%rax
cmp %rdx,%rax
jne 13e0 <func0+0x50>
mov %r12d,%eax
and $0xfffffffc,%eax
test $0x3,%r12b
je 142b <func0+0x9b>
mov %eax,%edx
mov (%rbx,%rdx,4),%ecx
mov %ecx,0x0(%rbp,%rdx,4)
lea 0x1(%rax),%edx
cmp %edx,%r12d
jle 142b <func0+0x9b>
movslq %edx,%rdx
add $0x2,%eax
mov (%rbx,%rdx,4),%ecx
mov %ecx,0x0(%rbp,%rdx,4)
cmp %eax,%r12d
jle 142b <func0+0x9b>
cltq
mov (%rbx,%rax,4),%edx
mov %edx,0x0(%rbp,%rax,4)
pop %rbx
pop %rbp
pop %r12
retq
mov %eax,%edx
xor %eax,%eax
nopl 0x0(%rax)
mov (%rbx,%rax,4),%ecx
mov %ecx,0x0(%rbp,%rax,4)
mov %rax,%rcx
add $0x1,%rax
cmp %rdx,%rcx
jne 1438 <func0+0xa8>
pop %rbx
pop %rbp
pop %r12
retq
| func0:
endbr64
push r12
movsxd rsi, esi; nmemb
mov r12, rcx
lea rcx, compare; compar
push rbp
mov rbp, rdi
push rbx
movsxd rbx, edx
mov edx, 4; size
call _qsort
test ebx, ebx
jle short loc_13E1
lea eax, [rbx-1]
cmp eax, 2
jbe short loc_13C1
lea rdx, [rbp+4]
mov rax, r12
sub rax, rdx
cmp rax, 8
ja short loc_13F0
loc_13C1:
shl rbx, 2
xor eax, eax
nop word ptr [rax+rax+00000000h]
loc_13D0:
mov edx, [rbp+rax+0]
mov [r12+rax], edx
add rax, 4
cmp rbx, rax
jnz short loc_13D0
loc_13E1:
pop rbx
pop rbp
pop r12
retn
loc_13F0:
mov edx, ebx
xor eax, eax
shr edx, 2
shl rdx, 4
nop dword ptr [rax+rax+00h]
loc_1400:
movdqu xmm0, xmmword ptr [rbp+rax+0]
movups xmmword ptr [r12+rax], xmm0
add rax, 10h
cmp rax, rdx
jnz short loc_1400
mov eax, ebx
and eax, 0FFFFFFFCh
test bl, 3
jz short loc_13E1
mov ecx, eax
mov esi, [rbp+rcx*4+0]
lea rdx, ds:0[rcx*4]
mov [r12+rcx*4], esi
lea ecx, [rax+1]
cmp ebx, ecx
jle short loc_13E1
mov ecx, [rbp+rdx+4]
add eax, 2
mov [r12+rdx+4], ecx
cmp ebx, eax
jle short loc_13E1
mov eax, [rbp+rdx+8]
mov [r12+rdx+8], eax
pop rbx
pop rbp
pop r12
retn | void func0(char *a1, int a2, int a3, long long a4)
{
long long v5; // rbx
long long v6; // rbx
long long v7; // rax
long long v8; // rax
unsigned int v9; // eax
long long v10; // rdx
v5 = a3;
qsort(a1, a2, 4uLL, compare);
if ( (int)v5 > 0 )
{
if ( (unsigned int)(v5 - 1) > 2 && (unsigned long long)(a4 - (_QWORD)(a1 + 4)) > 8 )
{
v8 = 0LL;
do
{
*(__m128i *)(a4 + v8) = _mm_loadu_si128((const __m128i *)&a1[v8]);
v8 += 16LL;
}
while ( v8 != 16LL * ((unsigned int)v5 >> 2) );
v9 = v5 & 0xFFFFFFFC;
if ( (v5 & 3) != 0 )
{
v10 = 4LL * v9;
*(_DWORD *)(a4 + v10) = *(_DWORD *)&a1[v10];
if ( (int)v5 > (int)(v9 + 1) )
{
*(_DWORD *)(a4 + v10 + 4) = *(_DWORD *)&a1[v10 + 4];
if ( (int)v5 > (int)(v9 + 2) )
*(_DWORD *)(a4 + v10 + 8) = *(_DWORD *)&a1[v10 + 8];
}
}
}
else
{
v6 = 4 * v5;
v7 = 0LL;
do
{
*(_DWORD *)(a4 + v7) = *(_DWORD *)&a1[v7];
v7 += 4LL;
}
while ( v6 != v7 );
}
}
} | func0:
ENDBR64
PUSH R12
MOVSXD RSI,ESI
MOV R12,RCX
LEA RCX,[0x101370]
PUSH RBP
MOV RBP,RDI
PUSH RBX
MOVSXD RBX,EDX
MOV EDX,0x4
CALL 0x00101070
TEST EBX,EBX
JLE 0x001013e1
LEA EAX,[RBX + -0x1]
CMP EAX,0x2
JBE 0x001013c1
LEA RDX,[RBP + 0x4]
MOV RAX,R12
SUB RAX,RDX
CMP RAX,0x8
JA 0x001013f0
LAB_001013c1:
SHL RBX,0x2
XOR EAX,EAX
NOP word ptr [RAX + RAX*0x1]
LAB_001013d0:
MOV EDX,dword ptr [RBP + RAX*0x1]
MOV dword ptr [R12 + RAX*0x1],EDX
ADD RAX,0x4
CMP RBX,RAX
JNZ 0x001013d0
LAB_001013e1:
POP RBX
POP RBP
POP R12
RET
LAB_001013f0:
MOV EDX,EBX
XOR EAX,EAX
SHR EDX,0x2
SHL RDX,0x4
NOP dword ptr [RAX + RAX*0x1]
LAB_00101400:
MOVDQU XMM0,xmmword ptr [RBP + RAX*0x1]
MOVUPS xmmword ptr [R12 + RAX*0x1],XMM0
ADD RAX,0x10
CMP RAX,RDX
JNZ 0x00101400
MOV EAX,EBX
AND EAX,0xfffffffc
TEST BL,0x3
JZ 0x001013e1
MOV ECX,EAX
MOV ESI,dword ptr [RBP + RCX*0x4]
LEA RDX,[RCX*0x4]
MOV dword ptr [R12 + RCX*0x4],ESI
LEA ECX,[RAX + 0x1]
CMP EBX,ECX
JLE 0x001013e1
MOV ECX,dword ptr [RBP + RDX*0x1 + 0x4]
ADD EAX,0x2
MOV dword ptr [R12 + RDX*0x1 + 0x4],ECX
CMP EBX,EAX
JLE 0x001013e1
MOV EAX,dword ptr [RBP + RDX*0x1 + 0x8]
MOV dword ptr [R12 + RDX*0x1 + 0x8],EAX
POP RBX
POP RBP
POP R12
RET | void func0(void *param_1,int param_2,uint param_3,long param_4)
{
int8 uVar1;
uint uVar2;
long lVar3;
ulong uVar4;
qsort(param_1,(long)param_2,4,compare);
if (0 < (int)param_3) {
if ((param_3 - 1 < 3) || ((ulong)(param_4 - ((long)param_1 + 4)) < 9)) {
lVar3 = 0;
do {
*(int4 *)(param_4 + lVar3) = *(int4 *)((long)param_1 + lVar3);
lVar3 = lVar3 + 4;
} while ((long)(int)param_3 * 4 != lVar3);
}
else {
lVar3 = 0;
do {
uVar1 = ((int8 *)((long)param_1 + lVar3))[1];
*(int8 *)(param_4 + lVar3) = *(int8 *)((long)param_1 + lVar3);
((int8 *)(param_4 + lVar3))[1] = uVar1;
lVar3 = lVar3 + 0x10;
} while (lVar3 != (ulong)(param_3 >> 2) << 4);
uVar2 = param_3 & 0xfffffffc;
if (((long)(int)param_3 & 3U) != 0) {
uVar4 = (ulong)uVar2;
lVar3 = uVar4 * 4;
*(int4 *)(param_4 + uVar4 * 4) = *(int4 *)((long)param_1 + uVar4 * 4);
if (((int)(uVar2 + 1) < (int)param_3) &&
(*(int4 *)(param_4 + 4 + lVar3) = *(int4 *)((long)param_1 + lVar3 + 4),
(int)(uVar2 + 2) < (int)param_3)) {
*(int4 *)(param_4 + 8 + lVar3) = *(int4 *)((long)param_1 + lVar3 + 8);
return;
}
}
}
}
return;
} |
5,880 | func0 |
#include <math.h>
#include <assert.h>
| double func0(double r, double h) {
double l = sqrt(r * r + h * h);
double SA = M_PI * r * (r + l);
return SA;
}
| int main() {
assert(func0(5, 12) == 282.7433388230814);
assert(func0(10, 15) == 880.5179353159282);
assert(func0(19, 17) == 2655.923961165254);
return 0;
}
| O0 | c | func0:
endbr64
push %rbp
mov %rsp,%rbp
sub $0x20,%rsp
movsd %xmm0,-0x18(%rbp)
movsd %xmm1,-0x20(%rbp)
movsd -0x18(%rbp),%xmm0
movapd %xmm0,%xmm1
mulsd %xmm0,%xmm1
movsd -0x20(%rbp),%xmm0
mulsd %xmm0,%xmm0
addsd %xmm1,%xmm0
callq 1070 <sqrt@plt>
movq %xmm0,%rax
mov %rax,-0x10(%rbp)
movsd -0x18(%rbp),%xmm1
movsd 0xf0c(%rip),%xmm0
mulsd %xmm0,%xmm1
movsd -0x18(%rbp),%xmm0
addsd -0x10(%rbp),%xmm0
mulsd %xmm1,%xmm0
movsd %xmm0,-0x8(%rbp)
movsd -0x8(%rbp),%xmm0
leaveq
retq
| func0:
endbr64
push rbp
mov rbp, rsp
sub rsp, 20h
movsd [rbp+var_18], xmm0
movsd [rbp+var_20], xmm1
movsd xmm0, [rbp+var_18]
movapd xmm1, xmm0
mulsd xmm1, xmm0
movsd xmm0, [rbp+var_20]
mulsd xmm0, xmm0
addsd xmm1, xmm0
movq rax, xmm1
movq xmm0, rax; x
call _sqrt
movq rax, xmm0
mov [rbp+var_10], rax
movsd xmm1, [rbp+var_18]
movsd xmm0, cs:qword_20A0
mulsd xmm1, xmm0
movsd xmm0, [rbp+var_18]
addsd xmm0, [rbp+var_10]
mulsd xmm0, xmm1
movsd [rbp+var_8], xmm0
movsd xmm0, [rbp+var_8]
leave
retn | double func0(double a1, double a2)
{
return (a1 + sqrt(a1 * a1 + a2 * a2)) * (a1 * 3.141592653589793);
} | func0:
ENDBR64
PUSH RBP
MOV RBP,RSP
SUB RSP,0x20
MOVSD qword ptr [RBP + -0x18],XMM0
MOVSD qword ptr [RBP + -0x20],XMM1
MOVSD XMM0,qword ptr [RBP + -0x18]
MOVAPD XMM1,XMM0
MULSD XMM1,XMM0
MOVSD XMM0,qword ptr [RBP + -0x20]
MULSD XMM0,XMM0
ADDSD XMM1,XMM0
MOVQ RAX,XMM1
MOVQ XMM0,RAX
CALL 0x00101070
MOVQ RAX,XMM0
MOV qword ptr [RBP + -0x10],RAX
MOVSD XMM1,qword ptr [RBP + -0x18]
MOVSD XMM0,qword ptr [0x001020a0]
MULSD XMM1,XMM0
MOVSD XMM0,qword ptr [RBP + -0x18]
ADDSD XMM0,qword ptr [RBP + -0x10]
MULSD XMM0,XMM1
MOVSD qword ptr [RBP + -0x8],XMM0
MOVSD XMM0,qword ptr [RBP + -0x8]
LEAVE
RET | double func0(double param_1,double param_2)
{
double dVar1;
dVar1 = sqrt(param_1 * param_1 + param_2 * param_2);
return (param_1 + dVar1) * param_1 * DAT_001020a0;
} |
5,881 | func0 |
#include <math.h>
#include <assert.h>
| double func0(double r, double h) {
double l = sqrt(r * r + h * h);
double SA = M_PI * r * (r + l);
return SA;
}
| int main() {
assert(func0(5, 12) == 282.7433388230814);
assert(func0(10, 15) == 880.5179353159282);
assert(func0(19, 17) == 2655.923961165254);
return 0;
}
| O1 | c | func0:
endbr64
sub $0x18,%rsp
movsd %xmm0,0x8(%rsp)
mulsd %xmm0,%xmm0
mulsd %xmm1,%xmm1
addsd %xmm1,%xmm0
movapd %xmm0,%xmm3
sqrtsd %xmm3,%xmm3
movsd %xmm3,(%rsp)
pxor %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja 11ba <func0+0x51>
movsd 0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd 0xf14(%rip),%xmm1
addsd (%rsp),%xmm0
mulsd %xmm1,%xmm0
add $0x18,%rsp
retq
callq 1070 <sqrt@plt>
jmp 119a <func0+0x31>
| func0:
endbr64
sub rsp, 18h
movsd [rsp+18h+var_10], xmm0
mulsd xmm0, xmm0
mulsd xmm1, xmm1
addsd xmm1, xmm0
pxor xmm0, xmm0
ucomisd xmm0, xmm1
ja short loc_11B0
sqrtsd xmm1, xmm1
loc_1191:
movsd xmm3, [rsp+18h+var_10]
movapd xmm0, xmm3
mulsd xmm0, cs:qword_20A0
addsd xmm1, xmm3
mulsd xmm0, xmm1
add rsp, 18h
retn
loc_11B0:
movapd xmm0, xmm1
call _sqrt
movapd xmm1, xmm0
jmp short loc_1191 | double func0(double a1, double a2)
{
double v2; // xmm1_8
double v3; // xmm1_8
v2 = a2 * a2 + a1 * a1;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
return a1 * 3.141592653589793 * (v3 + a1);
} | func0:
ENDBR64
SUB RSP,0x18
MOVSD qword ptr [RSP + 0x8],XMM0
MULSD XMM0,XMM0
MULSD XMM1,XMM1
ADDSD XMM1,XMM0
PXOR XMM0,XMM0
UCOMISD XMM0,XMM1
JA 0x001011b0
SQRTSD XMM1,XMM1
LAB_00101191:
MOVSD XMM3,qword ptr [RSP + 0x8]
MOVAPD XMM0,XMM3
MULSD XMM0,qword ptr [0x001020a0]
ADDSD XMM1,XMM3
MULSD XMM0,XMM1
ADD RSP,0x18
RET
LAB_001011b0:
MOVAPD XMM0,XMM1
CALL 0x00101070
MOVAPD XMM1,XMM0
JMP 0x00101191 | /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
double func0(double param_1,double param_2)
{
double dVar1;
dVar1 = param_2 * param_2 + param_1 * param_1;
if (dVar1 < 0.0) {
dVar1 = sqrt(dVar1);
}
else {
dVar1 = SQRT(dVar1);
}
return param_1 * _DAT_001020a0 * (dVar1 + param_1);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.