// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbp
movslq 0x98(%rsi), %rsi
leaq 0x28(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rcx
callq 0x505c
cmpl $0x0, 0x98(%r14)
jle 0x4410
movq 0xa0(%r14), %rax
movq 0x70(%rsp), %rcx
xorl %edx, %edx
movslq (%rax,%rdx,4), %rsi
incl (%rcx,%rsi,4)
incq %rdx
movslq 0x98(%r14), %rsi
cmpq %rsi, %rdx
jl 0x43fa
xorl %esi, %esi
cmpl $0x0, 0x98(%r14)
jle 0x4440
movq 0x70(%rsp), %rax
xorl %ecx, %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0x442e
movl %esi, (%rax,%rcx,4)
incl %esi
incq %rcx
movslq 0x98(%r14), %rdx
cmpq %rdx, %rcx
jl 0x4423
movslq %esi, %rsi
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x50da
movl $0x0, 0x28(%rsp)
cmpl $0x0, 0x98(%r14)
jle 0x44bd
xorl %eax, %eax
leaq 0x28(%rsp), %r15
movslq %eax, %rcx
movq 0xa0(%r14), %rdx
movslq (%rdx,%rcx,4), %rcx
movq 0x70(%rsp), %rdx
movslq (%rdx,%rcx,4), %rcx
movq 0x10(%rsp), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x44a2
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x44aa
movq %r15, %rdx
callq 0x5ab2
movl 0x28(%rsp), %eax
incl %eax
movl %eax, 0x28(%rsp)
cmpl 0x98(%r14), %eax
jl 0x4468
movq %rbp, %rdi
callq 0x259c
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rbx, %rsi
movl %esi, (%rbp)
leaq 0x18(%rbp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2f98
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
imulq %rbx, %rax
movq %rax, (%rsp)
testl %eax, %eax
jle 0x4808
leaq 0x30(%rsp), %r13
leaq 0x30(%rbp), %rax
movq %rax, 0xa0(%rsp)
leaq 0x48(%rbp), %rax
movq %rax, 0x98(%rsp)
movq (%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, (%rsp)
xorl %eax, %eax
movq %rbp, 0x68(%rsp)
movl $0x0, 0x30(%rsp)
movq %rax, %rcx
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movq %r13, 0x40(%rsp)
movq %r13, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rax
movq %rcx, 0x60(%rsp)
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq %rcx, 0xa8(%rsp)
subq (%rax,%rcx,8), %rdx
shrq $0x2, %rdx
movq %rdx, 0x8(%rsp)
testl %edx, %edx
jle 0x471d
movq 0x8(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rsp)
xorl %edx, %edx
movq 0x10(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%rdx,4), %eax
cmpl %eax, 0x38(%r14)
jbe 0x4841
testq %rax, %rax
movq %rdx, 0xb0(%rsp)
je 0x45fc
movq 0x80(%r14), %rbp
leal -0x1(%rax), %ecx
cmpq %rbp, 0x88(%r14)
je 0x4609
movq 0x50(%r14), %rdx
movq (%rdx,%rcx,8), %rcx
leaq (,%rcx,4), %r15
addq 0x68(%r14), %r15
leaq (%rbp,%rcx,4), %rbp
jmp 0x4619
movq 0x68(%r14), %r15
movq 0x80(%r14), %rbp
jmp 0x4619
movq 0x50(%r14), %rdx
movq (%rdx,%rcx,8), %r15
shlq $0x2, %r15
addq 0x68(%r14), %r15
testq %rax, %rax
je 0x462e
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rbx
decl %eax
subq (%rcx,%rax,8), %rbx
jmp 0x4635
movq 0x50(%r14), %rax
movq (%rax), %rbx
testl %ebx, %ebx
jle 0x4702
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
movq 0x88(%r14), %rax
movsd 0x2adb(%rip), %xmm0     # 0x7130
cmpq 0x80(%r14), %rax
je 0x4668
xorps %xmm0, %xmm0
cvtss2sd (%rbp,%r12,4), %xmm0
movslq (%r15,%r12,4), %rax
movq 0xa0(%r14), %rcx
movslq (%rcx,%rax,4), %rax
movq 0x70(%rsp), %rcx
movl (%rcx,%rax,4), %eax
movq 0x38(%rsp), %rdx
movq %r13, %rcx
testq %rdx, %rdx
je 0x46a6
movq %r13, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x468f
movq %r13, %rdx
cmpq %r13, %rcx
je 0x46b8
cmpl 0x20(%rcx), %eax
cmovlq %r13, %rcx
movq %rcx, %rdx
cmpq %r13, %rdx
je 0x46d4
xorps %xmm1, %xmm1
cvtss2sd 0x24(%rdx), %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x24(%rdx)
jmp 0x46f6
movl %eax, 0x88(%rsp)
movsd %xmm0, 0x90(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x5b8e
incq %r12
cmpq %rbx, %r12
jne 0x4646
movq 0xb0(%rsp), %rdx
incq %rdx
cmpq 0x8(%rsp), %rdx
movq 0x68(%rsp), %rbp
jne 0x45a3
movq 0x60(%rsp), %rdx
testq %rdx, %rdx
je 0x473b
movq 0x58(%rsp), %rax
movq (%rax), %rcx
movq 0x50(%rsp), %rax
addq -0x8(%rcx,%rdx,8), %rax
jmp 0x4740
movq 0x50(%rsp), %rax
movq 0x18(%rbp), %rcx
movq %rax, (%rcx,%rdx,8)
movq 0x50(%rsp), %rax
addq %rax, 0x8(%rbp)
movq 0x40(%rsp), %r12
cmpq %r13, %r12
je 0x47ec
xorps %xmm0, %xmm0
cvtss2sd 0x24(%r12), %xmm0
addsd 0x10(%rbp), %xmm0
movsd %xmm0, 0x10(%rbp)
movl 0x20(%r12), %eax
movl %eax, 0x88(%rsp)
movq 0x38(%rbp), %rsi
cmpq 0x40(%rbp), %rsi
je 0x4795
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rbp)
jmp 0x47aa
movq 0xa0(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x5cd8
leaq 0x24(%r12), %rdx
movq 0x50(%rbp), %rsi
cmpq 0x58(%rbp), %rsi
je 0x47cb
movss (%rdx), %xmm0
movss %xmm0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%rbp)
jmp 0x47d8
movq 0x98(%rsp), %rdi
callq 0x5db4
movq %r12, %rdi
callq 0x2160
movq %rax, %r12
cmpq %r13, %rax
jne 0x475f
leaq 0x28(%rsp), %rdi
callq 0x5586
movq 0x60(%rsp), %rax
incq %rax
cmpq (%rsp), %rax
jne 0x4541
leaq 0x10(%rsp), %rdi
callq 0x5162
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x482c
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq %rbp, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2815(%rip), %rdi      # 0x705d
leaq 0x2827(%rip), %rsi      # 0x7076
leaq 0x2831(%rip), %rcx      # 0x7087
movl $0x7b, %edx
callq 0x2130
movq %rax, %r14
jmp 0x488a
jmp 0x486c
movq %rax, %r14
jmp 0x48d7
movq %rax, %r14
jmp 0x48cd
jmp 0x4873
movq %rax, %r14
jmp 0x4880
movq %rax, %r14
movq 0x68(%rsp), %rbp
leaq 0x28(%rsp), %rdi
callq 0x5586
movq 0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x489f
movq 0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x48b4
movq 0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
movq 0x58(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x48cd
movq 0x28(%rbp), %rsi
subq %rdi, %rsi
callq 0x2200
leaq 0x10(%rsp), %rdi
callq 0x5162
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x48f1
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2200
movq %r14, %rdi
callq 0x2340
nop