// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/tests.c
// Function: rank_sum_test
int rank_sum_test(char **files, int *which, double confidence, double *real_confidence)
{
 /*Last Changed 02.02.2004 added safemalloc Added alpha/2 levels*/
 /*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.*/
 /*Last Changed 30.01.2002*/
 FILE *myfile;
 int i, j, counts[2], k, count, total, *combination;
 double T[2] = {0}, tmp, current;
 Obs *obs;
 for (i = 0; i < 2; i++)
   counts[i] = file_length(files[i]);
 obs = (Obs *)safemalloc((counts[0] + counts[1]) * sizeof(Obs), "rank_sum_test", 7);
 k = 0;
 for (i = 0; i < 2; i++)
  {
   if ((myfile = fopen(files[i], "r")) == NULL)
    {
     printf(m1274, files[i]);
     return 0;
    }
   for (j = 0; j < counts[i]; j++)
    {
     fscanf(myfile, "%lf", &tmp);
     obs[k].observation = tmp;
     obs[k].observation_no = i;
     obs[k].rij = 0;
     obs[k].index = k;
     k++;
    }
   fclose(myfile);
  }
 qsort(obs, k, sizeof(Obs), sort_function_observation_ascending);
 assign_ranks_to_observations(obs, k);
 for (i = 0; i < k; i++)
   T[obs[i].observation_no] += obs[i].rij;
 count = 0;
 total = 0;
 combination = first_combination(counts[0]);
 do{
   current = 0;
   for (i = 0; i < counts[0]; i++)
     current += obs[combination[i]].rij;
   if (T[0] > current)
     count++;
   total++;
 }while (next_combination(combination, counts[0], counts[0] + counts[1] - 1)); 
 safe_free(obs);
 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/*one tailed*/
  {
   (*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 $0x58, %rsp
movq %rdx, 0x38(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rdi, %rbp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
cmpq $0x2, %rbx
je 0x8ed41
movq (%rbp,%rbx,8), %rdi
callq 0x33f62
movl %eax, 0x8(%rsp,%rbx,4)
incq %rbx
jmp 0x8ed28
movslq 0x8(%rsp), %rax
movslq 0xc(%rsp), %rdi
movq %rax, 0x18(%rsp)
addq %rax, %rdi
movq %rdi, 0x30(%rsp)
shlq $0x5, %rdi
leaq 0x1301d(%rip), %rsi     # 0xa1d80
pushq $0x7
popq %rdx
callq 0x34f59
movq %rax, %r15
addq $0x18, %rax
movq %rax, 0x40(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %rbp, 0x48(%rsp)
movslq %ebx, %r13
cmpq $0x2, %r12
je 0x8ee24
movq (%rbp,%r12,8), %rdi
leaq 0xcae5(%rip), %rsi      # 0x9b87f
callq 0x40f0
testq %rax, %rax
je 0x8ef60
movq %rax, %r14
movl 0x8(%rsp,%r12,4), %ecx
testl %ecx, %ecx
movl $0x0, %eax
cmovlel %eax, %ecx
addl %r13d, %ecx
movl %ecx, (%rsp)
movslq %ecx, %rbp
subq %r13, %rbp
shlq $0x5, %r13
addq 0x40(%rsp), %r13
subq $0x1, %rbp
jb 0x8ee0c
movq %r14, %rdi
leaq 0xadc9(%rip), %rsi      # 0x99ba8
leaq 0x50(%rsp), %rdx
xorl %eax, %eax
callq 0x4070
movsd 0x50(%rsp), %xmm0
movsd %xmm0, -0x10(%r13)
movl %r12d, -0x18(%r13)
andq $0x0, -0x8(%r13)
movl %ebx, (%r13)
incl %ebx
addq $0x20, %r13
jmp 0x8edcf
movq %r14, %rdi
callq 0x42a0
incq %r12
movl (%rsp), %ebx
movq 0x48(%rsp), %rbp
jmp 0x8ed81
leaq -0x59a32(%rip), %rcx    # 0x353f9
pushq $0x20
popq %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x4240
movq %r15, %rdi
movl %r13d, %esi
callq 0x89558
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
shlq $0x5, %r13
cmpq %rax, %r13
je 0x8ee73
movsd 0x10(%r15,%rax), %xmm0
movslq (%r15,%rax), %rcx
addsd 0x20(%rsp,%rcx,8), %xmm0
movsd %xmm0, 0x20(%rsp,%rcx,8)
addq $0x20, %rax
jmp 0x8ee51
movq 0x18(%rsp), %r12
movl %r12d, %edi
callq 0x34598
movq %rax, %rbx
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq 0x30(%rsp), %rax
leal -0x1(%rax), %ebp
xorl %r14d, %r14d
testl %r12d, %r12d
movl $0x0, %r13d
cmovgl %r12d, %r13d
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq %rax, %r13
je 0x8eec8
movslq (%rbx,%rax,4), %rcx
shlq $0x5, %rcx
addsd 0x10(%r15,%rcx), %xmm0
incq %rax
jmp 0x8eeaf
xorl %eax, %eax
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
seta %al
addl %eax, %r14d
incl %r12d
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movl %ebp, %edx
callq 0x349ff
testl %eax, %eax
jne 0x8eea9
movq %r15, %rdi
callq 0x34ff7
leaq 0xd6e1(%rip), %rdi      # 0x9c5df
callq 0x4cd35
cvtsi2sd %r14d, %xmm0
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm0
movq 0x38(%rsp), %rcx
movsd %xmm0, (%rcx)
cmpl $0x2, %eax
jne 0x8ef77
movsd 0x65f9(%rip), %xmm1     # 0x95520
movsd 0x10(%rsp), %xmm2
addsd %xmm2, %xmm1
mulsd 0x6de7(%rip), %xmm1     # 0x95d20
ucomisd %xmm0, %xmm1
jbe 0x8ef5b
movsd 0x65d9(%rip), %xmm1     # 0x95520
subsd %xmm2, %xmm1
mulsd 0x6dcd(%rip), %xmm1     # 0x95d20
xorl %ebx, %ebx
ucomisd %xmm1, %xmm0
ja 0x8ef86
pushq $0x1
popq %rbx
jmp 0x8ef86
movq (%rbp,%r12,8), %rsi
leaq 0x729e(%rip), %rdi      # 0x9620a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4030
jmp 0x8ef86
xorl %ebx, %ebx
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %bl
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop