// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movsd %xmm0, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x37978
movq %r15, %rdi
callq 0x827d4
movapd %xmm0, 0x30(%rsp)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x81e9a
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
leaq 0x70(%rsp), %rbp
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x37978
movq %r15, %rdi
callq 0x827d4
movapd %xmm0, 0x20(%rsp)
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x81ed4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x8(%rbx), %r12
subq (%rbx), %r12
movq 0x8(%r14), %r13
subq (%r14), %r13
leaq 0x48(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x37978
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %r15
subq %rax, %r15
sarq $0x3, %r15
cmpq %rax, %rcx
je 0x81f28
cmpq $0x1, %r15
movq %r15, %rcx
adcq $0x0, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
addsd (%rax,%rdx,8), %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0x81f19
jmp 0x81f2c
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq 0x58(%rsp), %rbp
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x37978
sarq $0x3, %r12
sarq $0x3, %r13
movq %r12, %xmm0
movq 0x47155(%rip), %xmm1    # 0xc90b0
movq %r13, %xmm2
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x47154(%rip), %xmm3    # 0xc90c0
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
subpd %xmm3, %xmm0
subpd %xmm3, %xmm2
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
movapd 0x30(%rsp), %xmm4
mulsd %xmm4, %xmm4
movapd 0x20(%rsp), %xmm5
mulsd %xmm5, %xmm5
addsd %xmm0, %xmm1
addsd %xmm2, %xmm3
movapd %xmm4, 0x30(%rsp)
movapd %xmm4, %xmm0
divsd %xmm1, %xmm0
movapd %xmm5, 0x20(%rsp)
movapd %xmm5, %xmm1
divsd %xmm3, %xmm1
addsd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r15, %xmm2
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd (%rsp), %xmm3
divsd %xmm2, %xmm3
movq 0x90(%rsp), %rdi
movq 0x98(%rsp), %rcx
movq %rcx, %rax
subq %rdi, %rax
sarq $0x3, %rax
cmpq %rdi, %rcx
je 0x8203a
cmpq $0x1, %rax
movq %rax, %rcx
adcq $0x0, %rcx
xorpd %xmm1, %xmm1
xorl %edx, %edx
addsd (%rdi,%rdx,8), %xmm1
incq %rdx
cmpq %rdx, %rcx
jne 0x8200c
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
divsd %xmm2, %xmm1
subsd %xmm1, %xmm3
subsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm3
movsd %xmm3, (%rsp)
jmp 0x82066
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
movsd 0x5566e(%rip), %xmm2    # 0xd76b8
divsd %xmm1, %xmm2
addsd %xmm2, %xmm3
subsd 0x10(%rsp), %xmm3
divsd %xmm0, %xmm3
movsd %xmm3, (%rsp)
testq %rcx, %rcx
je 0x82076
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x8208d
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq 0x8(%r14), %xmm0
movq 0x8(%rbx), %xmm3
punpcklqdq %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0]
movq (%r14), %xmm0
movq (%rbx), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
psubq %xmm1, %xmm3
movdqa %xmm3, %xmm0
psrad $0x3, %xmm0
pshufd $0xed, %xmm0, %xmm1     # xmm1 = xmm0[1,3,2,3]
psrlq $0x3, %xmm3
pshufd $0xe8, %xmm3, %xmm2     # xmm2 = xmm3[0,2,2,3]
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movdqa 0x4e07f(%rip), %xmm1    # 0xd0150
pand %xmm1, %xmm3
movdqa 0x4e083(%rip), %xmm4    # 0xd0160
por %xmm4, %xmm3
psrlq $0x20, %xmm0
movdqa 0x4e082(%rip), %xmm5    # 0xd0170
por %xmm5, %xmm0
movapd 0x4e086(%rip), %xmm6    # 0xd0180
subpd %xmm6, %xmm0
addpd %xmm3, %xmm0
movapd 0x30(%rsp), %xmm7
unpcklpd 0x20(%rsp), %xmm7       # xmm7 = xmm7[0],mem[0]
divpd %xmm0, %xmm7
movapd %xmm7, %xmm0
unpckhpd %xmm7, %xmm0            # xmm0 = xmm0[1],xmm7[1]
addsd %xmm7, %xmm0
mulsd %xmm0, %xmm0
mulpd %xmm7, %xmm7
pcmpeqd %xmm3, %xmm3
paddq %xmm2, %xmm3
pand %xmm3, %xmm1
por %xmm4, %xmm1
psrlq $0x20, %xmm3
por %xmm5, %xmm3
subpd %xmm6, %xmm3
addpd %xmm1, %xmm3
divpd %xmm3, %xmm7
movapd %xmm7, %xmm1
unpckhpd %xmm7, %xmm1            # xmm1 = xmm1[1],xmm7[1]
addsd %xmm7, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm2
ucomisd %xmm1, %xmm2
jne 0x821b1
jp 0x821b1
ucomisd %xmm1, %xmm0
movsd (%rsp), %xmm1
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
ja 0x8219c
leaq 0x55c91(%rip), %rdi     # 0xd7e1c
leaq 0x55ccd(%rip), %rsi     # 0xd7e5f
leaq 0x8(%rsp), %rdx
callq 0x52256
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x828dd
addsd %xmm0, %xmm0
jmp 0x821ff
ucomisd %xmm1, %xmm0
movsd (%rsp), %xmm1
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
ja 0x821e0
leaq 0x55c4d(%rip), %rdi     # 0xd7e1c
leaq 0x55c89(%rip), %rsi     # 0xd7e5f
leaq 0x8(%rsp), %rdx
callq 0x52256
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x828dd
movapd %xmm0, %xmm1
movsd 0x4a515(%rip), %xmm0    # 0xcc710
subsd %xmm1, %xmm0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
jmp 0x82223
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
jne 0x8223f
jmp 0x8224b
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x8224b
leaq 0x88(%rsp), %rbp
movq (%rbp), %rsi
subq %rdi, %rsi
callq 0x8480
movq %rbx, %rdi
callq 0x8840