// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
movl %ecx, (%rsp)
movq %rdx, %rbx
movq %rsi, 0x60(%rsp)
movq %rdi, %r14
movq $0x0, 0x28(%rsp)
movq %rsi, %rdi
callq 0x30309
movl %eax, 0x48(%rsp)
leaq 0x30f08(%r14), %rax
movq %rax, 0x58(%rsp)
movq %rbx, %rcx
movq %rbx, 0x50(%rsp)
movslq (%rbx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movl 0x30f20(%r14,%rax), %ebx
movslq 0x4(%rcx), %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movl 0x30f20(%r14,%rax), %r13d
leaq 0x92a9b(%rip), %rbp     # 0xa664c
movl $0x8, %edi
movl $0x8, %esi
movl %ebx, %edx
movl %r13d, %ecx
movq %rbp, %r8
movl $0x9, %r9d
callq 0x3a231
movq %rax, %r14
movl $0x8, %edi
movl $0x4, %esi
movl %ebx, %edx
movl %r13d, %ecx
movq %rbp, %r8
movl $0xa, %r9d
callq 0x3a231
movq %rax, %r15
movq %rbx, 0x30(%rsp)
movslq %ebx, %r12
movl $0x8, %esi
movq %r12, %rdi
movq %rbp, %rdx
movq %rbp, %rbx
movl $0xe, %ecx
callq 0x3a1fc
movq %rax, 0x10(%rsp)
movslq %r13d, %rbp
movl $0x8, %esi
movq %rbp, %rdi
movq %rbx, %rdx
movl $0xf, %ecx
callq 0x3a1fc
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r12, %rdi
movq 0x60(%rsp), %r12
movq %rbx, %rdx
movl $0x10, %ecx
callq 0x3a1fc
movq %rax, %rbx
movl $0x8, %esi
movq %rbp, %rdi
leaq 0x929ed(%rip), %rdx     # 0xa664c
movl $0x11, %ecx
callq 0x3a1fc
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
movslq (%rsp), %r11
testq %r12, %r12
movq %rbx, 0x20(%rsp)
movq %rax, (%rsp)
movq %r11, 0x18(%rsp)
je 0x13d69
movq %rbx, %r9
imulq $0x340, %r11, %rbp      # imm = 0x340
addq 0x58(%rsp), %rbp
movq %r12, %rbx
movl (%rbp), %ecx
cmpl $0x4, %ecx
je 0x13cc4
cmpl $0x2, %ecx
je 0x13cc4
testl %ecx, %ecx
jne 0x13ccf
movq (%rbx), %r10
xorps %xmm0, %xmm0
cvtsi2sdl (%r10,%r11,8), %xmm0
jmp 0x13cff
movq (%rbx), %r10
movsd (%r10,%r11,8), %xmm0
jmp 0x13cff
leaq 0x938de(%rip), %rdi     # 0xa75b4
callq 0x4090
movq 0x18(%rsp), %r11
movq (%rsp), %rax
movq 0x20(%rsp), %r9
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq (%rbx), %r10
xorpd %xmm0, %xmm0
movslq (%rsi), %rcx
movslq (%r10,%rcx,8), %rcx
movslq 0x4(%rsi), %rdx
movslq (%r10,%rdx,8), %r10
movsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movsd (%rdi,%rcx,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rdi,%rcx,8)
incl (%r9,%rcx,4)
movsd (%r8,%r10,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r8,%r10,8)
incl (%rax,%r10,4)
movq (%r14,%rcx,8), %rdx
addsd (%rdx,%r10,8), %xmm0
movsd %xmm0, (%rdx,%r10,8)
movq (%r15,%rcx,8), %rcx
incl (%rcx,%r10,4)
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x13ca5
leaq 0x28(%rsp), %rdi
movl 0x48(%rsp), %esi
callq 0x3ac36
movq 0x30(%rsp), %r12
testl %r12d, %r12d
jle 0x13da4
xorl %ebx, %ebx
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %rax
movl (%rax,%rbx,4), %esi
movq %rbp, %rdi
callq 0x3ac36
incq %rbx
addq $0x8, %rbp
cmpq %rbx, %r12
jne 0x13d88
testl %r13d, %r13d
movq (%rsp), %r12
jle 0x13dcc
xorl %ebx, %ebx
movq 0x8(%rsp), %rbp
movl (%r12,%rbx,4), %esi
movq %rbp, %rdi
callq 0x3ac36
incq %rbx
addq $0x8, %rbp
cmpq %rbx, %r13
jne 0x13db4
movq 0x30(%rsp), %rbp
testl %ebp, %ebp
movq 0x60(%rsp), %r12
jle 0x13e10
xorl %ebx, %ebx
testl %r13d, %r13d
jle 0x13e03
xorl %ebp, %ebp
leaq (,%rbp,8), %rdi
addq (%r14,%rbx,8), %rdi
movq (%r15,%rbx,8), %rax
movl (%rax,%rbp,4), %esi
callq 0x3ac36
incq %rbp
cmpq %r13, %rbp
jne 0x13de3
incq %rbx
movq 0x30(%rsp), %rbp
cmpq %rbp, %rbx
jne 0x13ddc
testq %r12, %r12
je 0x13eef
movq 0x18(%rsp), %r11
imulq $0x340, %r11, %rax      # imm = 0x340
movq 0x58(%rsp), %rbx
addq %rax, %rbx
xorpd %xmm4, %xmm4
movq 0x50(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %r9
movq (%rsp), %r10
movl (%rbx), %eax
cmpl $0x4, %eax
je 0x13e68
cmpl $0x2, %eax
je 0x13e68
testl %eax, %eax
jne 0x13e74
movq (%r12), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%r11,8), %xmm0
jmp 0x13eb1
movq (%r12), %rax
movsd (%rax,%r11,8), %xmm0
jmp 0x13eb1
leaq 0x93739(%rip), %rdi     # 0xa75b4
movapd %xmm4, 0x30(%rsp)
callq 0x4090
movapd 0x30(%rsp), %xmm4
movq 0x18(%rsp), %r11
movq (%rsp), %r10
movq 0x20(%rsp), %r9
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq (%r12), %rax
xorpd %xmm0, %xmm0
movslq (%rsi), %rcx
movslq (%rax,%rcx,8), %rcx
movslq 0x4(%rsi), %rdx
movslq (%rax,%rdx,8), %rax
movq (%r14,%rcx,8), %rcx
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movsd 0x28(%rsp), %xmm1
movhpd (%rcx,%rax,8), %xmm1    # xmm1 = xmm1[0],mem[0]
subpd %xmm1, %xmm0
mulpd %xmm0, %xmm0
addpd %xmm0, %xmm4
movq 0x10(%r12), %r12
testq %r12, %r12
jne 0x13e49
jmp 0x13f06
xorpd %xmm4, %xmm4
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %r9
movq (%rsp), %r10
xorpd %xmm5, %xmm5
xorpd %xmm0, %xmm0
testl %ebp, %ebp
jle 0x13f40
movsd 0x28(%rsp), %xmm1
xorl %eax, %eax
xorps %xmm2, %xmm2
cvtsi2sdl (%r9,%rax,4), %xmm2
movsd (%rdi,%rax,8), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm0
incq %rax
cmpq %rax, %rbp
jne 0x13f1a
testl %r13d, %r13d
jle 0x13f78
xorpd %xmm5, %xmm5
movsd 0x28(%rsp), %xmm1
xorl %eax, %eax
xorps %xmm2, %xmm2
cvtsi2sdl (%r10,%rax,4), %xmm2
movsd (%r8,%rax,8), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm5
incq %rax
cmpq %rax, %r13
jne 0x13f51
leal -0x1(%r13), %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movl %ebx, 0x58(%rsp)
leal -0x1(%rbp), %edi
xorps %xmm2, %xmm2
cvtsi2sd %edi, %xmm2
movapd %xmm4, %xmm3
subsd %xmm5, %xmm3
divsd %xmm1, %xmm5
movsd %xmm5, 0x70(%rsp)
subsd %xmm0, %xmm3
divsd %xmm2, %xmm0
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
subsd %xmm4, %xmm3
imull %edi, %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm3
movapd %xmm3, 0x60(%rsp)
movl %ebp, %eax
imull %r13d, %eax
movl 0x48(%rsp), %r12d
subl %eax, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm4
movapd %xmm4, 0x30(%rsp)
divsd %xmm4, %xmm0
movl %r12d, %esi
callq 0x201ed
movsd %xmm0, 0x18(%rsp)
movsd 0x70(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
movl 0x58(%rsp), %edi
movl %r12d, %esi
callq 0x201ed
movsd %xmm0, 0x48(%rsp)
movapd 0x60(%rsp), %xmm0
divsd 0x30(%rsp), %xmm0
movl %ebx, %edi
movl %r12d, %esi
callq 0x201ed
movsd %xmm0, 0x30(%rsp)
leaq 0x9262b(%rip), %rdi     # 0xa6665
callq 0x54bec
testl %eax, %eax
je 0x140d7
leaq 0x918da(%rip), %rdi     # 0xa5928
callq 0x549ba
movq 0x50(%rsp), %rbx
movl (%rbx), %esi
incl %esi
ucomisd 0x18(%rsp), %xmm0
leaq 0x9261b(%rip), %r12     # 0xa6684
leaq 0x9264d(%rip), %r13     # 0xa66bd
movq %r13, %rdi
cmovaq %r12, %rdi
xorl %eax, %eax
callq 0x4030
leaq 0x918a3(%rip), %rdi     # 0xa5928
callq 0x549ba
ucomisd 0x48(%rsp), %xmm0
cmovaq %r12, %r13
movl 0x4(%rbx), %esi
incl %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x4030
leaq 0x9187e(%rip), %rdi     # 0xa5928
callq 0x549ba
ucomisd 0x30(%rsp), %xmm0
leaq 0x925b9(%rip), %rax     # 0xa6675
leaq 0x925eb(%rip), %rdi     # 0xa66ae
cmovaq %rax, %rdi
movl (%rbx), %esi
movl 0x4(%rbx), %edx
incl %esi
incl %edx
xorl %eax, %eax
callq 0x4030
leaq 0x94f0a(%rip), %rdi     # 0xa8fe8
movsd 0x18(%rsp), %xmm0
callq 0x34a17
leaq 0x94efe(%rip), %rdi     # 0xa8fee
movsd 0x48(%rsp), %xmm0
callq 0x34a17
leaq 0x94ef2(%rip), %rdi     # 0xa8ff4
movsd 0x30(%rsp), %xmm0
callq 0x34a17
movq 0x10(%rsp), %rdi
callq 0x3a180
movq 0x8(%rsp), %rdi
callq 0x3a180
movq 0x20(%rsp), %rdi
callq 0x3a180
movq (%rsp), %rdi
callq 0x3a180
movq %r14, %rdi
movl %ebp, %esi
callq 0x3a14b
movq %r15, %rdi
movl %ebp, %esi
callq 0x3a14b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq