// File: /workspace/github_cpp_makefile_star2_O3/GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Fusion.cpp
// Function: GPX2Fusion::unfeasiblePartitionsConnected(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*>>>&)
bool GPX2Fusion::unfeasiblePartitionsConnected(GPX2Structs::PartitionMap &partitions, GPX2Structs::NodeMap& unitedGraph)
{ // Verifica as conexões das partições unfeasible
  // And set the connectionNode in the partition
    vector<pair<string,int>> nodesToCheck;
    vector<string> nodesAlreadyChecked;
    bool atLeastOneConnected{ false };

    // Pega todos os nós que serão verificados
    for (auto& it : partitions) {
        for (string id : it.second->getAccessNodes()) {
            nodesToCheck.push_back(make_pair(id,it.first));
        }
    }

    // Percorre o vetor para verificar as conexões
    for (pair<string,int> node : nodesToCheck) {
        //não precisa verificar novamente se já foi encontrado aonde aquele nó chega
        if(find(nodesAlreadyChecked.begin(),nodesAlreadyChecked.end(),node.first)==nodesAlreadyChecked.end()){
            nodesAlreadyChecked.push_back(node.first);

            auto res = GPX2Support::DFS_outside(node.first, partitions, unitedGraph);
            
            int partitionConnected = GPX2Support::whichPartition(res.second.back(),partitions);
            
            partitions[node.second]->getConnectedTo().push_back(Partition::ConnectionNode(partitionConnected, node.first, res.second.back()));

            //utilizando o back podemos pegar a ultima conexão adicionada
            // Verifica qual partição está conectada
            int connectedPartition = partitions[node.second]->getConnectedTo().back().connectedPartition;

            // Verifica o ID do nó na qual ela está conectada
            string connectedId = partitions[node.second]->getConnectedTo().back().connectedNode;

            // Caso ele esteja conectado a outra partição unfeasible, caso não seja "-1"
            if (connectedPartition != -1) {
                atLeastOneConnected = true;

                // Insere no vetor de conexões
                partitions[connectedPartition]->getConnectedTo().push_back(Partition::ConnectionNode(node.second, connectedId, node.first));

                nodesAlreadyChecked.push_back(connectedId);
            } else {
                // Apaga por estar conectado com uma feasible
                partitions[node.second]->getConnectedTo().erase(partitions[node.second]->getConnectedTo().end());
            }
        }
    }
    return (atLeastOneConnected);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, 0x1b0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x130(%rsp)
xorl %eax, %eax
movq %rax, 0x140(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq 0x18(%rdi), %rbx
movq %rdi, 0x8(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x48(%rsp)
cmpq %rax, %rbx
je 0x24f94
leaq 0x98(%rsp), %rbp
leaq 0x88(%rsp), %r12
leaq 0x130(%rsp), %r13
movq 0x28(%rbx), %rdi
callq 0x2a8d6
movq (%rax), %r15
movq 0x8(%rax), %r14
cmpq %r14, %r15
je 0x24a97
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x82fa
movq %rbp, 0x88(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x82fa
movl 0x20(%rbx), %eax
movl %eax, 0xa8(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x266a8
movq 0x88(%rsp), %rdi
cmpq %rbp, %rdi
je 0x24a72
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x24a8e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53b0
addq $0x20, %r15
jmp 0x249fc
movq %rbx, %rdi
callq 0x52a0
movq %rax, %rbx
cmpq 0x48(%rsp), %rax
jne 0x249ec
movq 0x130(%rsp), %r12
movq 0x138(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq %rax, %r12
je 0x24f94
movq $0x0, 0x40(%rsp)
leaq 0x10(%rsp), %rbx
leaq 0x88(%rsp), %r15
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x82fa
movl 0x20(%r12), %eax
movl %eax, 0x30(%rsp)
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %rbx, %rdx
callq 0x219d3
cmpq 0x58(%rsp), %rax
jne 0x24f62
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1aa0a
leaq 0x1a0(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x190(%rsp), %rbx
movq %rbx, %rdi
callq 0x82fa
leaq 0x1b8(%rsp), %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
movq 0x1b0(%rsp), %rcx
callq 0x2c2d0
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x24ba3
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x1c8(%rsp), %rax
leaq 0x120(%rsp), %rcx
movq %rcx, 0x110(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x110(%rsp), %rdi
callq 0x82fa
leaq 0x1d8(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x2545c
leaq 0x110(%rsp), %rdi
movq %rbx, %rsi
callq 0x2c9dd
movl %eax, %r14d
movq %rbx, %rdi
callq 0x25630
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x24c28
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq %rax, %rbx
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0x82fa
movq 0x1c8(%rsp), %rax
leaq 0x180(%rsp), %rcx
movq %rcx, 0x170(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x170(%rsp), %r13
movq %r13, %rdi
callq 0x82fa
movq %r15, %rdi
movl %r14d, %esi
leaq 0xf0(%rsp), %rdx
movq %r13, %rcx
callq 0x252b2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26978
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x24ce5
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x24d0a
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x24d2f
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x24d54
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq 0x8(%rax), %rax
movl -0x48(%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq 0x8(%rax), %rax
leaq 0x78(%rsp), %rcx
movq %rcx, 0x68(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x82fa
cmpl $-0x1, 0x3c(%rsp)
je 0x24efc
movq 0x8(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq %rax, %rbx
movl 0x30(%rsp), %ebp
leaq 0xe0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd0(%rsp), %rdi
callq 0x82fa
leaq 0x160(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x150(%rsp), %r14
movq %r14, %rdi
callq 0x82fa
movq %r15, %rdi
movl %ebp, %esi
leaq 0xd0(%rsp), %rdx
movq %r14, %rcx
callq 0x252b2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26978
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x24e75
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x24e9a
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x24ebf
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x24ee4
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x53b0
movb $0x1, %al
movq %rax, 0x40(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1aa0a
jmp 0x24f39
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2524c
movq (%rax), %rdi
callq 0x2a8f8
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x25d36
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x24f55
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x1c0(%rsp), %rdi
callq 0x8206
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x24f7e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53b0
addq $0x28, %r12
cmpq 0x48(%rsp), %r12
leaq 0x10(%rsp), %rbx
jne 0x24ae1
jmp 0x24f9d
movq $0x0, 0x40(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x8206
leaq 0x130(%rsp), %rdi
callq 0x25326
movq 0x40(%rsp), %rax
andb $0x1, %al
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x25214
jmp 0x24fe2
movq %rax, %rbx
movq 0x150(%rsp), %rdi
leaq 0x160(%rsp), %rax
cmpq %rax, %rdi
je 0x2500c
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x2500c
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x25110
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x25110
jmp 0x2510d
movq %rax, %rbx
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x25172
movq 0x1a0(%rsp), %rsi
jmp 0x25160
movq %rax, %rbx
jmp 0x250ea
jmp 0x2516f
jmp 0x25134
movq %rax, %rbx
leaq 0x1d8(%rsp), %rdi
callq 0x25630
jmp 0x250a3
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x25214
jmp 0x250c5
jmp 0x2516f
movq %rax, %rbx
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x25137
movq 0x120(%rsp), %rsi
jmp 0x25124
movq %rax, %rbx
movq 0x170(%rsp), %rdi
leaq 0x180(%rsp), %rax
cmpq %rax, %rdi
je 0x250ea
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x53b0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x25137
movq 0x100(%rsp), %rsi
jmp 0x25124
jmp 0x2510d
jmp 0x25134
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x25137
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x25137
jmp 0x2516a
jmp 0x2516f
jmp 0x25134
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x8206
jmp 0x25172
jmp 0x2516a
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %rbp, %rdi
je 0x25172
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x53b0
jmp 0x25172
movq %rax, %rbx
jmp 0x2518e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2518e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x53b0
leaq 0x50(%rsp), %rdi
callq 0x8206
leaq 0x130(%rsp), %rdi
callq 0x25326
movq %rbx, %rdi
callq 0x5660
nop