// File: /workspace/github_cpp_makefile_star2_O1/GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2.cpp
// Function: GPX2::crossover(std::vector<int, std::allocator<int>>, std::vector<int, std::allocator<int>>)
vector<int> GPX2::crossover(vector<int> redT, vector<int> blueT)
{
    GPX2 obj;
    // Step 1
    obj.convertParentsToMap(redT,blueT);

    // Step 2
    obj.createGhosts();

    // Step 3
    obj.joinGraphs();

    // Step 4
    obj.cutCommonEdges();

    // Step 5
    obj.findAllPartitions();

    //the tours are equal if 0, or one of them is better if 
    if (obj.candidatePartitions.size() < 2) {
        return ((getFitness(redT) < getFitness(blueT)) ? redT : blueT);
    }

    // Step 6
    obj.checkAllPartitions();

    // Fusion
    // It's needed to have more than one unfeasible partition to fuse them
    if (obj.unfeasiblePartitions.size() > 1) {
        obj.fusion();
    }

    if (obj.feasiblePartitions.size() < 1) {
        return ((getFitness(redT) < getFitness(blueT)) ? redT : blueT);
    }

    // Step 7
    obj.choose();

    // Step 8
    obj.buildOffspring();


    // Step 9
    //return obj.convertChoosenChild();
    vector<int> offspring{obj.convertChoosenChild()};
    if(getFitness(redT) > getFitness(offspring) && getFitness(blueT) > getFitness(offspring) ){
        Log::printTourFile(redT,"red");
        Log::printTourFile(blueT,"blue");
        Log::printTourFile(offspring,"off");
    }
    return offspring;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x70(%rsp), %rcx
xorl %eax, %eax
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xa0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0xd0(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x100(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
leaq 0x148(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%rcx)
movups %xmm0, -0x28(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x178(%rsp), %rcx
movl %eax, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x30(%rcx)
leaq 0x68(%rsp), %rdi
callq 0x26d28
leaq 0x68(%rsp), %rdi
callq 0x26e22
leaq 0x68(%rsp), %rdi
callq 0x271d6
leaq 0x68(%rsp), %rdi
callq 0x278ac
leaq 0x68(%rsp), %rdi
callq 0x279fc
cmpq $0x1, 0x90(%rsp)
ja 0x26b16
movq %r15, %rdi
callq 0xf1c0
movl %eax, %ebp
movq %r14, %rdi
callq 0xf1c0
jmp 0x26c7d
leaq 0x68(%rsp), %rdi
callq 0x27ea0
cmpq $0x2, 0xf0(%rsp)
jb 0x26b35
leaq 0x68(%rsp), %rdi
callq 0x27f5e
cmpq $0x0, 0xc0(%rsp)
je 0x26c6b
leaq 0x68(%rsp), %rdi
callq 0x2807c
leaq 0x68(%rsp), %rdi
callq 0x284f6
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x289bc
movq %r15, %rdi
callq 0xf1c0
movl %eax, %ebp
movq %rbx, %rdi
callq 0xf1c0
cmpl %eax, %ebp
jle 0x26c93
movq %r14, %rdi
callq 0xf1c0
movl %eax, %ebp
movq %rbx, %rdi
callq 0xf1c0
cmpl %eax, %ebp
jle 0x26c93
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xbcea(%rip), %rsi      # 0x32894
leaq 0xbce6(%rip), %rdx      # 0x32897
leaq 0x48(%rsp), %rdi
callq 0x823c
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0xe130
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x26bdf
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xbca9(%rip), %rsi      # 0x32898
leaq 0xbca6(%rip), %rdx      # 0x3289c
leaq 0x28(%rsp), %rdi
callq 0x823c
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xe130
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x26c24
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xbc69(%rip), %rsi      # 0x3289d
leaq 0xbc65(%rip), %rdx      # 0x328a0
leaq 0x8(%rsp), %rdi
callq 0x823c
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xe130
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x26c93
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x26c93
movq %r15, %rdi
callq 0xf1c0
movl %eax, %ebp
movq %r14, %rdi
callq 0xf1c0
cmpl %eax, %ebp
setl %al
testb %al, %al
cmovneq %r15, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb05c
leaq 0x68(%rsp), %rdi
callq 0x28ad4
movq %rbx, %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x26cfd
movq 0x18(%rsp), %rsi
jmp 0x26cee
jmp 0x26cfa
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x26cfd
movq 0x38(%rsp), %rsi
jmp 0x26cee
jmp 0x26cfa
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x26cfd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x26cfd
jmp 0x26cfa
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x26d16
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x53c0
jmp 0x26d16
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x28ad4
movq %r14, %rdi
callq 0x5670