// File: /workspace/github_c_makefile_star2_O1/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), %r14
leaq 0x20(%rsp), %rbx
movq %r14, %rsi
movq %rbx, %rdx
callq 0x982a0
movq %rax, %r15
movslq (%rbx), %rbx
movl (%r14), %r14d
movq %rax, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x95349
leaq 0x1690f(%rip), %rdx     # 0xaed3d
movl $0x8, %esi
movq %rbx, %rdi
movl $0x6, %ecx
callq 0x39210
movq %rax, %r12
testq %rbx, %rbx
jle 0x9847f
movq %r14, %rax
shlq $0x5, %rax
xorl %ecx, %ecx
testl %r14d, %r14d
jle 0x98477
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 0x98462
incq %rcx
cmpq %rbx, %rcx
jne 0x98451
movq %r15, 0x8(%rsp)
testl %ebx, %ebx
movq %r14, 0x10(%rsp)
jle 0x9852b
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
xorl %r14d, %r14d
leaq 0xd16f(%rip), %rbp      # 0xa5621
leaq 0xb168(%rip), %r15      # 0xa3621
movsd (%r12,%r14,8), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, (%r12,%r14,8)
leaq 0x1(%r14), %r13
leaq 0xa2da(%rip), %rdi      # 0xa27b0
movl %r13d, %esi
movl $0x3, %edx
movq %rbp, %rcx
movb $0x1, %al
callq 0x32c64
movq %r15, %rdi
callq 0x536e7
cmpl $0x1, %eax
jne 0x98509
movsd (%r12,%r14,8), %xmm0
leaq 0x151e7(%rip), %rdi     # 0xad6e9
movb $0x1, %al
callq 0x4030
movsd (%r12,%r14,8), %xmm0
mulsd %xmm0, %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movq %r13, %r14
cmpq %r13, %rbx
jne 0x984b9
jmp 0x98534
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq 0xb0e6(%rip), %rdi      # 0xa3621
callq 0x536e7
cmpl $0x1, %eax
jne 0x9854f
movl $0xa, %edi
callq 0x40d0
movq %r12, %rdi
callq 0x39194
movq 0x8(%rsp), %rdi
callq 0x39194
movq 0x10(%rsp), %rsi
cvtsi2sd %esi, %xmm3
mulsd 0x166f6(%rip), %xmm3    # 0xaec68
leal 0x1(%rbx), %eax
movl %eax, %ecx
imull %ebx, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
imull %eax, %ecx
cvtsi2sd %ecx, %xmm2
mulsd 0xa758(%rip), %xmm2     # 0xa2ce8
divsd %xmm1, %xmm3
movsd (%rsp), %xmm0
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
decl %ebx
movl %esi, %eax
imull %ebx, %eax
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x985bf
jnp 0x985ec
decl %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd %xmm1, %xmm0
divsd %xmm2, %xmm0
imull %ebx, %esi
movl %ebx, %edi
callq 0x1faa9
movapd %xmm0, %xmm1
movsd 0x9f3a(%rip), %xmm0     # 0xa2520
subsd %xmm1, %xmm0
jmp 0x985f4
movsd 0x9f2c(%rip), %xmm0     # 0xa2520
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq