// File: GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::insertGhost(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*>>>&, Node*)
void GPX2Support::insertGhost(string& id, GPX2Structs::NodeMap& tour, Node* ghost)
{
    Node::node edgeFirst = tour[id]->getEdges()[0]; // edge to be added to the ghostNode
    tour[id]->deleteEdge(0); // delete edge
    tour[id]->addEdge(Node::node(ghost->getId(), 0)); // Adds to the original node the linking edge with the ghost

    for (unsigned i = 0; i < 2; i++) {
        // goes by the linking edges with the node connected with the ghost
        Node::node edge = tour[edgeFirst.first]->getEdges()[i];

        if (edge.first.compare(id) == 0) { // checks if it is the connection

            //adds the connection to the ghost and removes it from the original node
            tour[edgeFirst.first]->deleteEdge(i);
            tour[edgeFirst.first]->addEdge(Node::node(ghost->getId(), edgeFirst.second));
        }
    }

    ghost->addEdge(edgeFirst); // connects the ghost to the edge
    ghost->setAccess(true);
    ghost->addEdge(Node::node(tour[id]->getId(), 0)); // adds the original node as and edge of the ghost

    tour.insert(make_pair(ghost->getId(), ghost)); // inserts the ghost in the parent map
}

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdi, 0x250(%rsp)
movq %rsi, 0x248(%rsp)
movq %rdx, 0x240(%rsp)
movq 0x248(%rsp), %rdi
movq 0x250(%rsp), %rsi
callq 0x60c60
movq (%rax), %rdi
callq 0x661c0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x60c40
movq %rax, %rsi
leaq 0x218(%rsp), %rdi
callq 0x61030
movq 0x248(%rsp), %rdi
movq 0x250(%rsp), %rsi
callq 0x60c60
movq %rax, 0x70(%rsp)
jmp 0x6d494
movq 0x70(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x66280
jmp 0x6d4a5
movq 0x248(%rsp), %rdi
movq 0x250(%rsp), %rsi
callq 0x60c60
movq %rax, 0x68(%rsp)
jmp 0x6d4c1
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x1c0(%rsp), %rdi
callq 0x66190
jmp 0x6d4e5
movl $0x0, 0x1bc(%rsp)
leaq 0x1e0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
leaq 0x1bc(%rsp), %rdx
callq 0x70b40
jmp 0x6d50f
movq 0x60(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x66250
jmp 0x6d523
leaq 0x1e0(%rsp), %rdi
callq 0x610b0
leaq 0x1c0(%rsp), %rdi
callq 0x6988
movl $0x0, 0x1b8(%rsp)
cmpl $0x2, 0x1b8(%rsp)
jae 0x6d78a
movq 0x248(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x60c60
movq %rax, 0x58(%rsp)
jmp 0x6d572
movq 0x58(%rsp), %rax
movq (%rax), %rdi
callq 0x661c0
movq %rax, 0x50(%rsp)
jmp 0x6d586
movq 0x50(%rsp), %rdi
movl 0x1b8(%rsp), %eax
movl %eax, %esi
callq 0x60c40
movq %rax, %rsi
leaq 0x190(%rsp), %rdi
callq 0x61030
jmp 0x6d5ab
movq 0x250(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0x6060
movl %eax, 0x4c(%rsp)
jmp 0x6d5c6
movl 0x4c(%rsp), %eax
cmpl $0x0, %eax
jne 0x6d755
movq 0x248(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x60c60
movq %rax, 0x40(%rsp)
jmp 0x6d5ef
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movl 0x1b8(%rsp), %esi
callq 0x66280
jmp 0x6d605
movq 0x248(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x60c60
movq %rax, 0x38(%rsp)
jmp 0x6d621
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x66190
jmp 0x6d645
leaq 0x238(%rsp), %rdx
leaq 0x168(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x70b80
jmp 0x6d664
movq 0x30(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x66250
jmp 0x6d678
leaq 0x168(%rsp), %rdi
callq 0x610b0
leaq 0x148(%rsp), %rdi
callq 0x6988
jmp 0x6d755
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d9cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d6e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x610b0
leaq 0x1c0(%rsp), %rdi
callq 0x6988
jmp 0x6d9cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d778
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d746
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x610b0
leaq 0x148(%rsp), %rdi
callq 0x6988
jmp 0x6d778
leaq 0x190(%rsp), %rdi
callq 0x610b0
movl 0x1b8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b8(%rsp)
jmp 0x6d548
leaq 0x190(%rsp), %rdi
callq 0x610b0
jmp 0x6d9cf
movq 0x240(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x61030
jmp 0x6d7ae
movq 0x28(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x66250
jmp 0x6d7c2
leaq 0x120(%rsp), %rdi
callq 0x610b0
movq 0x240(%rsp), %rdi
movl $0x1, %esi
callq 0x66230
jmp 0x6d7e3
movq 0x240(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x248(%rsp), %rdi
movq 0x250(%rsp), %rsi
callq 0x60c60
movq %rax, 0x20(%rsp)
jmp 0x6d80c
movq 0x20(%rsp), %rax
movq (%rax), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x66190
jmp 0x6d823
movl $0x0, 0xd4(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xd4(%rsp), %rdx
callq 0x70b40
jmp 0x6d84d
movq 0x18(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x66250
jmp 0x6d861
leaq 0xf8(%rsp), %rdi
callq 0x610b0
leaq 0xd8(%rsp), %rdi
callq 0x6988
movq 0x248(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x88(%rsp), %rdi
callq 0x66190
jmp 0x6d89f
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x70bc0
jmp 0x6d8be
movq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x60df0
movb %dl, 0x7(%rsp)
movq %rax, 0x8(%rsp)
jmp 0x6d8db
movb 0x7(%rsp), %al
movq 0x8(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movb %al, 0x80(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x60e80
leaq 0x88(%rsp), %rdi
callq 0x6988
leaq 0x218(%rsp), %rdi
callq 0x610b0
addq $0x258, %rsp            # imm = 0x258
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x610b0
jmp 0x6d9cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d97c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x610b0
leaq 0xd8(%rsp), %rdi
callq 0x6988
jmp 0x6d9cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x6d9c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x60e80
leaq 0x88(%rsp), %rdi
callq 0x6988
leaq 0x218(%rsp), %rdi
callq 0x610b0
movq 0x210(%rsp), %rdi
callq 0x6850
nopl (%rax)