// File: /workspace/github_c_makefile_star2_O1/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 0x5140
movb $0x1, 0x78(%rbx)
movslq 0xc(%rbx), %rax
leaq (,%rax,4), %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x40(%rbx)
movl 0xc(%rbx), %eax
testl %eax, %eax
jle 0x5547
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 0x54e4
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 0x5ea2
movq %r15, %rdi
movq %r12, %rsi
callq 0x5f85
movq 0x60(%rbx), %rax
movq -0x8(%rax,%r13,4), %r15
movq (%rax,%r13,4), %r12
cmpq %r12, %r15
je 0x5523
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 0x5ea2
movq %r15, %rdi
movq %r12, %rsi
callq 0x5f85
movq 0x28(%rbx), %rax
movslq (%rax,%rbp,4), %rax
addq %rax, %r14
incq %rbp
movslq 0xc(%rbx), %rax
addq $0x6, %r13
cmpq %rax, %rbp
jl 0x54a5
addq %r14, %r14
jmp 0x554a
xorl %r14d, %r14d
movslq %eax, %rcx
movq %r14, %rax
cqto
idivq %rcx
movl $0x1, %esi
movl %esi, %edx
leal (%rdx,%rdx), %esi
cmpl %eax, %edx
jl 0x555a
decl %edx
movl %edx, 0x14(%rbx)
leaq (,%rcx,8), %rax
testl %ecx, %ecx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x48(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0xc(%rbx)
jle 0x55db
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 0x61f6
incq %r12
movslq 0xc(%rbx), %rax
cmpq %rax, %r12
jl 0x55a7
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r15, %r14
je 0x5616
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 0x636b
movq %r14, %rdi
movq %r15, %rsi
callq 0x641e
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x565a
movl (%rax), %edx
movl (%rcx), %esi
movl %esi, (%rax)
movl %edx, (%rcx)
movl 0x4(%rax), %edx
movl 0x4(%rcx), %esi
movl %esi, 0x4(%rax)
movl %edx, 0x4(%rcx)
addq $0x8, %rax
addq $-0x8, %rcx
cmpq %rcx, %rax
jb 0x5639
movl 0xc(%rbx), %eax
movl 0x14(%rbx), %ecx
leal (%rcx,%rcx,4), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
cmpl %edx, %eax
cmovll %eax, %edx
testl %edx, %edx
jle 0x5715
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 0x56bc
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 0x56ef
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 0x56df
incq %r15
movl 0xc(%rbx), %eax
movl 0x14(%rbx), %ecx
leal (%rcx,%rcx,4), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
cmpl %edx, %eax
cmovll %eax, %edx
movslq %edx, %rcx
cmpq %rcx, %r15
jl 0x567c
cltq
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x70(%rbx)
movl 0xc(%rbx), %eax
testl %eax, %eax
jle 0x57df
xorl %r14d, %r14d
movq $-0x1, %r15
movq 0x40(%rbx), %rax
cmpl $0x0, (%rax,%r14,4)
je 0x57cf
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 0x5772
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 0x57cf
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 0x57ae
incq %r14
movslq 0xc(%rbx), %rax
cmpq %rax, %r14
jl 0x574a
testl %eax, %eax
jle 0x5867
movl %eax, %r14d
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
je 0x585f
movq 0x28(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
jle 0x585f
leaq (%r15,%r15,2), %r12
xorl %r13d, %r13d
movl $0x10, %edi
callq 0x2190
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq 0x58(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
movl (%rcx,%r13,4), %edx
movl %edx, (%rax)
movq 0x30(%rbx), %rdx
movq 0x70(%rbx), %rsi
movq (%rsi,%r15,8), %rdi
movl (%rdx,%r15,4), %edx
andl (%rcx,%r13,4), %edx
movslq %edx, %rcx
movq (%rdi,%rcx,8), %rdx
movq %rdx, 0x8(%rax)
movq (%rsi,%r15,8), %rdx
movq %rax, (%rdx,%rcx,8)
incq %r13
movq 0x28(%rbx), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jl 0x580a
incq %r15
cmpq %r14, %r15
jne 0x57ed
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x587d
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 0x5894
jmp 0x5894
jmp 0x5894
jmp 0x5894
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x58ad
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22c0
nop