// File: 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:
subq $0x208, %rsp            # imm = 0x208
movq %rdi, 0xa8(%rsp)
movq %rdi, %rax
movq %rax, 0xb0(%rsp)
movq %rdi, 0x200(%rsp)
movq %rsi, 0x1f8(%rsp)
movb $0x0, 0x1f7(%rsp)
callq 0x19220
leaq 0x1d8(%rsp), %rdi
callq 0x19220
jmp 0xbeb6
leaq 0x1b0(%rsp), %rdi
callq 0xfdf0
movq 0x1f8(%rsp), %rdi
callq 0x19230
movq %rax, 0xa0(%rsp)
jmp 0xbeda
movq 0xa0(%rsp), %rdi
callq 0xfc20
movq %rax, 0x1a8(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x19230
movq %rax, 0x98(%rsp)
jmp 0xbf06
movq 0x98(%rsp), %rdi
callq 0xfc50
movq %rax, 0x1a0(%rsp)
movq 0x1a8(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
callq 0xcb50
jmp 0xbf32
movl $0x0, 0x198(%rsp)
movl 0x198(%rsp), %eax
leaq 0x90ab5(%rip), %rcx     # 0x9ca00
cmpl (%rcx), %eax
jae 0xc17e
movq 0x1f8(%rsp), %rdi
callq 0x19230
movq %rax, 0x90(%rsp)
jmp 0xbf6a
movq 0x90(%rsp), %rdi
movl 0x198(%rsp), %eax
movl %eax, %esi
callq 0x10230
movq %rax, %rsi
leaq 0x1b0(%rsp), %rdi
callq 0x10250
jmp 0xbf92
movl $0x0, 0x194(%rsp)
movl 0x194(%rsp), %eax
leaq 0x90a55(%rip), %rcx     # 0x9ca00
cmpl (%rcx), %eax
jae 0xc138
movl 0x198(%rsp), %eax
cmpl 0x194(%rsp), %eax
je 0xc120
movq 0x1f8(%rsp), %rdi
callq 0x19230
movq %rax, 0x88(%rsp)
jmp 0xbfde
movq 0x88(%rsp), %rdi
movl 0x194(%rsp), %eax
movl %eax, %esi
callq 0x10230
movq %rax, %rsi
leaq 0x160(%rsp), %rdi
callq 0xfcd0
jmp 0xc006
leaq 0x148(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0xfcd0
jmp 0xc01d
leaq 0x178(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x5dd80
jmp 0xc03c
leaq 0x148(%rsp), %rdi
callq 0x9af0
leaq 0x160(%rsp), %rdi
callq 0x9af0
leaq 0x1b0(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x10250
jmp 0xc06d
leaq 0x178(%rsp), %rdi
callq 0x9af0
jmp 0xc120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0xc47a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0xc441
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0xc0e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x9af0
leaq 0x160(%rsp), %rdi
callq 0x9af0
jmp 0xc441
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x9af0
jmp 0xc441
jmp 0xc122
movl 0x194(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x194(%rsp)
jmp 0xbf9d
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x80(%rsp)
jmp 0xc14f
movq 0x80(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x10190
jmp 0xc166
jmp 0xc168
movl 0x198(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x198(%rsp)
jmp 0xbf3d
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x78(%rsp)
jmp 0xc192
movq 0x78(%rsp), %rdi
callq 0xfc20
movq %rax, 0x140(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x70(%rsp)
jmp 0xc1b8
movq 0x70(%rsp), %rdi
callq 0xfc50
movq %rax, 0x138(%rsp)
movq 0x140(%rsp), %rdi
movq 0x138(%rsp), %rsi
callq 0xcb50
jmp 0xc1e1
movq 0xa8(%rsp), %rdi
callq 0x19230
movq %rax, 0x68(%rsp)
jmp 0xc1f5
movq 0xa8(%rsp), %rdi
callq 0x19230
movq %rax, 0x60(%rsp)
jmp 0xc209
movq 0x60(%rsp), %rdi
callq 0xfc50
movq %rax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x105f0
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x58(%rsp)
jmp 0xc244
movq 0x58(%rsp), %rdi
callq 0xfc20
movq %rax, 0x118(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x50(%rsp)
jmp 0xc26a
movq 0x50(%rsp), %rdi
callq 0xfc20
movq %rax, 0x108(%rsp)
leaq 0x9065d(%rip), %rax     # 0x9c8e0
movl (%rax), %eax
movl %eax, %esi
leaq 0x108(%rsp), %rdi
callq 0x10630
movq 0x68(%rsp), %rdi
movq %rax, 0x110(%rsp)
movq 0x128(%rsp), %rsi
movq 0x118(%rsp), %rdx
movq 0x110(%rsp), %rcx
callq 0x10530
movq %rax, 0x48(%rsp)
jmp 0xc2c5
movq 0xa8(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, 0x100(%rsp)
leaq 0x9071f(%rip), %rax     # 0x9ca00
movl (%rax), %eax
movq %rax, 0x38(%rsp)
callq 0x19230
movq %rax, 0x40(%rsp)
jmp 0xc2f4
movq 0x40(%rsp), %rdi
callq 0x10510
movq 0x38(%rsp), %rcx
movl %ecx, %edx
subl %eax, %edx
leaq 0xe8(%rsp), %rdi
leaq 0xe7(%rsp), %rsi
callq 0x4ff30
jmp 0xc31e
leaq 0x1d8(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
movq %rsi, 0x28(%rsp)
callq 0x9410
movq 0x28(%rsp), %rdi
callq 0x9440
movq 0xa8(%rsp), %rdi
callq 0x19230
movq %rax, 0x30(%rsp)
jmp 0xc356
movq 0xa8(%rsp), %rdi
callq 0x19230
movq %rax, 0x20(%rsp)
jmp 0xc36a
movq 0x20(%rsp), %rdi
callq 0xfc50
movq %rax, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x105f0
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x18(%rsp)
jmp 0xc3a5
movq 0x18(%rsp), %rdi
callq 0xfc20
movq %rax, 0xc8(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x19230
movq %rax, 0x10(%rsp)
jmp 0xc3cb
movq 0x10(%rsp), %rdi
callq 0xfc50
movq 0x30(%rsp), %rdi
movq %rax, 0xc0(%rsp)
movq 0xd8(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0x10530
movq %rax, 0x8(%rsp)
jmp 0xc406
movq 0x8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movb $0x1, 0x1f7(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x9af0
leaq 0x1d8(%rsp), %rdi
callq 0x9440
testb $0x1, 0x1f7(%rsp)
jne 0xc46a
jmp 0xc45d
leaq 0x1b0(%rsp), %rdi
callq 0x9af0
leaq 0x1d8(%rsp), %rdi
callq 0x9440
jmp 0xc47a
movq 0xa8(%rsp), %rdi
callq 0x9440
movq 0xb0(%rsp), %rax
addq $0x208, %rsp            # imm = 0x208
retq
movq 0xa8(%rsp), %rdi
callq 0x9440
movq 0x1d0(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)