// File: /workspace/github_c_makefile_star2_O3/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, 0x48(%rsp)
movsd %xmm0, 0x20(%rsp)
movq %rdi, %r14
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq (%rdi), %rdi
callq 0x38a4a
movl %eax, %ebx
leaq 0x64(%rsp), %r13
movl %eax, (%r13)
movq %r14, 0x28(%rsp)
movq 0x8(%r14), %rdi
callq 0x38a4a
leaq 0x1c(%rsp), %rcx
movl %eax, (%rcx)
movl %ebx, 0x4(%rsp)
addl %ebx, %eax
movl %eax, (%rsp)
movslq %eax, %rdi
shlq $0x5, %rdi
leaq 0x13ec4(%rip), %rsi     # 0xb1e28
movl $0x7, %edx
callq 0x3a0e1
movq %rax, 0x8(%rsp)
addq $0x18, %rax
movq %rax, 0x50(%rsp)
movb $0x1, %r15b
leaq 0x58(%rsp), %rbp
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %r13, %rbx
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rdi
leaq 0xd9be(%rip), %rsi      # 0xab95b
callq 0x40f0
testq %rax, %rax
je 0x9e094
movq %rax, %r13
movl %r15d, 0x10(%rsp)
movl (%rbx), %ebx
testl %ebx, %ebx
jle 0x9dfff
movslq %r12d, %r15
shlq $0x5, %r15
addq 0x50(%rsp), %r15
movq %r13, %rdi
leaq 0xbcb1(%rip), %rsi      # 0xa9c80
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4070
movsd 0x58(%rsp), %xmm0
movsd %xmm0, -0x10(%r15)
movl %r14d, -0x18(%r15)
movq $0x0, -0x8(%r15)
movl %r12d, (%r15)
addq $0x20, %r15
incl %r12d
decl %ebx
jne 0x9dfc5
movq %r13, %rdi
callq 0x42a0
movl $0x1, %r14d
leaq 0x1c(%rsp), %r13
testb $0x1, 0x10(%rsp)
movl $0x0, %r15d
jne 0x9df8a
movslq %r12d, %rbx
leaq -0x639fc(%rip), %rcx    # 0x3a631
movl $0x20, %edx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4240
movq %r14, %rdi
movl %ebx, %esi
callq 0x97e0c
testl %ebx, %ebx
jle 0x9e0b2
movl %r12d, %eax
shlq $0x5, %rax
xorl %ecx, %ecx
movl 0x4(%rsp), %r15d
movl (%rsp), %r13d
movq 0x8(%rsp), %rsi
movsd 0x10(%rsi,%rcx), %xmm0
movslq (%rsi,%rcx), %rdx
addsd 0x30(%rsp,%rdx,8), %xmm0
movsd %xmm0, 0x30(%rsp,%rdx,8)
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x9e067
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x9e0c5
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rsi
leaq 0x8166(%rip), %rdi      # 0xa620a
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x4030
jmp 0x9e1b0
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x4(%rsp), %r15d
movl (%rsp), %r13d
movl %r15d, %edi
callq 0x391d6
movq %rax, %rbx
decl %r13d
movl %r15d, %r12d
xorl %r14d, %r14d
xorl %ebp, %ebp
testl %r15d, %r15d
movq 0x8(%rsp), %rdx
xorpd %xmm0, %xmm0
jle 0x9e101
xorl %eax, %eax
movslq (%rbx,%rax,4), %rcx
shlq $0x5, %rcx
addsd 0x10(%rdx,%rcx), %xmm0
incq %rax
cmpq %rax, %r12
jne 0x9e0eb
xorl %eax, %eax
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
seta %al
addl %eax, %r14d
incl %ebp
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x39814
testl %eax, %eax
jne 0x9e0db
movq 0x8(%rsp), %rdi
callq 0x3a180
leaq 0xe583(%rip), %rdi      # 0xac6bb
callq 0x54920
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
divsd %xmm1, %xmm0
movq 0x48(%rsp), %rcx
movsd %xmm0, (%rcx)
cmpl $0x2, %eax
jne 0x9e1a1
movsd 0x73ba(%rip), %xmm1     # 0xa5520
movsd 0x20(%rsp), %xmm2
addsd %xmm2, %xmm1
mulsd 0x7ba0(%rip), %xmm1     # 0xa5d18
ucomisd %xmm0, %xmm1
jbe 0x9e19a
movsd 0x739a(%rip), %xmm1     # 0xa5520
subsd %xmm2, %xmm1
mulsd 0x7b86(%rip), %xmm1     # 0xa5d18
xorl %ebx, %ebx
ucomisd %xmm1, %xmm0
ja 0x9e1b0
movl $0x1, %ebx
jmp 0x9e1b0
xorl %ebx, %ebx
movsd 0x20(%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
nopl (%rax)