// File: /workspace/github_c_makefile_star2_O3/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 0x98fc7
movq %rdi, %r13
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %rdi, 0x10(%rsp)
leaq 0x1(%r15), %r12
leaq 0x4(,%r15,4), %rsi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x3a0b4
movq %rax, %rbx
leaq 0x8(,%r15,8), %rsi
movq %r14, %rdi
movq %r12, 0x8(%rsp)
movl %r12d, %edx
callq 0x3a0b4
movq %rax, %r14
movq (%r13,%r15,8), %rdi
callq 0x38a4a
movl %eax, (%rbx,%r15,4)
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x189f5(%rip), %rsi     # 0xb183f
movl $0xd, %edx
callq 0x3a0e1
movq %rax, (%r14,%r15,8)
movq (%r13,%r15,8), %rdi
leaq 0x12af7(%rip), %rsi     # 0xab95b
callq 0x40f0
testq %rax, %rax
je 0x99053
movq %rax, %rbp
cmpl $0x0, (%rbx,%r15,4)
movq %rbx, (%rsp)
movq %r14, %rbx
leaq 0x10df8(%rip), %r14     # 0xa9c80
jle 0x98eb8
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx,%r15,8), %rdx
addq %r12, %rdx
movq %rbp, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x4070
incq %r13
movq (%rsp), %rax
movslq (%rax,%r15,4), %rax
addq $0x8, %r12
cmpq %rax, %r13
jl 0x98e90
movq %rbp, %rdi
callq 0x42a0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %r13
cmpq $0x0, (%r13,%rdi,8)
movq %rdi, %r15
movq %rbx, %r14
movq (%rsp), %rbx
jne 0x98df9
leaq 0x18958(%rip), %rdx     # 0xb183f
movl $0x8, %esi
movl $0x17, %ecx
callq 0x3a1fc
movq 0x8(%rsp), %rsi
movq %rax, %r13
movl %esi, %eax
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
movslq (%rbx,%rcx,4), %rdx
testq %rdx, %rdx
jle 0x98f36
movq (%r14,%rcx,8), %r8
movsd (%r13,%rcx,8), %xmm1
xorl %edi, %edi
addsd (%r8,%rdi,8), %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rdi
cmpq %rdi, %rdx
jne 0x98f1f
jmp 0x98f3d
movsd (%r13,%rcx,8), %xmm1
addsd %xmm1, %xmm0
addl %edx, %r12d
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rcx
cmpq %rax, %rcx
jne 0x98f09
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm0
movl %esi, %eax
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
xorpd %xmm4, %xmm4
movslq (%rbx,%rcx,4), %rdx
movsd (%r13,%rcx,8), %xmm2
testq %rdx, %rdx
jle 0x98fa6
movq (%r14,%rcx,8), %r8
xorl %edi, %edi
movsd (%r8,%rdi,8), %xmm3
subsd %xmm2, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm1
incq %rdi
cmpq %rdi, %rdx
jne 0x98f8c
xorps %xmm3, %xmm3
cvtsi2sd %edx, %xmm3
subsd %xmm0, %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm3, %xmm2
addsd %xmm2, %xmm4
incq %rcx
cmpq %rax, %rcx
jne 0x98f76
jmp 0x98ff4
leaq 0x18871(%rip), %rdx     # 0xb183f
xorl %r12d, %r12d
movl $0x8, %esi
xorl %edi, %edi
movl $0x17, %ecx
callq 0x3a1fc
movq %rax, %r13
xorpd %xmm4, %xmm4
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %esi, %esi
xorpd %xmm1, %xmm1
leal -0x1(%rsi), %ebp
subl %esi, %r12d
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
divsd %xmm0, %xmm4
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd %xmm0, %xmm1
divsd %xmm1, %xmm4
movsd %xmm4, (%rsp)
movq %r14, %rdi
callq 0x3a14b
movq %rbx, %rdi
callq 0x3a180
movq %r13, %rdi
callq 0x3a180
movsd (%rsp), %xmm0
movl %ebp, %edi
movl %r12d, %esi
callq 0x201ed
movapd %xmm0, %xmm1
movsd 0xc4d3(%rip), %xmm0     # 0xa5520
subsd %xmm1, %xmm0
jmp 0x9906a
movq (%r13,%r15,8), %rsi
leaq 0xd1ab(%rip), %rdi      # 0xa620a
xorl %eax, %eax
callq 0x4030
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq