// File: /workspace/github_c_makefile_star2_O1/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 0x37e22
xorl %r12d, %r12d
testl %eax, %eax
je 0x2643c
movl %eax, %ebp
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x262eb
movl 0x8(%rbx), %esi
callq 0x3915f
movl %ebp, 0x8(%rbx)
movl 0xc(%rbx), %ecx
leaq 0x7ee4a(%rip), %r8      # 0xa5142
movl $0x8, %edi
movl $0x4, %esi
movl %ebp, %edx
movl $0xb, %r9d
callq 0x393b5
movq %rax, (%rbx)
movw $0xa20, 0x1(%rsp)       # imm = 0xA20
movb $0x0, 0x3(%rsp)
leaq 0x8256a(%rip), %rsi     # 0xa888f
movq %r15, %rdi
callq 0x40f0
testq %rax, %rax
je 0x2643c
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 0x26382
xorl %r15d, %r15d
leaq 0x1(%rsp), %r12
incl %r15d
xorl %edi, %edi
movq %r12, %rsi
callq 0x4280
testq %rax, %rax
jne 0x2636e
jmp 0x26385
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 0x2642f
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
leaq 0x1(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x4280
testq %rax, %rax
je 0x2640d
movl $0x10, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rcx
movq -0x8(%rcx,%r15), %rsi
movl (%rcx,%r15), %edx
movq %rax, %rdi
callq 0x3a2c5
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 0x263d6
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 0x263bd
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