// File: /workspace/github_c_makefile_star2_O1/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), %ecx
movl $0x20, %eax
testl %ecx, %ecx
jle 0x97b5
movl %ecx, %edx
movl %ecx, %esi
imulq $0x58ed2309, %rsi, %rsi # imm = 0x58ED2309
shrq $0x20, %rsi
subl %esi, %edx
shrl %edx
addl %esi, %edx
shrl $0x6, %edx
addl $0x2, %eax
cmpl $0x5e, %ecx
movl %edx, %ecx
ja 0x9795
movzbl 0x50(%r14), %edi
orl %eax, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x40(%r14), %r15d
testl %r15d, %r15d
jle 0x9804
movl %r15d, %eax
imulq $0x58ed2309, %rax, %rax # imm = 0x58ED2309
shrq $0x20, %rax
movl %r15d, %ebp
subl %eax, %ebp
shrl %ebp
addl %eax, %ebp
shrl $0x6, %ebp
imull $0x5f, %ebp, %eax
negl %eax
leal (%r15,%rax), %edi
addl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
cmpl $0x5f, %r15d
movl %ebp, %r15d
jae 0x97cd
movl $0x20, %ebp
cmpl $0x0, 0x4c(%r14)
movl $0x20, %edi
jle 0x985c
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %edi, %edi
cmpl $0x6, %ecx
jne 0x9833
addl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
xorl %edi, %edi
xorl %ecx, %ecx
movl %edi, %eax
movl $0x1, %edi
shll %cl, %edi
movq 0x60(%r14), %rdx
cmpb $0x0, (%rdx,%r12)
cmovel %r15d, %edi
orl %eax, %edi
incq %r12
incl %ecx
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jl 0x981f
addl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
cmpl $0x0, 0x4c(%r14)
jle 0x98b4
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpl $0x6, %ecx
jne 0x988b
addl $0x20, %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2280
xorl %ebp, %ebp
xorl %ecx, %ecx
movl %ebp, %eax
movl $0x1, %ebp
shll %cl, %ebp
movq 0x58(%r14), %rdx
cmpb $0x0, (%rdx,%r12)
cmovel %r15d, %ebp
orl %eax, %ebp
incq %r12
incl %ecx
movslq 0x4c(%r14), %rax
cmpq %rax, %r12
jl 0x9875
addl $0x20, %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2280
xorl %r12d, %r12d
cmpb $0x0, 0x48(%r14)
jne 0x98cc
movl 0x28(%r14), %r12d
leaq 0x30(%r14), %r15
leal 0x20(%r12), %edi
movq %rbx, %rsi
callq 0x2280
testl %r12d, %r12d
jle 0x9933
movq 0x18(%r14), %r12
addq $0x18, %r14
cmpq %r14, %r12
je 0x9933
leaq 0x10(%r12), %r13
movq 0x10(%r12), %rbp
cmpq %r13, %rbp
je 0x9920
movl 0x10(%rbp), %edi
addl $0x21, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x14(%rbp), %edi
addl $0x21, %edi
movq %rbx, %rsi
callq 0x2280
movq (%rbp), %rbp
jmp 0x98f9
movl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
movq (%r12), %r12
jmp 0x98ea
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
movq (%r15), %r14
cmpq %r15, %r14
je 0x9959
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x9776
movq (%r14), %r14
jmp 0x9943
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq