// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdi, %r14
testl %edx, %edx
je 0x1af34
movq %r14, %rdi
movl $0x2b, %esi
callq 0x1a69a
movq %rax, %r13
movq %rbx, %rdi
movl $0x2b, %esi
callq 0x1a69a
movq %rax, %r12
movzbl %bpl, %r15d
movq %r13, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x193f3
movq %rax, %rbp
movq %r14, %rdi
movl $0x2d, %esi
callq 0x1a69a
movq %rax, %r14
movq %rbx, %rdi
movl $0x2d, %esi
callq 0x1a69a
movq %rax, %rbx
movq %r14, (%rsp)
movq %r14, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x193f3
movq %rax, %r15
movl $0x18, %edi
callq 0x2180
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq 0x8(%rax), %rsi
movq (%rbp), %rdx
movq 0x8(%rbp), %rcx
movq %rax, %rdi
callq 0xb5e2
movq 0x8(%r14), %rsi
movq (%r15), %rdx
movq 0x8(%r15), %rcx
movq %r14, %rdi
callq 0xb5e2
movq (%r13), %rdi
testq %rdi, %rdi
je 0x1aeac
movq 0x10(%r13), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r13, %rdi
callq 0x2190
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1aecf
movq 0x10(%r12), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r12, %rdi
callq 0x2190
movq (%rsp), %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1aef4
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r15, %rdi
callq 0x2190
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1af15
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %rbx, %rdi
callq 0x2190
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x193f3