// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: k_way_anova_dataset_cont
void k_way_anova_dataset_cont(Datasetptr d, Instanceptr data, int* features, int fdependent)
{
 /*!Last Changed 07.05.2004 only for two way currently*/
 Instanceptr tmp;
 int rowsize, colsize, i, j, row, col, *rowcounts, *colcounts, **cellcounts, datasize;
 double grandmean = 0, value, criticalvalue;
 double** cellmeans;
 double* rowmeans;
 double* colmeans, sstotal = 0.0, sswithin = 0.0, sscolumns = 0.0, ssrows = 0.0;
 double mscolumn, msrow, msinteraction, mswithin;
 double columnconf, rowconf, interactionconf;
 datasize = data_size(data);
 rowsize = d->features[features[0]].valuecount;
 colsize = d->features[features[1]].valuecount;
 cellmeans = (double**) safecalloc_2d(sizeof(double *), sizeof(double), rowsize, colsize, "k_way_anova_dataset_cont", 9);
 cellcounts = (int**) safecalloc_2d(sizeof(int *), sizeof(int), rowsize, colsize, "k_way_anova_dataset_cont", 10);
 rowmeans = safecalloc(rowsize, sizeof(double), "k_way_anova_dataset_cont", 14);
 colmeans = safecalloc(colsize, sizeof(double), "k_way_anova_dataset_cont", 15);
 rowcounts = safecalloc(rowsize, sizeof(double), "k_way_anova_dataset_cont", 16);
 colcounts = safecalloc(colsize, sizeof(double), "k_way_anova_dataset_cont", 17);
 tmp = data;
 while (tmp)
  {
   switch (d->features[fdependent].type)
    {
     case INTEGER:value = tmp->values[fdependent].intvalue;
                  break;
     case    REAL:
     case  REGDEF:value = tmp->values[fdependent].floatvalue;
                  break;
     default     :value = 0;
                  printf(m1226);
                  break;
    }
   row = tmp->values[features[0]].stringindex;
   col = tmp->values[features[1]].stringindex;
   grandmean += value;
   rowmeans[row] += value;
   rowcounts[row]++;
   colmeans[col] += value;
   colcounts[col]++;
   cellmeans[row][col] += value;
   cellcounts[row][col]++;
   tmp = tmp->next;
  }
 check_and_set_mean(&grandmean, datasize);
 for (i = 0; i < rowsize; i++)
   check_and_set_mean(&(rowmeans[i]), rowcounts[i]);
 for (i = 0; i < colsize; i++)
   check_and_set_mean(&(colmeans[i]), colcounts[i]);
 for (i = 0; i < rowsize; i++)
   for (j = 0; j < colsize; j++)
     check_and_set_mean(&(cellmeans[i][j]), cellcounts[i][j]);
 tmp = data;
 while (tmp)
  {
   switch (d->features[fdependent].type)
    {
     case INTEGER:value = tmp->values[fdependent].intvalue;
                  break;
     case    REAL:
     case  REGDEF:value = tmp->values[fdependent].floatvalue;
                  break;
     default     :value = 0;
                  printf(m1226);
                  break;
    }   
   row = tmp->values[features[0]].stringindex;
   col = tmp->values[features[1]].stringindex;
   sstotal += (value - grandmean) * (value - grandmean);
   sswithin += (value - cellmeans[row][col]) * (value - cellmeans[row][col]);
   tmp = tmp->next;
  }
 for (i = 0; i < rowsize; i++)
   ssrows += rowcounts[i] * (rowmeans[i] - grandmean) * (rowmeans[i] - grandmean);
 for (i = 0; i < colsize; i++)
   sscolumns += colcounts[i] * (colmeans[i] - grandmean) * (colmeans[i] - grandmean);
 mscolumn = sscolumns / (colsize - 1);
 msrow = ssrows / (rowsize - 1);
 msinteraction = (sstotal - sscolumns - ssrows - sswithin) / ((colsize - 1) * (rowsize - 1));
 mswithin = sswithin / (datasize - rowsize * colsize);
 criticalvalue = msrow / mswithin;
 rowconf = f_distribution(criticalvalue, rowsize - 1, datasize - rowsize * colsize);
 criticalvalue = mscolumn / mswithin;
 columnconf = f_distribution(criticalvalue, colsize - 1, datasize - rowsize * colsize);
 criticalvalue = msinteraction / mswithin;
 interactionconf = f_distribution(criticalvalue, (colsize - 1) * (rowsize - 1), datasize - rowsize * colsize);
 if (get_parameter_o("displayresulton"))
  {
   if (rowconf < get_parameter_f("confidencelevel"))
     printf(m1249, features[0] + 1);
   else
     printf(m1250, features[0] + 1);
   if (columnconf < get_parameter_f("confidencelevel"))
     printf(m1249, features[1] + 1);
   else
     printf(m1250, features[1] + 1);
   if (interactionconf < get_parameter_f("confidencelevel"))
     printf(m1251, features[0] + 1, features[1] + 1);
   else
     printf(m1252, features[0] + 1, features[1] + 1);
  }
 set_default_variable("out1", rowconf);
 set_default_variable("out2", columnconf);
 set_default_variable("out3", interactionconf);
 safe_free(rowmeans);
 safe_free(colmeans);
 safe_free(rowcounts);
 safe_free(colcounts);
 free_2d((void**)cellmeans, rowsize);
 free_2d((void**)cellcounts, rowsize);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, 0x8(%rsp)
movq %rdx, %rbp
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
andq $0x0, 0x10(%rsp)
movq %rsi, %rdi
callq 0x2c3cc
movl %eax, 0x1c(%rsp)
movslq (%rbp), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq %rbx, %rcx
movq %rbx, 0x38(%rsp)
movl 0x30f20(%rbx,%rax), %ebx
movslq 0x4(%rbp), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movl 0x30f20(%rcx,%rax), %r13d
leaq 0x83ab4(%rip), %r12     # 0x965ec
pushq $0x8
popq %r15
pushq $0x9
popq %r9
movq %r15, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %r13d, %ecx
movq %r12, %r8
callq 0x3509c
movq %rax, %r14
pushq $0x4
popq %rsi
pushq $0xa
popq %r9
movq %r15, %rdi
movl %ebx, %edx
movl %r13d, %ecx
movq %r12, %r8
callq 0x3509c
movq %rax, %r15
movq %rbx, 0x58(%rsp)
movslq %ebx, %rbx
pushq $0xe
popq %rcx
movq %rbx, %rdi
pushq $0x8
popq %r12
movq %r12, %rsi
leaq 0x83a60(%rip), %rdx     # 0x965ec
callq 0x35067
movq %rax, 0x48(%rsp)
movq %r13, 0x80(%rsp)
movslq %r13d, %r13
pushq $0xf
popq %rcx
movq %r13, %rdi
movq %r12, %rsi
leaq 0x83a3b(%rip), %rdx     # 0x965ec
callq 0x35067
movq %rax, 0x40(%rsp)
pushq $0x10
popq %rcx
movq %rbx, %rdi
movq %r12, %rsi
movq %r12, %rbx
leaq 0x83a1e(%rip), %rdx     # 0x965ec
movq %rdx, %r12
callq 0x35067
pushq $0x11
popq %rcx
movq %r13, %rdi
movq %rax, %r13
movq %rbx, %rsi
movq %r12, %rdx
callq 0x35067
movq %rax, 0x50(%rsp)
movslq 0x8(%rsp), %rsi
imulq $0x340, %rsi, %rax      # imm = 0x340
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax), %rdi
addq $0x30f08, %rdi          # imm = 0x30F08
movq 0x20(%rsp), %rbx
movq %rsi, (%rsp)
movq %rdi, 0x60(%rsp)
testq %rbx, %rbx
je 0x12cd3
movl (%rdi), %eax
cmpl $0x4, %eax
je 0x12c3c
cmpl $0x2, %eax
je 0x12c3c
testl %eax, %eax
jne 0x12c46
movq (%rbx), %rax
cvtsi2sdl (%rax,%rsi,8), %xmm0
jmp 0x12c62
movq (%rbx), %rax
movsd (%rax,%rsi,8), %xmm0
jmp 0x12c62
leaq 0x84907(%rip), %rdi     # 0x97554
callq 0x4090
movq 0x60(%rsp), %rdi
movq (%rsp), %rsi
movq (%rbx), %rax
xorpd %xmm0, %xmm0
movslq (%rbp), %rcx
movslq (%rax,%rcx,8), %rcx
movslq 0x4(%rbp), %rdx
movslq (%rax,%rdx,8), %rax
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0x48(%rsp), %rdx
movsd (%rdx,%rcx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rcx,8)
incl (%r13,%rcx,4)
movq 0x40(%rsp), %rdx
movsd (%rdx,%rax,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rax,8)
movq 0x50(%rsp), %rdx
incl (%rdx,%rax,4)
movq (%r14,%rcx,8), %rdx
addsd (%rdx,%rax,8), %xmm0
movsd %xmm0, (%rdx,%rax,8)
movq (%r15,%rcx,8), %rcx
incl (%rcx,%rax,4)
movq 0x10(%rbx), %rbx
jmp 0x12c19
leaq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x359bc
xorl %r12d, %r12d
movq 0x58(%rsp), %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x8(%rsp)
movq 0x48(%rsp), %rbx
cmpq %r12, 0x8(%rsp)
je 0x12d1a
movl (%r13,%r12,4), %esi
movq %rbx, %rdi
callq 0x359bc
incq %r12
addq $0x8, %rbx
jmp 0x12cfd
movq %rbp, 0x78(%rsp)
xorl %ebp, %ebp
movq 0x80(%rsp), %rax
testl %eax, %eax
movl $0x0, %r12d
cmovgl %eax, %r12d
movq 0x40(%rsp), %rbx
cmpq %rbp, %r12
je 0x12d58
movq 0x50(%rsp), %rax
movl (%rax,%rbp,4), %esi
movq %rbx, %rdi
callq 0x359bc
incq %rbp
addq $0x8, %rbx
jmp 0x12d3a
xorl %ebx, %ebx
movq %r13, 0x38(%rsp)
cmpq 0x8(%rsp), %rbx
je 0x12d97
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x12d8d
movq (%r14,%rbx,8), %rdi
addq %rbp, %rdi
movq (%r15,%rbx,8), %rax
movl (%rax,%r13,4), %esi
callq 0x359bc
incq %r13
addq $0x8, %rbp
jmp 0x12d6b
incq %rbx
movq 0x38(%rsp), %r13
jmp 0x12d5f
xorpd %xmm4, %xmm4
movq 0x78(%rsp), %rbx
movq 0x20(%rsp), %rbp
movq (%rsp), %rsi
movq 0x60(%rsp), %rdi
testq %rbp, %rbp
je 0x12e3d
movl (%rdi), %eax
cmpl $0x4, %eax
je 0x12dd2
cmpl $0x2, %eax
je 0x12dd2
testl %eax, %eax
jne 0x12ddd
movq (%rbp), %rax
cvtsi2sdl (%rax,%rsi,8), %xmm0
jmp 0x12e06
movq (%rbp), %rax
movsd (%rax,%rsi,8), %xmm0
jmp 0x12e06
leaq 0x84770(%rip), %rdi     # 0x97554
movapd %xmm4, 0x20(%rsp)
callq 0x4090
movapd 0x20(%rsp), %xmm4
movq 0x60(%rsp), %rdi
movq (%rsp), %rsi
movq (%rbp), %rax
xorpd %xmm0, %xmm0
movslq (%rbx), %rcx
movslq (%rax,%rcx,8), %rcx
movslq 0x4(%rbx), %rdx
movslq (%rax,%rdx,8), %rax
movq (%r14,%rcx,8), %rcx
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movsd 0x10(%rsp), %xmm1
movhpd (%rcx,%rax,8), %xmm1    # xmm1 = xmm1[0],mem[0]
subpd %xmm1, %xmm0
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
movq 0x10(%rbp), %rbp
jmp 0x12dae
xorpd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm1
xorl %eax, %eax
movq 0x48(%rsp), %rcx
cmpq %rax, 0x8(%rsp)
je 0x12e76
cvtsi2sdl (%r13,%rax,4), %xmm2
movsd (%rcx,%rax,8), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm0
incq %rax
jmp 0x12e4e
xorpd %xmm5, %xmm5
xorl %eax, %eax
cmpq %rax, %r12
je 0x12eaa
movq 0x50(%rsp), %rcx
cvtsi2sdl (%rcx,%rax,4), %xmm2
movq 0x40(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm5
incq %rax
jmp 0x12e7c
movq 0x80(%rsp), %rcx
leal -0x1(%rcx), %r12d
cvtsi2sd %r12d, %xmm1
movq 0x58(%rsp), %rax
leal -0x1(%rax), %edi
cvtsi2sd %edi, %xmm2
movapd %xmm4, %xmm3
subsd %xmm5, %xmm3
divsd %xmm1, %xmm5
movsd %xmm5, (%rsp)
subsd %xmm0, %xmm3
divsd %xmm2, %xmm0
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
movl %r12d, %ebp
imull %edi, %ebp
cvtsi2sd %ebp, %xmm1
subsd %xmm4, %xmm3
divsd %xmm1, %xmm3
movapd %xmm3, 0x60(%rsp)
imull %eax, %ecx
movl 0x1c(%rsp), %ebx
subl %ecx, %ebx
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm4
movapd %xmm4, 0x20(%rsp)
divsd %xmm4, %xmm0
movl %ebx, %esi
callq 0x1db37
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movl %r12d, %edi
movl %ebx, %esi
callq 0x1db37
movsd %xmm0, (%rsp)
movapd 0x60(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movl %ebp, %edi
movl %ebx, %esi
callq 0x1db37
movsd %xmm0, 0x20(%rsp)
leaq 0x836a5(%rip), %rdi     # 0x96605
callq 0x4cff1
testl %eax, %eax
je 0x13002
leaq 0x829b4(%rip), %rbp     # 0x95928
movq %rbp, %rdi
callq 0x4cdcf
movq 0x78(%rsp), %r13
movl (%r13), %esi
incl %esi
ucomisd 0x8(%rsp), %xmm0
leaq 0x83690(%rip), %r12     # 0x96624
leaq 0x836c2(%rip), %rbx     # 0x9665d
movq %rbx, %rdi
cmovaq %r12, %rdi
xorl %eax, %eax
callq 0x4030
movq %rbp, %rdi
callq 0x4cdcf
ucomisd (%rsp), %xmm0
cmovaq %r12, %rbx
movl 0x4(%r13), %esi
incl %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4030
movq %rbp, %rdi
callq 0x4cdcf
ucomisd 0x20(%rsp), %xmm0
leaq 0x83636(%rip), %rax     # 0x96615
leaq 0x83668(%rip), %rdi     # 0x9664e
cmovaq %rax, %rdi
movl (%r13), %esi
movl 0x4(%r13), %edx
movq 0x38(%rsp), %r13
incl %esi
incl %edx
xorl %eax, %eax
callq 0x4030
leaq 0x85f4f(%rip), %rdi     # 0x98f58
movsd 0x8(%rsp), %xmm0
callq 0x30597
leaq 0x85f43(%rip), %rdi     # 0x98f5e
movsd (%rsp), %xmm0
callq 0x30597
leaq 0x85f38(%rip), %rdi     # 0x98f64
movsd 0x20(%rsp), %xmm0
callq 0x30597
movq 0x48(%rsp), %rdi
callq 0x34ff7
movq 0x40(%rsp), %rdi
callq 0x34ff7
movq %r13, %rdi
callq 0x34ff7
movq 0x50(%rsp), %rdi
callq 0x34ff7
movq %r14, %rdi
movq 0x58(%rsp), %rbx
movl %ebx, %esi
callq 0x34fc3
movq %r15, %rdi
movl %ebx, %esi
callq 0x34fc3
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq