// File: /workspace/github_cpp_makefile_star2_O2/GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::tourToMap[abi:cxx11](std::vector<int, std::allocator<int>>&)
GPX2Structs::NodeMap GPX2Support::tourToMap(vector<int> &t)
{
    //Maps the tour to a graph with connections between the nodes
    std::map<string, Node*> aux; 
    double dist = 0;
    vector<int> cities{ t };
    unsigned size = t.size();

    for (unsigned i = 0; i < size; i++) {
        Node* cn = new Node(to_string(cities[i]));
        if(i==0){
            //if the current node is the first one, connect it with the last one and the next
            //Node::node is a pair of string and double, the ID and distance
            dist = distance(cities[size-1],cities[i]);
            cn->getEdges().push_back(Node::node(to_string(cities[size-1]), dist));
            dist = distance(cities[i],cities[i+1]);
            cn->getEdges().push_back(Node::node(to_string(cities[i+1]), dist));
        }else if(i==(size-1)){
            //if the current node is the last one, connect it with the previous and the first node
            dist = distance(cities[i-1],cities[i]);
            cn->getEdges().push_back(Node::node(to_string(cities[i-1]), dist));
            dist = distance(cities[i],cities[0]);
            cn->getEdges().push_back(Node::node(to_string(cities[0]), dist));
        }else{
            //for all the other nodes connect if with the previous and next
            dist = distance(cities[i-1],cities[i]);
            cn->getEdges().push_back(Node::node(to_string(cities[i-1]), dist));
            dist = distance(cities[i],cities[i+1]);
            cn->getEdges().push_back(Node::node(to_string(cities[i+1]), dist));
        }

        aux.insert(make_pair(cn->getId(), cn));
    }

    return (aux); //returns a map with the nodes already instantiated and added 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
leaq 0x8(%rdi), %rax
andl $0x0, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rdi, 0x70(%rsp)
andq $0x0, 0x28(%rdi)
leaq 0x58(%rsp), %rdi
callq 0x9210
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %eax, %ecx
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movl %eax, %eax
negq %rax
movq %rax, 0x80(%rsp)
movq %rcx, 0x48(%rsp)
negq %rcx
movq %rcx, 0x78(%rsp)
pushq $0x1
popq %r13
movq 0x80(%rsp), %rax
addq %r13, %rax
cmpq $0x1, %rax
je 0x25c4c
movq %r13, 0x50(%rsp)
pushq $0x40
popq %rdi
callq 0x5380
movq %rax, %rbp
movq 0x58(%rsp), %rax
movq 0x50(%rsp), %rbx
movl -0x4(%rax,%rbx,4), %esi
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x25e0b
movq %rbp, %rdi
movq %r14, %rsi
callq 0x21bdc
movq %r14, %rdi
callq 0x56f8
cmpq $0x1, %rbx
jne 0x2584b
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rax,%rcx,4), %edi
movl (%rax), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
movq %r12, %rdx
cmpq %r12, %rax
je 0x2591a
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x25921
movq 0x78(%rsp), %rax
addq %rbx, %rax
cmpq $0x1, %rax
jne 0x258bb
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
movl -0x4(%rax,%rcx,4), %edi
movl (%rax,%rcx,4), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
movl -0x4(%rax,%rcx,4), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
movq %r12, %rdx
cmpq %r12, %rax
je 0x259f7
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x259fe
movq 0x58(%rsp), %rax
movl -0x8(%rax,%rbx,4), %edi
movl -0x4(%rax,%rbx,4), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movq 0x50(%rsp), %r13
movl -0x8(%rax,%r13,4), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
movq %r12, %rdx
cmpq %r12, %rax
je 0x25a9c
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x25aa3
movups (%rdx), %xmm0
movups %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %rdx, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
movq %rbx, %rdi
callq 0x56f8
movq %rsp, %rdi
callq 0x56f8
movq 0x58(%rsp), %rax
movl (%rax), %edi
movl 0x4(%rax), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movl 0x4(%rax), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
cmpq %r12, %rax
movq 0x50(%rsp), %r13
je 0x259b4
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x259bf
movupd (%r12), %xmm0
movupd %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %r12, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
jmp 0x25bbc
movups (%rdx), %xmm0
movups %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %rdx, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
movq %rbx, %rdi
callq 0x56f8
movq %rsp, %rdi
callq 0x56f8
movq 0x58(%rsp), %rax
movq 0x48(%rsp), %rcx
movl (%rax,%rcx,4), %edi
movl (%rax), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movl (%rax), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
cmpq %r12, %rax
movq 0x50(%rsp), %r13
je 0x25b3e
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x25b49
movups (%rdx), %xmm0
movups %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %rdx, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
movq %rbx, %rdi
callq 0x56f8
movq %rsp, %rdi
callq 0x56f8
movq 0x58(%rsp), %rax
movl -0x4(%rax,%r13,4), %edi
movl %r13d, %r13d
movl (%rax,%r13,4), %esi
callq 0xc0c6
movl %eax, %ebx
movq %rbp, %rdi
callq 0x21c02
movq %rax, %r14
movq 0x58(%rsp), %rax
movl (%rax,%r13,4), %esi
movq %rsp, %rdi
callq 0x25e0b
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
cmpq %r12, %rax
movq 0x50(%rsp), %r13
je 0x25b7e
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x25b89
movupd (%r12), %xmm0
movupd %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %r12, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
jmp 0x25bbc
movupd (%r12), %xmm0
movupd %xmm0, (%r15)
cvtsi2sd %ebx, %xmm0
movq 0x8(%rsp), %rax
movq %r12, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2667a
movq %rbx, %rdi
callq 0x56f8
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x56f8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x21bf4
movq %r15, 0x20(%rsp)
movq (%rsp), %rax
cmpq %r12, %rax
je 0x25bf9
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x25c04
movupd (%r12), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rsp), %rax
movq %r12, (%rsp)
andq $0x0, 0x8(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, 0x10(%rsp)
movq %rbp, 0x40(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x211da
movq %r14, %rdi
callq 0x56f8
movq %rbx, %rdi
callq 0x56f8
incq %r13
jmp 0x25790
leaq 0x58(%rsp), %rdi
callq 0x6e4c
movq 0x70(%rsp), %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x25cd2
jmp 0x25c9e
jmp 0x25cc5
jmp 0x25c9e
jmp 0x25cc5
jmp 0x25c9e
jmp 0x25cc5
jmp 0x25c9e
jmp 0x25cc5
jmp 0x25cc5
jmp 0x25c9e
jmp 0x25c9e
jmp 0x25cc5
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x56f8
jmp 0x25cb8
jmp 0x25cc5
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x56f8
movq %rsp, %rdi
callq 0x56f8
jmp 0x25cc8
movq %rax, %r14
pushq $0x40
popq %rsi
movq %rbp, %rdi
callq 0x5390
jmp 0x25cc8
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x6e4c
movq 0x70(%rsp), %rdi
callq 0x20be0
movq %r14, %rdi
callq 0x5610