// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/tests.c
// Function: permutation_test
int permutation_test(char **files, int *which, double confidence, double *real_confidence)
{
 /*One Tailed Test for H0: mu1 <= mu2 H1: mu1 > mu2*/
 /*Two Tailed Test for H0: mu1 = mu2 H1: mu1 != mu2*/
 /*confidence = 0.95 for alpha = 0.05, confidence = 0.99 for alpha = 0.01 etc.*/
 int i, counts[2], count, total;
 double **observations, sum[2], current[2];
 int* combination;
 observations = read_observations_for_two_file(files, counts);
 if (!observations)
  {
   *real_confidence = 0.5;
   return 0;
  }
 sum[0] = sum_of_list_double(observations[0], counts[0]);
 sum[1] = sum_of_list_double(observations[1], counts[1]);
 combination = first_combination(counts[0]);
 count = 0;
 total = 0;
 do{
   current[0] = 0;
   for (i = 0; i < counts[0]; i++)
     if (combination[i] < counts[0])
       current[0] += observations[0][combination[i]];
     else
       current[0] += observations[1][combination[i] - counts[0]];
   current[1] = sum[0] + sum[1] - current[0];
   total++;
   if (sum[0] / counts[0] - sum[1] / counts[1] > current[0] / counts[0] - current[1] / counts[1])
     count++;
 }while (next_combination(combination, counts[0], counts[0] + counts[1] - 1));
 free_2d((void**)observations, 2);
 if (get_parameter_i("tailed") == 2)
  {
   (*real_confidence) = count / (total + 0.0);
   if ((*real_confidence) < ((1 + confidence) / 2) && (*real_confidence) > ((1 - confidence) / 2))
     return 0;
   else
     return 1;
  }
 else
  {
   (*real_confidence) = count / (total + 0.0);
   if ((*real_confidence) < confidence)
     return 0;
   else
     return 1;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rsi
callq 0x95b63
testq %rax, %rax
je 0x9ac95
movq %rax, %r14
movq %rbx, 0x28(%rsp)
movq (%rax), %rdi
movl 0x18(%rsp), %r15d
movl %r15d, %esi
callq 0x37ae1
movsd %xmm0, 0x8(%rsp)
movq 0x8(%r14), %rdi
movl 0x1c(%rsp), %r13d
movl %r13d, %esi
callq 0x37ae1
movsd %xmm0, 0x20(%rsp)
movl %r15d, %edi
callq 0x3857b
movq %rax, %r12
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm2
addsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd %xmm0, 0x38(%rsp)
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x30(%rsp)
divsd %xmm0, %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, 0x8(%rsp)
leal (%r15,%r13), %ebp
decl %ebp
xorl %r13d, %r13d
xorl %ebx, %ebx
xorpd %xmm0, %xmm0
testl %r15d, %r15d
jle 0x9abd9
xorl %eax, %eax
movl (%r12,%rax,4), %ecx
xorl %edx, %edx
movl %ecx, %esi
subl %r15d, %esi
setge %dl
cmovll %ecx, %esi
movq (%r14,%rdx,8), %rcx
movslq %esi, %rdx
addsd (%rcx,%rdx,8), %xmm0
incq %rax
cmpq %rax, %r15
jne 0x9abb4
movsd 0x40(%rsp), %xmm1
subsd %xmm0, %xmm1
incl %r13d
divsd 0x38(%rsp), %xmm0
divsd 0x30(%rsp), %xmm1
subsd %xmm1, %xmm0
xorl %eax, %eax
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
seta %al
addl %eax, %ebx
movq %r12, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x38aaf
testl %eax, %eax
jne 0x9aba9
movq %r14, %rdi
movl $0x2, %esi
callq 0x3915f
leaq 0xe9c3(%rip), %rdi      # 0xa95ef
callq 0x5341c
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
divsd %xmm1, %xmm0
movq 0x28(%rsp), %rcx
movsd %xmm0, (%rcx)
cmpl $0x2, %eax
jne 0x9aca6
movsd 0x78c6(%rip), %xmm1     # 0xa2520
movsd 0x10(%rsp), %xmm2
addsd %xmm2, %xmm1
mulsd 0x80ac(%rip), %xmm1     # 0xa2d18
ucomisd %xmm0, %xmm1
jbe 0x9ac8e
movsd 0x78a6(%rip), %xmm1     # 0xa2520
subsd %xmm2, %xmm1
mulsd 0x8092(%rip), %xmm1     # 0xa2d18
xorl %eax, %eax
ucomisd %xmm1, %xmm0
ja 0x9acb5
movl $0x1, %eax
jmp 0x9acb5
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rbx)
xorl %eax, %eax
jmp 0x9acb5
xorl %eax, %eax
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq