// File: /workspace/github_c_makefile_star2_O1/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, %r15
movabsq $0x2229283d7d7b0a20, %rax # imm = 0x2229283D7D7B0A20
movq %rax, 0x89(%rsp)
movl $0x5b097c3b, 0x91(%rsp) # imm = 0x5B097C3B
movw $0x2c5d, 0x95(%rsp)     # imm = 0x2C5D
movb $0x0, 0x97(%rsp)
leaq 0x3937d(%rip), %rsi     # 0xa888f
callq 0x40f0
testq %rax, %rax
je 0x6f9cd
movq %rax, %rbp
leaq 0xf0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x6f9e2
leaq 0xf0(%rsp), %rdi
leaq 0x89(%rsp), %r12
leaq 0x62ef8(%rip), %r13     # 0xd2450
leaq 0x3d151(%rip), %rbx     # 0xac6b0
movq %rax, 0x68(%rsp)
movl $0x0, 0x60(%rsp)
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %rbp, 0x98(%rsp)
movq %r12, %rsi
callq 0x4280
testq %rax, %rax
je 0x6f999
movq %rax, %rbp
movq %rbp, %rdi
movq %r13, %rsi
movl $0x9, %edx
callq 0x3a2c5
movl %eax, %r14d
leal 0x1(%r14), %eax
cmpl $0x9, %eax
ja 0x6f5ed
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movl $0x2, %r14d
jmp 0x6f6ef
movl $0x0, 0x78(%rsp)
jmp 0x6f5ed
cmpl $0x4, %r15d
movl $0x5, %eax
cmovel %eax, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl 0x54(%rsp), %ecx
cmovel %eax, %ecx
movl %ecx, 0x54(%rsp)
movl %r15d, %r14d
jmp 0x6f6ef
movsbq (%rbp), %r14
cmpq $0x2f, %r14
jne 0x6f60a
cmpb $0x2f, 0x1(%rbp)
je 0x6f999
leal 0x1(%r15), %eax
cmpl $0x7, %eax
ja 0x6f5ed
leaq 0x3d0be(%rip), %rcx     # 0xac6d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbp, %rdi
callq 0x4d68a
movq %rax, 0x70(%rsp)
movl $0x1, %r14d
jmp 0x6f6ef
movl $0x4, %r14d
jmp 0x6f6ef
movl $0x0, 0x60(%rsp)
movl $0x6, %r14d
jmp 0x6f6ef
movl $0x5, %r14d
cmpl $-0x1, 0x54(%rsp)
je 0x6f673
movq 0x58(%rsp), %rdi
movq %rbp, %rsi
callq 0x4d58c
movl $0x0, 0x54(%rsp)
jmp 0x6f6ef
movl 0x60(%rsp), %eax
cmpl $0x1, %eax
je 0x6f70d
testl %eax, %eax
jne 0x6f7a2
movq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4cff0
cmpl $-0x1, %eax
je 0x6f9f1
movl %eax, 0x84(%rsp)
cltq
leaq (%rax,%rax,8), %rax
shlq $0x3, %rax
addq 0x8(%r14), %rax
movq %rax, 0x58(%rsp)
movl $0x1, %eax
movl $0x1, 0x78(%rsp)
jmp 0x6f7a2
movq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x4d16a
movq %rax, 0x58(%rsp)
movl $0x3, %r14d
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
movq %rax, %rbp
movl %r14d, %r15d
testq %rax, %rax
jne 0x6f596
jmp 0x6f99c
callq 0x41a0
movq (%rax), %rax
movb 0x1(%rax,%r14,2), %al
andb $0x4, %al
shrb $0x2, %al
cmpl $0x0, 0x78(%rsp)
setne %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x6f778
movq 0x70(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4cff0
cmpl $-0x1, %eax
je 0x6f8e9
movl %eax, %r15d
movq %r14, %rdi
movq 0x58(%rsp), %rsi
movl %eax, %edx
callq 0x4d508
movq %r14, %rdi
callq 0x4d426
movq %r14, %rdi
movq 0x58(%rsp), %rsi
movl %r15d, %edx
callq 0x4d47a
movl $0x1, %eax
jmp 0x6f7a2
movq 0x58(%rsp), %rdi
cmpl $0x0, 0x20(%rdi)
jne 0x6f9f1
callq 0x4d560
movl $0x0, 0x50(%rsp)
movl $0x2, %eax
movq $0x0, 0x68(%rsp)
movl 0x4c(%rsp), %ecx
movl $0x6, %r14d
cmpl $0x2, %eax
movl %ecx, 0x4c(%rsp)
jne 0x6f820
cmpl $0x0, 0x50(%rsp)
je 0x6f829
movq 0x70(%rsp), %r15
movq 0x8(%r15), %rdx
movl 0x84(%rsp), %esi
movslq %esi, %rax
leaq (%rax,%rax,8), %rax
cmpl 0x20(%rdx,%rax,8), %ecx
jge 0x6f866
movq %r15, %rdi
movl %ecx, %edx
callq 0x4d140
movq 0x8(%r15), %rcx
cltq
leaq (%rax,%rax,8), %rax
movq 0x8(%rcx,%rax,8), %rsi
movl 0x10(%rcx,%rax,8), %edx
movq %rbp, %rdi
callq 0x3a2c5
movl 0x4c(%rsp), %edx
movslq %edx, %rcx
movl %eax, 0xa0(%rsp,%rcx,4)
incl %edx
movl %edx, 0x4c(%rsp)
movl $0x1, 0x50(%rsp)
jmp 0x6f859
movl %eax, 0x60(%rsp)
jmp 0x6f6ef
movq %rbp, %rdi
callq 0x4130
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq 0x68(%rsp), %rdx
movslq %edx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl %edx
movq %rdx, 0x68(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x2, 0x60(%rsp)
jmp 0x6f6ef
cmpl $0x1, 0x50(%rsp)
je 0x6f93b
movq 0x68(%rsp), %r15
leal 0x1(%r15), %ecx
movl %ecx, 0x80(%rsp)
movq %rbp, %rdi
movq %rdx, 0x60(%rsp)
movq %rax, %rbp
callq 0x4130
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
movslq 0x7c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq %r15d, %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
addl $0x2, %ecx
movq 0x60(%rsp), %rax
cmpl 0x10(%rax,%rbp,8), %ecx
movl $0x0, %eax
movl 0x4c(%rsp), %ecx
cmovel %eax, %ecx
movl %ecx, 0x4c(%rsp)
movl $0x2, 0x60(%rsp)
movl $0x2, 0x50(%rsp)
movl 0x80(%rsp), %eax
movq %rax, 0x68(%rsp)
jmp 0x6f6ef
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movq 0x58(%rsp), %rdi
callq 0x4d560
movq $0x0, 0x68(%rsp)
movl $0x1, 0x50(%rsp)
movl $0x2, %eax
xorl %ecx, %ecx
jmp 0x6f7a6
leaq (%rdx,%rax,8), %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %rdi
callq 0x4d0a1
movl %eax, %r15d
movq %rbp, %rdi
callq 0x4130
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
movl %r15d, 0x7c(%rsp)
movslq %r15d, %rcx
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq $0x0, 0x68(%rsp)
movl $0x2, 0x60(%rsp)
movl $0x2, 0x50(%rsp)
jmp 0x6f6ef
movl %r15d, %r14d
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x98(%rsp), %rbp
movq %rbp, %rdx
callq 0x4120
movq %r15, %rdi
movl %r14d, %r15d
testq %rax, %rax
jne 0x6f582
jmp 0x6f9e2
leaq 0x3cfae(%rip), %rdi     # 0xac982
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x6f9f3
movq %rbp, %rdi
callq 0x42a0
movq 0x70(%rsp), %rbx
jmp 0x6f9f3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x7a218, %rsp          # imm = 0x7A218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq