// File: /workspace/github_cpp_makefile_star2_O3/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 0x27c4
movl (%rbx), %esi
movq (%rsp), %rdi
callq 0x2f48
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 0x2f7a
movq 0x8(%rbx), %rdx
movq 0x30(%rbx), %rsi
shlq $0x3, %rdx
leaq 0x8(%rsp), %rdi
callq 0x2260
movq %r12, %rdi
xorl %esi, %esi
callq 0x2fac
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 0x2fac
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 0x27a8
movsd 0x10(%rbx), %xmm0
movq 0x50(%rbx), %rcx
movq 0x48(%rbx), %rdx
movq 0x18(%rbx), %rsi
xorl %edi, %edi
cmpq %rdx, %rcx
je 0x273d
testq %rdi, %rdi
je 0x274d
leaq -0x1(%rdi), %r8
movq -0x8(%rsi,%rdi,8), %r9
leaq (%rdx,%r9,4), %r9
jmp 0x2756
testq %rdi, %rdi
je 0x2789
movq (%rsi,%rdi,8), %r8
subq -0x8(%rsi,%rdi,8), %r8
jmp 0x278c
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rdx, %r9
xorpd %xmm1, %xmm1
xorl %r10d, %r10d
testq %rdi, %rdi
je 0x276c
movq (%rsi,%rdi,8), %r11
subq (%rsi,%r8,8), %r11
jmp 0x276f
movl (%rsi), %r11d
movl %r11d, %r11d
cmpq %r11, %r10
jae 0x2797
xorps %xmm2, %xmm2
cvtss2sd (%r9,%r10,4), %xmm2
addsd %xmm2, %xmm1
incq %r10
jmp 0x275d
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 0x5839(%rip), %rdi      # 0x8004
leaq 0x5853(%rip), %rsi      # 0x8025
leaq 0x585d(%rip), %rcx      # 0x8036
movl $0x22, %edx
callq 0x2130
jmp 0x27fc
movq %rax, %r13
jmp 0x2809
movq %rax, %r13
leaq 0x210(%rsp), %rdi
callq 0x2070
jmp 0x27ff
movq %rax, %r13
leaq 0x8(%rsp), %rdi
callq 0x2070
movq (%r12), %rdi
testq %rdi, %rdi
je 0x281e
movq 0x58(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq (%r15), %rdi
testq %rdi, %rdi
je 0x2832
movq 0x40(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x284a
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x2200
movq %r13, %rdi
callq 0x2340