// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/tests.c
// Function: friedman
double friedman(char **files)
{
 /*!Last Changed 25.04.2010*/
 int i, j, N, k, df1, df2;
 Obsptr *obs;
 double *R, S, F, sumri2, res;
 obs = read_observations_for_multiple_equal_size_file(files, &N, &k);
 assign_ranks_to_equal_size_observations(obs, k, N);
 R = (double *)safecalloc(k, sizeof(double), "friedman", 6);
 for (i = 0; i < k; i++)
   for (j = 0; j < N; j++)
	 	  R[i] += obs[i][j].rij;
	sumri2 = 0.0;
 for (i = 0; i < k; i++)
	 { 
		 R[i] /= N;
   write_array_variables("aout", i + 1, 3, "f", R[i]);
   if (get_parameter_o("displayresulton") == ON)
     printf("%.6f ", R[i]);
			sumri2 += R[i] * R[i];
		}
 if (get_parameter_o("displayresulton") == ON)
   printf("\n");
 safe_free(R);
 safe_free(obs);
 S = ((12.0 * N) / (k * (k + 1))) * (sumri2 - ((k * (k + 1) * (k + 1)) / 4.0));
 if (N * (k - 1) - S != 0)
  {
	  F = ((N - 1) * S) / (N * (k - 1) - S);
   df1 = k - 1;
   df2 = (k - 1) * (N - 1);
	  res = f_distribution(F, df1, df2);
   return 1 - res;
  }
 else
   return 1.0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x24(%rsp), %rbx
leaq 0x20(%rsp), %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x9afd7
movq %rax, %r15
movslq (%r14), %r14
movl (%rbx), %ebx
movq %rax, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x97f73
leaq 0x16c4f(%rip), %rdx     # 0xb1dbd
movl $0x8, %esi
movq %r14, %rdi
movl $0x6, %ecx
callq 0x3a1fc
movq %rax, %r12
xorpd %xmm1, %xmm1
testq %r14, %r14
movq %r15, 0x10(%rsp)
jle 0x9b264
movq %rbx, %rax
shlq $0x5, %rax
xorl %ecx, %ecx
testl %ebx, %ebx
jle 0x9b1c3
movq (%r15,%rcx,8), %rdx
movsd (%r12,%rcx,8), %xmm0
xorl %esi, %esi
addsd 0x10(%rdx,%rsi), %xmm0
movsd %xmm0, (%r12,%rcx,8)
addq $0x20, %rsi
cmpq %rsi, %rax
jne 0x9b1ae
incq %rcx
cmpq %r14, %rcx
jne 0x9b19e
testl %r14d, %r14d
jle 0x9b264
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm1, %xmm1
xorl %ebp, %ebp
leaq 0xb477(%rip), %r13      # 0xa6665
movsd %xmm1, 0x8(%rsp)
movsd (%r12,%rbp,8), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, (%r12,%rbp,8)
leaq 0x1(%rbp), %r15
leaq 0xa59f(%rip), %rdi      # 0xa57b0
movl %r15d, %esi
movl $0x3, %edx
leaq 0xd459(%rip), %rcx      # 0xa8679
movb $0x1, %al
callq 0x33644
movq %r13, %rdi
callq 0x54bec
cmpl $0x1, %eax
jne 0x9b248
movsd (%r12,%rbp,8), %xmm0
leaq 0x15540(%rip), %rdi     # 0xb0781
movb $0x1, %al
callq 0x4030
movsd (%r12,%rbp,8), %xmm0
mulsd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movq %r15, %rbp
cmpq %r15, %r14
jne 0x9b1ee
movsd %xmm1, 0x8(%rsp)
leaq 0xb3f4(%rip), %rdi      # 0xa6665
callq 0x54bec
cmpl $0x1, %eax
jne 0x9b285
movl $0xa, %edi
callq 0x40d0
movq %r12, %rdi
callq 0x3a180
movq 0x10(%rsp), %rdi
callq 0x3a180
cvtsi2sd %ebx, %xmm3
mulsd 0xfbfd(%rip), %xmm3     # 0xaaea0
leal 0x1(%r14), %eax
movl %r14d, %ecx
imull %eax, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
imull %eax, %ecx
cvtsi2sd %ecx, %xmm2
mulsd 0xaa25(%rip), %xmm2     # 0xa5ce8
divsd %xmm1, %xmm3
movsd 0x8(%rsp), %xmm0
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
leal -0x1(%r14), %edi
movl %ebx, %eax
imull %edi, %eax
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x9b2f5
jnp 0x9b322
decl %ebx
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
imull %edi, %ebx
movl %ebx, %esi
callq 0x201ed
movapd %xmm0, %xmm1
movsd 0xa204(%rip), %xmm0     # 0xa5520
subsd %xmm1, %xmm0
jmp 0x9b32a
movsd 0xa1f6(%rip), %xmm0     # 0xa5520
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq