// File: 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
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), %rdi
movq %rdi, -0x458(%rbp)
addq $0x18, %rdi
movq %rdi, -0x468(%rbp)
callq 0x3010
movq -0x458(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x460(%rbp)
callq 0x3030
movq -0x458(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x450(%rbp)
callq 0x3050
leaq -0x228(%rbp), %rdi
callq 0x21e0
jmp 0x25b1
movq -0x10(%rbp), %rax
movq %rax, -0x478(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x3070
movl %eax, -0x46c(%rbp)
jmp 0x25d3
movl -0x46c(%rbp), %edx
movq -0x478(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x2100
jmp 0x25ee
movq -0x458(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x4, %edx
callq 0x2220
jmp 0x2608
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x2150
movl %eax, -0x47c(%rbp)
jmp 0x2628
movl -0x47c(%rbp), %eax
cmpl $0x0, %eax
jne 0x2635
jmp 0x2682
leaq 0xe9c8(%rip), %rdi      # 0x11004
leaq 0xe9e2(%rip), %rsi      # 0x11025
movl $0x22, %edx
leaq 0xe9e7(%rip), %rcx      # 0x11036
callq 0x2110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x28b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x28a9
movq -0x458(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0x3090
jmp 0x269b
movq -0x458(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3120
movq %rax, %rsi
movq -0x458(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
movl %eax, %edx
leaq -0x228(%rbp), %rdi
callq 0x2220
jmp 0x26ce
movq -0x458(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl (%rax), %eax
decl %eax
movl %eax, %esi
callq 0x3120
movq %rax, %rcx
movq -0x458(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, 0x8(%rax)
movq %rax, %rdi
addq $0x30, %rdi
movq 0x8(%rax), %rsi
callq 0x3140
jmp 0x270a
movq -0x458(%rbp), %rdi
addq $0x30, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x31d0
movq %rax, %rsi
movq -0x458(%rbp), %rax
movq 0x8(%rax), %rdx
shlq $0x3, %rdx
leaq -0x228(%rbp), %rdi
callq 0x2220
jmp 0x273e
movq -0x458(%rbp), %rdi
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x31f0
jmp 0x2754
movq -0x458(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0x2833
leaq -0x440(%rbp), %rdi
callq 0x21e0
jmp 0x277b
movq -0x18(%rbp), %rax
movq %rax, -0x488(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x3070
movl %eax, -0x480(%rbp)
jmp 0x279d
movl -0x480(%rbp), %edx
movq -0x488(%rbp), %rsi
leaq -0x440(%rbp), %rdi
callq 0x2100
jmp 0x27b8
movq -0x458(%rbp), %rax
movq %rax, %rdi
addq $0x48, %rdi
movq 0x8(%rax), %rsi
callq 0x31f0
jmp 0x27d1
movq -0x458(%rbp), %rdi
addq $0x48, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3280
movq %rax, %rsi
movq -0x458(%rbp), %rax
movq 0x8(%rax), %rdx
shlq $0x2, %rdx
leaq -0x440(%rbp), %rdi
callq 0x2220
jmp 0x2805
leaq -0x440(%rbp), %rdi
callq 0x2080
jmp 0x2833
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x2080
jmp 0x28a9
movl $0x0, -0x444(%rbp)
movq -0x458(%rbp), %rcx
movl -0x444(%rbp), %eax
cmpl (%rcx), %eax
jae 0x2894
movq -0x458(%rbp), %rdi
movl -0x444(%rbp), %esi
callq 0x32a0
movsd %xmm0, -0x490(%rbp)
jmp 0x286a
movq -0x458(%rbp), %rax
movsd -0x490(%rbp), %xmm0
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x10(%rax)
movl -0x444(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
jmp 0x283d
leaq -0x228(%rbp), %rdi
callq 0x2080
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x2080
movq -0x450(%rbp), %rdi
callq 0x33c0
movq -0x460(%rbp), %rdi
callq 0x3420
movq -0x468(%rbp), %rdi
callq 0x3480
movq -0x230(%rbp), %rdi
callq 0x22e0
nopw %cs:(%rax,%rax)