// File: /workspace/github_c_makefile_star2_O1/ComplexNetworks-DCC-FCUP[P]gtrieScanner/GTrie.cpp
// Function: GTrieNode::readFromFile(_IO_FILE*)
void GTrieNode::readFromFile(FILE *f) {
  int nchilds, i, j, pos, bits, ncond;
  iPair p;
  char aux, buf[MAX_BUF];
  GTrieNode *c;

  if (fgets(buf, MAX_BUF, f)) {
    aux = buf[0]-BASE_FIRST;
    if (BIT_VALUE(aux, 0)) is_graph=true;
    else                   is_graph=false;
    int nbytes = aux>>1;

    pos = 1;

    for (i=0, j=1, nchilds=0; i<nbytes; i++, j*=BASE_FORMAT) {
      aux = buf[pos++]-BASE_FIRST;
      nchilds += int(aux)*j;
    }

    // Connections: outgoing
    aux = buf[pos++]-BASE_FIRST;
    for (i=0, bits=0; i<depth; i++, bits++) {
      if (bits==BASE_BITS) {
	aux = buf[pos++]-BASE_FIRST;
	bits=0;
      }
      if (BIT_VALUE(aux, bits)) out[i] = true;
      else                      out[i] = false;
    }

    // Connections: ingoing
    aux = buf[pos++]-BASE_FIRST;
    for (i=0, bits=0; i<depth; i++, bits++) {
      if (bits==BASE_BITS) {
	aux = buf[pos++]-BASE_FIRST;
	bits=0;
      }
      if (BIT_VALUE(aux, bits)) in[i] = true;
      else                      in[i] = false;
    }

    // Previous Conditions
    aux = buf[pos++]-BASE_FIRST;
    if (aux==0) cond_ok = true;
    else        cond_ok = false;

    if (aux>0) {
      ncond = aux;
      for (i=0; i<ncond; i++) {
	list<iPair> newcond;
	while(1) {
	  aux = buf[pos++]-BASE_FIRST-1;
	  if (aux<0) break;
	  p.first = aux;
	  aux = buf[pos++]-BASE_FIRST-1;
	  p.second = aux;
	  newcond.push_back(p);
	}
	cond.push_back(newcond);
      }
    }
    
    if (buf[pos]!='\n') {
      fprintf(stderr, "ERROR: [%s] !%d!%c!\n", buf, pos, buf[pos]);
      fprintf(stderr,"[%d](%s) |", depth, is_graph?"X":" ");
      for (i=0, bits=0; i<depth; i++, bits++)
	fprintf(stderr,"%s", out[i]?"1":"0");
      fprintf(stderr,"|\n");
    }

    // Conn and nconn variables (was missing)
    for (i=0; i<depth; i++)
      if (out[i] || in[i]) 
      conn[(nconn)++] = i;
    
    
    for (i=0; i<nchilds; i++) {
      c = new GTrieNode(depth+1);
      c->readFromFile(f);
      child.push_back(c);
    }

  }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x40(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdx
callq 0x2320
testq %rax, %rax
je 0x9c26
movb 0x40(%rsp), %cl
leal -0x20(%rcx), %eax
andb $0x1, %cl
movb %cl, 0x50(%r14)
sarb %al
testb %al, %al
jle 0x99e0
movsbl %al, %edx
incl %edx
movl $0x1, %eax
xorl %r10d, %r10d
movl $0x1, %ecx
movb 0x40(%rsp,%rcx), %sil
incq %rcx
addb $-0x20, %sil
movsbl %sil, %esi
imull %eax, %esi
addl %esi, %r10d
imull $0x5f, %eax, %eax
cmpq %rcx, %rdx
jne 0x99c0
jmp 0x99e8
xorl %r10d, %r10d
movl $0x1, %edx
leal 0x1(%rdx), %ecx
movslq 0x4c(%r14), %rax
testq %rax, %rax
jle 0x9a36
movl %edx, %edx
movb 0x40(%rsp,%rdx), %dil
addb $-0x20, %dil
movq 0x60(%r14), %rdx
xorl %esi, %esi
xorl %r8d, %r8d
cmpl $0x6, %r8d
jne 0x9a1f
movslq %ecx, %rdi
incl %ecx
movb 0x40(%rsp,%rdi), %dil
addb $-0x20, %dil
xorl %r8d, %r8d
movsbl %dil, %r9d
btl %r8d, %r9d
setb (%rdx,%rsi)
incq %rsi
incl %r8d
cmpq %rsi, %rax
jne 0x9a08
movl %r10d, 0x10(%rsp)
leal 0x1(%rcx), %ebp
testl %eax, %eax
jle 0x9a81
movslq %ecx, %rcx
movb 0x40(%rsp,%rcx), %sil
addb $-0x20, %sil
movq 0x58(%r14), %rcx
xorl %edx, %edx
xorl %edi, %edi
cmpl $0x6, %edi
jne 0x9a6b
movslq %ebp, %rsi
incl %ebp
movb 0x40(%rsp,%rsi), %sil
addb $-0x20, %sil
xorl %edi, %edi
movsbl %sil, %r8d
btl %edi, %r8d
setb (%rcx,%rdx)
incq %rdx
incl %edi
cmpq %rdx, %rax
jne 0x9a56
movq %rbx, 0x30(%rsp)
movslq %ebp, %rax
incl %ebp
movb 0x40(%rsp,%rax), %al
addb $-0x20, %al
testb %al, %al
sete 0x48(%r14)
movq %r14, 0x8(%rsp)
jle 0x9b7e
movsbl %al, %eax
movl %eax, 0x14(%rsp)
leaq 0x18(%r14), %r12
xorl %r13d, %r13d
leaq 0x18(%rsp), %r15
movq %r12, 0x38(%rsp)
movq %r15, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movslq %ebp, %r14
incl %ebp
movb 0x40(%rsp,%r14), %r12b
addb $-0x21, %r12b
js 0x9b2d
leaq 0x42(%rsp), %rax
addq %rax, %r14
movslq %ebp, %rax
movb 0x40(%rsp,%rax), %bl
movl $0x18, %edi
callq 0x21f0
addb $-0x21, %bl
movsbq %bl, %rcx
shlq $0x20, %rcx
movzbl %r12b, %edx
orq %rcx, %rdx
movq %rdx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq 0x28(%rsp)
movb (%r14), %r12b
addl $0x2, %ebp
addq $0x2, %r14
addb $-0x21, %r12b
jns 0x9ae6
movq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xaf98
movq %rax, %rdi
movq %r12, %rsi
callq 0x2070
movq 0x8(%rsp), %r14
incq 0x28(%r14)
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x9b70
movq (%rdi), %rbx
movl $0x18, %esi
callq 0x2200
movq %rbx, %rdi
cmpq %r15, %rbx
jne 0x9b5b
incl %r13d
cmpl 0x14(%rsp), %r13d
jne 0x9abb
leaq 0x4c(%r14), %r15
movslq %ebp, %rax
movsbl 0x40(%rsp,%rax), %r8d
cmpl $0xa, %r8d
movq 0x30(%rsp), %rbx
jne 0x9c38
cmpl $0x0, (%r15)
movl 0x10(%rsp), %ebp
jle 0x9bd8
movq 0x58(%r14), %rax
movq 0x60(%r14), %rcx
movq 0x78(%r14), %rdx
xorl %esi, %esi
cmpb $0x0, (%rcx,%rsi)
jne 0x9bbe
cmpb $0x1, (%rax,%rsi)
jne 0x9bcd
movslq 0x74(%r14), %rdi
leal 0x1(%rdi), %r8d
movl %r8d, 0x74(%r14)
movl %esi, (%rdx,%rdi,4)
incq %rsi
movslq (%r15), %rdi
cmpq %rdi, %rsi
jl 0x9bb2
testl %ebp, %ebp
jle 0x9c26
leaq 0x30(%r14), %r12
movl $0x80, %edi
callq 0x21f0
movq %rax, %r13
movl (%r15), %esi
incl %esi
movq %rax, %rdi
callq 0x81fc
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9968
movl $0x18, %edi
callq 0x21f0
movq %r13, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2070
incq 0x40(%r14)
decl %ebp
jne 0x9be0
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %r12
movq 0xe396(%rip), %r14      # 0x17fd8
movq (%r14), %rdi
leaq 0x80d2(%rip), %rsi      # 0x11d1e
leaq 0x40(%rsp), %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x22d0
movq (%r14), %rdi
movl 0x4c(%r12), %edx
leaq 0x80d5(%rip), %rax      # 0x11d3e
leaq 0x87fd(%rip), %rcx      # 0x1246d
cmpb $0x0, 0x50(%r12)
cmovneq %rax, %rcx
leaq 0x80b2(%rip), %rsi      # 0x11d33
xorl %eax, %eax
callq 0x22d0
cmpl $0x0, 0x4c(%r12)
jle 0x9c9d
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x248f
movq (%r14), %rcx
leaq 0x8099(%rip), %rdi      # 0x11d40
movl $0x2, %esi
movl $0x1, %edx
callq 0x23e0
movq 0x8(%rsp), %r14
jmp 0x9b9a
jmp 0x9cd4
movq %rax, %rbx
movl $0x80, %esi
movq %r13, %rdi
callq 0x2200
jmp 0x9cf6
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x9cf6
movq (%rdi), %r14
movl $0x18, %esi
callq 0x2200
movq %r14, %rdi
cmpq %r15, %r14
jne 0x9ce1
movq %rbx, %rdi
callq 0x2370