// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movslq 0x98(%rsi), %rsi
leaq 0x38(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0xc0(%rsp), %rbx
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
callq 0x446a
movq 0xa0(%r14), %rcx
xorl %edx, %edx
movq (%rbx), %rsi
movslq 0x98(%r14), %rax
cmpq %rax, %rdx
jge 0x3b7d
movslq (%rcx,%rdx,4), %rax
incl (%rsi,%rax,4)
incq %rdx
jmp 0x3b65
xorl %ecx, %ecx
movq 0xc0(%rsp), %rdx
xorl %esi, %esi
movslq %eax, %rdi
cmpq %rdi, %rcx
jge 0x3ba8
cmpl $-0x1, (%rdx,%rcx,4)
je 0x3ba3
movl %esi, (%rdx,%rcx,4)
incl %esi
movl 0x98(%r14), %eax
incq %rcx
jmp 0x3b89
movslq %esi, %rsi
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x44c0
xorl %eax, %eax
leaq 0x38(%rsp), %rbx
movl %eax, 0x38(%rsp)
cmpl 0x98(%r14), %eax
jge 0x3c00
cltq
movq 0xa0(%r14), %rcx
movslq (%rcx,%rax,4), %rax
movq 0xc0(%rsp), %rcx
movslq (%rcx,%rax,4), %rax
imulq $0x18, %rax, %rdi
addq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x4512
movl 0x38(%rsp), %eax
incl %eax
jmp 0x3bc1
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x244c
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
pushq $0x18
popq %rbx
cqto
idivq %rbx
movl %eax, (%r15)
leaq 0x18(%r15), %rdi
movq %rdi, 0x68(%rsp)
movq %rax, %rsi
callq 0x2a48
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
cqto
idivq %rbx
leaq 0x38(%r14), %r13
leaq 0x30(%r15), %rcx
movq %rcx, 0x98(%rsp)
leaq 0x48(%r15), %rcx
movq %rcx, 0x90(%rsp)
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq %rax, 0x88(%rsp)
leaq 0x38(%rsp), %r12
xorl %eax, %eax
movq %r15, %rbx
movq %r13, 0xa0(%rsp)
cmpq 0x88(%rsp), %rax
je 0x3eba
andl $0x0, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movq %rax, %rcx
leaq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
movq 0x20(%rsp), %rax
movq %rcx, 0x70(%rsp)
imulq $0x18, %rcx, %r15
movq 0x8(%rax,%r15), %rcx
subq (%rax,%r15), %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
movq %rcx, 0xb0(%rsp)
xorl %ebp, %ebp
movq %r15, 0xa8(%rsp)
cmpq 0xb0(%rsp), %rbp
je 0x3e0e
movq 0x20(%rsp), %rax
movq (%rax,%r15), %rax
movl (%rax,%rbp,4), %esi
movq %r13, %rdi
callq 0x2b7c
movq %rax, %rbx
movq %r13, %rdi
movq %rdx, %r13
movq 0x20(%rsp), %rax
movq (%rax,%r15), %rax
movq %rbp, 0xb8(%rsp)
movl (%rax,%rbp,4), %esi
callq 0x2bd4
movl %eax, %ebp
testl %eax, %eax
movl $0x0, %eax
cmovlel %eax, %ebp
xorl %r15d, %r15d
cmpq %r15, %rbp
je 0x3de9
movslq (%rbx,%r15,4), %rax
movq 0xa0(%r14), %rcx
movslq (%rcx,%rax,4), %rax
movq 0xc0(%rsp), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, 0x14(%rsp)
movq 0x88(%r14), %rax
movsd 0x23f0(%rip), %xmm0     # 0x6160
movsd %xmm0, 0x18(%rsp)
cmpq 0x80(%r14), %rax
je 0x3d8c
cvtss2sd (%r13,%r15,4), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
callq 0x5240
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rax
je 0x3dbd
cvtss2sd 0x24(%rax), %xmm0
movsd 0x18(%rsp), %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x24(%rax)
jmp 0x3de1
movl 0x14(%rsp), %eax
movl %eax, 0x78(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movq %r12, %rdi
leaq 0x78(%rsp), %rsi
callq 0x5292
incq %r15
jmp 0x3d3a
movq 0xb8(%rsp), %rbp
incq %rbp
movq 0x8(%rsp), %rbx
movq 0xa0(%rsp), %r13
movq 0xa8(%rsp), %r15
jmp 0x3ce7
movq 0x70(%rsp), %rdx
testq %rdx, %rdx
je 0x3e2c
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq 0x60(%rsp), %rcx
addq -0x8(%rax,%rdx,8), %rcx
jmp 0x3e39
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rcx, (%rax,%rdx,8)
movq 0x60(%rsp), %rax
addq %rax, 0x8(%rbx)
movq 0x50(%rsp), %rbx
leaq 0x40(%rsp), %rax
cmpq %rax, %rbx
je 0x3ea0
cvtss2sd 0x24(%rbx), %xmm0
movq 0x8(%rsp), %rax
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x10(%rax)
movl 0x20(%rbx), %eax
movl %eax, 0x78(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x5418
leaq 0x24(%rbx), %rsi
movq 0x90(%rsp), %rdi
callq 0x4530
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
jmp 0x3e4b
movq %r12, %rdi
callq 0x49f4
movq 0x70(%rsp), %rax
incq %rax
movq 0x8(%rsp), %rbx
jmp 0x3c7f
leaq 0x20(%rsp), %rdi
callq 0x4552
leaq 0xc0(%rsp), %rdi
callq 0x4a80
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3f0c
jmp 0x3ef2
movq %rax, %rbx
jmp 0x3f20
movq %rax, %rbx
jmp 0x3f16
jmp 0x3eff
jmp 0x3eff
jmp 0x3eff
jmp 0x3eff
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x49f4
movq 0x8(%rsp), %rdi
callq 0x418c
leaq 0x20(%rsp), %rdi
callq 0x4552
leaq 0xc0(%rsp), %rdi
callq 0x4a80
movq %rbx, %rdi
callq 0x22c0
nop