// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/tests.c
// Function: kruskalwallis_multivariate
double kruskalwallis_multivariate(char **files)
{
 Graphptr mst;
 matrix* observations, distancematrix;
 int treatmentno, pos, i, p, n, treatments = 0, df, N = 0;
 double *T, S, sumd, res;
 while (files[treatments])
   treatments++;
 observations = safemalloc(treatments * sizeof(matrix), "kruskalwallis_multivariate", 5);
 p = read_multivariate_observations_for_multiple_file(files, observations, treatments);
 if (p == -1)
  {
   for (i = 0; i < treatments; i++)
     matrix_free(observations[i]);
   safe_free(observations);
   return 0;
  } 
 n = observations[0].row; 
 for (i = 0; i < treatments; i++) 
   N += observations[i].row; 
 T = (double *)safecalloc(treatments, sizeof(double), "kruskalwallis_multivariate", 15);
 distancematrix = distance_matrix_for_multiple_multivariate_sample(observations, treatments, N);
 mst = minimum_spanning_tree_from_observations(observations, distancematrix, treatments, N);
 if (mst == NULL)
   return 0;
 ranks_from_minimum_spanning_tree(mst, distancematrix);
 matrix_free(distancematrix);
 for (i = 0; i < N; i++)
  {
   treatmentno = index_in_multiple_sample(i, &pos, observations, treatments);
   write_array_variables("aout", pos + 1, 5 + treatmentno, "d", mst->visitorder[i]);
  }
 if (p == 2)
   save_mst_to_array_variables(mst, observations, treatments);
 for (i = 0; i < N; i++)
  {
   treatmentno = index_in_multiple_sample(i, &pos, observations, treatments);
   T[treatmentno] += mst->visitorder[i];
  }
 free_graph(mst);
 sumd = 0;
 for (i = 0; i < treatments; i++)
   sumd += T[i] * T[i] / observations[i].row;
 for (i = 0; i < treatments; i++)
   matrix_free(observations[i]);
 safe_free(observations); 
 safe_free(T);
 S = sumd * ((12 + 0.0) / (treatments * n * (treatments * n + 1))) - 3 * (treatments * n + 1);
 df = treatments - 1;
 res = chi_square(df, S);
 return 1 - res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movq $-0x1, %rbx
movq $-0x10, %rdi
addq $0x10, %rdi
cmpq $0x0, 0x8(%r15,%rbx,8)
leaq 0x1(%rbx), %rbx
jne 0x9abb1
leaq 0x171a2(%rip), %rsi     # 0xb1d6a
movl $0x5, %edx
callq 0x3a0e1
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
movl %ebx, %edx
callq 0x9824f
cmpl $-0x1, %eax
je 0x9ac05
testq %rbx, %rbx
movl %eax, 0x8(%rsp)
je 0x9ac33
xorl %ebp, %ebp
movq %rbx, %rax
movq %r12, %rcx
addl (%rcx), %ebp
addq $0x10, %rcx
decq %rax
jne 0x9abf8
jmp 0x9ac35
testq %rbx, %rbx
je 0x9ac26
movq %r12, %r14
addq $0x8, %r14
movq -0x8(%r14), %rdi
movq (%r14), %rsi
callq 0x3ed51
addq $0x10, %r14
decq %rbx
jne 0x9ac11
movq %r12, %rdi
callq 0x3a180
jmp 0x9ae02
xorl %ebp, %ebp
movl (%r12), %eax
movq %rax, 0x20(%rsp)
leaq 0x17125(%rip), %rdx     # 0xb1d6a
movl $0x8, %esi
movq %rbx, %rdi
movl $0xf, %ecx
callq 0x3a1fc
movq %rax, 0x18(%rsp)
movq %r12, 0x10(%rsp)
movq %r12, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x99958
movq %rax, %r13
movq %rdx, %r14
movq %rax, %rsi
movl %ebp, %r8d
callq 0x99f51
testq %rax, %rax
je 0x9ae02
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x9a0a7
movq %r13, %rdi
movq %r14, %rsi
callq 0x3ed51
movl %ebp, %r14d
testl %ebp, %ebp
jle 0x9ad12
xorl %r13d, %r13d
movl $0x4, %edx
testq %rbx, %rbx
je 0x9ace9
xorl %eax, %eax
movq 0x10(%rsp), %rcx
xorl %esi, %esi
movslq (%rcx), %r8
movslq %esi, %rdi
addq %r8, %rdi
cmpq %rdi, %r13
jl 0x9acde
incq %rax
addq $0x10, %rcx
movl %edi, %esi
cmpq %rax, %rbx
jne 0x9acc0
jmp 0x9ace9
movl %r13d, %r15d
subl %esi, %r15d
addl $0x5, %eax
movl %eax, %edx
leal 0x1(%r15), %esi
movl 0xf433a0(%r12,%r13,4), %r8d
leaq 0xaab4(%rip), %rdi      # 0xa57b0
leaq 0x15ef3(%rip), %rcx     # 0xb0bf6
xorl %eax, %eax
callq 0x33644
incq %r13
cmpq %r14, %r13
jne 0x9acad
cmpl $0x2, 0x8(%rsp)
movq 0x10(%rsp), %r13
jne 0x9ad2b
movq %r12, %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x99adc
testl %ebp, %ebp
movq 0x18(%rsp), %rbp
jle 0x9ad9b
xorl %eax, %eax
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq $-0x1, %rdx
testq %rbx, %rbx
je 0x9ad7a
xorl %esi, %esi
movq %r13, %rdi
movq %rbx, %r8
xorl %r9d, %r9d
movslq (%rdi), %r10
movslq %r9d, %r9
addq %r10, %r9
cmpq %r9, %rax
jl 0x9ad73
addq %rcx, %rsi
addq $0x10, %rdi
decq %r8
jne 0x9ad57
jmp 0x9ad7a
sarq $0x20, %rsi
movq %rsi, %rdx
xorps %xmm0, %xmm0
cvtsi2sdl 0xf433a0(%r12,%rax,4), %xmm0
addsd (%rbp,%rdx,8), %xmm0
movsd %xmm0, (%rbp,%rdx,8)
incq %rax
cmpq %r14, %rax
jne 0x9ad40
movq %r12, %rdi
callq 0x1bbac
testq %rbx, %rbx
je 0x9ae08
xorpd %xmm2, %xmm2
xorl %eax, %eax
movq %r13, %rcx
movsd (%rbp,%rax,8), %xmm0
mulsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rcx), %xmm1
divsd %xmm1, %xmm0
addsd %xmm0, %xmm2
incq %rax
addq $0x10, %rcx
cmpq %rax, %rbx
jne 0x9adb1
movsd %xmm2, 0x8(%rsp)
testq %rbx, %rbx
je 0x9ae12
movq %r13, %r14
addq $0x8, %r14
movq %rbx, %r15
movq -0x8(%r14), %rdi
movq (%r14), %rsi
callq 0x3ed51
addq $0x10, %r14
decq %r15
jne 0x9adeb
jmp 0x9ae12
xorpd %xmm0, %xmm0
jmp 0x9ae70
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
callq 0x3a180
movq %rbp, %rdi
callq 0x3a180
movq 0x20(%rsp), %rcx
imull %ebx, %ecx
leal 0x1(%rcx), %eax
imull %eax, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd 0x10061(%rip), %xmm0    # 0xaaea0
divsd %xmm1, %xmm0
mulsd 0x8(%rsp), %xmm0
leal (%rax,%rax,2), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
decl %ebx
movl %ebx, %edi
callq 0x1fc11
movapd %xmm0, %xmm1
movsd 0xa6b4(%rip), %xmm0     # 0xa5520
subsd %xmm1, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq