// File: /workspace/github_cpp_makefile_star2_O1/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 0x2bf8a
leaq 0x110(%rsp), %r14
leaq 0x120(%rsp), %rbp
leaq 0x50(%rsp), %rbx
leaq 0x98(%rsp), %r13
leaq 0x100(%rsp), %r12
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 0x2a6c2
leaq 0x140(%rsp), %rdi
movq %rax, %rsi
callq 0x17d56
movq 0x140(%rsp), %r15
movq 0x148(%rsp), %rax
movq %rax, 0xf0(%rsp)
cmpq %rax, %r15
je 0x2bf3f
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x82cc
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
callq 0x218f9
cmpq 0x18(%rsp), %rax
jne 0x2bf11
movq %r15, 0xe8(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
callq 0x82cc
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq 0xe0(%rsp), %rdx
movq 0x70(%rsp), %rcx
callq 0x2c0bb
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x2bd1b
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x53c0
cmpl $0x0, 0x30(%rsp)
je 0x2bee7
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %rax
movq %rax, 0xf8(%rsp)
cmpq %rax, %r15
je 0x2be6a
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
callq 0x82cc
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x28bca
movq (%rax), %rdi
callq 0x29d64
movq (%rax), %rbx
movq 0x8(%rax), %rbp
cmpq %rbp, %rbx
je 0x2be2e
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x82cc
movq %r14, 0x100(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x82cc
movq %r13, %rdi
movq %r12, %rsi
callq 0xf398
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rbx)
movq 0x100(%rsp), %rdi
cmpq %r14, %rdi
je 0x2be00
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2be25
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x28, %rbx
jmp 0x2bd81
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x2be50
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x20, %r15
cmpq 0xf8(%rsp), %r15
leaq 0x120(%rsp), %rbp
jne 0x2bd41
movq 0x38(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1a992
movq 0x40(%rsp), %rsi
addq $-0x20, %rsi
leaq 0x10(%rsp), %rdi
callq 0x1a992
movq 0x38(%rsp), %rsi
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x25c34
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x25c34
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x2a6bc
leaq 0x50(%rsp), %rbx
movq %rax, %r15
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x2a6bc
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq %r15, %rdi
callq 0x25cac
jmp 0x2beff
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x1a992
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a992
leaq 0x38(%rsp), %rdi
callq 0x81e0
movq 0xe8(%rsp), %r15
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2bf2d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x20, %r15
cmpq 0xf0(%rsp), %r15
jne 0x2bc6e
movq 0x8(%rsp), %rbx
movq 0x28(%rbx), %rdi
movq %rbp, %rsi
callq 0x2a6f8
leaq 0x140(%rsp), %rdi
callq 0x81e0
leaq 0x10(%rsp), %rdi
callq 0x81e0
movq %rbp, %rdi
callq 0x81e0
movq %rbx, %rdi
callq 0x52a0
cmpq 0xd8(%rsp), %rax
leaq 0x50(%rsp), %rbx
jne 0x2bc0d
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2bfe9
movq %rax, %rbx
jmp 0x2c09c
jmp 0x2bff1
jmp 0x2bff1
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c073
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2c073
jmp 0x2bfe1
jmp 0x2bff1
jmp 0x2bff1
movq %rax, %rbx
jmp 0x2c073
movq %rax, %rbx
jmp 0x2c08f
movq %rax, %rbx
jmp 0x2c069
jmp 0x2c01a
movq %rax, %rbx
movq 0x100(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c022
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x2c022
movq %rax, %rbx
jmp 0x2c047
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c047
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x2c069
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x38(%rsp), %rdi
callq 0x81e0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2c08f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x140(%rsp), %rdi
callq 0x81e0
leaq 0x10(%rsp), %rdi
callq 0x81e0
leaq 0x120(%rsp), %rdi
callq 0x81e0
movq %rbx, %rdi
callq 0x5670