// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %rdx, 0x50(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %rdi, %r15
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x37e22
movl %eax, 0x10(%rsp,%rbx,4)
incq %rbx
cmpq $0x1, %rbx
je 0x9af51
movslq 0x10(%rsp), %rax
movl %eax, %ecx
movq %rcx, 0x48(%rsp)
movslq 0x14(%rsp), %rdi
addq %rax, %rdi
movq %rdi, 0x38(%rsp)
shlq $0x5, %rdi
leaq 0x13e1d(%rip), %rsi     # 0xaeda8
movl $0x7, %edx
callq 0x390f5
movq %rax, 0x40(%rsp)
addq $0x18, %rax
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %r14
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r15, 0x8(%rsp)
movq (%r15,%rbp,8), %rdi
leaq 0xd8d2(%rip), %rsi      # 0xa888f
callq 0x40f0
testq %rax, %rax
je 0x9b17e
movq %rax, %rbx
movq %rbp, %r13
movl 0x10(%rsp,%rbp,4), %r15d
testl %r15d, %r15d
jle 0x9b022
movslq %r12d, %rbp
shlq $0x5, %rbp
addq 0x58(%rsp), %rbp
movq %rbx, %rdi
leaq 0xbc1f(%rip), %rsi      # 0xa6c10
movq %r14, %rdx
xorl %eax, %eax
callq 0x4070
movsd 0x60(%rsp), %xmm0
movsd %xmm0, -0x10(%rbp)
movl %r13d, -0x18(%rbp)
movq $0x0, -0x8(%rbp)
movl %r12d, (%rbp)
addq $0x20, %rbp
incl %r12d
decl %r15d
jne 0x9afe7
movq %rbx, %rdi
callq 0x42a0
leaq 0x1(%r13), %rbp
testq %r13, %r13
movq 0x8(%rsp), %r15
je 0x9afb2
movslq %r12d, %rbx
leaq -0x61a21(%rip), %rcx    # 0x39625
movl $0x20, %edx
movq 0x40(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4240
movq %r13, %rdi
movl %ebx, %esi
callq 0x95260
testl %ebx, %ebx
jle 0x9b093
movl %r12d, %eax
shlq $0x5, %rax
xorl %ecx, %ecx
movsd 0x10(%r13,%rcx), %xmm0
movslq (%r13,%rcx), %rdx
addsd 0x20(%rsp,%rdx,8), %xmm0
movsd %xmm0, 0x20(%rsp,%rdx,8)
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x9b072
movq 0x48(%rsp), %r15
movl %r15d, %edi
callq 0x3857b
movq %rax, %rbx
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x38(%rsp), %rax
leal -0x1(%rax), %ebp
xorl %r14d, %r14d
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
testl %r15d, %r15d
jle 0x9b0df
xorl %eax, %eax
movslq (%rbx,%rax,4), %rcx
shlq $0x5, %rcx
addsd 0x10(%r13,%rcx), %xmm0
incq %rax
cmpq %rax, %r15
jne 0x9b0c8
xorl %eax, %eax
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
seta %al
addl %eax, %r14d
incl %r12d
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x38aaf
testl %eax, %eax
jne 0x9b0bd
movq %r13, %rdi
callq 0x39194
leaq 0xe4db(%rip), %rdi      # 0xa95ef
callq 0x5341c
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
divsd %xmm1, %xmm0
movq 0x50(%rsp), %rcx
movsd %xmm0, (%rcx)
cmpl $0x2, %eax
jne 0x9b194
movsd 0x73dd(%rip), %xmm1     # 0xa2520
movsd 0x18(%rsp), %xmm2
addsd %xmm2, %xmm1
mulsd 0x7bc3(%rip), %xmm1     # 0xa2d18
ucomisd %xmm0, %xmm1
jbe 0x9b177
movsd 0x73bd(%rip), %xmm1     # 0xa2520
subsd %xmm2, %xmm1
mulsd 0x7ba9(%rip), %xmm1     # 0xa2d18
xorl %ebx, %ebx
ucomisd %xmm1, %xmm0
ja 0x9b1a3
movl $0x1, %ebx
jmp 0x9b1a3
movq (%r15,%rbp,8), %rsi
leaq 0x8081(%rip), %rdi      # 0xa320a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4030
jmp 0x9b1a3
xorl %ebx, %ebx
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %bl
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq