// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x480(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xc9d0
leaq -0x440(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x33f0
cmpq $0x0, %rax
je 0x131d2
movsbl -0x440(%rbp), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12c5f
movq -0x480(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x12c6a
movq -0x480(%rbp), %rax
movb $0x0, 0x50(%rax)
movsbl -0x31(%rbp), %eax
sarl %eax
movl %eax, -0x44c(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x44c(%rbp), %eax
jge 0x12cd8
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
imull -0x1c(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
imull $0x5f, -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x12c92
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x480(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x4c(%rcx), %eax
jge 0x12d8a
cmpl $0x6, -0x24(%rbp)
jne 0x12d38
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movl $0x0, -0x24(%rbp)
movsbl -0x31(%rbp), %eax
movl -0x24(%rbp), %ecx
sarl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12d5e
movq -0x480(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x12d71
movq -0x480(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x12d73
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x12d01
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x480(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x4c(%rcx), %eax
jge 0x12e3c
cmpl $0x6, -0x24(%rbp)
jne 0x12dea
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movl $0x0, -0x24(%rbp)
movsbl -0x31(%rbp), %eax
movl -0x24(%rbp), %ecx
sarl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x12e10
movq -0x480(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x18(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x12e23
movq -0x480(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x12e25
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x12db3
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
jne 0x12e6d
movq -0x480(%rbp), %rax
movb $0x1, 0x48(%rax)
jmp 0x12e78
movq -0x480(%rbp), %rax
movb $0x0, 0x48(%rax)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
jle 0x12f67
movsbl -0x31(%rbp), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x12f65
leaq -0x468(%rbp), %rdi
callq 0x15940
jmp 0x12ead
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
cltq
movsbl -0x440(%rbp,%rax), %eax
subl $0x20, %eax
subl $0x1, %eax
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
jge 0x12ed6
jmp 0x12f32
movsbl -0x31(%rbp), %eax
movl %eax, -0x30(%rbp)
movslq -0x20(%rbp), %rax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x20(%rbp)
movb -0x440(%rbp,%rax), %al
addb $-0x21, %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq -0x468(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xca80
jmp 0x12f0d
jmp 0x12eab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x15c10
jmp 0x131db
movq -0x480(%rbp), %rdi
addq $0x18, %rdi
leaq -0x468(%rbp), %rsi
callq 0x15cd0
jmp 0x12f4b
leaq -0x468(%rbp), %rdi
callq 0x15c10
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x12e93
jmp 0x12f67
movslq -0x20(%rbp), %rax
movsbl -0x440(%rbp,%rax), %eax
cmpl $0xa, %eax
je 0x130c2
movq 0x18055(%rip), %rax     # 0x2afd8
movq (%rax), %rdi
leaq -0x440(%rbp), %rdx
movl -0x20(%rbp), %ecx
movslq -0x20(%rbp), %rax
movsbl -0x440(%rbp,%rax), %r8d
leaq 0xdc42(%rip), %rsi      # 0x20be6
movb $0x0, %al
callq 0x33a0
movq -0x480(%rbp), %rax
movq 0x1801f(%rip), %rcx     # 0x2afd8
movq (%rcx), %rcx
movq %rcx, -0x490(%rbp)
movl 0x4c(%rax), %ecx
movl %ecx, -0x484(%rbp)
testb $0x1, 0x50(%rax)
je 0x12fe2
leaq 0xdc2d(%rip), %rax      # 0x20c06
movq %rax, -0x498(%rbp)
jmp 0x12ff2
leaq 0xde57(%rip), %rax      # 0x20e40
movq %rax, -0x498(%rbp)
jmp 0x12ff2
movl -0x484(%rbp), %edx
movq -0x490(%rbp), %rdi
movq -0x498(%rbp), %rcx
leaq 0xdbee(%rip), %rsi      # 0x20bfb
movb $0x0, %al
callq 0x33a0
movl $0x0, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x480(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x4c(%rcx), %eax
jge 0x130aa
movq -0x480(%rbp), %rax
movq 0x17f99(%rip), %rcx     # 0x2afd8
movq (%rcx), %rcx
movq %rcx, -0x4a0(%rbp)
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x13067
leaq 0xd9d3(%rip), %rax      # 0x20a31
movq %rax, -0x4a8(%rbp)
jmp 0x13077
leaq 0xdb5a(%rip), %rax      # 0x20bc8
movq %rax, -0x4a8(%rbp)
jmp 0x13077
movq -0x4a0(%rbp), %rdi
movq -0x4a8(%rbp), %rdx
leaq 0xdb22(%rip), %rsi      # 0x20bae
movb $0x0, %al
callq 0x33a0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x13022
movq 0x17f27(%rip), %rax     # 0x2afd8
movq (%rax), %rdi
leaq 0xdb4d(%rip), %rsi      # 0x20c08
movb $0x0, %al
callq 0x33a0
movl $0x0, -0x18(%rbp)
movq -0x480(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x4c(%rcx), %eax
jge 0x1312e
movq -0x480(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x18(%rbp), %rcx
testb $0x1, (%rax,%rcx)
jne 0x13102
movq -0x480(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x18(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x13121
movq -0x480(%rbp), %rsi
movl -0x18(%rbp), %edx
movq 0x78(%rsi), %rax
movl 0x74(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x74(%rsi)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x13123
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x130c9
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x131d0
movl $0x80, %edi
callq 0x3270
movq %rax, %rdi
movq -0x480(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x4b0(%rbp)
movl 0x4c(%rax), %esi
incl %esi
callq 0xfc80
jmp 0x1316b
movq -0x4b0(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x12bf0
movq -0x480(%rbp), %rdi
addq $0x30, %rdi
leaq -0x448(%rbp), %rsi
callq 0x158a0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x13135
movq -0x4b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x470(%rbp)
movl %eax, -0x474(%rbp)
movl $0x80, %esi
callq 0x3280
jmp 0x131db
jmp 0x131d2
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
movq -0x470(%rbp), %rdi
callq 0x3440
nopw (%rax,%rax)