// File: /workspace/github_c_makefile_star2_O1/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 $0x7a168, %rsp          # imm = 0x7A168
movq %rdi, %r14
callq 0x37f08
movq %rax, %rdi
callq 0x4d68a
movq %rax, %rbx
movabsq $0x2229283d7d7b0a20, %rax # imm = 0x2229283D7D7B0A20
movq %rax, 0x34(%rsp)
movl $0x97c3b, 0x3c(%rsp)    # imm = 0x97C3B
leaq 0x38e45(%rip), %rsi     # 0xa888f
movq %r14, %rdi
callq 0x40f0
testq %rax, %rax
je 0x6fd0e
movq %rbx, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, 0x28(%rsp)
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x6fcfd
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %r14
leaq 0x34(%rsp), %r12
leaq 0x62978(%rip), %r13     # 0xd2410
leaq 0x3cc59(%rip), %rbx     # 0xac6f8
movq %rax, 0x20(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r12, %rsi
callq 0x4280
testq %rax, %rax
je 0x6fcd7
movq %rax, %r14
movq %r14, %rdi
movq %r13, %rsi
movl $0x7, %edx
callq 0x3a2c5
movl %eax, %ebp
leal 0x1(%rbp), %eax
cmpl $0x7, %eax
ja 0x6fb35
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpb $0x25, (%r14)
je 0x6fcd7
leal 0x1(%r15), %eax
cmpl $0x8, %eax
ja 0x6fb35
leaq 0x3cc08(%rip), %rcx     # 0xac718
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4d16a
movq %rax, 0x8(%rsp)
movl $0x1, %ebp
jmp 0x6fbf8
movl %r15d, %ebp
jmp 0x6fbf8
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x7, %ebp
jmp 0x6fbf8
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
movl $0x6, %ebp
jmp 0x6fbf8
movq %r14, %rdi
callq 0x4200
movq 0x8(%rsp), %rcx
movl %eax, 0x44(%rcx)
jmp 0x6fc26
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4cff0
movl %eax, %r14d
cmpl $-0x1, 0x18(%rsp)
je 0x6fc7b
cmpl $-0x1, %r14d
je 0x6fd23
movslq 0x4(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %r15
movq 0x8(%rbp), %rsi
addq %r15, %rsi
movq %rbp, %rdi
movl %r14d, %edx
callq 0x4d508
movq %rbp, %rdi
callq 0x4d426
addq 0x8(%rbp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x4d47a
movq $0x0, 0x18(%rsp)
jmp 0x6fb58
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x4d58c
movl $0x5, %ebp
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
movq %rax, %r14
movl %ebp, %r15d
testq %rax, %rax
jne 0x6fad3
jmp 0x6fcda
movq %r14, %rdi
callq 0x4200
movq 0x8(%rsp), %rcx
movl %eax, 0x40(%rcx)
movl $0x4, %ebp
jmp 0x6fbf8
movl (%rsp), %ebp
cmpl $-0x1, %ebp
je 0x6fc9d
movq %r14, %rdi
callq 0x4130
movq 0x8(%rsp), %rdx
movq 0x38(%rdx), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%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, 0x20(%rsp)
addl %eax, %ebp
movl %ebp, (%rsp)
jmp 0x6fb44
movl $0x6, %ebp
cmpl $-0x1, %r14d
je 0x6fd23
movq $0x0, 0x18(%rsp)
movl %r14d, 0x4(%rsp)
jmp 0x6fbf8
movslq 0x4(%rsp), %rax
leaq (%rax,%rax,8), %rdi
shlq $0x3, %rdi
movq 0x10(%rsp), %rax
addq 0x8(%rax), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4d560
movl $0x0, (%rsp)
movl $0x7, %ebp
movq $0x0, 0x20(%rsp)
jmp 0x6fbf8
movl %r15d, %ebp
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x28(%rsp), %rdx
callq 0x4120
movl %ebp, %r15d
testq %rax, %rax
jne 0x6fabc
movq 0x28(%rsp), %rdi
callq 0x42a0
movq 0x10(%rsp), %rbx
jmp 0x6fd25
leaq 0x3cc6d(%rip), %rdi     # 0xac982
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x6fd25
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x7a168, %rsp          # imm = 0x7A168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq