// File: /workspace/github_cpp_makefile_star2_O2/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, 0x50(%rsp)
movq 0x18(%rdi), %rcx
movq %rdi, 0x60(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x58(%rsp)
leaq 0x118(%rsp), %rbx
leaq 0xf8(%rsp), %r15
leaq 0xd8(%rsp), %r13
cmpq 0x58(%rsp), %rcx
je 0x236de
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
andq $0x0, 0x90(%rsp)
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rcx, 0x8(%rsp)
movq 0x28(%rcx), %rdi
callq 0x223ae
leaq 0xa0(%rsp), %rdi
movq %rax, %rsi
callq 0x12b1e
movq 0xa0(%rsp), %r12
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0xb8(%rsp), %r14
cmpq 0x70(%rsp), %r12
je 0x23696
movq %r14, %rdi
movq %r12, %rsi
callq 0x54a0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
callq 0x1abd1
cmpq 0x18(%rsp), %rax
jne 0x2367d
leaq 0x138(%rsp), %r14
movq %r14, %rdi
leaq 0xb8(%rsp), %rsi
callq 0x54a0
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq 0x60(%rsp), %rdx
movq 0x50(%rsp), %rcx
callq 0x2379e
movq %r12, 0x68(%rsp)
movq %r14, %rdi
callq 0x56f8
cmpl $0x0, 0x30(%rsp)
je 0x23647
movq 0x38(%rsp), %rbp
movq 0x40(%rsp), %rax
movq %rax, 0x78(%rsp)
cmpq 0x78(%rsp), %rbp
je 0x235cf
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x54a0
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x20910
movq (%rax), %rdi
callq 0x21c02
movq (%rax), %r12
movq 0x8(%rax), %r14
cmpq %r14, %r12
je 0x235be
movq %r15, %rdi
movq %rbx, %rsi
callq 0x54a0
movq %r13, %rdi
movq %r12, %rsi
callq 0x54a0
movq %r15, %rdi
movq %r13, %rsi
callq 0xc20b
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%r12)
movq %r13, %rdi
callq 0x56f8
movq %r15, %rdi
callq 0x56f8
addq $0x28, %r12
jmp 0x23577
movq %rbx, %rdi
callq 0x56f8
addq $0x20, %rbp
jmp 0x23549
movq 0x38(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x14efa
movq 0x40(%rsp), %rsi
addq $-0x20, %rsi
leaq 0x10(%rsp), %rdi
callq 0x14efa
movq 0x38(%rsp), %rsi
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x1d8b4
movq 0x40(%rsp), %rsi
movq %r14, %rdi
callq 0x1d8b4
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x223a8
movq %rax, %r12
movq 0x8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x223a8
movq 0x8(%rax), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq %r12, %rdi
callq 0x1d8ba
jmp 0x2366e
leaq 0x80(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x14efa
leaq 0x10(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x14efa
leaq 0x38(%rsp), %rdi
callq 0x709c
movq 0x68(%rsp), %r12
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
callq 0x56f8
addq $0x20, %r12
jmp 0x234c0
movq 0x8(%rsp), %r14
movq 0x28(%r14), %rdi
leaq 0x80(%rsp), %r12
movq %r12, %rsi
callq 0x223e4
leaq 0xa0(%rsp), %rdi
callq 0x709c
leaq 0x10(%rsp), %rdi
callq 0x709c
movq %r12, %rdi
callq 0x709c
movq %r14, %rdi
callq 0x52a0
movq %rax, %rcx
jmp 0x23458
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2371b
movq %rax, %rbx
jmp 0x2377f
jmp 0x23720
jmp 0x23720
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x56f8
jmp 0x23765
jmp 0x23716
jmp 0x23720
jmp 0x23720
movq %rax, %rbx
jmp 0x23765
movq %rax, %rbx
jmp 0x23772
movq %rax, %rbx
jmp 0x2375b
jmp 0x23727
movq %rax, %rbx
jmp 0x2374e
movq %rax, %rbx
jmp 0x23741
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x56f8
leaq 0xf8(%rsp), %rdi
callq 0x56f8
leaq 0x118(%rsp), %rdi
callq 0x56f8
leaq 0x38(%rsp), %rdi
callq 0x709c
leaq 0xb8(%rsp), %rdi
callq 0x56f8
leaq 0xa0(%rsp), %rdi
callq 0x709c
leaq 0x10(%rsp), %rdi
callq 0x709c
leaq 0x80(%rsp), %rdi
callq 0x709c
movq %rbx, %rdi
callq 0x5610