// File: /workspace/github_cpp_makefile_star2_O3/millanek[P]evo/evo_PBS.cpp
// Function: calculatePBSfromAFs(double, double, double, double, double, double)
inline std::vector<double> calculatePBSfromAFs(double p1, double p2, double p3, double p1AlleleCount, double p2AlleleCount, double p3AlleleCount) {
    // std::cerr << "p:\t" << p1 << "\t" << p2 << "\t" << p3 <<  std::endl;
    double Fst12; double Fst13; double Fst23;
    double power12 = pow(p1-p2, 2);
    double power13 = pow(p1-p3, 2);
    double power23 = pow(p2-p3, 2);
    double fraction1 = (p1*(1-p1))/(p1AlleleCount-1);
    double fraction2 = (p2*(1-p2))/(p2AlleleCount-1);
    double fraction3 = (p3*(1-p3))/(p3AlleleCount-1);
    double numerator12 = power12 - fraction1 - fraction2;
    double numerator13 = power13 - fraction1 - fraction3;
    double numerator23 = power23 - fraction2 - fraction3;
    double denominator12 = (p1*(1-p2))+(p2*(1-p1));
    double denominator13 = (p1*(1-p3))+(p3*(1-p1));
    double denominator23 = (p2*(1-p3))+(p3*(1-p2));
    if ((p1 == 0 && p2 == 0) || (p1 == 1 && p2 == 1)) { Fst12 = 0.0; } else { Fst12 = numerator12/denominator12; }
    if ((p1 == 0 && p3 == 0) || (p1 == 1 && p3 == 1)) { Fst13 = 0.0; } else { Fst13 = numerator13/denominator13; }
    if ((p2 == 0 && p3 == 0) || (p2 == 1 && p3 == 1)) { Fst23 = 0.0; } else { Fst23 = numerator23/denominator23; }
    // std::cerr << Fst12 << "\t" << Fst13 << "\t" << Fst23 <<  std::endl;
    if (Fst12 < 0) Fst12 = 0; if (Fst13 < 0) Fst13 = 0; if (Fst23 < 0) Fst23 = 0;
    if (Fst12 == 1) Fst12 = 1 - (Fst12/p1AlleleCount); if (Fst13 == 1) Fst13 = 1 - (Fst13/p1AlleleCount); if (Fst23 == 1) Fst23 = 1 - (Fst23/p2AlleleCount);
    double T12 = -log(1-Fst12); double T13 = -log(1-Fst13); double T23 = -log(1-Fst23);
    double PBS1 = (T12+T13-T23)/2.0;
    double PBS2 = (T12+T23-T13)/2.0;
    double PBS3 = (T13+T23-T12)/2.0;
    if (PBS1 < 0) PBS1 = 0; if (PBS2 < 0) PBS2 = 0; if (PBS3 < 0) PBS3 = 0;
    //std::cerr << PBS1 << "\t" << PBS2 << "\t" << PBS3 <<  std::endl;
    std::vector<double> PBS; PBS.push_back(PBS1); PBS.push_back(PBS2); PBS.push_back(PBS3);
    return PBS;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movsd 0x1ef26(%rip), %xmm15   # 0xcc710
movapd %xmm15, %xmm11
subsd %xmm0, %xmm11
movapd %xmm11, %xmm12
mulsd %xmm0, %xmm12
movsd 0x1ef12(%rip), %xmm7    # 0xcc718
movapd %xmm3, %xmm6
addsd %xmm7, %xmm6
divsd %xmm6, %xmm12
movapd %xmm15, %xmm6
subsd %xmm1, %xmm6
movapd %xmm6, %xmm9
mulsd %xmm1, %xmm9
movapd %xmm4, %xmm8
addsd %xmm7, %xmm8
divsd %xmm8, %xmm9
movapd %xmm15, %xmm8
subsd %xmm2, %xmm8
movapd %xmm8, %xmm10
mulsd %xmm2, %xmm10
addsd %xmm7, %xmm5
xorpd %xmm7, %xmm7
ucomisd %xmm7, %xmm0
jne 0xad867
jp 0xad867
xorpd %xmm13, %xmm13
ucomisd %xmm13, %xmm1
jne 0xad867
jnp 0xad8b3
ucomisd 0x1eea1(%rip), %xmm0    # 0xcc710
jne 0xad87f
jp 0xad87f
ucomisd 0x1ee95(%rip), %xmm1    # 0xcc710
jne 0xad87f
jnp 0xad8b3
movapd %xmm0, %xmm7
subsd %xmm1, %xmm7
mulsd %xmm7, %xmm7
subsd %xmm12, %xmm7
subsd %xmm9, %xmm7
movapd %xmm11, %xmm13
mulsd %xmm1, %xmm13
movapd %xmm0, %xmm14
mulsd %xmm6, %xmm14
addsd %xmm13, %xmm14
divsd %xmm14, %xmm7
divsd %xmm5, %xmm10
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm0
jne 0xad8d2
jp 0xad8d2
xorpd %xmm13, %xmm13
ucomisd %xmm13, %xmm2
jne 0xad8d2
jnp 0xad913
ucomisd 0x1ee36(%rip), %xmm0    # 0xcc710
jne 0xad8ea
jp 0xad8ea
ucomisd 0x1ee2a(%rip), %xmm2    # 0xcc710
jne 0xad8ea
jnp 0xad913
movapd %xmm0, %xmm5
subsd %xmm2, %xmm5
mulsd %xmm5, %xmm5
subsd %xmm12, %xmm5
mulsd %xmm2, %xmm11
mulsd %xmm8, %xmm0
addsd %xmm11, %xmm0
subsd %xmm10, %xmm5
divsd %xmm0, %xmm5
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0xad92d
jp 0xad92d
xorpd %xmm11, %xmm11
ucomisd %xmm11, %xmm2
jne 0xad92d
jnp 0xad96e
ucomisd 0x1eddb(%rip), %xmm1    # 0xcc710
jne 0xad945
jp 0xad945
ucomisd 0x1edcf(%rip), %xmm2    # 0xcc710
jne 0xad945
jnp 0xad96e
movapd %xmm1, %xmm0
subsd %xmm2, %xmm0
mulsd %xmm0, %xmm0
subsd %xmm9, %xmm0
mulsd %xmm2, %xmm6
mulsd %xmm1, %xmm8
addsd %xmm6, %xmm8
subsd %xmm10, %xmm0
divsd %xmm8, %xmm0
xorpd %xmm6, %xmm6
maxsd %xmm7, %xmm6
xorpd %xmm7, %xmm7
maxsd %xmm5, %xmm7
xorpd %xmm2, %xmm2
maxsd %xmm0, %xmm2
movapd %xmm6, %xmm1
cmpeqsd %xmm15, %xmm1
movapd %xmm1, %xmm0
andnpd %xmm6, %xmm0
divsd %xmm3, %xmm6
movapd %xmm15, %xmm5
subsd %xmm6, %xmm5
andpd %xmm5, %xmm1
orpd %xmm0, %xmm1
movapd %xmm7, %xmm5
cmpeqsd %xmm15, %xmm5
movapd %xmm5, %xmm0
andnpd %xmm7, %xmm0
divsd %xmm3, %xmm7
movapd %xmm15, %xmm3
subsd %xmm7, %xmm3
andpd %xmm3, %xmm5
orpd %xmm0, %xmm5
movapd %xmm5, (%rsp)
movapd %xmm2, %xmm5
cmpeqsd %xmm15, %xmm5
movapd %xmm5, %xmm0
andnpd %xmm2, %xmm0
divsd %xmm4, %xmm2
movapd %xmm15, %xmm3
subsd %xmm2, %xmm3
andpd %xmm3, %xmm5
orpd %xmm0, %xmm5
movapd %xmm5, 0x50(%rsp)
movapd %xmm15, %xmm0
subsd %xmm1, %xmm0
callq 0x83b0
movsd %xmm0, 0x30(%rsp)
movsd 0x1ecee(%rip), %xmm0    # 0xcc710
subsd (%rsp), %xmm0
callq 0x83b0
movapd %xmm0, (%rsp)
xorpd 0x1eca7(%rip), %xmm0    # 0xcc6e0
movapd %xmm0, 0x40(%rsp)
movsd 0x1ecc9(%rip), %xmm0    # 0xcc710
subsd 0x50(%rsp), %xmm0
callq 0x83b0
movapd 0x1ec86(%rip), %xmm4    # 0xcc6e0
xorpd %xmm0, %xmm4
movsd 0x30(%rsp), %xmm2
movapd 0x40(%rsp), %xmm1
subsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x1eca6(%rip), %xmm0    # 0xcc720
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
movapd %xmm1, %xmm3
movapd %xmm4, %xmm1
subsd %xmm2, %xmm1
movapd (%rsp), %xmm5
addsd %xmm5, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
subsd %xmm5, %xmm4
addsd %xmm2, %xmm4
mulsd %xmm0, %xmm4
xorpd %xmm0, %xmm0
movapd %xmm4, (%rsp)
movsd %xmm4, 0x18(%rsp)
ucomisd %xmm3, %xmm0
jbe 0xadacd
movq $0x0, 0x28(%rsp)
ucomisd %xmm1, %xmm0
jbe 0xadae0
movq $0x0, 0x20(%rsp)
xorpd %xmm1, %xmm1
movapd %xmm1, 0x30(%rsp)
ucomisd (%rsp), %xmm0
jbe 0xadafb
movq $0x0, 0x18(%rsp)
movapd %xmm0, (%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x79b8e
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rax
cmpq %rax, %rsi
movapd 0x30(%rsp), %xmm0
je 0xadb3b
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xadb50
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x79b8e
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rax
cmpq %rax, %rsi
je 0xadb68
movapd (%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0xadb75
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x79b8e
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r14
retq
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xadb97
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x8480
movq %r14, %rdi
callq 0x8840
nop