// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/evo_abba_baba.cpp
// Function: incrementDnumDdenomFrequency(ThreeSetCounts const&, ABBA_BABA_Freq_allResults&)
inline void incrementDnumDdenomFrequency(const ThreeSetCounts& c, ABBA_BABA_Freq_allResults& res) {
    if (c.set1daAF == -1) {
        ABBABABAcounts::noDafInfo++;
    } else if (c.set3daAF == 0) {
        ABBABABAcounts::XXAA++;
    } else if (c.set1daAF == 0 && c.set2daAF == 0) {
        ABBABABAcounts::AABA++;
    } else if (c.set1daAF == 1 && c.set2daAF == 1) {
        ABBABABAcounts::BBBA++;
    } else if (c.set1daAF == c.set2daAF) {
        ABBABABAcounts::p1p2++;
    } else {
        ABBABABAcounts::usedVariantsCounter++;
        // Green et al. (2010) eq. S15.2
        
        double thisDnumerator = ((1-c.set1daAF)*c.set2daAF*c.set3daAF) - (c.set1daAF*(1-c.set2daAF)*c.set3daAF);
        double thisDdenominator = ((1-c.set1daAF)*c.set2daAF*c.set3daAF) + (c.set1daAF*(1-c.set2daAF)*c.set3daAF);
        res.Dnumerator += thisDnumerator; res.lastVarsDnum += thisDnumerator; res.windowDnum += thisDnumerator;
        res.Ddenominator += thisDdenominator; res.lastVarsDdenom += thisDdenominator; res.windowDdenom += thisDdenominator;
        
        double thisF_d_denom;
        if (c.set2daAF > c.set3daAF) {
            thisF_d_denom = ((1-c.set1daAF)*c.set2daAF*c.set2daAF) - (c.set1daAF*(1-c.set2daAF)*c.set2daAF);
        } else {
            thisF_d_denom = ((1-c.set1daAF)*c.set3daAF*c.set3daAF) - (c.set1daAF*(1-c.set3daAF)*c.set3daAF);
        }
        //if (thisF_d_denom != 0) {
        /* if (thisDnumerator/thisF_d_denom > 1) {
         std::cerr << "f_d:\t" << thisDnumerator/thisF_d_denom << std::endl;
         std::cerr << "D num:\t" << thisDnumerator << std::endl;
         std::cerr << "f_d denom:\t" << thisF_d_denom << std::endl;
         std::cerr << "p1:\t" << c.set1daAF << std::endl;
         std::cerr << "p2:\t" << c.set2daAF << std::endl;
         std::cerr << "p3:\t" << c.set3daAF << std::endl;
         } */
        res.f_d_denominator += thisF_d_denom; res.window_f_d_denominator += thisF_d_denom; res.lastVarsF_d_denom += thisF_d_denom;
        res.f_d_num += thisDnumerator; res.window_f_d_num += thisDnumerator; res.lastVarsF_d_num += thisDnumerator;
        ABBABABAcounts::used_f_d_Counter++;
        //}
        
        double thisF_dM_denom;
        if (c.set1daAF <= c.set2daAF) {
            if (c.set2daAF > c.set3daAF) {
                thisF_dM_denom = ((1-c.set1daAF)*c.set2daAF*c.set2daAF) - (c.set1daAF*(1-c.set2daAF)*c.set2daAF);
            } else {
                thisF_dM_denom = ((1-c.set1daAF)*c.set3daAF*c.set3daAF) - (c.set1daAF*(1-c.set3daAF)*c.set3daAF);
            }
        } else {
            if (c.set1daAF > c.set3daAF) {
                thisF_dM_denom = -(((1-c.set1daAF)*c.set2daAF*c.set1daAF) - (c.set1daAF*(1-c.set2daAF)*c.set1daAF));
            } else {
                thisF_dM_denom = -(((1-c.set3daAF)*c.set2daAF*c.set3daAF) - (c.set3daAF*(1-c.set2daAF)*c.set3daAF));
            }
        }
        if (thisF_dM_denom == 0) {
            std::cerr << "f_d:\t" << thisDnumerator/thisF_d_denom << std::endl;
            std::cerr << "D num:\t" << thisDnumerator << std::endl;
            std::cerr << "f_d denom:\t" << thisF_d_denom << std::endl;
            std::cerr << "f_dM denom:\t" << thisF_dM_denom << std::endl;
            std::cerr << "p1:\t" << c.set1daAF << std::endl;
            std::cerr << "p2:\t" << c.set2daAF << std::endl;
            std::cerr << "p3:\t" << c.set3daAF << std::endl;
        }
        res.f_dM_denominator += thisF_dM_denom; res.window_f_dM_denominator += thisF_dM_denom; res.lastVarsF_dM_denom += thisF_dM_denom;
        
        if (c.set3daAF == 1) {
            res.f_G_denom += 1-c.set1daAF; res.f_G_num += thisDnumerator;
            res.lastVarsF_G_denom += 1-c.set1daAF; res.lastVarsF_G_num += thisDnumerator;
        }
        
        if (thisDdenominator == 0) {
            std::cerr << "P1:" << c.set1daAF << " P2:" << c.set2daAF << " P3:" << c.set3daAF << std::endl;
        }
        assert(thisDdenominator != 0);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movsd 0x38(%rdi), %xmm1
ucomisd 0x68a10(%rip), %xmm1    # 0x975f8
jne 0x2ebf5
jp 0x2ebf5
leaq 0xaedbd(%rip), %rax     # 0xdd9b0
jmp 0x2ec67
movq %rdi, %rbx
movsd 0x48(%rdi), %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x2ec12
jp 0x2ec12
leaq 0xaed84(%rip), %rax     # 0xdd994
jmp 0x2ec67
movq %rsi, %r14
ucomisd %xmm2, %xmm1
movsd 0x40(%rbx), %xmm2
jne 0x2ec37
jp 0x2ec37
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jne 0x2ec37
jp 0x2ec37
leaq 0xaed5b(%rip), %rax     # 0xdd990
jmp 0x2ec67
ucomisd 0x689b1(%rip), %xmm1    # 0x975f0
jne 0x2ec58
jp 0x2ec58
ucomisd 0x689a5(%rip), %xmm2    # 0x975f0
jne 0x2ec58
jp 0x2ec58
leaq 0xaed42(%rip), %rax     # 0xdd998
jmp 0x2ec67
ucomisd %xmm2, %xmm1
jne 0x2ec73
jp 0x2ec73
leaq 0xaed41(%rip), %rax     # 0xdd9a8
incl (%rax)
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
incl 0xaed3b(%rip)           # 0xdd9b4
movsd 0x6896e(%rip), %xmm11   # 0x975f0
movapd %xmm11, %xmm3
subsd %xmm1, %xmm3
movapd %xmm3, %xmm4
mulsd %xmm2, %xmm4
movapd %xmm11, %xmm5
subsd %xmm2, %xmm5
movapd %xmm1, %xmm6
mulsd %xmm5, %xmm6
movapd %xmm0, %xmm7
mulsd %xmm6, %xmm7
movapd 0x6890b(%rip), %xmm8    # 0x975c0
xorpd %xmm7, %xmm8
unpcklpd %xmm7, %xmm8            # xmm8 = xmm8[0],xmm7[0]
movapd %xmm4, %xmm10
mulsd %xmm0, %xmm10
unpcklpd %xmm10, %xmm10          # xmm10 = xmm10[0,0]
addpd %xmm8, %xmm10
movupd (%r14), %xmm7
movupd 0x10(%r14), %xmm8
movupd 0x20(%r14), %xmm9
addpd %xmm10, %xmm7
movupd %xmm7, (%r14)
addpd %xmm10, %xmm8
movupd %xmm8, 0x10(%r14)
addpd %xmm10, %xmm9
movupd %xmm9, 0x20(%r14)
ucomisd %xmm0, %xmm2
movapd %xmm4, %xmm9
mulsd %xmm2, %xmm9
jbe 0x2ed23
movapd %xmm2, %xmm7
mulsd %xmm6, %xmm7
movapd %xmm9, %xmm12
jmp 0x2ed43
movapd %xmm3, %xmm12
mulsd %xmm0, %xmm12
movapd %xmm11, %xmm7
subsd %xmm0, %xmm7
mulsd %xmm1, %xmm7
mulsd %xmm0, %xmm7
mulsd %xmm0, %xmm12
subsd %xmm7, %xmm12
movapd %xmm12, %xmm7
unpcklpd %xmm12, %xmm7           # xmm7 = xmm7[0],xmm12[0]
movupd 0x30(%r14), %xmm8
addpd %xmm7, %xmm8
movupd 0x60(%r14), %xmm7
movupd %xmm8, 0x30(%r14)
movsd 0x40(%r14), %xmm8
addsd %xmm12, %xmm8
movsd %xmm8, 0x40(%r14)
movapd %xmm10, %xmm8
unpcklpd %xmm10, %xmm8           # xmm8 = xmm8[0],xmm10[0]
addpd %xmm8, %xmm7
movupd %xmm7, 0x60(%r14)
movsd 0x70(%r14), %xmm7
addsd %xmm10, %xmm7
movsd %xmm7, 0x70(%r14)
incl 0xaec12(%rip)           # 0xdd9b8
ucomisd %xmm1, %xmm2
jae 0x2edcd
ucomisd %xmm0, %xmm1
jbe 0x2edde
mulsd %xmm1, %xmm6
mulsd %xmm1, %xmm4
subsd %xmm6, %xmm4
xorpd 0x687fa(%rip), %xmm4    # 0x975c0
movapd %xmm4, %xmm9
jmp 0x2ee2c
ucomisd %xmm0, %xmm2
jbe 0x2ee0a
mulsd %xmm6, %xmm2
subsd %xmm2, %xmm9
jmp 0x2ee2c
movapd %xmm11, %xmm9
subsd %xmm0, %xmm9
mulsd %xmm2, %xmm9
mulsd %xmm0, %xmm5
mulsd %xmm0, %xmm5
mulsd %xmm0, %xmm9
subsd %xmm5, %xmm9
xorpd 0x687b8(%rip), %xmm9    # 0x975c0
jmp 0x2ee2c
mulsd %xmm0, %xmm3
movapd %xmm11, %xmm2
subsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm3
subsd %xmm2, %xmm3
movapd %xmm3, %xmm9
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm9
jne 0x2ef86
jp 0x2ef86
movq 0xae1a0(%rip), %r15     # 0xdcfe8
leaq 0x68a78(%rip), %rsi     # 0x978c7
movq %r15, %rdi
movapd %xmm10, (%rsp)
movapd %xmm8, 0x30(%rsp)
movapd %xmm9, 0x20(%rsp)
movapd %xmm12, 0x10(%rsp)
callq 0x8480
movapd (%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x68a39(%rip), %rsi     # 0x978cd
movq %r15, %rdi
callq 0x8480
movq %rax, %rdi
movaps (%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x68a1e(%rip), %rsi     # 0x978d5
movq %r15, %rdi
callq 0x8480
movq %rax, %rdi
movaps 0x10(%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x68a06(%rip), %rsi     # 0x978e1
movq %r15, %rdi
callq 0x8480
movq %rax, %rdi
movaps 0x20(%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x689ef(%rip), %rsi     # 0x978ee
movq %r15, %rdi
callq 0x8480
movsd 0x38(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x689d0(%rip), %rsi     # 0x978f3
movq %r15, %rdi
callq 0x8480
movsd 0x40(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x689b1(%rip), %rsi     # 0x978f8
movq %r15, %rdi
callq 0x8480
movsd 0x48(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
movapd 0x20(%rsp), %xmm9
movapd 0x30(%rsp), %xmm8
movsd 0x68675(%rip), %xmm11   # 0x975f0
movapd (%rsp), %xmm10
movsd 0x48(%rbx), %xmm0
movupd 0x48(%r14), %xmm1
movapd %xmm9, %xmm2
unpcklpd %xmm9, %xmm2            # xmm2 = xmm2[0],xmm9[0]
addpd %xmm1, %xmm2
movupd %xmm2, 0x48(%r14)
addsd 0x58(%r14), %xmm9
movsd %xmm9, 0x58(%r14)
ucomisd 0x6863c(%rip), %xmm0    # 0x975f0
jne 0x2eff4
jp 0x2eff4
subsd 0x38(%rbx), %xmm11
movsd %xmm11, %xmm8           # xmm8 = xmm11[0],xmm8[1]
movupd 0x78(%r14), %xmm0
addpd %xmm8, %xmm0
movupd 0x88(%r14), %xmm1
movupd %xmm0, 0x78(%r14)
movapd %xmm10, %xmm0
unpcklpd %xmm11, %xmm0           # xmm0 = xmm0[0],xmm11[0]
addpd %xmm1, %xmm0
movupd %xmm0, 0x88(%r14)
unpckhpd %xmm10, %xmm10          # xmm10 = xmm10[1,1]
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm10
jne 0x2f076
jp 0x2f076
movq 0xadfdb(%rip), %rdi     # 0xdcfe8
leaq 0x688e9(%rip), %rsi     # 0x978fd
movapd %xmm10, (%rsp)
callq 0x8480
movsd 0x38(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
leaq 0x688ce(%rip), %rsi     # 0x97901
movq %rax, %rdi
callq 0x8480
movsd 0x40(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
leaq 0x688b7(%rip), %rsi     # 0x97906
movq %rax, %rdi
callq 0x8480
movsd 0x48(%rbx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
xorpd %xmm0, %xmm0
movapd (%rsp), %xmm10
ucomisd %xmm0, %xmm10
jne 0x2ec69
jp 0x2ec69
leaq 0x6887d(%rip), %rdi     # 0x9790b
leaq 0x6870b(%rip), %rsi     # 0x977a0
leaq 0x68885(%rip), %rcx     # 0x97921
movl $0xaa, %edx
callq 0x82f0