// File: siolag161[P]louvain-original/community.cpp
// Function: Community::partition2graph_binary()
Graph
Community::partition2graph_binary() {
  // Renumber communities
  vector<int> renumber(size, -1);
  for (int node=0 ; node<size ; node++) {
    renumber[n2c[node]]++;
  }

  int final=0;
  for (int i=0 ; i<size ; i++)
    if (renumber[i]!=-1)
      renumber[i]=final++;

  // Compute communities
  vector<vector<int> > comm_nodes(final);
  for (int node=0 ; node<size ; node++) {
    comm_nodes[renumber[n2c[node]]].push_back(node);
  }

  // Compute weighted graph
  Graph g2;
  g2.nb_nodes = comm_nodes.size();
  g2.degrees.resize(comm_nodes.size());

  int comm_deg = comm_nodes.size();
  for (int comm=0 ; comm<comm_deg ; comm++) {
    map<int,float> m;
    map<int,float>::iterator it;

    int comm_size = comm_nodes[comm].size();
    for (int node=0 ; node<comm_size ; node++) {
      pair<vector<unsigned int>::iterator, vector<float>::iterator> p = g.neighbors(comm_nodes[comm][node]);
      int deg = g.nb_neighbors(comm_nodes[comm][node]);
      for (int i=0 ; i<deg ; i++) {
	int neigh        = *(p.first+i);
	int neigh_comm   = renumber[n2c[neigh]];
	double neigh_weight = (g.weights.size()==0)?1.:*(p.second+i);

	it = m.find(neigh_comm);
	if (it==m.end())
	  m.insert(make_pair(neigh_comm, neigh_weight));
	else
	  it->second+=neigh_weight;
      }
    }
    g2.degrees[comm]=(comm==0)?m.size():g2.degrees[comm-1]+m.size();
    g2.nb_links+=m.size();

    
    for (it = m.begin() ; it!=m.end() ; it++) {
      g2.total_weight  += it->second;
      g2.links.push_back(it->first);
      g2.weights.push_back(it->second);
    }
  }

  return g2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x170(%rbp)
movq %rdi, %rax
movq %rax, -0x168(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
movslq 0x98(%rax), %rax
movq %rax, -0x158(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
leaq -0x2d(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x8280
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x82a0
jmp 0x6db1
leaq -0x2d(%rbp), %rdi
callq 0x8320
movl $0x0, -0x40(%rbp)
movq -0x160(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0x98(%rcx), %eax
jge 0x6e22
movq -0x160(%rbp), %rdi
addq $0xa0, %rdi
movslq -0x40(%rbp), %rsi
callq 0x7d90
movslq (%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d90
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x6dc1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2d(%rbp), %rdi
callq 0x8320
jmp 0x7551
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x160(%rbp), %rcx
movl -0x48(%rbp), %eax
cmpl 0x98(%rcx), %eax
jge 0x6e85
movslq -0x48(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d90
cmpl $-0x1, (%rax)
je 0x6e78
movl -0x44(%rbp), %eax
movl %eax, -0x174(%rbp)
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movslq -0x48(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d90
movl -0x174(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x6e7a
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x6e30
movslq -0x44(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x8340
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x8360
jmp 0x6eb9
leaq -0x61(%rbp), %rdi
callq 0x83d0
movl $0x0, -0x68(%rbp)
movq -0x160(%rbp), %rcx
movl -0x68(%rbp), %eax
cmpl 0x98(%rcx), %eax
jge 0x6f50
movq -0x160(%rbp), %rdi
addq $0xa0, %rdi
movslq -0x68(%rbp), %rsi
callq 0x7d90
movslq (%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d90
movslq (%rax), %rsi
leaq -0x60(%rbp), %rdi
callq 0x83f0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x8410
jmp 0x6f18
jmp 0x6f1a
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x6ec9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x83d0
jmp 0x7548
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x753f
movq -0x170(%rbp), %rdi
movb $0x0, -0x69(%rbp)
callq 0x24e0
jmp 0x6f62
leaq -0x60(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x8480
movq -0x198(%rbp), %rdi
movq %rax, %rcx
movq -0x170(%rbp), %rax
movl %ecx, (%rax)
addq $0x18, %rax
movq %rax, -0x190(%rbp)
callq 0x8480
movq -0x190(%rbp), %rdi
movq %rax, %rsi
callq 0x3090
jmp 0x6fa6
leaq -0x60(%rbp), %rdi
callq 0x8480
movl %eax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x70(%rbp), %eax
jge 0x74fb
leaq -0xa8(%rbp), %rdi
callq 0x84b0
leaq -0xb0(%rbp), %rdi
callq 0x84d0
movslq -0x74(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x83f0
movq %rax, %rdi
callq 0x84f0
movl %eax, -0xb4(%rbp)
movl $0x0, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x7332
movq -0x160(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x1b0(%rbp)
movslq -0x74(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x83f0
movq %rax, %rdi
movslq -0xb8(%rbp), %rsi
callq 0x7d90
movq -0x1b0(%rbp), %rdi
movl (%rax), %esi
callq 0x34e0
movq %rdx, -0x1a8(%rbp)
movq %rax, -0x1a0(%rbp)
jmp 0x7060
movq -0x160(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq -0x1a0(%rbp), %rdx
movq %rdx, -0xc8(%rbp)
movq %rcx, -0xc0(%rbp)
addq $0x38, %rax
movq %rax, -0x1c0(%rbp)
movslq -0x74(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x83f0
movq %rax, %rdi
movslq -0xb8(%rbp), %rsi
callq 0x7d90
movq -0x1c0(%rbp), %rdi
movl (%rax), %esi
callq 0x3690
movl %eax, -0x1b4(%rbp)
jmp 0x70c0
movl -0x1b4(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl $0x0, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jge 0x731c
leaq -0xc8(%rbp), %rdi
movslq -0xd0(%rbp), %rsi
callq 0x3770
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x37b0
movq -0x160(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
addq $0xa0, %rdi
movslq -0xd4(%rbp), %rsi
callq 0x7d90
movslq (%rax), %rsi
leaq -0x28(%rbp), %rdi
callq 0x7d90
movq -0x160(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
addq $0x38, %rdi
addq $0x48, %rdi
callq 0x3750
cmpq $0x0, %rax
jne 0x7170
movsd 0x9ffa(%rip), %xmm0     # 0x11160
movsd %xmm0, -0x1c8(%rbp)
jmp 0x71aa
leaq -0xc8(%rbp), %rdi
addq $0x8, %rdi
movslq -0xd0(%rbp), %rsi
callq 0x37d0
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x3810
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x1c8(%rbp)
movsd -0x1c8(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xe4(%rbp), %rsi
callq 0x8510
movq %rax, -0x1d0(%rbp)
jmp 0x71d6
movq -0x1d0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8570
movq %rax, -0x108(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x8540
testb $0x1, %al
jne 0x7221
jmp 0x72cc
leaq -0xe4(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x85e0
movsd %xmm0, -0x1e0(%rbp)
movl %eax, -0x1d4(%rbp)
jmp 0x7244
movsd -0x1e0(%rbp), %xmm0
movl -0x1d4(%rbp), %eax
movl %eax, -0x118(%rbp)
movsd %xmm0, -0x110(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x85a0
movb %dl, -0x1e9(%rbp)
movq %rax, -0x1e8(%rbp)
jmp 0x7282
movb -0x1e9(%rbp), %al
movq -0x1e8(%rbp), %rcx
movq %rcx, -0x128(%rbp)
movb %al, -0x120(%rbp)
jmp 0x7306
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7533
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8790
jmp 0x7533
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x8610
movsd -0x1f8(%rbp), %xmm1
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
jmp 0x7308
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x70d6
jmp 0x731e
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x7002
cmpl $0x0, -0x74(%rbp)
jne 0x734d
leaq -0xa8(%rbp), %rdi
callq 0x8630
movq %rax, -0x200(%rbp)
jmp 0x7390
movq -0x170(%rbp), %rdi
addq $0x18, %rdi
movl -0x74(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x3120
movq (%rax), %rax
movq %rax, -0x208(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8630
movq %rax, %rcx
movq -0x208(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x200(%rbp)
movq -0x170(%rbp), %rdi
movq -0x200(%rbp), %rax
movq %rax, -0x210(%rbp)
addq $0x18, %rdi
movslq -0x74(%rbp), %rsi
callq 0x3120
movq -0x210(%rbp), %rcx
movq %rcx, (%rax)
leaq -0xa8(%rbp), %rdi
callq 0x8630
movq %rax, %rcx
movq -0x170(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
leaq -0xa8(%rbp), %rdi
callq 0x8650
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8570
movq %rax, -0x138(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x8680
testb $0x1, %al
jne 0x742a
jmp 0x74e1
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x8610
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movq -0x170(%rbp), %rax
movss 0x4(%rcx), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x10(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
addq $0x30, %rax
movq %rax, -0x218(%rbp)
callq 0x8610
movq -0x218(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x13c(%rbp)
leaq -0x13c(%rbp), %rsi
callq 0x86b0
jmp 0x7492
movq -0x170(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x228(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x8610
movq -0x228(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
callq 0x86e0
jmp 0x74c5
jmp 0x74c7
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x8750
movq %rax, -0x148(%rbp)
jmp 0x73fb
leaq -0xa8(%rbp), %rdi
callq 0x8790
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x6fb9
movb $0x1, -0x69(%rbp)
testb $0x1, -0x69(%rbp)
jne 0x7511
movq -0x170(%rbp), %rdi
callq 0x7b80
leaq -0x60(%rbp), %rdi
callq 0x87b0
leaq -0x28(%rbp), %rdi
callq 0x7f60
movq -0x168(%rbp), %rax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq -0x170(%rbp), %rdi
callq 0x7b80
leaq -0x60(%rbp), %rdi
callq 0x87b0
leaq -0x28(%rbp), %rdi
callq 0x7f60
movq -0x38(%rbp), %rdi
callq 0x22e0
nopw (%rax,%rax)