// File: /workspace/github_c_makefile_star2_O3/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 0x9909
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 0x98e9
movzbl 0x50(%r14), %edi
orl %eax, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x40(%r14), %r15d
testl %r15d, %r15d
jle 0x9958
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 0x9921
movl 0x4c(%r14), %eax
movl $0x20, %ebp
movl $0x20, %edi
testl %eax, %eax
jle 0x99b4
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %edi, %edi
cmpl $0x6, %ecx
jne 0x998c
addl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x4c(%r14), %eax
xorl %edi, %edi
xorl %ecx, %ecx
movl %edi, %edx
movl $0x1, %edi
shll %cl, %edi
movq 0x60(%r14), %rsi
cmpb $0x0, (%rsi,%r12)
cmovel %r15d, %edi
orl %edx, %edi
incq %r12
incl %ecx
movslq %eax, %rdx
cmpq %rdx, %r12
jl 0x9974
addl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x4c(%r14), %eax
testl %eax, %eax
jle 0x9a10
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %ebp, %ebp
cmpl $0x6, %ecx
jne 0x99e8
addl $0x20, %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2280
movl 0x4c(%r14), %eax
xorl %ebp, %ebp
xorl %ecx, %ecx
movl %ebp, %edx
movl $0x1, %ebp
shll %cl, %ebp
movq 0x58(%r14), %rsi
cmpb $0x0, (%rsi,%r12)
cmovel %r15d, %ebp
orl %edx, %ebp
incq %r12
incl %ecx
movslq %eax, %rdx
cmpq %rdx, %r12
jl 0x99ce
addl $0x20, %ebp
leaq 0x30(%r14), %r15
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2280
cmpb $0x1, 0x48(%r14)
jne 0x9a34
movl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
jmp 0x9a9b
movl 0x28(%r14), %r12d
leal 0x20(%r12), %edi
movq %rbx, %rsi
callq 0x2280
testl %r12d, %r12d
jle 0x9a9b
movq 0x18(%r14), %r12
addq $0x18, %r14
cmpq %r14, %r12
je 0x9a9b
leaq 0x10(%r12), %r13
movq 0x10(%r12), %rbp
cmpq %r13, %rbp
je 0x9a88
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 0x9a61
movl $0x20, %edi
movq %rbx, %rsi
callq 0x2280
movq (%r12), %r12
jmp 0x9a52
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
movq (%r15), %r14
cmpq %r15, %r14
je 0x9ac1
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x98ca
movq (%r14), %r14
jmp 0x9aab
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq