// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, (%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x20910
movq (%rax), %rdi
callq 0x21c02
movq (%rax), %rsi
leaq 0x88(%rsp), %rdi
callq 0x209fc
movq %rbx, %rdi
movq %r14, 0x28(%rsp)
movq %r14, %rsi
callq 0x20910
movq (%rax), %rdi
xorl %esi, %esi
callq 0x21c2c
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x20910
movq (%rax), %r14
leaq 0x30(%rsp), %rdi
movq (%rsp), %rsi
callq 0x21bf4
leaq 0x8(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x100(%rsp), %r12
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x25dea
movq %r14, %rdi
movq %r12, %rsi
callq 0x21c22
leaq 0x100(%rsp), %rdi
callq 0x56f8
leaq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0x56f8
leaq 0x70(%rsp), %r14
xorl %r15d, %r15d
leaq 0x88(%rsp), %r13
xorl %ebp, %ebp
cmpq $0x2, %rbp
je 0x244eb
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20910
movq (%rax), %rdi
callq 0x21c02
movq (%rax), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x209fc
movq %r12, %rdi
movq 0x28(%rsp), %rsi
callq 0x5040
testl %eax, %eax
jne 0x244d7
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20910
movq (%rax), %rdi
movl %ebp, %esi
callq 0x21c2c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x20910
movq %rbp, 0x58(%rsp)
movq %r15, %rbp
movq %r12, %r15
movq %r13, %r12
movq %rbx, %r13
movq %r14, %rbx
movq (%rax), %r14
leaq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x21bf4
movq %rbx, 0x60(%rsp)
movq 0x8(%rsp), %rax
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x2446f
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x70(%rsp)
jmp 0x24475
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x10(%rsp), %rax
movq %rcx, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movq %rax, 0x68(%rsp)
movb $0x0, 0x18(%rsp)
movsd 0xa8(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movq %r14, %rdi
leaq 0x60(%rsp), %r14
movq %r14, %rsi
callq 0x21c22
movq %r14, %rdi
callq 0x56f8
leaq 0x8(%rsp), %rdi
callq 0x56f8
movq %rbx, %r14
movq %r13, %rbx
movq %r12, %r13
movq %r15, %r12
movq %rbp, %r15
movq 0x58(%rsp), %rbp
movq %r12, %rdi
callq 0x56f8
incq %rbp
addq $0x28, %r15
jmp 0x243c5
leaq 0xb0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x209fc
leaq 0xb0(%rsp), %rsi
movq (%rsp), %r14
movq %r14, %rdi
callq 0x21c22
leaq 0xb0(%rsp), %rdi
callq 0x56f8
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x21c1c
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x20910
movq (%rax), %rsi
leaq 0x30(%rsp), %rdi
callq 0x21bf4
leaq 0x8(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0xd8(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x25dea
movq (%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x21c22
leaq 0xd8(%rsp), %rdi
callq 0x56f8
leaq 0x30(%rsp), %rdi
callq 0x56f8
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x21bf4
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%rsp), %rcx
leaq 0x18(%rsp), %rdx
cmpq %rdx, %rcx
je 0x245bf
movq %rcx, 0x30(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x245c5
movups (%rdx), %xmm0
movups %xmm0, (%rax)
movq (%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rdx, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %rsi
movq %rax, 0x8(%rsi)
movb $0x0, 0x18(%rsp)
movq %rcx, 0x20(%rsi)
movq %rbx, %rdi
callq 0x211da
leaq 0x30(%rsp), %rdi
callq 0x56f8
leaq 0x8(%rsp), %rdi
callq 0x56f8
leaq 0x88(%rsp), %rdi
callq 0x56f8
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x56f8
leaq 0x8(%rsp), %rdi
jmp 0x2468c
jmp 0x24693
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x2467d
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x2468c
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x2467d
jmp 0x24693
jmp 0x24693
jmp 0x24693
jmp 0x24684
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x56f8
leaq 0x8(%rsp), %rdi
callq 0x56f8
jmp 0x24687
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x56f8
jmp 0x24696
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x56f8
movq %rbx, %rdi
callq 0x5610