// File: /workspace/github_cpp_makefile_star2_O3/GAStudyGroup[P]GPX2/src/base/sources/GAUtils.cpp
// Function: GAUtils::crossNBestxAllwithReset(Population&)
Population GAUtils::crossNBestxAllwithReset(Population &pop) {
    Population newPop;

    sort(pop.getPopulation().begin(), pop.getPopulation().end(),sortPopulation);

    for (unsigned i = 0; i < Config::N_BEST; i++) {
        vector<int> savedTour = pop.getPopulation()[i];
        for (vector<int> t : pop.getPopulation()) {
            vector<int> tmp = GPX2::crossover(savedTour, t);
            savedTour = tmp;
        }
        newPop.getPopulation().push_back(savedTour);
    }

    fillPopulationWithReset(newPop, Config::POP_SIZE*Config::RESET_PERCENTAGE);

    fillPopulationWithRoulete(pop,newPop,Config::POP_SIZE-newPop.getPopulation().size());
    
    return (newPop);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
callq 0xeaac
movq %r12, %rdi
callq 0xeabc
movq (%rax), %r14
movq %r12, %rdi
callq 0xeabc
movq 0x8(%rax), %rbx
cmpq %rbx, %r14
je 0x9a72
movq %rbx, %r15
subq %r14, %r15
movq %r15, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa2e6
cmpq $0x181, %r15            # imm = 0x181
jl 0x9a67
leaq 0x180(%r14), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xa85f
cmpq %rbx, %r15
je 0x9a72
movq %r15, %rdi
callq 0xa960
addq $0x18, %r15
jmp 0x9a54
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa85f
leaq 0x38d37(%rip), %rax     # 0x427b0
cmpl $0x0, (%rax)
je 0x9bcd
xorl %r14d, %r14d
leaq 0x80(%rsp), %r15
leaq 0x50(%rsp), %r13
leaq 0x38(%rsp), %rbp
leaq 0x68(%rsp), %rbx
movq %r12, 0x10(%rsp)
movq %r12, %rdi
callq 0xeabc
leaq (%r14,%r14,2), %rsi
shlq $0x3, %rsi
addq (%rax), %rsi
movq %r15, %rdi
callq 0xb078
movq %r14, 0x18(%rsp)
movq %r12, %rdi
callq 0xeabc
movq (%rax), %r14
movq 0x8(%rax), %r12
cmpq %r12, %r14
je 0x9b7c
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0xb078
movq %r13, %rdi
movq %r15, %rsi
callq 0xb078
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0xb078
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x26bf4
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x9b23
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9b3a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq %r15, %rdi
movq %rbx, %rsi
callq 0xb296
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x9b5c
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9b73
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
addq $0x18, %r14
jmp 0x9ad0
movq 0x8(%rsp), %rdi
callq 0xeabc
movq 0x18(%rsp), %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0xb26a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %r12
je 0x9bb8
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
incq %r14
leaq 0x38bee(%rip), %rax     # 0x427b0
movl (%rax), %eax
cmpq %rax, %r14
jb 0x9aa1
leaq 0x38cfc(%rip), %rbx     # 0x428d0
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
leaq 0x38bde(%rip), %rax     # 0x427c0
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %rsi
movq 0x8(%rsp), %rdi
callq 0x858c
movl (%rbx), %ebx
movq 0x8(%rsp), %rdi
callq 0xeabc
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x55555555, %ecx, %eax # imm = 0x55555555
addl %eax, %ebx
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movl %ebx, %edx
callq 0x8b45
movq 0x8(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9c42
jmp 0x9c42
jmp 0x9cb2
jmp 0x9cb2
movq %rax, %rbx
jmp 0x9cd2
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x9c99
movq 0x78(%rsp), %rsi
jmp 0x9c8c
movq %rax, %rbx
jmp 0x9c7d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x9c7d
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9c99
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x9c99
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9cb5
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x9cb5
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x9cd2
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x8(%rsp), %rdi
callq 0x8122
movq %rbx, %rdi
callq 0x5660