// File: /workspace/github_cpp_makefile_star2_O1/GAStudyGroup[P]GPX2/src/base/sources/GAUtils.cpp
// Function: GAUtils::crossGPX2WithAntColony(Population&)
Population GAUtils::crossGPX2WithAntColony(Population &pop){
    Population newPop, tmpPop;
    vector<int> currentTour;

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

    for (unsigned i = 0; i < Config::POP_SIZE; i++) {
        currentTour = pop.getPopulation()[i];
        for (unsigned j = 0; j < Config::POP_SIZE; j++) {
            if (i != j) {
                vector<int> t = GPX2::crossover(pop.getPopulation()[j], currentTour);
                currentTour = t;
            }
        }

        tmpPop.getPopulation().push_back(currentTour);
    }

    sort(tmpPop.getPopulation().begin(), tmpPop.getPopulation().end(),sortPopulation);
    
    newPop.getPopulation().insert(newPop.getPopulation().end(),tmpPop.getPopulation().begin(),tmpPop.getPopulation().begin()+Config::N_BEST);

    tmpPop = AntColony().run(Config::POP_SIZE-(newPop.getPopulation().size()));

    newPop.getPopulation().insert(newPop.getPopulation().end(),tmpPop.getPopulation().begin(),tmpPop.getPopulation().end());

    return newPop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r13
movq %rdi, (%rsp)
callq 0xeac4
leaq 0x10(%rsp), %rdi
callq 0xeac4
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq %r13, %rdi
callq 0xead4
movq (%rax), %r15
movq %r13, %rdi
callq 0xead4
movq 0x8(%rax), %rbx
cmpq %rbx, %r15
je 0x9416
movq %rbx, %r14
subq %r15, %r14
movq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa304
cmpq $0x181, %r14            # imm = 0x181
jl 0x940b
leaq 0x180(%r15), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xa850
cmpq %rbx, %r12
je 0x9416
movq %r12, %rdi
callq 0xa955
addq $0x18, %r12
jmp 0x93f8
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa850
leaq 0x394c3(%rip), %rax     # 0x428e0
cmpl $0x0, (%rax)
je 0x954f
xorl %r12d, %r12d
leaq 0x88(%rsp), %r15
movq %r13, %rbp
movq %r13, %rdi
callq 0xead4
leaq (%r12,%r12,2), %rsi
shlq $0x3, %rsi
addq (%rax), %rsi
leaq 0x30(%rsp), %rdi
callq 0xb27a
leaq 0x39488(%rip), %rax     # 0x428e0
cmpl $0x0, (%rax)
je 0x9520
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x9507
movq %rbp, %rdi
callq 0xead4
movq (%rax), %rsi
addq %r14, %rsi
leaq 0x70(%rsp), %rdi
callq 0xb05c
movq %r15, %rbx
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0xb05c
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movq %rbx, %rdx
callq 0x26a04
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x94c7
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x94e1
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xb27a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9507
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
incq %r13
leaq 0x393cf(%rip), %rax     # 0x428e0
movl (%rax), %eax
addq $0x18, %r14
cmpq %rax, %r13
jb 0x9467
leaq 0x10(%rsp), %rdi
callq 0xead4
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0xb24e
incq %r12
leaq 0x3939f(%rip), %rax     # 0x428e0
movl (%rax), %eax
cmpq %rax, %r12
movq %rbp, %r13
jb 0x9431
leaq 0x10(%rsp), %rdi
callq 0xead4
movq (%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %rbx
cmpq %rbx, %r14
je 0x95db
movq %rbx, %r15
subq %r14, %r15
movq %r15, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa304
cmpq $0x181, %r15            # imm = 0x181
jl 0x95d0
leaq 0x180(%r14), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xa850
cmpq %rbx, %r15
je 0x95db
movq %r15, %rdi
callq 0xa955
addq $0x18, %r15
jmp 0x95bd
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa850
movq (%rsp), %rdi
callq 0xead4
movq %rax, %rbx
movq (%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xead4
movq (%rax), %r15
leaq 0x10(%rsp), %rdi
callq 0xead4
leaq 0x391ae(%rip), %rcx     # 0x427c0
movl (%rcx), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq (%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xbafc
leaq 0x392ac(%rip), %rax     # 0x428e0
movl (%rax), %ebx
movq (%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x55555555, %ecx, %eax # imm = 0x55555555
addl %eax, %ebx
leaq 0xa0(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movl %ebx, %edx
callq 0x22ea4
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movaps %xmm0, (%rdi)
movaps 0x10(%rsp), %xmm0
movq 0x20(%rsp), %rax
leaq 0xa0(%rsp), %rbx
movaps (%rbx), %xmm1
movaps %xmm1, 0x10(%rsp)
movq 0x10(%rbx), %rcx
movq %rcx, 0x20(%rsp)
movq %rax, 0x10(%rdi)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movaps %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x8102
movq %rbx, %rdi
callq 0x8102
movq (%rsp), %rdi
callq 0xead4
movq %rax, %rbx
movq (%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xead4
movq (%rax), %r15
leaq 0x10(%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xbafc
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x970f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
callq 0x8102
movq (%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x97c0
jmp 0x979c
jmp 0x979c
jmp 0x979c
jmp 0x979c
jmp 0x979c
jmp 0x979c
jmp 0x979c
jmp 0x979c
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x976c
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0x976c
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x979f
movq 0x80(%rsp), %rsi
jmp 0x9792
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x979f
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0x979f
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x97b6
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
callq 0x8102
movq (%rsp), %rdi
callq 0x8102
movq %rbx, %rdi
callq 0x5670