// File: /workspace/github_cpp_makefile_star2_O3/millanek[P]evo/process_vcf_utils.cpp
// Function: testMaxNumHet(FilterResult&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&)
bool testMaxNumHet(FilterResult& result, std::vector<int>& depthsHetFailed, std::vector<int>& depthsHetPassed, std::vector<int>& numVariantsPerHetCount, int maxNumHet, std::vector<std::vector<int> >& num_indiv_het_vs_depth) {
    // filter out sites where more than MAX_NUM_HET individuals are heterozygous
    int num_hets = 0;
    for (std::vector<std::vector<int> >::size_type i = 0; i < result.counts.individualsWithVariant.size(); i++) {
        if (result.counts.individualsWithVariant[i] == 1)
            num_hets++;
    }
    numVariantsPerHetCount[num_hets]++;
    
    // Randomly sample 1% of sites for num_indiv_het vs depth scatterplot
    double rn = ((double) rand() / RAND_MAX);
    if (rn < 0.01) {
        std::vector<int> this_num_het_depth; this_num_het_depth.push_back(num_hets); this_num_het_depth.push_back(result.counts.overallDepth); 
        num_indiv_het_vs_depth.push_back(this_num_het_depth);
    }
    
    if (num_hets > maxNumHet) {
        depthsHetFailed.push_back(result.counts.overallDepth);
        return false;
    } else {
        depthsHetPassed.push_back(result.counts.overallDepth);
        return true;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r13
movl %r8d, %ebx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
movl $0x0, 0xc(%rsp)
movq 0x78(%rdi), %rax
movq 0x80(%rdi), %rdx
subq %rax, %rdx
je 0x4f9b6
sarq $0x2, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %esi, %esi
xorl %ebp, %ebp
cmpl $0x1, (%rax,%rsi,4)
jne 0x4f9ac
incl %ebp
movl %ebp, 0xc(%rsp)
incq %rsi
cmpq %rsi, %rdx
jne 0x4f9a0
jmp 0x4f9b8
xorl %ebp, %ebp
movslq %ebp, %rax
movq (%rcx), %rcx
incl (%rcx,%rax,4)
callq 0x8140
cvtsi2sd %eax, %xmm0
divsd 0x8094e(%rip), %xmm0    # 0xd0320
movsd 0x8094e(%rip), %xmm1    # 0xd0328
ucomisd %xmm0, %xmm1
jbe 0x4fa52
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq 0xc(%rsp), %rdx
xorl %esi, %esi
callq 0x48c2e
movq 0x18(%rsp), %rsi
leaq 0x10(%r14), %rdx
cmpq 0x20(%rsp), %rsi
je 0x4fa20
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4fa2a
leaq 0x10(%rsp), %rdi
callq 0x48c2e
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x47e6a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4fa4e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movl 0xc(%rsp), %ebp
addq $0x10, %r14
cmpl %ebx, %ebp
jg 0x4fa73
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x4fa8f
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x4fa9f
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x4fa94
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r12)
jmp 0x4fa9f
movq %r15, %rdi
jmp 0x4fa97
movq %r12, %rdi
movq %r14, %rdx
callq 0x48c2e
cmpl %ebx, %ebp
setle %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4facd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq %rbx, %rdi
callq 0x8840