// File: /workspace/github_cpp_makefile_star2_O1/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_overlap_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_overlap_positions(const string &positions_overlap_file, const string &exclude_positions_overlap_file)
{
	// Filter sites by overlapping with a user defined file containing a list of positions
	if (passed_filters == false)
		return;

	if ((positions_overlap_file == "") && (exclude_positions_overlap_file == ""))
		return;

	int idx;
	if (keep_positions.empty() && positions_overlap_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_overlap_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + positions_overlap_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_overlap_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_overlap_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + exclude_positions_overlap_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;

				for (unsigned int ui=POS; ui<(POS+REF.size()); ui++)
					if (keep_positions[idx].find(ui) != keep_positions[idx].end())
					{
						found = true;
						break;
					}

				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;

			for (unsigned int ui=POS; ui<(POS+REF.size()); ui++)
				if (exclude_positions[idx].find(ui) != 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 0x29c4c
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x114aa(%rip), %rsi     # 0x3aeff
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
jne 0x29a78
leaq 0x11497(%rip), %rsi     # 0x3aeff
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x29c4c
movq 0x218a9(%rip), %rax     # 0x4b328
cmpq 0x218aa(%rip), %rax     # 0x4b330
je 0x29c5e
movq 0x218ad(%rip), %rax     # 0x4b340
cmpq 0x218ae(%rip), %rax     # 0x4b348
je 0x29ea0
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq 0x21872(%rip), %rax     # 0x4b328
cmpq 0x21873(%rip), %rax     # 0x4b330
je 0x29b73
leaq 0x3e0(%rbx), %r14
leaq 0x21887(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1818e
leaq 0x21880(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
je 0x29b6f
leaq 0x21868(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1785c
movl 0x400(%rbx), %ecx
movslq %ecx, %rdx
addq 0x430(%rbx), %rdx
cmpq %rcx, %rdx
jbe 0x29b6f
movslq (%rax), %rax
movq 0x21811(%rip), %rsi     # 0x4b328
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rsi, %rax
addq $0x8, %rax
movq 0x8(%rax), %rsi
movq %rax, %rdi
testq %rsi, %rsi
je 0x29b51
movq %rsi, %r8
movq %rax, %rdi
xorl %r9d, %r9d
cmpl %ecx, 0x20(%r8)
setl %r9b
cmovgeq %r8, %rdi
movq 0x10(%r8,%r9,8), %r8
testq %r8, %r8
jne 0x29b38
movq %rax, %r8
cmpq %rax, %rdi
je 0x29b63
cmpl 0x20(%rdi), %ecx
cmovlq %rax, %rdi
movq %rdi, %r8
cmpq %rax, %r8
jne 0x29b73
incl %ecx
cmpq %rcx, %rdx
ja 0x29b2a
movb $0x0, 0xc(%rbx)
movq 0x217c6(%rip), %rax     # 0x4b340
cmpq 0x217c7(%rip), %rax     # 0x4b348
je 0x29c4c
leaq 0x3e0(%rbx), %r14
leaq 0x217c3(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1818e
leaq 0x217bc(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
je 0x29c4c
leaq 0x217a4(%rip), %rdi     # 0x4b358
movq %r14, %rsi
callq 0x1785c
movl 0x400(%rbx), %ecx
movslq %ecx, %rdx
addq 0x430(%rbx), %rdx
cmpq %rcx, %rdx
jbe 0x29c4c
movslq (%rax), %rax
movq 0x21765(%rip), %rsi     # 0x4b340
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rsi, %rax
addq $0x8, %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
movl $0x1, %r8d
movq %rax, %r9
testq %rdi, %rdi
je 0x29c1d
movq %rdi, %r10
movq %rax, %r9
xorl %r11d, %r11d
cmpl %ecx, 0x20(%r10)
setl %r11b
cmovgeq %r10, %r9
movq 0x10(%r10,%r11,8), %r10
testq %r10, %r10
jne 0x29c04
movq %rax, %r10
cmpq %rax, %r9
je 0x29c30
cmpl 0x20(%r9), %ecx
cmovlq %rax, %r9
movq %r9, %r10
cmpq %rax, %r10
movzbl %sil, %esi
cmovnel %r8d, %esi
incl %ecx
cmpq %rcx, %rdx
ja 0x29bf6
testb $0x1, %sil
je 0x29c4c
movb $0x0, 0xc(%rbx)
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1129a(%rip), %rsi     # 0x3aeff
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
je 0x29a8c
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x216f0(%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 0xf855(%rip), %rsi      # 0x39522
callq 0x5650
movq %rax, %rbp
testq %rax, %rax
jne 0x29d20
leaq 0x111ac(%rip), %rsi     # 0x3ae8d
leaq 0x80(%rsp), %rdi
movq %r15, %rdx
callq 0xb7dd
leaq 0x207b0(%rip), %rdi     # 0x4a4a8
leaq 0x80(%rsp), %rsi
movl $0x1, %edx
callq 0x3721e
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29d20
callq 0x5410
movq %r12, 0x58(%rsp)
movq %r14, 0x28(%rsp)
leaq 0x111ce(%rip), %r12     # 0x3aeff
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %rbp, %rdi
callq 0x5110
testl %eax, %eax
jne 0x2a0d1
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 0x29d60
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29d39
movl $0x4, %ecx
movq %r15, %rdi
leaq 0xf9af(%rip), %rsi      # 0x3975d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x2a1a4
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 0x2152b(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1818e
leaq 0x21522(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
jne 0x29e6e
leaq 0x2150e(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movq 0x58(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x214c4(%rip), %rdi     # 0x4b328
movq %rsi, 0x58(%rsp)
callq 0x2c56c
leaq 0x214e3(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x21497(%rip), %rdi     # 0x4b328
leaq 0x4(%rsp), %rsi
callq 0x2cda0
jmp 0x29d39
leaq 0x11058(%rip), %rsi     # 0x3aeff
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x29aa0
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 0xf61f(%rip), %rsi      # 0x39522
callq 0x5650
movq %rax, %r13
testq %rax, %rax
jne 0x29f4d
leaq 0x10f76(%rip), %rsi     # 0x3ae8d
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0xb7dd
leaq 0x2057d(%rip), %rdi     # 0x4a4a8
leaq 0x60(%rsp), %rsi
movl $0x1, %edx
callq 0x3721e
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29f4d
callq 0x5410
movq %rbx, 0x50(%rsp)
xorl %r15d, %r15d
leaq 0x10fa3(%rip), %rbp     # 0x3aeff
leaq 0x8(%rsp), %r14
movq $0x0, 0x28(%rsp)
movq %r13, %rdi
callq 0x5110
testl %eax, %eax
jne 0x2a13d
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 0x29f91
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29f6a
movl $0x4, %ecx
movq %r14, %rdi
leaq 0xf77e(%rip), %rsi      # 0x3975d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x2a1bc
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 0x212fa(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1818e
leaq 0x212f1(%rip), %rcx     # 0x4b360
cmpq %rcx, %rax
jne 0x2a09f
leaq 0x212dd(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movq 0x28(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x212ab(%rip), %rdi     # 0x4b340
movq %rsi, 0x28(%rsp)
callq 0x2c56c
leaq 0x212b2(%rip), %rdi     # 0x4b358
leaq 0x30(%rsp), %rsi
callq 0x1785c
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x2127e(%rip), %rdi     # 0x4b340
leaq 0x4(%rsp), %rsi
callq 0x2cda0
jmp 0x29f6a
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 0x2a0ff
callq 0x5410
movq 0x1fe7a(%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 0x29a8c
callq 0x5410
jmp 0x29a8c
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 0x2a166
callq 0x5410
movq 0x1fe13(%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 0x29aa0
callq 0x5410
jmp 0x29aa0
leaq 0xf413(%rip), %rdi      # 0x395be
leaq 0xf443(%rip), %rsi      # 0x395f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
leaq 0xf3fb(%rip), %rdi      # 0x395be
leaq 0xf42b(%rip), %rsi      # 0x395f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x70(%rsp), %rax
jmp 0x2a1e9
movq %rax, %rbx
leaq 0x90(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a21d
callq 0x5410
jmp 0x2a21d
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a207
jmp 0x2a21a
movq %rax, %rbx
jmp 0x2a252
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
jmp 0x2a21a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2a231
callq 0x5410
movq 0x1fd48(%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 0x2a266
callq 0x5410
movq %rbx, %rdi
callq 0x57d0