// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/tests.c
// Function: anova
double anova(char **files)
{
 /*Last Changed 02.02.2004 added safemalloc*/
 /*Last Changed 23.04.2001*/
 FILE *myfile;
 int treatments = 0, df1, df2;
 int *counts = NULL, i, j, total = 0;
 double **observations = NULL;
 double *means, overall_mean = 0.0;
 double res, mst, mse, sst = 0.0, sse = 0.0;
 while (files[treatments])
  {
   treatments++;
   counts = alloc(counts, treatments * sizeof(int), treatments);
   observations = alloc(observations, treatments * sizeof(double *), treatments);
   counts[treatments - 1] = file_length(files[treatments - 1]);
   observations[treatments - 1] = (double *)safemalloc(counts[treatments - 1] * sizeof(double), "anova", 13);
   if ((myfile = fopen(files[treatments - 1], "r")) == NULL)
    {
     printf(m1274, files[treatments - 1]);
     return 0;
    }
   for (i = 0; i < counts[treatments - 1]; i++)
     fscanf(myfile, "%lf", &observations[treatments - 1][i]);
   fclose(myfile);
  }
 means = (double *)safecalloc(treatments, sizeof(double), "anova", 23);
 for (i = 0; i < treatments; i++)
  {
   for (j = 0; j < counts[i]; j++)
     means[i] += observations[i][j];
   overall_mean += means[i];
   total += counts[i];
   means[i] /= counts[i];
  }
 overall_mean /= total;
 for (i = 0; i < treatments; i++)
  {
   sst += counts[i] * pow(means[i] - overall_mean, 2);
   for (j = 0; j < counts[i]; j++)
     sse += pow(observations[i][j] - means[i], 2);
  }
 df1 = treatments - 1;
 df2 = total - treatments;
 mst=sst / df1;
 mse=sse / df2;
 free_2d((void**)observations, treatments);
 safe_free(counts);
 safe_free(means);
 res = f_distribution(mst / mse, df1, df2);
 return 1-res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpq $0x0, (%rdi)
je 0x96269
movq %rdi, %rbx
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rdi, 0x8(%rsp)
leaq 0x1(%r13), %rbp
leaq 0x4(,%r13,4), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x390c8
movq %rax, %r14
leaq 0x8(,%r13,8), %rsi
movq %r15, %rdi
movl %ebp, %edx
callq 0x390c8
movq %rax, %r15
movq (%rbx,%r13,8), %rdi
callq 0x37e22
movl %eax, (%r14,%r13,4)
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x185e2(%rip), %rsi     # 0xae7af
movl $0xd, %edx
callq 0x390f5
movq %rax, (%r15,%r13,8)
movq (%rbx,%r13,8), %rdi
leaq 0x126a9(%rip), %rsi     # 0xa888f
callq 0x40f0
testq %rax, %rax
je 0x963c5
movq %rax, %r12
movq %rbp, 0x10(%rsp)
cmpl $0x0, (%r14,%r13,4)
movq %r14, (%rsp)
movq %r15, %r14
leaq 0x10a01(%rip), %r15     # 0xa6c10
jle 0x9623d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq (%r14,%r13,8), %rdx
addq %rbx, %rdx
movq %r12, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x4070
incq %rbp
movq (%rsp), %rax
movslq (%rax,%r13,4), %rax
addq $0x8, %rbx
cmpq %rax, %rbp
jl 0x96215
movq %r12, %rdi
callq 0x42a0
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %rdi
cmpq $0x0, (%rbx,%rdi,8)
movq %rdi, %r13
movq %r14, %r15
movq (%rsp), %r14
jne 0x96184
movl %edi, %r12d
jmp 0x96274
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %edi, %edi
leaq 0x18534(%rip), %rdx     # 0xae7af
movl $0x8, %esi
movl $0x17, %ecx
callq 0x39210
movq %rax, %r13
xorpd %xmm4, %xmm4
movl %r12d, %eax
xorpd %xmm0, %xmm0
testl %r12d, %r12d
movl $0x0, %ebx
je 0x962f7
xorl %ecx, %ecx
xorl %ebx, %ebx
movslq (%r14,%rcx,4), %rdx
testq %rdx, %rdx
jle 0x962d0
movq (%r15,%rcx,8), %rsi
movsd (%r13,%rcx,8), %xmm1
xorl %edi, %edi
addsd (%rsi,%rdi,8), %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rdi
cmpq %rdi, %rdx
jne 0x962bc
movsd (%r13,%rcx,8), %xmm1
addsd %xmm1, %xmm0
addl %edx, %ebx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rcx
cmpq %rax, %rcx
jne 0x962a6
xorpd %xmm1, %xmm1
testl %r12d, %r12d
je 0x96363
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
xorpd %xmm4, %xmm4
movslq (%r14,%rcx,4), %rdx
movsd (%r13,%rcx,8), %xmm2
testq %rdx, %rdx
jle 0x96344
movq (%r15,%rcx,8), %rsi
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm3
subsd %xmm2, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %rdi
cmpq %rdi, %rdx
jne 0x9632b
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
subsd %xmm0, %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm4
incq %rcx
cmpq %rax, %rcx
jne 0x96315
leal -0x1(%r12), %ebp
subl %r12d, %ebx
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
divsd %xmm0, %xmm4
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
divsd %xmm0, %xmm1
divsd %xmm1, %xmm4
movsd %xmm4, (%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x3915f
movq %r14, %rdi
callq 0x39194
movq %r13, %rdi
callq 0x39194
movsd (%rsp), %xmm0
movl %ebp, %edi
movl %ebx, %esi
callq 0x1faa9
movapd %xmm0, %xmm1
movsd 0xc161(%rip), %xmm0     # 0xa2520
subsd %xmm1, %xmm0
jmp 0x963db
movq (%rbx,%r13,8), %rsi
leaq 0xce3a(%rip), %rdi      # 0xa320a
xorl %eax, %eax
callq 0x4030
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq