// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/readnet.c
// Function: read_network_bif
bayesiangraphptr read_network_bif(char *f_name)
{
/*!Last Changed 09.02.2001 Commentlere dikkat*/
 FILE *myfile;
 char myline[READLINELENGTH];
 char *st;
 char st1[15];
 int i,pos = -1, ind = -1, parents = 0, currentp, res, prob, noparents;
 int where, table_index, Index, parent_count;
 int parent[MAXPARENT];
 bayesiangraphptr result;
 nodeptr current;
 st1[0] = ' ';
 st1[1] = '\n';
 st1[2] = '{';
 st1[3] = '}';
 st1[4] = '=';
 st1[5] = '(';
 st1[6] = ')';
 st1[7] = '"';
 st1[8] = ';';
 st1[9] = '|';
 st1[10] = '\t';
 st1[11] = '[';
 st1[12] = ']';
 st1[13] = ',';
 st1[14] = '\0';
 if ((myfile = fopen(f_name, "r")) == NULL)
  {
   printf(m1308, f_name);
   return NULL;
  }
 while (fgets(myline, READLINELENGTH, myfile))
  {
   st = strtok(myline, st1);
   while (st)
    {
     switch (listindex(st, bif_words, 9)) 
      {
       case -1:if ((st[0] == '/') && (st[1] == '/'))
                 goto devam;
               switch (pos) 
                {
                 case -1:
                 case  0:result = create_graph(st);
                         pos = 1;
                         break;
                 case  1:return NULL;
                 case  2:break;
                 case  3:current = add_one_node(result, st);
                         break;
                 case  4:return NULL;
                 case  5:if (ind == -1)
                           ind = 0;
                         else
                           add_one_value(current, st);
                         break;
                 case  6:if (parents == 0)
                          {
                           currentp = node_in(result, st);
                           noparents = 1;
                           if (currentp == -1)
                             return NULL;
                           current = &(result->nodes[currentp]);
                           parents = 1;
                          }
                         else
                           if ((parents == 1) && (isalpha(st[0]) || (noparents)))
                            {
                             res = node_in(result, st);
                             if (res != -1)
                              {
                               add_parent_counts(result, current, res);
                               add_one_arc(result);
                               add_one_pointer(result, current, res);
                              }
                             else
                              {
                               prob = 1;
                               parent_count = 0;
                               for (i = 0; i < MAXPARENT; i++)
                                 parent[i] = 0;
                               parents = 2;
                               Index = 0;
                               alloc_conditional_table(current);
                              }
                            }
                           else
                             if (parents == 1)
                              {/*No parents*/
                               if (current->parents != 0)
                                 return NULL;
                               parents = 2;
                               prob = 0;
                               Index = 0;
                               alloc_conditional_table(current);
                              }
                         if (parents == 2)
                          {
                           if (prob == 0)/*No parents*/
                            {
                             current->table[0][Index] = (double) atof(st);
                             Index++;
                            }
                           else
                             if (parent_count < result->nodes[currentp].parents)
                              {
                               prob = 1;
                               where = parent_index(result, currentp, parent_count);
                               parent[parent_count] = listindex(st, result->nodes[where].values, result->nodes[where].value_count);
                               parent_count++;
                              }
                             else
                              {
                               if (prob == 1)
                                {
                                 Index = 0;
                                 table_index = table_pos(result->nodes[currentp], parent);
                                 current->table[table_index][0] = (double) atof(st);
                                 prob = 2;
                                }
                               else
                                {
                                 Index++;
                                 current->table[table_index][Index] = (double) atof(st);
                                 if (Index + 1 == result->nodes[currentp].value_count)
                                   parent_count = 0;
                                }
                              }
                          }
                         break;
               }
               break;
       case  0:pos = 0; /*network*/
               break;
       case  1:pos = 2; /*property*/
               break;
       case  2:pos = 3; /*variable*/
               break;
       case  3:pos = 4;/*type*/
               break;
       case  4:if (pos == 4) /*discrete*/
                {
                 ind = -1;
                 pos = 5;
                }
               break;
       case  5:pos = 2; /*function*/
               break;
       case  6:pos = 6; /*max*/
               break;
       case  7:pos = 6; /*probability*/
               parents = 0;
               break;
       case  8:noparents = 0; /*table*/
               break;
     }
     st = strtok(NULL, st1);
    }
devam:;
  }
 fclose(myfile);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a218, %rsp          # imm = 0x7A218
movq %rdi, %rbx
movabsq $0x2229283d7d7b0a20, %rax # imm = 0x2229283D7D7B0A20
movq %rax, 0x90(%rsp)
movl $0x5b097c3b, 0x98(%rsp) # imm = 0x5B097C3B
movw $0x2c5d, 0x9c(%rsp)     # imm = 0x2C5D
movb $0x0, 0x9e(%rsp)
leaq 0x34375(%rip), %rsi     # 0x9b87f
callq 0x40f0
movq %rax, 0x88(%rsp)
testq %rax, %rax
je 0x67938
pushq $-0x1
popq %rax
leaq 0xf0(%rsp), %rbx
leaq 0x90(%rsp), %r15
pushq $0x9
popq %rbp
leaq 0x3816b(%rip), %r13     # 0x9f6a8
movl %eax, %r12d
movl %eax, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movq %rax, 0x68(%rsp)
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x88(%rsp), %rdx
callq 0x4120
testq %rax, %rax
je 0x67953
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4280
movq %rax, %r14
testq %r14, %r14
je 0x6792b
movq %r14, %rdi
leaq 0x65ec0(%rip), %rsi     # 0xcd450
movl %ebp, %edx
callq 0x35f17
movl %eax, %ebx
leal 0x1(%rbx), %eax
cmpl $0x9, %eax
ja 0x675d5
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
pushq $0x2
jmp 0x676c4
movl $0x0, 0x64(%rsp)
jmp 0x675d5
cmpl $0x4, %r12d
pushq $0x5
popq %rax
cmovel %eax, %r12d
pushq $-0x1
popq %rax
movl 0x4c(%rsp), %ecx
cmovel %eax, %ecx
movl %ecx, 0x4c(%rsp)
movl %r12d, %ebx
jmp 0x676c7
movsbq (%r14), %rbx
cmpq $0x2f, %rbx
jne 0x675f2
cmpb $0x2f, 0x1(%r14)
je 0x6792b
leal 0x1(%r12), %eax
cmpl $0x7, %eax
ja 0x675d5
leaq 0x380cd(%rip), %rcx     # 0x9f6d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x4783d
movq %rax, 0x70(%rsp)
pushq $0x1
jmp 0x676c4
pushq $0x4
jmp 0x676c4
movl $0x0, 0x48(%rsp)
pushq $0x6
jmp 0x676c4
cmpl $-0x1, 0x4c(%rsp)
je 0x6764a
movq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x47750
pushq $0x5
popq %rax
movl %eax, %ebx
movl $0x0, 0x4c(%rsp)
jmp 0x676c7
movl 0x48(%rsp), %eax
cmpl $0x2, %eax
je 0x67747
cmpl $0x1, %eax
je 0x676dc
testl %eax, %eax
jne 0x6762f
movq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x47224
cmpl $-0x1, %eax
je 0x6794e
movl %eax, 0x84(%rsp)
cltq
imulq $0x48, %rax, %rax
addq 0x8(%rbx), %rax
movq %rax, 0x58(%rsp)
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x1
popq %rax
movl %eax, 0x48(%rsp)
movl %eax, 0x64(%rsp)
jmp 0x676c7
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x47398
movq %rax, 0x58(%rsp)
pushq $0x3
popq %rax
movl %eax, %ebx
xorl %edi, %edi
movq %r15, %rsi
callq 0x4280
movq %rax, %r14
movl %ebx, %r12d
jmp 0x6757d
callq 0x41a0
movq (%rax), %rax
movb 0x1(%rax,%rbx,2), %al
andb $0x4, %al
shrb $0x2, %al
cmpl $0x0, 0x64(%rsp)
setne %cl
orb %al, %cl
cmpb $0x1, %cl
movq 0x70(%rsp), %r12
jne 0x67759
movq %r12, %rdi
movq %r14, %rsi
callq 0x47224
cmpl $-0x1, %eax
je 0x677c0
movl %eax, %ebx
movq %r12, %rdi
movq 0x58(%rsp), %r14
movq %r14, %rsi
movl %eax, %edx
callq 0x476d6
movq %r12, %rdi
callq 0x47603
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x47654
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x1
jmp 0x677b6
movl 0x54(%rsp), %ecx
testl %ecx, %ecx
je 0x6777d
movq 0x70(%rsp), %r12
jmp 0x677f3
movq 0x58(%rsp), %rbx
cmpl $0x0, 0x20(%rbx)
jne 0x6794e
movq %rbx, %rdi
callq 0x4772a
movl $0x0, 0x64(%rsp)
xorl %r12d, %r12d
jmp 0x67787
movq 0x58(%rsp), %rbx
movq 0x68(%rsp), %r12
movq %r14, %rdi
callq 0x4130
movq 0x38(%rbx), %rax
movq (%rax), %rax
movslq %r12d, %r12
movsd %xmm0, (%rax,%r12,8)
incl %r12d
movq %r12, 0x68(%rsp)
movl $0x0, 0x54(%rsp)
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x2
popq %rax
movl %eax, 0x48(%rsp)
jmp 0x676c7
xorl %eax, %eax
cmpq $0x14, %rax
je 0x677d5
andl $0x0, 0xa0(%rsp,%rax,4)
incq %rax
jmp 0x677c2
movq 0x58(%rsp), %rdi
callq 0x4772a
movq $0x0, 0x68(%rsp)
pushq $0x1
popq %rcx
movl $0x0, 0x50(%rsp)
movq 0x8(%r12), %rbx
movl 0x84(%rsp), %esi
movslq %esi, %rax
imulq $0x48, %rax, %rax
movl 0x50(%rsp), %edx
cmpl 0x20(%rbx,%rax), %edx
jge 0x6785a
movq %r12, %rdi
movl %edx, %ebx
callq 0x47365
movq 0x8(%r12), %rcx
cltq
imulq $0x48, %rax, %rax
movq 0x8(%rcx,%rax), %rsi
movl 0x10(%rcx,%rax), %edx
movq %r14, %rdi
callq 0x35f17
movslq %ebx, %rcx
movl %eax, 0xa0(%rsp,%rcx,4)
incl %ebx
movl %ebx, 0x50(%rsp)
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x2
popq %rax
movl %eax, 0x48(%rsp)
pushq $0x1
popq %rax
jmp 0x67922
cmpl $0x1, %ecx
je 0x678cf
movq 0x68(%rsp), %r12
leal 0x1(%r12), %ecx
movl %ecx, 0x80(%rsp)
movq %r14, %rdi
movq %rax, %r14
callq 0x4130
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
movslq 0x7c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq %r12d, %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
addl $0x2, %ecx
cmpl 0x10(%rbx,%r14), %ecx
movl $0x0, %eax
movl 0x50(%rsp), %ecx
cmovel %eax, %ecx
movl %ecx, 0x50(%rsp)
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x2
popq %rax
movl %eax, 0x48(%rsp)
movl %eax, 0x54(%rsp)
movl 0x80(%rsp), %eax
movq %rax, 0x68(%rsp)
jmp 0x676c7
addq %rax, %rbx
pushq $0x9
popq %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %rdi
callq 0x472d4
movl %eax, %ebx
movq %r14, %rdi
callq 0x4130
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
movl %ebx, 0x7c(%rsp)
movslq %ebx, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq $0x0, 0x68(%rsp)
pushq $0x6
popq %rax
movl %eax, %ebx
pushq $0x2
popq %rax
movl %eax, 0x48(%rsp)
movl %eax, 0x54(%rsp)
jmp 0x676c7
leaq 0xf0(%rsp), %rbx
jmp 0x67551
leaq 0x3803b(%rip), %rdi     # 0x9f97a
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x67965
xorl %r14d, %r14d
jmp 0x67965
movq 0x88(%rsp), %rdi
callq 0x42a0
movq 0x70(%rsp), %r14
movq %r14, %rax
addq $0x7a218, %rsp          # imm = 0x7A218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq