// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/readnet.c
// Function: read_network_hugin
bayesiangraphptr read_network_hugin(char *f_name)
{
/*!Last Changed 06.02.2001 Commentlere dikkat*/
 FILE *myfile;
 bayesiangraphptr result = create_graph(file_only_name(f_name));
 char myline[READLINELENGTH];
 char *st;
 char st1[12];
 int pos = -1, ind = -1, child = -1, pindex, row = -1, col;
 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] = '\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, hugin_words, 7)) 
      {
       case -1:if (st[0] == '%')
                 goto devam;
               switch (pos) {
                 case -1:return NULL;
                 case  0:
                 case  2:break;
                 case  1:current = add_one_node(result, st);
                         break;
                 case  3:current->xpos = atoi(st);
                         pos++;
                         break;
                 case  4:current->ypos = atoi(st);
                         break;
                 case  5:add_one_value(current, st);
                         break;
                 case  6:if (ind == -1)
                          {
                           child = node_in(result, st);
                           if (child == -1)
                             return NULL;
                           ind++;
                          }
                         else
                          {
                           pindex = node_in(result, st);
                           if (pindex == -1)
                             return NULL;
                           add_parent_counts(result, &result->nodes[child],pindex);
                           add_one_arc(result);
                           add_one_pointer(result, &result->nodes[child],pindex);
                          }
                         break;
                 case  7:if (row == -1)
                          {
                           current = &result->nodes[child];
                           alloc_conditional_table(current);
                           row = 0;
                           col = 0;
                          }
                         else
                          {
                           current->table[row][col] = (double) atof(st);
                           col++;
                           if (col == current->value_count)
                            {
                             row++;
                             col = 0;
                            }
                          }
                         break;
               }
               break;
       case  0:pos = 0; /*net*/
               break;
       case  1:pos = 1; /*node*/
               break;
       case  2:pos = 2; /*label*/
               break;
       case  3:pos = 3; /*position*/
               break;
       case  4:pos = 5; /*states*/
               break;
       case  5:pos = 6; /*potential*/
               ind = -1;
               break;
       case  6:pos = 7; /*data*/
               row = -1;
               break;
     }
     st = strtok(NULL,st1);
    }
devam:;
  }
 fclose(myfile);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a178, %rsp          # imm = 0x7A178
movq %rdi, %rbx
callq 0x34033
movq %rax, %rdi
callq 0x4783d
movq %rax, %r14
movabsq $0x2229283d7d7b0a20, %rax # imm = 0x2229283D7D7B0A20
movq %rax, 0x40(%rsp)
movl $0x97c3b, 0x48(%rsp)    # imm = 0x97C3B
leaq 0x33ec3(%rip), %rsi     # 0x9b87f
movq %rbx, %rdi
callq 0x40f0
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x67c24
movq %r14, 0x20(%rsp)
pushq $-0x1
popq %rax
leaq 0x50(%rsp), %rbx
leaq 0x40(%rsp), %r12
pushq $0x7
popq %rbp
leaq 0x37d02(%rip), %r15     # 0x9f6f0
movl %eax, %r13d
movl %eax, %ecx
movq %rcx, 0x28(%rsp)
movl %eax, 0x1c(%rsp)
movl %eax, 0xc(%rsp)
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x38(%rsp), %rdx
callq 0x4120
testq %rax, %rax
je 0x67c3a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4280
movq %rax, %rbx
testq %rbx, %rbx
je 0x67c1a
movq %rbx, %rdi
leaq 0x659cf(%rip), %rsi     # 0xcd410
movl %ebp, %edx
callq 0x35f17
movl %eax, %r14d
leal 0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x67a9d
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
cmpb $0x25, (%rbx)
je 0x67c1a
leal 0x1(%r13), %eax
cmpl $0x8, %eax
ja 0x67a9d
leaq 0x37c9a(%rip), %rcx     # 0x9f710
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movslq 0x1c(%rsp), %r14
jmpq *%rax
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x47398
movq %rax, 0x10(%rsp)
pushq $0x1
jmp 0x67b4c
movl %r13d, %r14d
jmp 0x67b50
movl %ebp, %r14d
pushq $-0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0x67b50
pushq $0x6
popq %rax
movl %eax, %r14d
pushq $-0x1
popq %rax
movq %rax, 0x28(%rsp)
jmp 0x67b50
movq %rbx, %rdi
callq 0x4200
movq 0x10(%rsp), %rcx
movl %eax, 0x44(%rcx)
jmp 0x67b75
movq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x47224
movl %eax, %ebx
cmpl $-0x1, 0x28(%rsp)
je 0x67bcd
cmpl $-0x1, %ebx
je 0x67c4b
imulq $0x48, %r14, %r14
movq 0x8(%r13), %rsi
addq %r14, %rsi
movq %r13, %rdi
movl %ebx, %edx
callq 0x476d6
movq %r13, %rdi
callq 0x47603
addq 0x8(%r13), %r14
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x47654
movq $0x0, 0x28(%rsp)
pushq $0x6
jmp 0x67b4c
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x47750
pushq $0x5
popq %rax
movl %eax, %r14d
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
movq %rax, %rbx
movl %r14d, %r13d
jmp 0x67a2e
movq %rbx, %rdi
callq 0x4200
movq 0x10(%rsp), %rcx
movl %eax, 0x40(%rcx)
pushq $0x4
jmp 0x67b4c
movl 0xc(%rsp), %r13d
cmpl $-0x1, %r13d
je 0x67bea
movq %rbx, %rdi
callq 0x4130
movq 0x10(%rsp), %rdx
movq 0x38(%rdx), %rax
movslq %r13d, %rcx
movq (%rax,%rcx,8), %rax
movq 0x30(%rsp), %rsi
movslq %esi, %rsi
movsd %xmm0, (%rax,%rsi,8)
incl %esi
xorl %eax, %eax
cmpl 0x10(%rdx), %esi
sete %al
movl $0x0, %ecx
cmovel %ecx, %esi
movq %rsi, 0x30(%rsp)
addl %eax, %r13d
movl %r13d, 0xc(%rsp)
movl %ebp, %r14d
jmp 0x67b50
cmpl $-0x1, %ebx
je 0x67c4b
movq $0x0, 0x28(%rsp)
pushq $0x6
popq %rax
movl %eax, %r14d
movl %ebx, 0x1c(%rsp)
jmp 0x67b50
imulq $0x48, %r14, %rdi
movq 0x20(%rsp), %rax
addq 0x8(%rax), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4772a
movl $0x0, 0xc(%rsp)
movl %ebp, %r14d
movq $0x0, 0x30(%rsp)
jmp 0x67b50
leaq 0x50(%rsp), %rbx
jmp 0x67a05
leaq 0x37d4f(%rip), %rdi     # 0x9f97a
xorl %r14d, %r14d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x67c4e
movq 0x38(%rsp), %rdi
callq 0x42a0
movq 0x20(%rsp), %r14
jmp 0x67c4e
xorl %r14d, %r14d
movq %r14, %rax
addq $0x7a178, %rsp          # imm = 0x7A178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq