// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/process_vcf_fst.cpp
// Function: calculatePiTwoSets(SetCounts const&, int, int)
std::vector<double> calculatePiTwoSets(const SetCounts& thisVarCounts, const int n1, const int n2) {
    double pi1 = 0; double pi2 = 0;
 
    for (std::vector<std::string>::size_type i = 0; i != n1 - 1; i++) {
        for (std::vector<std::string>::size_type j = i+1; j != n1; j++) {
            if (thisVarCounts.set1HaplotypeVariant[i] == 1 && thisVarCounts.set1HaplotypeVariant[j] == 0) {
                pi1++;
            } else if (thisVarCounts.set1HaplotypeVariant[i] == 0 && thisVarCounts.set1HaplotypeVariant[j] == 1) {
                pi1++;
            }
        }
    }
    for (std::vector<std::string>::size_type i = 0; i != n2 - 1; i++) {
        for (std::vector<std::string>::size_type j = i+1; j != n2; j++) {
            if (thisVarCounts.set2HaplotypeVariant[i] == 1 && thisVarCounts.set2HaplotypeVariant[j] == 0) {
                pi2++;
            } else if (thisVarCounts.set2HaplotypeVariant[i] == 0 && thisVarCounts.set2HaplotypeVariant[j] == 1) {
                pi2++;
            }
        }
    }
    pi1 = (2.0/(thisVarCounts.set1_n_withoutMissing*(thisVarCounts.set1_n_withoutMissing-1)))*pi1;
    pi2 = (2.0/(thisVarCounts.set2_n_withoutMissing*(thisVarCounts.set2_n_withoutMissing-1)))*pi2;
    
    std::vector<double> pis; pis.push_back(pi1); pis.push_back(pi2);
    return pis;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movl %edx, %eax
decl %eax
je 0x8e1f7
cltq
movslq %edx, %rdx
movq 0x60(%rsi), %rdi
xorpd %xmm0, %xmm0
xorl %r9d, %r9d
movsd 0x4129c(%rip), %xmm1    # 0xcf440
movq %rdi, %r8
movq %rdx, %r10
movq %r9, %r11
incq %r9
cmpq %rdx, %r9
je 0x8e1e9
movl (%rdi,%r11,4), %r11d
movl $0x1, %r14d
testl %r11d, %r11d
je 0x8e1d6
cmpl $0x1, %r11d
jne 0x8e1e1
cmpl $0x0, (%r8,%r14,4)
je 0x8e1dd
testl %r11d, %r11d
jne 0x8e1e1
cmpl $0x1, (%r8,%r14,4)
jne 0x8e1e1
addsd %xmm1, %xmm0
incq %r14
cmpq %r14, %r10
jne 0x8e1bf
decq %r10
addq $0x4, %r8
cmpq %rax, %r9
jne 0x8e1aa
jmp 0x8e1fb
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl %ecx, %eax
movsd 0x8(%rsp), %xmm0
decl %eax
je 0x8e272
cltq
movslq %ecx, %rcx
movq 0x78(%rsi), %rdx
xorl %r8d, %r8d
movsd 0x4121f(%rip), %xmm1    # 0xcf440
movq %rdx, %rdi
movq %rcx, %r9
movq %r8, %r10
incq %r8
cmpq %rcx, %r8
je 0x8e266
movl (%rdx,%r10,4), %r10d
movl $0x1, %r11d
testl %r10d, %r10d
je 0x8e253
cmpl $0x1, %r10d
jne 0x8e25e
cmpl $0x0, (%rdi,%r11,4)
je 0x8e25a
testl %r10d, %r10d
jne 0x8e25e
cmpl $0x1, (%rdi,%r11,4)
jne 0x8e25e
addsd %xmm1, %xmm0
incq %r11
cmpq %r11, %r9
jne 0x8e23c
decq %r9
addq $0x4, %rdi
cmpq %rax, %r8
jne 0x8e227
movsd %xmm0, 0x8(%rsp)
movl 0xc8(%rsi), %eax
leal -0x1(%rax), %ecx
imull %eax, %ecx
cvtsi2sd %ecx, %xmm2
movsd 0x4dd50(%rip), %xmm3    # 0xdbfe0
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
movl 0xcc(%rsi), %eax
leal -0x1(%rax), %ecx
imull %eax, %ecx
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
divsd %xmm2, %xmm3
mulsd %xmm0, %xmm3
movsd %xmm3, 0x8(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x8e2ec
movsd %xmm1, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x8e2f9
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x79f34
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x8e317
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x8e324
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x79f34
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x8e346
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x8480
movq %r14, %rdi
callq 0x8840