// File: GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Fusion.cpp
// Function: GPX2Fusion::countConnectedPartitions(std::map<int, Partition*, std::less<int>, std::allocator<std::pair<int const, Partition*>>>&)
void GPX2Fusion::countConnectedPartitions(GPX2Structs::PartitionMap &partitions)
{ // Função que irá realizar a contagem das ligações entre as partições
    for (auto& p : partitions) {
        map<int, int> countConnected;
        for (auto node : p.second->getConnectedTo()) {
            // Tenta inserir uma nova partição que está conectada
            auto result = countConnected.insert(make_pair(node.connectedPartition, 1));
            // Caso a inserção falhar, a partição já está na lista de conectadas, sendo assim o total de ligações será aumentado
            if (!result.second) {
                countConnected[node.connectedPartition]++;
            }
        }
        // Insere os resultados da contagem
        for (auto node : countConnected) {
            p.second->getConnections().push_back(make_pair(node.first, node.second));
        }
    }
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rdi
callq 0x54cc0
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rdi
callq 0x54d10
movq %rax, 0x138(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x54cf0
testb $0x1, %al
jne 0x52db7
jmp 0x5303e
leaq 0x140(%rsp), %rdi
callq 0x54d40
movq %rax, 0x130(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x54e60
movq 0x130(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x67ee0
movq %rax, 0x30(%rsp)
jmp 0x52df1
movq 0x30(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x54e70
movq %rax, 0xe0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x54ea0
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x54ed0
testb $0x1, %al
jne 0x52e46
jmp 0x52f69
leaq 0xe0(%rsp), %rdi
callq 0x54f10
movq %rax, %rsi
leaq 0x90(%rsp), %rdi
callq 0x54f20
jmp 0x52e65
movl $0x1, 0x74(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x54ff0
movq %rax, 0x28(%rsp)
jmp 0x52e86
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x54fa0
movb %dl, 0x1f(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x52ead
movb 0x1f(%rsp), %al
movq 0x20(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movb %al, 0x68(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x80(%rsp)
movb 0x68(%rsp), %al
movb %al, 0x88(%rsp)
testb $0x1, 0x88(%rsp)
jne 0x52f4a
leaq 0x100(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x55020
movq %rax, 0x10(%rsp)
jmp 0x52efd
movq 0x10(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x52f4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0x5302f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x55110
jmp 0x5302f
leaq 0x90(%rsp), %rdi
callq 0x55110
leaq 0xe0(%rsp), %rdi
callq 0x55140
jmp 0x52e28
leaq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x55160
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x55190
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x551c0
testb $0x1, %al
jne 0x52fa9
jmp 0x53010
leaq 0x50(%rsp), %rdi
callq 0x551e0
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x130(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x67e90
movq %rax, 0x8(%rsp)
jmp 0x52fd3
leaq 0x44(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x55230
movq %rax, (%rsp)
jmp 0x52fe8
movq 0x8(%rsp), %rdi
movq (%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %rsi
callq 0x55200
jmp 0x53002
jmp 0x53004
leaq 0x50(%rsp), %rdi
callq 0x55260
jmp 0x52f94
leaq 0x100(%rsp), %rdi
callq 0x55290
leaq 0x140(%rsp), %rdi
callq 0x552a0
jmp 0x52d99
leaq 0x100(%rsp), %rdi
callq 0x55290
jmp 0x53046
addq $0x158, %rsp            # imm = 0x158
retq
movq 0xf0(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)