// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, 0x1a0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
xorl %eax, %eax
movq %rax, 0x130(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq 0x18(%rdi), %rbx
movq %rdi, (%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rbx
je 0x248db
leaq 0x18(%rsp), %rbp
leaq 0x88(%rsp), %r15
leaq 0x78(%rsp), %r12
movq 0x28(%rbx), %rdi
callq 0x2a6c2
movq (%rax), %r14
movq 0x8(%rax), %r13
cmpq %r13, %r14
je 0x248c5
movq %rbp, 0x8(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x82cc
movq %r15, 0x78(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x82cc
movl 0x20(%rbx), %eax
movl %eax, 0x98(%rsp)
leaq 0x120(%rsp), %rdi
movq %r12, %rsi
callq 0x264ca
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x248a5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x248bc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x20, %r14
jmp 0x24835
movq %rbx, %rdi
callq 0x52a0
movq %rax, %rbx
cmpq 0x38(%rsp), %rax
jne 0x24825
movq 0x120(%rsp), %r12
movq 0x128(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %r12
je 0x24db9
movl $0x0, 0x30(%rsp)
leaq 0x8(%rsp), %rbx
leaq 0x78(%rsp), %r15
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x82cc
movl 0x20(%r12), %eax
movl %eax, 0x28(%rsp)
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rbx, %rdx
callq 0x218f9
cmpq 0x48(%rsp), %rax
jne 0x24d83
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1a992
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x180(%rsp), %rbx
movq %rbx, %rdi
callq 0x82cc
leaq 0x1a8(%rsp), %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
movq 0x1a0(%rsp), %rcx
callq 0x2c0bb
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x249cc
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x1b8(%rsp), %rax
leaq 0x110(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0x82cc
leaq 0x1c8(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x25282
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x2c7c8
movl %eax, %r14d
movq %rbx, %rdi
callq 0x25456
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x24a50
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x53c0
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq %rax, %rbx
leaq 0xf0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0x82cc
movq 0x1b8(%rsp), %rax
leaq 0x170(%rsp), %rcx
movq %rcx, 0x160(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x160(%rsp), %rbp
movq %rbp, %rdi
callq 0x82cc
movq %r15, %rdi
movl %r14d, %esi
leaq 0xe0(%rsp), %rdx
movq %rbp, %rcx
callq 0x250da
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26792
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x24b0c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x24b31
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x24b56
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x24b7b
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x53c0
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq 0x8(%rax), %rax
movl -0x48(%rax), %eax
movl %eax, 0x34(%rsp)
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq 0x8(%rax), %rax
leaq 0x68(%rsp), %rcx
movq %rcx, 0x58(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x82cc
cmpl $-0x1, 0x34(%rsp)
je 0x24d1f
movq (%rsp), %rdi
leaq 0x34(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq %rax, %rbx
movl 0x28(%rsp), %ebp
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0x82cc
leaq 0x150(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x140(%rsp), %r14
movq %r14, %rdi
callq 0x82cc
movq %r15, %rdi
movl %ebp, %esi
leaq 0xc0(%rsp), %rdx
movq %r14, %rcx
callq 0x250da
movq %rbx, %rdi
movq %r15, %rsi
callq 0x26792
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x24c99
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x24cbe
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x24ce3
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x24d08
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x53c0
movb $0x1, %al
movl %eax, 0x30(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1a992
jmp 0x24d5a
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x25076
movq (%rax), %rdi
callq 0x2a6e4
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x25b58
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x24d76
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x1b0(%rsp), %rdi
callq 0x81e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x24d9f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53c0
addq $0x28, %r12
cmpq 0x38(%rsp), %r12
leaq 0x8(%rsp), %rbx
jne 0x2490b
movl 0x30(%rsp), %ebx
jmp 0x24dbb
xorl %ebx, %ebx
leaq 0x40(%rsp), %rdi
callq 0x81e0
leaq 0x120(%rsp), %rdi
callq 0x2514e
andb $0x1, %bl
movl %ebx, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2503e
jmp 0x24dfb
movq %rax, %rbx
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x24e25
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24e25
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x24f32
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24f32
jmp 0x24f2f
movq %rax, %rbx
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x24f6b
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24f6b
movq %rax, %rbx
jmp 0x24f0c
jmp 0x24f54
jmp 0x24f5b
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x25456
jmp 0x24ec1
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2503e
jmp 0x24ee7
jmp 0x24f54
movq %rax, %rbx
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x24f5e
movq 0x110(%rsp), %rsi
jmp 0x24f46
movq %rax, %rbx
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x24f0c
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x53c0
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0x24f5e
movq 0xf0(%rsp), %rsi
jmp 0x24f46
jmp 0x24f2f
jmp 0x24f5b
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x24f5e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24f5e
jmp 0x24f9b
jmp 0x24f9b
movq %rax, %rbx
jmp 0x24f6b
jmp 0x24f5b
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x81e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
jne 0x24fad
jmp 0x24fba
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x24fa3
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x53c0
jmp 0x24fa3
movq %rax, %rbx
jmp 0x24fba
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x24fba
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53c0
leaq 0x40(%rsp), %rdi
callq 0x81e0
leaq 0x120(%rsp), %rdi
callq 0x2514e
movq %rbx, %rdi
callq 0x5670
nop