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

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

    for (unsigned i = 0; i < Config::POP_SIZE/10; 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;
            }
        }

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

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

    sort(newPop.getPopulation().begin(), newPop.getPopulation().end(),sortPopulation);
    cout<<"Best tour from GPX2: "<<getFitness(newPop.getBestTour())<<endl;
    // cout<<newPop<<endl;

    // AntMap::updatePheromoneMap(newPop.getBestTour());

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

    // cout<<tmpPop<<endl;

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

    cout<<"Best tour after AntColony: "<<getFitness(newPop.getBestTour())<<endl;
    // cout<<newPop<<endl;

    // cin.get();

    return newPop;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, (%rsp)
callq 0xeaac
leaq 0x30(%rsp), %rdi
callq 0xeaac
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %r14, %rdi
callq 0xeabc
movq (%rax), %r12
movq %r14, %rdi
callq 0xeabc
movq 0x8(%rax), %r15
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
cmpq %r15, %r12
je 0x9da7
movq %r15, %rbx
subq %r12, %rbx
movq %rbx, %rax
sarq $0x3, %rax
imulq %rbp, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2e6
cmpq $0x181, %rbx            # imm = 0x181
jl 0x9d9c
leaq 0x180(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xa85f
cmpq %r15, %r13
je 0x9da7
movq %r13, %rdi
callq 0xa960
addq $0x18, %r13
jmp 0x9d89
movq %r12, %rdi
movq %r15, %rsi
callq 0xa85f
leaq 0x38b22(%rip), %rax     # 0x428d0
movl (%rax), %eax
cmpl $0xa, %eax
jb 0x9efd
xorl %ebx, %ebx
leaq 0x88(%rsp), %r15
movq %r14, %r13
movq %r14, %rdi
callq 0xeabc
leaq (%rbx,%rbx,2), %rsi
shlq $0x3, %rsi
addq (%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0xb296
leaq 0x38ae6(%rip), %rax     # 0x428d0
movl (%rax), %eax
testl %eax, %eax
je 0x9eb5
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x9ea3
movq %r13, %rdi
callq 0xeabc
movq (%rax), %rsi
addq %r14, %rsi
leaq 0x70(%rsp), %rdi
callq 0xb078
movq %r15, %rbp
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb078
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movq %rbp, %rdx
callq 0x26bf4
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x9e5a
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x9e74
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xb296
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9e9a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
leaq 0x38a2f(%rip), %rax     # 0x428d0
movl (%rax), %eax
incq %r12
movl %eax, %ecx
addq $0x18, %r14
cmpq %rcx, %r12
jb 0x9dfa
movq (%rsp), %rdi
callq 0xeabc
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb26a
incq %rbx
leaq 0x389fb(%rip), %rax     # 0x428d0
movl (%rax), %eax
movq %rax, %rcx
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
imulq %rdx, %rcx
shrq $0x23, %rcx
cmpq %rcx, %rbx
movq %r13, %r14
jb 0x9dc3
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x388b2(%rip), %rax     # 0x427c0
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %rsi
movq (%rsp), %rdi
callq 0x858c
movq (%rsp), %rdi
callq 0xeabc
movq (%rax), %r15
movq (%rsp), %rdi
callq 0xeabc
movq 0x8(%rax), %r14
cmpq %r14, %r15
je 0x9fa0
movq %r14, %rbx
subq %r15, %rbx
movq %rbx, %rax
sarq $0x3, %rax
imulq %rbp, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xa2e6
cmpq $0x181, %rbx            # imm = 0x181
jl 0x9f95
leaq 0x180(%r15), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xa85f
cmpq %r14, %r12
je 0x9fa0
movq %r12, %rdi
callq 0xa960
addq $0x18, %r12
jmp 0x9f82
movq %r15, %rdi
movq %r14, %rsi
callq 0xa85f
movq 0x37ff9(%rip), %rdi     # 0x41fa0
leaq 0x273d6(%rip), %rsi     # 0x31384
movl $0x15, %edx
callq 0x5430
movq (%rsp), %rdi
callq 0xeb5a
movq %rax, %rdi
callq 0xf1cc
movq 0x37fd0(%rip), %rdi     # 0x41fa0
movl %eax, %esi
callq 0x5630
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5380
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5290
leaq 0x388c8(%rip), %rax     # 0x428d0
movl (%rax), %ebp
movq (%rsp), %rdi
callq 0xeabc
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x55555555, %ecx, %eax # imm = 0x55555555
addl %eax, %ebp
leaq 0xa0(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movl %ebp, %edx
callq 0x22f1c
movq 0x40(%rsp), %rax
leaq 0xa0(%rsp), %r14
movapd (%r14), %xmm0
movq 0x10(%r14), %rcx
movq %rcx, 0x40(%rsp)
movaps 0x30(%rsp), %xmm1
movapd %xmm0, 0x30(%rsp)
leaq 0x50(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0x8122
movq %r14, %rdi
callq 0x8122
movq (%rsp), %rdi
callq 0xeabc
movq %rax, %r14
movq (%rsp), %rdi
callq 0xeabc
movq 0x8(%rax), %r15
leaq 0x30(%rsp), %rdi
callq 0xeabc
movq (%rax), %r12
leaq 0x30(%rsp), %rdi
callq 0xeabc
movq 0x8(%rax), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xbb22
movq 0x37ecd(%rip), %rdi     # 0x41fa0
leaq 0x272c0(%rip), %rsi     # 0x3139a
movl $0x1b, %edx
callq 0x5430
movq (%rsp), %rdi
callq 0xeb5a
movq %rax, %rdi
callq 0xf1cc
movq 0x37ea4(%rip), %rdi     # 0x41fa0
movl %eax, %esi
callq 0x5630
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5380
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5290
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa144
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
leaq 0x30(%rsp), %rdi
callq 0x8122
movq (%rsp), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0xa1f1
jmp 0xa1cd
jmp 0xa1cd
jmp 0xa1cd
jmp 0xa1cd
jmp 0xa1cd
jmp 0xa1cd
movq %rax, %r14
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xa19d
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0xa19d
movq %rax, %r14
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xa1d0
movq 0x80(%rsp), %rsi
jmp 0xa1c3
movq %rax, %r14
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xa1d0
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0xa1d0
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa1e7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53b0
leaq 0x30(%rsp), %rdi
callq 0x8122
movq (%rsp), %rdi
callq 0x8122
movq %r14, %rdi
callq 0x5660