// File: /workspace/github_c_makefile_star2_O2/ComplexNetworks-DCC-FCUP[P]gtrieScanner/GTrie.cpp
// Function: GTrieNode::goCondSample()
void GTrieNode::goCondSample() {
  int i, j, ci, mylim, glaux;
  int ncand;

  if (!cond_ok) {
    list< list<iPair> >::const_iterator jj, jjend;
    list<iPair>::const_iterator kk, kkend;
    for (jj=cond.begin(), jjend=cond.end(); jj!=jjend; ++jj) {
      for (kk=(*jj).begin(), kkend=(*jj).end(); kk!=kkend; ++kk)
	if ( mymap[kk->first]>mymap[kk->second])
	  break;
      if (kk==kkend) break;
    }
    if (jj==jjend) return;
  }

  ncand=0;
  j=ci=INT_MAX;
  if (nconn == 0) ncand = numNodes;
  else {
    for (i=0; i<nconn; i++) {
      glaux = numnei[mymap[conn[i]]];
      if (glaux<j) {
	ci = mymap[conn[i]];
	j = glaux;
      }
    }
    ncand = j;
  }
  int cand[ncand];

  ncand=0;
  if (nconn == 0) { // We are at a node with no connections to ancestors
    for (i=numNodes-1; i>=0; i--)
      if (!used[i]) 
	cand[ncand++]=i;
  } else {
    for (i=0; i<j; i++) {
      glaux = fastnei[ci][i];
      if (!used[glaux])
	cand[ncand++]=glaux;
    }
  }

  if (cond_this_ok) mylim = 0;
  else {
    list< list<int> >::const_iterator jjj;
    list<int>::const_iterator kkk;
    mylim = INT_MAX;
    for (jjj=this_node_cond.begin(); jjj!=this_node_cond.end(); ++jjj) {
      glaux = -1;
      for (kkk=(*jjj).begin(); kkk!=(*jjj).end(); ++kkk)
	if (mymap[*kkk]>glaux) glaux = mymap[*kkk];
      if (glaux<mylim) mylim=glaux;
    }
  }

  for (ci=ncand-1; ci>=0; ci--) {
    i = cand[ci];
    if (i<mylim) break;
    mymap[glk] = i;

    if (isdir) {  
      for (j=0; j<glk; j++)
	if (in[j]  != adjM[mymap[j]][i] ||
	    out[j] != adjM[i][mymap[j]])
	  break;
    } else {
      for (j=0; j<glk; j++)
	if (in[j]  != adjM[mymap[j]][i])
	  break;
    }
    if (j<glk) continue;

    if (is_graph) {      
      if (Global::show_occ) {
	for (int k = 0; k<=glk; k++)
	  for (int l = 0; l<=glk; l++)
	    fputc(adjM[mymap[k]][mymap[l]]?'1':'0', Global::occ_file);
	fputc(':', Global::occ_file);
	for (int k = 0; k<=glk; k++)
	  fprintf(Global::occ_file, " %d", mymap[k]+1);
	fputc('\n', Global::occ_file);
      }
      frequency++;
    }

    used[i]=true;
    glk++;
    list<GTrieNode *>::const_iterator ii, iiend;
    for(ii=child.begin(), iiend = child.end(); ii!=iiend; ++ii)
      if (Random::getDouble() <= prob[glk]) {
	(*ii)->goCondSample();
      }
    glk--;
    used[i]=false;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpb $0x0, 0x48(%rdi)
jne 0x9e26
leaq 0x18(%rdi), %rax
movq 0x17d78(%rip), %rdx     # 0x21b60
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0xa131
leaq 0x10(%rcx), %rsi
movq %rsi, %r10
movq (%r10), %r10
cmpq %rsi, %r10
je 0x9e1d
movslq 0x10(%r10), %r8
movl (%rdx,%r8,4), %r8d
movslq 0x14(%r10), %r9
cmpl (%rdx,%r9,4), %r8d
jle 0x9dfe
cmpq %rsi, %r10
jne 0x9deb
cmpq %rax, %rcx
je 0xa131
movl 0x74(%rdi), %eax
testl %eax, %eax
je 0x9e7b
movq 0x17d4c(%rip), %rcx     # 0x21b80
movq 0x17d25(%rip), %rdx     # 0x21b60
movq 0x78(%rdi), %rbx
xorl %r8d, %r8d
testl %eax, %eax
cmovlel %r8d, %eax
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
cmpq %r8, %rax
je 0x9e74
movslq (%rbx,%r8,4), %r10
movslq (%rdx,%r10,4), %r10
movl (%rcx,%r10,4), %r11d
cmpl %esi, %r11d
cmovll %r10d, %r9d
cmovll %r11d, %esi
incq %r8
jmp 0x9e53
movslq %r9d, %rcx
movl %esi, %edx
jmp 0x9e8b
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x17d01(%rip), %esi     # 0x21b8c
movq %rsp, %r8
movl %esi, %eax
movq %rsp, %rsi
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, -0x30(%rbp)
movq %rsi, %rsp
cmpl $0x0, 0x74(%rdi)
movq %r8, -0x50(%rbp)
je 0x9ef2
movq 0x17cbe(%rip), %rsi     # 0x21b78
movq 0x17ca7(%rip), %r11     # 0x21b68
xorl %r8d, %r8d
testl %edx, %edx
cmovlel %r8d, %edx
xorl %eax, %eax
movq -0x30(%rbp), %rbx
cmpq %r8, %rdx
je 0x9f1e
movq (%rsi,%rcx,8), %r9
movslq (%r9,%r8,4), %r9
cmpb $0x0, (%r11,%r9)
jne 0x9eed
movslq %eax, %r10
incl %eax
movl %r9d, (%rbx,%r10,4)
incq %r8
jmp 0x9ed0
movl 0x17c94(%rip), %ecx     # 0x21b8c
movq 0x17c69(%rip), %rdx     # 0x21b68
xorl %eax, %eax
movq -0x30(%rbp), %r9
testl %ecx, %ecx
jle 0x9f1e
decq %rcx
movl %ecx, %esi
cmpb $0x0, (%rdx,%rsi)
jne 0x9f05
movl %eax, %esi
incl %eax
movl %ecx, (%r9,%rsi,4)
jmp 0x9f05
cmpb $0x0, 0x49(%rdi)
movl $0x0, %ebx
je 0xa140
movl %ebx, -0x3c(%rbp)
movq %rdi, -0x38(%rbp)
leaq 0x30(%rdi), %r15
movl %eax, %eax
movq %rax, -0x48(%rbp)
leaq 0x1fbc3(%rip), %rbx     # 0x29b08
movq -0x48(%rbp), %rcx
testl %ecx, %ecx
jle 0xa12d
movq -0x30(%rbp), %rax
movl -0x4(%rax,%rcx,4), %eax
cmpl -0x3c(%rbp), %eax
jl 0xa12d
decq %rcx
movq %rcx, -0x48(%rbp)
movslq %eax, %r12
movq 0x17bed(%rip), %rcx     # 0x21b60
movslq 0x17c0e(%rip), %rdx     # 0x21b88
movl %eax, (%rcx,%rdx,4)
movl 0x17c05(%rip), %eax     # 0x21b88
movq -0x38(%rbp), %rdi
movq 0x58(%rdi), %rdx
movq 0x17bde(%rip), %rsi     # 0x21b70
cmpb $0x0, 0x17bf7(%rip)     # 0x21b90
je 0x9fd7
movq 0x60(%rdi), %r8
testl %eax, %eax
movl $0x0, %r9d
cmovgl %eax, %r9d
xorl %edi, %edi
cmpq %rdi, %r9
je 0xa009
movb (%rdx,%rdi), %r11b
movslq (%rcx,%rdi,4), %r10
movq (%rsi,%r10,8), %r14
cmpb (%r14,%r12), %r11b
jne 0xa001
movb (%r8,%rdi), %r11b
movq (%rsi,%r12,8), %r14
cmpb (%r14,%r10), %r11b
jne 0xa001
incq %rdi
jmp 0x9fad
testl %eax, %eax
movl $0x0, %r8d
cmovgl %eax, %r8d
xorl %edi, %edi
cmpq %rdi, %r8
je 0xa009
movb (%rdx,%rdi), %r9b
movslq (%rcx,%rdi,4), %r10
movq (%rsi,%r10,8), %r10
cmpb (%r10,%r12), %r9b
jne 0xa001
incq %rdi
jmp 0x9fe5
cmpl %edi, %eax
jg 0x9f45
movq -0x38(%rbp), %rcx
cmpb $0x1, 0x50(%rcx)
jne 0xa0ce
leaq 0x1fae3(%rip), %rcx     # 0x29b01
cmpb $0x1, (%rcx)
jne 0xa0c7
xorl %r14d, %r14d
movslq %eax, %rcx
cmpq %rcx, %r14
jg 0xa076
xorl %r13d, %r13d
movslq %eax, %rcx
cmpq %rcx, %r13
jg 0xa071
movq 0x17b2c(%rip), %rax     # 0x21b70
movq 0x17b15(%rip), %rcx     # 0x21b60
movslq (%rcx,%r14,4), %rdx
movq (%rax,%rdx,8), %rax
movslq (%rcx,%r13,4), %rcx
movzbl (%rax,%rcx), %edi
orl $0x30, %edi
movq (%rbx), %rsi
callq 0x22a0
incq %r13
movl 0x17b19(%rip), %eax     # 0x21b88
jmp 0xa035
incq %r14
jmp 0xa02a
movq (%rbx), %rsi
pushq $0x3a
popq %rdi
callq 0x22a0
xorl %r14d, %r14d
leaq 0x6b26(%rip), %r13      # 0x10bb1
movslq 0x17af6(%rip), %rax     # 0x21b88
movq (%rbx), %rsi
cmpq %rax, %r14
jg 0xa0b9
movq 0x17abf(%rip), %rax     # 0x21b60
movl (%rax,%r14,4), %edx
incl %edx
movq %rsi, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2310
incq %r14
jmp 0xa08b
pushq $0xa
popq %rdi
callq 0x22a0
movl 0x17ac1(%rip), %eax     # 0x21b88
movq -0x38(%rbp), %rcx
incl 0x54(%rcx)
movq 0x17a93(%rip), %rcx     # 0x21b68
movb $0x1, (%rcx,%r12)
incl %eax
movl %eax, 0x17aa6(%rip)     # 0x21b88
movq %r15, %r14
movq (%r14), %r14
cmpq %r15, %r14
je 0xa116
callq 0xab36
movq 0x17a9f(%rip), %rax     # 0x21b98
movslq 0x17a88(%rip), %rcx     # 0x21b88
movsd (%rax,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jb 0xa0e5
movq 0x10(%r14), %rdi
callq 0x9dc6
jmp 0xa0e5
decl 0x17a6c(%rip)           # 0x21b88
movq 0x17a45(%rip), %rax     # 0x21b68
movb $0x0, (%rax,%r12)
jmp 0x9f45
movq -0x50(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq 0x17a14(%rip), %rcx     # 0x21b60
pushq $-0x1
popq %rdx
movq %rdi, %rsi
movq (%rsi), %rsi
cmpq %rdi, %rsi
je 0x9f2d
leaq 0x10(%rsi), %r8
movq %r8, %r9
movl %edx, %r11d
movq (%r9), %r9
cmpq %r8, %r9
je 0xa181
movslq 0x10(%r9), %r10
movl (%rcx,%r10,4), %r10d
cmpl %r11d, %r10d
cmovgl %r10d, %r11d
jmp 0xa168
cmpl %ebx, %r11d
cmovll %r11d, %ebx
jmp 0xa152