// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/graphdata.c
// Function: load_data
int load_data(bayesiangraphptr mygraph, Bndata* mydata, char *f_name)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 07.03.2001*/
 FILE *myfile;
 int i, j, k = file_length(f_name);
 char *st;
 char st1[3];
 char myline[READLINELENGTH];
 if (k == 0)
   return 0;
 if (mydata->data)
   free_2d((void**)(void **)mydata->data, mydata->row);
 mydata->row = k;
 mydata->data = (int**) safemalloc_2d(sizeof(int *), sizeof(int), mydata->row, mydata->col, "load_data", 11);
 st1[0] = ' ';
 st1[1] = '\n';
 st1[2] = '\0';
 myfile = fopen(f_name, "r");
 if (!myfile)
   return 0;
 fgets(myline, READLINELENGTH, myfile);
 st = strtok(myline, st1);
 i = 0;
 while (st)
  {
   i++;
   st = strtok(NULL,st1);
  }
 mydata->col = i;
 fseek(myfile, 0, SEEK_SET);
 j = 0;
 while (fgets(myline, READLINELENGTH, myfile))
  {
   st = strtok(myline, st1);
   i = 0;
   while (st)
    {
     mydata->data[j][i] = listindex(st, mygraph->nodes[i].values, mygraph->nodes[i].value_count);
     i++;
     st = strtok(NULL, st1);
    }
   j++;
  }
 fclose(myfile);
 return k;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a138, %rsp          # imm = 0x7A138
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x38a4a
xorl %r12d, %r12d
testl %eax, %eax
je 0x26b90
movl %eax, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x26a3f
movl 0x8(%rbx), %esi
callq 0x3a14b
movl %ebp, 0x8(%rbx)
movl 0xc(%rbx), %ecx
leaq 0x8174e(%rip), %r8      # 0xa819a
movl $0x8, %edi
movl $0x4, %esi
movl %ebp, %edx
movl $0xb, %r9d
callq 0x3a3ac
movq %rax, (%rbx)
movw $0xa20, 0x1(%rsp)       # imm = 0xA20
movb $0x0, 0x3(%rsp)
leaq 0x84ee2(%rip), %rsi     # 0xab95b
movq %r15, %rdi
callq 0x40f0
testq %rax, %rax
je 0x26b90
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, 0x8(%rsp)
movq %rax, %rdx
callq 0x4120
leaq 0x1(%rsp), %rsi
movq %r12, %rdi
callq 0x4280
testq %rax, %rax
movl %ebp, 0x4(%rsp)
je 0x26ad6
xorl %r15d, %r15d
leaq 0x1(%rsp), %r12
incl %r15d
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
testq %rax, %rax
jne 0x26ac2
jmp 0x26ad9
xorl %r15d, %r15d
movl %r15d, 0xc(%rbx)
movq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x40a0
leaq 0x10(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r15, %rdx
callq 0x4120
testq %rax, %rax
je 0x26b83
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
leaq 0x1(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x4280
testq %rax, %rax
je 0x26b61
movl $0x10, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rcx
movq -0x8(%rcx,%r15), %rsi
movl (%rcx,%r15), %edx
movq %rax, %rdi
callq 0x3b355
movq (%rbx), %rcx
movq (%rcx,%rbp,8), %rcx
movl %eax, (%rcx,%r12)
xorl %edi, %edi
movq %r13, %rsi
callq 0x4280
addq $0x4, %r12
addq $0x48, %r15
testq %rax, %rax
jne 0x26b2a
incq %rbp
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x8(%rsp), %r15
movq %r15, %rdx
callq 0x4120
testq %rax, %rax
jne 0x26b11
movq %r15, %rdi
callq 0x42a0
movl 0x4(%rsp), %r12d
movl %r12d, %eax
addq $0x7a138, %rsp          # imm = 0x7A138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq