// File: /workspace/github_cpp_makefile_star2_O2/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: intersect_annot_regions(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, bool, bool)
vector<t_annot_region*>* intersect_annot_regions(vector<t_annot_region*>* annot_regions1,
														vector<t_annot_region*>* annot_regions2,
														bool match_strands,
														bool find_all_overlaps)
{
	// Merged annot. regions.
	if(match_strands)
	{
		vector<t_annot_region*>* plus_strand_regions1 = get_regions_per_strand(annot_regions1, '+');
		vector<t_annot_region*>* plus_strand_regions2 = get_regions_per_strand(annot_regions2, '+');
		vector<t_annot_region*>* intersected_pos_strand_regions = intersect_annot_regions(plus_strand_regions1, plus_strand_regions2, find_all_overlaps);

		// Merge negative strand regions.
		vector<t_annot_region*>* neg_strand_regions1 = get_regions_per_strand(annot_regions1, '-');
		vector<t_annot_region*>* neg_strand_regions2 = get_regions_per_strand(annot_regions2, '-');
		vector<t_annot_region*>* intersected_neg_strand_regions = intersect_annot_regions(neg_strand_regions1, neg_strand_regions2, find_all_overlaps);

		// Pool the merged plus and minus strand regions.
		vector<t_annot_region*>* intersected_annot_regions = new vector<t_annot_region*>();
		intersected_annot_regions->insert(intersected_annot_regions->end(), intersected_pos_strand_regions->begin(), intersected_pos_strand_regions->end());
		intersected_annot_regions->insert(intersected_annot_regions->end(), intersected_neg_strand_regions->begin(), intersected_neg_strand_regions->end());


		delete(plus_strand_regions1);
		delete(plus_strand_regions2);

		delete(neg_strand_regions1);
		delete(neg_strand_regions2);
		return(intersected_annot_regions);
	}
	else
	{
		vector<t_annot_region*>* intersected_annot_regions = intersect_annot_regions(annot_regions1, annot_regions2, find_all_overlaps);
		return(intersected_annot_regions);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rsi, %r15
movq %rdi, %r12
testl %edx, %edx
je 0x16787
pushq $0x2b
popq %rbx
movq %r12, %rdi
movl %ebx, %esi
callq 0x16108
movq %rax, %r14
movq %r15, %rdi
movl %ebx, %esi
callq 0x16108
movq %rax, (%rsp)
movzbl %bpl, %ebp
movq %r14, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x150d3
movq %rax, %r13
pushq $0x2d
popq %rbx
movq %r12, %rdi
movl %ebx, %esi
callq 0x16108
movq %rax, %r12
movq %r15, %rdi
movl %ebx, %esi
callq 0x16108
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
movl %ebp, %edx
callq 0x150d3
movq %rax, %rbx
pushq $0x18
popq %rdi
callq 0x2170
movq %rax, %rbp
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq (%r13), %rdx
movq 0x8(%r13), %rcx
movq %rax, %rdi
xorl %esi, %esi
callq 0x73e4
movq 0x8(%rbp), %rsi
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
movq %rbp, %rdi
callq 0x73e4
movq %r14, %rdi
callq 0x832c
movq %r14, %rdi
pushq $0x18
popq %r14
movq %r14, %rsi
callq 0x2180
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x832c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2180
movq %r12, %rdi
callq 0x832c
movq %r12, %rdi
movq %r14, %rsi
callq 0x2180
movq %r15, %rdi
callq 0x832c
movq %r15, %rdi
movq %r14, %rsi
callq 0x2180
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %bpl, %edx
movq %r12, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x150d3