// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/tests.c
// Function: ttestpaired
int ttestpaired(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 counts[2], i, df;
 double **observations, *difference, sum, upper, lower, mean, variance;
 observations = read_observations_for_two_file(files, counts);
 if (!observations)
  {
   *real_confidence = 0.5;
   return 0;
  }
 if (counts[0] != counts[1])
  {
   printf(m1315);
   free_2d((void**)observations, 2);
   return 0;
  }
 difference = (double *)safemalloc(counts[0] * sizeof(double), "ttestcv", 15);
 sum = 0;
 for (i = 0; i < counts[0]; i++)
  {
   difference[i] = observations[0][i] - observations[1][i];
   write_array_variables("aout", i + 1, 1, "f", difference[i]);
   sum += difference[i];
  }
 mean = sum / counts[0];
 if (sum > 0)
   (*which) = 1;
 else
   (*which) = 2;
 if (!get_parameter_o("accuracy")) 
   (*which) = 3 - (*which);       
 sum = 0;
 for (i = 0; i < counts[0]; i++)
   sum += (difference[i] - mean) * (difference[i] - mean);
 df = counts[0] - 1;
 variance = sqrt(sum / df);
 free_2d((void**)observations, 2);
 safe_free(difference);
 if (variance == 0)
  {
  (*real_confidence) = 0.5;
   return 0;
  }
 if (get_parameter_i("tailed") == 1)
  {
   upper = t_distribution_inverse(1 - confidence, df);
   (*real_confidence) = 1.0 - t_distribution(sqrt(counts[0]) * mean / variance, df);
   if ((sqrt(counts[0]) * mean / variance) < upper)
     return 0;
   else
     return 1;
  }
 else
  {
   upper = t_distribution_inverse((1 - confidence) / 2, df);
   lower = -t_distribution_inverse((1 - confidence) / 2, df);
   (*real_confidence) = 1.0 - t_distribution(fabs(sqrt(counts[0]) * mean / variance), df);
   if ((sqrt(counts[0]) * mean / variance) > lower && (sqrt(counts[0]) * mean / variance) < upper)
     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, 0x20(%rsp)
movq %rsi, %r15
leaq 0x38(%rsp), %rsi
callq 0x98796
testq %rax, %rax
je 0x9d228
movq %rax, %r14
movl 0x38(%rsp), %r12d
cmpl 0x3c(%rsp), %r12d
jne 0x9d237
movq %r15, 0x18(%rsp)
movq %rbx, 0x30(%rsp)
movslq %r12d, %rax
movq %rax, (%rsp)
leaq (,%rax,8), %rdi
leaq 0x14cd5(%rip), %rsi     # 0xb1df1
movl $0xf, %edx
callq 0x3a0e1
movq %rax, %r15
xorpd %xmm0, %xmm0
testl %r12d, %r12d
jle 0x9d189
xorl %ebx, %ebx
leaq 0xb53e(%rip), %rbp      # 0xa8679
movsd %xmm0, 0x8(%rsp)
movq (%r14), %rax
movq 0x8(%r14), %rcx
movsd (%rax,%rbx,8), %xmm0
subsd (%rcx,%rbx,8), %xmm0
movsd %xmm0, (%r15,%rbx,8)
leaq 0x1(%rbx), %r13
leaq 0x864d(%rip), %rdi      # 0xa57b0
movl %r13d, %esi
movl $0x1, %edx
movq %rbp, %rcx
movb $0x1, %al
callq 0x33644
movsd 0x8(%rsp), %xmm0
addsd (%r15,%rbx,8), %xmm0
movq %r13, %rbx
cmpq %r13, %r12
jne 0x9d13b
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %r12d, %xmm1
movsd %xmm1, 0x10(%rsp)
xorl %eax, %eax
ucomisd 0x8b64(%rip), %xmm0     # 0xa5d08
setbe %al
incl %eax
movq 0x18(%rsp), %rbx
movl %eax, (%rbx)
leaq 0xe951(%rip), %rdi      # 0xabb08
callq 0x54bec
testl %eax, %eax
jne 0x9d1c9
movl $0x3, %eax
subl (%rbx), %eax
movl %eax, (%rbx)
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm3
divsd %xmm0, %xmm3
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
testl %r12d, %r12d
movq (%rsp), %rcx
jle 0x9d206
xorl %eax, %eax
movsd (%r15,%rax,8), %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rax
cmpq %rax, %rcx
jne 0x9d1ec
leal -0x1(%r12), %ebp
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
movsd %xmm3, 0x8(%rsp)
jb 0x9d252
sqrtsd %xmm0, %xmm0
jmp 0x9d257
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rbx)
jmp 0x9d294
leaq 0x14d37(%rip), %rdi     # 0xb1f75
callq 0x4090
movq %r14, %rdi
movl $0x2, %esi
callq 0x3a14b
jmp 0x9d294
callq 0x4300
movsd %xmm0, (%rsp)
movq %r14, %rdi
movl $0x2, %esi
callq 0x3a14b
movq %r15, %rdi
callq 0x3a180
xorpd %xmm0, %xmm0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x9d2a5
jp 0x9d2a5
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq 0x30(%rsp), %rcx
movq %rax, (%rcx)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf40f(%rip), %rdi      # 0xac6bb
callq 0x54920
movsd 0x8267(%rip), %xmm0     # 0xa5520
subsd 0x20(%rsp), %xmm0
cmpl $0x1, %eax
jne 0x9d366
movl %ebp, %edi
callq 0x21056
movsd %xmm0, 0x20(%rsp)
movsd 0x10(%rsp), %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
movsd %xmm0, 0x18(%rsp)
jae 0x9d2fd
movsd 0x10(%rsp), %xmm0
callq 0x4300
mulsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
movl %ebp, %edi
callq 0x2100c
movsd 0x8209(%rip), %xmm1     # 0xa5520
subsd %xmm0, %xmm1
movq 0x30(%rsp), %rax
movsd %xmm1, (%rax)
movsd 0x10(%rsp), %xmm0
ucomisd 0x89d6(%rip), %xmm0     # 0xa5d08
movsd 0x18(%rsp), %xmm1
jae 0x9d343
callq 0x4300
movapd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
divsd (%rsp), %xmm0
xorl %eax, %eax
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %al
jmp 0x9d296
mulsd 0x89aa(%rip), %xmm0     # 0xa5d18
movsd %xmm0, 0x20(%rsp)
movl %ebp, %edi
callq 0x21056
movsd %xmm0, 0x40(%rsp)
movsd 0x20(%rsp), %xmm0
movl %ebp, %edi
callq 0x21056
xorps 0x8e3b(%rip), %xmm0     # 0xa61d0
movaps %xmm0, 0x20(%rsp)
movsd 0x10(%rsp), %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
movsd %xmm0, 0x18(%rsp)
jae 0x9d3c2
movsd 0x10(%rsp), %xmm0
callq 0x4300
mulsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
andpd 0x8e0b(%rip), %xmm0     # 0xa61e0
movl %ebp, %edi
callq 0x2100c
movsd 0x813c(%rip), %xmm1     # 0xa5520
subsd %xmm0, %xmm1
movq 0x30(%rsp), %rax
movsd %xmm1, (%rax)
movsd 0x10(%rsp), %xmm2
ucomisd 0x8909(%rip), %xmm2     # 0xa5d08
movsd 0x18(%rsp), %xmm0
jae 0x9d416
movapd %xmm2, %xmm0
callq 0x4300
movsd 0x10(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd (%rsp), %xmm3
divsd %xmm3, %xmm0
ucomisd 0x20(%rsp), %xmm0
jbe 0x9d472
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0x9d444
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x9d458
movapd %xmm2, %xmm0
callq 0x4300
movsd (%rsp), %xmm3
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
divsd %xmm3, %xmm1
xorl %eax, %eax
movsd 0x40(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x9d296
movl $0x1, %eax
jmp 0x9d296