// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/./process_vcf_stats_utils.h
// Function: double two_sample_t<std::vector<double, std::allocator<double>>>(std::vector<double, std::allocator<double>>, std::vector<double, std::allocator<double>>, double)
double two_sample_t(T vector1, T vector2, double d = 0) {
    double variance1 = pow(std_dev(vector1), 2.0);
    double variance2 = pow(std_dev(vector2), 2.0);
    double SE = sqrt((variance1/vector1.size())+(variance2/vector2.size()));
    double t = ((vector_average(vector1)-vector_average(vector2)) - d)/SE;
    // DF = (s1^2/n1 + s2^2/n2)^2/{ [ (s1^2 / n1)^2 / (n1 - 1) ] + [ (s2^2 / n2)^2 / (n2 - 1) ] }
    double DFnumerator = pow((variance1/vector1.size())+(variance2/vector2.size()), 2.0);
    double DFdenominatorPt1 = pow(variance1/vector1.size(), 2.0) / (vector1.size() - 1);
    double DFdenominatorPt2 = pow(variance2/vector2.size(), 2.0) / (vector2.size() - 1);
    double DF = DFnumerator/(DFdenominatorPt1 + DFdenominatorPt2);
    
   // std::cerr << "t-stat: " << t << std::endl;
   // std::cerr << "DF: " << DF << std::endl;
    
    if (d == 0) {
        // alternative hypothesis: true difference in means is not equal to 0
        return 2*students_t_cdf(DF, t);
    } else {
        // alternative hypothesis: true difference in means is greater than d
        return 1-students_t_cdf(DF, t);
    }
    
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm0, 0x30(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3a864
movq %r15, %rdi
callq 0x82bdc
movsd %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x8227e
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x60(%rsp), %r12
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3a864
movq %r15, %rdi
callq 0x82bdc
movapd %xmm0, %xmm3
movsd 0x10(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
mulsd %xmm3, %xmm3
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
movsd %xmm3, 0x28(%rsp)
je 0x822d6
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movsd 0x28(%rsp), %xmm3
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
movq %rax, %xmm0
movq 0x47eb2(%rip), %xmm4    # 0xca1a0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
movapd 0x47eb6(%rip), %xmm5    # 0xca1b0
subpd %xmm5, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm2
divsd %xmm1, %xmm2
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
movq %rax, %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm5, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm3, %xmm0
divsd %xmm1, %xmm0
addsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x82354
sqrtsd %xmm0, %xmm0
jmp 0x82359
callq 0x83a0
movsd %xmm0, 0x20(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3a864
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %r15
subq %rax, %r15
sarq $0x3, %r15
cmpq %rax, %rcx
xorpd %xmm0, %xmm0
je 0x823a3
cmpq $0x1, %r15
movq %r15, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
addsd (%rax,%rdx,8), %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x82396
movsd %xmm0, (%rsp)
leaq 0x48(%rsp), %r12
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
callq 0x3a864
movq %r15, %xmm0
punpckldq 0x47dd6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x47dde(%rip), %xmm0    # 0xca1b0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd (%rsp), %xmm7
divsd %xmm1, %xmm7
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rcx
movq %rcx, %rax
subq %rdi, %rax
sarq $0x3, %rax
cmpq %rdi, %rcx
je 0x82426
cmpq $0x1, %rax
movq %rax, %rcx
adcq $0x0, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
addsd (%rdi,%rdx,8), %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x82417
jmp 0x8242a
xorpd %xmm0, %xmm0
movq %rax, %xmm1
punpckldq 0x47d69(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x47d71(%rip), %xmm1    # 0xca1b0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
subsd %xmm0, %xmm7
testq %rdi, %rdi
je 0x82472
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
movsd %xmm7, (%rsp)
callq 0x8480
movsd (%rsp), %xmm7
subsd 0x30(%rsp), %xmm7
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x82499
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
movsd %xmm7, (%rsp)
callq 0x8480
movsd (%rsp), %xmm7
divsd 0x20(%rsp), %xmm7
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
movq %rax, %xmm0
movq 0x47ce9(%rip), %xmm5    # 0xca1a0
punpckldq %xmm5, %xmm0    # xmm0 = xmm0[0],xmm5[0],xmm0[1],xmm5[1]
movapd 0x47ced(%rip), %xmm6    # 0xca1b0
subpd %xmm6, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm3
divsd %xmm1, %xmm3
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
sarq $0x3, %rcx
movq %rcx, %xmm0
punpckldq %xmm5, %xmm0    # xmm0 = xmm0[0],xmm5[0],xmm0[1],xmm5[1]
subpd %xmm6, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm4
divsd %xmm1, %xmm4
movapd %xmm3, %xmm0
addsd %xmm4, %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm3, %xmm3
decq %rax
movq %rax, %xmm1
punpckldq %xmm5, %xmm1    # xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
subpd %xmm6, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm3
mulsd %xmm4, %xmm4
decq %rcx
movq %rcx, %xmm1
punpckldq %xmm5, %xmm1    # xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
subpd %xmm6, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm4
addsd %xmm3, %xmm4
divsd %xmm4, %xmm0
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm2
ucomisd %xmm1, %xmm2
jne 0x825b8
jp 0x825b8
ucomisd %xmm1, %xmm0
movsd %xmm7, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
ja 0x825a3
leaq 0x5d2aa(%rip), %rdi     # 0xdf83c
leaq 0x5d2e6(%rip), %rsi     # 0xdf87f
leaq 0x8(%rsp), %rdx
callq 0x5523c
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x82cfc
addsd %xmm0, %xmm0
jmp 0x82601
ucomisd %xmm1, %xmm0
movsd %xmm7, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
ja 0x825e2
leaq 0x5d26b(%rip), %rdi     # 0xdf83c
leaq 0x5d2a7(%rip), %rsi     # 0xdf87f
leaq 0x8(%rsp), %rdx
callq 0x5523c
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x82cfc
movapd %xmm0, %xmm1
movsd 0x4ce43(%rip), %xmm0    # 0xcf440
subsd %xmm1, %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x82622
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
jne 0x8263b
jmp 0x82647
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x82647
leaq 0x78(%rsp), %r12
movq (%r12), %rsi
subq %rdi, %rsi
callq 0x8480
movq %rbx, %rdi
callq 0x8840