// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/network.c
// Function: one_independence_test_indexed
double one_independence_test_indexed(bayesiangraphptr mygraph,int node1, int node2, int given)
{
/*!Last Changed 09.03.2001*/
 int flength=train.row, i, j, k;
 double p1, p2, p3;
 int list1[1], list2[2], list3[3];
 int value_list1[1], value_list2[2], value_list3[3];
 double denom;
	double result = 0;
 double temp;
 if (flength == 0)
   return 0;
 list1[0] = given;
 list3[0] = node1;
 list3[1] = node2;
 list3[2] = given;
 for (k = 0; k < mygraph->nodes[given].value_count; k++)
  {
   value_list1[0]=k;
   denom = count_data(list1,value_list1,1) + (double) 0.0;
   if (denom!=0)
     for (i = 0; i < mygraph->nodes[node1].value_count; i++)
      {
       value_list2[0]=i;
       value_list2[1]=k;
       list2[0]=node1;
       list2[1]=given;
       temp = count_data(list2,value_list2,2) + (double) 0.0;
       p2=temp/denom;
       if (p2!=0)
         for (j = 0; j < mygraph->nodes[node2].value_count; j++)
          {
           value_list3[0]=i;
           value_list3[1]=j;
           value_list3[2]=k;
           temp=count_data(list3,value_list3,3) + (double) 0.0;
           p1 = temp/denom;
           value_list2[0]=j;
           list2[0]=node2;
           temp=count_data(list2,value_list2,2) + (double) 0.0;
           p3=temp/denom;
           if ((p1 != 0) && (p3 != 0))
             result += p1 * log2(p1 / (p2 * p3));
          }
      }
  }
 if (result != 0)
   result = 1 - chi_square((mygraph->nodes[node1].value_count - 1) * (mygraph->nodes[node2].value_count - 1) * (mygraph->nodes[given].value_count - 1) , 2 * result * flength);
 return result;
}

// Assembly:
movl 0x8412e(%rip), %eax     # 0xd24c0
testl %eax, %eax
je 0x4e645
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, %r13d
movl %edx, %ebp
movq %rdi, %r15
movl %eax, 0x2c(%rsp)
movl %ecx, 0x3c(%rsp)
movl %esi, 0x6c(%rsp)
movl %edx, 0x70(%rsp)
movl %ecx, 0x74(%rsp)
movslq %ecx, %rcx
movq 0x8(%rdi), %rax
leaq (%rcx,%rcx,8), %rcx
movq %rcx, 0x78(%rsp)
movl 0x10(%rax,%rcx,8), %edi
movl %esi, 0x34(%rsp)
movslq %esi, %rcx
movq %rcx, 0x40(%rsp)
movslq %edx, %rcx
movq %rcx, 0x48(%rsp)
xorpd %xmm1, %xmm1
testl %edi, %edi
jle 0x4e5de
xorl %ebx, %ebx
movq 0x40(%rsp), %rax
leaq (%rax,%rax,8), %rax
movq %rax, 0x50(%rsp)
movq 0x48(%rsp), %rax
leaq (%rax,%rax,8), %r14
movl %r13d, 0x30(%rsp)
movsd %xmm1, 0x8(%rsp)
movl %ebx, 0x38(%rsp)
leaq 0x3c(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl $0x1, %edx
callq 0x26882
testl %eax, %eax
je 0x4e5c1
movq 0x8(%r15), %rcx
movq 0x50(%rsp), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
jle 0x4e5c1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
xorl %r12d, %r12d
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movl %r12d, 0x10(%rsp)
movl %ebx, 0x14(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x18(%rsp)
movl %r13d, 0x1c(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x2, %edx
callq 0x26882
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd 0x20(%rsp), %xmm1
xorpd %xmm0, %xmm0
movsd %xmm1, 0x80(%rsp)
ucomisd %xmm0, %xmm1
jne 0x4e4bf
jnp 0x4e59d
movq 0x8(%r15), %rax
cmpl $0x0, 0x10(%rax,%r14,8)
jle 0x4e59d
xorl %r13d, %r13d
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movl %r12d, 0x60(%rsp)
movl %r13d, 0x64(%rsp)
movl %ebx, 0x68(%rsp)
leaq 0x6c(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x3, %edx
callq 0x26882
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movl %r13d, 0x10(%rsp)
movl %ebp, 0x18(%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x2, %edx
callq 0x26882
xorpd %xmm0, %xmm0
movsd 0x58(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x4e542
jnp 0x4e583
movapd %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x4e55b
jnp 0x4e583
mulsd 0x80(%rsp), %xmm1
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x38e99
mulsd 0x58(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
jmp 0x4e589
movsd 0x8(%rsp), %xmm1
incl %r13d
movq 0x8(%r15), %rax
cmpl 0x10(%rax,%r14,8), %r13d
jl 0x4e4d8
jmp 0x4e5a3
movsd 0x8(%rsp), %xmm1
incl %r12d
movq 0x8(%r15), %rax
movq 0x50(%rsp), %rcx
cmpl 0x10(%rax,%rcx,8), %r12d
movl 0x30(%rsp), %r13d
jl 0x4e469
jmp 0x4e5c7
movsd 0x8(%rsp), %xmm1
incl %ebx
movq 0x8(%r15), %rax
movq 0x78(%rsp), %rcx
movl 0x10(%rax,%rcx,8), %edi
cmpl %edi, %ebx
jl 0x4e419
ucomisd 0x54722(%rip), %xmm1    # 0xa2d08
jne 0x4e5ea
jnp 0x4e632
movq 0x40(%rsp), %rcx
leaq (%rcx,%rcx,8), %rcx
movl 0x10(%rax,%rcx,8), %ecx
decl %ecx
movq 0x48(%rsp), %rdx
leaq (%rdx,%rdx,8), %rdx
movl 0x10(%rax,%rdx,8), %eax
decl %eax
decl %edi
imull %ecx, %edi
imull %eax, %edi
addsd %xmm1, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0x2c(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x1f4cd
movsd 0x53ef2(%rip), %xmm1    # 0xa2520
subsd %xmm0, %xmm1
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4e649
xorpd %xmm1, %xmm1
movapd %xmm1, %xmm0
retq