// File: /workspace/github_cpp_makefile_star2_O1/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 0xeac4
leaq 0x30(%rsp), %rdi
callq 0xeac4
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %r14, %rdi
callq 0xead4
movq (%rax), %r12
movq %r14, %rdi
callq 0xead4
movq 0x8(%rax), %r15
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
cmpq %r15, %r12
je 0x9dc2
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 0xa304
cmpq $0x181, %rbx            # imm = 0x181
jl 0x9db7
leaq 0x180(%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xa850
cmpq %r15, %r13
je 0x9dc2
movq %r13, %rdi
callq 0xa955
addq $0x18, %r13
jmp 0x9da4
movq %r12, %rdi
movq %r15, %rsi
callq 0xa850
leaq 0x38b17(%rip), %rax     # 0x428e0
movl (%rax), %eax
cmpl $0xa, %eax
jb 0x9f15
xorl %ebx, %ebx
leaq 0x88(%rsp), %r15
movq %r14, %r13
movq %r14, %rdi
callq 0xead4
leaq (%rbx,%rbx,2), %rsi
shlq $0x3, %rsi
addq (%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0xb27a
leaq 0x38adb(%rip), %rax     # 0x428e0
cmpl $0x0, (%rax)
je 0x9ecd
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x9eb4
movq %r13, %rdi
callq 0xead4
movq (%rax), %rsi
addq %r14, %rsi
leaq 0x70(%rsp), %rdi
callq 0xb05c
movq %r15, %rbp
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb05c
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movq %rbp, %rdx
callq 0x26a04
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x9e74
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x9e8e
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xb27a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9eb4
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
incq %r12
leaq 0x38a22(%rip), %rax     # 0x428e0
movl (%rax), %eax
addq $0x18, %r14
cmpq %rax, %r12
jb 0x9e14
movq (%rsp), %rdi
callq 0xead4
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb24e
incq %rbx
leaq 0x389f3(%rip), %rax     # 0x428e0
movl (%rax), %eax
movq %rax, %rcx
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
imulq %rdx, %rcx
shrq $0x23, %rcx
cmpq %rcx, %rbx
movq %r13, %r14
jb 0x9dde
movabsq $-0x5555555555555555, %rbp # imm = 0xAAAAAAAAAAAAAAAB
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x388aa(%rip), %rax     # 0x427d0
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %rsi
movq (%rsp), %rdi
callq 0x8566
movq (%rsp), %rdi
callq 0xead4
movq (%rax), %r15
movq (%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %r14
cmpq %r14, %r15
je 0x9fb8
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 0xa304
cmpq $0x181, %rbx            # imm = 0x181
jl 0x9fad
leaq 0x180(%r15), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xa850
cmpq %r14, %r12
je 0x9fb8
movq %r12, %rdi
callq 0xa955
addq $0x18, %r12
jmp 0x9f9a
movq %r15, %rdi
movq %r14, %rsi
callq 0xa850
movq 0x37fe1(%rip), %rdi     # 0x41fa0
leaq 0x273be(%rip), %rsi     # 0x31384
movl $0x15, %edx
callq 0x5440
movq (%rsp), %rdi
callq 0xeb72
movq %rax, %rdi
callq 0xf1c0
movq 0x37fb8(%rip), %rdi     # 0x41fa0
movl %eax, %esi
callq 0x5640
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5390
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5290
leaq 0x388c0(%rip), %rax     # 0x428e0
movl (%rax), %ebp
movq (%rsp), %rdi
callq 0xead4
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 0x22ea4
xorpd %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movapd %xmm0, (%rdi)
movapd 0x30(%rsp), %xmm0
movq 0x40(%rsp), %rax
leaq 0xa0(%rsp), %r14
movaps (%r14), %xmm1
movaps %xmm1, 0x30(%rsp)
movq 0x10(%r14), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x10(%rdi)
movaps (%rdi), %xmm1
movapd %xmm0, (%rdi)
movaps %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0x8102
movq %r14, %rdi
callq 0x8102
movq (%rsp), %rdi
callq 0xead4
movq %rax, %r14
movq (%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %r15
leaq 0x30(%rsp), %rdi
callq 0xead4
movq (%rax), %r12
leaq 0x30(%rsp), %rdi
callq 0xead4
movq 0x8(%rax), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xbafc
movq 0x37eaf(%rip), %rdi     # 0x41fa0
leaq 0x272a2(%rip), %rsi     # 0x3139a
movl $0x1b, %edx
callq 0x5440
movq (%rsp), %rdi
callq 0xeb72
movq %rax, %rdi
callq 0xf1c0
movq 0x37e86(%rip), %rdi     # 0x41fa0
movl %eax, %esi
callq 0x5640
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5390
movsbl %al, %esi
movq %r14, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5290
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa162
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x30(%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, %r14
jmp 0xa20f
jmp 0xa1eb
jmp 0xa1eb
jmp 0xa1eb
jmp 0xa1eb
jmp 0xa1eb
jmp 0xa1eb
movq %rax, %r14
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xa1bb
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0xa1bb
movq %rax, %r14
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xa1ee
movq 0x80(%rsp), %rsi
jmp 0xa1e1
movq %rax, %r14
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xa1ee
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0xa1ee
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa205
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x53c0
leaq 0x30(%rsp), %rdi
callq 0x8102
movq (%rsp), %rdi
callq 0x8102
movq %r14, %rdi
callq 0x5670