// File: /workspace/github_cpp_makefile_star2_O1/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_allele_count(double, double, double, double, double)
void entry::filter_sites_by_allele_count(double min_mac, double max_mac, double min_non_ref_ac, double max_non_ref_ac, double max_missing_call_count)
{
	// Filter sites so that all allele counts are between limits
	if (passed_filters == false)
		return;

	if ((min_mac <= 0) && (max_mac == numeric_limits<int>::max()) &&
			(min_non_ref_ac <= 0) && (max_non_ref_ac == numeric_limits<int>::max()) &&
			(max_missing_call_count == numeric_limits<int>::max()))
		return;

	unsigned int N_alleles, N_chr, N_non_missing_chr;
	parse_basic_entry(true);
	parse_genotype_entries(true);

	if (entry_header.has_genotypes == false)
		LOG.error("Require Genotypes in variant file to filter by allele counts and/or missing data");

	N_alleles = get_N_alleles();

	if (N_alleles <= 1 && min_mac > 0)
		passed_filters = false;

	vector<int> allele_counts;
	get_allele_counts(allele_counts, N_non_missing_chr);
	N_chr = get_N_chr();

	int mac = numeric_limits<int>::max();
	for (unsigned int ui=0; ui<N_alleles; ui++)
	{
		mac = min(allele_counts[ui], mac);
		if ((ui > 0) && ((allele_counts[ui] < min_non_ref_ac) || (allele_counts[ui] > max_non_ref_ac)))
			passed_filters = false;
	}

	if ((mac < min_mac) || (mac > max_mac))
		passed_filters = false;

	if ((N_chr-N_non_missing_chr) > max_missing_call_count)
		passed_filters = false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movsd %xmm4, 0x18(%rsp)
movsd %xmm3, 0x20(%rsp)
movsd %xmm2, 0x28(%rsp)
movsd %xmm1, 0x10(%rsp)
cmpb $0x0, 0xc(%rdi)
je 0x2bf4b
movapd %xmm0, %xmm1
movq %rdi, %rbx
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x2beab
movsd %xmm1, 0x8(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x28(%rax)
cmpb $0x0, 0x15(%rbx)
jne 0x2bdfb
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf1ad(%rip), %rsi      # 0x3af71
leaq 0xf1f6(%rip), %rdx      # 0x3afc1
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0xc868
leaq 0x1e6c9(%rip), %rdi     # 0x4a4a8
movq %r14, %rsi
movl $0x1, %edx
callq 0x3721e
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bdfb
callq 0x5410
movq %rbx, %rdi
callq 0x230f4
movl %eax, %ebp
cmpl $0x2, %eax
setae %al
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %cl
orb %al, %cl
jne 0x2be24
movb $0x0, 0xc(%rbx)
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x231a4
movq %rbx, %rdi
callq 0x23132
testl %ebp, %ebp
movsd 0x8(%rsp), %xmm1
je 0x2bf0a
movq 0x30(%rsp), %rcx
movl %ebp, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %edi, %edi
movsd 0x28(%rsp), %xmm2
movl (%rcx,%rdi,4), %r8d
cmpl %r8d, %esi
cmovgel %r8d, %esi
testq %rdi, %rdi
je 0x2be9a
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
ucomisd %xmm0, %xmm2
ja 0x2be96
ucomisd 0x20(%rsp), %xmm0
jbe 0x2be9a
movb $0x0, 0xc(%rbx)
incq %rdi
cmpq %rdi, %rdx
jne 0x2be70
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
jmp 0x2bf12
movsd 0x10(%rsp), %xmm0
ucomisd 0xee5f(%rip), %xmm0     # 0x3ad18
jne 0x2bd81
jp 0x2bd81
xorpd %xmm0, %xmm0
ucomisd 0x28(%rsp), %xmm0
jb 0x2bd81
movsd 0x20(%rsp), %xmm0
ucomisd 0xee35(%rip), %xmm0     # 0x3ad18
jne 0x2bd81
jp 0x2bd81
movsd 0x18(%rsp), %xmm0
ucomisd 0xee1b(%rip), %xmm0     # 0x3ad18
jne 0x2bd81
jnp 0x2bf4b
jmp 0x2bd81
movsd 0xee06(%rip), %xmm0     # 0x3ad18
ucomisd %xmm0, %xmm1
ja 0x2bf20
ucomisd 0x10(%rsp), %xmm0
jbe 0x2bf24
movb $0x0, 0xc(%rbx)
subl 0x4(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd 0x18(%rsp), %xmm0
jbe 0x2bf3c
movb $0x0, 0xc(%rbx)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bf4b
callq 0x5410
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
jne 0x2bf72
jmp 0x2bf77
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bf77
callq 0x5410
movq %rbx, %rdi
callq 0x57d0
nop