// File: /workspace/github_cpp_makefile_star2_O2/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 $0x168, %rsp            # imm = 0x168
movq %rcx, %r14
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdx, 0x30(%rsp)
movq %rdi, %rbx
movb $0x0, (%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x25e64
movq %r14, %rdi
callq 0x223a8
leaq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x12b1e
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x25ce4
movl $0x0, 0x8(%rsp)
leaq 0xc0(%rsp), %rbx
leaq 0x120(%rsp), %r12
movq 0xa0(%rsp), %rsi
cmpq 0x80(%rsp), %rsi
je 0x24b33
cmpq 0xa8(%rsp), %rsi
jne 0x249c6
movq 0xb8(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x5210
leaq 0x70(%rsp), %rdi
callq 0x25d0e
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x14efa
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x20910
movq (%rax), %rdi
callq 0x21c02
leaq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x20a64
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq 0x38(%rsp), %r15
je 0x24b1c
movq %r12, %rdi
movq %r15, %rsi
callq 0x209fc
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r12, %rdx
callq 0x1abd1
movq %rax, %rbx
movq 0x18(%rsp), %r14
movupd 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups 0xa0(%rsp), %xmm2
movups 0xb0(%rsp), %xmm3
movapd %xmm0, 0x100(%rsp)
movaps %xmm1, 0x110(%rsp)
movaps %xmm2, 0xe0(%rsp)
movaps %xmm3, 0xf0(%rsp)
leaq 0x148(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
movq %r12, %rcx
callq 0x25d2c
movq 0xa0(%rsp), %rbp
movq 0x148(%rsp), %r13
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %r12, %rdx
callq 0x1abd1
cmpq %r14, %rbx
jne 0x24b0b
cmpq %rbp, %r13
jne 0x24b0b
cmpq 0x48(%rsp), %rax
je 0x24b0b
cvtsi2sdl 0x8(%rsp), %xmm0
addsd 0x140(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x25ce4
cvttsd2si 0x8(%rsp), %eax
movl %eax, 0x8(%rsp)
movq %r12, %rdi
callq 0x56f8
addq $0x28, %r15
jmp 0x24a1a
leaq 0x58(%rsp), %rdi
callq 0x20abe
leaq 0xc0(%rsp), %rbx
jmp 0x24992
leaq 0x40(%rsp), %rdi
callq 0x709c
leaq 0x70(%rsp), %rdi
callq 0x25d6e
leaq 0x10(%rsp), %rdi
callq 0x709c
leaq 0xc0(%rsp), %rdi
callq 0x56f8
movl 0x8(%rsp), %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24b82
movq %rax, %rbx
jmp 0x24bc0
movq %rax, %rbx
jmp 0x24bb6
jmp 0x24b82
movq %rax, %rbx
jmp 0x24bac
jmp 0x24b8d
jmp 0x24b8d
jmp 0x24b8d
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x56f8
jmp 0x24ba2
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x20abe
leaq 0x40(%rsp), %rdi
callq 0x709c
leaq 0x70(%rsp), %rdi
callq 0x25d6e
leaq 0x10(%rsp), %rdi
callq 0x709c
leaq 0xc0(%rsp), %rdi
callq 0x56f8
movq %rbx, %rdi
callq 0x5610