// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/tests.c
// Function: vanderwaerdan
double vanderwaerdan(char **files)
{
 /*!Last Changed 13.01.2009 added find_observations_for_multiple_file, qsort, assign_ranks_to_observations*/
 /*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 14.02.2002*/
 int treatments, df;
 int *counts = NULL, i, k;
 Obs *obs = NULL;
 double *T, S = 0, sumd, res;
 obs = read_observations_for_multiple_file(files, &counts, &k, &treatments);
 T = (double *)safecalloc(treatments, sizeof(double), "vanderwaerdan", 27);
 qsort(obs, k, sizeof(Obs), sort_function_observation_ascending);
 assign_ranks_to_observations(obs, k);
 for (i = 0; i < k; i++)
  {
   obs[i].rij /= k+1;
   obs[i].rij = z_inverse(obs[i].rij);
   S += obs[i].rij * obs[i].rij;
   T[obs[i].observation_no] += obs[i].rij;
  }
 S /= k - 1;
 sumd = 0;
 for (i = 0; i < treatments; i++)
  {
   T[i] /= counts[i];
   sumd += counts[i] * T[i] * T[i];
  }
	safe_free(counts);
 sumd /= S;
 safe_free(obs);
 safe_free(T);
 df = treatments - 1;
 res = chi_square(df, sumd);
 return 1 - res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdx
leaq -0xc(%rbp), %rcx
callq 0xd1b40
movq %rax, -0x28(%rbp)
movslq -0xc(%rbp), %rdi
movl $0x8, %esi
leaq 0x15b7f(%rip), %rdx     # 0xee54c
movl $0x1b, %ecx
callq 0x52f40
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movslq -0x20(%rbp), %rsi
movl $0x20, %edx
leaq -0x8548f(%rip), %rcx    # 0x53560
callq 0x41f0
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0xd13f0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0xd8ae3
movl -0x20(%rbp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm1
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
callq 0x2efc0
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x10(%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm2
movsd -0x38(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd8a07
movl -0x20(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xd8b79
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm1
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd8b0a
movq -0x18(%rbp), %rdi
callq 0x52e80
movsd -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x30(%rbp), %rdi
callq 0x52e80
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edi
movsd -0x40(%rbp), %xmm0
callq 0x2d5e0
movsd %xmm0, -0x48(%rbp)
movsd 0x944e(%rip), %xmm0     # 0xe2018
subsd -0x48(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)