// File: /workspace/github_cpp_makefile_star2_O3/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, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x228(%rsp), %r12
movq %r12, %rdi
callq 0x2280
movq %r12, %rdi
movq %r15, %rsi
movl $0x14, %edx
callq 0x2040
movl %ebp, 0x10(%rsp)
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x228(%rsp), %rdi
movl $0x4, %edx
callq 0x2200
movq $0x0, 0x18(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x2e6c
movl $0x8, %r14d
xorl %r13d, %r13d
leaq 0x228(%rsp), %r15
leaq 0x18(%rsp), %r12
movq (%rbx), %rax
movq (%rax,%r14), %rcx
subq -0x8(%rax,%r14), %rcx
sarq $0x3, %rcx
addq %rcx, 0x18(%rsp)
movl $0x8, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2200
incq %r13
movl 0xc(%rsp), %ecx
addq $0x18, %r14
cmpq %rcx, %r13
jb 0x2dc2
testl %ecx, %ecx
je 0x2e6c
movq (%rbx), %rax
xorl %r13d, %r13d
leaq 0x228(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq (,%r13,2), %r14
addq %r13, %r14
movq (%rax,%r14,8), %rdx
cmpq %rdx, 0x8(%rax,%r14,8)
je 0x2e62
movl $0x1, %ebp
xorl %ecx, %ecx
movl (%rdx,%rcx,8), %eax
movl %eax, 0x28(%rsp)
movl $0x4, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2200
movl %ebp, %ecx
movq (%rbx), %rax
movq (%rax,%r14,8), %rdx
movq 0x8(%rax,%r14,8), %rsi
subq %rdx, %rsi
sarq $0x3, %rsi
incl %ebp
cmpq %rcx, %rsi
ja 0x2e2b
movl 0xc(%rsp), %ecx
incq %r13
movl %ecx, %edx
cmpq %rdx, %r13
jb 0x2e0e
leaq 0x228(%rsp), %rdi
callq 0x2210
cmpl $0x0, 0x10(%rsp)
je 0x2e93
movq 0x5141(%rip), %rax      # 0x7fc8
movq (%rax), %rbx
movq 0x18(%rax), %r14
jmp 0x2f61
leaq 0x28(%rsp), %rdi
callq 0x2280
leaq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x14, %edx
callq 0x2040
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
je 0x2f25
movq (%rbx), %rax
xorl %r12d, %r12d
leaq 0x28(%rsp), %r14
leaq 0x14(%rsp), %r15
leaq (%r12,%r12,2), %r13
movq (%rax,%r13,8), %rdx
cmpq %rdx, 0x8(%rax,%r13,8)
je 0x2f1b
movl $0x1, %ebp
xorl %ecx, %ecx
movss 0x4(%rdx,%rcx,8), %xmm0
movss %xmm0, 0x14(%rsp)
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2200
movl %ebp, %ecx
movq (%rbx), %rax
movq (%rax,%r13,8), %rdx
movq 0x8(%rax,%r13,8), %rsi
subq %rdx, %rsi
sarq $0x3, %rsi
incl %ebp
cmpq %rcx, %rsi
ja 0x2edf
movl 0xc(%rsp), %ecx
incq %r12
movl %ecx, %edx
cmpq %rdx, %r12
jb 0x2ec9
leaq 0x28(%rsp), %rdi
callq 0x2210
movq 0x5092(%rip), %rax      # 0x7fc8
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq 0x30(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x28(%rsp,%rax)
callq 0x2150
leaq 0x120(%rsp), %rdi
callq 0x2090
leaq 0x230(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x228(%rsp,%rax)
callq 0x2150
leaq 0x320(%rsp), %rdi
callq 0x2090
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2fb8
jmp 0x2fa9
jmp 0x2fb8
jmp 0x2fb8
jmp 0x2fb8
jmp 0x2fb8
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2230
jmp 0x2fbb
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x2230
movq %rbx, %rdi
callq 0x22b0