// File: auton1[P]viterbi/entry_filters.cpp
// Function: entry::apply_filters(parameters const&)
int entry::apply_filters(const parameters &params)
{
	if (line.empty())
	{
		passed_filters = false;
		return 0;
	}

// 	Apply all filters in turn.
	filter_sites_by_allele_type(params.keep_only_indels, params.remove_indels);
	filter_sites(params.snps_to_keep, params.snps_to_keep_file, params.snps_to_exclude_file);
	filter_sites_by_filter_status(params.site_filter_flags_to_exclude, params.site_filter_flags_to_keep, params.remove_all_filtered_sites);
	string chr_to_keep = "";
	if (params.chrs_to_keep.size() == 1)
		chr_to_keep = *(params.chrs_to_keep.begin()); // Get first chromosome in list (there should only be one).
	filter_sites_by_position(chr_to_keep, params.start_pos, params.end_pos);
	filter_sites_by_positions(params.positions_file, params.exclude_positions_file);
	filter_sites_by_overlap_positions(params.positions_overlap_file, params.exclude_positions_overlap_file);
	filter_sites_by_chromosome(params.chrs_to_keep, params.chrs_to_exclude);
	filter_sites_by_BED_file(params.BED_file, params.BED_exclude);
	filter_sites_by_number_of_alleles(params.min_alleles, params.max_alleles);
	filter_sites_by_INFO(params.site_INFO_flags_to_remove, params.site_INFO_flags_to_keep);
	filter_sites_by_quality(params.min_quality);
	filter_sites_by_mean_depth(params.min_mean_depth, params.max_mean_depth);
	filter_sites_by_mask(params.mask_file, params.invert_mask, params.min_kept_mask_value);
	if (params.phased_only == true)
		filter_sites_by_phase();
	filter_genotypes_by_quality_value(params.min_genotype_quality);
	filter_genotypes_by_depth_range(params.min_genotype_depth, params.max_genotype_depth);
	filter_genotypes_by_filter_flag(params.geno_filter_flags_to_exclude, params.remove_all_filtered_genotypes);
	filter_sites_by_frequency_and_call_rate(params.min_maf, params.max_maf, params.min_non_ref_af, params.max_non_ref_af, params.min_site_call_rate);
	filter_sites_by_allele_count(params.min_mac, params.max_mac, params.min_non_ref_ac, params.max_non_ref_ac, params.max_missing_call_count);
	filter_sites_by_HWE_pvalue(params.min_HWE_pvalue);
	filter_sites_by_thinning(params.min_interSNP_distance);

	return 1;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x58(%rsp), %rdi
movq %rdi, 0x8(%rsp)
addq $0x3c0, %rdi            # imm = 0x3C0
callq 0x39540
testb $0x1, %al
jne 0x595ba
jmp 0x595d0
movq 0x8(%rsp), %rax
movb $0x0, 0xc(%rax)
movl $0x0, 0x64(%rsp)
jmp 0x5996f
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movzbl 0x2fa(%rax), %edx
movzbl 0x1d9(%rax), %esi
andl $0x1, %esi
andl $0x1, %edx
callq 0x59990
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rcx
movq %rcx, %rsi
addq $0x400, %rsi            # imm = 0x400
movq %rcx, %rdx
addq $0x3e0, %rdx            # imm = 0x3E0
addq $0x3c0, %rcx            # imm = 0x3C0
xorl %r8d, %r8d
callq 0x59c10
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, %rsi
addq $0x300, %rsi            # imm = 0x300
movq %rax, %rdx
addq $0x330, %rdx            # imm = 0x330
movzbl 0x2f9(%rax), %ecx
andl $0x1, %ecx
callq 0x59c90
leaq 0x2f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x69f0
movq (%rsp), %rdx
leaq 0x1c6c3(%rip), %rsi     # 0x75d29
leaq 0x30(%rsp), %rdi
callq 0x67c0
jmp 0x59672
leaq 0x2f(%rsp), %rdi
callq 0x65f0
movq 0x50(%rsp), %rdi
addq $0x58, %rdi
callq 0x10b30
cmpq $0x1, %rax
jne 0x596f8
movq 0x50(%rsp), %rdi
addq $0x58, %rdi
callq 0x10ad0
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x10b00
movq %rax, %rsi
leaq 0x30(%rsp), %rdi
callq 0x6060
jmp 0x596bc
jmp 0x596f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x2f(%rsp), %rdi
callq 0x65f0
jmp 0x59978
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x20(%rsp)
movl %eax, 0x1c(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x6b50
jmp 0x59978
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movl 0x430(%rax), %edx
movl 0xa8(%rax), %ecx
leaq 0x30(%rsp), %rsi
callq 0x5a000
jmp 0x5971a
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq %rdx, %rsi
addq $0x2b8, %rsi            # imm = 0x2B8
addq $0xb0, %rdx
callq 0x5a0d0
jmp 0x5973c
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq %rdx, %rsi
addq $0x2d8, %rsi            # imm = 0x2D8
addq $0xd0, %rdx
callq 0x5ad70
jmp 0x5975e
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq %rdx, %rsi
addq $0x58, %rsi
addq $0x28, %rdx
callq 0x5bb20
jmp 0x5977a
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, %rsi
addq $0x8, %rsi
movzbl 0x1(%rax), %edx
andl $0x1, %edx
callq 0x5bc30
jmp 0x59799
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movl 0x208(%rax), %edx
movl 0x23c(%rax), %esi
callq 0x5ca40
jmp 0x597b6
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rdx
movq %rdx, %rsi
addq $0x390, %rsi            # imm = 0x390
addq $0x360, %rdx            # imm = 0x360
callq 0x5cad0
jmp 0x597d8
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x278(%rax), %xmm0
callq 0x5d040
jmp 0x597f1
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x220(%rax), %xmm1
movsd 0x260(%rax), %xmm0
callq 0x5d170
jmp 0x59812
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, %rsi
addq $0x1e8, %rsi            # imm = 0x1E8
movl 0x25c(%rax), %ecx
movzbl 0x1d8(%rax), %edx
andl $0x1, %edx
callq 0x5d410
jmp 0x5983d
movq 0x50(%rsp), %rax
movb 0x2b4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x59860
movq 0x8(%rsp), %rdi
callq 0x5d8c0
jmp 0x5985e
jmp 0x59860
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x248(%rax), %xmm0
callq 0x5d9a0
jmp 0x59879
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movl 0x20c(%rax), %edx
movl 0x240(%rax), %esi
callq 0x5dac0
jmp 0x59896
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, %rsi
addq $0xf0, %rsi
movzbl 0x2f8(%rax), %edx
andl $0x1, %edx
callq 0x5dbf0
jmp 0x598bb
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x1e0(%rax), %xmm0
movsd 0x218(%rax), %xmm1
movsd 0x270(%rax), %xmm2
movsd 0x230(%rax), %xmm3
movsd 0x288(%rax), %xmm4
callq 0x5dd30
jmp 0x598f4
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
cvtsi2sdl 0x1dc(%rax), %xmm0
cvtsi2sdl 0x210(%rax), %xmm1
cvtsi2sdl 0x268(%rax), %xmm2
cvtsi2sdl 0x22c(%rax), %xmm3
cvtsi2sdl 0x228(%rax), %xmm4
callq 0x5e0e0
jmp 0x5992d
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x250(%rax), %xmm0
callq 0x5e460
jmp 0x59946
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rax
movl 0x258(%rax), %esi
callq 0x5e5e0
jmp 0x5995d
movl $0x1, 0x64(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x6b50
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
movq 0x20(%rsp), %rdi
callq 0x69e0
nopw %cs:(%rax,%rax)