// File: /workspace/github_c_makefile_star2_O3/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, %rbp
leaq 0x40(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdx
callq 0x2320
testq %rax, %rax
je 0x9db3
movb 0x40(%rsp), %cl
leal -0x20(%rcx), %eax
andb $0x1, %cl
movb %cl, 0x50(%rbp)
sarb %al
testb %al, %al
jle 0x9b46
movsbl %al, %r15d
incl %r15d
movl $0x1, %eax
xorl %r10d, %r10d
movl $0x1, %ecx
movb 0x40(%rsp,%rcx), %dl
incq %rcx
addb $-0x20, %dl
movsbl %dl, %edx
imull %eax, %edx
addl %edx, %r10d
imull $0x5f, %eax, %eax
cmpq %rcx, %r15
jne 0x9b29
jmp 0x9b4f
xorl %r10d, %r10d
movl $0x1, %r15d
movslq 0x4c(%rbp), %rax
testq %rax, %rax
jle 0x9bef
movl %r15d, %ecx
incl %r15d
movb 0x40(%rsp,%rcx), %dil
addb $-0x20, %dil
movq 0x60(%rbp), %rdx
xorl %esi, %esi
xorl %r8d, %r8d
movl %r15d, %ecx
cmpl $0x6, %r8d
jne 0x9b8e
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 0x9b77
leal 0x1(%rcx), %r15d
testl %eax, %eax
jle 0x9bf3
movslq %ecx, %rcx
movb 0x40(%rsp,%rcx), %sil
addb $-0x20, %sil
movq 0x58(%rbp), %rcx
xorl %edx, %edx
xorl %edi, %edi
cmpl $0x6, %edi
jne 0x9bd7
movslq %r15d, %rsi
incl %r15d
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 0x9bc1
jmp 0x9bf3
addl $0x2, %r15d
movq %rbx, 0x28(%rsp)
movslq %r15d, %rax
incl %r15d
movb 0x40(%rsp,%rax), %al
addb $-0x20, %al
testb %al, %al
movl %r10d, 0x8(%rsp)
je 0x9cfe
movb $0x0, 0x48(%rbp)
jle 0x9d02
movsbl %al, %eax
movl %eax, 0xc(%rsp)
leaq 0x18(%rbp), %r13
xorl %ebx, %ebx
leaq 0x10(%rsp), %r12
movq %rbp, 0x30(%rsp)
movq %r13, 0x38(%rsp)
movq %r12, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movslq %r15d, %r14
incl %r15d
movb 0x40(%rsp,%r14), %r13b
addb $-0x21, %r13b
js 0x9cad
leaq 0x42(%rsp), %rax
addq %rax, %r14
movslq %r15d, %rax
movb 0x40(%rsp,%rax), %bpl
movl $0x18, %edi
callq 0x21f0
addb $-0x21, %bpl
movsbq %bpl, %rcx
shlq $0x20, %rcx
movzbl %r13b, %edx
orq %rcx, %rdx
movq %rdx, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2070
incq 0x20(%rsp)
movb (%r14), %r13b
addl $0x2, %r15d
addq $0x2, %r14
addb $-0x21, %r13b
jns 0x9c63
movq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xb10e
movq %rax, %rdi
movq %r13, %rsi
callq 0x2070
movq 0x30(%rsp), %rbp
incq 0x28(%rbp)
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x9cf0
movq (%rdi), %r14
movl $0x18, %esi
callq 0x2200
movq %r14, %rdi
cmpq %r12, %r14
jne 0x9cdb
incl %ebx
cmpl 0xc(%rsp), %ebx
jne 0x9c37
jmp 0x9d02
movb $0x1, 0x48(%rbp)
leaq 0x4c(%rbp), %r12
movslq %r15d, %rax
movsbl 0x40(%rsp,%rax), %r8d
cmpl $0xa, %r8d
movl 0x8(%rsp), %r14d
jne 0x9dc5
movl (%r12), %edi
testl %edi, %edi
movq 0x28(%rsp), %rbx
jle 0x9d62
movq 0x58(%rbp), %rax
movq 0x60(%rbp), %rcx
movq 0x78(%rbp), %rdx
xorl %esi, %esi
cmpb $0x0, (%rcx,%rsi)
jne 0x9d45
cmpb $0x1, (%rax,%rsi)
jne 0x9d57
movslq 0x74(%rbp), %rdi
leal 0x1(%rdi), %r8d
movl %r8d, 0x74(%rbp)
movl %esi, (%rdx,%rdi,4)
movl 0x4c(%rbp), %edi
incq %rsi
movslq %edi, %r8
cmpq %r8, %rsi
jl 0x9d39
testl %r14d, %r14d
jle 0x9db3
leaq 0x30(%rbp), %r15
movl $0x80, %edi
callq 0x21f0
movq %rax, %r13
movl (%r12), %esi
incl %esi
movq %rax, %rdi
callq 0x832c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ad0
movl $0x18, %edi
callq 0x21f0
movq %r13, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq 0x40(%rbp)
decl %r14d
jne 0x9d6b
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe20c(%rip), %rbx      # 0x17fd8
movq (%rbx), %rdi
leaq 0x7f70(%rip), %rsi      # 0x11d46
leaq 0x40(%rsp), %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x22d0
movq (%rbx), %rdi
movl 0x4c(%rbp), %edx
leaq 0x7f74(%rip), %rax      # 0x11d66
leaq 0x8684(%rip), %rcx      # 0x1247d
cmpb $0x0, 0x50(%rbp)
cmovneq %rax, %rcx
leaq 0x7f53(%rip), %rsi      # 0x11d5b
xorl %eax, %eax
callq 0x22d0
cmpl $0x0, 0x4c(%rbp)
jle 0x9e20
movq %rbp, %rdi
movq %r12, %rsi
callq 0x248f
movq (%rbx), %rcx
leaq 0x7f3e(%rip), %rdi      # 0x11d68
movl $0x2, %esi
movl $0x1, %edx
callq 0x23e0
jmp 0x9d1e
jmp 0x9e52
movq %rax, %rbx
movl $0x80, %esi
movq %r13, %rdi
callq 0x2200
jmp 0x9e74
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x9e74
movq (%rdi), %r14
movl $0x18, %esi
callq 0x2200
movq %r14, %rdi
cmpq %r12, %r14
jne 0x9e5f
movq %rbx, %rdi
callq 0x2370