// File: /workspace/github_c_makefile_star2_O2/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 0x8c2e0
movq %rax, %r15
movl (%r14), %r14d
movl (%rbx), %ebp
movq %rax, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x8962c
movslq %r14d, %rbx
leaq 0x158ca(%rip), %rdx     # 0xa1d15
pushq $0x8
popq %rsi
pushq $0x6
popq %rcx
movq %rbx, %rdi
callq 0x35067
movq %rax, %r12
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
testl %ebx, %ebx
movl $0x0, %r13d
cmovgl %r14d, %r13d
shlq $0x5, %rcx
cmpq %r13, %rax
je 0x8c4a5
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x8c4a0
movq (%r15,%rax,8), %rsi
movsd 0x10(%rsi,%rdx), %xmm0
addsd (%r12,%rax,8), %xmm0
movsd %xmm0, (%r12,%rax,8)
addq $0x20, %rdx
jmp 0x8c47f
incq %rax
jmp 0x8c478
movq %r14, 0x18(%rsp)
movl %ebp, 0x4(%rsp)
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm1, %xmm1
xorl %ebp, %ebp
pushq $0x3
popq %rbx
leaq 0xa13d(%rip), %r14      # 0x96605
movsd %xmm1, 0x10(%rsp)
cmpq %rbp, %r13
je 0x8c539
movsd (%r12,%rbp,8), %xmm0
divsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r12,%rbp,8)
leal 0x1(%rbp), %esi
leaq 0x92c1(%rip), %rdi      # 0x957b0
movl %ebx, %edx
leaq 0xc101(%rip), %rcx      # 0x985f9
movb $0x1, %al
callq 0x2f310
movq %r14, %rdi
callq 0x4cff1
cmpl $0x1, %eax
jne 0x8c520
movsd (%r12,%rbp,8), %xmm0
leaq 0x141cc(%rip), %rdi     # 0xa06e5
movb $0x1, %al
callq 0x4030
movsd (%r12,%rbp,8), %xmm0
mulsd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
incq %rbp
jmp 0x8c4c8
leaq 0xa0c5(%rip), %rdi      # 0x96605
callq 0x4cff1
cmpl $0x1, %eax
jne 0x8c552
pushq $0xa
popq %rdi
callq 0x40d0
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x34ff7
movsd 0x8(%rsp), %xmm2
mulsd 0xe868(%rip), %xmm2     # 0x9add8
movq 0x18(%rsp), %rdi
leal 0x1(%rdi), %eax
movl %eax, %ecx
imull %edi, %ecx
cvtsi2sd %ecx, %xmm0
imull %eax, %ecx
cvtsi2sd %ecx, %xmm1
mulsd 0x9770(%rip), %xmm1     # 0x95d00
divsd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
decl %edi
movl 0x4(%rsp), %esi
movl %esi, %eax
imull %edi, %eax
cvtsi2sd %eax, %xmm2
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x8c5c1
jnp 0x8c5e9
decl %esi
cvtsi2sd %esi, %xmm1
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
imull %edi, %esi
callq 0x1db37
movapd %xmm0, %xmm1
movsd 0x8f3d(%rip), %xmm0     # 0x95520
subsd %xmm1, %xmm0
jmp 0x8c5f1
movsd 0x8f2f(%rip), %xmm0     # 0x95520
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq