// File: /workspace/github_cpp_makefile_star2_O3/GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::cleanInsideAccess(std::map<int, Partition*, std::less<int>, std::allocator<std::pair<int const, Partition*>>>&, 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*>>>&)
void GPX2Support::cleanInsideAccess(GPX2Structs::PartitionMap &partitions, GPX2Structs::NodeMap &unitedGraph)
{//Removes de Acess flags from the vertices that connects the partition to itself

    //Goes through the partition
    for (auto& p : partitions) {
        //accessNodesAV - already visited
        vector<string> testedAccessNodes,accessNodesAV;

        vector<string> accessNodes = p.second->getAccessNodes();

        for (string node : accessNodes) {
            //If the node doenst have been visited already
            if(find(accessNodesAV.begin(),accessNodesAV.end(),node)==accessNodesAV.end()){
                //check if node is connected to another partition
                pair<GPX2Structs::SearchResult, vector<string>> result = DFS_outside(node, partitions, unitedGraph);

                if (result.first == GPX2Structs::SearchResult::CONNECTED_TO_PARTITION) {
                    testedAccessNodes.push_back(node);
                    accessNodesAV.push_back(node);
                } else {
                    //put the distance value in the edges of the nodes that are inserted in the partition 
                    for(string node : result.second){
                        for(auto &edge : unitedGraph[node]->getEdges()){
                            edge.second = distance(node, edge.first);
                        }
                    }

                    accessNodesAV.push_back(result.second.front());
                    accessNodesAV.push_back(result.second.back());

                    result.second.erase(result.second.begin());
                    result.second.erase(result.second.end());
                    
                    

                    p.second->getNodes().insert(p.second->getNodes().end(),result.second.begin(), result.second.end());
                }
            }
        }
        p.second->setAccessNodes(testedAccessNodes);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, 0x70(%rsp)
movq 0x18(%rdi), %rax
movq %rdi, 0xe0(%rsp)
leaq 0x8(%rdi), %rcx
movq %rcx, 0xd8(%rsp)
cmpq %rcx, %rax
je 0x2c19f
leaq 0x110(%rsp), %rbx
leaq 0x120(%rsp), %rbp
leaq 0x50(%rsp), %r14
leaq 0x98(%rsp), %r15
leaq 0x100(%rsp), %r13
xorpd %xmm0, %xmm0
movapd %xmm0, 0x120(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x130(%rsp)
movq %rcx, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0x28(%rax), %rdi
callq 0x2a8d6
leaq 0x140(%rsp), %rdi
movq %rax, %rsi
callq 0x17d42
movq 0x140(%rsp), %rcx
movq 0x148(%rsp), %rax
movq %rax, 0xe8(%rsp)
cmpq %rax, %rcx
je 0x2c154
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%rcx), %rsi
movq %rcx, 0xf0(%rsp)
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x82fa
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
callq 0x219d3
cmpq 0x18(%rsp), %rax
jne 0x2c11e
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %r12
movq %r12, %rdi
callq 0x82fa
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0xe0(%rsp), %rdx
movq 0x70(%rsp), %rcx
callq 0x2c2d0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x2bf2a
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x53b0
cmpl $0x0, 0x30(%rsp)
je 0x2c0fc
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %rax
movq %rax, 0xf8(%rsp)
cmpq %rax, %r12
je 0x2c081
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x82fa
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x28dba
movq (%rax), %rdi
callq 0x29f78
movq (%rax), %r14
movq 0x8(%rax), %rbp
cmpq %rbp, %r14
je 0x2c040
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x82fa
movq %rbx, 0x100(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x82fa
movq %r15, %rdi
movq %r13, %rsi
callq 0xf3a4
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%r14)
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2c012
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c037
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x53b0
addq $0x28, %r14
jmp 0x2bf92
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x2c062
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53b0
addq $0x20, %r12
cmpq 0xf8(%rsp), %r12
leaq 0x120(%rsp), %rbp
jne 0x2bf50
movq 0x38(%rsp), %r12
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1aa0a
movq 0x40(%rsp), %rsi
addq $-0x20, %rsi
leaq 0x10(%rsp), %rdi
callq 0x1aa0a
movq 0x38(%rsp), %rsi
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x25e12
movq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x25e12
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x2a8d0
leaq 0x50(%rsp), %r14
movq %rax, %r12
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x2a8d0
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq %r12, %rdi
callq 0x25e8e
jmp 0x2c114
movq %rbp, %rdi
movq %r14, %rsi
callq 0x1aa0a
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x1aa0a
leaq 0x38(%rsp), %rdi
callq 0x8206
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2c13a
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0xf0(%rsp), %rcx
addq $0x20, %rcx
cmpq 0xe8(%rsp), %rcx
jne 0x2be7d
movq 0x8(%rsp), %r14
movq 0x28(%r14), %rdi
movq %rbp, %rsi
callq 0x2a90c
leaq 0x140(%rsp), %rdi
callq 0x8206
leaq 0x10(%rsp), %rdi
callq 0x8206
movq %rbp, %rdi
callq 0x8206
movq %r14, %rdi
callq 0x52a0
cmpq 0xd8(%rsp), %rax
leaq 0x50(%rsp), %r14
jne 0x2be1c
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c1fe
movq %rax, %r14
jmp 0x2c2b1
jmp 0x2c206
jmp 0x2c206
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c288
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x2c288
jmp 0x2c1f6
jmp 0x2c206
jmp 0x2c206
movq %rax, %r14
jmp 0x2c288
movq %rax, %r14
jmp 0x2c2a4
movq %rax, %r14
jmp 0x2c27e
jmp 0x2c22f
movq %rax, %r14
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2c237
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x2c237
movq %rax, %r14
jmp 0x2c25c
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c25c
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x2c27e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x38(%rsp), %rdi
callq 0x8206
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2c2a4
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x140(%rsp), %rdi
callq 0x8206
leaq 0x10(%rsp), %rdi
callq 0x8206
leaq 0x120(%rsp), %rdi
callq 0x8206
movq %r14, %rdi
callq 0x5660