// File: riyadparvez[P]louvain-method/graph.cpp
// Function: Graph::display_binary(char*, char*, int)
void
Graph::display_binary(char *filename, char *filename_w, int type) {
  ofstream foutput;
  foutput.open(filename, fstream::out | fstream::binary);

  unsigned int s = links.size();

  // outputs number of nodes
  foutput.write((char *)(&s),4);

  // outputs cumulative degree sequence
  long tot=0;
  for (unsigned int i=0 ; i<s ; i++) {
    tot+=(long)links[i].size();
    foutput.write((char *)(&tot),8);
  }

  // outputs links
  for (unsigned int i=0 ; i<s ; i++) {
    for (unsigned int j=0 ; j<links[i].size() ; j++) {
      int dest = links[i][j].first;
      foutput.write((char *)(&dest),4);
    }
  }
  foutput.close();

  // outputs weights in a separate file
  if (type==WEIGHTED) {
    ofstream foutput_w;
    foutput_w.open(filename_w,fstream::out | fstream::binary);
    for (unsigned int i=0 ; i<s ; i++) {
      for (unsigned int j=0 ; j<links[i].size() ; j++) {
	float weight = links[i][j].second;
	foutput_w.write((char *)(&weight),4);
      }
    }
    foutput_w.close();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x2240
movq -0x10(%rbp), %rax
movq %rax, -0x460(%rbp)
movl $0x10, %edi
movl $0x4, %esi
callq 0x4460
movl %eax, -0x458(%rbp)
jmp 0x32f3
movl -0x458(%rbp), %edx
movq -0x460(%rbp), %rsi
leaq -0x220(%rbp), %rdi
callq 0x2030
jmp 0x330e
movq -0x468(%rbp), %rdi
callq 0x36b0
movl %eax, -0x230(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x4, %edx
callq 0x21c0
jmp 0x333a
movq $0x0, -0x238(%rbp)
movl $0x0, -0x23c(%rbp)
movl -0x23c(%rbp), %eax
cmpl -0x230(%rbp), %eax
jae 0x33d1
movq -0x468(%rbp), %rdi
movl -0x23c(%rbp), %eax
movl %eax, %esi
callq 0x37b0
movq %rax, %rdi
callq 0x3c10
movq %rax, %rcx
movq -0x238(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x238(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movl $0x8, %edx
callq 0x21c0
jmp 0x33a7
jmp 0x33a9
movl -0x23c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x23c(%rbp)
jmp 0x334f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x362c
movl $0x0, -0x240(%rbp)
movl -0x240(%rbp), %eax
cmpl -0x230(%rbp), %eax
jae 0x34a1
movl $0x0, -0x244(%rbp)
movq -0x468(%rbp), %rdi
movl -0x244(%rbp), %eax
movq %rax, -0x470(%rbp)
movl -0x240(%rbp), %eax
movl %eax, %esi
callq 0x37b0
movq %rax, %rdi
callq 0x3c10
movq %rax, %rcx
movq -0x470(%rbp), %rax
cmpq %rcx, %rax
jae 0x348b
movq -0x468(%rbp), %rdi
movl -0x240(%rbp), %eax
movl %eax, %esi
callq 0x37b0
movq %rax, %rdi
movl -0x244(%rbp), %eax
movl %eax, %esi
callq 0x3c50
movl (%rax), %eax
movl %eax, -0x248(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x4, %edx
callq 0x21c0
jmp 0x3475
jmp 0x3477
movl -0x244(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x244(%rbp)
jmp 0x33f7
jmp 0x348d
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x33db
leaq -0x220(%rbp), %rdi
callq 0x21e0
jmp 0x34af
cmpl $0x0, -0x1c(%rbp)
jne 0x3617
leaq -0x448(%rbp), %rdi
callq 0x2240
jmp 0x34c7
movq -0x18(%rbp), %rax
movq %rax, -0x480(%rbp)
movl $0x10, %edi
movl $0x4, %esi
callq 0x4460
movl %eax, -0x474(%rbp)
jmp 0x34e9
movl -0x474(%rbp), %edx
movq -0x480(%rbp), %rsi
leaq -0x448(%rbp), %rdi
callq 0x2030
jmp 0x3504
movl $0x0, -0x44c(%rbp)
movl -0x44c(%rbp), %eax
cmpl -0x230(%rbp), %eax
jae 0x35fd
movl $0x0, -0x450(%rbp)
movq -0x468(%rbp), %rdi
movl -0x450(%rbp), %eax
movq %rax, -0x488(%rbp)
movl -0x44c(%rbp), %eax
movl %eax, %esi
callq 0x37b0
movq %rax, %rdi
callq 0x3c10
movq %rax, %rcx
movq -0x488(%rbp), %rax
cmpq %rcx, %rax
jae 0x35e7
movq -0x468(%rbp), %rdi
movl -0x44c(%rbp), %eax
movl %eax, %esi
callq 0x37b0
movq %rax, %rdi
movl -0x450(%rbp), %eax
movl %eax, %esi
callq 0x3c50
movss 0x4(%rax), %xmm0
movss %xmm0, -0x454(%rbp)
leaq -0x448(%rbp), %rdi
leaq -0x454(%rbp), %rsi
movl $0x4, %edx
callq 0x21c0
jmp 0x35b1
jmp 0x35b3
movl -0x450(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x450(%rbp)
jmp 0x352a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x2200
jmp 0x362c
jmp 0x35e9
movl -0x44c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44c(%rbp)
jmp 0x350e
leaq -0x448(%rbp), %rdi
callq 0x21e0
jmp 0x360b
leaq -0x448(%rbp), %rdi
callq 0x2200
leaq -0x220(%rbp), %rdi
callq 0x2200
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x2200
movq -0x228(%rbp), %rdi
callq 0x2260
nopw %cs:(%rax,%rax)
nop