// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, %r14
movq 0x8(%rdi), %r15
movslq %esi, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,8), %r12
movl 0x10(%r15,%r12), %ecx
movl 0x28(%r15,%r12), %edx
leaq 0x5b13b(%rip), %r8      # 0xaa737
movl $0x8, %edi
movl $0x8, %esi
movl $0x2, %r9d
callq 0x3a231
movq %rax, 0x38(%r15,%r12)
movq 0x8(%r14), %rax
cmpl $0x0, 0x20(%rax,%r12)
je 0x4f65a
movq %r14, %rdi
movl %ebx, %esi
callq 0x4e548
movq %rax, %r15
movq 0x8(%r14), %rax
leaq (%rbx,%rbx,8), %rcx
movslq 0x20(%rax,%rcx,8), %rdi
shlq $0x2, %rdi
leaq 0x5b132(%rip), %rsi     # 0xaa779
movl $0x8, %edx
callq 0x3a0e1
movq %rax, %r12
movq 0x8(%r14), %rax
jmp 0x4f65a
movl 0x85e5f(%rip), %r10d    # 0xd54c0
testl %r10d, %r10d
jle 0x4f728
movq 0x85e47(%rip), %rcx     # 0xd54b8
leaq (%rbx,%rbx,8), %rdx
leaq (%rax,%rdx,8), %rdx
movq 0x38(%rdx), %rsi
movl 0x20(%rdx), %r8d
xorl %edi, %edi
movsd 0x55e95(%rip), %xmm0    # 0xa5520
movl %r8d, %r11d
movq (%rcx,%rdi,8), %r13
movslq (%r13,%rbx,4), %r9
testl %r11d, %r11d
je 0x4f6fb
testl %r8d, %r8d
jle 0x4f6ec
xorl %r10d, %r10d
movslq (%r15,%r10,4), %r8
movl (%r13,%r8,4), %r8d
movl %r8d, (%r12,%r10,4)
incq %r10
movslq 0x20(%rdx), %r8
cmpq %r8, %r10
jl 0x4f6a4
testl %r8d, %r8d
jle 0x4f6ec
movq 0x18(%rdx), %r10
xorl %r11d, %r11d
xorl %ebp, %ebp
testq %r11, %r11
je 0x4f6db
imull (%r10,%r11,4), %ebp
addl (%r12,%r11,4), %ebp
jmp 0x4f6df
movl (%r12), %ebp
incq %r11
cmpq %r11, %r8
jne 0x4f6cb
movslq %ebp, %r13
jmp 0x4f6ef
xorl %r13d, %r13d
movl 0x85dca(%rip), %r10d    # 0xd54c0
movl %r8d, %r11d
jmp 0x4f701
xorl %r11d, %r11d
xorl %r13d, %r13d
movq (%rsi,%r13,8), %r13
movsd (%r13,%r9,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r13,%r9,8)
incq %rdi
movslq %r10d, %r9
cmpq %r9, %rdi
jl 0x4f68e
jmp 0x4f731
leaq (%rbx,%rbx,8), %rcx
movl 0x20(%rax,%rcx,8), %r8d
testl %r8d, %r8d
je 0x4f74a
movq %r15, %rdi
callq 0x3a180
movq %r12, %rdi
callq 0x3a180
movq 0x8(%r14), %rax
leaq (%rbx,%rbx,8), %rdx
movq 0x28(%rax,%rdx,8), %rcx
testq %rcx, %rcx
jle 0x4f895
leaq (%rax,%rdx,8), %rax
movl 0x10(%rax), %edx
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
movsd 0x55dae(%rip), %xmm0    # 0xa5520
divsd %xmm1, %xmm0
leal 0x1(%rdx), %esi
leaq -0x1(%rdx), %rdi
movq %rdi, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
shrl %esi
shlq $0x4, %rsi
xorl %edi, %edi
xorpd %xmm2, %xmm2
movdqa 0x56ca5(%rip), %xmm3    # 0xa6440
movdqa 0x56cad(%rip), %xmm4    # 0xa6450
pxor %xmm4, %xmm1
pcmpeqd %xmm5, %xmm5
movdqa 0x56cdd(%rip), %xmm6    # 0xa6490
testl %edx, %edx
jle 0x4f889
movq 0x38(%rax), %r8
movq (%r8,%rdi,8), %r8
xorpd %xmm7, %xmm7
xorl %r9d, %r9d
addsd (%r8,%r9,8), %xmm7
incq %r9
cmpq %r9, %rdx
jne 0x4f7ca
ucomisd %xmm2, %xmm7
jne 0x4f7e0
jnp 0x4f80e
testl %edx, %edx
jle 0x4f889
movq 0x38(%rax), %r8
movq (%r8,%rdi,8), %r8
xorl %r9d, %r9d
movsd (%r8,%r9,8), %xmm8
divsd %xmm7, %xmm8
movsd %xmm8, (%r8,%r9,8)
incq %r9
cmpq %r9, %rdx
jne 0x4f7f3
jmp 0x4f889
testl %edx, %edx
jle 0x4f889
movq 0x38(%rax), %r8
movq (%r8,%rdi,8), %r8
xorl %r9d, %r9d
movdqa %xmm3, %xmm7
movdqa %xmm7, %xmm8
pxor %xmm4, %xmm8
movdqa %xmm8, %xmm9
pcmpgtd %xmm1, %xmm9
pcmpeqd %xmm1, %xmm8
pshufd $0xf5, %xmm8, %xmm10    # xmm10 = xmm8[1,1,3,3]
pand %xmm9, %xmm10
pshufd $0xf5, %xmm9, %xmm8     # xmm8 = xmm9[1,1,3,3]
por %xmm10, %xmm8
movd %xmm8, %r10d
notl %r10d
testb $0x1, %r10b
je 0x4f864
movsd %xmm0, (%r8,%r9)
pxor %xmm5, %xmm8
pextrw $0x4, %xmm8, %r10d
testb $0x1, %r10b
je 0x4f87c
movsd %xmm0, 0x8(%r8,%r9)
paddq %xmm6, %xmm7
addq $0x10, %r9
cmpq %r9, %rsi
jne 0x4f821
incq %rdi
cmpq %rcx, %rdi
jne 0x4f7b3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq