// File: /workspace/github_cpp_makefile_star2_O2/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 0x22897
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xcb9e(%rip), %rsi      # 0x2ee37
movq %r15, %rdi
callq 0x96f3
testb %al, %al
je 0x222bc
leaq 0xcb8b(%rip), %rsi      # 0x2ee37
movq %r14, %rdi
callq 0x96f3
testb %al, %al
jne 0x22897
movq 0x2008d(%rip), %rax     # 0x42350
cmpq 0x2008e(%rip), %rax     # 0x42358
jne 0x22500
leaq 0xcb60(%rip), %rsi      # 0x2ee37
movq %r15, %rdi
callq 0x12f17
testb %al, %al
je 0x22500
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x200a9(%rip), %r12d    # 0x423a8
leaq 0xa0(%rsp), %rdi
callq 0x5300
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r13
movq (%r15), %rdi
leaq 0xb179(%rip), %rsi      # 0x2d4ad
callq 0x56a0
movq %rax, %rbp
testq %rax, %rax
jne 0x2237c
leaq 0xca7d(%rip), %rsi      # 0x2edc5
leaq 0x80(%rsp), %rdi
movq %r15, %rdx
callq 0x967d
leaq 0x1f171(%rip), %rdi     # 0x414d0
leaq 0x80(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
leaq 0x80(%rsp), %rdi
callq 0x5908
movq %r12, 0x18(%rsp)
leaq 0xcaaf(%rip), %r12      # 0x2ee37
leaq 0x40(%rsp), %r15
movq %rbp, %rdi
callq 0x5120
testl %eax, %eax
jne 0x224cf
movq %r15, %rdi
movq %r12, %rsi
callq 0x58b0
movq %rbp, %rdi
movq %r13, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x57b0
movq %r15, %rdi
movq %r13, %rsi
callq 0x58a0
movq %r13, %rdi
callq 0x5190
cmpq $0xfffff, %rax          # imm = 0xFFFFF
je 0x223a8
movq 0x40(%rsp), %rax
cmpb $0x23, (%rax)
je 0x2238d
movq %r15, %rdi
leaq 0xb2b6(%rip), %rsi      # 0x2d69d
movq %r14, 0x10(%rsp)
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x5840
leaq 0x1(%rax), %rsi
movq %r15, %rdi
movq %r14, %rdx
movq 0x10(%rsp), %r14
callq 0x50c0
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xa0(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5790
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x5690
leaq 0xa0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x55c0
movq %rax, %rdi
leaq 0xc(%rsp), %rsi
callq 0x5250
leaq 0x1ff20(%rip), %rdi     # 0x42380
leaq 0x20(%rsp), %rsi
callq 0x13a1a
leaq 0x1ff17(%rip), %rcx     # 0x42388
cmpq %rcx, %rax
jne 0x224a1
leaq 0x1ff03(%rip), %rdi     # 0x42380
leaq 0x20(%rsp), %rsi
callq 0x1316c
movq 0x18(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x1feb9(%rip), %rdi     # 0x42350
movq %rsi, 0x18(%rsp)
callq 0x243ee
leaq 0x1fed8(%rip), %rdi     # 0x42380
leaq 0x20(%rsp), %rsi
callq 0x1316c
movslq (%rax), %rax
imulq $0x30, %rax, %rdi
addq 0x1fe90(%rip), %rdi     # 0x42350
leaq 0xc(%rsp), %rsi
callq 0x24c9c
jmp 0x2238d
movq %rbp, %rdi
callq 0x5780
movq %r13, %rdi
callq 0x55e0
leaq 0x40(%rsp), %rdi
callq 0x5908
leaq 0xa0(%rsp), %rdi
callq 0x5360
leaq 0x20(%rsp), %rdi
callq 0x5908
movq 0x1fe61(%rip), %rax     # 0x42368
cmpq 0x1fe62(%rip), %rax     # 0x42370
jne 0x2272b
leaq 0xc91c(%rip), %rsi      # 0x2ee37
movq %r14, %rdi
callq 0x12f17
testb %al, %al
je 0x2272b
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xa0(%rsp), %rdi
callq 0x5300
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r12
movq (%r14), %rdi
leaq 0xaf3c(%rip), %rsi      # 0x2d4ad
callq 0x56a0
movq %rax, %r13
testq %rax, %rax
jne 0x225b0
leaq 0xc840(%rip), %rsi      # 0x2edc5
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0x967d
leaq 0x1ef37(%rip), %rdi     # 0x414d0
leaq 0x60(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
leaq 0x60(%rsp), %rdi
callq 0x5908
movq $0x0, 0x10(%rsp)
leaq 0xc877(%rip), %rbp      # 0x2ee37
leaq 0x40(%rsp), %r15
movq %r13, %rdi
callq 0x5120
testl %eax, %eax
jne 0x226fa
movq %r15, %rdi
movq %rbp, %rsi
callq 0x58b0
movq %r13, %rdi
movq %r12, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x57b0
movq %r15, %rdi
movq %r12, %rsi
callq 0x58a0
movq %r12, %rdi
callq 0x5190
cmpq $0xfffff, %rax          # imm = 0xFFFFF
je 0x225e0
movq 0x40(%rsp), %rax
cmpb $0x23, (%rax)
je 0x225c5
movq %r15, %rdi
leaq 0xb07e(%rip), %rsi      # 0x2d69d
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x5840
leaq 0x1(%rax), %rsi
movq %r15, %rdi
movq %r14, %rdx
leaq 0x20(%rsp), %r14
callq 0x50c0
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xa0(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5790
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
callq 0x5690
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x55c0
movq %rax, %rdi
leaq 0xc(%rsp), %rsi
callq 0x5250
leaq 0x1fcef(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x13a1a
leaq 0x1fce8(%rip), %rcx     # 0x42388
cmpq %rcx, %rax
jne 0x226ce
leaq 0x1fcd4(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x1316c
movq 0x10(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x1fca4(%rip), %rdi     # 0x42368
movq %rsi, 0x10(%rsp)
callq 0x243ee
leaq 0x1fcab(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x1316c
movslq (%rax), %rax
imulq $0x30, %rax, %rdi
addq 0x1fc7d(%rip), %rdi     # 0x42368
leaq 0xc(%rsp), %rsi
callq 0x24c9c
jmp 0x225c5
movq %r13, %rdi
callq 0x5780
movq %r12, %rdi
callq 0x55e0
leaq 0x40(%rsp), %rdi
callq 0x5908
leaq 0xa0(%rsp), %rdi
callq 0x5360
leaq 0x20(%rsp), %rdi
callq 0x5908
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq 0x1fc0f(%rip), %rax     # 0x42350
cmpq 0x1fc10(%rip), %rax     # 0x42358
je 0x227dd
leaq 0x3e0(%rbx), %r14
leaq 0x1fc24(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x13a1a
leaq 0x1fc1d(%rip), %rcx     # 0x42388
cmpq %rcx, %rax
je 0x227d9
leaq 0x1fc09(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x1316c
movslq (%rax), %rax
movl 0x400(%rbx), %ebp
imulq $0x30, %rax, %r15
leaq 0xa0(%rsp), %r14
movl %ebp, %eax
movslq 0x400(%rbx), %rcx
addq 0x430(%rbx), %rcx
cmpq %rax, %rcx
jbe 0x227d9
movq 0x1fba0(%rip), %rdi     # 0x42350
addq %r15, %rdi
movl %ebp, 0xa0(%rsp)
movq %r14, %rsi
callq 0x24dee
movq 0x1fb87(%rip), %rcx     # 0x42350
addq %r15, %rcx
addq $0x8, %rcx
incl %ebp
cmpq %rcx, %rax
je 0x22794
jmp 0x227dd
movb $0x0, 0xc(%rbx)
movq 0x1fb84(%rip), %rax     # 0x42368
cmpq 0x1fb85(%rip), %rax     # 0x42370
je 0x22897
leaq 0x3e0(%rbx), %r14
leaq 0x1fb81(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x13a1a
leaq 0x1fb7a(%rip), %rcx     # 0x42388
cmpq %rcx, %rax
je 0x22897
leaq 0x1fb62(%rip), %rdi     # 0x42380
movq %r14, %rsi
callq 0x1316c
movslq (%rax), %rcx
movl 0x400(%rbx), %eax
xorl %ebp, %ebp
imulq $0x30, %rcx, %r15
leaq 0xa0(%rsp), %r14
movl %eax, %r12d
movl %r12d, %ecx
cltq
addq 0x430(%rbx), %rax
cmpq %rcx, %rax
jbe 0x2288d
movq 0x1fb10(%rip), %rdi     # 0x42368
addq %r15, %rdi
movl %r12d, 0xa0(%rsp)
movq %r14, %rsi
callq 0x24dee
movq 0x1faf6(%rip), %rcx     # 0x42368
addq %r15, %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
setne %al
orb %al, %bpl
incl %r12d
movl 0x400(%rbx), %eax
jmp 0x22840
testb $0x1, %bpl
je 0x22897
movb $0x0, 0xc(%rbx)
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x228be
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5908
jmp 0x228e5
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
jmp 0x228cf
jmp 0x228e2
movq %rax, %rbx
jmp 0x228fc
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
jmp 0x228e2
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5908
leaq 0xa0(%rsp), %rdi
callq 0x5360
leaq 0x20(%rsp), %rdi
callq 0x5908
movq %rbx, %rdi
callq 0x5800