// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: nuc_overlap_src_over_both_overlap(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
double nuc_overlap_src_over_both_overlap(vector<t_annot_region*>* annot_regions1, 
										vector<t_annot_region*>* annot_regions2)
{
	// Compute the coverage of overlap divided by the coverage of only parts that overlapped.
	vector<t_annot_region*>* overlapping_regions = intersect_annot_regions(annot_regions1, annot_regions2, false);

	// Get the overlapping regions in each list: Fix the indices: Batch intersection returns only the overlapping regions.
	vector<t_annot_region*>* overlapping_regions1 = intersect_annot_regions(annot_regions1, annot_regions2, false);
	for(int i_reg = 0; i_reg < (int)overlapping_regions1->size(); i_reg++)
	{
		if(overlapping_regions1->at(i_reg) != NULL)
		{
			overlapping_regions1->at(i_reg)->start = annot_regions1->at(i_reg)->start;
			overlapping_regions1->at(i_reg)->end = annot_regions1->at(i_reg)->end;
		}
	} // i_reg loop.

	vector<t_annot_region*>* overlapping_regions2 = intersect_annot_regions(annot_regions2, annot_regions1, false);
	for(int i_reg = 0; i_reg < (int)overlapping_regions2->size(); i_reg++)
	{
		if(overlapping_regions2->at(i_reg) != NULL)
		{
			overlapping_regions2->at(i_reg)->start = annot_regions2->at(i_reg)->start;
			overlapping_regions2->at(i_reg)->end = annot_regions2->at(i_reg)->end;
		}
	} // i_reg loop.

	int overlap_cvg = (int)coverage(overlapping_regions);
	int total_cvg = (int)coverage(overlapping_regions1) + (int)coverage(overlapping_regions2);

	if(total_cvg == 0)
	{
		return 0.0;
	}
	printf("2 * %d / (%d + %d)\n", (int)coverage(overlapping_regions), (int)coverage(overlapping_regions1), (int)coverage(overlapping_regions2));
	return((double)(2 * overlap_cvg) / total_cvg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r12
xorl %edx, %edx
callq 0x193f3
movq %rax, %rbx
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x193f3
movq %rax, %r14
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x19842
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x19942
movq (%rcx,%rsi,8), %r8
testq %r8, %r8
je 0x1983a
movq (%r12), %r9
movq 0x8(%r12), %rax
subq %r9, %rax
sarq $0x3, %rax
cmpq %rsi, %rax
jbe 0x1994e
movq (%r9,%rsi,8), %rax
movl 0xc(%rax), %r9d
movl %r9d, 0xc(%r8)
movl 0x20(%rax), %eax
movl %eax, 0x20(%r8)
incq %rsi
cmpq %rsi, %rdi
jne 0x197fc
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x193f3
movq %rax, %r12
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x198b2
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x19942
movq (%rcx,%rsi,8), %r8
testq %r8, %r8
je 0x198aa
movq (%r15), %r9
movq 0x8(%r15), %rax
subq %r9, %rax
sarq $0x3, %rax
cmpq %rsi, %rax
jbe 0x1994e
movq (%r9,%rsi,8), %rax
movl 0xc(%rax), %r9d
movl %r9d, 0xc(%r8)
movl 0x20(%rax), %eax
movl %eax, 0x20(%r8)
incq %rsi
cmpq %rsi, %rdi
jne 0x1986e
movq %rbx, %rdi
callq 0x1931c
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x1931c
cvttsd2si %xmm0, %ebp
movq %r12, %rdi
callq 0x1931c
cvttsd2si %xmm0, %r15d
addl %ebp, %r15d
je 0x1992f
cvttsd2si (%rsp), %r13d
movq %rbx, %rdi
callq 0x1931c
cvttsd2si %xmm0, %ebx
movq %r14, %rdi
callq 0x1931c
cvttsd2si %xmm0, %ebp
movq %r12, %rdi
callq 0x1931c
cvttsd2si %xmm0, %ecx
leaq 0x153f4(%rip), %rdi     # 0x2ed02
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2050
addl %r13d, %r13d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
jmp 0x19933
xorpd %xmm0, %xmm0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13f8d(%rip), %rdi     # 0x2d8d6
movq %rdx, %rsi
jmp 0x19958
leaq 0x13f81(%rip), %rdi     # 0x2d8d6
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270