// File: 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
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rsi, %rax
movq %rdi, %rsi
movq %rsi, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rax, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x53120
movq -0xe0(%rbp), %rdi
callq 0xcad90
movsd %xmm0, -0xd8(%rbp)
jmp 0xc9a32
movsd -0xd8(%rbp), %xmm0
movsd 0x69c86(%rip), %xmm1    # 0x1336c8
callq 0xab30
movsd %xmm0, -0x108(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3ecb0
movsd -0x108(%rbp), %xmm0
movq -0xe8(%rbp), %rsi
movsd %xmm0, -0x28(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x53120
movq -0x100(%rbp), %rdi
callq 0xcad90
movsd %xmm0, -0xf8(%rbp)
jmp 0xc9a92
movsd -0xf8(%rbp), %xmm0
movsd 0x69c26(%rip), %xmm1    # 0x1336c8
callq 0xab30
movsd %xmm0, -0x160(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3ecb0
movsd -0x160(%rbp), %xmm0
movq -0xf0(%rbp), %rdi
movsd %xmm0, -0x58(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
callq 0x3ebf0
movsd -0x158(%rbp), %xmm0
movq -0xe8(%rbp), %rdi
movq %rax, %xmm1
movaps 0x64667(%rip), %xmm2    # 0x12e160
movaps %xmm2, -0x150(%rbp)
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x64664(%rip), %xmm2    # 0x12e170
movaps %xmm2, -0x140(%rbp)
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x120(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
callq 0x3ebf0
movaps -0x150(%rbp), %xmm4
movaps -0x140(%rbp), %xmm3
movsd -0x128(%rbp), %xmm1
movsd -0x120(%rbp), %xmm0
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
callq 0xa480
movq -0xf0(%rbp), %rsi
movsd %xmm0, -0x78(%rbp)
leaq -0x98(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x53120
movq -0x118(%rbp), %rdi
callq 0x53060
movsd %xmm0, -0x110(%rbp)
jmp 0xc9bb8
movq -0xe8(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x53120
jmp 0xc9bcd
leaq -0xb0(%rbp), %rdi
callq 0x53060
movsd %xmm0, -0x168(%rbp)
jmp 0xc9be3
movsd -0x168(%rbp), %xmm1
movsd -0x110(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd -0x20(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd -0x78(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1d0(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3ecb0
leaq -0x98(%rbp), %rdi
callq 0x3ecb0
movsd -0x1d0(%rbp), %xmm0
movq -0xf0(%rbp), %rdi
movsd %xmm0, -0x80(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x1c8(%rbp)
callq 0x3ebf0
movsd -0x1c8(%rbp), %xmm0
movq -0xe8(%rbp), %rdi
movq %rax, %xmm1
movaps 0x644f6(%rip), %xmm2    # 0x12e160
movaps %xmm2, -0x190(%rbp)
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x644f3(%rip), %xmm2    # 0x12e170
movaps %xmm2, -0x180(%rbp)
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x1b8(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x1c0(%rbp)
callq 0x3ebf0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm0
movaps -0x190(%rbp), %xmm4
movaps -0x180(%rbp), %xmm3
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd 0x699d1(%rip), %xmm1    # 0x1336c8
movsd %xmm1, -0x198(%rbp)
callq 0xab30
movq -0xf0(%rbp), %rdi
movsd %xmm0, -0xb8(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
callq 0x3ebf0
movsd -0x1b0(%rbp), %xmm0
movsd -0x198(%rbp), %xmm1
movaps -0x190(%rbp), %xmm4
movaps -0x180(%rbp), %xmm3
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm0
callq 0xab30
movq -0xf0(%rbp), %rdi
movsd %xmm0, -0x1a8(%rbp)
callq 0x3ebf0
movsd -0x1a8(%rbp), %xmm0
movq -0xe8(%rbp), %rdi
movaps -0x190(%rbp), %xmm3
movaps -0x180(%rbp), %xmm2
decq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x1a0(%rbp)
callq 0x3ebf0
movsd -0x1a0(%rbp), %xmm0
movsd -0x198(%rbp), %xmm1
movaps -0x190(%rbp), %xmm4
movaps -0x180(%rbp), %xmm3
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm0
callq 0xab30
movq -0xe8(%rbp), %rdi
movsd %xmm0, -0x170(%rbp)
callq 0x3ebf0
movaps -0x190(%rbp), %xmm3
movaps -0x180(%rbp), %xmm2
movsd -0x170(%rbp), %xmm0
decq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
addsd -0xc8(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc9f27
jp 0xc9f27
movsd -0xd0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0xcaec0
movaps %xmm0, %xmm1
movsd 0x69811(%rip), %xmm0    # 0x1336c8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xc9f4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3ecb0
jmp 0xc9f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3ecb0
jmp 0xc9f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xc9f19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3ecb0
leaq -0x98(%rbp), %rdi
callq 0x3ecb0
jmp 0xc9f5b
movsd -0xd0(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
callq 0xcaec0
movaps %xmm0, %xmm1
movsd 0x68374(%rip), %xmm0    # 0x1322b8
subsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0xab50
nopw %cs:(%rax,%rax)
nop