// File: /workspace/github_c_makefile_star2_O1/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 0xa710
leaq 0x18(%rdi), %rax
movq 0x1746a(%rip), %rdx     # 0x21b40
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0xa707
leaq 0x10(%rcx), %rsi
movq %rsi, %r10
movq (%r10), %r10
cmpq %rsi, %r10
je 0xa702
movslq 0x10(%r10), %r8
movl (%rdx,%r8,4), %r8d
movslq 0x14(%r10), %r9
cmpl (%rdx,%r9,4), %r8d
jle 0xa6e8
cmpq %rsi, %r10
jne 0xa6d9
cmpq %rax, %rcx
je 0xaacb
movl 0x74(%rdi), %ecx
testq %rcx, %rcx
je 0xa762
testl %ecx, %ecx
jle 0xa774
movq 0x1743d(%rip), %rdx     # 0x21b60
movq 0x17416(%rip), %rsi     # 0x21b40
movq 0x78(%rdi), %rbx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movslq (%rbx,%r8,4), %r10
movslq (%rsi,%r10,4), %r10
movl (%rdx,%r10,4), %r11d
cmpl %eax, %r11d
cmovll %r10d, %r9d
cmovll %r11d, %eax
incq %r8
cmpq %r8, %rcx
jne 0xa73c
movslq %r9d, %rcx
movl %eax, %edx
jmp 0xa783
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x173fa(%rip), %eax     # 0x21b6c
jmp 0xa783
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rsp, %rsi
movl %eax, %eax
movq %rsp, %r14
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
cmpl $0x0, 0x74(%rdi)
movq %rsi, -0x48(%rbp)
je 0xa7e2
testl %edx, %edx
jle 0xa81a
movq 0x173a6(%rip), %rax     # 0x21b58
movq (%rax,%rcx,8), %rcx
movq 0x1738b(%rip), %rsi     # 0x21b48
movl %edx, %edx
xorl %r10d, %r10d
xorl %eax, %eax
movslq (%rcx,%r10,4), %r8
cmpb $0x0, (%rsi,%r8)
jne 0xa7d8
movslq %eax, %r9
incl %eax
movl %r8d, (%r14,%r9,4)
incq %r10
cmpq %r10, %rdx
jne 0xa7c4
jmp 0xa81c
movslq 0x17383(%rip), %rcx     # 0x21b6c
testq %rcx, %rcx
jle 0xa81a
xorl %eax, %eax
movq 0x17351(%rip), %rdx     # 0x21b48
cmpb $0x0, -0x1(%rdx,%rcx)
jne 0xa80b
movslq %eax, %rsi
incl %eax
leal -0x1(%rcx), %r8d
movl %r8d, (%r14,%rsi,4)
decq %rcx
leaq 0x1(%rcx), %rsi
cmpq $0x1, %rsi
jg 0xa7f7
jmp 0xa81c
xorl %eax, %eax
xorl %r10d, %r10d
cmpb $0x0, 0x49(%rdi)
jne 0xa86f
movq (%rdi), %rcx
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
cmpq %rdi, %rcx
je 0xa86f
movq 0x17306(%rip), %rdx     # 0x21b40
leaq 0x10(%rcx), %r11
movq 0x10(%rcx), %r8
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %r11, %r8
je 0xa860
movslq 0x10(%r8), %r9
movl (%rdx,%r9,4), %r9d
cmpl %esi, %r9d
cmovgl %r9d, %esi
movq (%r8), %r8
jmp 0xa847
cmpl %r10d, %esi
cmovll %esi, %r10d
movq (%rcx), %rcx
cmpq %rdi, %rcx
jne 0xa83a
testl %eax, %eax
jle 0xaac7
leaq 0x30(%rdi), %r15
movl %eax, %r11d
leaq 0x1f263(%rip), %r12     # 0x29ae8
movq %r14, -0x38(%rbp)
movl %r10d, -0x2c(%rbp)
movq %rdi, -0x40(%rbp)
movl -0x4(%r14,%r11,4), %eax
cmpl %r10d, %eax
jl 0xaac7
movslq %eax, %rbx
movq 0x17297(%rip), %rcx     # 0x21b40
movslq 0x172b8(%rip), %rdx     # 0x21b68
movl %eax, (%rcx,%rdx,4)
movl 0x172af(%rip), %eax     # 0x21b68
cmpb $0x0, 0x172b0(%rip)     # 0x21b70
je 0xa91b
testl %eax, %eax
jle 0xa950
movq %r11, %r13
movq 0x58(%rdi), %rsi
movq %rdi, %r14
movq 0x60(%rdi), %rdi
movq 0x17271(%rip), %r8      # 0x21b50
xorl %edx, %edx
movb (%rsi,%rdx), %r10b
movslq (%rcx,%rdx,4), %r9
movq (%r8,%r9,8), %r11
cmpb (%r11,%rbx), %r10b
jne 0xa90b
movb (%rdi,%rdx), %r10b
movq (%r8,%rbx,8), %r11
cmpb (%r11,%r9), %r10b
jne 0xa90b
incq %rdx
cmpq %rdx, %rax
jne 0xa8e1
movl %eax, %edx
movl -0x2c(%rbp), %r10d
movq %r13, %r11
movq %r14, %rdi
movq -0x38(%rbp), %r14
jmp 0xa952
testl %eax, %eax
jle 0xa950
movq %r14, %r13
movq 0x58(%rdi), %rsi
movq 0x17223(%rip), %r14     # 0x21b50
xorl %edx, %edx
movb (%rsi,%rdx), %r8b
movslq (%rcx,%rdx,4), %r9
movq (%r14,%r9,8), %r9
cmpb (%r9,%rbx), %r8b
jne 0xa94b
incq %rdx
cmpq %rdx, %rax
jne 0xa92f
movl %eax, %edx
movq %r13, %r14
jmp 0xa952
xorl %edx, %edx
cmpl 0x17210(%rip), %edx     # 0x21b68
jl 0xaab6
cmpb $0x1, 0x50(%rdi)
jne 0xaa4e
leaq 0x1f172(%rip), %rax     # 0x29ae1
cmpb $0x1, (%rax)
jne 0xaa4b
movq %r11, -0x50(%rbp)
cmpl $0x0, 0x171e5(%rip)     # 0x21b68
js 0xa9e5
xorl %r14d, %r14d
cmpl $0x0, 0x171d9(%rip)     # 0x21b68
js 0xa9d2
movq $-0x1, %r13
movq 0x171b1(%rip), %rax     # 0x21b50
movq 0x1719a(%rip), %rcx     # 0x21b40
movslq (%rcx,%r14,4), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x4(%rcx,%r13,4), %rcx
movzbl (%rax,%rcx), %edi
orl $0x30, %edi
movq (%r12), %rsi
callq 0x2280
movslq 0x1719e(%rip), %rax     # 0x21b68
incq %r13
cmpq %rax, %r13
jl 0xa998
leaq 0x1(%r14), %rax
movslq 0x1718b(%rip), %rcx     # 0x21b68
cmpq %rcx, %r14
movq %rax, %r14
jl 0xa988
movq (%r12), %rsi
movl $0x3a, %edi
callq 0x2280
cmpl $0x0, 0x1716e(%rip)     # 0x21b68
leaq 0x71f8(%rip), %r13      # 0x11bf9
js 0xaa35
movq $-0x1, %r14
movq (%r12), %rdi
movq 0x1712b(%rip), %rax     # 0x21b40
movl 0x4(%rax,%r14,4), %edx
incl %edx
movq %r13, %rsi
xorl %eax, %eax
callq 0x22d0
movslq 0x1713b(%rip), %rax     # 0x21b68
incq %r14
cmpq %rax, %r14
jl 0xaa0a
movq (%r12), %rsi
movl $0xa, %edi
callq 0x2280
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %r11
incl 0x54(%rdi)
movq %r11, %r13
movq 0x170f0(%rip), %rax     # 0x21b48
movb $0x1, (%rax,%rbx)
incl 0x17106(%rip)           # 0x21b68
movq (%r15), %r14
cmpq %r15, %r14
je 0xaa96
callq 0xb21a
movq 0x17102(%rip), %rax     # 0x21b78
movslq 0x170eb(%rip), %rcx     # 0x21b68
movsd (%rax,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jb 0xaa91
movq 0x10(%r14), %rdi
callq 0xa6b4
movq (%r14), %r14
jmp 0xaa65
decl 0x170cc(%rip)           # 0x21b68
movq 0x170a5(%rip), %rax     # 0x21b48
movb $0x0, (%rax,%rbx)
movq -0x38(%rbp), %r14
movl -0x2c(%rbp), %r10d
movq %r13, %r11
movq -0x40(%rbp), %rdi
leaq -0x1(%r11), %rax
cmpq $0x1, %r11
movq %rax, %r11
jg 0xa891
movq -0x48(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq