// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/indtests.c
// Function: zero_independence_test
double **zero_independence_test(bayesiangraphptr mygraph)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 09.03.2001*/
 double time;
	char pst[READLINELENGTH];
 int flength, i, j, k, l, total = (mygraph->nodecount) * (mygraph->nodecount - 1) / 2;
 double p1, p2, p3, walk = total / ((double)80.0), c;
 int list1[2], list2[1], list3[1];
 int value_list1[2], value_list2[1], value_list3[1];
 double **result;
 flength = train.row;
 if (flength == 0)
   return NULL;
 result = (double **)safemalloc_2d(sizeof(double *), sizeof(double), mygraph->nodecount, mygraph->nodecount, "zero_independence_test", 10);
 printf(m1269);
 time = -clock();
 c = 0;
 for (i = 0; i < mygraph->nodecount; i++)
   for (j = i + 1; j < mygraph->nodecount; j++)
    {
     c++;
     while (c >= walk)
      {
       printf(".");
       c -= walk;
      }
     result[i][j] = 0;
     for (k = 0; k < mygraph->nodes[i].value_count; k++)
      {
       list2[0] = i;
       value_list2[0] = k;
       p2 = count_data(list2, value_list2, 1) / (double)(flength + 0.0);
       if (p2 != 0)
         for (l = 0; l < mygraph->nodes[j].value_count; l++)
          {
           list1[0] = i;
           list1[1] = j;
           value_list1[0] = k;
           value_list1[1] = l;
           p1 = count_data(list1, value_list1, 2) / (double)(flength + 0.0);
           list3[0] = j;
           value_list3[0] = l;
           p3 = count_data(list3, value_list3, 1) / (double)(flength + 0.0);
           if ((p1 != 0) && (p3 != 0))
             result[i][j] += p1 * log2(p1 / (p2 * p3));
          }
      }
     if (result[i][j] != 0)
       result[i][j] = 1 - chi_square((mygraph->nodes[i].value_count - 1) * (mygraph->nodes[j].value_count - 1), 2 * result[i][j] * flength);
     result[j][i] = result[i][j];
    }
 time += clock();
	set_precision(pst, "Time for 0 independence calculations:", "\n");
 printf(pst, time / CLOCKS_PER_SEC);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7a1b0, %rsp          # imm = 0x7A1B0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
imull %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x7a158(%rbp)
cvtsi2sdl -0x7a158(%rbp), %xmm0
movsd 0xa2677(%rip), %xmm1    # 0xe4988
divsd %xmm1, %xmm0
movsd %xmm0, -0x7a178(%rbp)
leaq 0xc3164(%rip), %rax     # 0x105488
movl 0x8(%rax), %eax
movl %eax, -0x7a144(%rbp)
cmpl $0x0, -0x7a144(%rbp)
jne 0x42343
movq $0x0, -0x8(%rbp)
jmp 0x4281d
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movl $0x8, %esi
leaq 0xa31a5(%rip), %r8      # 0xe5502
movl $0xa, %r9d
movq %rsi, %rdi
callq 0x53120
movq %rax, -0x7a1a8(%rbp)
leaq 0xa31a0(%rip), %rdi     # 0xe5519
movb $0x0, %al
callq 0x4030
callq 0x4200
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x7a180(%rbp)
movl $0x0, -0x7a148(%rbp)
movl -0x7a148(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x427c5
movl -0x7a148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7a14c(%rbp)
movl -0x7a14c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x427af
movsd 0x9fc2f(%rip), %xmm0    # 0xe2018
addsd -0x7a180(%rbp), %xmm0
movsd %xmm0, -0x7a180(%rbp)
movsd -0x7a180(%rbp), %xmm0
ucomisd -0x7a178(%rbp), %xmm0
jb 0x42437
leaq 0xaa6f9(%rip), %rdi     # 0xecb0b
movb $0x0, %al
callq 0x4030
movsd -0x7a178(%rbp), %xmm1
movsd -0x7a180(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x7a180(%rbp)
jmp 0x423f9
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x7a150(%rbp)
movl -0x7a150(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x7a148(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jge 0x42692
movl -0x7a148(%rbp), %eax
movl %eax, -0x7a18c(%rbp)
movl -0x7a150(%rbp), %eax
movl %eax, -0x7a19c(%rbp)
leaq -0x7a18c(%rbp), %rdi
leaq -0x7a19c(%rbp), %rsi
movl $0x1, %edx
callq 0x37200
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x7a144(%rbp), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x7a168(%rbp)
movsd -0x7a168(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x424ee
jp 0x424ee
jmp 0x4267c
movl $0x0, -0x7a154(%rbp)
movl -0x7a154(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x7a14c(%rbp), %rdx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x10(%rcx), %eax
jge 0x4267a
movl -0x7a148(%rbp), %eax
movl %eax, -0x7a188(%rbp)
movl -0x7a14c(%rbp), %eax
movl %eax, -0x7a184(%rbp)
movl -0x7a150(%rbp), %eax
movl %eax, -0x7a198(%rbp)
movl -0x7a154(%rbp), %eax
movl %eax, -0x7a194(%rbp)
leaq -0x7a188(%rbp), %rdi
leaq -0x7a198(%rbp), %rsi
movl $0x2, %edx
callq 0x37200
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x7a144(%rbp), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x7a160(%rbp)
movl -0x7a14c(%rbp), %eax
movl %eax, -0x7a190(%rbp)
movl -0x7a154(%rbp), %eax
movl %eax, -0x7a1a0(%rbp)
leaq -0x7a190(%rbp), %rdi
leaq -0x7a1a0(%rbp), %rsi
movl $0x1, %edx
callq 0x37200
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x7a144(%rbp), %xmm1
xorps %xmm2, %xmm2
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x7a170(%rbp)
movsd -0x7a160(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x425e8
jp 0x425e8
jmp 0x42664
movsd -0x7a170(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x425fd
jp 0x425fd
jmp 0x42664
movsd -0x7a160(%rbp), %xmm0
movsd %xmm0, -0x7a1b0(%rbp)
movsd -0x7a160(%rbp), %xmm0
movsd -0x7a168(%rbp), %xmm1
mulsd -0x7a170(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x52ad0
movaps %xmm0, %xmm2
movsd -0x7a1b0(%rbp), %xmm0
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x42666
movl -0x7a154(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7a154(%rbp)
jmp 0x424f8
jmp 0x4267c
jmp 0x4267e
movl -0x7a150(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7a150(%rbp)
jmp 0x42462
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x426c0
jp 0x426c0
jmp 0x4275f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x7a148(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edi
subl $0x1, %edi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x7a14c(%rbp), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
imull %eax, %edi
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
movsd 0xa0584(%rip), %xmm0    # 0xe2ca0
mulsd (%rax,%rcx,8), %xmm0
cvtsi2sdl -0x7a144(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x2d5e0
movaps %xmm0, %xmm1
movsd 0x9f8db(%rip), %xmm0    # 0xe2018
subsd %xmm1, %xmm0
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x7a1a8(%rbp), %rax
movslq -0x7a148(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a14c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x7a1a8(%rbp), %rax
movslq -0x7a14c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7a148(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x7a14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7a14c(%rbp)
jmp 0x423ce
jmp 0x427b1
movl -0x7a148(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7a148(%rbp)
jmp 0x423ac
callq 0x4200
cvtsi2sd %rax, %xmm0
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq -0x7a140(%rbp), %rdi
leaq 0xa2d52(%rip), %rsi     # 0xe5539
leaq 0xa354d(%rip), %rdx     # 0xe5d3b
callq 0x53310
leaq -0x7a140(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movsd 0xa01b9(%rip), %xmm1    # 0xe29c0
divsd %xmm1, %xmm0
movb $0x1, %al
callq 0x4030
movq -0x7a1a8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x7a1b0, %rsp          # imm = 0x7A1B0
popq %rbp
retq
nopw (%rax,%rax)