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
482
func0
#include <iostream> #include <assert.h>
bool func0(int A[], int n, int sum, int count) { if (count == 3 && sum == 0) { return true; } if (count == 3 || n == 0 || sum < 0) { return false; } return func0(A, n - 1, sum - A[n - 1], count + 1) || func0(A, n - 1, sum, count); }
int main() { int arr1[] = {2, 7, 4, 0, 9, 5, 1, 3}; assert(func0(arr1, 8, 6, 0) == true); int arr2[] = {1, 4, 5, 6, 7, 8, 5, 9}; assert(func0(arr2, 8, 6, 0) == false); int arr3[] = {10, 4, 2, 3, 5}; assert(func0(arr3, 5, 15, 0) == true); std::cout << "All tests passed." << std::endl; return 0; }
O2
cpp
func0(int*, int, int, int): endbr64 cmp $0x3,%ecx sete %r8b test %edx,%edx sete %al and %r8b,%al jne 1400 <_Z5func0Piiii+0x30> test %esi,%esi mov %edx,%r9d sete %r10b shr $0x1f,%r9d or %r9b,%r10b jne 1400 <_Z5func0Piiii+0x30> test %r8b,%r8b jne 1400 <_Z5func0Piiii+0x30> jmp 1410 <_Z5func0Piiii.part.0> xchg %ax,%ax retq data16 nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
_Z5func0Piiii: endbr64 cmp ecx, 3 push r14 setz al test edx, edx push r13 push r12 mov r12d, edx setz dl and dl, al push rbp mov ebp, edx push rbx jnz short loc_142A mov edx, r12d sub esi, 1 mov r14, rdi mov r13d, ecx shr edx, 1Fh movsxd rbx, esi or al, dl jnz short loc_142A loc_1406: cmp ebx, 0FFFFFFFFh jz short loc_142A mov esi, ebx; int lea ecx, [r13+1]; int mov edx, r12d mov rdi, r14; int * sub edx, [r14+rbx*4]; int sub rbx, 1 call _Z5func0Piiii; func0(int *,int,int,int) test al, al jz short loc_1406 mov ebp, eax loc_142A: pop rbx mov eax, ebp pop rbp pop r12 pop r13 pop r14 retn
long long func0(int *a1, int a2, int a3, int a4) { int v4; // r12d unsigned int v5; // ebp long long v7; // rbx int v8; // esi int v9; // edx unsigned int v10; // eax v4 = a3; LOBYTE(a3) = a4 == 3 && a3 == 0; v5 = a3; if ( !(_BYTE)a3 ) { v7 = a2 - 1; if ( v4 >= 0 && a4 != 3 ) { while ( (_DWORD)v7 != -1 ) { v8 = v7; v9 = v4 - a1[v7--]; v10 = func0(a1, v8, v9, a4 + 1); if ( (_BYTE)v10 ) return v10; } } } return v5; }
func0: ENDBR64 CMP ECX,0x3 PUSH R14 SETZ AL TEST EDX,EDX PUSH R13 PUSH R12 MOV R12D,EDX SETZ DL AND DL,AL PUSH RBP MOV EBP,EDX PUSH RBX JNZ 0x0010142a MOV EDX,R12D SUB ESI,0x1 MOV R14,RDI MOV R13D,ECX SHR EDX,0x1f MOVSXD RBX,ESI OR AL,DL JNZ 0x0010142a LAB_00101406: CMP EBX,-0x1 JZ 0x0010142a MOV ESI,EBX LEA ECX,[R13 + 0x1] MOV EDX,R12D MOV RDI,R14 SUB EDX,dword ptr [R14 + RBX*0x4] SUB RBX,0x1 CALL 0x001013d0 TEST AL,AL JZ 0x00101406 MOV EBP,EAX LAB_0010142a: POP RBX MOV EAX,EBP POP RBP POP R12 POP R13 POP R14 RET
/* func0(int*, int, int, int) */ char func0(int *param_1,int param_2,int param_3,int param_4) { int *piVar1; char cVar2; bool bVar3; int iVar4; long lVar5; bool bVar6; bVar6 = param_4 == 3; bVar3 = param_3 == 0 && bVar6; cVar2 = bVar3; if ((param_3 != 0 || !bVar6) && (lVar5 = (long)(param_2 + -1), !bVar6 && -1 < param_3)) { do { iVar4 = (int)lVar5; if (iVar4 == -1) { return bVar3; } piVar1 = param_1 + lVar5; lVar5 = lVar5 + -1; cVar2 = func0(param_1,iVar4,param_3 - *piVar1,param_4 + 1); } while (cVar2 == '\0'); } return cVar2; }
483
func0
#include <iostream> #include <assert.h>
bool func0(int A[], int n, int sum, int count) { if (count == 3 && sum == 0) { return true; } if (count == 3 || n == 0 || sum < 0) { return false; } return func0(A, n - 1, sum - A[n - 1], count + 1) || func0(A, n - 1, sum, count); }
int main() { int arr1[] = {2, 7, 4, 0, 9, 5, 1, 3}; assert(func0(arr1, 8, 6, 0) == true); int arr2[] = {1, 4, 5, 6, 7, 8, 5, 9}; assert(func0(arr2, 8, 6, 0) == false); int arr3[] = {10, 4, 2, 3, 5}; assert(func0(arr3, 5, 15, 0) == true); std::cout << "All tests passed." << std::endl; return 0; }
O3
cpp
func0(int*, int, int, int) [clone .part.0]: push %r15 lea 0x1(%rcx),%r15d push %r14 mov %edx,%r14d push %r13 shr $0x1f,%r14d mov %ecx,%r13d push %r12 mov %rdi,%r12 push %rbp mov %edx,%ebp push %rbx mov %esi,%ebx sub $0x18,%rsp movslq %ebx,%rax cmp $0x3,%r15d mov %ebp,%r9d sete %dl sub -0x4(%r12,%rax,4),%r9d sete %al and %dl,%al jne 13fc <_Z5func0Piiii.part.0+0x6c> sub $0x1,%ebx sete %r8b or %r8b,%dl jne 1410 <_Z5func0Piiii.part.0+0x80> test %r9d,%r9d js 1410 <_Z5func0Piiii.part.0+0x80> mov %r15d,%ecx mov %r9d,%edx mov %ebx,%esi mov %r12,%rdi mov %r8b,0xf(%rsp) callq 1390 <_Z5func0Piiii.part.0> movzbl 0xf(%rsp),%r8d test %al,%al je 1410 <_Z5func0Piiii.part.0+0x80> add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax,%rax,1) cmp $0x3,%r13d sete %dl test %ebp,%ebp sete %al and %dl,%al jne 13fc <_Z5func0Piiii.part.0+0x6c> or %edx,%r8d or %r14b,%r8b je 13b3 <_Z5func0Piiii.part.0+0x23> add $0x18,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1)
_Z5func0Piiii: endbr64 push r15 push r14 push r13 push r12 mov r12d, edx push rbp push rbx sub rsp, 18h cmp ecx, 3 setz al test edx, edx setz dl mov ebx, edx and bl, al jnz loc_145D test esi, esi mov r13d, ecx mov ecx, r12d setz dl shr ecx, 1Fh or dl, cl jnz short loc_145D test al, al jnz short loc_145D cmp r13d, 2 lea r8d, [r13+1] movsxd rbp, esi setz r15b loc_13FF: mov r9d, r12d sub r9d, [rdi+rbp*4-4] setz dl mov ebx, edx and bl, r15b jnz short loc_145D mov eax, r9d mov r14d, ebp shr eax, 1Fh or al, r15b jnz short loc_1490 cmp ebp, 1 jz short loc_1490 sub r14d, 2 mov edx, r9d lea ecx, [r13+2]; int sub edx, [rdi+rbp*4-8]; int mov esi, r14d; int mov [rsp+48h+var_3C], r8d mov [rsp+48h+var_40], r9d mov [rsp+48h+var_48], rdi call _Z5func0Piiii; func0(int *,int,int,int) mov rdi, [rsp+48h+var_48]; int * mov r9d, [rsp+48h+var_40] test al, al mov r8d, [rsp+48h+var_3C] jz short loc_1470 loc_145B: mov ebx, eax loc_145D: add rsp, 18h mov eax, ebx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1470: mov ecx, r8d; int mov edx, r9d; int mov esi, r14d; int mov [rsp+48h+var_40], r8d call _Z5func0Piiii; func0(int *,int,int,int) mov rdi, [rsp+48h+var_48] mov r8d, [rsp+48h+var_40] test al, al jnz short loc_145B loc_1490: sub rbp, 1 test ebp, ebp jz short loc_145D jmp loc_13FF
long long func0(int *a1, int a2, int a3, int a4) { int v4; // r12d unsigned int v5; // ebx int v7; // r8d long long v8; // rbp bool v9; // r15 int v10; // r9d unsigned int v11; // eax int v13; // [rsp+8h] [rbp-40h] int v14; // [rsp+Ch] [rbp-3Ch] v4 = a3; LOBYTE(a3) = a3 == 0; v5 = a3; LOBYTE(v5) = (a4 == 3) & a3; if ( !(_BYTE)v5 && v4 >= 0 && a2 != 0 && a4 != 3 ) { v7 = a4 + 1; v8 = a2; v9 = a4 == 2; do { v10 = v4 - a1[v8 - 1]; LOBYTE(a3) = v4 == a1[v8 - 1]; v5 = a3; LOBYTE(v5) = v9 & a3; if ( (v9 & (unsigned __int8)a3) != 0 ) break; if ( !v9 && v10 >= 0 && (_DWORD)v8 != 1 ) { v14 = v7; v13 = v4 - a1[v8 - 1]; v11 = func0(a1, (int)v8 - 2, v10 - a1[v8 - 2], a4 + 2); if ( (_BYTE)v11 ) return v11; v11 = func0(a1, (int)v8 - 2, v13, v14); v7 = v14; if ( (_BYTE)v11 ) return v11; } --v8; } while ( (_DWORD)v8 ); } return v5; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12D,EDX PUSH RBP PUSH RBX SUB RSP,0x18 CMP ECX,0x3 SETZ AL TEST EDX,EDX SETZ DL MOV EBX,EDX AND BL,AL JNZ 0x0010145d TEST ESI,ESI MOV R13D,ECX MOV ECX,R12D SETZ DL SHR ECX,0x1f OR DL,CL JNZ 0x0010145d TEST AL,AL JNZ 0x0010145d CMP R13D,0x2 LEA R8D,[R13 + 0x1] MOVSXD RBP,ESI SETZ R15B LAB_001013ff: MOV R9D,R12D SUB R9D,dword ptr [RDI + RBP*0x4 + -0x4] SETZ DL MOV EBX,EDX AND BL,R15B JNZ 0x0010145d MOV EAX,R9D MOV R14D,EBP SHR EAX,0x1f OR AL,R15B JNZ 0x00101490 CMP EBP,0x1 JZ 0x00101490 SUB R14D,0x2 MOV EDX,R9D LEA ECX,[R13 + 0x2] SUB EDX,dword ptr [RDI + RBP*0x4 + -0x8] MOV ESI,R14D MOV dword ptr [RSP + 0xc],R8D MOV dword ptr [RSP + 0x8],R9D MOV qword ptr [RSP],RDI CALL 0x001013b0 MOV RDI,qword ptr [RSP] MOV R9D,dword ptr [RSP + 0x8] TEST AL,AL MOV R8D,dword ptr [RSP + 0xc] JZ 0x00101470 LAB_0010145b: MOV EBX,EAX LAB_0010145d: ADD RSP,0x18 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101470: MOV ECX,R8D MOV EDX,R9D MOV ESI,R14D MOV dword ptr [RSP + 0x8],R8D CALL 0x001013b0 MOV RDI,qword ptr [RSP] MOV R8D,dword ptr [RSP + 0x8] TEST AL,AL JNZ 0x0010145b LAB_00101490: SUB RBP,0x1 TEST EBP,EBP JZ 0x0010145d JMP 0x001013ff
/* func0(int*, int, int, int) */ ulong func0(int *param_1,int param_2,int param_3,int param_4) { uint3 uVar1; uint uVar2; uint7 uVar3; uint7 extraout_var; ulong uVar4; long lVar5; int iVar6; int iVar7; bool bVar8; bVar8 = param_4 == 3; uVar1 = (uint3)((uint)param_3 >> 8); uVar3 = (uint7)uVar1; uVar4 = (ulong)CONCAT31(uVar1,param_3 == 0 && bVar8); if (((param_3 != 0 || !bVar8) && (param_2 != 0 && -1 < param_3)) && (!bVar8)) { lVar5 = (long)param_2; do { iVar6 = param_3 - param_1[lVar5 + -1]; bVar8 = iVar6 == 0 && param_4 == 2; uVar4 = CONCAT71(uVar3,bVar8) & 0xffffffff; if (bVar8) { return uVar4; } if ((-1 < iVar6 && param_4 != 2) && ((int)lVar5 != 1)) { iVar7 = (int)lVar5 + -2; uVar2 = func0(param_1,iVar7,iVar6 - param_1[lVar5 + -2],param_4 + 2); if (((char)uVar2 != '\0') || (uVar2 = func0(param_1,iVar7,iVar6,param_4 + 1), uVar3 = extraout_var, (char)uVar2 != '\0')) { return (ulong)uVar2; } } lVar5 = lVar5 + -1; } while ((int)lVar5 != 0); } return uVar4; }
484
func0
#include <iostream> #include <vector> #include <assert.h> #include <algorithm> const int MAX = 3000;
int func0(int n) { std::vector<int> primes(MAX, 0); std::vector<int> result; for (int i = 2; i < MAX; ++i) { if (primes[i] == 0) { primes[i] = 1; int j = i * 2; while (j < MAX) { primes[j] -= 1; if (primes[j] + 3 == 0) { result.push_back(j); } j += i; } } } std::sort(result.begin(), result.end()); return result[n - 1]; }
int main() { assert(func0(1) == 30); assert(func0(50) == 273); assert(func0(1000) == 2664); return 0; }
O0
cpp
func0(int): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x68,%rsp mov %edi,-0x64(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax lea -0x58(%rbp),%rax mov %rax,%rdi callq 1676 <_ZNSaIiEC1Ev> movl $0x0,-0x30(%rbp) lea -0x58(%rbp),%rcx lea -0x30(%rbp),%rdx lea -0x50(%rbp),%rax mov $0xbb8,%esi mov %rax,%rdi callq 16b6 <_ZNSt6vectorIiSaIiEEC1EmRKiRKS0_> lea -0x58(%rbp),%rax mov %rax,%rdi callq 1696 <_ZNSaIiED1Ev> lea -0x30(%rbp),%rax mov %rax,%rdi callq 1628 <_ZNSt6vectorIiSaIiEEC1Ev> movl $0x2,-0x54(%rbp) cmpl $0xbb7,-0x54(%rbp) jg 1397 <_Z5func0i+0x12e> mov -0x54(%rbp),%eax movslq %eax,%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1804 <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%eax test %eax,%eax sete %al test %al,%al je 138e <_Z5func0i+0x125> mov -0x54(%rbp),%eax movslq %eax,%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1804 <_ZNSt6vectorIiSaIiEEixEm> movl $0x1,(%rax) mov -0x54(%rbp),%eax add %eax,%eax mov %eax,-0x58(%rbp) mov -0x58(%rbp),%eax cmp $0xbb7,%eax jg 138e <_Z5func0i+0x125> mov -0x58(%rbp),%eax movslq %eax,%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1804 <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%edx sub $0x1,%edx mov %edx,(%rax) mov -0x58(%rbp),%eax movslq %eax,%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1804 <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%eax cmp $0xfffffffd,%eax sete %al test %al,%al je 1381 <_Z5func0i+0x118> lea -0x58(%rbp),%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1828 <_ZNSt6vectorIiSaIiEE9push_backERKi> mov -0x58(%rbp),%edx mov -0x54(%rbp),%eax add %edx,%eax mov %eax,-0x58(%rbp) jmp 1327 <_Z5func0i+0xbe> addl $0x1,-0x54(%rbp) jmpq 12d3 <_Z5func0i+0x6a> lea -0x30(%rbp),%rax mov %rax,%rdi callq 18f4 <_ZNSt6vectorIiSaIiEE3endEv> mov %rax,%rbx lea -0x30(%rbp),%rax mov %rax,%rdi callq 18a8 <_ZNSt6vectorIiSaIiEE5beginEv> mov %rbx,%rsi mov %rax,%rdi callq 1944 <_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_> mov -0x64(%rbp),%eax sub $0x1,%eax movslq %eax,%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1804 <_ZNSt6vectorIiSaIiEEixEm> mov (%rax),%ebx lea -0x30(%rbp),%rax mov %rax,%rdi callq 173e <_ZNSt6vectorIiSaIiEED1Ev> lea -0x50(%rbp),%rax mov %rax,%rdi callq 173e <_ZNSt6vectorIiSaIiEED1Ev> mov %ebx,%eax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 144f <_Z5func0i+0x1e6> jmp 144a <_Z5func0i+0x1e1> endbr64 mov %rax,%rbx lea -0x58(%rbp),%rax mov %rax,%rdi callq 1696 <_ZNSaIiED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1170 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea -0x30(%rbp),%rax mov %rax,%rdi callq 173e <_ZNSt6vectorIiSaIiEED1Ev> lea -0x50(%rbp),%rax mov %rax,%rdi callq 173e <_ZNSt6vectorIiSaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1170 <_Unwind_Resume@plt> callq 1140 <__stack_chk_fail@plt> add $0x68,%rsp pop %rbx pop %rbp retq
_Z5func0i: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 68h mov [rbp+var_64], edi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax lea rax, [rbp+var_60] mov [rbp+var_58], rax nop nop mov [rbp+var_30], 0 lea rcx, [rbp+var_60] lea rdx, [rbp+var_30] lea rax, [rbp+var_50] mov esi, 0BB8h mov rdi, rax call _ZNSt6vectorIiSaIiEEC2EmRKiRKS0_; std::vector<int>::vector(ulong,int const&,std::allocator<int> const&) lea rax, [rbp+var_60] mov rdi, rax call _ZNSt15__new_allocatorIiED2Ev; std::__new_allocator<int>::~__new_allocator() nop lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEEC2Ev; std::vector<int>::vector(void) mov [rbp+var_5C], 2 jmp loc_1369 loc_12B7: mov eax, [rbp+var_5C] movsxd rdx, eax lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] test eax, eax setz al test al, al jz loc_1365 mov eax, [rbp+var_5C] movsxd rdx, eax lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov dword ptr [rax], 1 mov eax, [rbp+var_5C] add eax, eax mov [rbp+var_60], eax jmp short loc_135B loc_1300: mov eax, [rbp+var_60] movsxd rdx, eax lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov edx, [rax] sub edx, 1 mov [rax], edx mov eax, [rbp+var_60] movsxd rdx, eax lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] cmp eax, 0FFFFFFFDh setz al test al, al jz short loc_1350 lea rdx, [rbp+var_60] lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) loc_1350: mov edx, [rbp+var_60] mov eax, [rbp+var_5C] add eax, edx mov [rbp+var_60], eax loc_135B: mov eax, [rbp+var_60] cmp eax, 0BB7h jle short loc_1300 loc_1365: add [rbp+var_5C], 1 loc_1369: cmp [rbp+var_5C], 0BB7h jle loc_12B7 lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov rbx, rax lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rsi, rbx mov rdi, rax call _ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_; std::sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) mov eax, [rbp+var_64] sub eax, 1 movsxd rdx, eax lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() lea rax, [rbp+var_50] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov eax, ebx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1457 jmp short loc_1452 endbr64 mov rbx, rax lea rax, [rbp+var_60] mov rdi, rax call _ZNSt15__new_allocatorIiED2Ev; std::__new_allocator<int>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_140C call ___stack_chk_fail loc_140C: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() lea rax, [rbp+var_50] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_144A call ___stack_chk_fail loc_144A: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_1452: call ___stack_chk_fail loc_1457: mov rbx, [rbp+var_8] leave retn
long long func0(int a1) { _DWORD *v1; // rax long long v2; // rbx long long v3; // rax int j; // [rsp+10h] [rbp-60h] BYREF int i; // [rsp+14h] [rbp-5Ch] int *v7; // [rsp+18h] [rbp-58h] _BYTE v8[32]; // [rsp+20h] [rbp-50h] BYREF _DWORD v9[6]; // [rsp+40h] [rbp-30h] BYREF unsigned long long v10; // [rsp+58h] [rbp-18h] v10 = __readfsqword(0x28u); v7 = &j; v9[0] = 0; std::vector<int>::vector(v8, 3000LL, v9, &j); std::__new_allocator<int>::~__new_allocator(&j); std::vector<int>::vector(v9); for ( i = 2; i <= 2999; ++i ) { if ( !*(_DWORD *)std::vector<int>::operator[](v8, i) ) { *(_DWORD *)std::vector<int>::operator[](v8, i) = 1; for ( j = 2 * i; j <= 2999; j += i ) { v1 = (_DWORD *)std::vector<int>::operator[](v8, j); --*v1; if ( *(_DWORD *)std::vector<int>::operator[](v8, j) == -3 ) std::vector<int>::push_back(v9, &j); } } } v2 = std::vector<int>::end(v9); v3 = std::vector<int>::begin(v9); std::sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(v3, v2); LODWORD(v2) = *(_DWORD *)std::vector<int>::operator[](v9, a1 - 1); std::vector<int>::~vector(v9); std::vector<int>::~vector(v8); return (unsigned int)v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x68 MOV dword ptr [RBP + -0x64],EDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX LEA RAX,[RBP + -0x60] MOV qword ptr [RBP + -0x58],RAX NOP NOP MOV dword ptr [RBP + -0x30],0x0 LEA RCX,[RBP + -0x60] LEA RDX,[RBP + -0x30] LEA RAX,[RBP + -0x50] MOV ESI,0xbb8 MOV RDI,RAX LAB_0010128d: CALL 0x001015ca LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x001018ea NOP LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x001015aa MOV dword ptr [RBP + -0x5c],0x2 JMP 0x00101369 LAB_001012b7: MOV EAX,dword ptr [RBP + -0x5c] MOVSXD RDX,EAX LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010172e MOV EAX,dword ptr [RAX] TEST EAX,EAX SETZ AL TEST AL,AL JZ 0x00101365 MOV EAX,dword ptr [RBP + -0x5c] MOVSXD RDX,EAX LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010172e MOV dword ptr [RAX],0x1 MOV EAX,dword ptr [RBP + -0x5c] ADD EAX,EAX MOV dword ptr [RBP + -0x60],EAX JMP 0x0010135b LAB_00101300: MOV EAX,dword ptr [RBP + -0x60] MOVSXD RDX,EAX LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010172e MOV EDX,dword ptr [RAX] SUB EDX,0x1 MOV dword ptr [RAX],EDX MOV EAX,dword ptr [RBP + -0x60] MOVSXD RDX,EAX LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010172e MOV EAX,dword ptr [RAX] CMP EAX,-0x3 SETZ AL TEST AL,AL JZ 0x00101350 LEA RDX,[RBP + -0x60] LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX LAB_0010134b: CALL 0x00101752 LAB_00101350: MOV EDX,dword ptr [RBP + -0x60] MOV EAX,dword ptr [RBP + -0x5c] ADD EAX,EDX MOV dword ptr [RBP + -0x60],EAX LAB_0010135b: MOV EAX,dword ptr [RBP + -0x60] CMP EAX,0xbb7 JLE 0x00101300 LAB_00101365: ADD dword ptr [RBP + -0x5c],0x1 LAB_00101369: CMP dword ptr [RBP + -0x5c],0xbb7 JLE 0x001012b7 LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x0010186a MOV RBX,RAX LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x0010181e MOV RSI,RBX MOV RDI,RAX CALL 0x001018ba MOV EAX,dword ptr [RBP + -0x64] SUB EAX,0x1 MOVSXD RDX,EAX LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x0010172e MOV EBX,dword ptr [RAX] LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101650 LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00101650 MOV EAX,EBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x00101457 JMP 0x00101452 LAB_00101452: CALL 0x00101130 LAB_00101457: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(int) */ int4 func0(int param_1) { int4 uVar1; __normal_iterator _Var2; __normal_iterator _Var3; int *piVar4; int4 *puVar5; long in_FS_OFFSET; int local_68; int local_64; int *local_60; vector<int,std::allocator<int>> local_58 [32]; int local_38 [6]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_60 = &local_68; local_38[0] = 0; /* try { // try from 0010128d to 00101291 has its CatchHandler @ 001013e1 */ std::vector<int,std::allocator<int>>::vector(local_58,3000,local_38,(allocator *)&local_68); std::__new_allocator<int>::~__new_allocator((__new_allocator<int> *)&local_68); std::vector<int,std::allocator<int>>::vector((vector<int,std::allocator<int>> *)local_38); for (local_64 = 2; local_64 < 3000; local_64 = local_64 + 1) { piVar4 = (int *)std::vector<int,std::allocator<int>>::operator[](local_58,(long)local_64); if (*piVar4 == 0) { puVar5 = (int4 *) std::vector<int,std::allocator<int>>::operator[](local_58,(long)local_64); *puVar5 = 1; for (local_68 = local_64 * 2; local_68 < 3000; local_68 = local_64 + local_68) { piVar4 = (int *)std::vector<int,std::allocator<int>>::operator[](local_58,(long)local_68); *piVar4 = *piVar4 + -1; piVar4 = (int *)std::vector<int,std::allocator<int>>::operator[](local_58,(long)local_68); if (*piVar4 == -3) { /* try { // try from 0010134b to 0010139b has its CatchHandler @ 00101414 */ std::vector<int,std::allocator<int>>::push_back ((vector<int,std::allocator<int>> *)local_38,&local_68); } } } } _Var2 = std::vector<int,std::allocator<int>>::end((vector<int,std::allocator<int>> *)local_38); _Var3 = std::vector<int,std::allocator<int>>::begin((vector<int,std::allocator<int>> *)local_38); std::sort<__normal_iterator<int*,std::vector<int,std::allocator<int>>>>(_Var3,_Var2); puVar5 = (int4 *) std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)local_38,(long)(param_1 + -1)); uVar1 = *puVar5; std::vector<int,std::allocator<int>>::~vector((vector<int,std::allocator<int>> *)local_38); std::vector<int,std::allocator<int>>::~vector(local_58); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar1; }
485
func0
#include <iostream> #include <vector> #include <assert.h> #include <algorithm> const int MAX = 3000;
int func0(int n) { std::vector<int> primes(MAX, 0); std::vector<int> result; for (int i = 2; i < MAX; ++i) { if (primes[i] == 0) { primes[i] = 1; int j = i * 2; while (j < MAX) { primes[j] -= 1; if (primes[j] + 3 == 0) { result.push_back(j); } j += i; } } } std::sort(result.begin(), result.end()); return result[n - 1]; }
int main() { assert(func0(1) == 30); assert(func0(50) == 273); assert(func0(1000) == 2664); return 0; }
O1
cpp
func0(int): endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x30,%rsp mov %edi,%r14d mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax mov $0x2ee0,%edi callq 1130 <_Znwm@plt> mov %rax,%rbp lea 0x2ee0(%rax),%rdx movl $0x0,(%rax) add $0x4,%rax cmp %rdx,%rax jne 12a0 <_Z5func0i+0x37> movq $0x0,0x10(%rsp) movq $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) mov $0x2,%ebx lea 0xc(%rsp),%r13 jmp 132d <_Z5func0i+0xc4> lea 0x10(%rsp),%rdi mov %r13,%rdx callq 1522 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov %r12d,%edx add 0xc(%rsp),%edx mov %edx,0xc(%rsp) cmp $0xbb7,%edx jg 1320 <_Z5func0i+0xb7> movslq %edx,%rax lea 0x0(%rbp,%rax,4),%rcx mov (%rcx),%eax sub $0x1,%eax mov %eax,(%rcx) cmp $0xfffffffd,%eax jne 12e3 <_Z5func0i+0x7a> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 12d6 <_Z5func0i+0x6d> mov %edx,(%rsi) addq $0x4,0x18(%rsp) jmp 12e3 <_Z5func0i+0x7a> add $0x1,%rbx cmp $0xbb8,%rbx je 1350 <_Z5func0i+0xe7> mov %ebx,%r12d cmpl $0x0,0x0(%rbp,%rbx,4) jne 1320 <_Z5func0i+0xb7> movl $0x1,0x0(%rbp,%rbx,4) lea (%rbx,%rbx,1),%edx mov %edx,0xc(%rsp) cmp $0xbb7,%edx jle 12f6 <_Z5func0i+0x8d> jmp 1320 <_Z5func0i+0xb7> mov 0x18(%rsp),%rbx mov 0x10(%rsp),%r13 cmp %rbx,%r13 je 13e5 <_Z5func0i+0x17c> mov %rbx,%r12 sub %r13,%r12 mov %r12,%rax sar $0x2,%rax bsr %rax,%rax xor $0x3f,%rax mov $0x3f,%edx sub %eax,%edx movslq %edx,%rdx add %rdx,%rdx mov %rbx,%rsi mov %r13,%rdi callq 17a5 <_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1_> cmp $0x40,%r12 jle 13da <_Z5func0i+0x171> lea 0x40(%r13),%r12 mov %r12,%rsi mov %r13,%rdi callq 1651 <_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_> cmp %r12,%rbx je 13e5 <_Z5func0i+0x17c> mov %r12,%rdi mov %rdi,%rsi mov (%rdi),%ecx lea -0x4(%rdi),%rax mov -0x4(%rdi),%edx cmp %ecx,%edx jle 13cd <_Z5func0i+0x164> mov %edx,0x4(%rax) mov %rax,%rsi sub $0x4,%rax mov (%rax),%edx cmp %edx,%ecx jl 13bd <_Z5func0i+0x154> mov %ecx,(%rsi) add $0x4,%rdi cmp %rdi,%rbx jne 13ad <_Z5func0i+0x144> jmp 13e5 <_Z5func0i+0x17c> mov %rbx,%rsi mov %r13,%rdi callq 1651 <_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_> mov 0x10(%rsp),%rdi lea -0x1(%r14),%eax cltq mov (%rdi,%rax,4),%ebx test %rdi,%rdi je 13fd <_Z5func0i+0x194> callq 1120 <_ZdlPv@plt> mov %rbp,%rdi callq 1120 <_ZdlPv@plt> mov 0x28(%rsp),%rax xor %fs:0x28,%rax jne 144a <_Z5func0i+0x1e1> mov %ebx,%eax add $0x30,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq endbr64 mov %rax,%rbx mov 0x10(%rsp),%rdi test %rdi,%rdi je 143a <_Z5func0i+0x1d1> callq 1120 <_ZdlPv@plt> mov %rbp,%rdi callq 1120 <_ZdlPv@plt> mov %rbx,%rdi callq 1170 <_Unwind_Resume@plt> callq 1140 <__stack_chk_fail@plt>
_Z5func0i: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 68h mov [rsp+98h+var_8C], edi mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax mov edi, 2EE0h; unsigned __int64 call __Znwm; operator new(ulong) mov r13, rax mov [rsp+98h+var_78], rax lea rdx, [rax+2EE0h] mov [rsp+98h+var_68], rdx loc_126D: mov dword ptr [rax], 0 add rax, 4 cmp rax, rdx jnz short loc_126D mov [rsp+98h+var_70], rdx mov [rsp+98h+src], 0 mov [rsp+98h+var_50], 0 mov [rsp+98h+var_48], 0 mov r12d, 2 lea r15, [rsp+98h+var_7C] jmp short loc_1302 loc_12A9: lea rdi, [rsp+98h+src] mov rdx, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) loc_12B6: add ebp, r14d mov [rsp+98h+var_7C], ebp add rbx, r12 cmp ebx, 0BB7h jg short loc_12F5 loc_12C8: mov ebp, ebx mov eax, [r13+rbx*4+0] sub eax, 1 mov [r13+rbx*4+0], eax cmp eax, 0FFFFFFFDh jnz short loc_12B6 mov rsi, [rsp+98h+var_50] cmp rsi, [rsp+98h+var_48] jz short loc_12A9 mov [rsi], ebx add rsi, 4 mov [rsp+98h+var_50], rsi jmp short loc_12B6 loc_12F5: add r12, 1 cmp r12, 0BB8h jz short loc_132B loc_1302: cmp dword ptr [r13+r12*4+0], 0 jnz short loc_12F5 mov dword ptr [r13+r12*4+0], 1 mov r14d, r12d lea eax, [r12+r12] mov [rsp+98h+var_7C], eax cmp eax, 0BB7h jg short loc_12F5 lea rbx, [r12+r12] jmp short loc_12C8 loc_132B: mov rbp, [rsp+98h+var_50] mov rbx, [rsp+98h+src] cmp rbx, rbp jz loc_13C6 mov r12, rbp sub r12, rbx mov rcx, r12 sar rcx, 2 mov eax, 40h ; '@' jz short loc_1359 bsr rax, rcx xor eax, 3Fh loc_1359: mov edx, 3Fh ; '?' sub edx, eax movsxd rdx, edx add rdx, rdx mov rsi, rbp mov rdi, rbx call _ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1_; std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter) cmp r12, 40h ; '@' jle short loc_13BB lea r12, [rbx+40h] mov rsi, r12 mov rdi, rbx; src call _ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_; std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter) cmp rbp, r12 jz short loc_13C6 mov rdi, r12 loc_138E: mov rsi, rdi mov ecx, [rdi] lea rax, [rdi-4] mov edx, [rdi-4] cmp ecx, edx jge short loc_13AE loc_139E: mov [rax+4], edx mov rsi, rax sub rax, 4 mov edx, [rax] cmp ecx, edx jl short loc_139E loc_13AE: mov [rsi], ecx add rdi, 4 cmp rdi, rbp jnz short loc_138E jmp short loc_13C6 loc_13BB: mov rsi, rbp mov rdi, rbx; src call _ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_; std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter) loc_13C6: mov eax, [rsp+98h+var_8C] sub eax, 1 cdqe mov ebp, [rbx+rax*4] test rbx, rbx jz short loc_13E7 mov rsi, [rsp+98h+var_48] sub rsi, rbx; unsigned __int64 mov rdi, rbx; void * call __ZdlPvm; operator delete(void *,ulong) loc_13E7: mov esi, 2EE0h; unsigned __int64 mov rdi, r13; void * call __ZdlPvm; operator delete(void *,ulong) mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_144D mov eax, ebp add rsp, 68h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbx, rax lea rdi, [rsp+arg_38] call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() lea rdi, [rsp+arg_18] call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, [rsp+arg_50] sub rax, fs:28h jz short loc_1445 call ___stack_chk_fail loc_1445: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_144D: call ___stack_chk_fail
long long func0(int a1) { _DWORD *v1; // rax _DWORD *v2; // r13 _DWORD *v3; // rdx long long i; // r12 long long v5; // rbx int v6; // eax char *v7; // rsi char *v8; // rbp char *v9; // rbx long long v10; // r12 unsigned long long v11; // rcx int v12; // eax unsigned long long v13; // rax char *v14; // rdi char *v15; // rsi int v16; // ecx char *v17; // rax int v18; // edx unsigned int v19; // ebp int v22; // [rsp+1Ch] [rbp-7Ch] BYREF _DWORD *v23; // [rsp+20h] [rbp-78h] _DWORD *v24; // [rsp+28h] [rbp-70h] _DWORD *v25; // [rsp+30h] [rbp-68h] void *src; // [rsp+40h] [rbp-58h] BYREF char *v27; // [rsp+48h] [rbp-50h] char *v28; // [rsp+50h] [rbp-48h] unsigned long long v29; // [rsp+58h] [rbp-40h] v29 = __readfsqword(0x28u); v1 = (_DWORD *)operator new(0x2EE0uLL); v2 = v1; v23 = v1; v3 = v1 + 3000; v25 = v1 + 3000; do *v1++ = 0; while ( v1 != v3 ); v24 = v3; src = 0LL; v27 = 0LL; v28 = 0LL; for ( i = 2LL; i != 3000; ++i ) { if ( !v2[i] ) { v2[i] = 1; v22 = 2 * i; if ( 2 * (int)i <= 2999 ) { v5 = 2 * i; do { v6 = v2[v5] - 1; v2[v5] = v6; if ( v6 == -3 ) { v7 = v27; if ( v27 == v28 ) { std::vector<int>::_M_realloc_insert<int const&>(&src, v27, &v22); } else { *(_DWORD *)v27 = v5; v27 = v7 + 4; } } v22 = i + v5; v5 += i; } while ( (int)v5 <= 2999 ); } } } v8 = v27; v9 = (char *)src; if ( src != v27 ) { v10 = v27 - (_BYTE *)src; v11 = (v27 - (_BYTE *)src) >> 2; v12 = 64; if ( v11 ) { _BitScanReverse64(&v13, v11); v12 = v13 ^ 0x3F; } std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>( src, v27, 2LL * (63 - v12), v11); if ( v10 <= 64 ) { std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(v9); } else { std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(v9); if ( v8 != v9 + 64 ) { v14 = v9 + 64; do { v15 = v14; v16 = *(_DWORD *)v14; v17 = v14 - 4; v18 = *((_DWORD *)v14 - 1); if ( *(_DWORD *)v14 < v18 ) { do { *((_DWORD *)v17 + 1) = v18; v15 = v17; v17 -= 4; v18 = *(_DWORD *)v17; } while ( v16 < *(_DWORD *)v17 ); } *(_DWORD *)v15 = v16; v14 += 4; } while ( v14 != v8 ); } } } v19 = *(_DWORD *)&v9[4 * a1 - 4]; if ( v9 ) operator delete(v9, v28 - v9); operator delete(v2, 0x2EE0uLL); return v19; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x68 MOV dword ptr [RSP + 0xc],EDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX MOV EDI,0x2ee0 LAB_00101254: CALL 0x001010f0 MOV R13,RAX MOV qword ptr [RSP + 0x20],RAX LEA RDX,[RAX + 0x2ee0] MOV qword ptr [RSP + 0x30],RDX LAB_0010126d: MOV dword ptr [RAX],0x0 ADD RAX,0x4 CMP RAX,RDX JNZ 0x0010126d MOV qword ptr [RSP + 0x28],RDX MOV qword ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV R12D,0x2 LEA R15,[RSP + 0x1c] JMP 0x00101302 LAB_001012a9: LEA RDI,[RSP + 0x40] MOV RDX,R15 LAB_001012b1: CALL 0x00101518 LAB_001012b6: ADD EBP,R14D MOV dword ptr [RSP + 0x1c],EBP ADD RBX,R12 CMP EBX,0xbb7 JG 0x001012f5 LAB_001012c8: MOV EBP,EBX MOV EAX,dword ptr [R13 + RBX*0x4] SUB EAX,0x1 MOV dword ptr [R13 + RBX*0x4],EAX CMP EAX,-0x3 JNZ 0x001012b6 MOV RSI,qword ptr [RSP + 0x48] CMP RSI,qword ptr [RSP + 0x50] JZ 0x001012a9 MOV dword ptr [RSI],EBX ADD RSI,0x4 MOV qword ptr [RSP + 0x48],RSI JMP 0x001012b6 LAB_001012f5: ADD R12,0x1 CMP R12,0xbb8 JZ 0x0010132b LAB_00101302: CMP dword ptr [R13 + R12*0x4],0x0 JNZ 0x001012f5 MOV dword ptr [R13 + R12*0x4],0x1 MOV R14D,R12D LEA EAX,[R12 + R12*0x1] MOV dword ptr [RSP + 0x1c],EAX CMP EAX,0xbb7 JG 0x001012f5 LEA RBX,[R12 + R12*0x1] JMP 0x001012c8 LAB_0010132b: MOV RBP,qword ptr [RSP + 0x48] MOV RBX,qword ptr [RSP + 0x40] CMP RBX,RBP JZ 0x001013c6 MOV R12,RBP SUB R12,RBX MOV RCX,R12 SAR RCX,0x2 MOV EAX,0x40 JZ 0x00101359 BSR RAX,RCX XOR EAX,0x3f LAB_00101359: MOV EDX,0x3f SUB EDX,EAX MOVSXD RDX,EDX ADD RDX,RDX MOV RSI,RBP MOV RDI,RBX CALL 0x001017a6 CMP R12,0x40 JLE 0x001013bb LEA R12,[RBX + 0x40] MOV RSI,R12 MOV RDI,RBX CALL 0x00101649 CMP RBP,R12 JZ 0x001013c6 MOV RDI,R12 LAB_0010138e: MOV RSI,RDI MOV ECX,dword ptr [RDI] LEA RAX,[RDI + -0x4] MOV EDX,dword ptr [RDI + -0x4] CMP ECX,EDX JGE 0x001013ae LAB_0010139e: MOV dword ptr [RAX + 0x4],EDX MOV RSI,RAX SUB RAX,0x4 MOV EDX,dword ptr [RAX] CMP ECX,EDX JL 0x0010139e LAB_001013ae: MOV dword ptr [RSI],ECX ADD RDI,0x4 CMP RDI,RBP JNZ 0x0010138e JMP 0x001013c6 LAB_001013bb: MOV RSI,RBP MOV RDI,RBX CALL 0x00101649 LAB_001013c6: MOV EAX,dword ptr [RSP + 0xc] SUB EAX,0x1 CDQE MOV EBP,dword ptr [RBX + RAX*0x4] TEST RBX,RBX JZ 0x001013e7 MOV RSI,qword ptr [RSP + 0x50] SUB RSI,RBX MOV RDI,RBX CALL 0x00101100 LAB_001013e7: MOV ESI,0x2ee0 MOV RDI,R13 CALL 0x00101100 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010144d MOV EAX,EBP ADD RSP,0x68 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010144d: CALL 0x00101110
/* func0(int) */ int func0(int param_1,int param_2,int param_3,int param_4,int param_5, int param_6,int param_7,int param_8,int param_9,int param_10, int4 param_11,int8 param_12,int8 param_13) { int iVar1; int iVar2; int *piVar3; int *piVar4; int *piVar5; int *piVar6; int *piVar7; uint uVar8; int4 *puVar9; int4 *puVar10; ulong uVar11; _Iter_less_iter extraout_EDX; long lVar12; __normal_iterator _Var13; __normal_iterator _Var14; int *piVar15; long lVar16; long in_FS_OFFSET; int local_7c; int4 *local_78; int4 *local_70; int4 *local_68; int *local_58; int *local_50; int *local_48; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); puVar9 = (int4 *)operator_new(12000); local_70 = puVar9 + 3000; puVar10 = puVar9; do { *puVar10 = 0; puVar10 = puVar10 + 1; } while (puVar10 != local_70); local_58 = (int *)0x0; local_50 = (int *)0x0; local_48 = (int *)0x0; lVar16 = 2; local_78 = puVar9; local_68 = local_70; do { if (puVar9[lVar16] == 0) { puVar9[lVar16] = 1; local_7c = (int)lVar16 * 2; if (local_7c < 3000) { lVar12 = lVar16 * 2; do { iVar1 = puVar9[lVar12]; puVar9[lVar12] = iVar1 + -1; if (iVar1 + -1 == -3) { if (local_50 == local_48) { /* try { // try from 001012b1 to 001012b5 has its CatchHandler @ 00101415 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_58,(__normal_iterator)local_50, &local_7c); } else { *local_50 = (int)lVar12; local_50 = local_50 + 1; } } local_7c = (int)lVar12 + (int)lVar16; lVar12 = lVar12 + lVar16; } while ((int)lVar12 < 3000); } } piVar6 = local_50; piVar5 = local_58; lVar16 = lVar16 + 1; } while (lVar16 != 3000); if (local_58 != local_50) { lVar16 = (long)local_50 - (long)local_58; uVar11 = lVar16 >> 2; uVar8 = 0x40; if (uVar11 != 0) { lVar12 = 0x3f; if (uVar11 != 0) { for (; uVar11 >> lVar12 == 0; lVar12 = lVar12 + -1) { } } uVar8 = (uint)lVar12 ^ 0x3f; } _Var13 = (__normal_iterator)local_50; _Var14 = (__normal_iterator)local_58; std:: __introsort_loop<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,long,__ops::_Iter_less_iter> (_Var14,_Var13,(long)(int)(0x3f - uVar8) * 2,(_Iter_less_iter)uVar11); if (lVar16 < 0x41) { std:: __insertion_sort<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,__ops::_Iter_less_iter> (_Var14,_Var13,extraout_EDX); } else { piVar15 = piVar5 + 0x10; std:: __insertion_sort<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,__ops::_Iter_less_iter> (_Var14,(__normal_iterator)piVar15,extraout_EDX); for (; piVar6 != piVar15; piVar15 = piVar15 + 1) { iVar1 = *piVar15; iVar2 = piVar15[-1]; piVar7 = piVar15 + -1; piVar4 = piVar15; while (piVar3 = piVar7, iVar1 < iVar2) { piVar3[1] = iVar2; piVar7 = piVar3 + -1; piVar4 = piVar3; iVar2 = piVar3[-1]; } *piVar4 = iVar1; } } } iVar1 = piVar5[param_1 + -1]; if (piVar5 != (int *)0x0) { operator_delete(piVar5,(long)local_48 - (long)piVar5); } operator_delete(puVar9,12000); if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar1; }
486
func0
#include <iostream> #include <vector> #include <assert.h> #include <algorithm> const int MAX = 3000;
int func0(int n) { std::vector<int> primes(MAX, 0); std::vector<int> result; for (int i = 2; i < MAX; ++i) { if (primes[i] == 0) { primes[i] = 1; int j = i * 2; while (j < MAX) { primes[j] -= 1; if (primes[j] + 3 == 0) { result.push_back(j); } j += i; } } } std::sort(result.begin(), result.end()); return result[n - 1]; }
int main() { assert(func0(1) == 30); assert(func0(50) == 273); assert(func0(1000) == 2664); return 0; }
O2
cpp
func0(int): endbr64 push %r15 push %r14 mov %edi,%r14d mov $0x2ee0,%edi push %r13 push %r12 push %rbp push %rbx sub $0x38,%rsp mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax callq 1130 <_Znwm@plt> mov %rax,%rbp lea 0x2ee0(%rax),%rdx nopl 0x0(%rax) movl $0x0,(%rax) add $0x4,%rax cmp %rdx,%rax jne 13b0 <_Z5func0i+0x40> mov $0x2,%ebx xor %r15d,%r15d lea 0xc(%rsp),%r13 movq $0x0,0x10(%rsp) movq $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) jmp 1401 <_Z5func0i+0x91> nopl 0x0(%rax) add $0x1,%rbx cmp $0xbb8,%rbx je 147f <_Z5func0i+0x10f> mov 0x0(%rbp,%rbx,4),%eax mov %ebx,%r12d test %eax,%eax jne 13f0 <_Z5func0i+0x80> lea (%rbx,%rbx,1),%edx movl $0x1,0x0(%rbp,%rbx,4) mov %edx,0xc(%rsp) cmp $0xbb7,%edx jbe 143b <_Z5func0i+0xcb> jmp 13f0 <_Z5func0i+0x80> nopl (%rax) mov 0xc(%rsp),%edx add %r12d,%edx mov %edx,0xc(%rsp) cmp $0xbb7,%edx jg 13f0 <_Z5func0i+0x80> movslq %edx,%rax lea 0x0(%rbp,%rax,4),%rcx mov (%rcx),%eax sub $0x1,%eax mov %eax,(%rcx) cmp $0xfffffffd,%eax jne 1428 <_Z5func0i+0xb8> cmp 0x20(%rsp),%r15 je 1468 <_Z5func0i+0xf8> mov %edx,(%r15) add $0x4,%r15 mov %r15,0x18(%rsp) jmp 1428 <_Z5func0i+0xb8> nopl 0x0(%rax) lea 0x10(%rsp),%rdi mov %r13,%rdx mov %r15,%rsi callq 1580 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x18(%rsp),%r15 jmp 1428 <_Z5func0i+0xb8> mov 0x10(%rsp),%r12 cmp %r15,%r12 je 1511 <_Z5func0i+0x1a1> mov %r15,%rbx mov $0x3f,%edx mov %r15,%rsi mov %r12,%rdi sub %r12,%rbx mov %rbx,%rax sar $0x2,%rax bsr %rax,%rax xor $0x3f,%rax sub %eax,%edx movslq %edx,%rdx add %rdx,%rdx callq 18b0 <_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1_> cmp $0x40,%rbx jle 1552 <_Z5func0i+0x1e2> lea 0x40(%r12),%rbx mov %r12,%rdi mov %rbx,%rsi callq 16e0 <_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_> mov %rbx,%rdi cmp %rbx,%r15 je 155d <_Z5func0i+0x1ed> mov (%rdi),%ecx mov -0x4(%rdi),%edx mov %rdi,%rsi lea -0x4(%rdi),%rax cmp %ecx,%edx jle 1501 <_Z5func0i+0x191> mov %edx,0x4(%rax) mov %rax,%rsi mov -0x4(%rax),%edx sub $0x4,%rax cmp %edx,%ecx jl 14f0 <_Z5func0i+0x180> add $0x4,%rdi mov %ecx,(%rsi) cmp %rdi,%r15 jne 14e0 <_Z5func0i+0x170> mov 0x10(%rsp),%r15 lea -0x1(%r14),%eax cltq mov (%r15,%rax,4),%r12d test %r15,%r15 je 1528 <_Z5func0i+0x1b8> mov %r15,%rdi callq 1120 <_ZdlPv@plt> mov %rbp,%rdi callq 1120 <_ZdlPv@plt> mov 0x28(%rsp),%rax xor %fs:0x28,%rax jne 1564 <_Z5func0i+0x1f4> add $0x38,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov %r15,%rsi mov %r12,%rdi callq 16e0 <_ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0_> mov 0x10(%rsp),%r15 jmp 1511 <_Z5func0i+0x1a1> callq 1140 <__stack_chk_fail@plt> endbr64 mov %rax,%r12 jmpq 1180 <_Z5func0i.cold> nopw %cs:0x0(%rax,%rax,1)
_Z5func0i: endbr64 push r15 push r14 push r13 push r12 mov r12d, 2 push rbp push rbx sub rsp, 68h mov [rsp+98h+var_8C], edi mov edi, 2EE0h; unsigned __int64 mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax call __Znwm; operator new(ulong) mov edx, 2EE0h; n xor esi, esi; c lea rbx, [rax+2EE0h] mov rdi, rax; s mov [rsp+98h+var_78], rax mov r13, rax mov [rsp+98h+var_68], rbx call _memset pxor xmm0, xmm0 lea rax, [rsp+98h+var_7C] mov [rsp+98h+var_70], rbx mov [rsp+98h+var_48], 0 mov [rsp+98h+var_98], rax movaps xmmword ptr [rsp+98h+src], xmm0 jmp short loc_1751 loc_1740: add r12, 1 cmp r12, 0BB8h jz loc_17D3 loc_1751: mov eax, [r13+r12*4+0] test eax, eax jnz short loc_1740 lea eax, [r12+r12] mov r14d, r12d lea rbx, [r12+r12] mov dword ptr [r13+r12*4+0], 1 mov [rsp+98h+var_7C], eax cmp eax, 0BB7h jbe short loc_1792 jmp short loc_1740 loc_1780: add ebp, r14d add rbx, r12 mov [rsp+98h+var_7C], ebp cmp ebx, 0BB7h jg short loc_1740 loc_1792: mov eax, [r13+rbx*4+0] mov ebp, ebx sub eax, 1 mov [r13+rbx*4+0], eax cmp eax, 0FFFFFFFDh jnz short loc_1780 mov rsi, [rsp+98h+src+8] cmp rsi, [rsp+98h+var_48] jz short loc_17C0 mov [rsi], ebx add rsi, 4 mov [rsp+98h+src+8], rsi jmp short loc_1780 loc_17C0: lea r15, [rsp+98h+src] mov rdx, [rsp+98h+var_98] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) jmp short loc_1780 loc_17D3: mov r12, [rsp+98h+src+8] mov rbp, [rsp+98h+src] cmp rbp, r12 jz short loc_185C mov rbx, r12 mov rdx, 0FFFFFFFFFFFFFFFEh sub rbx, rbp mov rax, rbx sar rax, 2 jz short loc_1802 bsr rax, rax cdqe lea rdx, [rax+rax] loc_1802: mov rsi, r12 mov rdi, rbp call _ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1__isra_0; std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter) [clone] cmp rbx, 40h ; '@' jle loc_18AC lea rbx, [rbp+40h] mov rdi, rbp; src mov rsi, rbx call _ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0__isra_0; std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter) [clone] cmp r12, rbx jz short loc_185C nop dword ptr [rax+rax+00h] loc_1830: mov ecx, [rbx] mov edx, [rbx-4] lea rax, [rbx-4] cmp ecx, edx jge short loc_18B9 nop dword ptr [rax] loc_1840: mov [rax+4], edx mov rsi, rax mov edx, [rax-4] sub rax, 4 cmp ecx, edx jl short loc_1840 add rbx, 4 mov [rsi], ecx cmp r12, rbx jnz short loc_1830 loc_185C: mov eax, [rsp+98h+var_8C] sub eax, 1 cdqe mov ebx, [rbp+rax*4+0] test rbp, rbp jz short loc_187E mov rsi, [rsp+98h+var_48] mov rdi, rbp; void * sub rsi, rbp; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_187E: mov esi, 2EE0h; unsigned __int64 mov rdi, r13; void * call __ZdlPvm; operator delete(void *,ulong) mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_18CD add rsp, 68h mov eax, ebx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_18AC: mov rsi, r12 mov rdi, rbp; src call _ZSt16__insertion_sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEENS0_5__ops15_Iter_less_iterEEvT_S9_T0__isra_0; std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter) [clone] jmp short loc_185C loc_18B9: mov rsi, rbx add rbx, 4 mov [rsi], ecx cmp r12, rbx jnz loc_1830 jmp short loc_185C loc_18CD: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0i_cold; func0(int) [clone]
long long func0(int a1) { long long v1; // r12 char *v2; // rax char *v3; // rbx _DWORD *v4; // r13 long long v5; // rbx int v6; // ebp int v7; // eax char *v8; // rsi char *v9; // r12 char *v10; // rbp long long v11; // rdx signed long long v12; // rbx unsigned long long v13; // rax char *v14; // rbx int v15; // ecx int v16; // edx char *v17; // rax char *v18; // rsi unsigned int v19; // ebx char *v21; // rsi int v22; // [rsp+1Ch] [rbp-7Ch] BYREF char *v23; // [rsp+20h] [rbp-78h] char *v24; // [rsp+28h] [rbp-70h] char *v25; // [rsp+30h] [rbp-68h] void *src[2]; // [rsp+40h] [rbp-58h] BYREF _BYTE *v27; // [rsp+50h] [rbp-48h] unsigned long long v28; // [rsp+58h] [rbp-40h] v1 = 2LL; v28 = __readfsqword(0x28u); v2 = (char *)operator new(0x2EE0uLL); v3 = v2 + 12000; v23 = v2; v4 = v2; v25 = v2 + 12000; memset(v2, 0, 0x2EE0uLL); v24 = v3; v27 = 0LL; *(_OWORD *)src = 0LL; do { if ( !v4[v1] ) { v5 = 2 * v1; v4[v1] = 1; v22 = 2 * v1; if ( (unsigned int)(2 * v1) <= 0xBB7 ) { do { v6 = v5; v7 = v4[v5] - 1; v4[v5] = v7; if ( v7 == -3 ) { v8 = (char *)src[1]; if ( src[1] == v27 ) { std::vector<int>::_M_realloc_insert<int const&>(src, src[1], &v22); } else { *(_DWORD *)src[1] = v5; src[1] = v8 + 4; } } v5 += v1; v22 = v1 + v6; } while ( (int)v5 <= 2999 ); } } ++v1; } while ( v1 != 3000 ); v9 = (char *)src[1]; v10 = (char *)src[0]; if ( src[0] != src[1] ) { v11 = -2LL; v12 = (char *)src[1] - (char *)src[0]; if ( ((char *)src[1] - (char *)src[0]) >> 2 ) { _BitScanReverse64(&v13, ((char *)src[1] - (char *)src[0]) >> 2); v11 = 2LL * (int)v13; } std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>( src[0], src[1], v11); if ( v12 <= 64 ) { std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(v10); } else { v14 = v10 + 64; std::__insertion_sort<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__ops::_Iter_less_iter>(v10); if ( v9 != v10 + 64 ) { do { while ( 1 ) { v15 = *(_DWORD *)v14; v16 = *((_DWORD *)v14 - 1); v17 = v14 - 4; if ( *(_DWORD *)v14 < v16 ) break; v21 = v14; v14 += 4; *(_DWORD *)v21 = v15; if ( v9 == v14 ) goto LABEL_19; } do { *((_DWORD *)v17 + 1) = v16; v18 = v17; v16 = *((_DWORD *)v17 - 1); v17 -= 4; } while ( v15 < v16 ); v14 += 4; *(_DWORD *)v18 = v15; } while ( v9 != v14 ); } } } LABEL_19: v19 = *(_DWORD *)&v10[4 * a1 - 4]; if ( v10 ) operator delete(v10, v27 - v10); operator delete(v4, 0x2EE0uLL); return v19; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12D,0x2 PUSH RBP PUSH RBX SUB RSP,0x68 MOV dword ptr [RSP + 0xc],EDI MOV EDI,0x2ee0 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX LAB_001016f1: CALL 0x00101110 MOV EDX,0x2ee0 XOR ESI,ESI LEA RBX,[RAX + 0x2ee0] MOV RDI,RAX MOV qword ptr [RSP + 0x20],RAX MOV R13,RAX MOV qword ptr [RSP + 0x30],RBX CALL 0x001010e0 PXOR XMM0,XMM0 LEA RAX,[RSP + 0x1c] MOV qword ptr [RSP + 0x28],RBX MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP],RAX MOVAPS xmmword ptr [RSP + 0x40],XMM0 JMP 0x00101751 LAB_00101740: ADD R12,0x1 CMP R12,0xbb8 JZ 0x001017d3 LAB_00101751: MOV EAX,dword ptr [R13 + R12*0x4] TEST EAX,EAX JNZ 0x00101740 LEA EAX,[R12 + R12*0x1] MOV R14D,R12D LEA RBX,[R12 + R12*0x1] MOV dword ptr [R13 + R12*0x4],0x1 MOV dword ptr [RSP + 0x1c],EAX CMP EAX,0xbb7 JBE 0x00101792 JMP 0x00101740 LAB_00101780: ADD EBP,R14D ADD RBX,R12 MOV dword ptr [RSP + 0x1c],EBP CMP EBX,0xbb7 JG 0x00101740 LAB_00101792: MOV EAX,dword ptr [R13 + RBX*0x4] MOV EBP,EBX SUB EAX,0x1 MOV dword ptr [R13 + RBX*0x4],EAX CMP EAX,-0x3 JNZ 0x00101780 MOV RSI,qword ptr [RSP + 0x48] CMP RSI,qword ptr [RSP + 0x50] JZ 0x001017c0 MOV dword ptr [RSI],EBX ADD RSI,0x4 MOV qword ptr [RSP + 0x48],RSI JMP 0x00101780 LAB_001017c0: LEA R15,[RSP + 0x40] MOV RDX,qword ptr [RSP] MOV RDI,R15 LAB_001017cc: CALL 0x00101910 JMP 0x00101780 LAB_001017d3: MOV R12,qword ptr [RSP + 0x48] MOV RBP,qword ptr [RSP + 0x40] CMP RBP,R12 JZ 0x0010185c MOV RBX,R12 MOV RDX,-0x2 SUB RBX,RBP MOV RAX,RBX SAR RAX,0x2 JZ 0x00101802 BSR RAX,RAX CDQE LEA RDX,[RAX + RAX*0x1] LAB_00101802: MOV RSI,R12 MOV RDI,RBP CALL 0x001014f0 CMP RBX,0x40 JLE 0x001018ac LEA RBX,[RBP + 0x40] MOV RDI,RBP MOV RSI,RBX CALL 0x00101440 CMP R12,RBX JZ 0x0010185c NOP dword ptr [RAX + RAX*0x1] LAB_00101830: MOV ECX,dword ptr [RBX] MOV EDX,dword ptr [RBX + -0x4] LEA RAX,[RBX + -0x4] CMP ECX,EDX JGE 0x001018b9 NOP dword ptr [RAX] LAB_00101840: MOV dword ptr [RAX + 0x4],EDX MOV RSI,RAX MOV EDX,dword ptr [RAX + -0x4] SUB RAX,0x4 CMP ECX,EDX JL 0x00101840 ADD RBX,0x4 MOV dword ptr [RSI],ECX CMP R12,RBX JNZ 0x00101830 LAB_0010185c: MOV EAX,dword ptr [RSP + 0xc] SUB EAX,0x1 CDQE MOV EBX,dword ptr [RBP + RAX*0x4] TEST RBP,RBP JZ 0x0010187e MOV RSI,qword ptr [RSP + 0x50] MOV RDI,RBP SUB RSI,RBP CALL 0x00101120 LAB_0010187e: MOV ESI,0x2ee0 MOV RDI,R13 CALL 0x00101120 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018cd ADD RSP,0x68 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001018ac: MOV RSI,R12 MOV RDI,RBP CALL 0x00101440 JMP 0x0010185c LAB_001018b9: MOV RSI,RBX ADD RBX,0x4 MOV dword ptr [RSI],ECX CMP R12,RBX JNZ 0x00101830 JMP 0x0010185c LAB_001018cd: CALL 0x00101130
/* func0(int) */ int func0(int param_1,int param_2,int param_3,int param_4,int param_5, int param_6,int param_7,int param_8,int param_9,int param_10, int4 param_11,int8 param_12,int8 param_13) { int *piVar1; int8 uVar2; int8 uVar3; int iVar4; void *__s; ulong uVar5; int *piVar6; int7 in_register_00000009; int8 uVar7; _Iter_less_iter extraout_EDX; int iVar8; long lVar9; int *piVar10; __normal_iterator _Var11; __normal_iterator _Var12; long lVar13; long in_FS_OFFSET; uint local_7c; void *local_78; long local_70; long local_68; int local_58 [16]; int *local_48; long local_40; uVar7 = CONCAT71(in_register_00000009,param_4); lVar13 = 2; local_40 = *(long *)(in_FS_OFFSET + 0x28); __s = operator_new(12000); local_78 = __s; local_68 = (long)__s + 12000; memset(__s,0,12000); local_48 = (int *)0x0; local_58 = (int [16])0x0; local_70 = (long)__s + 12000; do { if (*(int *)((long)__s + lVar13 * 4) == 0) { local_7c = (int)lVar13 * 2; lVar9 = lVar13 * 2; *(int4 *)((long)__s + lVar13 * 4) = 1; if (local_7c < 3000) { do { iVar4 = *(int *)((long)__s + lVar9 * 4) + -1; *(int *)((long)__s + lVar9 * 4) = iVar4; if (iVar4 == -3) { if ((int *)local_58._8_8_ == local_48) { /* try { // try from 001017cc to 001017d0 has its CatchHandler @ 001018d2 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)local_58,local_58._8_4_,(int *)&local_7c ); } else { *(int *)local_58._8_8_ = (int)lVar9; local_58._8_8_ = (int *)(local_58._8_8_ + 4); } } local_7c = (int)lVar9 + (int)lVar13; lVar9 = lVar9 + lVar13; } while ((int)lVar9 < 3000); } } lVar13 = lVar13 + 1; } while (lVar13 != 3000); uVar3 = local_58._8_8_; uVar2 = local_58._0_8_; if (local_58._0_8_ != local_58._8_8_) { lVar13 = -2; lVar9 = local_58._8_8_ - local_58._0_8_; uVar5 = lVar9 >> 2; if (uVar5 != 0) { lVar13 = 0x3f; if (uVar5 != 0) { for (; uVar5 >> lVar13 == 0; lVar13 = lVar13 + -1) { } } lVar13 = (long)(int)lVar13 * 2; } _Var11 = local_58._8_4_; _Var12 = local_58._0_4_; std:: __introsort_loop<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,long,__ops::_Iter_less_iter> (_Var12,_Var11,lVar13,(_Iter_less_iter)uVar7); if (lVar9 < 0x41) { std:: __insertion_sort<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,__ops::_Iter_less_iter> (_Var12,_Var11,extraout_EDX); } else { piVar10 = (int *)(uVar2 + 0x40); std:: __insertion_sort<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,__ops::_Iter_less_iter> (_Var12,(__normal_iterator)piVar10,extraout_EDX); for (; (int *)uVar3 != piVar10; piVar10 = piVar10 + 1) { while( true ) { iVar4 = *piVar10; iVar8 = piVar10[-1]; piVar1 = piVar10; if (iVar8 <= iVar4) break; do { piVar6 = piVar1 + -1; *piVar1 = iVar8; iVar8 = piVar1[-2]; piVar1 = piVar6; } while (iVar4 < iVar8); piVar10 = piVar10 + 1; *piVar6 = iVar4; if ((int *)uVar3 == piVar10) goto LAB_0010185c; } *piVar10 = iVar4; } } } LAB_0010185c: iVar4 = *(int *)(uVar2 + (long)(param_1 + -1) * 4); if ((int *)uVar2 != (int *)0x0) { operator_delete((void *)uVar2,(long)local_48 - uVar2); } operator_delete(__s,12000); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar4; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
487
func0
#include <iostream> #include <vector> #include <assert.h> #include <algorithm> const int MAX = 3000;
int func0(int n) { std::vector<int> primes(MAX, 0); std::vector<int> result; for (int i = 2; i < MAX; ++i) { if (primes[i] == 0) { primes[i] = 1; int j = i * 2; while (j < MAX) { primes[j] -= 1; if (primes[j] + 3 == 0) { result.push_back(j); } j += i; } } } std::sort(result.begin(), result.end()); return result[n - 1]; }
int main() { assert(func0(1) == 30); assert(func0(50) == 273); assert(func0(1000) == 2664); return 0; }
O3
cpp
func0(int): endbr64 push %r15 xor %r15d,%r15d push %r14 push %r13 push %r12 push %rbp push %rbx mov $0x2,%ebx sub $0x48,%rsp mov %edi,0xc(%rsp) mov $0x2ee0,%edi lea 0x1c(%rsp),%r13 mov %fs:0x28,%rax mov %rax,0x38(%rsp) xor %eax,%eax callq 1150 <_Znwm@plt> mov $0x2ee0,%edx xor %esi,%esi mov %rax,%rdi mov %rax,%rbp callq 1100 <memset@plt> pxor %xmm0,%xmm0 movq $0x0,0x30(%rsp) movaps %xmm0,0x20(%rsp) jmp 1409 <_Z5func0i+0x79> nopl 0x0(%rax,%rax,1) add $0x1,%rbx cmp $0xbb8,%rbx je 148b <_Z5func0i+0xfb> mov 0x0(%rbp,%rbx,4),%eax mov %ebx,%r12d test %eax,%eax jne 13f8 <_Z5func0i+0x68> lea (%rbx,%rbx,1),%eax movl $0x1,0x0(%rbp,%rbx,4) mov %eax,0x1c(%rsp) cmp $0xbb7,%eax jbe 143e <_Z5func0i+0xae> jmp 13f8 <_Z5func0i+0x68> nopl 0x0(%rax) add %r12d,%eax mov %eax,0x1c(%rsp) cmp $0xbb7,%eax jg 13f8 <_Z5func0i+0x68> movslq %eax,%rdx lea 0x0(%rbp,%rdx,4),%rcx mov (%rcx),%edi lea -0x1(%rdi),%edx mov %edx,(%rcx) cmp $0xfffffffd,%edx jne 1430 <_Z5func0i+0xa0> cmp %r15,0x30(%rsp) je 1470 <_Z5func0i+0xe0> mov %eax,(%r15) add $0x4,%r15 mov 0x1c(%rsp),%eax mov %r15,0x28(%rsp) jmp 1430 <_Z5func0i+0xa0> nopl 0x0(%rax,%rax,1) lea 0x20(%rsp),%rdi mov %r13,%rdx mov %r15,%rsi callq 1660 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x1c(%rsp),%eax mov 0x28(%rsp),%r15 jmp 1430 <_Z5func0i+0xa0> mov 0x20(%rsp),%r14 cmp %r15,%r14 je 1581 <_Z5func0i+0x1f1> mov %r15,%r12 mov $0x3f,%edx mov %r15,%rsi mov %r14,%rdi sub %r14,%r12 lea 0x4(%r14),%rbx mov %r12,%rax sar $0x2,%rax bsr %rax,%rax xor $0x3f,%rax sub %eax,%edx movslq %edx,%rdx add %rdx,%rdx callq 18f0 <_ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1_> cmp $0x40,%r12 jle 15c9 <_Z5func0i+0x239> lea 0x40(%r14),%r13 jmp 1502 <_Z5func0i+0x172> cmp %rbx,%r14 je 14f6 <_Z5func0i+0x166> mov %rbx,%rdx mov $0x4,%eax mov %r14,%rsi sub %r14,%rdx lea (%r14,%rax,1),%rdi callq 1180 <memmove@plt> add $0x4,%rbx mov %r12d,(%r14) cmp %r13,%rbx je 153e <_Z5func0i+0x1ae> mov (%rbx),%r12d mov %rbx,%rsi cmp (%r14),%r12d jl 14da <_Z5func0i+0x14a> mov -0x4(%rbx),%edx lea -0x4(%rbx),%rax cmp %edx,%r12d jge 1532 <_Z5func0i+0x1a2> nopl 0x0(%rax) mov %edx,0x4(%rax) mov %rax,%rsi mov -0x4(%rax),%edx sub $0x4,%rax cmp %edx,%r12d jl 1520 <_Z5func0i+0x190> add $0x4,%rbx mov %r12d,(%rsi) cmp %r13,%rbx jne 1502 <_Z5func0i+0x172> cmp %r13,%r15 je 157c <_Z5func0i+0x1ec> mov 0x0(%r13),%ecx mov -0x4(%r13),%edx lea -0x4(%r13),%rax cmp %edx,%ecx jge 1637 <_Z5func0i+0x2a7> nopw 0x0(%rax,%rax,1) mov %edx,0x4(%rax) mov %rax,%rsi mov -0x4(%rax),%edx sub $0x4,%rax cmp %edx,%ecx jl 1560 <_Z5func0i+0x1d0> add $0x4,%r13 mov %ecx,(%rsi) cmp %r13,%r15 jne 1543 <_Z5func0i+0x1b3> mov 0x20(%rsp),%r15 mov 0xc(%rsp),%eax sub $0x1,%eax cltq mov (%r15,%rax,4),%r12d test %r15,%r15 je 159b <_Z5func0i+0x20b> mov %r15,%rdi callq 1140 <_ZdlPv@plt> mov %rbp,%rdi callq 1140 <_ZdlPv@plt> mov 0x38(%rsp),%rax xor %fs:0x28,%rax jne 164e <_Z5func0i+0x2be> add $0x48,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov $0x4,%r12d cmp %rbx,%r15 jne 1607 <_Z5func0i+0x277> jmp 157c <_Z5func0i+0x1ec> nopw %cs:0x0(%rax,%rax,1) cmp %r14,%rbx je 15f7 <_Z5func0i+0x267> mov %rbx,%rdx lea (%r14,%r12,1),%rdi mov %r14,%rsi sub %r14,%rdx callq 1180 <memmove@plt> mov %r13d,(%r14) add $0x4,%rbx cmp %rbx,%r15 je 157c <_Z5func0i+0x1ec> mov (%rbx),%r13d mov %rbx,%rsi cmp (%r14),%r13d jl 15e0 <_Z5func0i+0x250> mov -0x4(%rbx),%edx lea -0x4(%rbx),%rax cmp %edx,%r13d jge 1632 <_Z5func0i+0x2a2> xchg %ax,%ax mov %edx,0x4(%rax) mov %rax,%rsi mov -0x4(%rax),%edx sub $0x4,%rax cmp %edx,%r13d jl 1620 <_Z5func0i+0x290> mov %r13d,(%rsi) jmp 15fa <_Z5func0i+0x26a> mov %r13,%rsi add $0x4,%r13 mov %ecx,(%rsi) cmp %r13,%r15 jne 1543 <_Z5func0i+0x1b3> jmpq 157c <_Z5func0i+0x1ec> callq 1160 <__stack_chk_fail@plt> endbr64 mov %rax,%r12 jmpq 11a0 <_Z5func0i.cold>
_Z5func0i: endbr64 push r15 push r14 push r13 push r12 mov r12d, 2 push rbp push rbx sub rsp, 68h mov [rsp+98h+var_8C], edi mov edi, 2EE0h; unsigned __int64 mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax call __Znwm; operator new(ulong) mov edx, 2EE0h; n xor esi, esi; c lea rbx, [rax+2EE0h] mov rdi, rax; s mov [rsp+98h+var_78], rax mov r13, rax mov [rsp+98h+var_68], rbx call _memset pxor xmm0, xmm0 lea rax, [rsp+98h+var_7C] mov [rsp+98h+var_70], rbx mov [rsp+98h+var_48], 0 mov [rsp+98h+var_98], rax movaps xmmword ptr [rsp+98h+src], xmm0 jmp short loc_1671 loc_1660: add r12, 1 cmp r12, 0BB8h jz loc_16F3 loc_1671: mov eax, [r13+r12*4+0] test eax, eax jnz short loc_1660 lea eax, [r12+r12] mov r14d, r12d lea rbx, [r12+r12] mov dword ptr [r13+r12*4+0], 1 mov [rsp+98h+var_7C], eax cmp eax, 0BB7h jbe short loc_16B2 jmp short loc_1660 loc_16A0: add ebp, r14d add rbx, r12 mov [rsp+98h+var_7C], ebp cmp ebx, 0BB7h jg short loc_1660 loc_16B2: mov eax, [r13+rbx*4+0] mov ebp, ebx sub eax, 1 mov [r13+rbx*4+0], eax cmp eax, 0FFFFFFFDh jnz short loc_16A0 mov rsi, [rsp+98h+src+8] cmp rsi, [rsp+98h+var_48] jz short loc_16E0 mov [rsi], ebx add rsi, 4 mov [rsp+98h+src+8], rsi jmp short loc_16A0 loc_16E0: lea r15, [rsp+98h+src] mov rdx, [rsp+98h+var_98] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) jmp short loc_16A0 loc_16F3: mov r12, [rsp+98h+src+8] mov rbx, [rsp+98h+src] cmp rbx, r12 jz loc_1838 mov rbp, r12 lea r15, [rbx+4] sub rbp, rbx mov rdx, rbp sar rdx, 2 jz loc_1850 bsr rdx, rdx mov rsi, r12 mov rdi, rbx movsxd rdx, edx add rdx, rdx call _ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1__isra_0; std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter) [clone] cmp rbp, 40h ; '@' jle loc_1862 lea r14, [rbx+40h] loc_1740: mov ebp, [r15] mov eax, [rbx] mov rsi, r15 cmp ebp, eax jge loc_180A mov rdx, r15 sub rdx, rbx; n cmp rdx, 4 jle loc_18EE mov edi, 4 mov rsi, rbx; src sub rdi, rdx add rdi, r15; dest call _memmove loc_1773: mov [rbx], ebp loc_1775: add r15, 4 cmp r14, r15 jnz short loc_1740 cmp r12, r14 jz short loc_17BC nop dword ptr [rax+rax+00h] loc_1788: mov ecx, [r14] mov edx, [r14-4] lea rax, [r14-4] cmp ecx, edx jge loc_18D7 nop dword ptr [rax+rax+00h] loc_17A0: mov [rax+4], edx mov rsi, rax mov edx, [rax-4] sub rax, 4 cmp ecx, edx jl short loc_17A0 add r14, 4 mov [rsi], ecx cmp r12, r14 jnz short loc_1788 loc_17BC: mov eax, [rsp+98h+var_8C] sub eax, 1 cdqe mov ebp, [rbx+rax*4] loc_17C8: mov rsi, [rsp+98h+var_48] mov rdi, rbx; void * sub rsi, rbx; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_17D8: mov esi, 2EE0h; unsigned __int64 mov rdi, r13; void * call __ZdlPvm; operator delete(void *,ulong) mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz loc_1903 add rsp, 68h mov eax, ebp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_180A: mov edx, [r15-4] lea rax, [r15-4] cmp ebp, edx jge short loc_1831 nop word ptr [rax+rax+00000000h] loc_1820: mov [rax+4], edx mov rsi, rax mov edx, [rax-4] sub rax, 4 cmp ebp, edx jl short loc_1820 loc_1831: mov [rsi], ebp jmp loc_1775 loc_1838: mov eax, [rsp+98h+var_8C] sub eax, 1 cdqe mov ebp, [rbx+rax*4] test rbx, rbx jz short loc_17D8 jmp loc_17C8 loc_1850: mov rdx, 0FFFFFFFFFFFFFFFEh mov rsi, r12 mov rdi, rbx call _ZSt16__introsort_loopIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEElNS0_5__ops15_Iter_less_iterEEvT_S9_T0_T1__isra_0; std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter) [clone] loc_1862: cmp r12, r15 jz short loc_1838 mov r14, r15 mov ebp, 4 jmp short loc_189E loc_1871: mov rdx, r14 sub rdx, rbx; n cmp rdx, 4 jle short loc_18FC mov rdi, rbp mov rsi, rbx; src sub rdi, rdx add rdi, r14; dest call _memmove loc_188E: mov [rbx], r15d loc_1891: add r14, 4 cmp r14, r12 jz loc_17BC loc_189E: mov r15d, [r14] mov eax, [rbx] mov rcx, r14 cmp r15d, eax jl short loc_1871 mov edx, [r14-4] lea rax, [r14-4] cmp r15d, edx jge short loc_18D2 nop dword ptr [rax+rax+00000000h] loc_18C0: mov [rax+4], edx mov rcx, rax mov edx, [rax-4] sub rax, 4 cmp r15d, edx jl short loc_18C0 loc_18D2: mov [rcx], r15d jmp short loc_1891 loc_18D7: mov rsi, r14 add r14, 4 mov [rsi], ecx cmp r12, r14 jnz loc_1788 jmp loc_17BC loc_18EE: jnz loc_1773 mov [r15], eax jmp loc_1773 loc_18FC: jnz short loc_188E mov [r14], eax jmp short loc_188E loc_1903: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0i_cold; func0(int) [clone]
long long func0(int a1) { long long v1; // r12 char *v2; // rax char *v3; // rbx _DWORD *v4; // r13 long long v5; // rbx int v6; // ebp int v7; // eax char *v8; // rsi int *v9; // r12 int *v10; // rbx int *v11; // r15 signed long long v12; // rbp unsigned long long v13; // rdx int *v14; // r14 int v15; // ebp int *v16; // rsi int v17; // ecx int v18; // edx int *v19; // rax int *v20; // rsi unsigned int v21; // ebp int v23; // edx int *i; // rax int *v25; // r14 int v26; // r15d int *v27; // rcx int v28; // edx int *j; // rax int *v30; // rsi int v31; // [rsp+1Ch] [rbp-7Ch] BYREF char *v32; // [rsp+20h] [rbp-78h] char *v33; // [rsp+28h] [rbp-70h] char *v34; // [rsp+30h] [rbp-68h] void *src[2]; // [rsp+40h] [rbp-58h] BYREF _BYTE *v36; // [rsp+50h] [rbp-48h] unsigned long long v37; // [rsp+58h] [rbp-40h] v1 = 2LL; v37 = __readfsqword(0x28u); v2 = (char *)operator new(0x2EE0uLL); v3 = v2 + 12000; v32 = v2; v4 = v2; v34 = v2 + 12000; memset(v2, 0, 0x2EE0uLL); v33 = v3; v36 = 0LL; *(_OWORD *)src = 0LL; do { if ( !v4[v1] ) { v5 = 2 * v1; v4[v1] = 1; v31 = 2 * v1; if ( (unsigned int)(2 * v1) <= 0xBB7 ) { do { v6 = v5; v7 = v4[v5] - 1; v4[v5] = v7; if ( v7 == -3 ) { v8 = (char *)src[1]; if ( src[1] == v36 ) { std::vector<int>::_M_realloc_insert<int const&>(src, src[1], &v31); } else { *(_DWORD *)src[1] = v5; src[1] = v8 + 4; } } v5 += v1; v31 = v1 + v6; } while ( (int)v5 <= 2999 ); } } ++v1; } while ( v1 != 3000 ); v9 = (int *)src[1]; v10 = (int *)src[0]; if ( src[0] == src[1] ) goto LABEL_30; v11 = (int *)((char *)src[0] + 4); v12 = (char *)src[1] - (char *)src[0]; if ( ((char *)src[1] - (char *)src[0]) >> 2 ) { _BitScanReverse64(&v13, ((char *)src[1] - (char *)src[0]) >> 2); std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>( src[0], src[1], 2LL * (int)v13); if ( v12 > 64 ) { v14 = v10 + 16; do { v15 = *v11; v16 = v11; if ( *v11 >= *v10 ) { v23 = *(v11 - 1); for ( i = v11 - 1; v15 < v23; --i ) { i[1] = v23; v16 = i; v23 = *(i - 1); } *v16 = v15; } else { if ( (char *)v11 - (char *)v10 <= 4 ) { if ( (char *)v11 - (char *)v10 == 4 ) *v11 = *v10; } else { memmove(v10 + 1, v10, (char *)v11 - (char *)v10); } *v10 = v15; } ++v11; } while ( v14 != v11 ); for ( ; v9 != v14; *v20 = v17 ) { while ( 1 ) { v17 = *v14; v18 = *(v14 - 1); v19 = v14 - 1; if ( *v14 < v18 ) break; v30 = v14++; *v30 = v17; if ( v9 == v14 ) goto LABEL_24; } do { v19[1] = v18; v20 = v19; v18 = *--v19; } while ( v17 < v18 ); ++v14; } goto LABEL_24; } } else { std::__introsort_loop<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,long,__gnu_cxx::__ops::_Iter_less_iter>( src[0], src[1], -2LL); } if ( v9 == v11 ) { LABEL_30: v21 = v10[a1 - 1]; if ( !v10 ) goto LABEL_26; goto LABEL_25; } v25 = v10 + 1; do { v26 = *v25; v27 = v25; if ( *v25 < *v10 ) { if ( (char *)v25 - (char *)v10 <= 4 ) { if ( (char *)v25 - (char *)v10 == 4 ) *v25 = *v10; } else { memmove(v10 + 1, v10, (char *)v25 - (char *)v10); } *v10 = v26; } else { v28 = *(v25 - 1); for ( j = v25 - 1; v26 < v28; --j ) { j[1] = v28; v27 = j; v28 = *(j - 1); } *v27 = v26; } ++v25; } while ( v25 != v9 ); LABEL_24: v21 = v10[a1 - 1]; LABEL_25: operator delete(v10, v36 - (_BYTE *)v10); LABEL_26: operator delete(v4, 0x2EE0uLL); return v21; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 MOV R12D,0x2 PUSH RBP PUSH RBX SUB RSP,0x68 MOV dword ptr [RSP + 0xc],EDI MOV EDI,0x2ee0 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX LAB_00101611: CALL 0x00101110 MOV EDX,0x2ee0 XOR ESI,ESI LEA RBX,[RAX + 0x2ee0] MOV RDI,RAX MOV qword ptr [RSP + 0x20],RAX MOV R13,RAX MOV qword ptr [RSP + 0x30],RBX CALL 0x001010e0 PXOR XMM0,XMM0 LEA RAX,[RSP + 0x1c] MOV qword ptr [RSP + 0x28],RBX MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP],RAX MOVAPS xmmword ptr [RSP + 0x40],XMM0 JMP 0x00101671 LAB_00101660: ADD R12,0x1 CMP R12,0xbb8 JZ 0x001016f3 LAB_00101671: MOV EAX,dword ptr [R13 + R12*0x4] TEST EAX,EAX JNZ 0x00101660 LEA EAX,[R12 + R12*0x1] MOV R14D,R12D LEA RBX,[R12 + R12*0x1] MOV dword ptr [R13 + R12*0x4],0x1 MOV dword ptr [RSP + 0x1c],EAX CMP EAX,0xbb7 JBE 0x001016b2 JMP 0x00101660 LAB_001016a0: ADD EBP,R14D ADD RBX,R12 MOV dword ptr [RSP + 0x1c],EBP CMP EBX,0xbb7 JG 0x00101660 LAB_001016b2: MOV EAX,dword ptr [R13 + RBX*0x4] MOV EBP,EBX SUB EAX,0x1 MOV dword ptr [R13 + RBX*0x4],EAX CMP EAX,-0x3 JNZ 0x001016a0 MOV RSI,qword ptr [RSP + 0x48] CMP RSI,qword ptr [RSP + 0x50] JZ 0x001016e0 MOV dword ptr [RSI],EBX ADD RSI,0x4 MOV qword ptr [RSP + 0x48],RSI JMP 0x001016a0 LAB_001016e0: LEA R15,[RSP + 0x40] MOV RDX,qword ptr [RSP] MOV RDI,R15 LAB_001016ec: CALL 0x00101950 JMP 0x001016a0 LAB_001016f3: MOV R12,qword ptr [RSP + 0x48] MOV RBX,qword ptr [RSP + 0x40] CMP RBX,R12 JZ 0x00101838 MOV RBP,R12 LEA R15,[RBX + 0x4] SUB RBP,RBX MOV RDX,RBP SAR RDX,0x2 JZ 0x00101850 BSR RDX,RDX MOV RSI,R12 MOV RDI,RBX MOVSXD RDX,EDX ADD RDX,RDX CALL 0x00101440 CMP RBP,0x40 JLE 0x00101862 LEA R14,[RBX + 0x40] LAB_00101740: MOV EBP,dword ptr [R15] MOV EAX,dword ptr [RBX] MOV RSI,R15 CMP EBP,EAX JGE 0x0010180a MOV RDX,R15 SUB RDX,RBX CMP RDX,0x4 JLE 0x001018ee MOV EDI,0x4 MOV RSI,RBX SUB RDI,RDX ADD RDI,R15 CALL 0x00101140 LAB_00101773: MOV dword ptr [RBX],EBP LAB_00101775: ADD R15,0x4 CMP R14,R15 JNZ 0x00101740 CMP R12,R14 JZ 0x001017bc NOP dword ptr [RAX + RAX*0x1] LAB_00101788: MOV ECX,dword ptr [R14] MOV EDX,dword ptr [R14 + -0x4] LEA RAX,[R14 + -0x4] CMP ECX,EDX JGE 0x001018d7 NOP dword ptr [RAX + RAX*0x1] LAB_001017a0: MOV dword ptr [RAX + 0x4],EDX MOV RSI,RAX MOV EDX,dword ptr [RAX + -0x4] SUB RAX,0x4 CMP ECX,EDX JL 0x001017a0 ADD R14,0x4 MOV dword ptr [RSI],ECX CMP R12,R14 JNZ 0x00101788 LAB_001017bc: MOV EAX,dword ptr [RSP + 0xc] SUB EAX,0x1 CDQE MOV EBP,dword ptr [RBX + RAX*0x4] LAB_001017c8: MOV RSI,qword ptr [RSP + 0x50] MOV RDI,RBX SUB RSI,RBX CALL 0x00101120 LAB_001017d8: MOV ESI,0x2ee0 MOV RDI,R13 CALL 0x00101120 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101903 ADD RSP,0x68 MOV EAX,EBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010180a: MOV EDX,dword ptr [R15 + -0x4] LEA RAX,[R15 + -0x4] CMP EBP,EDX JGE 0x00101831 NOP word ptr CS:[RAX + RAX*0x1] LAB_00101820: MOV dword ptr [RAX + 0x4],EDX MOV RSI,RAX MOV EDX,dword ptr [RAX + -0x4] SUB RAX,0x4 CMP EBP,EDX JL 0x00101820 LAB_00101831: MOV dword ptr [RSI],EBP JMP 0x00101775 LAB_00101838: MOV EAX,dword ptr [RSP + 0xc] SUB EAX,0x1 CDQE MOV EBP,dword ptr [RBX + RAX*0x4] TEST RBX,RBX JZ 0x001017d8 JMP 0x001017c8 LAB_00101850: MOV RDX,-0x2 MOV RSI,R12 MOV RDI,RBX CALL 0x00101440 LAB_00101862: CMP R12,R15 JZ 0x00101838 MOV R14,R15 MOV EBP,0x4 JMP 0x0010189e LAB_00101871: MOV RDX,R14 SUB RDX,RBX CMP RDX,0x4 JLE 0x001018fc MOV RDI,RBP MOV RSI,RBX SUB RDI,RDX ADD RDI,R14 CALL 0x00101140 LAB_0010188e: MOV dword ptr [RBX],R15D LAB_00101891: ADD R14,0x4 CMP R14,R12 JZ 0x001017bc LAB_0010189e: MOV R15D,dword ptr [R14] MOV EAX,dword ptr [RBX] MOV RCX,R14 CMP R15D,EAX JL 0x00101871 MOV EDX,dword ptr [R14 + -0x4] LEA RAX,[R14 + -0x4] CMP R15D,EDX JGE 0x001018d2 NOP dword ptr [RAX + RAX*0x1] LAB_001018c0: MOV dword ptr [RAX + 0x4],EDX MOV RCX,RAX MOV EDX,dword ptr [RAX + -0x4] SUB RAX,0x4 CMP R15D,EDX JL 0x001018c0 LAB_001018d2: MOV dword ptr [RCX],R15D JMP 0x00101891 LAB_001018d7: MOV RSI,R14 ADD R14,0x4 MOV dword ptr [RSI],ECX CMP R12,R14 JNZ 0x00101788 JMP 0x001017bc LAB_001018ee: JNZ 0x00101773 MOV dword ptr [R15],EAX JMP 0x00101773 LAB_001018fc: JNZ 0x0010188e MOV dword ptr [R14],EAX JMP 0x0010188e LAB_00101903: CALL 0x00101130
/* func0(int) */ int func0(int param_1,int param_2,int param_3,int param_4,int param_5, int param_6,int param_7,int param_8,int param_9,int param_10, int4 param_11,int8 param_12,int8 param_13) { int8 __src; int8 uVar1; int iVar2; void *__s; int *piVar3; int7 in_register_00000009; int8 uVar4; int iVar5; ulong uVar6; size_t sVar7; long lVar8; long lVar9; int *piVar10; int *piVar11; long in_FS_OFFSET; uint local_7c; void *local_78; long local_70; long local_68; int local_58 [16]; int *local_48; long local_40; uVar4 = CONCAT71(in_register_00000009,param_4); lVar9 = 2; local_40 = *(long *)(in_FS_OFFSET + 0x28); __s = operator_new(12000); local_78 = __s; local_68 = (long)__s + 12000; memset(__s,0,12000); local_48 = (int *)0x0; local_58 = (int [16])0x0; local_70 = (long)__s + 12000; do { if (*(int *)((long)__s + lVar9 * 4) == 0) { local_7c = (int)lVar9 * 2; lVar8 = lVar9 * 2; *(int4 *)((long)__s + lVar9 * 4) = 1; if (local_7c < 3000) { do { iVar2 = *(int *)((long)__s + lVar8 * 4) + -1; *(int *)((long)__s + lVar8 * 4) = iVar2; if (iVar2 == -3) { if ((int *)local_58._8_8_ == local_48) { /* try { // try from 001016ec to 001016f0 has its CatchHandler @ 00101908 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)local_58,local_58._8_4_,(int *)&local_7c ); } else { *(int *)local_58._8_8_ = (int)lVar8; local_58._8_8_ = (int *)(local_58._8_8_ + 4); } } local_7c = (int)lVar8 + (int)lVar9; lVar8 = lVar8 + lVar9; } while ((int)lVar8 < 3000); } } lVar9 = lVar9 + 1; } while (lVar9 != 3000); uVar1 = local_58._8_8_; __src = local_58._0_8_; if (local_58._0_8_ == local_58._8_8_) { LAB_00101838: iVar2 = *(int *)(__src + (long)(param_1 + -1) * 4); if ((int *)__src == (int *)0x0) goto LAB_001017d8; } else { piVar11 = (int *)(local_58._0_8_ + 4); lVar9 = local_58._8_8_ - local_58._0_8_; uVar6 = lVar9 >> 2; if (uVar6 == 0) { std:: __introsort_loop<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,long,__ops::_Iter_less_iter> (local_58._0_4_,local_58._8_4_,-2,(_Iter_less_iter)uVar4); LAB_00101862: if ((int *)uVar1 == piVar11) goto LAB_00101838; do { iVar2 = *piVar11; if (iVar2 < *(int *)__src) { sVar7 = (long)piVar11 - __src; if ((long)sVar7 < 5) { if (sVar7 == 4) { *piVar11 = *(int *)__src; } } else { memmove((void *)((4 - sVar7) + (long)piVar11),(void *)__src,sVar7); } *(int *)__src = iVar2; } else { iVar5 = piVar11[-1]; piVar10 = piVar11; while (iVar2 < iVar5) { *piVar10 = iVar5; iVar5 = piVar10[-2]; piVar10 = piVar10 + -1; } *piVar10 = iVar2; } piVar11 = piVar11 + 1; } while (piVar11 != (int *)uVar1); } else { lVar8 = 0x3f; if (uVar6 != 0) { for (; uVar6 >> lVar8 == 0; lVar8 = lVar8 + -1) { } } std:: __introsort_loop<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,long,__ops::_Iter_less_iter> (local_58._0_4_,local_58._8_4_,(long)(int)lVar8 * 2,(_Iter_less_iter)uVar4); if (lVar9 < 0x41) goto LAB_00101862; piVar10 = (int *)(__src + 0x40); do { iVar2 = *piVar11; if (iVar2 < *(int *)__src) { sVar7 = (long)piVar11 - __src; if ((long)sVar7 < 5) { if (sVar7 == 4) { *piVar11 = *(int *)__src; } } else { memmove((void *)((4 - sVar7) + (long)piVar11),(void *)__src,sVar7); } *(int *)__src = iVar2; } else { iVar5 = piVar11[-1]; piVar3 = piVar11; while (iVar2 < iVar5) { *piVar3 = iVar5; iVar5 = piVar3[-2]; piVar3 = piVar3 + -1; } *piVar3 = iVar2; } piVar11 = piVar11 + 1; } while (piVar10 != piVar11); for (; (int *)uVar1 != piVar10; piVar10 = piVar10 + 1) { while( true ) { iVar2 = *piVar10; iVar5 = piVar10[-1]; piVar11 = piVar10; if (iVar5 <= iVar2) break; do { piVar3 = piVar11 + -1; *piVar11 = iVar5; iVar5 = piVar11[-2]; piVar11 = piVar3; } while (iVar2 < iVar5); piVar10 = piVar10 + 1; *piVar3 = iVar2; if ((int *)uVar1 == piVar10) goto LAB_001017bc; } *piVar10 = iVar2; } } LAB_001017bc: iVar2 = *(int *)(__src + (long)(param_1 + -1) * 4); } operator_delete((void *)__src,(long)local_48 - __src); LAB_001017d8: operator_delete(__s,12000); if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar2; }
488
func0
#include <iostream> #include <set> #include <assert.h>
int func0(int limit) { if (limit < 1) { throw std::invalid_argument("Input must be bigger than 0!"); } std::set<int> amicables; for (int num = 2; num <= limit; num++) { if (amicables.find(num) != amicables.end()) { continue; } int sum_fact = 0; for (int fact = 1; fact < num; fact++) { if (num % fact == 0) { sum_fact += fact; } } int sum_fact2 = 0; for (int fact = 1; fact < sum_fact; fact++) { if (sum_fact % fact == 0) { sum_fact2 += fact; } } if (num == sum_fact2 && num != sum_fact) { amicables.insert(num); amicables.insert(sum_fact2); } } int total_sum = 0; for (int am : amicables) { total_sum += am; } return total_sum; }
int main() { assert(func0(999) == 504); assert(func0(9999) == 31626); assert(func0(99) == 0); return 0; }
O0
cpp
func0(int): endbr64 push %rbp mov %rsp,%rbp push %r12 push %rbx sub $0x90,%rsp mov %edi,-0x94(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax cmpl $0x0,-0x94(%rbp) jg 136e <_Z5func0i+0x65> mov $0x10,%edi callq 1150 <__cxa_allocate_exception@plt> mov %rax,%rbx lea 0x1cbb(%rip),%rsi mov %rbx,%rdi callq 1210 <_ZNSt16invalid_argumentC1EPKc@plt> mov 0x4c74(%rip),%rax mov %rax,%rdx lea 0x49aa(%rip),%rsi mov %rbx,%rdi callq 11f0 <__cxa_throw@plt> lea -0x50(%rbp),%rax mov %rax,%rdi callq 1734 <_ZNSt3setIiSt4lessIiESaIiEEC1Ev> movl $0x2,-0x84(%rbp) mov -0x84(%rbp),%eax cmp %eax,-0x94(%rbp) jl 149c <_Z5func0i+0x193> lea -0x50(%rbp),%rax mov %rax,%rdi callq 1876 <_ZNKSt3setIiSt4lessIiESaIiEE3endEv> mov %rax,-0x60(%rbp) lea -0x84(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 180e <_ZNSt3setIiSt4lessIiESaIiEE4findERKi> mov %rax,-0x68(%rbp) lea -0x60(%rbp),%rdx lea -0x68(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1894 <_ZStneRKSt23_Rb_tree_const_iteratorIiES2_> test %al,%al jne 1487 <_Z5func0i+0x17e> movl $0x0,-0x7c(%rbp) movl $0x1,-0x78(%rbp) mov -0x84(%rbp),%eax cmp %eax,-0x78(%rbp) jge 1410 <_Z5func0i+0x107> mov -0x84(%rbp),%eax cltd idivl -0x78(%rbp) mov %edx,%eax test %eax,%eax jne 140a <_Z5func0i+0x101> mov -0x78(%rbp),%eax add %eax,-0x7c(%rbp) addl $0x1,-0x78(%rbp) jmp 13e9 <_Z5func0i+0xe0> movl $0x0,-0x80(%rbp) movl $0x1,-0x74(%rbp) mov -0x74(%rbp),%eax cmp -0x7c(%rbp),%eax jge 1444 <_Z5func0i+0x13b> mov -0x7c(%rbp),%eax cltd idivl -0x74(%rbp) mov %edx,%eax test %eax,%eax jne 143e <_Z5func0i+0x135> mov -0x80(%rbp),%edx mov -0x74(%rbp),%eax add %edx,%eax mov %eax,-0x80(%rbp) addl $0x1,-0x74(%rbp) jmp 141e <_Z5func0i+0x115> mov -0x84(%rbp),%edx mov -0x80(%rbp),%eax cmp %eax,%edx jne 1488 <_Z5func0i+0x17f> mov -0x84(%rbp),%eax cmp %eax,-0x7c(%rbp) je 1488 <_Z5func0i+0x17f> lea -0x84(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 18ba <_ZNSt3setIiSt4lessIiESaIiEE6insertERKi> lea -0x80(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 18ba <_ZNSt3setIiSt4lessIiESaIiEE6insertERKi> jmp 1488 <_Z5func0i+0x17f> mov -0x84(%rbp),%eax add $0x1,%eax mov %eax,-0x84(%rbp) jmpq 1384 <_Z5func0i+0x7b> movl $0x0,-0x70(%rbp) lea -0x50(%rbp),%rax mov %rax,-0x58(%rbp) mov -0x58(%rbp),%rax mov %rax,%rdi callq 1932 <_ZNKSt3setIiSt4lessIiESaIiEE5beginEv> mov %rax,-0x68(%rbp) mov -0x58(%rbp),%rax mov %rax,%rdi callq 1876 <_ZNKSt3setIiSt4lessIiESaIiEE3endEv> mov %rax,-0x60(%rbp) lea -0x60(%rbp),%rdx lea -0x68(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1894 <_ZStneRKSt23_Rb_tree_const_iteratorIiES2_> test %al,%al je 1507 <_Z5func0i+0x1fe> lea -0x68(%rbp),%rax mov %rax,%rdi callq 197c <_ZNKSt23_Rb_tree_const_iteratorIiEdeEv> mov (%rax),%eax mov %eax,-0x6c(%rbp) mov -0x6c(%rbp),%eax add %eax,-0x70(%rbp) lea -0x68(%rbp),%rax mov %rax,%rdi callq 1950 <_ZNSt23_Rb_tree_const_iteratorIiEppEv> jmp 14cb <_Z5func0i+0x1c2> mov -0x70(%rbp),%ebx lea -0x50(%rbp),%rax mov %rax,%rdi callq 1754 <_ZNSt3setIiSt4lessIiESaIiEED1Ev> mov %ebx,%eax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 1566 <_Z5func0i+0x25d> jmp 1561 <_Z5func0i+0x258> endbr64 mov %rax,%r12 mov %rbx,%rdi callq 1170 <__cxa_free_exception@plt> mov %r12,%rax mov %rax,%rdi callq 1200 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea -0x50(%rbp),%rax mov %rax,%rdi callq 1754 <_ZNSt3setIiSt4lessIiESaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1200 <_Unwind_Resume@plt> callq 11c0 <__stack_chk_fail@plt> add $0x90,%rsp pop %rbx pop %r12 pop %rbp retq
_Z5func0i: endbr64 push rbp mov rbp, rsp push r12 push rbx add rsp, 0FFFFFFFFFFFFFF80h mov [rbp+var_84], edi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax cmp [rbp+var_84], 0 jg short loc_1365 mov edi, 10h; thrown_size call ___cxa_allocate_exception mov rbx, rax lea rax, aInputMustBeBig; "Input must be bigger than 0!" mov rsi, rax; char * mov rdi, rbx; this call __ZNSt16invalid_argumentC1EPKc; std::invalid_argument::invalid_argument(char const*) mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_1349 call ___stack_chk_fail loc_1349: mov rax, cs:_ZNSt16invalid_argumentD1Ev_ptr mov rdx, rax; void (*)(void *) lea rax, _ZTISt16invalid_argument@GLIBCXX_3_4 mov rsi, rax; lptinfo mov rdi, rbx; void * call ___cxa_throw loc_1365: lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEEC2Ev; std::set<int>::set(void) mov [rbp+var_80], 2 jmp loc_1466 loc_137D: lea rax, [rbp+var_50] mov rdi, rax call _ZNKSt3setIiSt4lessIiESaIiEE3endEv; std::set<int>::end(void) mov [rbp+var_60], rax lea rdx, [rbp+var_80] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEE4findERKi; std::set<int>::find(int const&) mov [rbp+var_68], rax lea rdx, [rbp+var_60] lea rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZStneRKSt23_Rb_tree_const_iteratorIiES2_; std::operator!=(std::_Rb_tree_const_iterator<int> const&,std::_Rb_tree_const_iterator<int> const&) test al, al jnz loc_145C mov [rbp+var_7C], 0 mov [rbp+var_78], 1 jmp short loc_13E6 loc_13CF: mov eax, [rbp+var_80] cdq idiv [rbp+var_78] mov eax, edx test eax, eax jnz short loc_13E2 mov eax, [rbp+var_78] add [rbp+var_7C], eax loc_13E2: add [rbp+var_78], 1 loc_13E6: mov eax, [rbp+var_80] cmp [rbp+var_78], eax jl short loc_13CF mov dword ptr [rbp+var_60], 0 mov [rbp+var_74], 1 jmp short loc_141A loc_13FE: mov eax, [rbp+var_7C] cdq idiv [rbp+var_74] mov eax, edx test eax, eax jnz short loc_1416 mov edx, dword ptr [rbp+var_60] mov eax, [rbp+var_74] add eax, edx mov dword ptr [rbp+var_60], eax loc_1416: add [rbp+var_74], 1 loc_141A: mov eax, [rbp+var_74] cmp eax, [rbp+var_7C] jl short loc_13FE mov edx, [rbp+var_80] mov eax, dword ptr [rbp+var_60] cmp edx, eax jnz short loc_145D mov eax, [rbp+var_80] cmp [rbp+var_7C], eax jz short loc_145D lea rdx, [rbp+var_80] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEE6insertERKi; std::set<int>::insert(int const&) lea rdx, [rbp+var_60] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEE6insertERKi; std::set<int>::insert(int const&) jmp short loc_145D loc_145C: nop loc_145D: mov eax, [rbp+var_80] add eax, 1 mov [rbp+var_80], eax loc_1466: mov eax, [rbp+var_80] cmp [rbp+var_84], eax jge loc_137D mov [rbp+var_70], 0 lea rax, [rbp+var_50] mov [rbp+var_58], rax mov rax, [rbp+var_58] mov rdi, rax call _ZNKSt3setIiSt4lessIiESaIiEE5beginEv; std::set<int>::begin(void) mov [rbp+var_68], rax mov rax, [rbp+var_58] mov rdi, rax call _ZNKSt3setIiSt4lessIiESaIiEE3endEv; std::set<int>::end(void) mov [rbp+var_60], rax jmp short loc_14C9 loc_14A6: lea rax, [rbp+var_68] mov rdi, rax call _ZNKSt23_Rb_tree_const_iteratorIiEdeEv; std::_Rb_tree_const_iterator<int>::operator*(void) mov eax, [rax] mov [rbp+var_6C], eax mov eax, [rbp+var_6C] add [rbp+var_70], eax lea rax, [rbp+var_68] mov rdi, rax call _ZNSt23_Rb_tree_const_iteratorIiEppEv; std::_Rb_tree_const_iterator<int>::operator++(void) loc_14C9: lea rdx, [rbp+var_60] lea rax, [rbp+var_68] mov rsi, rdx mov rdi, rax call _ZStneRKSt23_Rb_tree_const_iteratorIiES2_; std::operator!=(std::_Rb_tree_const_iterator<int> const&,std::_Rb_tree_const_iterator<int> const&) test al, al jnz short loc_14A6 mov ebx, [rbp+var_70] lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEED2Ev; std::set<int>::~set() mov eax, ebx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1567 jmp short loc_1562 endbr64 mov r12, rax mov rdi, rbx; void * call ___cxa_free_exception mov rax, r12 mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1528 call ___stack_chk_fail loc_1528: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEED2Ev; std::set<int>::~set() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_155A call ___stack_chk_fail loc_155A: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_1562: call ___stack_chk_fail loc_1567: sub rsp, 0FFFFFFFFFFFFFF80h pop rbx pop r12 pop rbp retn
long long func0(int a1) { std::invalid_argument *exception; // rbx unsigned int v2; // ebx int i; // [rsp+10h] [rbp-80h] BYREF int v5; // [rsp+14h] [rbp-7Ch] int j; // [rsp+18h] [rbp-78h] int k; // [rsp+1Ch] [rbp-74h] unsigned int v8; // [rsp+20h] [rbp-70h] int v9; // [rsp+24h] [rbp-6Ch] long long v10; // [rsp+28h] [rbp-68h] BYREF long long v11; // [rsp+30h] [rbp-60h] BYREF _BYTE *v12; // [rsp+38h] [rbp-58h] _BYTE v13[56]; // [rsp+40h] [rbp-50h] BYREF unsigned long long v14; // [rsp+78h] [rbp-18h] v14 = __readfsqword(0x28u); if ( a1 <= 0 ) { exception = (std::invalid_argument *)__cxa_allocate_exception(0x10uLL); std::invalid_argument::invalid_argument(exception, "Input must be bigger than 0!"); __cxa_throw( exception, (struct type_info *)&`typeinfo for'std::invalid_argument, (void (*)(void *))&std::invalid_argument::~invalid_argument); } std::set<int>::set(v13); for ( i = 2; a1 >= i; ++i ) { v11 = std::set<int>::end(v13); v10 = std::set<int>::find(v13, &i); if ( !(unsigned __int8)std::operator!=(&v10, &v11) ) { v5 = 0; for ( j = 1; j < i; ++j ) { if ( !(i % j) ) v5 += j; } LODWORD(v11) = 0; for ( k = 1; k < v5; ++k ) { if ( !(v5 % k) ) LODWORD(v11) = v11 + k; } if ( i == (_DWORD)v11 && v5 != i ) { std::set<int>::insert(v13, &i); std::set<int>::insert(v13, &v11); } } } v8 = 0; v12 = v13; v10 = std::set<int>::begin(v13); v11 = std::set<int>::end(v12); while ( (unsigned __int8)std::operator!=(&v10, &v11) ) { v9 = *(_DWORD *)std::_Rb_tree_const_iterator<int>::operator*(&v10); v8 += v9; std::_Rb_tree_const_iterator<int>::operator++(&v10); } v2 = v8; std::set<int>::~set(v13); return v2; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R12 PUSH RBX ADD RSP,-0x80 MOV dword ptr [RBP + -0x84],EDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX CMP dword ptr [RBP + -0x84],0x0 JG 0x00101365 MOV EDI,0x10 CALL 0x00101140 MOV RBX,RAX LEA RAX,[0x103008] MOV RSI,RAX MOV RDI,RBX LAB_00101330: CALL 0x001011f0 MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x00101349 CALL 0x001011b0 LAB_00101349: MOV RAX,qword ptr [0x00104fe0] MOV RDX,RAX LEA RAX,[0x104d20] MOV RSI,RAX MOV RDI,RBX LAB_00101360: CALL 0x001011d0 LAB_00101365: LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x001016f0 MOV dword ptr [RBP + -0x80],0x2 JMP 0x00101466 LAB_0010137d: LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00101818 MOV qword ptr [RBP + -0x60],RAX LEA RDX,[RBP + -0x80] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX LAB_0010139b: CALL 0x001017b0 MOV qword ptr [RBP + -0x68],RAX LEA RDX,[RBP + -0x60] LEA RAX,[RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101836 TEST AL,AL JNZ 0x0010145c MOV dword ptr [RBP + -0x7c],0x0 MOV dword ptr [RBP + -0x78],0x1 JMP 0x001013e6 LAB_001013cf: MOV EAX,dword ptr [RBP + -0x80] CDQ IDIV dword ptr [RBP + -0x78] MOV EAX,EDX TEST EAX,EAX JNZ 0x001013e2 MOV EAX,dword ptr [RBP + -0x78] ADD dword ptr [RBP + -0x7c],EAX LAB_001013e2: ADD dword ptr [RBP + -0x78],0x1 LAB_001013e6: MOV EAX,dword ptr [RBP + -0x80] CMP dword ptr [RBP + -0x78],EAX JL 0x001013cf MOV dword ptr [RBP + -0x60],0x0 MOV dword ptr [RBP + -0x74],0x1 JMP 0x0010141a LAB_001013fe: MOV EAX,dword ptr [RBP + -0x7c] CDQ IDIV dword ptr [RBP + -0x74] MOV EAX,EDX TEST EAX,EAX JNZ 0x00101416 MOV EDX,dword ptr [RBP + -0x60] MOV EAX,dword ptr [RBP + -0x74] ADD EAX,EDX MOV dword ptr [RBP + -0x60],EAX LAB_00101416: ADD dword ptr [RBP + -0x74],0x1 LAB_0010141a: MOV EAX,dword ptr [RBP + -0x74] CMP EAX,dword ptr [RBP + -0x7c] JL 0x001013fe MOV EDX,dword ptr [RBP + -0x80] MOV EAX,dword ptr [RBP + -0x60] CMP EDX,EAX JNZ 0x0010145d MOV EAX,dword ptr [RBP + -0x80] CMP dword ptr [RBP + -0x7c],EAX JZ 0x0010145d LEA RDX,[RBP + -0x80] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010185c LEA RDX,[RBP + -0x60] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x0010185c JMP 0x0010145d LAB_0010145c: NOP LAB_0010145d: MOV EAX,dword ptr [RBP + -0x80] ADD EAX,0x1 MOV dword ptr [RBP + -0x80],EAX LAB_00101466: MOV EAX,dword ptr [RBP + -0x80] CMP dword ptr [RBP + -0x84],EAX JGE 0x0010137d MOV dword ptr [RBP + -0x70],0x0 LEA RAX,[RBP + -0x50] MOV qword ptr [RBP + -0x58],RAX MOV RAX,qword ptr [RBP + -0x58] MOV RDI,RAX CALL 0x001018d4 MOV qword ptr [RBP + -0x68],RAX MOV RAX,qword ptr [RBP + -0x58] MOV RDI,RAX CALL 0x00101818 MOV qword ptr [RBP + -0x60],RAX JMP 0x001014c9 LAB_001014a6: LEA RAX,[RBP + -0x68] MOV RDI,RAX CALL 0x0010191e MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x6c],EAX MOV EAX,dword ptr [RBP + -0x6c] ADD dword ptr [RBP + -0x70],EAX LEA RAX,[RBP + -0x68] MOV RDI,RAX CALL 0x001018f2 LAB_001014c9: LEA RDX,[RBP + -0x60] LEA RAX,[RBP + -0x68] MOV RSI,RDX MOV RDI,RAX CALL 0x00101836 TEST AL,AL JNZ 0x001014a6 MOV EBX,dword ptr [RBP + -0x70] LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00101710 MOV EAX,EBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x00101567 JMP 0x00101562 LAB_00101562: CALL 0x001011b0 LAB_00101567: SUB RSP,-0x80 POP RBX POP R12 POP RBP RET
/* func0(int) */ int func0(int param_1) { int iVar1; char cVar2; invalid_argument *this; int *piVar3; long in_FS_OFFSET; int local_88; int local_84; int local_80; int local_7c; int local_78; int local_74; int8 local_70; ulong local_68; set<int,std::less<int>,std::allocator<int>> *local_60; set<int,std::less<int>,std::allocator<int>> local_58 [56]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); if (param_1 < 1) { this = (invalid_argument *)__cxa_allocate_exception(0x10); /* try { // try from 00101330 to 00101334 has its CatchHandler @ 00101502 */ std::invalid_argument::invalid_argument(this,"Input must be bigger than 0!"); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ __cxa_throw(this,std::invalid_argument::typeinfo,PTR__invalid_argument_00104fe0); } std::set<int,std::less<int>,std::allocator<int>>::set(local_58); for (local_88 = 2; local_88 <= param_1; local_88 = local_88 + 1) { local_68 = std::set<int,std::less<int>,std::allocator<int>>::end(local_58); /* try { // try from 0010139b to 00101459 has its CatchHandler @ 00101530 */ local_70 = std::set<int,std::less<int>,std::allocator<int>>::find(local_58,&local_88); cVar2 = std::operator!=((_Rb_tree_const_iterator *)&local_70, (_Rb_tree_const_iterator *)&local_68); if (cVar2 == '\0') { local_84 = 0; for (local_80 = 1; local_80 < local_88; local_80 = local_80 + 1) { if (local_88 % local_80 == 0) { local_84 = local_84 + local_80; } } local_68 = local_68 & 0xffffffff00000000; for (local_7c = 1; local_7c < local_84; local_7c = local_7c + 1) { if (local_84 % local_7c == 0) { local_68 = CONCAT44(local_68._4_4_,local_7c + (int)local_68); } } if ((local_88 == (int)local_68) && (local_84 != local_88)) { std::set<int,std::less<int>,std::allocator<int>>::insert(local_58,&local_88); std::set<int,std::less<int>,std::allocator<int>>::insert(local_58,(int *)&local_68); } } } local_78 = 0; local_60 = local_58; local_70 = std::set<int,std::less<int>,std::allocator<int>>::begin(local_60); local_68 = std::set<int,std::less<int>,std::allocator<int>>::end(local_60); while( true ) { cVar2 = std::operator!=((_Rb_tree_const_iterator *)&local_70, (_Rb_tree_const_iterator *)&local_68); iVar1 = local_78; if (cVar2 == '\0') break; piVar3 = (int *)std::_Rb_tree_const_iterator<int>::operator* ((_Rb_tree_const_iterator<int> *)&local_70); local_74 = *piVar3; local_78 = local_78 + local_74; std::_Rb_tree_const_iterator<int>::operator++((_Rb_tree_const_iterator<int> *)&local_70); } std::set<int,std::less<int>,std::allocator<int>>::~set(local_58); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar1; }
489
func0
#include <iostream> #include <set> #include <assert.h>
int func0(int limit) { if (limit < 1) { throw std::invalid_argument("Input must be bigger than 0!"); } std::set<int> amicables; for (int num = 2; num <= limit; num++) { if (amicables.find(num) != amicables.end()) { continue; } int sum_fact = 0; for (int fact = 1; fact < num; fact++) { if (num % fact == 0) { sum_fact += fact; } } int sum_fact2 = 0; for (int fact = 1; fact < sum_fact; fact++) { if (sum_fact % fact == 0) { sum_fact2 += fact; } } if (num == sum_fact2 && num != sum_fact) { amicables.insert(num); amicables.insert(sum_fact2); } } int total_sum = 0; for (int am : amicables) { total_sum += am; } return total_sum; }
int main() { assert(func0(999) == 504); assert(func0(9999) == 31626); assert(func0(99) == 0); return 0; }
O1
cpp
func0(int): endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax test %edi,%edi jle 135f <_Z5func0i+0x76> mov %edi,%ebx movl $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) lea 0x18(%rsp),%rax mov %rax,0x28(%rsp) mov %rax,0x30(%rsp) movq $0x0,0x38(%rsp) movl $0x2,0x8(%rsp) cmp $0x1,%edi jle 142f <_Z5func0i+0x146> mov $0x2,%ecx mov $0x0,%r12d mov $0x0,%r13d mov $0x1,%ebp jmp 13ce <_Z5func0i+0xe5> mov $0x10,%edi callq 1130 <__cxa_allocate_exception@plt> mov %rax,%rbx lea 0xc91(%rip),%rsi mov %rax,%rdi callq 11f0 <_ZNSt16invalid_argumentC1EPKc@plt> mov 0x2c4e(%rip),%rdx lea 0x298f(%rip),%rsi mov %rbx,%rdi callq 11d0 <__cxa_throw@plt> mov 0x18(%rax),%rax test %rax,%rax je 13a8 <_Z5func0i+0xbf> cmp %ecx,0x20(%rax) jl 1391 <_Z5func0i+0xa8> mov %rax,%rdx mov 0x10(%rax),%rax jmp 1395 <_Z5func0i+0xac> lea 0x18(%rsp),%rax cmp %rax,%rdx je 14cf <_Z5func0i+0x1e6> cmp %ecx,0x20(%rdx) jg 14cf <_Z5func0i+0x1e6> mov 0x8(%rsp),%eax lea 0x1(%rax),%ecx mov %ecx,0x8(%rsp) cmp %ebx,%ecx jg 142f <_Z5func0i+0x146> mov 0x20(%rsp),%rax test %rax,%rax je 14cf <_Z5func0i+0x1e6> lea 0x18(%rsp),%rdx jmp 139a <_Z5func0i+0xb1> add %edi,%r8d mov %ebp,%r9d add $0x1,%edi cmp %edi,%esi je 13fb <_Z5func0i+0x112> mov %esi,%eax cltd idiv %edi test %edx,%edx jne 13e9 <_Z5func0i+0x100> jmp 13e3 <_Z5func0i+0xfa> test %r9b,%r9b je 13bf <_Z5func0i+0xd6> mov %r8d,0xc(%rsp) cmp %ecx,0xc(%rsp) jne 13bf <_Z5func0i+0xd6> cmp %ecx,%esi je 13bf <_Z5func0i+0xd6> lea 0x8(%rsp),%rsi lea 0x10(%rsp),%rdi callq 1622 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> lea 0xc(%rsp),%rsi lea 0x10(%rsp),%rdi callq 1622 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> jmp 13bf <_Z5func0i+0xd6> mov 0x28(%rsp),%rdi lea 0x18(%rsp),%rax cmp %rax,%rdi je 1486 <_Z5func0i+0x19d> mov $0x0,%ebx mov %rax,%rbp add 0x20(%rdi),%ebx callq 11b0 <_ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base@plt> mov %rax,%rdi cmp %rbp,%rax jne 1446 <_Z5func0i+0x15d> lea 0x10(%rsp),%rdi mov 0x20(%rsp),%rsi callq 15e8 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1511 <_Z5func0i+0x228> mov %ebx,%eax add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq mov $0x0,%ebx jmp 1456 <_Z5func0i+0x16d> endbr64 mov %rax,%rbp mov %rbx,%rdi callq 1150 <__cxa_free_exception@plt> mov %rbp,%rdi callq 11e0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea 0x10(%rsp),%rdi mov 0x20(%rsp),%rsi callq 15e8 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov %rbx,%rdi callq 11e0 <_Unwind_Resume@plt> mov %r12d,0xc(%rsp) mov %r12d,%esi jmpq 1405 <_Z5func0i+0x11c> cmp $0x1,%ecx jle 14c2 <_Z5func0i+0x1d9> mov $0x1,%edi mov %r12d,%esi mov %ecx,%eax cltd idiv %edi lea (%rsi,%rdi,1),%eax test %edx,%edx cmove %eax,%esi add $0x1,%edi cmp %ecx,%edi jne 14dc <_Z5func0i+0x1f3> mov %r12d,0xc(%rsp) cmp $0x1,%esi jle 13bf <_Z5func0i+0xd6> mov %r13d,%r9d mov $0x0,%r8d mov $0x1,%edi jmpq 13f0 <_Z5func0i+0x107> callq 11a0 <__stack_chk_fail@plt>
_Z5func0i: endbr64 push r14 push r13 push r12 push rbp push rbx sub rsp, 50h mov rax, fs:28h mov [rsp+78h+var_30], rax xor eax, eax test edi, edi jle short loc_1325 mov ebp, edi mov [rsp+78h+var_60], 0 mov [rsp+78h+var_58], 0 lea rax, [rsp+78h+var_60] mov [rsp+78h+var_50], rax mov [rsp+78h+var_48], rax mov [rsp+78h+var_40], 0 mov [rsp+78h+var_70], 2 cmp edi, 1 jle loc_140A mov ebx, 2 mov r13d, 0 mov r14d, 0 mov r12d, 1 jmp loc_13A5 loc_1325: mov edi, 10h; thrown_size call ___cxa_allocate_exception mov rbx, rax lea rsi, aInputMustBeBig; "Input must be bigger than 0!" mov rdi, rax; this call __ZNSt16invalid_argumentC1EPKc; std::invalid_argument::invalid_argument(char const*) mov rax, [rsp+78h+var_30] sub rax, fs:28h jz short loc_1356 call ___stack_chk_fail loc_1356: mov rdx, cs:_ZNSt16invalid_argumentD1Ev_ptr; void (*)(void *) lea rsi, _ZTISt16invalid_argument@GLIBCXX_3_4; lptinfo mov rdi, rbx; void * call ___cxa_throw loc_136C: mov rax, [rax+18h] loc_1370: test rax, rax jz short loc_1383 loc_1375: cmp [rax+20h], ebx jl short loc_136C mov rdx, rax mov rax, [rax+10h] jmp short loc_1370 loc_1383: lea rax, [rsp+78h+var_60] cmp rdx, rax jz loc_14DB cmp [rdx+20h], ebx jg loc_14DB loc_139A: add ebx, 1 mov [rsp+78h+var_70], ebx cmp ebx, ebp jg short loc_140A loc_13A5: mov rax, [rsp+78h+var_58] test rax, rax jz loc_14DB lea rdx, [rsp+78h+var_60] jmp short loc_1375 loc_13BA: add edi, esi mov r8d, r12d loc_13BF: add esi, 1 cmp ecx, esi jz short loc_13D1 loc_13C6: mov eax, ecx cdq idiv esi test edx, edx jnz short loc_13BF jmp short loc_13BA loc_13D1: test r8b, r8b jz short loc_13DA mov [rsp+78h+var_6C], edi loc_13DA: cmp [rsp+78h+var_6C], ebx jnz short loc_139A cmp esi, ebx jz short loc_139A lea rsi, [rsp+78h+var_70] lea rdi, [rsp+78h+var_68] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) jmp short loc_13F9 loc_13F5: mov esi, ecx jmp short loc_13DA loc_13F9: lea rsi, [rsp+78h+var_6C] lea rdi, [rsp+78h+var_68] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) jmp short loc_139A loc_140A: mov rdi, [rsp+78h+var_50] lea rax, [rsp+78h+var_60] cmp rdi, rax jz short loc_1463 mov ebx, 0 mov rbp, rax loc_1421: add ebx, [rdi+20h] call __ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base; std::_Rb_tree_increment(std::_Rb_tree_node_base const*) mov rdi, rax cmp rax, rbp jnz short loc_1421 loc_1431: lea rdi, [rsp+78h+var_68] mov rsi, [rsp+78h+var_58] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) mov rax, [rsp+78h+var_30] sub rax, fs:28h jnz loc_151C mov eax, ebx add rsp, 50h pop rbx pop rbp pop r12 pop r13 pop r14 retn loc_1463: mov ebx, 0 jmp short loc_1431 endbr64 mov rbp, rax mov rdi, rbx; void * call ___cxa_free_exception mov rax, [rsp+arg_40] sub rax, fs:28h jz short loc_148E call ___stack_chk_fail loc_148E: mov rdi, rbp; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rdi, [rsp+arg_8] mov rsi, [rsp+arg_18] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) mov rax, [rsp+arg_40] sub rax, fs:28h jz short loc_14C1 call ___stack_chk_fail loc_14C1: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_14C9: mov [rsp+78h+var_6C], 0 mov esi, 0 jmp loc_13DA loc_14DB: mov esi, 1 mov ecx, r13d cmp ebx, 1 jle short loc_14C9 loc_14E8: mov eax, ebx cdq idiv esi lea eax, [rcx+rsi] test edx, edx cmovz ecx, eax add esi, 1 cmp esi, ebx jnz short loc_14E8 mov [rsp+78h+var_6C], r13d cmp ecx, 1 jle loc_13F5 mov r8d, r14d mov edi, 0 mov esi, 1 jmp loc_13C6 loc_151C: call ___stack_chk_fail
long long func0(int a1) { int i; // ebx std::invalid_argument *exception; // rbx long long v4; // rax int *v5; // rdx int v6; // edi char v7; // r8 int j; // esi int *v9; // rdi unsigned int v10; // ebx int v12; // esi int v13; // ecx int v14; // [rsp+8h] [rbp-70h] BYREF int v15; // [rsp+Ch] [rbp-6Ch] BYREF _BYTE v16[8]; // [rsp+10h] [rbp-68h] BYREF int v17; // [rsp+18h] [rbp-60h] BYREF long long v18; // [rsp+20h] [rbp-58h] int *v19; // [rsp+28h] [rbp-50h] int *v20; // [rsp+30h] [rbp-48h] long long v21; // [rsp+38h] [rbp-40h] unsigned long long v22; // [rsp+48h] [rbp-30h] v22 = __readfsqword(0x28u); if ( a1 <= 0 ) { exception = (std::invalid_argument *)__cxa_allocate_exception(0x10uLL); std::invalid_argument::invalid_argument(exception, "Input must be bigger than 0!"); __cxa_throw( exception, (struct type_info *)&`typeinfo for'std::invalid_argument, (void (*)(void *))&std::invalid_argument::~invalid_argument); } v17 = 0; v18 = 0LL; v19 = &v17; v20 = &v17; v21 = 0LL; v14 = 2; if ( a1 > 1 ) { for ( i = 2; i <= a1; v14 = i ) { v4 = v18; if ( !v18 ) goto LABEL_29; v5 = &v17; do { if ( *(_DWORD *)(v4 + 32) < i ) { v4 = *(_QWORD *)(v4 + 24); } else { v5 = (int *)v4; v4 = *(_QWORD *)(v4 + 16); } } while ( v4 ); if ( v5 == &v17 || v5[8] > i ) { LABEL_29: v12 = 1; v13 = 0; if ( i <= 1 ) { v15 = 0; j = 0; } else { do { if ( !(i % v12) ) v13 += v12; ++v12; } while ( v12 != i ); v15 = 0; if ( v13 <= 1 ) { j = v13; } else { v7 = 0; v6 = 0; for ( j = 1; j != v13; ++j ) { if ( !(v13 % j) ) { v6 += j; v7 = 1; } } if ( v7 ) v15 = v6; } } if ( v15 == i && j != i ) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v16, &v14); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v16, &v15); } } ++i; } } v9 = v19; if ( v19 == &v17 ) { v10 = 0; } else { v10 = 0; do { v10 += v9[8]; v9 = (int *)std::_Rb_tree_increment(); } while ( v9 != &v17 ); } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(v16, v18); return v10; }
func0: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x50 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX TEST EDI,EDI JLE 0x00101325 MOV EBP,EDI MOV dword ptr [RSP + 0x18],0x0 MOV qword ptr [RSP + 0x20],0x0 LEA RAX,[RSP + 0x18] MOV qword ptr [RSP + 0x28],RAX MOV qword ptr [RSP + 0x30],RAX MOV qword ptr [RSP + 0x38],0x0 MOV dword ptr [RSP + 0x8],0x2 CMP EDI,0x1 JLE 0x0010140a MOV EBX,0x2 MOV R13D,0x0 MOV R14D,0x0 MOV R12D,0x1 JMP 0x001013a5 LAB_00101325: MOV EDI,0x10 CALL 0x00101110 MOV RBX,RAX LEA RSI,[0x102004] MOV RDI,RAX LAB_0010133c: CALL 0x001011b0 MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JZ 0x00101356 CALL 0x00101170 LAB_00101356: MOV RDX,qword ptr [0x00103fe0] LEA RSI,[0x103d30] MOV RDI,RBX LAB_00101367: CALL 0x00101190 LAB_0010136c: MOV RAX,qword ptr [RAX + 0x18] LAB_00101370: TEST RAX,RAX JZ 0x00101383 LAB_00101375: CMP dword ptr [RAX + 0x20],EBX JL 0x0010136c MOV RDX,RAX MOV RAX,qword ptr [RAX + 0x10] JMP 0x00101370 LAB_00101383: LEA RAX,[RSP + 0x18] CMP RDX,RAX JZ 0x001014db CMP dword ptr [RDX + 0x20],EBX JG 0x001014db LAB_0010139a: ADD EBX,0x1 MOV dword ptr [RSP + 0x8],EBX CMP EBX,EBP JG 0x0010140a LAB_001013a5: MOV RAX,qword ptr [RSP + 0x20] TEST RAX,RAX JZ 0x001014db LEA RDX,[RSP + 0x18] JMP 0x00101375 LAB_001013ba: ADD EDI,ESI MOV R8D,R12D LAB_001013bf: ADD ESI,0x1 CMP ECX,ESI JZ 0x001013d1 LAB_001013c6: MOV EAX,ECX CDQ IDIV ESI TEST EDX,EDX JNZ 0x001013bf JMP 0x001013ba LAB_001013d1: TEST R8B,R8B JZ 0x001013da MOV dword ptr [RSP + 0xc],EDI LAB_001013da: CMP dword ptr [RSP + 0xc],EBX JNZ 0x0010139a CMP ESI,EBX JZ 0x0010139a LEA RSI,[RSP + 0x8] LEA RDI,[RSP + 0x10] LAB_001013ee: CALL 0x001015fe JMP 0x001013f9 LAB_001013f5: MOV ESI,ECX JMP 0x001013da LAB_001013f9: LEA RSI,[RSP + 0xc] LEA RDI,[RSP + 0x10] CALL 0x001015fe JMP 0x0010139a LAB_0010140a: MOV RDI,qword ptr [RSP + 0x28] LEA RAX,[RSP + 0x18] CMP RDI,RAX JZ 0x00101463 MOV EBX,0x0 MOV RBP,RAX LAB_00101421: ADD EBX,dword ptr [RDI + 0x20] CALL 0x00101180 MOV RDI,RAX CMP RAX,RBP JNZ 0x00101421 LAB_00101431: LEA RDI,[RSP + 0x10] MOV RSI,qword ptr [RSP + 0x20] CALL 0x001015c0 MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010151c MOV EAX,EBX ADD RSP,0x50 POP RBX POP RBP POP R12 POP R13 POP R14 RET LAB_00101463: MOV EBX,0x0 JMP 0x00101431 LAB_001014c9: MOV dword ptr [RSP + 0xc],0x0 MOV ESI,0x0 JMP 0x001013da LAB_001014db: MOV ESI,0x1 MOV ECX,R13D CMP EBX,0x1 JLE 0x001014c9 LAB_001014e8: MOV EAX,EBX CDQ IDIV ESI LEA EAX,[RCX + RSI*0x1] TEST EDX,EDX CMOVZ ECX,EAX ADD ESI,0x1 CMP ESI,EBX JNZ 0x001014e8 MOV dword ptr [RSP + 0xc],R13D CMP ECX,0x1 JLE 0x001013f5 MOV R8D,R14D MOV EDI,0x0 MOV ESI,0x1 JMP 0x001013c6 LAB_0010151c: CALL 0x00101170
/* func0(int) */ int func0(int param_1) { bool bVar1; invalid_argument *this; _Rb_tree_node *p_Var2; _Rb_tree_node *p_Var3; _Rb_tree_node_base *p_Var4; _Rb_tree_node *p_Var5; int iVar6; int iVar7; int iVar8; int iVar9; long in_FS_OFFSET; int local_70; int local_6c; _Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> local_68 [8]; int4 local_60 [2]; _Rb_tree_node *local_58; _Rb_tree_node_base *local_50; _Rb_tree_node_base *local_48; int8 local_40; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); if (param_1 < 1) { this = (invalid_argument *)__cxa_allocate_exception(0x10); /* try { // try from 0010133c to 00101340 has its CatchHandler @ 0010146a */ std::invalid_argument::invalid_argument(this,"Input must be bigger than 0!"); if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __cxa_throw(this,std::invalid_argument::typeinfo,PTR__invalid_argument_00103fe0); } /* WARNING: Subroutine does not return */ __stack_chk_fail(); } local_60[0] = 0; local_58 = (_Rb_tree_node *)0x0; local_50 = (_Rb_tree_node_base *)local_60; local_40 = 0; local_70 = 2; local_48 = local_50; if (1 < param_1) { do { iVar6 = local_70; if (local_58 == (_Rb_tree_node *)0x0) { LAB_001014db: iVar7 = 1; iVar9 = 0; if (local_70 < 2) { local_6c = 0; iVar9 = 0; } else { do { if (local_70 % iVar7 == 0) { iVar9 = iVar9 + iVar7; } iVar7 = iVar7 + 1; } while (iVar7 != local_70); local_6c = 0; if (1 < iVar9) { bVar1 = false; iVar8 = 0; iVar7 = 1; do { if (iVar9 % iVar7 == 0) { iVar8 = iVar8 + iVar7; bVar1 = true; } iVar7 = iVar7 + 1; } while (iVar9 != iVar7); iVar9 = iVar7; if (bVar1) { local_6c = iVar8; } } } if ((local_6c == local_70) && (iVar9 != local_70)) { /* try { // try from 001013ee to 00101407 has its CatchHandler @ 00101496 */ std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_70); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_6c); } } else { p_Var5 = (_Rb_tree_node *)local_60; p_Var3 = local_58; do { if (*(int *)(p_Var3 + 0x20) < local_70) { p_Var2 = *(_Rb_tree_node **)(p_Var3 + 0x18); } else { p_Var2 = *(_Rb_tree_node **)(p_Var3 + 0x10); p_Var5 = p_Var3; } p_Var3 = p_Var2; } while (p_Var2 != (_Rb_tree_node *)0x0); if ((p_Var5 == (_Rb_tree_node *)local_60) || (local_70 < *(int *)(p_Var5 + 0x20))) goto LAB_001014db; } local_70 = iVar6 + 1; } while (local_70 <= param_1); } if (local_50 == (_Rb_tree_node_base *)local_60) { iVar6 = 0; } else { iVar6 = 0; p_Var4 = local_50; do { iVar6 = iVar6 + *(int *)(p_Var4 + 0x20); p_Var4 = (_Rb_tree_node_base *)std::_Rb_tree_increment(p_Var4); } while (p_Var4 != (_Rb_tree_node_base *)local_60); } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (local_68,local_58); if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar6; }
490
func0
#include <iostream> #include <set> #include <assert.h>
int func0(int limit) { if (limit < 1) { throw std::invalid_argument("Input must be bigger than 0!"); } std::set<int> amicables; for (int num = 2; num <= limit; num++) { if (amicables.find(num) != amicables.end()) { continue; } int sum_fact = 0; for (int fact = 1; fact < num; fact++) { if (num % fact == 0) { sum_fact += fact; } } int sum_fact2 = 0; for (int fact = 1; fact < sum_fact; fact++) { if (sum_fact % fact == 0) { sum_fact2 += fact; } } if (num == sum_fact2 && num != sum_fact) { amicables.insert(num); amicables.insert(sum_fact2); } } int total_sum = 0; for (int am : amicables) { total_sum += am; } return total_sum; }
int main() { assert(func0(999) == 504); assert(func0(9999) == 31626); assert(func0(99) == 0); return 0; }
O2
cpp
func0(int): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax test %edi,%edi jle 1200 <_Z5func0i.cold> lea 0x18(%rsp),%rbx mov %edi,%ebp xor %r15d,%r15d movl $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) mov %rbx,0x28(%rsp) mov %rbx,0x30(%rsp) movq $0x0,0x38(%rsp) movl $0x2,0x8(%rsp) cmp $0x1,%edi je 15d0 <_Z5func0i+0x1a0> mov $0x2,%ecx lea 0x10(%rsp),%r12 lea 0x8(%rsp),%r13 lea 0xc(%rsp),%r14 nopl (%rax) test %r15,%r15 je 14e4 <_Z5func0i+0xb4> mov %r15,%rax mov %rbx,%rdx jmp 14cc <_Z5func0i+0x9c> nopl (%rax) mov %rax,%rdx mov 0x10(%rax),%rax test %rax,%rax je 14da <_Z5func0i+0xaa> cmp %ecx,0x20(%rax) jge 14c0 <_Z5func0i+0x90> mov 0x18(%rax),%rax test %rax,%rax jne 14cc <_Z5func0i+0x9c> cmp %rbx,%rdx je 14e4 <_Z5func0i+0xb4> cmp %ecx,0x20(%rdx) jle 1550 <_Z5func0i+0x120> cmp $0x1,%ecx jle 1550 <_Z5func0i+0x120> mov $0x1,%edi xor %esi,%esi mov %ecx,%eax cltd idiv %edi lea (%rsi,%rdi,1),%eax test %edx,%edx cmove %eax,%esi add $0x1,%edi cmp %ecx,%edi jl 14f0 <_Z5func0i+0xc0> movl $0x0,0xc(%rsp) cmp $0x1,%esi jle 15ae <_Z5func0i+0x17e> xor %r9d,%r9d xor %r8d,%r8d mov $0x1,%edi mov %esi,%eax cltd idiv %edi test %edx,%edx jne 1532 <_Z5func0i+0x102> add %edi,%r8d mov $0x1,%r9d add $0x1,%edi cmp %edi,%esi jne 1520 <_Z5func0i+0xf0> test %r9b,%r9b je 15ae <_Z5func0i+0x17e> mov %r8d,0xc(%rsp) cmp %ecx,%esi je 1550 <_Z5func0i+0x120> cmp %r8d,%ecx je 15b3 <_Z5func0i+0x183> nopl 0x0(%rax) mov 0x8(%rsp),%eax lea 0x1(%rax),%ecx mov %ecx,0x8(%rsp) cmp %ebp,%ecx jle 14b0 <_Z5func0i+0x80> mov 0x28(%rsp),%rdi xor %r13d,%r13d cmp %rbx,%rdi je 1581 <_Z5func0i+0x151> add 0x20(%rdi),%r13d callq 11b0 <_ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base@plt> mov %rax,%rdi cmp %rbx,%rax jne 1570 <_Z5func0i+0x140> mov %r15,%rsi mov %r12,%rdi callq 15f0 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 15da <_Z5func0i+0x1aa> add $0x58,%rsp mov %r13d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq xor %r8d,%r8d jmp 1543 <_Z5func0i+0x113> mov %r13,%rsi mov %r12,%rdi callq 1640 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> mov %r14,%rsi mov %r12,%rdi callq 1640 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> mov 0x20(%rsp),%r15 jmp 1550 <_Z5func0i+0x120> xor %r13d,%r13d lea 0x10(%rsp),%r12 jmp 1581 <_Z5func0i+0x151> callq 11a0 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1249 <_Z5func0i.cold+0x49> nopl 0x0(%rax,%rax,1)
_Z5func0i: endbr64 push r13 push r12 push rbp push rbx sub rsp, 58h mov rax, fs:28h mov [rsp+78h+var_30], rax xor eax, eax test edi, edi jle _Z5func0i_cold; func0(int) [clone] lea rbp, [rsp+78h+var_60] mov r12d, edi xor r13d, r13d mov ebx, 2 mov [rsp+78h+var_60], 0 mov [rsp+78h+var_58], 0 mov [rsp+78h+var_50], rbp mov [rsp+78h+var_48], rbp mov [rsp+78h+var_40], 0 mov [rsp+78h+var_70], 2 cmp edi, 1 jz loc_17A3 nop dword ptr [rax+rax+00h] loc_1630: test r13, r13 jz short loc_166E loc_1635: mov rax, r13 mov rsi, rbp jmp short loc_1648 loc_1640: mov rax, rcx test rax, rax jz short loc_1660 loc_1648: mov rdx, [rax+10h] mov rcx, [rax+18h] cmp ebx, [rax+20h] jg short loc_1640 mov rsi, rax mov rax, rdx test rax, rax jnz short loc_1648 loc_1660: cmp rsi, rbp jz short loc_166E cmp ebx, [rsi+20h] jge loc_1758 loc_166E: mov esi, 1 xor ecx, ecx xor eax, eax xor edi, edi cmp ebx, 1 jle short loc_16CF xchg ax, ax loc_1680: mov eax, ebx cdq idiv esi lea eax, [rcx+rsi] test edx, edx cmovz ecx, eax add esi, 1 cmp ebx, esi jnz short loc_1680 mov [rsp+78h+var_6C], 0 cmp ecx, 1 jle short loc_16DF xor r8d, r8d xor edi, edi mov esi, 1 nop dword ptr [rax+rax+00h] loc_16B0: mov eax, ecx cdq idiv esi test edx, edx jnz short loc_16C1 add edi, esi mov r8d, 1 loc_16C1: add esi, 1 cmp esi, ecx jnz short loc_16B0 test r8b, r8b jz short loc_16DF mov eax, edi loc_16CF: mov [rsp+78h+var_6C], eax cmp ebx, ecx jz short loc_16DF cmp edi, ebx jz loc_176A loc_16DF: add ebx, 1 mov [rsp+78h+var_70], ebx cmp ebx, r12d jle loc_1630 loc_16EF: mov rdi, [rsp+78h+var_50] xor ebx, ebx cmp rdi, rbp jz short loc_1710 nop dword ptr [rax+rax+00h] loc_1700: add ebx, [rdi+20h] call __ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base; std::_Rb_tree_increment(std::_Rb_tree_node_base const*) mov rdi, rax cmp rax, rbp jnz short loc_1700 loc_1710: test r13, r13 jz short loc_1734 loc_1715: mov rdi, [r13+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, r13; void * mov r13, [r13+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test r13, r13 jnz short loc_1715 loc_1734: mov rax, [rsp+78h+var_30] sub rax, fs:28h jnz short loc_17A7 add rsp, 58h mov eax, ebx pop rbx pop rbp pop r12 pop r13 retn loc_1758: add ebx, 1 mov [rsp+78h+var_70], ebx cmp r12d, ebx jge loc_1635 jmp short loc_16EF loc_176A: lea r13, [rsp+78h+var_68] lea rsi, [rsp+78h+var_70] mov rdi, r13 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) lea rsi, [rsp+78h+var_6C] mov rdi, r13 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) add ebx, 1 mov r13, [rsp+78h+var_58] mov [rsp+78h+var_70], ebx cmp ebx, r12d jle loc_1630 jmp loc_16EF loc_17A3: xor ebx, ebx jmp short loc_1734 loc_17A7: call ___stack_chk_fail endbr64 mov rbx, rax jmp loc_1207
long long func0( int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, long long a15) { _QWORD *v16; // r13 int v17; // ebx _QWORD *v18; // rax int *v19; // rsi long long v20; // rdx long long v21; // rcx int v22; // esi int v23; // ecx int v24; // eax int v25; // edi char v26; // r8 int i; // esi int *v28; // rdi unsigned int j; // ebx void *v30; // rdi int v32; // [rsp+8h] [rbp-70h] BYREF int v33; // [rsp+Ch] [rbp-6Ch] BYREF char v34[8]; // [rsp+10h] [rbp-68h] BYREF int v35; // [rsp+18h] [rbp-60h] BYREF _QWORD *v36; // [rsp+20h] [rbp-58h] int *v37; // [rsp+28h] [rbp-50h] int *v38; // [rsp+30h] [rbp-48h] long long v39; // [rsp+38h] [rbp-40h] unsigned long long v40; // [rsp+48h] [rbp-30h] v40 = __readfsqword(0x28u); if ( a1 <= 0 ) func0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); v16 = 0LL; v17 = 2; v35 = 0; v36 = 0LL; v37 = &v35; v38 = &v35; v39 = 0LL; v32 = 2; if ( a1 == 1 ) return 0; do { while ( 1 ) { if ( v16 ) { while ( 1 ) { v18 = v16; v19 = &v35; do { while ( 1 ) { v20 = v18[2]; v21 = v18[3]; if ( v17 <= *((_DWORD *)v18 + 8) ) break; v18 = (_QWORD *)v18[3]; if ( !v21 ) goto LABEL_8; } v19 = (int *)v18; v18 = (_QWORD *)v18[2]; } while ( v20 ); LABEL_8: if ( v19 == &v35 || v17 < v19[8] ) break; v32 = ++v17; if ( a1 < v17 ) goto LABEL_24; } } v22 = 1; v23 = 0; v24 = 0; v25 = 0; if ( v17 > 1 ) { do { if ( !(v17 % v22) ) v23 += v22; ++v22; } while ( v17 != v22 ); v33 = 0; if ( v23 <= 1 ) goto LABEL_23; v26 = 0; v25 = 0; for ( i = 1; i != v23; ++i ) { if ( !(v23 % i) ) { v25 += i; v26 = 1; } } if ( !v26 ) goto LABEL_23; v24 = v25; } v33 = v24; if ( v17 != v23 && v25 == v17 ) break; LABEL_23: v32 = ++v17; if ( v17 > a1 ) goto LABEL_24; } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v34, &v32); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v34, &v33); ++v17; v16 = v36; v32 = v17; } while ( v17 <= a1 ); LABEL_24: v28 = v37; for ( j = 0; v28 != &v35; v28 = (int *)std::_Rb_tree_increment() ) j += v28[8]; while ( v16 ) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(v16[3]); v30 = v16; v16 = (_QWORD *)v16[2]; operator delete(v30, 0x28uLL); } return j; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x58 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX TEST EDI,EDI JLE 0x001011c0 LEA RBP,[RSP + 0x18] MOV R12D,EDI XOR R13D,R13D MOV EBX,0x2 MOV dword ptr [RSP + 0x18],0x0 MOV qword ptr [RSP + 0x20],0x0 MOV qword ptr [RSP + 0x28],RBP MOV qword ptr [RSP + 0x30],RBP MOV qword ptr [RSP + 0x38],0x0 MOV dword ptr [RSP + 0x8],0x2 CMP EDI,0x1 JZ 0x001017a3 NOP dword ptr [RAX + RAX*0x1] LAB_00101630: TEST R13,R13 JZ 0x0010166e LAB_00101635: MOV RAX,R13 MOV RSI,RBP JMP 0x00101648 LAB_00101640: MOV RAX,RCX TEST RAX,RAX JZ 0x00101660 LAB_00101648: MOV RDX,qword ptr [RAX + 0x10] MOV RCX,qword ptr [RAX + 0x18] CMP EBX,dword ptr [RAX + 0x20] JG 0x00101640 MOV RSI,RAX MOV RAX,RDX TEST RAX,RAX JNZ 0x00101648 LAB_00101660: CMP RSI,RBP JZ 0x0010166e CMP EBX,dword ptr [RSI + 0x20] JGE 0x00101758 LAB_0010166e: MOV ESI,0x1 XOR ECX,ECX XOR EAX,EAX XOR EDI,EDI CMP EBX,0x1 JLE 0x001016cf NOP LAB_00101680: MOV EAX,EBX CDQ IDIV ESI LEA EAX,[RCX + RSI*0x1] TEST EDX,EDX CMOVZ ECX,EAX ADD ESI,0x1 CMP EBX,ESI JNZ 0x00101680 MOV dword ptr [RSP + 0xc],0x0 CMP ECX,0x1 JLE 0x001016df XOR R8D,R8D XOR EDI,EDI MOV ESI,0x1 NOP dword ptr [RAX + RAX*0x1] LAB_001016b0: MOV EAX,ECX CDQ IDIV ESI TEST EDX,EDX JNZ 0x001016c1 ADD EDI,ESI MOV R8D,0x1 LAB_001016c1: ADD ESI,0x1 CMP ESI,ECX JNZ 0x001016b0 TEST R8B,R8B JZ 0x001016df MOV EAX,EDI LAB_001016cf: MOV dword ptr [RSP + 0xc],EAX CMP EBX,ECX JZ 0x001016df CMP EDI,EBX JZ 0x0010176a LAB_001016df: ADD EBX,0x1 MOV dword ptr [RSP + 0x8],EBX CMP EBX,R12D JLE 0x00101630 LAB_001016ef: MOV RDI,qword ptr [RSP + 0x28] XOR EBX,EBX CMP RDI,RBP JZ 0x00101710 NOP dword ptr [RAX + RAX*0x1] LAB_00101700: ADD EBX,dword ptr [RDI + 0x20] CALL 0x00101180 MOV RDI,RAX CMP RAX,RBP JNZ 0x00101700 LAB_00101710: TEST R13,R13 JZ 0x00101734 LAB_00101715: MOV RDI,qword ptr [R13 + 0x18] CALL 0x001013f0 MOV RDI,R13 MOV R13,qword ptr [R13 + 0x10] MOV ESI,0x28 CALL 0x00101150 TEST R13,R13 JNZ 0x00101715 LAB_00101734: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017a7 ADD RSP,0x58 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 RET LAB_00101758: ADD EBX,0x1 MOV dword ptr [RSP + 0x8],EBX CMP R12D,EBX JGE 0x00101635 JMP 0x001016ef LAB_0010176a: LEA R13,[RSP + 0x10] LEA RSI,[RSP + 0x8] MOV RDI,R13 LAB_00101777: CALL 0x001017c0 LEA RSI,[RSP + 0xc] MOV RDI,R13 CALL 0x001017c0 ADD EBX,0x1 MOV R13,qword ptr [RSP + 0x20] MOV dword ptr [RSP + 0x8],EBX CMP EBX,R12D JLE 0x00101630 JMP 0x001016ef LAB_001017a3: XOR EBX,EBX JMP 0x00101734 LAB_001017a7: CALL 0x00101170
/* func0(int) */ int func0(int param_1) { bool bVar1; invalid_argument *this; _Rb_tree_node_base *p_Var2; _Rb_tree_node_base *p_Var3; int iVar4; int iVar5; int iVar6; _Rb_tree_node_base *p_Var7; int iVar8; _Rb_tree_node_base *p_Var9; long in_FS_OFFSET; int local_70; int local_6c; _Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> local_68 [8]; int4 local_60 [2]; _Rb_tree_node_base *local_58; _Rb_tree_node_base *local_50; _Rb_tree_node_base *local_48; int8 local_40; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); if (param_1 < 1) { this = (invalid_argument *)__cxa_allocate_exception(0x10); std::invalid_argument::invalid_argument(this,"Input must be bigger than 0!"); if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ __cxa_throw(this,std::invalid_argument::typeinfo,PTR__invalid_argument_00103fe0); } p_Var9 = (_Rb_tree_node_base *)0x0; local_60[0] = 0; local_58 = (_Rb_tree_node_base *)0x0; local_40 = 0; local_70 = 2; local_50 = (_Rb_tree_node_base *)local_60; local_48 = (_Rb_tree_node_base *)local_60; if (param_1 == 1) { iVar5 = 0; } else { LAB_00101630: do { p_Var3 = p_Var9; p_Var7 = (_Rb_tree_node_base *)local_60; if (p_Var9 != (_Rb_tree_node_base *)0x0) { LAB_00101648: do { p_Var2 = p_Var3; if (*(int *)(p_Var2 + 0x20) < local_70) goto LAB_00101640; p_Var3 = *(_Rb_tree_node_base **)(p_Var2 + 0x10); p_Var7 = p_Var2; } while (*(_Rb_tree_node_base **)(p_Var2 + 0x10) != (_Rb_tree_node_base *)0x0); goto LAB_00101660; } LAB_0010166e: iVar5 = local_70; iVar6 = 1; iVar4 = 0; iVar8 = 0; if (local_70 < 2) { LAB_001016cf: local_6c = iVar8; if ((local_70 != iVar4) && (iVar8 == local_70)) { /* try { // try from 00101777 to 00101788 has its CatchHandler @ 001017ac */ std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_70); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_6c); local_70 = iVar5 + 1; p_Var9 = local_58; if (param_1 < local_70) break; goto LAB_00101630; } } else { do { if (local_70 % iVar6 == 0) { iVar4 = iVar4 + iVar6; } iVar6 = iVar6 + 1; } while (local_70 != iVar6); local_6c = 0; if (1 < iVar4) { bVar1 = false; iVar8 = 0; iVar6 = 1; do { if (iVar4 % iVar6 == 0) { iVar8 = iVar8 + iVar6; bVar1 = true; } iVar6 = iVar6 + 1; } while (iVar6 != iVar4); if (bVar1) goto LAB_001016cf; } } local_70 = local_70 + 1; } while (local_70 <= param_1); LAB_001016ef: iVar5 = 0; for (p_Var3 = local_50; p_Var3 != (_Rb_tree_node_base *)local_60; p_Var3 = (_Rb_tree_node_base *)std::_Rb_tree_increment(p_Var3)) { iVar5 = iVar5 + *(int *)(p_Var3 + 0x20); } while (p_Var9 != (_Rb_tree_node_base *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)(p_Var9 + 0x18)); p_Var3 = *(_Rb_tree_node_base **)(p_Var9 + 0x10); operator_delete(p_Var9,0x28); p_Var9 = p_Var3; } } if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar5; LAB_00101640: p_Var3 = *(_Rb_tree_node_base **)(p_Var2 + 0x18); if (*(_Rb_tree_node_base **)(p_Var2 + 0x18) == (_Rb_tree_node_base *)0x0) { LAB_00101660: if ((p_Var7 == (_Rb_tree_node_base *)local_60) || (local_70 < *(int *)(p_Var7 + 0x20))) goto LAB_0010166e; local_70 = local_70 + 1; p_Var3 = p_Var9; p_Var7 = (_Rb_tree_node_base *)local_60; if (param_1 < local_70) goto LAB_001016ef; } goto LAB_00101648; }
491
func0
#include <iostream> #include <set> #include <assert.h>
int func0(int limit) { if (limit < 1) { throw std::invalid_argument("Input must be bigger than 0!"); } std::set<int> amicables; for (int num = 2; num <= limit; num++) { if (amicables.find(num) != amicables.end()) { continue; } int sum_fact = 0; for (int fact = 1; fact < num; fact++) { if (num % fact == 0) { sum_fact += fact; } } int sum_fact2 = 0; for (int fact = 1; fact < sum_fact; fact++) { if (sum_fact % fact == 0) { sum_fact2 += fact; } } if (num == sum_fact2 && num != sum_fact) { amicables.insert(num); amicables.insert(sum_fact2); } } int total_sum = 0; for (int am : amicables) { total_sum += am; } return total_sum; }
int main() { assert(func0(999) == 504); assert(func0(9999) == 31626); assert(func0(99) == 0); return 0; }
O3
cpp
func0(int): endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x50,%rsp mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax test %edi,%edi jle 1200 <_Z5func0i.cold> lea 0x18(%rsp),%rbx mov %edi,%ebp xor %r14d,%r14d mov $0x2,%ecx mov %rbx,0x28(%rsp) lea 0x8(%rsp),%r13 lea 0x10(%rsp),%r12 movl $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) mov %rbx,0x30(%rsp) movq $0x0,0x38(%rsp) movl $0x2,0x8(%rsp) cmp $0x1,%edi je 1617 <_Z5func0i+0x1e7> nopw %cs:0x0(%rax,%rax,1) test %r14,%r14 je 14e8 <_Z5func0i+0xb8> mov %r14,%rax mov %rbx,%rdx jmp 14cc <_Z5func0i+0x9c> nopl (%rax) mov %rax,%rdx mov 0x10(%rax),%rax test %rax,%rax je 14da <_Z5func0i+0xaa> cmp %ecx,0x20(%rax) jge 14c0 <_Z5func0i+0x90> mov 0x18(%rax),%rax test %rax,%rax jne 14cc <_Z5func0i+0x9c> cmp %rbx,%rdx je 14e8 <_Z5func0i+0xb8> cmp %ecx,0x20(%rdx) jle 15e0 <_Z5func0i+0x1b0> cmp $0x1,%ecx jle 1560 <_Z5func0i+0x130> mov $0x1,%edi xor %esi,%esi mov %ecx,%eax cltd idiv %edi lea (%rsi,%rdi,1),%eax test %edx,%edx cmove %eax,%esi add $0x1,%edi cmp %edi,%ecx jg 14f4 <_Z5func0i+0xc4> movl $0x0,0xc(%rsp) cmp $0x1,%esi jle 15e9 <_Z5func0i+0x1b9> xor %r9d,%r9d xor %r8d,%r8d mov $0x1,%edi nopl 0x0(%rax) mov %esi,%eax cltd idiv %edi test %edx,%edx jne 153a <_Z5func0i+0x10a> add %edi,%r8d mov $0x1,%r9d add $0x1,%edi cmp %edi,%esi jne 1528 <_Z5func0i+0xf8> test %r9b,%r9b je 15e9 <_Z5func0i+0x1b9> mov %r8d,0xc(%rsp) cmp %ecx,%esi je 1560 <_Z5func0i+0x130> cmp %r8d,%ecx je 15f1 <_Z5func0i+0x1c1> nopl 0x0(%rax) add $0x1,%ecx mov %ecx,0x8(%rsp) cmp %ebp,%ecx jle 14b0 <_Z5func0i+0x80> mov 0x28(%rsp),%rdi xor %r12d,%r12d cmp %rbx,%rdi je 1591 <_Z5func0i+0x161> nopl 0x0(%rax) add 0x20(%rdi),%r12d callq 11b0 <_ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base@plt> mov %rax,%rdi cmp %rbx,%rax jne 1580 <_Z5func0i+0x150> lea 0x10(%rsp),%rbx test %r14,%r14 je 15b8 <_Z5func0i+0x188> mov 0x18(%r14),%rsi mov %rbx,%rdi callq 1630 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov %r14,%rdi mov 0x10(%r14),%r14 callq 1170 <_ZdlPv@plt> test %r14,%r14 jne 159b <_Z5func0i+0x16b> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 161c <_Z5func0i+0x1ec> add $0x50,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq nopl 0x0(%rax,%rax,1) mov 0x8(%rsp),%ecx jmpq 1560 <_Z5func0i+0x130> xor %r8d,%r8d jmpq 154f <_Z5func0i+0x11f> mov %r13,%rsi mov %r12,%rdi callq 1680 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> lea 0xc(%rsp),%rsi mov %r12,%rdi callq 1680 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> mov 0x8(%rsp),%ecx mov 0x20(%rsp),%r14 jmpq 1560 <_Z5func0i+0x130> xor %r12d,%r12d jmp 15b8 <_Z5func0i+0x188> callq 11a0 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1249 <_Z5func0i.cold+0x49> nopl (%rax)
_Z5func0i: endbr64 push r13 push r12 push rbp push rbx sub rsp, 58h mov rax, fs:28h mov [rsp+78h+var_30], rax xor eax, eax test edi, edi jle _Z5func0i_cold; func0(int) [clone] lea rbp, [rsp+78h+var_60] mov r12d, edi xor r13d, r13d mov ebx, 2 mov [rsp+78h+var_60], 0 mov [rsp+78h+var_58], 0 mov [rsp+78h+var_50], rbp mov [rsp+78h+var_48], rbp mov [rsp+78h+var_40], 0 mov [rsp+78h+var_70], 2 cmp edi, 1 jz loc_17C6 nop dword ptr [rax+rax+00h] loc_1630: test r13, r13 jz short loc_1681 loc_1635: mov rax, r13 mov rsi, rbp nop dword ptr [rax+rax+00h] loc_1640: mov rcx, [rax+10h] mov rdx, [rax+18h] cmp ebx, [rax+20h] jle short loc_1662 loc_164D: test rdx, rdx jz short loc_1670 mov rax, rdx mov rcx, [rax+10h] mov rdx, [rax+18h] cmp ebx, [rax+20h] jg short loc_164D loc_1662: test rcx, rcx jz short loc_1673 mov rsi, rax mov rax, rcx jmp short loc_1640 loc_1670: mov rax, rsi loc_1673: cmp rax, rbp jz short loc_1681 cmp [rax+20h], ebx jle loc_1770 loc_1681: mov esi, 1 xor ecx, ecx cmp ebx, 1 jle loc_17BB nop dword ptr [rax+00000000h] loc_1698: mov eax, ebx cdq idiv esi lea eax, [rcx+rsi] test edx, edx cmovz ecx, eax add esi, 1 cmp esi, ebx jnz short loc_1698 mov [rsp+78h+var_6C], 0 cmp ecx, 1 jle short loc_16F7 xor r8d, r8d xor edi, edi mov esi, 1 nop dword ptr [rax+rax+00h] loc_16C8: mov eax, ecx cdq idiv esi test edx, edx jnz short loc_16D9 add edi, esi mov r8d, 1 loc_16D9: add esi, 1 cmp ecx, esi jnz short loc_16C8 test r8b, r8b jz short loc_16F7 mov eax, edi loc_16E7: mov [rsp+78h+var_6C], eax cmp esi, ebx jz short loc_16F7 cmp edi, ebx jz loc_1782 loc_16F7: add ebx, 1 mov [rsp+78h+var_70], ebx cmp ebx, r12d jle loc_1630 loc_1707: mov rdi, [rsp+78h+var_50] xor ebx, ebx cmp rdi, rbp jz short loc_1728 nop dword ptr [rax+rax+00h] loc_1718: add ebx, [rdi+20h] call __ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base; std::_Rb_tree_increment(std::_Rb_tree_node_base const*) mov rdi, rax cmp rax, rbp jnz short loc_1718 loc_1728: test r13, r13 jz short loc_174C loc_172D: mov rdi, [r13+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, r13; void * mov r13, [r13+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test r13, r13 jnz short loc_172D loc_174C: mov rax, [rsp+78h+var_30] sub rax, fs:28h jnz short loc_17CA add rsp, 58h mov eax, ebx pop rbx pop rbp pop r12 pop r13 retn loc_1770: add ebx, 1 mov [rsp+78h+var_70], ebx cmp r12d, ebx jge loc_1635 jmp short loc_1707 loc_1782: lea r13, [rsp+78h+var_68] lea rsi, [rsp+78h+var_70] mov rdi, r13 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) lea rsi, [rsp+78h+var_6C] mov rdi, r13 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) add ebx, 1 mov r13, [rsp+78h+var_58] mov [rsp+78h+var_70], ebx cmp ebx, r12d jle loc_1630 jmp loc_1707 loc_17BB: xor eax, eax xor edi, edi xor esi, esi jmp loc_16E7 loc_17C6: xor ebx, ebx jmp short loc_174C loc_17CA: call ___stack_chk_fail endbr64 mov rbx, rax jmp loc_1207
long long func0( int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14, long long a15) { int *v16; // r13 int v17; // ebx int *v18; // rax int *v19; // rsi int *v20; // rcx long long v21; // rdx int v22; // esi int v23; // ecx char v24; // r8 int v25; // edi int i; // esi int v27; // eax int *v28; // rdi unsigned int j; // ebx int *v30; // rdi int v32; // [rsp+8h] [rbp-70h] BYREF int v33; // [rsp+Ch] [rbp-6Ch] BYREF char v34[8]; // [rsp+10h] [rbp-68h] BYREF int v35; // [rsp+18h] [rbp-60h] BYREF int *v36; // [rsp+20h] [rbp-58h] int *v37; // [rsp+28h] [rbp-50h] int *v38; // [rsp+30h] [rbp-48h] long long v39; // [rsp+38h] [rbp-40h] unsigned long long v40; // [rsp+48h] [rbp-30h] v40 = __readfsqword(0x28u); if ( a1 <= 0 ) func0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); v16 = 0LL; v17 = 2; v35 = 0; v36 = 0LL; v37 = &v35; v38 = &v35; v39 = 0LL; v32 = 2; if ( a1 == 1 ) return 0; do { while ( 1 ) { if ( v16 ) { while ( 1 ) { v18 = v16; v19 = &v35; while ( 1 ) { v20 = (int *)*((_QWORD *)v18 + 2); v21 = *((_QWORD *)v18 + 3); if ( v17 > v18[8] ) break; LABEL_8: if ( !v20 ) goto LABEL_11; v19 = v18; v18 = v20; } while ( v21 ) { v18 = (int *)v21; v20 = *(int **)(v21 + 16); v21 = *(_QWORD *)(v21 + 24); if ( v17 <= v18[8] ) goto LABEL_8; } v18 = v19; LABEL_11: if ( v18 == &v35 || v18[8] > v17 ) break; v32 = ++v17; if ( a1 < v17 ) goto LABEL_27; } } v22 = 1; v23 = 0; if ( v17 <= 1 ) { v27 = 0; v25 = 0; i = 0; } else { do { if ( !(v17 % v22) ) v23 += v22; ++v22; } while ( v22 != v17 ); v33 = 0; if ( v23 <= 1 ) goto LABEL_26; v24 = 0; v25 = 0; for ( i = 1; i != v23; ++i ) { if ( !(v23 % i) ) { v25 += i; v24 = 1; } } if ( !v24 ) goto LABEL_26; v27 = v25; } v33 = v27; if ( i != v17 && v25 == v17 ) break; LABEL_26: v32 = ++v17; if ( v17 > a1 ) goto LABEL_27; } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v34, &v32); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v34, &v33); ++v17; v16 = v36; v32 = v17; } while ( v17 <= a1 ); LABEL_27: v28 = v37; for ( j = 0; v28 != &v35; v28 = (int *)std::_Rb_tree_increment() ) j += v28[8]; while ( v16 ) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(*((_QWORD *)v16 + 3)); v30 = v16; v16 = (int *)*((_QWORD *)v16 + 2); operator delete(v30, 0x28uLL); } return j; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x58 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x48],RAX XOR EAX,EAX TEST EDI,EDI JLE 0x001011c0 LEA RBP,[RSP + 0x18] MOV R12D,EDI XOR R13D,R13D MOV EBX,0x2 MOV dword ptr [RSP + 0x18],0x0 MOV qword ptr [RSP + 0x20],0x0 MOV qword ptr [RSP + 0x28],RBP MOV qword ptr [RSP + 0x30],RBP MOV qword ptr [RSP + 0x38],0x0 MOV dword ptr [RSP + 0x8],0x2 CMP EDI,0x1 JZ 0x001017c6 NOP dword ptr [RAX + RAX*0x1] LAB_00101630: TEST R13,R13 JZ 0x00101681 LAB_00101635: MOV RAX,R13 MOV RSI,RBP NOP dword ptr [RAX + RAX*0x1] LAB_00101640: MOV RCX,qword ptr [RAX + 0x10] MOV RDX,qword ptr [RAX + 0x18] CMP EBX,dword ptr [RAX + 0x20] JLE 0x00101662 LAB_0010164d: TEST RDX,RDX JZ 0x00101670 MOV RAX,RDX MOV RCX,qword ptr [RAX + 0x10] MOV RDX,qword ptr [RAX + 0x18] CMP EBX,dword ptr [RAX + 0x20] JG 0x0010164d LAB_00101662: TEST RCX,RCX JZ 0x00101673 MOV RSI,RAX MOV RAX,RCX JMP 0x00101640 LAB_00101670: MOV RAX,RSI LAB_00101673: CMP RAX,RBP JZ 0x00101681 CMP dword ptr [RAX + 0x20],EBX JLE 0x00101770 LAB_00101681: MOV ESI,0x1 XOR ECX,ECX CMP EBX,0x1 JLE 0x001017bb NOP dword ptr [RAX] LAB_00101698: MOV EAX,EBX CDQ IDIV ESI LEA EAX,[RCX + RSI*0x1] TEST EDX,EDX CMOVZ ECX,EAX ADD ESI,0x1 CMP ESI,EBX JNZ 0x00101698 MOV dword ptr [RSP + 0xc],0x0 CMP ECX,0x1 JLE 0x001016f7 XOR R8D,R8D XOR EDI,EDI MOV ESI,0x1 NOP dword ptr [RAX + RAX*0x1] LAB_001016c8: MOV EAX,ECX CDQ IDIV ESI TEST EDX,EDX JNZ 0x001016d9 ADD EDI,ESI MOV R8D,0x1 LAB_001016d9: ADD ESI,0x1 CMP ECX,ESI JNZ 0x001016c8 TEST R8B,R8B JZ 0x001016f7 MOV EAX,EDI LAB_001016e7: MOV dword ptr [RSP + 0xc],EAX CMP ESI,EBX JZ 0x001016f7 CMP EDI,EBX JZ 0x00101782 LAB_001016f7: ADD EBX,0x1 MOV dword ptr [RSP + 0x8],EBX CMP EBX,R12D JLE 0x00101630 LAB_00101707: MOV RDI,qword ptr [RSP + 0x28] XOR EBX,EBX CMP RDI,RBP JZ 0x00101728 NOP dword ptr [RAX + RAX*0x1] LAB_00101718: ADD EBX,dword ptr [RDI + 0x20] CALL 0x00101180 MOV RDI,RAX CMP RAX,RBP JNZ 0x00101718 LAB_00101728: TEST R13,R13 JZ 0x0010174c LAB_0010172d: MOV RDI,qword ptr [R13 + 0x18] CALL 0x001013f0 MOV RDI,R13 MOV R13,qword ptr [R13 + 0x10] MOV ESI,0x28 CALL 0x00101150 TEST R13,R13 JNZ 0x0010172d LAB_0010174c: MOV RAX,qword ptr [RSP + 0x48] SUB RAX,qword ptr FS:[0x28] JNZ 0x001017ca ADD RSP,0x58 MOV EAX,EBX POP RBX POP RBP POP R12 POP R13 RET LAB_00101770: ADD EBX,0x1 MOV dword ptr [RSP + 0x8],EBX CMP R12D,EBX JGE 0x00101635 JMP 0x00101707 LAB_00101782: LEA R13,[RSP + 0x10] LEA RSI,[RSP + 0x8] MOV RDI,R13 LAB_0010178f: CALL 0x001017e0 LEA RSI,[RSP + 0xc] MOV RDI,R13 CALL 0x001017e0 ADD EBX,0x1 MOV R13,qword ptr [RSP + 0x20] MOV dword ptr [RSP + 0x8],EBX CMP EBX,R12D JLE 0x00101630 JMP 0x00101707 LAB_001017bb: XOR EAX,EAX XOR EDI,EDI XOR ESI,ESI JMP 0x001016e7 LAB_001017c6: XOR EBX,EBX JMP 0x0010174c LAB_001017ca: CALL 0x00101170
/* func0(int) */ int func0(int param_1) { bool bVar1; _Rb_tree_node_base *p_Var2; _Rb_tree_node_base *p_Var3; _Rb_tree_node_base *p_Var4; _Rb_tree_node_base *p_Var5; invalid_argument *this; _Rb_tree_node_base *p_Var6; _Rb_tree_node_base *p_Var7; int iVar8; int iVar9; int iVar10; int iVar11; _Rb_tree_node_base *p_Var12; long in_FS_OFFSET; int local_70; int local_6c; _Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> local_68 [8]; int4 local_60 [2]; _Rb_tree_node_base *local_58; _Rb_tree_node_base *local_50; _Rb_tree_node_base *local_48; int8 local_40; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); if (param_1 < 1) { this = (invalid_argument *)__cxa_allocate_exception(0x10); std::invalid_argument::invalid_argument(this,"Input must be bigger than 0!"); if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ __cxa_throw(this,std::invalid_argument::typeinfo,PTR__invalid_argument_00103fe0); } p_Var12 = (_Rb_tree_node_base *)0x0; local_60[0] = 0; local_58 = (_Rb_tree_node_base *)0x0; local_40 = 0; local_70 = 2; local_50 = (_Rb_tree_node_base *)local_60; local_48 = (_Rb_tree_node_base *)local_60; if (param_1 == 1) { iVar9 = 0; } else { LAB_00101630: do { p_Var7 = p_Var12; p_Var6 = (_Rb_tree_node_base *)local_60; if (p_Var12 != (_Rb_tree_node_base *)0x0) { do { do { iVar9 = *(int *)(p_Var7 + 0x20); p_Var4 = *(_Rb_tree_node_base **)(p_Var7 + 0x10); p_Var5 = *(_Rb_tree_node_base **)(p_Var7 + 0x18); p_Var3 = p_Var7; while (p_Var2 = p_Var5, p_Var7 = p_Var4, iVar9 < local_70) { if (p_Var2 == (_Rb_tree_node_base *)0x0) goto LAB_00101673; p_Var4 = *(_Rb_tree_node_base **)(p_Var2 + 0x10); p_Var5 = *(_Rb_tree_node_base **)(p_Var2 + 0x18); p_Var3 = p_Var2; iVar9 = *(int *)(p_Var2 + 0x20); } p_Var6 = p_Var3; } while (p_Var7 != (_Rb_tree_node_base *)0x0); LAB_00101673: if ((p_Var6 == (_Rb_tree_node_base *)local_60) || (local_70 < *(int *)(p_Var6 + 0x20))) break; local_70 = local_70 + 1; p_Var7 = p_Var12; p_Var6 = (_Rb_tree_node_base *)local_60; if (param_1 < local_70) goto LAB_00101707; } while( true ); } iVar9 = local_70; iVar10 = 1; iVar8 = 0; if (local_70 < 2) { iVar10 = 0; iVar11 = 0; LAB_001016e7: local_6c = iVar10; if ((iVar11 != local_70) && (iVar10 == local_70)) { /* try { // try from 0010178f to 001017a0 has its CatchHandler @ 001017cf */ std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_70); std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_68,&local_6c); local_70 = iVar9 + 1; p_Var12 = local_58; if (param_1 < local_70) break; goto LAB_00101630; } } else { do { if (local_70 % iVar10 == 0) { iVar8 = iVar8 + iVar10; } iVar10 = iVar10 + 1; } while (iVar10 != local_70); local_6c = 0; if (1 < iVar8) { bVar1 = false; iVar10 = 0; iVar11 = 1; do { if (iVar8 % iVar11 == 0) { iVar10 = iVar10 + iVar11; bVar1 = true; } iVar11 = iVar11 + 1; } while (iVar8 != iVar11); if (bVar1) goto LAB_001016e7; } } local_70 = local_70 + 1; } while (local_70 <= param_1); LAB_00101707: iVar9 = 0; for (p_Var7 = local_50; p_Var7 != (_Rb_tree_node_base *)local_60; p_Var7 = (_Rb_tree_node_base *)std::_Rb_tree_increment(p_Var7)) { iVar9 = iVar9 + *(int *)(p_Var7 + 0x20); } while (p_Var12 != (_Rb_tree_node_base *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)(p_Var12 + 0x18)); p_Var7 = *(_Rb_tree_node_base **)(p_Var12 + 0x10); operator_delete(p_Var12,0x28); p_Var12 = p_Var7; } } if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar9; }
492
func0
#include <iostream> #include <complex> #include <cmath> #include <cassert>
double func0(double a, double b) { std::complex<double> cn(a, b); double angle = std::arg(cn); return angle; }
int main() { assert(fabs(func0(0, 1) - 1.5707963267948966) < 1e-12); assert(fabs(func0(2, 1) - 0.4636476090008061) < 1e-12); assert(fabs(func0(0, 2) - 1.5707963267948966) < 1e-12); return 0; }
O0
cpp
func0(double, double): endbr64 push %rbp mov %rsp,%rbp sub $0x40,%rsp movsd %xmm0,-0x38(%rbp) movsd %xmm1,-0x40(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movsd -0x40(%rbp),%xmm0 mov -0x38(%rbp),%rdx lea -0x20(%rbp),%rax movapd %xmm0,%xmm1 movq %rdx,%xmm0 mov %rax,%rdi callq 140a <_ZNSt7complexIdEC1Edd> lea -0x20(%rbp),%rax mov %rax,%rdi callq 1469 <_ZSt3argIdET_RKSt7complexIS0_E> movq %xmm0,%rax mov %rax,-0x28(%rbp) movsd -0x28(%rbp),%xmm0 mov -0x8(%rbp),%rax xor %fs:0x28,%rax je 123a <_Z5func0dd+0x71> callq 10c0 <__stack_chk_fail@plt> leaveq retq
_Z5func0dd: endbr64 push rbp mov rbp, rsp sub rsp, 40h movsd [rbp+var_38], xmm0 movsd [rbp+var_40], xmm1 mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax movsd xmm0, [rbp+var_40] mov rdx, [rbp+var_38] lea rax, [rbp+var_20] movapd xmm1, xmm0 movq xmm0, rdx mov rdi, rax call _ZNSt7complexIdEC2Edd; std::complex<double>::complex(double,double) lea rax, [rbp+var_20] mov rdi, rax call _ZSt3argIdET_RKSt7complexIS0_E; std::arg<double>(std::complex<double> const&) movq rax, xmm0 mov [rbp+var_28], rax movsd xmm0, [rbp+var_28] mov rax, [rbp+var_8] sub rax, fs:28h jz short locret_11FA call ___stack_chk_fail locret_11FA: leave retn
unsigned long long func0(double a1, double a2) { _BYTE v3[24]; // [rsp+20h] [rbp-20h] BYREF unsigned long long v4; // [rsp+38h] [rbp-8h] v4 = __readfsqword(0x28u); std::complex<double>::complex(v3, a1, a2); std::arg<double>(v3); return v4 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 MOVSD qword ptr [RBP + -0x38],XMM0 MOVSD qword ptr [RBP + -0x40],XMM1 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOVSD XMM0,qword ptr [RBP + -0x40] MOV RDX,qword ptr [RBP + -0x38] LEA RAX,[RBP + -0x20] MOVAPD XMM1,XMM0 MOVQ XMM0,RDX MOV RDI,RAX CALL 0x001013a6 LEA RAX,[RBP + -0x20] MOV RDI,RAX CALL 0x00101405 MOVQ RAX,XMM0 MOV qword ptr [RBP + -0x28],RAX MOVSD XMM0,qword ptr [RBP + -0x28] MOV RAX,qword ptr [RBP + -0x8] SUB RAX,qword ptr FS:[0x28] JZ 0x001011fa CALL 0x00101090 LAB_001011fa: LEAVE RET
/* func0(double, double) */ double func0(double param_1,double param_2) { long in_FS_OFFSET; double dVar1; complex<double> local_28 [24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); std::complex<double>::complex(local_28,param_1,param_2); dVar1 = std::arg<double>((complex *)local_28); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return dVar1; }
493
func0
#include <iostream> #include <complex> #include <cmath> #include <cassert>
double func0(double a, double b) { std::complex<double> cn(a, b); double angle = std::arg(cn); return angle; }
int main() { assert(fabs(func0(0, 1) - 1.5707963267948966) < 1e-12); assert(fabs(func0(2, 1) - 0.4636476090008061) < 1e-12); assert(fabs(func0(0, 2) - 1.5707963267948966) < 1e-12); return 0; }
O1
cpp
func0(double, double): endbr64 sub $0x8,%rsp movapd %xmm0,%xmm2 movapd %xmm1,%xmm0 movapd %xmm2,%xmm1 callq 1070 <atan2@plt> add $0x8,%rsp retq
_Z5func0dd: endbr64 sub rsp, 8 movapd xmm2, xmm1 movapd xmm1, xmm0; x movapd xmm0, xmm2; y call _atan2 add rsp, 8 retn
double func0(double a1, double a2) { return atan2(a2, a1); }
func0: ENDBR64 SUB RSP,0x8 MOVAPD XMM2,XMM1 MOVAPD XMM1,XMM0 MOVAPD XMM0,XMM2 CALL 0x00101050 ADD RSP,0x8 RET
/* func0(double, double) */ void func0(double param_1,double param_2) { atan2(param_2,param_1); return; }
494
func0
#include <iostream> #include <complex> #include <cmath> #include <cassert>
double func0(double a, double b) { std::complex<double> cn(a, b); double angle = std::arg(cn); return angle; }
int main() { assert(fabs(func0(0, 1) - 1.5707963267948966) < 1e-12); assert(fabs(func0(2, 1) - 0.4636476090008061) < 1e-12); assert(fabs(func0(0, 2) - 1.5707963267948966) < 1e-12); return 0; }
O2
cpp
func0(double, double): endbr64 movapd %xmm0,%xmm2 movapd %xmm1,%xmm0 movapd %xmm2,%xmm1 jmpq 1070 <atan2@plt> nopw %cs:0x0(%rax,%rax,1)
_Z5func0dd: endbr64 movapd xmm2, xmm1 movapd xmm1, xmm0; x movapd xmm0, xmm2; y jmp _atan2
double func0(double a1, double a2) { return atan2(a2, a1); }
func0: ENDBR64 MOVAPD XMM2,XMM1 MOVAPD XMM1,XMM0 MOVAPD XMM0,XMM2 JMP 0x00101050
/* func0(double, double) */ void func0(double param_1,double param_2) { atan2(param_2,param_1); return; }
495
func0
#include <iostream> #include <complex> #include <cmath> #include <cassert>
double func0(double a, double b) { std::complex<double> cn(a, b); double angle = std::arg(cn); return angle; }
int main() { assert(fabs(func0(0, 1) - 1.5707963267948966) < 1e-12); assert(fabs(func0(2, 1) - 0.4636476090008061) < 1e-12); assert(fabs(func0(0, 2) - 1.5707963267948966) < 1e-12); return 0; }
O3
cpp
func0(double, double): endbr64 movapd %xmm0,%xmm2 movapd %xmm1,%xmm0 movapd %xmm2,%xmm1 jmpq 1070 <atan2@plt> nopw %cs:0x0(%rax,%rax,1)
_Z5func0dd: endbr64 movapd xmm2, xmm1 movapd xmm1, xmm0; x movapd xmm0, xmm2; y jmp _atan2
double func0(double a1, double a2) { return atan2(a2, a1); }
func0: ENDBR64 MOVAPD XMM2,XMM1 MOVAPD XMM1,XMM0 MOVAPD XMM0,XMM2 JMP 0x00101050
/* func0(double, double) */ void func0(double param_1,double param_2) { atan2(param_2,param_1); return; }
496
func0
#include <iostream> #include <cassert>
int func0(const std::string& string, int n) { int current_sum = 0; int max_sum = 0; for (int i = 0; i < n; i++) { current_sum += (string[i] == '0' ? 1 : -1); if (current_sum < 0) { current_sum = 0; } max_sum = std::max(current_sum, max_sum); } return max_sum ? max_sum : 0; }
int main() { assert(func0("11000010001", 11) == 6); assert(func0("10111", 5) == 1); assert(func0("11011101100101", 14) == 2); return 0; }
O0
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int): endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax movl $0x0,-0x14(%rbp) movl $0x0,-0x10(%rbp) movl $0x0,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x2c(%rbp),%eax jge 14a4 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x9b> mov -0xc(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1270 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm@plt> movzbl (%rax),%eax cmp $0x30,%al jne 146b <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x62> mov $0x1,%edx jmp 1470 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x67> mov $0xffffffff,%edx mov -0x14(%rbp),%eax add %edx,%eax mov %eax,-0x14(%rbp) mov -0x14(%rbp),%eax test %eax,%eax jns 1486 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x7d> movl $0x0,-0x14(%rbp) lea -0x10(%rbp),%rdx lea -0x14(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1811 <_ZSt3maxIiERKT_S2_S2_> mov (%rax),%eax mov %eax,-0x10(%rbp) addl $0x1,-0xc(%rbp) jmp 1440 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x37> mov -0x10(%rbp),%eax mov -0x8(%rbp),%rcx xor %fs:0x28,%rcx je 14bb <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0xb2> callq 1290 <__stack_chk_fail@plt> leaveq retq
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov [rbp+var_14], 0 mov [rbp+var_10], 0 mov [rbp+var_C], 0 jmp short loc_13BC loc_1362: mov eax, [rbp+var_C] movsxd rdx, eax mov rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm; std::string::operator[](ulong) movzx eax, byte ptr [rax] cmp al, 30h ; '0' jnz short loc_1385 mov edx, 1 jmp short loc_138A loc_1385: mov edx, 0FFFFFFFFh loc_138A: mov eax, [rbp+var_14] add eax, edx mov [rbp+var_14], eax mov eax, [rbp+var_14] test eax, eax jns short loc_13A0 mov [rbp+var_14], 0 loc_13A0: lea rdx, [rbp+var_10] lea rax, [rbp+var_14] mov rsi, rdx mov rdi, rax call _ZSt3maxIiERKT_S2_S2_; std::max<int>(int const&,int const&) mov eax, [rax] mov [rbp+var_10], eax add [rbp+var_C], 1 loc_13BC: mov eax, [rbp+var_C] cmp eax, [rbp+var_2C] jl short loc_1362 mov eax, [rbp+var_10] mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_13DB call ___stack_chk_fail locret_13DB: leave retn
long long func0(long long a1, int a2) { int v2; // edx int v4; // [rsp+1Ch] [rbp-14h] BYREF unsigned int v5; // [rsp+20h] [rbp-10h] BYREF int i; // [rsp+24h] [rbp-Ch] unsigned long long v7; // [rsp+28h] [rbp-8h] v7 = __readfsqword(0x28u); v4 = 0; v5 = 0; for ( i = 0; i < a2; ++i ) { if ( *(_BYTE *)std::string::operator[](a1, i) == 48 ) v2 = 1; else v2 = -1; v4 += v2; if ( v4 < 0 ) v4 = 0; v5 = *(_DWORD *)std::max<int>(&v4, &v5); } return v5; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV dword ptr [RBP + -0x14],0x0 MOV dword ptr [RBP + -0x10],0x0 MOV dword ptr [RBP + -0xc],0x0 JMP 0x001013bc LAB_00101362: MOV EAX,dword ptr [RBP + -0xc] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RDX MOV RDI,RAX CALL 0x001011d0 MOVZX EAX,byte ptr [RAX] CMP AL,0x30 JNZ 0x00101385 MOV EDX,0x1 JMP 0x0010138a LAB_00101385: MOV EDX,0xffffffff LAB_0010138a: MOV EAX,dword ptr [RBP + -0x14] ADD EAX,EDX MOV dword ptr [RBP + -0x14],EAX MOV EAX,dword ptr [RBP + -0x14] TEST EAX,EAX JNS 0x001013a0 MOV dword ptr [RBP + -0x14],0x0 LAB_001013a0: LEA RDX,[RBP + -0x10] LEA RAX,[RBP + -0x14] MOV RSI,RDX MOV RDI,RAX CALL 0x00101706 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x10],EAX ADD dword ptr [RBP + -0xc],0x1 LAB_001013bc: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x2c] JL 0x00101362 MOV EAX,dword ptr [RBP + -0x10] MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x001013db CALL 0x001011f0 LAB_001013db: LEAVE RET
/* func0(std::string const&, int) */ int func0(string *param_1,int param_2) { char *pcVar1; int *piVar2; int iVar3; long in_FS_OFFSET; int local_1c; int local_18; int local_14; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_1c = 0; local_18 = 0; for (local_14 = 0; local_14 < param_2; local_14 = local_14 + 1) { pcVar1 = (char *)std::string::operator[]((ulong)param_1); if (*pcVar1 == '0') { iVar3 = 1; } else { iVar3 = -1; } local_1c = local_1c + iVar3; if (local_1c < 0) { local_1c = 0; } piVar2 = std::max<int>(&local_1c,&local_18); local_18 = *piVar2; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return local_18; }
497
func0
#include <iostream> #include <cassert>
int func0(const std::string& string, int n) { int current_sum = 0; int max_sum = 0; for (int i = 0; i < n; i++) { current_sum += (string[i] == '0' ? 1 : -1); if (current_sum < 0) { current_sum = 0; } max_sum = std::max(current_sum, max_sum); } return max_sum ? max_sum : 0; }
int main() { assert(func0("11000010001", 11) == 6); assert(func0("10111", 5) == 1); assert(func0("11011101100101", 14) == 2); return 0; }
O1
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int): endbr64 test %esi,%esi jle 1270 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x47> mov (%rdi),%rdx lea -0x1(%rsi),%eax lea 0x1(%rdx,%rax,1),%r8 mov $0x0,%ecx mov $0x0,%eax mov $0x0,%edi cmpb $0x30,(%rdx) sete %sil movzbl %sil,%esi lea -0x1(%rax,%rsi,2),%eax test %eax,%eax cmovs %edi,%eax cmp %eax,%ecx cmovl %eax,%ecx add $0x1,%rdx cmp %r8,%rdx jne 124b <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x22> mov %ecx,%eax retq mov $0x0,%ecx jmp 126d <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x44>
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 test esi, esi jle short loc_1249 mov rdx, [rdi] movsxd rsi, esi add rsi, rdx mov ecx, 0 mov eax, 0 jmp short loc_123F loc_1226: sub eax, 1 mov edi, 0 cmovs eax, edi loc_1231: cmp ecx, eax cmovl ecx, eax add rdx, 1 cmp rsi, rdx jz short loc_124E loc_123F: cmp byte ptr [rdx], 30h ; '0' jnz short loc_1226 add eax, 1 jmp short loc_1231 loc_1249: mov ecx, 0 loc_124E: mov eax, ecx retn
long long func0(_BYTE **a1, int a2) { _BYTE *v2; // rdx _BYTE *v3; // rsi unsigned int v4; // ecx int v5; // eax if ( a2 <= 0 ) { return 0; } else { v2 = *a1; v3 = &(*a1)[a2]; v4 = 0; v5 = 0; do { if ( *v2 == 48 ) { ++v5; } else if ( --v5 < 0 ) { v5 = 0; } if ( (int)v4 < v5 ) v4 = v5; ++v2; } while ( v3 != v2 ); } return v4; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101249 MOV RDX,qword ptr [RDI] MOVSXD RSI,ESI ADD RSI,RDX MOV ECX,0x0 MOV EAX,0x0 JMP 0x0010123f LAB_00101226: SUB EAX,0x1 MOV EDI,0x0 CMOVS EAX,EDI LAB_00101231: CMP ECX,EAX CMOVL ECX,EAX ADD RDX,0x1 CMP RSI,RDX JZ 0x0010124e LAB_0010123f: CMP byte ptr [RDX],0x30 JNZ 0x00101226 ADD EAX,0x1 JMP 0x00101231 LAB_00101249: MOV ECX,0x0 LAB_0010124e: MOV EAX,ECX RET
/* func0(std::string const&, int) */ int func0(string *param_1,int param_2) { int iVar1; int iVar2; char *pcVar3; char *pcVar4; if (param_2 < 1) { iVar2 = 0; } else { pcVar3 = *(char **)param_1; pcVar4 = pcVar3 + param_2; iVar2 = 0; iVar1 = 0; do { if (*pcVar3 == '0') { iVar1 = iVar1 + 1; } else { iVar1 = iVar1 + -1; if (iVar1 < 0) { iVar1 = 0; } } if (iVar2 < iVar1) { iVar2 = iVar1; } pcVar3 = pcVar3 + 1; } while (pcVar4 != pcVar3); } return iVar2; }
498
func0
#include <iostream> #include <cassert>
int func0(const std::string& string, int n) { int current_sum = 0; int max_sum = 0; for (int i = 0; i < n; i++) { current_sum += (string[i] == '0' ? 1 : -1); if (current_sum < 0) { current_sum = 0; } max_sum = std::max(current_sum, max_sum); } return max_sum ? max_sum : 0; }
int main() { assert(func0("11000010001", 11) == 6); assert(func0("10111", 5) == 1); assert(func0("11011101100101", 14) == 2); return 0; }
O2
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int): endbr64 test %esi,%esi jle 1430 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x50> mov (%rdi),%rcx sub $0x1,%esi xor %r8d,%r8d xor %eax,%eax xor %edi,%edi lea 0x1(%rcx),%rdx add %rdx,%rsi jmp 1404 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x24> xchg %ax,%ax add $0x1,%rdx cmpb $0x30,(%rcx) sete %cl movzbl %cl,%ecx lea -0x1(%rax,%rcx,2),%eax mov %rdx,%rcx test %eax,%eax cmovs %edi,%eax cmp %eax,%r8d cmovl %eax,%r8d cmp %rdx,%rsi jne 1400 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x20> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq nopw 0x0(%rax,%rax,1)
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 test esi, esi jle short loc_1398 mov rdx, [rdi] movsxd rsi, esi xor ecx, ecx xor eax, eax add rsi, rdx jmp short loc_1379 loc_1360: sub eax, 1 mov edi, 0 cmovs eax, edi cmp ecx, eax cmovl ecx, eax add rdx, 1 cmp rsi, rdx jz short loc_138F loc_1379: cmp byte ptr [rdx], 30h ; '0' jnz short loc_1360 add eax, 1 cmp ecx, eax cmovl ecx, eax add rdx, 1 cmp rsi, rdx jnz short loc_1379 loc_138F: mov eax, ecx retn loc_1398: xor ecx, ecx mov eax, ecx retn
long long func0(_BYTE **a1, int a2) { _BYTE *v2; // rdx unsigned int v3; // ecx int v4; // eax _BYTE *v5; // rsi if ( a2 <= 0 ) return 0LL; v2 = *a1; v3 = 0; v4 = 0; v5 = &(*a1)[a2]; do { while ( *v2 == 48 ) { if ( (int)v3 < ++v4 ) v3 = v4; if ( v5 == ++v2 ) return v3; } if ( --v4 < 0 ) v4 = 0; if ( (int)v3 < v4 ) v3 = v4; ++v2; } while ( v5 != v2 ); return v3; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101398 MOV RDX,qword ptr [RDI] MOVSXD RSI,ESI XOR ECX,ECX XOR EAX,EAX ADD RSI,RDX JMP 0x00101379 LAB_00101360: SUB EAX,0x1 MOV EDI,0x0 CMOVS EAX,EDI CMP ECX,EAX CMOVL ECX,EAX ADD RDX,0x1 CMP RSI,RDX JZ 0x0010138f LAB_00101379: CMP byte ptr [RDX],0x30 JNZ 0x00101360 ADD EAX,0x1 CMP ECX,EAX CMOVL ECX,EAX ADD RDX,0x1 CMP RSI,RDX JNZ 0x00101379 LAB_0010138f: MOV EAX,ECX RET LAB_00101398: XOR ECX,ECX MOV EAX,ECX RET
/* func0(std::string const&, int) */ int func0(string *param_1,int param_2) { int iVar1; int iVar2; char *pcVar3; char *pcVar4; if (param_2 < 1) { return 0; } pcVar3 = *(char **)param_1; iVar2 = 0; iVar1 = 0; pcVar4 = pcVar3 + param_2; do { while (*pcVar3 == '0') { iVar1 = iVar1 + 1; if (iVar2 < iVar1) { iVar2 = iVar1; } pcVar3 = pcVar3 + 1; if (pcVar4 == pcVar3) { return iVar2; } } iVar1 = iVar1 + -1; if (iVar1 < 0) { iVar1 = 0; } if (iVar2 < iVar1) { iVar2 = iVar1; } pcVar3 = pcVar3 + 1; } while (pcVar4 != pcVar3); return iVar2; }
499
func0
#include <iostream> #include <cassert>
int func0(const std::string& string, int n) { int current_sum = 0; int max_sum = 0; for (int i = 0; i < n; i++) { current_sum += (string[i] == '0' ? 1 : -1); if (current_sum < 0) { current_sum = 0; } max_sum = std::max(current_sum, max_sum); } return max_sum ? max_sum : 0; }
int main() { assert(func0("11000010001", 11) == 6); assert(func0("10111", 5) == 1); assert(func0("11011101100101", 14) == 2); return 0; }
O3
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int): endbr64 test %esi,%esi jle 1438 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x58> mov (%rdi),%rcx sub $0x1,%esi xor %r8d,%r8d xor %eax,%eax xor %edi,%edi lea 0x1(%rcx),%rdx add %rdx,%rsi jmp 1419 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x39> xchg %ax,%ax sub $0x1,%eax mov %rdx,%rcx cmovs %edi,%eax cmp %eax,%r8d cmovl %eax,%r8d cmp %rsi,%rdx je 1430 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x50> add $0x1,%rdx cmpb $0x30,(%rcx) jne 1400 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x20> add $0x1,%eax mov %rdx,%rcx cmp %eax,%r8d cmovl %eax,%r8d cmp %rdx,%rsi jne 1415 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi+0x35> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi: endbr64 test esi, esi jle short loc_1398 mov rdx, [rdi] movsxd rsi, esi xor ecx, ecx xor eax, eax add rsi, rdx nop dword ptr [rax] loc_1358: cmp byte ptr [rdx], 30h ; '0' jz short loc_1380 sub eax, 1 mov edi, 0 cmovs eax, edi cmp ecx, eax cmovl ecx, eax add rdx, 1 cmp rsi, rdx jnz short loc_1358 mov eax, ecx retn loc_1380: add eax, 1 cmp ecx, eax cmovl ecx, eax add rdx, 1 cmp rdx, rsi jnz short loc_1358 mov eax, ecx retn loc_1398: xor ecx, ecx mov eax, ecx retn
long long func0(_BYTE **a1, int a2) { _BYTE *v2; // rdx unsigned int v3; // ecx int v4; // eax _BYTE *v5; // rsi if ( a2 <= 0 ) return 0LL; v2 = *a1; v3 = 0; v4 = 0; v5 = &(*a1)[a2]; do { while ( *v2 != 48 ) { if ( --v4 < 0 ) v4 = 0; if ( (int)v3 < v4 ) v3 = v4; if ( v5 == ++v2 ) return v3; } if ( (int)v3 < ++v4 ) v3 = v4; ++v2; } while ( v2 != v5 ); return v3; }
func0: ENDBR64 TEST ESI,ESI JLE 0x00101398 MOV RDX,qword ptr [RDI] MOVSXD RSI,ESI XOR ECX,ECX XOR EAX,EAX ADD RSI,RDX NOP dword ptr [RAX] LAB_00101358: CMP byte ptr [RDX],0x30 JZ 0x00101380 SUB EAX,0x1 MOV EDI,0x0 CMOVS EAX,EDI CMP ECX,EAX CMOVL ECX,EAX ADD RDX,0x1 CMP RSI,RDX JNZ 0x00101358 MOV EAX,ECX RET LAB_00101380: ADD EAX,0x1 CMP ECX,EAX CMOVL ECX,EAX ADD RDX,0x1 CMP RDX,RSI JNZ 0x00101358 MOV EAX,ECX RET LAB_00101398: XOR ECX,ECX MOV EAX,ECX RET
/* func0(std::string const&, int) */ int func0(string *param_1,int param_2) { int iVar1; int iVar2; char *pcVar3; char *pcVar4; if (param_2 < 1) { return 0; } pcVar3 = *(char **)param_1; iVar2 = 0; iVar1 = 0; pcVar4 = pcVar3 + param_2; do { while (*pcVar3 == '0') { iVar1 = iVar1 + 1; if (iVar2 < iVar1) { iVar2 = iVar1; } pcVar3 = pcVar3 + 1; if (pcVar3 == pcVar4) { return iVar2; } } iVar1 = iVar1 + -1; if (iVar1 < 0) { iVar1 = 0; } if (iVar2 < iVar1) { iVar2 = iVar1; } pcVar3 = pcVar3 + 1; } while (pcVar4 != pcVar3); return iVar2; }
500
func0
#include <iostream> #include <cassert>
int func0(int a, int b) { int sum = 0; for (int i = 1; i < std::min(a, b); i++) { if (a % i == 0 && b % i == 0) { sum += i; } } return sum; }
int main() { assert(func0(10, 15) == 6); assert(func0(100, 150) == 93); assert(func0(4, 6) == 3); return 0; }
O0
cpp
func0(int, int): endbr64 push %rbp mov %rsp,%rbp sub $0x20,%rsp mov %edi,-0x14(%rbp) mov %esi,-0x18(%rbp) movl $0x0,-0x8(%rbp) movl $0x1,-0x4(%rbp) lea -0x18(%rbp),%rdx lea -0x14(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1301 <_ZSt3minIiERKT_S2_S2_> mov (%rax),%eax cmp %eax,-0x4(%rbp) setl %al test %al,%al je 11ee <_Z5func0ii+0x65> mov -0x14(%rbp),%eax cltd idivl -0x4(%rbp) mov %edx,%eax test %eax,%eax jne 11e8 <_Z5func0ii+0x5f> mov -0x18(%rbp),%eax cltd idivl -0x4(%rbp) mov %edx,%eax test %eax,%eax jne 11e8 <_Z5func0ii+0x5f> mov -0x4(%rbp),%eax add %eax,-0x8(%rbp) addl $0x1,-0x4(%rbp) jmp 11a9 <_Z5func0ii+0x20> mov -0x8(%rbp),%eax leaveq retq
_Z5func0ii: endbr64 push rbp mov rbp, rsp sub rsp, 20h mov [rbp+var_14], edi mov [rbp+var_18], esi mov [rbp+var_8], 0 mov [rbp+var_4], 1 jmp short loc_118F loc_116B: mov eax, [rbp+var_14] cdq idiv [rbp+var_4] mov eax, edx test eax, eax jnz short loc_118B mov eax, [rbp+var_18] cdq idiv [rbp+var_4] mov eax, edx test eax, eax jnz short loc_118B mov eax, [rbp+var_4] add [rbp+var_8], eax loc_118B: add [rbp+var_4], 1 loc_118F: lea rdx, [rbp+var_18] lea rax, [rbp+var_14] mov rsi, rdx mov rdi, rax call _ZSt3minIiERKT_S2_S2_; std::min<int>(int const&,int const&) mov eax, [rax] cmp [rbp+var_4], eax setl al test al, al jnz short loc_116B mov eax, [rbp+var_8] leave retn
long long func0(int a1, int a2) { int *v2; // rax int v4; // [rsp+8h] [rbp-18h] BYREF _DWORD v5[3]; // [rsp+Ch] [rbp-14h] BYREF unsigned int v6; // [rsp+18h] [rbp-8h] int i; // [rsp+1Ch] [rbp-4h] v5[0] = a1; v4 = a2; v6 = 0; for ( i = 1; ; ++i ) { v2 = (int *)std::min<int>(v5, &v4); if ( i >= *v2 ) break; if ( !(v5[0] % i) && !(v4 % i) ) v6 += i; } return v6; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x20 MOV dword ptr [RBP + -0x14],EDI MOV dword ptr [RBP + -0x18],ESI MOV dword ptr [RBP + -0x8],0x0 MOV dword ptr [RBP + -0x4],0x1 JMP 0x0010118f LAB_0010116b: MOV EAX,dword ptr [RBP + -0x14] CDQ IDIV dword ptr [RBP + -0x4] MOV EAX,EDX TEST EAX,EAX JNZ 0x0010118b MOV EAX,dword ptr [RBP + -0x18] CDQ IDIV dword ptr [RBP + -0x4] MOV EAX,EDX TEST EAX,EAX JNZ 0x0010118b MOV EAX,dword ptr [RBP + -0x4] ADD dword ptr [RBP + -0x8],EAX LAB_0010118b: ADD dword ptr [RBP + -0x4],0x1 LAB_0010118f: LEA RDX,[RBP + -0x18] LEA RAX,[RBP + -0x14] MOV RSI,RDX MOV RDI,RAX CALL 0x00101276 MOV EAX,dword ptr [RAX] CMP dword ptr [RBP + -0x4],EAX SETL AL TEST AL,AL JNZ 0x0010116b MOV EAX,dword ptr [RBP + -0x8] LEAVE RET
/* func0(int, int) */ int func0(int param_1,int param_2) { int *piVar1; int local_20; int local_1c [3]; int local_10; int local_c; local_10 = 0; local_c = 1; local_20 = param_2; local_1c[0] = param_1; while( true ) { piVar1 = std::min<int>(local_1c,&local_20); if (*piVar1 <= local_c) break; if ((local_1c[0] % local_c == 0) && (local_20 % local_c == 0)) { local_10 = local_10 + local_c; } local_c = local_c + 1; } return local_10; }
501
func0
#include <iostream> #include <cassert>
int func0(int a, int b) { int sum = 0; for (int i = 1; i < std::min(a, b); i++) { if (a % i == 0 && b % i == 0) { sum += i; } } return sum; }
int main() { assert(func0(10, 15) == 6); assert(func0(100, 150) == 93); assert(func0(4, 6) == 3); return 0; }
O1
cpp
func0(int, int): endbr64 cmp %esi,%edi mov %esi,%r9d cmovle %edi,%r9d cmp $0x1,%r9d jle 11cb <_Z5func0ii+0x42> mov $0x1,%ecx mov $0x0,%r8d jmp 11b1 <_Z5func0ii+0x28> add $0x1,%ecx cmp %r9d,%ecx je 11d1 <_Z5func0ii+0x48> mov %edi,%eax cltd idiv %ecx test %edx,%edx jne 11a9 <_Z5func0ii+0x20> mov %esi,%eax cltd idiv %ecx lea (%r8,%rcx,1),%eax test %edx,%edx cmove %eax,%r8d jmp 11a9 <_Z5func0ii+0x20> mov $0x0,%r8d mov %r8d,%eax retq
_Z5func0ii: endbr64 cmp edi, esi mov r9d, esi cmovle r9d, edi cmp r9d, 1 jle short loc_118B mov ecx, 1 mov r8d, 0 jmp short loc_1171 loc_1169: add ecx, 1 cmp ecx, r9d jz short loc_1191 loc_1171: mov eax, edi cdq idiv ecx test edx, edx jnz short loc_1169 mov eax, esi cdq idiv ecx lea eax, [r8+rcx] test edx, edx cmovz r8d, eax jmp short loc_1169 loc_118B: mov r8d, 0 loc_1191: mov eax, r8d retn
long long func0(int a1, int a2) { int v2; // r9d int v3; // ecx unsigned int v4; // r8d v2 = a2; if ( a1 <= a2 ) v2 = a1; if ( v2 <= 1 ) { return 0; } else { v3 = 1; v4 = 0; do { if ( !(a1 % v3) && !(a2 % v3) ) v4 += v3; ++v3; } while ( v3 != v2 ); } return v4; }
func0: ENDBR64 CMP EDI,ESI MOV R9D,ESI CMOVLE R9D,EDI CMP R9D,0x1 JLE 0x0010118b MOV ECX,0x1 MOV R8D,0x0 JMP 0x00101171 LAB_00101169: ADD ECX,0x1 CMP ECX,R9D JZ 0x00101191 LAB_00101171: MOV EAX,EDI CDQ IDIV ECX TEST EDX,EDX JNZ 0x00101169 MOV EAX,ESI CDQ IDIV ECX LEA EAX,[R8 + RCX*0x1] TEST EDX,EDX CMOVZ R8D,EAX JMP 0x00101169 LAB_0010118b: MOV R8D,0x0 LAB_00101191: MOV EAX,R8D RET
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; int iVar2; int iVar3; iVar3 = param_2; if (param_1 <= param_2) { iVar3 = param_1; } if (iVar3 < 2) { iVar2 = 0; } else { iVar1 = 1; iVar2 = 0; do { if ((param_1 % iVar1 == 0) && (param_2 % iVar1 == 0)) { iVar2 = iVar2 + iVar1; } iVar1 = iVar1 + 1; } while (iVar1 != iVar3); } return iVar2; }
502
func0
#include <iostream> #include <cassert>
int func0(int a, int b) { int sum = 0; for (int i = 1; i < std::min(a, b); i++) { if (a % i == 0 && b % i == 0) { sum += i; } } return sum; }
int main() { assert(func0(10, 15) == 6); assert(func0(100, 150) == 93); assert(func0(4, 6) == 3); return 0; }
O2
cpp
func0(int, int): endbr64 cmp %esi,%edi mov %esi,%r9d cmovle %edi,%r9d cmp $0x1,%r9d jle 12e8 <_Z5func0ii+0x48> mov $0x1,%ecx xor %r8d,%r8d nopl 0x0(%rax,%rax,1) mov %edi,%eax cltd idiv %ecx test %edx,%edx jne 12d8 <_Z5func0ii+0x38> mov %esi,%eax cltd idiv %ecx lea (%r8,%rcx,1),%eax test %edx,%edx cmove %eax,%r8d add $0x1,%ecx cmp %r9d,%ecx jne 12c0 <_Z5func0ii+0x20> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq
_Z5func0ii: endbr64 cmp edi, esi mov r9d, esi cmovle r9d, edi cmp r9d, 1 jle short loc_1248 mov ecx, 1 xor r8d, r8d nop dword ptr [rax+rax+00h] loc_1220: mov eax, edi cdq idiv ecx test edx, edx jnz short loc_1238 mov eax, esi cdq idiv ecx lea eax, [r8+rcx] test edx, edx cmovz r8d, eax loc_1238: add ecx, 1 cmp ecx, r9d jnz short loc_1220 mov eax, r8d retn loc_1248: xor r8d, r8d mov eax, r8d retn
long long func0(int a1, int a2) { int v2; // r9d int v3; // ecx unsigned int v4; // r8d v2 = a2; if ( a1 <= a2 ) v2 = a1; if ( v2 <= 1 ) return 0LL; v3 = 1; v4 = 0; do { if ( !(a1 % v3) && !(a2 % v3) ) v4 += v3; ++v3; } while ( v3 != v2 ); return v4; }
func0: ENDBR64 CMP EDI,ESI MOV R9D,ESI CMOVLE R9D,EDI CMP R9D,0x1 JLE 0x00101248 MOV ECX,0x1 XOR R8D,R8D NOP dword ptr [RAX + RAX*0x1] LAB_00101220: MOV EAX,EDI CDQ IDIV ECX TEST EDX,EDX JNZ 0x00101238 MOV EAX,ESI CDQ IDIV ECX LEA EAX,[R8 + RCX*0x1] TEST EDX,EDX CMOVZ R8D,EAX LAB_00101238: ADD ECX,0x1 CMP ECX,R9D JNZ 0x00101220 MOV EAX,R8D RET LAB_00101248: XOR R8D,R8D MOV EAX,R8D RET
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; int iVar2; int iVar3; iVar3 = param_2; if (param_1 <= param_2) { iVar3 = param_1; } if (1 < iVar3) { iVar1 = 1; iVar2 = 0; do { if (param_1 % iVar1 == 0) { if (param_2 % iVar1 == 0) { iVar2 = iVar2 + iVar1; } } iVar1 = iVar1 + 1; } while (iVar1 != iVar3); return iVar2; } return 0; }
503
func0
#include <iostream> #include <cassert>
int func0(int a, int b) { int sum = 0; for (int i = 1; i < std::min(a, b); i++) { if (a % i == 0 && b % i == 0) { sum += i; } } return sum; }
int main() { assert(func0(10, 15) == 6); assert(func0(100, 150) == 93); assert(func0(4, 6) == 3); return 0; }
O3
cpp
func0(int, int): endbr64 cmp %esi,%edi mov %esi,%r9d cmovle %edi,%r9d cmp $0x1,%r9d jle 1288 <_Z5func0ii+0x48> mov $0x1,%ecx xor %r8d,%r8d nopl 0x0(%rax,%rax,1) mov %edi,%eax cltd idiv %ecx test %edx,%edx jne 1278 <_Z5func0ii+0x38> mov %esi,%eax cltd idiv %ecx lea (%r8,%rcx,1),%eax test %edx,%edx cmove %eax,%r8d add $0x1,%ecx cmp %r9d,%ecx jne 1260 <_Z5func0ii+0x20> mov %r8d,%eax retq nopl 0x0(%rax) xor %r8d,%r8d mov %r8d,%eax retq
_Z5func0ii: endbr64 cmp edi, esi mov r9d, esi cmovle r9d, edi cmp r9d, 1 jle short loc_11F8 mov ecx, 1 xor r8d, r8d nop dword ptr [rax+rax+00h] loc_11D0: mov eax, edi cdq idiv ecx test edx, edx jnz short loc_11E8 mov eax, esi cdq idiv ecx lea eax, [r8+rcx] test edx, edx cmovz r8d, eax loc_11E8: add ecx, 1 cmp ecx, r9d jnz short loc_11D0 mov eax, r8d retn loc_11F8: xor r8d, r8d mov eax, r8d retn
long long func0(int a1, int a2) { int v2; // r9d int v3; // ecx unsigned int v4; // r8d v2 = a2; if ( a1 <= a2 ) v2 = a1; if ( v2 <= 1 ) return 0LL; v3 = 1; v4 = 0; do { if ( !(a1 % v3) && !(a2 % v3) ) v4 += v3; ++v3; } while ( v3 != v2 ); return v4; }
func0: ENDBR64 CMP EDI,ESI MOV R9D,ESI CMOVLE R9D,EDI CMP R9D,0x1 JLE 0x001011f8 MOV ECX,0x1 XOR R8D,R8D NOP dword ptr [RAX + RAX*0x1] LAB_001011d0: MOV EAX,EDI CDQ IDIV ECX TEST EDX,EDX JNZ 0x001011e8 MOV EAX,ESI CDQ IDIV ECX LEA EAX,[R8 + RCX*0x1] TEST EDX,EDX CMOVZ R8D,EAX LAB_001011e8: ADD ECX,0x1 CMP ECX,R9D JNZ 0x001011d0 MOV EAX,R8D RET LAB_001011f8: XOR R8D,R8D MOV EAX,R8D RET
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; int iVar2; int iVar3; iVar3 = param_2; if (param_1 <= param_2) { iVar3 = param_1; } if (1 < iVar3) { iVar1 = 1; iVar2 = 0; do { if (param_1 % iVar1 == 0) { if (param_2 % iVar1 == 0) { iVar2 = iVar2 + iVar1; } } iVar1 = iVar1 + 1; } while (iVar1 != iVar3); return iVar2; } return 0; }
504
func0
#include <cassert>
int func0(int x, int y) { if (y < 0) { return -func0(x, -y); } else if (y == 0) { return 0; } else if (y == 1) { return x; } else { return x + func0(x, y - 1); } }
int main() { assert(func0(10, 20) == 200); assert(func0(5, 10) == 50); assert(func0(4, 8) == 32); return 0; }
O0
cpp
func0(int, int): endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %edi,-0x4(%rbp) mov %esi,-0x8(%rbp) cmpl $0x0,-0x8(%rbp) jns 1178 <_Z5func0ii+0x2f> mov -0x8(%rbp),%eax neg %eax mov %eax,%edx mov -0x4(%rbp),%eax mov %edx,%esi mov %eax,%edi callq 1149 <_Z5func0ii> neg %eax jmp 11a7 <_Z5func0ii+0x5e> cmpl $0x0,-0x8(%rbp) jne 1185 <_Z5func0ii+0x3c> mov $0x0,%eax jmp 11a7 <_Z5func0ii+0x5e> cmpl $0x1,-0x8(%rbp) jne 1190 <_Z5func0ii+0x47> mov -0x4(%rbp),%eax jmp 11a7 <_Z5func0ii+0x5e> mov -0x8(%rbp),%eax lea -0x1(%rax),%edx mov -0x4(%rbp),%eax mov %edx,%esi mov %eax,%edi callq 1149 <_Z5func0ii> mov -0x4(%rbp),%edx add %edx,%eax leaveq retq
_Z5func0ii: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov [rbp+var_4], edi mov [rbp+var_8], esi cmp [rbp+var_8], 0 jns short loc_1178 mov eax, [rbp+var_8] neg eax mov edx, eax mov eax, [rbp+var_4] mov esi, edx; int mov edi, eax; int call _Z5func0ii; func0(int,int) neg eax jmp short locret_11A7 loc_1178: cmp [rbp+var_8], 0 jnz short loc_1185 mov eax, 0 jmp short locret_11A7 loc_1185: cmp [rbp+var_8], 1 jnz short loc_1190 mov eax, [rbp+var_4] jmp short locret_11A7 loc_1190: mov eax, [rbp+var_8] lea edx, [rax-1] mov eax, [rbp+var_4] mov esi, edx; int mov edi, eax; int call _Z5func0ii; func0(int,int) mov edx, [rbp+var_4] add eax, edx locret_11A7: leave retn
long long func0(unsigned int a1, int a2) { if ( a2 < 0 ) return (unsigned int)-func0(a1, -a2); if ( !a2 ) return 0LL; if ( a2 == 1 ) return a1; return a1 + (unsigned int)func0(a1, a2 - 1); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV dword ptr [RBP + -0x4],EDI MOV dword ptr [RBP + -0x8],ESI CMP dword ptr [RBP + -0x8],0x0 JNS 0x00101178 MOV EAX,dword ptr [RBP + -0x8] NEG EAX MOV EDX,EAX MOV EAX,dword ptr [RBP + -0x4] MOV ESI,EDX MOV EDI,EAX CALL 0x00101149 NEG EAX JMP 0x001011a7 LAB_00101178: CMP dword ptr [RBP + -0x8],0x0 JNZ 0x00101185 MOV EAX,0x0 JMP 0x001011a7 LAB_00101185: CMP dword ptr [RBP + -0x8],0x1 JNZ 0x00101190 MOV EAX,dword ptr [RBP + -0x4] JMP 0x001011a7 LAB_00101190: MOV EAX,dword ptr [RBP + -0x8] LEA EDX,[RAX + -0x1] MOV EAX,dword ptr [RBP + -0x4] MOV ESI,EDX MOV EDI,EAX CALL 0x00101149 MOV EDX,dword ptr [RBP + -0x4] ADD EAX,EDX LAB_001011a7: LEAVE RET
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; if (param_2 < 0) { iVar1 = func0(param_1,-param_2); param_1 = -iVar1; } else if (param_2 == 0) { param_1 = 0; } else if (param_2 != 1) { iVar1 = func0(param_1,param_2 + -1); param_1 = iVar1 + param_1; } return param_1; }
505
func0
#include <cassert>
int func0(int x, int y) { if (y < 0) { return -func0(x, -y); } else if (y == 0) { return 0; } else if (y == 1) { return x; } else { return x + func0(x, y - 1); } }
int main() { assert(func0(10, 20) == 200); assert(func0(5, 10) == 50); assert(func0(4, 8) == 32); return 0; }
O1
cpp
func0(int, int): endbr64 push %rbx mov %edi,%ebx test %esi,%esi js 116b <_Z5func0ii+0x22> mov %esi,%eax je 1169 <_Z5func0ii+0x20> mov %edi,%eax cmp $0x1,%esi je 1169 <_Z5func0ii+0x20> sub $0x1,%esi callq 1149 <_Z5func0ii> add %ebx,%eax pop %rbx retq neg %esi callq 1149 <_Z5func0ii> neg %eax jmp 1169 <_Z5func0ii+0x20>
_Z5func0ii: endbr64 push rbx mov ebx, edi test esi, esi js short loc_116B mov eax, esi jz short loc_1169 mov eax, edi cmp esi, 1 jz short loc_1169 sub esi, 1; int call _Z5func0ii; func0(int,int) add eax, ebx loc_1169: pop rbx retn loc_116B: neg esi; int call _Z5func0ii; func0(int,int) neg eax jmp short loc_1169
long long func0(unsigned int a1, int a2) { long long result; // rax if ( a2 < 0 ) return (unsigned int)-func0(a1, -a2); result = (unsigned int)a2; if ( a2 ) { result = a1; if ( a2 != 1 ) return a1 + (unsigned int)func0(a1, a2 - 1); } return result; }
func0: ENDBR64 PUSH RBX MOV EBX,EDI TEST ESI,ESI JS 0x0010116b MOV EAX,ESI JZ 0x00101169 MOV EAX,EDI CMP ESI,0x1 JZ 0x00101169 SUB ESI,0x1 CALL 0x00101149 ADD EAX,EBX LAB_00101169: POP RBX RET LAB_0010116b: NEG ESI CALL 0x00101149 NEG EAX JMP 0x00101169
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; if (param_2 < 0) { iVar1 = func0(param_1,-param_2); iVar1 = -iVar1; } else { iVar1 = param_2; if ((param_2 != 0) && (iVar1 = param_1, param_2 != 1)) { iVar1 = func0(param_1,param_2 + -1); iVar1 = iVar1 + param_1; } } return iVar1; }
506
func0
#include <cassert>
int func0(int x, int y) { if (y < 0) { return -func0(x, -y); } else if (y == 0) { return 0; } else if (y == 1) { return x; } else { return x + func0(x, y - 1); } }
int main() { assert(func0(10, 20) == 200); assert(func0(5, 10) == 50); assert(func0(4, 8) == 32); return 0; }
O2
cpp
func0(int, int): endbr64 mov $0x1,%eax xor %r8d,%r8d nopl 0x0(%rax) test %esi,%esi js 12ba <_Z5func0ii+0x2a> je 12c0 <_Z5func0ii+0x30> mov %eax,%edx imul %edi,%edx add %edx,%r8d cmp $0x1,%esi je 12c0 <_Z5func0ii+0x30> sub $0x1,%esi test %esi,%esi jns 12a4 <_Z5func0ii+0x14> neg %esi neg %eax jmp 12a0 <_Z5func0ii+0x10> mov %r8d,%eax retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
_Z5func0ii: endbr64 mov ecx, edi mov eax, esi test esi, esi jns short loc_1240 neg eax mov edi, 0FFFFFFFFh mov edx, eax xor eax, eax loc_1217: imul edi, ecx lea ecx, [rdx-1] test dl, 1 jnz short loc_1235 mov eax, edi mov edx, ecx jmp short loc_1235 loc_1230: add eax, edi sub edx, 2 loc_1235: add eax, edi cmp edx, 1 jnz short loc_1230 locret_123C: retn loc_1240: jz short locret_123C mov edx, esi mov edi, 1 xor eax, eax jmp short loc_1217
long long func0(int a1, int a2) { long long result; // rax int v4; // edi int v5; // edx int v6; // eax int v7; // edi result = (unsigned int)a2; if ( a2 >= 0 ) { if ( !a2 ) return result; v5 = a2; v4 = 1; v6 = 0; } else { v4 = -1; v5 = -a2; v6 = 0; } v7 = a1 * v4; if ( (v5 & 1) == 0 ) { v6 = v7; --v5; } while ( 1 ) { result = (unsigned int)(v7 + v6); if ( v5 == 1 ) break; v6 = v7 + result; v5 -= 2; } return result; }
func0: ENDBR64 MOV ECX,EDI MOV EAX,ESI TEST ESI,ESI JNS 0x00101240 NEG EAX MOV EDI,0xffffffff MOV EDX,EAX XOR EAX,EAX LAB_00101217: IMUL EDI,ECX LEA ECX,[RDX + -0x1] TEST DL,0x1 JNZ 0x00101235 MOV EAX,EDI MOV EDX,ECX JMP 0x00101235 LAB_00101230: ADD EAX,EDI SUB EDX,0x2 LAB_00101235: ADD EAX,EDI CMP EDX,0x1 JNZ 0x00101230 LAB_0010123c: RET LAB_00101240: JZ 0x0010123c MOV EDX,ESI MOV EDI,0x1 XOR EAX,EAX JMP 0x00101217
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; int iVar2; if (param_2 < 0) { param_2 = -param_2; iVar2 = -1; } else { if (param_2 == 0) { return 0; } iVar2 = 1; } iVar2 = iVar2 * param_1; iVar1 = 0; if ((param_2 & 1U) == 0) { param_2 = param_2 - 1; iVar1 = iVar2; } for (; param_2 != 1; param_2 = param_2 - 2) { iVar1 = iVar1 + iVar2 + iVar2; } return iVar1 + iVar2; }
507
func0
#include <cassert>
int func0(int x, int y) { if (y < 0) { return -func0(x, -y); } else if (y == 0) { return 0; } else if (y == 1) { return x; } else { return x + func0(x, y - 1); } }
int main() { assert(func0(10, 20) == 200); assert(func0(5, 10) == 50); assert(func0(4, 8) == 32); return 0; }
O3
cpp
func0(int, int): endbr64 mov $0x1,%eax xor %r8d,%r8d nopl 0x0(%rax) test %esi,%esi js 12ba <_Z5func0ii+0x2a> je 12c0 <_Z5func0ii+0x30> mov %eax,%edx imul %edi,%edx add %edx,%r8d cmp $0x1,%esi je 12c0 <_Z5func0ii+0x30> sub $0x1,%esi test %esi,%esi jns 12a4 <_Z5func0ii+0x14> neg %esi neg %eax jmp 12a0 <_Z5func0ii+0x10> mov %r8d,%eax retq nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
_Z5func0ii: endbr64 mov eax, esi test esi, esi jns short loc_1180 neg eax mov ecx, 0FFFFFFFFh mov edx, eax xor eax, eax loc_1155: imul edi, ecx lea ecx, [rdx-1] test dl, 1 jnz short loc_1175 mov eax, edi mov edx, ecx jmp short loc_1175 loc_1170: add eax, edi sub edx, 2 loc_1175: add eax, edi cmp edx, 1 jnz short loc_1170 locret_117C: retn loc_1180: jz short locret_117C mov edx, esi mov ecx, 1 xor eax, eax jmp short loc_1155
long long func0(int a1, int a2) { long long result; // rax int v3; // ecx int v4; // edx int v5; // eax int v6; // edi result = (unsigned int)a2; if ( a2 >= 0 ) { if ( !a2 ) return result; v4 = a2; v3 = 1; v5 = 0; } else { v3 = -1; v4 = -a2; v5 = 0; } v6 = v3 * a1; if ( (v4 & 1) == 0 ) { v5 = v6; --v4; } while ( 1 ) { result = (unsigned int)(v6 + v5); if ( v4 == 1 ) break; v5 = v6 + result; v4 -= 2; } return result; }
func0: ENDBR64 MOV EAX,ESI TEST ESI,ESI JNS 0x00101180 NEG EAX MOV ECX,0xffffffff MOV EDX,EAX XOR EAX,EAX LAB_00101155: IMUL EDI,ECX LEA ECX,[RDX + -0x1] TEST DL,0x1 JNZ 0x00101175 MOV EAX,EDI MOV EDX,ECX JMP 0x00101175 LAB_00101170: ADD EAX,EDI SUB EDX,0x2 LAB_00101175: ADD EAX,EDI CMP EDX,0x1 JNZ 0x00101170 LAB_0010117c: RET LAB_00101180: JZ 0x0010117c MOV EDX,ESI MOV ECX,0x1 XOR EAX,EAX JMP 0x00101155
/* func0(int, int) */ int func0(int param_1,int param_2) { int iVar1; int iVar2; if (param_2 < 0) { param_2 = -param_2; iVar2 = -1; } else { if (param_2 == 0) { return 0; } iVar2 = 1; } iVar2 = param_1 * iVar2; iVar1 = 0; if ((param_2 & 1U) == 0) { param_2 = param_2 - 1; iVar1 = iVar2; } for (; param_2 != 1; param_2 = param_2 - 2) { iVar1 = iVar1 + iVar2 + iVar2; } return iVar1 + iVar2; }
508
func0
#include <iostream> #include <vector> #include <string> #include <assert.h> #include <sstream>
std::vector<std::string> func0(int n, std::string str) { std::vector<std::string> word_len; std::string temp; std::istringstream iss(str); while (iss >> temp) { if (temp.size() > n) { word_len.push_back(temp); } } return word_len; }
int main() { std::vector<std::string> result; result = func0(3, "python is a programming language"); assert((result == std::vector<std::string>{"python", "programming", "language"})); result = func0(2, "writing a program"); assert((result == std::vector<std::string>{"writing", "program"})); result = func0(5, "sorting list"); assert((result == std::vector<std::string>{"sorting"})); return 0; }
O0
cpp
func0(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x1d8,%rsp mov %rdi,-0x1c8(%rbp) mov %esi,-0x1cc(%rbp) mov %rdx,-0x1d8(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x1c8(%rbp),%rax mov %rax,%rdi callq 317e <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEC1Ev> lea -0x1c0(%rbp),%rax mov %rax,%rdi callq 2430 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev@plt> mov -0x1d8(%rbp),%rcx lea -0x1a0(%rbp),%rax mov $0x8,%edx mov %rcx,%rsi mov %rax,%rdi callq 2470 <_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@plt> lea -0x1c0(%rbp),%rdx lea -0x1a0(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2410 <_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@plt> mov (%rax),%rdx sub $0x18,%rdx mov (%rdx),%rdx add %rdx,%rax mov %rax,%rdi callq 2400 <_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv@plt> test %al,%al je 2687 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xde> lea -0x1c0(%rbp),%rax mov %rax,%rdi callq 2330 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv@plt> mov -0x1cc(%rbp),%edx movslq %edx,%rdx cmp %rdx,%rax seta %al test %al,%al je 2618 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x6f> lea -0x1c0(%rbp),%rdx mov -0x1c8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 3336 <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE9push_backERKS5_> jmp 2618 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x6f> lea -0x1a0(%rbp),%rax mov %rax,%rdi callq 22d0 <_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev@plt> lea -0x1c0(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 2705 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x15c> jmp 2700 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x157> endbr64 mov %rax,%rbx lea -0x1a0(%rbp),%rax mov %rax,%rdi callq 22d0 <_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev@plt> jmp 26d7 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x12e> endbr64 mov %rax,%rbx lea -0x1c0(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov -0x1c8(%rbp),%rax mov %rax,%rdi callq 32ee <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev> mov %rbx,%rax mov %rax,%rdi callq 2480 <_Unwind_Resume@plt> callq 23e0 <__stack_chk_fail@plt> mov -0x1c8(%rbp),%rax add $0x1d8,%rsp pop %rbx pop %rbp retq
_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 1D8h mov [rbp+var_1C8], rdi mov [rbp+var_1CC], esi mov [rbp+var_1D8], rdx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+var_1C8] mov rdi, rax call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEC2Ev; std::vector<std::string>::vector(void) lea rax, [rbp+var_1C0] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev; std::string::basic_string(void) mov rcx, [rbp+var_1D8] lea rax, [rbp+var_1A0] mov edx, 8 mov rsi, rcx mov rdi, rax call __ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode; std::istringstream::basic_istringstream(std::string const&,std::_Ios_Openmode) jmp short loc_25F5 loc_25BA: lea rax, [rbp+var_1C0] mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv; std::string::size(void) mov edx, [rbp+var_1CC] movsxd rdx, edx cmp rdx, rax setb al test al, al jz short loc_25F5 lea rdx, [rbp+var_1C0] mov rax, [rbp+var_1C8] mov rsi, rdx mov rdi, rax call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE9push_backERKS5_; std::vector<std::string>::push_back(std::string const&) loc_25F5: lea rdx, [rbp+var_1C0] lea rax, [rbp+var_1A0] mov rsi, rdx mov rdi, rax call __ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE; std::operator>><char>(std::istream &,std::string &) mov rdx, [rax] sub rdx, 18h mov rdx, [rdx] add rax, rdx mov rdi, rax call __ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv; std::ios::operator bool(void) test al, al jnz short loc_25BA nop lea rax, [rbp+var_1A0] mov rdi, rax call __ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev; std::istringstream::~istringstream() lea rax, [rbp+var_1C0] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() nop mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_26B9 jmp short loc_26B4 endbr64 mov rbx, rax lea rax, [rbp+var_1A0] mov rdi, rax call __ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev; std::istringstream::~istringstream() jmp short loc_2677 endbr64 mov rbx, rax loc_2677: lea rax, [rbp+var_1C0] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() mov rax, [rbp+var_1C8] mov rdi, rax call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED2Ev; std::vector<std::string>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_26AC call ___stack_chk_fail loc_26AC: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_26B4: call ___stack_chk_fail loc_26B9: mov rax, [rbp+var_1C8] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, int a2, long long a3) { _QWORD *v3; // rax _BYTE v6[32]; // [rsp+20h] [rbp-1C0h] BYREF _BYTE v7[392]; // [rsp+40h] [rbp-1A0h] BYREF unsigned long long v8; // [rsp+1C8h] [rbp-18h] v8 = __readfsqword(0x28u); std::vector<std::string>::vector(a1); std::string::basic_string(v6); std::istringstream::basic_istringstream(v7, a3, 8LL); while ( 1 ) { v3 = (_QWORD *)std::operator>><char>(v7, v6); if ( !(unsigned __int8)std::ios::operator bool((char *)v3 + *(_QWORD *)(*v3 - 24LL)) ) break; if ( a2 < (unsigned long long)std::string::size(v6) ) std::vector<std::string>::push_back(a1, v6); } std::istringstream::~istringstream(v7); std::string::~string(v6); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x1d8 MOV qword ptr [RBP + -0x1c8],RDI MOV dword ptr [RBP + -0x1cc],ESI MOV qword ptr [RBP + -0x1d8],RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x1c8] MOV RDI,RAX CALL 0x00103152 LEA RAX,[RBP + -0x1c0] MOV RDI,RAX CALL 0x001023f0 MOV RCX,qword ptr [RBP + -0x1d8] LEA RAX,[RBP + -0x1a0] MOV EDX,0x8 MOV RSI,RCX MOV RDI,RAX LAB_001025b3: CALL 0x00102420 JMP 0x001025f5 LAB_001025ba: LEA RAX,[RBP + -0x1c0] MOV RDI,RAX CALL 0x00102300 MOV EDX,dword ptr [RBP + -0x1cc] MOVSXD RDX,EDX CMP RDX,RAX SETC AL TEST AL,AL JZ 0x001025f5 LEA RDX,[RBP + -0x1c0] MOV RAX,qword ptr [RBP + -0x1c8] MOV RSI,RDX MOV RDI,RAX LAB_001025f0: CALL 0x001032e6 LAB_001025f5: LEA RDX,[RBP + -0x1c0] LEA RAX,[RBP + -0x1a0] MOV RSI,RDX MOV RDI,RAX CALL 0x001023d0 MOV RDX,qword ptr [RAX] SUB RDX,0x18 MOV RDX,qword ptr [RDX] ADD RAX,RDX MOV RDI,RAX CALL 0x001023c0 TEST AL,AL JNZ 0x001025ba NOP LEA RAX,[RBP + -0x1a0] MOV RDI,RAX CALL 0x001022a0 LEA RAX,[RBP + -0x1c0] MOV RDI,RAX CALL 0x001022d0 NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001026b9 JMP 0x001026b4 LAB_001026b4: CALL 0x001023a0 LAB_001026b9: MOV RAX,qword ptr [RBP + -0x1c8] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(int, std::string) */ vector<std::string,std::allocator<std::string>> * func0(vector<std::string,std::allocator<std::string>> *param_1,int param_2,string *param_3) { bool bVar1; ulong uVar2; istream *piVar3; long in_FS_OFFSET; string local_1c8 [32]; istringstream local_1a8 [392]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); std::vector<std::string,std::allocator<std::string>>::vector(param_1); std::string::string(local_1c8); /* try { // try from 001025b3 to 001025b7 has its CatchHandler @ 00102670 */ std::istringstream::istringstream(local_1a8,param_3,8); while( true ) { piVar3 = std::operator>>((istream *)local_1a8,local_1c8); bVar1 = std::ios::operator_cast_to_bool((ios *)(piVar3 + *(long *)(*(long *)piVar3 + -0x18))); if (!bVar1) break; uVar2 = std::string::size(); if ((ulong)(long)param_2 < uVar2) { /* try { // try from 001025f0 to 00102622 has its CatchHandler @ 00102658 */ std::vector<std::string,std::allocator<std::string>>::push_back(param_1,local_1c8); } } std::istringstream::~istringstream(local_1a8); std::string::~string(local_1c8); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
509
func0
#include <iostream> #include <vector> #include <string> #include <assert.h> #include <sstream>
std::vector<std::string> func0(int n, std::string str) { std::vector<std::string> word_len; std::string temp; std::istringstream iss(str); while (iss >> temp) { if (temp.size() > n) { word_len.push_back(temp); } } return word_len; }
int main() { std::vector<std::string> result; result = func0(3, "python is a programming language"); assert((result == std::vector<std::string>{"python", "programming", "language"})); result = func0(2, "writing a program"); assert((result == std::vector<std::string>{"writing", "program"})); result = func0(5, "sorting list"); assert((result == std::vector<std::string>{"sorting"})); return 0; }
O1
cpp
func0(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x1b8,%rsp mov %rdi,%r12 mov %esi,%ebx mov %rdx,%rbp mov %fs:0x28,%rax mov %rax,0x1a8(%rsp) xor %eax,%eax movq $0x0,(%rdi) movq $0x0,0x8(%rdi) movq $0x0,0x10(%rdi) lea 0x10(%rsp),%rax mov %rax,(%rsp) movq $0x0,0x8(%rsp) movb $0x0,0x10(%rsp) lea 0x20(%rsp),%r15 lea 0x98(%rsp),%rdi callq 21b0 <_ZNSt8ios_baseC2Ev@plt> lea 0x36f0(%rip),%rax mov %rax,0x98(%rsp) movq $0x0,0x170(%rsp) movb $0x0,0x178(%rsp) movb $0x0,0x179(%rsp) movq $0x0,0x180(%rsp) movq $0x0,0x188(%rsp) movq $0x0,0x190(%rsp) movq $0x0,0x198(%rsp) mov 0x377d(%rip),%r13 mov %r13,0x20(%rsp) mov 0x3779(%rip),%r14 mov -0x18(%r13),%rax mov %r14,0x20(%rsp,%rax,1) movq $0x0,0x28(%rsp) mov 0x20(%rsp),%rax mov %r15,%rdi add -0x18(%rax),%rdi mov $0x0,%esi callq 22a0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> lea 0x3682(%rip),%rax mov %rax,0x20(%rsp) lea 0x28(%rax),%rax mov %rax,0x98(%rsp) lea 0x36b2(%rip),%rax mov %rax,0x30(%rsp) movq $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) movq $0x0,0x48(%rsp) movq $0x0,0x50(%rsp) movq $0x0,0x58(%rsp) movq $0x0,0x60(%rsp) lea 0x68(%rsp),%rdi callq 2310 <_ZNSt6localeC1Ev@plt> lea 0x3706(%rip),%rax mov %rax,0x30(%rsp) movl $0x0,0x70(%rsp) mov 0x0(%rbp),%rsi lea 0x88(%rsp),%rax mov %rax,0x78(%rsp) mov %rsi,%rdx add 0x8(%rbp),%rdx lea 0x78(%rsp),%rdi callq 2e92 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> movl $0x8,0x70(%rsp) lea 0x30(%rsp),%rdi mov $0x0,%ecx mov $0x0,%edx mov 0x78(%rsp),%rsi callq 2290 <_ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm@plt> jmpq 2662 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x259> endbr64 mov %rax,%rbx mov 0x78(%rsp),%rdi lea 0x88(%rsp),%rax cmp %rax,%rdi je 25ed <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1e4> callq 2250 <_ZdlPv@plt> lea 0x35ec(%rip),%rax mov %rax,0x30(%rsp) lea 0x68(%rsp),%rdi callq 22b0 <_ZNSt6localeD1Ev@plt> mov %r13,0x20(%rsp) mov -0x18(%r13),%rax mov %r14,0x20(%rsp,%rax,1) movq $0x0,0x28(%rsp) lea 0x354f(%rip),%rax mov %rax,0x98(%rsp) lea 0x98(%rsp),%rdi callq 21c0 <_ZNSt8ios_baseD2Ev@plt> mov (%rsp),%rdi lea 0x10(%rsp),%rax cmp %rax,%rdi je 2649 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x240> callq 2250 <_ZdlPv@plt> mov %r12,%rdi callq 2d4a <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev> mov %rbx,%rdi callq 22f0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx jmp 25ed <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1e4> lea 0x30(%rsp),%rsi lea 0x98(%rsp),%rdi callq 22a0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> mov %rsp,%rbp jmp 26e2 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d9> endbr64 mov %rax,%rbx lea 0x35f9(%rip),%rax mov %rax,0x30(%rsp) mov 0x78(%rsp),%rdi lea 0x88(%rsp),%rax cmp %rax,%rdi je 26a3 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29a> callq 2250 <_ZdlPv@plt> lea 0x3536(%rip),%rax mov %rax,0x30(%rsp) lea 0x68(%rsp),%rdi callq 22b0 <_ZNSt6localeD1Ev@plt> jmpq 2603 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1fa> endbr64 mov %rax,%rbx jmpq 261a <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x211> mov (%rax),%rdx mov -0x18(%rdx),%rdx testb $0x5,0x20(%rax,%rdx,1) jne 272d <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x324> movslq %ebx,%rax cmp 0x8(%rsp),%rax jb 26f1 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2e8> lea 0x20(%rsp),%rdi mov %rbp,%rsi callq 2280 <_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@plt> jmp 26ca <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2c1> mov 0x8(%r12),%rdi cmp 0x10(%r12),%rdi je 271d <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x314> lea 0x10(%rdi),%rax mov %rax,(%rdi) mov (%rsp),%rsi mov %rsi,%rdx add 0x8(%rsp),%rdx callq 2f90 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag> addq $0x20,0x8(%r12) jmp 26e2 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d9> mov %rbp,%rdx mov %rdi,%rsi mov %r12,%rdi callq 3174 <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_> jmp 26e2 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d9> lea 0x3464(%rip),%rax mov %rax,0x20(%rsp) lea 0x28(%rax),%rax mov %rax,0x98(%rsp) lea 0x3534(%rip),%rax mov %rax,0x30(%rsp) mov 0x78(%rsp),%rdi lea 0x88(%rsp),%rax cmp %rax,%rdi je 2768 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x35f> callq 2250 <_ZdlPv@plt> lea 0x3471(%rip),%rax mov %rax,0x30(%rsp) lea 0x68(%rsp),%rdi callq 22b0 <_ZNSt6localeD1Ev@plt> mov %r13,0x20(%rsp) mov -0x18(%r13),%rax mov %r14,0x20(%rsp,%rax,1) movq $0x0,0x28(%rsp) lea 0x33d4(%rip),%rax mov %rax,0x98(%rsp) lea 0x98(%rsp),%rdi callq 21c0 <_ZNSt8ios_baseD2Ev@plt> mov (%rsp),%rdi lea 0x10(%rsp),%rax cmp %rax,%rdi je 27c4 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3bb> callq 2250 <_ZdlPv@plt> mov 0x1a8(%rsp),%rax xor %fs:0x28,%rax jne 2802 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3f9> mov %r12,%rax add $0x1b8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq endbr64 mov %rax,%rbx lea 0x20(%rsp),%rdi callq 21f0 <_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev@plt> jmpq 2636 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x22d> callq 2270 <__stack_chk_fail@plt>
_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 1B8h mov r12, rdi mov ebx, esi mov rbp, rdx mov rax, fs:28h mov [rsp+1E8h+var_40], rax xor eax, eax mov qword ptr [rdi], 0 mov qword ptr [rdi+8], 0 mov qword ptr [rdi+10h], 0 lea rax, [rsp+1E8h+var_1D8] mov [rsp+1E8h+var_1E8], rax mov [rsp+1E8h+var_1E0], 0 mov byte ptr [rsp+1E8h+var_1D8], 0 lea r15, [rsp+1E8h+var_1C8] lea rdi, [rsp+1E8h+var_150]; this call __ZNSt8ios_baseC2Ev; std::ios_base::ios_base(void) lea rax, unk_5B78 mov [rsp+1E8h+var_150], rax mov [rsp+1E8h+var_78], 0 mov [rsp+1E8h+var_70], 0 mov [rsp+1E8h+var_6F], 0 mov [rsp+1E8h+var_68], 0 mov [rsp+1E8h+var_60], 0 mov [rsp+1E8h+var_58], 0 mov [rsp+1E8h+var_50], 0 mov r13, cs:qword_5C60 mov [rsp+1E8h+var_1C8], r13 mov r14, cs:qword_5C68 mov rax, [r13-18h] mov [rsp+rax+1E8h+var_1C8], r14 mov [rsp+1E8h+var_1C0], 0 mov rax, [rsp+1E8h+var_1C8] mov rdi, r15 add rdi, [rax-18h] mov esi, 0 call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) lea rax, unk_5BA0 mov [rsp+1E8h+var_1C8], rax lea rax, [rax+28h] mov [rsp+1E8h+var_150], rax lea rax, unk_5BE8 mov [rsp+1E8h+var_1B8], rax mov [rsp+1E8h+var_1B0], 0 mov [rsp+1E8h+var_1A8], 0 mov [rsp+1E8h+var_1A0], 0 mov [rsp+1E8h+var_198], 0 mov [rsp+1E8h+var_190], 0 mov [rsp+1E8h+var_188], 0 lea rdi, [rsp+1E8h+var_180]; this call __ZNSt6localeC1Ev; std::locale::locale(void) lea rax, unk_5C88 mov [rsp+1E8h+var_1B8], rax mov [rsp+1E8h+var_178], 0 mov rdx, [rbp+8] mov rsi, [rbp+0] lea rax, [rsp+1E8h+var_160] mov [rsp+1E8h+var_170], rax test rsi, rsi jnz short loc_25A6 test rdx, rdx jnz short loc_25B5 loc_25A6: add rdx, rsi lea rdi, [rsp+1E8h+var_170] call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp short loc_25E2 loc_25B5: mov rax, [rsp+1E8h+var_40] sub rax, fs:28h jnz short loc_25DD lea rdi, aBasicStringCon; "basic_string: construction from null is"... call __ZSt19__throw_logic_errorPKc; std::__throw_logic_error(char const*) endbr64 mov rbx, rax jmp short loc_2619 loc_25DD: call ___stack_chk_fail loc_25E2: mov [rsp+1E8h+var_178], 8 lea rdi, [rsp+1E8h+var_1B8] mov ecx, 0 mov edx, 0 mov rsi, [rsp+1E8h+var_170] call __ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm; std::stringbuf::_M_sync(char *,ulong,ulong) jmp loc_268E endbr64 mov rbx, rax lea rdi, [rsp+1E8h+var_170] call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) loc_2619: lea rax, unk_5BE8 mov [rsp+1E8h+var_1B8], rax lea rdi, [rsp+1E8h+var_180]; this call __ZNSt6localeD1Ev; std::locale::~locale() loc_262F: mov [rsp+1E8h+var_1C8], r13 mov rax, [r13-18h] mov [rsp+rax+1E8h+var_1C8], r14 mov [rsp+1E8h+var_1C0], 0 loc_2646: lea rax, unk_5B78 mov [rsp+1E8h+var_150], rax lea rdi, [rsp+1E8h+var_150]; this call __ZNSt8ios_baseD2Ev; std::ios_base::~ios_base() loc_2662: mov rdi, rsp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) mov rdi, r12 call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED2Ev; std::vector<std::string>::~vector() mov rax, [rsp+1E8h+var_40] sub rax, fs:28h jz loc_2852 call ___stack_chk_fail loc_268E: lea rsi, [rsp+1E8h+var_1B8] lea rdi, [rsp+1E8h+var_150] call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) mov rbp, rsp jmp loc_2759 endbr64 mov rbx, rax lea rax, unk_5C88 mov [rsp+1E8h+var_1B8], rax mov rdi, [rsp+1E8h+var_170]; void * lea rax, [rsp+1E8h+var_160] cmp rdi, rax jz short loc_26DE mov rax, [rsp+1E8h+var_160] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_26DE: lea rax, unk_5BE8 mov [rsp+1E8h+var_1B8], rax lea rdi, [rsp+1E8h+var_180]; this call __ZNSt6localeD1Ev; std::locale::~locale() jmp loc_262F endbr64 mov rbx, rax jmp loc_2646 loc_2705: mov rdi, [r12+8] cmp rdi, [r12+10h] jz short loc_2731 lea rax, [rdi+10h] mov [rdi], rax mov rsi, [rsp+1E8h+var_1E8] mov rdx, rsi add rdx, [rsp+1E8h+var_1E0] call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag; std::string::_M_construct<char *>(char *,char *,std::forward_iterator_tag) add qword ptr [r12+8], 20h ; ' ' jmp short loc_2759 loc_2731: mov rdx, rsp mov rsi, rdi mov rdi, r12 call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_; std::vector<std::string>::_M_realloc_insert<std::string const&>(__gnu_cxx::__normal_iterator<std::string*,std::vector<std::string>>,std::string const&) jmp short loc_2759 loc_2741: mov rdx, [rax] mov rdx, [rdx-18h] test byte ptr [rax+rdx+20h], 5 jnz short loc_2768 movsxd rax, ebx cmp rax, [rsp+1E8h+var_1E0] jb short loc_2705 loc_2759: lea rdi, [rsp+1E8h+var_1C8] mov rsi, rbp call __ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE; std::operator>><char>(std::istream &,std::string &) jmp short loc_2741 loc_2768: lea rax, unk_5BA0 mov [rsp+1E8h+var_1C8], rax lea rax, [rax+28h] mov [rsp+1E8h+var_150], rax lea rax, unk_5C88 mov [rsp+1E8h+var_1B8], rax mov rdi, [rsp+1E8h+var_170]; void * lea rax, [rsp+1E8h+var_160] cmp rdi, rax jz short loc_27AF mov rax, [rsp+1E8h+var_160] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_27AF: lea rax, unk_5BE8 mov [rsp+1E8h+var_1B8], rax lea rdi, [rsp+1E8h+var_180]; this call __ZNSt6localeD1Ev; std::locale::~locale() mov [rsp+1E8h+var_1C8], r13 mov rax, [r13-18h] mov [rsp+rax+1E8h+var_1C8], r14 mov [rsp+1E8h+var_1C0], 0 lea rax, unk_5B78 mov [rsp+1E8h+var_150], rax lea rdi, [rsp+1E8h+var_150]; this call __ZNSt8ios_baseD2Ev; std::ios_base::~ios_base() mov rdi, [rsp+1E8h+var_1E8]; void * lea rax, [rsp+1E8h+var_1D8] cmp rdi, rax jz short loc_2814 mov rax, [rsp+1E8h+var_1D8] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_2814: mov rax, [rsp+1E8h+var_40] sub rax, fs:28h jnz short loc_285A mov rax, r12 add rsp, 1B8h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbx, rax lea rdi, [rsp+1E8h+var_1C8] call __ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev; std::istringstream::~istringstream() jmp loc_2662 loc_2852: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_285A: call ___stack_chk_fail
_QWORD * func0(_QWORD *a1, int a2, long long *a3) { long long v6; // rdx long long v7; // rsi _QWORD *v8; // rdi _QWORD *v9; // rax void *v11; // [rsp+0h] [rbp-1E8h] BYREF unsigned long long v12; // [rsp+8h] [rbp-1E0h] _QWORD v13[2]; // [rsp+10h] [rbp-1D8h] BYREF int *v14; // [rsp+20h] [rbp-1C8h] BYREF long long v15; // [rsp+28h] [rbp-1C0h] _QWORD v16[7]; // [rsp+30h] [rbp-1B8h] BYREF _BYTE v17[8]; // [rsp+68h] [rbp-180h] BYREF int v18; // [rsp+70h] [rbp-178h] void *v19; // [rsp+78h] [rbp-170h] BYREF _QWORD v20[2]; // [rsp+88h] [rbp-160h] BYREF _QWORD v21[28]; // [rsp+98h] [rbp-150h] BYREF char v22; // [rsp+178h] [rbp-70h] char v23; // [rsp+179h] [rbp-6Fh] long long v24; // [rsp+180h] [rbp-68h] long long v25; // [rsp+188h] [rbp-60h] long long v26; // [rsp+190h] [rbp-58h] long long v27; // [rsp+198h] [rbp-50h] unsigned long long v28; // [rsp+1A8h] [rbp-40h] v28 = __readfsqword(0x28u); *a1 = 0LL; a1[1] = 0LL; a1[2] = 0LL; v11 = v13; v12 = 0LL; LOBYTE(v13[0]) = 0; std::ios_base::ios_base((std::ios_base *)v21); v21[0] = &unk_5B78; v21[27] = 0LL; v22 = 0; v23 = 0; v24 = 0LL; v25 = 0LL; v26 = 0LL; v27 = 0LL; v14 = &dword_0; *(int **)((char *)&v14 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v15 = 0LL; std::ios::init((char *)&v14 + *((_QWORD *)v14 - 3), 0LL); v14 = (int *)&unk_5BA0; v21[0] = (char *)&unk_5BA0 + 40; v16[0] = &unk_5BE8; memset(&v16[1], 0, 48); std::locale::locale((std::locale *)v17); v16[0] = &unk_5C88; v18 = 0; v6 = a3[1]; v7 = *a3; v19 = v20; if ( !v7 && v6 ) std::__throw_logic_error("basic_string: construction from null is not valid"); std::string::_M_construct<char const*>(&v19, v7, v7 + v6); v18 = 8; std::stringbuf::_M_sync(v16, v19, 0LL, 0LL); std::ios::init(v21, v16); while ( 1 ) { v9 = (_QWORD *)std::operator>><char>(&v14, &v11); if ( (*((_BYTE *)v9 + *(_QWORD *)(*v9 - 24LL) + 32) & 5) != 0 ) break; if ( a2 < v12 ) { v8 = (_QWORD *)a1[1]; if ( v8 == (_QWORD *)a1[2] ) { std::vector<std::string>::_M_realloc_insert<std::string const&>(a1, a1[1], &v11); } else { *v8 = v8 + 2; std::string::_M_construct<char *>(v8, v11, (char *)v11 + v12); a1[1] += 32LL; } } } v14 = (int *)&unk_5BA0; v21[0] = (char *)&unk_5BA0 + 40; v16[0] = &unk_5C88; if ( v19 != v20 ) operator delete(v19, v20[0] + 1LL); v16[0] = &unk_5BE8; std::locale::~locale((std::locale *)v17); v14 = &dword_0; *(int **)((char *)&v14 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v15 = 0LL; v21[0] = &unk_5B78; std::ios_base::~ios_base((std::ios_base *)v21); if ( v11 != v13 ) operator delete(v11, v13[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x1b8 MOV R12,RDI MOV EBX,ESI MOV RBP,RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1a8],RAX XOR EAX,EAX MOV qword ptr [RDI],0x0 MOV qword ptr [RDI + 0x8],0x0 MOV qword ptr [RDI + 0x10],0x0 LEA RAX,[RSP + 0x10] MOV qword ptr [RSP],RAX MOV qword ptr [RSP + 0x8],0x0 MOV byte ptr [RSP + 0x10],0x0 LEA R15,[RSP + 0x20] LEA RDI,[RSP + 0x98] CALL 0x001021b0 LEA RAX,[0x105b78] MOV qword ptr [RSP + 0x98],RAX MOV qword ptr [RSP + 0x170],0x0 MOV byte ptr [RSP + 0x178],0x0 MOV byte ptr [RSP + 0x179],0x0 MOV qword ptr [RSP + 0x180],0x0 MOV qword ptr [RSP + 0x188],0x0 MOV qword ptr [RSP + 0x190],0x0 MOV qword ptr [RSP + 0x198],0x0 MOV R13,qword ptr [0x00105c60] MOV qword ptr [RSP + 0x20],R13 MOV R14,qword ptr [0x00105c68] MOV RAX,qword ptr [R13 + -0x18] MOV qword ptr [RSP + RAX*0x1 + 0x20],R14 MOV qword ptr [RSP + 0x28],0x0 MOV RAX,qword ptr [RSP + 0x20] MOV RDI,R15 ADD RDI,qword ptr [RAX + -0x18] MOV ESI,0x0 LAB_0010250a: CALL 0x001022b0 LEA RAX,[0x105ba0] MOV qword ptr [RSP + 0x20],RAX LEA RAX,[RAX + 0x28] MOV qword ptr [RSP + 0x98],RAX LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x30],RAX MOV qword ptr [RSP + 0x38],0x0 MOV qword ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP + 0x58],0x0 MOV qword ptr [RSP + 0x60],0x0 LEA RDI,[RSP + 0x68] CALL 0x00102310 LEA RAX,[0x105c88] MOV qword ptr [RSP + 0x30],RAX MOV dword ptr [RSP + 0x70],0x0 MOV RDX,qword ptr [RBP + 0x8] MOV RSI,qword ptr [RBP] LEA RAX,[RSP + 0x88] MOV qword ptr [RSP + 0x78],RAX TEST RSI,RSI JNZ 0x001025a6 TEST RDX,RDX JNZ 0x001025b5 LAB_001025a6: ADD RDX,RSI LEA RDI,[RSP + 0x78] LAB_001025ae: CALL 0x00102e14 JMP 0x001025e2 LAB_001025b5: MOV RAX,qword ptr [RSP + 0x1a8] SUB RAX,qword ptr FS:[0x28] JNZ 0x001025dd LEA RDI,[0x104008] CALL 0x00102230 LAB_001025d4: ENDBR64 MOV RBX,RAX JMP 0x00102619 LAB_001025dd: CALL 0x00102270 LAB_001025e2: MOV dword ptr [RSP + 0x70],0x8 LEA RDI,[RSP + 0x30] MOV ECX,0x0 MOV EDX,0x0 MOV RSI,qword ptr [RSP + 0x78] LAB_001025fe: CALL 0x001022a0 JMP 0x0010268e LAB_00102619: LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x30],RAX LEA RDI,[RSP + 0x68] CALL 0x001022c0 LAB_0010262f: MOV qword ptr [RSP + 0x20],R13 MOV RAX,qword ptr [R13 + -0x18] MOV qword ptr [RSP + RAX*0x1 + 0x20],R14 MOV qword ptr [RSP + 0x28],0x0 LAB_00102646: LEA RAX,[0x105b78] MOV qword ptr [RSP + 0x98],RAX LEA RDI,[RSP + 0x98] CALL 0x001021c0 LAB_00102662: MOV RDI,RSP CALL 0x00102280 MOV RDI,R12 CALL 0x00102d42 MOV RAX,qword ptr [RSP + 0x1a8] SUB RAX,qword ptr FS:[0x28] JZ 0x00102852 CALL 0x00102270 LAB_0010268e: LEA RSI,[RSP + 0x30] LEA RDI,[RSP + 0x98] LAB_0010269b: CALL 0x001022b0 MOV RBP,RSP JMP 0x00102759 LAB_00102705: MOV RDI,qword ptr [R12 + 0x8] CMP RDI,qword ptr [R12 + 0x10] JZ 0x00102731 LEA RAX,[RDI + 0x10] MOV qword ptr [RDI],RAX MOV RSI,qword ptr [RSP] MOV RDX,RSI ADD RDX,qword ptr [RSP + 0x8] LAB_00102724: CALL 0x00102f88 ADD qword ptr [R12 + 0x8],0x20 JMP 0x00102759 LAB_00102731: MOV RDX,RSP MOV RSI,RDI MOV RDI,R12 CALL 0x00103024 JMP 0x00102759 LAB_00102741: MOV RDX,qword ptr [RAX] MOV RDX,qword ptr [RDX + -0x18] TEST byte ptr [RAX + RDX*0x1 + 0x20],0x5 JNZ 0x00102768 MOVSXD RAX,EBX CMP RAX,qword ptr [RSP + 0x8] JC 0x00102705 LAB_00102759: LEA RDI,[RSP + 0x20] MOV RSI,RBP CALL 0x00102290 JMP 0x00102741 LAB_00102768: LEA RAX,[0x105ba0] MOV qword ptr [RSP + 0x20],RAX LEA RAX,[RAX + 0x28] MOV qword ptr [RSP + 0x98],RAX LEA RAX,[0x105c88] MOV qword ptr [RSP + 0x30],RAX MOV RDI,qword ptr [RSP + 0x78] LEA RAX,[RSP + 0x88] CMP RDI,RAX JZ 0x001027af MOV RAX,qword ptr [RSP + 0x88] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_001027af: LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x30],RAX LEA RDI,[RSP + 0x68] CALL 0x001022c0 MOV qword ptr [RSP + 0x20],R13 MOV RAX,qword ptr [R13 + -0x18] MOV qword ptr [RSP + RAX*0x1 + 0x20],R14 MOV qword ptr [RSP + 0x28],0x0 LEA RAX,[0x105b78] MOV qword ptr [RSP + 0x98],RAX LEA RDI,[RSP + 0x98] CALL 0x001021c0 MOV RDI,qword ptr [RSP] LEA RAX,[RSP + 0x10] CMP RDI,RAX JZ 0x00102814 MOV RAX,qword ptr [RSP + 0x10] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_00102814: MOV RAX,qword ptr [RSP + 0x1a8] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010285a MOV RAX,R12 ADD RSP,0x1b8 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00102852: MOV RDI,RBX LAB_00102855: CALL 0x001022f0 LAB_0010285a: CALL 0x00102270
/* func0(int, std::string) */ vector<std::string,std::allocator<std::string>> * func0(vector<std::string,std::allocator<std::string>> *param_1,int param_2,int8 *param_3) { char *pcVar1; long *plVar2; int8 uVar3; int8 uVar4; int8 uVar5; istream *piVar6; long in_FS_OFFSET; char *local_1e8; ulong local_1e0; char local_1d8; int7 uStack_1d7; long local_1c8 [2]; char local_1b8 [56]; locale local_180 [8]; int4 local_178; long *local_170 [2]; long local_160 [2]; int8 local_150 [27]; int8 local_78; int local_70; int local_6f; int8 local_68; int8 local_60; int8 local_58; int8 local_50; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); *(int8 *)param_1 = 0; *(int8 *)(param_1 + 8) = 0; *(int8 *)(param_1 + 0x10) = 0; local_1e8 = &local_1d8; local_1e0 = 0; local_1d8 = '\0'; std::ios_base::ios_base((ios_base *)local_150); uVar4 = std::istringstream::VTT._16_8_; uVar3 = std::istringstream::VTT._8_8_; local_150[0] = 0x105b78; local_78 = 0; local_70 = 0; local_6f = 0; local_68 = 0; local_60 = 0; local_58 = 0; local_50 = 0; local_1c8[0] = std::istringstream::VTT._8_8_; *(int8 *)((long)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18)) = std::istringstream::VTT._16_8_; local_1c8[1] = 0; /* try { // try from 0010250a to 0010250e has its CatchHandler @ 001026f9 */ std::ios::init((streambuf *)((long)local_1c8 + *(long *)(local_1c8[0] + -0x18))); local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_1b8[8] = '\0'; local_1b8[9] = '\0'; local_1b8[10] = '\0'; local_1b8[0xb] = '\0'; local_1b8[0xc] = '\0'; local_1b8[0xd] = '\0'; local_1b8[0xe] = '\0'; local_1b8[0xf] = '\0'; local_1b8[0x10] = '\0'; local_1b8[0x11] = '\0'; local_1b8[0x12] = '\0'; local_1b8[0x13] = '\0'; local_1b8[0x14] = '\0'; local_1b8[0x15] = '\0'; local_1b8[0x16] = '\0'; local_1b8[0x17] = '\0'; local_1b8[0x18] = '\0'; local_1b8[0x19] = '\0'; local_1b8[0x1a] = '\0'; local_1b8[0x1b] = '\0'; local_1b8[0x1c] = '\0'; local_1b8[0x1d] = '\0'; local_1b8[0x1e] = '\0'; local_1b8[0x1f] = '\0'; local_1b8[0x20] = '\0'; local_1b8[0x21] = '\0'; local_1b8[0x22] = '\0'; local_1b8[0x23] = '\0'; local_1b8[0x24] = '\0'; local_1b8[0x25] = '\0'; local_1b8[0x26] = '\0'; local_1b8[0x27] = '\0'; local_1b8[0x28] = '\0'; local_1b8[0x29] = '\0'; local_1b8[0x2a] = '\0'; local_1b8[0x2b] = '\0'; local_1b8[0x2c] = '\0'; local_1b8[0x2d] = '\0'; local_1b8[0x2e] = '\0'; local_1b8[0x2f] = '\0'; local_1b8[0x30] = '\0'; local_1b8[0x31] = '\0'; local_1b8[0x32] = '\0'; local_1b8[0x33] = '\0'; local_1b8[0x34] = '\0'; local_1b8[0x35] = '\0'; local_1b8[0x36] = '\0'; local_1b8[0x37] = '\0'; std::locale::locale(local_180); local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_178 = 0; pcVar1 = (char *)*param_3; local_170[0] = local_160; if ((pcVar1 != (char *)0x0) || (param_3[1] == 0)) { /* try { // try from 001025ae to 001025d3 has its CatchHandler @ 001025d4 */ std::string::_M_construct<char_const*>((char *)local_170,pcVar1,(int)param_3[1] + (int)pcVar1); local_178 = 8; /* try { // try from 001025fe to 00102602 has its CatchHandler @ 00102608 */ std::stringbuf::_M_sync(local_1b8,(ulong)local_170[0],0); /* try { // try from 0010269b to 0010269f has its CatchHandler @ 001026a8 */ std::ios::init((streambuf *)local_150); while( true ) { piVar6 = std::operator>>((istream *)local_1c8,(string *)&local_1e8); if (((byte)piVar6[*(long *)(*(long *)piVar6 + -0x18) + 0x20] & 5) != 0) break; if ((ulong)(long)param_2 < local_1e0) { plVar2 = *(long **)(param_1 + 8); if (plVar2 == *(long **)(param_1 + 0x10)) { std::vector<std::string,std::allocator<std::string>>:: _M_realloc_insert<std::string_const&> (param_1,(__normal_iterator)plVar2,(string *)&local_1e8); } else { *plVar2 = (long)(plVar2 + 2); /* try { // try from 00102724 to 00102765 has its CatchHandler @ 0010283c */ std::string::_M_construct<char*>((char *)plVar2,local_1e8,(int)local_1e8 + (int)local_1e0) ; *(long *)(param_1 + 8) = *(long *)(param_1 + 8) + 0x20; } } } local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; if (local_170[0] != local_160) { operator_delete(local_170[0],local_160[0] + 1); } local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; std::locale::~locale(local_180); local_1c8[0] = uVar3; *(int8 *)((long)local_1c8 + *(long *)(uVar3 + -0x18)) = uVar4; local_1c8[1] = 0; local_150[0] = 0x105b78; std::ios_base::~ios_base((ios_base *)local_150); if (local_1e8 != &local_1d8) { operator_delete(local_1e8,CONCAT71(uStack_1d7,local_1d8) + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); } if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } uVar5 = std::__throw_logic_error("basic_string: construction from null is not valid"); local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; std::locale::~locale(local_180); local_1c8[0] = uVar3; *(int8 *)((long)local_1c8 + *(long *)(uVar3 + -0x18)) = uVar4; local_1c8[1] = 0; local_150[0] = 0x105b78; std::ios_base::~ios_base((ios_base *)local_150); std::string::_M_dispose(); std::vector<std::string,std::allocator<std::string>>::~vector(param_1); /* catch() { ... } // from try @ 001025ae with catch @ 001025d4 */ if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar5); }
510
func0
#include <iostream> #include <vector> #include <string> #include <assert.h> #include <sstream>
std::vector<std::string> func0(int n, std::string str) { std::vector<std::string> word_len; std::string temp; std::istringstream iss(str); while (iss >> temp) { if (temp.size() > n) { word_len.push_back(temp); } } return word_len; }
int main() { std::vector<std::string> result; result = func0(3, "python is a programming language"); assert((result == std::vector<std::string>{"python", "programming", "language"})); result = func0(2, "writing a program"); assert((result == std::vector<std::string>{"writing", "program"})); result = func0(5, "sorting list"); assert((result == std::vector<std::string>{"sorting"})); return 0; }
O2
cpp
func0(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 push %r14 push %r13 mov %rdi,%r13 push %r12 mov %rdx,%r12 push %rbp push %rbx movslq %esi,%rbx sub $0x1d8,%rsp mov %fs:0x28,%rax mov %rax,0x1c8(%rsp) xor %eax,%eax movq $0x0,(%rdi) lea 0x30(%rsp),%rax lea 0xb8(%rsp),%r15 movq $0x0,0x8(%rdi) lea 0x40(%rsp),%rbp movq $0x0,0x10(%rdi) mov %r15,%rdi mov %rax,0x18(%rsp) mov %rax,0x20(%rsp) movq $0x0,0x28(%rsp) movb $0x0,0x30(%rsp) callq 21c0 <_ZNSt8ios_baseC2Ev@plt> mov 0x31df(%rip),%r14 lea 0x30f0(%rip),%rax xor %esi,%esi mov %rax,0xb8(%rsp) xor %eax,%eax mov 0x31cd(%rip),%rcx mov %ax,0x198(%rsp) mov -0x18(%r14),%rax movq $0x0,0x190(%rsp) movq $0x0,0x1a0(%rsp) movq $0x0,0x1a8(%rsp) movq $0x0,0x1b0(%rsp) movq $0x0,0x1b8(%rsp) mov %r14,0x40(%rsp) mov %rcx,0x40(%rsp,%rax,1) movq $0x0,0x48(%rsp) mov -0x18(%r14),%rdi add %rbp,%rdi callq 22c0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> movq $0x0,0x58(%rsp) lea 0x308e(%rip),%rax mov %rax,0x40(%rsp) add $0x28,%rax mov %rax,0xb8(%rsp) lea 0x30be(%rip),%rax mov %rax,0x50(%rsp) lea 0x88(%rsp),%rax mov %rax,%rdi mov %rax,0x10(%rsp) movq $0x0,0x60(%rsp) movq $0x0,0x68(%rsp) movq $0x0,0x70(%rsp) movq $0x0,0x78(%rsp) movq $0x0,0x80(%rsp) callq 2330 <_ZNSt6localeC1Ev@plt> mov (%r12),%rsi mov 0x8(%r12),%rdx lea 0x3104(%rip),%rax mov %rax,0x50(%rsp) lea 0x98(%rsp),%rdi lea 0xa8(%rsp),%rax add %rsi,%rdx mov %rax,0x8(%rsp) movl $0x0,0x90(%rsp) mov %rax,0x98(%rsp) callq 2e30 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> lea 0x50(%rsp),%r12 mov 0x98(%rsp),%rsi xor %ecx,%ecx xor %edx,%edx movl $0x8,0x90(%rsp) mov %r12,%rdi callq 22b0 <_ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm@plt> mov %r12,%rsi mov %r15,%rdi callq 22c0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> lea 0x20(%rsp),%r12 jmp 2beb <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1fb> cmp 0x28(%rsp),%rbx jb 2cc0 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d0> mov %r12,%rsi mov %rbp,%rdi callq 22a0 <_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@plt> mov (%rax),%rdx mov -0x18(%rdx),%rdx testb $0x5,0x20(%rax,%rdx,1) je 2be0 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1f0> lea 0x2f85(%rip),%rax mov 0x98(%rsp),%rdi mov %rax,0x40(%rsp) add $0x28,%rax mov %rax,0xb8(%rsp) lea 0x304d(%rip),%rax mov %rax,0x50(%rsp) cmp 0x8(%rsp),%rdi je 2c3c <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x24c> callq 2270 <_ZdlPv@plt> mov 0x10(%rsp),%rdi lea 0x2f90(%rip),%rax mov %rax,0x50(%rsp) callq 22d0 <_ZNSt6localeD1Ev@plt> mov -0x18(%r14),%rax mov %r14,0x40(%rsp) mov %r15,%rdi mov 0x2ff3(%rip),%rcx mov %rcx,0x40(%rsp,%rax,1) lea 0x2ef7(%rip),%rax movq $0x0,0x48(%rsp) mov %rax,0xb8(%rsp) callq 21d0 <_ZNSt8ios_baseD2Ev@plt> mov 0x20(%rsp),%rdi cmp 0x18(%rsp),%rdi je 2c98 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2a8> callq 2270 <_ZdlPv@plt> mov 0x1c8(%rsp),%rax xor %fs:0x28,%rax jne 2d03 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x313> add $0x1d8,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov 0x8(%r13),%rdi cmp 0x10(%r13),%rdi je 2cf0 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x300> lea 0x10(%rdi),%rax mov 0x28(%rsp),%rdx mov %rax,(%rdi) mov 0x20(%rsp),%rsi add %rsi,%rdx callq 2f50 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag> addq $0x20,0x8(%r13) jmpq 2beb <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1fb> nopl (%rax) mov %rdi,%rsi mov %r12,%rdx mov %r13,%rdi callq 3150 <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_> jmpq 2beb <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1fb> callq 2290 <__stack_chk_fail@plt> endbr64 mov %rax,%rbx jmpq 2340 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold> endbr64 mov %rax,%rbx jmpq 234d <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0xd> endbr64 mov %rax,%rbx jmpq 236d <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x2d> endbr64 mov %rax,%rbx jmpq 2359 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x19> endbr64 mov %rax,%rbp jmpq 23a4 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x64> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 pxor xmm0, xmm0 push r14 push r13 mov r13, rdi push r12 mov r12, rdx push rbp push rbx sub rsp, 1E8h mov [rsp+218h+var_204], esi lea rbx, [rsp+218h+var_1C8] mov rax, fs:28h mov [rsp+218h+var_40], rax xor eax, eax lea rax, [rsp+218h+var_1D8] mov qword ptr [rdi+10h], 0 mov [rsp+218h+var_200], rax mov [rsp+218h+var_1E8], rax lea rax, [rsp+218h+var_150] movups xmmword ptr [rdi], xmm0 mov rdi, rax; this mov [rsp+218h+var_218], rax mov [rsp+218h+var_1E0], 0 mov byte ptr [rsp+218h+var_1D8], 0 call __ZNSt8ios_baseC2Ev; std::ios_base::ios_base(void) mov r14, cs:qword_5C60 xor edx, edx xor esi, esi lea rax, unk_5B78 pxor xmm0, xmm0 mov [rsp+218h+var_70], dx mov rcx, cs:qword_5C68 movaps [rsp+218h+var_68], xmm0 movaps [rsp+218h+var_58], xmm0 mov [rsp+218h+var_150], rax mov rax, [r14-18h] mov [rsp+218h+var_78], 0 mov [rsp+218h+var_1C8], r14 mov [rsp+rax+218h+var_1C8], rcx mov [rsp+218h+var_1C0], 0 mov rdi, [r14-18h] add rdi, rbx call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) lea rax, unk_5BA0 mov [rsp+218h+var_1B0], 0 lea r15, [rsp+218h+var_160] mov [rsp+218h+var_1C8], rax add rax, 28h ; '(' mov [rsp+218h+var_150], rax lea rax, unk_5BE8 mov [rsp+218h+var_1B8], rax lea rax, [rsp+218h+var_180] mov rdi, rax; this mov [rsp+218h+var_210], rax mov [rsp+218h+var_1A8], 0 mov [rsp+218h+var_1A0], 0 mov [rsp+218h+var_198], 0 mov [rsp+218h+var_190], 0 mov [rsp+218h+var_188], 0 call __ZNSt6localeC1Ev; std::locale::locale(void) mov rbp, [r12+8] mov r12, [r12] lea rax, unk_5C88 mov [rsp+218h+var_1B8], rax mov [rsp+218h+var_178], 0 mov [rsp+218h+var_170], r15 test r12, r12 jnz short loc_2CF9 test rbp, rbp jnz loc_2F18 loc_2CF9: mov [rsp+218h+var_1F0], rbp cmp rbp, 0Fh ja loc_2EB0 cmp rbp, 1 jnz loc_2E70 movzx eax, byte ptr [r12] mov byte ptr [rsp+218h+var_160], al loc_2D1E: mov rax, r15 loc_2D21: mov [rsp+218h+var_168], rbp xor ecx, ecx xor edx, edx mov byte ptr [rax+rbp], 0 lea rbp, [rsp+218h+var_1B8] mov rsi, [rsp+218h+var_170] mov [rsp+218h+var_178], 8 mov rdi, rbp call __ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm; std::stringbuf::_M_sync(char *,ulong,ulong) mov rdi, [rsp+218h+var_218] mov rsi, rbp call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) movsxd rbp, [rsp+218h+var_204] lea r12, [rsp+218h+var_1E8] jmp short loc_2D7E loc_2D70: mov rdx, [rsp+218h+var_1E0] cmp rbp, rdx jb loc_2E80 loc_2D7E: mov rsi, r12 mov rdi, rbx call __ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE; std::operator>><char>(std::istream &,std::string &) mov rdx, [rax] mov rdx, [rdx-18h] test byte ptr [rax+rdx+20h], 5 jz short loc_2D70 lea rax, unk_5BA0 mov rdi, [rsp+218h+var_170]; void * mov [rsp+218h+var_1C8], rax add rax, 28h ; '(' mov [rsp+218h+var_150], rax lea rax, unk_5C88 mov [rsp+218h+var_1B8], rax cmp rdi, r15 jz short loc_2DD9 mov rax, [rsp+218h+var_160] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_2DD9: mov rdi, [rsp+218h+var_210]; this lea rax, unk_5BE8 mov [rsp+218h+var_1B8], rax call __ZNSt6localeD1Ev; std::locale::~locale() mov rax, [r14-18h] mov rdi, [rsp+218h+var_218]; this mov [rsp+218h+var_1C8], r14 mov rcx, cs:qword_5C68 mov [rsp+rax+218h+var_1C8], rcx lea rax, unk_5B78 mov [rsp+218h+var_150], rax mov [rsp+218h+var_1C0], 0 call __ZNSt8ios_baseD2Ev; std::ios_base::~ios_base() mov rdi, [rsp+218h+var_1E8]; void * mov rax, [rsp+218h+var_200] cmp rdi, rax jz short loc_2E42 mov rax, [rsp+218h+var_1D8] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_2E42: mov rax, [rsp+218h+var_40] sub rax, fs:28h jnz loc_2F13 add rsp, 1E8h mov rax, r13 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_2E70: test rbp, rbp jz loc_2D1E mov rdi, r15 jmp short loc_2EDC loc_2E80: mov rdi, [r13+8] cmp rdi, [r13+10h] jz short loc_2F00 lea rax, [rdi+10h] mov [rdi], rax mov rsi, [rsp+218h+var_1E8] add rdx, rsi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag_isra_0; std::string::_M_construct<char *>(char *,char *,std::forward_iterator_tag) [clone] add qword ptr [r13+8], 20h ; ' ' jmp loc_2D7E loc_2EB0: lea rsi, [rsp+218h+var_1F0] lea rdi, [rsp+218h+var_170] xor edx, edx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm; std::string::_M_create(ulong &,ulong) mov [rsp+218h+var_170], rax mov rdi, rax; dest mov rax, [rsp+218h+var_1F0] mov [rsp+218h+var_160], rax loc_2EDC: mov rdx, rbp; n mov rsi, r12; src call _memcpy mov rbp, [rsp+218h+var_1F0] mov rax, [rsp+218h+var_170] jmp loc_2D21 loc_2F00: mov rsi, rdi mov rdx, r12 mov rdi, r13 call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_; std::vector<std::string>::_M_realloc_insert<std::string const&>(__gnu_cxx::__normal_iterator<std::string*,std::vector<std::string>>,std::string const&) jmp loc_2D7E loc_2F13: call ___stack_chk_fail loc_2F18: mov rax, [rsp+218h+var_40] sub rax, fs:28h jnz short loc_2F13 lea rdi, aBasicStringCon; "basic_string: construction from null is"... call __ZSt19__throw_logic_errorPKc; std::__throw_logic_error(char const*) endbr64 mov rbx, rax jmp loc_235F endbr64 mov rbp, rax jmp loc_23A7 endbr64 mov rbx, rax jmp loc_23B4 endbr64 mov rbx, rax jmp _Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_cold; func0(int,std::string) [clone] endbr64 mov rbx, rax jmp loc_232D
long long func0(long long a1, int a2, long long a3) { char *v5; // rbp _BYTE *v6; // r12 _QWORD *v7; // rax unsigned long long v8; // rdx _QWORD *v9; // rax _QWORD *v11; // rdi _QWORD *v12; // rdi char *v13; // [rsp+28h] [rbp-1F0h] BYREF void *v14; // [rsp+30h] [rbp-1E8h] BYREF unsigned long long v15; // [rsp+38h] [rbp-1E0h] _QWORD v16[2]; // [rsp+40h] [rbp-1D8h] BYREF int *v17; // [rsp+50h] [rbp-1C8h] BYREF long long v18; // [rsp+58h] [rbp-1C0h] _QWORD v19[7]; // [rsp+60h] [rbp-1B8h] BYREF char v20[8]; // [rsp+98h] [rbp-180h] BYREF int v21; // [rsp+A0h] [rbp-178h] void *v22[2]; // [rsp+A8h] [rbp-170h] BYREF _QWORD v23[2]; // [rsp+B8h] [rbp-160h] BYREF _QWORD v24[28]; // [rsp+C8h] [rbp-150h] BYREF __int16 v25; // [rsp+1A8h] [rbp-70h] __int128 v26; // [rsp+1B0h] [rbp-68h] __int128 v27; // [rsp+1C0h] [rbp-58h] unsigned long long v28; // [rsp+1D8h] [rbp-40h] v28 = __readfsqword(0x28u); *(_QWORD *)(a1 + 16) = 0LL; v14 = v16; *(_OWORD *)a1 = 0LL; v15 = 0LL; LOBYTE(v16[0]) = 0; std::ios_base::ios_base((std::ios_base *)v24); v25 = 0; v26 = 0LL; v27 = 0LL; v24[0] = &unk_5B78; v24[27] = 0LL; v17 = &dword_0; *(int **)((char *)&v17 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v18 = 0LL; std::ios::init((char *)&v17 + MEMORY[0xFFFFFFFFFFFFFFE8], 0LL); memset(&v19[1], 0, 48); v17 = (int *)&unk_5BA0; v24[0] = (char *)&unk_5BA0 + 40; v19[0] = &unk_5BE8; std::locale::locale((std::locale *)v20); v5 = *(char **)(a3 + 8); v6 = *(_BYTE **)a3; v19[0] = &unk_5C88; v21 = 0; v22[0] = v23; if ( !v6 && v5 ) std::__throw_logic_error("basic_string: construction from null is not valid"); v13 = v5; if ( (unsigned long long)v5 > 0xF ) { v22[0] = (void *)std::string::_M_create(v22, &v13, 0LL); v11 = v22[0]; v23[0] = v13; goto LABEL_20; } if ( v5 != (_BYTE *)&dword_0 + 1 ) { if ( !v5 ) goto LABEL_6; v11 = v23; LABEL_20: memcpy(v11, v6, (size_t)v5); v5 = v13; v7 = v22[0]; goto LABEL_7; } LOBYTE(v23[0]) = *v6; LABEL_6: v7 = v23; LABEL_7: v22[1] = v5; v5[(_QWORD)v7] = 0; v21 = 8; std::stringbuf::_M_sync(v19, v22[0], 0LL, 0LL); std::ios::init(v24, v19); while ( 1 ) { v9 = (_QWORD *)std::operator>><char>(&v17, &v14); if ( (*((_BYTE *)v9 + *(_QWORD *)(*v9 - 24LL) + 32) & 5) != 0 ) break; v8 = v15; if ( a2 < v15 ) { v12 = *(_QWORD **)(a1 + 8); if ( v12 == *(_QWORD **)(a1 + 16) ) { std::vector<std::string>::_M_realloc_insert<std::string const&>(a1, *(_QWORD *)(a1 + 8), &v14); } else { *v12 = v12 + 2; std::string::_M_construct<char *>(v12, v14, (char *)v14 + v8); *(_QWORD *)(a1 + 8) += 32LL; } } } v17 = (int *)&unk_5BA0; v24[0] = (char *)&unk_5BA0 + 40; v19[0] = &unk_5C88; if ( v22[0] != v23 ) operator delete(v22[0], v23[0] + 1LL); v19[0] = &unk_5BE8; std::locale::~locale((std::locale *)v20); v17 = &dword_0; *(int **)((char *)&v17 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v24[0] = &unk_5B78; v18 = 0LL; std::ios_base::~ios_base((std::ios_base *)v24); if ( v14 != v16 ) operator delete(v14, v16[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 PUSH R13 MOV R13,RDI PUSH R12 MOV R12,RDX PUSH RBP PUSH RBX SUB RSP,0x1e8 MOV dword ptr [RSP + 0x14],ESI LEA RBX,[RSP + 0x50] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1d8],RAX XOR EAX,EAX LEA RAX,[RSP + 0x40] MOV qword ptr [RDI + 0x10],0x0 MOV qword ptr [RSP + 0x18],RAX MOV qword ptr [RSP + 0x30],RAX LEA RAX,[RSP + 0xc8] MOVUPS xmmword ptr [RDI],XMM0 MOV RDI,RAX MOV qword ptr [RSP],RAX MOV qword ptr [RSP + 0x38],0x0 MOV byte ptr [RSP + 0x40],0x0 CALL 0x001021b0 MOV R14,qword ptr [0x00105c60] XOR EDX,EDX XOR ESI,ESI LEA RAX,[0x105b78] PXOR XMM0,XMM0 MOV word ptr [RSP + 0x1a8],DX MOV RCX,qword ptr [0x00105c68] MOVAPS xmmword ptr [RSP + 0x1b0],XMM0 MOVAPS xmmword ptr [RSP + 0x1c0],XMM0 MOV qword ptr [RSP + 0xc8],RAX MOV RAX,qword ptr [R14 + -0x18] MOV qword ptr [RSP + 0x1a0],0x0 MOV qword ptr [RSP + 0x50],R14 MOV qword ptr [RSP + RAX*0x1 + 0x50],RCX MOV qword ptr [RSP + 0x58],0x0 MOV RDI,qword ptr [R14 + -0x18] ADD RDI,RBX LAB_00102c3e: CALL 0x001022b0 LEA RAX,[0x105ba0] MOV qword ptr [RSP + 0x68],0x0 LEA R15,[RSP + 0xb8] MOV qword ptr [RSP + 0x50],RAX ADD RAX,0x28 MOV qword ptr [RSP + 0xc8],RAX LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x60],RAX LEA RAX,[RSP + 0x98] MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX MOV qword ptr [RSP + 0x70],0x0 MOV qword ptr [RSP + 0x78],0x0 MOV qword ptr [RSP + 0x80],0x0 MOV qword ptr [RSP + 0x88],0x0 MOV qword ptr [RSP + 0x90],0x0 CALL 0x00102310 MOV RBP,qword ptr [R12 + 0x8] MOV R12,qword ptr [R12] LEA RAX,[0x105c88] MOV qword ptr [RSP + 0x60],RAX MOV dword ptr [RSP + 0xa0],0x0 MOV qword ptr [RSP + 0xa8],R15 TEST R12,R12 JNZ 0x00102cf9 TEST RBP,RBP JNZ 0x00102f18 LAB_00102cf9: MOV qword ptr [RSP + 0x28],RBP CMP RBP,0xf JA 0x00102eb0 CMP RBP,0x1 JNZ 0x00102e70 MOVZX EAX,byte ptr [R12] MOV byte ptr [RSP + 0xb8],AL LAB_00102d1e: MOV RAX,R15 LAB_00102d21: MOV qword ptr [RSP + 0xb0],RBP XOR ECX,ECX XOR EDX,EDX MOV byte ptr [RAX + RBP*0x1],0x0 LEA RBP,[RSP + 0x60] MOV RSI,qword ptr [RSP + 0xa8] MOV dword ptr [RSP + 0xa0],0x8 MOV RDI,RBP LAB_00102d4c: CALL 0x001022a0 MOV RDI,qword ptr [RSP] MOV RSI,RBP LAB_00102d58: CALL 0x001022b0 MOVSXD RBP,dword ptr [RSP + 0x14] LEA R12,[RSP + 0x30] JMP 0x00102d7e LAB_00102d70: MOV RDX,qword ptr [RSP + 0x38] CMP RBP,RDX JC 0x00102e80 LAB_00102d7e: MOV RSI,R12 MOV RDI,RBX LAB_00102d84: CALL 0x00102290 MOV RDX,qword ptr [RAX] MOV RDX,qword ptr [RDX + -0x18] TEST byte ptr [RAX + RDX*0x1 + 0x20],0x5 JZ 0x00102d70 LEA RAX,[0x105ba0] MOV RDI,qword ptr [RSP + 0xa8] MOV qword ptr [RSP + 0x50],RAX ADD RAX,0x28 MOV qword ptr [RSP + 0xc8],RAX LEA RAX,[0x105c88] MOV qword ptr [RSP + 0x60],RAX CMP RDI,R15 JZ 0x00102dd9 MOV RAX,qword ptr [RSP + 0xb8] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_00102dd9: MOV RDI,qword ptr [RSP + 0x8] LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x60],RAX CALL 0x001022c0 MOV RAX,qword ptr [R14 + -0x18] MOV RDI,qword ptr [RSP] MOV qword ptr [RSP + 0x50],R14 MOV RCX,qword ptr [0x00105c68] MOV qword ptr [RSP + RAX*0x1 + 0x50],RCX LEA RAX,[0x105b78] MOV qword ptr [RSP + 0xc8],RAX MOV qword ptr [RSP + 0x58],0x0 CALL 0x001021c0 MOV RDI,qword ptr [RSP + 0x30] MOV RAX,qword ptr [RSP + 0x18] CMP RDI,RAX JZ 0x00102e42 MOV RAX,qword ptr [RSP + 0x40] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_00102e42: MOV RAX,qword ptr [RSP + 0x1d8] SUB RAX,qword ptr FS:[0x28] JNZ 0x00102f13 ADD RSP,0x1e8 MOV RAX,R13 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00102e70: TEST RBP,RBP JZ 0x00102d1e MOV RDI,R15 JMP 0x00102edc LAB_00102e80: MOV RDI,qword ptr [R13 + 0x8] CMP RDI,qword ptr [R13 + 0x10] JZ 0x00102f00 LEA RAX,[RDI + 0x10] MOV qword ptr [RDI],RAX MOV RSI,qword ptr [RSP + 0x30] ADD RDX,RSI CALL 0x00102a40 ADD qword ptr [R13 + 0x8],0x20 JMP 0x00102d7e LAB_00102eb0: LEA RSI,[RSP + 0x28] LEA RDI,[RSP + 0xa8] XOR EDX,EDX LAB_00102ebf: CALL 0x00102300 MOV qword ptr [RSP + 0xa8],RAX MOV RDI,RAX MOV RAX,qword ptr [RSP + 0x28] MOV qword ptr [RSP + 0xb8],RAX LAB_00102edc: MOV RDX,RBP MOV RSI,R12 CALL 0x00102240 MOV RBP,qword ptr [RSP + 0x28] MOV RAX,qword ptr [RSP + 0xa8] JMP 0x00102d21 LAB_00102f00: MOV RSI,RDI MOV RDX,R12 MOV RDI,R13 LAB_00102f09: CALL 0x001032e0 JMP 0x00102d7e LAB_00102f13: CALL 0x00102270 LAB_00102f18: MOV RAX,qword ptr [RSP + 0x1d8] SUB RAX,qword ptr FS:[0x28] JNZ 0x00102f13 LEA RDI,[0x104008] LAB_00102f32: CALL 0x00102230 LAB_00102f37: ENDBR64 MOV RBX,RAX JMP 0x0010235f
/* func0(int, std::string) */ vector<std::string,std::allocator<std::string>> * func0(vector<std::string,std::allocator<std::string>> *param_1,int param_2,int8 *param_3) { ulong __n; int *__src; long *plVar1; istream *piVar2; int8 uVar3; long in_FS_OFFSET; ulong local_1f0; char *local_1e8; ulong local_1e0; char local_1d8; int7 uStack_1d7; int8 local_1c8 [2]; char local_1b8 [56]; locale local_180 [8]; int4 local_178; ulong *local_170; ulong local_168; ulong local_160 [2]; int8 local_150 [27]; int8 local_78; int2 local_70; int local_68 [16]; int local_58 [16]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); *(int8 *)(param_1 + 0x10) = 0; *(int (*) [16])param_1 = (int [16])0x0; local_1e0 = 0; local_1d8 = '\0'; local_1e8 = &local_1d8; std::ios_base::ios_base((ios_base *)local_150); uVar3 = std::istringstream::VTT._8_8_; local_70 = 0; local_68 = (int [16])0x0; local_58 = (int [16])0x0; local_150[0] = 0x105b78; local_78 = 0; local_1c8[0] = std::istringstream::VTT._8_8_; *(int8 *)((long)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18)) = std::istringstream::VTT._16_8_; local_1c8[1] = 0; /* try { // try from 00102c3e to 00102c42 has its CatchHandler @ 00102f37 */ std::ios::init((streambuf *) ((istream *)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18))); local_1b8[8] = '\0'; local_1b8[9] = '\0'; local_1b8[10] = '\0'; local_1b8[0xb] = '\0'; local_1b8[0xc] = '\0'; local_1b8[0xd] = '\0'; local_1b8[0xe] = '\0'; local_1b8[0xf] = '\0'; local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_1b8[0x10] = '\0'; local_1b8[0x11] = '\0'; local_1b8[0x12] = '\0'; local_1b8[0x13] = '\0'; local_1b8[0x14] = '\0'; local_1b8[0x15] = '\0'; local_1b8[0x16] = '\0'; local_1b8[0x17] = '\0'; local_1b8[0x18] = '\0'; local_1b8[0x19] = '\0'; local_1b8[0x1a] = '\0'; local_1b8[0x1b] = '\0'; local_1b8[0x1c] = '\0'; local_1b8[0x1d] = '\0'; local_1b8[0x1e] = '\0'; local_1b8[0x1f] = '\0'; local_1b8[0x20] = '\0'; local_1b8[0x21] = '\0'; local_1b8[0x22] = '\0'; local_1b8[0x23] = '\0'; local_1b8[0x24] = '\0'; local_1b8[0x25] = '\0'; local_1b8[0x26] = '\0'; local_1b8[0x27] = '\0'; local_1b8[0x28] = '\0'; local_1b8[0x29] = '\0'; local_1b8[0x2a] = '\0'; local_1b8[0x2b] = '\0'; local_1b8[0x2c] = '\0'; local_1b8[0x2d] = '\0'; local_1b8[0x2e] = '\0'; local_1b8[0x2f] = '\0'; local_1b8[0x30] = '\0'; local_1b8[0x31] = '\0'; local_1b8[0x32] = '\0'; local_1b8[0x33] = '\0'; local_1b8[0x34] = '\0'; local_1b8[0x35] = '\0'; local_1b8[0x36] = '\0'; local_1b8[0x37] = '\0'; std::locale::locale(local_180); __n = param_3[1]; __src = (int *)*param_3; local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_178 = 0; local_170 = local_160; if ((__src == (int *)0x0) && (__n != 0)) { if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { /* try { // try from 00102f32 to 00102f36 has its CatchHandler @ 00102f67 */ uVar3 = std::__throw_logic_error("basic_string: construction from null is not valid"); local_150[0] = 0x105b78; std::ios_base::~ios_base((ios_base *)local_150); std::string::_M_dispose(); std::vector<std::string,std::allocator<std::string>>::~vector(param_1); /* catch() { ... } // from try @ 00102c3e with catch @ 00102f37 */ if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar3); } goto LAB_00102f13; } local_1f0 = __n; if (__n < 0x10) { if (__n == 1) { local_160[0] = CONCAT71(local_160[0]._1_7_,*__src); } else if (__n != 0) goto LAB_00102edc; } else { /* try { // try from 00102ebf to 00102ec3 has its CatchHandler @ 00102f67 */ local_170 = (ulong *)std::string::_M_create((ulong *)&local_170,(ulong)&local_1f0); local_160[0] = local_1f0; LAB_00102edc: memcpy(local_170,__src,__n); } *(int *)((long)local_170 + local_1f0) = 0; local_178 = 8; local_168 = local_1f0; /* try { // try from 00102d4c to 00102d50 has its CatchHandler @ 00102f5b */ std::stringbuf::_M_sync(local_1b8,(ulong)local_170,0); /* try { // try from 00102d58 to 00102d5c has its CatchHandler @ 00102f4f */ std::ios::init((streambuf *)local_150); /* try { // try from 00102d84 to 00102e9d has its CatchHandler @ 00102f43 */ while (piVar2 = std::operator>>((istream *)local_1c8,(string *)&local_1e8), ((byte)piVar2[*(long *)(*(long *)piVar2 + -0x18) + 0x20] & 5) == 0) { if ((ulong)(long)param_2 < local_1e0) { plVar1 = *(long **)(param_1 + 8); if (plVar1 == *(long **)(param_1 + 0x10)) { /* try { // try from 00102f09 to 00102f0d has its CatchHandler @ 00102f43 */ std::vector<std::string,std::allocator<std::string>>::_M_realloc_insert<std::string_const&> (param_1,(__normal_iterator)plVar1,(string *)&local_1e8); } else { *plVar1 = (long)(plVar1 + 2); std::string::_M_construct<char*>((char *)plVar1,local_1e8,(int)local_1e0 + (int)local_1e8); *(long *)(param_1 + 8) = *(long *)(param_1 + 8) + 0x20; } } } local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; if (local_170 != local_160) { operator_delete(local_170,local_160[0] + 1); } local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; std::locale::~locale(local_180); local_1c8[0] = uVar3; *(int8 *)((long)local_1c8 + *(long *)(uVar3 + -0x18)) = std::istringstream::VTT._16_8_; local_150[0] = 0x105b78; local_1c8[1] = 0; std::ios_base::~ios_base((ios_base *)local_150); if (local_1e8 != &local_1d8) { operator_delete(local_1e8,CONCAT71(uStack_1d7,local_1d8) + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } LAB_00102f13: /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
511
func0
#include <iostream> #include <vector> #include <string> #include <assert.h> #include <sstream>
std::vector<std::string> func0(int n, std::string str) { std::vector<std::string> word_len; std::string temp; std::istringstream iss(str); while (iss >> temp) { if (temp.size() > n) { word_len.push_back(temp); } } return word_len; }
int main() { std::vector<std::string> result; result = func0(3, "python is a programming language"); assert((result == std::vector<std::string>{"python", "programming", "language"})); result = func0(2, "writing a program"); assert((result == std::vector<std::string>{"writing", "program"})); result = func0(5, "sorting list"); assert((result == std::vector<std::string>{"sorting"})); return 0; }
O3
cpp
func0(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 pxor %xmm0,%xmm0 mov %esi,%r15d push %r14 push %r13 mov %rdi,%r13 push %r12 push %rbp push %rbx mov %rdx,%rbx sub $0x1f8,%rsp mov %fs:0x28,%rax mov %rax,0x1e8(%rsp) xor %eax,%eax lea 0x50(%rsp),%rax movups %xmm0,(%rdi) lea 0x60(%rsp),%rbp movq $0x0,0x10(%rdi) mov %rax,0x20(%rsp) mov %rax,0x40(%rsp) lea 0xd8(%rsp),%rax mov %rax,%rdi mov %rax,0x8(%rsp) movq $0x0,0x48(%rsp) movb $0x0,0x50(%rsp) callq 21c0 <_ZNSt8ios_baseC2Ev@plt> lea 0x307a(%rip),%rax pxor %xmm0,%xmm0 xor %esi,%esi mov %rax,0xd8(%rsp) xor %eax,%eax mov 0x3153(%rip),%rcx mov %ax,0x1b8(%rsp) mov 0x313c(%rip),%rax movaps %xmm0,0x1c0(%rsp) movaps %xmm0,0x1d0(%rsp) mov %rax,0x60(%rsp) mov -0x18(%rax),%rax movq $0x0,0x1b0(%rsp) mov %rcx,0x60(%rsp,%rax,1) mov 0x310b(%rip),%rax movq $0x0,0x68(%rsp) mov -0x18(%rax),%rdi add %rbp,%rdi callq 22c0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> movq $0x0,0x78(%rsp) lea 0x3026(%rip),%rax mov %rax,0x60(%rsp) add $0x28,%rax mov %rax,0xd8(%rsp) lea 0x3056(%rip),%rax mov %rax,0x70(%rsp) lea 0xa8(%rsp),%rax mov %rax,%rdi mov %rax,0x18(%rsp) movq $0x0,0x80(%rsp) movq $0x0,0x88(%rsp) movq $0x0,0x90(%rsp) movq $0x0,0x98(%rsp) movq $0x0,0xa0(%rsp) callq 2330 <_ZNSt6localeC1Ev@plt> lea 0x3099(%rip),%rax mov (%rbx),%r14 mov 0x8(%rbx),%r12 mov %rax,0x70(%rsp) lea 0xc8(%rsp),%rax mov %rax,0x10(%rsp) mov %rax,0xb8(%rsp) mov %r14,%rax movl $0x0,0xb0(%rsp) add %r12,%rax je 2c1c <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1ac> test %r14,%r14 je 2ed3 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x463> mov %r12,0x38(%rsp) cmp $0xf,%r12 ja 2e08 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x398> cmp $0x1,%r12 jne 2d80 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x310> movzbl (%r14),%eax mov %al,0xc8(%rsp) mov 0x10(%rsp),%rax mov %r12,0xc0(%rsp) xor %ecx,%ecx xor %edx,%edx movb $0x0,(%rax,%r12,1) lea 0x70(%rsp),%r12 mov 0xb8(%rsp),%rsi movl $0x8,0xb0(%rsp) mov %r12,%rdi callq 22b0 <_ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm@plt> mov 0x8(%rsp),%rdi mov %r12,%rsi callq 22c0 <_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E@plt> lea 0x40(%rsp),%r12 movslq %r15d,%rbx jmp 2c9b <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x22b> nopl (%rax) cmp 0x48(%rsp),%rbx jb 2d98 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x328> mov %r12,%rsi mov %rbp,%rdi callq 22a0 <_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@plt> mov (%rax),%rdx mov -0x18(%rdx),%rdx testb $0x5,0x20(%rax,%rdx,1) je 2c90 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x220> lea 0x2ed5(%rip),%rax mov 0xb8(%rsp),%rdi mov %rax,0x60(%rsp) add $0x28,%rax mov %rax,0xd8(%rsp) lea 0x2f9d(%rip),%rax mov %rax,0x70(%rsp) cmp 0x10(%rsp),%rdi je 2cec <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x27c> callq 2270 <_ZdlPv@plt> mov 0x18(%rsp),%rdi lea 0x2ee0(%rip),%rax mov %rax,0x70(%rsp) callq 22d0 <_ZNSt6localeD1Ev@plt> mov 0x2f47(%rip),%rax mov 0x8(%rsp),%rdi mov 0x2f43(%rip),%rcx mov %rax,0x60(%rsp) mov -0x18(%rax),%rax mov %rcx,0x60(%rsp,%rax,1) lea 0x2e3e(%rip),%rax movq $0x0,0x68(%rsp) mov %rax,0xd8(%rsp) callq 21d0 <_ZNSt8ios_baseD2Ev@plt> mov 0x40(%rsp),%rdi cmp 0x20(%rsp),%rdi je 2d51 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2e1> callq 2270 <_ZdlPv@plt> mov 0x1e8(%rsp),%rax xor %fs:0x28,%rax jne 2eb8 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x448> add $0x1f8,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl (%rax) test %r12,%r12 jne 2ebd <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x44d> mov 0x10(%rsp),%rax jmpq 2c45 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1d5> nopl 0x0(%rax,%rax,1) mov 0x8(%r13),%r14 cmp 0x10(%r13),%r14 je 2e58 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3e8> lea 0x10(%r14),%rdi mov 0x48(%rsp),%r15 mov %rdi,(%r14) mov 0x40(%rsp),%rax mov %rax,%rcx mov %rax,0x28(%rsp) add %r15,%rcx je 2dcd <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x35d> test %rax,%rax je 2ec7 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x457> mov %r15,0x38(%rsp) cmp $0xf,%r15 ja 2e80 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x410> cmp $0x1,%r15 jne 2e70 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x400> mov 0x28(%rsp),%rax movzbl (%rax),%eax mov %al,0x10(%r14) mov %r15,0x8(%r14) movb $0x0,(%rdi,%r15,1) addq $0x20,0x8(%r13) jmpq 2c9b <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x22b> nopl (%rax) lea 0x38(%rsp),%rsi lea 0xb8(%rsp),%rdi xor %edx,%edx callq 2320 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@plt> mov %rax,0xb8(%rsp) mov %rax,%rdi mov 0x38(%rsp),%rax mov %rax,0xc8(%rsp) mov %r12,%rdx mov %r14,%rsi callq 2250 <memcpy@plt> mov 0x38(%rsp),%r12 mov 0xb8(%rsp),%rax jmpq 2c45 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1d5> nopl 0x0(%rax) mov %r12,%rdx mov %r14,%rsi mov %r13,%rdi callq 3200 <_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_> jmpq 2c9b <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x22b> nopl 0x0(%rax,%rax,1) test %r15,%r15 je 2df2 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x382> jmp 2e9e <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x42e> nopl 0x0(%rax,%rax,1) lea 0x38(%rsp),%rsi xor %edx,%edx mov %r14,%rdi callq 2320 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@plt> mov %rax,(%r14) mov %rax,%rdi mov 0x38(%rsp),%rax mov %rax,0x10(%r14) mov 0x28(%rsp),%rsi mov %r15,%rdx callq 2250 <memcpy@plt> mov 0x38(%rsp),%r15 mov (%r14),%rdi jmpq 2df2 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x382> callq 2290 <__stack_chk_fail@plt> mov 0x10(%rsp),%rdi jmpq 2e34 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3c4> lea 0x113a(%rip),%rdi callq 2240 <_ZSt19__throw_logic_errorPKc@plt> lea 0x112e(%rip),%rdi callq 2240 <_ZSt19__throw_logic_errorPKc@plt> endbr64 mov %rax,%rbx jmpq 2360 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x20> endbr64 mov %rax,%rbp jmpq 239e <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x5e> endbr64 mov %rax,%rbx jmpq 2340 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold> endbr64 mov %rax,%rbx jmpq 234c <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0xc> endbr64 mov %rax,%rbx jmpq 23d8 <_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x98> nopl 0x0(%rax,%rax,1)
_Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 pxor xmm0, xmm0 push r14 mov r14, rdi push r13 mov r13, rdx push r12 push rbp movsxd rbp, esi push rbx sub rsp, 1F8h mov rax, fs:28h mov [rsp+228h+var_40], rax xor eax, eax lea rax, [rsp+228h+var_1D8] movups xmmword ptr [rdi], xmm0 lea r12, [rsp+228h+var_1C8] mov qword ptr [rdi+10h], 0 mov [rsp+228h+var_208], rax mov [rsp+228h+var_1E8], rax lea rax, [rsp+228h+var_150] mov rdi, rax; this mov [rsp+228h+var_220], rax mov [rsp+228h+n], 0 mov byte ptr [rsp+228h+var_1D8], 0 call __ZNSt8ios_baseC2Ev; std::ios_base::ios_base(void) lea rax, unk_5B78 xor edx, edx xor esi, esi mov [rsp+228h+var_150], rax mov rax, cs:qword_5C60 pxor xmm0, xmm0 mov [rsp+228h+var_70], dx mov rcx, cs:qword_5C68 movaps [rsp+228h+var_68], xmm0 movaps [rsp+228h+var_58], xmm0 mov [rsp+228h+var_1C8], rax mov rax, [rax-18h] mov [rsp+228h+var_78], 0 mov [rsp+rax+228h+var_1C8], rcx mov rax, cs:qword_5C60 mov [rsp+228h+var_1C0], 0 mov rdi, [rax-18h] add rdi, r12 call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) mov [rsp+228h+var_1B0], 0 lea rax, unk_5BA0 mov [rsp+228h+var_1C8], rax add rax, 28h ; '(' mov [rsp+228h+var_150], rax lea rax, unk_5BE8 mov [rsp+228h+var_1B8], rax lea rax, [rsp+228h+var_180] mov rdi, rax; this mov [rsp+228h+var_210], rax mov [rsp+228h+var_1A8], 0 mov [rsp+228h+var_1A0], 0 mov [rsp+228h+var_198], 0 mov [rsp+228h+var_190], 0 mov [rsp+228h+var_188], 0 call __ZNSt6localeC1Ev; std::locale::locale(void) lea rax, unk_5C88 mov rbx, [r13+8] mov r13, [r13+0] mov [rsp+228h+var_1B8], rax lea rax, [rsp+228h+var_160] mov [rsp+228h+var_178], 0 mov [rsp+228h+var_218], rax mov [rsp+228h+var_170], rax test r13, r13 jnz short loc_2CFA test rbx, rbx jnz loc_2F95 loc_2CFA: mov [rsp+228h+var_1F0], rbx cmp rbx, 0Fh ja loc_2EF0 cmp rbx, 1 jnz loc_2E80 movzx eax, byte ptr [r13+0] mov byte ptr [rsp+228h+var_160], al loc_2D1F: mov rax, [rsp+228h+var_218] loc_2D24: mov [rsp+228h+var_168], rbx xor ecx, ecx xor edx, edx mov byte ptr [rax+rbx], 0 lea rbx, [rsp+228h+var_1B8] mov rsi, [rsp+228h+var_170] mov [rsp+228h+var_178], 8 mov rdi, rbx call __ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm; std::stringbuf::_M_sync(char *,ulong,ulong) mov rdi, [rsp+228h+var_220] mov rsi, rbx call __ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E; std::ios::init(std::streambuf *) lea r13, [rsp+228h+var_1E8] jmp short loc_2D7E loc_2D70: mov rbx, [rsp+228h+n] cmp rbp, rbx jb loc_2E98 loc_2D7E: mov rsi, r13 mov rdi, r12 call __ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE; std::operator>><char>(std::istream &,std::string &) mov rdx, [rax] mov rdx, [rdx-18h] test byte ptr [rax+rdx+20h], 5 jz short loc_2D70 lea rax, unk_5BA0 mov rdi, [rsp+228h+var_170]; void * mov [rsp+228h+var_1C8], rax add rax, 28h ; '(' mov [rsp+228h+var_150], rax lea rax, unk_5C88 mov [rsp+228h+var_1B8], rax mov rax, [rsp+228h+var_218] cmp rdi, rax jz short loc_2DDE mov rax, [rsp+228h+var_160] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_2DDE: mov rdi, [rsp+228h+var_210]; this lea rax, unk_5BE8 mov [rsp+228h+var_1B8], rax call __ZNSt6localeD1Ev; std::locale::~locale() mov rax, cs:qword_5C60 mov rdi, [rsp+228h+var_220]; this mov rcx, cs:qword_5C68 mov [rsp+228h+var_1C8], rax mov rax, [rax-18h] mov [rsp+rax+228h+var_1C8], rcx lea rax, unk_5B78 mov [rsp+228h+var_150], rax mov [rsp+228h+var_1C0], 0 call __ZNSt8ios_baseD2Ev; std::ios_base::~ios_base() mov rdi, [rsp+228h+var_1E8]; void * mov rax, [rsp+228h+var_208] cmp rdi, rax jz short loc_2E4F mov rax, [rsp+228h+var_1D8] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_2E4F: mov rax, [rsp+228h+var_40] sub rax, fs:28h jnz loc_2F90 add rsp, 1F8h mov rax, r14 pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_2E80: test rbx, rbx jz loc_2D1F mov rdi, [rsp+228h+var_218] jmp loc_2F1C loc_2E98: mov r15, [r14+8] cmp r15, [r14+10h] jz loc_2F40 lea rdi, [r15+10h] mov [r15], rdi mov rax, [rsp+228h+var_1E8] mov [rsp+228h+var_1F0], rbx mov [rsp+228h+src], rax cmp rbx, 0Fh ja loc_2F58 cmp rbx, 1 jnz loc_2F76 movzx eax, byte ptr [rax] mov [r15+10h], al loc_2ED7: mov [r15+8], rbx mov byte ptr [rdi+rbx], 0 add qword ptr [r14+8], 20h ; ' ' jmp loc_2D7E loc_2EF0: lea rsi, [rsp+228h+var_1F0] lea rdi, [rsp+228h+var_170] xor edx, edx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm; std::string::_M_create(ulong &,ulong) mov [rsp+228h+var_170], rax mov rdi, rax; dest mov rax, [rsp+228h+var_1F0] mov [rsp+228h+var_160], rax loc_2F1C: mov rdx, rbx; n mov rsi, r13; src call _memcpy mov rbx, [rsp+228h+var_1F0] mov rax, [rsp+228h+var_170] jmp loc_2D24 loc_2F40: mov rdx, r13 mov rsi, r15 mov rdi, r14 call _ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_; std::vector<std::string>::_M_realloc_insert<std::string const&>(__gnu_cxx::__normal_iterator<std::string*,std::vector<std::string>>,std::string const&) jmp loc_2D7E loc_2F58: lea rsi, [rsp+228h+var_1F0] xor edx, edx mov rdi, r15 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm; std::string::_M_create(ulong &,ulong) mov [r15], rax mov rdi, rax; dest mov rax, [rsp+228h+var_1F0] mov [r15+10h], rax loc_2F76: mov rsi, [rsp+228h+src]; src mov rdx, rbx; n call _memcpy mov rbx, [rsp+228h+var_1F0] mov rdi, [r15] jmp loc_2ED7 loc_2F90: call ___stack_chk_fail loc_2F95: mov rax, [rsp+228h+var_40] sub rax, fs:28h jnz short loc_2F90 lea rdi, aBasicStringCon; "basic_string: construction from null is"... call __ZSt19__throw_logic_errorPKc; std::__throw_logic_error(char const*) endbr64 mov rbx, rax jmp loc_2372 endbr64 mov rbx, rax jmp loc_2392 endbr64 mov rbx, rax jmp _Z5func0iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_cold; func0(int,std::string) [clone] endbr64 mov rbx, rax jmp loc_23C5 endbr64 mov rbx, rax jmp loc_2339
long long func0(long long a1, int a2, long long a3) { char *v5; // rbx _BYTE *v6; // r13 _QWORD *v7; // rax size_t v8; // rbx _QWORD *v9; // rax _QWORD *v11; // rdi long long *v12; // r15 void *v13; // rdi long long v14; // rax const void *src; // [rsp+20h] [rbp-200h] char *v16; // [rsp+30h] [rbp-1F0h] BYREF void *v17; // [rsp+38h] [rbp-1E8h] BYREF size_t n; // [rsp+40h] [rbp-1E0h] _QWORD v19[2]; // [rsp+48h] [rbp-1D8h] BYREF int *v20; // [rsp+58h] [rbp-1C8h] BYREF long long v21; // [rsp+60h] [rbp-1C0h] _QWORD v22[7]; // [rsp+68h] [rbp-1B8h] BYREF char v23[8]; // [rsp+A0h] [rbp-180h] BYREF int v24; // [rsp+A8h] [rbp-178h] void *v25[2]; // [rsp+B0h] [rbp-170h] BYREF _QWORD v26[2]; // [rsp+C0h] [rbp-160h] BYREF _QWORD v27[28]; // [rsp+D0h] [rbp-150h] BYREF __int16 v28; // [rsp+1B0h] [rbp-70h] __int128 v29; // [rsp+1B8h] [rbp-68h] __int128 v30; // [rsp+1C8h] [rbp-58h] unsigned long long v31; // [rsp+1E0h] [rbp-40h] v31 = __readfsqword(0x28u); *(_OWORD *)a1 = 0LL; *(_QWORD *)(a1 + 16) = 0LL; v17 = v19; n = 0LL; LOBYTE(v19[0]) = 0; std::ios_base::ios_base((std::ios_base *)v27); v27[0] = &unk_5B78; v28 = 0; v29 = 0LL; v30 = 0LL; v20 = &dword_0; v27[27] = 0LL; *(int **)((char *)&v20 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v21 = 0LL; std::ios::init((char *)&v20 + MEMORY[0xFFFFFFFFFFFFFFE8], 0LL); memset(&v22[1], 0, 48); v20 = (int *)&unk_5BA0; v27[0] = (char *)&unk_5BA0 + 40; v22[0] = &unk_5BE8; std::locale::locale((std::locale *)v23); v5 = *(char **)(a3 + 8); v6 = *(_BYTE **)a3; v22[0] = &unk_5C88; v24 = 0; v25[0] = v26; if ( !v6 && v5 ) std::__throw_logic_error("basic_string: construction from null is not valid"); v16 = v5; if ( (unsigned long long)v5 > 0xF ) { v25[0] = (void *)std::string::_M_create(v25, &v16, 0LL); v11 = v25[0]; v26[0] = v16; goto LABEL_23; } if ( v5 != (_BYTE *)&dword_0 + 1 ) { if ( !v5 ) goto LABEL_6; v11 = v26; LABEL_23: memcpy(v11, v6, (size_t)v5); v5 = v16; v7 = v25[0]; goto LABEL_7; } LOBYTE(v26[0]) = *v6; LABEL_6: v7 = v26; LABEL_7: v25[1] = v5; v5[(_QWORD)v7] = 0; v24 = 8; std::stringbuf::_M_sync(v22, v25[0], 0LL, 0LL); std::ios::init(v27, v22); while ( 1 ) { v9 = (_QWORD *)std::operator>><char>(&v20, &v17); if ( (*((_BYTE *)v9 + *(_QWORD *)(*v9 - 24LL) + 32) & 5) != 0 ) break; v8 = n; if ( a2 < n ) { v12 = *(long long **)(a1 + 8); if ( v12 == *(long long **)(a1 + 16) ) { std::vector<std::string>::_M_realloc_insert<std::string const&>(a1, *(_QWORD *)(a1 + 8), &v17); } else { v13 = v12 + 2; *v12 = (long long)(v12 + 2); v16 = (char *)v8; src = v17; if ( v8 > 0xF ) { v14 = std::string::_M_create(v12, &v16, 0LL); *v12 = v14; v13 = (void *)v14; v12[2] = (long long)v16; } else if ( v8 == 1 ) { *((_BYTE *)v12 + 16) = *(_BYTE *)v17; goto LABEL_21; } memcpy(v13, src, v8); v8 = (size_t)v16; v13 = (void *)*v12; LABEL_21: v12[1] = v8; *((_BYTE *)v13 + v8) = 0; *(_QWORD *)(a1 + 8) += 32LL; } } } v20 = (int *)&unk_5BA0; v27[0] = (char *)&unk_5BA0 + 40; v22[0] = &unk_5C88; if ( v25[0] != v26 ) operator delete(v25[0], v26[0] + 1LL); v22[0] = &unk_5BE8; std::locale::~locale((std::locale *)v23); v20 = &dword_0; *(int **)((char *)&v20 + MEMORY[0xFFFFFFFFFFFFFFE8]) = &dword_0; v27[0] = &unk_5B78; v21 = 0LL; std::ios_base::~ios_base((std::ios_base *)v27); if ( v17 != v19 ) operator delete(v17, v19[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 MOV R14,RDI PUSH R13 MOV R13,RDX PUSH R12 PUSH RBP MOVSXD RBP,ESI PUSH RBX SUB RSP,0x1f8 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x1e8],RAX XOR EAX,EAX LEA RAX,[RSP + 0x50] MOVUPS xmmword ptr [RDI],XMM0 LEA R12,[RSP + 0x60] MOV qword ptr [RDI + 0x10],0x0 MOV qword ptr [RSP + 0x20],RAX MOV qword ptr [RSP + 0x40],RAX LEA RAX,[RSP + 0xd8] MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX MOV qword ptr [RSP + 0x48],0x0 MOV byte ptr [RSP + 0x50],0x0 CALL 0x001021b0 LEA RAX,[0x105b78] XOR EDX,EDX XOR ESI,ESI MOV qword ptr [RSP + 0xd8],RAX MOV RAX,qword ptr [0x00105c60] PXOR XMM0,XMM0 MOV word ptr [RSP + 0x1b8],DX MOV RCX,qword ptr [0x00105c68] MOVAPS xmmword ptr [RSP + 0x1c0],XMM0 MOVAPS xmmword ptr [RSP + 0x1d0],XMM0 MOV qword ptr [RSP + 0x60],RAX MOV RAX,qword ptr [RAX + -0x18] MOV qword ptr [RSP + 0x1b0],0x0 MOV qword ptr [RSP + RAX*0x1 + 0x60],RCX MOV RAX,qword ptr [0x00105c60] MOV qword ptr [RSP + 0x68],0x0 MOV RDI,qword ptr [RAX + -0x18] ADD RDI,R12 LAB_00102c35: CALL 0x001022b0 MOV qword ptr [RSP + 0x78],0x0 LEA RAX,[0x105ba0] MOV qword ptr [RSP + 0x60],RAX ADD RAX,0x28 MOV qword ptr [RSP + 0xd8],RAX LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x70],RAX LEA RAX,[RSP + 0xa8] MOV RDI,RAX MOV qword ptr [RSP + 0x18],RAX MOV qword ptr [RSP + 0x80],0x0 MOV qword ptr [RSP + 0x88],0x0 MOV qword ptr [RSP + 0x90],0x0 MOV qword ptr [RSP + 0x98],0x0 MOV qword ptr [RSP + 0xa0],0x0 CALL 0x00102310 LEA RAX,[0x105c88] MOV RBX,qword ptr [R13 + 0x8] MOV R13,qword ptr [R13] MOV qword ptr [RSP + 0x70],RAX LEA RAX,[RSP + 0xc8] MOV dword ptr [RSP + 0xb0],0x0 MOV qword ptr [RSP + 0x10],RAX MOV qword ptr [RSP + 0xb8],RAX TEST R13,R13 JNZ 0x00102cfa TEST RBX,RBX JNZ 0x00102f95 LAB_00102cfa: MOV qword ptr [RSP + 0x38],RBX CMP RBX,0xf JA 0x00102ef0 CMP RBX,0x1 JNZ 0x00102e80 MOVZX EAX,byte ptr [R13] MOV byte ptr [RSP + 0xc8],AL LAB_00102d1f: MOV RAX,qword ptr [RSP + 0x10] LAB_00102d24: MOV qword ptr [RSP + 0xc0],RBX XOR ECX,ECX XOR EDX,EDX MOV byte ptr [RAX + RBX*0x1],0x0 LEA RBX,[RSP + 0x70] MOV RSI,qword ptr [RSP + 0xb8] MOV dword ptr [RSP + 0xb0],0x8 MOV RDI,RBX LAB_00102d4f: CALL 0x001022a0 MOV RDI,qword ptr [RSP + 0x8] MOV RSI,RBX LAB_00102d5c: CALL 0x001022b0 LEA R13,[RSP + 0x40] JMP 0x00102d7e LAB_00102d70: MOV RBX,qword ptr [RSP + 0x48] CMP RBP,RBX JC 0x00102e98 LAB_00102d7e: MOV RSI,R13 MOV RDI,R12 LAB_00102d84: CALL 0x00102290 MOV RDX,qword ptr [RAX] MOV RDX,qword ptr [RDX + -0x18] TEST byte ptr [RAX + RDX*0x1 + 0x20],0x5 JZ 0x00102d70 LEA RAX,[0x105ba0] MOV RDI,qword ptr [RSP + 0xb8] MOV qword ptr [RSP + 0x60],RAX ADD RAX,0x28 MOV qword ptr [RSP + 0xd8],RAX LEA RAX,[0x105c88] MOV qword ptr [RSP + 0x70],RAX MOV RAX,qword ptr [RSP + 0x10] CMP RDI,RAX JZ 0x00102dde MOV RAX,qword ptr [RSP + 0xc8] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_00102dde: MOV RDI,qword ptr [RSP + 0x18] LEA RAX,[0x105be8] MOV qword ptr [RSP + 0x70],RAX CALL 0x001022c0 MOV RAX,qword ptr [0x00105c60] MOV RDI,qword ptr [RSP + 0x8] MOV RCX,qword ptr [0x00105c68] MOV qword ptr [RSP + 0x60],RAX MOV RAX,qword ptr [RAX + -0x18] MOV qword ptr [RSP + RAX*0x1 + 0x60],RCX LEA RAX,[0x105b78] MOV qword ptr [RSP + 0xd8],RAX MOV qword ptr [RSP + 0x68],0x0 CALL 0x001021c0 MOV RDI,qword ptr [RSP + 0x40] MOV RAX,qword ptr [RSP + 0x20] CMP RDI,RAX JZ 0x00102e4f MOV RAX,qword ptr [RSP + 0x50] LEA RSI,[RAX + 0x1] CALL 0x00102260 LAB_00102e4f: MOV RAX,qword ptr [RSP + 0x1e8] SUB RAX,qword ptr FS:[0x28] JNZ 0x00102f90 ADD RSP,0x1f8 MOV RAX,R14 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00102e80: TEST RBX,RBX JZ 0x00102d1f MOV RDI,qword ptr [RSP + 0x10] JMP 0x00102f1c LAB_00102e98: MOV R15,qword ptr [R14 + 0x8] CMP R15,qword ptr [R14 + 0x10] JZ 0x00102f40 LEA RDI,[R15 + 0x10] MOV qword ptr [R15],RDI MOV RAX,qword ptr [RSP + 0x40] MOV qword ptr [RSP + 0x38],RBX MOV qword ptr [RSP + 0x28],RAX CMP RBX,0xf JA 0x00102f58 CMP RBX,0x1 JNZ 0x00102f76 MOVZX EAX,byte ptr [RAX] MOV byte ptr [R15 + 0x10],AL LAB_00102ed7: MOV qword ptr [R15 + 0x8],RBX MOV byte ptr [RDI + RBX*0x1],0x0 ADD qword ptr [R14 + 0x8],0x20 JMP 0x00102d7e LAB_00102ef0: LEA RSI,[RSP + 0x38] LEA RDI,[RSP + 0xb8] XOR EDX,EDX LAB_00102eff: CALL 0x00102300 MOV qword ptr [RSP + 0xb8],RAX MOV RDI,RAX MOV RAX,qword ptr [RSP + 0x38] MOV qword ptr [RSP + 0xc8],RAX LAB_00102f1c: MOV RDX,RBX MOV RSI,R13 CALL 0x00102240 MOV RBX,qword ptr [RSP + 0x38] MOV RAX,qword ptr [RSP + 0xb8] JMP 0x00102d24 LAB_00102f40: MOV RDX,R13 MOV RSI,R15 MOV RDI,R14 LAB_00102f49: CALL 0x00103270 JMP 0x00102d7e LAB_00102f58: LEA RSI,[RSP + 0x38] XOR EDX,EDX MOV RDI,R15 CALL 0x00102300 MOV qword ptr [R15],RAX MOV RDI,RAX MOV RAX,qword ptr [RSP + 0x38] MOV qword ptr [R15 + 0x10],RAX LAB_00102f76: MOV RSI,qword ptr [RSP + 0x28] MOV RDX,RBX CALL 0x00102240 MOV RBX,qword ptr [RSP + 0x38] MOV RDI,qword ptr [R15] JMP 0x00102ed7 LAB_00102f90: CALL 0x00102270 LAB_00102f95: MOV RAX,qword ptr [RSP + 0x1e8] SUB RAX,qword ptr FS:[0x28] JNZ 0x00102f90 LEA RDI,[0x104008] LAB_00102faf: CALL 0x00102230 LAB_00102fb4: ENDBR64 MOV RBX,RAX JMP 0x00102372
/* func0(int, std::string) */ vector<std::string,std::allocator<std::string>> * func0(vector<std::string,std::allocator<std::string>> *param_1,int param_2,int8 *param_3) { ulong uVar1; int *puVar2; ulong *puVar3; istream *piVar4; ulong *__dest; int8 uVar5; long in_FS_OFFSET; ulong local_1f0; int *local_1e8; ulong local_1e0; int local_1d8; int7 uStack_1d7; int8 local_1c8 [2]; char local_1b8 [56]; locale local_180 [8]; int4 local_178; ulong *local_170; ulong local_168; ulong local_160 [2]; int8 local_150 [27]; int8 local_78; int2 local_70; int local_68 [16]; int local_58 [16]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); *(int (*) [16])param_1 = (int [16])0x0; *(int8 *)(param_1 + 0x10) = 0; local_1e0 = 0; local_1d8 = 0; local_1e8 = &local_1d8; std::ios_base::ios_base((ios_base *)local_150); local_150[0] = 0x105b78; local_70 = 0; local_68 = (int [16])0x0; local_58 = (int [16])0x0; local_1c8[0] = std::istringstream::VTT._8_8_; local_78 = 0; *(int8 *)((long)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18)) = std::istringstream::VTT._16_8_; local_1c8[1] = 0; /* try { // try from 00102c35 to 00102c39 has its CatchHandler @ 00102fb4 */ std::ios::init((streambuf *) ((istream *)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18))); local_1b8[8] = '\0'; local_1b8[9] = '\0'; local_1b8[10] = '\0'; local_1b8[0xb] = '\0'; local_1b8[0xc] = '\0'; local_1b8[0xd] = '\0'; local_1b8[0xe] = '\0'; local_1b8[0xf] = '\0'; local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_1b8[0x10] = '\0'; local_1b8[0x11] = '\0'; local_1b8[0x12] = '\0'; local_1b8[0x13] = '\0'; local_1b8[0x14] = '\0'; local_1b8[0x15] = '\0'; local_1b8[0x16] = '\0'; local_1b8[0x17] = '\0'; local_1b8[0x18] = '\0'; local_1b8[0x19] = '\0'; local_1b8[0x1a] = '\0'; local_1b8[0x1b] = '\0'; local_1b8[0x1c] = '\0'; local_1b8[0x1d] = '\0'; local_1b8[0x1e] = '\0'; local_1b8[0x1f] = '\0'; local_1b8[0x20] = '\0'; local_1b8[0x21] = '\0'; local_1b8[0x22] = '\0'; local_1b8[0x23] = '\0'; local_1b8[0x24] = '\0'; local_1b8[0x25] = '\0'; local_1b8[0x26] = '\0'; local_1b8[0x27] = '\0'; local_1b8[0x28] = '\0'; local_1b8[0x29] = '\0'; local_1b8[0x2a] = '\0'; local_1b8[0x2b] = '\0'; local_1b8[0x2c] = '\0'; local_1b8[0x2d] = '\0'; local_1b8[0x2e] = '\0'; local_1b8[0x2f] = '\0'; local_1b8[0x30] = '\0'; local_1b8[0x31] = '\0'; local_1b8[0x32] = '\0'; local_1b8[0x33] = '\0'; local_1b8[0x34] = '\0'; local_1b8[0x35] = '\0'; local_1b8[0x36] = '\0'; local_1b8[0x37] = '\0'; std::locale::locale(local_180); uVar1 = param_3[1]; puVar2 = (int *)*param_3; local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; local_178 = 0; local_170 = local_160; if ((puVar2 == (int *)0x0) && (uVar1 != 0)) { if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { /* try { // try from 00102faf to 00102fb3 has its CatchHandler @ 00102fe4 */ uVar5 = std::__throw_logic_error("basic_string: construction from null is not valid"); local_150[0] = 0x105b78; std::ios_base::~ios_base((ios_base *)local_150); std::string::_M_dispose(); std::vector<std::string,std::allocator<std::string>>::~vector(param_1); /* catch() { ... } // from try @ 00102c35 with catch @ 00102fb4 */ if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar5); } goto LAB_00102f90; } local_1f0 = uVar1; if (uVar1 < 0x10) { if (uVar1 == 1) { local_160[0] = CONCAT71(local_160[0]._1_7_,*puVar2); } else if (uVar1 != 0) goto LAB_00102f1c; } else { /* try { // try from 00102eff to 00102f03 has its CatchHandler @ 00102fe4 */ local_170 = (ulong *)std::string::_M_create((ulong *)&local_170,(ulong)&local_1f0); local_160[0] = local_1f0; LAB_00102f1c: memcpy(local_170,puVar2,uVar1); } *(int *)((long)local_170 + local_1f0) = 0; local_178 = 8; local_168 = local_1f0; /* try { // try from 00102d4f to 00102d53 has its CatchHandler @ 00102fd8 */ std::stringbuf::_M_sync(local_1b8,(ulong)local_170,0); /* try { // try from 00102d5c to 00102d60 has its CatchHandler @ 00102fcc */ std::ios::init((streambuf *)local_150); /* try { // try from 00102d84 to 00102d88 has its CatchHandler @ 00102fc0 */ while (piVar4 = std::operator>>((istream *)local_1c8,(string *)&local_1e8), uVar1 = local_1e0, puVar2 = local_1e8, ((byte)piVar4[*(long *)(*(long *)piVar4 + -0x18) + 0x20] & 5) == 0) { if ((ulong)(long)param_2 < local_1e0) { puVar3 = *(ulong **)(param_1 + 8); if (puVar3 == *(ulong **)(param_1 + 0x10)) { /* try { // try from 00102f49 to 00102f66 has its CatchHandler @ 00102fc0 */ std::vector<std::string,std::allocator<std::string>>::_M_realloc_insert<std::string_const&> (param_1,(__normal_iterator)puVar3,(string *)&local_1e8); } else { __dest = puVar3 + 2; *puVar3 = (ulong)__dest; local_1f0 = local_1e0; if (local_1e0 < 0x10) { if (local_1e0 != 1) goto LAB_00102f76; *(int *)(puVar3 + 2) = *local_1e8; } else { __dest = (ulong *)std::string::_M_create(puVar3,(ulong)&local_1f0); *puVar3 = (ulong)__dest; puVar3[2] = local_1f0; LAB_00102f76: memcpy(__dest,puVar2,uVar1); __dest = (ulong *)*puVar3; } puVar3[1] = local_1f0; *(int *)((long)__dest + local_1f0) = 0; *(long *)(param_1 + 8) = *(long *)(param_1 + 8) + 0x20; } } } local_1c8[0] = 0x105ba0; local_150[0] = 0x105bc8; local_1b8[0] = -0x78; local_1b8[1] = '\\'; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; if (local_170 != local_160) { operator_delete(local_170,local_160[0] + 1); } local_1b8[0] = -0x18; local_1b8[1] = '['; local_1b8[2] = '\x10'; local_1b8[3] = '\0'; local_1b8[4] = '\0'; local_1b8[5] = '\0'; local_1b8[6] = '\0'; local_1b8[7] = '\0'; std::locale::~locale(local_180); local_1c8[0] = std::istringstream::VTT._8_8_; *(int8 *)((long)local_1c8 + *(long *)(std::istringstream::VTT._8_8_ + -0x18)) = std::istringstream::VTT._16_8_; local_150[0] = 0x105b78; local_1c8[1] = 0; std::ios_base::~ios_base((ios_base *)local_150); if (local_1e8 != &local_1d8) { operator_delete(local_1e8,CONCAT71(uStack_1d7,local_1d8) + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } LAB_00102f90: /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
512
func0
#include <vector> #include <set> #include <cassert>
bool func0(const std::vector<std::vector<int>>& my_matrix) { int iSize = my_matrix[0].size(); std::vector<int> sum_list; for (const auto& lines : my_matrix) { int line_sum = 0; for (int num : lines) { line_sum += num; } sum_list.push_back(line_sum); } for (int col = 0; col < iSize; ++col) { int col_sum = 0; for (int row = 0; row < iSize; ++row) { col_sum += my_matrix[row][col]; } sum_list.push_back(col_sum); } int result1 = 0; for (int i = 0; i < iSize; ++i) { result1 += my_matrix[i][i]; } sum_list.push_back(result1); int result2 = 0; for (int i = iSize - 1; i >= 0; --i) { result2 += my_matrix[i][i]; } sum_list.push_back(result2); std::set<int> unique_sums(sum_list.begin(), sum_list.end()); return unique_sums.size() == 1; }
int main() { assert(func0({{7, 12, 1, 14}, {2, 13, 8, 11}, {16, 3, 10, 5}, {9, 6, 15, 4}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 8}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 7}}) == false); return 0; }
O0
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0xc8,%rsp mov %rdi,-0xc8(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0xc8(%rbp),%rax mov $0x0,%esi mov %rax,%rdi callq 220c <_ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdi callq 223a <_ZNKSt6vectorIiSaIiEE4sizeEv> mov %eax,-0xa8(%rbp) lea -0x70(%rbp),%rax mov %rax,%rdi callq 21cc <_ZNSt6vectorIiSaIiEEC1Ev> mov -0xc8(%rbp),%rax mov %rax,-0x88(%rbp) mov -0x88(%rbp),%rax mov %rax,%rdi callq 2348 <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE5beginEv> mov %rax,-0xa0(%rbp) mov -0x88(%rbp),%rax mov %rax,%rdi callq 23a0 <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE3endEv> mov %rax,-0x98(%rbp) lea -0x98(%rbp),%rdx lea -0xa0(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 23f8 <_ZN9__gnu_cxxneIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_> test %al,%al je 1460 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x177> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 245c <_ZNK9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEdeEv> mov %rax,-0x80(%rbp) movl $0x0,-0xbc(%rbp) mov -0x80(%rbp),%rax mov %rax,-0x78(%rbp) mov -0x78(%rbp),%rax mov %rax,%rdi callq 2472 <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x90(%rbp) mov -0x78(%rbp),%rax mov %rax,%rdi callq 24ca <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x50(%rbp) lea -0x50(%rbp),%rdx lea -0x90(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2522 <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 1436 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x14d> lea -0x90(%rbp),%rax mov %rax,%rdi callq 2586 <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0xa4(%rbp) mov -0xbc(%rbp),%edx mov -0xa4(%rbp),%eax add %edx,%eax mov %eax,-0xbc(%rbp) lea -0x90(%rbp),%rax mov %rax,%rdi callq 2562 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmp 13e0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xf7> lea -0xbc(%rbp),%rdx lea -0x70(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 259c <_ZNSt6vectorIiSaIiEE9push_backERKi> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 2438 <_ZN9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEppEv> jmpq 1377 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x8e> movl $0x0,-0xb8(%rbp) mov -0xb8(%rbp),%eax cmp -0xa8(%rbp),%eax jge 14fe <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x215> movl $0x0,-0x50(%rbp) movl $0x0,-0xb4(%rbp) mov -0xb4(%rbp),%eax cmp -0xa8(%rbp),%eax jge 14df <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1f6> mov -0xb4(%rbp),%eax movslq %eax,%rdx mov -0xc8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 220c <_ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdx mov -0xb8(%rbp),%eax cltq mov %rax,%rsi mov %rdx,%rdi callq 261c <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%edx mov -0x50(%rbp),%eax add %edx,%eax mov %eax,-0x50(%rbp) addl $0x1,-0xb4(%rbp) jmp 148d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1a4> lea -0x50(%rbp),%rdx lea -0x70(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 259c <_ZNSt6vectorIiSaIiEE9push_backERKi> addl $0x1,-0xb8(%rbp) jmpq 146a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x181> movl $0x0,-0x98(%rbp) movl $0x0,-0xb0(%rbp) mov -0xb0(%rbp),%eax cmp -0xa8(%rbp),%eax jge 156a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x281> mov -0xb0(%rbp),%eax movslq %eax,%rdx mov -0xc8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 220c <_ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdx mov -0xb0(%rbp),%eax cltq mov %rax,%rsi mov %rdx,%rdi callq 261c <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%edx mov -0x98(%rbp),%eax add %edx,%eax mov %eax,-0x98(%rbp) addl $0x1,-0xb0(%rbp) jmp 1512 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x229> lea -0x98(%rbp),%rdx lea -0x70(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 259c <_ZNSt6vectorIiSaIiEE9push_backERKi> movl $0x0,-0x90(%rbp) mov -0xa8(%rbp),%eax sub $0x1,%eax mov %eax,-0xac(%rbp) cmpl $0x0,-0xac(%rbp) js 15ec <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x303> mov -0xac(%rbp),%eax movslq %eax,%rdx mov -0xc8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 220c <_ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm> mov %rax,%rdx mov -0xac(%rbp),%eax cltq mov %rax,%rsi mov %rdx,%rdi callq 261c <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%edx mov -0x90(%rbp),%eax add %edx,%eax mov %eax,-0x90(%rbp) subl $0x1,-0xac(%rbp) jmp 1599 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2b0> lea -0x90(%rbp),%rdx lea -0x70(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 259c <_ZNSt6vectorIiSaIiEE9push_backERKi> lea -0x70(%rbp),%rax mov %rax,%rdi callq 268c <_ZNSt6vectorIiSaIiEE3endEv> mov %rax,%rbx lea -0x70(%rbp),%rax mov %rax,%rdi callq 2640 <_ZNSt6vectorIiSaIiEE5beginEv> mov %rax,%rcx lea -0x50(%rbp),%rax mov %rbx,%rdx mov %rcx,%rsi mov %rax,%rdi callq 271c <_ZNSt3setIiSt4lessIiESaIiEEC1IN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiS2_EEEEET_SB_> lea -0x50(%rbp),%rax mov %rax,%rdi callq 27f0 <_ZNKSt3setIiSt4lessIiESaIiEE4sizeEv> cmp $0x1,%rax sete %bl lea -0x50(%rbp),%rax mov %rax,%rdi callq 21ec <_ZNSt3setIiSt4lessIiESaIiEED1Ev> lea -0x70(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSt6vectorIiSaIiEED1Ev> mov %ebx,%eax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 1693 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x3aa> jmp 168e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x3a5> endbr64 mov %rax,%rbx lea -0x70(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSt6vectorIiSaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 11f0 <_Unwind_Resume@plt> callq 11b0 <__stack_chk_fail@plt> add $0xc8,%rsp pop %rbx pop %rbp retq
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 0C8h mov [rbp+var_C8], rdi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+var_C8] mov esi, 0 mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) mov [rbp+var_A8], eax lea rax, [rbp+var_70] mov rdi, rax call _ZNSt6vectorIiSaIiEEC2Ev; std::vector<int>::vector(void) mov rax, [rbp+var_C8] mov [rbp+var_88], rax mov rax, [rbp+var_88] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE5beginEv; std::vector<std::vector<int>>::begin(void) mov [rbp+var_A0], rax mov rax, [rbp+var_88] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE3endEv; std::vector<std::vector<int>>::end(void) mov [rbp+var_98], rax jmp loc_145F loc_139C: lea rax, [rbp+var_A0] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEdeEv; __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator*(void) mov [rbp+var_80], rax mov [rbp+var_BC], 0 mov rax, [rbp+var_80] mov [rbp+var_78], rax mov rax, [rbp+var_78] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_90], rax mov rax, [rbp+var_78] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_50], rax jmp short loc_1420 loc_13E6: lea rax, [rbp+var_90] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov [rbp+var_A4], eax mov edx, [rbp+var_BC] mov eax, [rbp+var_A4] add eax, edx mov [rbp+var_BC], eax lea rax, [rbp+var_90] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_1420: lea rdx, [rbp+var_50] lea rax, [rbp+var_90] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz short loc_13E6 lea rdx, [rbp+var_BC] lea rax, [rbp+var_70] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) lea rax, [rbp+var_A0] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEppEv; __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator++(void) loc_145F: lea rdx, [rbp+var_98] lea rax, [rbp+var_A0] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_; __gnu_cxx::operator!=<std::vector<int> const*,std::vector<std::vector<int>>>(__gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>> const&,__gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>> const&) test al, al jnz loc_139C mov [rbp+var_B8], 0 jmp short loc_1509 loc_148C: mov dword ptr [rbp+var_50], 0 mov [rbp+var_B4], 0 jmp short loc_14E1 loc_149F: mov eax, [rbp+var_B4] movsxd rdx, eax mov rax, [rbp+var_C8] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdx, rax mov eax, [rbp+var_B8] cdqe mov rsi, rax mov rdi, rdx call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov edx, [rax] mov eax, dword ptr [rbp+var_50] add eax, edx mov dword ptr [rbp+var_50], eax add [rbp+var_B4], 1 loc_14E1: mov eax, [rbp+var_B4] cmp eax, [rbp+var_A8] jl short loc_149F lea rdx, [rbp+var_50] lea rax, [rbp+var_70] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) add [rbp+var_B8], 1 loc_1509: mov eax, [rbp+var_B8] cmp eax, [rbp+var_A8] jl loc_148C mov dword ptr [rbp+var_98], 0 mov [rbp+var_B0], 0 jmp short loc_1579 loc_1531: mov eax, [rbp+var_B0] movsxd rdx, eax mov rax, [rbp+var_C8] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdx, rax mov eax, [rbp+var_B0] cdqe mov rsi, rax mov rdi, rdx call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov edx, [rax] mov eax, dword ptr [rbp+var_98] add eax, edx mov dword ptr [rbp+var_98], eax add [rbp+var_B0], 1 loc_1579: mov eax, [rbp+var_B0] cmp eax, [rbp+var_A8] jl short loc_1531 lea rdx, [rbp+var_98] lea rax, [rbp+var_70] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) mov dword ptr [rbp+var_90], 0 mov eax, [rbp+var_A8] sub eax, 1 mov [rbp+var_AC], eax jmp short loc_1600 loc_15B8: mov eax, [rbp+var_AC] movsxd rdx, eax mov rax, [rbp+var_C8] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EEixEm; std::vector<std::vector<int>>::operator[](ulong) mov rdx, rax mov eax, [rbp+var_AC] cdqe mov rsi, rax mov rdi, rdx call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov edx, [rax] mov eax, dword ptr [rbp+var_90] add eax, edx mov dword ptr [rbp+var_90], eax sub [rbp+var_AC], 1 loc_1600: cmp [rbp+var_AC], 0 jns short loc_15B8 lea rdx, [rbp+var_90] lea rax, [rbp+var_70] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) lea rax, [rbp+var_70] mov rdi, rax call _ZNSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov rbx, rax lea rax, [rbp+var_70] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rcx, rax lea rax, [rbp+var_50] mov rdx, rbx mov rsi, rcx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEEC2IN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiS2_EEEEET_SB_; std::set<int>::set<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) lea rax, [rbp+var_50] mov rdi, rax call _ZNKSt3setIiSt4lessIiESaIiEE4sizeEv; std::set<int>::size(void) cmp rax, 1 setz bl lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEED2Ev; std::set<int>::~set() lea rax, [rbp+var_70] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov eax, ebx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_16C4 jmp short loc_16BF endbr64 mov rbx, rax lea rax, [rbp+var_70] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_16B7 call ___stack_chk_fail loc_16B7: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_16BF: call ___stack_chk_fail loc_16C4: mov rbx, [rbp+var_8] leave retn
long long func0(long long a1) { long long v1; // rax long long v2; // rax _DWORD *v3; // rax long long v4; // rax _DWORD *v5; // rax long long v6; // rax _DWORD *v7; // rax long long v8; // rbx long long v9; // rax int v11; // [rsp+14h] [rbp-BCh] BYREF int i; // [rsp+18h] [rbp-B8h] int j; // [rsp+1Ch] [rbp-B4h] int k; // [rsp+20h] [rbp-B0h] int m; // [rsp+24h] [rbp-ACh] int v16; // [rsp+28h] [rbp-A8h] int v17; // [rsp+2Ch] [rbp-A4h] long long v18; // [rsp+30h] [rbp-A0h] BYREF long long v19; // [rsp+38h] [rbp-98h] BYREF _QWORD v20[2]; // [rsp+40h] [rbp-90h] BYREF long long v21; // [rsp+50h] [rbp-80h] long long v22; // [rsp+58h] [rbp-78h] _BYTE v23[32]; // [rsp+60h] [rbp-70h] BYREF _QWORD v24[9]; // [rsp+80h] [rbp-50h] BYREF v24[7] = __readfsqword(0x28u); v1 = std::vector<std::vector<int>>::operator[](a1, 0LL); v16 = std::vector<int>::size(v1); std::vector<int>::vector(v23); v20[1] = a1; v18 = std::vector<std::vector<int>>::begin(a1); v19 = std::vector<std::vector<int>>::end(a1); while ( (unsigned __int8)__gnu_cxx::operator!=<std::vector<int> const*,std::vector<std::vector<int>>>(&v18, &v19) ) { v21 = __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator*(&v18); v11 = 0; v22 = v21; v20[0] = std::vector<int>::begin(v21); v24[0] = std::vector<int>::end(v22); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(v20, v24) ) { v17 = *(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(v20); v11 += v17; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(v20); } std::vector<int>::push_back(v23, &v11); __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator++(&v18); } for ( i = 0; i < v16; ++i ) { LODWORD(v24[0]) = 0; for ( j = 0; j < v16; ++j ) { v2 = std::vector<std::vector<int>>::operator[](a1, j); v3 = (_DWORD *)std::vector<int>::operator[](v2, i); LODWORD(v24[0]) += *v3; } std::vector<int>::push_back(v23, v24); } LODWORD(v19) = 0; for ( k = 0; k < v16; ++k ) { v4 = std::vector<std::vector<int>>::operator[](a1, k); v5 = (_DWORD *)std::vector<int>::operator[](v4, k); LODWORD(v19) = *v5 + v19; } std::vector<int>::push_back(v23, &v19); LODWORD(v20[0]) = 0; for ( m = v16 - 1; m >= 0; --m ) { v6 = std::vector<std::vector<int>>::operator[](a1, m); v7 = (_DWORD *)std::vector<int>::operator[](v6, m); LODWORD(v20[0]) += *v7; } std::vector<int>::push_back(v23, v20); v8 = std::vector<int>::end(v23); v9 = std::vector<int>::begin(v23); std::set<int>::set<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(v24, v9, v8); LOBYTE(v8) = std::set<int>::size(v24) == 1; std::set<int>::~set(v24); std::vector<int>::~vector(v23); return (unsigned int)v8; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0xc8 MOV qword ptr [RBP + -0xc8],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0xc8] MOV ESI,0x0 MOV RDI,RAX CALL 0x0010221a MOV RDI,RAX CALL 0x00102248 MOV dword ptr [RBP + -0xa8],EAX LEA RAX,[RBP + -0x70] MOV RDI,RAX CALL 0x001021da MOV RAX,qword ptr [RBP + -0xc8] MOV qword ptr [RBP + -0x88],RAX MOV RAX,qword ptr [RBP + -0x88] MOV RDI,RAX CALL 0x0010234e MOV qword ptr [RBP + -0xa0],RAX MOV RAX,qword ptr [RBP + -0x88] MOV RDI,RAX CALL 0x0010239a MOV qword ptr [RBP + -0x98],RAX JMP 0x0010145f LAB_0010139c: LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x0010244e MOV qword ptr [RBP + -0x80],RAX MOV dword ptr [RBP + -0xbc],0x0 MOV RAX,qword ptr [RBP + -0x80] MOV qword ptr [RBP + -0x78],RAX MOV RAX,qword ptr [RBP + -0x78] MOV RDI,RAX CALL 0x00102464 MOV qword ptr [RBP + -0x90],RAX MOV RAX,qword ptr [RBP + -0x78] MOV RDI,RAX CALL 0x001024b0 MOV qword ptr [RBP + -0x50],RAX JMP 0x00101420 LAB_001013e6: LEA RAX,[RBP + -0x90] MOV RDI,RAX CALL 0x00102564 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0xa4],EAX MOV EDX,dword ptr [RBP + -0xbc] MOV EAX,dword ptr [RBP + -0xa4] ADD EAX,EDX MOV dword ptr [RBP + -0xbc],EAX LEA RAX,[RBP + -0x90] MOV RDI,RAX CALL 0x00102540 LAB_00101420: LEA RDX,[RBP + -0x50] LEA RAX,[RBP + -0x90] MOV RSI,RDX MOV RDI,RAX CALL 0x00102500 TEST AL,AL JNZ 0x001013e6 LEA RDX,[RBP + -0xbc] LEA RAX,[RBP + -0x70] MOV RSI,RDX MOV RDI,RAX LAB_0010144b: CALL 0x0010257a LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x0010242a LAB_0010145f: LEA RDX,[RBP + -0x98] LEA RAX,[RBP + -0xa0] MOV RSI,RDX MOV RDI,RAX CALL 0x001023ea TEST AL,AL JNZ 0x0010139c MOV dword ptr [RBP + -0xb8],0x0 JMP 0x00101509 LAB_0010148c: MOV dword ptr [RBP + -0x50],0x0 MOV dword ptr [RBP + -0xb4],0x0 JMP 0x001014e1 LAB_0010149f: MOV EAX,dword ptr [RBP + -0xb4] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0xc8] MOV RSI,RDX MOV RDI,RAX CALL 0x0010221a MOV RDX,RAX MOV EAX,dword ptr [RBP + -0xb8] CDQE MOV RSI,RAX MOV RDI,RDX CALL 0x00102646 MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x50] ADD EAX,EDX MOV dword ptr [RBP + -0x50],EAX ADD dword ptr [RBP + -0xb4],0x1 LAB_001014e1: MOV EAX,dword ptr [RBP + -0xb4] CMP EAX,dword ptr [RBP + -0xa8] JL 0x0010149f LEA RDX,[RBP + -0x50] LEA RAX,[RBP + -0x70] MOV RSI,RDX MOV RDI,RAX CALL 0x0010257a ADD dword ptr [RBP + -0xb8],0x1 LAB_00101509: MOV EAX,dword ptr [RBP + -0xb8] CMP EAX,dword ptr [RBP + -0xa8] JL 0x0010148c MOV dword ptr [RBP + -0x98],0x0 MOV dword ptr [RBP + -0xb0],0x0 JMP 0x00101579 LAB_00101531: MOV EAX,dword ptr [RBP + -0xb0] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0xc8] MOV RSI,RDX MOV RDI,RAX CALL 0x0010221a MOV RDX,RAX MOV EAX,dword ptr [RBP + -0xb0] CDQE MOV RSI,RAX MOV RDI,RDX CALL 0x00102646 MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x98] ADD EAX,EDX MOV dword ptr [RBP + -0x98],EAX ADD dword ptr [RBP + -0xb0],0x1 LAB_00101579: MOV EAX,dword ptr [RBP + -0xb0] CMP EAX,dword ptr [RBP + -0xa8] JL 0x00101531 LEA RDX,[RBP + -0x98] LEA RAX,[RBP + -0x70] MOV RSI,RDX MOV RDI,RAX CALL 0x0010257a MOV dword ptr [RBP + -0x90],0x0 MOV EAX,dword ptr [RBP + -0xa8] SUB EAX,0x1 MOV dword ptr [RBP + -0xac],EAX JMP 0x00101600 LAB_001015b8: MOV EAX,dword ptr [RBP + -0xac] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0xc8] MOV RSI,RDX MOV RDI,RAX CALL 0x0010221a MOV RDX,RAX MOV EAX,dword ptr [RBP + -0xac] CDQE MOV RSI,RAX MOV RDI,RDX CALL 0x00102646 MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x90] ADD EAX,EDX MOV dword ptr [RBP + -0x90],EAX SUB dword ptr [RBP + -0xac],0x1 LAB_00101600: CMP dword ptr [RBP + -0xac],0x0 JNS 0x001015b8 LEA RDX,[RBP + -0x90] LEA RAX,[RBP + -0x70] MOV RSI,RDX MOV RDI,RAX CALL 0x0010257a LEA RAX,[RBP + -0x70] MOV RDI,RAX CALL 0x001026b6 MOV RBX,RAX LEA RAX,[RBP + -0x70] MOV RDI,RAX CALL 0x0010266a MOV RCX,RAX LEA RAX,[RBP + -0x50] MOV RDX,RBX MOV RSI,RCX MOV RDI,RAX CALL 0x0010274e LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00102802 CMP RAX,0x1 SETZ BL LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x001021fa LEA RAX,[RBP + -0x70] MOV RDI,RAX CALL 0x001022f4 MOV EAX,EBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x001016c4 JMP 0x001016bf LAB_001016bf: CALL 0x001011d0 LAB_001016c4: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ ulong func0(vector *param_1) { bool bVar1; int extraout_EAX; vector<int,std::allocator<int>> *pvVar2; int4 extraout_var; int *piVar3; int8 uVar4; int8 uVar5; long lVar6; long in_FS_OFFSET; int local_c4; int local_c0; int local_bc; int local_b8; int local_b4; int local_b0; int local_ac; int8 local_a8; int local_a0; int4 uStack_9c; ulong local_98; vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *local_90; vector<int,std::allocator<int>> *local_88; vector<int,std::allocator<int>> *local_80; vector<int,std::allocator<int>> local_78 [32]; ulong local_58 [7]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); pvVar2 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[]((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1,0); local_b0 = std::vector<int,std::allocator<int>>::size(pvVar2); std::vector<int,std::allocator<int>>::vector(local_78); local_90 = (vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1; local_a8 = std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::begin((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1); std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::end(local_90); local_a0 = extraout_EAX; uStack_9c = extraout_var; while( true ) { bVar1 = operator!=((__normal_iterator *)&local_a8,(__normal_iterator *)&local_a0); if (!bVar1) break; local_88 = (vector<int,std::allocator<int>> *) __normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> ::operator*((__normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> *)&local_a8); local_c4 = 0; local_80 = local_88; local_98 = std::vector<int,std::allocator<int>>::begin(local_88); local_58[0] = std::vector<int,std::allocator<int>>::end(local_80); while( true ) { bVar1 = operator!=((__normal_iterator *)&local_98,(__normal_iterator *)local_58); if (!bVar1) break; piVar3 = (int *)__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_98); local_ac = *piVar3; local_c4 = local_ac + local_c4; __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_98); } /* try { // try from 0010144b to 0010164e has its CatchHandler @ 0010168d */ std::vector<int,std::allocator<int>>::push_back(local_78,&local_c4); __normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> ::operator++((__normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> *)&local_a8); } for (local_c0 = 0; local_c0 < local_b0; local_c0 = local_c0 + 1) { local_58[0] = local_58[0] & 0xffffffff00000000; for (local_bc = 0; local_bc < local_b0; local_bc = local_bc + 1) { pvVar2 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[]((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1,(long)local_bc); piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[](pvVar2,(long)local_c0); local_58[0] = CONCAT44(local_58[0]._4_4_,(int)local_58[0] + *piVar3); } std::vector<int,std::allocator<int>>::push_back(local_78,(int *)local_58); } local_a0 = 0; for (local_b8 = 0; local_b8 < local_b0; local_b8 = local_b8 + 1) { pvVar2 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[]((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1,(long)local_b8); piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[](pvVar2,(long)local_b8); local_a0 = local_a0 + *piVar3; } std::vector<int,std::allocator<int>>::push_back(local_78,&local_a0); local_98 = local_98 & 0xffffffff00000000; local_b4 = local_b0; while (local_b4 = local_b4 + -1, -1 < local_b4) { pvVar2 = (vector<int,std::allocator<int>> *) std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::operator[]((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)param_1,(long)local_b4); piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[](pvVar2,(long)local_b4); local_98 = CONCAT44(local_98._4_4_,(int)local_98 + *piVar3); } std::vector<int,std::allocator<int>>::push_back(local_78,(int *)&local_98); uVar4 = std::vector<int,std::allocator<int>>::end(local_78); uVar5 = std::vector<int,std::allocator<int>>::begin(local_78); std::set<int,std::less<int>,std::allocator<int>>:: set<__normal_iterator<int*,std::vector<int,std::allocator<int>>>> ((set<int,std::less<int>,std::allocator<int>> *)local_58,uVar5,uVar4); lVar6 = std::set<int,std::less<int>,std::allocator<int>>::size ((set<int,std::less<int>,std::allocator<int>> *)local_58); std::set<int,std::less<int>,std::allocator<int>>::~set ((set<int,std::less<int>,std::allocator<int>> *)local_58); std::vector<int,std::allocator<int>>::~vector(local_78); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return CONCAT71((int7)((ulong)uVar4 >> 8),lVar6 == 1) & 0xffffffff; }
513
func0
#include <vector> #include <set> #include <cassert>
bool func0(const std::vector<std::vector<int>>& my_matrix) { int iSize = my_matrix[0].size(); std::vector<int> sum_list; for (const auto& lines : my_matrix) { int line_sum = 0; for (int num : lines) { line_sum += num; } sum_list.push_back(line_sum); } for (int col = 0; col < iSize; ++col) { int col_sum = 0; for (int row = 0; row < iSize; ++row) { col_sum += my_matrix[row][col]; } sum_list.push_back(col_sum); } int result1 = 0; for (int i = 0; i < iSize; ++i) { result1 += my_matrix[i][i]; } sum_list.push_back(result1); int result2 = 0; for (int i = iSize - 1; i >= 0; --i) { result2 += my_matrix[i][i]; } sum_list.push_back(result2); std::set<int> unique_sums(sum_list.begin(), sum_list.end()); return unique_sums.size() == 1; }
int main() { assert(func0({{7, 12, 1, 14}, {2, 13, 8, 11}, {16, 3, 10, 5}, {9, 6, 15, 4}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 8}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 7}}) == false); return 0; }
O1
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x78,%rsp mov %rdi,%rbp mov %fs:0x28,%rax mov %rax,0x68(%rsp) xor %eax,%eax mov (%rdi),%rax mov 0x8(%rax),%r12 sub (%rax),%r12 sar $0x2,%r12 movq $0x0,0x10(%rsp) movq $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) mov 0x8(%rdi),%r13 mov %rax,%rbx lea 0x30(%rsp),%r14 cmp %rax,%r13 jne 13a8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x9f> test %r12d,%r12d jle 164e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x345> lea -0x1(%r12),%eax lea 0x4(,%rax,4),%r13 lea (%rax,%rax,2),%r14 shl $0x3,%r14 mov $0x0,%ebx lea 0x30(%rsp),%r15 jmp 13ff <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xf6> lea 0x10(%rsp),%rdi mov %r14,%rdx callq 1db4 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> add $0x18,%rbx cmp %rbx,%r13 je 1368 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x5f> movl $0x0,0x30(%rsp) mov (%rbx),%rax mov 0x8(%rbx),%rcx cmp %rax,%rcx je 13cb <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xc2> mov (%rax),%edx add %edx,0x30(%rsp) add $0x4,%rax cmp %rax,%rcx jne 13bc <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xb3> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 1392 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x89> mov 0x30(%rsp),%eax mov %eax,(%rsi) addq $0x4,0x18(%rsp) jmp 139f <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x96> lea 0x10(%rsp),%rdi mov %r15,%rdx callq 1db4 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> add $0x4,%rbx cmp %r13,%rbx je 155b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x252> movl $0x0,0x30(%rsp) mov 0x0(%rbp),%rax lea 0x18(%rax,%r14,1),%rsi mov (%rax),%rcx mov 0x30(%rsp),%edx add (%rcx,%rbx,1),%edx mov %edx,0x30(%rsp) add $0x18,%rax cmp %rsi,%rax jne 1410 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x107> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 13e5 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xdc> mov %edx,(%rsi) addq $0x4,0x18(%rsp) jmp 13f2 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xe9> lea 0x8(%rsp),%rdx lea 0x10(%rsp),%rdi callq 1db4 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> jmpq 159f <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x296> lea 0xc(%rsp),%rdx lea 0x10(%rsp),%rdi callq 1db4 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> jmpq 1608 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2ff> mov 0x20(%rdx),%eax cmp %eax,(%rbx) setl %r12b jmp 14cd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1c4> mov %rax,%rsi mov 0x0(%r13),%eax mov %eax,0x20(%rsi) lea 0x38(%rsp),%rcx movzbl %r12b,%edi mov %rbp,%rdx callq 1130 <_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@plt> addq $0x1,0x58(%rsp) add $0x4,%rbx cmp %rbx,%r14 je 14d9 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1d0> mov %rbx,%r13 lea 0x38(%rsp),%rsi mov %rbx,%rdx mov %r15,%rdi callq 1fa8 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIiERKi> mov %rdx,%rbp test %rdx,%rdx je 1491 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x188> test %rax,%rax setne %r12b lea 0x38(%rsp),%rax cmp %rax,%rdx sete %dil or %dil,%r12b je 1465 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x15c> mov $0x28,%edi callq 11b0 <_Znwm@plt> jmp 1470 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x167> cmpq $0x1,0x58(%rsp) sete %bl lea 0x30(%rsp),%rdi mov 0x40(%rsp),%rsi callq 1ee4 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x10(%rsp),%rdi test %rdi,%rdi je 1500 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1f7> callq 11a0 <_ZdlPv@plt> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 165b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x352> mov %ebx,%eax add $0x78,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq endbr64 mov %rax,%rbx lea 0x30(%rsp),%rdi mov 0x40(%rsp),%rsi callq 1ee4 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x10(%rsp),%rdi test %rdi,%rdi je 154a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x241> callq 11a0 <_ZdlPv@plt> mov %rbx,%rdi callq 1210 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx jmp 153b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x232> movl $0x0,0x8(%rsp) mov 0x0(%rbp),%rdx mov $0x0,%eax mov (%rdx),%rcx mov (%rcx,%rax,1),%ecx add %ecx,0x8(%rsp) add $0x18,%rdx add $0x4,%rax cmp %r13,%rax jne 156c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x263> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 143d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x134> mov 0x8(%rsp),%eax mov %eax,(%rsi) addq $0x4,0x18(%rsp) movl $0x0,0xc(%rsp) mov %r12d,%eax sub $0x1,%eax js 15ec <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2e3> movslq %r12d,%rcx lea (%rcx,%rcx,2),%rsi mov 0x0(%rbp),%rdx lea -0x18(%rdx,%rsi,8),%rdx cltq shl $0x2,%rax lea -0x1(%r12),%esi sub %rsi,%rcx lea -0x8(,%rcx,4),%rsi mov (%rdx),%rcx mov (%rcx,%rax,1),%ecx add %ecx,0xc(%rsp) sub $0x18,%rdx sub $0x4,%rax cmp %rsi,%rax jne 15d5 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2cc> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 1451 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x148> mov 0xc(%rsp),%eax mov %eax,(%rsi) addq $0x4,0x18(%rsp) mov 0x18(%rsp),%r14 mov 0x10(%rsp),%rbx movl $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) lea 0x38(%rsp),%rax mov %rax,0x48(%rsp) mov %rax,0x50(%rsp) movq $0x0,0x58(%rsp) cmp %r14,%rbx je 14d9 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1d0> lea 0x30(%rsp),%r15 jmpq 149a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x191> movl $0x0,0x8(%rsp) jmpq 1583 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x27a> callq 11d0 <__stack_chk_fail@plt>
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 88h mov rbp, rdi mov rax, fs:28h mov [rsp+0B8h+var_40], rax xor eax, eax mov rbx, [rdi] mov r12, [rbx+8] sub r12, [rbx] sar r12, 2 mov [rsp+0B8h+var_98], 0 mov [rsp+0B8h+var_90], 0 mov [rsp+0B8h+var_88], 0 mov r13, [rdi+8] cmp rbx, r13 jz short loc_13C5 lea r14, [rsp+0B8h+var_78] jmp short loc_1380 loc_136A: lea rdi, [rsp+0B8h+var_98] mov rdx, r14 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) loc_1377: add rbx, 18h cmp r13, rbx jz short loc_13C5 loc_1380: mov [rsp+0B8h+var_78], 0 mov rax, [rbx] mov rsi, [rbx+8] cmp rax, rsi jz short loc_13A8 mov ecx, 0 loc_1399: add ecx, [rax] add rax, 4 cmp rax, rsi jnz short loc_1399 mov [rsp+0B8h+var_78], ecx loc_13A8: mov rsi, [rsp+0B8h+var_90] cmp rsi, [rsp+0B8h+var_88] jz short loc_136A mov eax, [rsp+0B8h+var_78] mov [rsi], eax add rsi, 4 mov [rsp+0B8h+var_90], rsi jmp short loc_1377 loc_13C5: test r12d, r12d jle loc_153B lea eax, [r12-1] lea r13, ds:4[rax*4] lea r14, [rax+rax*2] shl r14, 3 mov ebx, 0 mov r15d, 0 jmp short loc_1408 loc_13F0: lea rdx, [rsp+0B8h+var_78] lea rdi, [rsp+0B8h+var_98] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) loc_13FF: add rbx, 4 cmp rbx, r13 jz short loc_1440 loc_1408: mov rax, [rbp+0] lea rsi, [rax+r14+18h] mov ecx, r15d loc_1414: mov rdx, [rax] add ecx, [rdx+rbx] add rax, 18h cmp rax, rsi jnz short loc_1414 mov [rsp+0B8h+var_78], ecx mov rsi, [rsp+0B8h+var_90] cmp rsi, [rsp+0B8h+var_88] jz short loc_13F0 mov [rsi], ecx add rsi, 4 mov [rsp+0B8h+var_90], rsi jmp short loc_13FF loc_1440: mov rdx, [rbp+0] mov eax, 0 mov ecx, 0 loc_144E: mov rsi, [rdx] add ecx, [rsi+rax] add rdx, 18h add rax, 4 cmp rax, r13 jnz short loc_144E loc_1461: mov [rsp+0B8h+var_A0], ecx mov rsi, [rsp+0B8h+var_90] cmp rsi, [rsp+0B8h+var_88] jz loc_1545 mov [rsi], ecx add rsi, 4 mov [rsp+0B8h+var_90], rsi loc_1480: mov [rsp+0B8h+var_9C], 0 mov eax, r12d sub eax, 1 js short loc_14D2 movsxd rcx, r12d lea rsi, [rcx+rcx*2] mov rdx, [rbp+0] lea rdx, [rdx+rsi*8-18h] cdqe shl rax, 2 lea esi, [r12-1] sub rcx, rsi lea rdi, ds:0FFFFFFFFFFFFFFF8h[rcx*4] mov esi, 0 loc_14BB: mov rcx, [rdx] add esi, [rcx+rax] sub rdx, 18h sub rax, 4 cmp rdi, rax jnz short loc_14BB mov [rsp+0B8h+var_9C], esi loc_14D2: mov rsi, [rsp+0B8h+var_90] cmp rsi, [rsp+0B8h+var_88] jz short loc_1559 mov eax, [rsp+0B8h+var_9C] mov [rsi], eax add rsi, 4 mov [rsp+0B8h+var_90], rsi loc_14ED: mov r14, [rsp+0B8h+var_90] mov rax, [rsp+0B8h+var_98] mov rdi, rax mov [rsp+0B8h+var_B0], rax mov [rsp+0B8h+var_70], 0 mov [rsp+0B8h+var_68], 0 lea rax, [rsp+0B8h+var_70] mov [rsp+0B8h+var_60], rax mov [rsp+0B8h+var_58], rax mov [rsp+0B8h+var_50], 0 cmp rdi, r14 jz loc_15DE mov rbp, rdi lea r15, [rsp+0B8h+var_78] jmp short loc_15A0 loc_153B: mov ecx, 0 jmp loc_1461 loc_1545: lea rdx, [rsp+0B8h+var_A0] lea rdi, [rsp+0B8h+var_98] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) jmp loc_1480 loc_1559: lea rdx, [rsp+0B8h+var_9C] lea rdi, [rsp+0B8h+var_98] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) jmp short loc_14ED loc_156A: mov eax, [rdx+20h] cmp [rbp+0], eax setl r12b jmp short loc_15D2 loc_1576: mov rsi, rax mov eax, [r13+0] mov [rsi+20h], eax lea rcx, [rsp+0B8h+var_70] movzx edi, r12b mov rdx, rbx call __ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; std::_Rb_tree_insert_and_rebalance(bool,std::_Rb_tree_node_base *,std::_Rb_tree_node_base *,std::_Rb_tree_node_base&) add [rsp+0B8h+var_50], 1 loc_1597: add rbp, 4 cmp r14, rbp jz short loc_15DE loc_15A0: mov r13, rbp lea rsi, [rsp+0B8h+var_70] mov rdx, rbp mov rdi, r15 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIiERKi; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<int>,int const&) mov rbx, rdx test rdx, rdx jz short loc_1597 test rax, rax setnz r12b lea rax, [rsp+0B8h+var_70] cmp rdx, rax setz al or r12b, al jz short loc_156A loc_15D2: mov edi, 28h ; '('; unsigned __int64 call __Znwm; operator new(ulong) jmp short loc_1576 loc_15DE: cmp [rsp+0B8h+var_50], 1 setz bl lea rdi, [rsp+0B8h+var_78] mov rsi, [rsp+0B8h+var_68] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) cmp [rsp+0B8h+var_B0], 0 jz short loc_1610 mov rsi, [rsp+0B8h+var_88] mov rdi, [rsp+0B8h+var_B0]; void * sub rsi, rdi; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1610: mov rax, [rsp+0B8h+var_40] sub rax, fs:28h jnz short loc_167A mov eax, ebx add rsp, 88h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbx, rax lea rdi, [rsp+arg_38] mov rsi, [rsp+arg_48] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) loc_164A: lea rdi, [rsp+arg_18] call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, [rsp+arg_70] sub rax, fs:28h jz short loc_1672 call ___stack_chk_fail endbr64 mov rbx, rax jmp short loc_164A loc_1672: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_167A: call ___stack_chk_fail
long long func0(int **a1, long long a2, int *a3) { int *v3; // rbx long long v4; // r12 int *i; // r13 _DWORD *v6; // rax _DWORD *v7; // rsi int v8; // ecx char *v9; // rsi long long v10; // rax long long v11; // r13 long long v12; // r14 int *v13; // rax int v14; // ecx char *v15; // rsi long long v16; // rax int v17; // ecx char *v18; // rsi long long v19; // rax int v20; // esi char *v21; // rsi char *v22; // r14 char *v23; // rbp long long insert_hint_unique_pos; // rax bool v25; // r12 long long v26; // rax char *v28; // [rsp+8h] [rbp-B0h] int v29; // [rsp+18h] [rbp-A0h] BYREF int v30; // [rsp+1Ch] [rbp-9Ch] BYREF char *v31; // [rsp+20h] [rbp-98h] BYREF char *v32; // [rsp+28h] [rbp-90h] char *v33; // [rsp+30h] [rbp-88h] int v34; // [rsp+40h] [rbp-78h] BYREF int v35; // [rsp+48h] [rbp-70h] BYREF long long v36; // [rsp+50h] [rbp-68h] int *v37; // [rsp+58h] [rbp-60h] int *v38; // [rsp+60h] [rbp-58h] long long v39; // [rsp+68h] [rbp-50h] unsigned long long v40; // [rsp+78h] [rbp-40h] v40 = __readfsqword(0x28u); v3 = *a1; v4 = (long long)(*((_QWORD *)*a1 + 1) - *(_QWORD *)*a1) >> 2; v31 = 0LL; v32 = 0LL; v33 = 0LL; for ( i = a1[1]; i != v3; v3 += 6 ) { v34 = 0; v6 = *(_DWORD **)v3; v7 = (_DWORD *)*((_QWORD *)v3 + 1); if ( *(_DWORD **)v3 != v7 ) { v8 = 0; do v8 += *v6++; while ( v6 != v7 ); v34 = v8; } v9 = v32; if ( v32 == v33 ) { std::vector<int>::_M_realloc_insert<int const&>(&v31, v32, &v34); } else { *(_DWORD *)v32 = v34; v32 = v9 + 4; } } if ( (int)v4 <= 0 ) { v17 = 0; } else { v10 = (unsigned int)(v4 - 1); v11 = 4 * v10 + 4; v12 = 6 * v10; v3 = 0LL; do { v13 = *a1; v14 = 0; do { v14 += *(int *)((char *)v3 + *(_QWORD *)v13); v13 += 6; } while ( v13 != &(*a1)[v12 + 6] ); v34 = v14; v15 = v32; if ( v32 == v33 ) { std::vector<int>::_M_realloc_insert<int const&>(&v31, v32, &v34); } else { *(_DWORD *)v32 = v14; v32 = v15 + 4; } ++v3; } while ( v3 != (int *)v11 ); a3 = *a1; v16 = 0LL; v17 = 0; do { v17 += *(_DWORD *)(*(_QWORD *)a3 + v16); a3 += 6; v16 += 4LL; } while ( v16 != v11 ); } v29 = v17; v18 = v32; if ( v32 == v33 ) { std::vector<int>::_M_realloc_insert<int const&>(&v31, v32, &v29); } else { *(_DWORD *)v32 = v17; v32 = v18 + 4; } v30 = 0; if ( (int)v4 - 1 >= 0 ) { a3 = &(*a1)[6 * (int)v4 - 6]; v19 = 4LL * ((int)v4 - 1); v20 = 0; do { v20 += *(_DWORD *)(*(_QWORD *)a3 + v19); a3 -= 6; v19 -= 4LL; } while ( 4 * ((int)v4 - (unsigned long long)(unsigned int)(v4 - 1)) - 8 != v19 ); v30 = v20; } v21 = v32; if ( v32 == v33 ) { std::vector<int>::_M_realloc_insert<int const&>(&v31, v32, &v30); } else { *(_DWORD *)v32 = v30; v32 = v21 + 4; } v22 = v32; v28 = v31; v35 = 0; v36 = 0LL; v37 = &v35; v38 = &v35; v39 = 0LL; if ( v31 != v32 ) { v23 = v31; do { insert_hint_unique_pos = std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_get_insert_hint_unique_pos( &v34, &v35, v23); v3 = a3; if ( a3 ) { v25 = a3 == &v35 || insert_hint_unique_pos != 0; if ( !v25 ) v25 = *(_DWORD *)v23 < a3[8]; v26 = operator new(0x28uLL); *(_DWORD *)(v26 + 32) = *(_DWORD *)v23; std::_Rb_tree_insert_and_rebalance(v25, v26, v3, &v35); ++v39; } v23 += 4; } while ( v22 != v23 ); } LOBYTE(v3) = v39 == 1; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(&v34, v36, a3); if ( v28 ) operator delete(v28, v33 - v28); return (unsigned int)v3; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x88 MOV RBP,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x78],RAX XOR EAX,EAX MOV RBX,qword ptr [RDI] MOV R12,qword ptr [RBX + 0x8] SUB R12,qword ptr [RBX] SAR R12,0x2 MOV qword ptr [RSP + 0x20],0x0 MOV qword ptr [RSP + 0x28],0x0 MOV qword ptr [RSP + 0x30],0x0 MOV R13,qword ptr [RDI + 0x8] CMP RBX,R13 JZ 0x001013c5 LEA R14,[RSP + 0x40] JMP 0x00101380 LAB_0010136a: LEA RDI,[RSP + 0x20] MOV RDX,R14 LAB_00101372: CALL 0x00101e12 LAB_00101377: ADD RBX,0x18 CMP R13,RBX JZ 0x001013c5 LAB_00101380: MOV dword ptr [RSP + 0x40],0x0 MOV RAX,qword ptr [RBX] MOV RSI,qword ptr [RBX + 0x8] CMP RAX,RSI JZ 0x001013a8 MOV ECX,0x0 LAB_00101399: ADD ECX,dword ptr [RAX] ADD RAX,0x4 CMP RAX,RSI JNZ 0x00101399 MOV dword ptr [RSP + 0x40],ECX LAB_001013a8: MOV RSI,qword ptr [RSP + 0x28] CMP RSI,qword ptr [RSP + 0x30] JZ 0x0010136a MOV EAX,dword ptr [RSP + 0x40] MOV dword ptr [RSI],EAX ADD RSI,0x4 MOV qword ptr [RSP + 0x28],RSI JMP 0x00101377 LAB_001013c5: TEST R12D,R12D JLE 0x0010153b LEA EAX,[R12 + -0x1] LEA R13,[0x4 + RAX*0x4] LEA R14,[RAX + RAX*0x2] SHL R14,0x3 MOV EBX,0x0 MOV R15D,0x0 JMP 0x00101408 LAB_001013f0: LEA RDX,[RSP + 0x40] LEA RDI,[RSP + 0x20] CALL 0x00101e12 LAB_001013ff: ADD RBX,0x4 CMP RBX,R13 JZ 0x00101440 LAB_00101408: MOV RAX,qword ptr [RBP] LEA RSI,[RAX + R14*0x1 + 0x18] MOV ECX,R15D LAB_00101414: MOV RDX,qword ptr [RAX] ADD ECX,dword ptr [RDX + RBX*0x1] ADD RAX,0x18 CMP RAX,RSI JNZ 0x00101414 MOV dword ptr [RSP + 0x40],ECX MOV RSI,qword ptr [RSP + 0x28] CMP RSI,qword ptr [RSP + 0x30] JZ 0x001013f0 MOV dword ptr [RSI],ECX ADD RSI,0x4 MOV qword ptr [RSP + 0x28],RSI JMP 0x001013ff LAB_00101440: MOV RDX,qword ptr [RBP] MOV EAX,0x0 MOV ECX,0x0 LAB_0010144e: MOV RSI,qword ptr [RDX] ADD ECX,dword ptr [RSI + RAX*0x1] ADD RDX,0x18 ADD RAX,0x4 CMP RAX,R13 JNZ 0x0010144e LAB_00101461: MOV dword ptr [RSP + 0x18],ECX MOV RSI,qword ptr [RSP + 0x28] CMP RSI,qword ptr [RSP + 0x30] JZ 0x00101545 MOV dword ptr [RSI],ECX ADD RSI,0x4 MOV qword ptr [RSP + 0x28],RSI LAB_00101480: MOV dword ptr [RSP + 0x1c],0x0 MOV EAX,R12D SUB EAX,0x1 JS 0x001014d2 MOVSXD RCX,R12D LEA RSI,[RCX + RCX*0x2] MOV RDX,qword ptr [RBP] LEA RDX,[RDX + RSI*0x8 + -0x18] CDQE SHL RAX,0x2 LEA ESI,[R12 + -0x1] SUB RCX,RSI LEA RDI,[-0x8 + RCX*0x4] MOV ESI,0x0 LAB_001014bb: MOV RCX,qword ptr [RDX] ADD ESI,dword ptr [RCX + RAX*0x1] SUB RDX,0x18 SUB RAX,0x4 CMP RDI,RAX JNZ 0x001014bb MOV dword ptr [RSP + 0x1c],ESI LAB_001014d2: MOV RSI,qword ptr [RSP + 0x28] CMP RSI,qword ptr [RSP + 0x30] JZ 0x00101559 MOV EAX,dword ptr [RSP + 0x1c] MOV dword ptr [RSI],EAX ADD RSI,0x4 MOV qword ptr [RSP + 0x28],RSI LAB_001014ed: MOV R14,qword ptr [RSP + 0x28] MOV RAX,qword ptr [RSP + 0x20] MOV RDI,RAX MOV qword ptr [RSP + 0x8],RAX MOV dword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 LEA RAX,[RSP + 0x48] MOV qword ptr [RSP + 0x58],RAX MOV qword ptr [RSP + 0x60],RAX MOV qword ptr [RSP + 0x68],0x0 CMP RDI,R14 JZ 0x001015de MOV RBP,RDI LEA R15,[RSP + 0x40] JMP 0x001015a0 LAB_0010153b: MOV ECX,0x0 JMP 0x00101461 LAB_00101545: LEA RDX,[RSP + 0x18] LEA RDI,[RSP + 0x20] CALL 0x00101e12 JMP 0x00101480 LAB_00101559: LEA RDX,[RSP + 0x1c] LEA RDI,[RSP + 0x20] CALL 0x00101e12 JMP 0x001014ed LAB_0010156a: MOV EAX,dword ptr [RDX + 0x20] CMP dword ptr [RBP],EAX SETL R12B JMP 0x001015d2 LAB_00101576: MOV RSI,RAX MOV EAX,dword ptr [R13] MOV dword ptr [RSI + 0x20],EAX LEA RCX,[RSP + 0x48] MOVZX EDI,R12B MOV RDX,RBX CALL 0x00101130 ADD qword ptr [RSP + 0x68],0x1 LAB_00101597: ADD RBP,0x4 CMP R14,RBP JZ 0x001015de LAB_001015a0: MOV R13,RBP LEA RSI,[RSP + 0x48] MOV RDX,RBP MOV RDI,R15 CALL 0x00102014 MOV RBX,RDX TEST RDX,RDX JZ 0x00101597 TEST RAX,RAX SETNZ R12B LEA RAX,[RSP + 0x48] CMP RDX,RAX SETZ AL OR R12B,AL JZ 0x0010156a LAB_001015d2: MOV EDI,0x28 LAB_001015d7: CALL 0x001011a0 JMP 0x00101576 LAB_001015de: CMP qword ptr [RSP + 0x68],0x1 SETZ BL LEA RDI,[RSP + 0x40] MOV RSI,qword ptr [RSP + 0x50] CALL 0x00101f44 CMP qword ptr [RSP + 0x8],0x0 JZ 0x00101610 MOV RSI,qword ptr [RSP + 0x30] MOV RDI,qword ptr [RSP + 0x8] SUB RSI,RDI CALL 0x001011b0 LAB_00101610: MOV RAX,qword ptr [RSP + 0x78] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010167a MOV EAX,EBX ADD RSP,0x88 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010167a: CALL 0x001011d0
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ ulong func0(vector *param_1) { long lVar1; int *piVar2; int *piVar3; long *plVar4; _Rb_tree_node_base *p_Var5; long lVar6; _Rb_tree_node_base *p_Var7; long *plVar8; _Rb_tree_node_base *p_Var9; int *piVar10; bool bVar11; int iVar12; long in_FS_OFFSET; bool bVar13; int auVar14 [16]; int local_a0; int local_9c; int *local_98; int *local_90; int *local_88; int local_78 [2]; int4 local_70 [2]; _Rb_tree_node *local_68; int4 *local_60; int4 *local_58; long local_50; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); p_Var9 = *(_Rb_tree_node_base **)param_1; lVar6 = *(long *)(p_Var9 + 8); lVar1 = *(long *)p_Var9; local_98 = (int *)0x0; local_90 = (int *)0x0; local_88 = (int *)0x0; p_Var7 = *(_Rb_tree_node_base **)(param_1 + 8); if (p_Var9 != p_Var7) { do { local_78[0] = 0; piVar3 = *(int **)p_Var9; if (piVar3 != *(int **)(p_Var9 + 8)) { local_78[0] = 0; do { local_78[0] = local_78[0] + *piVar3; piVar3 = piVar3 + 1; } while (piVar3 != *(int **)(p_Var9 + 8)); } if (local_90 == local_88) { /* try { // try from 00101372 to 00101567 has its CatchHandler @ 00101669 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_90,local_78 ); } else { *local_90 = local_78[0]; local_90 = local_90 + 1; } p_Var9 = p_Var9 + 0x18; } while (p_Var7 != p_Var9); } iVar12 = (int)(lVar6 - lVar1 >> 2); if (iVar12 < 1) { local_a0 = 0; } else { p_Var7 = (_Rb_tree_node_base *)((ulong)(iVar12 - 1) * 4 + 4); p_Var9 = (_Rb_tree_node_base *)0x0; do { plVar4 = *(long **)param_1; plVar8 = plVar4 + (ulong)(iVar12 - 1) * 3 + 3; local_78[0] = 0; do { local_78[0] = local_78[0] + *(int *)(p_Var9 + *plVar4); plVar4 = plVar4 + 3; } while (plVar4 != plVar8); if (local_90 == local_88) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_90,local_78 ); } else { *local_90 = local_78[0]; local_90 = local_90 + 1; } p_Var9 = p_Var9 + 4; } while (p_Var9 != p_Var7); plVar8 = *(long **)param_1; p_Var5 = (_Rb_tree_node_base *)0x0; local_a0 = 0; do { local_a0 = local_a0 + *(int *)(p_Var5 + *plVar8); plVar8 = plVar8 + 3; p_Var5 = p_Var5 + 4; } while (p_Var5 != p_Var7); } if (local_90 == local_88) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_90,&local_a0); } else { *local_90 = local_a0; local_90 = local_90 + 1; } local_9c = 0; if (-1 < iVar12 + -1) { plVar8 = (long *)(*(long *)param_1 + -0x18 + (long)iVar12 * 0x18); lVar6 = (long)(iVar12 + -1) << 2; local_9c = 0; do { local_9c = local_9c + *(int *)(*plVar8 + lVar6); plVar8 = plVar8 + -3; lVar6 = lVar6 + -4; } while (((long)iVar12 - (ulong)(iVar12 - 1)) * 4 + -8 != lVar6); } if (local_90 == local_88) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_90,&local_9c); } else { *local_90 = local_9c; local_90 = local_90 + 1; } piVar2 = local_90; piVar3 = local_98; local_70[0] = 0; local_68 = (_Rb_tree_node *)0x0; local_60 = local_70; local_50 = 0; local_58 = local_60; if (local_98 != local_90) { piVar10 = local_98; do { auVar14 = std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_get_insert_hint_unique_pos ((_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> *)local_78,(_Rb_tree_const_iterator)local_70,piVar10); p_Var9 = auVar14._8_8_; if (p_Var9 != (_Rb_tree_node_base *)0x0) { bVar13 = auVar14._0_8_ != 0; bVar11 = bVar13 || p_Var9 == (_Rb_tree_node_base *)local_70; if (!bVar13 && p_Var9 != (_Rb_tree_node_base *)local_70) { bVar11 = *piVar10 < *(int *)(p_Var9 + 0x20); } /* try { // try from 001015d7 to 001015db has its CatchHandler @ 00101634 */ p_Var7 = (_Rb_tree_node_base *)operator_new(0x28); *(int *)(p_Var7 + 0x20) = *piVar10; std::_Rb_tree_insert_and_rebalance(bVar11,p_Var7,p_Var9,(_Rb_tree_node_base *)local_70); local_50 = local_50 + 1; } piVar10 = piVar10 + 1; } while (piVar2 != piVar10); } bVar11 = local_50 == 1; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase ((_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> *)local_78, local_68); if (piVar3 != (int *)0x0) { operator_delete(piVar3,(long)local_88 - (long)piVar3); } if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return CONCAT71((int7)((ulong)p_Var9 >> 8),bVar11) & 0xffffffff; }
514
func0
#include <vector> #include <set> #include <cassert>
bool func0(const std::vector<std::vector<int>>& my_matrix) { int iSize = my_matrix[0].size(); std::vector<int> sum_list; for (const auto& lines : my_matrix) { int line_sum = 0; for (int num : lines) { line_sum += num; } sum_list.push_back(line_sum); } for (int col = 0; col < iSize; ++col) { int col_sum = 0; for (int row = 0; row < iSize; ++row) { col_sum += my_matrix[row][col]; } sum_list.push_back(col_sum); } int result1 = 0; for (int i = 0; i < iSize; ++i) { result1 += my_matrix[i][i]; } sum_list.push_back(result1); int result2 = 0; for (int i = iSize - 1; i >= 0; --i) { result2 += my_matrix[i][i]; } sum_list.push_back(result2); std::set<int> unique_sums(sum_list.begin(), sum_list.end()); return unique_sums.size() == 1; }
int main() { assert(func0({{7, 12, 1, 14}, {2, 13, 8, 11}, {16, 3, 10, 5}, {9, 6, 15, 4}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 8}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 7}}) == false); return 0; }
O2
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 xor %r8d,%r8d mov %rdi,%r15 xor %esi,%esi push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x88,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r12 mov %fs:0x28,%rax mov %rax,0x78(%rsp) xor %eax,%eax lea 0x40(%rsp),%r13 mov 0x8(%rbx),%rbp sub (%rbx),%rbp movq $0x0,0x20(%rsp) movq $0x0,0x28(%rsp) sar $0x2,%rbp movq $0x0,0x30(%rsp) cmp %r12,%rbx je 18e1 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xb1> nopl 0x0(%rax) mov 0x8(%rbx),%rcx mov (%rbx),%rax movl $0x0,0x40(%rsp) xor %edx,%edx cmp %rcx,%rax je 18bf <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x8f> xchg %ax,%ax add (%rax),%edx add $0x4,%rax mov %edx,0x40(%rsp) cmp %rax,%rcx jne 18b0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x80> cmp %r8,%rsi je 1960 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x130> mov 0x40(%rsp),%eax add $0x4,%rsi mov %eax,-0x4(%rsi) mov %rsi,0x28(%rsp) add $0x18,%rbx cmp %rbx,%r12 jne 1898 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x68> test %ebp,%ebp jle 1b96 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x366> lea -0x1(%rbp),%eax mov (%r15),%r9 xor %ebx,%ebx lea 0x0(,%rax,4),%r14 add $0x1,%rax mov %rax,0x8(%rsp) lea (%rax,%rax,2),%r13 shl $0x3,%r13 nopw 0x0(%rax,%rax,1) movl $0x0,0x40(%rsp) mov %r9,%rax lea 0x0(%r13,%r9,1),%rdi xor %edx,%edx nopw 0x0(%rax,%rax,1) mov (%rax),%rcx add $0x18,%rax add (%rcx,%rbx,1),%edx mov %edx,0x40(%rsp) cmp %rdi,%rax jne 1928 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xf8> cmp %r8,%rsi je 1980 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x150> mov %edx,(%rsi) add $0x4,%rsi mov %rsi,0x28(%rsp) cmp %rbx,%r14 je 19a0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x170> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%r8 add $0x4,%rbx jmp 1910 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xe0> lea 0x20(%rsp),%rdi mov %r13,%rdx callq 1eb0 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%r8 jmpq 18d8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xa8> nopl 0x0(%rax) lea 0x40(%rsp),%r12 lea 0x20(%rsp),%rdi mov %r12,%rdx callq 1eb0 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov (%r15),%r9 cmp %rbx,%r14 jne 1950 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x120> nopw 0x0(%rax,%rax,1) mov 0x8(%rsp),%rdi mov %r9,%rax xor %edx,%edx xor %ecx,%ecx movl $0x0,0x18(%rsp) shl $0x2,%rdi nopl 0x0(%rax,%rax,1) mov (%rax),%rsi add $0x18,%rax add (%rsi,%rdx,1),%ecx add $0x4,%rdx mov %ecx,0x18(%rsp) cmp %rdx,%rdi jne 19c0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x190> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%r8 cmp %r8,%rsi je 1b53 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x323> mov 0x18(%rsp),%eax add $0x4,%rsi mov %eax,-0x4(%rsi) mov %rsi,0x28(%rsp) mov %ebp,%edx movl $0x0,0x1c(%rsp) sub $0x1,%edx js 1a47 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x217> movslq %edx,%rax mov (%r15),%rcx mov %edx,%edx movslq %ebp,%rbp lea (%rax,%rax,2),%rdi sub %rdx,%rbp shl $0x2,%rax xor %edx,%edx lea (%rcx,%rdi,8),%rcx lea -0x8(,%rbp,4),%r9 nopl (%rax) mov (%rcx),%rdi sub $0x18,%rcx add (%rdi,%rax,1),%edx sub $0x4,%rax mov %edx,0x1c(%rsp) cmp %rax,%r9 jne 1a30 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x200> cmp %r8,%rsi je 1b71 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x341> mov 0x1c(%rsp),%eax lea 0x4(%rsi),%r15 mov %eax,(%rsi) mov %r15,0x28(%rsp) mov 0x20(%rsp),%rbx lea 0x48(%rsp),%r14 movl $0x0,0x48(%rsp) movq $0x0,0x50(%rsp) mov %r14,0x58(%rsp) mov %r14,0x60(%rsp) movq $0x0,0x68(%rsp) cmp %r15,%rbx je 1b8a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x35a> lea 0x40(%rsp),%r12 jmp 1ad0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2a0> nopl (%rax) mov $0x28,%edi callq 11b0 <_Znwm@plt> mov %rax,%rsi mov (%rbx),%eax movzbl %bpl,%edi mov %r14,%rcx mov %r13,%rdx mov %eax,0x20(%rsi) callq 1130 <_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@plt> addq $0x1,0x68(%rsp) add $0x4,%rbx cmp %rbx,%r15 je 1b08 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2d8> mov %rbx,%rdx mov %r14,%rsi mov %r12,%rdi callq 20f0 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIiERKi> mov %rdx,%r13 test %rdx,%rdx je 1ac7 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x297> test %rax,%rax setne %bpl cmp %r14,%rdx sete %dil or %dil,%bpl jne 1aa0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x270> mov 0x20(%rdx),%eax cmp %eax,(%rbx) setl %bpl jmp 1aa0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x270> nopl 0x0(%rax) cmpq $0x1,0x68(%rsp) mov 0x50(%rsp),%rsi sete %r13b mov %r12,%rdi callq 2010 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x20(%rsp),%rdi test %rdi,%rdi je 1b2e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2fe> callq 11a0 <_ZdlPv@plt> mov 0x78(%rsp),%rax xor %fs:0x28,%rax jne 1ba3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x373> add $0x88,%rsp mov %r13d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0x18(%rsp),%rdx lea 0x20(%rsp),%rdi callq 1eb0 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%r8 jmpq 19fa <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1ca> lea 0x1c(%rsp),%rdx lea 0x20(%rsp),%rdi callq 1eb0 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x28(%rsp),%r15 jmpq 1a5f <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x22f> xor %r13d,%r13d xor %esi,%esi lea 0x40(%rsp),%r12 jmp 1b17 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2e7> movl $0x0,0x18(%rsp) jmpq 19e1 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b1> callq 11d0 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 122d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold+0xd> endbr64 mov %rax,%rbp jmpq 1220 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold>
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 pxor xmm0, xmm0 push r14 push r13 mov r13, rdi push r12 push rbp push rbx sub rsp, 88h mov rbx, [rdi] mov r12, [rdi+8] mov rax, fs:28h mov [rsp+0B8h+var_40], rax xor eax, eax movaps [rsp+0B8h+var_98], xmm0 mov [rsp+0B8h+var_88], 0 mov rbp, [rbx+8] sub rbp, [rbx] sar rbp, 2 cmp rbx, r12 jz loc_1C10 xor edi, edi xor esi, esi lea r14, [rsp+0B8h+var_78] xchg ax, ax loc_1B90: mov rax, [rbx] mov rcx, [rbx+8] mov [rsp+0B8h+var_78], 0 cmp rax, rcx jz short loc_1BBF xor edx, edx nop word ptr [rax+rax+00000000h] loc_1BB0: add edx, [rax] add rax, 4 cmp rcx, rax jnz short loc_1BB0 mov [rsp+0B8h+var_78], edx loc_1BBF: cmp rdi, rsi jz short loc_1BF0 mov eax, [rsp+0B8h+var_78] add rsi, 4 add rbx, 18h mov [rsi-4], eax mov qword ptr [rsp+0B8h+var_98+8], rsi cmp r12, rbx jz short loc_1C10 loc_1BDD: mov rsi, qword ptr [rsp+0B8h+var_98+8] mov rdi, [rsp+0B8h+var_88] jmp short loc_1B90 loc_1BF0: lea r15, [rsp+0B8h+var_98] mov rsi, rdi mov rdx, r14 mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) add rbx, 18h cmp r12, rbx jnz short loc_1BDD nop dword ptr [rax+00h] loc_1C10: test ebp, ebp jle loc_1F2B lea eax, [rbp-1] mov r8, [r13+0] mov rdi, qword ptr [rsp+0B8h+var_98+8] xor ebx, ebx add rax, 1 mov r9, [rsp+0B8h+var_88] lea r14, [rax+rax*2] lea r12, ds:0[rax*4] shl r14, 3 nop loc_1C40: mov rax, r8 lea rsi, [r14+r8] xor edx, edx nop dword ptr [rax+00000000h] loc_1C50: mov rcx, [rax] add rax, 18h add edx, [rcx+rbx] cmp rsi, rax jnz short loc_1C50 mov [rsp+0B8h+var_78], edx cmp rdi, r9 jz loc_1E58 mov [rdi], edx add rdi, 4 mov qword ptr [rsp+0B8h+var_98+8], rdi loc_1C77: add rbx, 4 cmp rbx, r12 jnz short loc_1C40 mov rax, r8 xor edx, edx xor ecx, ecx nop word ptr [rax+rax+00000000h] loc_1C90: mov rsi, [rax] add rax, 18h add ecx, [rsi+rdx] add rdx, 4 cmp rdx, r12 jnz short loc_1C90 mov [rsp+0B8h+var_A0], ecx loc_1CA7: cmp rdi, r9 jz loc_1F07 mov eax, [rsp+0B8h+var_A0] lea rsi, [rdi+4] mov qword ptr [rsp+0B8h+var_98+8], rsi mov [rdi], eax loc_1CBF: mov ecx, ebp mov [rsp+0B8h+var_9C], 0 sub ecx, 1 js short loc_1D0F mov rax, [r13+0] movsxd rbp, ebp lea rdx, [rbp+rbp*2+0] lea rdx, [rax+rdx*8-18h] movsxd rax, ecx mov ecx, ecx sub rbp, rcx shl rax, 2 xor ecx, ecx lea r8, ds:0FFFFFFFFFFFFFFF8h[rbp*4] nop dword ptr [rax] loc_1CF8: mov rdi, [rdx] sub rdx, 18h add ecx, [rdi+rax] sub rax, 4 cmp rax, r8 jnz short loc_1CF8 mov [rsp+0B8h+var_9C], ecx loc_1D0F: cmp rsi, r9 jz loc_1EAD mov eax, [rsp+0B8h+var_9C] lea r14, [rsp+0B8h+var_70] lea rbx, [rsi+4] mov qword ptr [rsp+0B8h+var_98+8], rbx mov [rsi], eax mov rax, qword ptr [rsp+0B8h+var_98] mov [rsp+0B8h+var_70], 0 mov [rsp+0B8h+var_B0], rax mov [rsp+0B8h+var_68], 0 mov [rsp+0B8h+var_60], r14 mov [rsp+0B8h+var_58], r14 mov [rsp+0B8h+var_50], 0 cmp rbx, rax jz loc_1E94 loc_1D63: lea rax, [rsp+0B8h+var_78] mov r12, [rsp+0B8h+var_B0] xor r13d, r13d mov [rsp+0B8h+var_B8], rax nop dword ptr [rax+00h] loc_1D78: mov r15d, [r12] test r13, r13 jz short loc_1D90 mov rbp, [rsp+0B8h+var_58] cmp r15d, [rbp+20h] jg loc_1E8D loc_1D90: mov rdi, [rsp+0B8h+var_B8] mov esi, r15d call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE24_M_get_insert_unique_posERKi_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_get_insert_unique_pos(int const&) [clone] mov rbp, rdx test rdx, rdx jz short loc_1DEB test rax, rax setnz al loc_1DAA: cmp rbp, r14 setz r13b or r13b, al jz loc_1E80 loc_1DBA: mov edi, 28h ; '('; unsigned __int64 call __Znwm; operator new(ulong) mov rsi, rax mov eax, [r12] movzx edi, r13b mov rcx, r14 mov rdx, rbp mov [rsi+20h], eax call __ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; std::_Rb_tree_insert_and_rebalance(bool,std::_Rb_tree_node_base *,std::_Rb_tree_node_base *,std::_Rb_tree_node_base&) mov rax, [rsp+0B8h+var_50] lea r13, [rax+1] mov [rsp+0B8h+var_50], r13 loc_1DEB: add r12, 4 cmp rbx, r12 jnz short loc_1D78 mov rbx, [rsp+0B8h+var_68] cmp r13, 1 setz bpl test rbx, rbx jz short loc_1E25 loc_1E06: mov rdi, [rbx+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, rbx; void * mov rbx, [rbx+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test rbx, rbx jnz short loc_1E06 loc_1E25: cmp [rsp+0B8h+var_B0], 0 jnz short loc_1E96 loc_1E2D: mov rax, [rsp+0B8h+var_40] sub rax, fs:28h jnz loc_1F42 add rsp, 88h mov eax, ebp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1E58: lea r15, [rsp+0B8h+var_98] mov rsi, rdi lea rdx, [rsp+0B8h+var_78] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov r8, [r13+0] mov rdi, qword ptr [rsp+0B8h+var_98+8] mov r9, [rsp+0B8h+var_88] jmp loc_1C77 loc_1E80: cmp r15d, [rbp+20h] setl r13b jmp loc_1DBA loc_1E8D: xor eax, eax jmp loc_1DAA loc_1E94: xor ebp, ebp loc_1E96: mov rsi, [rsp+0B8h+var_88] mov rdi, [rsp+0B8h+var_B0]; void * sub rsi, rdi; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) jmp loc_1E2D loc_1EAD: lea r15, [rsp+0B8h+var_98] lea rdx, [rsp+0B8h+var_9C] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rax, qword ptr [rsp+0B8h+var_98] mov rbx, qword ptr [rsp+0B8h+var_98+8] lea r14, [rsp+0B8h+var_70] mov [rsp+0B8h+var_70], 0 mov [rsp+0B8h+var_68], 0 mov [rsp+0B8h+var_B0], rax mov [rsp+0B8h+var_60], r14 mov [rsp+0B8h+var_58], r14 mov [rsp+0B8h+var_50], 0 cmp rax, rbx jnz loc_1D63 xor ebp, ebp jmp loc_1E25 loc_1F07: lea r15, [rsp+0B8h+var_98] mov rsi, rdi lea rdx, [rsp+0B8h+var_A0] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rsi, qword ptr [rsp+0B8h+var_98+8] mov r9, [rsp+0B8h+var_88] jmp loc_1CBF loc_1F2B: mov [rsp+0B8h+var_A0], 0 mov rdi, qword ptr [rsp+0B8h+var_98+8] mov r9, [rsp+0B8h+var_88] jmp loc_1CA7 loc_1F42: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE_cold; func0(std::vector<std::vector<int>> const&) [clone] endbr64 mov rbx, rax jmp loc_122F
long long func0(long long **a1, long long a2, long long a3) { long long *v4; // rbx long long *v5; // r12 long long v6; // rbp _DWORD *v7; // rdi _DWORD *v8; // rsi _DWORD *v9; // rax _DWORD *v10; // rcx _DWORD *v11; // rsi long long *v12; // r8 _DWORD *v13; // rdi long long v14; // rbx long long v15; // rax _DWORD *v16; // r9 long long v17; // r12 long long v18; // r14 long long *v19; // rax int v20; // edx long long v21; // rcx long long *v22; // rax int v23; // ecx long long v24; // rsi _DWORD *v25; // rsi long long v26; // rcx unsigned long long v27; // rbp long long v28; // rax long long v29; // rdi signed int *v30; // rbx signed int *v31; // r12 long long v32; // r13 signed int v33; // r15d int *v34; // rbp long long insert_unique_pos; // rax bool v36; // al bool v37; // r13 long long v38; // rax _QWORD *v39; // rbx void *v40; // rdi void *v42; // [rsp+8h] [rbp-B0h] int v43; // [rsp+18h] [rbp-A0h] BYREF int v44; // [rsp+1Ch] [rbp-9Ch] BYREF __int128 v45; // [rsp+20h] [rbp-98h] BYREF _DWORD *v46; // [rsp+30h] [rbp-88h] int v47; // [rsp+40h] [rbp-78h] BYREF int v48; // [rsp+48h] [rbp-70h] BYREF void *v49; // [rsp+50h] [rbp-68h] int *v50; // [rsp+58h] [rbp-60h] int *v51; // [rsp+60h] [rbp-58h] long long v52; // [rsp+68h] [rbp-50h] unsigned long long v53; // [rsp+78h] [rbp-40h] v4 = *a1; v5 = a1[1]; v53 = __readfsqword(0x28u); v45 = 0LL; v46 = 0LL; v6 = (v4[1] - *v4) >> 2; if ( v4 != v5 ) { v7 = 0LL; v8 = 0LL; while ( 1 ) { v9 = (_DWORD *)*v4; v10 = (_DWORD *)v4[1]; v47 = 0; if ( v9 != v10 ) { LODWORD(a3) = 0; do a3 = (unsigned int)(*v9++ + a3); while ( v10 != v9 ); v47 = a3; } if ( v7 == v8 ) { std::vector<int>::_M_realloc_insert<int const&>(&v45, v7, &v47); v4 += 3; if ( v5 == v4 ) break; } else { v11 = v8 + 1; v4 += 3; *(v11 - 1) = v47; *((_QWORD *)&v45 + 1) = v11; if ( v5 == v4 ) break; } v8 = (_DWORD *)*((_QWORD *)&v45 + 1); v7 = v46; } } if ( (int)v6 <= 0 ) { v43 = 0; v13 = (_DWORD *)*((_QWORD *)&v45 + 1); v16 = v46; } else { v12 = *a1; v13 = (_DWORD *)*((_QWORD *)&v45 + 1); v14 = 0LL; v15 = (unsigned int)(v6 - 1) + 1LL; v16 = v46; v17 = 4 * v15; v18 = 3 * v15; do { v19 = v12; v20 = 0; do { v21 = *v19; v19 += 3; v20 += *(_DWORD *)(v21 + v14); } while ( &v12[v18] != v19 ); v47 = v20; if ( v13 == v16 ) { std::vector<int>::_M_realloc_insert<int const&>(&v45, v13, &v47); v12 = *a1; v13 = (_DWORD *)*((_QWORD *)&v45 + 1); v16 = v46; } else { *v13++ = v20; *((_QWORD *)&v45 + 1) = v13; } v14 += 4LL; } while ( v14 != v17 ); v22 = v12; a3 = 0LL; v23 = 0; do { v24 = *v22; v22 += 3; v23 += *(_DWORD *)(v24 + a3); a3 += 4LL; } while ( a3 != v17 ); v43 = v23; } if ( v13 == v16 ) { std::vector<int>::_M_realloc_insert<int const&>(&v45, v13, &v43); v25 = (_DWORD *)*((_QWORD *)&v45 + 1); v16 = v46; } else { v25 = v13 + 1; *((_QWORD *)&v45 + 1) = v13 + 1; *v13 = v43; } v44 = 0; v26 = (unsigned int)(v6 - 1); if ( (int)v6 - 1 >= 0 ) { a3 = (long long)&(*a1)[3 * (int)v6 - 3]; v27 = (int)v6 - (unsigned long long)(unsigned int)v26; v28 = 4LL * (int)v26; LODWORD(v26) = 0; do { v29 = *(_QWORD *)a3; a3 -= 24LL; v26 = (unsigned int)(*(_DWORD *)(v29 + v28) + v26); v28 -= 4LL; } while ( v28 != 4 * v27 - 8 ); v44 = v26; } if ( v25 == v16 ) { std::vector<int>::_M_realloc_insert<int const&>(&v45, v25, &v44); v30 = (signed int *)*((_QWORD *)&v45 + 1); v48 = 0; v49 = 0LL; v42 = (void *)v45; v50 = &v48; v51 = &v48; v52 = 0LL; if ( (_QWORD)v45 == *((_QWORD *)&v45 + 1) ) { LODWORD(v34) = 0; goto LABEL_40; } } else { v30 = v25 + 1; *((_QWORD *)&v45 + 1) = v25 + 1; *v25 = v44; v48 = 0; v42 = (void *)v45; v49 = 0LL; v50 = &v48; v51 = &v48; v52 = 0LL; if ( v25 + 1 == (_DWORD *)v45 ) { LODWORD(v34) = 0; LABEL_45: operator delete(v42, (char *)v46 - (_BYTE *)v42); return (unsigned int)v34; } } v31 = (signed int *)v42; v32 = 0LL; do { v33 = *v31; if ( v32 && (v34 = v51, v33 > v51[8]) ) { v36 = 0; } else { insert_unique_pos = std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_get_insert_unique_pos( &v47, (unsigned int)v33, a3, v26); v34 = (int *)a3; if ( !a3 ) goto LABEL_37; v36 = insert_unique_pos != 0; } v37 = v36 || v34 == &v48; if ( !v37 ) v37 = v33 < v34[8]; v38 = operator new(0x28uLL); *(_DWORD *)(v38 + 32) = *v31; std::_Rb_tree_insert_and_rebalance(v37, v38, v34, &v48); v32 = ++v52; LABEL_37: ++v31; } while ( v30 != v31 ); v39 = v49; LOBYTE(v34) = v32 == 1; if ( v49 ) { do { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(v39[3]); v40 = v39; v39 = (_QWORD *)v39[2]; operator delete(v40, 0x28uLL); } while ( v39 ); } LABEL_40: if ( v42 ) goto LABEL_45; return (unsigned int)v34; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 PUSH R13 MOV R13,RDI PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x88 MOV RBX,qword ptr [RDI] MOV R12,qword ptr [RDI + 0x8] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x78],RAX XOR EAX,EAX MOVAPS xmmword ptr [RSP + 0x20],XMM0 MOV qword ptr [RSP + 0x30],0x0 MOV RBP,qword ptr [RBX + 0x8] SUB RBP,qword ptr [RBX] SAR RBP,0x2 CMP RBX,R12 JZ 0x00101c10 XOR EDI,EDI XOR ESI,ESI LEA R14,[RSP + 0x40] NOP LAB_00101b90: MOV RAX,qword ptr [RBX] MOV RCX,qword ptr [RBX + 0x8] MOV dword ptr [RSP + 0x40],0x0 CMP RAX,RCX JZ 0x00101bbf XOR EDX,EDX NOP word ptr CS:[RAX + RAX*0x1] LAB_00101bb0: ADD EDX,dword ptr [RAX] ADD RAX,0x4 CMP RCX,RAX JNZ 0x00101bb0 MOV dword ptr [RSP + 0x40],EDX LAB_00101bbf: CMP RDI,RSI JZ 0x00101bf0 MOV EAX,dword ptr [RSP + 0x40] ADD RSI,0x4 ADD RBX,0x18 MOV dword ptr [RSI + -0x4],EAX MOV qword ptr [RSP + 0x28],RSI CMP R12,RBX JZ 0x00101c10 LAB_00101bdd: MOV RSI,qword ptr [RSP + 0x28] MOV RDI,qword ptr [RSP + 0x30] JMP 0x00101b90 LAB_00101bf0: LEA R15,[RSP + 0x20] MOV RSI,RDI MOV RDX,R14 MOV RDI,R15 LAB_00101bfe: CALL 0x001020e0 ADD RBX,0x18 CMP R12,RBX JNZ 0x00101bdd NOP dword ptr [RAX] LAB_00101c10: TEST EBP,EBP JLE 0x00101f2b LEA EAX,[RBP + -0x1] MOV R8,qword ptr [R13] MOV RDI,qword ptr [RSP + 0x28] XOR EBX,EBX ADD RAX,0x1 MOV R9,qword ptr [RSP + 0x30] LEA R14,[RAX + RAX*0x2] LEA R12,[RAX*0x4] SHL R14,0x3 NOP LAB_00101c40: MOV RAX,R8 LEA RSI,[R14 + R8*0x1] XOR EDX,EDX NOP dword ptr [RAX] LAB_00101c50: MOV RCX,qword ptr [RAX] ADD RAX,0x18 ADD EDX,dword ptr [RCX + RBX*0x1] CMP RSI,RAX JNZ 0x00101c50 MOV dword ptr [RSP + 0x40],EDX CMP RDI,R9 JZ 0x00101e58 MOV dword ptr [RDI],EDX ADD RDI,0x4 MOV qword ptr [RSP + 0x28],RDI LAB_00101c77: ADD RBX,0x4 CMP RBX,R12 JNZ 0x00101c40 MOV RAX,R8 XOR EDX,EDX XOR ECX,ECX NOP word ptr [RAX + RAX*0x1] LAB_00101c90: MOV RSI,qword ptr [RAX] ADD RAX,0x18 ADD ECX,dword ptr [RSI + RDX*0x1] ADD RDX,0x4 CMP RDX,R12 JNZ 0x00101c90 MOV dword ptr [RSP + 0x18],ECX LAB_00101ca7: CMP RDI,R9 JZ 0x00101f07 MOV EAX,dword ptr [RSP + 0x18] LEA RSI,[RDI + 0x4] MOV qword ptr [RSP + 0x28],RSI MOV dword ptr [RDI],EAX LAB_00101cbf: MOV ECX,EBP MOV dword ptr [RSP + 0x1c],0x0 SUB ECX,0x1 JS 0x00101d0f MOV RAX,qword ptr [R13] MOVSXD RBP,EBP LEA RDX,[RBP + RBP*0x2] LEA RDX,[RAX + RDX*0x8 + -0x18] MOVSXD RAX,ECX MOV ECX,ECX SUB RBP,RCX SHL RAX,0x2 XOR ECX,ECX LEA R8,[-0x8 + RBP*0x4] NOP dword ptr [RAX] LAB_00101cf8: MOV RDI,qword ptr [RDX] SUB RDX,0x18 ADD ECX,dword ptr [RDI + RAX*0x1] SUB RAX,0x4 CMP RAX,R8 JNZ 0x00101cf8 MOV dword ptr [RSP + 0x1c],ECX LAB_00101d0f: CMP RSI,R9 JZ 0x00101ead MOV EAX,dword ptr [RSP + 0x1c] LEA R14,[RSP + 0x48] LEA RBX,[RSI + 0x4] MOV qword ptr [RSP + 0x28],RBX MOV dword ptr [RSI],EAX MOV RAX,qword ptr [RSP + 0x20] MOV dword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x8],RAX MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP + 0x58],R14 MOV qword ptr [RSP + 0x60],R14 MOV qword ptr [RSP + 0x68],0x0 CMP RBX,RAX JZ 0x00101e94 LAB_00101d63: LEA RAX,[RSP + 0x40] MOV R12,qword ptr [RSP + 0x8] XOR R13D,R13D MOV qword ptr [RSP],RAX NOP dword ptr [RAX] LAB_00101d78: MOV R15D,dword ptr [R12] TEST R13,R13 JZ 0x00101d90 MOV RBP,qword ptr [RSP + 0x60] CMP R15D,dword ptr [RBP + 0x20] JG 0x00101e8d LAB_00101d90: MOV RDI,qword ptr [RSP] MOV ESI,R15D CALL 0x001018d0 MOV RBP,RDX TEST RDX,RDX JZ 0x00101deb TEST RAX,RAX SETNZ AL LAB_00101daa: CMP RBP,R14 SETZ R13B OR R13B,AL JZ 0x00101e80 LAB_00101dba: MOV EDI,0x28 LAB_00101dbf: CALL 0x001011a0 MOV RSI,RAX MOV EAX,dword ptr [R12] MOVZX EDI,R13B MOV RCX,R14 MOV RDX,RBP MOV dword ptr [RSI + 0x20],EAX CALL 0x00101130 MOV RAX,qword ptr [RSP + 0x68] LEA R13,[RAX + 0x1] MOV qword ptr [RSP + 0x68],R13 LAB_00101deb: ADD R12,0x4 CMP RBX,R12 JNZ 0x00101d78 MOV RBX,qword ptr [RSP + 0x50] CMP R13,0x1 SETZ BPL TEST RBX,RBX JZ 0x00101e25 LAB_00101e06: MOV RDI,qword ptr [RBX + 0x18] CALL 0x00101960 MOV RDI,RBX MOV RBX,qword ptr [RBX + 0x10] MOV ESI,0x28 CALL 0x001011b0 TEST RBX,RBX JNZ 0x00101e06 LAB_00101e25: CMP qword ptr [RSP + 0x8],0x0 JNZ 0x00101e96 LAB_00101e2d: MOV RAX,qword ptr [RSP + 0x78] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101f42 ADD RSP,0x88 MOV EAX,EBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101e58: LEA R15,[RSP + 0x20] MOV RSI,RDI LEA RDX,[RSP + 0x40] MOV RDI,R15 LAB_00101e68: CALL 0x001020e0 MOV R8,qword ptr [R13] MOV RDI,qword ptr [RSP + 0x28] MOV R9,qword ptr [RSP + 0x30] JMP 0x00101c77 LAB_00101e80: CMP R15D,dword ptr [RBP + 0x20] SETL R13B JMP 0x00101dba LAB_00101e8d: XOR EAX,EAX JMP 0x00101daa LAB_00101e94: XOR EBP,EBP LAB_00101e96: MOV RSI,qword ptr [RSP + 0x30] MOV RDI,qword ptr [RSP + 0x8] SUB RSI,RDI CALL 0x001011b0 JMP 0x00101e2d LAB_00101ead: LEA R15,[RSP + 0x20] LEA RDX,[RSP + 0x1c] MOV RDI,R15 CALL 0x001020e0 MOV RAX,qword ptr [RSP + 0x20] MOV RBX,qword ptr [RSP + 0x28] LEA R14,[RSP + 0x48] MOV dword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP + 0x8],RAX MOV qword ptr [RSP + 0x58],R14 MOV qword ptr [RSP + 0x60],R14 MOV qword ptr [RSP + 0x68],0x0 CMP RAX,RBX JNZ 0x00101d63 XOR EBP,EBP JMP 0x00101e25 LAB_00101f07: LEA R15,[RSP + 0x20] MOV RSI,RDI LEA RDX,[RSP + 0x18] MOV RDI,R15 CALL 0x001020e0 MOV RSI,qword ptr [RSP + 0x28] MOV R9,qword ptr [RSP + 0x30] JMP 0x00101cbf LAB_00101f2b: MOV dword ptr [RSP + 0x18],0x0 MOV RDI,qword ptr [RSP + 0x28] MOV R9,qword ptr [RSP + 0x30] JMP 0x00101ca7 LAB_00101f42: CALL 0x001011d0
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ ulong func0(vector *param_1) { long lVar1; void *pvVar2; void *pvVar3; int *piVar4; long lVar5; long *plVar6; long *plVar7; long lVar8; _Rb_tree_node_base *p_Var9; uint uVar10; long lVar11; int iVar12; _Rb_tree_node_base *p_Var13; ulong uVar14; uint *puVar15; uint *puVar16; long in_FS_OFFSET; bool bVar17; int auVar18 [16]; uint *local_b0; uint local_a0; uint local_9c; uint *local_98; uint *puStack_90; uint *local_88; uint local_78 [2]; int4 local_70 [2]; void *local_68; _Rb_tree_node_base *local_60; _Rb_tree_node_base *local_58; long local_50; long local_40; plVar7 = *(long **)param_1; plVar6 = *(long **)(param_1 + 8); local_40 = *(long *)(in_FS_OFFSET + 0x28); local_98 = (uint *)0x0; puStack_90 = (uint *)0x0; local_88 = (uint *)0x0; lVar8 = plVar7[1]; lVar5 = *plVar7; if (plVar7 != plVar6) { while( true ) { piVar4 = (int *)*plVar7; local_78[0] = 0; if (piVar4 != (int *)plVar7[1]) { local_78[0] = 0; do { local_78[0] = local_78[0] + *piVar4; piVar4 = piVar4 + 1; } while ((int *)plVar7[1] != piVar4); } if (local_88 == puStack_90) { /* try { // try from 00101bfe to 00101c02 has its CatchHandler @ 00101f53 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_88, (int *)local_78); } else { *puStack_90 = local_78[0]; puStack_90 = puStack_90 + 1; } if (plVar6 == plVar7 + 3) break; plVar7 = plVar7 + 3; } } iVar12 = (int)(lVar8 - lVar5 >> 2); puVar15 = local_88; if (iVar12 < 1) { local_a0 = 0; } else { plVar7 = *(long **)param_1; lVar11 = 0; lVar5 = (ulong)(iVar12 - 1) + 1; lVar8 = lVar5 * 4; do { local_78[0] = 0; plVar6 = plVar7; do { lVar1 = *plVar6; plVar6 = plVar6 + 3; local_78[0] = local_78[0] + *(int *)(lVar1 + lVar11); } while (plVar7 + lVar5 * 3 != plVar6); if (puStack_90 == puVar15) { /* try { // try from 00101e68 to 00101f1b has its CatchHandler @ 00101f53 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)puStack_90, (int *)local_78); plVar7 = *(long **)param_1; puVar15 = local_88; } else { *puStack_90 = local_78[0]; puStack_90 = puStack_90 + 1; } lVar11 = lVar11 + 4; } while (lVar11 != lVar8); lVar5 = 0; local_a0 = 0; do { lVar11 = *plVar7; plVar7 = plVar7 + 3; local_a0 = local_a0 + *(int *)(lVar11 + lVar5); lVar5 = lVar5 + 4; } while (lVar5 != lVar8); } if (puStack_90 == puVar15) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)puStack_90, (int *)&local_a0); puVar15 = local_88; } else { *puStack_90 = local_a0; puStack_90 = puStack_90 + 1; } local_9c = 0; uVar10 = iVar12 - 1; if (-1 < (int)uVar10) { plVar7 = (long *)(*(long *)param_1 + -0x18 + (long)iVar12 * 0x18); lVar8 = (long)(int)uVar10 << 2; local_9c = 0; do { lVar5 = *plVar7; plVar7 = plVar7 + -3; local_9c = local_9c + *(int *)(lVar5 + lVar8); lVar8 = lVar8 + -4; } while (lVar8 != ((long)iVar12 - (ulong)uVar10) * 4 + -8); } if (puStack_90 == puVar15) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)puStack_90, (int *)&local_9c); local_b0 = local_98; local_60 = (_Rb_tree_node_base *)local_70; local_70[0] = 0; local_68 = (void *)0x0; local_50 = 0; if (local_98 != puStack_90) goto LAB_00101d63; uVar14 = 0; local_58 = local_60; LAB_00101e25: if (local_b0 == (uint *)0x0) goto LAB_00101e2d; } else { local_60 = (_Rb_tree_node_base *)local_70; puVar15 = puStack_90 + 1; *puStack_90 = local_9c; local_70[0] = 0; local_b0 = local_98; local_68 = (void *)0x0; local_50 = 0; puStack_90 = puVar15; if (puVar15 != local_98) { LAB_00101d63: puVar15 = puStack_90; local_b0 = local_98; local_50 = 0; local_68 = (void *)0x0; local_70[0] = 0; lVar8 = 0; puVar16 = local_98; local_60 = (_Rb_tree_node_base *)local_70; local_58 = (_Rb_tree_node_base *)local_70; do { uVar10 = *puVar16; if ((lVar8 == 0) || ((int)uVar10 <= *(int *)(local_58 + 0x20))) { auVar18 = std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_get_insert_unique_pos ((_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> *)local_78,(int *)(ulong)uVar10); p_Var13 = auVar18._8_8_; if (p_Var13 != (_Rb_tree_node_base *)0x0) { bVar17 = auVar18._0_8_ != 0; goto LAB_00101daa; } } else { bVar17 = false; p_Var13 = local_58; LAB_00101daa: bVar17 = (bool)(p_Var13 == (_Rb_tree_node_base *)local_70 | bVar17); if (bVar17 == false) { bVar17 = (int)uVar10 < *(int *)(p_Var13 + 0x20); } /* try { // try from 00101dbf to 00101dc3 has its CatchHandler @ 00101f47 */ p_Var9 = (_Rb_tree_node_base *)operator_new(0x28); *(uint *)(p_Var9 + 0x20) = *puVar16; std::_Rb_tree_insert_and_rebalance(bVar17,p_Var9,p_Var13,(_Rb_tree_node_base *)local_70); lVar8 = local_50 + 1; local_50 = lVar8; } puVar16 = puVar16 + 1; } while (puVar15 != puVar16); uVar14 = CONCAT71((int7)((ulong)p_Var13 >> 8),lVar8 == 1); pvVar3 = local_68; while (pvVar3 != (void *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)((long)pvVar3 + 0x18)); pvVar2 = *(void **)((long)pvVar3 + 0x10); operator_delete(pvVar3,0x28); pvVar3 = pvVar2; } goto LAB_00101e25; } uVar14 = 0; local_58 = local_60; } operator_delete(local_b0,(long)local_88 - (long)local_b0); LAB_00101e2d: if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar14 & 0xffffffff; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
515
func0
#include <vector> #include <set> #include <cassert>
bool func0(const std::vector<std::vector<int>>& my_matrix) { int iSize = my_matrix[0].size(); std::vector<int> sum_list; for (const auto& lines : my_matrix) { int line_sum = 0; for (int num : lines) { line_sum += num; } sum_list.push_back(line_sum); } for (int col = 0; col < iSize; ++col) { int col_sum = 0; for (int row = 0; row < iSize; ++row) { col_sum += my_matrix[row][col]; } sum_list.push_back(col_sum); } int result1 = 0; for (int i = 0; i < iSize; ++i) { result1 += my_matrix[i][i]; } sum_list.push_back(result1); int result2 = 0; for (int i = iSize - 1; i >= 0; --i) { result2 += my_matrix[i][i]; } sum_list.push_back(result2); std::set<int> unique_sums(sum_list.begin(), sum_list.end()); return unique_sums.size() == 1; }
int main() { assert(func0({{7, 12, 1, 14}, {2, 13, 8, 11}, {16, 3, 10, 5}, {9, 6, 15, 4}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 8}}) == true); assert(func0({{2, 7, 6}, {9, 5, 1}, {4, 3, 7}}) == false); return 0; }
O3
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 pxor %xmm0,%xmm0 mov %rdi,%r15 xor %esi,%esi push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x88,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r12 xor %edi,%edi mov %fs:0x28,%rax mov %rax,0x78(%rsp) xor %eax,%eax lea 0x40(%rsp),%r13 mov 0x8(%rbx),%rbp sub (%rbx),%rbp movaps %xmm0,0x20(%rsp) movq $0x0,0x30(%rsp) sar $0x2,%rbp cmp %r12,%rbx je 191c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xac> nopw 0x0(%rax,%rax,1) mov (%rbx),%rax mov 0x8(%rbx),%rcx movl $0x0,0x40(%rsp) xor %edx,%edx cmp %rcx,%rax je 18ff <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x8f> nopw %cs:0x0(%rax,%rax,1) add (%rax),%edx add $0x4,%rax mov %edx,0x40(%rsp) cmp %rax,%rcx jne 18f0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x80> cmp %rdi,%rsi je 19a0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x130> mov %edx,(%rsi) add $0x4,%rsi mov %rsi,0x28(%rsp) add $0x18,%rbx cmp %rbx,%r12 jne 18d0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x60> test %ebp,%ebp jle 1bfd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x38d> lea -0x1(%rbp),%eax mov (%r15),%r9 xor %ebx,%ebx lea 0x0(,%rax,4),%r14 add $0x1,%rax mov %rax,0x8(%rsp) lea (%rax,%rax,2),%r13 shl $0x3,%r13 nopl (%rax) movl $0x0,0x40(%rsp) mov %r9,%rax lea 0x0(%r13,%r9,1),%r8 xor %edx,%edx nopw 0x0(%rax,%rax,1) mov (%rax),%rcx add $0x18,%rax add (%rcx,%rbx,1),%edx mov %edx,0x40(%rsp) cmp %rax,%r8 jne 1960 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xf0> cmp %rdi,%rsi je 19c0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x150> mov %edx,(%rsi) add $0x4,%rsi mov %rsi,0x28(%rsp) cmp %rbx,%r14 je 19e0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x170> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%rdi add $0x4,%rbx jmp 1948 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xd8> nopl 0x0(%rax,%rax,1) lea 0x20(%rsp),%rdi mov %r13,%rdx callq 1e70 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%rdi jmpq 1913 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xa3> nopl 0x0(%rax) lea 0x40(%rsp),%r12 lea 0x20(%rsp),%rdi mov %r12,%rdx callq 1e70 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov (%r15),%r9 cmp %rbx,%r14 jne 1988 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x118> nopw 0x0(%rax,%rax,1) mov 0x8(%rsp),%rdi mov %r9,%rax xor %edx,%edx xor %ecx,%ecx movl $0x0,0x18(%rsp) shl $0x2,%rdi nopl 0x0(%rax,%rax,1) mov (%rax),%rsi add $0x18,%rax add (%rsi,%rdx,1),%ecx add $0x4,%rdx mov %ecx,0x18(%rsp) cmp %rdx,%rdi jne 1a00 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x190> mov 0x28(%rsp),%rsi mov 0x30(%rsp),%rdi cmp %rdi,%rsi je 1bad <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x33d> mov %ecx,(%rsi) mov %ebp,%edx add $0x4,%rsi mov %rsi,0x28(%rsp) movl $0x0,0x1c(%rsp) sub $0x1,%edx js 1bd9 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x369> movslq %edx,%rax mov (%r15),%rcx mov %edx,%edx movslq %ebp,%rbp lea (%rax,%rax,2),%r8 sub %rdx,%rbp shl $0x2,%rax xor %edx,%edx lea (%rcx,%r8,8),%rcx lea -0x8(,%rbp,4),%r9 nopl 0x0(%rax) mov (%rcx),%r8 sub $0x18,%rcx add (%r8,%rax,1),%edx sub $0x4,%rax mov %edx,0x1c(%rsp) cmp %rax,%r9 jne 1a70 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x200> cmp %rdi,%rsi je 1be4 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x374> lea 0x4(%rsi),%r15 mov %edx,(%rsi) mov %r15,0x28(%rsp) mov 0x20(%rsp),%rbx lea 0x48(%rsp),%r14 movl $0x0,0x48(%rsp) movq $0x0,0x50(%rsp) mov %r14,0x58(%rsp) mov %r14,0x60(%rsp) movq $0x0,0x68(%rsp) cmp %r15,%rbx je 1c0c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x39c> lea 0x40(%rsp),%r12 jmp 1b10 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2a0> nopw 0x0(%rax,%rax,1) mov $0x28,%edi callq 11b0 <_Znwm@plt> mov %rax,%rsi mov (%rbx),%eax movzbl %bpl,%edi mov %r14,%rcx mov %r13,%rdx mov %eax,0x20(%rsi) callq 1130 <_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@plt> addq $0x1,0x68(%rsp) add $0x4,%rbx cmp %rbx,%r15 je 1b48 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2d8> mov %rbx,%rdx mov %r14,%rsi mov %r12,%rdi callq 2020 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIiERKi> mov %rdx,%r13 test %rdx,%rdx je 1b07 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x297> test %rax,%rax setne %bpl cmp %r14,%rdx sete %dil or %dil,%bpl jne 1ae0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x270> mov 0x20(%rdx),%eax cmp %eax,(%rbx) setl %bpl jmp 1ae0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x270> nopl 0x0(%rax) mov 0x50(%rsp),%rbx cmpq $0x1,0x68(%rsp) sete %r13b test %rbx,%rbx je 1b79 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x309> mov 0x18(%rbx),%rsi mov %r12,%rdi callq 1fd0 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov %rbx,%rdi mov 0x10(%rbx),%rbx callq 11a0 <_ZdlPv@plt> test %rbx,%rbx jne 1b5c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2ec> mov 0x20(%rsp),%rdi test %rdi,%rdi je 1b88 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x318> callq 11a0 <_ZdlPv@plt> mov 0x78(%rsp),%rax xor %fs:0x28,%rax jne 1c14 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x3a4> add $0x88,%rsp mov %r13d,%eax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0x18(%rsp),%rdx lea 0x20(%rsp),%rdi callq 1e70 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov %ebp,%edx mov 0x28(%rsp),%rsi mov 0x30(%rsp),%rdi movl $0x0,0x1c(%rsp) sub $0x1,%edx jns 1a48 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1d8> xor %edx,%edx cmp %rdi,%rsi jne 1a91 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x221> lea 0x1c(%rsp),%rdx lea 0x20(%rsp),%rdi callq 1e70 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x28(%rsp),%r15 jmpq 1a9c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x22c> movl $0x0,0x18(%rsp) xor %ecx,%ecx jmpq 1a21 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b1> xor %r13d,%r13d jmpq 1b79 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x309> callq 11d0 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1235 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold> endbr64 mov %rax,%rbp jmpq 1242 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold+0xd> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 pxor xmm0, xmm0 push r14 mov r14, rdi push r13 push r12 push rbp push rbx sub rsp, 88h mov rbx, [rdi] mov rbp, [rdi+8] mov rax, fs:28h mov [rsp+0B8h+var_40], rax xor eax, eax movaps xmmword ptr [rsp+0B8h+var_98], xmm0 mov [rsp+0B8h+var_88], 0 mov r12, [rbx+8] sub r12, [rbx] sar r12, 2 cmp rbx, rbp jz loc_1CD0 xor edi, edi xor r8d, r8d lea r13, [rsp+0B8h+var_78] nop loc_1BC0: mov rdx, [rbx] mov r9, [rbx+8] mov [rsp+0B8h+var_78], 0 cmp rdx, r9 jz loc_1F70 lea rcx, [r9-4] mov rax, rdx sub rcx, rdx mov rsi, rcx shr rsi, 2 add rsi, 1 cmp rcx, 8 jbe loc_1F79 mov rcx, rsi pxor xmm0, xmm0 shr rcx, 2 shl rcx, 4 add rcx, rdx nop dword ptr [rax+00000000h] loc_1C10: movdqu xmm2, xmmword ptr [rax] add rax, 10h paddd xmm0, xmm2 cmp rax, rcx jnz short loc_1C10 movdqa xmm1, xmm0 psrldq xmm1, 8 paddd xmm0, xmm1 movdqa xmm1, xmm0 psrldq xmm1, 4 paddd xmm0, xmm1 test sil, 3 jz short loc_1C75 and rsi, 0FFFFFFFFFFFFFFFCh lea rdx, [rdx+rsi*4] loc_1C49: movd xmm1, dword ptr [rdx] lea rax, [rdx+4] paddd xmm0, xmm1 cmp r9, rax jz short loc_1C75 movd xmm1, dword ptr [rdx+4] lea rax, [rdx+8] paddd xmm0, xmm1 cmp r9, rax jz short loc_1C75 movd xmm1, dword ptr [rdx+8] paddd xmm0, xmm1 loc_1C75: movd [rsp+0B8h+var_78], xmm0 loc_1C7B: cmp rdi, r8 jz short loc_1CB0 movd dword ptr [r8], xmm0 add rbx, 18h add r8, 4 mov [rsp+0B8h+var_98+8], r8 cmp rbp, rbx jz short loc_1CD0 loc_1C97: mov r8, [rsp+0B8h+var_98+8] mov rdi, [rsp+0B8h+var_88] jmp loc_1BC0 loc_1CB0: lea r15, [rsp+0B8h+var_98] mov rsi, rdi mov rdx, r13 mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) add rbx, 18h cmp rbp, rbx jnz short loc_1C97 nop dword ptr [rax+00h] loc_1CD0: test r12d, r12d jle loc_2064 lea eax, [r12-1] mov r8, [r14] mov rdi, [rsp+0B8h+var_98+8] xor ebx, ebx add rax, 1 mov r9, [rsp+0B8h+var_88] lea r13, [rax+rax*2] lea rbp, ds:0[rax*4] shl r13, 3 nop dword ptr [rax+00000000h] loc_1D08: mov rax, r8 lea rsi, [r13+r8+0] xor edx, edx nop word ptr [rax+rax+00h] loc_1D18: mov rcx, [rax] add rax, 18h add edx, [rcx+rbx] cmp rax, rsi jnz short loc_1D18 mov [rsp+0B8h+var_78], edx cmp rdi, r9 jz loc_1F48 mov [rdi], edx add rdi, 4 mov [rsp+0B8h+var_98+8], rdi loc_1D3F: add rbx, 4 cmp rbp, rbx jnz short loc_1D08 mov rax, r8 xor edx, edx xor ecx, ecx nop loc_1D50: mov rsi, [rax] add rax, 18h add ecx, [rsi+rdx] add rdx, 4 cmp rdx, rbp jnz short loc_1D50 mov [rsp+0B8h+var_A0], ecx loc_1D67: cmp rdi, r9 jz loc_2011 mov [rdi], ecx lea rsi, [rdi+4] mov ecx, r12d mov [rsp+0B8h+var_98+8], rsi mov [rsp+0B8h+var_9C], 0 sub ecx, 1 js loc_2044 loc_1D8F: mov rax, [r14] movsxd r12, r12d lea rdx, [r12+r12*2] lea rdx, [rax+rdx*8-18h] movsxd rax, ecx mov ecx, ecx sub r12, rcx shl rax, 2 xor ecx, ecx lea r8, ds:0FFFFFFFFFFFFFFF8h[r12*4] nop dword ptr [rax+00h] loc_1DB8: mov rdi, [rdx] sub rdx, 18h add ecx, [rdi+rax] sub rax, 4 cmp rax, r8 jnz short loc_1DB8 mov [rsp+0B8h+var_9C], ecx loc_1DCF: cmp rsi, r9 jz loc_1FBC mov r14, [rsp+0B8h+var_98] lea r13, [rsp+0B8h+var_70] lea rbx, [rsi+4] mov [rsi], ecx mov [rsp+0B8h+var_98+8], rbx mov [rsp+0B8h+var_70], 0 mov [rsp+0B8h+var_68], 0 mov [rsp+0B8h+var_60], r13 mov [rsp+0B8h+var_58], r13 mov [rsp+0B8h+var_50], 0 cmp rbx, r14 jz loc_1F82 loc_1E1A: mov r12, r14 xor r15d, r15d loc_1E20: mov ecx, [r12] test r15, r15 jz loc_1EF0 mov rbp, [rsp+0B8h+var_58] cmp ecx, [rbp+20h] jle loc_1EF0 loc_1E3B: mov r15d, 1 cmp rbp, r13 jnz loc_1F36 loc_1E4A: mov edi, 28h ; '('; unsigned __int64 call __Znwm; operator new(ulong) mov rsi, rax mov eax, [r12] movzx edi, r15b mov rcx, r13 mov rdx, rbp mov [rsi+20h], eax call __ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; std::_Rb_tree_insert_and_rebalance(bool,std::_Rb_tree_node_base *,std::_Rb_tree_node_base *,std::_Rb_tree_node_base&) mov rax, [rsp+0B8h+var_50] lea r15, [rax+1] mov [rsp+0B8h+var_50], r15 loc_1E7B: add r12, 4 cmp rbx, r12 jnz short loc_1E20 mov rbx, [rsp+0B8h+var_68] cmp r15, 1 setz bpl test rbx, rbx jz short loc_1EB5 loc_1E96: mov rdi, [rbx+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, rbx; void * mov rbx, [rbx+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test rbx, rbx jnz short loc_1E96 loc_1EB5: test r14, r14 jnz loc_1F84 loc_1EBE: mov rax, [rsp+0B8h+var_40] sub rax, fs:28h jnz loc_207D add rsp, 88h mov eax, ebp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1EF0: mov rbp, [rsp+0B8h+var_68] test rbp, rbp jnz short loc_1F03 jmp loc_204B loc_1F00: mov rbp, rax loc_1F03: mov edx, [rbp+20h] mov rax, [rbp+18h] cmp ecx, edx cmovl rax, [rbp+10h] setl sil test rax, rax jnz short loc_1F00 test sil, sil jnz short loc_1F99 loc_1F1F: cmp edx, ecx jge loc_1E7B mov r15d, 1 cmp rbp, r13 jz loc_1E4A loc_1F36: cmp ecx, [rbp+20h] setl r15b jmp loc_1E4A loc_1F48: lea r15, [rsp+0B8h+var_98] mov rsi, rdi lea rdx, [rsp+0B8h+var_78] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov r8, [r14] mov rdi, [rsp+0B8h+var_98+8] mov r9, [rsp+0B8h+var_88] jmp loc_1D3F loc_1F70: pxor xmm0, xmm0 jmp loc_1C7B loc_1F79: pxor xmm0, xmm0 jmp loc_1C49 loc_1F82: xor ebp, ebp loc_1F84: mov rsi, [rsp+0B8h+var_88] mov rdi, r14; void * sub rsi, r14; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) jmp loc_1EBE loc_1F99: cmp [rsp+0B8h+var_60], rbp jz loc_1E3B loc_1FA4: mov rdi, rbp mov [rsp+0B8h+var_AC], ecx call __ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base; std::_Rb_tree_decrement(std::_Rb_tree_node_base *) mov ecx, [rsp+0B8h+var_AC] mov edx, [rax+20h] jmp loc_1F1F loc_1FBC: lea r15, [rsp+0B8h+var_98] lea rdx, [rsp+0B8h+var_9C] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rbx, [rsp+0B8h+var_98+8] mov r14, [rsp+0B8h+var_98] lea r13, [rsp+0B8h+var_70] mov [rsp+0B8h+var_70], 0 mov [rsp+0B8h+var_68], 0 mov [rsp+0B8h+var_60], r13 mov [rsp+0B8h+var_58], r13 mov [rsp+0B8h+var_50], 0 cmp r14, rbx jnz loc_1E1A xor ebp, ebp jmp loc_1EB5 loc_2011: lea r15, [rsp+0B8h+var_98] mov rsi, rdi lea rdx, [rsp+0B8h+var_A0] mov rdi, r15 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov ecx, r12d mov rsi, [rsp+0B8h+var_98+8] mov r9, [rsp+0B8h+var_88] mov [rsp+0B8h+var_9C], 0 sub ecx, 1 jns loc_1D8F loc_2044: xor ecx, ecx jmp loc_1DCF loc_204B: mov rbp, r13 cmp [rsp+0B8h+var_60], r13 jnz loc_1FA4 mov r15d, 1 jmp loc_1E4A loc_2064: mov [rsp+0B8h+var_A0], 0 mov rdi, [rsp+0B8h+var_98+8] xor ecx, ecx mov r9, [rsp+0B8h+var_88] jmp loc_1D67 loc_207D: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE_cold; func0(std::vector<std::vector<int>> const&) [clone] endbr64 mov rbx, rax jmp loc_124B
long long func0(unsigned int ***a1) { unsigned int **v2; // rbx unsigned int **v3; // rbp long long v4; // r12 _DWORD *v5; // rdi _DWORD *v6; // r8 unsigned int *v7; // rdx unsigned int *v8; // r9 const __m128i *v9; // rax unsigned long long v10; // rsi __m128i v11; // xmm0 __m128i v12; // xmm2 __m128i v13; // xmm0 __m128i v14; // xmm0 unsigned int **v15; // r8 int *v16; // rdi unsigned long long v17; // rbx long long v18; // rax int *v19; // r9 long long v20; // rbp long long v21; // r13 unsigned int **v22; // rax int v23; // edx unsigned int *v24; // rcx unsigned int **v25; // rax unsigned long long v26; // rdx int v27; // ecx unsigned int *v28; // rsi int *v29; // rsi unsigned int v30; // ecx long long *v31; // rdx unsigned long long v32; // r12 long long v33; // rax int v34; // ecx long long v35; // rdi int *v36; // r14 int *v37; // rbx int *v38; // r12 long long v39; // r15 int v40; // ecx int *v41; // rbp bool v42; // r15 long long v43; // rax _QWORD *v44; // rbx void *v45; // rdi int v47; // edx int *v48; // rax long long v49; // rax int v50; // [rsp+4h] [rbp-ACh] int v51; // [rsp+10h] [rbp-A0h] BYREF int v52; // [rsp+14h] [rbp-9Ch] BYREF void *v53[2]; // [rsp+18h] [rbp-98h] BYREF _DWORD *v54; // [rsp+28h] [rbp-88h] int v55; // [rsp+38h] [rbp-78h] BYREF int v56; // [rsp+40h] [rbp-70h] BYREF void *v57; // [rsp+48h] [rbp-68h] int *v58; // [rsp+50h] [rbp-60h] int *v59; // [rsp+58h] [rbp-58h] long long v60; // [rsp+60h] [rbp-50h] unsigned long long v61; // [rsp+70h] [rbp-40h] v2 = *a1; v3 = a1[1]; v61 = __readfsqword(0x28u); *(_OWORD *)v53 = 0LL; v54 = 0LL; v4 = v2[1] - *v2; if ( v2 != v3 ) { v5 = 0LL; v6 = 0LL; while ( 1 ) { v7 = *v2; v8 = v2[1]; v55 = 0; if ( v7 != v8 ) break; v14 = 0LL; LABEL_13: if ( v5 == v6 ) { std::vector<int>::_M_realloc_insert<int const&>(v53, v5, &v55); v2 += 3; if ( v3 == v2 ) goto LABEL_17; } else { *v6 = _mm_cvtsi128_si32(v14); v2 += 3; v53[1] = v6 + 1; if ( v3 == v2 ) goto LABEL_17; } v6 = v53[1]; v5 = v54; } v9 = (const __m128i *)v7; v10 = ((unsigned long long)((char *)(v8 - 1) - (char *)v7) >> 2) + 1; if ( (unsigned long long)((char *)(v8 - 1) - (char *)v7) <= 8 ) { v14 = 0LL; } else { v11 = 0LL; do { v12 = _mm_loadu_si128(v9++); v11 = _mm_add_epi32(v11, v12); } while ( v9 != (const __m128i *)&v7[4 * (v10 >> 2)] ); v13 = _mm_add_epi32(v11, _mm_srli_si128(v11, 8)); v14 = _mm_add_epi32(v13, _mm_srli_si128(v13, 4)); if ( (v10 & 3) == 0 ) { LABEL_12: v55 = _mm_cvtsi128_si32(v14); goto LABEL_13; } v7 += v10 & 0xFFFFFFFFFFFFFFFCLL; } v14 = _mm_add_epi32(v14, _mm_cvtsi32_si128(*v7)); if ( v8 != v7 + 1 ) { v14 = _mm_add_epi32(v14, _mm_cvtsi32_si128(v7[1])); if ( v8 != v7 + 2 ) v14 = _mm_add_epi32(v14, _mm_cvtsi32_si128(v7[2])); } goto LABEL_12; } LABEL_17: if ( (int)v4 <= 0 ) { v51 = 0; v16 = (int *)v53[1]; v27 = 0; v19 = v54; } else { v15 = *a1; v16 = (int *)v53[1]; v17 = 0LL; v18 = (unsigned int)(v4 - 1) + 1LL; v19 = v54; v20 = 4 * v18; v21 = 3 * v18; do { v22 = v15; v23 = 0; do { v24 = *v22; v22 += 3; v23 += v24[v17 / 4]; } while ( v22 != &v15[v21] ); v55 = v23; if ( v16 == v19 ) { std::vector<int>::_M_realloc_insert<int const&>(v53, v16, &v55); v15 = *a1; v16 = (int *)v53[1]; v19 = v54; } else { *v16++ = v23; v53[1] = v16; } v17 += 4LL; } while ( v20 != v17 ); v25 = v15; v26 = 0LL; v27 = 0; do { v28 = *v25; v25 += 3; v27 += v28[v26 / 4]; v26 += 4LL; } while ( v26 != v20 ); v51 = v27; } if ( v16 == v19 ) { std::vector<int>::_M_realloc_insert<int const&>(v53, v16, &v51); v29 = (int *)v53[1]; v19 = v54; v52 = 0; v30 = v4 - 1; if ( (int)v4 - 1 >= 0 ) { LABEL_29: v31 = (long long *)&(*a1)[3 * (int)v4 - 3]; v32 = (int)v4 - (unsigned long long)v30; v33 = 4LL * (int)v30; v34 = 0; do { v35 = *v31; v31 -= 3; v34 += *(_DWORD *)(v35 + v33); v33 -= 4LL; } while ( v33 != 4 * v32 - 8 ); v52 = v34; goto LABEL_32; } } else { *v16 = v27; v29 = v16 + 1; v53[1] = v16 + 1; v52 = 0; v30 = v4 - 1; if ( (int)v4 - 1 >= 0 ) goto LABEL_29; } v34 = 0; LABEL_32: if ( v29 == v19 ) { std::vector<int>::_M_realloc_insert<int const&>(v53, v29, &v52); v37 = (int *)v53[1]; v36 = (int *)v53[0]; v56 = 0; v57 = 0LL; v58 = &v56; v59 = &v56; v60 = 0LL; if ( v53[0] == v53[1] ) { LODWORD(v41) = 0; goto LABEL_42; } } else { v36 = (int *)v53[0]; v37 = v29 + 1; *v29 = v34; v53[1] = v29 + 1; v56 = 0; v57 = 0LL; v58 = &v56; v59 = &v56; v60 = 0LL; if ( v29 + 1 == v36 ) { LODWORD(v41) = 0; LABEL_58: operator delete(v36, (char *)v54 - (char *)v36); return (unsigned int)v41; } } v38 = v36; v39 = 0LL; do { v40 = *v38; if ( v39 ) { v41 = v59; if ( v40 > v59[8] ) { LABEL_37: v42 = 1; if ( v41 != &v56 ) goto LABEL_53; goto LABEL_38; } } v41 = (int *)v57; if ( !v57 ) { v41 = &v56; if ( v58 == &v56 ) { v42 = 1; goto LABEL_38; } goto LABEL_60; } while ( 1 ) { v47 = v41[8]; v48 = (int *)*((_QWORD *)v41 + 3); if ( v40 < v47 ) v48 = (int *)*((_QWORD *)v41 + 2); if ( !v48 ) break; v41 = v48; } if ( v40 < v47 ) { if ( v58 == v41 ) goto LABEL_37; LABEL_60: v50 = *v38; v49 = std::_Rb_tree_decrement(v41); v40 = v50; v47 = *(_DWORD *)(v49 + 32); } if ( v47 < v40 ) { v42 = 1; if ( v41 != &v56 ) LABEL_53: v42 = v40 < v41[8]; LABEL_38: v43 = operator new(0x28uLL); *(_DWORD *)(v43 + 32) = *v38; std::_Rb_tree_insert_and_rebalance(v42, v43, v41, &v56); v39 = ++v60; } ++v38; } while ( v37 != v38 ); v44 = v57; LOBYTE(v41) = v39 == 1; if ( v57 ) { do { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(v44[3]); v45 = v44; v44 = (_QWORD *)v44[2]; operator delete(v45, 0x28uLL); } while ( v44 ); } LABEL_42: if ( v36 ) goto LABEL_58; return (unsigned int)v41; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 MOV R14,RDI PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x88 MOV RBX,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x78],RAX XOR EAX,EAX MOVAPS xmmword ptr [RSP + 0x20],XMM0 MOV qword ptr [RSP + 0x30],0x0 MOV R12,qword ptr [RBX + 0x8] SUB R12,qword ptr [RBX] SAR R12,0x2 CMP RBX,RBP JZ 0x00101cd0 XOR EDI,EDI XOR R8D,R8D LEA R13,[RSP + 0x40] NOP LAB_00101bc0: MOV RDX,qword ptr [RBX] MOV R9,qword ptr [RBX + 0x8] MOV dword ptr [RSP + 0x40],0x0 CMP RDX,R9 JZ 0x00101f70 LEA RCX,[R9 + -0x4] MOV RAX,RDX SUB RCX,RDX MOV RSI,RCX SHR RSI,0x2 ADD RSI,0x1 CMP RCX,0x8 JBE 0x00101f79 MOV RCX,RSI PXOR XMM0,XMM0 SHR RCX,0x2 SHL RCX,0x4 ADD RCX,RDX NOP dword ptr [RAX] LAB_00101c10: MOVDQU XMM2,xmmword ptr [RAX] ADD RAX,0x10 PADDD XMM0,XMM2 CMP RAX,RCX JNZ 0x00101c10 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x8 PADDD XMM0,XMM1 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x4 PADDD XMM0,XMM1 TEST SIL,0x3 JZ 0x00101c75 AND RSI,-0x4 LEA RDX,[RDX + RSI*0x4] LAB_00101c49: MOVD XMM1,dword ptr [RDX] LEA RAX,[RDX + 0x4] PADDD XMM0,XMM1 CMP R9,RAX JZ 0x00101c75 MOVD XMM1,dword ptr [RDX + 0x4] LEA RAX,[RDX + 0x8] PADDD XMM0,XMM1 CMP R9,RAX JZ 0x00101c75 MOVD XMM1,dword ptr [RDX + 0x8] PADDD XMM0,XMM1 LAB_00101c75: MOVD dword ptr [RSP + 0x40],XMM0 LAB_00101c7b: CMP RDI,R8 JZ 0x00101cb0 MOVD dword ptr [R8],XMM0 ADD RBX,0x18 ADD R8,0x4 MOV qword ptr [RSP + 0x28],R8 CMP RBP,RBX JZ 0x00101cd0 LAB_00101c97: MOV R8,qword ptr [RSP + 0x28] MOV RDI,qword ptr [RSP + 0x30] JMP 0x00101bc0 LAB_00101cb0: LEA R15,[RSP + 0x20] MOV RSI,RDI MOV RDX,R13 MOV RDI,R15 LAB_00101cbe: CALL 0x00102150 ADD RBX,0x18 CMP RBP,RBX JNZ 0x00101c97 NOP dword ptr [RAX] LAB_00101cd0: TEST R12D,R12D JLE 0x00102064 LEA EAX,[R12 + -0x1] MOV R8,qword ptr [R14] MOV RDI,qword ptr [RSP + 0x28] XOR EBX,EBX ADD RAX,0x1 MOV R9,qword ptr [RSP + 0x30] LEA R13,[RAX + RAX*0x2] LEA RBP,[RAX*0x4] SHL R13,0x3 NOP dword ptr [RAX] LAB_00101d08: MOV RAX,R8 LEA RSI,[R13 + R8*0x1] XOR EDX,EDX NOP word ptr [RAX + RAX*0x1] LAB_00101d18: MOV RCX,qword ptr [RAX] ADD RAX,0x18 ADD EDX,dword ptr [RCX + RBX*0x1] CMP RAX,RSI JNZ 0x00101d18 MOV dword ptr [RSP + 0x40],EDX CMP RDI,R9 JZ 0x00101f48 MOV dword ptr [RDI],EDX ADD RDI,0x4 MOV qword ptr [RSP + 0x28],RDI LAB_00101d3f: ADD RBX,0x4 CMP RBP,RBX JNZ 0x00101d08 MOV RAX,R8 XOR EDX,EDX XOR ECX,ECX NOP LAB_00101d50: MOV RSI,qword ptr [RAX] ADD RAX,0x18 ADD ECX,dword ptr [RSI + RDX*0x1] ADD RDX,0x4 CMP RDX,RBP JNZ 0x00101d50 MOV dword ptr [RSP + 0x18],ECX LAB_00101d67: CMP RDI,R9 JZ 0x00102011 MOV dword ptr [RDI],ECX LEA RSI,[RDI + 0x4] MOV ECX,R12D MOV qword ptr [RSP + 0x28],RSI MOV dword ptr [RSP + 0x1c],0x0 SUB ECX,0x1 JS 0x00102044 LAB_00101d8f: MOV RAX,qword ptr [R14] MOVSXD R12,R12D LEA RDX,[R12 + R12*0x2] LEA RDX,[RAX + RDX*0x8 + -0x18] MOVSXD RAX,ECX MOV ECX,ECX SUB R12,RCX SHL RAX,0x2 XOR ECX,ECX LEA R8,[-0x8 + R12*0x4] NOP dword ptr [RAX] LAB_00101db8: MOV RDI,qword ptr [RDX] SUB RDX,0x18 ADD ECX,dword ptr [RDI + RAX*0x1] SUB RAX,0x4 CMP RAX,R8 JNZ 0x00101db8 MOV dword ptr [RSP + 0x1c],ECX LAB_00101dcf: CMP RSI,R9 JZ 0x00101fbc MOV R14,qword ptr [RSP + 0x20] LEA R13,[RSP + 0x48] LEA RBX,[RSI + 0x4] MOV dword ptr [RSI],ECX MOV qword ptr [RSP + 0x28],RBX MOV dword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP + 0x58],R13 MOV qword ptr [RSP + 0x60],R13 MOV qword ptr [RSP + 0x68],0x0 CMP RBX,R14 JZ 0x00101f82 LAB_00101e1a: MOV R12,R14 XOR R15D,R15D LAB_00101e20: MOV ECX,dword ptr [R12] TEST R15,R15 JZ 0x00101ef0 MOV RBP,qword ptr [RSP + 0x60] CMP ECX,dword ptr [RBP + 0x20] JLE 0x00101ef0 LAB_00101e3b: MOV R15D,0x1 CMP RBP,R13 JNZ 0x00101f36 LAB_00101e4a: MOV EDI,0x28 LAB_00101e4f: CALL 0x001011a0 MOV RSI,RAX MOV EAX,dword ptr [R12] MOVZX EDI,R15B MOV RCX,R13 MOV RDX,RBP MOV dword ptr [RSI + 0x20],EAX CALL 0x00101130 MOV RAX,qword ptr [RSP + 0x68] LEA R15,[RAX + 0x1] MOV qword ptr [RSP + 0x68],R15 LAB_00101e7b: ADD R12,0x4 CMP RBX,R12 JNZ 0x00101e20 MOV RBX,qword ptr [RSP + 0x50] CMP R15,0x1 SETZ BPL TEST RBX,RBX JZ 0x00101eb5 LAB_00101e96: MOV RDI,qword ptr [RBX + 0x18] CALL 0x00101990 MOV RDI,RBX MOV RBX,qword ptr [RBX + 0x10] MOV ESI,0x28 CALL 0x001011b0 TEST RBX,RBX JNZ 0x00101e96 LAB_00101eb5: TEST R14,R14 JNZ 0x00101f84 LAB_00101ebe: MOV RAX,qword ptr [RSP + 0x78] SUB RAX,qword ptr FS:[0x28] JNZ 0x0010207d ADD RSP,0x88 MOV EAX,EBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101ef0: MOV RBP,qword ptr [RSP + 0x50] TEST RBP,RBP JNZ 0x00101f03 JMP 0x0010204b LAB_00101f00: MOV RBP,RAX LAB_00101f03: MOV EDX,dword ptr [RBP + 0x20] MOV RAX,qword ptr [RBP + 0x18] CMP ECX,EDX CMOVL RAX,qword ptr [RBP + 0x10] SETL SIL TEST RAX,RAX JNZ 0x00101f00 TEST SIL,SIL JNZ 0x00101f99 LAB_00101f1f: CMP EDX,ECX JGE 0x00101e7b MOV R15D,0x1 CMP RBP,R13 JZ 0x00101e4a LAB_00101f36: CMP ECX,dword ptr [RBP + 0x20] SETL R15B JMP 0x00101e4a LAB_00101f48: LEA R15,[RSP + 0x20] MOV RSI,RDI LEA RDX,[RSP + 0x40] MOV RDI,R15 LAB_00101f58: CALL 0x00102150 MOV R8,qword ptr [R14] MOV RDI,qword ptr [RSP + 0x28] MOV R9,qword ptr [RSP + 0x30] JMP 0x00101d3f LAB_00101f70: PXOR XMM0,XMM0 JMP 0x00101c7b LAB_00101f79: PXOR XMM0,XMM0 JMP 0x00101c49 LAB_00101f82: XOR EBP,EBP LAB_00101f84: MOV RSI,qword ptr [RSP + 0x30] MOV RDI,R14 SUB RSI,R14 CALL 0x001011b0 JMP 0x00101ebe LAB_00101f99: CMP qword ptr [RSP + 0x58],RBP JZ 0x00101e3b LAB_00101fa4: MOV RDI,RBP MOV dword ptr [RSP + 0xc],ECX CALL 0x001011c0 MOV ECX,dword ptr [RSP + 0xc] MOV EDX,dword ptr [RAX + 0x20] JMP 0x00101f1f LAB_00101fbc: LEA R15,[RSP + 0x20] LEA RDX,[RSP + 0x1c] MOV RDI,R15 CALL 0x00102150 MOV RBX,qword ptr [RSP + 0x28] MOV R14,qword ptr [RSP + 0x20] LEA R13,[RSP + 0x48] MOV dword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV qword ptr [RSP + 0x58],R13 MOV qword ptr [RSP + 0x60],R13 MOV qword ptr [RSP + 0x68],0x0 CMP R14,RBX JNZ 0x00101e1a XOR EBP,EBP JMP 0x00101eb5 LAB_00102011: LEA R15,[RSP + 0x20] MOV RSI,RDI LEA RDX,[RSP + 0x18] MOV RDI,R15 CALL 0x00102150 MOV ECX,R12D MOV RSI,qword ptr [RSP + 0x28] MOV R9,qword ptr [RSP + 0x30] MOV dword ptr [RSP + 0x1c],0x0 SUB ECX,0x1 JNS 0x00101d8f LAB_00102044: XOR ECX,ECX JMP 0x00101dcf LAB_0010204b: MOV RBP,R13 CMP qword ptr [RSP + 0x58],R13 JNZ 0x00101fa4 MOV R15D,0x1 JMP 0x00101e4a LAB_00102064: MOV dword ptr [RSP + 0x18],0x0 MOV RDI,qword ptr [RSP + 0x28] XOR ECX,ECX MOV R9,qword ptr [RSP + 0x30] JMP 0x00101d67 LAB_0010207d: CALL 0x001011d0
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ ulong func0(vector *param_1) { int *piVar1; long lVar2; int iVar3; int *piVar4; int *piVar5; int *piVar6; int *piVar7; long lVar8; long *plVar9; long *plVar10; long lVar11; _Rb_tree_node_base *p_Var12; ulong uVar13; int *piVar14; long lVar15; _Rb_tree_node_base *p_Var16; ulong uVar17; bool bVar18; long in_FS_OFFSET; int iVar19; int iVar20; int iVar21; int iVar22; int local_a0; int local_9c; int *local_98; int *piStack_90; int *local_88; int local_78 [2]; int4 local_70 [2]; _Rb_tree_node_base *local_68; _Rb_tree_node_base *local_60; _Rb_tree_node_base *local_58; long local_50; long local_40; plVar10 = *(long **)param_1; plVar9 = *(long **)(param_1 + 8); local_40 = *(long *)(in_FS_OFFSET + 0x28); local_98 = (int *)0x0; piStack_90 = (int *)0x0; local_88 = (int *)0x0; lVar11 = plVar10[1]; lVar8 = *plVar10; if (plVar10 != plVar9) { do { piVar14 = (int *)*plVar10; piVar1 = (int *)plVar10[1]; local_78[0] = 0; if (piVar14 != piVar1) { uVar13 = (long)piVar1 + (-4 - (long)piVar14); uVar17 = (uVar13 >> 2) + 1; if (uVar13 < 9) { local_78[0] = 0; } else { iVar19 = 0; iVar20 = 0; iVar21 = 0; iVar22 = 0; piVar7 = piVar14; do { iVar3 = *piVar7; piVar4 = piVar7 + 1; piVar5 = piVar7 + 2; piVar6 = piVar7 + 3; piVar7 = piVar7 + 4; iVar19 = iVar19 + iVar3; iVar20 = iVar20 + *piVar4; iVar21 = iVar21 + *piVar5; iVar22 = iVar22 + *piVar6; } while (piVar7 != piVar14 + (uVar17 & 0xfffffffffffffffc)); local_78[0] = iVar19 + iVar21 + iVar20 + iVar22; if ((uVar17 & 3) == 0) goto LAB_00101c7b; piVar14 = piVar14 + (uVar17 & 0xfffffffffffffffc); } local_78[0] = local_78[0] + *piVar14; if ((piVar1 != piVar14 + 1) && (local_78[0] = local_78[0] + piVar14[1], piVar1 != piVar14 + 2)) { local_78[0] = local_78[0] + piVar14[2]; } } LAB_00101c7b: if (local_88 == piStack_90) { /* try { // try from 00101cbe to 00101cc2 has its CatchHandler @ 0010208e */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)local_88,local_78 ); } else { *piStack_90 = local_78[0]; piStack_90 = piStack_90 + 1; } if (plVar9 == plVar10 + 3) break; plVar10 = plVar10 + 3; } while( true ); } iVar19 = (int)(lVar11 - lVar8 >> 2); piVar14 = local_88; if (iVar19 < 1) { local_a0 = 0; } else { plVar10 = *(long **)param_1; lVar15 = 0; lVar8 = (ulong)(iVar19 - 1) + 1; lVar11 = lVar8 * 4; do { local_78[0] = 0; plVar9 = plVar10; do { lVar2 = *plVar9; plVar9 = plVar9 + 3; local_78[0] = local_78[0] + *(int *)(lVar2 + lVar15); } while (plVar9 != plVar10 + lVar8 * 3); if (piStack_90 == piVar14) { /* try { // try from 00101f58 to 00102025 has its CatchHandler @ 0010208e */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)piStack_90, local_78); plVar10 = *(long **)param_1; piVar14 = local_88; } else { *piStack_90 = local_78[0]; piStack_90 = piStack_90 + 1; } lVar15 = lVar15 + 4; } while (lVar11 - lVar15 != 0); lVar8 = 0; local_a0 = 0; do { lVar15 = *plVar10; plVar10 = plVar10 + 3; local_a0 = local_a0 + *(int *)(lVar15 + lVar8); lVar8 = lVar8 + 4; } while (lVar8 != lVar11); } if (piStack_90 == piVar14) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)piStack_90,&local_a0) ; piVar14 = local_88; if (iVar19 + -1 < 0) goto LAB_00102044; LAB_00101d8f: plVar10 = (long *)(*(long *)param_1 + -0x18 + (long)iVar19 * 0x18); lVar11 = (long)(int)(iVar19 - 1U) << 2; local_9c = 0; do { lVar8 = *plVar10; plVar10 = plVar10 + -3; local_9c = local_9c + *(int *)(lVar8 + lVar11); lVar11 = lVar11 + -4; } while (lVar11 != ((long)iVar19 - (ulong)(iVar19 - 1U)) * 4 + -8); } else { *piStack_90 = local_a0; piStack_90 = piStack_90 + 1; if (-1 < iVar19 + -1) goto LAB_00101d8f; LAB_00102044: local_9c = 0; } if (piStack_90 == piVar14) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_98,(__normal_iterator)piStack_90,&local_9c) ; local_60 = (_Rb_tree_node_base *)local_70; local_70[0] = 0; local_68 = (_Rb_tree_node_base *)0x0; local_50 = 0; if (local_98 != piStack_90) goto LAB_00101e1a; uVar13 = 0; piVar14 = local_98; local_58 = local_60; LAB_00101eb5: if (piVar14 == (int *)0x0) goto LAB_00101ebe; } else { local_60 = (_Rb_tree_node_base *)local_70; piVar14 = piStack_90 + 1; *piStack_90 = local_9c; local_70[0] = 0; local_68 = (_Rb_tree_node_base *)0x0; local_50 = 0; piStack_90 = piVar14; if (piVar14 != local_98) { LAB_00101e1a: piVar1 = piStack_90; piVar14 = local_98; local_50 = 0; local_68 = (_Rb_tree_node_base *)0x0; local_70[0] = 0; lVar11 = 0; piVar7 = local_98; local_60 = (_Rb_tree_node_base *)local_70; local_58 = (_Rb_tree_node_base *)local_70; do { iVar19 = *piVar7; if ((lVar11 == 0) || (p_Var16 = local_58, iVar19 <= *(int *)(local_58 + 0x20))) { p_Var12 = local_68; if (local_68 != (_Rb_tree_node_base *)0x0) { do { p_Var16 = p_Var12; iVar20 = *(int *)(p_Var16 + 0x20); p_Var12 = *(_Rb_tree_node_base **)(p_Var16 + 0x18); if (iVar19 < iVar20) { p_Var12 = *(_Rb_tree_node_base **)(p_Var16 + 0x10); } } while (p_Var12 != (_Rb_tree_node_base *)0x0); if (iVar20 <= iVar19) goto LAB_00101f1f; if (local_60 != p_Var16) goto LAB_00101fa4; goto LAB_00101e3b; } p_Var16 = (_Rb_tree_node_base *)local_70; if (local_60 == (_Rb_tree_node_base *)local_70) { bVar18 = true; goto LAB_00101e4a; } LAB_00101fa4: lVar8 = std::_Rb_tree_decrement(p_Var16); iVar20 = *(int *)(lVar8 + 0x20); LAB_00101f1f: if (iVar20 < iVar19) { bVar18 = true; if (p_Var16 == (_Rb_tree_node_base *)local_70) goto LAB_00101e4a; goto LAB_00101f36; } } else { LAB_00101e3b: bVar18 = true; if (p_Var16 != (_Rb_tree_node_base *)local_70) { LAB_00101f36: bVar18 = iVar19 < *(int *)(p_Var16 + 0x20); } LAB_00101e4a: /* try { // try from 00101e4f to 00101e53 has its CatchHandler @ 00102082 */ p_Var12 = (_Rb_tree_node_base *)operator_new(0x28); *(int *)(p_Var12 + 0x20) = *piVar7; std::_Rb_tree_insert_and_rebalance(bVar18,p_Var12,p_Var16,(_Rb_tree_node_base *)local_70); lVar11 = local_50 + 1; local_50 = lVar11; } piVar7 = piVar7 + 1; } while (piVar1 != piVar7); uVar13 = CONCAT71((int7)((ulong)p_Var16 >> 8),lVar11 == 1); p_Var16 = local_68; while (p_Var16 != (_Rb_tree_node_base *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)(p_Var16 + 0x18)); p_Var12 = *(_Rb_tree_node_base **)(p_Var16 + 0x10); operator_delete(p_Var16,0x28); p_Var16 = p_Var12; } goto LAB_00101eb5; } uVar13 = 0; piVar14 = local_98; local_58 = local_60; } operator_delete(piVar14,(long)local_88 - (long)piVar14); LAB_00101ebe: if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar13 & 0xffffffff; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
516
func0
#include <iostream> #include <vector> #include <unordered_map> #include <cassert>
std::pair<int, int> func0(const std::vector<int>& nums) { std::unordered_map<int, int> dict; for (int num : nums) { ++dict[num]; } std::pair<int, int> result; int max_count = 0; for (int num : nums) { if (dict[num] > max_count) { max_count = dict[num]; result = {num, max_count}; } } return result; }
int main() { // Using assertions with conditionals std::pair<int, int> result1 = func0({2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2}); assert(result1.first == 2 && result1.second == 5); std::pair<int, int> result2 = func0({2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,16,18}); assert(result2.first == 8 && result2.second == 2); std::pair<int, int> result3 = func0({10,20,20,30,40,90,80,50,30,20,50,10}); assert(result3.first == 20 && result3.second == 3); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x98,%rsp mov %rdi,-0x98(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax lea -0x50(%rbp),%rax mov %rax,%rdi callq 1c1c <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1Ev> mov -0x98(%rbp),%rax mov %rax,-0x70(%rbp) mov -0x70(%rbp),%rax mov %rax,%rdi callq 1ce6 <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x60(%rbp) mov -0x70(%rbp),%rax mov %rax,%rdi callq 1d3e <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x58(%rbp) lea -0x58(%rbp),%rdx lea -0x60(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1d96 <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 13b6 <_Z5func0RKSt6vectorIiSaIiEE+0xad> lea -0x60(%rbp),%rax mov %rax,%rdi callq 1dfa <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0x78(%rbp) lea -0x78(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1e10 <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_> mov (%rax),%edx add $0x1,%edx mov %edx,(%rax) lea -0x60(%rbp),%rax mov %rax,%rdi callq 1dd6 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmp 1366 <_Z5func0RKSt6vectorIiSaIiEE+0x5d> movq $0x0,-0x60(%rbp) movl $0x0,-0x88(%rbp) mov -0x98(%rbp),%rax mov %rax,-0x68(%rbp) mov -0x68(%rbp),%rax mov %rax,%rdi callq 1ce6 <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x80(%rbp) mov -0x68(%rbp),%rax mov %rax,%rdi callq 1d3e <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x78(%rbp) lea -0x78(%rbp),%rdx lea -0x80(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1d96 <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 14a8 <_Z5func0RKSt6vectorIiSaIiEE+0x19f> lea -0x80(%rbp),%rax mov %rax,%rdi callq 1dfa <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0x84(%rbp) lea -0x84(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1e10 <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_> mov (%rax),%edx mov -0x88(%rbp),%eax cmp %eax,%edx setg %al test %al,%al je 1497 <_Z5func0RKSt6vectorIiSaIiEE+0x18e> lea -0x84(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1e10 <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_> mov (%rax),%eax mov %eax,-0x88(%rbp) lea -0x88(%rbp),%rdx lea -0x84(%rbp),%rcx lea -0x58(%rbp),%rax mov %rcx,%rsi mov %rax,%rdi callq 1e3a <_ZNSt4pairIiiEC1IRiS2_Lb1EEEOT_OT0_> lea -0x58(%rbp),%rdx lea -0x60(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1e7e <_ZNSt4pairIiiEaSEOS0_> lea -0x80(%rbp),%rax mov %rax,%rdi callq 1dd6 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmpq 13f3 <_Z5func0RKSt6vectorIiSaIiEE+0xea> mov -0x60(%rbp),%rbx lea -0x50(%rbp),%rax mov %rax,%rdi callq 1c3c <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEED1Ev> mov %rbx,%rax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 14ef <_Z5func0RKSt6vectorIiSaIiEE+0x1e6> jmp 14ea <_Z5func0RKSt6vectorIiSaIiEE+0x1e1> endbr64 mov %rax,%rbx lea -0x50(%rbp),%rax mov %rax,%rdi callq 1c3c <_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1210 <_Unwind_Resume@plt> callq 11b0 <__stack_chk_fail@plt> add $0x98,%rsp pop %rbx pop %rbp retq
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 98h mov [rbp+var_98], rdi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax lea rax, [rbp+var_50] mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC2Ev; std::unordered_map<int,int>::unordered_map(void) mov rax, [rbp+var_98] mov [rbp+var_70], rax mov rax, [rbp+var_70] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_60], rax mov rax, [rbp+var_70] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_58], rax jmp short loc_137F loc_1348: lea rax, [rbp+var_60] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov dword ptr [rbp+var_78], eax lea rdx, [rbp+var_78] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_; std::unordered_map<int,int>::operator[](int const&) mov edx, [rax] add edx, 1 mov [rax], edx lea rax, [rbp+var_60] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_137F: lea rdx, [rbp+var_58] lea rax, [rbp+var_60] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz short loc_1348 mov [rbp+var_60], 0 mov [rbp+var_88], 0 mov rax, [rbp+var_98] mov [rbp+var_68], rax mov rax, [rbp+var_68] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_80], rax mov rax, [rbp+var_68] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_78], rax jmp loc_146D loc_13D8: lea rax, [rbp+var_80] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov [rbp+var_84], eax lea rdx, [rbp+var_84] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_; std::unordered_map<int,int>::operator[](int const&) mov edx, [rax] mov eax, [rbp+var_88] cmp edx, eax setnle al test al, al jz short loc_1461 lea rdx, [rbp+var_84] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEixERS5_; std::unordered_map<int,int>::operator[](int const&) mov eax, [rax] mov [rbp+var_88], eax lea rdx, [rbp+var_88] lea rcx, [rbp+var_84] lea rax, [rbp+var_58] mov rsi, rcx mov rdi, rax call _ZNSt4pairIiiEC2IRiS2_Lb1EEEOT_OT0_; std::pair<int,int>::pair<int &,int &,true>(int &,int &) lea rdx, [rbp+var_58] lea rax, [rbp+var_60] mov rsi, rdx mov rdi, rax call _ZNSt4pairIiiEaSEOS0_; std::pair<int,int>::operator=(std::pair<int,int>&&) loc_1461: lea rax, [rbp+var_80] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_146D: lea rdx, [rbp+var_78] lea rax, [rbp+var_80] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz loc_13D8 mov rbx, [rbp+var_60] lea rax, [rbp+var_50] mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEED2Ev; std::unordered_map<int,int>::~unordered_map() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14E3 jmp short loc_14DE endbr64 mov rbx, rax lea rax, [rbp+var_50] mov rdi, rax call _ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEED2Ev; std::unordered_map<int,int>::~unordered_map() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14D6 call ___stack_chk_fail loc_14D6: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_14DE: call ___stack_chk_fail loc_14E3: mov rbx, [rbp+var_8] leave retn
long long func0(long long a1) { _DWORD *v1; // rax _DWORD *v2; // rax long long v3; // rbx int v5; // [rsp+18h] [rbp-88h] BYREF int v6; // [rsp+1Ch] [rbp-84h] BYREF long long v7; // [rsp+20h] [rbp-80h] BYREF _QWORD v8[2]; // [rsp+28h] [rbp-78h] BYREF long long v9; // [rsp+38h] [rbp-68h] long long v10; // [rsp+40h] [rbp-60h] BYREF long long v11; // [rsp+48h] [rbp-58h] BYREF _BYTE v12[56]; // [rsp+50h] [rbp-50h] BYREF unsigned long long v13; // [rsp+88h] [rbp-18h] v13 = __readfsqword(0x28u); std::unordered_map<int,int>::unordered_map(v12); v8[1] = a1; v10 = std::vector<int>::begin(a1); v11 = std::vector<int>::end(a1); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(&v10, &v11) ) { LODWORD(v8[0]) = *(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(&v10); v1 = (_DWORD *)std::unordered_map<int,int>::operator[](v12, v8); ++*v1; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(&v10); } v10 = 0LL; v5 = 0; v9 = a1; v7 = std::vector<int>::begin(a1); v8[0] = std::vector<int>::end(v9); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(&v7, v8) ) { v6 = *(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(&v7); v2 = (_DWORD *)std::unordered_map<int,int>::operator[](v12, &v6); if ( *v2 > v5 ) { v5 = *(_DWORD *)std::unordered_map<int,int>::operator[](v12, &v6); std::pair<int,int>::pair<int &,int &,true>(&v11, &v6, &v5); std::pair<int,int>::operator=(&v10, &v11); } __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(&v7); } v3 = v10; std::unordered_map<int,int>::~unordered_map(v12); return v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x98 MOV qword ptr [RBP + -0x98],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00101c28 MOV RAX,qword ptr [RBP + -0x98] MOV qword ptr [RBP + -0x70],RAX MOV RAX,qword ptr [RBP + -0x70] MOV RDI,RAX CALL 0x00101ce2 MOV qword ptr [RBP + -0x60],RAX MOV RAX,qword ptr [RBP + -0x70] MOV RDI,RAX CALL 0x00101d2e MOV qword ptr [RBP + -0x58],RAX JMP 0x0010137f LAB_00101348: LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x00101de2 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x78],EAX LEA RDX,[RBP + -0x78] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX LAB_00101367: CALL 0x00101df8 MOV EDX,dword ptr [RAX] ADD EDX,0x1 MOV dword ptr [RAX],EDX LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x00101dbe LAB_0010137f: LEA RDX,[RBP + -0x58] LEA RAX,[RBP + -0x60] MOV RSI,RDX MOV RDI,RAX CALL 0x00101d7e TEST AL,AL JNZ 0x00101348 MOV qword ptr [RBP + -0x60],0x0 MOV dword ptr [RBP + -0x88],0x0 MOV RAX,qword ptr [RBP + -0x98] MOV qword ptr [RBP + -0x68],RAX MOV RAX,qword ptr [RBP + -0x68] MOV RDI,RAX CALL 0x00101ce2 MOV qword ptr [RBP + -0x80],RAX MOV RAX,qword ptr [RBP + -0x68] MOV RDI,RAX CALL 0x00101d2e MOV qword ptr [RBP + -0x78],RAX JMP 0x0010146d LAB_001013d8: LEA RAX,[RBP + -0x80] MOV RDI,RAX CALL 0x00101de2 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x84],EAX LEA RDX,[RBP + -0x84] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x00101df8 MOV EDX,dword ptr [RAX] MOV EAX,dword ptr [RBP + -0x88] CMP EDX,EAX SETG AL TEST AL,AL JZ 0x00101461 LEA RDX,[RBP + -0x84] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x00101df8 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x88],EAX LEA RDX,[RBP + -0x88] LEA RCX,[RBP + -0x84] LEA RAX,[RBP + -0x58] MOV RSI,RCX MOV RDI,RAX CALL 0x00101e22 LEA RDX,[RBP + -0x58] LEA RAX,[RBP + -0x60] MOV RSI,RDX MOV RDI,RAX CALL 0x00101e66 LAB_00101461: LEA RAX,[RBP + -0x80] MOV RDI,RAX CALL 0x00101dbe LAB_0010146d: LEA RDX,[RBP + -0x78] LEA RAX,[RBP + -0x80] MOV RSI,RDX MOV RDI,RAX CALL 0x00101d7e TEST AL,AL JNZ 0x001013d8 MOV RBX,qword ptr [RBP + -0x60] LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00101c48 MOV RAX,RBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x001014e3 JMP 0x001014de LAB_001014de: CALL 0x001011a0 LAB_001014e3: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<int, std::allocator<int> > const&) */ int8 func0(vector *param_1) { int8 uVar1; bool bVar2; int4 *puVar3; int *piVar4; long in_FS_OFFSET; int local_90; int local_8c; int8 local_88; int8 local_80; vector<int,std::allocator<int>> *local_78; vector<int,std::allocator<int>> *local_70; int8 local_68; int8 local_60; unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> local_58 [56]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); std:: unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> ::unordered_map(local_58); local_78 = (vector<int,std::allocator<int>> *)param_1; local_68 = std::vector<int,std::allocator<int>>::begin((vector<int,std::allocator<int>> *)param_1) ; local_60 = std::vector<int,std::allocator<int>>::end(local_78); while( true ) { bVar2 = operator!=((__normal_iterator *)&local_68,(__normal_iterator *)&local_60); if (!bVar2) break; puVar3 = (int4 *) __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *) &local_68); local_80 = CONCAT44(local_80._4_4_,*puVar3); /* try { // try from 00101367 to 00101428 has its CatchHandler @ 001014ac */ piVar4 = (int *)std:: unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> ::operator[](local_58,(int *)&local_80); *piVar4 = *piVar4 + 1; __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_68); } local_68 = 0; local_90 = 0; local_70 = (vector<int,std::allocator<int>> *)param_1; local_88 = std::vector<int,std::allocator<int>>::begin((vector<int,std::allocator<int>> *)param_1) ; local_80 = std::vector<int,std::allocator<int>>::end(local_70); while( true ) { bVar2 = operator!=((__normal_iterator *)&local_88,(__normal_iterator *)&local_80); uVar1 = local_68; if (!bVar2) break; piVar4 = (int *)__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> * )&local_88); local_8c = *piVar4; piVar4 = (int *)std:: unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> ::operator[](local_58,&local_8c); if (local_90 < *piVar4) { piVar4 = (int *)std:: unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> ::operator[](local_58,&local_8c); local_90 = *piVar4; std::pair<int,int>::pair<int&,int&,true>((pair<int,int> *)&local_60,&local_8c,&local_90); std::pair<int,int>::operator=((pair<int,int> *)&local_68,(pair *)&local_60); } __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_88); } std:: unordered_map<int,int,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<int_const,int>>> ::~unordered_map(local_58); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar1; }
517
func0
#include <iostream> #include <vector> #include <unordered_map> #include <cassert>
std::pair<int, int> func0(const std::vector<int>& nums) { std::unordered_map<int, int> dict; for (int num : nums) { ++dict[num]; } std::pair<int, int> result; int max_count = 0; for (int num : nums) { if (dict[num] > max_count) { max_count = dict[num]; result = {num, max_count}; } } return result; }
int main() { // Using assertions with conditionals std::pair<int, int> result1 = func0({2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2}); assert(result1.first == 2 && result1.second == 5); std::pair<int, int> result2 = func0({2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,16,18}); assert(result2.first == 8 && result2.second == 2); std::pair<int, int> result3 = func0({10,20,20,30,40,90,80,50,30,20,50,10}); assert(result3.first == 20 && result3.second == 3); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %rdi,%r13 mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax lea 0x40(%rsp),%rax mov %rax,0x10(%rsp) movq $0x1,0x18(%rsp) movq $0x0,0x20(%rsp) movq $0x0,0x28(%rsp) movl $0x3f800000,0x30(%rsp) movq $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) mov (%rdi),%rbx mov 0x8(%rdi),%rbp cmp %rbp,%rbx je 13a1 <_Z5func0RKSt6vectorIiSaIiEE+0x98> lea 0xc(%rsp),%r12 jmp 138c <_Z5func0RKSt6vectorIiSaIiEE+0x83> addl $0x1,(%rax) add $0x4,%rbx cmp %rbx,%rbp je 13a1 <_Z5func0RKSt6vectorIiSaIiEE+0x98> mov (%rbx),%eax mov %eax,0xc(%rsp) lea 0x10(%rsp),%rdi mov %r12,%rsi callq 1b5e <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> jmp 1380 <_Z5func0RKSt6vectorIiSaIiEE+0x77> mov 0x0(%r13),%rbx mov 0x8(%r13),%r13 cmp %rbx,%r13 je 1401 <_Z5func0RKSt6vectorIiSaIiEE+0xf8> mov $0x0,%ebp mov $0x0,%r14d mov $0x0,%r15d lea 0xc(%rsp),%r12 jmp 13d3 <_Z5func0RKSt6vectorIiSaIiEE+0xca> cmp %ebp,(%rax) jg 13e8 <_Z5func0RKSt6vectorIiSaIiEE+0xdf> add $0x4,%rbx cmp %rbx,%r13 je 140d <_Z5func0RKSt6vectorIiSaIiEE+0x104> mov (%rbx),%eax mov %eax,0xc(%rsp) lea 0x10(%rsp),%rdi mov %r12,%rsi callq 1b5e <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> jmp 13c6 <_Z5func0RKSt6vectorIiSaIiEE+0xbd> lea 0x10(%rsp),%rdi mov %r12,%rsi callq 1b5e <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> mov (%rax),%ebp mov 0xc(%rsp),%r14d mov %ebp,%r15d jmp 13ca <_Z5func0RKSt6vectorIiSaIiEE+0xc1> mov $0x0,%r14d mov $0x0,%r15d shl $0x20,%r15 mov %r14d,%r14d or %r14,%r15 lea 0x10(%rsp),%rdi callq 1808 <_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 145c <_Z5func0RKSt6vectorIiSaIiEE+0x153> mov %r15,%rax add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq endbr64 mov %rax,%rbx lea 0x10(%rsp),%rdi callq 1808 <_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev> mov %rbx,%rdi callq 1210 <_Unwind_Resume@plt> callq 11c0 <__stack_chk_fail@plt>
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 68h mov r13, rdi mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax lea rax, [rsp+98h+var_48] mov [rsp+98h+var_78], rax mov [rsp+98h+var_70], 1 mov [rsp+98h+var_68], 0 mov [rsp+98h+var_60], 0 mov [rsp+98h+var_58], 3F800000h mov [rsp+98h+var_50], 0 mov [rsp+98h+var_48], 0 mov rbx, [rdi] mov rbp, [rdi+8] cmp rbp, rbx jz short loc_1381 lea r12, [rsp+98h+var_7C] jmp short loc_136C loc_1360: add dword ptr [rax], 1 add rbx, 4 cmp rbp, rbx jz short loc_1381 loc_136C: mov eax, [rbx] mov [rsp+98h+var_7C], eax lea rdi, [rsp+98h+var_78] mov rsi, r12 call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) jmp short loc_1360 loc_1381: mov rbx, [r13+0] mov r14, [r13+8] cmp r14, rbx jz short loc_13E5 mov r15d, 0 mov r12d, 0 mov [rsp+98h+var_8C], 0 lea r13, [rsp+98h+var_7C] jmp short loc_13B7 loc_13A9: cmp [rax], r12d jg short loc_13CC loc_13AE: add rbx, 4 cmp r14, rbx jz short loc_13F3 loc_13B7: mov ebp, [rbx] mov [rsp+98h+var_7C], ebp lea rdi, [rsp+98h+var_78] mov rsi, r13 call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) jmp short loc_13A9 loc_13CC: lea rdi, [rsp+98h+var_78] mov rsi, r13 call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) mov r12d, [rax] mov r15d, r12d mov [rsp+98h+var_8C], ebp jmp short loc_13AE loc_13E5: mov r15d, 0 mov [rsp+98h+var_8C], 0 loc_13F3: shl r15, 20h mov eax, [rsp+98h+var_8C] or r15, rax lea rdi, [rsp+98h+var_78] call _ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev; std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::~_Hashtable() mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1458 mov rax, r15 add rsp, 68h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbx, rax lea rdi, [rsp+arg_18] call _ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev; std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::~_Hashtable() mov rax, [rsp+arg_50] sub rax, fs:28h jz short loc_1450 call ___stack_chk_fail loc_1450: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_1458: call ___stack_chk_fail
unsigned long long func0(int **a1) { int *v1; // rbx int *v2; // rbp _DWORD *v3; // rax int *v4; // rbx int *v5; // r14 long long v6; // r15 long long v7; // r12 unsigned int v8; // ebp unsigned int v10; // [rsp+Ch] [rbp-8Ch] unsigned int v11; // [rsp+1Ch] [rbp-7Ch] BYREF _QWORD v12[4]; // [rsp+20h] [rbp-78h] BYREF int v13; // [rsp+40h] [rbp-58h] long long v14; // [rsp+48h] [rbp-50h] _QWORD v15[9]; // [rsp+50h] [rbp-48h] BYREF v15[1] = __readfsqword(0x28u); v12[0] = v15; v12[1] = 1LL; v12[2] = 0LL; v12[3] = 0LL; v13 = 1065353216; v14 = 0LL; v15[0] = 0LL; v1 = *a1; v2 = a1[1]; if ( v2 != *a1 ) { do { v11 = *v1; v3 = (_DWORD *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v12, &v11); ++*v3; ++v1; } while ( v2 != v1 ); } v4 = *a1; v5 = a1[1]; if ( v5 == *a1 ) { v6 = 0LL; v10 = 0; } else { v6 = 0LL; LODWORD(v7) = 0; v10 = 0; do { v8 = *v4; v11 = *v4; if ( *(_DWORD *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v12, &v11) > (int)v7 ) { v7 = *(unsigned int *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v12, &v11); v6 = v7; v10 = v8; } ++v4; } while ( v5 != v4 ); } std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::~_Hashtable(v12); return v10 | (unsigned long long)(v6 << 32); }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x68 MOV R13,RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX LEA RAX,[RSP + 0x50] MOV qword ptr [RSP + 0x20],RAX MOV qword ptr [RSP + 0x28],0x1 MOV qword ptr [RSP + 0x30],0x0 MOV qword ptr [RSP + 0x38],0x0 MOV dword ptr [RSP + 0x40],0x3f800000 MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 MOV RBX,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] CMP RBP,RBX JZ 0x00101381 LEA R12,[RSP + 0x1c] JMP 0x0010136c LAB_00101360: ADD dword ptr [RAX],0x1 ADD RBX,0x4 CMP RBP,RBX JZ 0x00101381 LAB_0010136c: MOV EAX,dword ptr [RBX] MOV dword ptr [RSP + 0x1c],EAX LEA RDI,[RSP + 0x20] MOV RSI,R12 LAB_0010137a: CALL 0x00101a64 JMP 0x00101360 LAB_00101381: MOV RBX,qword ptr [R13] MOV R14,qword ptr [R13 + 0x8] CMP R14,RBX JZ 0x001013e5 MOV R15D,0x0 MOV R12D,0x0 MOV dword ptr [RSP + 0xc],0x0 LEA R13,[RSP + 0x1c] JMP 0x001013b7 LAB_001013a9: CMP dword ptr [RAX],R12D JG 0x001013cc LAB_001013ae: ADD RBX,0x4 CMP R14,RBX JZ 0x001013f3 LAB_001013b7: MOV EBP,dword ptr [RBX] MOV dword ptr [RSP + 0x1c],EBP LEA RDI,[RSP + 0x20] MOV RSI,R13 CALL 0x00101a64 JMP 0x001013a9 LAB_001013cc: LEA RDI,[RSP + 0x20] MOV RSI,R13 CALL 0x00101a64 MOV R12D,dword ptr [RAX] MOV R15D,R12D MOV dword ptr [RSP + 0xc],EBP JMP 0x001013ae LAB_001013e5: MOV R15D,0x0 MOV dword ptr [RSP + 0xc],0x0 LAB_001013f3: SHL R15,0x20 MOV EAX,dword ptr [RSP + 0xc] OR R15,RAX LEA RDI,[RSP + 0x20] CALL 0x001017fa MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101458 MOV RAX,R15 ADD RSP,0x68 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101458: CALL 0x001011b0
/* func0(std::vector<int, std::allocator<int> > const&) */ ulong func0(vector *param_1) { uint uVar1; uint *puVar2; int *piVar3; uint *puVar4; uint *puVar5; uint uVar6; ulong uVar7; long in_FS_OFFSET; uint local_8c; uint local_7c; int8 *local_78; int8 local_70; int8 local_68; int8 local_60; int4 local_58; int8 local_50; int8 local_48; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); local_78 = &local_48; local_70 = 1; local_68 = 0; local_60 = 0; local_58 = 0x3f800000; local_50 = 0; local_48 = 0; puVar5 = *(uint **)param_1; puVar2 = *(uint **)(param_1 + 8); if (puVar2 != puVar5) { do { local_7c = *puVar5; /* try { // try from 0010137a to 001013d8 has its CatchHandler @ 0010142a */ piVar3 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,(int *)&local_7c); *piVar3 = *piVar3 + 1; puVar5 = puVar5 + 1; } while (puVar2 != puVar5); } puVar5 = *(uint **)param_1; puVar2 = *(uint **)(param_1 + 8); if (puVar2 == puVar5) { uVar7 = 0; local_8c = 0; } else { uVar7 = 0; uVar6 = 0; local_8c = 0; do { uVar1 = *puVar5; local_7c = uVar1; piVar3 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,(int *)&local_7c); if ((int)uVar6 < *piVar3) { puVar4 = (uint *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,(int *)&local_7c); uVar6 = *puVar4; uVar7 = (ulong)uVar6; local_8c = uVar1; } puVar5 = puVar5 + 1; } while (puVar2 != puVar5); } std:: _Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> ::~_Hashtable((_Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> *)&local_78); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar7 << 0x20 | (ulong)local_8c; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
518
func0
#include <iostream> #include <vector> #include <unordered_map> #include <cassert>
std::pair<int, int> func0(const std::vector<int>& nums) { std::unordered_map<int, int> dict; for (int num : nums) { ++dict[num]; } std::pair<int, int> result; int max_count = 0; for (int num : nums) { if (dict[num] > max_count) { max_count = dict[num]; result = {num, max_count}; } } return result; }
int main() { // Using assertions with conditionals std::pair<int, int> result1 = func0({2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2}); assert(result1.first == 2 && result1.second == 5); std::pair<int, int> result2 = func0({2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,16,18}); assert(result2.first == 8 && result2.second == 2); std::pair<int, int> result3 = func0({10,20,20,30,40,90,80,50,30,20,50,10}); assert(result3.first == 20 && result3.second == 3); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r13 mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax lea 0x40(%rsp),%rax movl $0x3f800000,0x30(%rsp) mov %rax,0x10(%rsp) movq $0x1,0x18(%rsp) movq $0x0,0x20(%rsp) movq $0x0,0x28(%rsp) movq $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) cmp %r13,%rbx je 17c8 <_Z5func0RKSt6vectorIiSaIiEE+0x128> mov %rdi,%r14 lea 0xc(%rsp),%r12 lea 0x10(%rsp),%rbp xchg %ax,%ax mov (%rbx),%eax mov %r12,%rsi mov %rbp,%rdi mov %eax,0xc(%rsp) callq 1a70 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> add $0x4,%rbx addl $0x1,(%rax) cmp %rbx,%r13 jne 1720 <_Z5func0RKSt6vectorIiSaIiEE+0x80> mov (%r14),%rbx mov 0x8(%r14),%r14 xor %r13d,%r13d xor %r15d,%r15d cmp %r14,%rbx jne 1761 <_Z5func0RKSt6vectorIiSaIiEE+0xc1> jmp 1793 <_Z5func0RKSt6vectorIiSaIiEE+0xf3> nopl 0x0(%rax) add $0x4,%rbx cmp %rbx,%r14 je 1793 <_Z5func0RKSt6vectorIiSaIiEE+0xf3> mov (%rbx),%eax mov %r12,%rsi mov %rbp,%rdi mov %eax,0xc(%rsp) callq 1a70 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> cmp %r13d,(%rax) jle 1758 <_Z5func0RKSt6vectorIiSaIiEE+0xb8> mov %r12,%rsi mov %rbp,%rdi callq 1a70 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> add $0x4,%rbx mov (%rax),%r13d mov 0xc(%rsp),%r15d cmp %rbx,%r14 jne 1761 <_Z5func0RKSt6vectorIiSaIiEE+0xc1> shl $0x20,%r13 mov %rbp,%rdi callq 17f0 <_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev> or %r15,%r13 mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 17d5 <_Z5func0RKSt6vectorIiSaIiEE+0x135> add $0x58,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopl 0x0(%rax) xor %r13d,%r13d xor %r15d,%r15d lea 0x10(%rsp),%rbp jmp 1793 <_Z5func0RKSt6vectorIiSaIiEE+0xf3> callq 11c0 <__stack_chk_fail@plt> endbr64 mov %rax,%r12 jmpq 1220 <_Z5func0RKSt6vectorIiSaIiEE.cold> nopw %cs:0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 68h mov rbx, [rdi] mov r14, [rdi+8] mov rax, fs:28h mov [rsp+98h+var_40], rax xor eax, eax lea rax, [rsp+98h+var_48] lea rbp, [rsp+98h+var_78] mov [rsp+98h+var_70], 1 mov [rsp+98h+var_78], rax mov [rsp+98h+var_68], 0 mov [rsp+98h+var_60], 0 mov [rsp+98h+var_58], 3F800000h mov [rsp+98h+var_50], 0 mov [rsp+98h+var_48], 0 cmp r14, rbx jz loc_16BA mov r13, rdi lea r12, [rsp+98h+var_7C] lea rbp, [rsp+98h+var_78] nop dword ptr [rax+rax+00h] loc_1608: mov eax, [rbx] mov rsi, r12 mov rdi, rbp mov [rsp+98h+var_7C], eax call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) add rbx, 4 add dword ptr [rax], 1 cmp r14, rbx jnz short loc_1608 mov r15, [r13+8] mov rbx, [r13+0] cmp r15, rbx jz loc_16BA mov [rsp+98h+var_8C], 0 xor r14d, r14d jmp short loc_1651 loc_1648: add rbx, 4 cmp r15, rbx jz short loc_1685 loc_1651: mov r13d, [rbx] mov rsi, r12 mov rdi, rbp mov [rsp+98h+var_7C], r13d call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) cmp [rax], r14d jle short loc_1648 mov rsi, r12 mov rdi, rbp call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) add rbx, 4 mov [rsp+98h+var_8C], r13d mov r14d, [rax] cmp r15, rbx jnz short loc_1651 loc_1685: mov ebx, [rsp+98h+var_8C] shl r14, 20h mov rdi, rbp or rbx, r14 call _ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev; std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::~_Hashtable() mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_16C5 add rsp, 68h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_16BA: xor eax, eax xor r14d, r14d mov [rsp+98h+var_8C], eax jmp short loc_1685 loc_16C5: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIiSaIiEE_cold; func0(std::vector<int> const&) [clone]
long long func0(int **a1) { int *v1; // rbx int *v2; // r14 _DWORD *v3; // rax int *v4; // r15 int *v5; // rbx long long v6; // r14 unsigned int v7; // r13d unsigned int v9; // [rsp+Ch] [rbp-8Ch] unsigned int v10; // [rsp+1Ch] [rbp-7Ch] BYREF _QWORD v11[4]; // [rsp+20h] [rbp-78h] BYREF int v12; // [rsp+40h] [rbp-58h] long long v13; // [rsp+48h] [rbp-50h] _QWORD v14[9]; // [rsp+50h] [rbp-48h] BYREF v1 = *a1; v2 = a1[1]; v14[1] = __readfsqword(0x28u); v11[1] = 1LL; v11[0] = v14; v11[2] = 0LL; v11[3] = 0LL; v12 = 1065353216; v13 = 0LL; v14[0] = 0LL; if ( v2 == v1 ) goto LABEL_9; do { v10 = *v1; v3 = (_DWORD *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v11, &v10); ++v1; ++*v3; } while ( v2 != v1 ); v4 = a1[1]; v5 = *a1; if ( v4 == *a1 ) { LABEL_9: v6 = 0LL; v9 = 0; } else { v9 = 0; v6 = 0LL; do { while ( 1 ) { v7 = *v5; v10 = *v5; if ( *(_DWORD *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v11, &v10) > (int)v6 ) break; if ( v4 == ++v5 ) goto LABEL_8; } ++v5; v9 = v7; v6 = *(unsigned int *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( v11, &v10); } while ( v4 != v5 ); } LABEL_8: std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::~_Hashtable(v11); return (v6 << 32) | v9; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x68 MOV RBX,qword ptr [RDI] MOV R14,qword ptr [RDI + 0x8] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RAX XOR EAX,EAX LEA RAX,[RSP + 0x50] LEA RBP,[RSP + 0x20] MOV qword ptr [RSP + 0x28],0x1 MOV qword ptr [RSP + 0x20],RAX MOV qword ptr [RSP + 0x30],0x0 MOV qword ptr [RSP + 0x38],0x0 MOV dword ptr [RSP + 0x40],0x3f800000 MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x50],0x0 CMP R14,RBX JZ 0x001016ba MOV R13,RDI LEA R12,[RSP + 0x1c] LEA RBP,[RSP + 0x20] NOP dword ptr [RAX + RAX*0x1] LAB_00101608: MOV EAX,dword ptr [RBX] MOV RSI,R12 MOV RDI,RBP MOV dword ptr [RSP + 0x1c],EAX LAB_00101614: CALL 0x001019c0 ADD RBX,0x4 ADD dword ptr [RAX],0x1 CMP R14,RBX JNZ 0x00101608 MOV R15,qword ptr [R13 + 0x8] MOV RBX,qword ptr [R13] CMP R15,RBX JZ 0x001016ba MOV dword ptr [RSP + 0xc],0x0 XOR R14D,R14D JMP 0x00101651 LAB_00101648: ADD RBX,0x4 CMP R15,RBX JZ 0x00101685 LAB_00101651: MOV R13D,dword ptr [RBX] MOV RSI,R12 MOV RDI,RBP MOV dword ptr [RSP + 0x1c],R13D CALL 0x001019c0 CMP dword ptr [RAX],R14D JLE 0x00101648 MOV RSI,R12 MOV RDI,RBP CALL 0x001019c0 ADD RBX,0x4 MOV dword ptr [RSP + 0xc],R13D MOV R14D,dword ptr [RAX] CMP R15,RBX JNZ 0x00101651 LAB_00101685: MOV EBX,dword ptr [RSP + 0xc] SHL R14,0x20 MOV RDI,RBP OR RBX,R14 CALL 0x001016e0 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x001016c5 ADD RSP,0x68 MOV RAX,RBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001016ba: XOR EAX,EAX XOR R14D,R14D MOV dword ptr [RSP + 0xc],EAX JMP 0x00101685 LAB_001016c5: CALL 0x001011b0
/* func0(std::vector<int, std::allocator<int> > const&) */ int8 func0(vector *param_1) { int iVar1; int *piVar2; int *piVar3; int *piVar4; int iVar5; long in_FS_OFFSET; int local_8c; int local_7c; int8 *local_78; int8 local_70; int8 local_68; int8 local_60; int4 local_58; int8 local_50; int8 local_48; long local_40; piVar3 = *(int **)param_1; piVar4 = *(int **)(param_1 + 8); local_40 = *(long *)(in_FS_OFFSET + 0x28); local_78 = &local_48; local_70 = 1; local_68 = 0; local_60 = 0; local_58 = 0x3f800000; local_50 = 0; local_48 = 0; if (piVar4 != piVar3) { do { local_7c = *piVar3; /* try { // try from 00101614 to 00101673 has its CatchHandler @ 001016ca */ piVar2 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,&local_7c); piVar3 = piVar3 + 1; *piVar2 = *piVar2 + 1; } while (piVar4 != piVar3); piVar3 = *(int **)(param_1 + 8); piVar4 = *(int **)param_1; if (piVar3 != piVar4) { local_8c = 0; iVar5 = 0; do { while( true ) { iVar1 = *piVar4; local_7c = iVar1; piVar2 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,&local_7c); if (*piVar2 <= iVar5) break; piVar2 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,&local_7c); piVar4 = piVar4 + 1; iVar5 = *piVar2; local_8c = iVar1; if (piVar3 == piVar4) goto LAB_00101685; } piVar4 = piVar4 + 1; } while (piVar3 != piVar4); goto LAB_00101685; } } iVar5 = 0; local_8c = 0; LAB_00101685: std:: _Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> ::~_Hashtable((_Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> *)&local_78); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return CONCAT44(iVar5,local_8c); } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
519
func0
#include <iostream> #include <vector> #include <unordered_map> #include <cassert>
std::pair<int, int> func0(const std::vector<int>& nums) { std::unordered_map<int, int> dict; for (int num : nums) { ++dict[num]; } std::pair<int, int> result; int max_count = 0; for (int num : nums) { if (dict[num] > max_count) { max_count = dict[num]; result = {num, max_count}; } } return result; }
int main() { // Using assertions with conditionals std::pair<int, int> result1 = func0({2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2}); assert(result1.first == 2 && result1.second == 5); std::pair<int, int> result2 = func0({2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,16,18}); assert(result2.first == 8 && result2.second == 2); std::pair<int, int> result3 = func0({10,20,20,30,40,90,80,50,30,20,50,10}); assert(result3.first == 20 && result3.second == 3); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x68,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r13 mov %fs:0x28,%rax mov %rax,0x58(%rsp) xor %eax,%eax lea 0x50(%rsp),%rax movl $0x3f800000,0x40(%rsp) mov %rax,0x8(%rsp) mov %rax,0x20(%rsp) movq $0x1,0x28(%rsp) movq $0x0,0x30(%rsp) movq $0x0,0x38(%rsp) movq $0x0,0x48(%rsp) movq $0x0,0x50(%rsp) cmp %r13,%rbx je 17a0 <_Z5func0RKSt6vectorIiSaIiEE+0x180> mov %rdi,%r14 lea 0x1c(%rsp),%rbp lea 0x20(%rsp),%r12 nopl 0x0(%rax,%rax,1) mov (%rbx),%eax mov %rbp,%rsi mov %r12,%rdi mov %eax,0x1c(%rsp) callq 19b0 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> add $0x4,%rbx addl $0x1,(%rax) cmp %rbx,%r13 jne 16a8 <_Z5func0RKSt6vectorIiSaIiEE+0x88> mov (%r14),%rbx mov 0x8(%r14),%r14 xor %r13d,%r13d xor %r15d,%r15d cmp %rbx,%r14 jne 16e9 <_Z5func0RKSt6vectorIiSaIiEE+0xc9> jmp 171b <_Z5func0RKSt6vectorIiSaIiEE+0xfb> nopl 0x0(%rax) add $0x4,%rbx cmp %rbx,%r14 je 171b <_Z5func0RKSt6vectorIiSaIiEE+0xfb> mov (%rbx),%eax mov %rbp,%rsi mov %r12,%rdi mov %eax,0x1c(%rsp) callq 19b0 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> cmp %r13d,(%rax) jle 16e0 <_Z5func0RKSt6vectorIiSaIiEE+0xc0> mov %rbp,%rsi mov %r12,%rdi callq 19b0 <_ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_> add $0x4,%rbx mov (%rax),%r13d mov 0x1c(%rsp),%r15d cmp %rbx,%r14 jne 16e9 <_Z5func0RKSt6vectorIiSaIiEE+0xc9> mov 0x30(%rsp),%rbx shl $0x20,%r13 or %r15,%r13 test %rbx,%rbx je 1740 <_Z5func0RKSt6vectorIiSaIiEE+0x120> nopl 0x0(%rax) mov %rbx,%rdi mov (%rbx),%rbx callq 11a0 <_ZdlPv@plt> test %rbx,%rbx jne 1730 <_Z5func0RKSt6vectorIiSaIiEE+0x110> mov 0x28(%rsp),%rax mov 0x20(%rsp),%rdi xor %esi,%esi lea 0x0(,%rax,8),%rdx callq 1160 <memset@plt> mov 0x20(%rsp),%rdi movq $0x0,0x38(%rsp) movq $0x0,0x30(%rsp) cmp 0x8(%rsp),%rdi je 177c <_Z5func0RKSt6vectorIiSaIiEE+0x15c> callq 11a0 <_ZdlPv@plt> mov 0x58(%rsp),%rax xor %fs:0x28,%rax jne 17ab <_Z5func0RKSt6vectorIiSaIiEE+0x18b> add $0x68,%rsp mov %r13,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq xchg %ax,%ax xor %r13d,%r13d xor %r15d,%r15d jmpq 171b <_Z5func0RKSt6vectorIiSaIiEE+0xfb> callq 11c0 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1220 <_Z5func0RKSt6vectorIiSaIiEE.cold> nopl 0x0(%rax)
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 78h mov rbp, [rdi] mov r15, [rdi+8] mov [rsp+0A8h+var_90], rdi mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax lea rax, [rsp+0A8h+var_48] mov [rsp+0A8h+var_58], 3F800000h mov [rsp+0A8h+var_98], rax mov [rsp+0A8h+s], rax mov [rsp+0A8h+var_70], 1 mov [rsp+0A8h+var_68], 0 mov [rsp+0A8h+var_60], 0 mov [rsp+0A8h+var_50], 0 mov [rsp+0A8h+var_48], 0 cmp r15, rbp jz loc_18F1 mov rdi, rax lea rax, [rsp+0A8h+var_58] mov r8d, 1 mov [rsp+0A8h+var_A0], rax xchg ax, ax loc_1680: movsxd r12, dword ptr [rbp+0] xor edx, edx mov rax, r12 mov r13, r12 div r8 mov r10, [rdi+rdx*8] mov r9, rdx lea r14, ds:0[rdx*8] test r10, r10 jz short loc_16F8 mov rax, [r10] mov ecx, [rax+8] cmp r13d, ecx jz short loc_16D1 loc_16AE: mov rsi, [rax] test rsi, rsi jz short loc_16F8 mov ecx, [rsi+8] mov r10, rax xor edx, edx movsxd rax, ecx div r8 cmp r9, rdx jnz short loc_16F8 mov rax, rsi cmp r13d, ecx jnz short loc_16AE loc_16D1: mov rax, [r10] lea rbx, [rax+0Ch] test rax, rax jz short loc_16F8 add rbp, 4 add dword ptr [rbx], 1 cmp r15, rbp jz loc_177F loc_16ED: mov r8, [rsp+0A8h+var_70] jmp short loc_1680 loc_16F8: mov edi, 10h; unsigned __int64 call __Znwm; operator new(ulong) mov qword ptr [rax], 0 mov rbx, rax mov rdx, [rsp+0A8h+var_60]; unsigned __int64 mov ecx, 1; unsigned __int64 mov rsi, [rsp+0A8h+var_70]; unsigned __int64 mov rdi, [rsp+0A8h+var_A0]; this mov [rax+8], r13d mov dword ptr [rax+0Ch], 0 mov rax, [rsp+0A8h+var_50] mov [rsp+0A8h+var_80], rax call __ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm; std::__detail::_Prime_rehash_policy::_M_need_rehash(ulong,ulong,ulong) mov rsi, rdx test al, al jnz loc_1888 mov rdi, [rsp+0A8h+s] add r14, rdi mov rax, [r14] test rax, rax jz loc_18C3 loc_1759: mov rax, [rax] mov [rbx], rax mov rax, [r14] mov [rax], rbx loc_1765: add rbx, 0Ch add rbp, 4 add [rsp+0A8h+var_60], 1 add dword ptr [rbx], 1 cmp r15, rbp jnz loc_16ED loc_177F: mov rax, [rsp+0A8h+var_90] mov r15, [rax+8] mov rbx, [rax] cmp r15, rbx jz loc_18F1 mov dword ptr [rsp+0A8h+var_A0], 0 xor r12d, r12d lea r13, [rsp+0A8h+var_80] lea r14, [rsp+0A8h+s] jmp short loc_17B9 loc_17B0: add rbx, 4 cmp r15, rbx jz short loc_17EA loc_17B9: mov ebp, [rbx] mov rsi, r13 mov rdi, r14 mov dword ptr [rsp+0A8h+var_80], ebp call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) cmp [rax], r12d jle short loc_17B0 mov rsi, r13 mov rdi, r14 call _ZNSt8__detail9_Map_baseIiSt4pairIKiiESaIS3_ENS_10_Select1stESt8equal_toIiESt4hashIiENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_; std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[](int const&) add rbx, 4 mov dword ptr [rsp+0A8h+var_A0], ebp mov r12d, [rax] cmp r15, rbx jnz short loc_17B9 loc_17EA: mov ebp, dword ptr [rsp+0A8h+var_A0] mov rbx, [rsp+0A8h+var_68] shl r12, 20h or rbp, r12 test rbx, rbx jz short loc_1815 nop loc_1800: mov rdi, rbx; void * mov rbx, [rbx] mov esi, 10h; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test rbx, rbx jnz short loc_1800 loc_1815: mov rax, [rsp+0A8h+var_70] mov rdi, [rsp+0A8h+s]; s xor esi, esi; c lea rdx, ds:0[rax*8]; n call _memset mov rdi, [rsp+0A8h+s]; void * mov rax, [rsp+0A8h+var_98] mov [rsp+0A8h+var_60], 0 mov [rsp+0A8h+var_68], 0 mov rsi, [rsp+0A8h+var_70] cmp rdi, rax jz short loc_185D shl rsi, 3; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_185D: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz loc_18FF add rsp, 78h mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1888: lea r13, [rsp+0A8h+var_80] lea r14, [rsp+0A8h+s] mov rdx, r13 mov rdi, r14 call _ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE9_M_rehashEmRKm; std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::_M_rehash(ulong,ulong const&) mov rax, r12 xor edx, edx mov rdi, [rsp+0A8h+s] div [rsp+0A8h+var_70] lea r14, ds:0[rdx*8] add r14, rdi mov rax, [r14] test rax, rax jnz loc_1759 loc_18C3: mov rax, [rsp+0A8h+var_68] mov [rsp+0A8h+var_68], rbx mov [rbx], rax test rax, rax jz short loc_18E4 movsxd rax, dword ptr [rax+8] xor edx, edx div [rsp+0A8h+var_70] mov [rdi+rdx*8], rbx loc_18E4: lea rax, [rsp+0A8h+var_68] mov [r14], rax jmp loc_1765 loc_18F1: xor edx, edx xor r12d, r12d mov dword ptr [rsp+0A8h+var_A0], edx jmp loc_17EA loc_18FF: call ___stack_chk_fail endbr64 mov rbp, rax jmp _Z5func0RKSt6vectorIiSaIiEE_cold; func0(std::vector<int> const&) [clone] endbr64 mov rbx, rax jmp loc_1210
long long func0(int **a1) { int *v1; // rbp int *v2; // r15 _QWORD *v3; // rdi unsigned long long i; // r8 unsigned long long v5; // r12 int v6; // r13d unsigned long long v7; // rdx long long **v8; // r10 unsigned long long v9; // r9 long long v10; // r14 long long *v11; // rax long long v12; // rcx _DWORD *v13; // rax _DWORD *v14; // rbx unsigned long long v15; // rdx unsigned long long v16; // rsi char *v17; // r14 _QWORD *v18; // rax int *v19; // r15 int *v20; // rbx long long v21; // r12 int v22; // ebp _QWORD *v23; // rbx void *v24; // rdi int *v26; // rax unsigned int v27; // [rsp+8h] [rbp-A0h] long long v29; // [rsp+28h] [rbp-80h] BYREF void *s; // [rsp+30h] [rbp-78h] BYREF unsigned long long v31; // [rsp+38h] [rbp-70h] void *v32; // [rsp+40h] [rbp-68h] BYREF unsigned long long v33; // [rsp+48h] [rbp-60h] int v34; // [rsp+50h] [rbp-58h] BYREF long long v35; // [rsp+58h] [rbp-50h] _QWORD v36[9]; // [rsp+60h] [rbp-48h] BYREF v1 = *a1; v2 = a1[1]; v36[1] = __readfsqword(0x28u); v34 = 1065353216; s = v36; v31 = 1LL; v32 = 0LL; v33 = 0LL; v35 = 0LL; v36[0] = 0LL; if ( v2 == v1 ) goto LABEL_29; v3 = v36; for ( i = 1LL; ; i = v31 ) { v5 = *v1; v6 = *v1; v7 = v5 % i; v8 = (long long **)v3[v5 % i]; v9 = v5 % i; v10 = 8 * (v5 % i); if ( !v8 ) break; v11 = *v8; v12 = *((unsigned int *)*v8 + 2); if ( v6 != (_DWORD)v12 ) { while ( *v11 ) { v12 = *(unsigned int *)(*v11 + 8); v8 = (long long **)v11; v7 = (int)v12 % i; if ( v9 != v7 ) break; v11 = (long long *)*v11; if ( v6 == (_DWORD)v12 ) goto LABEL_8; } break; } LABEL_8: if ( !*v8 ) break; ++v1; ++*((_DWORD *)*v8 + 3); if ( v2 == v1 ) goto LABEL_15; LABEL_10: ; } v13 = (_DWORD *)operator new(0x10uLL); *(_QWORD *)v13 = 0LL; v14 = v13; v15 = v33; v16 = v31; v13[2] = v6; v13[3] = 0; v29 = v35; if ( (unsigned __int8)std::__detail::_Prime_rehash_policy::_M_need_rehash( (std::__detail::_Prime_rehash_policy *)&v34, v16, v15, 1uLL) ) { std::_Hashtable<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>>::_M_rehash( &s, v7, &v29); v3 = s; v7 = v5 % v31; v17 = (char *)s + 8 * (v5 % v31); v18 = *(_QWORD **)v17; if ( *(_QWORD *)v17 ) goto LABEL_13; } else { v3 = s; v17 = (char *)s + v10; v18 = *(_QWORD **)v17; if ( *(_QWORD *)v17 ) { LABEL_13: *(_QWORD *)v14 = *v18; **(_QWORD **)v17 = v14; goto LABEL_14; } } v26 = (int *)v32; v32 = v14; *(_QWORD *)v14 = v26; if ( v26 ) { v7 = v26[2] % v31; v3[v7] = v14; } *(_QWORD *)v17 = &v32; LABEL_14: ++v1; ++v33; ++v14[3]; if ( v2 != v1 ) goto LABEL_10; LABEL_15: v19 = a1[1]; v20 = *a1; if ( v19 == *a1 ) { LABEL_29: v21 = 0LL; v27 = 0; goto LABEL_20; } v27 = 0; v21 = 0LL; do { while ( 1 ) { v22 = *v20; LODWORD(v29) = *v20; if ( *(_DWORD *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( &s, &v29, v7, v12, i, v9) > (int)v21 ) break; if ( v19 == ++v20 ) goto LABEL_20; } ++v20; v27 = v22; v21 = *(unsigned int *)std::__detail::_Map_base<int,std::pair<int const,int>,std::allocator<std::pair<int const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true>::operator[]( &s, &v29, v7, v12, i, v9); } while ( v19 != v20 ); LABEL_20: v23 = v32; if ( v32 ) { do { v24 = v23; v23 = (_QWORD *)*v23; operator delete(v24, 0x10uLL); } while ( v23 ); } memset(s, 0, 8 * v31); v33 = 0LL; v32 = 0LL; if ( s != v36 ) operator delete(s, 8 * v31); return (v21 << 32) | v27; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x78 MOV RBP,qword ptr [RDI] MOV R15,qword ptr [RDI + 0x8] MOV qword ptr [RSP + 0x18],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX LEA RAX,[RSP + 0x60] MOV dword ptr [RSP + 0x50],0x3f800000 MOV qword ptr [RSP + 0x10],RAX MOV qword ptr [RSP + 0x30],RAX MOV qword ptr [RSP + 0x38],0x1 MOV qword ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x58],0x0 MOV qword ptr [RSP + 0x60],0x0 CMP R15,RBP JZ 0x001018f1 MOV RDI,RAX LEA RAX,[RSP + 0x50] MOV R8D,0x1 MOV qword ptr [RSP + 0x8],RAX NOP LAB_00101680: MOVSXD R12,dword ptr [RBP] XOR EDX,EDX MOV RAX,R12 MOV R13,R12 DIV R8 MOV R10,qword ptr [RDI + RDX*0x8] MOV R9,RDX LEA R14,[RDX*0x8] TEST R10,R10 JZ 0x001016f8 MOV RAX,qword ptr [R10] MOV ECX,dword ptr [RAX + 0x8] CMP R13D,ECX JZ 0x001016d1 LAB_001016ae: MOV RSI,qword ptr [RAX] TEST RSI,RSI JZ 0x001016f8 MOV ECX,dword ptr [RSI + 0x8] MOV R10,RAX XOR EDX,EDX MOVSXD RAX,ECX DIV R8 CMP R9,RDX JNZ 0x001016f8 MOV RAX,RSI CMP R13D,ECX JNZ 0x001016ae LAB_001016d1: MOV RAX,qword ptr [R10] LEA RBX,[RAX + 0xc] TEST RAX,RAX JZ 0x001016f8 ADD RBP,0x4 ADD dword ptr [RBX],0x1 CMP R15,RBP JZ 0x0010177f LAB_001016ed: MOV R8,qword ptr [RSP + 0x38] JMP 0x00101680 LAB_001016f8: MOV EDI,0x10 LAB_001016fd: CALL 0x00101190 MOV qword ptr [RAX],0x0 MOV RBX,RAX MOV RDX,qword ptr [RSP + 0x48] MOV ECX,0x1 MOV RSI,qword ptr [RSP + 0x38] MOV RDI,qword ptr [RSP + 0x8] MOV dword ptr [RAX + 0x8],R13D MOV dword ptr [RAX + 0xc],0x0 MOV RAX,qword ptr [RSP + 0x58] MOV qword ptr [RSP + 0x28],RAX LAB_00101735: CALL 0x001011c0 MOV RSI,RDX TEST AL,AL JNZ 0x00101888 MOV RDI,qword ptr [RSP + 0x30] ADD R14,RDI MOV RAX,qword ptr [R14] TEST RAX,RAX JZ 0x001018c3 LAB_00101759: MOV RAX,qword ptr [RAX] MOV qword ptr [RBX],RAX MOV RAX,qword ptr [R14] MOV qword ptr [RAX],RBX LAB_00101765: ADD RBX,0xc ADD RBP,0x4 ADD qword ptr [RSP + 0x48],0x1 ADD dword ptr [RBX],0x1 CMP R15,RBP JNZ 0x001016ed LAB_0010177f: MOV RAX,qword ptr [RSP + 0x18] MOV R15,qword ptr [RAX + 0x8] MOV RBX,qword ptr [RAX] CMP R15,RBX JZ 0x001018f1 MOV dword ptr [RSP + 0x8],0x0 XOR R12D,R12D LEA R13,[RSP + 0x28] LEA R14,[RSP + 0x30] JMP 0x001017b9 LAB_001017b0: ADD RBX,0x4 CMP R15,RBX JZ 0x001017ea LAB_001017b9: MOV EBP,dword ptr [RBX] MOV RSI,R13 MOV RDI,R14 MOV dword ptr [RSP + 0x28],EBP LAB_001017c5: CALL 0x00101b70 CMP dword ptr [RAX],R12D JLE 0x001017b0 MOV RSI,R13 MOV RDI,R14 CALL 0x00101b70 ADD RBX,0x4 MOV dword ptr [RSP + 0x8],EBP MOV R12D,dword ptr [RAX] CMP R15,RBX JNZ 0x001017b9 LAB_001017ea: MOV EBP,dword ptr [RSP + 0x8] MOV RBX,qword ptr [RSP + 0x40] SHL R12,0x20 OR RBP,R12 TEST RBX,RBX JZ 0x00101815 NOP LAB_00101800: MOV RDI,RBX MOV RBX,qword ptr [RBX] MOV ESI,0x10 CALL 0x001011a0 TEST RBX,RBX JNZ 0x00101800 LAB_00101815: MOV RAX,qword ptr [RSP + 0x38] MOV RDI,qword ptr [RSP + 0x30] XOR ESI,ESI LEA RDX,[RAX*0x8] CALL 0x00101150 MOV RDI,qword ptr [RSP + 0x30] MOV RAX,qword ptr [RSP + 0x10] MOV qword ptr [RSP + 0x48],0x0 MOV qword ptr [RSP + 0x40],0x0 MOV RSI,qword ptr [RSP + 0x38] CMP RDI,RAX JZ 0x0010185d SHL RSI,0x3 CALL 0x001011a0 LAB_0010185d: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018ff ADD RSP,0x78 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101888: LEA R13,[RSP + 0x28] LEA R14,[RSP + 0x30] MOV RDX,R13 MOV RDI,R14 LAB_00101898: CALL 0x00101a30 MOV RAX,R12 XOR EDX,EDX MOV RDI,qword ptr [RSP + 0x30] DIV qword ptr [RSP + 0x38] LEA R14,[RDX*0x8] ADD R14,RDI MOV RAX,qword ptr [R14] TEST RAX,RAX JNZ 0x00101759 LAB_001018c3: MOV RAX,qword ptr [RSP + 0x40] MOV qword ptr [RSP + 0x40],RBX MOV qword ptr [RBX],RAX TEST RAX,RAX JZ 0x001018e4 MOVSXD RAX,dword ptr [RAX + 0x8] XOR EDX,EDX DIV qword ptr [RSP + 0x38] MOV qword ptr [RDI + RDX*0x8],RBX LAB_001018e4: LEA RAX,[RSP + 0x40] MOV qword ptr [R14],RAX JMP 0x00101765 LAB_001018f1: XOR EDX,EDX XOR R12D,R12D MOV dword ptr [RSP + 0x8],EDX JMP 0x001017ea LAB_001018ff: CALL 0x001011b0
/* func0(std::vector<int, std::allocator<int> > const&) */ ulong func0(vector *param_1) { int *piVar1; int iVar2; int iVar3; uint uVar4; int *piVar5; long *plVar6; uint *puVar7; long *plVar8; char cVar9; int8 *puVar10; int8 *puVar11; int *piVar12; uint *puVar13; ulong uVar14; ulong extraout_RDX; uint *puVar15; uint uVar16; long *plVar17; long in_FS_OFFSET; ulong local_a0; ulong local_80; int8 *local_78; ulong local_70; int8 *local_68; ulong local_60; int4 local_58 [2]; ulong local_50; int8 local_48; long local_40; piVar12 = *(int **)param_1; piVar5 = *(int **)(param_1 + 8); local_40 = *(long *)(in_FS_OFFSET + 0x28); local_58[0] = 0x3f800000; local_70 = 1; local_68 = (int8 *)0x0; local_60 = 0; local_50 = 0; local_48 = 0; local_78 = &local_48; if (piVar5 != piVar12) { puVar10 = &local_48; do { iVar2 = *piVar12; uVar14 = (ulong)(long)iVar2 % local_70; plVar17 = (long *)puVar10[uVar14]; if (plVar17 != (long *)0x0) { iVar3 = *(int *)((long *)*plVar17 + 1); plVar8 = (long *)*plVar17; while (iVar2 != iVar3) { plVar6 = (long *)*plVar8; if ((plVar6 == (long *)0x0) || (iVar3 = *(int *)(plVar6 + 1), plVar17 = plVar8, plVar8 = plVar6, uVar14 != (ulong)(long)iVar3 % local_70)) goto LAB_001016f8; } piVar1 = (int *)(*plVar17 + 0xc); if (*plVar17 != 0) { *piVar1 = *piVar1 + 1; goto joined_r0x00101779; } } LAB_001016f8: /* try { // try from 001016fd to 00101701 has its CatchHandler @ 00101910 */ puVar10 = (int8 *)operator_new(0x10); *puVar10 = 0; *(int *)(puVar10 + 1) = iVar2; *(int4 *)((long)puVar10 + 0xc) = 0; local_80 = local_50; /* try { // try from 00101735 to 00101739 has its CatchHandler @ 00101904 */ cVar9 = std::__detail::_Prime_rehash_policy::_M_need_rehash((ulong)local_58,local_70,local_60) ; if (cVar9 == '\0') { plVar17 = local_78 + uVar14; puVar11 = (int8 *)*plVar17; if (puVar11 != (int8 *)0x0) goto LAB_00101759; LAB_001018c3: *puVar10 = local_68; if (local_68 != (int8 *)0x0) { local_78[(ulong)(long)*(int *)(local_68 + 1) % local_70] = puVar10; } *plVar17 = (long)&local_68; local_68 = puVar10; } else { /* try { // try from 00101898 to 0010189c has its CatchHandler @ 00101904 */ std:: _Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> ::_M_rehash((_Hashtable<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>> *)&local_78,extraout_RDX,&local_80); plVar17 = local_78 + (ulong)(long)iVar2 % local_70; puVar11 = (int8 *)*plVar17; if (puVar11 == (int8 *)0x0) goto LAB_001018c3; LAB_00101759: *puVar10 = *puVar11; *(int8 **)*plVar17 = puVar10; } local_60 = local_60 + 1; *(int *)((long)puVar10 + 0xc) = *(int *)((long)puVar10 + 0xc) + 1; puVar10 = local_78; joined_r0x00101779: if (piVar5 == piVar12 + 1) goto LAB_0010177f; piVar12 = piVar12 + 1; } while( true ); } LAB_001018f1: uVar16 = 0; local_a0 = 0; LAB_001017ea: puVar10 = local_68; while (puVar10 != (int8 *)0x0) { puVar11 = (int8 *)*puVar10; operator_delete(puVar10,0x10); puVar10 = puVar11; } memset(local_78,0,local_70 * 8); local_60 = 0; local_68 = (int8 *)0x0; if (local_78 != &local_48) { operator_delete(local_78,local_70 << 3); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return local_a0 | (ulong)uVar16 << 0x20; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); LAB_0010177f: puVar7 = *(uint **)(param_1 + 8); puVar15 = *(uint **)param_1; if (puVar7 != puVar15) { local_a0 = 0; uVar16 = 0; do { while( true ) { uVar4 = *puVar15; local_80 = CONCAT44(local_80._4_4_,uVar4); /* try { // try from 001017c5 to 001017d9 has its CatchHandler @ 00101910 */ piVar12 = (int *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,(int *)&local_80); if (*piVar12 <= (int)uVar16) break; puVar13 = (uint *)std::__detail:: _Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> ::operator[]((_Map_base<int,std::pair<int_const,int>,std::allocator<std::pair<int_const,int>>,std::__detail::_Select1st,std::equal_to<int>,std::hash<int>,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits<false,false,true>,true> *)&local_78,(int *)&local_80); puVar15 = puVar15 + 1; local_a0 = (ulong)uVar4; uVar16 = *puVar13; if (puVar7 == puVar15) goto LAB_001017ea; } puVar15 = puVar15 + 1; } while (puVar7 != puVar15); goto LAB_001017ea; } goto LAB_001018f1; }
520
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string str1) { std::string vowels = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { vowels += ch; } } std::string result_string = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { result_string += vowels.back(); vowels.pop_back(); } else { result_string += ch; } } return result_string; }
int main() { assert(func0("Python") == "Python"); assert(func0("USA") == "ASU"); assert(func0("ab") == "ab"); return 0; }
O0
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0xb8,%rsp mov %rdi,-0xb8(%rbp) mov %rsi,-0xc0(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax lea -0x98(%rbp),%rax mov %rax,%rdi callq 23b0 <_ZNSaIcEC1Ev@plt> lea -0x98(%rbp),%rdx lea -0x80(%rbp),%rax lea 0x1af1(%rip),%rsi mov %rax,%rdi callq 2c7e <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> lea -0x98(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> mov -0xc0(%rbp),%rax mov %rax,-0x90(%rbp) mov -0x90(%rbp),%rax mov %rax,%rdi callq 22d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv@plt> mov %rax,-0xa0(%rbp) mov -0x90(%rbp),%rax mov %rax,%rdi callq 2240 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv@plt> mov %rax,-0x98(%rbp) lea -0x98(%rbp),%rdx lea -0xa0(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2d1a <_ZN9__gnu_cxxneIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKNS_17__normal_iteratorIT_T0_EESD_> test %al,%al je 2633 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x16a> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 2d7e <_ZNK9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEdeEv> movzbl (%rax),%eax mov %al,-0xa1(%rbp) lea -0xa3(%rbp),%rax mov %rax,%rdi callq 23b0 <_ZNSaIcEC1Ev@plt> lea -0xa3(%rbp),%rdx lea -0x60(%rbp),%rax lea 0x1a47(%rip),%rsi mov %rax,%rdi callq 2c7e <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> movsbl -0xa1(%rbp),%ecx lea -0x60(%rbp),%rax mov $0x0,%edx mov %ecx,%esi mov %rax,%rdi callq 2360 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> cmp $0xffffffffffffffff,%rax setne %bl lea -0x60(%rbp),%rax mov %rax,%rdi callq 2250 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> lea -0xa3(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> test %bl,%bl je 261f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x156> movsbl -0xa1(%rbp),%edx lea -0x80(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc@plt> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 2d5a <_ZN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEppEv> jmpq 2568 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x9f> lea -0x98(%rbp),%rax mov %rax,%rdi callq 23b0 <_ZNSaIcEC1Ev@plt> lea -0x98(%rbp),%rdx mov -0xb8(%rbp),%rax lea 0x19b1(%rip),%rsi mov %rax,%rdi callq 2c7e <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> lea -0x98(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> mov -0xc0(%rbp),%rax mov %rax,-0x88(%rbp) mov -0x88(%rbp),%rax mov %rax,%rdi callq 22d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv@plt> mov %rax,-0xa0(%rbp) mov -0x88(%rbp),%rax mov %rax,%rdi callq 2240 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv@plt> mov %rax,-0x98(%rbp) lea -0x98(%rbp),%rdx lea -0xa0(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2d1a <_ZN9__gnu_cxxneIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKNS_17__normal_iteratorIT_T0_EESD_> test %al,%al je 27a7 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2de> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 2d7e <_ZNK9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEdeEv> movzbl (%rax),%eax mov %al,-0xa2(%rbp) lea -0xa3(%rbp),%rax mov %rax,%rdi callq 23b0 <_ZNSaIcEC1Ev@plt> lea -0xa3(%rbp),%rdx lea -0x40(%rbp),%rax lea 0x1907(%rip),%rsi mov %rax,%rdi callq 2c7e <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> movsbl -0xa2(%rbp),%ecx lea -0x40(%rbp),%rax mov $0x0,%edx mov %ecx,%esi mov %rax,%rdi callq 2360 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> cmp $0xffffffffffffffff,%rax setne %bl lea -0x40(%rbp),%rax mov %rax,%rdi callq 2250 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> lea -0xa3(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> test %bl,%bl je 277b <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2b2> lea -0x80(%rbp),%rax mov %rax,%rdi callq 22a0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4backEv@plt> movzbl (%rax),%eax movsbl %al,%edx mov -0xb8(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc@plt> lea -0x80(%rbp),%rax mov %rax,%rdi callq 2340 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8pop_backEv@plt> jmp 2793 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2ca> movsbl -0xa2(%rbp),%edx mov -0xb8(%rbp),%rax mov %edx,%esi mov %rax,%rdi callq 2260 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc@plt> lea -0xa0(%rbp),%rax mov %rax,%rdi callq 2d5a <_ZN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEppEv> jmpq 26a8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1df> lea -0x80(%rbp),%rax mov %rax,%rdi callq 2250 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 2871 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3a8> jmpq 286c <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3a3> endbr64 mov %rax,%rbx lea -0x98(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 23a0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea -0xa3(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> jmp 2855 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x38c> endbr64 mov %rax,%rbx lea -0x98(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> jmp 2855 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x38c> endbr64 mov %rax,%rbx lea -0xa3(%rbp),%rax mov %rax,%rdi callq 2300 <_ZNSaIcED1Ev@plt> jmp 283d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x374> endbr64 mov %rax,%rbx mov -0xb8(%rbp),%rax mov %rax,%rdi callq 2250 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> jmp 2855 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x38c> endbr64 mov %rax,%rbx lea -0x80(%rbp),%rax mov %rax,%rdi callq 2250 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 23a0 <_Unwind_Resume@plt> callq 2330 <__stack_chk_fail@plt> mov -0xb8(%rbp),%rax add $0xb8,%rsp pop %rbx pop %rbp retq
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 0B8h mov [rbp+var_B8], rdi mov [rbp+var_C0], rsi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax lea rax, [rbp+var_98] mov [rbp+var_80], rax nop nop lea rdx, [rbp+var_98] lea rax, [rbp+var_60] lea rcx, unk_4008 mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) lea rax, [rbp+var_98] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, [rbp+var_C0] mov [rbp+var_90], rax mov rax, [rbp+var_90] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv; std::string::begin(void) mov [rbp+var_A0], rax mov rax, [rbp+var_90] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv; std::string::end(void) mov [rbp+var_98], rax jmp loc_2576 loc_24CF: lea rax, [rbp+var_A0] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEdeEv; __gnu_cxx::__normal_iterator<char *,std::string>::operator*(void) movzx eax, byte ptr [rax] mov [rbp+var_A1], al lea rax, [rbp+var_A3] mov [rbp+var_78], rax nop nop lea rdx, [rbp+var_A3] lea rax, [rbp+var_40] lea rcx, aAeiouaeiou; "aeiouAEIOU" mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) movsx ecx, [rbp+var_A1] lea rax, [rbp+var_40] mov edx, 0 mov esi, ecx mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) cmp rax, 0FFFFFFFFFFFFFFFFh setnz bl lea rax, [rbp+var_40] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() lea rax, [rbp+var_A3] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop test bl, bl jz short loc_2567 movsx edx, [rbp+var_A1] lea rax, [rbp+var_60] mov esi, edx mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc; std::string::operator+=(char) loc_2567: lea rax, [rbp+var_A0] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEppEv; __gnu_cxx::__normal_iterator<char *,std::string>::operator++(void) loc_2576: lea rdx, [rbp+var_98] lea rax, [rbp+var_A0] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKNS_17__normal_iteratorIT_T0_EESD_; __gnu_cxx::operator!=<char *,std::string>(__gnu_cxx::__normal_iterator<char *,std::string> const&,__gnu_cxx::__normal_iterator<char *,std::string> const&) test al, al jnz loc_24CF lea rax, [rbp+var_98] mov [rbp+var_70], rax nop nop lea rdx, [rbp+var_98] mov rax, [rbp+var_B8] lea rcx, unk_4008 mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) lea rax, [rbp+var_98] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, [rbp+var_C0] mov [rbp+var_88], rax mov rax, [rbp+var_88] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv; std::string::begin(void) mov [rbp+var_A0], rax mov rax, [rbp+var_88] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv; std::string::end(void) mov [rbp+var_98], rax jmp loc_26EE loc_2613: lea rax, [rbp+var_A0] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEdeEv; __gnu_cxx::__normal_iterator<char *,std::string>::operator*(void) movzx eax, byte ptr [rax] mov [rbp+var_A2], al lea rax, [rbp+var_A3] mov [rbp+var_68], rax nop nop lea rdx, [rbp+var_A3] lea rax, [rbp+var_40] lea rcx, aAeiouaeiou; "aeiouAEIOU" mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) movsx ecx, [rbp+var_A2] lea rax, [rbp+var_40] mov edx, 0 mov esi, ecx mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) cmp rax, 0FFFFFFFFFFFFFFFFh setnz bl lea rax, [rbp+var_40] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() lea rax, [rbp+var_A3] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop test bl, bl jz short loc_26C7 lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4backEv; std::string::back(void) movzx eax, byte ptr [rax] movsx edx, al mov rax, [rbp+var_B8] mov esi, edx mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc; std::string::operator+=(char) lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8pop_backEv; std::string::pop_back(void) jmp short loc_26DF loc_26C7: movsx edx, [rbp+var_A2] mov rax, [rbp+var_B8] mov esi, edx mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc; std::string::operator+=(char) loc_26DF: lea rax, [rbp+var_A0] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEppEv; __gnu_cxx::__normal_iterator<char *,std::string>::operator++(void) loc_26EE: lea rdx, [rbp+var_98] lea rax, [rbp+var_A0] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRKNS_17__normal_iteratorIT_T0_EESD_; __gnu_cxx::operator!=<char *,std::string>(__gnu_cxx::__normal_iterator<char *,std::string> const&,__gnu_cxx::__normal_iterator<char *,std::string> const&) test al, al jnz loc_2613 nop lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() nop mov rax, [rbp+var_18] sub rax, fs:28h jz loc_2805 jmp loc_2800 endbr64 mov rbx, rax lea rax, [rbp+var_98] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_2763 call ___stack_chk_fail loc_2763: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rax, [rbp+var_A3] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop jmp short loc_27D5 endbr64 mov rbx, rax lea rax, [rbp+var_98] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop jmp short loc_27D5 endbr64 mov rbx, rax lea rax, [rbp+var_A3] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop jmp short loc_27BD endbr64 mov rbx, rax loc_27BD: mov rax, [rbp+var_B8] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() jmp short loc_27D5 endbr64 mov rbx, rax loc_27D5: lea rax, [rbp+var_60] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_27F8 call ___stack_chk_fail loc_27F8: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_2800: call ___stack_chk_fail loc_2805: mov rax, [rbp+var_B8] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, long long a2) { bool v2; // bl bool v3; // bl char *v4; // rax char v6; // [rsp+1Dh] [rbp-A3h] BYREF char v7; // [rsp+1Eh] [rbp-A2h] char v8; // [rsp+1Fh] [rbp-A1h] long long v9; // [rsp+20h] [rbp-A0h] BYREF long long v10; // [rsp+28h] [rbp-98h] BYREF long long v11; // [rsp+30h] [rbp-90h] long long v12; // [rsp+38h] [rbp-88h] long long *v13; // [rsp+40h] [rbp-80h] char *v14; // [rsp+48h] [rbp-78h] long long *v15; // [rsp+50h] [rbp-70h] char *v16; // [rsp+58h] [rbp-68h] _BYTE v17[32]; // [rsp+60h] [rbp-60h] BYREF _BYTE v18[40]; // [rsp+80h] [rbp-40h] BYREF unsigned long long v19; // [rsp+A8h] [rbp-18h] v19 = __readfsqword(0x28u); v13 = &v10; std::string::basic_string<std::allocator<char>>(v17, &unk_4008, &v10); std::__new_allocator<char>::~__new_allocator(&v10); v11 = a2; v9 = std::string::begin(a2); v10 = std::string::end(v11); while ( (unsigned __int8)__gnu_cxx::operator!=<char *,std::string>(&v9, &v10) ) { v8 = *(_BYTE *)__gnu_cxx::__normal_iterator<char *,std::string>::operator*(&v9); v14 = &v6; std::string::basic_string<std::allocator<char>>(v18, "aeiouAEIOU", &v6); v2 = std::string::find(v18, (unsigned int)v8, 0LL) != -1; std::string::~string(v18); std::__new_allocator<char>::~__new_allocator(&v6); if ( v2 ) std::string::operator+=(v17, (unsigned int)v8); __gnu_cxx::__normal_iterator<char *,std::string>::operator++(&v9); } v15 = &v10; std::string::basic_string<std::allocator<char>>(a1, &unk_4008, &v10); std::__new_allocator<char>::~__new_allocator(&v10); v12 = a2; v9 = std::string::begin(a2); v10 = std::string::end(v12); while ( (unsigned __int8)__gnu_cxx::operator!=<char *,std::string>(&v9, &v10) ) { v7 = *(_BYTE *)__gnu_cxx::__normal_iterator<char *,std::string>::operator*(&v9); v16 = &v6; std::string::basic_string<std::allocator<char>>(v18, "aeiouAEIOU", &v6); v3 = std::string::find(v18, (unsigned int)v7, 0LL) != -1; std::string::~string(v18); std::__new_allocator<char>::~__new_allocator(&v6); if ( v3 ) { v4 = (char *)std::string::back(v17); std::string::operator+=(a1, (unsigned int)*v4); std::string::pop_back(v17); } else { std::string::operator+=(a1, (unsigned int)v7); } __gnu_cxx::__normal_iterator<char *,std::string>::operator++(&v9); } std::string::~string(v17); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0xb8 MOV qword ptr [RBP + -0xb8],RDI MOV qword ptr [RBP + -0xc0],RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX LEA RAX,[RBP + -0x98] MOV qword ptr [RBP + -0x80],RAX NOP NOP LEA RDX,[RBP + -0x98] LEA RAX,[RBP + -0x60] LEA RCX,[0x104008] MOV RSI,RCX MOV RDI,RAX LAB_0010247b: CALL 0x00102d0e LEA RAX,[RBP + -0x98] MOV RDI,RAX CALL 0x00102ed0 NOP MOV RAX,qword ptr [RBP + -0xc0] MOV qword ptr [RBP + -0x90],RAX MOV RAX,qword ptr [RBP + -0x90] MOV RDI,RAX CALL 0x00102280 MOV qword ptr [RBP + -0xa0],RAX MOV RAX,qword ptr [RBP + -0x90] MOV RDI,RAX CALL 0x001021e0 MOV qword ptr [RBP + -0x98],RAX JMP 0x00102576 LAB_001024cf: LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x00102e1a MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBP + -0xa1],AL LEA RAX,[RBP + -0xa3] MOV qword ptr [RBP + -0x78],RAX NOP NOP LEA RDX,[RBP + -0xa3] LEA RAX,[RBP + -0x40] LEA RCX,[0x104009] MOV RSI,RCX MOV RDI,RAX LAB_0010250c: CALL 0x00102d0e MOVSX ECX,byte ptr [RBP + -0xa1] LEA RAX,[RBP + -0x40] MOV EDX,0x0 MOV ESI,ECX MOV RDI,RAX CALL 0x00102300 CMP RAX,-0x1 SETNZ BL LEA RAX,[RBP + -0x40] MOV RDI,RAX CALL 0x001021f0 LEA RAX,[RBP + -0xa3] MOV RDI,RAX CALL 0x00102ed0 NOP TEST BL,BL JZ 0x00102567 MOVSX EDX,byte ptr [RBP + -0xa1] LEA RAX,[RBP + -0x60] MOV ESI,EDX MOV RDI,RAX LAB_00102562: CALL 0x00102200 LAB_00102567: LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x00102df6 LAB_00102576: LEA RDX,[RBP + -0x98] LEA RAX,[RBP + -0xa0] MOV RSI,RDX MOV RDI,RAX CALL 0x00102db6 TEST AL,AL JNZ 0x001024cf LEA RAX,[RBP + -0x98] MOV qword ptr [RBP + -0x70],RAX NOP NOP LEA RDX,[RBP + -0x98] MOV RAX,qword ptr [RBP + -0xb8] LEA RCX,[0x104008] MOV RSI,RCX MOV RDI,RAX LAB_001025bf: CALL 0x00102d0e LEA RAX,[RBP + -0x98] MOV RDI,RAX CALL 0x00102ed0 NOP MOV RAX,qword ptr [RBP + -0xc0] MOV qword ptr [RBP + -0x88],RAX MOV RAX,qword ptr [RBP + -0x88] MOV RDI,RAX CALL 0x00102280 MOV qword ptr [RBP + -0xa0],RAX MOV RAX,qword ptr [RBP + -0x88] MOV RDI,RAX CALL 0x001021e0 MOV qword ptr [RBP + -0x98],RAX JMP 0x001026ee LAB_00102613: LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x00102e1a MOVZX EAX,byte ptr [RAX] MOV byte ptr [RBP + -0xa2],AL LEA RAX,[RBP + -0xa3] MOV qword ptr [RBP + -0x68],RAX NOP NOP LEA RDX,[RBP + -0xa3] LEA RAX,[RBP + -0x40] LEA RCX,[0x104009] MOV RSI,RCX MOV RDI,RAX LAB_00102650: CALL 0x00102d0e MOVSX ECX,byte ptr [RBP + -0xa2] LEA RAX,[RBP + -0x40] MOV EDX,0x0 MOV ESI,ECX MOV RDI,RAX CALL 0x00102300 CMP RAX,-0x1 SETNZ BL LEA RAX,[RBP + -0x40] MOV RDI,RAX CALL 0x001021f0 LEA RAX,[RBP + -0xa3] MOV RDI,RAX CALL 0x00102ed0 NOP TEST BL,BL JZ 0x001026c7 LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x00102250 MOVZX EAX,byte ptr [RAX] MOVSX EDX,AL MOV RAX,qword ptr [RBP + -0xb8] MOV ESI,EDX MOV RDI,RAX LAB_001026b4: CALL 0x00102200 LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x001022d0 JMP 0x001026df LAB_001026c7: MOVSX EDX,byte ptr [RBP + -0xa2] MOV RAX,qword ptr [RBP + -0xb8] MOV ESI,EDX MOV RDI,RAX CALL 0x00102200 LAB_001026df: LEA RAX,[RBP + -0xa0] MOV RDI,RAX CALL 0x00102df6 LAB_001026ee: LEA RDX,[RBP + -0x98] LEA RAX,[RBP + -0xa0] MOV RSI,RDX MOV RDI,RAX CALL 0x00102db6 TEST AL,AL JNZ 0x00102613 NOP LEA RAX,[RBP + -0x60] MOV RDI,RAX CALL 0x001021f0 NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x00102805 JMP 0x00102800 LAB_00102800: CALL 0x001022c0 LAB_00102805: MOV RAX,qword ptr [RBP + -0xb8] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::string) */ string * func0(string *param_1,int8 param_2) { bool bVar1; char *pcVar2; long lVar3; long in_FS_OFFSET; allocator local_ab; char local_aa; char local_a9; int8 local_a8; int8 local_a0; int8 local_98; int8 local_90; int8 *local_88; allocator *local_80; int8 *local_78; allocator *local_70; string local_68 [32]; string local_48 [40]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_88 = &local_a0; /* try { // try from 0010247b to 0010247f has its CatchHandler @ 00102735 */ std::string::string<std::allocator<char>>(local_68,"",(allocator *)&local_a0); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_a0); local_98 = param_2; local_a8 = std::string::begin(); local_a0 = std::string::end(); while( true ) { bVar1 = operator!=((__normal_iterator *)&local_a8,(__normal_iterator *)&local_a0); if (!bVar1) break; pcVar2 = (char *)__normal_iterator<char*,std::string>::operator* ((__normal_iterator<char*,std::string> *)&local_a8); local_a9 = *pcVar2; local_80 = &local_ab; /* try { // try from 0010250c to 00102510 has its CatchHandler @ 0010276b */ std::string::string<std::allocator<char>>(local_48,"aeiouAEIOU",&local_ab); lVar3 = std::string::find((char)local_48,(ulong)(uint)(int)local_a9); std::string::~string(local_48); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_ab); if (lVar3 != -1) { /* try { // try from 00102562 to 00102566 has its CatchHandler @ 001027ce */ std::string::operator+=(local_68,local_a9); } __normal_iterator<char*,std::string>::operator++ ((__normal_iterator<char*,std::string> *)&local_a8); } local_78 = &local_a0; /* try { // try from 001025bf to 001025c3 has its CatchHandler @ 00102784 */ std::string::string<std::allocator<char>>(param_1,"",(allocator *)&local_a0); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_a0); local_90 = param_2; local_a8 = std::string::begin(); local_a0 = std::string::end(); while( true ) { bVar1 = operator!=((__normal_iterator *)&local_a8,(__normal_iterator *)&local_a0); if (!bVar1) break; pcVar2 = (char *)__normal_iterator<char*,std::string>::operator* ((__normal_iterator<char*,std::string> *)&local_a8); local_aa = *pcVar2; local_70 = &local_ab; /* try { // try from 00102650 to 00102654 has its CatchHandler @ 0010279d */ std::string::string<std::allocator<char>>(local_48,"aeiouAEIOU",&local_ab); lVar3 = std::string::find((char)local_48,(ulong)(uint)(int)local_aa); std::string::~string(local_48); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_ab); if (lVar3 == -1) { std::string::operator+=(param_1,local_aa); } else { pcVar2 = (char *)std::string::back(); /* try { // try from 001026b4 to 001026de has its CatchHandler @ 001027b6 */ std::string::operator+=(param_1,*pcVar2); std::string::pop_back(); } __normal_iterator<char*,std::string>::operator++ ((__normal_iterator<char*,std::string> *)&local_a8); } std::string::~string(local_68); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
521
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string str1) { std::string vowels = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { vowels += ch; } } std::string result_string = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { result_string += vowels.back(); vowels.pop_back(); } else { result_string += ch; } } return result_string; }
int main() { assert(func0("Python") == "Python"); assert(func0("USA") == "ASU"); assert(func0("ab") == "ab"); return 0; }
O1
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x98,%rsp mov %rdi,%rbx mov %rsi,%r15 mov %rsi,0x18(%rsp) mov %fs:0x28,%rax mov %rax,0x88(%rsp) xor %eax,%eax lea 0x20(%rsp),%rdi lea 0x30(%rsp),%rax mov %rax,0x20(%rsp) lea 0xd76(%rip),%rdx mov %rdx,%rsi callq 1860 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov (%r15),%rbp mov %rbp,%rcx add 0x8(%r15),%rcx mov %rcx,0x8(%rsp) cmp %rbp,%rcx je 13fa <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x131> lea 0x40(%rsp),%r14 jmp 1376 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xad> movsbl %r12b,%esi mov $0x0,%edx mov %r14,%rdi callq 1190 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov %rax,%r13 mov 0x40(%rsp),%rdi lea 0x50(%rsp),%rax cmp %rax,%rdi je 1361 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x98> callq 1160 <_ZdlPv@plt> cmp $0xffffffffffffffff,%r13 jne 139a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xd1> add $0x1,%rbp cmp %rbp,0x8(%rsp) je 13fa <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x131> movzbl 0x0(%rbp),%r12d lea 0x50(%rsp),%rax mov %rax,0x40(%rsp) lea 0xcb0(%rip),%rdx lea -0xa(%rdx),%rsi mov %r14,%rdi callq 1860 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> jmp 1339 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x70> mov 0x28(%rsp),%r13 lea 0x1(%r13),%r15 lea 0x30(%rsp),%rax cmp %rax,0x20(%rsp) je 13d4 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x10b> mov 0x30(%rsp),%rax cmp %rax,%r15 ja 13db <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x112> mov 0x20(%rsp),%rax mov %r12b,(%rax,%r13,1) mov %r15,0x28(%rsp) mov 0x20(%rsp),%rax movb $0x0,0x1(%rax,%r13,1) jmp 1367 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x9e> mov $0xf,%eax jmp 13b4 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xeb> lea 0x20(%rsp),%rdi mov $0x1,%r8d mov $0x0,%ecx mov $0x0,%edx mov %r13,%rsi callq 11d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> jmp 13b9 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xf0> lea 0x10(%rbx),%rax mov %rax,0x10(%rsp) mov %rax,(%rbx) lea 0xc7b(%rip),%rdx mov %rdx,%rsi mov %rbx,%rdi callq 1860 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov 0x18(%rsp),%rax mov (%rax),%rbp mov %rax,%rcx mov %rbp,%rax add 0x8(%rcx),%rax mov %rax,0x8(%rsp) cmp %rbp,%rax je 1581 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2b8> lea 0x60(%rsp),%r13 jmpq 14db <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x212> movsbl %r12b,%esi mov $0x0,%edx mov %r13,%rdi callq 1190 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov %rax,%r14 mov 0x60(%rsp),%rdi lea 0x70(%rsp),%rax cmp %rax,%rdi je 146a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1a1> callq 1160 <_ZdlPv@plt> cmp $0xffffffffffffffff,%r14 je 1529 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x260> mov 0x20(%rsp),%rdx mov 0x28(%rsp),%rax movzbl -0x1(%rdx,%rax,1),%r15d mov 0x8(%rbx),%r12 lea 0x1(%r12),%r14 mov 0x10(%rsp),%rax cmp (%rbx),%rax je 1502 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x239> mov 0x10(%rbx),%rax cmp %rax,%r14 ja 1509 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x240> mov (%rbx),%rax mov %r15b,(%rax,%r12,1) mov %r14,0x8(%rbx) mov (%rbx),%rax movb $0x0,0x1(%rax,%r12,1) mov 0x28(%rsp),%rax lea -0x1(%rax),%rsi lea 0x20(%rsp),%rdi mov $0x1,%edx callq 1180 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm@plt> add $0x1,%rbp cmp %rbp,0x8(%rsp) je 1581 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2b8> movzbl 0x0(%rbp),%r12d lea 0x70(%rsp),%rax mov %rax,0x60(%rsp) lea 0xb4b(%rip),%rdx lea -0xa(%rdx),%rsi mov %r13,%rdi callq 1860 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> jmpq 1442 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x179> mov $0xf,%eax jmp 149b <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1d2> mov $0x1,%r8d mov $0x0,%ecx mov $0x0,%edx mov %r12,%rsi mov %rbx,%rdi callq 11d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> jmpq 14a0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1d7> mov 0x8(%rbx),%r14 lea 0x1(%r14),%r15 mov 0x10(%rsp),%rax cmp (%rbx),%rax je 155d <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x294> mov 0x10(%rbx),%rax cmp %rax,%r15 ja 1564 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29b> mov (%rbx),%rax mov %r12b,(%rax,%r14,1) mov %r15,0x8(%rbx) mov (%rbx),%rax movb $0x0,0x1(%rax,%r14,1) jmpq 14cc <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x203> mov $0xf,%eax jmp 153f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x276> mov $0x1,%r8d mov $0x0,%ecx mov $0x0,%edx mov %r14,%rsi mov %rbx,%rdi callq 11d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> jmp 1544 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x27b> mov 0x20(%rsp),%rdi lea 0x30(%rsp),%rax cmp %rax,%rdi je 1595 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2cc> callq 1160 <_ZdlPv@plt> mov 0x88(%rsp),%rax xor %fs:0x28,%rax jne 15f8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x32f> mov %rbx,%rax add $0x98,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq endbr64 mov %rax,%rbp mov (%rbx),%rdi cmp 0x10(%rsp),%rdi je 15d3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x30a> callq 1160 <_ZdlPv@plt> mov 0x20(%rsp),%rdi lea 0x30(%rsp),%rax cmp %rax,%rdi je 15e7 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x31e> callq 1160 <_ZdlPv@plt> mov %rbp,%rdi callq 11b0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbp jmp 15d3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x30a> callq 1170 <__stack_chk_fail@plt>
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 78h mov rbx, rdi mov r14, rsi mov [rsp+0A8h+var_90], rsi mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax lea rdi, [rsp+0A8h+var_88] lea rax, [rsp+0A8h+var_78] mov [rsp+0A8h+var_88], rax lea rsi, aFunc0UsaAsu+15h; "" mov rdx, rsi call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) mov rbp, [r14] mov rax, rbp add rax, [r14+8] mov [rsp+0A8h+var_A0], rax cmp rbp, rax jz loc_1402 lea rax, [rsp+0A8h+var_68] mov [rsp+0A8h+var_98], rax lea r14, [rsp+0A8h+var_58] jmp short loc_137E loc_133D: movsx esi, r12b mov edx, 0 mov rdi, r15 call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov r13, rax mov rdi, [rsp+0A8h+var_68]; void * cmp rdi, r14 jz short loc_1369 mov rax, [rsp+0A8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1369: cmp r13, 0FFFFFFFFFFFFFFFFh jnz short loc_13A2 loc_136F: add rbp, 1 cmp [rsp+0A8h+var_A0], rbp jz loc_1402 loc_137E: movzx r12d, byte ptr [rbp+0] mov [rsp+0A8h+var_68], r14 lea rdx, aAeiouaeiou+0Ah; "" lea rsi, [rdx-0Ah] mov r15, [rsp+0A8h+var_98] mov rdi, r15 call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp short loc_133D loc_13A2: mov r13, [rsp+0A8h+var_80] lea r15, [r13+1] lea rax, [rsp+0A8h+var_78] cmp [rsp+0A8h+var_88], rax jz short loc_13DC mov rax, [rsp+0A8h+var_78] loc_13BC: cmp rax, r15 jb short loc_13E3 loc_13C1: mov rax, [rsp+0A8h+var_88] mov [rax+r13], r12b mov [rsp+0A8h+var_80], r15 mov rax, [rsp+0A8h+var_88] mov byte ptr [rax+r13+1], 0 jmp short loc_136F loc_13DC: mov eax, 0Fh jmp short loc_13BC loc_13E3: lea rdi, [rsp+0A8h+var_88] mov r8d, 1 mov ecx, 0 mov edx, 0 mov rsi, r13 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) jmp short loc_13C1 loc_1402: lea rax, [rbx+10h] mov [rsp+0A8h+var_98], rax mov [rbx], rax lea rsi, aFunc0UsaAsu+15h; "" mov rdx, rsi mov rdi, rbx call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) mov rax, [rsp+0A8h+var_90] mov rbp, [rax] mov rcx, rax mov rax, rbp add rax, [rcx+8] mov [rsp+0A8h+var_A0], rax cmp rax, rbp jz loc_1597 lea rax, [rsp+0A8h+var_68] mov [rsp+0A8h+var_90], rax lea r13, [rsp+0A8h+var_58] jmp loc_14F1 loc_1454: movsx esi, r12b mov edx, 0 mov rdi, r15 call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov r14, rax mov rdi, [rsp+0A8h+var_68]; void * cmp rdi, r13 jz short loc_1480 mov rax, [rsp+0A8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1480: cmp r14, 0FFFFFFFFFFFFFFFFh jz loc_153F mov rdx, [rsp+0A8h+var_88] mov rax, [rsp+0A8h+var_80] movzx r15d, byte ptr [rdx+rax-1] mov r12, [rbx+8] lea r14, [r12+1] mov rax, [rsp+0A8h+var_98] cmp rax, [rbx] jz short loc_1518 mov rax, [rbx+10h] loc_14B1: cmp rax, r14 jb short loc_151F loc_14B6: mov rax, [rbx] mov [rax+r12], r15b mov [rbx+8], r14 mov rax, [rbx] mov byte ptr [rax+r12+1], 0 mov rax, [rsp+0A8h+var_80] lea rsi, [rax-1] lea rdi, [rsp+0A8h+var_88] mov edx, 1 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm; std::string::_M_erase(ulong,ulong) loc_14E2: add rbp, 1 cmp [rsp+0A8h+var_A0], rbp jz loc_1597 loc_14F1: movzx r12d, byte ptr [rbp+0] mov [rsp+0A8h+var_68], r13 lea rdx, aAeiouaeiou+0Ah; "" lea rsi, [rdx-0Ah] mov r15, [rsp+0A8h+var_90] mov rdi, r15 call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp loc_1454 loc_1518: mov eax, 0Fh jmp short loc_14B1 loc_151F: mov r8d, 1 mov ecx, 0 mov edx, 0 mov rsi, r12 mov rdi, rbx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) jmp loc_14B6 loc_153F: mov r14, [rbx+8] lea r15, [r14+1] mov rax, [rsp+0A8h+var_98] cmp rax, [rbx] jz short loc_1573 mov rax, [rbx+10h] loc_1555: cmp rax, r15 jb short loc_157A loc_155A: mov rax, [rbx] mov [rax+r14], r12b mov [rbx+8], r15 mov rax, [rbx] mov byte ptr [rax+r14+1], 0 jmp loc_14E2 loc_1573: mov eax, 0Fh jmp short loc_1555 loc_157A: mov r8d, 1 mov ecx, 0 mov edx, 0 mov rsi, r14 mov rdi, rbx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) jmp short loc_155A loc_1597: mov rdi, [rsp+0A8h+var_88]; void * lea rax, [rsp+0A8h+var_78] cmp rdi, rax jz short loc_15B4 mov rax, [rsp+0A8h+var_78] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_15B4: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_1615 mov rax, rbx add rsp, 78h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbp, rax mov rdi, rbx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) loc_15E5: lea rdi, [rsp+arg_18] call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) mov rax, [rsp+arg_60] sub rax, fs:28h jz short loc_160D call ___stack_chk_fail endbr64 mov rbp, rax jmp short loc_15E5 loc_160D: mov rdi, rbp; struct _Unwind_Exception * call __Unwind_Resume loc_1615: call ___stack_chk_fail
_QWORD * func0(_QWORD *a1, long long a2) { char *v2; // rbp long long v3; // r13 char v4; // r12 unsigned long long v5; // r13 unsigned long long v6; // r15 unsigned long long v7; // rax char *v8; // rbp long long v9; // r14 char v10; // r15 long long v11; // r12 unsigned long long v12; // r14 unsigned long long v13; // rax char v14; // r12 long long v15; // r14 unsigned long long v16; // r15 unsigned long long v17; // rax char *v19; // [rsp+8h] [rbp-A0h] char *v20; // [rsp+8h] [rbp-A0h] _QWORD *v21; // [rsp+10h] [rbp-98h] void *v22; // [rsp+20h] [rbp-88h] BYREF unsigned long long v23; // [rsp+28h] [rbp-80h] _QWORD v24[2]; // [rsp+30h] [rbp-78h] BYREF void *v25[2]; // [rsp+40h] [rbp-68h] BYREF _QWORD v26[11]; // [rsp+50h] [rbp-58h] BYREF v26[3] = __readfsqword(0x28u); v22 = v24; std::string::_M_construct<char const*>(&v22, "", ""); v2 = *(char **)a2; v19 = (char *)(*(_QWORD *)(a2 + 8) + *(_QWORD *)a2); if ( *(char **)a2 != v19 ) { do { v4 = *v2; v25[0] = v26; std::string::_M_construct<char const*>(v25, "aeiouAEIOU", ""); v3 = std::string::find(v25, (unsigned int)v4, 0LL); if ( v25[0] != v26 ) operator delete(v25[0], v26[0] + 1LL); if ( v3 != -1 ) { v5 = v23; v6 = v23 + 1; if ( v22 == v24 ) v7 = 15LL; else v7 = v24[0]; if ( v7 < v6 ) std::string::_M_mutate(&v22, v23, 0LL, 0LL, 1LL); *((_BYTE *)v22 + v5) = v4; v23 = v6; *((_BYTE *)v22 + v5 + 1) = 0; } ++v2; } while ( v19 != v2 ); } v21 = a1 + 2; *a1 = a1 + 2; std::string::_M_construct<char const*>(a1, "", ""); v8 = *(char **)a2; v20 = (char *)(*(_QWORD *)(a2 + 8) + *(_QWORD *)a2); if ( v20 != *(char **)a2 ) { do { v14 = *v8; v25[0] = v26; std::string::_M_construct<char const*>(v25, "aeiouAEIOU", ""); v9 = std::string::find(v25, (unsigned int)v14, 0LL); if ( v25[0] != v26 ) operator delete(v25[0], v26[0] + 1LL); if ( v9 == -1 ) { v15 = a1[1]; v16 = v15 + 1; if ( v21 == (_QWORD *)*a1 ) v17 = 15LL; else v17 = a1[2]; if ( v17 < v16 ) std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); *(_BYTE *)(*a1 + v15) = v14; a1[1] = v16; *(_BYTE *)(*a1 + v15 + 1) = 0; } else { v10 = *((char *)v22 + v23 - 1); v11 = a1[1]; v12 = v11 + 1; if ( v21 == (_QWORD *)*a1 ) v13 = 15LL; else v13 = a1[2]; if ( v13 < v12 ) std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); *(_BYTE *)(*a1 + v11) = v10; a1[1] = v12; *(_BYTE *)(*a1 + v11 + 1) = 0; std::string::_M_erase(&v22, v23 - 1, 1LL); } ++v8; } while ( v20 != v8 ); } if ( v22 != v24 ) operator delete(v22, v24[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x78 MOV RBX,RDI MOV R14,RSI MOV qword ptr [RSP + 0x18],RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX LEA RDI,[RSP + 0x20] LEA RAX,[RSP + 0x30] MOV qword ptr [RSP + 0x20],RAX LEA RSI,[0x1020b6] MOV RDX,RSI LAB_0010130f: CALL 0x00101878 MOV RBP,qword ptr [R14] MOV RAX,RBP ADD RAX,qword ptr [R14 + 0x8] MOV qword ptr [RSP + 0x8],RAX CMP RBP,RAX JZ 0x00101402 LEA RAX,[RSP + 0x40] MOV qword ptr [RSP + 0x10],RAX LEA R14,[RSP + 0x50] JMP 0x0010137e LAB_0010133d: MOVSX ESI,R12B MOV EDX,0x0 MOV RDI,R15 CALL 0x001011a0 MOV R13,RAX MOV RDI,qword ptr [RSP + 0x40] CMP RDI,R14 JZ 0x00101369 MOV RAX,qword ptr [RSP + 0x50] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_00101369: CMP R13,-0x1 JNZ 0x001013a2 LAB_0010136f: ADD RBP,0x1 CMP qword ptr [RSP + 0x8],RBP JZ 0x00101402 LAB_0010137e: MOVZX R12D,byte ptr [RBP] MOV qword ptr [RSP + 0x40],R14 LEA RDX,[0x10206a] LEA RSI,[RDX + -0xa] MOV R15,qword ptr [RSP + 0x10] MOV RDI,R15 LAB_0010139b: CALL 0x00101878 JMP 0x0010133d LAB_001013a2: MOV R13,qword ptr [RSP + 0x28] LEA R15,[R13 + 0x1] LEA RAX,[RSP + 0x30] CMP qword ptr [RSP + 0x20],RAX JZ 0x001013dc MOV RAX,qword ptr [RSP + 0x30] LAB_001013bc: CMP RAX,R15 JC 0x001013e3 LAB_001013c1: MOV RAX,qword ptr [RSP + 0x20] MOV byte ptr [RAX + R13*0x1],R12B MOV qword ptr [RSP + 0x28],R15 MOV RAX,qword ptr [RSP + 0x20] MOV byte ptr [RAX + R13*0x1 + 0x1],0x0 JMP 0x0010136f LAB_001013dc: MOV EAX,0xf JMP 0x001013bc LAB_001013e3: LEA RDI,[RSP + 0x20] MOV R8D,0x1 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,R13 CALL 0x001011d0 JMP 0x001013c1 LAB_00101402: LEA RAX,[RBX + 0x10] MOV qword ptr [RSP + 0x10],RAX MOV qword ptr [RBX],RAX LEA RSI,[0x1020b6] MOV RDX,RSI MOV RDI,RBX CALL 0x00101878 MOV RAX,qword ptr [RSP + 0x18] MOV RBP,qword ptr [RAX] MOV RCX,RAX MOV RAX,RBP ADD RAX,qword ptr [RCX + 0x8] MOV qword ptr [RSP + 0x8],RAX CMP RAX,RBP JZ 0x00101597 LEA RAX,[RSP + 0x40] MOV qword ptr [RSP + 0x18],RAX LEA R13,[RSP + 0x50] JMP 0x001014f1 LAB_00101454: MOVSX ESI,R12B MOV EDX,0x0 MOV RDI,R15 CALL 0x001011a0 MOV R14,RAX MOV RDI,qword ptr [RSP + 0x40] CMP RDI,R13 JZ 0x00101480 MOV RAX,qword ptr [RSP + 0x50] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_00101480: CMP R14,-0x1 JZ 0x0010153f MOV RDX,qword ptr [RSP + 0x20] MOV RAX,qword ptr [RSP + 0x28] MOVZX R15D,byte ptr [RDX + RAX*0x1 + -0x1] MOV R12,qword ptr [RBX + 0x8] LEA R14,[R12 + 0x1] MOV RAX,qword ptr [RSP + 0x10] CMP RAX,qword ptr [RBX] JZ 0x00101518 MOV RAX,qword ptr [RBX + 0x10] LAB_001014b1: CMP RAX,R14 JC 0x0010151f LAB_001014b6: MOV RAX,qword ptr [RBX] MOV byte ptr [RAX + R12*0x1],R15B MOV qword ptr [RBX + 0x8],R14 MOV RAX,qword ptr [RBX] MOV byte ptr [RAX + R12*0x1 + 0x1],0x0 MOV RAX,qword ptr [RSP + 0x28] LEA RSI,[RAX + -0x1] LEA RDI,[RSP + 0x20] MOV EDX,0x1 CALL 0x00101180 LAB_001014e2: ADD RBP,0x1 CMP qword ptr [RSP + 0x8],RBP JZ 0x00101597 LAB_001014f1: MOVZX R12D,byte ptr [RBP] MOV qword ptr [RSP + 0x40],R13 LEA RDX,[0x10206a] LEA RSI,[RDX + -0xa] MOV R15,qword ptr [RSP + 0x18] MOV RDI,R15 LAB_0010150e: CALL 0x00101878 JMP 0x00101454 LAB_00101518: MOV EAX,0xf JMP 0x001014b1 LAB_0010151f: MOV R8D,0x1 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,R12 MOV RDI,RBX CALL 0x001011d0 JMP 0x001014b6 LAB_0010153f: MOV R14,qword ptr [RBX + 0x8] LEA R15,[R14 + 0x1] MOV RAX,qword ptr [RSP + 0x10] CMP RAX,qword ptr [RBX] JZ 0x00101573 MOV RAX,qword ptr [RBX + 0x10] LAB_00101555: CMP RAX,R15 JC 0x0010157a LAB_0010155a: MOV RAX,qword ptr [RBX] MOV byte ptr [RAX + R14*0x1],R12B MOV qword ptr [RBX + 0x8],R15 MOV RAX,qword ptr [RBX] MOV byte ptr [RAX + R14*0x1 + 0x1],0x0 JMP 0x001014e2 LAB_00101573: MOV EAX,0xf JMP 0x00101555 LAB_0010157a: MOV R8D,0x1 MOV ECX,0x0 MOV EDX,0x0 MOV RSI,R14 MOV RDI,RBX CALL 0x001011d0 JMP 0x0010155a LAB_00101597: MOV RDI,qword ptr [RSP + 0x20] LEA RAX,[RSP + 0x30] CMP RDI,RAX JZ 0x001015b4 MOV RAX,qword ptr [RSP + 0x30] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_001015b4: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101615 MOV RAX,RBX ADD RSP,0x78 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101615: CALL 0x00101170
/* func0(std::string) */ long * func0(long *param_1,int8 *param_2) { long *plVar1; char cVar2; int uVar3; ulong uVar4; char *pcVar5; long lVar6; ulong uVar7; ulong uVar8; char *pcVar9; long in_FS_OFFSET; ulong *local_88; ulong local_80; ulong local_78 [2]; long *local_68 [2]; long local_58 [3]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); local_88 = local_78; std::string::_M_construct<char_const*>((char *)&local_88,"",0x1020b6); pcVar9 = (char *)*param_2; pcVar5 = pcVar9 + param_2[1]; if (pcVar9 != pcVar5) { do { cVar2 = *pcVar9; local_68[0] = local_58; /* try { // try from 0010139b to 0010141f has its CatchHandler @ 00101604 */ std::string::_M_construct<char_const*>((char *)local_68,"aeiouAEIOU",0x10206a); lVar6 = std::string::find((char)local_68,(ulong)(uint)(int)cVar2); if (local_68[0] != local_58) { operator_delete(local_68[0],local_58[0] + 1); } uVar4 = local_80; if (lVar6 != -1) { uVar8 = local_80 + 1; uVar7 = local_78[0]; if (local_88 == local_78) { uVar7 = 0xf; } if (uVar7 < uVar8) { std::string::_M_mutate((ulong)&local_88,local_80,(char *)0x0,0); } *(char *)((long)local_88 + uVar4) = cVar2; *(int *)((long)local_88 + uVar4 + 1) = 0; local_80 = uVar8; } pcVar9 = pcVar9 + 1; } while (pcVar5 != pcVar9); } plVar1 = param_1 + 2; *param_1 = (long)plVar1; std::string::_M_construct<char_const*>((char *)param_1,"",0x1020b6); pcVar9 = (char *)*param_2; pcVar5 = pcVar9 + param_2[1]; if (pcVar5 != pcVar9) { do { cVar2 = *pcVar9; local_68[0] = local_58; /* try { // try from 0010150e to 00101594 has its CatchHandler @ 001015d6 */ std::string::_M_construct<char_const*>((char *)local_68,"aeiouAEIOU",0x10206a); lVar6 = std::string::find((char)local_68,(ulong)(uint)(int)cVar2); if (local_68[0] != local_58) { operator_delete(local_68[0],local_58[0] + 1); } if (lVar6 == -1) { uVar4 = param_1[1]; if (plVar1 == (long *)*param_1) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar4 + 1) { std::string::_M_mutate((ulong)param_1,uVar4,(char *)0x0,0); } *(char *)(*param_1 + uVar4) = cVar2; param_1[1] = uVar4 + 1; *(int *)(*param_1 + 1 + uVar4) = 0; } else { uVar3 = *(int *)((long)local_88 + (local_80 - 1)); uVar4 = param_1[1]; if (plVar1 == (long *)*param_1) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar4 + 1) { std::string::_M_mutate((ulong)param_1,uVar4,(char *)0x0,0); } *(int *)(*param_1 + uVar4) = uVar3; param_1[1] = uVar4 + 1; *(int *)(*param_1 + 1 + uVar4) = 0; std::string::_M_erase((ulong)&local_88,local_80 - 1); } pcVar9 = pcVar9 + 1; } while (pcVar5 != pcVar9); } if (local_88 != local_78) { operator_delete(local_88,local_78[0] + 1); } if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
522
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string str1) { std::string vowels = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { vowels += ch; } } std::string result_string = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { result_string += vowels.back(); vowels.pop_back(); } else { result_string += ch; } } return result_string; }
int main() { assert(func0("Python") == "Python"); assert(func0("USA") == "ASU"); assert(func0("ab") == "ab"); return 0; }
O2
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 push %r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x88,%rsp mov (%rsi),%rbp mov %rsi,0x20(%rsp) mov %fs:0x28,%rax mov %rax,0x78(%rsp) xor %eax,%eax lea 0x40(%rsp),%rax movb $0x0,0x40(%rsp) mov %rax,0x28(%rsp) mov %rax,0x30(%rsp) mov 0x8(%rsi),%rax movq $0x0,0x38(%rsp) lea 0x0(%rbp,%rax,1),%rcx mov %rcx,0x10(%rsp) cmp %rbp,%rcx je 16a9 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x149> lea 0x50(%rsp),%rax lea 0x60(%rsp),%rbx mov %rax,0x8(%rsp) jmp 15fb <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x9b> nopl (%rax) mov %r13b,(%rdx,%r14,1) mov 0x30(%rsp),%rax mov %r15,0x38(%rsp) movb $0x0,0x1(%rax,%r14,1) add $0x1,%rbp cmp %rbp,0x10(%rsp) je 16a0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x140> movsbl 0x0(%rbp),%esi mov 0x8(%rsp),%rdi mov $0x554f,%edx mov %rbx,0x50(%rsp) movabs $0x494541756f696561,%rax mov %dx,0x8(%rbx) xor %edx,%edx mov %rax,(%rbx) mov %esi,%r13d movq $0xa,0x58(%rsp) movb $0x0,0x6a(%rsp) callq 11b0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov 0x50(%rsp),%rdi mov %rax,%r14 cmp %rbx,%rdi je 1649 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xe9> callq 1180 <_ZdlPv@plt> cmp $0xffffffffffffffff,%r14 je 15ec <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c> mov 0x38(%rsp),%r14 mov 0x30(%rsp),%rdx mov $0xf,%eax cmp 0x28(%rsp),%rdx cmovne 0x40(%rsp),%rax lea 0x1(%r14),%r15 cmp %rax,%r15 jbe 15d8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x78> lea 0x30(%rsp),%rdi mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r14,%rsi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov 0x30(%rsp),%rdx jmpq 15d8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x78> nopw 0x0(%rax,%rax,1) mov 0x20(%rsp),%rax mov 0x8(%rax),%rax lea 0x10(%r12),%rcx movb $0x0,0x10(%r12) lea 0x60(%rsp),%rbx mov %rcx,(%r12) mov %rcx,0x18(%rsp) mov 0x20(%rsp),%rcx movq $0x0,0x8(%r12) mov (%rcx),%rbp lea 0x50(%rsp),%rcx mov %rcx,0x8(%rsp) add %rbp,%rax mov %rax,0x10(%rsp) cmp %rbp,%rax jne 1753 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1f3> jmpq 17fa <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29a> mov 0x30(%rsp),%rcx mov 0x38(%rsp),%rax movzbl -0x1(%rcx,%rax,1),%r15d cmp %rdx,0x18(%rsp) je 1850 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2f0> mov 0x10(%r12),%rax cmp %rax,%r14 ja 1830 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d0> mov %r15b,(%rdx,%r13,1) mov (%r12),%rax lea 0x30(%rsp),%rdi add $0x1,%rbp mov %r14,0x8(%r12) mov $0x1,%edx movb $0x0,0x1(%rax,%r13,1) mov 0x38(%rsp),%rax lea -0x1(%rax),%rsi callq 11a0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm@plt> cmp %rbp,0x10(%rsp) je 17fa <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29a> movsbl 0x0(%rbp),%esi mov 0x8(%rsp),%rdi mov %rbx,0x50(%rsp) xor %edx,%edx movabs $0x494541756f696561,%rax mov %rax,(%rbx) mov $0x554f,%eax mov %esi,%r15d mov %ax,0x8(%rbx) movq $0xa,0x58(%rsp) movb $0x0,0x6a(%rsp) callq 11b0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov 0x50(%rsp),%rdi cmp %rbx,%rdi je 17a8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x248> mov %rax,0x20(%rsp) callq 1180 <_ZdlPv@plt> mov 0x20(%rsp),%rax mov 0x8(%r12),%r13 mov (%r12),%rdx lea 0x1(%r13),%r14 cmp $0xffffffffffffffff,%rax jne 16f0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x190> cmp %rdx,0x18(%rsp) je 1880 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x320> mov 0x10(%r12),%rax cmp %rax,%r14 ja 1860 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x300> mov %r15b,(%rdx,%r13,1) mov (%r12),%rax add $0x1,%rbp mov %r14,0x8(%r12) movb $0x0,0x1(%rax,%r13,1) cmp %rbp,0x10(%rsp) jne 1753 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1f3> mov 0x30(%rsp),%rdi cmp 0x28(%rsp),%rdi je 180b <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2ab> callq 1180 <_ZdlPv@plt> mov 0x78(%rsp),%rax xor %fs:0x28,%rax jne 188a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x32a> add $0x88,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r13,%rsi mov %r12,%rdi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov (%r12),%rdx jmpq 1719 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b9> xchg %ax,%ax mov $0xf,%eax jmpq 1710 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b0> nopw 0x0(%rax,%rax,1) mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r13,%rsi mov %r12,%rdi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov (%r12),%rdx jmpq 17d8 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x278> xchg %ax,%ax mov $0xf,%eax jmpq 17cf <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x26f> callq 1190 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1200 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold> endbr64 mov %rax,%rbp jmpq 1210 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x10> nopw 0x0(%rax,%rax,1)
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 lea rdx, aFunc0UsaAsu+15h; "" mov r15, rsi push r14 push r13 push r12 push rbp push rbx mov rbx, rdi sub rsp, 98h mov [rsp+0C8h+var_A8], rsi lea rdi, [rsp+0C8h+var_88] mov rsi, rdx mov rax, fs:28h mov [rsp+0C8h+var_40], rax xor eax, eax lea rax, [rsp+0C8h+var_78] mov [rsp+0C8h+var_98], rdi mov [rsp+0C8h+var_90], rax mov [rsp+0C8h+var_88], rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rbp, [r15] mov rax, [r15+8] add rax, rbp mov [rsp+0C8h+var_B0], rax cmp rbp, rax jz loc_16E0 lea rax, [rsp+0C8h+var_68] lea r13, [rsp+0C8h+var_58] mov [rsp+0C8h+var_C8], rax lea rax, unk_200E mov [rsp+0C8h+var_B8], rax sub rax, 0Ah mov [rsp+0C8h+var_C0], rax jmp short loc_1643 loc_1620: mov [rax+r14], r12b mov rax, [rsp+0C8h+var_88] mov [rsp+0C8h+var_80], r15 mov byte ptr [rax+r14+1], 0 loc_1634: add rbp, 1 cmp [rsp+0C8h+var_B0], rbp jz loc_16E0 loc_1643: mov r15, [rsp+0C8h+var_C8] mov rdx, [rsp+0C8h+var_B8] mov rsi, [rsp+0C8h+var_C0] movzx r12d, byte ptr [rbp+0] mov [rsp+0C8h+var_68], r13 mov rdi, r15 call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rdi, r15 movsx esi, r12b xor edx, edx call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov rdi, [rsp+0C8h+var_68]; void * mov r14, rax cmp rdi, r13 jz short loc_168C mov rax, [rsp+0C8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_168C: cmp r14, 0FFFFFFFFFFFFFFFFh jz short loc_1634 mov r14, [rsp+0C8h+var_80] mov rax, [rsp+0C8h+var_88] mov rcx, [rsp+0C8h+var_90] lea r15, [r14+1] cmp rax, rcx jz loc_18E0 mov rdx, [rsp+0C8h+var_78] loc_16B3: cmp rdx, r15 jnb loc_1620 mov rdi, [rsp+0C8h+var_98] mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r14 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rax, [rsp+0C8h+var_88] jmp loc_1620 loc_16E0: lea rax, [rbx+10h] lea rdx, aFunc0UsaAsu+15h; "" mov rdi, rbx mov [rbx], rax mov rsi, rdx mov [rsp+0C8h+var_A0], rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rax, [rsp+0C8h+var_A8] mov rbp, [rax] mov rax, [rax+8] add rax, rbp mov [rsp+0C8h+var_A8], rax cmp rax, rbp jz loc_183E lea rax, [rsp+0C8h+var_68] lea r13, [rsp+0C8h+var_58] mov [rsp+0C8h+var_C8], rax lea rax, unk_200E mov [rsp+0C8h+var_B8], rax sub rax, 0Ah mov [rsp+0C8h+var_C0], rax jmp short loc_17A0 loc_1740: mov rcx, [rsp+0C8h+var_88] mov rax, [rsp+0C8h+var_80] movzx r15d, byte ptr [rcx+rax-1] cmp [rsp+0C8h+var_A0], rdx jz loc_18B0 mov rax, [rbx+10h] loc_175F: cmp rax, r14 jb loc_1890 loc_1768: mov [rdx+r12], r15b mov rax, [rbx] mov edx, 1 add rbp, 1 mov [rbx+8], r14 mov rdi, [rsp+0C8h+var_98] mov byte ptr [rax+r12+1], 0 mov rax, [rsp+0C8h+var_80] lea rsi, [rax-1] call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm; std::string::_M_erase(ulong,ulong) cmp [rsp+0C8h+var_A8], rbp jz loc_183E loc_17A0: mov r14, [rsp+0C8h+var_C8] mov rdx, [rsp+0C8h+var_B8] mov rsi, [rsp+0C8h+var_C0] movzx r15d, byte ptr [rbp+0] mov [rsp+0C8h+var_68], r13 mov rdi, r14 call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rdi, r14 movsx esi, r15b xor edx, edx call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov rdi, [rsp+0C8h+var_68]; void * cmp rdi, r13 jz short loc_17F0 mov [rsp+0C8h+var_B0], rax mov rax, [rsp+0C8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) mov rax, [rsp+0C8h+var_B0] loc_17F0: mov r12, [rbx+8] mov rdx, [rbx] lea r14, [r12+1] cmp rax, 0FFFFFFFFFFFFFFFFh jnz loc_1740 cmp [rsp+0C8h+var_A0], rdx jz loc_18F0 mov rax, [rbx+10h] loc_1815: cmp rax, r14 jb loc_18C0 loc_181E: mov [rdx+r12], r15b mov rax, [rbx] add rbp, 1 mov [rbx+8], r14 mov byte ptr [rax+r12+1], 0 cmp [rsp+0C8h+var_A8], rbp jnz loc_17A0 loc_183E: mov rdi, [rsp+0C8h+var_88]; void * mov rax, [rsp+0C8h+var_90] cmp rdi, rax jz short loc_185B mov rax, [rsp+0C8h+var_78] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_185B: mov rax, [rsp+0C8h+var_40] sub rax, fs:28h jnz loc_18FA add rsp, 98h mov rax, rbx pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1890: mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r12 mov rdi, rbx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rdx, [rbx] jmp loc_1768 loc_18B0: mov eax, 0Fh jmp loc_175F loc_18C0: mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r12 mov rdi, rbx call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rdx, [rbx] jmp loc_181E loc_18E0: mov edx, 0Fh jmp loc_16B3 loc_18F0: mov eax, 0Fh jmp loc_1815 loc_18FA: call ___stack_chk_fail endbr64 mov rbp, rax jmp _Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_cold; func0(std::string) [clone] endbr64 mov rbp, rax jmp loc_11E8
_QWORD * func0(_QWORD *a1, long long a2) { char *v2; // rbp char v3; // r12 long long v4; // r14 unsigned long long v5; // r14 _BYTE *v6; // rax unsigned long long v7; // r15 unsigned long long v8; // rdx char *v9; // rbp char v10; // r15 unsigned long long v11; // rax _QWORD *v12; // rax char v13; // r15 long long v14; // rax long long v15; // r12 unsigned long long v16; // r14 unsigned long long v17; // rax _QWORD *v18; // rax _QWORD *v20; // rdx char *v21; // [rsp+18h] [rbp-B0h] long long v22; // [rsp+18h] [rbp-B0h] char *v23; // [rsp+20h] [rbp-A8h] _QWORD *v24; // [rsp+28h] [rbp-A0h] void *v25; // [rsp+40h] [rbp-88h] BYREF unsigned long long v26; // [rsp+48h] [rbp-80h] _QWORD v27[2]; // [rsp+50h] [rbp-78h] BYREF void *v28[2]; // [rsp+60h] [rbp-68h] BYREF _QWORD v29[11]; // [rsp+70h] [rbp-58h] BYREF v29[3] = __readfsqword(0x28u); v25 = v27; std::string::_M_construct<char const*>(&v25, ""); v2 = *(char **)a2; v21 = (char *)(*(_QWORD *)a2 + *(_QWORD *)(a2 + 8)); if ( *(char **)a2 != v21 ) { do { v3 = *v2; v28[0] = v29; std::string::_M_construct<char const*>(v28, (char *)&unk_200E - 10); v4 = std::string::find(v28, (unsigned int)v3, 0LL); if ( v28[0] != v29 ) operator delete(v28[0], v29[0] + 1LL); if ( v4 != -1 ) { v5 = v26; v6 = v25; v7 = v26 + 1; if ( v25 == v27 ) v8 = 15LL; else v8 = v27[0]; if ( v8 < v7 ) { std::string::_M_mutate(&v25, v26, 0LL, 0LL, 1LL); v6 = v25; } v6[v5] = v3; v26 = v7; *((_BYTE *)v25 + v5 + 1) = 0; } ++v2; } while ( v21 != v2 ); } *a1 = a1 + 2; v24 = a1 + 2; std::string::_M_construct<char const*>(a1, ""); v9 = *(char **)a2; v23 = (char *)(*(_QWORD *)a2 + *(_QWORD *)(a2 + 8)); if ( v23 != *(char **)a2 ) { do { while ( 1 ) { v13 = *v9; v28[0] = v29; std::string::_M_construct<char const*>(v28, (char *)&unk_200E - 10); v14 = std::string::find(v28, (unsigned int)v13, 0LL); if ( v28[0] != v29 ) { v22 = v14; operator delete(v28[0], v29[0] + 1LL); v14 = v22; } v15 = a1[1]; v20 = (_QWORD *)*a1; v16 = v15 + 1; if ( v14 != -1 ) break; if ( v24 == v20 ) v17 = 15LL; else v17 = a1[2]; if ( v17 < v16 ) { std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); v20 = (_QWORD *)*a1; } *((_BYTE *)v20 + v15) = v13; v18 = (_QWORD *)*a1; ++v9; a1[1] = v16; *((_BYTE *)v18 + v15 + 1) = 0; if ( v23 == v9 ) goto LABEL_27; } v10 = *((char *)v25 + v26 - 1); if ( v24 == v20 ) v11 = 15LL; else v11 = a1[2]; if ( v11 < v16 ) { std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); v20 = (_QWORD *)*a1; } *((_BYTE *)v20 + v15) = v10; v12 = (_QWORD *)*a1; ++v9; a1[1] = v16; *((_BYTE *)v12 + v15 + 1) = 0; std::string::_M_erase(&v25, v26 - 1, 1LL); } while ( v23 != v9 ); } LABEL_27: if ( v25 != v27 ) operator delete(v25, v27[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 LEA RDX,[0x10205a] MOV R15,RSI PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV RBX,RDI SUB RSP,0x98 MOV qword ptr [RSP + 0x20],RSI LEA RDI,[RSP + 0x40] MOV RSI,RDX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x88],RAX XOR EAX,EAX LEA RAX,[RSP + 0x50] MOV qword ptr [RSP + 0x30],RDI MOV qword ptr [RSP + 0x38],RAX MOV qword ptr [RSP + 0x40],RAX LAB_001015d6: CALL 0x001014d0 MOV RBP,qword ptr [R15] MOV RAX,qword ptr [R15 + 0x8] ADD RAX,RBP MOV qword ptr [RSP + 0x18],RAX CMP RBP,RAX JZ 0x001016e0 LEA RAX,[RSP + 0x60] LEA R13,[RSP + 0x70] MOV qword ptr [RSP],RAX LEA RAX,[0x10200e] MOV qword ptr [RSP + 0x10],RAX SUB RAX,0xa MOV qword ptr [RSP + 0x8],RAX JMP 0x00101643 LAB_00101620: MOV byte ptr [RAX + R14*0x1],R12B MOV RAX,qword ptr [RSP + 0x40] MOV qword ptr [RSP + 0x48],R15 MOV byte ptr [RAX + R14*0x1 + 0x1],0x0 LAB_00101634: ADD RBP,0x1 CMP qword ptr [RSP + 0x18],RBP JZ 0x001016e0 LAB_00101643: MOV R15,qword ptr [RSP] MOV RDX,qword ptr [RSP + 0x10] MOV RSI,qword ptr [RSP + 0x8] MOVZX R12D,byte ptr [RBP] MOV qword ptr [RSP + 0x60],R13 MOV RDI,R15 LAB_0010165e: CALL 0x001014d0 MOV RDI,R15 MOVSX ESI,R12B XOR EDX,EDX CALL 0x001011a0 MOV RDI,qword ptr [RSP + 0x60] MOV R14,RAX CMP RDI,R13 JZ 0x0010168c MOV RAX,qword ptr [RSP + 0x70] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_0010168c: CMP R14,-0x1 JZ 0x00101634 MOV R14,qword ptr [RSP + 0x48] MOV RAX,qword ptr [RSP + 0x40] MOV RCX,qword ptr [RSP + 0x38] LEA R15,[R14 + 0x1] CMP RAX,RCX JZ 0x001018e0 MOV RDX,qword ptr [RSP + 0x50] LAB_001016b3: CMP RDX,R15 JNC 0x00101620 MOV RDI,qword ptr [RSP + 0x30] MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R14 CALL 0x001011d0 MOV RAX,qword ptr [RSP + 0x40] JMP 0x00101620 LAB_001016e0: LEA RAX,[RBX + 0x10] LEA RDX,[0x10205a] MOV RDI,RBX MOV qword ptr [RBX],RAX MOV RSI,RDX MOV qword ptr [RSP + 0x28],RAX CALL 0x001014d0 MOV RAX,qword ptr [RSP + 0x20] MOV RBP,qword ptr [RAX] MOV RAX,qword ptr [RAX + 0x8] ADD RAX,RBP MOV qword ptr [RSP + 0x20],RAX CMP RAX,RBP JZ 0x0010183e LEA RAX,[RSP + 0x60] LEA R13,[RSP + 0x70] MOV qword ptr [RSP],RAX LEA RAX,[0x10200e] MOV qword ptr [RSP + 0x10],RAX SUB RAX,0xa MOV qword ptr [RSP + 0x8],RAX JMP 0x001017a0 LAB_00101740: MOV RCX,qword ptr [RSP + 0x40] MOV RAX,qword ptr [RSP + 0x48] MOVZX R15D,byte ptr [RCX + RAX*0x1 + -0x1] CMP qword ptr [RSP + 0x28],RDX JZ 0x001018b0 MOV RAX,qword ptr [RBX + 0x10] LAB_0010175f: CMP RAX,R14 JC 0x00101890 LAB_00101768: MOV byte ptr [RDX + R12*0x1],R15B MOV RAX,qword ptr [RBX] MOV EDX,0x1 ADD RBP,0x1 MOV qword ptr [RBX + 0x8],R14 MOV RDI,qword ptr [RSP + 0x30] MOV byte ptr [RAX + R12*0x1 + 0x1],0x0 MOV RAX,qword ptr [RSP + 0x48] LEA RSI,[RAX + -0x1] CALL 0x00101180 CMP qword ptr [RSP + 0x20],RBP JZ 0x0010183e LAB_001017a0: MOV R14,qword ptr [RSP] MOV RDX,qword ptr [RSP + 0x10] MOV RSI,qword ptr [RSP + 0x8] MOVZX R15D,byte ptr [RBP] MOV qword ptr [RSP + 0x60],R13 MOV RDI,R14 LAB_001017bb: CALL 0x001014d0 MOV RDI,R14 MOVSX ESI,R15B XOR EDX,EDX CALL 0x001011a0 MOV RDI,qword ptr [RSP + 0x60] CMP RDI,R13 JZ 0x001017f0 MOV qword ptr [RSP + 0x18],RAX MOV RAX,qword ptr [RSP + 0x70] LEA RSI,[RAX + 0x1] CALL 0x00101160 MOV RAX,qword ptr [RSP + 0x18] LAB_001017f0: MOV R12,qword ptr [RBX + 0x8] MOV RDX,qword ptr [RBX] LEA R14,[R12 + 0x1] CMP RAX,-0x1 JNZ 0x00101740 CMP qword ptr [RSP + 0x28],RDX JZ 0x001018f0 MOV RAX,qword ptr [RBX + 0x10] LAB_00101815: CMP RAX,R14 JC 0x001018c0 LAB_0010181e: MOV byte ptr [RDX + R12*0x1],R15B MOV RAX,qword ptr [RBX] ADD RBP,0x1 MOV qword ptr [RBX + 0x8],R14 MOV byte ptr [RAX + R12*0x1 + 0x1],0x0 CMP qword ptr [RSP + 0x20],RBP JNZ 0x001017a0 LAB_0010183e: MOV RDI,qword ptr [RSP + 0x40] MOV RAX,qword ptr [RSP + 0x38] CMP RDI,RAX JZ 0x0010185b MOV RAX,qword ptr [RSP + 0x50] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_0010185b: MOV RAX,qword ptr [RSP + 0x88] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018fa ADD RSP,0x98 MOV RAX,RBX POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101890: MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R12 MOV RDI,RBX CALL 0x001011d0 MOV RDX,qword ptr [RBX] JMP 0x00101768 LAB_001018b0: MOV EAX,0xf JMP 0x0010175f LAB_001018c0: MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R12 MOV RDI,RBX CALL 0x001011d0 MOV RDX,qword ptr [RBX] JMP 0x0010181e LAB_001018e0: MOV EDX,0xf JMP 0x001016b3 LAB_001018f0: MOV EAX,0xf JMP 0x00101815 LAB_001018fa: CALL 0x00101170
/* func0(std::string) */ long * func0(long *param_1,int8 *param_2) { ulong uVar1; long *plVar2; ulong uVar3; char cVar4; int uVar5; char *pcVar6; long lVar7; ulong uVar8; long *plVar9; char *pcVar10; long in_FS_OFFSET; ulong *local_88; ulong local_80; ulong local_78 [2]; long *local_68 [2]; long local_58 [3]; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); local_88 = local_78; std::string::_M_construct<char_const*>((char *)&local_88,"",0x10205a); pcVar10 = (char *)*param_2; pcVar6 = pcVar10 + param_2[1]; if (pcVar10 != pcVar6) { do { cVar4 = *pcVar10; local_68[0] = local_58; /* try { // try from 0010165e to 001016fd has its CatchHandler @ 0010190b */ std::string::_M_construct<char_const*>((char *)local_68,"aeiouAEIOU",0x10200e); lVar7 = std::string::find((char)local_68,(ulong)(uint)(int)cVar4); if (local_68[0] != local_58) { operator_delete(local_68[0],local_58[0] + 1); } uVar3 = local_80; if (lVar7 != -1) { uVar1 = local_80 + 1; uVar8 = local_78[0]; if (local_88 == local_78) { uVar8 = 0xf; } if (uVar8 < uVar1) { std::string::_M_mutate((ulong)&local_88,local_80,(char *)0x0,0); } *(char *)((long)local_88 + uVar3) = cVar4; *(int *)((long)local_88 + uVar3 + 1) = 0; local_80 = uVar1; } pcVar10 = pcVar10 + 1; } while (pcVar6 != pcVar10); } plVar2 = param_1 + 2; *param_1 = (long)plVar2; std::string::_M_construct<char_const*>((char *)param_1,"",0x10205a); pcVar10 = (char *)*param_2; pcVar6 = pcVar10 + param_2[1]; if (pcVar6 != pcVar10) { do { while( true ) { cVar4 = *pcVar10; local_68[0] = local_58; /* try { // try from 001017bb to 001018d4 has its CatchHandler @ 001018ff */ std::string::_M_construct<char_const*>((char *)local_68,"aeiouAEIOU",0x10200e); lVar7 = std::string::find((char)local_68,(ulong)(uint)(int)cVar4); if (local_68[0] != local_58) { operator_delete(local_68[0],local_58[0] + 1); } uVar1 = param_1[1]; plVar9 = (long *)*param_1; uVar3 = uVar1 + 1; if (lVar7 != -1) break; if (plVar2 == plVar9) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar3) { std::string::_M_mutate((ulong)param_1,uVar1,(char *)0x0,0); plVar9 = (long *)*param_1; } *(char *)((long)plVar9 + uVar1) = cVar4; pcVar10 = pcVar10 + 1; param_1[1] = uVar3; *(int *)(*param_1 + 1 + uVar1) = 0; if (pcVar6 == pcVar10) goto LAB_0010183e; } uVar5 = *(int *)((long)local_88 + (local_80 - 1)); if (plVar2 == plVar9) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar3) { std::string::_M_mutate((ulong)param_1,uVar1,(char *)0x0,0); plVar9 = (long *)*param_1; } *(int *)((long)plVar9 + uVar1) = uVar5; pcVar10 = pcVar10 + 1; param_1[1] = uVar3; *(int *)(*param_1 + 1 + uVar1) = 0; std::string::_M_erase((ulong)&local_88,local_80 - 1); } while (pcVar6 != pcVar10); } LAB_0010183e: if (local_88 != local_78) { operator_delete(local_88,local_78[0] + 1); } if (local_40 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
523
func0
#include <iostream> #include <string> #include <assert.h>
std::string func0(std::string str1) { std::string vowels = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { vowels += ch; } } std::string result_string = ""; for (char ch : str1) { if (std::string("aeiouAEIOU").find(ch) != std::string::npos) { result_string += vowels.back(); vowels.pop_back(); } else { result_string += ch; } } return result_string; }
int main() { assert(func0("Python") == "Python"); assert(func0("USA") == "ASU"); assert(func0("ab") == "ab"); return 0; }
O3
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >): endbr64 push %r15 push %r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x88,%rsp mov (%rsi),%rbp mov %rsi,0x20(%rsp) mov %fs:0x28,%rax mov %rax,0x78(%rsp) xor %eax,%eax lea 0x40(%rsp),%rax movb $0x0,0x40(%rsp) mov %rax,0x28(%rsp) mov %rax,0x30(%rsp) mov 0x8(%rsi),%rax movq $0x0,0x38(%rsp) lea 0x0(%rbp,%rax,1),%rcx mov %rcx,0x10(%rsp) cmp %rbp,%rcx je 1749 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x149> lea 0x50(%rsp),%rax lea 0x60(%rsp),%rbx mov %rax,0x8(%rsp) jmp 169b <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x9b> nopl (%rax) mov %r13b,(%rdx,%r14,1) mov 0x30(%rsp),%rax mov %r15,0x38(%rsp) movb $0x0,0x1(%rax,%r14,1) add $0x1,%rbp cmp %rbp,0x10(%rsp) je 1740 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x140> movsbl 0x0(%rbp),%esi mov 0x8(%rsp),%rdi mov $0x554f,%edx mov %rbx,0x50(%rsp) movabs $0x494541756f696561,%rax mov %dx,0x8(%rbx) xor %edx,%edx mov %rax,(%rbx) mov %esi,%r13d movq $0xa,0x58(%rsp) movb $0x0,0x6a(%rsp) callq 11b0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov 0x50(%rsp),%rdi mov %rax,%r14 cmp %rbx,%rdi je 16e9 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xe9> callq 1180 <_ZdlPv@plt> cmp $0xffffffffffffffff,%r14 je 168c <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8c> mov 0x38(%rsp),%r14 mov 0x30(%rsp),%rdx mov $0xf,%eax cmp 0x28(%rsp),%rdx cmovne 0x40(%rsp),%rax lea 0x1(%r14),%r15 cmp %rax,%r15 jbe 1678 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x78> lea 0x30(%rsp),%rdi mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r14,%rsi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov 0x30(%rsp),%rdx jmpq 1678 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x78> nopw 0x0(%rax,%rax,1) mov 0x20(%rsp),%rax mov 0x8(%rax),%rax lea 0x10(%r12),%rcx movb $0x0,0x10(%r12) lea 0x60(%rsp),%rbx mov %rcx,(%r12) mov %rcx,0x18(%rsp) mov 0x20(%rsp),%rcx movq $0x0,0x8(%r12) mov (%rcx),%rbp lea 0x50(%rsp),%rcx mov %rcx,0x8(%rsp) add %rbp,%rax mov %rax,0x10(%rsp) cmp %rbp,%rax jne 17f3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1f3> jmpq 189a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29a> mov 0x30(%rsp),%rcx mov 0x38(%rsp),%rax movzbl -0x1(%rcx,%rax,1),%r15d cmp %rdx,0x18(%rsp) je 18f0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2f0> mov 0x10(%r12),%rax cmp %rax,%r14 ja 18d0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2d0> mov %r15b,(%rdx,%r13,1) mov (%r12),%rax lea 0x30(%rsp),%rdi add $0x1,%rbp mov %r14,0x8(%r12) mov $0x1,%edx movb $0x0,0x1(%rax,%r13,1) mov 0x38(%rsp),%rax lea -0x1(%rax),%rsi callq 11a0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm@plt> cmp %rbp,0x10(%rsp) je 189a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29a> movsbl 0x0(%rbp),%esi mov 0x8(%rsp),%rdi mov %rbx,0x50(%rsp) xor %edx,%edx movabs $0x494541756f696561,%rax mov %rax,(%rbx) mov $0x554f,%eax mov %esi,%r15d mov %ax,0x8(%rbx) movq $0xa,0x58(%rsp) movb $0x0,0x6a(%rsp) callq 11b0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm@plt> mov 0x50(%rsp),%rdi cmp %rbx,%rdi je 1848 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x248> mov %rax,0x20(%rsp) callq 1180 <_ZdlPv@plt> mov 0x20(%rsp),%rax mov 0x8(%r12),%r13 mov (%r12),%rdx lea 0x1(%r13),%r14 cmp $0xffffffffffffffff,%rax jne 1790 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x190> cmp %rdx,0x18(%rsp) je 1920 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x320> mov 0x10(%r12),%rax cmp %rax,%r14 ja 1900 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x300> mov %r15b,(%rdx,%r13,1) mov (%r12),%rax add $0x1,%rbp mov %r14,0x8(%r12) movb $0x0,0x1(%rax,%r13,1) cmp %rbp,0x10(%rsp) jne 17f3 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1f3> mov 0x30(%rsp),%rdi cmp 0x28(%rsp),%rdi je 18ab <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2ab> callq 1180 <_ZdlPv@plt> mov 0x78(%rsp),%rax xor %fs:0x28,%rax jne 192a <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x32a> add $0x88,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r13,%rsi mov %r12,%rdi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov (%r12),%rdx jmpq 17b9 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b9> xchg %ax,%ax mov $0xf,%eax jmpq 17b0 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b0> nopw 0x0(%rax,%rax,1) mov $0x1,%r8d xor %ecx,%ecx xor %edx,%edx mov %r13,%rsi mov %r12,%rdi callq 11f0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm@plt> mov (%r12),%rdx jmpq 1878 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x278> xchg %ax,%ax mov $0xf,%eax jmpq 186f <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x26f> callq 1190 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1200 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold> endbr64 mov %rax,%rbp jmpq 1210 <_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold+0x10> nopw 0x0(%rax,%rax,1)
_Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push r15 push r14 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 88h mov r12, [rsi] mov [rsp+0B8h+var_A0], rsi lea rcx, [rsp+0B8h+var_68] lea rbx, [rsp+0B8h+var_58] mov rax, fs:28h mov [rsp+0B8h+var_40], rax xor eax, eax lea rax, [rsp+0B8h+var_78] mov byte ptr [rsp+0B8h+var_78], 0 mov [rsp+0B8h+var_90], rax mov [rsp+0B8h+var_88], rax mov rax, [rsi+8] mov [rsp+0B8h+var_80], 0 add rax, r12 mov [rsp+0B8h+var_B0], rcx mov [rsp+0B8h+var_A8], rax cmp r12, rax jnz short loc_162B jmp loc_16E0 loc_1608: mov [rax+r14], r13b mov rax, [rsp+0B8h+var_88] mov [rsp+0B8h+var_80], r15 mov byte ptr [rax+r14+1], 0 loc_161C: add r12, 1 cmp [rsp+0B8h+var_A8], r12 jz loc_16E0 loc_162B: mov edx, 554Fh movsx esi, byte ptr [r12] mov [rsp+0B8h+var_68], rbx mov rax, 494541756F696561h mov [rbx+8], dx mov rdi, [rsp+0B8h+var_B0] xor edx, edx mov [rbx], rax mov r13d, esi mov [rsp+0B8h+var_60], 0Ah mov [rsp+0B8h+var_4E], 0 call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov rdi, [rsp+0B8h+var_68]; void * mov r14, rax cmp rdi, rbx jz short loc_1683 mov rax, [rsp+0B8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1683: cmp r14, 0FFFFFFFFFFFFFFFFh jz short loc_161C mov r14, [rsp+0B8h+var_80] mov rax, [rsp+0B8h+var_88] mov rcx, [rsp+0B8h+var_90] lea r15, [r14+1] cmp rax, rcx jz loc_18E0 mov rdx, [rsp+0B8h+var_78] loc_16AA: cmp rdx, r15 jnb loc_1608 lea rdi, [rsp+0B8h+var_88] mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r14 mov [rsp+0B8h+var_98], rdi call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rax, [rsp+0B8h+var_88] jmp loc_1608 loc_16E0: lea rax, [rbp+10h] mov byte ptr [rbp+10h], 0 lea rcx, [rsp+0B8h+var_68] mov [rbp+0], rax lea rbx, [rsp+0B8h+var_58] mov [rsp+0B8h+var_98], rax mov rax, [rsp+0B8h+var_A0] mov qword ptr [rbp+8], 0 mov r12, [rax] mov rax, [rax+8] mov [rsp+0B8h+var_B0], rcx add rax, r12 mov [rsp+0B8h+var_A0], rax cmp rax, r12 jnz short loc_1791 jmp loc_183F loc_1730: mov rcx, [rsp+0B8h+var_88] mov rax, [rsp+0B8h+var_80] movzx r15d, byte ptr [rcx+rax-1] cmp [rsp+0B8h+var_98], rdx jz loc_18B0 mov rax, [rbp+10h] loc_174F: cmp rax, r14 jb loc_1888 loc_1758: mov [rdx+r13], r15b mov rax, [rbp+0] lea rdi, [rsp+0B8h+var_88] add r12, 1 mov [rbp+8], r14 mov edx, 1 mov byte ptr [rax+r13+1], 0 mov rax, [rsp+0B8h+var_80] lea rsi, [rax-1] call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm; std::string::_M_erase(ulong,ulong) cmp [rsp+0B8h+var_A0], r12 jz loc_183F loc_1791: movsx esi, byte ptr [r12] mov rdi, [rsp+0B8h+var_B0] mov [rsp+0B8h+var_68], rbx xor edx, edx mov rax, 494541756F696561h mov [rbx], rax mov eax, 554Fh mov r15d, esi mov [rbx+8], ax mov [rsp+0B8h+var_60], 0Ah mov [rsp+0B8h+var_4E], 0 call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm; std::string::find(char,ulong) mov rdi, [rsp+0B8h+var_68]; void * cmp rdi, rbx jz short loc_17F0 mov [rsp+0B8h+var_A8], rax mov rax, [rsp+0B8h+var_58] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) mov rax, [rsp+0B8h+var_A8] loc_17F0: mov r13, [rbp+8] mov rdx, [rbp+0] lea r14, [r13+1] cmp rax, 0FFFFFFFFFFFFFFFFh jnz loc_1730 cmp [rsp+0B8h+var_98], rdx jz loc_18F0 mov rax, [rbp+10h] loc_1815: cmp rax, r14 jb loc_18C0 loc_181E: mov [rdx+r13], r15b mov rax, [rbp+0] add r12, 1 mov [rbp+8], r14 mov byte ptr [rax+r13+1], 0 cmp [rsp+0B8h+var_A0], r12 jnz loc_1791 loc_183F: mov rdi, [rsp+0B8h+var_88]; void * mov rax, [rsp+0B8h+var_90] cmp rdi, rax jz short loc_185C mov rax, [rsp+0B8h+var_78] lea rsi, [rax+1]; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_185C: mov rax, [rsp+0B8h+var_40] sub rax, fs:28h jnz loc_18FA add rsp, 88h mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1888: mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r13 mov rdi, rbp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rdx, [rbp+0] jmp loc_1758 loc_18B0: mov eax, 0Fh jmp loc_174F loc_18C0: mov r8d, 1 xor ecx, ecx xor edx, edx mov rsi, r13 mov rdi, rbp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm; std::string::_M_mutate(ulong,ulong,char const*,ulong) mov rdx, [rbp+0] jmp loc_181E loc_18E0: mov edx, 0Fh jmp loc_16AA loc_18F0: mov eax, 0Fh jmp loc_1815 loc_18FA: call ___stack_chk_fail endbr64 mov rbx, rax jmp loc_11F2 endbr64 mov rbx, rax jmp _Z5func0NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE_cold; func0(std::string) [clone]
_QWORD * func0(_QWORD *a1, char **a2) { char *v2; // r12 char *v3; // rax long long v4; // rsi long long v5; // r14 unsigned long long v6; // r14 _BYTE *v7; // rax unsigned long long v8; // r15 unsigned long long v9; // rdx char *v10; // r12 char *v11; // rax char v12; // r15 unsigned long long v13; // rax _BYTE *v14; // rax long long v15; // rsi long long v16; // rax long long v17; // r13 unsigned long long v18; // r14 unsigned long long v19; // rax _BYTE *v20; // rax _QWORD *v22; // rdx char *i; // [rsp+10h] [rbp-A8h] long long v24; // [rsp+10h] [rbp-A8h] char *v26; // [rsp+18h] [rbp-A0h] _QWORD *v27; // [rsp+20h] [rbp-98h] void *v28; // [rsp+30h] [rbp-88h] BYREF unsigned long long v29; // [rsp+38h] [rbp-80h] _QWORD v30[2]; // [rsp+40h] [rbp-78h] BYREF void *v31; // [rsp+50h] [rbp-68h] BYREF long long v32; // [rsp+58h] [rbp-60h] _QWORD v33[11]; // [rsp+60h] [rbp-58h] BYREF v2 = *a2; v33[3] = __readfsqword(0x28u); LOBYTE(v30[0]) = 0; v28 = v30; v3 = a2[1]; v29 = 0LL; for ( i = &v3[(_QWORD)v2]; i != v2; ++v2 ) { v4 = (unsigned int)*v2; v31 = v33; strcpy((char *)v33, "aeiouAEIOU"); v32 = 10LL; v5 = std::string::find(&v31, v4, 0LL); if ( v31 != v33 ) operator delete(v31, v33[0] + 1LL); if ( v5 != -1 ) { v6 = v29; v7 = v28; v8 = v29 + 1; if ( v28 == v30 ) v9 = 15LL; else v9 = v30[0]; if ( v9 < v8 ) { std::string::_M_mutate(&v28, v29, 0LL, 0LL, 1LL); v7 = v28; } v7[v6] = v4; v29 = v8; *((_BYTE *)v28 + v6 + 1) = 0; } } *((_BYTE *)a1 + 16) = 0; *a1 = a1 + 2; v27 = a1 + 2; a1[1] = 0LL; v10 = *a2; v11 = a2[1]; v26 = &v11[(_QWORD)*a2]; if ( &v11[(_QWORD)v10] != v10 ) { do { while ( 1 ) { v15 = (unsigned int)*v10; v31 = v33; strcpy((char *)v33, "aeiouAEIOU"); v32 = 10LL; v16 = std::string::find(&v31, v15, 0LL); if ( v31 != v33 ) { v24 = v16; operator delete(v31, v33[0] + 1LL); v16 = v24; } v17 = a1[1]; v22 = (_QWORD *)*a1; v18 = v17 + 1; if ( v16 != -1 ) break; if ( v27 == v22 ) v19 = 15LL; else v19 = a1[2]; if ( v19 < v18 ) { std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); v22 = (_QWORD *)*a1; } *((_BYTE *)v22 + v17) = v15; v20 = (_BYTE *)*a1; ++v10; a1[1] = v18; v20[v17 + 1] = 0; if ( v26 == v10 ) goto LABEL_27; } v12 = *((char *)v28 + v29 - 1); if ( v27 == v22 ) v13 = 15LL; else v13 = a1[2]; if ( v13 < v18 ) { std::string::_M_mutate(a1, a1[1], 0LL, 0LL, 1LL); v22 = (_QWORD *)*a1; } *((_BYTE *)v22 + v17) = v12; v14 = (_BYTE *)*a1; ++v10; a1[1] = v18; v14[v17 + 1] = 0; std::string::_M_erase(&v28, v29 - 1, 1LL); } while ( v26 != v10 ); } LABEL_27: if ( v28 != v30 ) operator delete(v28, v30[0] + 1LL); return a1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x88 MOV R12,qword ptr [RSI] MOV qword ptr [RSP + 0x18],RSI LEA RCX,[RSP + 0x50] LEA RBX,[RSP + 0x60] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x78],RAX XOR EAX,EAX LEA RAX,[RSP + 0x40] MOV byte ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x28],RAX MOV qword ptr [RSP + 0x30],RAX MOV RAX,qword ptr [RSI + 0x8] MOV qword ptr [RSP + 0x38],0x0 ADD RAX,R12 MOV qword ptr [RSP + 0x8],RCX MOV qword ptr [RSP + 0x10],RAX CMP R12,RAX JNZ 0x0010162b JMP 0x001016e0 LAB_00101608: MOV byte ptr [RAX + R14*0x1],R13B MOV RAX,qword ptr [RSP + 0x30] MOV qword ptr [RSP + 0x38],R15 MOV byte ptr [RAX + R14*0x1 + 0x1],0x0 LAB_0010161c: ADD R12,0x1 CMP qword ptr [RSP + 0x10],R12 JZ 0x001016e0 LAB_0010162b: MOV EDX,0x554f MOVSX ESI,byte ptr [R12] MOV qword ptr [RSP + 0x50],RBX MOV RAX,0x494541756f696561 MOV word ptr [RBX + 0x8],DX MOV RDI,qword ptr [RSP + 0x8] XOR EDX,EDX MOV qword ptr [RBX],RAX MOV R13D,ESI MOV qword ptr [RSP + 0x58],0xa MOV byte ptr [RSP + 0x6a],0x0 CALL 0x001011a0 MOV RDI,qword ptr [RSP + 0x50] MOV R14,RAX CMP RDI,RBX JZ 0x00101683 MOV RAX,qword ptr [RSP + 0x60] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_00101683: CMP R14,-0x1 JZ 0x0010161c MOV R14,qword ptr [RSP + 0x38] MOV RAX,qword ptr [RSP + 0x30] MOV RCX,qword ptr [RSP + 0x28] LEA R15,[R14 + 0x1] CMP RAX,RCX JZ 0x001018e0 MOV RDX,qword ptr [RSP + 0x40] LAB_001016aa: CMP RDX,R15 JNC 0x00101608 LEA RDI,[RSP + 0x30] MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R14 MOV qword ptr [RSP + 0x20],RDI LAB_001016ca: CALL 0x001011d0 MOV RAX,qword ptr [RSP + 0x30] JMP 0x00101608 LAB_001016e0: LEA RAX,[RBP + 0x10] MOV byte ptr [RBP + 0x10],0x0 LEA RCX,[RSP + 0x50] MOV qword ptr [RBP],RAX LEA RBX,[RSP + 0x60] MOV qword ptr [RSP + 0x20],RAX MOV RAX,qword ptr [RSP + 0x18] MOV qword ptr [RBP + 0x8],0x0 MOV R12,qword ptr [RAX] MOV RAX,qword ptr [RAX + 0x8] MOV qword ptr [RSP + 0x8],RCX ADD RAX,R12 MOV qword ptr [RSP + 0x18],RAX CMP RAX,R12 JNZ 0x00101791 JMP 0x0010183f LAB_00101730: MOV RCX,qword ptr [RSP + 0x30] MOV RAX,qword ptr [RSP + 0x38] MOVZX R15D,byte ptr [RCX + RAX*0x1 + -0x1] CMP qword ptr [RSP + 0x20],RDX JZ 0x001018b0 MOV RAX,qword ptr [RBP + 0x10] LAB_0010174f: CMP RAX,R14 JC 0x00101888 LAB_00101758: MOV byte ptr [RDX + R13*0x1],R15B MOV RAX,qword ptr [RBP] LEA RDI,[RSP + 0x30] ADD R12,0x1 MOV qword ptr [RBP + 0x8],R14 MOV EDX,0x1 MOV byte ptr [RAX + R13*0x1 + 0x1],0x0 MOV RAX,qword ptr [RSP + 0x38] LEA RSI,[RAX + -0x1] CALL 0x00101180 CMP qword ptr [RSP + 0x18],R12 JZ 0x0010183f LAB_00101791: MOVSX ESI,byte ptr [R12] MOV RDI,qword ptr [RSP + 0x8] MOV qword ptr [RSP + 0x50],RBX XOR EDX,EDX MOV RAX,0x494541756f696561 MOV qword ptr [RBX],RAX MOV EAX,0x554f MOV R15D,ESI MOV word ptr [RBX + 0x8],AX MOV qword ptr [RSP + 0x58],0xa MOV byte ptr [RSP + 0x6a],0x0 CALL 0x001011a0 MOV RDI,qword ptr [RSP + 0x50] CMP RDI,RBX JZ 0x001017f0 MOV qword ptr [RSP + 0x10],RAX MOV RAX,qword ptr [RSP + 0x60] LEA RSI,[RAX + 0x1] CALL 0x00101160 MOV RAX,qword ptr [RSP + 0x10] LAB_001017f0: MOV R13,qword ptr [RBP + 0x8] MOV RDX,qword ptr [RBP] LEA R14,[R13 + 0x1] CMP RAX,-0x1 JNZ 0x00101730 CMP qword ptr [RSP + 0x20],RDX JZ 0x001018f0 MOV RAX,qword ptr [RBP + 0x10] LAB_00101815: CMP RAX,R14 JC 0x001018c0 LAB_0010181e: MOV byte ptr [RDX + R13*0x1],R15B MOV RAX,qword ptr [RBP] ADD R12,0x1 MOV qword ptr [RBP + 0x8],R14 MOV byte ptr [RAX + R13*0x1 + 0x1],0x0 CMP qword ptr [RSP + 0x18],R12 JNZ 0x00101791 LAB_0010183f: MOV RDI,qword ptr [RSP + 0x30] MOV RAX,qword ptr [RSP + 0x28] CMP RDI,RAX JZ 0x0010185c MOV RAX,qword ptr [RSP + 0x40] LEA RSI,[RAX + 0x1] CALL 0x00101160 LAB_0010185c: MOV RAX,qword ptr [RSP + 0x78] SUB RAX,qword ptr FS:[0x28] JNZ 0x001018fa ADD RSP,0x88 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101888: MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R13 MOV RDI,RBP LAB_00101898: CALL 0x001011d0 MOV RDX,qword ptr [RBP] JMP 0x00101758 LAB_001018b0: MOV EAX,0xf JMP 0x0010174f LAB_001018c0: MOV R8D,0x1 XOR ECX,ECX XOR EDX,EDX MOV RSI,R13 MOV RDI,RBP CALL 0x001011d0 MOV RDX,qword ptr [RBP] JMP 0x0010181e LAB_001018e0: MOV EDX,0xf JMP 0x001016aa LAB_001018f0: MOV EAX,0xf JMP 0x00101815 LAB_001018fa: CALL 0x00101170
/* func0(std::string) */ long * func0(long *param_1,int8 *param_2) { long *plVar1; ulong uVar2; int uVar3; char cVar4; ulong uVar5; char *pcVar6; long lVar7; ulong uVar8; long *plVar9; char *pcVar10; long in_FS_OFFSET; int *local_88; ulong local_80; int local_78; int7 uStack_77; long *local_68; int8 local_60; long local_58; int2 local_50; int local_4e; long local_40; pcVar10 = (char *)*param_2; local_40 = *(long *)(in_FS_OFFSET + 0x28); local_78 = 0; local_80 = 0; pcVar6 = pcVar10 + param_2[1]; local_88 = &local_78; for (; pcVar10 != pcVar6; pcVar10 = pcVar10 + 1) { cVar4 = *pcVar10; local_50 = 0x554f; local_58 = 0x494541756f696561; local_60 = 10; local_4e = 0; local_68 = &local_58; lVar7 = std::string::find((char)&local_68,(ulong)(uint)(int)cVar4); if (local_68 != &local_58) { operator_delete(local_68,local_58 + 1); } uVar2 = local_80; if (lVar7 != -1) { uVar5 = local_80 + 1; if (local_88 == &local_78) { uVar8 = 0xf; } else { uVar8 = CONCAT71(uStack_77,local_78); } if (uVar8 < uVar5) { /* try { // try from 001016ca to 001016ce has its CatchHandler @ 001018ff */ std::string::_M_mutate((ulong)&local_88,local_80,(char *)0x0,0); } local_88[uVar2] = cVar4; local_88[uVar2 + 1] = 0; local_80 = uVar5; } } plVar1 = param_1 + 2; *(int *)(param_1 + 2) = 0; *param_1 = (long)plVar1; param_1[1] = 0; pcVar10 = (char *)*param_2; pcVar6 = pcVar10 + param_2[1]; for (; pcVar6 != pcVar10; pcVar10 = pcVar10 + 1) { while( true ) { cVar4 = *pcVar10; local_58 = 0x494541756f696561; local_50 = 0x554f; local_60 = 10; local_4e = 0; local_68 = &local_58; lVar7 = std::string::find((char)&local_68,(ulong)(uint)(int)cVar4); if (local_68 != &local_58) { operator_delete(local_68,local_58 + 1); } uVar5 = param_1[1]; plVar9 = (long *)*param_1; uVar2 = uVar5 + 1; if (lVar7 != -1) break; if (plVar1 == plVar9) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar2) { std::string::_M_mutate((ulong)param_1,uVar5,(char *)0x0,0); plVar9 = (long *)*param_1; } *(char *)((long)plVar9 + uVar5) = cVar4; pcVar10 = pcVar10 + 1; param_1[1] = uVar2; *(int *)(*param_1 + 1 + uVar5) = 0; if (pcVar6 == pcVar10) goto LAB_0010183f; } uVar3 = local_88[local_80 - 1]; if (plVar1 == plVar9) { uVar8 = 0xf; } else { uVar8 = param_1[2]; } if (uVar8 < uVar2) { /* try { // try from 00101898 to 001018d4 has its CatchHandler @ 0010190b */ std::string::_M_mutate((ulong)param_1,uVar5,(char *)0x0,0); plVar9 = (long *)*param_1; } *(int *)((long)plVar9 + uVar5) = uVar3; param_1[1] = uVar2; *(int *)(*param_1 + 1 + uVar5) = 0; std::string::_M_erase((ulong)&local_88,local_80 - 1); } LAB_0010183f: if (local_88 != &local_78) { operator_delete(local_88,CONCAT71(uStack_77,local_78) + 1); } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
524
func0
#include <string> #include <cassert>
std::string func0(const char* tup[], int size) { std::string str; for (int i = 0; i < size; ++i) { str += tup[i]; } return str; }
int main() { const char* tuple1[] = {"e", "x", "e", "r", "c", "i", "s", "e", "s"}; const char* tuple2[] = {"p", "y", "t", "h", "o", "n"}; const char* tuple3[] = {"p", "r", "o", "g", "r", "a", "m"}; assert(func0(tuple1, 9) == "exercises"); assert(func0(tuple2, 6) == "python"); assert(func0(tuple3, 7) == "program"); return 0; }
O0
cpp
func0[abi:cxx11](char const**, int): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %rdi,-0x28(%rbp) mov %rsi,-0x30(%rbp) mov %edx,-0x34(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x28(%rbp),%rax mov %rax,%rdi callq 1100 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev@plt> movl $0x0,-0x1c(%rbp) mov -0x1c(%rbp),%eax cmp -0x34(%rbp),%eax jge 1295 <_Z5func0B5cxx11PPKci+0x8c> mov -0x1c(%rbp),%eax cltq lea 0x0(,%rax,8),%rdx mov -0x30(%rbp),%rax add %rdx,%rax mov (%rax),%rdx mov -0x28(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 10e0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc@plt> addl $0x1,-0x1c(%rbp) jmp 1243 <_Z5func0B5cxx11PPKci+0x3a> endbr64 mov %rax,%rbx mov -0x28(%rbp),%rax mov %rax,%rdi callq 10c0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 1110 <_Unwind_Resume@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 12aa <_Z5func0B5cxx11PPKci+0xa1> callq 10f0 <__stack_chk_fail@plt> mov -0x28(%rbp),%rax add $0x38,%rsp pop %rbx pop %rbp retq
_Z5func0B5cxx11PPKci: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 38h mov [rbp+var_28], rdi mov [rbp+var_30], rsi mov [rbp+var_34], edx mov rax, [rbp+var_28] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev; std::string::basic_string(void) mov [rbp+var_14], 0 jmp short loc_12C0 loc_1296: mov eax, [rbp+var_14] cdqe lea rdx, ds:0[rax*8] mov rax, [rbp+var_30] add rax, rdx mov rdx, [rax] mov rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc; std::string::operator+=(char const*) add [rbp+var_14], 1 loc_12C0: mov eax, [rbp+var_14] cmp eax, [rbp+var_34] jl short loc_1296 jmp short loc_12E8 endbr64 mov rbx, rax mov rax, [rbp+var_28] mov rdi, rax call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev; std::string::~string() mov rax, rbx mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_12E8: mov rax, [rbp+var_28] mov rbx, [rbp+var_8] leave retn
long long func0[abi:cxx11](long long a1, long long a2, int a3) { int i; // [rsp+2Ch] [rbp-14h] std::string::basic_string(a1); for ( i = 0; i < a3; ++i ) std::string::operator+=(a1, *(_QWORD *)(8LL * i + a2)); return a1; }
func0[abi:cxx11]: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x38 MOV qword ptr [RBP + -0x28],RDI MOV qword ptr [RBP + -0x30],RSI MOV dword ptr [RBP + -0x34],EDX MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x00101160 MOV dword ptr [RBP + -0x14],0x0 JMP 0x001012c0 LAB_00101296: MOV EAX,dword ptr [RBP + -0x14] CDQE LEA RDX,[RAX*0x8] MOV RAX,qword ptr [RBP + -0x30] ADD RAX,RDX MOV RDX,qword ptr [RAX] MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RDX MOV RDI,RAX LAB_001012b7: CALL 0x00101130 ADD dword ptr [RBP + -0x14],0x1 LAB_001012c0: MOV EAX,dword ptr [RBP + -0x14] CMP EAX,dword ptr [RBP + -0x34] JL 0x00101296 JMP 0x001012e8 LAB_001012e8: MOV RAX,qword ptr [RBP + -0x28] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0[abi:cxx11](char const**, int) */ char ** func0_abi_cxx11_(char **param_1,int param_2) { int in_EDX; int4 in_register_00000034; int4 local_1c; std::string::string((string *)param_1); for (local_1c = 0; local_1c < in_EDX; local_1c = local_1c + 1) { /* try { // try from 001012b7 to 001012bb has its CatchHandler @ 001012ca */ std::string::operator+= ((string *)param_1, *(char **)(CONCAT44(in_register_00000034,param_2) + (long)local_1c * 8)); } return param_1; }
525
func0
#include <string> #include <cassert>
std::string func0(const char* tup[], int size) { std::string str; for (int i = 0; i < size; ++i) { str += tup[i]; } return str; }
int main() { const char* tuple1[] = {"e", "x", "e", "r", "c", "i", "s", "e", "s"}; const char* tuple2[] = {"p", "y", "t", "h", "o", "n"}; const char* tuple3[] = {"p", "r", "o", "g", "r", "a", "m"}; assert(func0(tuple1, 9) == "exercises"); assert(func0(tuple2, 6) == "python"); assert(func0(tuple3, 7) == "program"); return 0; }
O1
cpp
func0[abi:cxx11](char const**, int): endbr64 push %r14 push %r13 push %r12 push %rbp push %rbx mov %rdi,%rbp lea 0x10(%rdi),%r14 mov %r14,(%rdi) movq $0x0,0x8(%rdi) movb $0x0,0x10(%rdi) test %edx,%edx jle 12a9 <_Z5func0B5cxx11PPKci+0xa0> mov %rsi,%rbx lea -0x1(%rdx),%eax lea 0x8(%rsi,%rax,8),%r13 movabs $0x3fffffffffffffff,%r12 jmp 1278 <_Z5func0B5cxx11PPKci+0x6f> lea 0xdb7(%rip),%rdi callq 10d0 <_ZSt20__throw_length_errorPKc@plt> endbr64 mov %rax,%rbx mov 0x0(%rbp),%rdi cmp %rdi,%r14 je 1267 <_Z5func0B5cxx11PPKci+0x5e> callq 10f0 <_ZdlPv@plt> mov %rbx,%rdi callq 1110 <_Unwind_Resume@plt> add $0x8,%rbx cmp %r13,%rbx je 12a9 <_Z5func0B5cxx11PPKci+0xa0> mov (%rbx),%rsi mov $0xffffffffffffffff,%rcx mov $0x0,%eax mov %rsi,%rdi repnz scas %es:(%rdi),%al not %rcx lea -0x1(%rcx),%rdx mov %r12,%rax sub 0x8(%rbp),%rax cmp %rax,%rdx ja 1246 <_Z5func0B5cxx11PPKci+0x3d> mov %rbp,%rdi callq 10c0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> jmp 126f <_Z5func0B5cxx11PPKci+0x66> mov %rbp,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 retq
_Z5func0B5cxx11PPKci: endbr64 push r14 push r13 push r12 push rbp push rbx mov r12, rdi lea rax, [rdi+10h] mov [rdi], rax mov qword ptr [rdi+8], 0 mov byte ptr [rdi+10h], 0 test edx, edx jle short loc_12B9 mov rbx, rsi movsxd rdx, edx lea r14, [rsi+rdx*8] mov r13, 3FFFFFFFFFFFFFFFh jmp short loc_1291 loc_1265: lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) endbr64 mov rbx, rax mov rdi, r12 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv; std::string::_M_dispose(void) mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_1288: add rbx, 8 cmp rbx, r14 jz short loc_12B9 loc_1291: mov rbp, [rbx] mov rdi, rbp; s call _strlen mov rdx, rax mov rax, r13 sub rax, [r12+8] cmp rax, rdx jb short loc_1265 mov rsi, rbp mov rdi, r12 call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) jmp short loc_1288 loc_12B9: mov rax, r12 pop rbx pop rbp pop r12 pop r13 pop r14 retn
long long func0[abi:cxx11](long long a1, const char **a2, int a3) { const char **v3; // rbx const char **v4; // r14 const char *v5; // rbp *(_QWORD *)a1 = a1 + 16; *(_QWORD *)(a1 + 8) = 0LL; *(_BYTE *)(a1 + 16) = 0; if ( a3 > 0 ) { v3 = a2; v4 = &a2[a3]; do { v5 = *v3; if ( 0x3FFFFFFFFFFFFFFFLL - *(_QWORD *)(a1 + 8) < strlen(*v3) ) std::__throw_length_error("basic_string::append"); std::string::_M_append(a1, v5); ++v3; } while ( v3 != v4 ); } return a1; }
func0[abi:cxx11]: ENDBR64 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX MOV R12,RDI LEA RAX,[RDI + 0x10] MOV qword ptr [RDI],RAX MOV qword ptr [RDI + 0x8],0x0 MOV byte ptr [RDI + 0x10],0x0 TEST EDX,EDX JLE 0x001012b9 MOV RBX,RSI MOVSXD RDX,EDX LEA R14,[RSI + RDX*0x8] MOV R13,0x3fffffffffffffff JMP 0x00101291 LAB_00101265: LEA RDI,[0x102004] LAB_0010126c: CALL 0x001010f0 LAB_00101271: ENDBR64 MOV RBX,RAX MOV RDI,R12 CALL 0x00101120 MOV RDI,RBX LAB_00101283: CALL 0x00101130 LAB_00101288: ADD RBX,0x8 CMP RBX,R14 JZ 0x001012b9 LAB_00101291: MOV RBP,qword ptr [RBX] MOV RDI,RBP CALL 0x001010d0 MOV RDX,RAX MOV RAX,R13 SUB RAX,qword ptr [R12 + 0x8] CMP RAX,RDX JC 0x00101265 MOV RSI,RBP MOV RDI,R12 LAB_001012b2: CALL 0x001010c0 JMP 0x00101288 LAB_001012b9: MOV RAX,R12 POP RBX POP RBP POP R12 POP R13 POP R14 RET
/* func0[abi:cxx11](char const**, int) */ char ** func0_abi_cxx11_(char **param_1,int param_2) { int8 *puVar1; char *__s; int8 uVar2; size_t sVar3; int in_EDX; int8 *puVar4; int4 in_register_00000034; puVar4 = (int8 *)CONCAT44(in_register_00000034,param_2); *param_1 = (char *)(param_1 + 2); param_1[1] = (char *)0x0; *(int *)(param_1 + 2) = 0; if (0 < in_EDX) { puVar1 = puVar4 + in_EDX; do { __s = (char *)*puVar4; sVar3 = strlen(__s); if (0x3fffffffffffffffU - (long)param_1[1] < sVar3) { /* try { // try from 0010126c to 00101270 has its CatchHandler @ 00101271 */ uVar2 = std::__throw_length_error("basic_string::append"); /* catch() { ... } // from try @ 0010126c with catch @ 00101271 catch() { ... } // from try @ 001012b2 with catch @ 00101271 */ std::string::_M_dispose(); /* WARNING: Subroutine does not return */ _Unwind_Resume(uVar2); } /* try { // try from 001012b2 to 001012b6 has its CatchHandler @ 00101271 */ std::string::_M_append((char *)param_1,(ulong)__s); puVar4 = puVar4 + 1; } while (puVar4 != puVar1); } return param_1; }
526
func0
#include <string> #include <cassert>
std::string func0(const char* tup[], int size) { std::string str; for (int i = 0; i < size; ++i) { str += tup[i]; } return str; }
int main() { const char* tuple1[] = {"e", "x", "e", "r", "c", "i", "s", "e", "s"}; const char* tuple2[] = {"p", "y", "t", "h", "o", "n"}; const char* tuple3[] = {"p", "r", "o", "g", "r", "a", "m"}; assert(func0(tuple1, 9) == "exercises"); assert(func0(tuple2, 6) == "python"); assert(func0(tuple3, 7) == "program"); return 0; }
O2
cpp
func0[abi:cxx11](char const**, int): endbr64 push %r15 push %r14 lea 0x10(%rdi),%r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x8,%rsp mov %r14,(%rdi) movq $0x0,0x8(%rdi) movb $0x0,0x10(%rdi) test %edx,%edx jle 1517 <_Z5func0B5cxx11PPKci+0x77> movabs $0x3fffffffffffffff,%rbp lea -0x1(%rdx),%eax mov %rsi,%rbx lea 0x8(%rsi,%rax,8),%r13 nopl 0x0(%rax) mov (%rbx),%r15 mov %r15,%rdi callq 10e0 <strlen@plt> mov %rax,%rdx mov %rbp,%rax sub 0x8(%r12),%rax cmp %rax,%rdx ja 1529 <_Z5func0B5cxx11PPKci+0x89> mov %r15,%rsi mov %r12,%rdi callq 10d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> add $0x8,%rbx cmp %r13,%rbx jne 14e8 <_Z5func0B5cxx11PPKci+0x48> add $0x8,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0xad4(%rip),%rdi callq 10f0 <_ZSt20__throw_length_errorPKc@plt> endbr64 mov %rax,%rbp jmpq 1140 <_Z5func0B5cxx11PPKci.cold> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
_Z5func0B5cxx11PPKci: endbr64 push r15 lea rax, [rdi+10h] push r14 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 8 mov [rdi], rax mov qword ptr [rdi+8], 0 mov byte ptr [rdi+10h], 0 test edx, edx jle short loc_1529 movsxd rdx, edx mov rbx, rsi xor r12d, r12d mov r13, 3FFFFFFFFFFFFFFFh lea r14, [rsi+rdx*8] jmp short loc_14FC loc_14F8: mov r12, [rbp+8] loc_14FC: mov r15, [rbx] mov rdi, r15; s call _strlen mov rdx, rax mov rax, r13 sub rax, r12 cmp rax, rdx jb short loc_153B mov rsi, r15 mov rdi, rbp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) add rbx, 8 cmp rbx, r14 jnz short loc_14F8 loc_1529: add rsp, 8 mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_153B: lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) endbr64 mov rbx, rax jmp _Z5func0B5cxx11PPKci_cold; func0(char const**,int) [clone]
long long func0[abi:cxx11](long long a1, const char **a2, int a3) { const char **v3; // rbx long long v4; // r12 const char **v5; // r14 const char *v6; // r15 *(_QWORD *)a1 = a1 + 16; *(_QWORD *)(a1 + 8) = 0LL; *(_BYTE *)(a1 + 16) = 0; if ( a3 > 0 ) { v3 = a2; v4 = 0LL; v5 = &a2[a3]; while ( 1 ) { v6 = *v3; if ( 0x3FFFFFFFFFFFFFFFLL - v4 < strlen(*v3) ) std::__throw_length_error("basic_string::append"); std::string::_M_append(a1, v6); if ( ++v3 == v5 ) break; v4 = *(_QWORD *)(a1 + 8); } } return a1; }
func0[abi:cxx11]: ENDBR64 PUSH R15 LEA RAX,[RDI + 0x10] PUSH R14 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x8 MOV qword ptr [RDI],RAX MOV qword ptr [RDI + 0x8],0x0 MOV byte ptr [RDI + 0x10],0x0 TEST EDX,EDX JLE 0x00101529 MOVSXD RDX,EDX MOV RBX,RSI XOR R12D,R12D MOV R13,0x3fffffffffffffff LEA R14,[RSI + RDX*0x8] JMP 0x001014fc LAB_001014f8: MOV R12,qword ptr [RBP + 0x8] LAB_001014fc: MOV R15,qword ptr [RBX] MOV RDI,R15 CALL 0x001010d0 MOV RDX,RAX MOV RAX,R13 SUB RAX,R12 CMP RAX,RDX JC 0x0010153b MOV RSI,R15 MOV RDI,RBP LAB_0010151b: CALL 0x001010c0 ADD RBX,0x8 CMP RBX,R14 JNZ 0x001014f8 LAB_00101529: ADD RSP,0x8 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010153b: LEA RDI,[0x102004] CALL 0x001010f0 LAB_00101547: ENDBR64 MOV RBX,RAX JMP 0x00101140
/* func0[abi:cxx11](char const**, int) */ char ** func0_abi_cxx11_(char **param_1,int param_2) { char *pcVar1; size_t sVar2; char **ppcVar3; int in_EDX; char *pcVar4; int iVar5; int4 in_register_00000034; char *__s; char *pcVar6; pcVar4 = (char *)CONCAT44(in_register_00000034,param_2); *param_1 = (char *)(param_1 + 2); param_1[1] = (char *)0x0; *(int *)(param_1 + 2) = 0; if (0 < in_EDX) { pcVar6 = (char *)0x0; pcVar1 = pcVar4 + (long)in_EDX * 8; __s = pcVar4; while( true ) { iVar5 = (int)__s; __s = *(char **)pcVar4; sVar2 = strlen(__s); if (0x3fffffffffffffffU - (long)pcVar6 < sVar2) { pcVar4 = "basic_string::append"; std::__throw_length_error("basic_string::append"); /* catch() { ... } // from try @ 0010151b with catch @ 00101547 */ ppcVar3 = (char **)func0_abi_cxx11_((char **)pcVar4,iVar5); return ppcVar3; } /* try { // try from 0010151b to 00101546 has its CatchHandler @ 00101547 */ std::string::_M_append((char *)param_1,(ulong)__s); pcVar4 = pcVar4 + 8; if (pcVar4 == pcVar1) break; pcVar6 = param_1[1]; } } return param_1; }
527
func0
#include <string> #include <cassert>
std::string func0(const char* tup[], int size) { std::string str; for (int i = 0; i < size; ++i) { str += tup[i]; } return str; }
int main() { const char* tuple1[] = {"e", "x", "e", "r", "c", "i", "s", "e", "s"}; const char* tuple2[] = {"p", "y", "t", "h", "o", "n"}; const char* tuple3[] = {"p", "r", "o", "g", "r", "a", "m"}; assert(func0(tuple1, 9) == "exercises"); assert(func0(tuple2, 6) == "python"); assert(func0(tuple3, 7) == "program"); return 0; }
O3
cpp
func0[abi:cxx11](char const**, int): endbr64 push %r15 push %r14 lea 0x10(%rdi),%r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x8,%rsp mov %r14,(%rdi) movq $0x0,0x8(%rdi) movb $0x0,0x10(%rdi) test %edx,%edx jle 1557 <_Z5func0B5cxx11PPKci+0x77> movabs $0x3fffffffffffffff,%rbp lea -0x1(%rdx),%eax mov %rsi,%rbx lea 0x8(%rsi,%rax,8),%r13 nopl 0x0(%rax) mov (%rbx),%r15 mov %r15,%rdi callq 10e0 <strlen@plt> mov %rax,%rdx mov %rbp,%rax sub 0x8(%r12),%rax cmp %rax,%rdx ja 1569 <_Z5func0B5cxx11PPKci+0x89> mov %r15,%rsi mov %r12,%rdi callq 10d0 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@plt> add $0x8,%rbx cmp %rbx,%r13 jne 1528 <_Z5func0B5cxx11PPKci+0x48> add $0x8,%rsp mov %r12,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq lea 0xa94(%rip),%rdi callq 10f0 <_ZSt20__throw_length_errorPKc@plt> endbr64 mov %rax,%rbp jmpq 1140 <_Z5func0B5cxx11PPKci.cold> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax,%rax,1)
_Z5func0B5cxx11PPKci: endbr64 push r15 lea rax, [rdi+10h] push r14 push r13 push r12 push rbp mov rbp, rdi push rbx sub rsp, 8 mov [rdi], rax mov qword ptr [rdi+8], 0 mov byte ptr [rdi+10h], 0 test edx, edx jle short loc_1529 movsxd rdx, edx mov rbx, rsi xor r12d, r12d mov r13, 3FFFFFFFFFFFFFFFh lea r14, [rsi+rdx*8] jmp short loc_14FC loc_14F8: mov r12, [rbp+8] loc_14FC: mov r15, [rbx] mov rdi, r15; s call _strlen mov rdx, rax mov rax, r13 sub rax, r12 cmp rax, rdx jb short loc_153B mov rsi, r15 mov rdi, rbp call __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm; std::string::_M_append(char const*,ulong) add rbx, 8 cmp r14, rbx jnz short loc_14F8 loc_1529: add rsp, 8 mov rax, rbp pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_153B: lea rdi, aBasicStringApp; "basic_string::append" call __ZSt20__throw_length_errorPKc; std::__throw_length_error(char const*) endbr64 mov rbx, rax jmp _Z5func0B5cxx11PPKci_cold; func0(char const**,int) [clone]
long long func0[abi:cxx11](long long a1, const char **a2, int a3) { const char **v3; // rbx long long v4; // r12 const char **v5; // r14 const char *v6; // r15 *(_QWORD *)a1 = a1 + 16; *(_QWORD *)(a1 + 8) = 0LL; *(_BYTE *)(a1 + 16) = 0; if ( a3 > 0 ) { v3 = a2; v4 = 0LL; v5 = &a2[a3]; while ( 1 ) { v6 = *v3; if ( 0x3FFFFFFFFFFFFFFFLL - v4 < strlen(*v3) ) std::__throw_length_error("basic_string::append"); std::string::_M_append(a1, v6); if ( v5 == ++v3 ) break; v4 = *(_QWORD *)(a1 + 8); } } return a1; }
func0[abi:cxx11]: ENDBR64 PUSH R15 LEA RAX,[RDI + 0x10] PUSH R14 PUSH R13 PUSH R12 PUSH RBP MOV RBP,RDI PUSH RBX SUB RSP,0x8 MOV qword ptr [RDI],RAX MOV qword ptr [RDI + 0x8],0x0 MOV byte ptr [RDI + 0x10],0x0 TEST EDX,EDX JLE 0x00101529 MOVSXD RDX,EDX MOV RBX,RSI XOR R12D,R12D MOV R13,0x3fffffffffffffff LEA R14,[RSI + RDX*0x8] JMP 0x001014fc LAB_001014f8: MOV R12,qword ptr [RBP + 0x8] LAB_001014fc: MOV R15,qword ptr [RBX] MOV RDI,R15 CALL 0x001010d0 MOV RDX,RAX MOV RAX,R13 SUB RAX,R12 CMP RAX,RDX JC 0x0010153b MOV RSI,R15 MOV RDI,RBP LAB_0010151b: CALL 0x001010c0 ADD RBX,0x8 CMP R14,RBX JNZ 0x001014f8 LAB_00101529: ADD RSP,0x8 MOV RAX,RBP POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_0010153b: LEA RDI,[0x102004] CALL 0x001010f0 LAB_00101547: ENDBR64 MOV RBX,RAX JMP 0x00101140
/* func0[abi:cxx11](char const**, int) */ char ** func0_abi_cxx11_(char **param_1,int param_2) { char *pcVar1; size_t sVar2; char **ppcVar3; int in_EDX; char *pcVar4; int iVar5; int4 in_register_00000034; char *__s; char *pcVar6; pcVar4 = (char *)CONCAT44(in_register_00000034,param_2); *param_1 = (char *)(param_1 + 2); param_1[1] = (char *)0x0; *(int *)(param_1 + 2) = 0; if (0 < in_EDX) { pcVar6 = (char *)0x0; pcVar1 = pcVar4 + (long)in_EDX * 8; __s = pcVar4; while( true ) { iVar5 = (int)__s; __s = *(char **)pcVar4; sVar2 = strlen(__s); if (0x3fffffffffffffffU - (long)pcVar6 < sVar2) { pcVar4 = "basic_string::append"; std::__throw_length_error("basic_string::append"); /* catch() { ... } // from try @ 0010151b with catch @ 00101547 */ ppcVar3 = (char **)func0_abi_cxx11_((char **)pcVar4,iVar5); return ppcVar3; } /* try { // try from 0010151b to 00101546 has its CatchHandler @ 00101547 */ std::string::_M_append((char *)param_1,(ulong)__s); pcVar4 = pcVar4 + 8; if (pcVar1 == pcVar4) break; pcVar6 = param_1[1]; } } return param_1; }
528
func0
#include <vector> #include <numeric> #include <assert.h>
int func0(const std::vector<int>& nums) { std::vector<int> negatives; for (int num : nums) { if (num < 0) { negatives.push_back(num); } } return std::accumulate(negatives.begin(), negatives.end(), 0); }
int main() { assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == -32); assert(func0({10, 15, -14, 13, -18, 12, -20}) == -52); assert(func0({19, -65, 57, 39, 152, -639, 121, 44, 90, -190}) == -894); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x58,%rsp mov %rdi,-0x58(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax lea -0x30(%rbp),%rax mov %rax,%rdi callq 1708 <_ZNSt6vectorIiSaIiEEC1Ev> mov -0x58(%rbp),%rax mov %rax,-0x38(%rbp) mov -0x38(%rbp),%rax mov %rax,%rdi callq 180e <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x48(%rbp) mov -0x38(%rbp),%rax mov %rax,%rdi callq 1866 <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x40(%rbp) lea -0x40(%rbp),%rdx lea -0x48(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 18be <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 12cd <_Z5func0RKSt6vectorIiSaIiEE+0xa4> lea -0x48(%rbp),%rax mov %rax,%rdi callq 1922 <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0x4c(%rbp) mov -0x4c(%rbp),%eax test %eax,%eax jns 12bf <_Z5func0RKSt6vectorIiSaIiEE+0x96> lea -0x4c(%rbp),%rdx lea -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1938 <_ZNSt6vectorIiSaIiEE9push_backERKi> lea -0x48(%rbp),%rax mov %rax,%rdi callq 18fe <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmp 127d <_Z5func0RKSt6vectorIiSaIiEE+0x54> lea -0x30(%rbp),%rax mov %rax,%rdi callq 1a04 <_ZNSt6vectorIiSaIiEE3endEv> mov %rax,%rbx lea -0x30(%rbp),%rax mov %rax,%rdi callq 19b8 <_ZNSt6vectorIiSaIiEE5beginEv> mov $0x0,%edx mov %rbx,%rsi mov %rax,%rdi callq 1a54 <_ZSt10accumulateIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET0_T_S8_S7_> mov %eax,%ebx lea -0x30(%rbp),%rax mov %rax,%rdi callq 17c6 <_ZNSt6vectorIiSaIiEED1Ev> mov %ebx,%eax mov -0x18(%rbp),%rcx xor %fs:0x28,%rcx je 133d <_Z5func0RKSt6vectorIiSaIiEE+0x114> jmp 1338 <_Z5func0RKSt6vectorIiSaIiEE+0x10f> endbr64 mov %rax,%rbx lea -0x30(%rbp),%rax mov %rax,%rdi callq 17c6 <_ZNSt6vectorIiSaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 1130 <_Unwind_Resume@plt> callq 1110 <__stack_chk_fail@plt> add $0x58,%rsp pop %rbx pop %rbp retq
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 58h mov [rbp+var_58], rdi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEEC2Ev; std::vector<int>::vector(void) mov rax, [rbp+var_58] mov [rbp+var_38], rax mov rax, [rbp+var_38] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_48], rax mov rax, [rbp+var_38] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_40], rax jmp short loc_12D6 loc_129F: lea rax, [rbp+var_48] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov [rbp+var_4C], eax mov eax, [rbp+var_4C] test eax, eax jns short loc_12CA lea rdx, [rbp+var_4C] lea rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) loc_12CA: lea rax, [rbp+var_48] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_12D6: lea rdx, [rbp+var_40] lea rax, [rbp+var_48] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz short loc_129F lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov rbx, rax lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov edx, 0 mov rsi, rbx mov rdi, rax call _ZSt10accumulateIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEiET0_T_S8_S7_; std::accumulate<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int) mov ebx, eax nop lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov eax, ebx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1371 jmp short loc_136C endbr64 mov rbx, rax lea rax, [rbp+var_30] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1364 call ___stack_chk_fail loc_1364: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_136C: call ___stack_chk_fail loc_1371: mov rbx, [rbp+var_8] leave retn
long long func0(long long a1) { long long v1; // rbx long long v2; // rax int v4; // [rsp+14h] [rbp-4Ch] BYREF long long v5; // [rsp+18h] [rbp-48h] BYREF _QWORD v6[2]; // [rsp+20h] [rbp-40h] BYREF _BYTE v7[24]; // [rsp+30h] [rbp-30h] BYREF unsigned long long v8; // [rsp+48h] [rbp-18h] v8 = __readfsqword(0x28u); std::vector<int>::vector(v7); v6[1] = a1; v5 = std::vector<int>::begin(a1); v6[0] = std::vector<int>::end(a1); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(&v5, v6) ) { v4 = *(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(&v5); if ( v4 < 0 ) std::vector<int>::push_back(v7, &v4); __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(&v5); } v1 = std::vector<int>::end(v7); v2 = std::vector<int>::begin(v7); LODWORD(v1) = std::accumulate<__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int>(v2, v1, 0LL); std::vector<int>::~vector(v7); return (unsigned int)v1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x58 MOV qword ptr [RBP + -0x58],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101782 MOV RAX,qword ptr [RBP + -0x58] MOV qword ptr [RBP + -0x38],RAX MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x00101880 MOV qword ptr [RBP + -0x48],RAX MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x001018cc MOV qword ptr [RBP + -0x40],RAX JMP 0x001012d6 LAB_0010129f: LEA RAX,[RBP + -0x48] MOV RDI,RAX CALL 0x00101980 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x4c],EAX MOV EAX,dword ptr [RBP + -0x4c] TEST EAX,EAX JNS 0x001012ca LEA RDX,[RBP + -0x4c] LEA RAX,[RBP + -0x30] MOV RSI,RDX MOV RDI,RAX LAB_001012c5: CALL 0x00101996 LAB_001012ca: LEA RAX,[RBP + -0x48] MOV RDI,RAX CALL 0x0010195c LAB_001012d6: LEA RDX,[RBP + -0x40] LEA RAX,[RBP + -0x48] MOV RSI,RDX MOV RDI,RAX CALL 0x0010191c TEST AL,AL JNZ 0x0010129f LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101aae MOV RBX,RAX LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101a62 MOV EDX,0x0 MOV RSI,RBX MOV RDI,RAX CALL 0x00101afe MOV EBX,EAX NOP LEA RAX,[RBP + -0x30] MOV RDI,RAX CALL 0x00101826 MOV EAX,EBX MOV RDX,qword ptr [RBP + -0x18] SUB RDX,qword ptr FS:[0x28] JZ 0x00101371 JMP 0x0010136c LAB_0010136c: CALL 0x00101130 LAB_00101371: MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<int, std::allocator<int> > const&) */ int4 func0(vector *param_1) { bool bVar1; int4 uVar2; int *piVar3; int8 uVar4; int8 uVar5; long in_FS_OFFSET; int local_54; int8 local_50; int8 local_48; vector<int,std::allocator<int>> *local_40; vector<int,std::allocator<int>> local_38 [24]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); std::vector<int,std::allocator<int>>::vector(local_38); local_40 = (vector<int,std::allocator<int>> *)param_1; local_50 = std::vector<int,std::allocator<int>>::begin((vector<int,std::allocator<int>> *)param_1) ; local_48 = std::vector<int,std::allocator<int>>::end(local_40); while( true ) { bVar1 = operator!=((__normal_iterator *)&local_50,(__normal_iterator *)&local_48); if (!bVar1) break; piVar3 = (int *)__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> * )&local_50); local_54 = *piVar3; if (local_54 < 0) { /* try { // try from 001012c5 to 001012c9 has its CatchHandler @ 0010133a */ std::vector<int,std::allocator<int>>::push_back(local_38,&local_54); } __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_50); } uVar4 = std::vector<int,std::allocator<int>>::end(local_38); uVar5 = std::vector<int,std::allocator<int>>::begin(local_38); uVar2 = std::accumulate<__normal_iterator<int*,std::vector<int,std::allocator<int>>>,int> (uVar5,uVar4,0); std::vector<int,std::allocator<int>>::~vector(local_38); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return uVar2; }
529
func0
#include <vector> #include <numeric> #include <assert.h>
int func0(const std::vector<int>& nums) { std::vector<int> negatives; for (int num : nums) { if (num < 0) { negatives.push_back(num); } } return std::accumulate(negatives.begin(), negatives.end(), 0); }
int main() { assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == -32); assert(func0({10, 15, -14, 13, -18, 12, -20}) == -52); assert(func0({19, -65, 57, 39, 152, -639, 121, 44, 90, -190}) == -894); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r12 push %rbp push %rbx sub $0x30,%rsp mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax movq $0x0,0x10(%rsp) movq $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) mov (%rdi),%rbx mov 0x8(%rdi),%rbp cmp %rbx,%rbp je 12a9 <_Z5func0RKSt6vectorIiSaIiEE+0x80> lea 0xc(%rsp),%r12 jmp 1289 <_Z5func0RKSt6vectorIiSaIiEE+0x60> lea 0x10(%rsp),%rdi mov %r12,%rdx callq 1644 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> add $0x4,%rbx cmp %rbx,%rbp je 12a9 <_Z5func0RKSt6vectorIiSaIiEE+0x80> mov (%rbx),%eax mov %eax,0xc(%rsp) test %eax,%eax jns 1280 <_Z5func0RKSt6vectorIiSaIiEE+0x57> mov 0x18(%rsp),%rsi cmp 0x20(%rsp),%rsi je 1273 <_Z5func0RKSt6vectorIiSaIiEE+0x4a> mov %eax,(%rsi) addq $0x4,0x18(%rsp) jmp 1280 <_Z5func0RKSt6vectorIiSaIiEE+0x57> mov 0x18(%rsp),%rdx mov 0x10(%rsp),%rdi cmp %rdx,%rdi je 12f0 <_Z5func0RKSt6vectorIiSaIiEE+0xc7> mov %rdi,%rax mov $0x0,%ebx add (%rax),%ebx add $0x4,%rax cmp %rax,%rdx jne 12c0 <_Z5func0RKSt6vectorIiSaIiEE+0x97> test %rdi,%rdi je 12d5 <_Z5func0RKSt6vectorIiSaIiEE+0xac> callq 10f0 <_ZdlPv@plt> mov 0x28(%rsp),%rax xor %fs:0x28,%rax jne 1315 <_Z5func0RKSt6vectorIiSaIiEE+0xec> mov %ebx,%eax add $0x30,%rsp pop %rbx pop %rbp pop %r12 retq mov $0x0,%ebx jmp 12cb <_Z5func0RKSt6vectorIiSaIiEE+0xa2> endbr64 mov %rax,%rbx mov 0x10(%rsp),%rdi test %rdi,%rdi je 130d <_Z5func0RKSt6vectorIiSaIiEE+0xe4> callq 10f0 <_ZdlPv@plt> mov %rbx,%rdi callq 1130 <_Unwind_Resume@plt> callq 1110 <__stack_chk_fail@plt>
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push rbp push rbx sub rsp, 38h mov rax, fs:28h mov [rsp+48h+var_20], rax xor eax, eax mov [rsp+48h+var_38], 0 mov [rsp+48h+var_30], 0 mov [rsp+48h+var_28], 0 mov rbx, [rdi] mov rbp, [rdi+8] cmp rbx, rbp jnz short loc_12CF loc_126A: mov rdx, [rsp+48h+var_30] mov rdi, [rsp+48h+var_38]; void * cmp rdi, rdx jz short loc_12F2 mov rax, rdi mov ebx, 0 loc_1281: add ebx, [rax] add rax, 4 cmp rax, rdx jnz short loc_1281 loc_128C: test rdi, rdi jz short loc_129E mov rsi, [rsp+48h+var_28] sub rsi, rdi; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_129E: mov rax, [rsp+48h+var_20] sub rax, fs:28h jnz short loc_1327 mov eax, ebx add rsp, 38h pop rbx pop rbp retn loc_12B7: lea rdx, [rsp+48h+var_3C] lea rdi, [rsp+48h+var_38] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) loc_12C6: add rbx, 4 cmp rbp, rbx jz short loc_126A loc_12CF: mov eax, [rbx] mov [rsp+48h+var_3C], eax test eax, eax jns short loc_12C6 mov rsi, [rsp+48h+var_30] cmp rsi, [rsp+48h+var_28] jz short loc_12B7 mov [rsi], eax add rsi, 4 mov [rsp+48h+var_30], rsi jmp short loc_12C6 loc_12F2: mov ebx, 0 jmp short loc_128C endbr64 mov rbx, rax lea rdi, [rsp+arg_8] call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, [rsp+arg_20] sub rax, fs:28h jz short loc_131F call ___stack_chk_fail loc_131F: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_1327: call ___stack_chk_fail
long long func0(int **a1) { int *v1; // rbx int *v2; // rbp int *v3; // rax unsigned int v4; // ebx int v6; // eax int *v7; // rsi int v8; // [rsp+Ch] [rbp-3Ch] BYREF void *v9; // [rsp+10h] [rbp-38h] BYREF int *v10; // [rsp+18h] [rbp-30h] int *v11; // [rsp+20h] [rbp-28h] unsigned long long v12; // [rsp+28h] [rbp-20h] v12 = __readfsqword(0x28u); v9 = 0LL; v10 = 0LL; v11 = 0LL; v1 = *a1; v2 = a1[1]; if ( *a1 != v2 ) { do { v6 = *v1; v8 = v6; if ( v6 < 0 ) { v7 = v10; if ( v10 == v11 ) { std::vector<int>::_M_realloc_insert<int const&>(&v9, v10, &v8); } else { *v10 = v6; v10 = v7 + 1; } } ++v1; } while ( v2 != v1 ); } if ( v9 == v10 ) { v4 = 0; } else { v3 = (int *)v9; v4 = 0; do v4 += *v3++; while ( v3 != v10 ); } if ( v9 ) operator delete(v9, (char *)v11 - (_BYTE *)v9); return v4; }
func0: ENDBR64 PUSH RBP PUSH RBX SUB RSP,0x38 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX XOR EAX,EAX MOV qword ptr [RSP + 0x10],0x0 MOV qword ptr [RSP + 0x18],0x0 MOV qword ptr [RSP + 0x20],0x0 MOV RBX,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] CMP RBX,RBP JNZ 0x001012cf LAB_0010126a: MOV RDX,qword ptr [RSP + 0x18] MOV RDI,qword ptr [RSP + 0x10] CMP RDI,RDX JZ 0x001012f2 MOV RAX,RDI MOV EBX,0x0 LAB_00101281: ADD EBX,dword ptr [RAX] ADD RAX,0x4 CMP RAX,RDX JNZ 0x00101281 LAB_0010128c: TEST RDI,RDI JZ 0x0010129e MOV RSI,qword ptr [RSP + 0x20] SUB RSI,RDI CALL 0x00101100 LAB_0010129e: MOV RAX,qword ptr [RSP + 0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101327 MOV EAX,EBX ADD RSP,0x38 POP RBX POP RBP RET LAB_001012b7: LEA RDX,[RSP + 0xc] LEA RDI,[RSP + 0x10] LAB_001012c1: CALL 0x001016b0 LAB_001012c6: ADD RBX,0x4 CMP RBP,RBX JZ 0x0010126a LAB_001012cf: MOV EAX,dword ptr [RBX] MOV dword ptr [RSP + 0xc],EAX TEST EAX,EAX JNS 0x001012c6 MOV RSI,qword ptr [RSP + 0x18] CMP RSI,qword ptr [RSP + 0x20] JZ 0x001012b7 MOV dword ptr [RSI],EAX ADD RSI,0x4 MOV qword ptr [RSP + 0x18],RSI JMP 0x001012c6 LAB_001012f2: MOV EBX,0x0 JMP 0x0010128c LAB_00101327: CALL 0x00101110
/* func0(std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1) { int *piVar1; int *piVar2; int iVar3; long in_FS_OFFSET; int local_3c; int *local_38; int *local_30; int *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_38 = (int *)0x0; local_30 = (int *)0x0; local_28 = (int *)0x0; piVar1 = *(int **)(param_1 + 8); for (piVar2 = *(int **)param_1; piVar2 != piVar1; piVar2 = piVar2 + 1) { local_3c = *piVar2; if (local_3c < 0) { if (local_30 == local_28) { /* try { // try from 001012c1 to 001012c5 has its CatchHandler @ 001012f9 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_38,(__normal_iterator)local_30, &local_3c); } else { *local_30 = local_3c; local_30 = local_30 + 1; } } } if (local_38 == local_30) { iVar3 = 0; } else { iVar3 = 0; piVar2 = local_38; do { iVar3 = iVar3 + *piVar2; piVar2 = piVar2 + 1; } while (piVar2 != local_30); } if (local_38 != (int *)0x0) { operator_delete(local_38,(long)local_28 - (long)local_38); } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return iVar3; }
530
func0
#include <vector> #include <numeric> #include <assert.h>
int func0(const std::vector<int>& nums) { std::vector<int> negatives; for (int num : nums) { if (num < 0) { negatives.push_back(num); } } return std::accumulate(negatives.begin(), negatives.end(), 0); }
int main() { assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == -32); assert(func0({10, 15, -14, 13, -18, 12, -20}) == -52); assert(func0({19, -65, 57, 39, 152, -639, 121, 44, 90, -190}) == -894); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r12 xor %esi,%esi push %rbp push %rbx sub $0x30,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r12 mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax lea 0xc(%rsp),%rbp movq $0x0,0x10(%rsp) movq $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) cmp %r12,%rbx jne 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0x59> jmpq 1570 <_Z5func0RKSt6vectorIiSaIiEE+0xe0> add $0x4,%rbx cmp %rbx,%r12 je 150e <_Z5func0RKSt6vectorIiSaIiEE+0x7e> mov (%rbx),%eax mov %eax,0xc(%rsp) test %eax,%eax jns 14e0 <_Z5func0RKSt6vectorIiSaIiEE+0x50> cmp 0x20(%rsp),%rsi je 1558 <_Z5func0RKSt6vectorIiSaIiEE+0xc8> mov %eax,(%rsi) add $0x4,%rbx add $0x4,%rsi mov %rsi,0x18(%rsp) cmp %rbx,%r12 jne 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0x59> mov 0x10(%rsp),%rdi cmp %rdi,%rsi je 1578 <_Z5func0RKSt6vectorIiSaIiEE+0xe8> mov %rdi,%rax xor %r12d,%r12d xchg %ax,%ax add (%rax),%r12d add $0x4,%rax cmp %rax,%rsi jne 1520 <_Z5func0RKSt6vectorIiSaIiEE+0x90> test %rdi,%rdi je 1536 <_Z5func0RKSt6vectorIiSaIiEE+0xa6> callq 10f0 <_ZdlPv@plt> mov 0x28(%rsp),%rax xor %fs:0x28,%rax jne 157d <_Z5func0RKSt6vectorIiSaIiEE+0xed> add $0x30,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 retq nopw 0x0(%rax,%rax,1) lea 0x10(%rsp),%rdi mov %rbp,%rdx callq 1650 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x18(%rsp),%rsi jmpq 14e0 <_Z5func0RKSt6vectorIiSaIiEE+0x50> xor %r12d,%r12d jmp 1536 <_Z5func0RKSt6vectorIiSaIiEE+0xa6> nopl (%rax) xor %r12d,%r12d jmp 152c <_Z5func0RKSt6vectorIiSaIiEE+0x9c> callq 1110 <__stack_chk_fail@plt> endbr64 mov %rax,%rbp jmpq 1140 <_Z5func0RKSt6vectorIiSaIiEE.cold> xchg %ax,%ax
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push r12 pxor xmm0, xmm0 xor edx, edx xor esi, esi push rbp push rbx sub rsp, 30h mov rbx, [rdi] mov rbp, [rdi+8] mov rax, fs:28h mov [rsp+48h+var_20], rax xor eax, eax movaps xmmword ptr [rsp+48h+var_38], xmm0 mov [rsp+48h+var_28], 0 cmp rbx, rbp jnz short loc_1491 jmp loc_1528 loc_1488: add rbx, 4 cmp rbp, rbx jz short loc_14B4 loc_1491: mov eax, [rbx] mov [rsp+48h+var_3C], eax test eax, eax jns short loc_1488 cmp rsi, rdx jz short loc_1500 mov [rsi], eax add rbx, 4 add rsi, 4 mov [rsp+48h+var_38+8], rsi cmp rbp, rbx jnz short loc_1491 loc_14B4: mov rdi, [rsp+48h+var_38]; void * cmp rsi, rdi jz short loc_152C mov rax, rdi xor ebx, ebx nop dword ptr [rax+rax+00h] loc_14C8: add ebx, [rax] add rax, 4 cmp rsi, rax jnz short loc_14C8 loc_14D3: test rdi, rdi jz short loc_14E3 sub rdx, rdi mov rsi, rdx; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_14E3: mov rax, [rsp+48h+var_20] sub rax, fs:28h jnz short loc_1530 add rsp, 30h mov eax, ebx pop rbx pop rbp pop r12 retn loc_1500: lea r12, [rsp+48h+var_38] lea rdx, [rsp+48h+var_3C] mov rdi, r12 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rsi, [rsp+48h+var_38+8] mov rdx, [rsp+48h+var_28] jmp loc_1488 loc_1528: xor ebx, ebx jmp short loc_14E3 loc_152C: xor ebx, ebx jmp short loc_14D3 loc_1530: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIiSaIiEE_cold; func0(std::vector<int> const&) [clone]
long long func0(int **a1) { int *v1; // rdx int *v2; // rsi int *v3; // rbx int *v4; // rbp int v5; // eax int *v6; // rax unsigned int v8; // ebx int v9; // [rsp+4h] [rbp-3Ch] BYREF void *v10[2]; // [rsp+8h] [rbp-38h] BYREF int *v11; // [rsp+18h] [rbp-28h] unsigned long long v12; // [rsp+20h] [rbp-20h] v1 = 0LL; v2 = 0LL; v3 = *a1; v4 = a1[1]; v12 = __readfsqword(0x28u); *(_OWORD *)v10 = 0LL; v11 = 0LL; if ( v3 == v4 ) return 0; do { while ( 1 ) { v5 = *v3; v9 = v5; if ( v5 < 0 ) break; LABEL_3: if ( v4 == ++v3 ) goto LABEL_7; } if ( v2 == v1 ) { std::vector<int>::_M_realloc_insert<int const&>(v10, v2, &v9); v2 = (int *)v10[1]; v1 = v11; goto LABEL_3; } *v2 = v5; ++v3; v10[1] = ++v2; } while ( v4 != v3 ); LABEL_7: if ( v2 == v10[0] ) { v8 = 0; } else { v6 = (int *)v10[0]; v8 = 0; do v8 += *v6++; while ( v2 != v6 ); } if ( v10[0] ) operator delete(v10[0], (char *)v1 - (char *)v10[0]); return v8; }
func0: ENDBR64 PUSH R12 PXOR XMM0,XMM0 XOR EDX,EDX XOR ESI,ESI PUSH RBP PUSH RBX SUB RSP,0x30 MOV RBX,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX XOR EAX,EAX MOVAPS xmmword ptr [RSP + 0x10],XMM0 MOV qword ptr [RSP + 0x20],0x0 CMP RBX,RBP JNZ 0x00101491 JMP 0x00101528 LAB_00101488: ADD RBX,0x4 CMP RBP,RBX JZ 0x001014b4 LAB_00101491: MOV EAX,dword ptr [RBX] MOV dword ptr [RSP + 0xc],EAX TEST EAX,EAX JNS 0x00101488 CMP RSI,RDX JZ 0x00101500 MOV dword ptr [RSI],EAX ADD RBX,0x4 ADD RSI,0x4 MOV qword ptr [RSP + 0x18],RSI CMP RBP,RBX JNZ 0x00101491 LAB_001014b4: MOV RDI,qword ptr [RSP + 0x10] CMP RSI,RDI JZ 0x0010152c MOV RAX,RDI XOR EBX,EBX NOP dword ptr [RAX + RAX*0x1] LAB_001014c8: ADD EBX,dword ptr [RAX] ADD RAX,0x4 CMP RSI,RAX JNZ 0x001014c8 LAB_001014d3: TEST RDI,RDI JZ 0x001014e3 SUB RDX,RDI MOV RSI,RDX CALL 0x00101100 LAB_001014e3: MOV RAX,qword ptr [RSP + 0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101530 ADD RSP,0x30 MOV EAX,EBX POP RBX POP RBP POP R12 RET LAB_00101500: LEA R12,[RSP + 0x10] LEA RDX,[RSP + 0xc] MOV RDI,R12 LAB_0010150d: CALL 0x00101660 MOV RSI,qword ptr [RSP + 0x18] MOV RDX,qword ptr [RSP + 0x20] JMP 0x00101488 LAB_00101528: XOR EBX,EBX JMP 0x001014e3 LAB_0010152c: XOR EBX,EBX JMP 0x001014d3 LAB_00101530: CALL 0x00101110
/* func0(std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1) { int *piVar1; int *piVar2; int *piVar3; int iVar4; int *piVar5; long in_FS_OFFSET; int local_3c; int *local_38; int *piStack_30; int *local_28; long local_20; piVar3 = (int *)0x0; piVar5 = (int *)0x0; piVar2 = *(int **)param_1; piVar1 = *(int **)(param_1 + 8); local_20 = *(long *)(in_FS_OFFSET + 0x28); local_38 = (int *)0x0; piStack_30 = (int *)0x0; local_28 = (int *)0x0; if (piVar2 == piVar1) { iVar4 = 0; } else { LAB_00101491: do { local_3c = *piVar2; if (local_3c < 0) { if (piVar5 != piVar3) { *piVar5 = local_3c; piVar2 = piVar2 + 1; piVar5 = piVar5 + 1; piStack_30 = piVar5; if (piVar1 == piVar2) break; goto LAB_00101491; } /* try { // try from 0010150d to 00101511 has its CatchHandler @ 00101535 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_38,(__normal_iterator)piVar5,&local_3c) ; piVar3 = local_28; piVar5 = piStack_30; } piVar2 = piVar2 + 1; } while (piVar1 != piVar2); if (piVar5 == local_38) { iVar4 = 0; } else { iVar4 = 0; piVar2 = local_38; do { iVar4 = iVar4 + *piVar2; piVar2 = piVar2 + 1; } while (piVar5 != piVar2); } if (local_38 != (int *)0x0) { operator_delete(local_38,(long)piVar3 - (long)local_38); } } if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar4; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
531
func0
#include <vector> #include <numeric> #include <assert.h>
int func0(const std::vector<int>& nums) { std::vector<int> negatives; for (int num : nums) { if (num < 0) { negatives.push_back(num); } } return std::accumulate(negatives.begin(), negatives.end(), 0); }
int main() { assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == -32); assert(func0({10, 15, -14, 13, -18, 12, -20}) == -52); assert(func0({19, -65, 57, 39, 152, -639, 121, 44, 90, -190}) == -894); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %r12 pxor %xmm0,%xmm0 push %rbp push %rbx sub $0x30,%rsp mov (%rdi),%rbx mov 0x8(%rdi),%r12 mov %fs:0x28,%rax mov %rax,0x28(%rsp) xor %eax,%eax movaps %xmm0,0x10(%rsp) movq $0x0,0x20(%rsp) cmp %r12,%rbx je 15c0 <_Z5func0RKSt6vectorIiSaIiEE+0x180> xor %esi,%esi lea 0xc(%rsp),%rbp jmp 1499 <_Z5func0RKSt6vectorIiSaIiEE+0x59> nopw 0x0(%rax,%rax,1) add $0x4,%rbx cmp %rbx,%r12 je 14c2 <_Z5func0RKSt6vectorIiSaIiEE+0x82> mov (%rbx),%eax mov %eax,0xc(%rsp) test %eax,%eax jns 1490 <_Z5func0RKSt6vectorIiSaIiEE+0x50> cmp 0x20(%rsp),%rsi je 15a0 <_Z5func0RKSt6vectorIiSaIiEE+0x160> mov %eax,(%rsi) add $0x4,%rbx add $0x4,%rsi mov %rsi,0x18(%rsp) cmp %rbx,%r12 jne 1499 <_Z5func0RKSt6vectorIiSaIiEE+0x59> mov 0x10(%rsp),%rdi cmp %rdi,%rsi je 15cf <_Z5func0RKSt6vectorIiSaIiEE+0x18f> lea -0x4(%rsi),%rdx mov %rdi,%rax movabs $0x3ffffffffffffffc,%r8 sub %rdi,%rdx shr $0x2,%rdx lea 0x1(%rdx),%rcx test %r8,%rdx je 15c5 <_Z5func0RKSt6vectorIiSaIiEE+0x185> mov %rcx,%rdx pxor %xmm0,%xmm0 shr $0x2,%rdx shl $0x4,%rdx add %rdi,%rdx nopw 0x0(%rax,%rax,1) movdqu (%rax),%xmm2 add $0x10,%rax paddd %xmm2,%xmm0 cmp %rdx,%rax jne 1510 <_Z5func0RKSt6vectorIiSaIiEE+0xd0> movdqa %xmm0,%xmm1 mov %rcx,%rdx psrldq $0x8,%xmm1 and $0xfffffffffffffffc,%rdx paddd %xmm1,%xmm0 lea (%rdi,%rdx,4),%rax movdqa %xmm0,%xmm1 psrldq $0x4,%xmm1 paddd %xmm1,%xmm0 movd %xmm0,%r12d cmp %rdx,%rcx je 157a <_Z5func0RKSt6vectorIiSaIiEE+0x13a> lea 0x4(%rax),%rdx add (%rax),%r12d cmp %rdx,%rsi je 157a <_Z5func0RKSt6vectorIiSaIiEE+0x13a> lea 0x8(%rax),%rdx add 0x4(%rax),%r12d cmp %rdx,%rsi je 157a <_Z5func0RKSt6vectorIiSaIiEE+0x13a> lea 0xc(%rax),%rdx add 0x8(%rax),%r12d cmp %rdx,%rsi je 157a <_Z5func0RKSt6vectorIiSaIiEE+0x13a> add 0xc(%rax),%r12d test %rdi,%rdi je 1584 <_Z5func0RKSt6vectorIiSaIiEE+0x144> callq 10f0 <_ZdlPv@plt> mov 0x28(%rsp),%rax xor %fs:0x28,%rax jne 15ca <_Z5func0RKSt6vectorIiSaIiEE+0x18a> add $0x30,%rsp mov %r12d,%eax pop %rbx pop %rbp pop %r12 retq lea 0x10(%rsp),%rdi mov %rbp,%rdx callq 1690 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> mov 0x18(%rsp),%rsi jmpq 1490 <_Z5func0RKSt6vectorIiSaIiEE+0x50> nopw 0x0(%rax,%rax,1) xor %r12d,%r12d jmp 1584 <_Z5func0RKSt6vectorIiSaIiEE+0x144> xor %r12d,%r12d jmp 1550 <_Z5func0RKSt6vectorIiSaIiEE+0x110> callq 1110 <__stack_chk_fail@plt> xor %r12d,%r12d jmp 157a <_Z5func0RKSt6vectorIiSaIiEE+0x13a> endbr64 mov %rax,%rbp jmpq 1140 <_Z5func0RKSt6vectorIiSaIiEE.cold>
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push r12 pxor xmm0, xmm0 xor r8d, r8d xor esi, esi push rbp push rbx sub rsp, 30h mov rbx, [rdi] mov rbp, [rdi+8] mov rax, fs:28h mov [rsp+48h+var_20], rax xor eax, eax movaps xmmword ptr [rsp+48h+var_38], xmm0 mov [rsp+48h+var_28], 0 cmp rbx, rbp jnz short loc_1491 jmp loc_15B0 loc_1488: add rbx, 4 cmp rbp, rbx jz short loc_14B8 loc_1491: mov eax, [rbx] mov [rsp+48h+var_3C], eax test eax, eax jns short loc_1488 cmp rsi, r8 jz loc_1588 mov [rsi], eax add rbx, 4 add rsi, 4 mov [rsp+48h+var_38+8], rsi cmp rbp, rbx jnz short loc_1491 loc_14B8: mov rdi, [rsp+48h+var_38]; void * cmp rsi, rdi jz loc_15B8 lea rdx, [rsi-4] mov rax, rdi sub rdx, rdi mov rcx, rdx shr rcx, 2 add rcx, 1 cmp rdx, 8 jbe loc_15B4 mov rdx, rcx pxor xmm0, xmm0 shr rdx, 2 shl rdx, 4 add rdx, rdi nop word ptr [rax+rax+00000000h] loc_1500: movdqu xmm2, xmmword ptr [rax] add rax, 10h paddd xmm0, xmm2 cmp rax, rdx jnz short loc_1500 movdqa xmm1, xmm0 psrldq xmm1, 8 paddd xmm0, xmm1 movdqa xmm1, xmm0 psrldq xmm1, 4 paddd xmm0, xmm1 movd ebx, xmm0 test cl, 3 jz short loc_1556 and rcx, 0FFFFFFFFFFFFFFFCh lea rax, [rdi+rcx*4] loc_153C: lea rdx, [rax+4] add ebx, [rax] cmp rsi, rdx jz short loc_1556 lea rdx, [rax+8] add ebx, [rax+4] cmp rsi, rdx jz short loc_1556 add ebx, [rax+8] loc_1556: test rdi, rdi jz short loc_1566 mov rsi, r8 sub rsi, rdi; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) loc_1566: mov rax, [rsp+48h+var_20] sub rax, fs:28h jnz short loc_15BC add rsp, 30h mov eax, ebx pop rbx pop rbp pop r12 retn loc_1588: lea r12, [rsp+48h+var_38] lea rdx, [rsp+48h+var_3C] mov rdi, r12 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rsi, [rsp+48h+var_38+8] mov r8, [rsp+48h+var_28] jmp loc_1488 loc_15B0: xor ebx, ebx jmp short loc_1566 loc_15B4: xor ebx, ebx jmp short loc_153C loc_15B8: xor ebx, ebx jmp short loc_1556 loc_15BC: call ___stack_chk_fail endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIiSaIiEE_cold; func0(std::vector<int> const&) [clone]
long long func0(int **a1) { int *v1; // r8 int *v2; // rsi int *v3; // rbx int *v4; // rbp int v5; // eax const __m128i *v6; // rax unsigned long long v7; // rcx __m128i v8; // xmm0 __m128i v9; // xmm2 __m128i v10; // xmm0 unsigned int v12; // ebx int v13; // [rsp+4h] [rbp-3Ch] BYREF void *v14[2]; // [rsp+8h] [rbp-38h] BYREF int *v15; // [rsp+18h] [rbp-28h] unsigned long long v16; // [rsp+20h] [rbp-20h] v1 = 0LL; v2 = 0LL; v3 = *a1; v4 = a1[1]; v16 = __readfsqword(0x28u); *(_OWORD *)v14 = 0LL; v15 = 0LL; if ( v3 == v4 ) return 0; do { while ( 1 ) { v5 = *v3; v13 = v5; if ( v5 < 0 ) break; LABEL_3: if ( v4 == ++v3 ) goto LABEL_7; } if ( v2 == v1 ) { std::vector<int>::_M_realloc_insert<int const&>(v14, v2, &v13); v2 = (int *)v14[1]; v1 = v15; goto LABEL_3; } *v2 = v5; ++v3; v14[1] = ++v2; } while ( v4 != v3 ); LABEL_7: if ( v2 == v14[0] ) { v12 = 0; } else { v6 = (const __m128i *)v14[0]; v7 = ((unsigned long long)((char *)(v2 - 1) - (char *)v14[0]) >> 2) + 1; if ( (unsigned long long)((char *)(v2 - 1) - (char *)v14[0]) <= 8 ) { v12 = 0; LABEL_13: v12 += v6->m128i_i32[0]; if ( v2 != (int *)((char *)v6->m128i_i64 + 4) ) { v12 += v6->m128i_u32[1]; if ( v2 != (int *)&v6->m128i_u64[1] ) v12 += v6->m128i_u32[2]; } } else { v8 = 0LL; do { v9 = _mm_loadu_si128(v6++); v8 = _mm_add_epi32(v8, v9); } while ( v6 != (const __m128i *)((char *)v14[0] + 16 * (v7 >> 2)) ); v10 = _mm_add_epi32(v8, _mm_srli_si128(v8, 8)); v12 = _mm_cvtsi128_si32(_mm_add_epi32(v10, _mm_srli_si128(v10, 4))); if ( (v7 & 3) != 0 ) { v6 = (const __m128i *)((char *)v14[0] + 4 * (v7 & 0xFFFFFFFFFFFFFFFCLL)); goto LABEL_13; } } } if ( v14[0] ) operator delete(v14[0], (char *)v1 - (char *)v14[0]); return v12; }
func0: ENDBR64 PUSH R12 PXOR XMM0,XMM0 XOR R8D,R8D XOR ESI,ESI PUSH RBP PUSH RBX SUB RSP,0x30 MOV RBX,qword ptr [RDI] MOV RBP,qword ptr [RDI + 0x8] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x28],RAX XOR EAX,EAX MOVAPS xmmword ptr [RSP + 0x10],XMM0 MOV qword ptr [RSP + 0x20],0x0 CMP RBX,RBP JNZ 0x00101491 JMP 0x001015b0 LAB_00101488: ADD RBX,0x4 CMP RBP,RBX JZ 0x001014b8 LAB_00101491: MOV EAX,dword ptr [RBX] MOV dword ptr [RSP + 0xc],EAX TEST EAX,EAX JNS 0x00101488 CMP RSI,R8 JZ 0x00101588 MOV dword ptr [RSI],EAX ADD RBX,0x4 ADD RSI,0x4 MOV qword ptr [RSP + 0x18],RSI CMP RBP,RBX JNZ 0x00101491 LAB_001014b8: MOV RDI,qword ptr [RSP + 0x10] CMP RSI,RDI JZ 0x001015b8 LEA RDX,[RSI + -0x4] MOV RAX,RDI SUB RDX,RDI MOV RCX,RDX SHR RCX,0x2 ADD RCX,0x1 CMP RDX,0x8 JBE 0x001015b4 MOV RDX,RCX PXOR XMM0,XMM0 SHR RDX,0x2 SHL RDX,0x4 ADD RDX,RDI NOP word ptr [RAX + RAX*0x1] LAB_00101500: MOVDQU XMM2,xmmword ptr [RAX] ADD RAX,0x10 PADDD XMM0,XMM2 CMP RAX,RDX JNZ 0x00101500 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x8 PADDD XMM0,XMM1 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x4 PADDD XMM0,XMM1 MOVD EBX,XMM0 TEST CL,0x3 JZ 0x00101556 AND RCX,-0x4 LEA RAX,[RDI + RCX*0x4] LAB_0010153c: LEA RDX,[RAX + 0x4] ADD EBX,dword ptr [RAX] CMP RSI,RDX JZ 0x00101556 LEA RDX,[RAX + 0x8] ADD EBX,dword ptr [RAX + 0x4] CMP RSI,RDX JZ 0x00101556 ADD EBX,dword ptr [RAX + 0x8] LAB_00101556: TEST RDI,RDI JZ 0x00101566 MOV RSI,R8 SUB RSI,RDI CALL 0x00101100 LAB_00101566: MOV RAX,qword ptr [RSP + 0x28] SUB RAX,qword ptr FS:[0x28] JNZ 0x001015bc ADD RSP,0x30 MOV EAX,EBX POP RBX POP RBP POP R12 RET LAB_00101588: LEA R12,[RSP + 0x10] LEA RDX,[RSP + 0xc] MOV RDI,R12 LAB_00101595: CALL 0x001016e0 MOV RSI,qword ptr [RSP + 0x18] MOV R8,qword ptr [RSP + 0x20] JMP 0x00101488 LAB_001015b0: XOR EBX,EBX JMP 0x00101566 LAB_001015b4: XOR EBX,EBX JMP 0x0010153c LAB_001015b8: XOR EBX,EBX JMP 0x00101556 LAB_001015bc: CALL 0x00101110
/* func0(std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1) { int *piVar1; int iVar2; int *piVar3; int *piVar4; int *piVar5; ulong uVar6; ulong uVar7; int *piVar8; int *piVar9; long in_FS_OFFSET; int iVar10; int iVar11; int iVar12; int iVar13; int local_3c; int *local_38; int *piStack_30; int *local_28; long local_20; piVar9 = (int *)0x0; piVar8 = (int *)0x0; piVar5 = *(int **)param_1; piVar1 = *(int **)(param_1 + 8); local_20 = *(long *)(in_FS_OFFSET + 0x28); local_38 = (int *)0x0; piStack_30 = (int *)0x0; local_28 = (int *)0x0; if (piVar5 == piVar1) { iVar10 = 0; goto LAB_00101566; } LAB_00101491: do { local_3c = *piVar5; if (local_3c < 0) { if (piVar8 != piVar9) { *piVar8 = local_3c; piVar5 = piVar5 + 1; piVar8 = piVar8 + 1; piStack_30 = piVar8; if (piVar1 == piVar5) break; goto LAB_00101491; } /* try { // try from 00101595 to 00101599 has its CatchHandler @ 001015c1 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)&local_38,(__normal_iterator)piVar8,&local_3c); piVar8 = piStack_30; piVar9 = local_28; } piVar5 = piVar5 + 1; } while (piVar1 != piVar5); if (piVar8 == local_38) { iVar10 = 0; } else { uVar7 = (long)piVar8 + (-4 - (long)local_38); uVar6 = (uVar7 >> 2) + 1; if (uVar7 < 9) { iVar10 = 0; piVar5 = local_38; } else { iVar10 = 0; iVar11 = 0; iVar12 = 0; iVar13 = 0; piVar5 = local_38; do { iVar2 = *piVar5; piVar1 = piVar5 + 1; piVar3 = piVar5 + 2; piVar4 = piVar5 + 3; piVar5 = piVar5 + 4; iVar10 = iVar10 + iVar2; iVar11 = iVar11 + *piVar1; iVar12 = iVar12 + *piVar3; iVar13 = iVar13 + *piVar4; } while (piVar5 != local_38 + (uVar6 & 0xfffffffffffffffc)); iVar10 = iVar10 + iVar12 + iVar11 + iVar13; if ((uVar6 & 3) == 0) goto LAB_00101556; piVar5 = local_38 + (uVar6 & 0xfffffffffffffffc); } iVar10 = iVar10 + *piVar5; if ((piVar8 != piVar5 + 1) && (iVar10 = iVar10 + piVar5[1], piVar8 != piVar5 + 2)) { iVar10 = iVar10 + piVar5[2]; } } LAB_00101556: if (local_38 != (int *)0x0) { operator_delete(local_38,(long)piVar9 - (long)local_38); } LAB_00101566: if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar10; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
532
func0
#include <string> #include <assert.h>
std::string func0(int arr[], int n, int p) { int _sum = 0; for (int i = 0; i < n; ++i) { _sum += arr[i]; } if (p == 1) { if (_sum % 2 == 0) { return "ODD"; } else { return "EVEN"; } } return "EVEN"; }
int main() { int array1[3] = {5, 7, 10}; int array2[2] = {2, 3}; int array3[3] = {1, 2, 3}; assert(func0(array1, 3, 1) == "ODD"); assert(func0(array2, 2, 3) == "EVEN"); assert(func0(array3, 3, 1) == "ODD"); return 0; }
O0
cpp
func0[abi:cxx11](int*, int, int): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x48,%rsp mov %rdi,-0x38(%rbp) mov %rsi,-0x40(%rbp) mov %edx,-0x44(%rbp) mov %ecx,-0x48(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax movl $0x0,-0x20(%rbp) movl $0x0,-0x1c(%rbp) mov -0x1c(%rbp),%eax cmp -0x44(%rbp),%eax jge 1428 <_Z5func0B5cxx11Piii+0x5f> mov -0x1c(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x40(%rbp),%rax add %rdx,%rax mov (%rax),%eax add %eax,-0x20(%rbp) addl $0x1,-0x1c(%rbp) jmp 1401 <_Z5func0B5cxx11Piii+0x38> cmpl $0x1,-0x48(%rbp) jne 14a0 <_Z5func0B5cxx11Piii+0xd7> mov -0x20(%rbp),%eax and $0x1,%eax test %eax,%eax jne 146c <_Z5func0B5cxx11Piii+0xa3> lea -0x21(%rbp),%rax mov %rax,%rdi callq 12b0 <_ZNSaIcEC1Ev@plt> lea -0x21(%rbp),%rdx mov -0x38(%rbp),%rax lea 0xbb5(%rip),%rsi mov %rax,%rdi callq 17d4 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> jmpq 152b <_Z5func0B5cxx11Piii+0x162> lea -0x21(%rbp),%rax mov %rax,%rdi callq 12b0 <_ZNSaIcEC1Ev@plt> lea -0x21(%rbp),%rdx mov -0x38(%rbp),%rax lea 0xb85(%rip),%rsi mov %rax,%rdi callq 17d4 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> jmpq 152b <_Z5func0B5cxx11Piii+0x162> lea -0x21(%rbp),%rax mov %rax,%rdi callq 12b0 <_ZNSaIcEC1Ev@plt> lea -0x21(%rbp),%rdx mov -0x38(%rbp),%rax lea 0xb51(%rip),%rsi mov %rax,%rdi callq 17d4 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_> lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> jmp 152b <_Z5func0B5cxx11Piii+0x162> endbr64 mov %rax,%rbx lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 12a0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 12a0 <_Unwind_Resume@plt> endbr64 mov %rax,%rbx lea -0x21(%rbp),%rax mov %rax,%rdi callq 1230 <_ZNSaIcED1Ev@plt> mov %rbx,%rax mov %rax,%rdi callq 12a0 <_Unwind_Resume@plt> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 153f <_Z5func0B5cxx11Piii+0x176> callq 1260 <__stack_chk_fail@plt> mov -0x38(%rbp),%rax add $0x48,%rsp pop %rbx pop %rbp retq
_Z5func0B5cxx11Piii: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 58h mov [rbp+var_48], rdi mov [rbp+var_50], rsi mov [rbp+var_54], edx mov [rbp+var_58], ecx mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov [rbp+var_38], 0 mov [rbp+var_34], 0 jmp short loc_13C0 loc_13A3: mov eax, [rbp+var_34] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_50] add rax, rdx mov eax, [rax] add [rbp+var_38], eax add [rbp+var_34], 1 loc_13C0: mov eax, [rbp+var_34] cmp eax, [rbp+var_54] jl short loc_13A3 cmp [rbp+var_58], 1 jnz short loc_143C mov eax, [rbp+var_38] and eax, 1 test eax, eax jnz short loc_140A lea rax, [rbp+var_39] mov [rbp+var_30], rax nop nop lea rdx, [rbp+var_39] mov rax, [rbp+var_48] lea rcx, unk_2008 mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() jmp short loc_146D loc_140A: lea rax, [rbp+var_39] mov [rbp+var_28], rax nop nop lea rdx, [rbp+var_39] mov rax, [rbp+var_48] lea rcx, aEven; "EVEN" mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() jmp short loc_146D loc_143C: lea rax, [rbp+var_39] mov [rbp+var_20], rax nop nop lea rdx, [rbp+var_39] mov rax, [rbp+var_48] lea rcx, aEven; "EVEN" mov rsi, rcx mov rdi, rax call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_; std::string::basic_string<std::allocator<char>>(char const*,std::allocator<char> const&) lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop loc_146D: mov rax, [rbp+var_18] sub rax, fs:28h jz loc_1523 jmp loc_151E endbr64 mov rbx, rax lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14B0 call ___stack_chk_fail loc_14B0: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_14E3 call ___stack_chk_fail loc_14E3: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume endbr64 mov rbx, rax lea rax, [rbp+var_39] mov rdi, rax call _ZNSt15__new_allocatorIcED2Ev; std::__new_allocator<char>::~__new_allocator() nop mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1516 call ___stack_chk_fail loc_1516: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_151E: call ___stack_chk_fail loc_1523: mov rax, [rbp+var_48] mov rbx, [rbp+var_8] leave retn
long long func0[abi:cxx11](long long a1, long long a2, int a3, int a4) { char v5; // [rsp+27h] [rbp-39h] BYREF int v6; // [rsp+28h] [rbp-38h] int i; // [rsp+2Ch] [rbp-34h] char *v8; // [rsp+30h] [rbp-30h] char *v9; // [rsp+38h] [rbp-28h] char *v10; // [rsp+40h] [rbp-20h] unsigned long long v11; // [rsp+48h] [rbp-18h] v11 = __readfsqword(0x28u); v6 = 0; for ( i = 0; i < a3; ++i ) v6 += *(_DWORD *)(4LL * i + a2); if ( a4 == 1 ) { if ( (v6 & 1) != 0 ) { v9 = &v5; std::string::basic_string<std::allocator<char>>(a1, "EVEN", &v5); } else { v8 = &v5; std::string::basic_string<std::allocator<char>>(a1, &unk_2008, &v5); } std::__new_allocator<char>::~__new_allocator(&v5); } else { v10 = &v5; std::string::basic_string<std::allocator<char>>(a1, "EVEN", &v5); std::__new_allocator<char>::~__new_allocator(&v5); } return a1; }
func0[abi:cxx11]: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x58 MOV qword ptr [RBP + -0x48],RDI MOV qword ptr [RBP + -0x50],RSI MOV dword ptr [RBP + -0x54],EDX MOV dword ptr [RBP + -0x58],ECX MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV dword ptr [RBP + -0x38],0x0 MOV dword ptr [RBP + -0x34],0x0 JMP 0x001013c0 LAB_001013a3: MOV EAX,dword ptr [RBP + -0x34] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x50] ADD RAX,RDX MOV EAX,dword ptr [RAX] ADD dword ptr [RBP + -0x38],EAX ADD dword ptr [RBP + -0x34],0x1 LAB_001013c0: MOV EAX,dword ptr [RBP + -0x34] CMP EAX,dword ptr [RBP + -0x54] JL 0x001013a3 CMP dword ptr [RBP + -0x58],0x1 JNZ 0x0010143c MOV EAX,dword ptr [RBP + -0x38] AND EAX,0x1 TEST EAX,EAX JNZ 0x0010140a LEA RAX,[RBP + -0x39] MOV qword ptr [RBP + -0x30],RAX NOP NOP LEA RDX,[RBP + -0x39] MOV RAX,qword ptr [RBP + -0x48] LEA RCX,[0x102008] MOV RSI,RCX MOV RDI,RAX LAB_001013f7: CALL 0x0010193e LEA RAX,[RBP + -0x39] MOV RDI,RAX CALL 0x00101a86 JMP 0x0010146d LAB_0010140a: LEA RAX,[RBP + -0x39] MOV qword ptr [RBP + -0x28],RAX NOP NOP LEA RDX,[RBP + -0x39] MOV RAX,qword ptr [RBP + -0x48] LEA RCX,[0x10200c] MOV RSI,RCX MOV RDI,RAX LAB_00101429: CALL 0x0010193e LEA RAX,[RBP + -0x39] MOV RDI,RAX CALL 0x00101a86 JMP 0x0010146d LAB_0010143c: LEA RAX,[RBP + -0x39] MOV qword ptr [RBP + -0x20],RAX NOP NOP LEA RDX,[RBP + -0x39] MOV RAX,qword ptr [RBP + -0x48] LEA RCX,[0x10200c] MOV RSI,RCX MOV RDI,RAX LAB_0010145b: CALL 0x0010193e LEA RAX,[RBP + -0x39] MOV RDI,RAX CALL 0x00101a86 NOP LAB_0010146d: MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x00101523 JMP 0x0010151e LAB_0010151e: CALL 0x00101220 LAB_00101523: MOV RAX,qword ptr [RBP + -0x48] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0[abi:cxx11](int*, int, int) */ int * func0_abi_cxx11_(int *param_1,int param_2,int param_3) { int in_ECX; int4 in_register_00000034; long in_FS_OFFSET; allocator local_41; uint local_40; int local_3c; allocator *local_38; allocator *local_30; allocator *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_40 = 0; for (local_3c = 0; local_3c < param_3; local_3c = local_3c + 1) { local_40 = local_40 + *(int *)(CONCAT44(in_register_00000034,param_2) + (long)local_3c * 4); } if (in_ECX == 1) { if ((local_40 & 1) == 0) { local_38 = &local_41; /* try { // try from 001013f7 to 001013fb has its CatchHandler @ 00101485 */ std::string::string<std::allocator<char>>((string *)param_1,"ODD",&local_41); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_41); } else { local_30 = &local_41; /* try { // try from 00101429 to 0010142d has its CatchHandler @ 001014b8 */ std::string::string<std::allocator<char>>((string *)param_1,"EVEN",&local_41); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_41); } } else { local_28 = &local_41; /* try { // try from 0010145b to 0010145f has its CatchHandler @ 001014eb */ std::string::string<std::allocator<char>>((string *)param_1,"EVEN",&local_41); std::__new_allocator<char>::~__new_allocator((__new_allocator<char> *)&local_41); } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
533
func0
#include <string> #include <assert.h>
std::string func0(int arr[], int n, int p) { int _sum = 0; for (int i = 0; i < n; ++i) { _sum += arr[i]; } if (p == 1) { if (_sum % 2 == 0) { return "ODD"; } else { return "EVEN"; } } return "EVEN"; }
int main() { int array1[3] = {5, 7, 10}; int array2[2] = {2, 3}; int array3[3] = {1, 2, 3}; assert(func0(array1, 3, 1) == "ODD"); assert(func0(array2, 2, 3) == "EVEN"); assert(func0(array3, 3, 1) == "ODD"); return 0; }
O1
cpp
func0[abi:cxx11](int*, int, int): endbr64 push %rbx mov %rdi,%rbx test %edx,%edx jle 1275 <_Z5func0B5cxx11Piii+0x6c> mov %rsi,%rax lea -0x1(%rdx),%edx lea 0x4(%rsi,%rdx,4),%rsi mov $0x0,%edx add (%rax),%edx add $0x4,%rax cmp %rsi,%rax jne 1225 <_Z5func0B5cxx11Piii+0x1c> cmp $0x1,%ecx jne 1256 <_Z5func0B5cxx11Piii+0x4d> test $0x1,%dl je 127a <_Z5func0B5cxx11Piii+0x71> lea 0x10(%rbx),%rax mov %rax,(%rbx) lea 0xdf2(%rip),%rdx lea -0x4(%rdx),%rsi mov %rbx,%rdi callq 143a <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> jmp 1270 <_Z5func0B5cxx11Piii+0x67> lea 0x10(%rbx),%rax mov %rax,(%rbx) lea 0xdd6(%rip),%rdx lea -0x4(%rdx),%rsi mov %rbx,%rdi callq 143a <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> mov %rbx,%rax pop %rbx retq cmp $0x1,%ecx jne 1256 <_Z5func0B5cxx11Piii+0x4d> lea 0x10(%rbx),%rax mov %rax,(%rbx) lea 0xdad(%rip),%rdx lea -0x3(%rdx),%rsi mov %rbx,%rdi callq 143a <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag> jmp 1270 <_Z5func0B5cxx11Piii+0x67>
_Z5func0B5cxx11Piii: endbr64 push rbx mov rbx, rdi test edx, edx jle short loc_1279 mov rax, rsi movsxd rdx, edx lea rdi, [rsi+rdx*4] mov edx, 0 loc_1224: mov esi, edx add esi, [rax] mov edx, esi add rax, 4 cmp rax, rdi jnz short loc_1224 cmp ecx, 1 jnz short loc_125A test sil, 1 jz short loc_127E lea rax, [rbx+10h] mov [rbx], rax lea rdx, aEven+4; "" lea rsi, [rdx-4] mov rdi, rbx call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp short loc_1274 loc_125A: lea rax, [rbx+10h] mov [rbx], rax lea rdx, aEven+4; "" lea rsi, [rdx-4] mov rdi, rbx call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) loc_1274: mov rax, rbx pop rbx retn loc_1279: cmp ecx, 1 jnz short loc_125A loc_127E: lea rax, [rbx+10h] mov [rbx], rax lea rdx, unk_2007 lea rsi, [rdx-3] mov rdi, rbx call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) jmp short loc_1274
_QWORD * func0[abi:cxx11](_QWORD *a1, _DWORD *a2, int a3, int a4) { _DWORD *v5; // rax _DWORD *v6; // rdi int v7; // edx int v8; // esi if ( a3 > 0 ) { v5 = a2; v6 = &a2[a3]; v7 = 0; do { v8 = *v5 + v7; v7 = v8; ++v5; } while ( v5 != v6 ); if ( a4 != 1 || (v8 & 1) != 0 ) goto LABEL_6; LABEL_9: *a1 = a1 + 2; std::string::_M_construct<char const*>(a1, (char *)&unk_2007 - 3); return a1; } if ( a4 == 1 ) goto LABEL_9; LABEL_6: *a1 = a1 + 2; std::string::_M_construct<char const*>(a1, "EVEN"); return a1; }
func0[abi:cxx11]: ENDBR64 PUSH RBX MOV RBX,RDI TEST EDX,EDX JLE 0x00101279 MOV RAX,RSI MOVSXD RDX,EDX LEA RDI,[RSI + RDX*0x4] MOV EDX,0x0 LAB_00101224: MOV ESI,EDX ADD ESI,dword ptr [RAX] MOV EDX,ESI ADD RAX,0x4 CMP RAX,RDI JNZ 0x00101224 CMP ECX,0x1 JNZ 0x0010125a TEST SIL,0x1 JZ 0x0010127e LEA RAX,[RBX + 0x10] MOV qword ptr [RBX],RAX LEA RDX,[0x10200c] LEA RSI,[RDX + -0x4] MOV RDI,RBX CALL 0x00101464 JMP 0x00101274 LAB_0010125a: LEA RAX,[RBX + 0x10] MOV qword ptr [RBX],RAX LEA RDX,[0x10200c] LEA RSI,[RDX + -0x4] MOV RDI,RBX CALL 0x00101464 LAB_00101274: MOV RAX,RBX POP RBX RET LAB_00101279: CMP ECX,0x1 JNZ 0x0010125a LAB_0010127e: LEA RAX,[RBX + 0x10] MOV qword ptr [RBX],RAX LEA RDX,[0x102007] LEA RSI,[RDX + -0x3] MOV RDI,RBX CALL 0x00101464 JMP 0x00101274
/* func0[abi:cxx11](int*, int, int) */ int * func0_abi_cxx11_(int *param_1,int param_2,int param_3) { int *piVar1; int *piVar2; int in_ECX; uint uVar3; int4 in_register_00000034; piVar2 = (int *)CONCAT44(in_register_00000034,param_2); if (param_3 < 1) { if (in_ECX != 1) goto LAB_0010125a; } else { piVar1 = piVar2 + param_3; uVar3 = 0; do { uVar3 = uVar3 + *piVar2; piVar2 = piVar2 + 1; } while (piVar2 != piVar1); if (in_ECX != 1) { LAB_0010125a: *(int **)param_1 = param_1 + 4; std::string::_M_construct<char_const*>((char *)param_1,"EVEN",0x10200c); return param_1; } if ((uVar3 & 1) != 0) { *(int **)param_1 = param_1 + 4; std::string::_M_construct<char_const*>((char *)param_1,"EVEN",0x10200c); return param_1; } } *(int **)param_1 = param_1 + 4; std::string::_M_construct<char_const*>((char *)param_1,"ODD",0x102007); return param_1; }
534
func0
#include <string> #include <assert.h>
std::string func0(int arr[], int n, int p) { int _sum = 0; for (int i = 0; i < n; ++i) { _sum += arr[i]; } if (p == 1) { if (_sum % 2 == 0) { return "ODD"; } else { return "EVEN"; } } return "EVEN"; }
int main() { int array1[3] = {5, 7, 10}; int array2[2] = {2, 3}; int array3[3] = {1, 2, 3}; assert(func0(array1, 3, 1) == "ODD"); assert(func0(array2, 2, 3) == "EVEN"); assert(func0(array3, 3, 1) == "ODD"); return 0; }
O2
cpp
func0[abi:cxx11](int*, int, int): endbr64 mov %rdi,%rax lea 0x10(%rdi),%rdi test %edx,%edx jle 1390 <_Z5func0B5cxx11Piii+0x50> sub $0x1,%edx lea 0x4(%rsi,%rdx,4),%r8 xor %edx,%edx nopl 0x0(%rax) add (%rsi),%edx add $0x4,%rsi cmp %r8,%rsi jne 1360 <_Z5func0B5cxx11Piii+0x20> cmp $0x1,%ecx jne 1375 <_Z5func0B5cxx11Piii+0x35> and $0x1,%edx je 1395 <_Z5func0B5cxx11Piii+0x55> mov %rdi,(%rax) movl $0x4e455645,0x10(%rax) movq $0x4,0x8(%rax) movb $0x0,0x14(%rax) retq nopl 0x0(%rax) cmp $0x1,%ecx jne 1375 <_Z5func0B5cxx11Piii+0x35> mov $0x444f,%edx mov %rdi,(%rax) mov %dx,0x10(%rax) movb $0x44,0x2(%rdi) movq $0x3,0x8(%rax) movb $0x0,0x13(%rax) retq nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
_Z5func0B5cxx11Piii: endbr64 push rbx mov rbx, rdi test edx, edx jle short loc_1480 movsxd rdx, edx xor eax, eax lea rdx, [rsi+rdx*4] nop dword ptr [rax] loc_1448: add eax, [rsi] add rsi, 4 cmp rsi, rdx jnz short loc_1448 cmp ecx, 1 jnz short loc_145C test al, 1 jz short loc_1485 loc_145C: lea rax, [rbx+10h] lea rdx, aEven+4; "" mov rdi, rbx mov [rbx], rax lea rsi, [rdx-4] call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rax, rbx pop rbx retn loc_1480: cmp ecx, 1 jnz short loc_145C loc_1485: lea rax, [rbx+10h] lea rdx, unk_2007 mov rdi, rbx mov [rbx], rax lea rsi, [rdx-3] call _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag_isra_0; std::string::_M_construct<char const*>(char const*,char const*,std::forward_iterator_tag) [clone] mov rax, rbx pop rbx retn
_QWORD * func0[abi:cxx11](_QWORD *a1, _DWORD *a2, int a3, int a4) { int v4; // eax _DWORD *v5; // rdx if ( a3 <= 0 ) { if ( a4 != 1 ) { LABEL_6: *a1 = a1 + 2; std::string::_M_construct<char const*>(a1, "EVEN"); return a1; } } else { v4 = 0; v5 = &a2[a3]; do v4 += *a2++; while ( a2 != v5 ); if ( a4 != 1 || (v4 & 1) != 0 ) goto LABEL_6; } *a1 = a1 + 2; std::string::_M_construct<char const*>(a1, (char *)&unk_2007 - 3); return a1; }
func0[abi:cxx11]: ENDBR64 PUSH RBX MOV RBX,RDI TEST EDX,EDX JLE 0x00101480 MOVSXD RDX,EDX XOR EAX,EAX LEA RDX,[RSI + RDX*0x4] NOP dword ptr [RAX] LAB_00101448: ADD EAX,dword ptr [RSI] ADD RSI,0x4 CMP RSI,RDX JNZ 0x00101448 CMP ECX,0x1 JNZ 0x0010145c TEST AL,0x1 JZ 0x00101485 LAB_0010145c: LEA RAX,[RBX + 0x10] LEA RDX,[0x10200c] MOV RDI,RBX MOV qword ptr [RBX],RAX LEA RSI,[RDX + -0x4] CALL 0x00101380 MOV RAX,RBX POP RBX RET LAB_00101480: CMP ECX,0x1 JNZ 0x0010145c LAB_00101485: LEA RAX,[RBX + 0x10] LEA RDX,[0x102007] MOV RDI,RBX MOV qword ptr [RBX],RAX LEA RSI,[RDX + -0x3] CALL 0x00101380 MOV RAX,RBX POP RBX RET
/* func0[abi:cxx11](int*, int, int) */ int * func0_abi_cxx11_(int *param_1,int param_2,int param_3) { int *piVar1; uint uVar2; int in_ECX; int4 in_register_00000034; int *piVar3; piVar3 = (int *)CONCAT44(in_register_00000034,param_2); if (param_3 < 1) { if (in_ECX == 1) goto LAB_00101485; } else { uVar2 = 0; piVar1 = piVar3 + param_3; do { uVar2 = uVar2 + *piVar3; piVar3 = piVar3 + 1; } while (piVar3 != piVar1); if ((in_ECX == 1) && ((uVar2 & 1) == 0)) { LAB_00101485: *(int **)param_1 = param_1 + 4; std::string::_M_construct<char_const*>((char *)param_1,"ODD",0x102007); return param_1; } } *(int **)param_1 = param_1 + 4; std::string::_M_construct<char_const*>((char *)param_1,"EVEN",0x10200c); return param_1; }
535
func0
#include <string> #include <assert.h>
std::string func0(int arr[], int n, int p) { int _sum = 0; for (int i = 0; i < n; ++i) { _sum += arr[i]; } if (p == 1) { if (_sum % 2 == 0) { return "ODD"; } else { return "EVEN"; } } return "EVEN"; }
int main() { int array1[3] = {5, 7, 10}; int array2[2] = {2, 3}; int array3[3] = {1, 2, 3}; assert(func0(array1, 3, 1) == "ODD"); assert(func0(array2, 2, 3) == "EVEN"); assert(func0(array3, 3, 1) == "ODD"); return 0; }
O3
cpp
func0[abi:cxx11](int*, int, int): endbr64 mov %rdi,%rax lea 0x10(%rdi),%r10 test %edx,%edx jle 1410 <_Z5func0B5cxx11Piii+0xd0> lea -0x1(%rdx),%edi cmp $0x3,%edi jbe 1433 <_Z5func0B5cxx11Piii+0xf3> mov %edx,%r9d mov %rsi,%r8 pxor %xmm0,%xmm0 shr $0x2,%r9d shl $0x4,%r9 add %rsi,%r9 nopl 0x0(%rax) movdqu (%r8),%xmm2 add $0x10,%r8 paddd %xmm2,%xmm0 cmp %r8,%r9 jne 1378 <_Z5func0B5cxx11Piii+0x38> movdqa %xmm0,%xmm1 mov %edx,%edi psrldq $0x8,%xmm1 and $0xfffffffc,%edi paddd %xmm1,%xmm0 movdqa %xmm0,%xmm1 psrldq $0x4,%xmm1 paddd %xmm1,%xmm0 movd %xmm0,%r8d test $0x3,%dl je 13e8 <_Z5func0B5cxx11Piii+0xa8> movslq %edi,%r9 add (%rsi,%r9,4),%r8d lea 0x1(%rdi),%r9d cmp %r9d,%edx jle 13e8 <_Z5func0B5cxx11Piii+0xa8> movslq %r9d,%r9 add (%rsi,%r9,4),%r8d lea 0x2(%rdi),%r9d cmp %r9d,%edx jle 13e8 <_Z5func0B5cxx11Piii+0xa8> movslq %r9d,%r9 add $0x3,%edi add (%rsi,%r9,4),%r8d cmp %edi,%edx jle 13e8 <_Z5func0B5cxx11Piii+0xa8> movslq %edi,%rdi add (%rsi,%rdi,4),%r8d cmp $0x1,%ecx jne 13f3 <_Z5func0B5cxx11Piii+0xb3> and $0x1,%r8d je 1415 <_Z5func0B5cxx11Piii+0xd5> mov %r10,(%rax) movl $0x4e455645,0x10(%rax) movq $0x4,0x8(%rax) movb $0x0,0x14(%rax) retq nopw 0x0(%rax,%rax,1) cmp $0x1,%ecx jne 13f3 <_Z5func0B5cxx11Piii+0xb3> mov $0x444f,%edx mov %r10,(%rax) mov %dx,0x10(%rax) movb $0x44,0x2(%r10) movq $0x3,0x8(%rax) movb $0x0,0x13(%rax) retq xor %edi,%edi xor %r8d,%r8d jmpq 13b3 <_Z5func0B5cxx11Piii+0x73> nopl (%rax)
_Z5func0B5cxx11Piii: endbr64 mov r8, rsi mov r9d, ecx mov esi, edx test edx, edx jle loc_13F8 lea eax, [rdx-1] cmp eax, 2 jbe loc_1421 shr edx, 2 mov rax, r8 pxor xmm0, xmm0 shl rdx, 4 add rdx, r8 nop dword ptr [rax+00000000h] loc_1368: movdqu xmm2, xmmword ptr [rax] add rax, 10h paddd xmm0, xmm2 cmp rax, rdx jnz short loc_1368 movdqa xmm1, xmm0 mov edx, esi psrldq xmm1, 8 and edx, 0FFFFFFFCh paddd xmm0, xmm1 movdqa xmm1, xmm0 psrldq xmm1, 4 paddd xmm0, xmm1 movd eax, xmm0 test sil, 3 jz short loc_13C9 loc_13A2: movsxd rcx, edx lea r10, ds:0[rcx*4] add eax, [r8+rcx*4] lea ecx, [rdx+1] cmp esi, ecx jle short loc_13C9 add edx, 2 add eax, [r8+r10+4] cmp esi, edx jle short loc_13C9 add eax, [r8+r10+8] loc_13C9: cmp r9d, 1 jnz short loc_13D3 test al, 1 jz short loc_13FD loc_13D3: lea rax, [rdi+10h] mov dword ptr [rdi+10h], 4E455645h mov [rdi], rax mov rax, rdi mov qword ptr [rdi+8], 4 mov byte ptr [rdi+14h], 0 retn loc_13F8: cmp ecx, 1 jnz short loc_13D3 loc_13FD: lea rax, [rdi+10h] mov byte ptr [rdi+12h], 44h ; 'D' mov [rdi], rax mov eax, 444Fh mov [rdi+10h], ax mov rax, rdi mov qword ptr [rdi+8], 3 mov byte ptr [rdi+13h], 0 retn loc_1421: xor edx, edx xor eax, eax jmp loc_13A2
long long func0[abi:cxx11](long long a1, const __m128i *a2, int a3, int a4) { const __m128i *v6; // rax __m128i v7; // xmm0 const __m128i *v8; // rdx __m128i v9; // xmm2 signed int v10; // edx __m128i v11; // xmm0 int v12; // eax long long v13; // r10 long long result; // rax if ( a3 > 0 ) { if ( (unsigned int)(a3 - 1) <= 2 ) { v10 = 0; v12 = 0; } else { v6 = a2; v7 = 0LL; v8 = &a2[(unsigned int)a3 >> 2]; do { v9 = _mm_loadu_si128(v6++); v7 = _mm_add_epi32(v7, v9); } while ( v6 != v8 ); v10 = a3 & 0xFFFFFFFC; v11 = _mm_add_epi32(v7, _mm_srli_si128(v7, 8)); v12 = _mm_cvtsi128_si32(_mm_add_epi32(v11, _mm_srli_si128(v11, 4))); if ( (a3 & 3) == 0 ) goto LABEL_9; } v13 = v10; v12 += a2->m128i_i32[v13]; if ( a3 > v10 + 1 ) { v12 += a2->m128i_i32[v13 + 1]; if ( a3 > v10 + 2 ) v12 += a2->m128i_i32[v13 + 2]; } LABEL_9: if ( a4 != 1 || (v12 & 1) != 0 ) goto LABEL_11; goto LABEL_13; } if ( a4 != 1 ) { LABEL_11: strcpy((char *)(a1 + 16), "EVEN"); *(_QWORD *)a1 = a1 + 16; result = a1; *(_QWORD *)(a1 + 8) = 4LL; return result; } LABEL_13: *(_BYTE *)(a1 + 18) = 68; *(_QWORD *)a1 = a1 + 16; *(_WORD *)(a1 + 16) = 17487; result = a1; *(_QWORD *)(a1 + 8) = 3LL; *(_BYTE *)(a1 + 19) = 0; return result; }
func0[abi:cxx11]: ENDBR64 MOV R8,RSI MOV R9D,ECX MOV ESI,EDX TEST EDX,EDX JLE 0x001013f8 LEA EAX,[RDX + -0x1] CMP EAX,0x2 JBE 0x00101421 SHR EDX,0x2 MOV RAX,R8 PXOR XMM0,XMM0 SHL RDX,0x4 ADD RDX,R8 NOP dword ptr [RAX] LAB_00101368: MOVDQU XMM2,xmmword ptr [RAX] ADD RAX,0x10 PADDD XMM0,XMM2 CMP RAX,RDX JNZ 0x00101368 MOVDQA XMM1,XMM0 MOV EDX,ESI PSRLDQ XMM1,0x8 AND EDX,0xfffffffc PADDD XMM0,XMM1 MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x4 PADDD XMM0,XMM1 MOVD EAX,XMM0 TEST SIL,0x3 JZ 0x001013c9 LAB_001013a2: MOVSXD RCX,EDX LEA R10,[RCX*0x4] ADD EAX,dword ptr [R8 + RCX*0x4] LEA ECX,[RDX + 0x1] CMP ESI,ECX JLE 0x001013c9 ADD EDX,0x2 ADD EAX,dword ptr [R8 + R10*0x1 + 0x4] CMP ESI,EDX JLE 0x001013c9 ADD EAX,dword ptr [R8 + R10*0x1 + 0x8] LAB_001013c9: CMP R9D,0x1 JNZ 0x001013d3 TEST AL,0x1 JZ 0x001013fd LAB_001013d3: LEA RAX,[RDI + 0x10] MOV dword ptr [RDI + 0x10],0x4e455645 MOV qword ptr [RDI],RAX MOV RAX,RDI MOV qword ptr [RDI + 0x8],0x4 MOV byte ptr [RDI + 0x14],0x0 RET LAB_001013f8: CMP ECX,0x1 JNZ 0x001013d3 LAB_001013fd: LEA RAX,[RDI + 0x10] MOV byte ptr [RDI + 0x12],0x44 MOV qword ptr [RDI],RAX MOV EAX,0x444f MOV word ptr [RDI + 0x10],AX MOV RAX,RDI MOV qword ptr [RDI + 0x8],0x3 MOV byte ptr [RDI + 0x13],0x0 RET LAB_00101421: XOR EDX,EDX XOR EAX,EAX JMP 0x001013a2
/* func0[abi:cxx11](int*, int, int) */ int * func0_abi_cxx11_(int *param_1,int param_2,int param_3) { int iVar1; int *piVar2; int *piVar3; int *piVar4; int *piVar5; int in_ECX; uint uVar6; int4 in_register_00000034; int *piVar7; int iVar8; uint uVar9; int iVar10; int iVar11; int iVar12; piVar7 = (int *)CONCAT44(in_register_00000034,param_2); if (param_3 < 1) { if (in_ECX == 1) goto LAB_001013fd; goto LAB_001013d3; } if (param_3 - 1U < 3) { uVar6 = 0; uVar9 = 0; LAB_001013a2: uVar9 = uVar9 + piVar7[(int)uVar6]; if (((int)(uVar6 + 1) < param_3) && (uVar9 = uVar9 + piVar7[(long)(int)uVar6 + 1], (int)(uVar6 + 2) < param_3)) { uVar9 = uVar9 + piVar7[(long)(int)uVar6 + 2]; } } else { iVar8 = 0; iVar10 = 0; iVar11 = 0; iVar12 = 0; piVar5 = piVar7; do { iVar1 = *piVar5; piVar2 = piVar5 + 1; piVar3 = piVar5 + 2; piVar4 = piVar5 + 3; piVar5 = piVar5 + 4; iVar8 = iVar8 + iVar1; iVar10 = iVar10 + *piVar2; iVar11 = iVar11 + *piVar3; iVar12 = iVar12 + *piVar4; } while (piVar5 != piVar7 + (ulong)((uint)param_3 >> 2) * 4); uVar6 = param_3 & 0xfffffffc; uVar9 = iVar8 + iVar11 + iVar10 + iVar12; if ((param_3 & 3U) != 0) goto LAB_001013a2; } if ((in_ECX == 1) && ((uVar9 & 1) == 0)) { LAB_001013fd: *(int *)((long)param_1 + 0x12) = 0x44; *(int **)param_1 = param_1 + 4; *(int2 *)(param_1 + 4) = 0x444f; param_1[2] = 3; param_1[3] = 0; *(int *)((long)param_1 + 0x13) = 0; return param_1; } LAB_001013d3: param_1[4] = 0x4e455645; *(int **)param_1 = param_1 + 4; param_1[2] = 4; param_1[3] = 0; *(int *)(param_1 + 5) = 0; return param_1; }
536
func0
#include <assert.h>
int func0(int n) { return n * (2*n - 1); }
int main() { assert(func0(10) == 190); assert(func0(5) == 45); assert(func0(7) == 91); return 0; }
O0
cpp
func0(int): endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x4(%rbp) mov -0x4(%rbp),%eax add %eax,%eax sub $0x1,%eax imul -0x4(%rbp),%eax pop %rbp retq
_Z5func0i: endbr64 push rbp mov rbp, rsp mov [rbp+var_4], edi mov eax, [rbp+var_4] add eax, eax sub eax, 1 imul eax, [rbp+var_4] pop rbp retn
long long func0(int a1) { return (unsigned int)(a1 * (2 * a1 - 1)); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x4],EDI MOV EAX,dword ptr [RBP + -0x4] ADD EAX,EAX SUB EAX,0x1 IMUL EAX,dword ptr [RBP + -0x4] POP RBP RET
/* func0(int) */ int func0(int param_1) { return (param_1 * 2 + -1) * param_1; }
537
func0
#include <assert.h>
int func0(int n) { return n * (2*n - 1); }
int main() { assert(func0(10) == 190); assert(func0(5) == 45); assert(func0(7) == 91); return 0; }
O1
cpp
func0(int): endbr64 lea -0x1(%rdi,%rdi,1),%eax imul %edi,%eax retq
_Z5func0i: endbr64 lea eax, [rdi+rdi-1] imul eax, edi retn
long long func0(int a1) { return (unsigned int)(a1 * (2 * a1 - 1)); }
func0: ENDBR64 LEA EAX,[RDI + RDI*0x1 + -0x1] IMUL EAX,EDI RET
/* func0(int) */ int func0(int param_1) { return (param_1 * 2 + -1) * param_1; }
538
func0
#include <assert.h>
int func0(int n) { return n * (2*n - 1); }
int main() { assert(func0(10) == 190); assert(func0(5) == 45); assert(func0(7) == 91); return 0; }
O2
cpp
func0(int): endbr64 lea -0x1(%rdi,%rdi,1),%eax imul %edi,%eax retq nopl 0x0(%rax)
_Z5func0i: endbr64 lea eax, [rdi+rdi-1] imul eax, edi retn
long long func0(int a1) { return (unsigned int)(a1 * (2 * a1 - 1)); }
func0: ENDBR64 LEA EAX,[RDI + RDI*0x1 + -0x1] IMUL EAX,EDI RET
/* func0(int) */ int func0(int param_1) { return (param_1 * 2 + -1) * param_1; }
539
func0
#include <assert.h>
int func0(int n) { return n * (2*n - 1); }
int main() { assert(func0(10) == 190); assert(func0(5) == 45); assert(func0(7) == 91); return 0; }
O3
cpp
func0(int): endbr64 lea -0x1(%rdi,%rdi,1),%eax imul %edi,%eax retq nopl 0x0(%rax)
_Z5func0i: endbr64 lea eax, [rdi+rdi-1] imul eax, edi retn
long long func0(int a1) { return (unsigned int)(a1 * (2 * a1 - 1)); }
func0: ENDBR64 LEA EAX,[RDI + RDI*0x1 + -0x1] IMUL EAX,EDI RET
/* func0(int) */ int func0(int param_1) { return (param_1 * 2 + -1) * param_1; }
540
func0
#include <assert.h>
double func0(int units) { double amount; int surcharge; if (units < 50) { amount = units * 2.60; surcharge = 25; } else if (units <= 100) { amount = 130 + ((units - 50) * 3.25); surcharge = 35; } else if (units <= 200) { amount = 130 + 162.50 + ((units - 100) * 5.26); surcharge = 45; } else { amount = 130 + 162.50 + 526 + ((units - 200) * 8.45); surcharge = 75; } double total = amount + surcharge; return total; }
int main() { assert(func0(75) == 246.25); assert(func0(265) == 1442.75); assert(func0(100) == 327.5); return 0; }
O0
cpp
func0(int): endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x24(%rbp) cmpl $0x31,-0x24(%rbp) jg 117c <_Z5func0i+0x33> cvtsi2sdl -0x24(%rbp),%xmm1 movsd 0xf31(%rip),%xmm0 mulsd %xmm1,%xmm0 movsd %xmm0,-0x10(%rbp) movl $0x19,-0x14(%rbp) jmpq 121b <_Z5func0i+0xd2> cmpl $0x64,-0x24(%rbp) jg 11b2 <_Z5func0i+0x69> mov -0x24(%rbp),%eax sub $0x32,%eax cvtsi2sd %eax,%xmm1 movsd 0xf0c(%rip),%xmm0 mulsd %xmm0,%xmm1 movsd 0xf08(%rip),%xmm0 addsd %xmm1,%xmm0 movsd %xmm0,-0x10(%rbp) movl $0x23,-0x14(%rbp) jmp 121b <_Z5func0i+0xd2> cmpl $0xc8,-0x24(%rbp) jg 11eb <_Z5func0i+0xa2> mov -0x24(%rbp),%eax sub $0x64,%eax cvtsi2sd %eax,%xmm1 movsd 0xee3(%rip),%xmm0 mulsd %xmm0,%xmm1 movsd 0xedf(%rip),%xmm0 addsd %xmm1,%xmm0 movsd %xmm0,-0x10(%rbp) movl $0x2d,-0x14(%rbp) jmp 121b <_Z5func0i+0xd2> mov -0x24(%rbp),%eax sub $0xc8,%eax cvtsi2sd %eax,%xmm1 movsd 0xec1(%rip),%xmm0 mulsd %xmm0,%xmm1 movsd 0xebd(%rip),%xmm0 addsd %xmm1,%xmm0 movsd %xmm0,-0x10(%rbp) movl $0x4b,-0x14(%rbp) cvtsi2sdl -0x14(%rbp),%xmm0 movsd -0x10(%rbp),%xmm1 addsd %xmm1,%xmm0 movsd %xmm0,-0x8(%rbp) movsd -0x8(%rbp),%xmm0 pop %rbp retq
_Z5func0i: endbr64 push rbp mov rbp, rsp mov [rbp+var_24], edi cmp [rbp+var_24], 31h ; '1' jg short loc_1180 pxor xmm1, xmm1 cvtsi2sd xmm1, [rbp+var_24] movsd xmm0, cs:qword_2078 mulsd xmm0, xmm1 movsd [rbp+var_10], xmm0 mov [rbp+var_14], 19h jmp loc_122B loc_1180: cmp [rbp+var_24], 64h ; 'd' jg short loc_11BA mov eax, [rbp+var_24] sub eax, 32h ; '2' pxor xmm1, xmm1 cvtsi2sd xmm1, eax movsd xmm0, cs:qword_2080 mulsd xmm1, xmm0 movsd xmm0, cs:qword_2088 addsd xmm0, xmm1 movsd [rbp+var_10], xmm0 mov [rbp+var_14], 23h ; '#' jmp short loc_122B loc_11BA: cmp [rbp+var_24], 0C8h jg short loc_11F7 mov eax, [rbp+var_24] sub eax, 64h ; 'd' pxor xmm1, xmm1 cvtsi2sd xmm1, eax movsd xmm0, cs:qword_2090 mulsd xmm1, xmm0 movsd xmm0, cs:qword_2098 addsd xmm0, xmm1 movsd [rbp+var_10], xmm0 mov [rbp+var_14], 2Dh ; '-' jmp short loc_122B loc_11F7: mov eax, [rbp+var_24] sub eax, 0C8h pxor xmm1, xmm1 cvtsi2sd xmm1, eax movsd xmm0, cs:qword_20A0 mulsd xmm1, xmm0 movsd xmm0, cs:qword_20A8 addsd xmm0, xmm1 movsd [rbp+var_10], xmm0 mov [rbp+var_14], 4Bh ; 'K' loc_122B: pxor xmm0, xmm0 cvtsi2sd xmm0, [rbp+var_14] movsd xmm1, [rbp+var_10] addsd xmm0, xmm1 movsd [rbp+var_8], xmm0 movsd xmm0, [rbp+var_8] pop rbp retn
double func0(int a1) { int v2; // [rsp+10h] [rbp-14h] double v3; // [rsp+14h] [rbp-10h] if ( a1 > 49 ) { if ( a1 > 100 ) { if ( a1 > 200 ) { v3 = (double)(a1 - 200) * 8.449999999999999 + 818.5; v2 = 75; } else { v3 = (double)(a1 - 100) * 5.26 + 292.5; v2 = 45; } } else { v3 = (double)(a1 - 50) * 3.25 + 130.0; v2 = 35; } } else { v3 = 2.6 * (double)a1; v2 = 25; } return (double)v2 + v3; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x24],EDI CMP dword ptr [RBP + -0x24],0x31 JG 0x00101180 PXOR XMM1,XMM1 CVTSI2SD XMM1,dword ptr [RBP + -0x24] MOVSD XMM0,qword ptr [0x00102078] MULSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x10],XMM0 MOV dword ptr [RBP + -0x14],0x19 JMP 0x0010122b LAB_00101180: CMP dword ptr [RBP + -0x24],0x64 JG 0x001011ba MOV EAX,dword ptr [RBP + -0x24] SUB EAX,0x32 PXOR XMM1,XMM1 CVTSI2SD XMM1,EAX MOVSD XMM0,qword ptr [0x00102080] MULSD XMM1,XMM0 MOVSD XMM0,qword ptr [0x00102088] ADDSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x10],XMM0 MOV dword ptr [RBP + -0x14],0x23 JMP 0x0010122b LAB_001011ba: CMP dword ptr [RBP + -0x24],0xc8 JG 0x001011f7 MOV EAX,dword ptr [RBP + -0x24] SUB EAX,0x64 PXOR XMM1,XMM1 CVTSI2SD XMM1,EAX MOVSD XMM0,qword ptr [0x00102090] MULSD XMM1,XMM0 MOVSD XMM0,qword ptr [0x00102098] ADDSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x10],XMM0 MOV dword ptr [RBP + -0x14],0x2d JMP 0x0010122b LAB_001011f7: MOV EAX,dword ptr [RBP + -0x24] SUB EAX,0xc8 PXOR XMM1,XMM1 CVTSI2SD XMM1,EAX MOVSD XMM0,qword ptr [0x001020a0] MULSD XMM1,XMM0 MOVSD XMM0,qword ptr [0x001020a8] ADDSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x10],XMM0 MOV dword ptr [RBP + -0x14],0x4b LAB_0010122b: PXOR XMM0,XMM0 CVTSI2SD XMM0,dword ptr [RBP + -0x14] MOVSD XMM1,qword ptr [RBP + -0x10] ADDSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x8],XMM0 MOVSD XMM0,qword ptr [RBP + -0x8] POP RBP RET
/* func0(int) */ double func0(int param_1) { int4 local_1c; int8 local_18; if (param_1 < 0x32) { local_18 = DAT_00102078 * (double)param_1; local_1c = 0x19; } else if (param_1 < 0x65) { local_18 = DAT_00102088 + (double)(param_1 + -0x32) * DAT_00102080; local_1c = 0x23; } else if (param_1 < 0xc9) { local_18 = DAT_00102098 + (double)(param_1 + -100) * DAT_00102090; local_1c = 0x2d; } else { local_18 = DAT_001020a8 + (double)(param_1 + -200) * DAT_001020a0; local_1c = 0x4b; } return (double)local_1c + local_18; }
541
func0
#include <assert.h>
double func0(int units) { double amount; int surcharge; if (units < 50) { amount = units * 2.60; surcharge = 25; } else if (units <= 100) { amount = 130 + ((units - 50) * 3.25); surcharge = 35; } else if (units <= 200) { amount = 130 + 162.50 + ((units - 100) * 5.26); surcharge = 45; } else { amount = 130 + 162.50 + 526 + ((units - 200) * 8.45); surcharge = 75; } double total = amount + surcharge; return total; }
int main() { assert(func0(75) == 246.25); assert(func0(265) == 1442.75); assert(func0(100) == 327.5); return 0; }
O1
cpp
func0(int): endbr64 cmp $0x31,%edi jg 1154 <_Z5func0i+0x2b> pxor %xmm0,%xmm0 cvtsi2sd %edi,%xmm0 mulsd 0xec6(%rip),%xmm0 mov $0x19,%eax pxor %xmm1,%xmm1 cvtsi2sd %eax,%xmm1 addsd %xmm1,%xmm0 retq cmp $0x64,%edi jg 117b <_Z5func0i+0x52> sub $0x32,%edi pxor %xmm0,%xmm0 cvtsi2sd %edi,%xmm0 mulsd 0xea4(%rip),%xmm0 addsd 0xea4(%rip),%xmm0 mov $0x23,%eax jmp 1147 <_Z5func0i+0x1e> cmp $0xc8,%edi jg 11a5 <_Z5func0i+0x7c> sub $0x64,%edi pxor %xmm0,%xmm0 cvtsi2sd %edi,%xmm0 mulsd 0xe8a(%rip),%xmm0 addsd 0xe8a(%rip),%xmm0 mov $0x2d,%eax jmp 1147 <_Z5func0i+0x1e> sub $0xc8,%edi pxor %xmm0,%xmm0 cvtsi2sd %edi,%xmm0 mulsd 0xe75(%rip),%xmm0 addsd 0xe75(%rip),%xmm0 mov $0x4b,%eax jmpq 1147 <_Z5func0i+0x1e>
_Z5func0i: endbr64 cmp edi, 31h ; '1' jg short loc_1154 pxor xmm1, xmm1 cvtsi2sd xmm1, edi mulsd xmm1, cs:qword_2008 mov eax, 19h loc_1147: pxor xmm0, xmm0 cvtsi2sd xmm0, eax addsd xmm0, xmm1 retn loc_1154: cmp edi, 64h ; 'd' jg short loc_117B sub edi, 32h ; '2' pxor xmm1, xmm1 cvtsi2sd xmm1, edi mulsd xmm1, cs:qword_2010 addsd xmm1, cs:qword_2018 mov eax, 23h ; '#' jmp short loc_1147 loc_117B: cmp edi, 0C8h jg short loc_11A5 sub edi, 64h ; 'd' pxor xmm1, xmm1 cvtsi2sd xmm1, edi mulsd xmm1, cs:qword_2020 addsd xmm1, cs:qword_2028 mov eax, 2Dh ; '-' jmp short loc_1147 loc_11A5: sub edi, 0C8h pxor xmm1, xmm1 cvtsi2sd xmm1, edi mulsd xmm1, cs:qword_2030 addsd xmm1, cs:qword_2038 mov eax, 4Bh ; 'K' jmp loc_1147
double func0(int a1) { double v1; // xmm1_8 int v2; // eax if ( a1 > 49 ) { if ( a1 > 100 ) { if ( a1 > 200 ) { v1 = (double)(a1 - 200) * 8.449999999999999 + 818.5; v2 = 75; } else { v1 = (double)(a1 - 100) * 5.26 + 292.5; v2 = 45; } } else { v1 = (double)(a1 - 50) * 3.25 + 130.0; v2 = 35; } } else { v1 = (double)a1 * 2.6; v2 = 25; } return (double)v2 + v1; }
func0: ENDBR64 CMP EDI,0x31 JG 0x00101154 PXOR XMM1,XMM1 CVTSI2SD XMM1,EDI MULSD XMM1,qword ptr [0x00102008] MOV EAX,0x19 LAB_00101147: PXOR XMM0,XMM0 CVTSI2SD XMM0,EAX ADDSD XMM0,XMM1 RET LAB_00101154: CMP EDI,0x64 JG 0x0010117b SUB EDI,0x32 PXOR XMM1,XMM1 CVTSI2SD XMM1,EDI MULSD XMM1,qword ptr [0x00102010] ADDSD XMM1,qword ptr [0x00102018] MOV EAX,0x23 JMP 0x00101147 LAB_0010117b: CMP EDI,0xc8 JG 0x001011a5 SUB EDI,0x64 PXOR XMM1,XMM1 CVTSI2SD XMM1,EDI MULSD XMM1,qword ptr [0x00102020] ADDSD XMM1,qword ptr [0x00102028] MOV EAX,0x2d JMP 0x00101147 LAB_001011a5: SUB EDI,0xc8 PXOR XMM1,XMM1 CVTSI2SD XMM1,EDI MULSD XMM1,qword ptr [0x00102030] ADDSD XMM1,qword ptr [0x00102038] MOV EAX,0x4b JMP 0x00101147
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(int) */ double func0(int param_1) { int iVar1; double dVar2; if (param_1 < 0x32) { dVar2 = (double)param_1 * _DAT_00102008; iVar1 = 0x19; } else if (param_1 < 0x65) { dVar2 = (double)(param_1 + -0x32) * _DAT_00102010 + _DAT_00102018; iVar1 = 0x23; } else if (param_1 < 0xc9) { dVar2 = (double)(param_1 + -100) * _DAT_00102020 + _DAT_00102028; iVar1 = 0x2d; } else { dVar2 = (double)(param_1 + -200) * _DAT_00102030 + _DAT_00102038; iVar1 = 0x4b; } return (double)iVar1 + dVar2; }
542
func0
#include <assert.h>
double func0(int units) { double amount; int surcharge; if (units < 50) { amount = units * 2.60; surcharge = 25; } else if (units <= 100) { amount = 130 + ((units - 50) * 3.25); surcharge = 35; } else if (units <= 200) { amount = 130 + 162.50 + ((units - 100) * 5.26); surcharge = 45; } else { amount = 130 + 162.50 + 526 + ((units - 200) * 8.45); surcharge = 75; } double total = amount + surcharge; return total; }
int main() { assert(func0(75) == 246.25); assert(func0(265) == 1442.75); assert(func0(100) == 327.5); return 0; }
O2
cpp
func0(int): endbr64 cmp $0x31,%edi jg 1170 <_Z5func0i+0x30> pxor %xmm0,%xmm0 movsd 0xeb3(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xec7(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopw %cs:0x0(%rax,%rax,1) cmp $0x64,%edi jg 11a0 <_Z5func0i+0x60> sub $0x32,%edi pxor %xmm0,%xmm0 movsd 0xe8c(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xea0(%rip),%xmm0 addsd 0xea0(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopl (%rax) cmp $0xc8,%edi jg 11d0 <_Z5func0i+0x90> sub $0x64,%edi pxor %xmm0,%xmm0 movsd 0xe61(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xe7d(%rip),%xmm0 addsd 0xe7d(%rip),%xmm0 addsd %xmm1,%xmm0 retq sub $0xc8,%edi pxor %xmm0,%xmm0 movsd 0xe3e(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xe62(%rip),%xmm0 addsd 0xe62(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopl 0x0(%rax,%rax,1)
_Z5func0i: endbr64 cmp edi, 31h ; '1' jg short loc_1170 pxor xmm0, xmm0 movsd xmm1, cs:qword_2008 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2028 addsd xmm0, xmm1 retn loc_1170: cmp edi, 64h ; 'd' jg short loc_11A0 sub edi, 32h ; '2' pxor xmm0, xmm0 movsd xmm1, cs:qword_2010 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2030 addsd xmm0, cs:qword_2038 addsd xmm0, xmm1 retn loc_11A0: cmp edi, 0C8h jg short loc_11D0 sub edi, 64h ; 'd' pxor xmm0, xmm0 movsd xmm1, cs:qword_2018 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2040 addsd xmm0, cs:qword_2048 addsd xmm0, xmm1 retn loc_11D0: sub edi, 0C8h pxor xmm0, xmm0 movsd xmm1, cs:qword_2020 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2050 addsd xmm0, cs:qword_2058 addsd xmm0, xmm1 retn
double func0(int a1) { if ( a1 <= 49 ) return (double)a1 * 2.6 + 25.0; if ( a1 <= 100 ) return (double)(a1 - 50) * 3.25 + 130.0 + 35.0; if ( a1 > 200 ) return (double)(a1 - 200) * 8.449999999999999 + 818.5 + 75.0; return (double)(a1 - 100) * 5.26 + 292.5 + 45.0; }
func0: ENDBR64 CMP EDI,0x31 JG 0x00101170 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102008] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102028] ADDSD XMM0,XMM1 RET LAB_00101170: CMP EDI,0x64 JG 0x001011a0 SUB EDI,0x32 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102010] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102030] ADDSD XMM0,qword ptr [0x00102038] ADDSD XMM0,XMM1 RET LAB_001011a0: CMP EDI,0xc8 JG 0x001011d0 SUB EDI,0x64 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102018] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102040] ADDSD XMM0,qword ptr [0x00102048] ADDSD XMM0,XMM1 RET LAB_001011d0: SUB EDI,0xc8 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102020] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102050] ADDSD XMM0,qword ptr [0x00102058] ADDSD XMM0,XMM1 RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(int) */ double func0(int param_1) { if (param_1 < 0x32) { return (double)param_1 * _DAT_00102028 + DAT_00102008; } if (param_1 < 0x65) { return (double)(param_1 + -0x32) * _DAT_00102030 + _DAT_00102038 + DAT_00102010; } if (param_1 < 0xc9) { return (double)(param_1 + -100) * _DAT_00102040 + _DAT_00102048 + DAT_00102018; } return (double)(param_1 + -200) * _DAT_00102050 + _DAT_00102058 + DAT_00102020; }
543
func0
#include <assert.h>
double func0(int units) { double amount; int surcharge; if (units < 50) { amount = units * 2.60; surcharge = 25; } else if (units <= 100) { amount = 130 + ((units - 50) * 3.25); surcharge = 35; } else if (units <= 200) { amount = 130 + 162.50 + ((units - 100) * 5.26); surcharge = 45; } else { amount = 130 + 162.50 + 526 + ((units - 200) * 8.45); surcharge = 75; } double total = amount + surcharge; return total; }
int main() { assert(func0(75) == 246.25); assert(func0(265) == 1442.75); assert(func0(100) == 327.5); return 0; }
O3
cpp
func0(int): endbr64 cmp $0x31,%edi jg 1170 <_Z5func0i+0x30> pxor %xmm0,%xmm0 movsd 0xeb3(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xec7(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopw %cs:0x0(%rax,%rax,1) cmp $0x64,%edi jg 11a0 <_Z5func0i+0x60> sub $0x32,%edi pxor %xmm0,%xmm0 movsd 0xe8c(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xea0(%rip),%xmm0 addsd 0xea0(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopl (%rax) cmp $0xc8,%edi jg 11d0 <_Z5func0i+0x90> sub $0x64,%edi pxor %xmm0,%xmm0 movsd 0xe61(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xe7d(%rip),%xmm0 addsd 0xe7d(%rip),%xmm0 addsd %xmm1,%xmm0 retq sub $0xc8,%edi pxor %xmm0,%xmm0 movsd 0xe3e(%rip),%xmm1 cvtsi2sd %edi,%xmm0 mulsd 0xe62(%rip),%xmm0 addsd 0xe62(%rip),%xmm0 addsd %xmm1,%xmm0 retq nopl 0x0(%rax,%rax,1)
_Z5func0i: endbr64 cmp edi, 31h ; '1' jg short loc_1170 pxor xmm0, xmm0 movsd xmm1, cs:qword_2008 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2028 addsd xmm0, xmm1 retn loc_1170: cmp edi, 64h ; 'd' jg short loc_11A0 sub edi, 32h ; '2' pxor xmm0, xmm0 movsd xmm1, cs:qword_2010 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2030 addsd xmm0, cs:qword_2038 addsd xmm0, xmm1 retn loc_11A0: cmp edi, 0C8h jg short loc_11D0 sub edi, 64h ; 'd' pxor xmm0, xmm0 movsd xmm1, cs:qword_2018 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2040 addsd xmm0, cs:qword_2048 addsd xmm0, xmm1 retn loc_11D0: sub edi, 0C8h pxor xmm0, xmm0 movsd xmm1, cs:qword_2020 cvtsi2sd xmm0, edi mulsd xmm0, cs:qword_2050 addsd xmm0, cs:qword_2058 addsd xmm0, xmm1 retn
double func0(int a1) { if ( a1 <= 49 ) return (double)a1 * 2.6 + 25.0; if ( a1 <= 100 ) return (double)(a1 - 50) * 3.25 + 130.0 + 35.0; if ( a1 > 200 ) return (double)(a1 - 200) * 8.449999999999999 + 818.5 + 75.0; return (double)(a1 - 100) * 5.26 + 292.5 + 45.0; }
func0: ENDBR64 CMP EDI,0x31 JG 0x00101170 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102008] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102028] ADDSD XMM0,XMM1 RET LAB_00101170: CMP EDI,0x64 JG 0x001011a0 SUB EDI,0x32 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102010] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102030] ADDSD XMM0,qword ptr [0x00102038] ADDSD XMM0,XMM1 RET LAB_001011a0: CMP EDI,0xc8 JG 0x001011d0 SUB EDI,0x64 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102018] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102040] ADDSD XMM0,qword ptr [0x00102048] ADDSD XMM0,XMM1 RET LAB_001011d0: SUB EDI,0xc8 PXOR XMM0,XMM0 MOVSD XMM1,qword ptr [0x00102020] CVTSI2SD XMM0,EDI MULSD XMM0,qword ptr [0x00102050] ADDSD XMM0,qword ptr [0x00102058] ADDSD XMM0,XMM1 RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(int) */ double func0(int param_1) { if (param_1 < 0x32) { return (double)param_1 * _DAT_00102028 + DAT_00102008; } if (param_1 < 0x65) { return (double)(param_1 + -0x32) * _DAT_00102030 + _DAT_00102038 + DAT_00102010; } if (param_1 < 0xc9) { return (double)(param_1 + -100) * _DAT_00102040 + _DAT_00102048 + DAT_00102018; } return (double)(param_1 + -200) * _DAT_00102050 + _DAT_00102058 + DAT_00102020; }
544
func0
#include <cassert> #include <vector> #include <cmath>
double func0(const std::vector<int>& nums) { int n = nums.size(); int n1 = 0; for (int x : nums) { if (x == 0) { n1 += 1; } } return round(static_cast<double>(n1) / n * 100.0) / 100.0; }
int main() { assert(func0({0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8}) == 0.15); assert(func0({2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8}) == 0.00); assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == 0.00); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 push %rbp mov %rsp,%rbp sub $0x40,%rsp mov %rdi,-0x38(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax mov -0x38(%rbp),%rax mov %rax,%rdi callq 16de <_ZNKSt6vectorIiSaIiEE4sizeEv> mov %eax,-0x28(%rbp) movl $0x0,-0x2c(%rbp) mov -0x38(%rbp),%rax mov %rax,-0x10(%rbp) mov -0x10(%rbp),%rax mov %rax,%rdi callq 1706 <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x20(%rbp) mov -0x10(%rbp),%rax mov %rax,%rdi callq 175e <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x18(%rbp) lea -0x18(%rbp),%rdx lea -0x20(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 17b6 <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 12e6 <_Z5func0RKSt6vectorIiSaIiEE+0x9d> lea -0x20(%rbp),%rax mov %rax,%rdi callq 181a <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0x24(%rbp) cmpl $0x0,-0x24(%rbp) jne 12d8 <_Z5func0RKSt6vectorIiSaIiEE+0x8f> addl $0x1,-0x2c(%rbp) lea -0x20(%rbp),%rax mov %rax,%rdi callq 17f6 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmp 12a6 <_Z5func0RKSt6vectorIiSaIiEE+0x5d> cvtsi2sdl -0x2c(%rbp),%xmm0 cvtsi2sdl -0x28(%rbp),%xmm1 divsd %xmm1,%xmm0 movapd %xmm0,%xmm1 movsd 0x1e50(%rip),%xmm0 mulsd %xmm1,%xmm0 callq 10e0 <round@plt> movsd 0x1e3f(%rip),%xmm1 divsd %xmm1,%xmm0 mov -0x8(%rbp),%rax xor %fs:0x28,%rax je 1329 <_Z5func0RKSt6vectorIiSaIiEE+0xe0> callq 1130 <__stack_chk_fail@plt> leaveq retq
_Z5func0RKSt6vectorIiSaIiEE: endbr64 push rbp mov rbp, rsp sub rsp, 40h mov [rbp+var_38], rdi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rax, [rbp+var_38] mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) mov [rbp+var_28], eax mov [rbp+var_2C], 0 mov rax, [rbp+var_38] mov [rbp+var_10], rax mov rax, [rbp+var_10] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_20], rax mov rax, [rbp+var_10] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_18], rax jmp short loc_12EF loc_12C8: lea rax, [rbp+var_20] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov [rbp+var_24], eax cmp [rbp+var_24], 0 jnz short loc_12E3 add [rbp+var_2C], 1 loc_12E3: lea rax, [rbp+var_20] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_12EF: lea rdx, [rbp+var_18] lea rax, [rbp+var_20] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz short loc_12C8 pxor xmm0, xmm0 cvtsi2sd xmm0, [rbp+var_2C] pxor xmm2, xmm2 cvtsi2sd xmm2, [rbp+var_28] movapd xmm1, xmm0 divsd xmm1, xmm2 movsd xmm0, cs:qword_3130 mulsd xmm1, xmm0 movq rax, xmm1 movq xmm0, rax; x call _round movq rax, xmm0 movsd xmm0, cs:qword_3130 movq xmm1, rax divsd xmm1, xmm0 movapd xmm0, xmm1 mov rax, [rbp+var_8] sub rax, fs:28h jz short locret_1369 call ___stack_chk_fail locret_1369: leave retn
unsigned long long func0(long long a1) { int v2; // [rsp+14h] [rbp-2Ch] int v3; // [rsp+18h] [rbp-28h] long long v4; // [rsp+20h] [rbp-20h] BYREF _QWORD v5[2]; // [rsp+28h] [rbp-18h] BYREF unsigned long long v6; // [rsp+38h] [rbp-8h] v6 = __readfsqword(0x28u); v3 = std::vector<int>::size(a1); v2 = 0; v5[1] = a1; v4 = std::vector<int>::begin(a1); v5[0] = std::vector<int>::end(a1); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(&v4, v5) ) { if ( !*(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(&v4) ) ++v2; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(&v4); } round((double)v2 / (double)v3 * 100.0); return v6 - __readfsqword(0x28u); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x40 MOV qword ptr [RBP + -0x38],RDI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x38] MOV RDI,RAX CALL 0x00101790 MOV dword ptr [RBP + -0x28],EAX MOV dword ptr [RBP + -0x2c],0x0 MOV RAX,qword ptr [RBP + -0x38] MOV qword ptr [RBP + -0x10],RAX MOV RAX,qword ptr [RBP + -0x10] MOV RDI,RAX CALL 0x001017b8 MOV qword ptr [RBP + -0x20],RAX MOV RAX,qword ptr [RBP + -0x10] MOV RDI,RAX CALL 0x00101804 MOV qword ptr [RBP + -0x18],RAX JMP 0x001012ef LAB_001012c8: LEA RAX,[RBP + -0x20] MOV RDI,RAX CALL 0x001018b8 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x24],EAX CMP dword ptr [RBP + -0x24],0x0 JNZ 0x001012e3 ADD dword ptr [RBP + -0x2c],0x1 LAB_001012e3: LEA RAX,[RBP + -0x20] MOV RDI,RAX CALL 0x00101894 LAB_001012ef: LEA RDX,[RBP + -0x18] LEA RAX,[RBP + -0x20] MOV RSI,RDX MOV RDI,RAX CALL 0x00101854 TEST AL,AL JNZ 0x001012c8 PXOR XMM0,XMM0 CVTSI2SD XMM0,dword ptr [RBP + -0x2c] PXOR XMM2,XMM2 CVTSI2SD XMM2,dword ptr [RBP + -0x28] MOVAPD XMM1,XMM0 DIVSD XMM1,XMM2 MOVSD XMM0,qword ptr [0x00103130] MULSD XMM1,XMM0 MOVQ RAX,XMM1 MOVQ XMM0,RAX CALL 0x001010f0 MOVQ RAX,XMM0 MOVSD XMM0,qword ptr [0x00103130] MOVQ XMM1,RAX DIVSD XMM1,XMM0 MOVAPD XMM0,XMM1 MOV RAX,qword ptr [RBP + -0x8] SUB RAX,qword ptr FS:[0x28] JZ 0x00101369 CALL 0x00101150 LAB_00101369: LEAVE RET
/* func0(std::vector<int, std::allocator<int> > const&) */ double func0(vector *param_1) { bool bVar1; int iVar2; int *piVar3; long in_FS_OFFSET; double dVar4; int local_34; int8 local_28; int8 local_20; vector<int,std::allocator<int>> *local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); iVar2 = std::vector<int,std::allocator<int>>::size((vector<int,std::allocator<int>> *)param_1); local_34 = 0; local_18 = (vector<int,std::allocator<int>> *)param_1; local_28 = std::vector<int,std::allocator<int>>::begin((vector<int,std::allocator<int>> *)param_1) ; local_20 = std::vector<int,std::allocator<int>>::end(local_18); while( true ) { bVar1 = operator!=((__normal_iterator *)&local_28,(__normal_iterator *)&local_20); if (!bVar1) break; piVar3 = (int *)__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> * )&local_28); if (*piVar3 == 0) { local_34 = local_34 + 1; } __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_28); } dVar4 = round(((double)local_34 / (double)iVar2) * DAT_00103130); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return dVar4 / DAT_00103130; }
545
func0
#include <cassert> #include <vector> #include <cmath>
double func0(const std::vector<int>& nums) { int n = nums.size(); int n1 = 0; for (int x : nums) { if (x == 0) { n1 += 1; } } return round(static_cast<double>(n1) / n * 100.0) / 100.0; }
int main() { assert(func0({0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8}) == 0.15); assert(func0({2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8}) == 0.00); assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == 0.00); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 sub $0x8,%rsp mov 0x8(%rdi),%rcx mov (%rdi),%rax mov %rcx,%rsi sub %rax,%rsi sar $0x2,%rsi cmp %rax,%rcx je 1289 <_Z5func0RKSt6vectorIiSaIiEE+0x60> mov $0x0,%edx cmpl $0x1,(%rax) adc $0x0,%edx add $0x4,%rax cmp %rax,%rcx jne 124c <_Z5func0RKSt6vectorIiSaIiEE+0x23> pxor %xmm0,%xmm0 cvtsi2sd %edx,%xmm0 pxor %xmm1,%xmm1 cvtsi2sd %esi,%xmm1 divsd %xmm1,%xmm0 mulsd 0xed1(%rip),%xmm0 callq 10c0 <round@plt> divsd 0xec4(%rip),%xmm0 add $0x8,%rsp retq mov $0x0,%edx jmp 125b <_Z5func0RKSt6vectorIiSaIiEE+0x32>
_Z5func0RKSt6vectorIiSaIiEE: endbr64 sub rsp, 8 mov rcx, [rdi+8] mov rax, [rdi] mov rsi, rcx sub rsi, rax sar rsi, 2 cmp rcx, rax jz short loc_1289 mov edx, 0 loc_124C: cmp dword ptr [rax], 1 adc edx, 0 add rax, 4 cmp rax, rcx jnz short loc_124C loc_125B: pxor xmm0, xmm0 cvtsi2sd xmm0, edx pxor xmm1, xmm1 cvtsi2sd xmm1, esi divsd xmm0, xmm1 mulsd xmm0, cs:qword_2120; x call _round divsd xmm0, cs:qword_2120 add rsp, 8 retn loc_1289: mov edx, 0 jmp short loc_125B
double func0(long long a1) { _DWORD *v1; // rcx _DWORD *v2; // rax int v3; // edx v1 = *(_DWORD **)(a1 + 8); v2 = *(_DWORD **)a1; if ( v1 == *(_DWORD **)a1 ) { v3 = 0; } else { v3 = 0; do v3 += *v2++ == 0; while ( v2 != v1 ); } return round((double)v3 / (double)(int)(((long long)v1 - *(_QWORD *)a1) >> 2) * 100.0) / 100.0; }
func0: ENDBR64 SUB RSP,0x8 MOV RCX,qword ptr [RDI + 0x8] MOV RAX,qword ptr [RDI] MOV RSI,RCX SUB RSI,RAX SAR RSI,0x2 CMP RCX,RAX JZ 0x00101289 MOV EDX,0x0 LAB_0010124c: CMP dword ptr [RAX],0x1 ADC EDX,0x0 ADD RAX,0x4 CMP RAX,RCX JNZ 0x0010124c LAB_0010125b: PXOR XMM0,XMM0 CVTSI2SD XMM0,EDX PXOR XMM1,XMM1 CVTSI2SD XMM1,ESI DIVSD XMM0,XMM1 MULSD XMM0,qword ptr [0x00102120] CALL 0x001010c0 DIVSD XMM0,qword ptr [0x00102120] ADD RSP,0x8 RET LAB_00101289: MOV EDX,0x0 JMP 0x0010125b
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(std::vector<int, std::allocator<int> > const&) */ double func0(vector *param_1) { int *piVar1; int *piVar2; int iVar3; long lVar4; double dVar5; piVar1 = *(int **)(param_1 + 8); piVar2 = *(int **)param_1; lVar4 = (long)piVar1 - (long)piVar2; if (piVar1 == piVar2) { iVar3 = 0; } else { iVar3 = 0; do { iVar3 = iVar3 + (uint)(*piVar2 == 0); piVar2 = piVar2 + 1; } while (piVar2 != piVar1); } dVar5 = round(((double)iVar3 / (double)(int)(lVar4 >> 2)) * _DAT_00102120); return dVar5 / _DAT_00102120; }
546
func0
#include <cassert> #include <vector> #include <cmath>
double func0(const std::vector<int>& nums) { int n = nums.size(); int n1 = 0; for (int x : nums) { if (x == 0) { n1 += 1; } } return round(static_cast<double>(n1) / n * 100.0) / 100.0; }
int main() { assert(func0({0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8}) == 0.15); assert(func0({2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8}) == 0.00); assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == 0.00); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 sub $0x8,%rsp mov 0x8(%rdi),%rcx mov (%rdi),%rax mov %rcx,%rsi sub %rax,%rsi sar $0x2,%rsi cmp %rcx,%rax je 1500 <_Z5func0RKSt6vectorIiSaIiEE+0x60> xor %edx,%edx cmpl $0x1,(%rax) adc $0x0,%edx add $0x4,%rax cmp %rax,%rcx jne 14c0 <_Z5func0RKSt6vectorIiSaIiEE+0x20> pxor %xmm0,%xmm0 cvtsi2sd %edx,%xmm0 pxor %xmm1,%xmm1 cvtsi2sd %esi,%xmm1 divsd %xmm1,%xmm0 mulsd 0xc5d(%rip),%xmm0 callq 10c0 <round@plt> divsd 0xc50(%rip),%xmm0 add $0x8,%rsp retq nopl (%rax) pxor %xmm0,%xmm0 jmp 14d7 <_Z5func0RKSt6vectorIiSaIiEE+0x37> nopw %cs:0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIiSaIiEE: endbr64 sub rsp, 8 mov rcx, [rdi+8] mov rax, [rdi] mov rsi, rcx sub rsi, rax sar rsi, 2 cmp rcx, rax jz short loc_1460 xor edx, edx loc_1420: cmp dword ptr [rax], 1 adc edx, 0 add rax, 4 cmp rax, rcx jnz short loc_1420 pxor xmm0, xmm0 cvtsi2sd xmm0, edx loc_1437: pxor xmm1, xmm1 cvtsi2sd xmm1, esi divsd xmm0, xmm1 mulsd xmm0, cs:qword_2120; x call _round divsd xmm0, cs:qword_2120 add rsp, 8 retn loc_1460: pxor xmm0, xmm0 jmp short loc_1437
double func0(long long a1) { _DWORD *v1; // rcx _DWORD *v2; // rax int v3; // edx double v4; // xmm0_8 v1 = *(_DWORD **)(a1 + 8); v2 = *(_DWORD **)a1; if ( v1 == *(_DWORD **)a1 ) { v4 = 0.0; } else { v3 = 0; do v3 += *v2++ == 0; while ( v2 != v1 ); v4 = (double)v3; } return round(v4 / (double)(int)(((long long)v1 - *(_QWORD *)a1) >> 2) * 100.0) / 100.0; }
func0: ENDBR64 SUB RSP,0x8 MOV RCX,qword ptr [RDI + 0x8] MOV RAX,qword ptr [RDI] MOV RSI,RCX SUB RSI,RAX SAR RSI,0x2 CMP RCX,RAX JZ 0x00101460 XOR EDX,EDX LAB_00101420: CMP dword ptr [RAX],0x1 ADC EDX,0x0 ADD RAX,0x4 CMP RAX,RCX JNZ 0x00101420 PXOR XMM0,XMM0 CVTSI2SD XMM0,EDX LAB_00101437: PXOR XMM1,XMM1 CVTSI2SD XMM1,ESI DIVSD XMM0,XMM1 MULSD XMM0,qword ptr [0x00102120] CALL 0x001010c0 DIVSD XMM0,qword ptr [0x00102120] ADD RSP,0x8 RET LAB_00101460: PXOR XMM0,XMM0 JMP 0x00101437
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(std::vector<int, std::allocator<int> > const&) */ double func0(vector *param_1) { int *piVar1; int *piVar2; int iVar3; long lVar4; double dVar5; piVar1 = *(int **)(param_1 + 8); piVar2 = *(int **)param_1; lVar4 = (long)piVar1 - (long)piVar2; if (piVar1 == piVar2) { dVar5 = 0.0; } else { iVar3 = 0; do { iVar3 = iVar3 + (uint)(*piVar2 == 0); piVar2 = piVar2 + 1; } while (piVar2 != piVar1); dVar5 = (double)iVar3; } dVar5 = round((dVar5 / (double)(int)(lVar4 >> 2)) * _DAT_00102120); return dVar5 / _DAT_00102120; }
547
func0
#include <cassert> #include <vector> #include <cmath>
double func0(const std::vector<int>& nums) { int n = nums.size(); int n1 = 0; for (int x : nums) { if (x == 0) { n1 += 1; } } return round(static_cast<double>(n1) / n * 100.0) / 100.0; }
int main() { assert(func0({0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8}) == 0.15); assert(func0({2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8}) == 0.00); assert(func0({2, 4, -6, -9, 11, -12, 14, -5, 17}) == 0.00); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> > const&): endbr64 sub $0x8,%rsp mov 0x8(%rdi),%r8 mov (%rdi),%rdx mov %r8,%rsi sub %rdx,%rsi sar $0x2,%rsi cmp %r8,%rdx je 1520 <_Z5func0RKSt6vectorIiSaIiEE+0x110> lea -0x4(%r8),%rcx mov %rdx,%rax movabs $0x3ffffffffffffffc,%r9 sub %rdx,%rcx shr $0x2,%rcx lea 0x1(%rcx),%rdi test %r9,%rcx je 1526 <_Z5func0RKSt6vectorIiSaIiEE+0x116> mov %rdi,%rcx pxor %xmm0,%xmm0 shr $0x2,%rcx movdqa %xmm0,%xmm2 shl $0x4,%rcx add %rdx,%rcx nopl (%rax) movdqu (%rax),%xmm1 add $0x10,%rax pcmpeqd %xmm2,%xmm1 psubd %xmm1,%xmm0 cmp %rcx,%rax jne 1470 <_Z5func0RKSt6vectorIiSaIiEE+0x60> movdqa %xmm0,%xmm1 mov %rdi,%rcx psrldq $0x8,%xmm1 and $0xfffffffffffffffc,%rcx paddd %xmm1,%xmm0 lea (%rdx,%rcx,4),%rdx movdqa %xmm0,%xmm1 psrldq $0x4,%xmm1 paddd %xmm1,%xmm0 movd %xmm0,%eax cmp %rcx,%rdi je 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0xd9> cmpl $0x1,(%rdx) lea 0x4(%rdx),%rcx adc $0x0,%eax cmp %rcx,%r8 je 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0xd9> cmpl $0x1,0x4(%rdx) lea 0x8(%rdx),%rcx adc $0x0,%eax cmp %rcx,%r8 je 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0xd9> cmpl $0x1,0x8(%rdx) lea 0xc(%rdx),%rcx adc $0x0,%eax cmp %rcx,%r8 je 14e9 <_Z5func0RKSt6vectorIiSaIiEE+0xd9> cmpl $0x1,0xc(%rdx) adc $0x0,%eax pxor %xmm0,%xmm0 cvtsi2sd %eax,%xmm0 pxor %xmm1,%xmm1 cvtsi2sd %esi,%xmm1 divsd %xmm1,%xmm0 mulsd 0xc43(%rip),%xmm0 callq 10c0 <round@plt> divsd 0xc36(%rip),%xmm0 add $0x8,%rsp retq nopw 0x0(%rax,%rax,1) pxor %xmm0,%xmm0 jmp 14f1 <_Z5func0RKSt6vectorIiSaIiEE+0xe1> xor %eax,%eax jmp 14b3 <_Z5func0RKSt6vectorIiSaIiEE+0xa3> nopw 0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIiSaIiEE: endbr64 sub rsp, 8 mov r8, [rdi+8] mov rdx, [rdi] mov rdi, r8 sub rdi, rdx sar rdi, 2 cmp r8, rdx jz loc_1500 lea rcx, [r8-4] mov rax, rdx sub rcx, rdx mov rsi, rcx shr rsi, 2 add rsi, 1 cmp rcx, 8 jbe loc_1506 mov rcx, rsi pxor xmm0, xmm0 shr rcx, 2 movdqa xmm2, xmm0 shl rcx, 4 add rcx, rdx nop word ptr [rax+rax+00000000h] loc_1460: movdqu xmm1, xmmword ptr [rax] add rax, 10h pcmpeqd xmm1, xmm2 psubd xmm0, xmm1 cmp rax, rcx jnz short loc_1460 movdqa xmm1, xmm0 mov rcx, rsi psrldq xmm1, 8 and rcx, 0FFFFFFFFFFFFFFFCh and esi, 3 paddd xmm0, xmm1 lea rdx, [rdx+rcx*4] movdqa xmm1, xmm0 psrldq xmm1, 4 paddd xmm0, xmm1 movd eax, xmm0 jz short loc_14C9 loc_14A3: cmp dword ptr [rdx], 1 lea rcx, [rdx+4] adc eax, 0 cmp r8, rcx jz short loc_14C9 cmp dword ptr [rdx+4], 1 lea rcx, [rdx+8] adc eax, 0 cmp r8, rcx jz short loc_14C9 cmp dword ptr [rdx+8], 1 adc eax, 0 loc_14C9: pxor xmm0, xmm0 cvtsi2sd xmm0, eax loc_14D1: pxor xmm1, xmm1 cvtsi2sd xmm1, edi divsd xmm0, xmm1 mulsd xmm0, cs:qword_2128; x call _round divsd xmm0, cs:qword_2128 add rsp, 8 retn loc_1500: pxor xmm0, xmm0 jmp short loc_14D1 loc_1506: xor eax, eax jmp short loc_14A3
double func0(const __m128i **a1) { const __m128i *v1; // r8 const __m128i *v2; // rdx long long v3; // rdi const __m128i *v4; // rax unsigned long long v5; // rsi __m128i v6; // xmm0 __m128i v7; // xmm1 __m128i v8; // xmm0 int v9; // eax double v10; // xmm0_8 v1 = a1[1]; v2 = *a1; v3 = ((char *)v1 - (char *)*a1) >> 2; if ( v1 == v2 ) { v10 = 0.0; return round(v10 / (double)(int)v3 * 100.0) / 100.0; } v4 = v2; v5 = ((unsigned long long)((char *)&v1[-1].m128i_u64[1] + 4 - (char *)v2) >> 2) + 1; if ( (unsigned long long)((char *)&v1[-1].m128i_u64[1] + 4 - (char *)v2) <= 8 ) { v9 = 0; goto LABEL_6; } v6 = 0LL; do { v7 = _mm_loadu_si128(v4++); v6 = _mm_sub_epi32(v6, _mm_cmpeq_epi32(v7, (__m128i)0LL)); } while ( v4 != &v2[v5 >> 2] ); v8 = _mm_add_epi32(v6, _mm_srli_si128(v6, 8)); v2 = (const __m128i *)((char *)v2 + 4 * (v5 & 0xFFFFFFFFFFFFFFFCLL)); v9 = _mm_cvtsi128_si32(_mm_add_epi32(v8, _mm_srli_si128(v8, 4))); if ( (v5 & 3) != 0 ) { LABEL_6: v9 += v2->m128i_i32[0] == 0; if ( v1 != (const __m128i *)((char *)v2->m128i_i64 + 4) ) { v9 += v2->m128i_i32[1] == 0; if ( v1 != (const __m128i *)&v2->m128i_u64[1] ) v9 += v2->m128i_i32[2] == 0; } } v10 = (double)v9; return round(v10 / (double)(int)v3 * 100.0) / 100.0; }
func0: ENDBR64 SUB RSP,0x8 MOV R8,qword ptr [RDI + 0x8] MOV RDX,qword ptr [RDI] MOV RDI,R8 SUB RDI,RDX SAR RDI,0x2 CMP R8,RDX JZ 0x00101500 LEA RCX,[R8 + -0x4] MOV RAX,RDX SUB RCX,RDX MOV RSI,RCX SHR RSI,0x2 ADD RSI,0x1 CMP RCX,0x8 JBE 0x00101506 MOV RCX,RSI PXOR XMM0,XMM0 SHR RCX,0x2 MOVDQA XMM2,XMM0 SHL RCX,0x4 ADD RCX,RDX NOP word ptr [RAX + RAX*0x1] LAB_00101460: MOVDQU XMM1,xmmword ptr [RAX] ADD RAX,0x10 PCMPEQD XMM1,XMM2 PSUBD XMM0,XMM1 CMP RAX,RCX JNZ 0x00101460 MOVDQA XMM1,XMM0 MOV RCX,RSI PSRLDQ XMM1,0x8 AND RCX,-0x4 AND ESI,0x3 PADDD XMM0,XMM1 LEA RDX,[RDX + RCX*0x4] MOVDQA XMM1,XMM0 PSRLDQ XMM1,0x4 PADDD XMM0,XMM1 MOVD EAX,XMM0 JZ 0x001014c9 LAB_001014a3: CMP dword ptr [RDX],0x1 LEA RCX,[RDX + 0x4] ADC EAX,0x0 CMP R8,RCX JZ 0x001014c9 CMP dword ptr [RDX + 0x4],0x1 LEA RCX,[RDX + 0x8] ADC EAX,0x0 CMP R8,RCX JZ 0x001014c9 CMP dword ptr [RDX + 0x8],0x1 ADC EAX,0x0 LAB_001014c9: PXOR XMM0,XMM0 CVTSI2SD XMM0,EAX LAB_001014d1: PXOR XMM1,XMM1 CVTSI2SD XMM1,EDI DIVSD XMM0,XMM1 MULSD XMM0,qword ptr [0x00102128] CALL 0x001010c0 DIVSD XMM0,qword ptr [0x00102128] ADD RSP,0x8 RET LAB_00101500: PXOR XMM0,XMM0 JMP 0x001014d1 LAB_00101506: XOR EAX,EAX JMP 0x001014a3
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(std::vector<int, std::allocator<int> > const&) */ double func0(vector *param_1) { int *piVar1; int iVar2; int *piVar3; int *piVar4; int *piVar5; int *piVar6; ulong uVar7; int *piVar8; ulong uVar9; long lVar10; int iVar11; int iVar13; double dVar12; int iVar14; int iVar15; piVar1 = *(int **)(param_1 + 8); piVar8 = *(int **)param_1; lVar10 = (long)piVar1 - (long)piVar8; if (piVar1 == piVar8) { dVar12 = 0.0; goto LAB_001014d1; } uVar7 = (long)piVar1 + (-4 - (long)piVar8); uVar9 = (uVar7 >> 2) + 1; if (uVar7 < 9) { iVar11 = 0; LAB_001014a3: iVar11 = iVar11 + (uint)(*piVar8 == 0); if ((piVar1 != piVar8 + 1) && (iVar11 = iVar11 + (uint)(piVar8[1] == 0), piVar1 != piVar8 + 2)) { iVar11 = iVar11 + (uint)(piVar8[2] == 0); } } else { iVar11 = 0; iVar13 = 0; iVar14 = 0; iVar15 = 0; piVar6 = piVar8; do { iVar2 = *piVar6; piVar3 = piVar6 + 1; piVar4 = piVar6 + 2; piVar5 = piVar6 + 3; piVar6 = piVar6 + 4; iVar11 = iVar11 + (uint)(iVar2 == 0); iVar13 = iVar13 + (uint)(*piVar3 == 0); iVar14 = iVar14 + (uint)(*piVar4 == 0); iVar15 = iVar15 + (uint)(*piVar5 == 0); } while (piVar6 != piVar8 + (uVar9 & 0xfffffffffffffffc)); piVar8 = piVar8 + (uVar9 & 0xfffffffffffffffc); iVar11 = iVar11 + iVar14 + iVar13 + iVar15; if ((uVar9 & 3) != 0) goto LAB_001014a3; } dVar12 = (double)iVar11; LAB_001014d1: dVar12 = round((dVar12 / (double)(int)(lVar10 >> 2)) * _DAT_00102128); return dVar12 / _DAT_00102128; }
548
func0
#include <assert.h>
bool func0(int n) { if (n % 2 == 1) { return false; } else { return true; } }
int main() { assert(func0(10) == true); assert(func0(7) == false); assert(func0(14) == true); return 0; }
O0
cpp
func0(int): endbr64 push %rbp mov %rsp,%rbp mov %edi,-0x4(%rbp) mov -0x4(%rbp),%eax cltd shr $0x1f,%edx add %edx,%eax and $0x1,%eax sub %edx,%eax cmp $0x1,%eax jne 116e <_Z5func0i+0x25> mov $0x0,%eax jmp 1173 <_Z5func0i+0x2a> mov $0x1,%eax pop %rbp retq
_Z5func0i: endbr64 push rbp mov rbp, rsp mov [rbp+var_4], edi mov edx, [rbp+var_4] mov eax, edx sar eax, 1Fh shr eax, 1Fh add edx, eax and edx, 1 sub edx, eax mov eax, edx cmp eax, 1 jnz short loc_1174 mov eax, 0 jmp short loc_1179 loc_1174: mov eax, 1 loc_1179: pop rbp retn
_BOOL8 func0(int a1) { return a1 % 2 != 1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOV dword ptr [RBP + -0x4],EDI MOV EDX,dword ptr [RBP + -0x4] MOV EAX,EDX SAR EAX,0x1f SHR EAX,0x1f ADD EDX,EAX AND EDX,0x1 SUB EDX,EAX MOV EAX,EDX CMP EAX,0x1 JNZ 0x00101174 MOV EAX,0x0 JMP 0x00101179 LAB_00101174: MOV EAX,0x1 LAB_00101179: POP RBP RET
/* func0(int) */ bool func0(int param_1) { return param_1 % 2 != 1; }
549
func0
#include <assert.h>
bool func0(int n) { if (n % 2 == 1) { return false; } else { return true; } }
int main() { assert(func0(10) == true); assert(func0(7) == false); assert(func0(14) == true); return 0; }
O1
cpp
func0(int): endbr64 mov %edi,%eax shr $0x1f,%eax add %eax,%edi and $0x1,%edi sub %eax,%edi cmp $0x1,%edi setne %al retq
_Z5func0i: endbr64 mov eax, edi shr eax, 1Fh add edi, eax and edi, 1 sub edi, eax cmp edi, 1 setnz al retn
bool func0(int a1) { return a1 % 2 != 1; }
func0: ENDBR64 MOV EAX,EDI SHR EAX,0x1f ADD EDI,EAX AND EDI,0x1 SUB EDI,EAX CMP EDI,0x1 SETNZ AL RET
/* func0(int) */ bool func0(int param_1) { return param_1 % 2 != 1; }
550
func0
#include <assert.h>
bool func0(int n) { if (n % 2 == 1) { return false; } else { return true; } }
int main() { assert(func0(10) == true); assert(func0(7) == false); assert(func0(14) == true); return 0; }
O2
cpp
func0(int): endbr64 mov %edi,%eax shr $0x1f,%eax add %eax,%edi and $0x1,%edi sub %eax,%edi cmp $0x1,%edi setne %al retq nopw 0x0(%rax,%rax,1)
_Z5func0i: endbr64 mov eax, edi shr eax, 1Fh add edi, eax and edi, 1 sub edi, eax cmp edi, 1 setnz al retn
bool func0(int a1) { return a1 % 2 != 1; }
func0: ENDBR64 MOV EAX,EDI SHR EAX,0x1f ADD EDI,EAX AND EDI,0x1 SUB EDI,EAX CMP EDI,0x1 SETNZ AL RET
/* func0(int) */ bool func0(int param_1) { return param_1 % 2 != 1; }
551
func0
#include <assert.h>
bool func0(int n) { if (n % 2 == 1) { return false; } else { return true; } }
int main() { assert(func0(10) == true); assert(func0(7) == false); assert(func0(14) == true); return 0; }
O3
cpp
func0(int): endbr64 mov %edi,%eax shr $0x1f,%eax add %eax,%edi and $0x1,%edi sub %eax,%edi cmp $0x1,%edi setne %al retq nopw 0x0(%rax,%rax,1)
_Z5func0i: endbr64 mov eax, edi shr eax, 1Fh add edi, eax and edi, 1 sub edi, eax cmp edi, 1 setnz al retn
bool func0(int a1) { return a1 % 2 != 1; }
func0: ENDBR64 MOV EAX,EDI SHR EAX,0x1f ADD EDI,EAX AND EDI,0x1 SUB EDI,EAX CMP EDI,0x1 SETNZ AL RET
/* func0(int) */ bool func0(int param_1) { return param_1 % 2 != 1; }
552
func0
#include <assert.h>
double func0(double r) { double perimeter = 2 * 3.1415 * r; return perimeter; }
int main() { assert(func0(10) == 62.830000000000005); assert(func0(5) == 31.415000000000003); assert(func0(4) == 25.132); return 0; }
O0
cpp
func0(double): endbr64 push %rbp mov %rsp,%rbp movsd %xmm0,-0x18(%rbp) movsd -0x18(%rbp),%xmm1 movsd 0xf55(%rip),%xmm0 mulsd %xmm1,%xmm0 movsd %xmm0,-0x8(%rbp) movsd -0x8(%rbp),%xmm0 pop %rbp retq
_Z5func0d: endbr64 push rbp mov rbp, rsp movsd [rbp+var_18], xmm0 movsd xmm1, [rbp+var_18] movsd xmm0, cs:qword_2098 mulsd xmm0, xmm1 movsd [rbp+var_8], xmm0 movsd xmm0, [rbp+var_8] pop rbp retn
double func0(double a1) { return 6.283 * a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP MOVSD qword ptr [RBP + -0x18],XMM0 MOVSD XMM1,qword ptr [RBP + -0x18] MOVSD XMM0,qword ptr [0x00102098] MULSD XMM0,XMM1 MOVSD qword ptr [RBP + -0x8],XMM0 MOVSD XMM0,qword ptr [RBP + -0x8] POP RBP RET
/* func0(double) */ double func0(double param_1) { return DAT_00102098 * param_1; }
553
func0
#include <assert.h>
double func0(double r) { double perimeter = 2 * 3.1415 * r; return perimeter; }
int main() { assert(func0(10) == 62.830000000000005); assert(func0(5) == 31.415000000000003); assert(func0(4) == 25.132); return 0; }
O1
cpp
func0(double): endbr64 mulsd 0xed3(%rip),%xmm0 retq
_Z5func0d: endbr64 mulsd xmm0, cs:qword_2008 retn
double func0(double a1) { return a1 * 6.283; }
func0: ENDBR64 MULSD XMM0,qword ptr [0x00102008] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(double) */ double func0(double param_1) { return param_1 * _DAT_00102008; }
554
func0
#include <assert.h>
double func0(double r) { double perimeter = 2 * 3.1415 * r; return perimeter; }
int main() { assert(func0(10) == 62.830000000000005); assert(func0(5) == 31.415000000000003); assert(func0(4) == 25.132); return 0; }
O2
cpp
func0(double): endbr64 mulsd 0xebc(%rip),%xmm0 retq nopl (%rax)
_Z5func0d: endbr64 mulsd xmm0, cs:qword_2008 retn
double func0(double a1) { return a1 * 6.283; }
func0: ENDBR64 MULSD XMM0,qword ptr [0x00102008] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(double) */ double func0(double param_1) { return param_1 * _DAT_00102008; }
555
func0
#include <assert.h>
double func0(double r) { double perimeter = 2 * 3.1415 * r; return perimeter; }
int main() { assert(func0(10) == 62.830000000000005); assert(func0(5) == 31.415000000000003); assert(func0(4) == 25.132); return 0; }
O3
cpp
func0(double): endbr64 mulsd 0xebc(%rip),%xmm0 retq nopl (%rax)
_Z5func0d: endbr64 mulsd xmm0, cs:qword_2008 retn
double func0(double a1) { return a1 * 6.283; }
func0: ENDBR64 MULSD XMM0,qword ptr [0x00102008] RET
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(double) */ double func0(double param_1) { return param_1 * _DAT_00102008; }
556
func0
#include <vector> #include <set> #include <cassert>
std::vector<int> func0(const std::vector<std::vector<int>>& test_list) { std::vector<int> res; std::set<int> temp; for (const auto& inner : test_list) { for (int ele : inner) { if (temp.find(ele) == temp.end()) { temp.insert(ele); res.push_back(ele); } } } return res; }
int main() { assert((func0({{3, 4, 5}, {4, 5, 7}, {1, 4}}) == std::vector<int>{3, 4, 5, 7, 1})); assert((func0({{1, 2, 3}, {4, 2, 3}, {7, 8}}) == std::vector<int>{1, 2, 3, 4, 7, 8})); assert((func0({{7, 8, 9}, {10, 11, 12}, {10, 11}}) == std::vector<int>{7, 8, 9, 10, 11, 12})); return 0; }
O0
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0xa8,%rsp mov %rdi,-0xa8(%rbp) mov %rsi,-0xb0(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0xa8(%rbp),%rax mov %rax,%rdi callq 224c <_ZNSt6vectorIiSaIiEEC1Ev> lea -0x50(%rbp),%rax mov %rax,%rdi callq 22ac <_ZNSt3setIiSt4lessIiESaIiEEC1Ev> mov -0xb0(%rbp),%rax mov %rax,-0x68(%rbp) mov -0x68(%rbp),%rax mov %rax,%rdi callq 246c <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE5beginEv> mov %rax,-0x98(%rbp) mov -0x68(%rbp),%rax mov %rax,%rdi callq 24c4 <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE3endEv> mov %rax,-0x90(%rbp) lea -0x90(%rbp),%rdx lea -0x98(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 251c <_ZN9__gnu_cxxneIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_> test %al,%al je 148e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1a5> lea -0x98(%rbp),%rax mov %rax,%rdi callq 2580 <_ZNK9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEdeEv> mov %rax,-0x60(%rbp) mov -0x60(%rbp),%rax mov %rax,-0x58(%rbp) mov -0x58(%rbp),%rax mov %rax,%rdi callq 2596 <_ZNKSt6vectorIiSaIiEE5beginEv> mov %rax,-0x88(%rbp) mov -0x58(%rbp),%rax mov %rax,%rdi callq 25ee <_ZNKSt6vectorIiSaIiEE3endEv> mov %rax,-0x80(%rbp) lea -0x80(%rbp),%rdx lea -0x88(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2646 <_ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_> test %al,%al je 147a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x191> lea -0x88(%rbp),%rax mov %rax,%rdi callq 26aa <_ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv> mov (%rax),%eax mov %eax,-0x9c(%rbp) lea -0x50(%rbp),%rax mov %rax,%rdi callq 2728 <_ZNKSt3setIiSt4lessIiESaIiEE3endEv> mov %rax,-0x70(%rbp) lea -0x9c(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 26c0 <_ZNSt3setIiSt4lessIiESaIiEE4findERKi> mov %rax,-0x78(%rbp) lea -0x70(%rbp),%rdx lea -0x78(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 2746 <_ZSteqRKSt23_Rb_tree_const_iteratorIiES2_> test %al,%al je 1466 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x17d> lea -0x9c(%rbp),%rdx lea -0x50(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 276c <_ZNSt3setIiSt4lessIiESaIiEE6insertERKi> lea -0x9c(%rbp),%rdx mov -0xa8(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 27e4 <_ZNSt6vectorIiSaIiEE9push_backERKi> lea -0x88(%rbp),%rax mov %rax,%rdi callq 2686 <_ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv> jmpq 13c1 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xd8> lea -0x98(%rbp),%rax mov %rax,%rdi callq 255c <_ZN9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEppEv> jmpq 1362 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x79> lea -0x50(%rbp),%rax mov %rax,%rdi callq 22cc <_ZNSt3setIiSt4lessIiESaIiEED1Ev> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 14df <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1f6> jmp 14da <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1f1> endbr64 mov %rax,%rbx lea -0x50(%rbp),%rax mov %rax,%rdi callq 22cc <_ZNSt3setIiSt4lessIiESaIiEED1Ev> mov -0xa8(%rbp),%rax mov %rax,%rdi callq 238a <_ZNSt6vectorIiSaIiEED1Ev> mov %rbx,%rax mov %rax,%rdi callq 11f0 <_Unwind_Resume@plt> callq 11b0 <__stack_chk_fail@plt> mov -0xa8(%rbp),%rax add $0xa8,%rsp pop %rbx pop %rbp retq
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 0A8h mov [rbp+var_A8], rdi mov [rbp+var_B0], rsi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+var_A8] mov rdi, rax call _ZNSt6vectorIiSaIiEEC2Ev; std::vector<int>::vector(void) lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEEC2Ev; std::set<int>::set(void) mov rax, [rbp+var_B0] mov [rbp+var_68], rax mov rax, [rbp+var_68] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE5beginEv; std::vector<std::vector<int>>::begin(void) mov [rbp+var_98], rax mov rax, [rbp+var_68] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE3endEv; std::vector<std::vector<int>>::end(void) mov [rbp+var_90], rax jmp loc_148D loc_1387: lea rax, [rbp+var_98] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEdeEv; __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator*(void) mov [rbp+var_60], rax mov rax, [rbp+var_60] mov [rbp+var_58], rax mov rax, [rbp+var_58] mov rdi, rax call _ZNKSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_88], rax mov rax, [rbp+var_58] mov rdi, rax call _ZNKSt6vectorIiSaIiEE3endEv; std::vector<int>::end(void) mov [rbp+var_80], rax jmp loc_1460 loc_13CA: lea rax, [rbp+var_88] mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEdeEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(void) mov eax, [rax] mov [rbp+var_9C], eax lea rax, [rbp+var_50] mov rdi, rax call _ZNKSt3setIiSt4lessIiESaIiEE3endEv; std::set<int>::end(void) mov [rbp+var_70], rax lea rdx, [rbp+var_9C] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEE4findERKi; std::set<int>::find(int const&) mov [rbp+var_78], rax lea rdx, [rbp+var_70] lea rax, [rbp+var_78] mov rsi, rdx mov rdi, rax call _ZSteqRKSt23_Rb_tree_const_iteratorIiES2_; std::operator==(std::_Rb_tree_const_iterator<int> const&,std::_Rb_tree_const_iterator<int> const&) test al, al jz short loc_1451 lea rdx, [rbp+var_9C] lea rax, [rbp+var_50] mov rsi, rdx mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEE6insertERKi; std::set<int>::insert(int const&) lea rdx, [rbp+var_9C] mov rax, [rbp+var_A8] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEE9push_backERKi; std::vector<int>::push_back(int const&) loc_1451: lea rax, [rbp+var_88] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEppEv; __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(void) loc_1460: lea rdx, [rbp+var_80] lea rax, [rbp+var_88] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESB_; __gnu_cxx::operator!=<int const*,std::vector<int>>(__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int const*,std::vector<int>> const&) test al, al jnz loc_13CA lea rax, [rbp+var_98] mov rdi, rax call _ZN9__gnu_cxx17__normal_iteratorIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEppEv; __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator++(void) loc_148D: lea rdx, [rbp+var_90] lea rax, [rbp+var_98] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxneIPKSt6vectorIiSaIiEES1_IS3_SaIS3_EEEEbRKNS_17__normal_iteratorIT_T0_EESD_; __gnu_cxx::operator!=<std::vector<int> const*,std::vector<std::vector<int>>>(__gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>> const&,__gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>> const&) test al, al jnz loc_1387 nop lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEED2Ev; std::set<int>::~set() nop mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_1513 jmp short loc_150E endbr64 mov rbx, rax lea rax, [rbp+var_50] mov rdi, rax call _ZNSt3setIiSt4lessIiESaIiEED2Ev; std::set<int>::~set() mov rax, [rbp+var_A8] mov rdi, rax call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, rbx mov rdx, [rbp+var_18] sub rdx, fs:28h jz short loc_1506 call ___stack_chk_fail loc_1506: mov rdi, rax; struct _Unwind_Exception * call __Unwind_Resume loc_150E: call ___stack_chk_fail loc_1513: mov rax, [rbp+var_A8] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, long long a2) { int v3; // [rsp+14h] [rbp-9Ch] BYREF long long v4; // [rsp+18h] [rbp-98h] BYREF long long v5; // [rsp+20h] [rbp-90h] BYREF long long v6; // [rsp+28h] [rbp-88h] BYREF long long v7; // [rsp+30h] [rbp-80h] BYREF long long v8; // [rsp+38h] [rbp-78h] BYREF _QWORD v9[2]; // [rsp+40h] [rbp-70h] BYREF long long v10; // [rsp+50h] [rbp-60h] long long v11; // [rsp+58h] [rbp-58h] _BYTE v12[56]; // [rsp+60h] [rbp-50h] BYREF unsigned long long v13; // [rsp+98h] [rbp-18h] v13 = __readfsqword(0x28u); std::vector<int>::vector(a1); std::set<int>::set(v12); v9[1] = a2; v4 = std::vector<std::vector<int>>::begin(a2); v5 = std::vector<std::vector<int>>::end(a2); while ( (unsigned __int8)__gnu_cxx::operator!=<std::vector<int> const*,std::vector<std::vector<int>>>(&v4, &v5) ) { v10 = __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator*(&v4); v11 = v10; v6 = std::vector<int>::begin(v10); v7 = std::vector<int>::end(v11); while ( (unsigned __int8)__gnu_cxx::operator!=<int const*,std::vector<int>>(&v6, &v7) ) { v3 = *(_DWORD *)__gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator*(&v6); v9[0] = std::set<int>::end(v12); v8 = std::set<int>::find(v12, &v3); if ( (unsigned __int8)std::operator==(&v8, v9) ) { std::set<int>::insert(v12, &v3); std::vector<int>::push_back(a1, &v3); } __gnu_cxx::__normal_iterator<int const*,std::vector<int>>::operator++(&v6); } __gnu_cxx::__normal_iterator<std::vector<int> const*,std::vector<std::vector<int>>>::operator++(&v4); } std::set<int>::~set(v12); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0xa8 MOV qword ptr [RBP + -0xa8],RDI MOV qword ptr [RBP + -0xb0],RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0xa8] MOV RDI,RAX CALL 0x001022d6 LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x0010233e MOV RAX,qword ptr [RBP + -0xb0] MOV qword ptr [RBP + -0x68],RAX MOV RAX,qword ptr [RBP + -0x68] MOV RDI,RAX CALL 0x001024dc MOV qword ptr [RBP + -0x98],RAX MOV RAX,qword ptr [RBP + -0x68] MOV RDI,RAX CALL 0x00102528 MOV qword ptr [RBP + -0x90],RAX JMP 0x0010148d LAB_00101387: LEA RAX,[RBP + -0x98] MOV RDI,RAX CALL 0x001025dc MOV qword ptr [RBP + -0x60],RAX MOV RAX,qword ptr [RBP + -0x60] MOV qword ptr [RBP + -0x58],RAX MOV RAX,qword ptr [RBP + -0x58] MOV RDI,RAX CALL 0x001025f2 MOV qword ptr [RBP + -0x88],RAX MOV RAX,qword ptr [RBP + -0x58] MOV RDI,RAX CALL 0x0010263e MOV qword ptr [RBP + -0x80],RAX JMP 0x00101460 LAB_001013ca: LEA RAX,[RBP + -0x88] MOV RDI,RAX CALL 0x001026f2 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x9c],EAX LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x00102770 MOV qword ptr [RBP + -0x70],RAX LEA RDX,[RBP + -0x9c] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX LAB_00101402: CALL 0x00102708 MOV qword ptr [RBP + -0x78],RAX LEA RDX,[RBP + -0x70] LEA RAX,[RBP + -0x78] MOV RSI,RDX MOV RDI,RAX CALL 0x0010278e TEST AL,AL JZ 0x00101451 LEA RDX,[RBP + -0x9c] LEA RAX,[RBP + -0x50] MOV RSI,RDX MOV RDI,RAX CALL 0x001027b4 LEA RDX,[RBP + -0x9c] MOV RAX,qword ptr [RBP + -0xa8] MOV RSI,RDX MOV RDI,RAX CALL 0x0010282c LAB_00101451: LEA RAX,[RBP + -0x88] MOV RDI,RAX CALL 0x001026ce LAB_00101460: LEA RDX,[RBP + -0x80] LEA RAX,[RBP + -0x88] MOV RSI,RDX MOV RDI,RAX CALL 0x0010268e TEST AL,AL JNZ 0x001013ca LEA RAX,[RBP + -0x98] MOV RDI,RAX CALL 0x001025b8 LAB_0010148d: LEA RDX,[RBP + -0x90] LEA RAX,[RBP + -0x98] MOV RSI,RDX MOV RDI,RAX CALL 0x00102578 TEST AL,AL JNZ 0x00101387 NOP LEA RAX,[RBP + -0x50] MOV RDI,RAX CALL 0x0010235e NOP MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x00101513 JMP 0x0010150e LAB_0010150e: CALL 0x001011d0 LAB_00101513: MOV RAX,qword ptr [RBP + -0xa8] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ vector * func0(vector *param_1) { char cVar1; bool bVar2; int *piVar3; vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *in_RSI; long in_FS_OFFSET; int local_a4; int8 local_a0; int8 local_98; int8 local_90; int8 local_88; int8 local_80; int8 local_78; vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *local_70; vector<int,std::allocator<int>> *local_68; vector<int,std::allocator<int>> *local_60; set<int,std::less<int>,std::allocator<int>> local_58 [56]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); std::vector<int,std::allocator<int>>::vector((vector<int,std::allocator<int>> *)param_1); std::set<int,std::less<int>,std::allocator<int>>::set(local_58); local_70 = in_RSI; local_a0 = std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::begin(in_RSI); local_98 = std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::end(local_70); while( true ) { bVar2 = operator!=((__normal_iterator *)&local_a0,(__normal_iterator *)&local_98); if (!bVar2) break; local_68 = (vector<int,std::allocator<int>> *) __normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> ::operator*((__normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> *)&local_a0); local_60 = local_68; local_90 = std::vector<int,std::allocator<int>>::begin(local_68); local_88 = std::vector<int,std::allocator<int>>::end(local_60); while( true ) { bVar2 = operator!=((__normal_iterator *)&local_90,(__normal_iterator *)&local_88); if (!bVar2) break; piVar3 = (int *)__normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator* ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_90); local_a4 = *piVar3; local_78 = std::set<int,std::less<int>,std::allocator<int>>::end(local_58); /* try { // try from 00101402 to 00101450 has its CatchHandler @ 001014cd */ local_80 = std::set<int,std::less<int>,std::allocator<int>>::find(local_58,&local_a4); cVar1 = std::operator==((_Rb_tree_const_iterator *)&local_80, (_Rb_tree_const_iterator *)&local_78); if (cVar1 != '\0') { std::set<int,std::less<int>,std::allocator<int>>::insert(local_58,&local_a4); std::vector<int,std::allocator<int>>::push_back ((vector<int,std::allocator<int>> *)param_1,&local_a4); } __normal_iterator<int_const*,std::vector<int,std::allocator<int>>>::operator++ ((__normal_iterator<int_const*,std::vector<int,std::allocator<int>>> *)&local_90); } __normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> ::operator++((__normal_iterator<std::vector<int,std::allocator<int>>const*,std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>>> *)&local_a0); } std::set<int,std::less<int>,std::allocator<int>>::~set(local_58); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
557
func0
#include <vector> #include <set> #include <cassert>
std::vector<int> func0(const std::vector<std::vector<int>>& test_list) { std::vector<int> res; std::set<int> temp; for (const auto& inner : test_list) { for (int ele : inner) { if (temp.find(ele) == temp.end()) { temp.insert(ele); res.push_back(ele); } } } return res; }
int main() { assert((func0({{3, 4, 5}, {4, 5, 7}, {1, 4}}) == std::vector<int>{3, 4, 5, 7, 1})); assert((func0({{1, 2, 3}, {4, 2, 3}, {7, 8}}) == std::vector<int>{1, 2, 3, 4, 7, 8})); assert((func0({{7, 8, 9}, {10, 11, 12}, {10, 11}}) == std::vector<int>{7, 8, 9, 10, 11, 12})); return 0; }
O1
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x58,%rsp mov %rdi,%r12 mov %fs:0x28,%rax mov %rax,0x48(%rsp) xor %eax,%eax movq $0x0,(%rdi) movq $0x0,0x8(%rdi) movq $0x0,0x10(%rdi) movl $0x0,0x18(%rsp) movq $0x0,0x20(%rsp) lea 0x18(%rsp),%rax mov %rax,0x28(%rsp) mov %rax,0x30(%rsp) movq $0x0,0x38(%rsp) mov (%rsi),%r13 mov 0x8(%rsi),%r15 cmp %r15,%r13 je 13f8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xef> lea 0xc(%rsp),%r14 jmp 13e9 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xe0> mov 0x18(%rax),%rax test %rax,%rax je 1398 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x8f> cmp 0x20(%rax),%edx jg 1381 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x78> mov %rax,%rcx mov 0x10(%rax),%rax jmp 1385 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x7c> lea 0x18(%rsp),%rax cmp %rax,%rcx je 1455 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x14c> cmp 0x20(%rcx),%edx jl 1455 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x14c> add $0x4,%rbx cmp %rbx,%rbp je 13e0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xd7> mov (%rbx),%edx mov %edx,0xc(%rsp) mov 0x20(%rsp),%rax test %rax,%rax je 1455 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x14c> lea 0x18(%rsp),%rcx jmp 138a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x81> mov %r14,%rdx mov %r12,%rdi callq 1f28 <_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_> jmp 13af <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xa6> add $0x18,%r13 cmp %r13,%r15 je 13f8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xef> mov 0x0(%r13),%rbx mov 0x8(%r13),%rbp cmp %rbx,%rbp jne 13b8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xaf> jmp 13e0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xd7> lea 0x10(%rsp),%rdi mov 0x20(%rsp),%rsi callq 1df6 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x48(%rsp),%rax xor %fs:0x28,%rax jne 1483 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x17a> mov %r12,%rax add $0x58,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq endbr64 mov %rax,%rbx lea 0x10(%rsp),%rdi mov 0x20(%rsp),%rsi callq 1df6 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov (%r12),%rdi test %rdi,%rdi je 144d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x144> callq 11a0 <_ZdlPv@plt> mov %rbx,%rdi callq 1210 <_Unwind_Resume@plt> lea 0x10(%rsp),%rdi mov %r14,%rsi callq 1e30 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_> mov 0x8(%r12),%rsi cmp 0x10(%r12),%rsi je 13d3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xca> mov 0xc(%rsp),%eax mov %eax,(%rsi) addq $0x4,0x8(%r12) jmpq 13af <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xa6> callq 11d0 <__stack_chk_fail@plt>
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 push r14 push r13 push r12 push rbp push rbx sub rsp, 68h mov r13, rdi mov rdx, fs:28h mov [rsp+98h+var_40], rdx xor edx, edx mov qword ptr [rdi], 0 mov qword ptr [rdi+8], 0 mov qword ptr [rdi+10h], 0 mov [rsp+98h+var_70], 0 mov [rsp+98h+var_68], 0 lea rdx, [rsp+98h+var_70] mov [rsp+98h+var_60], rdx mov [rsp+98h+var_58], rdx mov [rsp+98h+var_50], 0 mov r14, [rsi] mov rax, [rsi+8] mov [rsp+98h+var_90], rax cmp rax, r14 jz loc_1416 lea r15, [rsp+98h+var_7C] jmp short loc_1408 loc_138A: mov rax, [rax+18h] loc_138E: test rax, rax jz short loc_13A1 loc_1393: cmp ebx, [rax+20h] jg short loc_138A mov rdx, rax mov rax, [rax+10h] jmp short loc_138E loc_13A1: lea rax, [rsp+98h+var_70] cmp rdx, rax jz loc_1482 cmp ebx, [rdx+20h] jl loc_1482 loc_13B8: add rbp, 4 cmp r12, rbp jz short loc_13FD loc_13C1: mov ebx, [rbp+0] mov [rsp+98h+var_7C], ebx mov rax, [rsp+98h+var_68] test rax, rax jz loc_1482 lea rdx, [rsp+98h+var_70] jmp short loc_1393 loc_13DD: mov rsi, [r13+8] cmp rsi, [r13+10h] jz short loc_13F0 mov [rsi], ebx add qword ptr [r13+8], 4 jmp short loc_13B8 loc_13F0: mov rdx, r15 mov rdi, r13 call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) jmp short loc_13B8 loc_13FD: add r14, 18h cmp [rsp+98h+var_90], r14 jz short loc_1416 loc_1408: mov rbp, [r14] mov r12, [r14+8] cmp rbp, r12 jnz short loc_13C1 jmp short loc_13FD loc_1416: lea rdi, [rsp+98h+var_78] mov rsi, [rsp+98h+var_68] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) mov rax, [rsp+98h+var_40] sub rax, fs:28h jnz short loc_1494 mov rax, r13 add rsp, 68h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn endbr64 mov rbx, rax lea rdi, [rsp+arg_18] mov rsi, [rsp+arg_28] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) mov rdi, r13 call _ZNSt6vectorIiSaIiEED2Ev; std::vector<int>::~vector() mov rax, [rsp+arg_50] sub rax, fs:28h jz short loc_147A call ___stack_chk_fail loc_147A: mov rdi, rbx; struct _Unwind_Exception * call __Unwind_Resume loc_1482: lea rdi, [rsp+98h+var_78] mov rsi, r15 call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>(int const&) jmp loc_13DD loc_1494: call ___stack_chk_fail
_QWORD * func0(_QWORD *a1, int ***a2) { int **v2; // r14 long long v3; // rax int *v4; // rdx int *v5; // rbp int v6; // ebx _DWORD *v7; // rsi int *v8; // r12 int **v10; // [rsp+8h] [rbp-90h] int v11; // [rsp+1Ch] [rbp-7Ch] BYREF _BYTE v12[8]; // [rsp+20h] [rbp-78h] BYREF int v13; // [rsp+28h] [rbp-70h] BYREF long long v14; // [rsp+30h] [rbp-68h] int *v15; // [rsp+38h] [rbp-60h] int *v16; // [rsp+40h] [rbp-58h] long long v17; // [rsp+48h] [rbp-50h] unsigned long long v18; // [rsp+58h] [rbp-40h] v18 = __readfsqword(0x28u); *a1 = 0LL; a1[1] = 0LL; a1[2] = 0LL; v13 = 0; v14 = 0LL; v15 = &v13; v16 = &v13; v17 = 0LL; v2 = *a2; v10 = a2[1]; if ( v10 != *a2 ) { do { v5 = *v2; v8 = v2[1]; if ( *v2 != v8 ) { do { v6 = *v5; v11 = *v5; v3 = v14; if ( !v14 ) goto LABEL_19; v4 = &v13; do { if ( v6 > *(_DWORD *)(v3 + 32) ) { v3 = *(_QWORD *)(v3 + 24); } else { v4 = (int *)v3; v3 = *(_QWORD *)(v3 + 16); } } while ( v3 ); if ( v4 == &v13 || v6 < v4[8] ) { LABEL_19: std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_insert_unique<int const&>( v12, &v11); v7 = (_DWORD *)a1[1]; if ( v7 == (_DWORD *)a1[2] ) { std::vector<int>::_M_realloc_insert<int const&>(a1, v7, &v11); } else { *v7 = v6; a1[1] += 4LL; } } ++v5; } while ( v8 != v5 ); } v2 += 3; } while ( v10 != v2 ); } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(v12, v14); return a1; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x68 MOV R13,RDI MOV RDX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x58],RDX XOR EDX,EDX MOV qword ptr [RDI],0x0 MOV qword ptr [RDI + 0x8],0x0 MOV qword ptr [RDI + 0x10],0x0 MOV dword ptr [RSP + 0x28],0x0 MOV qword ptr [RSP + 0x30],0x0 LEA RDX,[RSP + 0x28] MOV qword ptr [RSP + 0x38],RDX MOV qword ptr [RSP + 0x40],RDX MOV qword ptr [RSP + 0x48],0x0 MOV R14,qword ptr [RSI] MOV RAX,qword ptr [RSI + 0x8] MOV qword ptr [RSP + 0x8],RAX CMP RAX,R14 JZ 0x00101416 LEA R15,[RSP + 0x1c] JMP 0x00101408 LAB_0010138a: MOV RAX,qword ptr [RAX + 0x18] LAB_0010138e: TEST RAX,RAX JZ 0x001013a1 LAB_00101393: CMP EBX,dword ptr [RAX + 0x20] JG 0x0010138a MOV RDX,RAX MOV RAX,qword ptr [RAX + 0x10] JMP 0x0010138e LAB_001013a1: LEA RAX,[RSP + 0x28] CMP RDX,RAX JZ 0x00101482 CMP EBX,dword ptr [RDX + 0x20] JL 0x00101482 LAB_001013b8: ADD RBP,0x4 CMP R12,RBP JZ 0x001013fd LAB_001013c1: MOV EBX,dword ptr [RBP] MOV dword ptr [RSP + 0x1c],EBX MOV RAX,qword ptr [RSP + 0x30] TEST RAX,RAX JZ 0x00101482 LEA RDX,[RSP + 0x28] JMP 0x00101393 LAB_001013dd: MOV RSI,qword ptr [R13 + 0x8] CMP RSI,qword ptr [R13 + 0x10] JZ 0x001013f0 MOV dword ptr [RSI],EBX ADD qword ptr [R13 + 0x8],0x4 JMP 0x001013b8 LAB_001013f0: MOV RDX,R15 MOV RDI,R13 LAB_001013f6: CALL 0x00101f48 JMP 0x001013b8 LAB_001013fd: ADD R14,0x18 CMP qword ptr [RSP + 0x8],R14 JZ 0x00101416 LAB_00101408: MOV RBP,qword ptr [R14] MOV R12,qword ptr [R14 + 0x8] CMP RBP,R12 JNZ 0x001013c1 JMP 0x001013fd LAB_00101416: LEA RDI,[RSP + 0x20] MOV RSI,qword ptr [RSP + 0x30] CALL 0x00101e14 MOV RAX,qword ptr [RSP + 0x58] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101494 MOV RAX,R13 ADD RSP,0x68 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101482: LEA RDI,[RSP + 0x20] MOV RSI,R15 LAB_0010148a: CALL 0x00101e52 JMP 0x001013dd LAB_00101494: CALL 0x001011d0
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ vector * func0(vector *param_1) { int iVar1; int8 *puVar2; int *piVar3; int *piVar4; _Rb_tree_node *p_Var5; _Rb_tree_node *p_Var6; _Rb_tree_node *p_Var7; int *piVar8; int8 *in_RSI; int8 *puVar9; long in_FS_OFFSET; int local_7c; _Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>> local_78 [8]; int4 local_70 [2]; _Rb_tree_node *local_68; int4 *local_60; int4 *local_58; int8 local_50; long local_40; local_40 = *(long *)(in_FS_OFFSET + 0x28); *(int8 *)param_1 = 0; *(int8 *)(param_1 + 8) = 0; *(int8 *)(param_1 + 0x10) = 0; local_70[0] = 0; local_68 = (_Rb_tree_node *)0x0; local_60 = local_70; local_50 = 0; puVar9 = (int8 *)*in_RSI; puVar2 = (int8 *)in_RSI[1]; local_58 = local_60; if (puVar2 != puVar9) { do { piVar4 = (int *)puVar9[1]; for (piVar8 = (int *)*puVar9; piVar8 != piVar4; piVar8 = piVar8 + 1) { iVar1 = *piVar8; local_7c = iVar1; if (local_68 == (_Rb_tree_node *)0x0) { LAB_00101482: /* try { // try from 0010148a to 0010148e has its CatchHandler @ 00101447 */ std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>:: _M_insert_unique<int_const&>(local_78,&local_7c); piVar3 = *(int **)(param_1 + 8); if (piVar3 == *(int **)(param_1 + 0x10)) { /* try { // try from 001013f6 to 001013fa has its CatchHandler @ 00101447 */ std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)param_1,(__normal_iterator)piVar3, &local_7c); } else { *piVar3 = iVar1; *(long *)(param_1 + 8) = *(long *)(param_1 + 8) + 4; } } else { p_Var7 = (_Rb_tree_node *)local_70; p_Var6 = local_68; do { if (*(int *)(p_Var6 + 0x20) < iVar1) { p_Var5 = *(_Rb_tree_node **)(p_Var6 + 0x18); } else { p_Var5 = *(_Rb_tree_node **)(p_Var6 + 0x10); p_Var7 = p_Var6; } p_Var6 = p_Var5; } while (p_Var5 != (_Rb_tree_node *)0x0); if ((p_Var7 == (_Rb_tree_node *)local_70) || (iVar1 < *(int *)(p_Var7 + 0x20))) goto LAB_00101482; } } puVar9 = puVar9 + 3; } while (puVar2 != puVar9); } std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (local_78,local_68); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
558
func0
#include <vector> #include <set> #include <cassert>
std::vector<int> func0(const std::vector<std::vector<int>>& test_list) { std::vector<int> res; std::set<int> temp; for (const auto& inner : test_list) { for (int ele : inner) { if (temp.find(ele) == temp.end()) { temp.insert(ele); res.push_back(ele); } } } return res; }
int main() { assert((func0({{3, 4, 5}, {4, 5, 7}, {1, 4}}) == std::vector<int>{3, 4, 5, 7, 1})); assert((func0({{1, 2, 3}, {4, 2, 3}, {7, 8}}) == std::vector<int>{1, 2, 3, 4, 7, 8})); assert((func0({{7, 8, 9}, {10, 11, 12}, {10, 11}}) == std::vector<int>{7, 8, 9, 10, 11, 12})); return 0; }
O2
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 mov %rsi,%rax mov %rdi,%r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x78,%rsp mov (%rax),%rdx mov 0x8(%rax),%rax mov %fs:0x28,%rsi mov %rsi,0x68(%rsp) xor %esi,%esi lea 0x38(%rsp),%r13 movq $0x0,(%rdi) movq $0x0,0x8(%rdi) movq $0x0,0x10(%rdi) movl $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) mov %r13,0x48(%rsp) mov %r13,0x50(%rsp) movq $0x0,0x58(%rsp) mov %rax,0x18(%rsp) cmp %rax,%rdx je 1c7c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2dc> mov %rdx,0x8(%rsp) xor %r12d,%r12d nopl (%rax) mov 0x8(%rsp),%rax mov (%rax),%rbp mov 0x8(%rax),%r14 cmp %r14,%rbp je 1a85 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xe5> nopl 0x0(%rax) mov 0x0(%rbp),%ebx test %r12,%r12 je 1b58 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b8> mov %r12,%rax mov %r13,%rdx jmp 1a64 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xc4> nopl 0x0(%rax) mov %rax,%rdx mov 0x10(%rax),%rax test %rax,%rax je 1a72 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xd2> cmp 0x20(%rax),%ebx jle 1a58 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xb8> mov 0x18(%rax),%rax test %rax,%rax jne 1a64 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xc4> cmp %r13,%rdx je 1ae2 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x142> cmp 0x20(%rdx),%ebx jl 1ae2 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x142> add $0x4,%rbp cmp %rbp,%r14 jne 1a40 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xa0> addq $0x18,0x8(%rsp) mov 0x8(%rsp),%rax cmp %rax,0x18(%rsp) jne 1a28 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x88> lea 0x30(%rsp),%rdi mov %r12,%rsi callq 2020 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 1c84 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2e4> add $0x78,%rsp mov %r15,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw 0x0(%rax,%rax,1) mov 0x10(%r12),%rax mov $0x1,%ecx test %rax,%rax je 1af7 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x157> mov %rax,%r12 mov 0x20(%r12),%edx cmp %edx,%ebx jl 1ad0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x130> mov 0x18(%r12),%rax xor %ecx,%ecx test %rax,%rax jne 1adf <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x13f> test %cl,%cl jne 1cb8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x318> cmp %edx,%ebx jle 1b33 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x193> movb $0x1,0x10(%rsp) cmp %r13,%r12 jne 1b82 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1e2> mov $0x28,%edi callq 11b0 <_Znwm@plt> mov %ebx,0x20(%rax) movzbl 0x10(%rsp),%edi mov %rax,%rsi mov %r13,%rcx mov %r12,%rdx callq 1130 <_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@plt> addq $0x1,0x58(%rsp) mov 0x8(%r15),%r12 cmp 0x10(%r15),%r12 je 1b91 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1f1> mov %ebx,(%r12) add $0x4,%r12 mov %r12,0x8(%r15) mov 0x40(%rsp),%r12 jmpq 1a7c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xdc> nopl 0x0(%rax,%rax,1) mov %r13,%r12 cmp %r13,0x48(%rsp) je 1c1b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x27b> mov %r12,%rdi callq 11c0 <_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@plt> cmp 0x20(%rax),%ebx jle 1b33 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x193> test %r12,%r12 je 1b33 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x193> movb $0x1,0x10(%rsp) cmp %r13,%r12 je 1b0d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x16d> cmp 0x20(%r12),%ebx setl 0x10(%rsp) jmpq 1b0d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x16d> movabs $0x1fffffffffffffff,%rdi mov (%r15),%rax sub %rax,%r12 mov %rax,0x20(%rsp) mov %r12,%rax sar $0x2,%rax cmp %rdi,%rax je 1cac <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x30c> test %rax,%rax je 1c6e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2ce> movabs $0x7ffffffffffffffc,%rdi lea (%rax,%rax,1),%rdx mov %rdi,0x10(%rsp) cmp %rdx,%rax jbe 1c62 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2c2> mov 0x10(%rsp),%rdi callq 11b0 <_Znwm@plt> mov 0x10(%rsp),%r8 mov %rax,%rcx add %rax,%r8 mov %ebx,(%rcx,%r12,1) lea 0x4(%rcx,%r12,1),%rbx test %r12,%r12 jg 1c25 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x285> cmpq $0x0,0x20(%rsp) jne 1c42 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2a2> mov %rcx,(%r15) mov 0x40(%rsp),%r12 mov %rbx,0x8(%r15) mov %r8,0x10(%r15) jmpq 1a7c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xdc> movb $0x1,0x10(%rsp) jmpq 1b0d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x16d> mov 0x20(%rsp),%rsi mov %rcx,%rdi mov %r12,%rdx mov %r8,0x10(%rsp) callq 11f0 <memmove@plt> mov 0x10(%rsp),%r8 mov %rax,%rcx mov 0x20(%rsp),%rdi mov %rcx,0x28(%rsp) mov %r8,0x10(%rsp) callq 11a0 <_ZdlPv@plt> mov 0x28(%rsp),%rcx mov 0x10(%rsp),%r8 jmp 1c06 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x266> test %rdx,%rdx jne 1c89 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2e9> xor %r8d,%r8d xor %ecx,%ecx jmp 1bf0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x250> movq $0x4,0x10(%rsp) jmpq 1bdb <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x23b> xor %r12d,%r12d jmpq 1a97 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xf7> callq 11d0 <__stack_chk_fail@plt> movabs $0x1fffffffffffffff,%rax cmp %rax,%rdx cmova %rax,%rdx lea 0x0(,%rdx,4),%rax mov %rax,0x10(%rsp) jmpq 1bdb <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x23b> lea 0x1386(%rip),%rdi callq 1170 <_ZSt20__throw_length_errorPKc@plt> cmp 0x48(%rsp),%r12 jne 1b66 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1c6> jmpq 1b03 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x163> endbr64 mov %rax,%rbp jmpq 1220 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold> nopw %cs:0x0(%rax,%rax,1) xchg %ax,%ax
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 pxor xmm0, xmm0 push r14 push r13 push r12 push rbp push rbx sub rsp, 78h mov r15, [rsi] mov [rsp+0A8h+var_A0], rdi lea r13, [rsp+0A8h+var_70] mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax mov rax, [rsi+8] mov qword ptr [rdi+10h], 0 mov [rsp+0A8h+var_70], 0 mov [rsp+0A8h+var_68], 0 mov [rsp+0A8h+var_60], r13 mov [rsp+0A8h+var_58], r13 mov [rsp+0A8h+var_50], 0 mov [rsp+0A8h+var_90], rax movups xmmword ptr [rdi], xmm0 cmp rax, r15 jz loc_1E03 xor ebp, ebp nop word ptr [rax+rax+00000000h] loc_1CD0: mov r12, [r15] mov r14, [r15+8] cmp r12, r14 jz loc_1DD0 loc_1CE0: mov ebx, [r12] mov [rsp+0A8h+var_7C], ebx test rbp, rbp jz loc_1E30 loc_1CF1: mov rax, rbp mov rsi, r13 jmp short loc_1D08 loc_1D00: mov rax, rcx test rax, rax jz short loc_1D20 loc_1D08: mov rdx, [rax+10h] mov rcx, [rax+18h] cmp [rax+20h], ebx jl short loc_1D00 mov rsi, rax mov rax, rdx test rax, rax jnz short loc_1D08 loc_1D20: cmp rsi, r13 jz short loc_1D4B cmp [rsi+20h], ebx jg short loc_1D4B add r12, 4 cmp r14, r12 jz loc_1DD0 mov ebx, [r12] mov [rsp+0A8h+var_7C], ebx jmp short loc_1CF1 loc_1D48: mov rbp, rax loc_1D4B: mov edx, [rbp+20h] mov rax, [rbp+18h] cmp ebx, edx cmovl rax, [rbp+10h] setl cl test rax, rax jnz short loc_1D48 test cl, cl jnz loc_1E82 loc_1D69: cmp ebx, edx jle short loc_1DA1 loc_1D6D: mov [rsp+0A8h+var_91], 1 cmp rbp, r13 jnz loc_1E70 loc_1D7B: mov edi, 28h ; '('; unsigned __int64 call __Znwm; operator new(ulong) mov [rax+20h], ebx movzx edi, [rsp+0A8h+var_91] mov rsi, rax mov rcx, r13 mov rdx, rbp call __ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; std::_Rb_tree_insert_and_rebalance(bool,std::_Rb_tree_node_base *,std::_Rb_tree_node_base *,std::_Rb_tree_node_base&) add [rsp+0A8h+var_50], 1 loc_1DA1: mov rax, [rsp+0A8h+var_A0] mov rsi, [rax+8] cmp rsi, [rax+10h] jz loc_1E4D mov [rsi], ebx add rsi, 4 mov rbp, [rsp+0A8h+var_68] mov [rax+8], rsi loc_1DC3: add r12, 4 cmp r14, r12 jnz loc_1CE0 loc_1DD0: add r15, 18h cmp [rsp+0A8h+var_90], r15 jnz loc_1CD0 test rbp, rbp jz short loc_1E03 loc_1DE4: mov rdi, [rbp+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, rbp; void * mov rbp, [rbp+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test rbp, rbp jnz short loc_1DE4 loc_1E03: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_1E7D mov rax, [rsp+0A8h+var_A0] add rsp, 78h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1E30: mov rbp, [rsp+0A8h+var_60] cmp rbp, r13 jz short loc_1E66 mov rbp, r13 loc_1E3D: mov rdi, rbp call __ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base; std::_Rb_tree_decrement(std::_Rb_tree_node_base *) mov edx, [rax+20h] jmp loc_1D69 loc_1E4D: mov rdi, [rsp+0A8h+var_A0] lea rdx, [rsp+0A8h+var_7C] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rbp, [rsp+0A8h+var_68] jmp loc_1DC3 loc_1E66: mov [rsp+0A8h+var_91], 1 jmp loc_1D7B loc_1E70: cmp ebx, [rbp+20h] setl [rsp+0A8h+var_91] jmp loc_1D7B loc_1E7D: call ___stack_chk_fail loc_1E82: cmp [rsp+0A8h+var_60], rbp jnz short loc_1E3D jmp loc_1D6D endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE_cold; func0(std::vector<std::vector<int>> const&) [clone]
long long func0(long long a1, int ***a2) { int **v2; // r15 int **v3; // rax int *v4; // rbp int *v5; // r12 int *v6; // r14 int v7; // ebx int *v8; // rax int *v9; // rsi long long v10; // rdx long long v11; // rcx int v12; // edx int *v13; // rax long long v14; // rax _DWORD *v15; // rsi int *v16; // rdi bool v19; // [rsp+Fh] [rbp-91h] int **v20; // [rsp+10h] [rbp-90h] _DWORD v21[3]; // [rsp+24h] [rbp-7Ch] BYREF int v22; // [rsp+30h] [rbp-70h] BYREF int *v23; // [rsp+38h] [rbp-68h] int *v24; // [rsp+40h] [rbp-60h] int *v25; // [rsp+48h] [rbp-58h] long long v26; // [rsp+50h] [rbp-50h] unsigned long long v27; // [rsp+60h] [rbp-40h] v2 = *a2; v27 = __readfsqword(0x28u); v3 = a2[1]; *(_QWORD *)(a1 + 16) = 0LL; v22 = 0; v23 = 0LL; v24 = &v22; v25 = &v22; v26 = 0LL; v20 = v3; *(_OWORD *)a1 = 0LL; if ( v3 != v2 ) { v4 = 0LL; do { v5 = *v2; v6 = v2[1]; if ( *v2 != v6 ) { while ( 1 ) { v7 = *v5; v21[0] = *v5; if ( !v4 ) break; while ( 1 ) { v8 = v4; v9 = &v22; do { while ( 1 ) { v10 = *((_QWORD *)v8 + 2); v11 = *((_QWORD *)v8 + 3); if ( v8[8] >= v7 ) break; v8 = (int *)*((_QWORD *)v8 + 3); if ( !v11 ) goto LABEL_9; } v9 = v8; v8 = (int *)*((_QWORD *)v8 + 2); } while ( v10 ); LABEL_9: if ( v9 == &v22 || v9[8] > v7 ) break; if ( v6 == ++v5 ) goto LABEL_25; v7 = *v5; v21[0] = *v5; } while ( 1 ) { v12 = v4[8]; v13 = (int *)*((_QWORD *)v4 + 3); if ( v7 < v12 ) v13 = (int *)*((_QWORD *)v4 + 2); if ( !v13 ) break; v4 = v13; } if ( v7 < v12 ) { if ( v24 == v4 ) { LABEL_19: v19 = 1; if ( v4 != &v22 ) v19 = v7 < v4[8]; goto LABEL_21; } LABEL_31: v12 = *(_DWORD *)(std::_Rb_tree_decrement(v4) + 32); } if ( v7 > v12 ) goto LABEL_19; LABEL_22: v15 = *(_DWORD **)(a1 + 8); if ( v15 == *(_DWORD **)(a1 + 16) ) { std::vector<int>::_M_realloc_insert<int const&>(a1, v15, v21); v4 = v23; } else { *v15 = v7; v4 = v23; *(_QWORD *)(a1 + 8) = v15 + 1; } if ( v6 == ++v5 ) goto LABEL_25; } v4 = v24; if ( v24 == &v22 ) { v19 = 1; LABEL_21: v14 = operator new(0x28uLL); *(_DWORD *)(v14 + 32) = v7; std::_Rb_tree_insert_and_rebalance(v19, v14, v4, &v22); ++v26; goto LABEL_22; } v4 = &v22; goto LABEL_31; } LABEL_25: v2 += 3; } while ( v20 != v2 ); while ( v4 ) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(*((_QWORD *)v4 + 3)); v16 = v4; v4 = (int *)*((_QWORD *)v4 + 2); operator delete(v16, 0x28uLL); } } return a1; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x78 MOV R15,qword ptr [RSI] MOV qword ptr [RSP + 0x8],RDI LEA R13,[RSP + 0x38] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX MOV RAX,qword ptr [RSI + 0x8] MOV qword ptr [RDI + 0x10],0x0 MOV dword ptr [RSP + 0x38],0x0 MOV qword ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x48],R13 MOV qword ptr [RSP + 0x50],R13 MOV qword ptr [RSP + 0x58],0x0 MOV qword ptr [RSP + 0x18],RAX MOVUPS xmmword ptr [RDI],XMM0 CMP RAX,R15 JZ 0x00101e03 XOR EBP,EBP NOP word ptr CS:[RAX + RAX*0x1] LAB_00101cd0: MOV R12,qword ptr [R15] MOV R14,qword ptr [R15 + 0x8] CMP R12,R14 JZ 0x00101dd0 LAB_00101ce0: MOV EBX,dword ptr [R12] MOV dword ptr [RSP + 0x2c],EBX TEST RBP,RBP JZ 0x00101e30 LAB_00101cf1: MOV RAX,RBP MOV RSI,R13 JMP 0x00101d08 LAB_00101d00: MOV RAX,RCX TEST RAX,RAX JZ 0x00101d20 LAB_00101d08: MOV RDX,qword ptr [RAX + 0x10] MOV RCX,qword ptr [RAX + 0x18] CMP dword ptr [RAX + 0x20],EBX JL 0x00101d00 MOV RSI,RAX MOV RAX,RDX TEST RAX,RAX JNZ 0x00101d08 LAB_00101d20: CMP RSI,R13 JZ 0x00101d4b CMP dword ptr [RSI + 0x20],EBX JG 0x00101d4b ADD R12,0x4 CMP R14,R12 JZ 0x00101dd0 MOV EBX,dword ptr [R12] MOV dword ptr [RSP + 0x2c],EBX JMP 0x00101cf1 LAB_00101d48: MOV RBP,RAX LAB_00101d4b: MOV EDX,dword ptr [RBP + 0x20] MOV RAX,qword ptr [RBP + 0x18] CMP EBX,EDX CMOVL RAX,qword ptr [RBP + 0x10] SETL CL TEST RAX,RAX JNZ 0x00101d48 TEST CL,CL JNZ 0x00101e82 LAB_00101d69: CMP EBX,EDX JLE 0x00101da1 LAB_00101d6d: MOV byte ptr [RSP + 0x17],0x1 CMP RBP,R13 JNZ 0x00101e70 LAB_00101d7b: MOV EDI,0x28 LAB_00101d80: CALL 0x001011c0 MOV dword ptr [RAX + 0x20],EBX MOVZX EDI,byte ptr [RSP + 0x17] MOV RSI,RAX MOV RCX,R13 MOV RDX,RBP CALL 0x00101140 ADD qword ptr [RSP + 0x58],0x1 LAB_00101da1: MOV RAX,qword ptr [RSP + 0x8] MOV RSI,qword ptr [RAX + 0x8] CMP RSI,qword ptr [RAX + 0x10] JZ 0x00101e4d MOV dword ptr [RSI],EBX ADD RSI,0x4 MOV RBP,qword ptr [RSP + 0x40] MOV qword ptr [RAX + 0x8],RSI LAB_00101dc3: ADD R12,0x4 CMP R14,R12 JNZ 0x00101ce0 LAB_00101dd0: ADD R15,0x18 CMP qword ptr [RSP + 0x18],R15 JNZ 0x00101cd0 TEST RBP,RBP JZ 0x00101e03 LAB_00101de4: MOV RDI,qword ptr [RBP + 0x18] CALL 0x00101a80 MOV RDI,RBP MOV RBP,qword ptr [RBP + 0x10] MOV ESI,0x28 CALL 0x001011d0 TEST RBP,RBP JNZ 0x00101de4 LAB_00101e03: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101e7d MOV RAX,qword ptr [RSP + 0x8] ADD RSP,0x78 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101e30: MOV RBP,qword ptr [RSP + 0x48] CMP RBP,R13 JZ 0x00101e66 MOV RBP,R13 LAB_00101e3d: MOV RDI,RBP CALL 0x001011e0 MOV EDX,dword ptr [RAX + 0x20] JMP 0x00101d69 LAB_00101e4d: MOV RDI,qword ptr [RSP + 0x8] LEA RDX,[RSP + 0x2c] CALL 0x00102020 MOV RBP,qword ptr [RSP + 0x40] JMP 0x00101dc3 LAB_00101e66: MOV byte ptr [RSP + 0x17],0x1 JMP 0x00101d7b LAB_00101e70: CMP EBX,dword ptr [RBP + 0x20] SETL byte ptr [RSP + 0x17] JMP 0x00101d7b LAB_00101e7d: CALL 0x001011f0 LAB_00101e82: CMP qword ptr [RSP + 0x48],RBP JNZ 0x00101e3d JMP 0x00101d6d
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ vector * func0(vector *param_1) { int8 *puVar1; int *piVar2; int *piVar3; _Rb_tree_node_base *p_Var4; _Rb_tree_node_base *p_Var5; long lVar6; int iVar7; int iVar8; _Rb_tree_node_base *p_Var9; int8 *in_RSI; _Rb_tree_node_base *p_Var10; int *piVar11; int8 *puVar12; long in_FS_OFFSET; bool local_91; int local_7c [3]; int4 local_70 [2]; _Rb_tree_node_base *local_68; _Rb_tree_node_base *local_60; _Rb_tree_node_base *local_58; long local_50; long local_40; puVar12 = (int8 *)*in_RSI; local_40 = *(long *)(in_FS_OFFSET + 0x28); puVar1 = (int8 *)in_RSI[1]; *(int8 *)(param_1 + 0x10) = 0; local_70[0] = 0; local_68 = (_Rb_tree_node_base *)0x0; local_50 = 0; *(int (*) [16])param_1 = (int [16])0x0; local_60 = (_Rb_tree_node_base *)local_70; local_58 = (_Rb_tree_node_base *)local_70; if (puVar1 != puVar12) { p_Var5 = (_Rb_tree_node_base *)0x0; do { piVar11 = (int *)*puVar12; piVar2 = (int *)puVar12[1]; if (piVar11 != piVar2) { LAB_00101ce0: iVar8 = *piVar11; p_Var9 = p_Var5; p_Var10 = (_Rb_tree_node_base *)local_70; if (p_Var5 != (_Rb_tree_node_base *)0x0) { LAB_00101d08: do { p_Var4 = p_Var9; if (*(int *)(p_Var4 + 0x20) < iVar8) goto LAB_00101d00; p_Var9 = *(_Rb_tree_node_base **)(p_Var4 + 0x10); p_Var10 = p_Var4; } while (*(_Rb_tree_node_base **)(p_Var4 + 0x10) != (_Rb_tree_node_base *)0x0); goto LAB_00101d20; } p_Var9 = (_Rb_tree_node_base *)local_70; local_7c[0] = iVar8; if (local_60 != (_Rb_tree_node_base *)local_70) goto LAB_00101e3d; local_91 = true; p_Var9 = local_60; goto LAB_00101d7b; } LAB_00101dd0: puVar12 = puVar12 + 3; } while (puVar1 != puVar12); while (p_Var5 != (_Rb_tree_node_base *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)(p_Var5 + 0x18)); p_Var9 = *(_Rb_tree_node_base **)(p_Var5 + 0x10); operator_delete(p_Var5,0x28); p_Var5 = p_Var9; } } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); LAB_00101d00: p_Var9 = *(_Rb_tree_node_base **)(p_Var4 + 0x18); if (*(_Rb_tree_node_base **)(p_Var4 + 0x18) == (_Rb_tree_node_base *)0x0) { LAB_00101d20: local_7c[0] = iVar8; if ((p_Var10 == (_Rb_tree_node_base *)local_70) || (iVar8 < *(int *)(p_Var10 + 0x20))) goto LAB_00101d4b; piVar11 = piVar11 + 1; if (piVar2 == piVar11) goto LAB_00101dd0; iVar8 = *piVar11; p_Var9 = p_Var5; p_Var10 = (_Rb_tree_node_base *)local_70; } goto LAB_00101d08; LAB_00101d4b: do { p_Var9 = p_Var5; iVar7 = *(int *)(p_Var9 + 0x20); p_Var5 = *(_Rb_tree_node_base **)(p_Var9 + 0x18); if (iVar8 < iVar7) { p_Var5 = *(_Rb_tree_node_base **)(p_Var9 + 0x10); } } while (p_Var5 != (_Rb_tree_node_base *)0x0); if (iVar8 < iVar7) { if (local_60 != p_Var9) { LAB_00101e3d: iVar8 = local_7c[0]; lVar6 = std::_Rb_tree_decrement(p_Var9); iVar7 = *(int *)(lVar6 + 0x20); goto LAB_00101d69; } } else { LAB_00101d69: if (iVar8 <= iVar7) goto LAB_00101da1; } local_91 = true; if (p_Var9 != (_Rb_tree_node_base *)local_70) { local_91 = iVar8 < *(int *)(p_Var9 + 0x20); } LAB_00101d7b: /* try { // try from 00101d80 to 00101e5b has its CatchHandler @ 00101e8e */ p_Var5 = (_Rb_tree_node_base *)operator_new(0x28); *(int *)(p_Var5 + 0x20) = iVar8; std::_Rb_tree_insert_and_rebalance(local_91,p_Var5,p_Var9,(_Rb_tree_node_base *)local_70); local_50 = local_50 + 1; LAB_00101da1: piVar3 = *(int **)(param_1 + 8); if (piVar3 == *(int **)(param_1 + 0x10)) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)param_1,(__normal_iterator)piVar3,local_7c); } else { *piVar3 = iVar8; *(int **)(param_1 + 8) = piVar3 + 1; } piVar11 = piVar11 + 1; p_Var5 = local_68; if (piVar2 == piVar11) goto LAB_00101dd0; goto LAB_00101ce0; }
559
func0
#include <vector> #include <set> #include <cassert>
std::vector<int> func0(const std::vector<std::vector<int>>& test_list) { std::vector<int> res; std::set<int> temp; for (const auto& inner : test_list) { for (int ele : inner) { if (temp.find(ele) == temp.end()) { temp.insert(ele); res.push_back(ele); } } } return res; }
int main() { assert((func0({{3, 4, 5}, {4, 5, 7}, {1, 4}}) == std::vector<int>{3, 4, 5, 7, 1})); assert((func0({{1, 2, 3}, {4, 2, 3}, {7, 8}}) == std::vector<int>{1, 2, 3, 4, 7, 8})); assert((func0({{7, 8, 9}, {10, 11, 12}, {10, 11}}) == std::vector<int>{7, 8, 9, 10, 11, 12})); return 0; }
O3
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&): endbr64 push %r15 mov %rsi,%rax pxor %xmm0,%xmm0 mov %rdi,%r15 push %r14 push %r13 push %r12 push %rbp push %rbx sub $0x78,%rsp mov %fs:0x28,%rsi mov %rsi,0x68(%rsp) xor %esi,%esi movq $0x0,0x10(%rdi) lea 0x38(%rsp),%r13 movups %xmm0,(%rdi) mov 0x8(%rax),%rdi mov (%rax),%rax movl $0x0,0x38(%rsp) movq $0x0,0x40(%rsp) mov %r13,0x48(%rsp) mov %r13,0x50(%rsp) movq $0x0,0x58(%rsp) mov %rdi,0x18(%rsp) mov %rax,0x8(%rsp) cmp %rdi,%rax je 1b50 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x120> xor %r12d,%r12d nopl (%rax) mov 0x8(%rsp),%rax mov (%rax),%rbp mov 0x8(%rax),%r14 cmp %r14,%rbp je 1b15 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xe5> nopl 0x0(%rax) mov 0x0(%rbp),%ebx test %r12,%r12 je 1c08 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1d8> mov %r12,%rax mov %r13,%rdx jmp 1aec <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xbc> nopl 0x0(%rax) mov %rax,%rdx mov 0x10(%rax),%rax test %rax,%rax je 1afa <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xca> cmp 0x20(%rax),%ebx jle 1ae0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xb0> mov 0x18(%rax),%rax test %rax,%rax jne 1aec <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xbc> cmp %r13,%rdx je 1b92 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x162> cmp 0x20(%rdx),%ebx jl 1b92 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x162> add $0x4,%rbp cmp %rbp,%r14 jne 1ac8 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x98> addq $0x18,0x8(%rsp) mov 0x8(%rsp),%rax cmp %rax,0x18(%rsp) jne 1ab0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x80> test %r12,%r12 je 1b50 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x120> lea 0x30(%rsp),%rbx mov 0x18(%r12),%rsi mov %rbx,%rdi callq 2010 <_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE> mov %r12,%rdi mov 0x10(%r12),%r12 callq 11a0 <_ZdlPv@plt> test %r12,%r12 jne 1b31 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x101> mov 0x68(%rsp),%rax xor %fs:0x28,%rax jne 1d3a <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x30a> add $0x78,%rsp mov %r15,%rax pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw %cs:0x0(%rax,%rax,1) mov 0x10(%r12),%rax mov $0x1,%ecx test %rax,%rax je 1ba7 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x177> mov %rax,%r12 mov 0x20(%r12),%edx cmp %edx,%ebx jl 1b80 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x150> mov 0x18(%r12),%rax xor %ecx,%ecx test %rax,%rax jne 1b8f <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x15f> test %cl,%cl jne 1d6e <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x33e> cmp %edx,%ebx jle 1be3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b3> movb $0x1,0x10(%rsp) cmp %r13,%r12 jne 1c32 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x202> mov $0x28,%edi callq 11b0 <_Znwm@plt> mov %ebx,0x20(%rax) movzbl 0x10(%rsp),%edi mov %rax,%rsi mov %r13,%rcx mov %r12,%rdx callq 1130 <_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_@plt> addq $0x1,0x58(%rsp) mov 0x8(%r15),%r12 cmp 0x10(%r15),%r12 je 1c41 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x211> mov %ebx,(%r12) add $0x4,%r12 mov %r12,0x8(%r15) mov 0x40(%rsp),%r12 jmpq 1b0c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xdc> nopl 0x0(%rax,%rax,1) mov %r13,%r12 cmp %r13,0x48(%rsp) je 1cd6 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2a6> mov %r12,%rdi callq 11c0 <_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base@plt> cmp 0x20(%rax),%ebx jle 1be3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b3> test %r12,%r12 je 1be3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1b3> movb $0x1,0x10(%rsp) cmp %r13,%r12 je 1bbd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x18d> cmp 0x20(%r12),%ebx setl 0x10(%rsp) jmpq 1bbd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x18d> movabs $0x1fffffffffffffff,%rdi mov (%r15),%rax sub %rax,%r12 mov %rax,0x20(%rsp) mov %r12,%rax sar $0x2,%rax cmp %rdi,%rax je 1d62 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x332> test %rax,%rax je 1d2c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2fc> movabs $0x7ffffffffffffffc,%rsi lea (%rax,%rax,1),%rdx mov %rsi,0x10(%rsp) cmp %rdx,%rax jbe 1d1d <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2ed> mov 0x10(%rsp),%rdi callq 11b0 <_Znwm@plt> mov 0x10(%rsp),%r8 mov %rax,%rcx add %rax,%r8 mov %ebx,(%rcx,%r12,1) lea 0x4(%rcx,%r12,1),%rbx test %r12,%r12 jg 1ce0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2b0> cmpq $0x0,0x20(%rsp) jne 1cfd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x2cd> movq %rcx,%xmm0 movq %rbx,%xmm1 mov %r8,0x10(%r15) mov 0x40(%rsp),%r12 punpcklqdq %xmm1,%xmm0 movups %xmm0,(%r15) jmpq 1b0c <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0xdc> movb $0x1,0x10(%rsp) jmpq 1bbd <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x18d> mov 0x20(%rsp),%rsi mov %rcx,%rdi mov %r12,%rdx mov %r8,0x10(%rsp) callq 11f0 <memmove@plt> mov 0x10(%rsp),%r8 mov %rax,%rcx mov 0x20(%rsp),%rdi mov %rcx,0x28(%rsp) mov %r8,0x10(%rsp) callq 11a0 <_ZdlPv@plt> mov 0x28(%rsp),%rcx mov 0x10(%rsp),%r8 jmp 1cb6 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x286> test %rdx,%rdx jne 1d3f <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x30f> xor %r8d,%r8d xor %ecx,%ecx jmpq 1ca0 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x270> movq $0x4,0x10(%rsp) jmpq 1c8b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x25b> callq 11d0 <__stack_chk_fail@plt> movabs $0x1fffffffffffffff,%rax cmp %rax,%rdx cmova %rax,%rdx lea 0x0(,%rdx,4),%rax mov %rax,0x10(%rsp) jmpq 1c8b <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x25b> lea 0x1415(%rip),%rdi callq 1170 <_ZSt20__throw_length_errorPKc@plt> cmp 0x48(%rsp),%r12 jne 1c16 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x1e6> jmpq 1bb3 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE+0x183> endbr64 mov %rax,%rbp jmpq 1235 <_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE.cold> nopw 0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE: endbr64 push r15 pxor xmm0, xmm0 push r14 push r13 push r12 push rbp push rbx sub rsp, 78h mov r15, [rsi] mov [rsp+0A8h+var_A0], rdi lea r13, [rsp+0A8h+var_70] mov rax, fs:28h mov [rsp+0A8h+var_40], rax xor eax, eax mov rax, [rsi+8] mov qword ptr [rdi+10h], 0 mov [rsp+0A8h+var_70], 0 mov [rsp+0A8h+var_68], 0 mov [rsp+0A8h+var_60], r13 mov [rsp+0A8h+var_58], r13 mov [rsp+0A8h+var_50], 0 mov [rsp+0A8h+var_90], rax movups xmmword ptr [rdi], xmm0 cmp rax, r15 jz loc_1EA3 xor ebp, ebp nop word ptr [rax+rax+00000000h] loc_1D60: mov r12, [r15] mov r14, [r15+8] cmp r12, r14 jz loc_1E70 loc_1D70: mov ebx, [r12] mov [rsp+0A8h+var_7C], ebx test rbp, rbp jz loc_1ED0 loc_1D81: mov rax, rbp mov rsi, r13 nop word ptr [rax+rax+00000000h] loc_1D90: mov rcx, [rax+10h] mov rdx, [rax+18h] cmp ebx, [rax+20h] jle short loc_1DB2 loc_1D9D: test rdx, rdx jz short loc_1DC0 mov rax, rdx mov rcx, [rax+10h] mov rdx, [rax+18h] cmp ebx, [rax+20h] jg short loc_1D9D loc_1DB2: test rcx, rcx jz short loc_1DC3 mov rsi, rax mov rax, rcx jmp short loc_1D90 loc_1DC0: mov rax, rsi loc_1DC3: cmp rax, r13 jz short loc_1DEB cmp ebx, [rax+20h] jl short loc_1DEB add r12, 4 cmp r14, r12 jz loc_1E70 mov ebx, [r12] mov [rsp+0A8h+var_7C], ebx jmp short loc_1D81 loc_1DE8: mov rbp, rax loc_1DEB: mov edx, [rbp+20h] mov rax, [rbp+18h] cmp ebx, edx cmovl rax, [rbp+10h] setl cl test rax, rax jnz short loc_1DE8 test cl, cl jnz loc_1F1D loc_1E09: cmp ebx, edx jle short loc_1E41 loc_1E0D: mov [rsp+0A8h+var_91], 1 cmp rbp, r13 jnz loc_1F0B loc_1E1B: mov edi, 28h ; '('; unsigned __int64 call __Znwm; operator new(ulong) mov [rax+20h], ebx movzx edi, [rsp+0A8h+var_91] mov rsi, rax mov rcx, r13 mov rdx, rbp call __ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_; std::_Rb_tree_insert_and_rebalance(bool,std::_Rb_tree_node_base *,std::_Rb_tree_node_base *,std::_Rb_tree_node_base&) add [rsp+0A8h+var_50], 1 loc_1E41: mov rax, [rsp+0A8h+var_A0] mov rsi, [rax+8] cmp rsi, [rax+10h] jz loc_1EEA mov [rsi], ebx add rsi, 4 mov rbp, [rsp+0A8h+var_68] mov [rax+8], rsi loc_1E63: add r12, 4 cmp r14, r12 jnz loc_1D70 loc_1E70: add r15, 18h cmp [rsp+0A8h+var_90], r15 jnz loc_1D60 test rbp, rbp jz short loc_1EA3 loc_1E84: mov rdi, [rbp+18h] call _ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE8_M_eraseEPSt13_Rb_tree_nodeIiE_isra_0; std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(std::_Rb_tree_node<int> *) [clone] mov rdi, rbp; void * mov rbp, [rbp+10h] mov esi, 28h ; '('; unsigned __int64 call __ZdlPvm; operator delete(void *,ulong) test rbp, rbp jnz short loc_1E84 loc_1EA3: mov rax, [rsp+0A8h+var_40] sub rax, fs:28h jnz short loc_1F18 mov rax, [rsp+0A8h+var_A0] add rsp, 78h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_1ED0: mov rbp, r13 cmp [rsp+0A8h+var_60], r13 jz short loc_1F01 loc_1EDA: mov rdi, rbp call __ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base; std::_Rb_tree_decrement(std::_Rb_tree_node_base *) mov edx, [rax+20h] jmp loc_1E09 loc_1EEA: mov rdi, rax lea rdx, [rsp+0A8h+var_7C] call _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_; std::vector<int>::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,int const&) mov rbp, [rsp+0A8h+var_68] jmp loc_1E63 loc_1F01: mov [rsp+0A8h+var_91], 1 jmp loc_1E1B loc_1F0B: cmp ebx, [rbp+20h] setl [rsp+0A8h+var_91] jmp loc_1E1B loc_1F18: call ___stack_chk_fail loc_1F1D: cmp rbp, [rsp+0A8h+var_60] jnz short loc_1EDA jmp loc_1E0D endbr64 mov rbx, rax jmp _Z5func0RKSt6vectorIS_IiSaIiEESaIS1_EE_cold; func0(std::vector<std::vector<int>> const&) [clone]
long long func0(long long a1, int ***a2) { int **v2; // r15 int **v3; // rax int *v4; // rbp int *v5; // r12 int *v6; // r14 int v7; // ebx int *v8; // rax int *v9; // rsi int *v10; // rcx long long v11; // rdx int v12; // edx int *v13; // rax long long v14; // rax _DWORD *v15; // rsi int *v16; // rdi bool v19; // [rsp+Fh] [rbp-91h] int **v20; // [rsp+10h] [rbp-90h] int v21[3]; // [rsp+24h] [rbp-7Ch] BYREF int v22; // [rsp+30h] [rbp-70h] BYREF int *v23; // [rsp+38h] [rbp-68h] int *v24; // [rsp+40h] [rbp-60h] int *v25; // [rsp+48h] [rbp-58h] long long v26; // [rsp+50h] [rbp-50h] unsigned long long v27; // [rsp+60h] [rbp-40h] v2 = *a2; v27 = __readfsqword(0x28u); v3 = a2[1]; *(_QWORD *)(a1 + 16) = 0LL; v22 = 0; v23 = 0LL; v24 = &v22; v25 = &v22; v26 = 0LL; v20 = v3; *(_OWORD *)a1 = 0LL; if ( v3 != v2 ) { v4 = 0LL; do { v5 = *v2; v6 = v2[1]; if ( *v2 != v6 ) { while ( 1 ) { v7 = *v5; v21[0] = *v5; if ( !v4 ) break; while ( 1 ) { v8 = v4; v9 = &v22; while ( 1 ) { v10 = (int *)*((_QWORD *)v8 + 2); v11 = *((_QWORD *)v8 + 3); if ( v7 > v8[8] ) break; LABEL_9: if ( !v10 ) goto LABEL_12; v9 = v8; v8 = v10; } while ( v11 ) { v8 = (int *)v11; v10 = *(int **)(v11 + 16); v11 = *(_QWORD *)(v11 + 24); if ( v7 <= v8[8] ) goto LABEL_9; } v8 = v9; LABEL_12: if ( v8 == &v22 || v7 < v8[8] ) break; if ( v6 == ++v5 ) goto LABEL_28; v7 = *v5; v21[0] = *v5; } while ( 1 ) { v12 = v4[8]; v13 = (int *)*((_QWORD *)v4 + 3); if ( v7 < v12 ) v13 = (int *)*((_QWORD *)v4 + 2); if ( !v13 ) break; v4 = v13; } if ( v7 < v12 ) { if ( v4 == v24 ) { LABEL_22: v19 = 1; if ( v4 != &v22 ) v19 = v7 < v4[8]; goto LABEL_24; } LABEL_33: v12 = *(_DWORD *)(std::_Rb_tree_decrement(v4) + 32); } if ( v7 > v12 ) goto LABEL_22; LABEL_25: v15 = *(_DWORD **)(a1 + 8); if ( v15 == *(_DWORD **)(a1 + 16) ) { std::vector<int>::_M_realloc_insert<int const&>(a1, v15, v21); v4 = v23; } else { *v15 = v7; v4 = v23; *(_QWORD *)(a1 + 8) = v15 + 1; } if ( v6 == ++v5 ) goto LABEL_28; } v4 = &v22; if ( v24 == &v22 ) { v19 = 1; LABEL_24: v14 = operator new(0x28uLL); *(_DWORD *)(v14 + 32) = v7; std::_Rb_tree_insert_and_rebalance(v19, v14, v4, &v22); ++v26; goto LABEL_25; } goto LABEL_33; } LABEL_28: v2 += 3; } while ( v20 != v2 ); while ( v4 ) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase(*((_QWORD *)v4 + 3)); v16 = v4; v4 = (int *)*((_QWORD *)v4 + 2); operator delete(v16, 0x28uLL); } } return a1; }
func0: ENDBR64 PUSH R15 PXOR XMM0,XMM0 PUSH R14 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x78 MOV R15,qword ptr [RSI] MOV qword ptr [RSP + 0x8],RDI LEA R13,[RSP + 0x38] MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x68],RAX XOR EAX,EAX MOV RAX,qword ptr [RSI + 0x8] MOV qword ptr [RDI + 0x10],0x0 MOV dword ptr [RSP + 0x38],0x0 MOV qword ptr [RSP + 0x40],0x0 MOV qword ptr [RSP + 0x48],R13 MOV qword ptr [RSP + 0x50],R13 MOV qword ptr [RSP + 0x58],0x0 MOV qword ptr [RSP + 0x18],RAX MOVUPS xmmword ptr [RDI],XMM0 CMP RAX,R15 JZ 0x00101ea3 XOR EBP,EBP NOP word ptr CS:[RAX + RAX*0x1] LAB_00101d60: MOV R12,qword ptr [R15] MOV R14,qword ptr [R15 + 0x8] CMP R12,R14 JZ 0x00101e70 LAB_00101d70: MOV EBX,dword ptr [R12] MOV dword ptr [RSP + 0x2c],EBX TEST RBP,RBP JZ 0x00101ed0 LAB_00101d81: MOV RAX,RBP MOV RSI,R13 NOP word ptr [RAX + RAX*0x1] LAB_00101d90: MOV RCX,qword ptr [RAX + 0x10] MOV RDX,qword ptr [RAX + 0x18] CMP EBX,dword ptr [RAX + 0x20] JLE 0x00101db2 LAB_00101d9d: TEST RDX,RDX JZ 0x00101dc0 MOV RAX,RDX MOV RCX,qword ptr [RAX + 0x10] MOV RDX,qword ptr [RAX + 0x18] CMP EBX,dword ptr [RAX + 0x20] JG 0x00101d9d LAB_00101db2: TEST RCX,RCX JZ 0x00101dc3 MOV RSI,RAX MOV RAX,RCX JMP 0x00101d90 LAB_00101dc0: MOV RAX,RSI LAB_00101dc3: CMP RAX,R13 JZ 0x00101deb CMP EBX,dword ptr [RAX + 0x20] JL 0x00101deb ADD R12,0x4 CMP R14,R12 JZ 0x00101e70 MOV EBX,dword ptr [R12] MOV dword ptr [RSP + 0x2c],EBX JMP 0x00101d81 LAB_00101de8: MOV RBP,RAX LAB_00101deb: MOV EDX,dword ptr [RBP + 0x20] MOV RAX,qword ptr [RBP + 0x18] CMP EBX,EDX CMOVL RAX,qword ptr [RBP + 0x10] SETL CL TEST RAX,RAX JNZ 0x00101de8 TEST CL,CL JNZ 0x00101f1d LAB_00101e09: CMP EBX,EDX JLE 0x00101e41 LAB_00101e0d: MOV byte ptr [RSP + 0x17],0x1 CMP RBP,R13 JNZ 0x00101f0b LAB_00101e1b: MOV EDI,0x28 LAB_00101e20: CALL 0x001011c0 MOV dword ptr [RAX + 0x20],EBX MOVZX EDI,byte ptr [RSP + 0x17] MOV RSI,RAX MOV RCX,R13 MOV RDX,RBP CALL 0x00101140 ADD qword ptr [RSP + 0x58],0x1 LAB_00101e41: MOV RAX,qword ptr [RSP + 0x8] MOV RSI,qword ptr [RAX + 0x8] CMP RSI,qword ptr [RAX + 0x10] JZ 0x00101eea MOV dword ptr [RSI],EBX ADD RSI,0x4 MOV RBP,qword ptr [RSP + 0x40] MOV qword ptr [RAX + 0x8],RSI LAB_00101e63: ADD R12,0x4 CMP R14,R12 JNZ 0x00101d70 LAB_00101e70: ADD R15,0x18 CMP qword ptr [RSP + 0x18],R15 JNZ 0x00101d60 TEST RBP,RBP JZ 0x00101ea3 LAB_00101e84: MOV RDI,qword ptr [RBP + 0x18] CALL 0x00101b10 MOV RDI,RBP MOV RBP,qword ptr [RBP + 0x10] MOV ESI,0x28 CALL 0x001011d0 TEST RBP,RBP JNZ 0x00101e84 LAB_00101ea3: MOV RAX,qword ptr [RSP + 0x68] SUB RAX,qword ptr FS:[0x28] JNZ 0x00101f18 MOV RAX,qword ptr [RSP + 0x8] ADD RSP,0x78 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_00101ed0: MOV RBP,R13 CMP qword ptr [RSP + 0x48],R13 JZ 0x00101f01 LAB_00101eda: MOV RDI,RBP CALL 0x001011e0 MOV EDX,dword ptr [RAX + 0x20] JMP 0x00101e09 LAB_00101eea: MOV RDI,RAX LEA RDX,[RSP + 0x2c] CALL 0x00101ff0 MOV RBP,qword ptr [RSP + 0x40] JMP 0x00101e63 LAB_00101f01: MOV byte ptr [RSP + 0x17],0x1 JMP 0x00101e1b LAB_00101f0b: CMP EBX,dword ptr [RBP + 0x20] SETL byte ptr [RSP + 0x17] JMP 0x00101e1b LAB_00101f18: CALL 0x001011f0 LAB_00101f1d: CMP RBP,qword ptr [RSP + 0x48] JNZ 0x00101eda JMP 0x00101e0d
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) */ vector * func0(vector *param_1) { int8 *puVar1; int *piVar2; int *piVar3; _Rb_tree_node_base *p_Var4; _Rb_tree_node_base *p_Var5; _Rb_tree_node_base *p_Var6; _Rb_tree_node_base *p_Var7; _Rb_tree_node_base *p_Var8; _Rb_tree_node_base *p_Var9; _Rb_tree_node_base *p_Var10; long lVar11; int iVar12; int iVar13; int8 *in_RSI; int *piVar14; int8 *puVar15; long in_FS_OFFSET; bool local_91; int local_7c [3]; int4 local_70 [2]; _Rb_tree_node_base *local_68; _Rb_tree_node_base *local_60; _Rb_tree_node_base *local_58; long local_50; long local_40; puVar15 = (int8 *)*in_RSI; local_40 = *(long *)(in_FS_OFFSET + 0x28); puVar1 = (int8 *)in_RSI[1]; *(int8 *)(param_1 + 0x10) = 0; local_70[0] = 0; local_68 = (_Rb_tree_node_base *)0x0; local_50 = 0; *(int (*) [16])param_1 = (int [16])0x0; local_60 = (_Rb_tree_node_base *)local_70; local_58 = (_Rb_tree_node_base *)local_70; if (puVar1 != puVar15) { p_Var10 = (_Rb_tree_node_base *)0x0; do { piVar14 = (int *)*puVar15; piVar2 = (int *)puVar15[1]; if (piVar14 != piVar2) { LAB_00101d70: iVar13 = *piVar14; p_Var8 = p_Var10; p_Var9 = (_Rb_tree_node_base *)local_70; if (p_Var10 != (_Rb_tree_node_base *)0x0) { do { do { iVar12 = *(int *)(p_Var8 + 0x20); p_Var6 = *(_Rb_tree_node_base **)(p_Var8 + 0x10); p_Var7 = *(_Rb_tree_node_base **)(p_Var8 + 0x18); p_Var5 = p_Var8; while (p_Var4 = p_Var7, p_Var8 = p_Var6, iVar12 < iVar13) { if (p_Var4 == (_Rb_tree_node_base *)0x0) goto LAB_00101dc3; p_Var6 = *(_Rb_tree_node_base **)(p_Var4 + 0x10); p_Var7 = *(_Rb_tree_node_base **)(p_Var4 + 0x18); p_Var5 = p_Var4; iVar12 = *(int *)(p_Var4 + 0x20); } p_Var9 = p_Var5; } while (p_Var8 != (_Rb_tree_node_base *)0x0); LAB_00101dc3: local_7c[0] = iVar13; if ((p_Var9 == (_Rb_tree_node_base *)local_70) || (iVar13 < *(int *)(p_Var9 + 0x20))) goto LAB_00101deb; piVar14 = piVar14 + 1; if (piVar2 == piVar14) goto LAB_00101e70; iVar13 = *piVar14; p_Var8 = p_Var10; p_Var9 = (_Rb_tree_node_base *)local_70; } while( true ); } p_Var8 = (_Rb_tree_node_base *)local_70; local_7c[0] = iVar13; if (local_60 != (_Rb_tree_node_base *)local_70) goto LAB_00101eda; local_91 = true; goto LAB_00101e1b; } LAB_00101e70: puVar15 = puVar15 + 3; } while (puVar1 != puVar15); while (p_Var10 != (_Rb_tree_node_base *)0x0) { std::_Rb_tree<int,int,std::_Identity<int>,std::less<int>,std::allocator<int>>::_M_erase (*(_Rb_tree_node **)(p_Var10 + 0x18)); p_Var8 = *(_Rb_tree_node_base **)(p_Var10 + 0x10); operator_delete(p_Var10,0x28); p_Var10 = p_Var8; } } if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return param_1; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); LAB_00101deb: do { p_Var8 = p_Var10; iVar12 = *(int *)(p_Var8 + 0x20); p_Var10 = *(_Rb_tree_node_base **)(p_Var8 + 0x18); if (iVar13 < iVar12) { p_Var10 = *(_Rb_tree_node_base **)(p_Var8 + 0x10); } } while (p_Var10 != (_Rb_tree_node_base *)0x0); if (iVar13 < iVar12) { if (p_Var8 != local_60) { LAB_00101eda: iVar13 = local_7c[0]; lVar11 = std::_Rb_tree_decrement(p_Var8); iVar12 = *(int *)(lVar11 + 0x20); goto LAB_00101e09; } } else { LAB_00101e09: if (iVar13 <= iVar12) goto LAB_00101e41; } local_91 = true; if (p_Var8 != (_Rb_tree_node_base *)local_70) { local_91 = iVar13 < *(int *)(p_Var8 + 0x20); } LAB_00101e1b: /* try { // try from 00101e20 to 00101ef6 has its CatchHandler @ 00101f29 */ p_Var10 = (_Rb_tree_node_base *)operator_new(0x28); *(int *)(p_Var10 + 0x20) = iVar13; std::_Rb_tree_insert_and_rebalance(local_91,p_Var10,p_Var8,(_Rb_tree_node_base *)local_70); local_50 = local_50 + 1; LAB_00101e41: piVar3 = *(int **)(param_1 + 8); if (piVar3 == *(int **)(param_1 + 0x10)) { std::vector<int,std::allocator<int>>::_M_realloc_insert<int_const&> ((vector<int,std::allocator<int>> *)param_1,(__normal_iterator)piVar3,local_7c); } else { *piVar3 = iVar13; *(int **)(param_1 + 8) = piVar3 + 1; } piVar14 = piVar14 + 1; p_Var10 = local_68; if (piVar2 == piVar14) goto LAB_00101e70; goto LAB_00101d70; }
560
func0
#include <vector> #include <algorithm> #include <assert.h>
std::vector<int> func0(std::vector<int>& nums) { int arr_len = nums.size(); while (arr_len > 1) { int mi = std::distance(nums.begin(), std::max_element(nums.begin(), nums.begin() + arr_len)); std::reverse(nums.begin(), nums.begin() + mi + 1); std::reverse(nums.begin(), nums.begin() + arr_len); arr_len--; } return nums; }
int main() { std::vector<int> nums1 = {15, 79, 25, 38, 69}; assert(func0(nums1) == std::vector<int>({15, 25, 38, 69, 79})); std::vector<int> nums2 = {98, 12, 54, 36, 85}; assert(func0(nums2) == std::vector<int>({12, 36, 54, 85, 98})); std::vector<int> nums3 = {41, 42, 32, 12, 23}; assert(func0(nums3) == std::vector<int>({12, 23, 32, 41, 42})); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> >&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %rdi,-0x38(%rbp) mov %rsi,-0x40(%rbp) mov %fs:0x28,%rax mov %rax,-0x18(%rbp) xor %eax,%eax mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a04 <_ZNKSt6vectorIiSaIiEE4sizeEv> mov %eax,-0x30(%rbp) cmpl $0x1,-0x30(%rbp) jle 137e <_Z5func0RSt6vectorIiSaIiEE+0x135> mov -0x30(%rbp),%eax movslq %eax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rax,-0x20(%rbp) lea -0x20(%rbp),%rax mov %rbx,%rsi mov %rax,%rdi callq 1a78 <_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl> mov %rax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rbx,%rsi mov %rax,%rdi callq 1ade <_ZSt11max_elementIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEET_S7_S7_> mov %rax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rbx,%rsi mov %rax,%rdi callq 1b0c <_ZSt8distanceIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEENSt15iterator_traitsIT_E15difference_typeES8_S8_> mov %eax,-0x2c(%rbp) mov -0x2c(%rbp),%eax movslq %eax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rax,-0x28(%rbp) lea -0x28(%rbp),%rax mov %rbx,%rsi mov %rax,%rdi callq 1a78 <_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl> mov %rax,-0x20(%rbp) lea -0x20(%rbp),%rax mov $0x1,%esi mov %rax,%rdi callq 1a78 <_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl> mov %rax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rbx,%rsi mov %rax,%rdi callq 1b41 <_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_> mov -0x30(%rbp),%eax movslq %eax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rax,-0x20(%rbp) lea -0x20(%rbp),%rax mov %rbx,%rsi mov %rax,%rdi callq 1a78 <_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl> mov %rax,%rbx mov -0x40(%rbp),%rax mov %rax,%rdi callq 1a2c <_ZNSt6vectorIiSaIiEE5beginEv> mov %rbx,%rsi mov %rax,%rdi callq 1b41 <_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_> subl $0x1,-0x30(%rbp) jmpq 127c <_Z5func0RSt6vectorIiSaIiEE+0x33> mov -0x40(%rbp),%rdx mov -0x38(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1b78 <_ZNSt6vectorIiSaIiEEC1ERKS1_> mov -0x18(%rbp),%rax xor %fs:0x28,%rax je 13a5 <_Z5func0RSt6vectorIiSaIiEE+0x15c> callq 1130 <__stack_chk_fail@plt> mov -0x38(%rbp),%rax add $0x38,%rsp pop %rbx pop %rbp retq
_Z5func0RSt6vectorIiSaIiEE: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 58h mov [rbp+var_58], rdi mov [rbp+var_60], rsi mov rax, fs:28h mov [rbp+var_18], rax xor eax, eax mov rax, [rbp+var_60] mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) mov [rbp+var_48], eax jmp loc_13B7 loc_12A1: mov eax, [rbp+var_48] movsxd rbx, eax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_40], rax lea rax, [rbp+var_40] mov rsi, rbx mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl; __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(long) mov rbx, rax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rsi, rbx mov rdi, rax call _ZSt11max_elementIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEET_S7_S7_; std::max_element<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) mov rbx, rax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_38], rax mov [rbp+var_30], rbx nop mov rax, [rbp+var_38] mov [rbp+var_20], rax mov rax, [rbp+var_30] mov [rbp+var_28], rax lea rdx, [rbp+var_20] lea rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call _ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_; __gnu_cxx::operator-<int *,std::vector<int>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>> const&,__gnu_cxx::__normal_iterator<int *,std::vector<int>> const&) nop nop mov [rbp+var_44], eax mov eax, [rbp+var_44] movsxd rbx, eax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_28], rax lea rax, [rbp+var_28] mov rsi, rbx mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl; __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(long) mov [rbp+var_20], rax lea rax, [rbp+var_20] mov esi, 1 mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl; __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(long) mov rbx, rax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rsi, rbx mov rdi, rax call _ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_; std::reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) mov eax, [rbp+var_48] movsxd rbx, eax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov [rbp+var_20], rax lea rax, [rbp+var_20] mov rsi, rbx mov rdi, rax call _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEplEl; __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(long) mov rbx, rax mov rax, [rbp+var_60] mov rdi, rax call _ZNSt6vectorIiSaIiEE5beginEv; std::vector<int>::begin(void) mov rsi, rbx mov rdi, rax call _ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_; std::reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>) sub [rbp+var_48], 1 loc_13B7: cmp [rbp+var_48], 1 jg loc_12A1 mov rdx, [rbp+var_60] mov rax, [rbp+var_58] mov rsi, rdx mov rdi, rax call _ZNSt6vectorIiSaIiEEC2ERKS1_; std::vector<int>::vector(std::vector<int> const&) mov rax, [rbp+var_18] sub rax, fs:28h jz short loc_13E8 call ___stack_chk_fail loc_13E8: mov rax, [rbp+var_58] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, long long a2) { long long v2; // rbx long long v3; // rax long long v4; // rbx long long v5; // rbx long long v6; // rbx long long v7; // rax long long v8; // rbx long long v9; // rax int i; // [rsp+18h] [rbp-48h] long long v12; // [rsp+20h] [rbp-40h] BYREF long long v13; // [rsp+28h] [rbp-38h] long long v14; // [rsp+30h] [rbp-30h] long long v15; // [rsp+38h] [rbp-28h] BYREF _QWORD v16[3]; // [rsp+40h] [rbp-20h] BYREF v16[1] = __readfsqword(0x28u); for ( i = std::vector<int>::size(a2); i > 1; --i ) { v12 = std::vector<int>::begin(a2); v2 = __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(&v12, i); v3 = std::vector<int>::begin(a2); v4 = std::max_element<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(v3, v2); v13 = std::vector<int>::begin(a2); v14 = v4; v16[0] = v13; v15 = v4; v5 = (int)__gnu_cxx::operator-<int *,std::vector<int>>(&v15, v16); v15 = std::vector<int>::begin(a2); v16[0] = __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(&v15, v5); v6 = __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(v16, 1LL); v7 = std::vector<int>::begin(a2); std::reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(v7, v6); v16[0] = std::vector<int>::begin(a2); v8 = __gnu_cxx::__normal_iterator<int *,std::vector<int>>::operator+(v16, i); v9 = std::vector<int>::begin(a2); std::reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(v9, v8); } std::vector<int>::vector(a1, a2); return a1; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x58 MOV qword ptr [RBP + -0x58],RDI MOV qword ptr [RBP + -0x60],RSI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x18],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a4c MOV dword ptr [RBP + -0x48],EAX JMP 0x001013b7 LAB_001012a1: MOV EAX,dword ptr [RBP + -0x48] MOVSXD RBX,EAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV qword ptr [RBP + -0x40],RAX LEA RAX,[RBP + -0x40] MOV RSI,RBX MOV RDI,RAX CALL 0x00101ac0 MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV RSI,RBX MOV RDI,RAX CALL 0x00101b26 MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV qword ptr [RBP + -0x38],RAX MOV qword ptr [RBP + -0x30],RBX NOP MOV RAX,qword ptr [RBP + -0x38] MOV qword ptr [RBP + -0x20],RAX MOV RAX,qword ptr [RBP + -0x30] MOV qword ptr [RBP + -0x28],RAX LEA RDX,[RBP + -0x20] LEA RAX,[RBP + -0x28] MOV RSI,RDX MOV RDI,RAX CALL 0x00102440 NOP NOP MOV dword ptr [RBP + -0x44],EAX MOV EAX,dword ptr [RBP + -0x44] MOVSXD RBX,EAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV qword ptr [RBP + -0x28],RAX LEA RAX,[RBP + -0x28] MOV RSI,RBX MOV RDI,RAX CALL 0x00101ac0 MOV qword ptr [RBP + -0x20],RAX LEA RAX,[RBP + -0x20] MOV ESI,0x1 MOV RDI,RAX CALL 0x00101ac0 MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV RSI,RBX MOV RDI,RAX CALL 0x00101b54 MOV EAX,dword ptr [RBP + -0x48] MOVSXD RBX,EAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV qword ptr [RBP + -0x20],RAX LEA RAX,[RBP + -0x20] MOV RSI,RBX MOV RDI,RAX CALL 0x00101ac0 MOV RBX,RAX MOV RAX,qword ptr [RBP + -0x60] MOV RDI,RAX CALL 0x00101a74 MOV RSI,RBX MOV RDI,RAX CALL 0x00101b54 SUB dword ptr [RBP + -0x48],0x1 LAB_001013b7: CMP dword ptr [RBP + -0x48],0x1 JG 0x001012a1 MOV RDX,qword ptr [RBP + -0x60] MOV RAX,qword ptr [RBP + -0x58] MOV RSI,RDX MOV RDI,RAX CALL 0x00101b80 MOV RAX,qword ptr [RBP + -0x18] SUB RAX,qword ptr FS:[0x28] JZ 0x001013e8 CALL 0x00101150 LAB_001013e8: MOV RAX,qword ptr [RBP + -0x58] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<int, std::allocator<int> >&) */ vector * func0(vector *param_1) { __normal_iterator _Var1; __normal_iterator _Var2; difference_type dVar3; int4 extraout_var; vector<int,std::allocator<int>> *in_RSI; long in_FS_OFFSET; int local_50; int8 local_48; int8 local_40; int8 local_38; int8 local_30; int8 local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); for (local_50 = std::vector<int,std::allocator<int>>::size(in_RSI); 1 < local_50; local_50 = local_50 + -1) { local_48 = std::vector<int,std::allocator<int>>::begin(in_RSI); _Var1 = __normal_iterator<int*,std::vector<int,std::allocator<int>>>::operator+ ((__normal_iterator<int*,std::vector<int,std::allocator<int>>> *)&local_48, (long)local_50); _Var2 = std::vector<int,std::allocator<int>>::begin(in_RSI); _Var1 = std::max_element<__normal_iterator<int*,std::vector<int,std::allocator<int>>>> (_Var2,_Var1); local_40 = std::vector<int,std::allocator<int>>::begin(in_RSI); local_38 = CONCAT44(extraout_var,_Var1); local_30 = CONCAT44(extraout_var,_Var1); local_28 = local_40; dVar3 = operator-((__normal_iterator *)&local_30,(__normal_iterator *)&local_28); local_30 = std::vector<int,std::allocator<int>>::begin(in_RSI); local_28 = __normal_iterator<int*,std::vector<int,std::allocator<int>>>::operator+ ((__normal_iterator<int*,std::vector<int,std::allocator<int>>> *)&local_30, (long)(int)dVar3); _Var1 = __normal_iterator<int*,std::vector<int,std::allocator<int>>>::operator+ ((__normal_iterator<int*,std::vector<int,std::allocator<int>>> *)&local_28,1); _Var2 = std::vector<int,std::allocator<int>>::begin(in_RSI); std::reverse<__normal_iterator<int*,std::vector<int,std::allocator<int>>>>(_Var2,_Var1); local_28 = std::vector<int,std::allocator<int>>::begin(in_RSI); _Var1 = __normal_iterator<int*,std::vector<int,std::allocator<int>>>::operator+ ((__normal_iterator<int*,std::vector<int,std::allocator<int>>> *)&local_28, (long)local_50); _Var2 = std::vector<int,std::allocator<int>>::begin(in_RSI); std::reverse<__normal_iterator<int*,std::vector<int,std::allocator<int>>>>(_Var2,_Var1); } std::vector<int,std::allocator<int>>::vector ((vector<int,std::allocator<int>> *)param_1,(vector *)in_RSI); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return param_1; }
561
func0
#include <vector> #include <algorithm> #include <assert.h>
std::vector<int> func0(std::vector<int>& nums) { int arr_len = nums.size(); while (arr_len > 1) { int mi = std::distance(nums.begin(), std::max_element(nums.begin(), nums.begin() + arr_len)); std::reverse(nums.begin(), nums.begin() + mi + 1); std::reverse(nums.begin(), nums.begin() + arr_len); arr_len--; } return nums; }
int main() { std::vector<int> nums1 = {15, 79, 25, 38, 69}; assert(func0(nums1) == std::vector<int>({15, 25, 38, 69, 79})); std::vector<int> nums2 = {98, 12, 54, 36, 85}; assert(func0(nums2) == std::vector<int>({12, 36, 54, 85, 98})); std::vector<int> nums3 = {41, 42, 32, 12, 23}; assert(func0(nums3) == std::vector<int>({12, 23, 32, 41, 42})); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> >&): endbr64 push %r13 push %r12 push %rbp push %rbx sub $0x8,%rsp mov %rdi,%r13 mov %rsi,%rbp mov 0x8(%rsi),%rax sub (%rsi),%rax sar $0x2,%rax cmp $0x1,%eax jle 12fd <_Z5func0RSt6vectorIiSaIiEE+0x94> movslq %eax,%r12 lea 0x0(,%r12,4),%rbx lea -0x2(%rax),%eax sub %rax,%r12 shl $0x2,%r12 jmp 12d1 <_Z5func0RSt6vectorIiSaIiEE+0x68> sub %rdi,%rdx sar $0x2,%rdx movslq %edx,%rdx lea 0x4(%rdi,%rdx,4),%rsi callq 18ee <_ZSt9__reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_St26random_access_iterator_tag> mov 0x0(%rbp),%rdi lea (%rdi,%rbx,1),%rsi callq 18ee <_ZSt9__reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_St26random_access_iterator_tag> lea -0x4(%rbx),%rax cmp %r12,%rbx je 12fd <_Z5func0RSt6vectorIiSaIiEE+0x94> mov %rax,%rbx mov 0x0(%rbp),%rdi lea (%rdi,%rbx,1),%rcx mov %rdi,%rdx cmp %rdi,%rcx je 12a4 <_Z5func0RSt6vectorIiSaIiEE+0x3b> lea 0x4(%rdi),%rax cmp %rax,%rcx je 12a4 <_Z5func0RSt6vectorIiSaIiEE+0x3b> mov (%rax),%esi cmp %esi,(%rdx) cmovl %rax,%rdx add $0x4,%rax cmp %rax,%rcx jne 12ea <_Z5func0RSt6vectorIiSaIiEE+0x81> jmp 12a4 <_Z5func0RSt6vectorIiSaIiEE+0x3b> mov 0x8(%rbp),%r12 sub 0x0(%rbp),%r12 movq $0x0,0x0(%r13) movq $0x0,0x8(%r13) movq $0x0,0x10(%r13) mov %r12,%rax sar $0x2,%rax je 1387 <_Z5func0RSt6vectorIiSaIiEE+0x11e> movabs $0x1fffffffffffffff,%rdx cmp %rdx,%rax ja 1382 <_Z5func0RSt6vectorIiSaIiEE+0x119> mov %r12,%rdi callq 1140 <_Znwm@plt> mov %rax,%rbx mov %rbx,0x0(%r13) mov %rbx,0x8(%r13) add %rbx,%r12 mov %r12,0x10(%r13) mov 0x8(%rbp),%rax mov 0x0(%rbp),%rsi mov %rax,%rbp sub %rsi,%rbp cmp %rsi,%rax je 136d <_Z5func0RSt6vectorIiSaIiEE+0x104> mov %rbp,%rdx mov %rbx,%rdi callq 1160 <memmove@plt> add %rbp,%rbx mov %rbx,0x8(%r13) mov %r13,%rax add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r13 retq callq 10e0 <_ZSt17__throw_bad_allocv@plt> mov $0x0,%ebx jmp 1340 <_Z5func0RSt6vectorIiSaIiEE+0xd7>
_Z5func0RSt6vectorIiSaIiEE: endbr64 push r13 push r12 push rbp push rbx sub rsp, 8 mov r13, rdi mov rbp, rsi mov rax, [rsi+8] sub rax, [rsi] sar rax, 2 cmp eax, 1 jle short loc_12FB movsxd r12, eax lea rbx, ds:0[r12*4] lea eax, [rax-2] sub r12, rax shl r12, 2 jmp short loc_12D4 loc_12A4: mov rdx, rdi loc_12A7: sub rdx, rdi sar rdx, 2 movsxd rdx, edx lea rsi, [rdi+rdx*4+4] call _ZSt9__reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_St26random_access_iterator_tag; std::__reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,std::random_access_iterator_tag) mov rdi, [rbp+0] lea rsi, [rdi+rbx] call _ZSt9__reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_St26random_access_iterator_tag; std::__reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(__gnu_cxx::__normal_iterator<int *,std::vector<int>>,__gnu_cxx::__normal_iterator<int *,std::vector<int>>,std::random_access_iterator_tag) lea rax, [rbx-4] cmp r12, rbx jz short loc_12FB mov rbx, rax loc_12D4: mov rdi, [rbp+0] lea rcx, [rdi+rbx] lea rax, [rdi+4] cmp rcx, rax jz short loc_12A4 mov rdx, rdi loc_12E8: mov esi, [rax] cmp [rdx], esi cmovl rdx, rax add rax, 4 cmp rcx, rax jnz short loc_12E8 jmp short loc_12A7 loc_12FB: mov r12, [rbp+8] sub r12, [rbp+0] mov qword ptr [r13+0], 0 mov qword ptr [r13+8], 0 mov qword ptr [r13+10h], 0 jz short loc_137C mov rax, 7FFFFFFFFFFFFFFCh cmp rax, r12 jb short loc_1377 mov rdi, r12; unsigned __int64 call __Znwm; operator new(ulong) mov rbx, rax loc_1337: mov [r13+0], rbx mov [r13+8], rbx add r12, rbx mov [r13+10h], r12 mov rsi, [rbp+0]; src mov rbp, [rbp+8] sub rbp, rsi cmp rbp, 4 jle short loc_1383 mov rdx, rbp; n mov rdi, rbx; dest call _memmove loc_1362: add rbx, rbp mov [r13+8], rbx mov rax, r13 add rsp, 8 pop rbx pop rbp pop r12 pop r13 retn loc_1377: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) loc_137C: mov ebx, 0 jmp short loc_1337 loc_1383: jnz short loc_1362 mov eax, [rsi] mov [rbx], eax jmp short loc_1362
_QWORD * func0(_QWORD *a1, _QWORD *a2) { long long v3; // rax long long v4; // rbx unsigned long long v5; // r12 _DWORD *v6; // rdx _DWORD *v7; // rcx _DWORD *v8; // rax unsigned long long v9; // r12 _DWORD *v10; // rbx _DWORD *v11; // rsi signed long long v12; // rbp v3 = (long long)(a2[1] - *a2) >> 2; if ( (int)v3 > 1 ) { v4 = 4LL * (int)v3; v5 = 4 * ((int)v3 - (unsigned long long)(unsigned int)(v3 - 2)); while ( 1 ) { v7 = (_DWORD *)(*a2 + v4); v8 = (_DWORD *)(*a2 + 4LL); if ( v7 == v8 ) { v6 = (_DWORD *)*a2; } else { v6 = (_DWORD *)*a2; do { if ( *v6 < *v8 ) v6 = v8; ++v8; } while ( v7 != v8 ); } std::__reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>( *a2, *a2 + 4LL * (int)(((long long)v6 - *a2) >> 2) + 4); std::__reverse<__gnu_cxx::__normal_iterator<int *,std::vector<int>>>(*a2, *a2 + v4); if ( v5 == v4 ) break; v4 -= 4LL; } } v9 = a2[1] - *a2; *a1 = 0LL; a1[1] = 0LL; a1[2] = 0LL; if ( v9 ) { if ( v9 <= 0x7FFFFFFFFFFFFFFCLL ) { v10 = (_DWORD *)operator new(v9); goto LABEL_15; } std::__throw_bad_array_new_length(); } v10 = 0LL; LABEL_15: *a1 = v10; a1[1] = v10; a1[2] = (char *)v10 + v9; v11 = (_DWORD *)*a2; v12 = a2[1] - *a2; if ( v12 <= 4 ) { if ( v12 == 4 ) *v10 = *v11; } else { memmove(v10, v11, v12); } a1[1] = (char *)v10 + v12; return a1; }
func0: ENDBR64 PUSH R13 PUSH R12 PUSH RBP PUSH RBX SUB RSP,0x8 MOV R13,RDI MOV RBP,RSI MOV RAX,qword ptr [RSI + 0x8] SUB RAX,qword ptr [RSI] SAR RAX,0x2 CMP EAX,0x1 JLE 0x001012fb MOVSXD R12,EAX LEA RBX,[R12*0x4] LEA EAX,[RAX + -0x2] SUB R12,RAX SHL R12,0x2 JMP 0x001012d4 LAB_001012a4: MOV RDX,RDI LAB_001012a7: SUB RDX,RDI SAR RDX,0x2 MOVSXD RDX,EDX LEA RSI,[RDI + RDX*0x4 + 0x4] CALL 0x001018c3 MOV RDI,qword ptr [RBP] LEA RSI,[RDI + RBX*0x1] CALL 0x001018c3 LEA RAX,[RBX + -0x4] CMP R12,RBX JZ 0x001012fb MOV RBX,RAX LAB_001012d4: MOV RDI,qword ptr [RBP] LEA RCX,[RDI + RBX*0x1] LEA RAX,[RDI + 0x4] CMP RCX,RAX JZ 0x001012a4 MOV RDX,RDI LAB_001012e8: MOV ESI,dword ptr [RAX] CMP dword ptr [RDX],ESI CMOVL RDX,RAX ADD RAX,0x4 CMP RCX,RAX JNZ 0x001012e8 JMP 0x001012a7 LAB_001012fb: MOV R12,qword ptr [RBP + 0x8] SUB R12,qword ptr [RBP] MOV qword ptr [R13],0x0 MOV qword ptr [R13 + 0x8],0x0 MOV qword ptr [R13 + 0x10],0x0 JZ 0x0010137c MOV RAX,0x7ffffffffffffffc CMP RAX,R12 JC 0x00101377 MOV RDI,R12 CALL 0x00101130 MOV RBX,RAX LAB_00101337: MOV qword ptr [R13],RBX MOV qword ptr [R13 + 0x8],RBX ADD R12,RBX MOV qword ptr [R13 + 0x10],R12 MOV RSI,qword ptr [RBP] MOV RBP,qword ptr [RBP + 0x8] SUB RBP,RSI CMP RBP,0x4 JLE 0x00101383 MOV RDX,RBP MOV RDI,RBX CALL 0x00101160 LAB_00101362: ADD RBX,RBP MOV qword ptr [R13 + 0x8],RBX MOV RAX,R13 ADD RSP,0x8 POP RBX POP RBP POP R12 POP R13 RET LAB_00101377: CALL 0x00101110 LAB_0010137c: MOV EBX,0x0 JMP 0x00101337 LAB_00101383: JNZ 0x00101362 MOV EAX,dword ptr [RSI] MOV dword ptr [RBX],EAX JMP 0x00101362
/* func0(std::vector<int, std::allocator<int> >&) */ vector * func0(vector *param_1) { int *piVar1; int4 *__src; int *piVar2; int *piVar3; int iVar4; int4 *__dest; random_access_iterator_tag rVar5; random_access_iterator_tag extraout_EDX; long lVar6; size_t __n; long *in_RSI; ulong uVar7; bool bVar8; iVar4 = (int)(in_RSI[1] - *in_RSI >> 2); if (1 < iVar4) { lVar6 = (long)iVar4 * 4; do { piVar1 = (int *)*in_RSI; piVar2 = piVar1; piVar3 = piVar1; while (piVar3 = piVar3 + 1, (int *)((long)piVar1 + lVar6) != piVar3) { if (*piVar2 < *piVar3) { piVar2 = piVar3; } } rVar5 = (random_access_iterator_tag)((long)piVar2 - (long)piVar1 >> 2); std::__reverse<__normal_iterator<int*,std::vector<int,std::allocator<int>>>> ((__normal_iterator)piVar1,(__normal_iterator)piVar1 + 4 + rVar5 * 4,rVar5); std::__reverse<__normal_iterator<int*,std::vector<int,std::allocator<int>>>> ((__normal_iterator)*in_RSI,(__normal_iterator)*in_RSI + (int)lVar6,extraout_EDX); bVar8 = ((long)iVar4 - (ulong)(iVar4 - 2)) * 4 != lVar6; lVar6 = lVar6 + -4; } while (bVar8); } uVar7 = in_RSI[1] - *in_RSI; *(int8 *)param_1 = 0; *(int8 *)(param_1 + 8) = 0; *(int8 *)(param_1 + 0x10) = 0; if (uVar7 != 0) { if (uVar7 < 0x7ffffffffffffffd) { __dest = (int4 *)operator_new(uVar7); goto LAB_00101337; } std::__throw_bad_array_new_length(); } __dest = (int4 *)0x0; LAB_00101337: *(int4 **)param_1 = __dest; *(int4 **)(param_1 + 8) = __dest; *(ulong *)(param_1 + 0x10) = uVar7 + (long)__dest; __src = (int4 *)*in_RSI; __n = in_RSI[1] - (long)__src; if ((long)__n < 5) { if (__n == 4) { *__dest = *__src; } } else { memmove(__dest,__src,__n); } *(size_t *)(param_1 + 8) = (long)__dest + __n; return param_1; }
562
func0
#include <vector> #include <algorithm> #include <assert.h>
std::vector<int> func0(std::vector<int>& nums) { int arr_len = nums.size(); while (arr_len > 1) { int mi = std::distance(nums.begin(), std::max_element(nums.begin(), nums.begin() + arr_len)); std::reverse(nums.begin(), nums.begin() + mi + 1); std::reverse(nums.begin(), nums.begin() + arr_len); arr_len--; } return nums; }
int main() { std::vector<int> nums1 = {15, 79, 25, 38, 69}; assert(func0(nums1) == std::vector<int>({15, 25, 38, 69, 79})); std::vector<int> nums2 = {98, 12, 54, 36, 85}; assert(func0(nums2) == std::vector<int>({12, 36, 54, 85, 98})); std::vector<int> nums3 = {41, 42, 32, 12, 23}; assert(func0(nums3) == std::vector<int>({12, 23, 32, 41, 42})); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> >&): endbr64 push %r14 push %r12 mov %rdi,%r12 push %rbp push %rbx mov %rsi,%rbx sub $0x8,%rsp mov (%rsi),%rdi mov 0x8(%rsi),%rbp sub %rdi,%rbp mov %rbp,%rsi sar $0x2,%rsi cmp $0x1,%esi jle 178c <_Z5func0RSt6vectorIiSaIiEE+0xec> movslq %esi,%rax lea 0x4(%rdi),%r9 shl $0x2,%rax lea -0x4(%rdi,%rax,1),%r8 lea (%rdi,%rax,1),%rcx lea -0x2(%rsi),%eax mov %r8,%r10 shl $0x2,%rax sub %rax,%r10 mov %r9,%rax mov %rdi,%rdx cmp %rcx,%r9 je 1753 <_Z5func0RSt6vectorIiSaIiEE+0xb3> nopl 0x0(%rax,%rax,1) mov (%rax),%r11d cmp %r11d,(%rdx) cmovl %rax,%rdx add $0x4,%rax cmp %rax,%rcx jne 1700 <_Z5func0RSt6vectorIiSaIiEE+0x60> sub %rdi,%rdx sar $0x2,%rdx movslq %edx,%rdx shl $0x2,%rdx lea (%rdi,%rdx,1),%rax cmp $0xfffffffffffffffc,%rdx je 1753 <_Z5func0RSt6vectorIiSaIiEE+0xb3> cmp %rax,%rdi jae 1753 <_Z5func0RSt6vectorIiSaIiEE+0xb3> mov %rdi,%rdx nopl 0x0(%rax,%rax,1) mov (%rdx),%r11d mov (%rax),%r14d add $0x4,%rdx sub $0x4,%rax mov %r14d,-0x4(%rdx) mov %r11d,0x4(%rax) cmp %rdx,%rax ja 1738 <_Z5func0RSt6vectorIiSaIiEE+0x98> mov %r8,%rdx mov %rdi,%rax cmp %r8,%rdi jae 177b <_Z5func0RSt6vectorIiSaIiEE+0xdb> xchg %ax,%ax mov (%rax),%r11d mov (%rdx),%r14d add $0x4,%rax sub $0x4,%rdx mov %r14d,-0x4(%rax) mov %r11d,0x4(%rdx) cmp %rax,%rdx ja 1760 <_Z5func0RSt6vectorIiSaIiEE+0xc0> sub $0x4,%rcx sub $0x4,%r8 cmp %r10,%rcx jne 16f0 <_Z5func0RSt6vectorIiSaIiEE+0x50> movq $0x0,(%r12) movq $0x0,0x8(%r12) movq $0x0,0x10(%r12) test %rsi,%rsi je 180c <_Z5func0RSt6vectorIiSaIiEE+0x16c> movabs $0x1fffffffffffffff,%rax cmp %rax,%rsi ja 1810 <_Z5func0RSt6vectorIiSaIiEE+0x170> mov %rbp,%rdi callq 1140 <_Znwm@plt> mov %rax,%rcx add %rcx,%rbp mov %rcx,(%r12) mov %rcx,0x8(%r12) mov %rbp,0x10(%r12) mov 0x8(%rbx),%rax mov (%rbx),%rsi mov %rax,%rbx sub %rsi,%rbx cmp %rsi,%rax je 17f6 <_Z5func0RSt6vectorIiSaIiEE+0x156> mov %rcx,%rdi mov %rbx,%rdx callq 1160 <memmove@plt> mov %rax,%rcx add %rbx,%rcx mov %r12,%rax mov %rcx,0x8(%r12) add $0x8,%rsp pop %rbx pop %rbp pop %r12 pop %r14 retq xor %ecx,%ecx jmp 17c5 <_Z5func0RSt6vectorIiSaIiEE+0x125> callq 10e0 <_ZSt17__throw_bad_allocv@plt> nopw %cs:0x0(%rax,%rax,1)
_Z5func0RSt6vectorIiSaIiEE: endbr64 push r12 push rbp mov rbp, rsi push rbx mov rsi, [rsi] mov rbx, rdi mov r10, [rbp+8] sub r10, rsi mov rdx, r10 sar rdx, 2 cmp edx, 1 jle loc_1779 movsxd rax, edx lea r8, [rsi+4] shl rax, 2 lea rdi, [rsi+rax-4] lea rcx, [rsi+rax] lea eax, [rdx-2] mov r9, rdi shl rax, 2 sub r9, rax nop dword ptr [rax+00000000h] loc_1670: mov rax, r8 cmp r8, rcx jz short loc_16A2 mov rdx, rsi nop dword ptr [rax+rax+00h] loc_1680: mov r11d, [rdx] cmp [rax], r11d cmovg rdx, rax add rax, 4 cmp rax, rcx jnz short loc_1680 sub rdx, rsi sar rdx, 2 movsxd rdx, edx lea rax, [rsi+rdx*4+4] loc_16A2: cmp rsi, rax jz short loc_16D3 sub rax, 4 cmp rsi, rax jnb short loc_16D3 mov rdx, rsi nop dword ptr [rax+rax+00h] loc_16B8: mov r11d, [rdx] mov r12d, [rax] add rdx, 4 sub rax, 4 mov [rdx-4], r12d mov [rax+4], r11d cmp rdx, rax jb short loc_16B8 loc_16D3: mov rdx, rsi mov rax, rdi cmp rsi, rdi jnb short loc_16FB xchg ax, ax loc_16E0: mov r11d, [rdx] mov r12d, [rax] add rdx, 4 sub rax, 4 mov [rdx-4], r12d mov [rax+4], r11d cmp rdx, rax jb short loc_16E0 loc_16FB: sub rcx, 4 sub rdi, 4 cmp rcx, r9 jnz loc_1670 mov qword ptr [rbx+10h], 0 pxor xmm0, xmm0 mov r12, r10 movups xmmword ptr [rbx], xmm0 loc_171E: mov rax, 7FFFFFFFFFFFFFFCh cmp rax, r10 jb short loc_179C mov rdi, r10; unsigned __int64 call __Znwm; operator new(ulong) mov rcx, rax loc_1738: movq xmm0, rcx add r12, rcx punpcklqdq xmm0, xmm0 mov [rbx+10h], r12 movups xmmword ptr [rbx], xmm0 mov rsi, [rbp+0]; src mov rbp, [rbp+8] sub rbp, rsi cmp rbp, 4 jle short loc_1794 mov rdi, rcx; dest mov rdx, rbp; n call _memmove mov rcx, rax loc_176A: add rcx, rbp mov rax, rbx mov [rbx+8], rcx pop rbx pop rbp pop r12 retn loc_1779: pxor xmm0, xmm0 mov qword ptr [rdi+10h], 0 movups xmmword ptr [rdi], xmm0 test r10, r10 jnz short loc_17A1 xor r12d, r12d xor ecx, ecx jmp short loc_1738 loc_1794: jnz short loc_176A mov eax, [rsi] mov [rcx], eax jmp short loc_176A loc_179C: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) loc_17A1: mov r12, r10 jmp loc_171E
long long func0(long long a1, int **a2) { int *v3; // rsi signed long long v5; // r10 long long v6; // rdx long long v7; // rax long long v8; // rdi int *v9; // rcx long long v10; // r9 int *v11; // rax int *v12; // rdx int *v13; // rax int *v14; // rdx int v15; // r11d int v16; // r12d int *v17; // rdx int *v18; // rax int v19; // r11d int v20; // r12d signed long long v21; // r12 _DWORD *v22; // rcx int *v23; // rsi signed long long v24; // rbp long long result; // rax v3 = *a2; v5 = (char *)a2[1] - (char *)v3; v6 = v5 >> 2; if ( (int)(v5 >> 2) <= 1 ) { *(_QWORD *)(a1 + 16) = 0LL; *(_OWORD *)a1 = 0LL; if ( v5 ) goto LABEL_27; v21 = 0LL; v22 = 0LL; } else { v7 = (int)v6; v8 = (long long)&v3[v7 - 1]; v9 = &v3[v7]; v10 = v8 - 4LL * (unsigned int)(v6 - 2); do { v11 = v3 + 1; if ( v3 + 1 != v9 ) { v12 = v3; do { if ( *v11 > *v12 ) v12 = v11; ++v11; } while ( v11 != v9 ); v11 = &v3[(int)(v12 - v3) + 1]; } if ( v3 != v11 ) { v13 = v11 - 1; if ( v3 < v13 ) { v14 = v3; do { v15 = *v14; v16 = *v13; ++v14; --v13; *(v14 - 1) = v16; v13[1] = v15; } while ( v14 < v13 ); } } v17 = v3; v18 = (int *)v8; if ( (unsigned long long)v3 < v8 ) { do { v19 = *v17; v20 = *v18; ++v17; --v18; *(v17 - 1) = v20; v18[1] = v19; } while ( v17 < v18 ); } --v9; v8 -= 4LL; } while ( v9 != (int *)v10 ); *(_QWORD *)(a1 + 16) = 0LL; v21 = v5; *(_OWORD *)a1 = 0LL; while ( (unsigned long long)v5 > 0x7FFFFFFFFFFFFFFCLL ) { std::__throw_bad_array_new_length(); LABEL_27: v21 = v5; } v22 = (_DWORD *)operator new(v5); } *(_QWORD *)(a1 + 16) = (char *)v22 + v21; *(__m128i *)a1 = _mm_unpacklo_epi64((__m128i)(unsigned long long)v22, (__m128i)(unsigned long long)v22); v23 = *a2; v24 = (char *)a2[1] - (char *)*a2; if ( v24 <= 4 ) { if ( v24 == 4 ) *v22 = *v23; } else { v22 = memmove(v22, v23, v24); } result = a1; *(_QWORD *)(a1 + 8) = (char *)v22 + v24; return result; }
func0: ENDBR64 PUSH R12 PUSH RBP MOV RBP,RSI PUSH RBX MOV RSI,qword ptr [RSI] MOV RBX,RDI MOV R10,qword ptr [RBP + 0x8] SUB R10,RSI MOV RDX,R10 SAR RDX,0x2 CMP EDX,0x1 JLE 0x00101779 MOVSXD RAX,EDX LEA R8,[RSI + 0x4] SHL RAX,0x2 LEA RDI,[RSI + RAX*0x1 + -0x4] LEA RCX,[RSI + RAX*0x1] LEA EAX,[RDX + -0x2] MOV R9,RDI SHL RAX,0x2 SUB R9,RAX NOP dword ptr [RAX] LAB_00101670: MOV RAX,R8 CMP R8,RCX JZ 0x001016a2 MOV RDX,RSI NOP dword ptr [RAX + RAX*0x1] LAB_00101680: MOV R11D,dword ptr [RDX] CMP dword ptr [RAX],R11D CMOVG RDX,RAX ADD RAX,0x4 CMP RAX,RCX JNZ 0x00101680 SUB RDX,RSI SAR RDX,0x2 MOVSXD RDX,EDX LEA RAX,[RSI + RDX*0x4 + 0x4] LAB_001016a2: CMP RSI,RAX JZ 0x001016d3 SUB RAX,0x4 CMP RSI,RAX JNC 0x001016d3 MOV RDX,RSI NOP dword ptr [RAX + RAX*0x1] LAB_001016b8: MOV R11D,dword ptr [RDX] MOV R12D,dword ptr [RAX] ADD RDX,0x4 SUB RAX,0x4 MOV dword ptr [RDX + -0x4],R12D MOV dword ptr [RAX + 0x4],R11D CMP RDX,RAX JC 0x001016b8 LAB_001016d3: MOV RDX,RSI MOV RAX,RDI CMP RSI,RDI JNC 0x001016fb NOP LAB_001016e0: MOV R11D,dword ptr [RDX] MOV R12D,dword ptr [RAX] ADD RDX,0x4 SUB RAX,0x4 MOV dword ptr [RDX + -0x4],R12D MOV dword ptr [RAX + 0x4],R11D CMP RDX,RAX JC 0x001016e0 LAB_001016fb: SUB RCX,0x4 SUB RDI,0x4 CMP RCX,R9 JNZ 0x00101670 MOV qword ptr [RBX + 0x10],0x0 PXOR XMM0,XMM0 MOV R12,R10 MOVUPS xmmword ptr [RBX],XMM0 LAB_0010171e: MOV RAX,0x7ffffffffffffffc CMP RAX,R10 JC 0x0010179c MOV RDI,R10 CALL 0x00101130 MOV RCX,RAX LAB_00101738: MOVQ XMM0,RCX ADD R12,RCX PUNPCKLQDQ XMM0,XMM0 MOV qword ptr [RBX + 0x10],R12 MOVUPS xmmword ptr [RBX],XMM0 MOV RSI,qword ptr [RBP] MOV RBP,qword ptr [RBP + 0x8] SUB RBP,RSI CMP RBP,0x4 JLE 0x00101794 MOV RDI,RCX MOV RDX,RBP CALL 0x00101160 MOV RCX,RAX LAB_0010176a: ADD RCX,RBP MOV RAX,RBX MOV qword ptr [RBX + 0x8],RCX POP RBX POP RBP POP R12 RET LAB_00101779: PXOR XMM0,XMM0 MOV qword ptr [RDI + 0x10],0x0 MOVUPS xmmword ptr [RDI],XMM0 TEST R10,R10 JNZ 0x001017a1 XOR R12D,R12D XOR ECX,ECX JMP 0x00101738 LAB_00101794: JNZ 0x0010176a MOV EAX,dword ptr [RSI] MOV dword ptr [RCX],EAX JMP 0x0010176a LAB_0010179c: CALL 0x00101110 LAB_001017a1: MOV R12,R10 JMP 0x0010171e
/* func0(std::vector<int, std::allocator<int> >&) */ vector * func0(vector *param_1) { int *piVar1; int *piVar2; int4 *__src; int *piVar3; int *piVar4; int4 *__dest; int *piVar5; int iVar6; int *piVar7; int *piVar8; size_t __n; int8 *in_RSI; int *piVar9; int *piVar10; ulong uVar11; piVar2 = (int *)*in_RSI; uVar11 = in_RSI[1] - (long)piVar2; iVar6 = (int)((long)uVar11 >> 2); if (iVar6 < 2) { *(int8 *)(param_1 + 0x10) = 0; *(int (*) [16])param_1 = (int [16])0x0; if (uVar11 == 0) { uVar11 = 0; __dest = (int4 *)0x0; goto LAB_00101738; } } else { piVar1 = piVar2 + 1; piVar9 = piVar2 + (long)iVar6 + -1; piVar5 = piVar2 + iVar6; piVar10 = piVar9 + -(ulong)(iVar6 - 2); do { piVar3 = piVar1; piVar7 = piVar2; if (piVar1 != piVar5) { do { if (*piVar7 < *piVar3) { piVar7 = piVar3; } piVar3 = piVar3 + 1; } while (piVar3 != piVar5); piVar3 = piVar2 + (long)(int)((long)piVar7 - (long)piVar2 >> 2) + 1; } if ((piVar2 != piVar3) && (piVar3 = piVar3 + -1, piVar7 = piVar2, piVar2 < piVar3)) { do { iVar6 = *piVar7; piVar8 = piVar7 + 1; piVar4 = piVar3 + -1; *piVar7 = *piVar3; *piVar3 = iVar6; piVar3 = piVar4; piVar7 = piVar8; } while (piVar8 < piVar4); } piVar3 = piVar9; piVar7 = piVar2; if (piVar2 < piVar9) { do { iVar6 = *piVar7; piVar8 = piVar7 + 1; piVar4 = piVar3 + -1; *piVar7 = *piVar3; *piVar3 = iVar6; piVar3 = piVar4; piVar7 = piVar8; } while (piVar8 < piVar4); } piVar5 = piVar5 + -1; piVar9 = piVar9 + -1; } while (piVar5 != piVar10); *(int8 *)(param_1 + 0x10) = 0; *(int (*) [16])param_1 = (int [16])0x0; } while (0x7ffffffffffffffc < uVar11) { std::__throw_bad_array_new_length(); } __dest = (int4 *)operator_new(uVar11); LAB_00101738: *(ulong *)(param_1 + 0x10) = uVar11 + (long)__dest; *(int4 **)param_1 = __dest; *(int4 **)(param_1 + 8) = __dest; __src = (int4 *)*in_RSI; __n = in_RSI[1] - (long)__src; if ((long)__n < 5) { if (__n == 4) { *__dest = *__src; } } else { __dest = (int4 *)memmove(__dest,__src,__n); } *(size_t *)(param_1 + 8) = (long)__dest + __n; return param_1; }
563
func0
#include <vector> #include <algorithm> #include <assert.h>
std::vector<int> func0(std::vector<int>& nums) { int arr_len = nums.size(); while (arr_len > 1) { int mi = std::distance(nums.begin(), std::max_element(nums.begin(), nums.begin() + arr_len)); std::reverse(nums.begin(), nums.begin() + mi + 1); std::reverse(nums.begin(), nums.begin() + arr_len); arr_len--; } return nums; }
int main() { std::vector<int> nums1 = {15, 79, 25, 38, 69}; assert(func0(nums1) == std::vector<int>({15, 25, 38, 69, 79})); std::vector<int> nums2 = {98, 12, 54, 36, 85}; assert(func0(nums2) == std::vector<int>({12, 36, 54, 85, 98})); std::vector<int> nums3 = {41, 42, 32, 12, 23}; assert(func0(nums3) == std::vector<int>({12, 23, 32, 41, 42})); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> >&): endbr64 push %r15 push %r14 push %r13 push %r12 mov %rdi,%r12 push %rbp push %rbx sub $0x28,%rsp mov (%rsi),%rcx mov 0x8(%rsi),%rax mov %rsi,0x18(%rsp) sub %rcx,%rax mov %rax,0x10(%rsp) sar $0x2,%rax mov %rax,0x8(%rsp) cmp $0x1,%eax jle 1900 <_Z5func0RSt6vectorIiSaIiEE+0x2e0> movslq %eax,%r13 sub $0x2,%eax lea 0x4(%rcx),%rbp mov %rcx,%r14 lea 0x0(,%r13,4),%rdi sub %rax,%r13 not %r14 lea (%rcx,%rdi,1),%rdx shl $0x2,%r13 xchg %ax,%ax cmp %rdx,%rbp je 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> mov (%rcx),%r9d mov %rbp,%rax mov %rcx,%r8 nopw 0x0(%rax,%rax,1) mov (%rax),%esi cmp %r9d,%esi jle 16a5 <_Z5func0RSt6vectorIiSaIiEE+0x85> mov %esi,%r9d mov %rax,%r8 add $0x4,%rax cmp %rax,%rdx jne 1698 <_Z5func0RSt6vectorIiSaIiEE+0x78> sub %rcx,%r8 sar $0x2,%r8 movslq %r8d,%rax shl $0x2,%rax lea (%rcx,%rax,1),%r9 cmp $0xfffffffffffffffc,%rax je 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> cmp %r9,%rcx jae 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> lea (%r14,%r9,1),%r11 mov %r9,%rsi mov %rcx,%rax mov %r11,%r8 shr $0x3,%r8 lea 0x1(%r8),%r10 neg %r8 lea (%rcx,%r10,4),%rbx lea (%r9,%r8,4),%r8 cmp %r8,%rbx lea 0x4(%r9),%r8 setbe %bl cmp %r8,%rcx setae %r8b or %r8b,%bl je 18c0 <_Z5func0RSt6vectorIiSaIiEE+0x2a0> cmp $0x17,%r11 jbe 18c0 <_Z5func0RSt6vectorIiSaIiEE+0x2a0> mov %r10,%r8 lea -0xc(%r9),%rsi shr $0x2,%r8 shl $0x4,%r8 add %rcx,%r8 nopl 0x0(%rax) movdqu (%rsi),%xmm3 movdqu (%rax),%xmm0 add $0x10,%rax sub $0x10,%rsi pshufd $0x1b,%xmm3,%xmm1 pshufd $0x1b,%xmm0,%xmm0 movups %xmm1,-0x10(%rax) movups %xmm0,0x10(%rsi) cmp %r8,%rax jne 1730 <_Z5func0RSt6vectorIiSaIiEE+0x110> mov %r10,%r8 and $0xfffffffffffffffc,%r8 mov %r8,%rax lea (%rcx,%r8,4),%rsi neg %rax lea (%r9,%rax,4),%rax cmp %r8,%r10 je 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> mov (%rsi),%r8d mov (%rax),%r9d mov %r9d,(%rsi) lea -0x4(%rax),%r9 mov %r8d,(%rax) lea 0x4(%rsi),%r8 cmp %r8,%r9 jbe 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> mov 0x4(%rsi),%r8d mov -0x4(%rax),%r9d mov %r9d,0x4(%rsi) lea 0x8(%rsi),%r9 mov %r8d,-0x4(%rax) lea -0x8(%rax),%r8 cmp %r8,%r9 jae 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> mov 0x8(%rsi),%r8d mov -0x8(%rax),%r9d mov %r9d,0x8(%rsi) mov %r8d,-0x8(%rax) lea -0x4(%rdx),%r8 mov %r8,%rsi cmp %r8,%rcx jae 19a0 <_Z5func0RSt6vectorIiSaIiEE+0x380> lea -0x5(%rdi),%r11 mov %rcx,%rax mov %r11,%r10 shr $0x3,%r10 mov %r10,%r15 lea 0x1(%r10),%r9 lea -0x4(%rdi),%r10 neg %r15 lea 0x0(,%r9,4),%rbx lea (%r10,%r15,4),%r15 cmp %r15,%rbx setle %r15b test %rdi,%rdi setle %bl or %bl,%r15b je 18e0 <_Z5func0RSt6vectorIiSaIiEE+0x2c0> cmp $0x17,%r11 jbe 18e0 <_Z5func0RSt6vectorIiSaIiEE+0x2c0> mov %r9,%rsi sub $0x10,%rdx shr $0x2,%rsi shl $0x4,%rsi add %rcx,%rsi nopl 0x0(%rax) movdqu (%rdx),%xmm2 movdqu (%rax),%xmm0 add $0x10,%rax sub $0x10,%rdx pshufd $0x1b,%xmm2,%xmm1 pshufd $0x1b,%xmm0,%xmm0 movups %xmm1,-0x10(%rax) movups %xmm0,0x10(%rdx) cmp %rax,%rsi jne 1828 <_Z5func0RSt6vectorIiSaIiEE+0x208> mov %r9,%rsi and $0xfffffffffffffffc,%rsi mov %rsi,%rax lea (%rcx,%rsi,4),%rdx neg %rax lea (%r8,%rax,4),%rax cmp %rsi,%r9 je 18a9 <_Z5func0RSt6vectorIiSaIiEE+0x289> mov (%rdx),%esi mov (%rax),%r9d mov %r9d,(%rdx) lea 0x4(%rdx),%r9 mov %esi,(%rax) lea -0x4(%rax),%rsi cmp %rsi,%r9 jae 18a9 <_Z5func0RSt6vectorIiSaIiEE+0x289> mov 0x4(%rdx),%esi mov -0x4(%rax),%r9d mov %r9d,0x4(%rdx) lea 0x8(%rdx),%r9 mov %esi,-0x4(%rax) lea -0x8(%rax),%rsi cmp %rsi,%r9 jae 18a9 <_Z5func0RSt6vectorIiSaIiEE+0x289> mov 0x8(%rdx),%esi mov -0x8(%rax),%r9d mov %r9d,0x8(%rdx) mov %esi,-0x8(%rax) mov %r8,%rdx cmp %r13,%rdi je 1900 <_Z5func0RSt6vectorIiSaIiEE+0x2e0> mov %r10,%rdi jmpq 1680 <_Z5func0RSt6vectorIiSaIiEE+0x60> nopl 0x0(%rax) mov (%rax),%r8d mov (%rsi),%r9d add $0x4,%rax sub $0x4,%rsi mov %r9d,-0x4(%rax) mov %r8d,0x4(%rsi) cmp %rsi,%rax jb 18c0 <_Z5func0RSt6vectorIiSaIiEE+0x2a0> jmpq 17b7 <_Z5func0RSt6vectorIiSaIiEE+0x197> mov (%rax),%edx mov (%rsi),%r9d add $0x4,%rax sub $0x4,%rsi mov %r9d,-0x4(%rax) mov %edx,0x4(%rsi) cmp %rax,%rsi ja 18e0 <_Z5func0RSt6vectorIiSaIiEE+0x2c0> jmp 18a9 <_Z5func0RSt6vectorIiSaIiEE+0x289> nopl 0x0(%rax,%rax,1) pxor %xmm0,%xmm0 cmpq $0x0,0x8(%rsp) movq $0x0,0x10(%r12) movups %xmm0,(%r12) je 19a9 <_Z5func0RSt6vectorIiSaIiEE+0x389> movabs $0x1fffffffffffffff,%rax cmp %rax,0x8(%rsp) ja 19ad <_Z5func0RSt6vectorIiSaIiEE+0x38d> mov 0x10(%rsp),%rdi callq 1140 <_Znwm@plt> mov %rax,%rcx mov 0x10(%rsp),%rax mov 0x18(%rsp),%rbx movq %rcx,%xmm0 punpcklqdq %xmm0,%xmm0 add %rcx,%rax movups %xmm0,(%r12) mov %rax,0x10(%r12) mov 0x8(%rbx),%rax mov (%rbx),%rsi mov %rax,%rbx sub %rsi,%rbx cmp %rsi,%rax je 197c <_Z5func0RSt6vectorIiSaIiEE+0x35c> mov %rcx,%rdi mov %rbx,%rdx callq 1160 <memmove@plt> mov %rax,%rcx add %rbx,%rcx mov %r12,%rax mov %rcx,0x8(%r12) add $0x28,%rsp pop %rbx pop %rbp pop %r12 pop %r13 pop %r14 pop %r15 retq nopw %cs:0x0(%rax,%rax,1) lea -0x4(%rdi),%r10 jmpq 18a9 <_Z5func0RSt6vectorIiSaIiEE+0x289> xor %ecx,%ecx jmp 193c <_Z5func0RSt6vectorIiSaIiEE+0x31c> callq 10e0 <_ZSt17__throw_bad_allocv@plt> nopw %cs:0x0(%rax,%rax,1) nopl 0x0(%rax)
_Z5func0RSt6vectorIiSaIiEE: endbr64 push r15 push r14 push r13 mov r13, rdi push r12 mov r12, rsi push rbp push rbx sub rsp, 38h mov rsi, [rsi] mov rax, [r12+8] sub rax, rsi mov rcx, rax sar rcx, 2 cmp ecx, 1 jle loc_19FF movsxd rdx, ecx sub ecx, 2 mov [rsp+68h+var_50], rax lea r15, [rsi+4] lea r9, ds:0[rdx*4] sub rdx, rcx mov [rsp+68h+var_48], r13 mov [rsp+68h+var_40], r12 lea rbx, ds:0FFFFFFFFFFFFFFF7h[rdx*4] lea rbp, [r9-4] mov [rsp+68h+var_58], rbx lea rdi, [rsi+r9] lea r10, [rsi+rbp] lea r11, [r9-5] nop dword ptr [rax+00h] loc_1698: cmp r15, rdi jz loc_1750 mov ebx, [rsi] mov rdx, r15 mov rax, rsi mov rcx, rsi nop dword ptr [rax+00h] loc_16B0: mov r8d, [rdx] cmp r8d, ebx jle short loc_16BE mov ebx, r8d mov rcx, rdx loc_16BE: add rdx, 4 cmp rdi, rdx jnz short loc_16B0 sub rcx, rsi sar rcx, 2 movsxd rcx, ecx shl rcx, 2 lea r8, [rsi+rcx] lea rdx, [r8+4] cmp rsi, rdx jz short loc_1750 cmp rsi, r8 jnb short loc_1750 lea r12, [rcx-1] mov rdx, r8 cmp r12, 7 jbe short loc_1730 mov r13, r12 shr r13, 3 lea rbx, [r13+1] lea r14, ds:0[rbx*4] mov [rsp+68h+var_60], r14 mov r14, r13 neg r14 lea r14, [rcx+r14*4] cmp [rsp+68h+var_60], r14 jle loc_18A0 lea r14, [rcx+4] test r14, r14 jle loc_18A0 xchg ax, ax loc_1730: mov ecx, [rax] mov r8d, [rdx] add rax, 4 sub rdx, 4 mov [rax-4], r8d mov [rdx+4], ecx cmp rax, rdx jb short loc_1730 nop dword ptr [rax+00000000h] loc_1750: mov rcx, r10 cmp rsi, r10 jnb short loc_17B0 mov rax, rsi cmp r11, 7 jbe loc_1960 mov r8, r11 shr r8, 3 mov rbx, r8 lea rdx, [r8+1] neg rbx lea r12, ds:0[rdx*4] lea rbx, [rbp+rbx*4+0] cmp r12, rbx jle short loc_17E0 mov rbx, r10 test r9, r9 jle short loc_17E0 loc_1790: mov edx, [rax] mov ecx, [rbx] add rax, 4 sub rbx, 4 mov [rax-4], ecx mov [rbx+4], edx cmp rax, rbx jb short loc_1790 nop word ptr [rax+rax+00000000h] loc_17B0: mov rax, [rsp+68h+var_58] sub r11, 4 sub rdi, 4 mov r9, rbp sub r10, 4 cmp r11, rax jz loc_1970 sub rbp, 4 jmp loc_1698 loc_17E0: cmp r11, 17h jbe loc_1A19 mov rbx, rdx lea rcx, [rdi-10h] shr rbx, 2 shl rbx, 4 add rbx, rsi nop dword ptr [rax+00h] loc_1800: movdqu xmm2, xmmword ptr [rcx] movdqu xmm0, xmmword ptr [rax] add rax, 10h sub rcx, 10h pshufd xmm1, xmm2, 1Bh pshufd xmm0, xmm0, 1Bh movups xmmword ptr [rax-10h], xmm1 movups xmmword ptr [rcx+10h], xmm0 cmp rax, rbx jnz short loc_1800 test dl, 3 jz short loc_17B0 mov r12, rdx mov rcx, r10 and r12, 0FFFFFFFFFFFFFFFCh lea rbx, ds:0[r12*4] sub rdx, r12 lea rax, [rsi+rbx] sub rcx, rbx cmp r8, r12 jz short loc_1890 loc_184D: sub r9, 8 lea r8, [rsi+rbx] sub r9, rbx movq xmm0, qword ptr [r8] add r9, rsi movq xmm1, qword ptr [r9] pshufd xmm0, xmm0, 0E1h pshufd xmm1, xmm1, 0E1h movq qword ptr [r8], xmm1 movq qword ptr [r9], xmm0 test dl, 1 jz loc_17B0 and rdx, 0FFFFFFFFFFFFFFFEh shl rdx, 2 add rax, rdx sub rcx, rdx loc_1890: mov edx, [rax] mov r8d, [rcx] mov [rax], r8d mov [rcx], edx jmp loc_17B0 loc_18A0: cmp r12, 17h jbe loc_1A23 mov r12, rbx lea rdx, [rsi+rcx-0Ch] shr r12, 2 shl r12, 4 add r12, rsi nop dword ptr [rax] loc_18C0: movdqu xmm3, xmmword ptr [rdx] movdqu xmm0, xmmword ptr [rax] add rax, 10h sub rdx, 10h pshufd xmm1, xmm3, 1Bh pshufd xmm0, xmm0, 1Bh movups xmmword ptr [rax-10h], xmm1 movups xmmword ptr [rdx+10h], xmm0 cmp rax, r12 jnz short loc_18C0 test bl, 3 jz loc_1750 mov r12, rbx and r12, 0FFFFFFFFFFFFFFFCh lea rdx, ds:0[r12*4] sub rbx, r12 lea rax, [rsi+rdx] sub r8, rdx cmp r13, r12 jz short loc_194C loc_190E: not r12 add rdx, rsi lea rcx, [rcx+r12*4] movq xmm0, qword ptr [rdx] add rcx, rsi movq xmm1, qword ptr [rcx] pshufd xmm0, xmm0, 0E1h pshufd xmm1, xmm1, 0E1h movq qword ptr [rdx], xmm1 movq qword ptr [rcx], xmm0 test bl, 1 jz loc_1750 and rbx, 0FFFFFFFFFFFFFFFEh shl rbx, 2 add rax, rbx sub r8, rbx loc_194C: mov edx, [rax] mov ecx, [r8] mov [rax], ecx mov [r8], edx jmp loc_1750 loc_1960: mov rbx, r10 jmp loc_1790 loc_1970: mov r13, [rsp+68h+var_48] mov rax, [rsp+68h+var_50] pxor xmm0, xmm0 mov r12, [rsp+68h+var_40] mov qword ptr [r13+10h], 0 mov rbx, rax movups xmmword ptr [r13+0], xmm0 loc_1993: mov rdx, 7FFFFFFFFFFFFFFCh cmp rdx, rax jb loc_1A38 mov rdi, rax; unsigned __int64 call __Znwm; operator new(ulong) mov rcx, rax loc_19B1: movq xmm0, rcx add rbx, rcx punpcklqdq xmm0, xmm0 mov [r13+10h], rbx movups xmmword ptr [r13+0], xmm0 mov rsi, [r12]; src mov rbx, [r12+8] sub rbx, rsi cmp rbx, 4 jle short loc_1A30 mov rdi, rcx; dest mov rdx, rbx; n call _memmove mov rcx, rax loc_19E6: add rcx, rbx mov rax, r13 mov [r13+8], rcx add rsp, 38h pop rbx pop rbp pop r12 pop r13 pop r14 pop r15 retn loc_19FF: pxor xmm0, xmm0 mov qword ptr [rdi+10h], 0 movups xmmword ptr [rdi], xmm0 test rax, rax jnz short loc_1A3D xor ebx, ebx xor ecx, ecx jmp short loc_19B1 loc_1A19: mov rax, rsi xor ebx, ebx jmp loc_184D loc_1A23: mov rax, rsi xor r12d, r12d xor edx, edx jmp loc_190E loc_1A30: jnz short loc_19E6 mov eax, [rsi] mov [rcx], eax jmp short loc_19E6 loc_1A38: call __ZSt28__throw_bad_array_new_lengthv; std::__throw_bad_array_new_length(void) loc_1A3D: mov rbx, rax jmp loc_1993
__m128i * func0(__m128i *a1, const __m128i **a2) { __m128i *v2; // r13 const __m128i **v3; // r12 const __m128i *v4; // rsi signed long long v5; // rax long long v6; // rcx long long v7; // r9 long long v8; // rbp const __m128i *v9; // rdi const __m128i *v10; // r10 unsigned long long v11; // r11 __int32 v12; // ebx const __m128i *v13; // rdx const __m128i *v14; // rax const __m128i *v15; // rcx long long v16; // rcx __m128i *v17; // r8 unsigned long long v18; // r12 const __m128i *v19; // rdx unsigned long long v20; // r13 unsigned long long v21; // rbx __int32 v22; // ecx __int32 v23; // r8d __m128i *v24; // rcx const __m128i *v25; // rax unsigned long long v26; // rdx const __m128i *v27; // rbx __int32 v28; // edx __int32 v29; // ecx const __m128i *v30; // rcx __m128i v31; // xmm2 __m128i v32; // xmm0 unsigned long long v33; // r12 unsigned long long v34; // rbx __m128i *v35; // rax __m128i *v36; // r9 unsigned long long v37; // xmm0_8 unsigned long long v38; // rdx __int32 v39; // edx const __m128i *v40; // rdx __m128i v41; // xmm3 __m128i v42; // xmm0 unsigned long long v43; // r12 unsigned long long v44; // rdx __m128i *v45; // rax __m128i *v46; // rdx __m128i *v47; // rcx unsigned long long v48; // xmm0_8 unsigned long long v49; // rbx __int32 v50; // edx unsigned long long v51; // rbx _DWORD *v52; // rcx const __m128i *v53; // rsi long long v54; // rbx __m128i *result; // rax unsigned long long v56; // [rsp+10h] [rbp-58h] unsigned long long v57; // [rsp+18h] [rbp-50h] const __m128i **v59; // [rsp+28h] [rbp-40h] v2 = a1; v3 = a2; v4 = *a2; v5 = (char *)v3[1] - (char *)v4; v6 = v5 >> 2; if ( (int)(v5 >> 2) > 1 ) { v57 = (char *)v3[1] - (char *)v4; v7 = 4LL * (int)v6; v59 = v3; v8 = v7 - 4; v56 = 4 * ((int)v6 - (unsigned long long)(unsigned int)(v6 - 2)) - 9; v9 = (const __m128i *)((char *)v4 + v7); v10 = (const __m128i *)((char *)v4 + v7 - 4); v11 = v7 - 5; while ( 1 ) { if ( (const __m128i *)((char *)v4->m128i_i64 + 4) != v9 ) { v12 = v4->m128i_i32[0]; v13 = (const __m128i *)((char *)v4->m128i_i64 + 4); v14 = v4; v15 = v4; do { if ( v13->m128i_i32[0] > v12 ) { v12 = v13->m128i_i32[0]; v15 = v13; } v13 = (const __m128i *)((char *)v13 + 4); } while ( v9 != v13 ); v16 = 4LL * (int)(((char *)v15 - (char *)v4) >> 2); v17 = (__m128i *)((char *)v4 + v16); if ( v4 != (const __m128i *)((char *)v4->m128i_i64 + v16 + 4) && v4 < v17 ) { v18 = v16 - 1; v19 = (const __m128i *)((char *)v4 + v16); if ( (unsigned long long)(v16 - 1) > 7 && ((v20 = v18 >> 3, v21 = (v18 >> 3) + 1, (long long)(4 * v21) <= (long long)(v16 - 4 * (v18 >> 3))) || v16 + 4 <= 0) ) { if ( v18 <= 0x17 ) { v45 = (__m128i *)v4; v43 = 0LL; v44 = 0LL; LABEL_34: v46 = (__m128i *)((char *)v4 + v44); v47 = (__m128i *)((char *)v4 + 4 * ~v43 + v16); v48 = _mm_shuffle_epi32(_mm_loadl_epi64(v46), 225).m128i_u64[0]; v46->m128i_i64[0] = _mm_shuffle_epi32(_mm_loadl_epi64(v47), 225).m128i_u64[0]; v47->m128i_i64[0] = v48; if ( (v21 & 1) == 0 ) goto LABEL_14; v49 = 4 * (v21 & 0xFFFFFFFFFFFFFFFELL); v45 = (__m128i *)((char *)v45 + v49); v17 = (__m128i *)((char *)v17 - v49); LABEL_36: v50 = v45->m128i_i32[0]; v45->m128i_i32[0] = v17->m128i_i32[0]; v17->m128i_i32[0] = v50; goto LABEL_14; } v40 = (const __m128i *)((char *)v4 + v16 - 12); do { v41 = _mm_loadu_si128(v40); v42 = _mm_loadu_si128(v14++); --v40; v14[-1] = _mm_shuffle_epi32(v41, 27); v40[1] = _mm_shuffle_epi32(v42, 27); } while ( v14 != &v4[v21 >> 2] ); if ( (v21 & 3) != 0 ) { v43 = v21 & 0xFFFFFFFFFFFFFFFCLL; v44 = 4 * (v21 & 0xFFFFFFFFFFFFFFFCLL); v21 -= v21 & 0xFFFFFFFFFFFFFFFCLL; v45 = (__m128i *)((char *)v4 + v44); v17 = (__m128i *)((char *)v17 - v44); if ( v20 != v43 ) goto LABEL_34; goto LABEL_36; } } else { do { v22 = v14->m128i_i32[0]; v23 = v19->m128i_i32[0]; v14 = (const __m128i *)((char *)v14 + 4); v19 = (const __m128i *)((char *)v19 - 4); v14[-1].m128i_i32[3] = v23; v19->m128i_i32[1] = v22; } while ( v14 < v19 ); } } } LABEL_14: v24 = (__m128i *)v10; if ( v4 >= v10 ) goto LABEL_19; v25 = v4; if ( v11 <= 7 ) { v27 = v10; do { LABEL_18: v28 = v25->m128i_i32[0]; v29 = v27->m128i_i32[0]; v25 = (const __m128i *)((char *)v25 + 4); v27 = (const __m128i *)((char *)v27 - 4); v25[-1].m128i_i32[3] = v29; v27->m128i_i32[1] = v28; } while ( v25 < v27 ); goto LABEL_19; } v26 = (v11 >> 3) + 1; if ( (long long)(4 * v26) > (long long)(v8 - 4 * (v11 >> 3)) ) { v27 = v10; if ( v7 > 0 ) goto LABEL_18; } if ( v11 <= 0x17 ) { v35 = (__m128i *)v4; v34 = 0LL; LABEL_26: v36 = (__m128i *)((char *)v4 + v7 - 8 - v34); v37 = _mm_shuffle_epi32(_mm_loadl_epi64((const __m128i *)((char *)v4 + v34)), 225).m128i_u64[0]; *(long long *)((char *)v4->m128i_i64 + v34) = _mm_shuffle_epi32(_mm_loadl_epi64(v36), 225).m128i_u64[0]; v36->m128i_i64[0] = v37; if ( (v26 & 1) == 0 ) goto LABEL_19; v38 = 4 * (v26 & 0xFFFFFFFFFFFFFFFELL); v35 = (__m128i *)((char *)v35 + v38); v24 = (__m128i *)((char *)v24 - v38); LABEL_28: v39 = v35->m128i_i32[0]; v35->m128i_i32[0] = v24->m128i_i32[0]; v24->m128i_i32[0] = v39; goto LABEL_19; } v30 = v9 - 1; do { v31 = _mm_loadu_si128(v30); v32 = _mm_loadu_si128(v25++); --v30; v25[-1] = _mm_shuffle_epi32(v31, 27); v30[1] = _mm_shuffle_epi32(v32, 27); } while ( v25 != &v4[v26 >> 2] ); if ( (v26 & 3) != 0 ) { v33 = v26 & 0xFFFFFFFFFFFFFFFCLL; v34 = 4 * (v26 & 0xFFFFFFFFFFFFFFFCLL); v26 -= v26 & 0xFFFFFFFFFFFFFFFCLL; v35 = (__m128i *)((char *)v4 + v34); v24 = (__m128i *)((char *)v10 - v34); if ( v11 >> 3 != v33 ) goto LABEL_26; goto LABEL_28; } LABEL_19: v11 -= 4LL; v9 = (const __m128i *)((char *)v9 - 4); v7 = v8; v10 = (const __m128i *)((char *)v10 - 4); if ( v11 == v56 ) { v2 = a1; v5 = v57; v3 = v59; a1[1].m128i_i64[0] = 0LL; v51 = v57; *a1 = 0LL; while ( (unsigned long long)v5 > 0x7FFFFFFFFFFFFFFCLL ) { v5 = std::__throw_bad_array_new_length(); LABEL_51: v51 = v5; } v52 = (_DWORD *)operator new(v5); goto LABEL_41; } v8 -= 4LL; } } a1[1].m128i_i64[0] = 0LL; *a1 = 0LL; if ( v5 ) goto LABEL_51; v51 = 0LL; v52 = 0LL; LABEL_41: v2[1].m128i_i64[0] = (long long)v52 + v51; *v2 = _mm_unpacklo_epi64((__m128i)(unsigned long long)v52, (__m128i)(unsigned long long)v52); v53 = *v3; v54 = (char *)v3[1] - (char *)*v3; if ( v54 <= 4 ) { if ( v54 == 4 ) *v52 = v53->m128i_i32[0]; } else { v52 = memmove(v52, v53, (char *)v3[1] - (char *)*v3); } result = v2; v2->m128i_i64[1] = (long long)v52 + v54; return result; }
func0: ENDBR64 PUSH R15 PUSH R14 PUSH R13 MOV R13,RDI PUSH R12 MOV R12,RSI PUSH RBP PUSH RBX SUB RSP,0x38 MOV RSI,qword ptr [RSI] MOV RAX,qword ptr [R12 + 0x8] SUB RAX,RSI MOV RCX,RAX SAR RCX,0x2 CMP ECX,0x1 JLE 0x001019ff MOVSXD RDX,ECX SUB ECX,0x2 MOV qword ptr [RSP + 0x18],RAX LEA R15,[RSI + 0x4] LEA R9,[RDX*0x4] SUB RDX,RCX MOV qword ptr [RSP + 0x20],R13 MOV qword ptr [RSP + 0x28],R12 LEA RBX,[-0x9 + RDX*0x4] LEA RBP,[R9 + -0x4] MOV qword ptr [RSP + 0x10],RBX LEA RDI,[RSI + R9*0x1] LEA R10,[RSI + RBP*0x1] LEA R11,[R9 + -0x5] NOP dword ptr [RAX] LAB_00101698: CMP R15,RDI JZ 0x00101750 MOV EBX,dword ptr [RSI] MOV RDX,R15 MOV RAX,RSI MOV RCX,RSI NOP dword ptr [RAX] LAB_001016b0: MOV R8D,dword ptr [RDX] CMP R8D,EBX JLE 0x001016be MOV EBX,R8D MOV RCX,RDX LAB_001016be: ADD RDX,0x4 CMP RDI,RDX JNZ 0x001016b0 SUB RCX,RSI SAR RCX,0x2 MOVSXD RCX,ECX SHL RCX,0x2 LEA R8,[RSI + RCX*0x1] LEA RDX,[R8 + 0x4] CMP RSI,RDX JZ 0x00101750 CMP RSI,R8 JNC 0x00101750 LEA R12,[RCX + -0x1] MOV RDX,R8 CMP R12,0x7 JBE 0x00101730 MOV R13,R12 SHR R13,0x3 LEA RBX,[R13 + 0x1] LEA R14,[RBX*0x4] MOV qword ptr [RSP + 0x8],R14 MOV R14,R13 NEG R14 LEA R14,[RCX + R14*0x4] CMP qword ptr [RSP + 0x8],R14 JLE 0x001018a0 LEA R14,[RCX + 0x4] TEST R14,R14 JLE 0x001018a0 NOP LAB_00101730: MOV ECX,dword ptr [RAX] MOV R8D,dword ptr [RDX] ADD RAX,0x4 SUB RDX,0x4 MOV dword ptr [RAX + -0x4],R8D MOV dword ptr [RDX + 0x4],ECX CMP RAX,RDX JC 0x00101730 NOP dword ptr [RAX] LAB_00101750: MOV RCX,R10 CMP RSI,R10 JNC 0x001017b0 MOV RAX,RSI CMP R11,0x7 JBE 0x00101960 MOV R8,R11 SHR R8,0x3 MOV RBX,R8 LEA RDX,[R8 + 0x1] NEG RBX LEA R12,[RDX*0x4] LEA RBX,[RBP + RBX*0x4] CMP R12,RBX JLE 0x001017e0 MOV RBX,R10 TEST R9,R9 JLE 0x001017e0 LAB_00101790: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [RBX] ADD RAX,0x4 SUB RBX,0x4 MOV dword ptr [RAX + -0x4],ECX MOV dword ptr [RBX + 0x4],EDX CMP RAX,RBX JC 0x00101790 NOP word ptr [RAX + RAX*0x1] LAB_001017b0: MOV RAX,qword ptr [RSP + 0x10] SUB R11,0x4 SUB RDI,0x4 MOV R9,RBP SUB R10,0x4 CMP R11,RAX JZ 0x00101970 SUB RBP,0x4 JMP 0x00101698 LAB_001017e0: CMP R11,0x17 JBE 0x00101a19 MOV RBX,RDX LEA RCX,[RDI + -0x10] SHR RBX,0x2 SHL RBX,0x4 ADD RBX,RSI NOP dword ptr [RAX] LAB_00101800: MOVDQU XMM2,xmmword ptr [RCX] MOVDQU XMM0,xmmword ptr [RAX] ADD RAX,0x10 SUB RCX,0x10 PSHUFD XMM1,XMM2,0x1b PSHUFD XMM0,XMM0,0x1b MOVUPS xmmword ptr [RAX + -0x10],XMM1 MOVUPS xmmword ptr [RCX + 0x10],XMM0 CMP RAX,RBX JNZ 0x00101800 TEST DL,0x3 JZ 0x001017b0 MOV R12,RDX MOV RCX,R10 AND R12,-0x4 LEA RBX,[R12*0x4] SUB RDX,R12 LEA RAX,[RSI + RBX*0x1] SUB RCX,RBX CMP R8,R12 JZ 0x00101890 LAB_0010184d: SUB R9,0x8 LEA R8,[RSI + RBX*0x1] SUB R9,RBX MOVQ XMM0,qword ptr [R8] ADD R9,RSI MOVQ XMM1,qword ptr [R9] PSHUFD XMM0,XMM0,0xe1 PSHUFD XMM1,XMM1,0xe1 MOVQ qword ptr [R8],XMM1 MOVQ qword ptr [R9],XMM0 TEST DL,0x1 JZ 0x001017b0 AND RDX,-0x2 SHL RDX,0x2 ADD RAX,RDX SUB RCX,RDX LAB_00101890: MOV EDX,dword ptr [RAX] MOV R8D,dword ptr [RCX] MOV dword ptr [RAX],R8D MOV dword ptr [RCX],EDX JMP 0x001017b0 LAB_001018a0: CMP R12,0x17 JBE 0x00101a23 MOV R12,RBX LEA RDX,[RSI + RCX*0x1 + -0xc] SHR R12,0x2 SHL R12,0x4 ADD R12,RSI NOP dword ptr [RAX] LAB_001018c0: MOVDQU XMM3,xmmword ptr [RDX] MOVDQU XMM0,xmmword ptr [RAX] ADD RAX,0x10 SUB RDX,0x10 PSHUFD XMM1,XMM3,0x1b PSHUFD XMM0,XMM0,0x1b MOVUPS xmmword ptr [RAX + -0x10],XMM1 MOVUPS xmmword ptr [RDX + 0x10],XMM0 CMP RAX,R12 JNZ 0x001018c0 TEST BL,0x3 JZ 0x00101750 MOV R12,RBX AND R12,-0x4 LEA RDX,[R12*0x4] SUB RBX,R12 LEA RAX,[RSI + RDX*0x1] SUB R8,RDX CMP R13,R12 JZ 0x0010194c LAB_0010190e: NOT R12 ADD RDX,RSI LEA RCX,[RCX + R12*0x4] MOVQ XMM0,qword ptr [RDX] ADD RCX,RSI MOVQ XMM1,qword ptr [RCX] PSHUFD XMM0,XMM0,0xe1 PSHUFD XMM1,XMM1,0xe1 MOVQ qword ptr [RDX],XMM1 MOVQ qword ptr [RCX],XMM0 TEST BL,0x1 JZ 0x00101750 AND RBX,-0x2 SHL RBX,0x2 ADD RAX,RBX SUB R8,RBX LAB_0010194c: MOV EDX,dword ptr [RAX] MOV ECX,dword ptr [R8] MOV dword ptr [RAX],ECX MOV dword ptr [R8],EDX JMP 0x00101750 LAB_00101960: MOV RBX,R10 JMP 0x00101790 LAB_00101970: MOV R13,qword ptr [RSP + 0x20] MOV RAX,qword ptr [RSP + 0x18] PXOR XMM0,XMM0 MOV R12,qword ptr [RSP + 0x28] MOV qword ptr [R13 + 0x10],0x0 MOV RBX,RAX MOVUPS xmmword ptr [R13],XMM0 LAB_00101993: MOV RDX,0x7ffffffffffffffc CMP RDX,RAX JC 0x00101a38 MOV RDI,RAX CALL 0x00101130 MOV RCX,RAX LAB_001019b1: MOVQ XMM0,RCX ADD RBX,RCX PUNPCKLQDQ XMM0,XMM0 MOV qword ptr [R13 + 0x10],RBX MOVUPS xmmword ptr [R13],XMM0 MOV RSI,qword ptr [R12] MOV RBX,qword ptr [R12 + 0x8] SUB RBX,RSI CMP RBX,0x4 JLE 0x00101a30 MOV RDI,RCX MOV RDX,RBX CALL 0x00101160 MOV RCX,RAX LAB_001019e6: ADD RCX,RBX MOV RAX,R13 MOV qword ptr [R13 + 0x8],RCX ADD RSP,0x38 POP RBX POP RBP POP R12 POP R13 POP R14 POP R15 RET LAB_001019ff: PXOR XMM0,XMM0 MOV qword ptr [RDI + 0x10],0x0 MOVUPS xmmword ptr [RDI],XMM0 TEST RAX,RAX JNZ 0x00101a3d XOR EBX,EBX XOR ECX,ECX JMP 0x001019b1 LAB_00101a19: MOV RAX,RSI XOR EBX,EBX JMP 0x0010184d LAB_00101a23: MOV RAX,RSI XOR R12D,R12D XOR EDX,EDX JMP 0x0010190e LAB_00101a30: JNZ 0x001019e6 MOV EAX,dword ptr [RSI] MOV dword ptr [RCX],EAX JMP 0x001019e6 LAB_00101a38: CALL 0x00101110 LAB_00101a3d: MOV RBX,RAX JMP 0x00101993
/* func0(std::vector<int, std::allocator<int> >&) */ vector * func0(vector *param_1) { int8 uVar1; int8 uVar2; int *piVar3; int4 *__src; int iVar4; int iVar5; int iVar6; int iVar7; int iVar8; int iVar9; ulong uVar10; int *piVar11; int *piVar12; int4 *__dest; int iVar13; long lVar14; long lVar15; long lVar16; int *piVar17; ulong uVar18; int *piVar19; int8 *puVar20; int iVar21; size_t __n; int8 *in_RSI; int *piVar22; ulong uVar23; long lVar24; int8 *puVar25; int *piVar26; ulong uVar27; ulong uVar28; piVar3 = (int *)*in_RSI; uVar10 = in_RSI[1] - (long)piVar3; iVar13 = (int)((long)uVar10 >> 2); if (iVar13 < 2) { *(int8 *)(param_1 + 0x10) = 0; *(int (*) [16])param_1 = (int [16])0x0; if (uVar10 == 0) { uVar10 = 0; __dest = (int4 *)0x0; goto LAB_001019b1; } } else { lVar16 = (long)iVar13; piVar22 = piVar3 + lVar16; piVar26 = piVar3 + lVar16 + -1; uVar27 = lVar16 * 4 - 5; lVar24 = lVar16 * 4; do { if (piVar3 + 1 != piVar22) { iVar21 = *piVar3; piVar11 = piVar3; piVar12 = piVar3 + 1; do { if (iVar21 < *piVar12) { piVar11 = piVar12; iVar21 = *piVar12; } piVar12 = piVar12 + 1; } while (piVar22 != piVar12); lVar14 = (long)(int)((long)piVar11 - (long)piVar3 >> 2); lVar15 = lVar14 * 4; piVar11 = piVar3 + lVar14; if ((piVar3 != piVar11 + 1) && (piVar3 < piVar11)) { uVar18 = lVar15 - 1; piVar12 = piVar3; if (7 < uVar18) { uVar28 = uVar18 >> 3; uVar23 = uVar28 + 1; if (((long)(uVar23 * 4) <= (long)(lVar15 + uVar28 * -4)) || (lVar15 == -4 || lVar15 + 4 < 0)) { if (uVar18 < 0x18) { uVar18 = 0; lVar15 = 0; LAB_0010190e: puVar20 = (int8 *)(lVar15 + (long)piVar3); uVar1 = *puVar20; piVar19 = piVar3 + ~uVar18 + lVar14; uVar2 = *(int8 *)piVar19; *(int *)puVar20 = (int)((ulong)uVar2 >> 0x20); *(int *)((long)puVar20 + 4) = (int)uVar2; *piVar19 = (int)((ulong)uVar1 >> 0x20); piVar19[1] = (int)uVar1; if ((uVar23 & 1) == 0) goto LAB_00101750; piVar12 = piVar12 + (uVar23 & 0xfffffffffffffffe); piVar11 = piVar11 + -(uVar23 & 0xfffffffffffffffe); } else { piVar19 = piVar3 + lVar14 + -3; do { iVar21 = *piVar19; iVar4 = piVar19[1]; iVar5 = piVar19[2]; iVar6 = *piVar12; iVar7 = piVar12[1]; iVar8 = piVar12[2]; iVar9 = piVar12[3]; piVar17 = piVar12 + 4; *piVar12 = piVar19[3]; piVar12[1] = iVar5; piVar12[2] = iVar4; piVar12[3] = iVar21; *piVar19 = iVar9; piVar19[1] = iVar8; piVar19[2] = iVar7; piVar19[3] = iVar6; piVar12 = piVar17; piVar19 = piVar19 + -4; } while (piVar17 != piVar3 + (uVar23 & 0xfffffffffffffffc)); if ((uVar23 & 3) == 0) goto LAB_00101750; uVar18 = uVar23 & 0xfffffffffffffffc; lVar15 = uVar18 * 4; uVar23 = uVar23 - uVar18; piVar12 = piVar3 + uVar18; piVar11 = piVar11 + -uVar18; if (uVar28 != uVar18) goto LAB_0010190e; } iVar21 = *piVar12; *piVar12 = *piVar11; *piVar11 = iVar21; goto LAB_00101750; } } do { iVar21 = *piVar12; piVar19 = piVar12 + 1; piVar17 = piVar11 + -1; *piVar12 = *piVar11; *piVar11 = iVar21; piVar12 = piVar19; piVar11 = piVar17; } while (piVar19 < piVar17); } } LAB_00101750: if (piVar3 < piVar26) { piVar11 = piVar3; piVar12 = piVar26; if (7 < uVar27) { uVar23 = uVar27 >> 3; uVar18 = uVar23 + 1; lVar14 = lVar24 + -4 + uVar23 * -4; if ((uVar18 * 4 - lVar14 == 0 || (long)(uVar18 * 4) < lVar14) || (lVar24 < 1)) { if (uVar27 < 0x18) { lVar14 = 0; LAB_0010184d: puVar20 = (int8 *)((long)piVar3 + lVar14); uVar1 = *puVar20; puVar25 = (int8 *)(((lVar24 + -8) - lVar14) + (long)piVar3); uVar2 = *puVar25; *(int *)puVar20 = (int)((ulong)uVar2 >> 0x20); *(int *)((long)puVar20 + 4) = (int)uVar2; *(int *)puVar25 = (int)((ulong)uVar1 >> 0x20); *(int *)((long)puVar25 + 4) = (int)uVar1; if ((uVar18 & 1) == 0) goto LAB_001017b0; piVar11 = piVar11 + (uVar18 & 0xfffffffffffffffe); piVar12 = piVar12 + -(uVar18 & 0xfffffffffffffffe); } else { piVar12 = piVar3; piVar11 = piVar22; do { piVar17 = piVar11 + -4; iVar21 = *piVar17; iVar4 = piVar11[-3]; iVar5 = piVar11[-2]; iVar6 = *piVar12; iVar7 = piVar12[1]; iVar8 = piVar12[2]; iVar9 = piVar12[3]; piVar19 = piVar12 + 4; *piVar12 = piVar11[-1]; piVar12[1] = iVar5; piVar12[2] = iVar4; piVar12[3] = iVar21; *piVar17 = iVar9; piVar11[-3] = iVar8; piVar11[-2] = iVar7; piVar11[-1] = iVar6; piVar12 = piVar19; piVar11 = piVar17; } while (piVar19 != piVar3 + (uVar18 & 0xfffffffffffffffc)); if ((uVar18 & 3) == 0) goto LAB_001017b0; uVar28 = uVar18 & 0xfffffffffffffffc; lVar14 = uVar28 * 4; uVar18 = uVar18 - uVar28; piVar11 = piVar3 + uVar28; piVar12 = piVar26 + -uVar28; if (uVar23 != uVar28) goto LAB_0010184d; } iVar21 = *piVar11; *piVar11 = *piVar12; *piVar12 = iVar21; goto LAB_001017b0; } } do { iVar21 = *piVar11; piVar19 = piVar11 + 1; piVar17 = piVar12 + -1; *piVar11 = *piVar12; *piVar12 = iVar21; piVar11 = piVar19; piVar12 = piVar17; } while (piVar19 < piVar17); } LAB_001017b0: uVar27 = uVar27 - 4; piVar22 = piVar22 + -1; piVar26 = piVar26 + -1; lVar24 = lVar24 + -4; } while (uVar27 != (lVar16 - (ulong)(iVar13 - 2)) * 4 - 9); *(int8 *)(param_1 + 0x10) = 0; *(int (*) [16])param_1 = (int [16])0x0; } while (0x7ffffffffffffffc < uVar10) { uVar10 = std::__throw_bad_array_new_length(); } __dest = (int4 *)operator_new(uVar10); LAB_001019b1: *(ulong *)(param_1 + 0x10) = uVar10 + (long)__dest; *(int4 **)param_1 = __dest; *(int4 **)(param_1 + 8) = __dest; __src = (int4 *)*in_RSI; __n = in_RSI[1] - (long)__src; if ((long)__n < 5) { if (__n == 4) { *__dest = *__src; } } else { __dest = (int4 *)memmove(__dest,__src,__n); } *(size_t *)(param_1 + 8) = (long)__dest + __n; return param_1; }
564
func0
#include <vector> #include <assert.h>
int func0(const std::vector<int>& list1, const std::vector<int>& list2, const std::vector<int>& list3) { int result = 0; for (size_t i = 0; i < list1.size(); ++i) { if (list1[i] == list2[i] && list2[i] == list3[i]) { result++; } } return result; }
int main() { assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,9},{2,1,3,1,2,6,7,9}) == 3); assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 4); assert(func0({1,2,3,4,2,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 5); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&): endbr64 push %rbp mov %rsp,%rbp push %rbx sub $0x38,%rsp mov %rdi,-0x28(%rbp) mov %rsi,-0x30(%rbp) mov %rdx,-0x38(%rbp) movl $0x0,-0x1c(%rbp) movq $0x0,-0x18(%rbp) mov -0x28(%rbp),%rax mov %rax,%rdi callq 1bae <_ZNKSt6vectorIiSaIiEE4sizeEv> cmp %rax,-0x18(%rbp) setb %al test %al,%al je 12e2 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0xb9> mov -0x18(%rbp),%rdx mov -0x28(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1bd6 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%ebx mov -0x18(%rbp),%rdx mov -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1bd6 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%eax cmp %eax,%ebx jne 12cb <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0xa2> mov -0x18(%rbp),%rdx mov -0x30(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1bd6 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%ebx mov -0x18(%rbp),%rdx mov -0x38(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1bd6 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%eax cmp %eax,%ebx jne 12cb <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0xa2> mov $0x1,%eax jmp 12d0 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0xa7> mov $0x0,%eax test %al,%al je 12d8 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0xaf> addl $0x1,-0x1c(%rbp) addq $0x1,-0x18(%rbp) jmpq 1251 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x28> mov -0x1c(%rbp),%eax add $0x38,%rsp pop %rbx pop %rbp retq
_Z5func0RKSt6vectorIiSaIiEES3_S3_: endbr64 push rbp mov rbp, rsp push rbx sub rsp, 38h mov [rbp+var_28], rdi mov [rbp+var_30], rsi mov [rbp+var_38], rdx mov [rbp+var_1C], 0 mov [rbp+var_18], 0 jmp short loc_12E8 loc_1273: mov rdx, [rbp+var_18] mov rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] mov rdx, [rbp+var_18] mov rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] cmp ebx, eax jnz short loc_12D6 mov rdx, [rbp+var_18] mov rax, [rbp+var_30] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov ebx, [rax] mov rdx, [rbp+var_18] mov rax, [rbp+var_38] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] cmp ebx, eax jnz short loc_12D6 mov eax, 1 jmp short loc_12DB loc_12D6: mov eax, 0 loc_12DB: test al, al jz short loc_12E3 add [rbp+var_1C], 1 loc_12E3: add [rbp+var_18], 1 loc_12E8: mov rax, [rbp+var_28] mov rdi, rax call _ZNKSt6vectorIiSaIiEE4sizeEv; std::vector<int>::size(void) cmp [rbp+var_18], rax setb al test al, al jnz loc_1273 mov eax, [rbp+var_1C] mov rbx, [rbp+var_8] leave retn
long long func0(long long a1, long long a2, long long a3) { unsigned long long i; // rax int v4; // ebx int v5; // ebx unsigned int v9; // [rsp+24h] [rbp-1Ch] unsigned long long v10; // [rsp+28h] [rbp-18h] v9 = 0; v10 = 0LL; for ( i = std::vector<int>::size(a1); v10 < i; i = std::vector<int>::size(a1) ) { v4 = *(_DWORD *)std::vector<int>::operator[](a1, v10); if ( v4 == *(_DWORD *)std::vector<int>::operator[](a2, v10) ) { v5 = *(_DWORD *)std::vector<int>::operator[](a2, v10); if ( v5 == *(_DWORD *)std::vector<int>::operator[](a3, v10) ) ++v9; } ++v10; } return v9; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH RBX SUB RSP,0x38 MOV qword ptr [RBP + -0x28],RDI MOV qword ptr [RBP + -0x30],RSI MOV qword ptr [RBP + -0x38],RDX MOV dword ptr [RBP + -0x1c],0x0 MOV qword ptr [RBP + -0x18],0x0 JMP 0x001012e8 LAB_00101273: MOV RDX,qword ptr [RBP + -0x18] MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RDX MOV RDI,RAX CALL 0x00101c56 MOV EBX,dword ptr [RAX] MOV RDX,qword ptr [RBP + -0x18] MOV RAX,qword ptr [RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101c56 MOV EAX,dword ptr [RAX] CMP EBX,EAX JNZ 0x001012d6 MOV RDX,qword ptr [RBP + -0x18] MOV RAX,qword ptr [RBP + -0x30] MOV RSI,RDX MOV RDI,RAX CALL 0x00101c56 MOV EBX,dword ptr [RAX] MOV RDX,qword ptr [RBP + -0x18] MOV RAX,qword ptr [RBP + -0x38] MOV RSI,RDX MOV RDI,RAX CALL 0x00101c56 MOV EAX,dword ptr [RAX] CMP EBX,EAX JNZ 0x001012d6 MOV EAX,0x1 JMP 0x001012db LAB_001012d6: MOV EAX,0x0 LAB_001012db: TEST AL,AL JZ 0x001012e3 ADD dword ptr [RBP + -0x1c],0x1 LAB_001012e3: ADD qword ptr [RBP + -0x18],0x1 LAB_001012e8: MOV RAX,qword ptr [RBP + -0x28] MOV RDI,RAX CALL 0x00101c2e CMP qword ptr [RBP + -0x18],RAX SETC AL TEST AL,AL JNZ 0x00101273 MOV EAX,dword ptr [RBP + -0x1c] MOV RBX,qword ptr [RBP + -0x8] LEAVE RET
/* func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1,vector *param_2,vector *param_3) { int iVar1; bool bVar2; int *piVar3; ulong uVar4; int4 local_24; int8 local_20; local_24 = 0; local_20 = 0; do { uVar4 = std::vector<int,std::allocator<int>>::size((vector<int,std::allocator<int>> *)param_1); if (uVar4 <= local_20) { return local_24; } piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_1,local_20); iVar1 = *piVar3; piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_2,local_20); if (iVar1 == *piVar3) { piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_2,local_20); iVar1 = *piVar3; piVar3 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_3,local_20); if (iVar1 != *piVar3) goto LAB_001012d6; bVar2 = true; } else { LAB_001012d6: bVar2 = false; } if (bVar2) { local_24 = local_24 + 1; } local_20 = local_20 + 1; } while( true ); }
565
func0
#include <vector> #include <assert.h>
int func0(const std::vector<int>& list1, const std::vector<int>& list2, const std::vector<int>& list3) { int result = 0; for (size_t i = 0; i < list1.size(); ++i) { if (list1[i] == list2[i] && list2[i] == list3[i]) { result++; } } return result; }
int main() { assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,9},{2,1,3,1,2,6,7,9}) == 3); assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 4); assert(func0({1,2,3,4,2,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 5); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&): endbr64 mov %rsi,%rax mov (%rdi),%r8 mov 0x8(%rdi),%rsi sub %r8,%rsi mov %rsi,%rdi shr $0x2,%rdi je 1257 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x4e> mov (%rax),%rdi mov $0x0,%eax mov $0x0,%r9d jmp 123c <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x33> add $0x4,%rax cmp %rax,%rsi je 125d <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x54> mov (%rdi,%rax,1),%ecx cmp %ecx,(%r8,%rax,1) jne 1233 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x2a> mov (%rdx),%r10 cmp (%r10,%rax,1),%ecx sete %cl movzbl %cl,%ecx add %ecx,%r9d jmp 1233 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x2a> mov $0x0,%r9d mov %r9d,%eax retq
_Z5func0RKSt6vectorIiSaIiEES3_S3_: endbr64 mov rax, [rdi+8] mov rdi, [rdi] mov r8, rax sub r8, rdi sar r8, 2 cmp rax, rdi jz short loc_1253 mov rsi, [rsi] mov eax, 0 mov r10d, 0 jmp short loc_123C loc_1233: add rax, 1 cmp rax, r8 jnb short loc_1259 loc_123C: mov ecx, [rsi+rax*4] cmp [rdi+rax*4], ecx jnz short loc_1233 mov r9, [rdx] cmp ecx, [r9+rax*4] jnz short loc_1233 add r10d, 1 jmp short loc_1233 loc_1253: mov r10d, 0 loc_1259: mov eax, r10d retn
long long func0(long long *a1, long long *a2, _QWORD *a3) { long long v3; // rax long long v4; // rdi unsigned long long v5; // r8 long long v6; // rsi unsigned long long v7; // rax unsigned int v8; // r10d int v9; // ecx v3 = a1[1]; v4 = *a1; v5 = (v3 - v4) >> 2; if ( v3 == v4 ) { return 0; } else { v6 = *a2; v7 = 0LL; v8 = 0; do { v9 = *(_DWORD *)(v6 + 4 * v7); if ( *(_DWORD *)(v4 + 4 * v7) == v9 && v9 == *(_DWORD *)(*a3 + 4 * v7) ) ++v8; ++v7; } while ( v7 < v5 ); } return v8; }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] MOV RDI,qword ptr [RDI] MOV R8,RAX SUB R8,RDI SAR R8,0x2 CMP RAX,RDI JZ 0x00101253 MOV RSI,qword ptr [RSI] MOV EAX,0x0 MOV R10D,0x0 JMP 0x0010123c LAB_00101233: ADD RAX,0x1 CMP RAX,R8 JNC 0x00101259 LAB_0010123c: MOV ECX,dword ptr [RSI + RAX*0x4] CMP dword ptr [RDI + RAX*0x4],ECX JNZ 0x00101233 MOV R9,qword ptr [RDX] CMP ECX,dword ptr [R9 + RAX*0x4] JNZ 0x00101233 ADD R10D,0x1 JMP 0x00101233 LAB_00101253: MOV R10D,0x0 LAB_00101259: MOV EAX,R10D RET
/* func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1,vector *param_2,vector *param_3) { int iVar1; long lVar2; ulong uVar3; int iVar4; lVar2 = *(long *)param_1; if (*(long *)(param_1 + 8) == lVar2) { iVar4 = 0; } else { uVar3 = 0; iVar4 = 0; do { iVar1 = *(int *)(*(long *)param_2 + uVar3 * 4); if ((*(int *)(lVar2 + uVar3 * 4) == iVar1) && (iVar1 == *(int *)(*(long *)param_3 + uVar3 * 4))) { iVar4 = iVar4 + 1; } uVar3 = uVar3 + 1; } while (uVar3 < (ulong)(*(long *)(param_1 + 8) - lVar2 >> 2)); } return iVar4; }
566
func0
#include <vector> #include <assert.h>
int func0(const std::vector<int>& list1, const std::vector<int>& list2, const std::vector<int>& list3) { int result = 0; for (size_t i = 0; i < list1.size(); ++i) { if (list1[i] == list2[i] && list2[i] == list3[i]) { result++; } } return result; }
int main() { assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,9},{2,1,3,1,2,6,7,9}) == 3); assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 4); assert(func0({1,2,3,4,2,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 5); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&): endbr64 mov (%rdi),%r8 mov 0x8(%rdi),%rdi sub %r8,%rdi mov %rdi,%rax shr $0x2,%rax je 1890 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x50> mov (%rsi),%rsi xor %eax,%eax xor %r9d,%r9d mov (%rsi,%rax,1),%ecx cmp %ecx,(%r8,%rax,1) jne 1879 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x39> mov (%rdx),%r10 cmp (%r10,%rax,1),%ecx sete %cl movzbl %cl,%ecx add %ecx,%r9d add $0x4,%rax cmp %rdi,%rax jne 1860 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x20> mov %r9d,%eax retq nopw %cs:0x0(%rax,%rax,1) xor %r9d,%r9d mov %r9d,%eax retq nopw 0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIiSaIiEES3_S3_: endbr64 mov rax, [rdi+8] mov rdi, [rdi] mov r8, rax sub r8, rdi sar r8, 2 cmp rax, rdi jz short loc_1658 mov rsi, [rsi] xor eax, eax xor r10d, r10d jmp short loc_1631 loc_1628: add rax, 1 cmp rax, r8 jnb short loc_164F loc_1631: mov ecx, [rsi+rax*4] cmp [rdi+rax*4], ecx jnz short loc_1628 mov r9, [rdx] cmp ecx, [r9+rax*4] jnz short loc_1628 add rax, 1 add r10d, 1 cmp rax, r8 jb short loc_1631 loc_164F: mov eax, r10d retn loc_1658: xor r10d, r10d mov eax, r10d retn
long long func0(long long *a1, long long *a2, _QWORD *a3) { long long v3; // rax long long v4; // rdi unsigned long long v5; // r8 long long v6; // rsi unsigned long long v7; // rax unsigned int v8; // r10d int v9; // ecx v3 = a1[1]; v4 = *a1; v5 = (v3 - v4) >> 2; if ( v3 == v4 ) return 0LL; v6 = *a2; v7 = 0LL; v8 = 0; do { while ( 1 ) { v9 = *(_DWORD *)(v6 + 4 * v7); if ( *(_DWORD *)(v4 + 4 * v7) == v9 && v9 == *(_DWORD *)(*a3 + 4 * v7) ) break; if ( ++v7 >= v5 ) return v8; } ++v7; ++v8; } while ( v7 < v5 ); return v8; }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] MOV RDI,qword ptr [RDI] MOV R8,RAX SUB R8,RDI SAR R8,0x2 CMP RAX,RDI JZ 0x00101658 MOV RSI,qword ptr [RSI] XOR EAX,EAX XOR R10D,R10D JMP 0x00101631 LAB_00101628: ADD RAX,0x1 CMP RAX,R8 JNC 0x0010164f LAB_00101631: MOV ECX,dword ptr [RSI + RAX*0x4] CMP dword ptr [RDI + RAX*0x4],ECX JNZ 0x00101628 MOV R9,qword ptr [RDX] CMP ECX,dword ptr [R9 + RAX*0x4] JNZ 0x00101628 ADD RAX,0x1 ADD R10D,0x1 CMP RAX,R8 JC 0x00101631 LAB_0010164f: MOV EAX,R10D RET LAB_00101658: XOR R10D,R10D MOV EAX,R10D RET
/* func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1,vector *param_2,vector *param_3) { int iVar1; long lVar2; ulong uVar3; ulong uVar4; int iVar5; lVar2 = *(long *)param_1; uVar4 = *(long *)(param_1 + 8) - lVar2 >> 2; if (*(long *)(param_1 + 8) == lVar2) { return 0; } uVar3 = 0; iVar5 = 0; do { while ((iVar1 = *(int *)(*(long *)param_2 + uVar3 * 4), *(int *)(lVar2 + uVar3 * 4) == iVar1 && (iVar1 == *(int *)(*(long *)param_3 + uVar3 * 4)))) { uVar3 = uVar3 + 1; iVar5 = iVar5 + 1; if (uVar4 <= uVar3) { return iVar5; } } uVar3 = uVar3 + 1; } while (uVar3 < uVar4); return iVar5; }
567
func0
#include <vector> #include <assert.h>
int func0(const std::vector<int>& list1, const std::vector<int>& list2, const std::vector<int>& list3) { int result = 0; for (size_t i = 0; i < list1.size(); ++i) { if (list1[i] == list2[i] && list2[i] == list3[i]) { result++; } } return result; }
int main() { assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,9},{2,1,3,1,2,6,7,9}) == 3); assert(func0({1,2,3,4,5,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 4); assert(func0({1,2,3,4,2,6,7,8},{2,2,3,1,2,6,7,8},{2,1,3,1,2,6,7,8}) == 5); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&): endbr64 mov (%rdi),%r8 mov 0x8(%rdi),%rdi sub %r8,%rdi mov %rdi,%rax shr $0x2,%rax je 17b0 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x50> mov (%rsi),%rsi xor %eax,%eax xor %r9d,%r9d mov (%rsi,%rax,1),%ecx cmp %ecx,(%r8,%rax,1) jne 1799 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x39> mov (%rdx),%r10 cmp (%r10,%rax,1),%ecx sete %cl movzbl %cl,%ecx add %ecx,%r9d add $0x4,%rax cmp %rax,%rdi jne 1780 <_Z5func0RKSt6vectorIiSaIiEES3_S3_+0x20> mov %r9d,%eax retq nopw %cs:0x0(%rax,%rax,1) xor %r9d,%r9d mov %r9d,%eax retq nopw 0x0(%rax,%rax,1)
_Z5func0RKSt6vectorIiSaIiEES3_S3_: endbr64 mov rax, [rdi+8] mov rdi, [rdi] mov r8, rax sub r8, rdi sar r8, 2 cmp rax, rdi jz short loc_1748 mov rsi, [rsi] xor eax, eax xor r10d, r10d jmp short loc_1721 loc_1718: add rax, 1 cmp rax, r8 jnb short loc_173F loc_1721: mov ecx, [rsi+rax*4] cmp [rdi+rax*4], ecx jnz short loc_1718 mov r9, [rdx] cmp ecx, [r9+rax*4] jnz short loc_1718 add rax, 1 add r10d, 1 cmp rax, r8 jb short loc_1721 loc_173F: mov eax, r10d retn loc_1748: xor r10d, r10d mov eax, r10d retn
long long func0(long long *a1, long long *a2, _QWORD *a3) { long long v3; // rax long long v4; // rdi unsigned long long v5; // r8 long long v6; // rsi unsigned long long v7; // rax unsigned int v8; // r10d int v9; // ecx v3 = a1[1]; v4 = *a1; v5 = (v3 - v4) >> 2; if ( v3 == v4 ) return 0LL; v6 = *a2; v7 = 0LL; v8 = 0; do { while ( 1 ) { v9 = *(_DWORD *)(v6 + 4 * v7); if ( *(_DWORD *)(v4 + 4 * v7) == v9 && v9 == *(_DWORD *)(*a3 + 4 * v7) ) break; if ( ++v7 >= v5 ) return v8; } ++v7; ++v8; } while ( v7 < v5 ); return v8; }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] MOV RDI,qword ptr [RDI] MOV R8,RAX SUB R8,RDI SAR R8,0x2 CMP RAX,RDI JZ 0x00101748 MOV RSI,qword ptr [RSI] XOR EAX,EAX XOR R10D,R10D JMP 0x00101721 LAB_00101718: ADD RAX,0x1 CMP RAX,R8 JNC 0x0010173f LAB_00101721: MOV ECX,dword ptr [RSI + RAX*0x4] CMP dword ptr [RDI + RAX*0x4],ECX JNZ 0x00101718 MOV R9,qword ptr [RDX] CMP ECX,dword ptr [R9 + RAX*0x4] JNZ 0x00101718 ADD RAX,0x1 ADD R10D,0x1 CMP RAX,R8 JC 0x00101721 LAB_0010173f: MOV EAX,R10D RET LAB_00101748: XOR R10D,R10D MOV EAX,R10D RET
/* func0(std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&) */ int func0(vector *param_1,vector *param_2,vector *param_3) { int iVar1; long lVar2; ulong uVar3; ulong uVar4; int iVar5; lVar2 = *(long *)param_1; uVar4 = *(long *)(param_1 + 8) - lVar2 >> 2; if (*(long *)(param_1 + 8) == lVar2) { return 0; } uVar3 = 0; iVar5 = 0; do { while ((iVar1 = *(int *)(*(long *)param_2 + uVar3 * 4), *(int *)(lVar2 + uVar3 * 4) == iVar1 && (iVar1 == *(int *)(*(long *)param_3 + uVar3 * 4)))) { uVar3 = uVar3 + 1; iVar5 = iVar5 + 1; if (uVar4 <= uVar3) { return iVar5; } } uVar3 = uVar3 + 1; } while (uVar3 < uVar4); return iVar5; }
568
func0
#include <iostream> #include <assert.h> #include <vector>
int func0(std::vector<std::vector<int>> Input) { return Input.size(); }
int main() { assert(func0({{1, 2, 3, 4}, {5, 6, 7, 8}}) == 2); assert(func0({{1, 2}, {3, 4}, {5, 6}}) == 3); assert(func0({{9, 8, 7, 6, 5, 4, 3, 2, 1}}) == 1); return 0; }
O0
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %rdi,-0x8(%rbp) mov -0x8(%rbp),%rax mov %rax,%rdi callq 1ab4 <_ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv> leaveq retq
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov [rbp+var_8], rdi mov rax, [rbp+var_8] mov rdi, rax call _ZNKSt6vectorIS_IiSaIiEESaIS1_EE4sizeEv; std::vector<std::vector<int>>::size(void) leave retn
long long func0(long long a1) { return std::vector<std::vector<int>>::size(a1); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV qword ptr [RBP + -0x8],RDI MOV RAX,qword ptr [RBP + -0x8] MOV RDI,RAX CALL 0x00101ad0 LEAVE RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ void func0(vector param_1) { int4 in_register_0000003c; std:: vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> ::size((vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *)CONCAT44(in_register_0000003c,param_1)); return; }
569
func0
#include <iostream> #include <assert.h> #include <vector>
int func0(std::vector<std::vector<int>> Input) { return Input.size(); }
int main() { assert(func0({{1, 2, 3, 4}, {5, 6, 7, 8}}) == 2); assert(func0({{1, 2}, {3, 4}, {5, 6}}) == 3); assert(func0({{9, 8, 7, 6, 5, 4, 3, 2, 1}}) == 1); return 0; }
O1
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 mov 0x8(%rdi),%rax sub (%rdi),%rax sar $0x3,%rax movabs $0xaaaaaaaaaaaaaaab,%rdx imul %rdx,%rax retq
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 mov rax, [rdi+8] sub rax, [rdi] sar rax, 3 imul eax, 0AAAAAAABh retn
long long func0(_QWORD *a1) { return -1431655765 * (unsigned int)((long long)(a1[1] - *a1) >> 3); }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] SUB RAX,qword ptr [RDI] SAR RAX,0x3 IMUL EAX,EAX,-0x55555555 RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ int func0(vector param_1) { int4 in_register_0000003c; return (int)(*(long *)(CONCAT44(in_register_0000003c,param_1) + 8) - *(long *)CONCAT44(in_register_0000003c,param_1) >> 3) * -0x55555555; }
570
func0
#include <iostream> #include <assert.h> #include <vector>
int func0(std::vector<std::vector<int>> Input) { return Input.size(); }
int main() { assert(func0({{1, 2, 3, 4}, {5, 6, 7, 8}}) == 2); assert(func0({{1, 2}, {3, 4}, {5, 6}}) == 3); assert(func0({{9, 8, 7, 6, 5, 4, 3, 2, 1}}) == 1); return 0; }
O2
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 movabs $0xaaaaaaaaaaaaaaab,%rdx mov 0x8(%rdi),%rax sub (%rdi),%rax sar $0x3,%rax imul %rdx,%rax retq xchg %ax,%ax
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 mov rax, [rdi+8] sub rax, [rdi] sar rax, 3 imul eax, 0AAAAAAABh retn
long long func0(_QWORD *a1) { return -1431655765 * (unsigned int)((long long)(a1[1] - *a1) >> 3); }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] SUB RAX,qword ptr [RDI] SAR RAX,0x3 IMUL EAX,EAX,-0x55555555 RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ int func0(vector param_1) { int4 in_register_0000003c; return (int)(*(long *)(CONCAT44(in_register_0000003c,param_1) + 8) - *(long *)CONCAT44(in_register_0000003c,param_1) >> 3) * -0x55555555; }
571
func0
#include <iostream> #include <assert.h> #include <vector>
int func0(std::vector<std::vector<int>> Input) { return Input.size(); }
int main() { assert(func0({{1, 2, 3, 4}, {5, 6, 7, 8}}) == 2); assert(func0({{1, 2}, {3, 4}, {5, 6}}) == 3); assert(func0({{9, 8, 7, 6, 5, 4, 3, 2, 1}}) == 1); return 0; }
O3
cpp
func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >): endbr64 movabs $0xaaaaaaaaaaaaaaab,%rdx mov 0x8(%rdi),%rax sub (%rdi),%rax sar $0x3,%rax imul %rdx,%rax retq xchg %ax,%ax
_Z5func0St6vectorIS_IiSaIiEESaIS1_EE: endbr64 mov rax, [rdi+8] sub rax, [rdi] sar rax, 3 imul eax, 0AAAAAAABh retn
long long func0(_QWORD *a1) { return -1431655765 * (unsigned int)((long long)(a1[1] - *a1) >> 3); }
func0: ENDBR64 MOV RAX,qword ptr [RDI + 0x8] SUB RAX,qword ptr [RDI] SAR RAX,0x3 IMUL EAX,EAX,-0x55555555 RET
/* func0(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >) */ int func0(vector param_1) { int4 in_register_0000003c; return (int)(*(long *)(CONCAT44(in_register_0000003c,param_1) + 8) - *(long *)CONCAT44(in_register_0000003c,param_1) >> 3) * -0x55555555; }
572
func0
#include <iostream> #include <vector> #include <assert.h>
int func0(const std::vector<int>& arr, int n) { int sum = 0; for (int i = n - 1; i >= 0; --i) { sum += i * arr[i] - (n - 1 - i) * arr[i]; } return sum; }
int main() { assert(func0({1, 8, 9, 15, 16}, 5) == 74); assert(func0({1, 2, 3, 4}, 4) == 10); assert(func0({1, 2, 3, 4, 5, 7, 9, 11, 14}, 9) == 188); return 0; }
O0
cpp
func0(std::vector<int, std::allocator<int> > const&, int): endbr64 push %rbp mov %rsp,%rbp push %r12 push %rbx sub $0x20,%rsp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) movl $0x0,-0x18(%rbp) mov -0x2c(%rbp),%eax sub $0x1,%eax mov %eax,-0x14(%rbp) cmpl $0x0,-0x14(%rbp) js 12e6 <_Z5func0RKSt6vectorIiSaIiEEi+0x7d> mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1656 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%eax imul -0x14(%rbp),%eax mov %eax,%ebx mov -0x2c(%rbp),%eax sub $0x1,%eax sub -0x14(%rbp),%eax mov %eax,%r12d mov -0x14(%rbp),%eax movslq %eax,%rdx mov -0x28(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 1656 <_ZNKSt6vectorIiSaIiEEixEm> mov (%rax),%eax imul %r12d,%eax sub %eax,%ebx mov %ebx,%eax add %eax,-0x18(%rbp) subl $0x1,-0x14(%rbp) jmp 128f <_Z5func0RKSt6vectorIiSaIiEEi+0x26> mov -0x18(%rbp),%eax add $0x20,%rsp pop %rbx pop %r12 pop %rbp retq
_Z5func0RKSt6vectorIiSaIiEEi: endbr64 push rbp mov rbp, rsp push r12 push rbx sub rsp, 20h mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov [rbp+var_18], 0 mov eax, [rbp+var_2C] sub eax, 1 mov [rbp+var_14], eax jmp short loc_12C0 loc_1271: mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] imul eax, [rbp+var_14] mov r12d, eax mov eax, [rbp+var_2C] sub eax, 1 sub eax, [rbp+var_14] mov ebx, eax mov eax, [rbp+var_14] movsxd rdx, eax mov rax, [rbp+var_28] mov rsi, rdx mov rdi, rax call _ZNKSt6vectorIiSaIiEEixEm; std::vector<int>::operator[](ulong) mov eax, [rax] imul eax, ebx mov edx, r12d sub edx, eax add [rbp+var_18], edx sub [rbp+var_14], 1 loc_12C0: cmp [rbp+var_14], 0 jns short loc_1271 mov eax, [rbp+var_18] add rsp, 20h pop rbx pop r12 pop rbp retn
long long func0(long long a1, int a2) { int v2; // r12d unsigned int v4; // [rsp+18h] [rbp-18h] int i; // [rsp+1Ch] [rbp-14h] v4 = 0; for ( i = a2 - 1; i >= 0; --i ) { v2 = i * *(_DWORD *)std::vector<int>::operator[](a1, i); v4 += v2 - (a2 - 1 - i) * *(_DWORD *)std::vector<int>::operator[](a1, i); } return v4; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP PUSH R12 PUSH RBX SUB RSP,0x20 MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV dword ptr [RBP + -0x18],0x0 MOV EAX,dword ptr [RBP + -0x2c] SUB EAX,0x1 MOV dword ptr [RBP + -0x14],EAX JMP 0x001012c0 LAB_00101271: MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RDX MOV RDI,RAX CALL 0x00101616 MOV EAX,dword ptr [RAX] IMUL EAX,dword ptr [RBP + -0x14] MOV R12D,EAX MOV EAX,dword ptr [RBP + -0x2c] SUB EAX,0x1 SUB EAX,dword ptr [RBP + -0x14] MOV EBX,EAX MOV EAX,dword ptr [RBP + -0x14] MOVSXD RDX,EAX MOV RAX,qword ptr [RBP + -0x28] MOV RSI,RDX MOV RDI,RAX CALL 0x00101616 MOV EAX,dword ptr [RAX] IMUL EAX,EBX MOV EDX,R12D SUB EDX,EAX ADD dword ptr [RBP + -0x18],EDX SUB dword ptr [RBP + -0x14],0x1 LAB_001012c0: CMP dword ptr [RBP + -0x14],0x0 JNS 0x00101271 MOV EAX,dword ptr [RBP + -0x18] ADD RSP,0x20 POP RBX POP R12 POP RBP RET
/* func0(std::vector<int, std::allocator<int> > const&, int) */ int func0(vector *param_1,int param_2) { int iVar1; int *piVar2; int4 local_20; int4 local_1c; local_20 = 0; for (local_1c = param_2 + -1; -1 < local_1c; local_1c = local_1c + -1) { piVar2 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_1,(long)local_1c); iVar1 = *piVar2; piVar2 = (int *)std::vector<int,std::allocator<int>>::operator[] ((vector<int,std::allocator<int>> *)param_1,(long)local_1c); local_20 = local_20 + (iVar1 * local_1c - *piVar2 * ((param_2 + -1) - local_1c)); } return local_20; }
573
func0
#include <iostream> #include <vector> #include <assert.h>
int func0(const std::vector<int>& arr, int n) { int sum = 0; for (int i = n - 1; i >= 0; --i) { sum += i * arr[i] - (n - 1 - i) * arr[i]; } return sum; }
int main() { assert(func0({1, 8, 9, 15, 16}, 5) == 74); assert(func0({1, 2, 3, 4}, 4) == 10); assert(func0({1, 2, 3, 4, 5, 7, 9, 11, 14}, 9) == 188); return 0; }
O1
cpp
func0(std::vector<int, std::allocator<int> > const&, int): endbr64 mov %esi,%eax sub $0x1,%eax js 127f <_Z5func0RKSt6vectorIiSaIiEEi+0x36> mov (%rdi),%rdi cltq mov $0x0,%ecx sub $0x1,%esi mov %esi,%edx sub %eax,%edx mov %eax,%r8d sub %edx,%r8d mov %r8d,%edx imul (%rdi,%rax,4),%edx add %edx,%ecx sub $0x1,%rax test %eax,%eax jns 1261 <_Z5func0RKSt6vectorIiSaIiEEi+0x18> mov %ecx,%eax retq mov $0x0,%ecx jmp 127c <_Z5func0RKSt6vectorIiSaIiEEi+0x33>
_Z5func0RKSt6vectorIiSaIiEEi: endbr64 mov eax, esi sub eax, 1 js short loc_123B mov r8, [rdi] cdqe mov ecx, 0 sub esi, 1 loc_1221: mov edi, esi sub edi, eax mov edx, eax sub edx, edi imul edx, [r8+rax*4] add ecx, edx sub rax, 1 test eax, eax jns short loc_1221 loc_1238: mov eax, ecx retn loc_123B: mov ecx, 0 jmp short loc_1238
long long func0(_QWORD *a1, int a2) { long long v2; // rax unsigned int v3; // ecx int v4; // esi LODWORD(v2) = a2 - 1; if ( a2 - 1 < 0 ) { return 0; } else { v2 = (int)v2; v3 = 0; v4 = a2 - 1; do { v3 += *(_DWORD *)(*a1 + 4 * v2) * (v2 - (v4 - v2)); --v2; } while ( (int)v2 >= 0 ); } return v3; }
func0: ENDBR64 MOV EAX,ESI SUB EAX,0x1 JS 0x0010123b MOV R8,qword ptr [RDI] CDQE MOV ECX,0x0 SUB ESI,0x1 LAB_00101221: MOV EDI,ESI SUB EDI,EAX MOV EDX,EAX SUB EDX,EDI IMUL EDX,dword ptr [R8 + RAX*0x4] ADD ECX,EDX SUB RAX,0x1 TEST EAX,EAX JNS 0x00101221 LAB_00101238: MOV EAX,ECX RET LAB_0010123b: MOV ECX,0x0 JMP 0x00101238
/* func0(std::vector<int, std::allocator<int> > const&, int) */ int func0(vector *param_1,int param_2) { long lVar1; int iVar2; if (param_2 + -1 < 0) { iVar2 = 0; } else { lVar1 = (long)(param_2 + -1); iVar2 = 0; do { iVar2 = iVar2 + ((int)lVar1 * 2 - (param_2 + -1)) * *(int *)(*(long *)param_1 + lVar1 * 4); lVar1 = lVar1 + -1; } while (-1 < (int)lVar1); } return iVar2; }
574
func0
#include <iostream> #include <vector> #include <assert.h>
int func0(const std::vector<int>& arr, int n) { int sum = 0; for (int i = n - 1; i >= 0; --i) { sum += i * arr[i] - (n - 1 - i) * arr[i]; } return sum; }
int main() { assert(func0({1, 8, 9, 15, 16}, 5) == 74); assert(func0({1, 2, 3, 4}, 4) == 10); assert(func0({1, 2, 3, 4, 5, 7, 9, 11, 14}, 9) == 188); return 0; }
O2
cpp
func0(std::vector<int, std::allocator<int> > const&, int): endbr64 sub $0x1,%esi js 14d8 <_Z5func0RKSt6vectorIiSaIiEEi+0x38> mov (%rdi),%rcx movslq %esi,%rax xor %r8d,%r8d nopw 0x0(%rax,%rax,1) mov %esi,%edx mov %eax,%edi sub %eax,%edx sub %edx,%edi mov (%rcx,%rax,4),%edx sub $0x1,%rax imul %edi,%edx add %edx,%r8d test %eax,%eax jns 14b8 <_Z5func0RKSt6vectorIiSaIiEEi+0x18> mov %r8d,%eax retq nopl (%rax) xor %r8d,%r8d mov %r8d,%eax retq
_Z5func0RKSt6vectorIiSaIiEEi: endbr64 sub esi, 1 js short loc_13C8 mov r8, [rdi] movsxd rax, esi xor ecx, ecx nop dword ptr [rax+00000000h] loc_13A8: mov edi, esi mov edx, eax sub edi, eax sub edx, edi imul edx, [r8+rax*4] sub rax, 1 add ecx, edx test eax, eax jns short loc_13A8 mov eax, ecx retn loc_13C8: xor ecx, ecx mov eax, ecx retn
long long func0(_QWORD *a1, int a2) { int v2; // esi long long v3; // rax unsigned int v4; // ecx int v5; // edx v2 = a2 - 1; if ( v2 < 0 ) return 0LL; v3 = v2; v4 = 0; do { v5 = *(_DWORD *)(*a1 + 4 * v3) * (v3 - (v2 - v3)); --v3; v4 += v5; } while ( (int)v3 >= 0 ); return v4; }
func0: ENDBR64 SUB ESI,0x1 JS 0x001013c8 MOV R8,qword ptr [RDI] MOVSXD RAX,ESI XOR ECX,ECX NOP dword ptr [RAX] LAB_001013a8: MOV EDI,ESI MOV EDX,EAX SUB EDI,EAX SUB EDX,EDI IMUL EDX,dword ptr [R8 + RAX*0x4] SUB RAX,0x1 ADD ECX,EDX TEST EAX,EAX JNS 0x001013a8 MOV EAX,ECX RET LAB_001013c8: XOR ECX,ECX MOV EAX,ECX RET
/* func0(std::vector<int, std::allocator<int> > const&, int) */ int func0(vector *param_1,int param_2) { long lVar1; int iVar2; long lVar3; int iVar4; int iVar5; iVar5 = param_2 + -1; if (-1 < iVar5) { lVar3 = (long)iVar5; iVar4 = 0; do { iVar2 = (int)lVar3; lVar1 = lVar3 * 4; lVar3 = lVar3 + -1; iVar4 = iVar4 + (iVar2 * 2 - iVar5) * *(int *)(*(long *)param_1 + lVar1); } while (-1 < (int)lVar3); return iVar4; } return 0; }
575
func0
#include <iostream> #include <vector> #include <assert.h>
int func0(const std::vector<int>& arr, int n) { int sum = 0; for (int i = n - 1; i >= 0; --i) { sum += i * arr[i] - (n - 1 - i) * arr[i]; } return sum; }
int main() { assert(func0({1, 8, 9, 15, 16}, 5) == 74); assert(func0({1, 2, 3, 4}, 4) == 10); assert(func0({1, 2, 3, 4, 5, 7, 9, 11, 14}, 9) == 188); return 0; }
O3
cpp
func0(std::vector<int, std::allocator<int> > const&, int): endbr64 mov %esi,%ecx sub $0x1,%ecx js 1760 <_Z5func0RKSt6vectorIiSaIiEEi+0x170> mov (%rdi),%rdi cmp $0x3,%ecx jbe 1769 <_Z5func0RKSt6vectorIiSaIiEEi+0x179> movslq %ecx,%rax movd %esi,%xmm5 movd %ecx,%xmm6 mov %esi,%edx lea -0xc(%rdi,%rax,4),%rax shr $0x2,%edx pshufd $0x0,%xmm5,%xmm4 movdqa 0xaf3(%rip),%xmm5 shl $0x4,%rdx pshufd $0x0,%xmm6,%xmm6 pxor %xmm3,%xmm3 mov %rax,%r10 sub %rdx,%r10 paddd 0xac8(%rip),%xmm4 mov %r10,%rdx nopl 0x0(%rax,%rax,1) movdqu (%rax),%xmm7 movdqa %xmm4,%xmm8 movdqa %xmm6,%xmm1 sub $0x10,%rax psubd %xmm8,%xmm1 movdqa %xmm8,%xmm2 paddd %xmm5,%xmm4 pshufd $0x1b,%xmm7,%xmm0 movdqa %xmm8,%xmm7 pmuludq %xmm0,%xmm2 psrlq $0x20,%xmm7 movdqa %xmm0,%xmm9 psrlq $0x20,%xmm9 pmuludq %xmm1,%xmm0 psrlq $0x20,%xmm1 pmuludq %xmm9,%xmm7 pmuludq %xmm9,%xmm1 pshufd $0x8,%xmm2,%xmm2 pshufd $0x8,%xmm0,%xmm0 pshufd $0x8,%xmm7,%xmm7 pshufd $0x8,%xmm1,%xmm1 punpckldq %xmm7,%xmm2 punpckldq %xmm1,%xmm0 psubd %xmm0,%xmm2 paddd %xmm2,%xmm3 cmp %rdx,%rax jne 1650 <_Z5func0RKSt6vectorIiSaIiEEi+0x60> movdqa %xmm3,%xmm0 mov %esi,%r8d mov %ecx,%edx psrldq $0x8,%xmm0 and $0xfffffffc,%r8d paddd %xmm0,%xmm3 sub %r8d,%edx movdqa %xmm3,%xmm0 psrldq $0x4,%xmm0 paddd %xmm0,%xmm3 movd %xmm3,%eax cmp %esi,%r8d je 1768 <_Z5func0RKSt6vectorIiSaIiEEi+0x178> mov %ecx,%r8d movslq %edx,%r9 mov %edx,%r11d sub %edx,%r8d sub %r8d,%r11d mov (%rdi,%r9,4),%r8d imul %r11d,%r8d add %r8d,%eax lea -0x1(%rdx),%r8d test %edx,%edx je 1762 <_Z5func0RKSt6vectorIiSaIiEEi+0x172> movslq %r8d,%r9 sub %edx,%esi sub %esi,%r8d imul (%rdi,%r9,4),%r8d lea -0x2(%rdx),%esi add %r8d,%eax cmp $0x1,%edx je 1762 <_Z5func0RKSt6vectorIiSaIiEEi+0x172> mov %ecx,%r9d movslq %esi,%r8 sub %esi,%r9d sub %r9d,%esi imul (%rdi,%r8,4),%esi add %esi,%eax lea -0x3(%rdx),%esi cmp $0x2,%edx je 1762 <_Z5func0RKSt6vectorIiSaIiEEi+0x172> movslq %esi,%rdx sub %esi,%ecx sub %ecx,%esi imul (%rdi,%rdx,4),%esi add %esi,%eax retq nopl 0x0(%rax,%rax,1) xor %eax,%eax retq nopl 0x0(%rax,%rax,1) retq mov %ecx,%edx xor %eax,%eax jmp 16f8 <_Z5func0RKSt6vectorIiSaIiEEi+0x108>
_Z5func0RKSt6vectorIiSaIiEEi: endbr64 mov edx, esi sub esi, 1 js loc_16C0 mov r8, [rdi] cmp esi, 2 jbe loc_16C3 movsxd rax, edx movd xmm5, edx movd xmm6, esi mov edi, edx lea rax, [r8+rax*4-10h] shr edi, 2 pshufd xmm4, xmm5, 0 movdqa xmm5, cs:xmmword_2100 shl rdi, 4 pshufd xmm6, xmm6, 0 pxor xmm3, xmm3 mov rcx, rax paddd xmm4, cs:xmmword_20F0 sub rcx, rdi nop dword ptr [rax+rax+00000000h] loc_15D0: movdqu xmm2, xmmword ptr [rax] movdqa xmm8, xmm4 sub rax, 10h paddd xmm4, xmm5 movdqa xmm1, xmm8 movdqa xmm7, xmm8 pshufd xmm0, xmm2, 1Bh psrlq xmm7, 20h ; ' ' pmuludq xmm1, xmm0 movdqa xmm9, xmm0 psrlq xmm9, 20h ; ' ' pmuludq xmm7, xmm9 pshufd xmm1, xmm1, 8 movdqa xmm2, xmm1 movdqa xmm1, xmm6 psubd xmm1, xmm8 pshufd xmm7, xmm7, 8 pmuludq xmm0, xmm1 psrlq xmm1, 20h ; ' ' punpckldq xmm2, xmm7 pmuludq xmm1, xmm9 pshufd xmm0, xmm0, 8 pshufd xmm1, xmm1, 8 punpckldq xmm0, xmm1 psubd xmm2, xmm0 paddd xmm3, xmm2 cmp rcx, rax jnz short loc_15D0 movdqa xmm0, xmm3 mov edi, edx psrldq xmm0, 8 and edi, 0FFFFFFFCh paddd xmm3, xmm0 movdqa xmm0, xmm3 psrldq xmm0, 4 paddd xmm3, xmm0 movd eax, xmm3 test dl, 3 jz short locret_16C2 mov ecx, esi sub ecx, edi loc_1679: mov r11d, esi movsxd r10, ecx mov edi, ecx sub r11d, ecx lea r9, ds:0[r10*4] sub edi, r11d imul edi, [r8+r10*4] add eax, edi lea edi, [rcx-1] test ecx, ecx jz short locret_16C2 sub edx, ecx sub edi, edx imul edi, [r8+r9-4] lea edx, [rcx-2] add eax, edi cmp ecx, 1 jz short locret_16C2 sub esi, edx sub edx, esi imul edx, [r8+r9-8] add eax, edx retn loc_16C0: xor eax, eax locret_16C2: retn loc_16C3: mov ecx, esi xor eax, eax jmp short loc_1679
long long func0(long long *a1, signed int a2) { signed int v3; // esi long long v4; // r8 const __m128i *v5; // rax __m128i si128; // xmm5 __m128i v7; // xmm6 __m128i v8; // xmm3 __m128i v9; // xmm4 __m128i v10; // xmm2 __m128i v11; // xmm8 __m128i v12; // xmm0 __m128i v13; // xmm9 __m128i v14; // xmm1 __m128i v15; // xmm3 long long result; // rax signed int v17; // ecx long long v18; // r9 v3 = a2 - 1; if ( v3 < 0 ) return 0LL; v4 = *a1; if ( (unsigned int)v3 <= 2 ) { v17 = v3; LODWORD(result) = 0; } else { v5 = (const __m128i *)(v4 + 4LL * a2 - 16); si128 = _mm_load_si128((const __m128i *)&xmmword_2100); v7 = _mm_shuffle_epi32(_mm_cvtsi32_si128(v3), 0); v8 = 0LL; v9 = _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(a2), 0), (__m128i)xmmword_20F0); do { v10 = _mm_loadu_si128(v5); v11 = v9; --v5; v9 = _mm_add_epi32(v9, si128); v12 = _mm_shuffle_epi32(v10, 27); v13 = _mm_srli_epi64(v12, 0x20u); v14 = _mm_sub_epi32(v7, v11); v8 = _mm_add_epi32( v8, _mm_sub_epi32( _mm_unpacklo_epi32( _mm_shuffle_epi32(_mm_mul_epu32(v11, v12), 8), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_epi64(v11, 0x20u), v13), 8)), _mm_unpacklo_epi32( _mm_shuffle_epi32(_mm_mul_epu32(v12, v14), 8), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_epi64(v14, 0x20u), v13), 8)))); } while ( (const __m128i *)(v4 + 4LL * a2 - 16 - 16LL * ((unsigned int)a2 >> 2)) != v5 ); v15 = _mm_add_epi32(v8, _mm_srli_si128(v8, 8)); result = (unsigned int)_mm_cvtsi128_si32(_mm_add_epi32(v15, _mm_srli_si128(v15, 4))); if ( (a2 & 3) == 0 ) return result; v17 = v3 - (a2 & 0xFFFFFFFC); } v18 = 4LL * v17; result = (unsigned int)(*(_DWORD *)(v4 + v18) * (v17 - (v3 - v17)) + result); if ( v17 ) { result = (unsigned int)(*(_DWORD *)(v4 + v18 - 4) * (v17 - 1 - (a2 - v17)) + result); if ( v17 != 1 ) return (unsigned int)(*(_DWORD *)(v4 + v18 - 8) * (v17 - 2 - (v3 - (v17 - 2))) + result); } return result; }
func0: ENDBR64 MOV EDX,ESI SUB ESI,0x1 JS 0x001016c0 MOV R8,qword ptr [RDI] CMP ESI,0x2 JBE 0x001016c3 MOVSXD RAX,EDX MOVD XMM5,EDX MOVD XMM6,ESI MOV EDI,EDX LEA RAX,[R8 + RAX*0x4 + -0x10] SHR EDI,0x2 PSHUFD XMM4,XMM5,0x0 MOVDQA XMM5,xmmword ptr [0x00102100] SHL RDI,0x4 PSHUFD XMM6,XMM6,0x0 PXOR XMM3,XMM3 MOV RCX,RAX PADDD XMM4,xmmword ptr [0x001020f0] SUB RCX,RDI NOP dword ptr [RAX + RAX*0x1] LAB_001015d0: MOVDQU XMM2,xmmword ptr [RAX] MOVDQA XMM8,XMM4 SUB RAX,0x10 PADDD XMM4,XMM5 MOVDQA XMM1,XMM8 MOVDQA XMM7,XMM8 PSHUFD XMM0,XMM2,0x1b PSRLQ XMM7,0x20 PMULUDQ XMM1,XMM0 MOVDQA XMM9,XMM0 PSRLQ XMM9,0x20 PMULUDQ XMM7,XMM9 PSHUFD XMM1,XMM1,0x8 MOVDQA XMM2,XMM1 MOVDQA XMM1,XMM6 PSUBD XMM1,XMM8 PSHUFD XMM7,XMM7,0x8 PMULUDQ XMM0,XMM1 PSRLQ XMM1,0x20 PUNPCKLDQ XMM2,XMM7 PMULUDQ XMM1,XMM9 PSHUFD XMM0,XMM0,0x8 PSHUFD XMM1,XMM1,0x8 PUNPCKLDQ XMM0,XMM1 PSUBD XMM2,XMM0 PADDD XMM3,XMM2 CMP RCX,RAX JNZ 0x001015d0 MOVDQA XMM0,XMM3 MOV EDI,EDX PSRLDQ XMM0,0x8 AND EDI,0xfffffffc PADDD XMM3,XMM0 MOVDQA XMM0,XMM3 PSRLDQ XMM0,0x4 PADDD XMM3,XMM0 MOVD EAX,XMM3 TEST DL,0x3 JZ 0x001016c2 MOV ECX,ESI SUB ECX,EDI LAB_00101679: MOV R11D,ESI MOVSXD R10,ECX MOV EDI,ECX SUB R11D,ECX LEA R9,[R10*0x4] SUB EDI,R11D IMUL EDI,dword ptr [R8 + R10*0x4] ADD EAX,EDI LEA EDI,[RCX + -0x1] TEST ECX,ECX JZ 0x001016c2 SUB EDX,ECX SUB EDI,EDX IMUL EDI,dword ptr [R8 + R9*0x1 + -0x4] LEA EDX,[RCX + -0x2] ADD EAX,EDI CMP ECX,0x1 JZ 0x001016c2 SUB ESI,EDX SUB EDX,ESI IMUL EDX,dword ptr [R8 + R9*0x1 + -0x8] ADD EAX,EDX RET LAB_001016c0: XOR EAX,EAX LAB_001016c2: RET LAB_001016c3: MOV ECX,ESI XOR EAX,EAX JMP 0x00101679
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */ /* func0(std::vector<int, std::allocator<int> > const&, int) */ int func0(vector *param_1,int param_2) { long lVar1; long lVar2; int auVar3 [16]; uint *puVar4; uint uVar5; uint uVar6; uint *puVar7; uint uVar8; uint *puVar9; uint uVar10; int auVar11 [16]; int iVar12; int iVar13; int iVar14; int iVar15; int iVar16; int iVar17; int iVar18; int iVar19; uVar10 = param_2 - 1; if ((int)uVar10 < 0) { iVar13 = 0; } else { lVar2 = *(long *)param_1; if (uVar10 < 3) { iVar13 = 0; uVar8 = uVar10; } else { puVar7 = (uint *)(lVar2 + -0x10 + (long)param_2 * 4); iVar12 = 0; iVar14 = 0; iVar15 = 0; iVar16 = 0; iVar19 = param_2 + _UNK_001020fc; puVar9 = puVar7 + (ulong)((uint)param_2 >> 2) * -4; iVar13 = param_2 + _DAT_001020f0; iVar17 = param_2 + _UNK_001020f4; iVar18 = param_2 + _UNK_001020f8; do { uVar8 = *puVar7; puVar4 = puVar7 + 1; uVar5 = puVar7[2]; uVar6 = puVar7[3]; auVar3._4_4_ = iVar17; auVar3._0_4_ = iVar13; auVar3._8_4_ = iVar18; auVar3._12_4_ = iVar19; puVar7 = puVar7 + -4; iVar19 = iVar19 + _UNK_0010210c; auVar11._4_4_ = uVar5; auVar11._0_4_ = uVar6; auVar11._8_4_ = *puVar4; auVar11._12_4_ = uVar8; iVar12 = iVar12 + (iVar13 * uVar6 - uVar6 * (uVar10 - iVar13)); iVar14 = iVar14 + (iVar17 * uVar5 - (uVar10 - iVar17) * uVar5); iVar15 = iVar15 + ((int)((auVar3._8_8_ & 0xffffffff) * (ulong)*puVar4) - (int)((auVar11._8_8_ & 0xffffffff) * (ulong)(uVar10 - iVar18))); iVar16 = iVar16 + ((int)((auVar3._8_8_ >> 0x20) * (ulong)uVar8) - (uVar10 - iVar17) * uVar8) ; iVar13 = iVar13 + _DAT_00102100; iVar17 = iVar17 + _UNK_00102104; iVar18 = iVar18 + _UNK_00102108; } while (puVar9 != puVar7); iVar13 = iVar12 + iVar15 + iVar14 + iVar16; if ((param_2 & 3U) == 0) { return iVar13; } uVar8 = uVar10 - (param_2 & 0xfffffffcU); } lVar1 = (long)(int)uVar8 * 4; iVar13 = iVar13 + (uVar8 * 2 - uVar10) * *(int *)(lVar2 + (long)(int)uVar8 * 4); if (uVar8 != 0) { iVar13 = iVar13 + ((uVar8 * 2 + -1) - param_2) * *(int *)(lVar2 + -4 + lVar1); if (uVar8 != 1) { return iVar13 + ((uVar8 - 2) * 2 - uVar10) * *(int *)(lVar2 + -8 + lVar1); } } } return iVar13; }
576
func0
#include <iostream> #include <cassert>
int func0(int arr[], int n) { int minEle = arr[0]; int maxEle = arr[0]; for (int i = 1; i < n; i++) { minEle = std::min(minEle, arr[i]); maxEle = std::max(maxEle, arr[i]); } return (maxEle - minEle); }
int main() { int arr1[] = {2, 1, 5, 3}; assert(func0(arr1, 4) == 4); int arr2[] = {9, 3, 2, 5, 1}; assert(func0(arr2, 5) == 8); int arr3[] = {3, 2, 1}; assert(func0(arr3, 3) == 2); return 0; }
O0
cpp
func0(int*, int): endbr64 push %rbp mov %rsp,%rbp sub $0x30,%rsp mov %rdi,-0x28(%rbp) mov %esi,-0x2c(%rbp) mov %fs:0x28,%rax mov %rax,-0x8(%rbp) xor %eax,%eax mov -0x28(%rbp),%rax mov (%rax),%eax mov %eax,-0x14(%rbp) mov -0x28(%rbp),%rax mov (%rax),%eax mov %eax,-0x10(%rbp) movl $0x1,-0xc(%rbp) mov -0xc(%rbp),%eax cmp -0x2c(%rbp),%eax jge 1242 <_Z5func0Pii+0x99> mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rax,%rdx lea -0x14(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 13f1 <_ZSt3minIiERKT_S2_S2_> mov (%rax),%eax mov %eax,-0x14(%rbp) mov -0xc(%rbp),%eax cltq lea 0x0(,%rax,4),%rdx mov -0x28(%rbp),%rax add %rax,%rdx lea -0x10(%rbp),%rax mov %rdx,%rsi mov %rax,%rdi callq 141d <_ZSt3maxIiERKT_S2_S2_> mov (%rax),%eax mov %eax,-0x10(%rbp) addl $0x1,-0xc(%rbp) jmp 11e4 <_Z5func0Pii+0x3b> mov -0x10(%rbp),%edx mov -0x14(%rbp),%eax sub %eax,%edx mov %edx,%eax mov -0x8(%rbp),%rcx xor %fs:0x28,%rcx je 1260 <_Z5func0Pii+0xb7> callq 10a0 <__stack_chk_fail@plt> leaveq retq
_Z5func0Pii: endbr64 push rbp mov rbp, rsp sub rsp, 30h mov [rbp+var_28], rdi mov [rbp+var_2C], esi mov rax, fs:28h mov [rbp+var_8], rax xor eax, eax mov rax, [rbp+var_28] mov eax, [rax] mov [rbp+var_14], eax mov rax, [rbp+var_28] mov eax, [rax] mov [rbp+var_10], eax mov [rbp+var_C], 1 jmp short loc_11FA loc_11A6: mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rdx, rax lea rax, [rbp+var_14] mov rsi, rdx mov rdi, rax call _ZSt3minIiERKT_S2_S2_; std::min<int>(int const&,int const&) mov eax, [rax] mov [rbp+var_14], eax mov eax, [rbp+var_C] cdqe lea rdx, ds:0[rax*4] mov rax, [rbp+var_28] add rdx, rax lea rax, [rbp+var_10] mov rsi, rdx mov rdi, rax call _ZSt3maxIiERKT_S2_S2_; std::max<int>(int const&,int const&) mov eax, [rax] mov [rbp+var_10], eax add [rbp+var_C], 1 loc_11FA: mov eax, [rbp+var_C] cmp eax, [rbp+var_2C] jl short loc_11A6 mov edx, [rbp+var_10] mov eax, [rbp+var_14] sub edx, eax mov eax, edx mov rdx, [rbp+var_8] sub rdx, fs:28h jz short locret_1220 call ___stack_chk_fail locret_1220: leave retn
long long func0(int *a1, int a2) { int v3; // [rsp+1Ch] [rbp-14h] BYREF int v4; // [rsp+20h] [rbp-10h] BYREF int i; // [rsp+24h] [rbp-Ch] unsigned long long v6; // [rsp+28h] [rbp-8h] v6 = __readfsqword(0x28u); v3 = *a1; v4 = *a1; for ( i = 1; i < a2; ++i ) { v3 = *(_DWORD *)std::min<int>(&v3, &a1[i]); v4 = *(_DWORD *)std::max<int>(&v4, &a1[i]); } return (unsigned int)(v4 - v3); }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x30 MOV qword ptr [RBP + -0x28],RDI MOV dword ptr [RBP + -0x2c],ESI MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RBP + -0x8],RAX XOR EAX,EAX MOV RAX,qword ptr [RBP + -0x28] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x14],EAX MOV RAX,qword ptr [RBP + -0x28] MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x10],EAX MOV dword ptr [RBP + -0xc],0x1 JMP 0x001011fa LAB_001011a6: MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RDX,RAX LEA RAX,[RBP + -0x14] MOV RSI,RDX MOV RDI,RAX CALL 0x00101366 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x14],EAX MOV EAX,dword ptr [RBP + -0xc] CDQE LEA RDX,[RAX*0x4] MOV RAX,qword ptr [RBP + -0x28] ADD RDX,RAX LEA RAX,[RBP + -0x10] MOV RSI,RDX MOV RDI,RAX CALL 0x00101392 MOV EAX,dword ptr [RAX] MOV dword ptr [RBP + -0x10],EAX ADD dword ptr [RBP + -0xc],0x1 LAB_001011fa: MOV EAX,dword ptr [RBP + -0xc] CMP EAX,dword ptr [RBP + -0x2c] JL 0x001011a6 MOV EDX,dword ptr [RBP + -0x10] MOV EAX,dword ptr [RBP + -0x14] SUB EDX,EAX MOV EAX,EDX MOV RDX,qword ptr [RBP + -0x8] SUB RDX,qword ptr FS:[0x28] JZ 0x00101220 CALL 0x00101070 LAB_00101220: LEAVE RET
/* func0(int*, int) */ int func0(int *param_1,int param_2) { int *piVar1; long in_FS_OFFSET; int local_1c; int local_18; int local_14; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_1c = *param_1; local_18 = *param_1; for (local_14 = 1; local_14 < param_2; local_14 = local_14 + 1) { piVar1 = std::min<int>(&local_1c,param_1 + local_14); local_1c = *piVar1; piVar1 = std::max<int>(&local_18,param_1 + local_14); local_18 = *piVar1; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return local_18 - local_1c; }
577
func0
#include <iostream> #include <cassert>
int func0(int arr[], int n) { int minEle = arr[0]; int maxEle = arr[0]; for (int i = 1; i < n; i++) { minEle = std::min(minEle, arr[i]); maxEle = std::max(maxEle, arr[i]); } return (maxEle - minEle); }
int main() { int arr1[] = {2, 1, 5, 3}; assert(func0(arr1, 4) == 4); int arr2[] = {9, 3, 2, 5, 1}; assert(func0(arr2, 5) == 8); int arr3[] = {3, 2, 1}; assert(func0(arr3, 3) == 2); return 0; }
O1
cpp
func0(int*, int): endbr64 sub $0x18,%rsp mov %fs:0x28,%rax mov %rax,0x8(%rsp) xor %eax,%eax mov (%rdi),%eax mov %eax,(%rsp) mov %eax,0x4(%rsp) cmp $0x1,%esi jle 120b <_Z5func0Pii+0x62> lea 0x4(%rdi),%rax lea -0x2(%rsi),%edx lea 0x8(%rdi,%rdx,4),%rdi lea 0x4(%rsp),%rsi mov (%rax),%edx mov %rsp,%rcx cmp (%rsp),%edx cmovl %rax,%rcx mov (%rcx),%ecx mov %ecx,(%rsp) cmp %edx,0x4(%rsp) mov %rax,%rdx cmovge %rsi,%rdx mov (%rdx),%edx mov %edx,0x4(%rsp) add $0x4,%rax cmp %rdi,%rax jne 11e0 <_Z5func0Pii+0x37> mov 0x4(%rsp),%eax sub (%rsp),%eax mov 0x8(%rsp),%rsi xor %fs:0x28,%rsi jne 1227 <_Z5func0Pii+0x7e> add $0x18,%rsp retq callq 10a0 <__stack_chk_fail@plt>
_Z5func0Pii: endbr64 sub rsp, 18h mov rax, fs:28h mov [rsp+18h+var_10], rax xor eax, eax mov eax, [rdi] mov [rsp+18h+var_18], eax mov [rsp+18h+var_14], eax cmp esi, 1 jle short loc_11CE lea rax, [rdi+4] lea edx, [rsi-2] lea r8, [rdi+rdx*4+8] mov rdi, rsp lea rsi, [rsp+18h+var_14] loc_11A3: mov edx, [rax] cmp edx, [rsp+18h+var_18] mov rcx, rax cmovge rcx, rdi mov ecx, [rcx] mov [rsp+18h+var_18], ecx cmp [rsp+18h+var_14], edx mov rdx, rax cmovge rdx, rsi mov edx, [rdx] mov [rsp+18h+var_14], edx add rax, 4 cmp rax, r8 jnz short loc_11A3 loc_11CE: mov eax, [rsp+18h+var_14] sub eax, [rsp+18h+var_18] mov rdx, [rsp+18h+var_10] sub rdx, fs:28h jnz short loc_11EA add rsp, 18h retn loc_11EA: call ___stack_chk_fail
long long func0(int *a1, int a2) { int *v2; // rax int v3; // edx int *v4; // rcx bool v5; // cc int *v6; // rdx int v8; // [rsp+0h] [rbp-18h] BYREF int v9; // [rsp+4h] [rbp-14h] BYREF unsigned long long v10; // [rsp+8h] [rbp-10h] v10 = __readfsqword(0x28u); v8 = *a1; v9 = v8; if ( a2 > 1 ) { v2 = a1 + 1; do { v3 = *v2; v4 = v2; if ( *v2 >= v8 ) v4 = &v8; v8 = *v4; v5 = v9 < v3; v6 = v2; if ( !v5 ) v6 = &v9; v9 = *v6; ++v2; } while ( v2 != &a1[a2 - 2 + 2] ); } return (unsigned int)(v9 - v8); }
func0: ENDBR64 SUB RSP,0x18 MOV RAX,qword ptr FS:[0x28] MOV qword ptr [RSP + 0x8],RAX XOR EAX,EAX MOV EAX,dword ptr [RDI] MOV dword ptr [RSP],EAX MOV dword ptr [RSP + 0x4],EAX CMP ESI,0x1 JLE 0x001011ce LEA RAX,[RDI + 0x4] LEA EDX,[RSI + -0x2] LEA R8,[RDI + RDX*0x4 + 0x8] MOV RDI,RSP LEA RSI,[RSP + 0x4] LAB_001011a3: MOV EDX,dword ptr [RAX] CMP EDX,dword ptr [RSP] MOV RCX,RAX CMOVGE RCX,RDI MOV ECX,dword ptr [RCX] MOV dword ptr [RSP],ECX CMP dword ptr [RSP + 0x4],EDX MOV RDX,RAX CMOVGE RDX,RSI MOV EDX,dword ptr [RDX] MOV dword ptr [RSP + 0x4],EDX ADD RAX,0x4 CMP RAX,R8 JNZ 0x001011a3 LAB_001011ce: MOV EAX,dword ptr [RSP + 0x4] SUB EAX,dword ptr [RSP] MOV RDX,qword ptr [RSP + 0x8] SUB RDX,qword ptr FS:[0x28] JNZ 0x001011ea ADD RSP,0x18 RET LAB_001011ea: CALL 0x00101070
/* func0(int*, int) */ int func0(int *param_1,int param_2) { int *piVar1; int *piVar2; long in_FS_OFFSET; int local_18; int local_14; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_18 = *param_1; local_14 = *param_1; if (1 < param_2) { piVar1 = param_1 + 1; do { piVar2 = piVar1; if (local_18 <= *piVar1) { piVar2 = &local_18; } local_18 = *piVar2; piVar2 = piVar1; if (*piVar1 <= local_14) { piVar2 = &local_14; } local_14 = *piVar2; piVar1 = piVar1 + 1; } while (piVar1 != param_1 + (ulong)(param_2 - 2) + 2); } if (*(long *)(in_FS_OFFSET + 0x28) == *(long *)(in_FS_OFFSET + 0x28)) { return local_14 - local_18; } /* WARNING: Subroutine does not return */ __stack_chk_fail(); }
578
func0
#include <iostream> #include <cassert>
int func0(int arr[], int n) { int minEle = arr[0]; int maxEle = arr[0]; for (int i = 1; i < n; i++) { minEle = std::min(minEle, arr[i]); maxEle = std::max(maxEle, arr[i]); } return (maxEle - minEle); }
int main() { int arr1[] = {2, 1, 5, 3}; assert(func0(arr1, 4) == 4); int arr2[] = {9, 3, 2, 5, 1}; assert(func0(arr2, 5) == 8); int arr3[] = {3, 2, 1}; assert(func0(arr3, 3) == 2); return 0; }
O2
cpp
func0(int*, int): endbr64 sub $0x18,%rsp mov (%rdi),%r8d mov %fs:0x28,%rax mov %rax,0x8(%rsp) xor %eax,%eax mov %r8d,0x4(%rsp) cmp $0x1,%esi jle 1390 <_Z5func0Pii+0x70> lea -0x2(%rsi),%eax lea 0x4(%rdi),%rcx lea 0x8(%rdi,%rax,4),%rsi mov %r8d,%eax nopl 0x0(%rax) mov (%rcx),%edx cmp %edx,%r8d cmovg %edx,%r8d cmp %edx,%eax cmovl %edx,%eax add $0x4,%rcx cmp %rcx,%rsi jne 1358 <_Z5func0Pii+0x38> sub %r8d,%eax mov 0x8(%rsp),%rdi xor %fs:0x28,%rdi jne 1394 <_Z5func0Pii+0x74> add $0x18,%rsp retq nopw 0x0(%rax,%rax,1) xor %eax,%eax jmp 1372 <_Z5func0Pii+0x52> callq 10a0 <__stack_chk_fail@plt> nopl 0x0(%rax)
_Z5func0Pii: endbr64 mov r8d, [rdi] cmp esi, 1 jle short loc_12B0 lea eax, [rsi-2] lea rcx, [rdi+4] lea rsi, [rdi+rax*4+8] mov eax, r8d nop dword ptr [rax+rax+00h] loc_1290: mov edx, [rcx] cmp r8d, edx cmovg r8d, edx cmp eax, edx cmovl eax, edx add rcx, 4 cmp rsi, rcx jnz short loc_1290 sub eax, r8d retn loc_12B0: xor eax, eax retn
long long func0(int *a1, int a2) { int v2; // r8d int *v3; // rcx int *v4; // rsi int v5; // eax v2 = *a1; if ( a2 <= 1 ) return 0LL; v3 = a1 + 1; v4 = &a1[a2 - 2 + 2]; v5 = *a1; do { if ( v2 > *v3 ) v2 = *v3; if ( v5 < *v3 ) v5 = *v3; ++v3; } while ( v4 != v3 ); return (unsigned int)(v5 - v2); }
func0: ENDBR64 MOV R8D,dword ptr [RDI] CMP ESI,0x1 JLE 0x001012b0 LEA EAX,[RSI + -0x2] LEA RCX,[RDI + 0x4] LEA RSI,[RDI + RAX*0x4 + 0x8] MOV EAX,R8D NOP dword ptr [RAX + RAX*0x1] LAB_00101290: MOV EDX,dword ptr [RCX] CMP R8D,EDX CMOVG R8D,EDX CMP EAX,EDX CMOVL EAX,EDX ADD RCX,0x4 CMP RSI,RCX JNZ 0x00101290 SUB EAX,R8D RET LAB_001012b0: XOR EAX,EAX RET
/* func0(int*, int) */ int func0(int *param_1,int param_2) { int iVar1; int iVar2; int *piVar3; int iVar4; iVar4 = *param_1; if (1 < param_2) { piVar3 = param_1 + 1; iVar2 = iVar4; do { iVar1 = *piVar3; if (iVar1 < iVar4) { iVar4 = iVar1; } if (iVar2 < iVar1) { iVar2 = iVar1; } piVar3 = piVar3 + 1; } while (param_1 + (ulong)(param_2 - 2) + 2 != piVar3); return iVar2 - iVar4; } return 0; }
579
func0
#include <iostream> #include <cassert>
int func0(int arr[], int n) { int minEle = arr[0]; int maxEle = arr[0]; for (int i = 1; i < n; i++) { minEle = std::min(minEle, arr[i]); maxEle = std::max(maxEle, arr[i]); } return (maxEle - minEle); }
int main() { int arr1[] = {2, 1, 5, 3}; assert(func0(arr1, 4) == 4); int arr2[] = {9, 3, 2, 5, 1}; assert(func0(arr2, 5) == 8); int arr3[] = {3, 2, 1}; assert(func0(arr3, 3) == 2); return 0; }
O3
cpp
func0(int*, int): endbr64 sub $0x18,%rsp mov (%rdi),%r8d mov %fs:0x28,%rax mov %rax,0x8(%rsp) xor %eax,%eax mov %r8d,0x4(%rsp) cmp $0x1,%esi jle 1370 <_Z5func0Pii+0x70> lea -0x2(%rsi),%eax lea 0x4(%rdi),%rcx lea 0x8(%rdi,%rax,4),%rsi mov %r8d,%eax nopl 0x0(%rax) mov (%rcx),%edx cmp %edx,%r8d cmovg %edx,%r8d add $0x4,%rcx cmp %edx,%eax jge 134b <_Z5func0Pii+0x4b> mov %edx,%eax cmp %rsi,%rcx jne 1338 <_Z5func0Pii+0x38> sub %r8d,%eax mov 0x8(%rsp),%rdi xor %fs:0x28,%rdi jne 1374 <_Z5func0Pii+0x74> add $0x18,%rsp retq nopl 0x0(%rax,%rax,1) xor %eax,%eax jmp 1353 <_Z5func0Pii+0x53> callq 10a0 <__stack_chk_fail@plt> nopl 0x0(%rax)
_Z5func0Pii: endbr64 mov edx, [rdi] mov rcx, rdi cmp esi, 1 jle loc_13D0 lea eax, [rsi-2] lea r8d, [rsi-1] cmp eax, 2 jbe loc_13D3 movd xmm5, edx mov edx, r8d mov rax, rdi shr edx, 2 pshufd xmm0, xmm5, 0 shl rdx, 4 movdqa xmm1, xmm0 add rdx, rdi nop loc_12B0: movdqu xmm3, xmmword ptr [rax+4] movdqa xmm2, xmm0 add rax, 10h pcmpgtd xmm2, xmm3 movdqa xmm4, xmm3 pand xmm4, xmm2 pandn xmm2, xmm0 movdqa xmm0, xmm2 movdqa xmm2, xmm1 pcmpgtd xmm2, xmm3 por xmm0, xmm4 pand xmm1, xmm2 pandn xmm2, xmm3 por xmm1, xmm2 cmp rax, rdx jnz short loc_12B0 movdqa xmm3, xmm1 mov edi, r8d psrldq xmm3, 8 and edi, 0FFFFFFFCh movdqa xmm2, xmm3 add edi, 1 and r8d, 3 pcmpgtd xmm2, xmm1 pand xmm3, xmm2 pandn xmm2, xmm1 por xmm2, xmm3 movdqa xmm3, xmm2 psrldq xmm3, 4 movdqa xmm1, xmm3 pcmpgtd xmm1, xmm2 pand xmm3, xmm1 pandn xmm1, xmm2 movdqa xmm2, xmm0 psrldq xmm2, 8 por xmm1, xmm3 movd eax, xmm1 movdqa xmm1, xmm2 pcmpgtd xmm1, xmm0 pand xmm0, xmm1 pandn xmm1, xmm2 por xmm0, xmm1 movdqa xmm2, xmm0 psrldq xmm2, 4 movdqa xmm1, xmm2 pcmpgtd xmm1, xmm0 pand xmm0, xmm1 pandn xmm1, xmm2 por xmm1, xmm0 movd edx, xmm1 jz short loc_13C8 loc_1379: movsxd r8, edi lea r9, ds:0[r8*4] mov r8d, [rcx+r8*4] cmp edx, r8d cmovg edx, r8d cmp eax, r8d cmovl eax, r8d lea r8d, [rdi+1] cmp esi, r8d jle short loc_13C8 mov r8d, [rcx+r9+4] cmp edx, r8d cmovg edx, r8d cmp eax, r8d cmovl eax, r8d add edi, 2 cmp esi, edi jle short loc_13C8 mov ecx, [rcx+r9+8] cmp edx, ecx cmovg edx, ecx cmp eax, ecx cmovl eax, ecx loc_13C8: sub eax, edx retn loc_13D0: xor eax, eax retn loc_13D3: mov eax, edx mov edi, 1 jmp short loc_1379
long long func0(int *a1, int a2) { signed int v2; // edx unsigned int v4; // r8d int *v5; // rax __m128i v6; // xmm0 __m128i v7; // xmm1 __m128i v8; // xmm3 __m128i v9; // xmm2 __m128i v10; // xmm4 __m128i v11; // xmm0 __m128i v12; // xmm2 __m128i v13; // xmm3 signed int v14; // edi __m128i v15; // xmm2 __m128i v16; // xmm2 __m128i v17; // xmm3 __m128i v18; // xmm1 __m128i v19; // xmm3 __m128i v20; // xmm1 __m128i v21; // xmm2 int v22; // eax __m128i v23; // xmm1 __m128i v24; // xmm0 __m128i v25; // xmm2 __m128i v26; // xmm1 long long v27; // r9 int v28; // r8d int v29; // r8d int v30; // ecx v2 = *a1; if ( a2 > 1 ) { v4 = a2 - 1; if ( (unsigned int)(a2 - 2) <= 2 ) { v22 = *a1; v14 = 1; } else { v5 = a1; v6 = _mm_shuffle_epi32(_mm_cvtsi32_si128(v2), 0); v7 = v6; do { v8 = _mm_loadu_si128((const __m128i *)(v5 + 1)); v5 += 4; v9 = _mm_cmpgt_epi32(v6, v8); v10 = _mm_and_si128(v8, v9); v11 = _mm_andnot_si128(v9, v6); v12 = _mm_cmpgt_epi32(v7, v8); v6 = _mm_or_si128(v11, v10); v7 = _mm_or_si128(_mm_and_si128(v7, v12), _mm_andnot_si128(v12, v8)); } while ( v5 != &a1[4 * (v4 >> 2)] ); v13 = _mm_srli_si128(v7, 8); v14 = (v4 & 0xFFFFFFFC) + 1; v15 = _mm_cmpgt_epi32(v13, v7); v16 = _mm_or_si128(_mm_andnot_si128(v15, v7), _mm_and_si128(v13, v15)); v17 = _mm_srli_si128(v16, 4); v18 = _mm_cmpgt_epi32(v17, v16); v19 = _mm_and_si128(v17, v18); v20 = _mm_andnot_si128(v18, v16); v21 = _mm_srli_si128(v6, 8); v22 = _mm_cvtsi128_si32(_mm_or_si128(v20, v19)); v23 = _mm_cmpgt_epi32(v21, v6); v24 = _mm_or_si128(_mm_and_si128(v6, v23), _mm_andnot_si128(v23, v21)); v25 = _mm_srli_si128(v24, 4); v26 = _mm_cmpgt_epi32(v25, v24); v2 = _mm_cvtsi128_si32(_mm_or_si128(_mm_andnot_si128(v26, v25), _mm_and_si128(v24, v26))); if ( (v4 & 3) == 0 ) return (unsigned int)(v22 - v2); } v27 = v14; v28 = a1[v27]; if ( v2 > v28 ) v2 = a1[v14]; if ( v22 < v28 ) v22 = a1[v14]; if ( a2 > v14 + 1 ) { v29 = a1[v27 + 1]; if ( v2 > v29 ) v2 = a1[v27 + 1]; if ( v22 < v29 ) v22 = a1[v27 + 1]; if ( a2 > v14 + 2 ) { v30 = a1[v27 + 2]; if ( v2 > v30 ) v2 = v30; if ( v22 < v30 ) v22 = v30; } } return (unsigned int)(v22 - v2); } return 0LL; }
func0: ENDBR64 MOV EDX,dword ptr [RDI] MOV RCX,RDI CMP ESI,0x1 JLE 0x001013d0 LEA EAX,[RSI + -0x2] LEA R8D,[RSI + -0x1] CMP EAX,0x2 JBE 0x001013d3 MOVD XMM5,EDX MOV EDX,R8D MOV RAX,RDI SHR EDX,0x2 PSHUFD XMM0,XMM5,0x0 SHL RDX,0x4 MOVDQA XMM1,XMM0 ADD RDX,RDI NOP LAB_001012b0: MOVDQU XMM3,xmmword ptr [RAX + 0x4] MOVDQA XMM2,XMM0 ADD RAX,0x10 PCMPGTD XMM2,XMM3 MOVDQA XMM4,XMM3 PAND XMM4,XMM2 PANDN XMM2,XMM0 MOVDQA XMM0,XMM2 MOVDQA XMM2,XMM1 PCMPGTD XMM2,XMM3 POR XMM0,XMM4 PAND XMM1,XMM2 PANDN XMM2,XMM3 POR XMM1,XMM2 CMP RAX,RDX JNZ 0x001012b0 MOVDQA XMM3,XMM1 MOV EDI,R8D PSRLDQ XMM3,0x8 AND EDI,0xfffffffc MOVDQA XMM2,XMM3 ADD EDI,0x1 AND R8D,0x3 PCMPGTD XMM2,XMM1 PAND XMM3,XMM2 PANDN XMM2,XMM1 POR XMM2,XMM3 MOVDQA XMM3,XMM2 PSRLDQ XMM3,0x4 MOVDQA XMM1,XMM3 PCMPGTD XMM1,XMM2 PAND XMM3,XMM1 PANDN XMM1,XMM2 MOVDQA XMM2,XMM0 PSRLDQ XMM2,0x8 POR XMM1,XMM3 MOVD EAX,XMM1 MOVDQA XMM1,XMM2 PCMPGTD XMM1,XMM0 PAND XMM0,XMM1 PANDN XMM1,XMM2 POR XMM0,XMM1 MOVDQA XMM2,XMM0 PSRLDQ XMM2,0x4 MOVDQA XMM1,XMM2 PCMPGTD XMM1,XMM0 PAND XMM0,XMM1 PANDN XMM1,XMM2 POR XMM1,XMM0 MOVD EDX,XMM1 JZ 0x001013c8 LAB_00101379: MOVSXD R8,EDI LEA R9,[R8*0x4] MOV R8D,dword ptr [RCX + R8*0x4] CMP EDX,R8D CMOVG EDX,R8D CMP EAX,R8D CMOVL EAX,R8D LEA R8D,[RDI + 0x1] CMP ESI,R8D JLE 0x001013c8 MOV R8D,dword ptr [RCX + R9*0x1 + 0x4] CMP EDX,R8D CMOVG EDX,R8D CMP EAX,R8D CMOVL EAX,R8D ADD EDI,0x2 CMP ESI,EDI JLE 0x001013c8 MOV ECX,dword ptr [RCX + R9*0x1 + 0x8] CMP EDX,ECX CMOVG EDX,ECX CMP EAX,ECX CMOVL EAX,ECX LAB_001013c8: SUB EAX,EDX RET LAB_001013d0: XOR EAX,EAX RET LAB_001013d3: MOV EAX,EDX MOV EDI,0x1 JMP 0x00101379
/* func0(int*, int) */ int func0(int *param_1,int param_2) { uint uVar1; uint uVar2; uint uVar3; uint uVar4; uint uVar5; int *piVar6; int iVar7; uint uVar8; uint uVar9; uint uVar10; uint uVar11; uint uVar12; uint uVar13; uint uVar14; uint uVar15; uVar13 = *param_1; if (param_2 < 2) { return 0; } uVar8 = param_2 - 1; if (param_2 - 2U < 3) { iVar7 = 1; uVar5 = uVar13; } else { piVar6 = param_1; uVar5 = uVar13; uVar15 = uVar13; uVar14 = uVar13; uVar9 = uVar13; uVar10 = uVar13; uVar11 = uVar13; uVar12 = uVar13; do { uVar1 = piVar6[1]; uVar2 = piVar6[2]; uVar3 = piVar6[3]; uVar4 = piVar6[4]; piVar6 = piVar6 + 4; uVar9 = ~-(uint)((int)uVar1 < (int)uVar9) & uVar9 | uVar1 & -(uint)((int)uVar1 < (int)uVar9); uVar10 = ~-(uint)((int)uVar2 < (int)uVar10) & uVar10 | uVar2 & -(uint)((int)uVar2 < (int)uVar10); uVar11 = ~-(uint)((int)uVar3 < (int)uVar11) & uVar11 | uVar3 & -(uint)((int)uVar3 < (int)uVar11); uVar12 = ~-(uint)((int)uVar4 < (int)uVar12) & uVar12 | uVar4 & -(uint)((int)uVar4 < (int)uVar12); uVar13 = uVar13 & -(uint)((int)uVar1 < (int)uVar13) | ~-(uint)((int)uVar1 < (int)uVar13) & uVar1; uVar5 = uVar5 & -(uint)((int)uVar2 < (int)uVar5) | ~-(uint)((int)uVar2 < (int)uVar5) & uVar2; uVar15 = uVar15 & -(uint)((int)uVar3 < (int)uVar15) | ~-(uint)((int)uVar3 < (int)uVar15) & uVar3; uVar14 = uVar14 & -(uint)((int)uVar4 < (int)uVar14) | ~-(uint)((int)uVar4 < (int)uVar14) & uVar4; } while (piVar6 != param_1 + (ulong)(uVar8 >> 2) * 4); iVar7 = (uVar8 & 0xfffffffc) + 1; uVar15 = ~-(uint)((int)uVar13 < (int)uVar15) & uVar13 | uVar15 & -(uint)((int)uVar13 < (int)uVar15); uVar5 = ~-(uint)((int)uVar5 < (int)uVar14) & uVar5 | uVar14 & -(uint)((int)uVar5 < (int)uVar14); uVar13 = -(uint)((int)uVar15 < (int)uVar5); uVar5 = ~uVar13 & uVar15 | uVar5 & uVar13; uVar13 = uVar9 & -(uint)((int)uVar9 < (int)uVar11) | ~-(uint)((int)uVar9 < (int)uVar11) & uVar11 ; uVar15 = uVar10 & -(uint)((int)uVar10 < (int)uVar12) | ~-(uint)((int)uVar10 < (int)uVar12) & uVar12; uVar14 = -(uint)((int)uVar13 < (int)uVar15); uVar13 = ~uVar14 & uVar15 | uVar13 & uVar14; if ((uVar8 & 3) == 0) goto LAB_001013c8; } uVar8 = param_1[iVar7]; if ((int)uVar8 < (int)uVar13) { uVar13 = uVar8; } if ((int)uVar5 < (int)uVar8) { uVar5 = uVar8; } if (iVar7 + 1 < param_2) { uVar8 = param_1[(long)iVar7 + 1]; if ((int)uVar8 < (int)uVar13) { uVar13 = uVar8; } if ((int)uVar5 < (int)uVar8) { uVar5 = uVar8; } if (iVar7 + 2 < param_2) { uVar8 = param_1[(long)iVar7 + 2]; if ((int)uVar8 < (int)uVar13) { uVar13 = uVar8; } if ((int)uVar5 < (int)uVar8) { uVar5 = uVar8; } } } LAB_001013c8: return uVar5 - uVar13; }
580
func0
#include <cassert> #include <string>
int func0(const std::string& str1) { if (!str1.empty()) { return static_cast<int>(str1[0]); } return -1; // Return -1 if string is empty }
int main() { assert(func0("python") == 112); assert(func0("Program") == 80); assert(func0("Language") == 76); return 0; }
O0
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): endbr64 push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %rdi,-0x8(%rbp) mov -0x8(%rbp),%rax mov %rax,%rdi callq 12b0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv@plt> xor $0x1,%eax test %al,%al je 1425 <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3c> mov -0x8(%rbp),%rax mov $0x0,%esi mov %rax,%rdi callq 1250 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm@plt> movzbl (%rax),%eax movsbl %al,%eax jmp 142a <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x41> mov $0xffffffff,%eax leaveq retq
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 push rbp mov rbp, rsp sub rsp, 10h mov [rbp+var_8], rdi mov rax, [rbp+var_8] mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv; std::string::empty(void) xor eax, 1 test al, al jz short loc_1385 mov rax, [rbp+var_8] mov esi, 0 mov rdi, rax call __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm; std::string::operator[](ulong) movzx eax, byte ptr [rax] movsx eax, al jmp short locret_138A loc_1385: mov eax, 0FFFFFFFFh locret_138A: leave retn
long long func0(long long a1) { if ( (unsigned __int8)std::string::empty(a1) != 1 ) return (unsigned int)*(char *)std::string::operator[](a1, 0LL); else return 0xFFFFFFFFLL; }
func0: ENDBR64 PUSH RBP MOV RBP,RSP SUB RSP,0x10 MOV qword ptr [RBP + -0x8],RDI MOV RAX,qword ptr [RBP + -0x8] MOV RDI,RAX CALL 0x00101220 XOR EAX,0x1 TEST AL,AL JZ 0x00101385 MOV RAX,qword ptr [RBP + -0x8] MOV ESI,0x0 MOV RDI,RAX CALL 0x001011e0 MOVZX EAX,byte ptr [RAX] MOVSX EAX,AL JMP 0x0010138a LAB_00101385: MOV EAX,0xffffffff LAB_0010138a: LEAVE RET
/* func0(std::string const&) */ int func0(string *param_1) { char cVar1; int iVar2; char *pcVar3; cVar1 = std::string::empty(); if (cVar1 == '\x01') { iVar2 = -1; } else { pcVar3 = (char *)std::string::operator[]((ulong)param_1); iVar2 = (int)*pcVar3; } return iVar2; }
581
func0
#include <cassert> #include <string>
int func0(const std::string& str1) { if (!str1.empty()) { return static_cast<int>(str1[0]); } return -1; // Return -1 if string is empty }
int main() { assert(func0("python") == 112); assert(func0("Program") == 80); assert(func0("Language") == 76); return 0; }
O1
cpp
func0(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): endbr64 cmpq $0x0,0x8(%rdi) je 11fb <_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x12> mov (%rdi),%rax movsbl (%rax),%eax retq mov $0xffffffff,%eax retq
_Z5func0RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: endbr64 cmp qword ptr [rdi+8], 0 jz short loc_121B mov rax, [rdi] movsx eax, byte ptr [rax] retn loc_121B: mov eax, 0FFFFFFFFh retn
long long func0(char **a1) { if ( a1[1] ) return (unsigned int)**a1; else return 0xFFFFFFFFLL; }
func0: ENDBR64 CMP qword ptr [RDI + 0x8],0x0 JZ 0x0010121b MOV RAX,qword ptr [RDI] MOVSX EAX,byte ptr [RAX] RET LAB_0010121b: MOV EAX,0xffffffff RET
/* func0(std::string const&) */ int func0(string *param_1) { if (*(long *)(param_1 + 8) != 0) { return (int)**(char **)param_1; } return -1; }