// File: /workspace/github_c_makefile_star2_O3/ComplexNetworks-DCC-FCUP[P]fase/DynamicGraph.cpp
// Function: DynamicGraph::prepareGraph()
void DynamicGraph::prepareGraph() {
  _deleteAux();
  ready = true;

  hybrid_ch = new int[_num_nodes];

  int i, j;
  long long int total = 0;
  for (i = 0; i < _num_nodes; i++) {
    sort(_adjOut[i].begin(), _adjOut[i].end());
    sort(_adjIn[i].begin(), _adjIn[i].end());

    total += _out[i];
  }

  int tmp_log = 2 * total / _num_nodes;
  _sqrt_nodes = 1;
  while (_sqrt_nodes < tmp_log)
    _sqrt_nodes *= 2;
  _sqrt_nodes--;

  _adjM = new bool*[_num_nodes];

  vector<pair<int, int> > vs;
  for (i = 0; i < _num_nodes; i++) {
    hybrid_ch[i] = 1;
    vs.push_back(pair<int, int>(_out[i], i));
  }

  sort(vs.begin(), vs.end());
  reverse(vs.begin(), vs.end());

  for (i = 0; i < min(5 * _sqrt_nodes / 2, _num_nodes); i++) {
    int cur_node = vs[i].second;
    hybrid_ch[cur_node] = 0;
    _adjM[cur_node] = new bool[_num_nodes];
    for (j = 0; j < _num_nodes; j++)
      _adjM[cur_node][j] = false;

    for (j = 0; j < _out[cur_node]; j++)
      _adjM[cur_node][_adjOut[cur_node][j]] = true;
  }

  _hashM = new l_list**[_num_nodes];

  for (i = 0; i < _num_nodes; i++) {
    if (!hybrid_ch[i])
      continue;

    int tmp_log = 5 * _out[i] / 2;
    _hash_out[i] = 1;
    while (_hash_out[i] < tmp_log)
      _hash_out[i] *= 2;
    _hash_out[i]--;

    _hashM[i] = new l_list*[_hash_out[i] + 1];

    for (j = 0; j <= _hash_out[i]; j++)
      _hashM[i][j] = NULL;
  }

  for (i = 0; i < _num_nodes; i++) {
    if (!hybrid_ch[i])
      continue;

    for (j = 0; j < _out[i]; j++) {
      l_list* n_node = new l_list();
      n_node->value = _adjOut[i][j];
      n_node->next = _hashM[i][_adjOut[i][j] & _hash_out[i]];
      _hashM[i][_adjOut[i][j] & _hash_out[i]] = n_node;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0x5166
movb $0x1, 0x78(%rbx)
movslq 0xc(%rbx), %r15
leaq (,%r15,4), %rax
testq %r15, %r15
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x40(%rbx)
testq %r15, %r15
jle 0x5562
movl $0x2, %r13d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x58(%rbx), %rax
movq -0x8(%rax,%r13,4), %r15
movq (%rax,%r13,4), %r12
cmpq %r12, %r15
je 0x54fc
movq %r12, %rax
subq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5edc
movq %r15, %rdi
movq %r12, %rsi
callq 0x5fbf
movq 0x60(%rbx), %rax
movq -0x8(%rax,%r13,4), %r15
movq (%rax,%r13,4), %r12
cmpq %r12, %r15
je 0x553b
movq %r12, %rax
subq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5edc
movq %r15, %rdi
movq %r12, %rsi
callq 0x5fbf
movq 0x28(%rbx), %rax
movslq (%rax,%rbp,4), %rax
addq %rax, %r14
incq %rbp
movl 0xc(%rbx), %r12d
movslq %r12d, %r15
addq $0x6, %r13
cmpq %r15, %rbp
jl 0x54bd
addq %r14, %r14
jmp 0x5568
xorl %r14d, %r14d
movl %r15d, %r12d
movq %r14, %rax
cqto
idivq %r15
movl $0x1, %edx
movl %edx, %ecx
leal (%rcx,%rcx), %edx
cmpl %eax, %ecx
jl 0x5575
decl %ecx
movl %ecx, 0x14(%rbx)
shlq $0x3, %r15
testl %r12d, %r12d
movq $-0x1, %rdi
cmovnsq %r15, %rdi
callq 0x2030
movq %rax, 0x48(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testl %r12d, %r12d
jle 0x5637
xorl %r12d, %r12d
movq %rsp, %r14
leaq 0x20(%rsp), %r15
movq 0x40(%rbx), %rax
movl $0x1, (%rax,%r12,4)
movq 0x28(%rbx), %rax
movl (%rax,%r12,4), %eax
movl %eax, 0x20(%rsp)
movl %r12d, 0x24(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x620c
incq %r12
movslq 0xc(%rbx), %rax
cmpq %rax, %r12
jl 0x55c2
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0x563a
movq %r15, %rax
subq %r14, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x6389
movq %r14, %rdi
movq %r15, %rsi
callq 0x643c
movq (%rsp), %r14
jmp 0x563a
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
cmpq %rax, %r14
setne %cl
addq $-0x8, %rax
cmpq %r14, %rax
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x567b
movl (%r14), %ecx
movl (%rax), %edx
movl %edx, (%r14)
movl %ecx, (%rax)
movl 0x4(%r14), %ecx
movl 0x4(%rax), %edx
movl %edx, 0x4(%r14)
movl %ecx, 0x4(%rax)
addq $0x8, %r14
addq $-0x8, %rax
cmpq %rax, %r14
jb 0x5656
movl 0xc(%rbx), %ebp
movl 0x14(%rbx), %eax
leal (%rax,%rax,4), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %ecx, %ebp
cmovll %ebp, %ecx
testl %ecx, %ecx
jle 0x5736
xorl %r15d, %r15d
movq (%rsp), %rax
movslq 0x4(%rax,%r15,8), %r12
movq 0x40(%rbx), %rax
movl $0x0, (%rax,%r12,4)
movslq 0xc(%rbx), %r14
movq %r14, %rdi
callq 0x2030
movq 0x48(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
testl %r14d, %r14d
jle 0x56dd
movq 0x48(%rbx), %rax
movq (%rax,%r12,8), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20d0
movq 0x28(%rbx), %rax
movslq (%rax,%r12,4), %rax
testq %rax, %rax
jle 0x5710
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rdx
movq (%rcx,%r12,8), %rcx
leaq (%r12,%r12,2), %rsi
movq (%rdx,%rsi,8), %rdx
xorl %esi, %esi
movslq (%rdx,%rsi,4), %rdi
movb $0x1, (%rcx,%rdi)
incq %rsi
cmpq %rsi, %rax
jne 0x5700
incq %r15
movl 0xc(%rbx), %ebp
movl 0x14(%rbx), %eax
leal (%rax,%rax,4), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %ecx, %ebp
cmovll %ebp, %ecx
movslq %ecx, %rax
cmpq %rax, %r15
jl 0x569d
movslq %ebp, %rax
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x70(%rbx)
testl %ebp, %ebp
jle 0x587c
xorl %r14d, %r14d
movq $-0x1, %r15
movq 0x40(%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
je 0x57ee
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rax
movl (%rcx,%r14,4), %ecx
leal (%rcx,%rcx,4), %edx
movl %edx, %ecx
shrl $0x1f, %ecx
addl %edx, %ecx
sarl %ecx
movl $0x1, %esi
movl %esi, %edx
leal (%rdx,%rdx), %esi
cmpl %ecx, %edx
jl 0x5791
leal -0x1(%rdx), %ecx
movl %ecx, (%rax,%r14,4)
movslq %edx, %rdi
shlq $0x3, %rdi
testl %edx, %edx
cmovsq %r15, %rdi
callq 0x2030
movq 0x70(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x30(%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
js 0x57ee
movq $-0x1, %rax
movq 0x70(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq $0x0, 0x8(%rcx,%rax,8)
movq 0x30(%rbx), %rcx
movslq (%rcx,%r14,4), %rcx
incq %rax
cmpq %rcx, %rax
jl 0x57cd
incq %r14
movslq 0xc(%rbx), %r12
cmpq %r12, %r14
jl 0x5769
testl %r12d, %r12d
jle 0x587c
xorl %r14d, %r14d
movq 0x40(%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
je 0x5874
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0x5874
leaq (%r14,%r14,2), %r15
xorl %r13d, %r13d
movl $0x10, %edi
callq 0x2190
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq 0x58(%rbx), %rcx
movq (%rcx,%r15,8), %rcx
movl (%rcx,%r13,4), %ecx
movl %ecx, (%rax)
movq 0x30(%rbx), %rdx
movq 0x70(%rbx), %rsi
movq (%rsi,%r14,8), %rdi
andl (%rdx,%r14,4), %ecx
movslq %ecx, %rcx
movq (%rdi,%rcx,8), %rdx
movq %rdx, 0x8(%rax)
movq (%rsi,%r14,8), %rdx
movq %rax, (%rdx,%rcx,8)
incq %r13
movq 0x28(%rbx), %rax
movslq (%rax,%r14,4), %rax
cmpq %rax, %r13
jl 0x5823
incq %r14
cmpq %r12, %r14
jne 0x5806
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x5892
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x58a9
jmp 0x58a9
jmp 0x58a9
jmp 0x58a9
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x58c2
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22c0