// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movl %ecx, %ebp
movq %rdx, 0x18(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x228(%rsp), %r12
movq %r12, %rdi
callq 0x2210
pushq $0x14
popq %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x2030
movl %ebp, 0x10(%rsp)
movq 0x8(%rbx), %rax
subq (%rbx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x228(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x21a0
leaq 0x20(%rsp), %r15
andq $0x0, (%r15)
pushq $0x8
popq %r12
xorl %r14d, %r14d
leaq 0x228(%rsp), %r13
movq %r12, %rbp
movl 0x4(%rsp), %eax
cmpq %rax, %r14
jae 0x2b5e
movq (%rbx), %rax
movq (%rax,%rbp), %rcx
subq -0x8(%rax,%rbp), %rcx
sarq $0x3, %rcx
addq %rcx, 0x20(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x21a0
incq %r14
addq $0x18, %rbp
jmp 0x2b29
xorl %ecx, %ecx
leaq 0x228(%rsp), %r15
leaq 0x28(%rsp), %r12
pushq $0x4
popq %r13
movl %eax, %eax
cmpq %rax, %rcx
jae 0x2bc4
xorl %ebp, %ebp
movq %rcx, 0x8(%rsp)
imulq $0x18, %rcx, %r14
movl %ebp, %ebp
movq (%rbx), %rcx
movq (%rcx,%r14), %rax
movq 0x8(%rcx,%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
jbe 0x2bb6
movl (%rax,%rbp,8), %eax
movl %eax, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21a0
incl %ebp
jmp 0x2b83
movq 0x8(%rsp), %rcx
incq %rcx
movl 0x4(%rsp), %eax
jmp 0x2b71
leaq 0x228(%rsp), %rdi
callq 0x21b0
cmpl $0x0, 0x10(%rsp)
jne 0x2c72
leaq 0x28(%rsp), %rdi
callq 0x2210
leaq 0x28(%rsp), %rdi
pushq $0x14
popq %rdx
movq 0x18(%rsp), %rsi
callq 0x2030
xorl %ecx, %ecx
leaq 0x28(%rsp), %r14
leaq 0x14(%rsp), %r15
pushq $0x4
popq %r12
movl 0x4(%rsp), %eax
cmpq %rax, %rcx
jae 0x2c5e
xorl %ebp, %ebp
movq %rcx, 0x8(%rsp)
imulq $0x18, %rcx, %r13
movl %ebp, %ebp
movq (%rbx), %rcx
movq (%rcx,%r13), %rax
movq 0x8(%rcx,%r13), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
jbe 0x2c54
movss 0x4(%rax,%rbp,8), %xmm0
movss %xmm0, 0x14(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x21a0
incl %ebp
jmp 0x2c1c
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x2c08
leaq 0x28(%rsp), %rdi
callq 0x21b0
leaq 0x28(%rsp), %rdi
callq 0x21d0
leaq 0x228(%rsp), %rdi
callq 0x21d0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cac
jmp 0x2c9d
jmp 0x2cac
jmp 0x2cac
jmp 0x2cac
jmp 0x2cac
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x21d0
jmp 0x2caf
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x21d0
movq %rbx, %rdi
callq 0x2240