// File: /workspace/github_cpp_makefile_star2_O3/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 0x2fae6
movq %r14, %rdi
callq 0x2a8d0
leaq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x17d42
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x2f9ea
movq 0xd0(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
je 0x2dec9
movl $0x0, (%rsp)
leaq 0x88(%rsp), %rbp
leaq 0x10(%rsp), %rbx
leaq 0xf8(%rsp), %r14
leaq 0x78(%rsp), %r12
cmpq 0xd8(%rsp), %rsi
jne 0x2dcf2
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 0x2fa28
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x1aa0a
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x28dba
movq (%rax), %rdi
callq 0x29f78
movq %r14, %rdi
movq %rax, %rsi
callq 0x28efa
movq 0xf8(%rsp), %r15
movq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq %rax, %r15
je 0x2de9c
movq %rbp, 0x78(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x82fa
movsd 0x20(%r15), %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x219d3
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 0x300dc
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 0x219d3
cmpq %rbx, %r14
jne 0x2de6b
cmpq %rbp, %r13
jne 0x2de6b
cmpq 0x68(%rsp), %rax
movq %r15, %rbp
je 0x2de6e
xorps %xmm0, %xmm0
cvtsi2sdl (%rsp), %xmm0
addsd 0x98(%rsp), %xmm0
movsd %xmm0, (%rsp)
leaq 0xa0(%rsp), %rdi
movq %r12, %rsi
callq 0x2f9ea
movq 0x8(%rsp), %r15
cvttsd2si (%rsp), %eax
movl %eax, (%rsp)
jmp 0x2de73
movq %r15, %rbp
movq 0x8(%rsp), %r15
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2de8d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53b0
addq $0x28, %r15
cmpq 0x58(%rsp), %r15
jne 0x2dd56
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x28f94
movq 0xd0(%rsp), %rsi
cmpq 0xb0(%rsp), %rsi
leaq 0x10(%rsp), %rbx
jne 0x2dcd4
jmp 0x2ded0
movl $0x0, (%rsp)
leaq 0x60(%rsp), %rdi
callq 0x8206
leaq 0xa0(%rsp), %rdi
callq 0x2fa58
leaq 0x30(%rsp), %rdi
callq 0x8206
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2df0d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53b0
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 0x2df82
movq %rax, %r14
jmp 0x2df99
movq %rax, %r14
jmp 0x2df8c
jmp 0x2df33
movq %rax, %r14
leaq 0x20(%rsp), %r15
jmp 0x2df82
jmp 0x2df41
jmp 0x2df41
movq %rax, %r14
jmp 0x2df56
movq %rax, %r14
leaq 0x20(%rsp), %r15
jmp 0x2df75
movq %rax, %r14
movq %r15, %rbp
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x20(%rsp), %r15
je 0x2df75
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0xf8(%rsp), %rdi
callq 0x28f94
leaq 0x60(%rsp), %rdi
callq 0x8206
leaq 0xa0(%rsp), %rdi
callq 0x2fa58
leaq 0x30(%rsp), %rdi
callq 0x8206
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x2dfba
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53b0
movq %r14, %rdi
callq 0x5660