// File: /workspace/github_c_makefile_star2_O3/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 0x38b30
movq %rax, %rdi
callq 0x4eade
movq %rax, %rbx
movabsq $0x2229283d7d7b0a20, %rax # imm = 0x2229283D7D7B0A20
movq %rax, 0x30(%rsp)
movl $0x97c3b, 0x38(%rsp)    # imm = 0x97C3B
leaq 0x3a71d(%rip), %rsi     # 0xab95b
movq %r14, %rdi
callq 0x40f0
testq %rax, %rax
je 0x71502
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 0x714f1
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %r14
leaq 0x30(%rsp), %r12
leaq 0x64184(%rip), %r13     # 0xd5410
leaq 0x3e53d(%rip), %rbx     # 0xaf7d0
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 0x714cb
movq %rax, %r14
movq %r14, %rdi
movq %r13, %rsi
movl $0x7, %edx
callq 0x3b355
movl %eax, %ebp
leal 0x1(%rbp), %eax
cmpl $0x7, %eax
ja 0x71329
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
cmpb $0x25, (%r14)
je 0x714cb
leal 0x1(%r15), %eax
cmpl $0x8, %eax
ja 0x71329
leaq 0x3e4ec(%rip), %rcx     # 0xaf7f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4e5de
movq %rax, 0x8(%rsp)
movl $0x1, %ebp
jmp 0x713ec
movl %r15d, %ebp
jmp 0x713ec
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x7, %ebp
jmp 0x713ec
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x18(%rsp)
movl $0x6, %ebp
jmp 0x713ec
movq %r14, %rdi
callq 0x4200
movq 0x8(%rsp), %rcx
movl %eax, 0x44(%rcx)
jmp 0x7141a
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4e464
movl %eax, %r14d
cmpl $-0x1, 0x18(%rsp)
je 0x7146f
cmpl $-0x1, %r14d
je 0x71517
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 0x4e964
movq %rbp, %rdi
callq 0x4e881
addq 0x8(%rbp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x4e8d5
movq $0x0, 0x18(%rsp)
jmp 0x7134c
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x4e9e4
movl $0x5, %ebp
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
movq %rax, %r14
movl %ebp, %r15d
testq %rax, %rax
jne 0x712c7
jmp 0x714ce
movq %r14, %rdi
callq 0x4200
movq 0x8(%rsp), %rcx
movl %eax, 0x40(%rcx)
movl $0x4, %ebp
jmp 0x713ec
movl (%rsp), %ebp
cmpl $-0x1, %ebp
je 0x71491
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 0x71338
movl $0x6, %ebp
cmpl $-0x1, %r14d
je 0x71517
movq $0x0, 0x18(%rsp)
movl %r14d, 0x4(%rsp)
jmp 0x713ec
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 0x4e9b8
movl $0x0, (%rsp)
movl $0x7, %ebp
movq $0x0, 0x20(%rsp)
jmp 0x713ec
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 0x712b0
movq 0x28(%rsp), %rdi
callq 0x42a0
movq 0x10(%rsp), %rbx
jmp 0x71519
leaq 0x3e551(%rip), %rdi     # 0xafa5a
xorl %ebx, %ebx
movq %r14, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x71519
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x7a168, %rsp          # imm = 0x7A168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq