// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x50(%rsp)
testl %esi, %esi
jle 0x27329
movq %rdi, %rbp
movq %rsi, %rax
shrq $0x20, %rax
movq %rax, 0x60(%rsp)
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq $0x0, 0x48(%rsp)
xorl %r8d, %r8d
movq %rsi, 0x68(%rsp)
movq %rdi, 0x70(%rsp)
cmpl $0x0, 0x60(%rsp)
jle 0x2730c
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
xorl %r13d, %r13d
movq 0x48(%rsp), %rcx
movq (%rbp,%rcx,8), %rcx
movl (%rcx,%r13,4), %r9d
leaq (,%r13,8), %rbx
addq %r13, %rbx
cmpl $0x0, 0x20(%rax,%rbx,8)
je 0x272ad
movl %r9d, 0x58(%rsp)
movl %r8d, 0x5c(%rsp)
movq 0x50(%rsp), %rbp
movq %rbp, %rdi
movl %r13d, %esi
callq 0x4e548
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 0x80fac(%rip), %rsi     # 0xa81d6
movl $0xa, %edx
callq 0x3a0e1
movq %rax, %r12
movq 0x8(%rbp), %rax
movq 0x70(%rsp), %rbp
leaq (%rax,%r15), %rsi
cmpl $0x0, 0x20(%rax,%r15)
jle 0x2726f
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 0x27258
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
callq 0x4e515
movl %eax, %r15d
movq %r14, %rdi
callq 0x3a180
movq %r12, %rdi
callq 0x3a180
movslq %r15d, %rdx
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movl 0x5c(%rsp), %r8d
movl 0x58(%rsp), %r9d
jmp 0x272af
xorl %edx, %edx
movslq 0x20(%rax,%rbx,8), %rcx
testq %rcx, %rcx
jle 0x272ee
leaq (%rax,%rbx,8), %rsi
movq 0x38(%rsi), %rsi
movq (%rsi,%rdx,8), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorpd %xmm0, %xmm0
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edi, %edx
maxsd %xmm0, %xmm1
incq %rdi
movapd %xmm1, %xmm0
cmpq %rdi, %rcx
jne 0x272d0
jmp 0x272f3
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl %r9d, %edx
sete %cl
addl %ecx, %r8d
incq %r13
cmpq 0x60(%rsp), %r13
jne 0x271c9
movq 0x48(%rsp), %rcx
incq %rcx
movq 0x68(%rsp), %rsi
movq %rcx, 0x48(%rsp)
cmpq %rsi, %rcx
jne 0x271b2
jmp 0x2732c
xorl %r8d, %r8d
movl %r8d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq