// File: GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::printMap(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*>>>&, std::ostream&)
void GPX2Support::printMap(GPX2Structs::NodeMap& graph, std::ostream& stream)
{
    stream << "size: " << graph.size() << "\n";
    for (map<string, Node*>::iterator it = graph.begin(); it != graph.end(); it++) {
        stream << " " << it->first << " | " << graph[it->first]->getId() <<  "\n";
        if (it->second->getAccess()) {
            stream << "Access: " << true <<  "\n";
        } else {
            stream << "Access: " << false <<  "\n";
        }
        stream << "==================================\n";

        stream << "connections: " << it->second->getEdges().size() <<  "\n";
        for (unsigned i = 0; i < it->second->getEdges().size(); i++) {
            stream << "Edge " << i << ": " << graph[it->second->getEdges()[i].first]->getId();
            stream << "\t#\t";
            stream << "Distance: " << it->second->getEdges()[i].second << "\n";
        }
        stream << "----------------------------------\n";
    }

    stream << "______________________________________________________________THE DIVISION______________________________________________________________\n";

    deque<string> nextToVisit;
    vector<string> isAlreadyVisited;
    bool notAlreadyVisited{ false };
    bool notToVisit{ false };

    Node* city = graph.begin()->second; // Reduzir chamadas (Node dentro do map)

    isAlreadyVisited.push_back(graph.begin()->first);
    stream << graph.begin()->first << "\n";
    nextToVisit.push_back(city->getEdges()[0].first);

    while (!nextToVisit.empty()) {

        stream << nextToVisit.front() << "\n";
        isAlreadyVisited.push_back(nextToVisit.front());
        city = graph[nextToVisit.front()];
        nextToVisit.pop_front();

        for (Node::node n : city->getEdges()) {

            notAlreadyVisited = find(isAlreadyVisited.begin(), isAlreadyVisited.end(), n.first) == isAlreadyVisited.end();
            notToVisit = find(nextToVisit.begin(), nextToVisit.end(), n.first) == nextToVisit.end();

            if (notAlreadyVisited && notToVisit) {
                nextToVisit.push_back(n.first);
            }
        }
    }
    stream << "size " << isAlreadyVisited.size() << "\n";
    stream << "map size " << graph.size() << "\n";
    stream.flush();
}

// Assembly:
subq $0x2e8, %rsp            # imm = 0x2E8
movq %rdi, 0x2e0(%rsp)
movq %rsi, 0x2d8(%rsp)
movq 0x2d8(%rsp), %rdi
leaq 0x7465(%rip), %rsi      # 0x758fb
callq 0x64a0
movq %rax, 0xf8(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x70c20
movq 0xf8(%rsp), %rdi
movq %rax, %rsi
callq 0x6100
movq %rax, %rdi
leaq 0x7384(%rip), %rsi      # 0x7584e
callq 0x64a0
movq 0x2e0(%rsp), %rdi
callq 0x60ba0
movq %rax, 0x2d0(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x60bd0
movq %rax, 0x2c8(%rsp)
leaq 0x2d0(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x60c00
testb $0x1, %al
jne 0x6e517
jmp 0x6e8f1
movq 0x2d8(%rsp), %rdi
leaq 0x5e2e(%rip), %rsi      # 0x74354
callq 0x64a0
movq %rax, 0xc8(%rsp)
leaq 0x2d0(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x70c00
movq 0xc8(%rsp), %rdi
movq %rax, %rsi
callq 0x6440
movq %rax, %rdi
leaq 0x744a(%rip), %rsi      # 0x759ac
callq 0x64a0
movq 0xd0(%rsp), %rdi
movq %rax, 0xe0(%rsp)
movq 0x2e0(%rsp), %rax
movq %rax, 0xd8(%rsp)
callq 0x70c00
movq 0xd8(%rsp), %rdi
movq %rax, %rsi
callq 0x60c60
movq (%rax), %rsi
leaq 0x2a8(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0x66190
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x6440
movq %rax, 0xf0(%rsp)
jmp 0x6e5d3
movq 0xf0(%rsp), %rdi
leaq 0x726c(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6e5e9
leaq 0x2a8(%rsp), %rdi
callq 0x6988
leaq 0x2d0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rdi
callq 0x661d0
testb $0x1, %al
jne 0x6e612
jmp 0x6e66a
movq 0x2d8(%rsp), %rdi
leaq 0x738f(%rip), %rsi      # 0x759b0
callq 0x64a0
movq %rax, %rdi
movl $0x1, %esi
callq 0x6870
movq %rax, %rdi
leaq 0x7211(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6e697
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x6988
jmp 0x6ee0d
movq 0x2d8(%rsp), %rdi
leaq 0x7337(%rip), %rsi      # 0x759b0
callq 0x64a0
movq %rax, %rdi
xorl %esi, %esi
callq 0x6870
movq %rax, %rdi
leaq 0x71bc(%rip), %rsi      # 0x7584e
callq 0x64a0
movq 0x2d8(%rsp), %rdi
leaq 0x7313(%rip), %rsi      # 0x759b9
callq 0x64a0
movq 0x2d8(%rsp), %rdi
leaq 0x7323(%rip), %rsi      # 0x759dd
callq 0x64a0
movq %rax, 0xc0(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rdi
callq 0x661c0
movq %rax, %rdi
callq 0x610e0
movq 0xc0(%rsp), %rdi
movq %rax, %rsi
callq 0x6100
movq %rax, %rdi
leaq 0x714f(%rip), %rsi      # 0x7584e
callq 0x64a0
movl $0x0, 0x298(%rsp)
movl 0x298(%rsp), %eax
movq %rax, 0xb8(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rdi
callq 0x661c0
movq %rax, %rdi
callq 0x610e0
movq %rax, %rcx
movq 0xb8(%rsp), %rax
cmpq %rcx, %rax
jae 0x6e8c1
movq 0x2d8(%rsp), %rdi
leaq 0x728c(%rip), %rsi      # 0x759eb
callq 0x64a0
movq %rax, %rdi
movl 0x298(%rsp), %esi
callq 0x6660
movq %rax, %rdi
leaq 0x5bd6(%rip), %rsi      # 0x74353
callq 0x64a0
movq %rax, 0xa8(%rsp)
movq 0x2e0(%rsp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rdi
callq 0x661c0
movq %rax, %rdi
movl 0x298(%rsp), %eax
movl %eax, %esi
callq 0x60c40
movq 0xa0(%rsp), %rdi
movq %rax, %rsi
callq 0x60c60
movq (%rax), %rsi
leaq 0x278(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x66190
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x6440
jmp 0x6e800
leaq 0x278(%rsp), %rdi
callq 0x6988
movq 0x2d8(%rsp), %rdi
leaq 0x71d5(%rip), %rsi      # 0x759f1
callq 0x64a0
movq 0x2d8(%rsp), %rdi
leaq 0x71c5(%rip), %rsi      # 0x759f5
callq 0x64a0
movq %rax, 0x98(%rsp)
leaq 0x2d0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rdi
callq 0x661c0
movq %rax, %rdi
movl 0x298(%rsp), %eax
movl %eax, %esi
callq 0x60c40
movq 0x98(%rsp), %rdi
movsd 0x20(%rax), %xmm0
callq 0x6900
movq %rax, %rdi
leaq 0x6fce(%rip), %rsi      # 0x7584e
callq 0x64a0
movl 0x298(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x298(%rsp)
jmp 0x6e70f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x6988
jmp 0x6ee0d
movq 0x2d8(%rsp), %rdi
leaq 0x7130(%rip), %rsi      # 0x75a00
callq 0x64a0
leaq 0x2d0(%rsp), %rdi
xorl %esi, %esi
callq 0x70c30
movq %rax, 0x270(%rsp)
jmp 0x6e4e4
movq 0x2d8(%rsp), %rdi
leaq 0x7124(%rip), %rsi      # 0x75a24
callq 0x64a0
leaq 0x220(%rsp), %rdi
callq 0x70690
leaq 0x208(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x1e3e0
movb $0x0, 0x207(%rsp)
movb $0x0, 0x206(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x60ba0
movq %rax, 0x1f0(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x70c00
movq 0x20(%rax), %rax
movq %rax, 0x1f8(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x60ba0
movq %rax, 0x1e8(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x70c00
movq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x37210
jmp 0x6e999
movq 0x2d8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x60ba0
movq %rax, 0x1e0(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x70c00
movq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x6440
movq %rax, 0x88(%rsp)
jmp 0x6e9e5
movq 0x88(%rsp), %rdi
leaq 0x6e5a(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6e9fb
movq 0x1f8(%rsp), %rdi
callq 0x661c0
movq %rax, 0x78(%rsp)
jmp 0x6ea0f
movq 0x78(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x60c40
movq %rax, %rsi
leaq 0x220(%rsp), %rdi
callq 0x706a0
jmp 0x6ea2f
jmp 0x6ea31
leaq 0x220(%rsp), %rdi
callq 0x70700
xorb $-0x1, %al
testb $0x1, %al
jne 0x6ea49
jmp 0x6ed24
movq 0x2d8(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x70970
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x6440
movq %rax, 0x70(%rsp)
jmp 0x6ea77
movq 0x70(%rsp), %rdi
leaq 0x6dcb(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6ea8a
leaq 0x220(%rsp), %rdi
callq 0x70970
movq %rax, %rsi
leaq 0x208(%rsp), %rdi
callq 0x37210
jmp 0x6eaa9
movq 0x2e0(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x70970
movq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x60c60
movq %rax, 0x60(%rsp)
jmp 0x6ead7
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1f8(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x709a0
movq 0x1f8(%rsp), %rdi
callq 0x661c0
movq %rax, 0x50(%rsp)
jmp 0x6eb08
movq 0x50(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq 0x1d8(%rsp), %rdi
callq 0x60f80
movq %rax, 0x1d0(%rsp)
movq 0x1d8(%rsp), %rdi
callq 0x60fb0
movq %rax, 0x1c8(%rsp)
leaq 0x1d0(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x60fe0
testb $0x1, %al
jne 0x6eb5d
jmp 0x6ed1f
leaq 0x1d0(%rsp), %rdi
callq 0x61020
movq %rax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x61030
jmp 0x6eb7c
leaq 0x208(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x1e310
movq 0x40(%rsp), %rdi
movq %rax, 0x190(%rsp)
callq 0x1e340
movq %rax, 0x188(%rsp)
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rsi
leaq 0x1a0(%rsp), %rdx
callq 0x49c90
movq %rax, 0x48(%rsp)
jmp 0x6ebcc
movq 0x48(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x1e340
movq %rax, 0x180(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x55c20
movb %al, 0x207(%rsp)
leaq 0x140(%rsp), %rdi
movq %rdi, 0x30(%rsp)
leaq 0x220(%rsp), %rsi
movq %rsi, 0x28(%rsp)
callq 0x70860
movq 0x28(%rsp), %rsi
leaq 0x120(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x70890
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0x160(%rsp), %rdi
leaq 0x1a0(%rsp), %rcx
callq 0x707e0
jmp 0x6ec61
leaq 0x100(%rsp), %rdi
leaq 0x220(%rsp), %rsi
callq 0x70890
leaq 0x160(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x707c0
andb $0x1, %al
movb %al, 0x206(%rsp)
testb $0x1, 0x207(%rsp)
je 0x6ed00
testb $0x1, 0x206(%rsp)
je 0x6ed00
leaq 0x220(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x706a0
jmp 0x6ecbf
jmp 0x6ed00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x6edf3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x610b0
jmp 0x6edf3
leaq 0x1a0(%rsp), %rdi
callq 0x610b0
leaq 0x1d0(%rsp), %rdi
callq 0x610c0
jmp 0x6eb3f
jmp 0x6ea31
movq 0x2d8(%rsp), %rdi
leaq 0x572f(%rip), %rsi      # 0x74462
callq 0x64a0
movq %rax, 0x20(%rsp)
jmp 0x6ed3f
leaq 0x208(%rsp), %rdi
callq 0x30bb0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x6100
movq %rax, 0x18(%rsp)
jmp 0x6ed60
movq 0x18(%rsp), %rdi
leaq 0x6ae2(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6ed73
movq 0x2d8(%rsp), %rdi
leaq 0x6d2c(%rip), %rsi      # 0x75aae
callq 0x64a0
movq %rax, 0x10(%rsp)
jmp 0x6ed8e
movq 0x2e0(%rsp), %rdi
callq 0x70c20
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x6100
movq %rax, 0x8(%rsp)
jmp 0x6edaf
movq 0x8(%rsp), %rdi
leaq 0x6a93(%rip), %rsi      # 0x7584e
callq 0x64a0
jmp 0x6edc2
movq 0x2d8(%rsp), %rdi
callq 0x6340
jmp 0x6edd1
leaq 0x208(%rsp), %rdi
callq 0xa2c0
leaq 0x220(%rsp), %rdi
callq 0x70900
addq $0x2e8, %rsp            # imm = 0x2E8
retq
leaq 0x208(%rsp), %rdi
callq 0xa2c0
leaq 0x220(%rsp), %rdi
callq 0x70900
movq 0x2a0(%rsp), %rdi
callq 0x6850
nopw (%rax,%rax)