// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, %r13
cmpb $0x0, 0x48(%rdi)
jne 0xa88d
leaq 0x18(%r13), %rax
movq 0x172f1(%rip), %rdx     # 0x21b40
movq %rax, %rcx
movq (%rcx), %rcx
cmpq %rax, %rcx
je 0xac24
leaq 0x10(%rcx), %rsi
movq %rsi, %rdi
movq (%rdi), %rdi
cmpq %rsi, %rdi
je 0xa884
movslq 0x10(%rdi), %r8
movl (%rdx,%r8,4), %r8d
movslq 0x14(%rdi), %r9
cmpl (%rdx,%r9,4), %r8d
jle 0xa865
cmpq %rsi, %rdi
jne 0xa852
cmpq %rax, %rcx
je 0xac24
movl 0x74(%r13), %ecx
testq %rcx, %rcx
je 0xa8e0
testl %ecx, %ecx
jle 0xa8f2
movq 0x172bf(%rip), %rdx     # 0x21b60
movq 0x17298(%rip), %rsi     # 0x21b40
movq 0x78(%r13), %rdi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movslq (%rdi,%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 0xa8ba
movslq %r9d, %rcx
movl %eax, %edx
jmp 0xa901
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x1727c(%rip), %eax     # 0x21b6c
jmp 0xa901
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rsp, %rsi
movl %eax, %eax
movq %rsp, %r12
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
cmpl $0x0, 0x74(%r13)
movq %rsi, -0x38(%rbp)
je 0xa960
testl %edx, %edx
jle 0xa997
movq 0x17227(%rip), %rax     # 0x21b58
movq (%rax,%rcx,8), %rcx
movq 0x1720c(%rip), %rsi     # 0x21b48
movl %edx, %edx
xorl %edi, %edi
xorl %eax, %eax
movslq (%rcx,%rdi,4), %r8
cmpb $0x0, (%rsi,%r8)
jne 0xa956
movslq %eax, %r9
incl %eax
movl %r8d, (%r12,%r9,4)
incq %rdi
cmpq %rdi, %rdx
jne 0xa942
jmp 0xa999
movslq 0x17205(%rip), %rcx     # 0x21b6c
testq %rcx, %rcx
jle 0xa997
xorl %eax, %eax
movq 0x171d3(%rip), %rdx     # 0x21b48
cmpb $0x0, -0x1(%rdx,%rcx)
jne 0xa988
movslq %eax, %rsi
incl %eax
leal -0x1(%rcx), %edi
movl %edi, (%r12,%rsi,4)
decq %rcx
leaq 0x1(%rcx), %rsi
cmpq $0x1, %rsi
ja 0xa975
jmp 0xa999
xorl %eax, %eax
xorl %r10d, %r10d
cmpb $0x0, 0x49(%r13)
jne 0xa9ee
movq (%r13), %rcx
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
cmpq %r13, %rcx
je 0xa9ee
movq 0x17187(%rip), %rdx     # 0x21b40
leaq 0x10(%rcx), %rdi
movq 0x10(%rcx), %r8
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rdi, %r8
je 0xa9df
movslq 0x10(%r8), %r9
movl (%rdx,%r9,4), %r9d
cmpl %esi, %r9d
cmovgl %r9d, %esi
movq (%r8), %r8
jmp 0xa9c6
cmpl %r10d, %esi
cmovll %esi, %r10d
movq (%rcx), %rcx
cmpq %r13, %rcx
jne 0xa9b9
testl %eax, %eax
jle 0xac20
leaq 0x30(%r13), %r15
movl %eax, %ecx
leaq 0x1f0e5(%rip), %r14     # 0x29ae8
movq %r12, -0x48(%rbp)
movq %r13, -0x40(%rbp)
movl %r10d, -0x2c(%rbp)
movl -0x4(%r12,%rcx,4), %eax
cmpl %r10d, %eax
jl 0xac20
movq %rcx, -0x50(%rbp)
movslq %eax, %rbx
movq 0x17115(%rip), %rcx     # 0x21b40
movslq 0x17136(%rip), %rdx     # 0x21b68
movl %eax, (%rcx,%rdx,4)
movl 0x1712d(%rip), %eax     # 0x21b68
cmpb $0x0, 0x1712e(%rip)     # 0x21b70
je 0xaa83
testl %eax, %eax
jle 0xaab0
movq 0x58(%r13), %rsi
movq 0x60(%r13), %rdi
movq 0x170f9(%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 0xaab2
movb (%rdi,%rdx), %r10b
movq (%r8,%rbx,8), %r11
cmpb (%r11,%r9), %r10b
jne 0xaab2
incq %rdx
cmpq %rdx, %rax
jne 0xaa59
jmp 0xaaba
testl %eax, %eax
jle 0xaab0
movq 0x58(%r13), %rsi
movq 0x170be(%rip), %rdi     # 0x21b50
xorl %edx, %edx
movb (%rsi,%rdx), %r8b
movslq (%rcx,%rdx,4), %r9
movq (%rdi,%r9,8), %r9
cmpb (%r9,%rbx), %r8b
jne 0xaab2
incq %rdx
cmpq %rdx, %rax
jne 0xaa94
jmp 0xaaba
xorl %edx, %edx
cmpl %eax, %edx
jl 0xac07
cmpb $0x1, 0x50(%r13)
jne 0xab9d
leaq 0x1f015(%rip), %rcx     # 0x29ae1
cmpb $0x1, (%rcx)
jne 0xab99
testl %eax, %eax
js 0xab34
xorl %r12d, %r12d
testl %eax, %eax
js 0xab24
movq $-0x1, %r13
movq 0x17062(%rip), %rax     # 0x21b50
movq 0x1704b(%rip), %rcx     # 0x21b40
movslq (%rcx,%r12,4), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x4(%rcx,%r13,4), %rcx
movzbl (%rax,%rcx), %edi
orl $0x30, %edi
movq (%r14), %rsi
callq 0x2280
movl 0x17051(%rip), %eax     # 0x21b68
movslq %eax, %rcx
incq %r13
cmpq %rcx, %r13
jl 0xaae7
jmp 0xab27
movslq %eax, %rcx
leaq 0x1(%r12), %rdx
cmpq %rcx, %r12
movq %rdx, %r12
jl 0xaadc
movq (%r14), %rsi
movl $0x3a, %edi
callq 0x2280
cmpl $0x0, 0x17020(%rip)     # 0x21b68
leaq 0x70c3(%rip), %r13      # 0x11c12
js 0xab82
movq $-0x1, %r12
movq (%r14), %rdi
movq 0x16fde(%rip), %rax     # 0x21b40
movl 0x4(%rax,%r12,4), %edx
incl %edx
movq %r13, %rsi
xorl %eax, %eax
callq 0x22d0
movslq 0x16fee(%rip), %rax     # 0x21b68
incq %r12
cmpq %rax, %r12
jl 0xab58
movq (%r14), %rsi
movl $0xa, %edi
callq 0x2280
movl 0x16fd3(%rip), %eax     # 0x21b68
movq -0x40(%rbp), %r13
incl 0x54(%r13)
movq 0x16fa4(%rip), %rcx     # 0x21b48
movb $0x1, (%rcx,%rbx)
leal 0x1(%rax), %edx
movl %edx, 0x16fb7(%rip)     # 0x21b68
movq (%r15), %r12
cmpq %r15, %r12
je 0xabf9
callq 0xb396
movq 0x16fb3(%rip), %rax     # 0x21b78
movslq 0x16f9c(%rip), %rcx     # 0x21b68
movsd (%rax,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jb 0xabe1
movq 0x10(%r12), %rdi
callq 0xa82a
movq (%r12), %r12
cmpq %r15, %r12
jne 0xabb9
movl 0x16f78(%rip), %eax     # 0x21b68
movq 0x16f51(%rip), %rcx     # 0x21b48
decl %eax
movl %eax, 0x16f69(%rip)     # 0x21b68
movb $0x0, (%rcx,%rbx)
movq -0x48(%rbp), %r12
movq -0x50(%rbp), %rcx
leaq -0x1(%rcx), %rax
cmpq $0x1, %rcx
movq %rax, %rcx
movl -0x2c(%rbp), %r10d
jg 0xaa0f
movq -0x38(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop