// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leal -0x1(%rdx), %eax
cltq
movslq %edx, %rdx
movq 0x60(%rsi), %rdi
xorpd %xmm0, %xmm0
xorl %r10d, %r10d
pushq $0x1
popq %r8
movsd 0x2c3c8(%rip), %xmm1    # 0x975f0
movq %rdi, %r9
cmpq %rax, %r10
je 0x6b26e
leaq 0x1(%r10), %r11
movq %r8, %r14
cmpq %r14, %rdx
je 0x6b262
movl (%rdi,%r10,4), %ebp
testl %ebp, %ebp
je 0x6b252
cmpl $0x1, %ebp
jne 0x6b25d
cmpl $0x0, (%r9,%r14,4)
jne 0x6b25d
jmp 0x6b259
cmpl $0x1, (%r9,%r14,4)
jne 0x6b25d
addsd %xmm1, %xmm0
incq %r14
jmp 0x6b237
addq $0x4, %r9
decq %rdx
movq %r11, %r10
jmp 0x6b22b
leal -0x1(%rcx), %eax
cltq
movslq %ecx, %rcx
movq 0x78(%rsi), %rdx
xorpd %xmm2, %xmm2
xorl %r9d, %r9d
pushq $0x1
popq %rdi
movq %rdx, %r8
cmpq %rax, %r9
je 0x6b2ca
leaq 0x1(%r9), %r10
movq %rdi, %r11
cmpq %r11, %rcx
je 0x6b2be
movl (%rdx,%r9,4), %ebp
testl %ebp, %ebp
je 0x6b2ae
cmpl $0x1, %ebp
jne 0x6b2b9
cmpl $0x0, (%r8,%r11,4)
jne 0x6b2b9
jmp 0x6b2b5
cmpl $0x1, (%r8,%r11,4)
jne 0x6b2b9
addsd %xmm1, %xmm2
incq %r11
jmp 0x6b293
addq $0x4, %r8
decq %rcx
movq %r10, %r9
jmp 0x6b287
movl 0xc8(%rsi), %eax
leal -0x1(%rax), %ecx
imull %eax, %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x38f7e(%rip), %xmm3    # 0xa4260
movapd %xmm3, %xmm4
divsd %xmm1, %xmm4
mulsd %xmm4, %xmm0
leaq 0x8(%rsp), %rax
movsd %xmm0, (%rax)
movl 0xcc(%rsi), %ecx
leal -0x1(%rcx), %edx
imull %ecx, %edx
cvtsi2sd %edx, %xmm0
divsd %xmm0, %xmm3
mulsd %xmm3, %xmm2
movsd %xmm2, (%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5a406
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x5a406
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2b43c
movq %r14, %rdi
callq 0x8870