// File: /workspace/github_c_makefile_star2_O2/ComplexNetworks-DCC-FCUP[P]gtrieScanner/GTrie.cpp
// Function: GTrieNode::writeToFile(_IO_FILE*)
void GTrieNode::writeToFile(FILE *f) {
  int i, bits, aux, nbytes;

  int nchild       = child.size();
  nbytes=0;
  while (nchild>0) {
    nbytes++;
    nchild/=BASE_FORMAT;
  }

  int first_byte   = nbytes<<1;

  // first bit: isgraph ?
  if (is_graph) BIT_SET(first_byte,0);
  else          BIT_CLEAR(first_byte,0);
  fputc(BASE_FIRST+first_byte,f);

  nchild       = child.size();
  while (nchild>0) {
    fputc(BASE_FIRST+(nchild%BASE_FORMAT),f);
    nchild/=BASE_FORMAT;
  }

  // Connections: outgoing
  for (i=0, bits=0, aux=0; i<depth; i++, bits++) {
    if (bits==BASE_BITS) {
      fputc(BASE_FIRST+aux, f);
      aux=0;
      bits=0;
    }
    if (out[i]) BIT_SET(aux, bits);
  }
  fputc(BASE_FIRST+aux, f);


  // Connections: ingoing
  for (i=0, bits=0, aux=0; i<depth; i++, bits++) {
    if (bits==BASE_BITS) {
      fputc(BASE_FIRST+aux, f);
      aux=0;
      bits=0;
    }
    if (in[i]) BIT_SET(aux, bits);
  }
  fputc(BASE_FIRST+aux, f);

  // Previous Conditions
  if (cond_ok) aux = 0;
  else         aux = cond.size();
  fputc(BASE_FIRST+aux, f);

  if (aux>0) {
    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) {
	fputc(BASE_FIRST+1+(kk->first),f);
	fputc(BASE_FIRST+1+(kk->second),f);
      }
      fputc(BASE_FIRST, f);
    }
  }
  
  fputc('\n', f);

  list<GTrieNode *>::iterator ii;
  for(ii=child.begin(); ii!=child.end(); ii++)
    (*ii)->writeToFile(f);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x40(%rdi), %eax
pushq $0x20
popq %rcx
pushq $0x5f
popq %r15
testl %eax, %eax
jle 0x8fe1
xorl %edx, %edx
divl %r15d
addl $0x2, %ecx
jmp 0x8fd3
movzbl 0x50(%r14), %edi
addl %ecx, %edi
movq %rbx, %rsi
callq 0x22a0
movl 0x40(%r14), %ebp
testl %ebp, %ebp
jle 0x900e
movl %ebp, %eax
xorl %edx, %edx
divl %r15d
leal 0x20(%rdx), %edi
movl %eax, %ebp
movq %rbx, %rsi
callq 0x22a0
jmp 0x8ff4
xorl %r15d, %r15d
pushq $0x1
popq %rbp
xorl %r12d, %r12d
xorl %edi, %edi
xorl %ecx, %ecx
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jge 0x9052
cmpl $0x6, %ecx
jne 0x9038
addl $0x20, %edi
movq %rbx, %rsi
callq 0x22a0
xorl %edi, %edi
xorl %ecx, %ecx
movq 0x60(%r14), %rax
movl %ebp, %edx
shll %cl, %edx
cmpb $0x0, (%rax,%r12)
cmovel %r15d, %edx
orl %edx, %edi
incq %r12
incl %ecx
jmp 0x901b
addl $0x20, %edi
movq %rbx, %rsi
callq 0x22a0
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %edi, %edi
xorl %ecx, %ecx
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jge 0x909e
cmpl $0x6, %ecx
jne 0x9084
addl $0x20, %edi
movq %rbx, %rsi
callq 0x22a0
xorl %edi, %edi
xorl %ecx, %ecx
movq 0x58(%r14), %rax
movl %ebp, %edx
shll %cl, %edx
cmpb $0x0, (%rax,%r12)
cmovel %r15d, %edx
orl %edx, %edi
incq %r12
incl %ecx
jmp 0x9067
addl $0x20, %edi
movq %rbx, %rsi
callq 0x22a0
xorl %r15d, %r15d
cmpb $0x0, 0x48(%r14)
jne 0x90b7
movl 0x28(%r14), %r15d
leal 0x20(%r15), %edi
movq %rbx, %rsi
callq 0x22a0
testl %r15d, %r15d
jle 0x9116
leaq 0x18(%r14), %r15
movq %r15, %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0x9116
leaq 0x10(%r12), %rbp
movq %rbp, %r13
movq (%r13), %r13
cmpq %rbp, %r13
je 0x9109
movl 0x10(%r13), %edi
addl $0x21, %edi
movq %rbx, %rsi
callq 0x22a0
movl 0x14(%r13), %edi
addl $0x21, %edi
movq %rbx, %rsi
callq 0x22a0
jmp 0x90e0
pushq $0x20
popq %rdi
movq %rbx, %rsi
callq 0x22a0
jmp 0x90cf
addq $0x30, %r14
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x22a0
movq %r14, %r15
movq (%r15), %r15
cmpq %r14, %r15
je 0x913e
movq 0x10(%r15), %rdi
movq %rbx, %rsi
callq 0x8fb8
jmp 0x9128
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop