// File: /workspace/github_c_makefile_star2_O1/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 0x95b63
testq %rax, %rax
je 0x9a2b2
movq %rax, %r14
movl 0x38(%rsp), %r12d
cmpl 0x3c(%rsp), %r12d
jne 0x9a2c1
movq %r15, 0x18(%rsp)
movq %rbx, 0x30(%rsp)
movslq %r12d, %rax
movq %rax, (%rsp)
leaq (,%rax,8), %rdi
leaq 0x14bcb(%rip), %rsi     # 0xaed71
movl $0xf, %edx
callq 0x390f5
movq %rax, %r15
xorpd %xmm0, %xmm0
testl %r12d, %r12d
jle 0x9a213
xorl %ebx, %ebx
leaq 0xb45c(%rip), %rbp      # 0xa5621
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 0x85c3(%rip), %rdi      # 0xa27b0
movl %r13d, %esi
movl $0x1, %edx
movq %rbp, %rcx
movb $0x1, %al
callq 0x32c64
movsd 0x8(%rsp), %xmm0
addsd (%r15,%rbx,8), %xmm0
movq %r13, %rbx
cmpq %r13, %r12
jne 0x9a1c5
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %r12d, %xmm1
movsd %xmm1, 0x10(%rsp)
xorl %eax, %eax
ucomisd 0x8ada(%rip), %xmm0     # 0xa2d08
setbe %al
incl %eax
movq 0x18(%rsp), %rbx
movl %eax, (%rbx)
leaq 0xe7fb(%rip), %rdi      # 0xa8a3c
callq 0x536e7
testl %eax, %eax
jne 0x9a253
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 0x9a290
xorl %eax, %eax
movsd (%r15,%rax,8), %xmm2
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm2
addsd %xmm2, %xmm0
incq %rax
cmpq %rax, %rcx
jne 0x9a276
leal -0x1(%r12), %ebp
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
movsd %xmm3, 0x8(%rsp)
jb 0x9a2dc
sqrtsd %xmm0, %xmm0
jmp 0x9a2e1
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rbx)
jmp 0x9a31e
leaq 0x14c2d(%rip), %rdi     # 0xaeef5
callq 0x4090
movq %r14, %rdi
movl $0x2, %esi
callq 0x3915f
jmp 0x9a31e
callq 0x4300
movsd %xmm0, (%rsp)
movq %r14, %rdi
movl $0x2, %esi
callq 0x3915f
movq %r15, %rdi
callq 0x39194
xorpd %xmm0, %xmm0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x9a32f
jp 0x9a32f
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 0xf2b9(%rip), %rdi      # 0xa95ef
callq 0x5341c
movsd 0x81dd(%rip), %xmm0     # 0xa2520
subsd 0x20(%rsp), %xmm0
cmpl $0x1, %eax
jne 0x9a3f0
movl %ebp, %edi
callq 0x208dc
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 0x9a387
movsd 0x10(%rsp), %xmm0
callq 0x4300
mulsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
movl %ebp, %edi
callq 0x20892
movsd 0x817f(%rip), %xmm1     # 0xa2520
subsd %xmm0, %xmm1
movq 0x30(%rsp), %rax
movsd %xmm1, (%rax)
movsd 0x10(%rsp), %xmm0
ucomisd 0x894c(%rip), %xmm0     # 0xa2d08
movsd 0x18(%rsp), %xmm1
jae 0x9a3cd
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 0x9a320
mulsd 0x8920(%rip), %xmm0     # 0xa2d18
movsd %xmm0, 0x20(%rsp)
movl %ebp, %edi
callq 0x208dc
movsd %xmm0, 0x40(%rsp)
movsd 0x20(%rsp), %xmm0
movl %ebp, %edi
callq 0x208dc
xorps 0x8db1(%rip), %xmm0     # 0xa31d0
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 0x9a44c
movsd 0x10(%rsp), %xmm0
callq 0x4300
mulsd 0x8(%rsp), %xmm0
divsd (%rsp), %xmm0
andpd 0x8d81(%rip), %xmm0     # 0xa31e0
movl %ebp, %edi
callq 0x20892
movsd 0x80b2(%rip), %xmm1     # 0xa2520
subsd %xmm0, %xmm1
movq 0x30(%rsp), %rax
movsd %xmm1, (%rax)
movsd 0x10(%rsp), %xmm2
ucomisd 0x887f(%rip), %xmm2     # 0xa2d08
movsd 0x18(%rsp), %xmm0
jae 0x9a4a0
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 0x9a4fc
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0x9a4ce
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x9a4e2
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 0x9a320
movl $0x1, %eax
jmp 0x9a320