// File: /workspace/github_cpp_makefile_star2_O2/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 %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 0x23e6f
movapd %xmm0, %xmm1
movq %rdi, %rbx
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x23e11
movsd %xmm1, 0x8(%rsp)
movq (%rbx), %rax
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x28(%rax)
cmpb $0x0, 0x15(%rbx)
jne 0x23d3f
leaq 0xb197(%rip), %rsi      # 0x2eea9
leaq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x5160
leaq 0x1d7a8(%rip), %rdi     # 0x414d0
leaq 0x48(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
leaq 0x48(%rsp), %rdi
callq 0x5908
movq %rbx, %rdi
callq 0x1ce64
movl %eax, %ebp
cmpl $0x2, %eax
setae %al
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %cl
orb %al, %cl
jne 0x23d68
movb $0x0, 0xc(%rbx)
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movapd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x1cf20
movq %rbx, %rdi
callq 0x1cea2
movq 0x30(%rsp), %rcx
movl %ebp, %edx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %edi, %edi
movsd 0x8(%rsp), %xmm1
movsd 0x28(%rsp), %xmm2
cmpq %rdi, %rdx
je 0x23dda
movl (%rcx,%rdi,4), %r8d
cmpl %r8d, %esi
cmovgel %r8d, %esi
testq %rdi, %rdi
je 0x23dd5
cvtsi2sd %r8d, %xmm0
ucomisd %xmm0, %xmm2
ja 0x23dd1
ucomisd 0x20(%rsp), %xmm0
jbe 0x23dd5
movb $0x0, 0xc(%rbx)
incq %rdi
jmp 0x23da9
cvtsi2sd %esi, %xmm0
ucomisd %xmm0, %xmm1
ja 0x23dec
ucomisd 0x10(%rsp), %xmm0
jbe 0x23df0
movb $0x0, 0xc(%rbx)
subl 0x4(%rsp), %eax
cvtsi2sd %rax, %xmm0
ucomisd 0x18(%rsp), %xmm0
jbe 0x23e05
movb $0x0, 0xc(%rbx)
leaq 0x30(%rsp), %rdi
callq 0xa18e
jmp 0x23e6f
movsd 0x10(%rsp), %xmm0
ucomisd 0xae31(%rip), %xmm0     # 0x2ec50
jne 0x23cdb
jp 0x23cdb
xorpd %xmm0, %xmm0
ucomisd 0x28(%rsp), %xmm0
jb 0x23cdb
movsd 0x20(%rsp), %xmm0
ucomisd 0xae07(%rip), %xmm0     # 0x2ec50
jne 0x23cdb
jp 0x23cdb
movsd 0x18(%rsp), %xmm0
ucomisd 0xaded(%rip), %xmm0     # 0x2ec50
jne 0x23cdb
jp 0x23cdb
addq $0x68, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5908
jmp 0x23e97
movq %rax, %rbx
jmp 0x23e97
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xa18e
movq %rbx, %rdi
callq 0x5800
nop