// File: /workspace/github_cpp_makefile_star2_O3/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 0x26f36
leaq 0x68(%rsp), %rdi
callq 0x27030
leaq 0x68(%rsp), %rdi
callq 0x273c2
leaq 0x68(%rsp), %rdi
callq 0x27aa2
leaq 0x68(%rsp), %rdi
callq 0x27bf6
cmpq $0x1, 0x90(%rsp)
ja 0x26d06
movq %r15, %rdi
callq 0xf1cc
movl %eax, %ebp
movq %r14, %rdi
callq 0xf1cc
jmp 0x26e8b
leaq 0x68(%rsp), %rdi
callq 0x28092
cmpq $0x2, 0xf0(%rsp)
jb 0x26d25
leaq 0x68(%rsp), %rdi
callq 0x28150
cmpq $0x0, 0xc0(%rsp)
je 0x26e79
leaq 0x68(%rsp), %rdi
callq 0x2826e
leaq 0x68(%rsp), %rdi
callq 0x286e6
leaq 0x140(%rsp), %rax
cmpl $0x0, 0x78(%rax)
leaq 0x170(%rsp), %r12
cmoveq %rax, %r12
movq %r12, %rdi
callq 0x2e601
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2d7d0
movq %r15, %rdi
callq 0xf1cc
movl %eax, %ebp
movq %rbx, %rdi
callq 0xf1cc
cmpl %eax, %ebp
jle 0x26ea1
movq %r14, %rdi
callq 0xf1cc
movl %eax, %ebp
movq %rbx, %rdi
callq 0xf1cc
cmpl %eax, %ebp
jle 0x26ea1
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xbadc(%rip), %rsi      # 0x32894
leaq 0xbad8(%rip), %rdx      # 0x32897
leaq 0x48(%rsp), %rdi
callq 0x8264
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0xe0c9
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x26ded
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xba9b(%rip), %rsi      # 0x32898
leaq 0xba98(%rip), %rdx      # 0x3289c
leaq 0x28(%rsp), %rdi
callq 0x8264
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xe0c9
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x26e32
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xba5b(%rip), %rsi      # 0x3289d
leaq 0xba57(%rip), %rdx      # 0x328a0
leaq 0x8(%rsp), %rdi
callq 0x8264
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xe0c9
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x26ea1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x26ea1
movq %r15, %rdi
callq 0xf1cc
movl %eax, %ebp
movq %r14, %rdi
callq 0xf1cc
cmpl %eax, %ebp
setl %al
testb %al, %al
cmovneq %r15, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb078
leaq 0x68(%rsp), %rdi
callq 0x28cc4
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 0x26f0b
movq 0x18(%rsp), %rsi
jmp 0x26efc
jmp 0x26f08
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x26f0b
movq 0x38(%rsp), %rsi
jmp 0x26efc
jmp 0x26f08
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x26f0b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x26f0b
jmp 0x26f08
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x26f24
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x53b0
jmp 0x26f24
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x28cc4
movq %r14, %rdi
callq 0x5660