// File: /workspace/github_cpp_makefile_star2_O1/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 0x52b63
movl 0xc(%rsp), %esi
sarq $0x2, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %edi, %edi
cmpl $0x1, (%rax,%rdi,4)
jne 0x52b5b
incl %esi
movl %esi, 0xc(%rsp)
incq %rdi
cmpq %rdi, %rdx
jne 0x52b4f
movslq 0xc(%rsp), %rax
movq (%rcx), %rcx
incl (%rcx,%rax,4)
callq 0x8140
cvtsi2sd %eax, %xmm0
divsd 0x77589(%rip), %xmm0    # 0xca108
movsd 0x84311(%rip), %xmm1    # 0xd6e98
ucomisd %xmm0, %xmm1
jbe 0x52c1b
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x52bbf
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x52bce
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x4bc3a
leaq 0x10(%r14), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x52bed
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x52bf7
leaq 0x10(%rsp), %rdi
callq 0x4bc3a
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0x4ae84
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x52c1b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movl 0xc(%rsp), %ebp
addq $0x10, %r14
cmpl %ebx, %ebp
jg 0x52c40
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x52c5c
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x52c6c
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x52c61
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r12)
jmp 0x52c6c
movq %r15, %rdi
jmp 0x52c64
movq %r12, %rdi
movq %r14, %rdx
callq 0x4bc3a
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 0x52c9a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8480
movq %rbx, %rdi
callq 0x8840