// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/graphdata.c
// Function: guess_data
int guess_data(Bndata mydata, bayesiangraphptr mygraph)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 07.03.2001*/
 int i, j, k, pos, value_pos, *parents, *list1, result = 0, maxindex;
 double max;
 for (i = 0; i < mydata.row; i++)
   for (j = 0; j < mydata.col; j++)
    {
     value_pos = mydata.data[i][j];
     if (mygraph->nodes[j].parents)
      {
       parents = find_parents(mygraph, j);
       list1 = safemalloc(mygraph->nodes[j].parents * sizeof(int), "guess_data", 10);
       for (k = 0; k < mygraph->nodes[j].parents; k++)
         list1[k] = mydata.data[i][parents[k]];
       pos = table_pos(mygraph->nodes[j], list1);
       safe_free(parents);
       safe_free(list1);
      }
     else /*No parents*/
       pos = 0;
     max = 0;
     maxindex = -1;
     for (k = 0; k < mygraph->nodes[j].parents; k++)
       if (mygraph->nodes[j].table[pos][k] > max)
        {
         max = mygraph->nodes[j].table[pos][k];
         maxindex = k;
        }
     if (maxindex == value_pos)
       result++;   
    }
 return result;   
}

// Assembly:
testl %esi, %esi
jle 0x26bf9
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r14
movq %rdi, %rbp
movq %rsi, %rax
shrq $0x20, %rax
movq %rax, 0x58(%rsp)
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq $0x0, 0x48(%rsp)
xorl %edi, %edi
movq %rdx, 0x70(%rsp)
movq %rsi, 0x60(%rsp)
movq %rbp, 0x68(%rsp)
cmpl $0x0, 0x58(%rsp)
jle 0x26bce
xorl %r13d, %r13d
movq 0x48(%rsp), %rax
movq (%rbp,%rax,8), %rax
movl (%rax,%r13,4), %r8d
movq 0x8(%r14), %rax
leaq (,%r13,8), %rbx
addq %r13, %rbx
cmpl $0x0, 0x20(%rax,%rbx,8)
je 0x26b6c
movl %r8d, 0x50(%rsp)
movl %edi, 0x54(%rsp)
movq %r14, %rdi
movl %r13d, %esi
callq 0x4d0d4
movq %r14, %rbp
movq %rax, %r14
movq 0x8(%rbp), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,8), %r15
movslq 0x20(%rax,%r15), %rdi
shlq $0x2, %rdi
leaq 0x7e690(%rip), %rsi     # 0xa517e
movl $0xa, %edx
callq 0x390f5
movq %rax, %r12
movq 0x8(%rbp), %rax
movq 0x68(%rsp), %rbp
leaq (%rax,%r15), %rsi
cmpl $0x0, 0x20(%rax,%r15)
jle 0x26b33
movq 0x48(%rsp), %rax
movq (%rbp,%rax,8), %rax
xorl %ecx, %ecx
movslq (%r14,%rcx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, (%r12,%rcx,4)
incq %rcx
movslq 0x20(%rsi), %rdx
cmpq %rdx, %rcx
jl 0x26b1c
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
callq 0x4d0a1
movl %eax, %r15d
movq %r14, %rdi
callq 0x39194
movq %r12, %rdi
callq 0x39194
movslq %r15d, %rcx
movq 0x70(%rsp), %r14
movl 0x54(%rsp), %edi
movl 0x50(%rsp), %r8d
jmp 0x26b6e
xorl %ecx, %ecx
movq 0x8(%r14), %rdx
movslq 0x20(%rdx,%rbx,8), %rax
testq %rax, %rax
jle 0x26bb1
leaq (%rdx,%rbx,8), %rdx
movq 0x38(%rdx), %rdx
movq (%rdx,%rcx,8), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorpd %xmm0, %xmm0
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %esi, %ecx
maxsd %xmm0, %xmm1
incq %rsi
movapd %xmm1, %xmm0
cmpq %rsi, %rax
jne 0x26b93
jmp 0x26bb6
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl %r8d, %ecx
sete %al
addl %eax, %edi
incq %r13
cmpq 0x58(%rsp), %r13
jne 0x26a8c
movq 0x48(%rsp), %rcx
incq %rcx
movq 0x60(%rsp), %rsi
movq %rcx, 0x48(%rsp)
cmpq %rsi, %rcx
jne 0x26a7e
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x26bfb
xorl %edi, %edi
movl %edi, %eax
retq