// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/readnet.c
// Function: read_network_net
bayesiangraphptr read_network_net(char *f_name)
{
/*!Last Changed 24.12.2000*/
 FILE *myfile;
 bayesiangraphptr result;
 nodeptr current;
 int pos, var, parents, prob, res, parent_count, i, Index, where, table_index, currentp;
 int parent[MAXPARENT];
 char myline[READLINELENGTH];
 char *st;
 char st1[7];
 st1[0] = ' ';
 st1[1] = '\n';
 st1[2] = ':';
 st1[3] = '(';
 st1[4] = ')';
 st1[5] = '\t';
 st1[6] = '\0';
 if ((myfile = fopen(f_name, "r")) == NULL)
  {
   printf(m1308, f_name);
   return NULL;
  }
 pos = -1;
 var = 0;
 parents = 0;
 while (fgets(myline, READLINELENGTH, myfile))
  {
   st = strtok(myline, st1);
   while (st)
    {
     switch (listindex(st, net_words, 4)) 
      {
       case -1:switch (pos)
                {
                 case -1:return NULL;
                 case  0:result = create_graph(st);
                         break;
                 case  1:return NULL;
                 case  2:if (var == 0)
                          {
                           current = add_one_node(result, st);
                           var = 1;
                          }
                         else
                           add_one_value(current, st);
                         break;
                 case  3:if (parents == 0)
                          {
                           currentp = node_in(result, st);
                           if (currentp == -1)
                             return NULL;
                           current = &(result->nodes[currentp]);
                           parents = 1;
                          }
                         else
                           if ((parents == 1) && (isalpha(st[0])))
                            {
                             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 (isalpha(st[0]))
                              {
                               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)
                                {
                                 parent_count = 0;
                                 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);
                                }
                              }
                          }
                         break;
                 default:return NULL;
               }
               break;
       case  0:if (pos == -1)
                 pos = 0;
               else
                 return NULL;
               break;
       case  1:if (pos == 0)
                 pos = 1;
               else
                 return NULL;
               break;
       case  2:if (pos == 1)
                 pos = 2;
               else
                 if (pos == 2)
                   var = 0;
                 else
                   return NULL;
               break;
       case  3:if (pos == 2)
                 pos = 3;
               else
                 if (pos == 3)
                   parents = 0;
               break;
       default:return NULL;
     }
     st = strtok(NULL, st1);
    }
  }
 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
movl $0x283a0a20, 0x81(%rsp) # imm = 0x283A0A20
movw $0x929, 0x85(%rsp)      # imm = 0x929
movb $0x0, 0x87(%rsp)
leaq 0x38382(%rip), %rsi     # 0xa888f
callq 0x40f0
testq %rax, %rax
je 0x709c3
movq %rax, %rbp
leaq 0xf0(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x709dc
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0xf0(%rsp), %r14
leaq 0x81(%rsp), %r12
leaq 0x3c313(%rip), %rbx     # 0xac86c
movq %rax, 0x60(%rsp)
movq %rax, 0x78(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x0, 0x5c(%rsp)
movq %rbp, 0x98(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x4280
testq %rax, %rax
je 0x70992
movq %rax, %rbp
movq %r13, %r14
leaq 0x61d74(%rip), %r13     # 0xd2310
movq %rbp, %rdi
movq %r13, %rsi
movl $0x4, %edx
callq 0x3a2c5
incl %eax
cmpl $0x4, %eax
ja 0x709d8
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpl $0x3, %r15d
je 0x70676
cmpl $0x2, %r15d
je 0x7065b
testl %r15d, %r15d
jne 0x709d8
movq %rbp, %rdi
callq 0x4d68a
movq %rax, 0x68(%rsp)
jmp 0x70648
cmpl $0x2, %r15d
je 0x70650
cmpl $0x3, %r15d
jne 0x7071f
movl $0x0, 0x58(%rsp)
jmp 0x7071f
testl %r15d, %r15d
movl $0x1, %r15d
je 0x7071f
jmp 0x709d8
cmpl $0x1, %r15d
je 0x70719
cmpl $0x2, %r15d
jne 0x709d8
movl $0x0, 0x5c(%rsp)
jmp 0x7071f
cmpl $-0x1, %r15d
jne 0x709d8
xorl %r15d, %r15d
jmp 0x7071f
movl $0x3, %r15d
jmp 0x7071f
cmpl $0x0, 0x5c(%rsp)
je 0x70701
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4d58c
jmp 0x70711
movl 0x58(%rsp), %eax
cmpl $0x1, %eax
je 0x706bf
testl %eax, %eax
jne 0x707de
movq 0x68(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4cff0
cmpl $-0x1, %eax
je 0x709d8
movl %eax, 0x74(%rsp)
cltq
leaq (%rax,%rax,8), %rax
shlq $0x3, %rax
addq 0x8(%r14), %rax
movq %rax, %r14
movl $0x1, %eax
jmp 0x707de
callq 0x41a0
movq (%rax), %rax
movsbq (%rbp), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x7073a
cmpl $0x0, 0x20(%r14)
jne 0x709d8
movq %r14, %rdi
callq 0x4d560
movl $0x0, 0x54(%rsp)
movl $0x2, %eax
movq $0x0, 0x60(%rsp)
jmp 0x707de
movq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0x4d16a
movq %rax, %r14
movl $0x1, 0x5c(%rsp)
movl $0x2, %r15d
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
movq %rax, %rbp
testq %rax, %rax
jne 0x7059c
jmp 0x70995
movq %r14, %r13
movq 0x68(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4cff0
cmpl $-0x1, %eax
je 0x70782
movl %eax, %r15d
movq %r14, %rdi
movq %r13, %rsi
movl %eax, %edx
callq 0x4d508
movq %r14, %rdi
callq 0x4d426
movq %r14, %rdi
movq %r13, %r14
movq %r13, %rsi
movl %r15d, %edx
callq 0x4d47a
movl $0x1, %eax
jmp 0x707d7
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movq %r13, %r14
movq %r13, %rdi
callq 0x4d560
movq $0x0, 0x78(%rsp)
movl $0x1, 0x54(%rsp)
movl $0x2, %eax
movq $0x0, 0x60(%rsp)
leaq 0x61b32(%rip), %r13     # 0xd2310
movl $0x3, %r15d
movl %eax, 0x58(%rsp)
cmpl $0x2, %eax
jne 0x7071f
cmpl $0x0, 0x54(%rsp)
je 0x7086d
callq 0x41a0
movq (%rax), %rax
movsbq (%rbp), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x708a5
cmpl $0x1, 0x54(%rsp)
je 0x7090e
movq 0x60(%rsp), %r13
leal 0x1(%r13), %eax
movl %eax, 0x88(%rsp)
movq %rbp, %rdi
callq 0x4130
movq 0x38(%r14), %rax
movslq 0x94(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq %r13d, %rcx
movsd %xmm0, 0x8(%rax,%rcx,8)
movl $0x2, 0x58(%rsp)
movl $0x2, 0x54(%rsp)
movl 0x88(%rsp), %eax
movq %rax, 0x60(%rsp)
jmp 0x70986
movq %rbp, %rdi
callq 0x4130
movq 0x38(%r14), %rax
movq (%rax), %rax
movq 0x60(%rsp), %rdx
movslq %edx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl %edx
movq %rdx, 0x60(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x2, 0x58(%rsp)
jmp 0x7071f
movq %r14, 0x88(%rsp)
movq 0x68(%rsp), %r14
movq %r14, %rdi
movl 0x74(%rsp), %esi
movq 0x78(%rsp), %r13
movl %r13d, %edx
callq 0x4d140
movq 0x8(%r14), %rcx
movq 0x88(%rsp), %r14
cltq
leaq (%rax,%rax,8), %rax
movq 0x8(%rcx,%rax,8), %rsi
movl 0x10(%rcx,%rax,8), %edx
movq %rbp, %rdi
callq 0x3a2c5
movslq %r13d, %r13
movl %eax, 0xa0(%rsp,%r13,4)
incl %r13d
movq %r13, 0x78(%rsp)
movl $0x1, 0x54(%rsp)
movl $0x2, 0x58(%rsp)
jmp 0x70986
movslq 0x74(%rsp), %rax
leaq (%rax,%rax,8), %rsi
shlq $0x3, %rsi
movq 0x68(%rsp), %rax
addq 0x8(%rax), %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xa0(%rsp), %rdi
callq 0x4d0a1
movq %r14, %r13
movl %eax, %r14d
movq %rbp, %rdi
callq 0x4130
movq 0x38(%r13), %rax
movl %r14d, 0x94(%rsp)
movslq %r14d, %rcx
movq %r13, %r14
movq (%rax,%rcx,8), %rax
movsd %xmm0, (%rax)
movq $0x0, 0x78(%rsp)
movl $0x2, 0x58(%rsp)
movl $0x2, 0x54(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x61983(%rip), %r13     # 0xd2310
jmp 0x7071f
movq %r13, %r14
movq %r14, %r13
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x98(%rsp), %rbp
movq %rbp, %rdx
callq 0x4120
testq %rax, %rax
jne 0x7057b
jmp 0x709dc
leaq 0x3bfb8(%rip), %rdi     # 0xac982
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x709e9
xorl %ebx, %ebx
jmp 0x709e9
movq %rbp, %rdi
callq 0x42a0
movq 0x68(%rsp), %rbx
movq %rbx, %rax
addq $0x7a218, %rsp          # imm = 0x7A218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop