// File: /workspace/github_cpp_makefile_star2_O3/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 0x2bcc9
movapd %xmm0, %xmm1
movq %rdi, %rbx
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x2bc29
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 0x2bb79
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xe407(%rip), %rsi      # 0x39f49
leaq 0xe450(%rip), %rdx      # 0x39f99
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0xc85e
leaq 0x1d94b(%rip), %rdi     # 0x494a8
movq %r14, %rsi
movl $0x1, %edx
callq 0x36ec8
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bb79
callq 0x5410
movq %rbx, %rdi
callq 0x22eb0
movl %eax, %ebp
cmpl $0x2, %eax
setae %al
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %cl
orb %al, %cl
jne 0x2bba2
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 0x22f60
movq %rbx, %rdi
callq 0x22eee
testl %ebp, %ebp
movsd 0x8(%rsp), %xmm1
je 0x2bc88
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 0x2bc18
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
ucomisd %xmm0, %xmm2
ja 0x2bc14
ucomisd 0x20(%rsp), %xmm0
jbe 0x2bc18
movb $0x0, 0xc(%rbx)
incq %rdi
cmpq %rdi, %rdx
jne 0x2bbee
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
jmp 0x2bc90
movsd 0x10(%rsp), %xmm0
ucomisd 0xe0b9(%rip), %xmm0     # 0x39cf0
jne 0x2baff
jp 0x2baff
xorpd %xmm0, %xmm0
ucomisd 0x28(%rsp), %xmm0
jb 0x2baff
movsd 0x20(%rsp), %xmm0
ucomisd 0xe08f(%rip), %xmm0     # 0x39cf0
jne 0x2baff
jp 0x2baff
movsd 0x18(%rsp), %xmm0
ucomisd 0xe075(%rip), %xmm0     # 0x39cf0
jne 0x2baff
jnp 0x2bcc9
jmp 0x2baff
movsd 0xe060(%rip), %xmm0     # 0x39cf0
ucomisd %xmm0, %xmm1
ja 0x2bc9e
ucomisd 0x10(%rsp), %xmm0
jbe 0x2bca2
movb $0x0, 0xc(%rbx)
subl 0x4(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd 0x18(%rsp), %xmm0
jbe 0x2bcba
movb $0x0, 0xc(%rbx)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bcc9
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 0x2bcf0
jmp 0x2bcf5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bcf5
callq 0x5410
movq %rbx, %rdi
callq 0x57d0
nop