// File: /workspace/github_cpp_makefile_star2_O1/siolag161[P]louvain-original/graph_binary.cpp
// Function: Graph::Graph(char*, char*, int)
Graph::Graph(char *filename, char *filename_w, int type) {
  ifstream finput;
  finput.open(filename,fstream::in | fstream::binary);

  // Read number of nodes on 4 bytes
  finput.read((char *)&nb_nodes, 4);
  assert(finput.rdstate() == ios::goodbit);

  // Read cumulative degree sequence: 8 bytes for each node
  // cum_degree[0]=degree(0); cum_degree[1]=degree(0)+degree(1), etc.
  degrees.resize(nb_nodes);
  finput.read((char *)&degrees[0], nb_nodes*8);

  // Read links: 4 bytes for each link (each link is counted twice)
  nb_links=degrees[nb_nodes-1];
  links.resize(nb_links);
  finput.read((char *)(&links[0]), (long)nb_links*8);  

  // IF WEIGHTED : read weights: 4 bytes for each link (each link is counted twice)
  weights.resize(0);
  total_weight=0;
  if (type==WEIGHTED) {
    ifstream finput_w;
    finput_w.open(filename_w,fstream::in | fstream::binary);
    weights.resize(nb_links);
    finput_w.read((char *)&weights[0], (long)nb_links*4);  
  }    

  // Compute total weight
  for (unsigned int i=0 ; i<nb_nodes ; i++) {
    total_weight += (double)weighted_degree(i);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %ecx, %ebp
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rdi), %rax
movq %rax, (%rsp)
leaq 0x30(%rdi), %r15
leaq 0x48(%rdi), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, 0x48(%rdi)
movupd %xmm0, 0x38(%rdi)
movupd %xmm0, 0x28(%rdi)
movupd %xmm0, 0x18(%rdi)
movq $0x0, 0x58(%rdi)
leaq 0x8(%rsp), %rdi
callq 0x2220
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movl $0xc, %edx
callq 0x2120
leaq 0x8(%rsp), %rdi
movl $0x4, %edx
movq %rbx, %rsi
callq 0x2260
movq 0x8(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x28(%rsp,%rax)
jne 0x27bc
movl (%rbx), %esi
movq (%rsp), %rdi
callq 0x2f98
movq 0x18(%rbx), %rsi
movl (%rbx), %edx
shll $0x3, %edx
leaq 0x8(%rsp), %rdi
callq 0x2260
movl (%rbx), %eax
decl %eax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq %rsi, 0x8(%rbx)
movq %r15, %rdi
callq 0x2fca
movq 0x8(%rbx), %rdx
movq 0x30(%rbx), %rsi
shlq $0x3, %rdx
leaq 0x8(%rsp), %rdi
callq 0x2260
movq %r12, %rdi
xorl %esi, %esi
callq 0x2ffc
movq $0x0, 0x10(%rbx)
testl %ebp, %ebp
jne 0x2706
leaq 0x210(%rsp), %rdi
callq 0x2220
leaq 0x210(%rsp), %rdi
movq %r13, %rsi
movl $0xc, %edx
callq 0x2120
movq 0x8(%rbx), %rsi
movq %r12, %rdi
callq 0x2ffc
movq 0x8(%rbx), %rdx
movq 0x48(%rbx), %rsi
shlq $0x2, %rdx
leaq 0x210(%rsp), %rdi
callq 0x2260
leaq 0x210(%rsp), %rdi
callq 0x2070
movl (%rbx), %eax
testq %rax, %rax
je 0x27a0
movsd 0x10(%rbx), %xmm0
movq 0x50(%rbx), %rcx
movq 0x48(%rbx), %rdx
movq 0x18(%rbx), %rsi
xorl %edi, %edi
cmpq %rdx, %rcx
je 0x2771
movq %rdx, %r8
testq %rdi, %rdi
je 0x273a
movq -0x8(%rsi,%rdi,8), %r8
leaq (%rdx,%r8,4), %r8
leal -0x1(%rdi), %r9d
xorpd %xmm1, %xmm1
xorl %r10d, %r10d
testq %rdi, %rdi
je 0x2754
movq (%rsi,%rdi,8), %r11
subq (%rsi,%r9,8), %r11
jmp 0x2757
movl (%rsi), %r11d
movl %r11d, %r11d
cmpq %r11, %r10
jae 0x278f
xorps %xmm2, %xmm2
cvtss2sd (%r8,%r10,4), %xmm2
addsd %xmm2, %xmm1
incq %r10
jmp 0x2745
testq %rdi, %rdi
je 0x2781
movq (%rsi,%rdi,8), %r8
subq -0x8(%rsi,%rdi,8), %r8
jmp 0x2784
movq (%rsi), %r8
movl %r8d, %r8d
xorps %xmm1, %xmm1
cvtsi2sd %r8, %xmm1
addsd %xmm1, %xmm0
incq %rdi
cmpq %rax, %rdi
jne 0x2724
movsd %xmm0, 0x10(%rbx)
leaq 0x8(%rsp), %rdi
callq 0x2070
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4841(%rip), %rdi      # 0x7004
leaq 0x485b(%rip), %rsi      # 0x7025
leaq 0x4865(%rip), %rcx      # 0x7036
movl $0x22, %edx
callq 0x2130
jmp 0x27f4
movq %rax, %r13
jmp 0x2801
movq %rax, %r13
leaq 0x210(%rsp), %rdi
callq 0x2070
jmp 0x27f7
movq %rax, %r13
leaq 0x8(%rsp), %rdi
callq 0x2070
movq (%r12), %rdi
testq %rdi, %rdi
je 0x2816
movq 0x58(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq (%r15), %rdi
testq %rdi, %rdi
je 0x282a
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x2842
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq %r13, %rdi
callq 0x2340