// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movq %rsi, %r14
movq %rdi, (%rsp)
callq 0xb97c
leaq 0x10(%rsp), %rdi
callq 0xb97c
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq %r14, %rdi
callq 0xb988
movq (%rax), %rbx
movq %r14, %rdi
callq 0xb988
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x8442
xorl %ebx, %ebx
leaq 0x80(%rsp), %r12
leaq 0x68(%rsp), %r13
leaq 0x50(%rsp), %rbp
xorl %r15d, %r15d
movq %r14, 0x28(%rsp)
leaq 0x34ad0(%rip), %rax     # 0x3c8c0
movl (%rax), %eax
cmpq %rax, %r15
jae 0x7ecb
movq %r14, %rdi
callq 0xb988
imulq $0x18, %r15, %rsi
addq (%rax), %rsi
leaq 0x30(%rsp), %rdi
callq 0x93b6
movq %r15, 0x48(%rsp)
leaq 0x34aa0(%rip), %rax     # 0x3c8c0
movl (%rax), %eax
xorl %r14d, %r14d
xorl %r15d, %r15d
movl %eax, %ecx
cmpq %rcx, %r15
jae 0x7e9e
cmpq %r14, %rbx
je 0x7e95
movq 0x28(%rsp), %rdi
callq 0xb988
movq (%rax), %rsi
addq %r14, %rsi
movq %r12, %rdi
callq 0x9210
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
callq 0x9210
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1f198
movq %r13, %rdi
callq 0x6e4c
movq %r12, %rdi
callq 0x6e4c
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x93b6
movq %rbp, %rdi
callq 0x6e4c
leaq 0x34a2d(%rip), %rax     # 0x3c8c0
movl (%rax), %eax
incq %r15
addq $0x18, %r14
jmp 0x7e28
leaq 0x10(%rsp), %rdi
callq 0xb988
movq 0x48(%rsp), %r15
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x938a
incq %r15
addq $0x18, %rbx
movq 0x28(%rsp), %r14
jmp 0x7de9
leaq 0x10(%rsp), %rdi
callq 0xb988
movq (%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xb988
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x8442
movq (%rsp), %rdi
callq 0xb988
movq %rax, %r12
movq (%rsp), %rdi
callq 0xb988
movq 0x8(%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xb988
movq (%rax), %r15
leaq 0x10(%rsp), %rdi
callq 0xb988
leaq 0x3487b(%rip), %rcx     # 0x3c7a0
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq (%rax), %rcx
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x9480
leaq 0x3497d(%rip), %rax     # 0x3c8c0
movl (%rax), %ebx
movq (%rsp), %rdi
callq 0xb988
movq 0x8(%rax), %rcx
subq (%rax), %rcx
pushq $-0x18
popq %rsi
movq %rcx, %rax
cqto
idivq %rsi
addl %eax, %ebx
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movl %ebx, %edx
callq 0x1bee4
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rbx
movq %rbx, %rsi
callq 0x6d8c
movq %rbx, %rdi
callq 0x6dde
movq (%rsp), %rdi
callq 0xb988
movq %rax, %rbx
movq (%rsp), %rdi
callq 0xb988
movq 0x8(%rax), %r14
leaq 0x10(%rsp), %rdi
callq 0xb988
movq (%rax), %r15
leaq 0x10(%rsp), %rdi
callq 0xb988
movq 0x8(%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x9480
leaq 0x30(%rsp), %rdi
callq 0x6e4c
leaq 0x10(%rsp), %rdi
callq 0x6dde
movq (%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x804c
jmp 0x8035
jmp 0x8035
jmp 0x8035
jmp 0x8035
jmp 0x8035
jmp 0x8035
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x802e
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x6e4c
jmp 0x8026
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x6e4c
jmp 0x8038
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6e4c
leaq 0x10(%rsp), %rdi
callq 0x6dde
movq (%rsp), %rdi
callq 0x6dde
movq %rbx, %rdi
callq 0x5610