// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/network.c
// Function: make_one_conditional_table
void make_one_conditional_table(bayesiangraphptr mygraph,int node)
{
 /*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 09.03.2001*/
 int i,j,k,value_pos,pos;
 int *list1,*parents;
 double sum;
 alloc_conditional_table(&mygraph->nodes[node]);
 if (mygraph->nodes[node].parents)
  {
   parents=find_parents(mygraph,node);
   list1 = safemalloc(mygraph->nodes[node].parents*sizeof(int), "make_one_conditional_table", 8);
  }
 for (i=0;i<train.row;i++)
  {
   value_pos=train.data[i][node];
   if (mygraph->nodes[node].parents)
    {
     for (k=0;k<mygraph->nodes[node].parents;k++)
       list1[k]=train.data[i][parents[k]];
     pos=table_pos(mygraph->nodes[node],list1);
    }
   else/*No parents*/
     pos=0;
   mygraph->nodes[node].table[pos][value_pos]++;
  }
 if (mygraph->nodes[node].parents)
  {
   safe_free(parents);
   safe_free(list1);
  } 
 for (j=0;j<mygraph->nodes[node].table_count;j++)
  {
   sum=0;
   for (k=0;k<mygraph->nodes[node].value_count;k++)
     sum+=mygraph->nodes[node].table[j][k];
   if (sum!=0)
    {
     for (k=0;k<mygraph->nodes[node].value_count;k++)
       mygraph->nodes[node].table[j][k]/=sum;
    }
   else
     for (k=0;k<mygraph->nodes[node].value_count;k++)
       mygraph->nodes[node].table[j][k] = (double) 1.0 / mygraph->nodes[node].value_count;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movslq %esi, %r13
imulq $0x48, %r13, %r12
movq 0x8(%rdi), %rdi
addq %r12, %rdi
callq 0x4772a
movq 0x8(%rbx), %rax
cmpl $0x0, 0x20(%rax,%r12)
je 0x481e0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x47301
movq %rax, %r14
movq 0x8(%rbx), %rax
movslq 0x20(%rax,%r12), %rdi
shlq $0x2, %rdi
leaq 0x524d6(%rip), %rsi     # 0x9a6a9
pushq $0x8
popq %rdx
callq 0x34f59
movq %rax, %r15
jmp 0x481e0
movq 0x852d1(%rip), %rax     # 0xcd4b8
xorl %ecx, %ecx
movsd 0x4d32f(%rip), %xmm3    # 0x95520
movslq 0x852c8(%rip), %rdx     # 0xcd4c0
cmpq %rdx, %rcx
jge 0x4828d
movq (%rax,%rcx,8), %r8
movslq (%r8,%r13,4), %rdx
movq 0x8(%rbx), %rsi
movl 0x20(%rsi,%r12), %edi
testl %edi, %edi
je 0x4826c
leaq (%rsi,%r12), %r9
xorl %r10d, %r10d
movslq %edi, %r11
cmpq %r11, %r10
jge 0x4823a
movslq (%r14,%r10,4), %rdi
movl (%r8,%rdi,4), %edi
movl %edi, (%r15,%r10,4)
incq %r10
movl 0x20(%r9), %edi
jmp 0x4821d
movq 0x18(%r9), %r8
xorl %r9d, %r9d
testl %edi, %edi
cmovlel %r9d, %edi
xorl %r10d, %r10d
cmpq %r9, %rdi
je 0x48267
testq %r9, %r9
je 0x4825f
imull (%r8,%r9,4), %r10d
addl (%r15,%r9,4), %r10d
jmp 0x48262
movl (%r15), %r10d
incq %r9
jmp 0x4824a
movslq %r10d, %rdi
jmp 0x4826e
xorl %edi, %edi
movq 0x38(%rsi,%r12), %rsi
movq (%rsi,%rdi,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rsi,%rdx,8)
incq %rcx
jmp 0x481f1
movq 0x8(%rbx), %rcx
cmpl $0x0, 0x20(%rcx,%r12)
je 0x482b5
movq %r14, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x34ff7
movsd 0x4d26f(%rip), %xmm3    # 0x95520
movq 0x8(%rbx), %rcx
leaq (%rcx,%r12), %rax
movq 0x28(%rcx,%r12), %rcx
xorl %edx, %edx
testq %rcx, %rcx
cmovleq %rdx, %rcx
xorpd %xmm0, %xmm0
cmpq %rcx, %rdx
je 0x4835a
movl 0x10(%rax), %edi
testl %edi, %edi
movl $0x0, %esi
cmovgl %edi, %esi
xorpd %xmm1, %xmm1
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x48300
movq 0x38(%rax), %r9
movq (%r9,%rdx,8), %r9
addsd (%r9,%r8,8), %xmm1
incq %r8
jmp 0x482e8
ucomisd %xmm0, %xmm1
jne 0x48308
jnp 0x4832c
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x48352
movq 0x38(%rax), %r8
movq (%r8,%rdx,8), %r8
movsd (%r8,%rdi,8), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, (%r8,%rdi,8)
incq %rdi
jmp 0x4830a
cvtsi2sd %edi, %xmm2
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x48352
movq 0x38(%rax), %r8
movq (%r8,%rdx,8), %r8
movsd %xmm1, (%r8,%rdi,8)
incq %rdi
jmp 0x4833a
incq %rdx
jmp 0x482cb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq