// File: /workspace/github_cpp_makefile_star2_O1/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_positions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void entry::filter_sites_by_positions(const string &positions_file, const string &exclude_positions_file)
{
	// Filter sites by a user defined file containing a list of positions
	if (passed_filters == false)
		return;

	if ((positions_file == "") && (exclude_positions_file == ""))
		return;

	int idx;
	if (keep_positions.empty() && positions_file != "")
	{
		string chr;
		int pos1;
		unsigned int N_chr=chr_to_idx.size();
		stringstream ss;
		string line;
		unsigned int gzMAX_LINE_LEN = 1024*1024;
		char *gz_readbuffer = new char[gzMAX_LINE_LEN];

		gzFile gz_in = gzopen(positions_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + positions_file);

		while (!gzeof(gz_in))
		{
			line = "";
			bool again = true;
			while (again == true)
			{
				gzgets(gz_in, gz_readbuffer, gzMAX_LINE_LEN);
				line.append(gz_readbuffer);
				if (strlen(gz_readbuffer) != gzMAX_LINE_LEN-1)
					again = false;
			}
			if (line[0] == '#')
				continue;
			line.erase( line.find_last_not_of(" \t\n\r") + 1);	// Trim whitespace at end of line (required in gzipped case!)

			ss.clear();
			ss.str(line);
			ss >> chr >> pos1;

			if (chr_to_idx.find(chr) == chr_to_idx.end())
			{
				N_chr++;
				chr_to_idx[chr] = (N_chr-1);
				keep_positions.resize(N_chr);
			}

			idx = chr_to_idx[chr];
			keep_positions[idx].insert(pos1);
		}
		gzclose(gz_in);
		delete [] gz_readbuffer;
	}
	if (exclude_positions.empty() && exclude_positions_file != "")
	{
		string chr;
		int pos1;
		unsigned int N_chr=0;
		stringstream ss;
		string line;
		unsigned int gzMAX_LINE_LEN = 1024*1024;
		char *gz_readbuffer = new char[gzMAX_LINE_LEN];

		gzFile gz_in = gzopen(exclude_positions_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + exclude_positions_file);

		while (!gzeof(gz_in))
		{
			line = "";
			bool again = true;
			while (again == true)
			{
				gzgets(gz_in, gz_readbuffer, gzMAX_LINE_LEN);
				line.append(gz_readbuffer);
				if (strlen(gz_readbuffer) != gzMAX_LINE_LEN-1)
					again = false;
			}
			if (line[0] == '#')
				continue;
			line.erase( line.find_last_not_of(" \t\n\r") + 1);	// Trim whitespace at end of line (required in gzipped case!)

			ss.clear();
			ss.str(line);
			ss >> chr >> pos1;

			if (chr_to_idx.find(chr) == chr_to_idx.end())
			{
				N_chr++;
				chr_to_idx[chr] = (N_chr-1);
				exclude_positions.resize(N_chr);
			}

			idx = chr_to_idx[chr];
			exclude_positions[idx].insert(pos1);
		}
		gzclose(gz_in);
		delete [] gz_readbuffer;
	}

	parse_basic_entry();

	if (!keep_positions.empty())
	{	// Check to see if position is in keep list
			if (chr_to_idx.find(CHROM) == chr_to_idx.end())
				passed_filters = false;
			else
			{
				idx = chr_to_idx[CHROM];
				bool found=false;

				if (keep_positions[idx].find(POS) != keep_positions[idx].end())
					found = true;

				if (found == false)
					passed_filters = false;
			}
	}
	if (!exclude_positions.empty())
	{	// Check to see if position is in exclude list
		if (chr_to_idx.find(CHROM) != chr_to_idx.end())
		{
			idx = chr_to_idx[CHROM];
			bool found=false;

			if (exclude_positions[idx].find(POS) != exclude_positions[idx].end())
				found = true;

				if (found == true)
					passed_filters = false;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
cmpb $0x0, 0xc(%rdi)
je 0x29407
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x11ca8(%rip), %rsi     # 0x3aeff
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
jne 0x2927a
leaq 0x11c95(%rip), %rsi     # 0x3aeff
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x29407
movq 0x220a7(%rip), %rax     # 0x4b328
cmpq 0x220a8(%rip), %rax     # 0x4b330
je 0x29419
movq 0x220ab(%rip), %rax     # 0x4b340
cmpq 0x220ac(%rip), %rax     # 0x4b348
je 0x2965b
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq 0x22070(%rip), %rax     # 0x4b328
cmpq 0x22071(%rip), %rax     # 0x4b330
je 0x2935c
leaq 0x3e0(%rbx), %r14
leaq 0x22085(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1818e
leaq 0x2207e(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
je 0x29358
leaq 0x2206a(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1785c
movslq (%rax), %rax
movq 0x22028(%rip), %rcx     # 0x4b328
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
movq 0x8(%rax), %rdx
movq %rax, %rcx
testq %rdx, %rdx
je 0x2933b
movl 0x400(%rbx), %esi
movq %rax, %rcx
xorl %edi, %edi
cmpl %esi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x29324
movq %rax, %rdx
cmpq %rax, %rcx
je 0x29353
movl 0x400(%rbx), %edx
cmpl 0x20(%rcx), %edx
cmovlq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
jne 0x2935c
movb $0x0, 0xc(%rbx)
movq 0x21fdd(%rip), %rax     # 0x4b340
cmpq 0x21fde(%rip), %rax     # 0x4b348
je 0x29407
leaq 0x3e0(%rbx), %r14
leaq 0x21fda(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1818e
leaq 0x21fd3(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
je 0x29407
leaq 0x21fbf(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1785c
movslq (%rax), %rax
movq 0x21f95(%rip), %rcx     # 0x4b340
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rcx, %rax
addq $0x8, %rax
movq 0x8(%rax), %rdx
movq %rax, %rcx
testq %rdx, %rdx
je 0x293e6
movl 0x400(%rbx), %esi
movq %rax, %rcx
xorl %edi, %edi
cmpl %esi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x293cf
movq %rax, %rdx
cmpq %rax, %rcx
je 0x293fe
movl 0x400(%rbx), %edx
cmpl 0x20(%rcx), %edx
cmovlq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x29407
movb $0x0, 0xc(%rbx)
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11adf(%rip), %rsi     # 0x3aeff
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2928e
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x21f35(%rip), %r12d    # 0x4b380
leaq 0xa0(%rsp), %rdi
callq 0x52e0
movq %rbx, 0x50(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r13
movq (%r15), %rdi
leaq 0x1009a(%rip), %rsi     # 0x39522
callq 0x5650
movq %rax, %rbp
testq %rax, %rax
jne 0x294db
leaq 0x119f1(%rip), %rsi     # 0x3ae8d
leaq 0x80(%rsp), %rdi
movq %r15, %rdx
callq 0xb7dd
leaq 0x20ff5(%rip), %rdi     # 0x4a4a8
leaq 0x80(%rsp), %rsi
movl $0x1, %edx
callq 0x3721e
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x294db
callq 0x5410
movq %r12, 0x58(%rsp)
movq %r14, 0x28(%rsp)
leaq 0x11a13(%rip), %r12     # 0x3aeff
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %rbp, %rdi
callq 0x5110
testl %eax, %eax
jne 0x2988c
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x5690
movb $0x1, %bl
movq %rbp, %rdi
movq %r13, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x5770
movq %r15, %rdi
movq %r13, %rsi
callq 0x5870
movq %r13, %rdi
callq 0x5180
cmpq $0xfffff, %rax          # imm = 0xFFFFF
movzbl %bl, %ebx
cmovnel %r14d, %ebx
testb $0x1, %bl
jne 0x2951b
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x294f4
movl $0x4, %ecx
movq %r15, %rdi
leaq 0x101f4(%rip), %rsi     # 0x3975d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x2995f
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xa0(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5750
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x5640
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5590
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x5230
leaq 0x21d70(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1818e
leaq 0x21d67(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
jne 0x29629
leaq 0x21d53(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movq 0x58(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x21d09(%rip), %rdi     # 0x4b328
movq %rsi, 0x58(%rsp)
callq 0x2c56c
leaq 0x21d28(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x21cdc(%rip), %rdi     # 0x4b328
leaq 0x4(%rsp), %rsi
callq 0x2cda0
jmp 0x294f4
leaq 0x1189d(%rip), %rsi     # 0x3aeff
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x292a2
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xa0(%rsp), %rdi
callq 0x52e0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r12
movq (%r14), %rdi
leaq 0xfe64(%rip), %rsi      # 0x39522
callq 0x5650
movq %rax, %r13
testq %rax, %rax
jne 0x29708
leaq 0x117bb(%rip), %rsi     # 0x3ae8d
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0xb7dd
leaq 0x20dc2(%rip), %rdi     # 0x4a4a8
leaq 0x60(%rsp), %rsi
movl $0x1, %edx
callq 0x3721e
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29708
callq 0x5410
movq %rbx, 0x50(%rsp)
xorl %r15d, %r15d
leaq 0x117e8(%rip), %rbp     # 0x3aeff
leaq 0x8(%rsp), %r14
movq $0x0, 0x28(%rsp)
movq %r13, %rdi
callq 0x5110
testl %eax, %eax
jne 0x298f8
movq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x5690
movb $0x1, %bl
movq %r13, %rdi
movq %r12, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x5770
movq %r14, %rdi
movq %r12, %rsi
callq 0x5870
movq %r12, %rdi
callq 0x5180
cmpq $0xfffff, %rax          # imm = 0xFFFFF
movzbl %bl, %ebx
cmovnel %r15d, %ebx
testb $0x1, %bl
jne 0x2974c
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29725
movl $0x4, %ecx
movq %r14, %rdi
leaq 0xffc3(%rip), %rsi      # 0x3975d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x29977
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xa0(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5750
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq 0x5640
leaq 0xa0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5590
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x5230
leaq 0x21b3f(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1818e
leaq 0x21b36(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
jne 0x2985a
leaq 0x21b22(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movq 0x28(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x21af0(%rip), %rdi     # 0x4b340
movq %rsi, 0x28(%rsp)
callq 0x2c56c
leaq 0x21af7(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x21ac3(%rip), %rdi     # 0x4b340
leaq 0x4(%rsp), %rsi
callq 0x2cda0
jmp 0x29725
movq %rbp, %rdi
callq 0x5740
movq 0x28(%rsp), %r14
movq %r13, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
movq 0x50(%rsp), %rbx
je 0x298ba
callq 0x5410
movq 0x206bf(%rip), %rsi     # 0x49f80
leaq 0xa0(%rsp), %rdi
callq 0x5330
leaq 0x120(%rsp), %rdi
callq 0x5100
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2928e
callq 0x5410
jmp 0x2928e
movq %r13, %rdi
callq 0x5740
movq 0x50(%rsp), %rbx
movq %r12, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x29921
callq 0x5410
movq 0x20658(%rip), %rsi     # 0x49f80
leaq 0xa0(%rsp), %rdi
callq 0x5330
leaq 0x120(%rsp), %rdi
callq 0x5100
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x292a2
callq 0x5410
jmp 0x292a2
leaq 0xfc58(%rip), %rdi      # 0x395be
leaq 0xfc88(%rip), %rsi      # 0x395f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
leaq 0xfc40(%rip), %rdi      # 0x395be
leaq 0xfc70(%rip), %rsi      # 0x395f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x70(%rsp), %rax
jmp 0x299a4
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x299d8
callq 0x5410
jmp 0x299d8
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299c2
jmp 0x299d5
movq %rax, %rbx
jmp 0x29a0d
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
jmp 0x299d5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x299ec
callq 0x5410
movq 0x2058d(%rip), %rsi     # 0x49f80
leaq 0xa0(%rsp), %rdi
callq 0x5330
leaq 0x120(%rsp), %rdi
callq 0x5100
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x29a21
callq 0x5410
movq %rbx, %rdi
callq 0x57d0
nop