// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebp
movl 0x85bdd(%rip), %esi     # 0xd54c0
xorpd %xmm1, %xmm1
testl %esi, %esi
je 0x4fb52
movl %ecx, %ebx
movq %rdi, %r13
movl %ecx, 0x34(%rsp)
movl %ebp, 0x44(%rsp)
movl %edx, 0x48(%rsp)
movl %ecx, 0x4c(%rsp)
movslq %ecx, %rax
movq 0x8(%rdi), %rcx
leaq (%rax,%rax,8), %rax
movq %rax, 0x50(%rsp)
cmpl $0x0, 0x10(%rcx,%rax,8)
jle 0x4fb52
movl %esi, 0x20(%rsp)
movslq %ebp, %rax
movl %edx, 0x2c(%rsp)
movslq %edx, %rcx
xorl %r12d, %r12d
leaq (%rax,%rax,8), %rax
movq %rax, 0x18(%rsp)
leaq (%rcx,%rcx,8), %r14
movl %ebx, 0x28(%rsp)
movl %ebp, 0x24(%rsp)
movq %r13, %r15
movsd %xmm1, (%rsp)
movl %r12d, 0x30(%rsp)
leaq 0x34(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0x26fc2
movq 0x8(%r13), %rcx
testl %eax, %eax
je 0x4faed
movq 0x18(%rsp), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
jle 0x4faed
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movapd %xmm0, 0x60(%rsp)
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0x80(%rsp)
xorl %r13d, %r13d
movsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
movl %r13d, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movl %ebp, 0x10(%rsp)
movl %ebx, 0x14(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x2, %edx
callq 0x26fc2
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
ucomisd 0x5631e(%rip), %xmm0    # 0xa5d08
movq 0x8(%r15), %rcx
jne 0x4f9f6
jnp 0x4facb
cmpl $0x0, 0x10(%rcx,%r14,8)
jle 0x4facb
xorl %ebp, %ebp
movsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
movl %r13d, 0x38(%rsp)
movl %ebp, 0x3c(%rsp)
movl %r12d, 0x40(%rsp)
leaq 0x44(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movl $0x3, %edx
callq 0x26fc2
movl %eax, %ebx
movl %ebp, 0x8(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x2, %edx
callq 0x26fc2
movd %ebx, %xmm0
movd %eax, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm2
divpd 0x80(%rsp), %xmm2
movapd %xmm2, %xmm0
cmpneqpd 0x57d58(%rip), %xmm0    # 0xa77d0
movmskpd %xmm0, %eax
cmpl $0x3, %eax
jne 0x4fab3
movsd 0x58(%rsp), %xmm1
mulsd %xmm2, %xmm1
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
movapd %xmm2, 0x70(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x39bdc
mulsd 0x70(%rsp), %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
jmp 0x4fab8
movsd (%rsp), %xmm1
incl %ebp
movq 0x8(%r15), %rcx
cmpl 0x10(%rcx,%r14,8), %ebp
jl 0x4fa09
jmp 0x4fad0
movsd (%rsp), %xmm1
incl %r13d
movq 0x18(%rsp), %rax
cmpl 0x10(%rcx,%rax,8), %r13d
movl 0x28(%rsp), %ebx
movl 0x24(%rsp), %ebp
jl 0x4f9a4
jmp 0x4faf2
movsd (%rsp), %xmm1
incl %r12d
movq 0x50(%rsp), %rax
movl 0x10(%rcx,%rax,8), %edi
cmpl %edi, %r12d
movq %r15, %r13
jl 0x4f948
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x4fb16
jnp 0x4fb52
movq 0x18(%rsp), %rax
movl 0x10(%rcx,%rax,8), %eax
decl %eax
movl 0x10(%rcx,%r14,8), %ecx
decl %ecx
decl %edi
imull %eax, %edi
imull %ecx, %edi
addsd %xmm1, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0x20(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x1fc11
movsd 0x559d2(%rip), %xmm1    # 0xa5520
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq