// File: /workspace/github_cpp_makefile_star2_O1/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_mask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool, int)
void entry::filter_sites_by_mask(const string &mask_file, bool invert_mask, int min_kept_mask_value)
{
	// Filter sites on the basis of a fasta-like mask file.
	if (passed_filters == false || mask_file == "")
		return;

	if (!mask.is_open())
	{
		mask.open(mask_file.c_str());
		mask_chr = "";
		mask_line = "";

		if (!mask.is_open())
			LOG.error("Could not open mask file: " + mask_file);
	}

	string line;
	string next_chr="";
	unsigned int next_pos = 0;

	parse_basic_entry();
	next_chr = CHROM;

	if (mask_chr != next_chr)
	{
		mask_chr = "";
		mask_line = "";
		while (!mask.eof())
		{
			getline(mask, line);
			line.erase( line.find_last_not_of(" \t") + 1);

			if (line[0] == '>')
			// Header
				mask_chr = line.substr(1, line.find_first_of(" \t")-1);
			else
			{
				mask_line = line;
				if (mask_chr == next_chr)
					break;
			}
		}
	}

	if (next_chr == mask_chr)
		next_pos = (unsigned)POS;
	else
	{
		passed_filters = false;
		return;
	}

	if (next_pos <= mask_line.size())
	{
		char mask_base = mask_line[next_pos-1]-48;
		bool keep = (mask_base <= min_kept_mask_value);

		if (invert_mask == true)
			keep = !keep;

		if (keep == false)
			passed_filters = false;
	}
	else
		passed_filters = false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %ecx, (%rsp)
movl %edx, 0x4(%rsp)
cmpb $0x0, 0xc(%rdi)
je 0x2b802
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xfa28(%rip), %rsi      # 0x3aeff
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2b802
leaq 0x1ff2a(%rip), %rdi     # 0x4b418
callq 0x50b0
testb %al, %al
jne 0x2b59a
movq (%r14), %rsi
leaq 0x1fe9b(%rip), %rdi     # 0x4b3a0
movl $0x8, %edx
callq 0x5240
movq 0x2009a(%rip), %rdx     # 0x4b5b0
leaq 0x2008b(%rip), %rdi     # 0x4b5a8
leaq 0xf9db(%rip), %r15      # 0x3aeff
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x5690
movq 0x20098(%rip), %rdx     # 0x4b5d0
leaq 0x20089(%rip), %rdi     # 0x4b5c8
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x5690
leaq 0x1fec5(%rip), %rdi     # 0x4b418
callq 0x50b0
testb %al, %al
jne 0x2b59a
leaq 0xf97f(%rip), %rsi      # 0x3aee2
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xb7dd
leaq 0x1ef2e(%rip), %rdi     # 0x4a4a8
movq %r15, %rsi
movl $0x1, %edx
callq 0x3721e
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b59a
callq 0x5410
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xf941(%rip), %rdx      # 0x3aeff
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0xc868
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
leaq 0x3e0(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x51f0
movq 0x1ffbe(%rip), %r14     # 0x4b5b0
cmpq 0x10(%rsp), %r14
jne 0x2b61e
testq %r14, %r14
je 0x2b782
movq 0x8(%rsp), %rsi
movq 0x1ff9a(%rip), %rdi     # 0x4b5a8
movq %r14, %rdx
callq 0x5470
testl %eax, %eax
je 0x2b782
leaq 0x1ff83(%rip), %rdi     # 0x4b5a8
leaq 0xf8d3(%rip), %rcx      # 0x3aeff
xorl %esi, %esi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0x5690
movq 0x1ff90(%rip), %rdx     # 0x4b5d0
leaq 0x1ff81(%rip), %rdi     # 0x4b5c8
leaq 0xf8b1(%rip), %rcx      # 0x3aeff
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x5690
leaq 0x1fd41(%rip), %r15     # 0x4b3a0
movq 0x1fd3a(%rip), %rax     # 0x4b3a0
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rdi,%r15)
jne 0x2b782
addq %r15, %rdi
leaq 0x28(%rsp), %r12
leaq 0xf878(%rip), %r13      # 0x3aefd
leaq 0x48(%rsp), %rbp
leaq 0x1ff37(%rip), %r14     # 0x4b5c8
movl $0xa, %esi
callq 0x5440
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5830
movl $0x2, %ecx
movq %r12, %rdi
movq %r13, %rsi
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x30(%rsp), %rcx
cmpq %rax, %rcx
jb 0x2b814
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x28(%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x2b734
movl $0x2, %ecx
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x5670
leaq -0x1(%rax), %rcx
movl $0x1, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5480
leaq 0x1fe92(%rip), %rdi     # 0x4b5a8
movq %rbp, %rsi
callq 0x5550
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2b767
callq 0x5410
jmp 0x2b767
movq %r14, %rdi
movq %r12, %rsi
callq 0x51f0
movq 0x1fe6a(%rip), %rdx     # 0x4b5b0
cmpq 0x10(%rsp), %rdx
jne 0x2b767
testq %rdx, %rdx
je 0x2b782
movq 0x8(%rsp), %rsi
movq 0x1fe4a(%rip), %rdi     # 0x4b5a8
callq 0x5470
testl %eax, %eax
je 0x2b782
movq 0x1fc32(%rip), %rax     # 0x4b3a0
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
testb $0x2, 0x20(%rax,%r15)
je 0x2b691
movq 0x10(%rsp), %rdx
cmpq 0x1fe22(%rip), %rdx     # 0x4b5b0
jne 0x2b7d6
testq %rdx, %rdx
je 0x2b7aa
movq 0x1fe0c(%rip), %rsi     # 0x4b5a8
movq 0x8(%rsp), %rdi
callq 0x5470
testl %eax, %eax
jne 0x2b7d6
movl 0x400(%rbx), %eax
cmpq %rax, 0x1fe19(%rip)     # 0x4b5d0
jb 0x2b7d6
decl %eax
movq 0x1fe06(%rip), %rcx     # 0x4b5c8
movb (%rcx,%rax), %al
addb $-0x30, %al
movsbl %al, %eax
cmpl (%rsp), %eax
setle %al
xorb 0x4(%rsp), %al
jne 0x2b7da
movb $0x0, 0xc(%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2b7ee
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2b802
callq 0x5410
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdda3(%rip), %rdi      # 0x395be
leaq 0xddd3(%rip), %rsi      # 0x395f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x2b864
movq %rax, %rbx
jmp 0x2b85a
jmp 0x2b843
jmp 0x2b843
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2b85a
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2b86e
callq 0x5410
movq %rbx, %rdi
callq 0x57d0