// File: /workspace/github_cpp_makefile_star2_O1/GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::partialDistance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Node*, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Node*>>>, Partition*)
int GPX2Support::partialDistance(string entry, string exit, GPX2Structs::NodeMap father, Partition* partitionPtr)
{ // Distancia do SubTour da partição no pai
    //fazer uma busca em profundidade dentro da partição
    string now;
    vector<string> alreadyVisited;
    deque<string> nextToVisit;
    vector<string> partition = partitionPtr->getNodes();
    bool notAlreadyVisited{ false };
    bool notToVisit{ false };
    bool isInPartition{ false };

    int totalDistance{ 0 };

    nextToVisit.push_back(entry);

    while (!nextToVisit.empty()) {

        now = nextToVisit.back();
        nextToVisit.pop_back();
        alreadyVisited.push_back(now);
        vector<Node::node> edges = father[now]->getEdges();

        for (Node::node cn : edges) {

            notAlreadyVisited = (find(alreadyVisited.begin(), alreadyVisited.end(), cn.first) == alreadyVisited.end());
            notToVisit = (find(nextToVisit.begin(), nextToVisit.end(), cn.first) == nextToVisit.end());
            isInPartition = (find(partition.begin(), partition.end(), cn.first) != partition.end());

            if (notAlreadyVisited && notToVisit && isInPartition) {
                totalDistance += cn.second;
                nextToVisit.push_back(cn.first);
            }
        }
    }
    return (totalDistance);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rcx, %r14
movq %rdx, 0x50(%rsp)
movq %rdi, %rbx
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
movq %rax, 0x40(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
leaq 0xa0(%rsp), %rdi
movapd %xmm0, 0x40(%rdi)
movapd %xmm0, 0x30(%rdi)
movapd %xmm0, 0x20(%rdi)
movapd %xmm0, 0x10(%rdi)
movapd %xmm0, (%rdi)
xorl %esi, %esi
callq 0x2f88c
movq %r14, %rdi
callq 0x2a6bc
leaq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x17d56
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x2f798
movq 0xd0(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
je 0x2dc8c
movl $0x0, (%rsp)
leaq 0x88(%rsp), %rbp
leaq 0x10(%rsp), %rbx
leaq 0xf8(%rsp), %r14
leaq 0x78(%rsp), %r12
cmpq 0xd8(%rsp), %rsi
jne 0x2dab5
movq 0xe8(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x5210
leaq 0xa0(%rsp), %rdi
callq 0x2f7d6
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a992
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x28bca
movq (%rax), %rdi
callq 0x29d64
movq %r14, %rdi
movq %rax, %rsi
callq 0x28d04
movq 0xf8(%rsp), %r15
movq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq %rax, %r15
je 0x2dc5f
movq %rbp, 0x78(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x82cc
movsd 0x20(%r15), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x218f9
movq %rax, %r14
movq 0x38(%rsp), %rbx
movapd 0xb0(%rsp), %xmm0
movaps 0xc0(%rsp), %xmm1
movaps 0xd0(%rsp), %xmm2
movaps 0xe0(%rsp), %xmm3
movapd %xmm0, 0x130(%rsp)
movaps %xmm1, 0x140(%rsp)
movaps %xmm2, 0x110(%rsp)
movaps %xmm3, 0x120(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x110(%rsp), %rdx
movq %r12, %rcx
callq 0x2fe74
movq %r15, 0x8(%rsp)
movq %r12, %rdx
movq %rbp, %r15
movq 0xd0(%rsp), %rbp
movq 0x158(%rsp), %r13
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x218f9
cmpq %rbx, %r14
jne 0x2dc2e
cmpq %rbp, %r13
jne 0x2dc2e
cmpq 0x68(%rsp), %rax
movq %r15, %rbp
je 0x2dc31
xorps %xmm0, %xmm0
cvtsi2sdl (%rsp), %xmm0
addsd 0x98(%rsp), %xmm0
movsd %xmm0, (%rsp)
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x2f798
movq 0x8(%rsp), %r15
cvttsd2si (%rsp), %eax
movl %eax, (%rsp)
jmp 0x2dc36
movq %r15, %rbp
movq 0x8(%rsp), %r15
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2dc50
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x28, %r15
cmpq 0x58(%rsp), %r15
jne 0x2db19
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x28d9e
movq 0xd0(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
leaq 0x10(%rsp), %rbx
jne 0x2da97
jmp 0x2dc93
movl $0x0, (%rsp)
leaq 0x60(%rsp), %rdi
callq 0x81e0
leaq 0xa0(%rsp), %rdi
callq 0x2f806
leaq 0x30(%rsp), %rdi
callq 0x81e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2dcd0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
movl (%rsp), %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x2dd45
movq %rax, %r14
jmp 0x2dd5c
movq %rax, %r14
jmp 0x2dd4f
jmp 0x2dcf6
movq %rax, %r14
leaq 0x20(%rsp), %r15
jmp 0x2dd45
jmp 0x2dd04
jmp 0x2dd04
movq %rax, %r14
jmp 0x2dd19
movq %rax, %r14
leaq 0x20(%rsp), %r15
jmp 0x2dd38
movq %rax, %r14
movq %r15, %rbp
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x20(%rsp), %r15
je 0x2dd38
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0xf8(%rsp), %rdi
callq 0x28d9e
leaq 0x60(%rsp), %rdi
callq 0x81e0
leaq 0xa0(%rsp), %rdi
callq 0x2f806
leaq 0x30(%rsp), %rdi
callq 0x81e0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2dd7d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53c0
movq %r14, %rdi
callq 0x5670