// File: /workspace/github_c_makefile_star2_O2/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, %r14
leaq 0x30(%rsp), %rsi
callq 0x89dc2
testq %rax, %rax
je 0x8e12f
movq %rax, %r15
movq %r14, (%rsp)
movslq 0x30(%rsp), %r13
cmpl 0x34(%rsp), %r13d
jne 0x8e050
movq %rbx, 0x40(%rsp)
leaq (,%r13,8), %rdi
leaq 0x13d72(%rip), %rsi     # 0xa1d49
pushq $0xf
popq %rdx
callq 0x34f59
movq %rax, %r12
xorl %r14d, %r14d
testl %r13d, %r13d
movl $0x0, %ebp
movq %r13, 0x18(%rsp)
cmovgl %r13d, %ebp
xorpd %xmm1, %xmm1
leaq 0xa5f8(%rip), %r13      # 0x985f9
cmpq %r14, %rbp
movsd %xmm1, 0x10(%rsp)
je 0x8e06c
movq (%r15), %rax
movq 0x8(%r15), %rcx
movsd (%rax,%r14,8), %xmm0
subsd (%rcx,%r14,8), %xmm0
movsd %xmm0, (%r12,%r14,8)
leaq 0x1(%r14), %rbx
leaq 0x7780(%rip), %rdi      # 0x957b0
movl %ebx, %esi
pushq $0x1
popq %rdx
movq %r13, %rcx
movb $0x1, %al
callq 0x2f310
movsd 0x10(%rsp), %xmm1
addsd (%r12,%r14,8), %xmm1
movq %rbx, %r14
jmp 0x8e001
leaq 0x13e76(%rip), %rdi     # 0xa1ecd
callq 0x4090
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0x34fc3
jmp 0x8e13c
movq 0x18(%rsp), %r14
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
incl %eax
movq (%rsp), %rbx
movl %eax, (%rbx)
leaq 0xd994(%rip), %rdi      # 0x9ba2c
callq 0x4cff1
testl %eax, %eax
jne 0x8e0a8
pushq $0x3
popq %rax
subl (%rbx), %eax
movl %eax, (%rbx)
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
xorl %eax, %eax
movq 0x40(%rsp), %rbx
xorpd %xmm0, %xmm0
cmpq %rax, %rbp
je 0x8e0df
movsd (%r12,%rax,8), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm3
addsd %xmm3, %xmm0
incq %rax
jmp 0x8e0c3
decl %r14d
cvtsi2sd %r14d, %xmm3
divsd %xmm3, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
movsd %xmm1, 0x10(%rsp)
jb 0x8e101
sqrtsd %xmm0, %xmm0
jmp 0x8e106
callq 0x4300
movsd %xmm0, (%rsp)
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0x34fc3
movq %r12, %rdi
callq 0x34ff7
movsd (%rsp), %xmm0
ucomisd 0x7bed(%rip), %xmm0     # 0x95d18
jne 0x8e14d
jp 0x8e14d
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe48b(%rip), %rdi      # 0x9c5df
callq 0x4cd35
movsd 0x73bf(%rip), %xmm0     # 0x95520
subsd 0x20(%rsp), %xmm0
cmpl $0x1, %eax
jne 0x8e208
movl %r14d, %edi
callq 0x1ea02
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm1
sqrtsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
movsd %xmm0, 0x18(%rsp)
jae 0x8e1a3
movsd 0x8(%rsp), %xmm0
callq 0x4300
mulsd 0x10(%rsp), %xmm0
divsd (%rsp), %xmm0
movl %r14d, %edi
callq 0x1e9ba
movsd 0x7362(%rip), %xmm1     # 0x95520
subsd %xmm0, %xmm1
movsd %xmm1, (%rbx)
movsd 0x8(%rsp), %xmm0
ucomisd 0x7b44(%rip), %xmm0     # 0x95d18
movsd 0x18(%rsp), %xmm1
jae 0x8e1e5
callq 0x4300
movapd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
divsd (%rsp), %xmm0
xorl %eax, %eax
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %al
jmp 0x8e13e
mulsd 0x7b10(%rip), %xmm0     # 0x95d20
movsd %xmm0, 0x20(%rsp)
movl %r14d, %edi
callq 0x1ea02
movsd %xmm0, 0x38(%rsp)
movsd 0x20(%rsp), %xmm0
movl %r14d, %edi
callq 0x1ea02
xorps 0x7f97(%rip), %xmm0     # 0x961d0
movaps %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm1
sqrtsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
movsd %xmm0, 0x18(%rsp)
jae 0x8e263
movsd 0x8(%rsp), %xmm0
callq 0x4300
mulsd 0x10(%rsp), %xmm0
divsd (%rsp), %xmm0
andpd 0x7f6a(%rip), %xmm0     # 0x961e0
movl %r14d, %edi
callq 0x1e9ba
movsd 0x729a(%rip), %xmm1     # 0x95520
subsd %xmm0, %xmm1
movsd %xmm1, (%rbx)
movsd 0x8(%rsp), %xmm2
ucomisd 0x7a7c(%rip), %xmm2     # 0x95d18
movsd 0x18(%rsp), %xmm0
jae 0x8e2b3
movapd %xmm2, %xmm0
callq 0x4300
movsd 0x8(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd (%rsp), %xmm3
divsd %xmm3, %xmm0
ucomisd 0x20(%rsp), %xmm0
jbe 0x8e30c
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0x8e2de
sqrtsd %xmm2, %xmm0
jmp 0x8e2f2
movapd %xmm2, %xmm0
callq 0x4300
movsd (%rsp), %xmm3
movsd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
divsd %xmm3, %xmm1
xorl %eax, %eax
movsd 0x38(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x8e13e
pushq $0x1
popq %rax
jmp 0x8e13e