// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2f816
movq %r15, %rdi
callq 0x633d7
movaps %xmm0, 0x20(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x2b43c
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2f816
movq %r15, %rdi
callq 0x633d7
movaps %xmm0, 0x10(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x2b43c
movq (%rbx), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rbx), %rbp
movq (%r14), %r13
movq 0x8(%r14), %r12
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2f816
movq %r15, %rdi
callq 0x2f7e9
movsd %xmm0, (%rsp)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x2f816
movapd 0x20(%rsp), %xmm0
unpcklpd 0x10(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm3
movapd %xmm0, 0x20(%rsp)
movq %r12, %xmm0
movq %rbp, %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %r13, %xmm0
movq 0x30(%rsp), %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
psubq %xmm2, %xmm1
movdqa %xmm1, %xmm0
psrad $0x3, %xmm0
psrlq $0x3, %xmm1
pand 0x3c1bf(%rip), %xmm1    # 0x9f050
por 0x3c1c7(%rip), %xmm1    # 0x9f060
psrlq $0x20, %xmm0
por 0x3c1ca(%rip), %xmm0    # 0x9f070
subpd 0x3c1d2(%rip), %xmm0    # 0x9f080
addpd %xmm1, %xmm0
movapd %xmm3, %xmm1
divpd %xmm0, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x2f7e9
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
subsd 0x8(%rsp), %xmm1
divsd 0x10(%rsp), %xmm1
movsd %xmm1, (%rsp)
movq %r15, %rdi
callq 0x2b43c
leaq 0x50(%rsp), %rdi
callq 0x2b43c
movq 0x8(%r14), %xmm0
movq 0x8(%rbx), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq (%r14), %xmm0
movq (%rbx), %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
psubq %xmm2, %xmm1
movdqa %xmm1, %xmm0
psrad $0x3, %xmm0
pshufd $0xed, %xmm0, %xmm2     # xmm2 = xmm0[1,3,2,3]
psrlq $0x3, %xmm1
pshufd $0xe8, %xmm1, %xmm3     # xmm3 = xmm1[0,2,2,3]
punpckldq %xmm2, %xmm3    # xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
movdqa 0x3c103(%rip), %xmm4    # 0x9f050
pand %xmm4, %xmm1
movdqa 0x3c107(%rip), %xmm5    # 0x9f060
por %xmm5, %xmm1
psrlq $0x20, %xmm0
movdqa 0x3c106(%rip), %xmm6    # 0x9f070
por %xmm6, %xmm0
movapd 0x3c10a(%rip), %xmm7    # 0x9f080
subpd %xmm7, %xmm0
addpd %xmm1, %xmm0
movapd 0x20(%rsp), %xmm1
divpd %xmm0, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
mulpd %xmm1, %xmm1
movapd %xmm1, %xmm2
pcmpeqd %xmm1, %xmm1
paddq %xmm3, %xmm1
movdqa %xmm4, %xmm3
pand %xmm1, %xmm3
por %xmm5, %xmm3
psrlq $0x20, %xmm1
por %xmm6, %xmm1
subpd %xmm7, %xmm1
addpd %xmm3, %xmm1
divpd %xmm1, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd (%rsp), %xmm1
callq 0x63481
movsd 0x34605(%rip), %xmm1    # 0x975f0
subsd %xmm0, %xmm1
addsd %xmm0, %xmm0
xorpd %xmm2, %xmm2
cmpeqsd 0x8(%rsp), %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm2, %xmm0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x63020
jmp 0x63020
movq %rax, %rbx
movq %r15, %rdi
callq 0x2b43c
movq %rbx, %rdi
callq 0x8870