// File: millanek[P]evo/evo_abba_baba.cpp
// Function: incrementDnumDdenomSingleSequence(ThreeSetCounts&, ABBA_BABA_Freq_allResults&)
inline void incrementDnumDdenomSingleSequence(ThreeSetCounts& c, ABBA_BABA_Freq_allResults& res) {
    if (c.set1daAF == -1) {
        ABBABABAcounts::noDafInfo++;
    } else if (c.set3daAF == 0) {
        ABBABABAcounts::XXAA++;
    } else {
        if (c.set3daAF == 0.5) { c.set3daAF = sample01(0.5); } // If hets then randomly sample one of the alleles
        if (c.set2daAF == 0.5) { c.set2daAF = sample01(0.5); }
        if (c.set1daAF == 0.5) { c.set1daAF = sample01(0.5); }
        
        if (c.set3daAF == 1) {
            ABBABABAcounts::XXBA++;
            // Green et al. (2010) eq. S15.1
            if (c.set1daAF == 0 && c.set2daAF == 1) {
                ABBABABAcounts::ABBA++; ABBABABAcounts::usedVariantsCounter++;
                res.Ddenominator++; res.Dnumerator++; res.lastVarsDdenom++; res.lastVarsDnum++; res.windowDdenom++; res.windowDnum++;
            } else if (c.set1daAF == 1 && c.set2daAF == 0) {
                ABBABABAcounts::BABA++; ABBABABAcounts::usedVariantsCounter++;
                res.Ddenominator++; res.Dnumerator--; res.lastVarsDdenom++; res.lastVarsDnum--; res.windowDdenom++; res.windowDnum--;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd 0xe1b7f(%rip), %xmm1    # 0x1336c0
ucomisd %xmm1, %xmm0
jne 0x51b5d
jp 0x51b5d
movl 0x148311(%rip), %eax    # 0x199e60
addl $0x1, %eax
movl %eax, 0x148308(%rip)    # 0x199e60
jmp 0x51e30
movq -0x8(%rbp), %rax
movsd 0x48(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x51b85
jp 0x51b85
movl 0x1482cd(%rip), %eax    # 0x199e44
addl $0x1, %eax
movl %eax, 0x1482c4(%rip)    # 0x199e44
jmp 0x51e2e
movq -0x8(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd 0xdc572(%rip), %xmm1    # 0x12e108
ucomisd %xmm1, %xmm0
jne 0x51bc1
jp 0x51bc1
movsd 0xdc562(%rip), %xmm0    # 0x12e108
movsd %xmm0, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x52910
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movq -0x8(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd 0xdc536(%rip), %xmm1    # 0x12e108
ucomisd %xmm1, %xmm0
jne 0x51bfd
jp 0x51bfd
movsd 0xdc526(%rip), %xmm0    # 0x12e108
movsd %xmm0, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x52910
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movq -0x8(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd 0xdc4fa(%rip), %xmm1    # 0x12e108
ucomisd %xmm1, %xmm0
jne 0x51c39
jp 0x51c39
movsd 0xdc4ea(%rip), %xmm0    # 0x12e108
movsd %xmm0, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x52910
cvtsi2sd %eax, %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movq -0x8(%rbp), %rax
movsd 0x48(%rax), %xmm0
movsd 0xe066e(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jne 0x51e2c
jp 0x51e2c
movl 0x1481ec(%rip), %eax    # 0x199e4c
addl $0x1, %eax
movl %eax, 0x1481e3(%rip)    # 0x199e4c
movq -0x8(%rbp), %rax
movsd 0x38(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x51d4b
jp 0x51d4b
movq -0x8(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd 0xe0622(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jne 0x51d4b
jp 0x51d4b
movl 0x1481a4(%rip), %eax    # 0x199e50
addl $0x1, %eax
movl %eax, 0x14819b(%rip)    # 0x199e50
movl 0x1481a9(%rip), %eax    # 0x199e64
addl $0x1, %eax
movl %eax, 0x1481a0(%rip)    # 0x199e64
movq -0x10(%rbp), %rax
movsd 0xe05e8(%rip), %xmm0    # 0x1322b8
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rax
movsd 0xe05d2(%rip), %xmm0    # 0x1322b8
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd 0xe05be(%rip), %xmm0    # 0x1322b8
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movq -0x10(%rbp), %rax
movsd 0xe05a8(%rip), %xmm0    # 0x1322b8
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x10(%rbp), %rax
movsd 0xe0592(%rip), %xmm0    # 0x1322b8
addsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
movq -0x10(%rbp), %rax
movsd 0xe057c(%rip), %xmm0    # 0x1322b8
addsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rax)
jmp 0x51e2a
movq -0x8(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd 0xe055c(%rip), %xmm1    # 0x1322b8
ucomisd %xmm1, %xmm0
jne 0x51e28
jp 0x51e28
movq -0x8(%rbp), %rax
movsd 0x40(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x51e28
jp 0x51e28
movl 0x1480c6(%rip), %eax    # 0x199e54
addl $0x1, %eax
movl %eax, 0x1480bd(%rip)    # 0x199e54
movl 0x1480c7(%rip), %eax    # 0x199e64
addl $0x1, %eax
movl %eax, 0x1480be(%rip)    # 0x199e64
movq -0x10(%rbp), %rax
movsd 0xe0506(%rip), %xmm0    # 0x1322b8
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rax
movsd 0xe18f8(%rip), %xmm0    # 0x1336c0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd 0xe04dc(%rip), %xmm0    # 0x1322b8
addsd 0x18(%rax), %xmm0
movsd %xmm0, 0x18(%rax)
movq -0x10(%rbp), %rax
movsd 0xe18ce(%rip), %xmm0    # 0x1336c0
addsd 0x10(%rax), %xmm0
movsd %xmm0, 0x10(%rax)
movq -0x10(%rbp), %rax
movsd 0xe04b0(%rip), %xmm0    # 0x1322b8
addsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
movq -0x10(%rbp), %rax
movsd 0xe18a2(%rip), %xmm0    # 0x1336c0
addsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rax)
jmp 0x51e2a
jmp 0x51e2c
jmp 0x51e2e
jmp 0x51e30
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)