LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: extract_region_mids(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int)
vector<t_annot_region*>* extract_region_mids(vector<t_annot_region*>* regions, int l_mid_reg)
{
	vector<t_annot_region*>* region_mids = new vector<t_annot_region*>();
	for(int i = 0; i < (int)regions->size(); i++)
	{
		int cur_mid = (regions->at(i)->start + regions->at(i)->end) / 2;
		t_annot_region* cur_mid_reg = get_empty_region();
		cur_mid_reg->chrom = t_string::copy_me_str(regions->at(i)->chrom);
		cur_mid_reg->start = (cur_mid > l_mid_reg/2)?(cur_mid - l_mid_reg/2):(1);
		cur_mid_reg->end = cur_mid + l_mid_reg/2;
		cur_mid_reg->strand = regions->at(i)->strand;

		region_mids->push_back(cur_mid_reg);
	} // i loop.

	return(region_mids);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movl $0x18, %edi
callq 0x2180
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %r12
movq 0x8(%rbx), %rdx
subq %r12, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x15621
movl %ebp, %r13d
shrl $0x1f, %r13d
addl %ebp, %r13d
sarl %r13d
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x15633
movq (%r12,%r15,8), %rax
movl 0x20(%rax), %ecx
addl 0xc(%rax), %ecx
movl %ecx, %ebp
shrl $0x1f, %ebp
addl %ecx, %ebp
sarl %ebp
movl $0x50, %edi
callq 0x2180
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rax, (%rsp)
movq (%r12,%r15,8), %rax
movq (%rax), %rdi
callq 0x26db4
movq (%rsp), %rcx
movq %rax, (%rcx)
movl %ebp, %ecx
subl %r13d, %ecx
movl $0x1, %eax
cmovlel %eax, %ecx
movq (%rsp), %rax
movl %ecx, 0xc(%rax)
addl %r13d, %ebp
movl %ebp, 0x20(%rax)
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x15633
movq (%rcx,%r15,8), %rcx
movb 0x8(%rcx), %cl
movb %cl, 0x8(%rax)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x155f3
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x155fe
movq %r14, %rdi
movq %rsp, %rdx
callq 0xb74c
incq %r15
movq (%rbx), %r12
movq 0x8(%rbx), %rax
subq %r12, %rax
movq %rax, %rdx
sarq $0x3, %rdx
shrq $0x3, %rax
cltq
cmpq %rax, %r15
jl 0x15555
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17296(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_top_region_per_total_coverage(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, double)
vector<t_annot_region*>* get_top_region_per_total_coverage(vector<t_annot_region*>* regions, double max_covg)
{
	double cur_total_covg = 0;
	vector<t_annot_region*>* top_regions = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		cur_total_covg += (regions->at(i_reg)->end - regions->at(i_reg)->start + 1);
		top_regions->push_back(regions->at(i_reg));
		if(max_covg == 0 ||
			max_covg <= cur_total_covg)
		{
			break;
		}
	} // i_reg loop.

	return(top_regions);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movl $0x18, %edi
callq 0x2180
movsd (%rsp), %xmm1
movq %rax, %r14
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %rdx
movq 0x8(%rbx), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x15c14
xorpd %xmm2, %xmm2
xorl %r12d, %r12d
xorl %r15d, %r15d
xorpd %xmm3, %xmm3
cmpq %r15, %rax
jbe 0x15c24
movq (%rdx,%r12), %rax
movl 0x20(%rax), %ebp
subl 0xc(%rax), %ebp
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x15bb1
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x15bd1
addq %r12, %rdx
movq %r14, %rdi
movsd %xmm3, 0x8(%rsp)
callq 0xb74c
movsd 0x8(%rsp), %xmm3
xorpd %xmm2, %xmm2
movsd (%rsp), %xmm1
ucomisd %xmm2, %xmm1
jne 0x15bd9
jnp 0x15c14
incl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0x15c14
incq %r15
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %r12
cmpq %rcx, %r15
jl 0x15b8a
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16ca5(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: extend_BED(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int, bool, bool)
void extend_BED(vector<t_annot_region*>* regions, int l_extend, bool extend_3p, bool extend_5p)
{	
	for(int i = 0; i < (int)regions->size(); i++)
	{
		int l_2_extend = (l_extend>0)?(l_extend):(regions->at(i)->end-regions->at(i)->start);

		if(regions->at(i)->strand == '+')
		{
			if(extend_5p)
			{
				regions->at(i)->start = (regions->at(i)->start > l_2_extend)?(regions->at(i)->start - l_2_extend):(1);
			}
			
			if(extend_3p)
			{
				regions->at(i)->end = (regions->at(i)->end + l_2_extend);
			}
		} // strand check for pos. strand.
		else
		{
			if(extend_3p)
			{
				regions->at(i)->start = (regions->at(i)->start > l_2_extend)?(regions->at(i)->start - l_2_extend):(1);
			}
			
			if(extend_5p)
			{
				regions->at(i)->end = (regions->at(i)->end + l_2_extend);
			}
		} // strand check for neg. strand.
	} // i loop.
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %eax
movq (%rdi), %r9
movq 0x8(%rdi), %rdx
subq %r9, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x15e35
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movl $0x1, %r10d
movl %esi, %r11d
testl %esi, %esi
jg 0x15dee
cmpq %r8, %rdx
jbe 0x15e48
movq (%r9,%r8,8), %rbx
movl 0x20(%rbx), %r11d
subl 0xc(%rbx), %r11d
cmpq %r8, %rdx
je 0x15e3c
movq (%r9,%r8,8), %rbx
cmpb $0x2b, 0x8(%rbx)
jne 0x15e14
testb %cl, %cl
je 0x15e0e
movl 0xc(%rbx), %ebp
subl %r11d, %ebp
cmovlel %r10d, %ebp
movl %ebp, 0xc(%rbx)
testb %al, %al
jne 0x15e29
jmp 0x15e2d
testb %al, %al
je 0x15e25
movl 0xc(%rbx), %ebp
subl %r11d, %ebp
cmovlel %r10d, %ebp
movl %ebp, 0xc(%rbx)
testb %cl, %cl
je 0x15e2d
addl %r11d, 0x20(%rbx)
incq %r8
cmpq %r8, %rdi
jne 0x15dd6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x16a8d(%rip), %rdi     # 0x2c8d0
movq %rdx, %rsi
jmp 0x15e52
leaq 0x16a81(%rip), %rdi     # 0x2c8d0
movq %r8, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: dump_BED(char*, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
void dump_BED(char* bed_fp, vector<t_annot_region*>* annot_regions)
{
	FILE* f_bed = open_f(bed_fp, "w");

	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		if(annot_regions->at(i_reg)->strand == '-' ||
			annot_regions->at(i_reg)->strand == '+')
		{
			if(annot_regions->at(i_reg)->name == NULL)
			{
				annot_regions->at(i_reg)->name = new char[5];
				strcpy(annot_regions->at(i_reg)->name, ".");
			}

			// Translate the start and end to CODEBASE's start and end.
			fprintf(f_bed, "%s\t%d\t%d\t%s\t.\t%c\n", annot_regions->at(i_reg)->chrom, 
				translate_coord(annot_regions->at(i_reg)->start, CODEBASE_COORDS::start_base, BED_COORDS::start_base),
				translate_coord(annot_regions->at(i_reg)->end, CODEBASE_COORDS::end_base, BED_COORDS::end_base),
				annot_regions->at(i_reg)->name,
				annot_regions->at(i_reg)->strand);
		}
		else
		{
			fprintf(f_bed, "%s\t%d\t%d\n", annot_regions->at(i_reg)->chrom, 
				translate_coord(annot_regions->at(i_reg)->start, CODEBASE_COORDS::start_base, BED_COORDS::start_base),
				translate_coord(annot_regions->at(i_reg)->end, CODEBASE_COORDS::end_base, BED_COORDS::end_base));
		}
	} // i_ref loop.

	fclose(f_bed);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
leaq 0x14c3a(%rip), %rsi     # 0x2aaa8
callq 0x25d5a
movq %rax, %r14
movq (%rbx), %rbp
movq 0x8(%rbx), %rdx
movq %rdx, %rax
subq %rbp, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x15f61
leaq 0x17a5a(%rip), %r12     # 0x2d8f0
xorl %r15d, %r15d
cmpq %r15, %rax
jbe 0x15f77
movq (%rbp,%r15,8), %r13
movzbl 0x8(%r13), %eax
cmpl $0x2d, %eax
je 0x15eb6
cmpl $0x2b, %eax
jne 0x15f1b
cmpq $0x0, 0x18(%r13)
jne 0x15ee0
movl $0x5, %edi
callq 0x2040
movq %rax, 0x18(%r13)
movq (%rbp,%r15,8), %rax
movq 0x18(%rax), %rax
movw $0x2e, (%rax)
movq (%rbx), %rbp
movq 0x8(%rbx), %rdx
subq %rbp, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x15f86
movq (%rbp,%r15,8), %rax
movq (%rax), %rdx
movl 0xc(%rax), %ecx
decl %ecx
movl 0x20(%rax), %r8d
movq 0x18(%rax), %r9
movsbl 0x8(%rax), %eax
movl %eax, (%rsp)
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2250
jmp 0x15f3a
movq (%r13), %rdx
movl 0xc(%r13), %ecx
decl %ecx
movl 0x20(%r13), %r8d
movq %r14, %rdi
leaq 0x179cf(%rip), %rsi     # 0x2d902
xorl %eax, %eax
callq 0x2250
incq %r15
movq (%rbx), %rbp
movq 0x8(%rbx), %rdx
movq %rdx, %rcx
subq %rbp, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0x15e99
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2170
leaq 0x16952(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
movq %rax, %rdx
jmp 0x15f90
leaq 0x16943(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: locate_posn_region_per_region_starts(int, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int, int)
int locate_posn_region_per_region_starts(int start_posn, vector<t_annot_region*>* region_list, int i, int j)
{
	int i_mid = (i + j) / 2;

	if(i_mid == i ||
		i_mid == j)
	{
		//return(i);
		while(i_mid > 0 && region_list->at(i_mid)->start >= start_posn)
		{
			i_mid--;
		}

		return(i_mid);
	}

	if(region_list->at(i_mid)->start == start_posn)
	{
		while(i_mid > 0 && region_list->at(i_mid)->start >= start_posn)
		{
			i_mid--;
		}

		return(i_mid);
	}
	else if(region_list->at(i_mid)->start > start_posn)
	{
		return(locate_posn_region_per_region_starts(start_posn, region_list, i, i_mid));
	}
	else if(region_list->at(i_mid)->start < start_posn)
	{
		return(locate_posn_region_per_region_starts(start_posn, region_list, i_mid, j));
	}
	else
	{
		fprintf(stderr, "Current indices are (%d, %d), searching for %d @ %s(%d)\n", region_list->at(i)->start, region_list->at(j)->start,
			start_posn, __FILE__, __LINE__);
		exit(0);
	}
}

// Assembly:
pushq %rax
movl %edi, %eax
movl %edx, %edi
movl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rdi), %r11d
movl %r11d, %edx
shrl $0x1f, %edx
addl %r11d, %edx
sarl %edx
cmpl %edi, %edx
je 0x167f8
cmpl %ecx, %edx
je 0x167f8
movslq %edx, %r9
movq (%rsi), %r10
movq 0x8(%rsi), %r8
subq %r10, %r8
sarq $0x3, %r8
cmpq %r9, %r8
jbe 0x1684e
movq (%r10,%r9,8), %r9
movl 0xc(%r9), %r9d
cmpl %eax, %r9d
je 0x16828
jg 0x167af
jl 0x167ab
movl %ecx, %edx
movl %eax, %ecx
callq 0x4a66
cmpl $0x2, %r11d
jl 0x1684a
movq (%rsi), %rdi
movq 0x8(%rsi), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movl %edx, %esi
cmpq %rsi, %rcx
jbe 0x1685a
movq (%rdi,%rsi,8), %rsi
cmpl %eax, 0xc(%rsi)
jl 0x1684a
leal -0x1(%rdx), %esi
cmpl $0x1, %edx
movl %esi, %edx
jg 0x1680c
jmp 0x16848
cmpl $0x2, %r11d
jl 0x1684a
movl %edx, %esi
cmpq %rsi, %r8
jbe 0x16866
movq (%r10,%rsi,8), %rcx
cmpl %eax, 0xc(%rcx)
jl 0x1684a
leal -0x1(%rdx), %ecx
cmpl $0x1, %edx
movl %ecx, %edx
jg 0x1682e
xorl %edx, %edx
movl %edx, %eax
popq %rcx
retq
leaq 0x1607b(%rip), %rdi     # 0x2c8d0
movq %r9, %rsi
jmp 0x1686d
leaq 0x1606f(%rip), %rdi     # 0x2c8d0
movq %rcx, %rdx
jmp 0x16870
leaq 0x16063(%rip), %rdi     # 0x2c8d0
movq %r8, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: delete_restructured_annot_regions(t_sorted_annot_region_lists*)
void delete_restructured_annot_regions(t_sorted_annot_region_lists* restructured_region_lists)
{
	for(int i_chr = 0; i_chr < (int)restructured_region_lists->chr_ids->size(); i_chr++)
	{
		delete [] restructured_region_lists->chr_ids->at(i_chr);
		delete restructured_region_lists->neg_strand_regions_per_chrom[i_chr];
		delete restructured_region_lists->pos_strand_regions_per_chrom[i_chr];
		delete restructured_region_lists->regions_per_chrom[i_chr];
	} // i_chr loop.

	delete [] restructured_region_lists->neg_strand_regions_per_chrom;
	delete [] restructured_region_lists->pos_strand_regions_per_chrom;
	delete [] restructured_region_lists->regions_per_chrom;
	delete restructured_region_lists->chr_ids;

	delete restructured_region_lists;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x16964
xorl %r14d, %r14d
cmpq %r14, %rdx
jbe 0x169c9
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x168b3
callq 0x2220
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x168d4
movq (%r15), %rdi
testq %rdi, %rdi
je 0x168d4
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r15, %rdi
callq 0x2190
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x16902
movq (%r15), %rdi
testq %rdi, %rdi
je 0x16902
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r15, %rdi
callq 0x2190
movq (%rbx), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x1692f
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1692f
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r15, %rdi
callq 0x2190
incq %r14
movq 0x18(%rbx), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
jl 0x1689c
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x16972
callq 0x2220
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x16980
callq 0x2220
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1698d
callq 0x2220
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x169aa
movq (%r14), %rdi
testq %rdi, %rdi
je 0x169aa
movq 0x10(%r14), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %r14, %rdi
callq 0x2190
movl $0x20, %esi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2190
leaq 0x15f00(%rip), %rdi     # 0x2c8d0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: duplicate_region(t_annot_region*)
t_annot_region* duplicate_region(t_annot_region* region_2_dup)
{
	t_annot_region* dup_region = new t_annot_region();

	if(region_2_dup->chrom != NULL)
	{
		dup_region->chrom = new char[strlen(region_2_dup->chrom) + 2];
		strcpy(dup_region->chrom, region_2_dup->chrom);
	}
	else
	{
		dup_region->chrom = NULL;
	}

	if(region_2_dup->name != NULL)
	{
		dup_region->name = new char[strlen(region_2_dup->name) + 2];
		strcpy(dup_region->name, region_2_dup->name);
	}
	else
	{
		dup_region->name = NULL;
	}

	dup_region->start = region_2_dup->start;
	dup_region->end = region_2_dup->end;
	dup_region->strand = region_2_dup->strand;
	dup_region->n_exons = dup_region->n_exons;
	dup_region->score = dup_region->score;
	dup_region->thick_start = dup_region->thick_start;
	dup_region->thick_end = dup_region->thick_end;

	dup_region->intervals = NULL;

	return(dup_region);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x50, %edi
callq 0x2180
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movq (%rbx), %r15
testq %r15, %r15
je 0x16f76
movq %r15, %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
jmp 0x16f79
xorl %r12d, %r12d
movq %r12, (%r14)
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x16fa6
movq %r15, %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
jmp 0x16fa9
xorl %r12d, %r12d
movq %r12, 0x18(%r14)
movl 0xc(%rbx), %eax
movl %eax, 0xc(%r14)
movl 0x20(%rbx), %eax
movl %eax, 0x20(%r14)
movb 0x8(%rbx), %al
movb %al, 0x8(%r14)
movq $0x0, 0x30(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_chr_ids(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
vector<char*>* get_chr_ids(vector<t_annot_region*>* annot_regions)
{
	//printf("/*Determining*/ the chromosome list from region list.\n");
	vector<char*>* chr_ids = new vector<char*>();

	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		bool is_new_id = true;

		// Check if the the current chromosome id is included in the list of chromosome ids already collected, otherwise add it.
		for(int i_chr = 0; 
			is_new_id && i_chr < (int)chr_ids->size(); 
			i_chr++)
		{
			if(strcmp(chr_ids->at(i_chr), annot_regions->at(i_reg)->chrom) == 0)
			{
				is_new_id = false;
			}
		} // i_chr loop

		if(is_new_id)
		{
			char* new_id = new char[strlen(annot_regions->at(i_reg)->chrom) + 2];
			strcpy(new_id, annot_regions->at(i_reg)->chrom);
			chr_ids->push_back(new_id); // Add the new id.
		}
	} // i_reg loop.

	//printf("Determined %d chromosomes from region list.\n", chr_ids->size());
	return(chr_ids);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl $0x18, %edi
callq 0x2180
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %rcx
movq %rbx, 0x18(%rsp)
movq 0x8(%rbx), %rsi
movq %rsi, %r15
subq %rcx, %r15
sarq $0x3, %r15
testl %r15d, %r15d
jle 0x17349
xorl %r13d, %r13d
movq %r12, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rcx, 0x8(%rsp)
movq (%r12), %r14
movq 0x8(%r12), %rbp
movq %rbp, 0x28(%rsp)
subq %r14, %rbp
sarq $0x3, %rbp
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x172bb
cmpq %rbx, %rbp
je 0x1736a
cmpq %r13, %r15
jbe 0x1735b
movq (%r14,%rbx,8), %rdi
movq 0x8(%rsp), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rsi
callq 0x2240
incq %rbx
testl %eax, %eax
jne 0x17277
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rsi
jmp 0x1732a
cmpq %r13, %r15
jbe 0x1735b
movq 0x8(%rsp), %rbx
movq (%rbx,%r13,8), %rax
movq (%rax), %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, %r14
movq %rax, 0x30(%rsp)
movq (%rbx,%r13,8), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x2150
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %rsi
cmpq 0x10(%r12), %rsi
je 0x17311
movq %r14, (%rsi)
addq $0x8, 0x8(%r12)
jmp 0x1731e
movq %r12, %rdi
leaq 0x30(%rsp), %rdx
callq 0x12a12
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rsi
incq %r13
movq %rsi, %rax
subq %rcx, %rax
movq %rax, %r15
sarq $0x3, %r15
shrq $0x3, %rax
cltq
cmpq %rax, %r13
jl 0x1724a
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1556e(%rip), %rdi     # 0x2c8d0
movq %r13, %rsi
movq %r15, %rdx
jmp 0x17377
leaq 0x1555f(%rip), %rdi     # 0x2c8d0
movq %rbp, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: check_line_skip(char*)
bool check_line_skip(char* cur_line)
{
	// Skip empty lines.
	if(strlen(cur_line) == 0)
	{
		return(true);
	}

	// Check comment.
	if(cur_line[0] == '#')
	{
		return(true);
	}
	
	// Check track info line.
	char* first_word = new char[strlen(cur_line) + 2];
	strcpy(first_word, cur_line);
	sscanf(cur_line, "%s", first_word);

	if(strcmp(first_word, "track") == 0)
	{
		delete [] first_word;
		return(true);
	}

	delete [] first_word;

	return(false);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x20d0
movb $0x1, %bpl
testq %rax, %rax
je 0x17ab5
cmpb $0x23, (%rbx)
je 0x17ab5
addq $0x2, %rax
movq %rax, %rdi
callq 0x2040
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2150
leaq 0x15ab3(%rip), %rsi     # 0x2d53e
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2160
leaq 0x162f9(%rip), %rsi     # 0x2dd98
movq %r14, %rdi
callq 0x2240
testl %eax, %eax
sete %bpl
movq %r14, %rdi
callq 0x2220
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: validate_region_coords(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
bool validate_region_coords(vector<t_annot_region*>* regions)
{
	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		if(regions->at(i_reg)->start > regions->at(i_reg)->end)
		{
			fprintf(stderr, "%s:%d-%d is not valid.\n", regions->at(i_reg)->chrom, regions->at(i_reg)->start, regions->at(i_reg)->end);
			return(false);
		}
	} // i_reg loop.

	return(true);
}

// Assembly:
pushq %rbx
movq (%rdi), %rax
movq 0x8(%rdi), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x17edf
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rdx, %rdi
negq %rdi
movq %rsi, %r9
negq %r9
movl $0x1, %r10d
xorl %ebx, %ebx
leaq (%rdi,%r10), %rcx
cmpq $0x1, %rcx
je 0x17f05
movq -0x8(%rax,%r10,8), %r11
movl 0xc(%r11), %ecx
movl 0x20(%r11), %r8d
cmpl %r8d, %ecx
jg 0x17ee8
cmpq %rsi, %r10
setae %bl
leaq (%r9,%r10), %rcx
incq %rcx
incq %r10
cmpq $0x1, %rcx
jne 0x17eab
jmp 0x17ee1
movb $0x1, %bl
andb $0x1, %bl
movl %ebx, %eax
popq %rbx
retq
movq 0x210f1(%rip), %rax     # 0x38fe0
movq (%rax), %rdi
movq (%r11), %rdx
leaq 0x15fcc(%rip), %rsi     # 0x2dec8
xorl %eax, %eax
callq 0x2250
jmp 0x17ee1
leaq 0x149c4(%rip), %rdi     # 0x2c8d0
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: dump_BED_w_p_values(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char*)
void dump_BED_w_p_values(vector<t_annot_region*>* regions, char* op_fp)
{
	FILE* f_op = open_f(op_fp, "w");

	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		t_significance_info* sig_info = (t_significance_info*)(regions->at(i_reg)->significance_info);
		fprintf(f_op, "%s\t%d\t%d\t.\t%lf\t%c\n", regions->at(i_reg)->chrom, regions->at(i_reg)->start, regions->at(i_reg)->end, sig_info->log_p_val / log(10.0), regions->at(i_reg)->strand);
	} // i_reg loop.

	fclose(f_op);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x12b53(%rip), %rsi     # 0x2aaa8
movq %rax, %rdi
callq 0x25d5a
movq %rax, %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x17fd1
xorl %r15d, %r15d
leaq 0x15bb0(%rip), %r12     # 0x2db2c
cmpq %r15, %rdx
jbe 0x17fe4
movq (%rax,%r15,8), %rax
movq 0x40(%rax), %rsi
movq (%rax), %rdx
movl 0xc(%rax), %ecx
movl 0x20(%rax), %r8d
movsd (%rsi), %xmm0
divsd 0x14a21(%rip), %xmm0    # 0x2c9c0
movsbl 0x8(%rax), %r9d
movq %r14, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x2250
incq %r15
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0x17f7c
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2170
leaq 0x148e5(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: dump_BED_w_q_values(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char*)
void dump_BED_w_q_values(vector<t_annot_region*>* regions, char* op_fp)
{
	FILE* f_op = open_f(op_fp, "w");

	for(int i_reg = 0; i_reg < (int)regions->size(); i_reg++)
	{
		t_significance_info* sig_info = (t_significance_info*)(regions->at(i_reg)->significance_info);
		fprintf(f_op, "%s\t%d\t%d\t.\t%lf\t%c\n", regions->at(i_reg)->chrom, regions->at(i_reg)->start, regions->at(i_reg)->end, sig_info->log_q_val, regions->at(i_reg)->strand);
	} // i_reg loop.

	fclose(f_op);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x12a9e(%rip), %rsi     # 0x2aaa8
movq %rax, %rdi
callq 0x25d5a
movq %rax, %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x1807f
xorl %r15d, %r15d
leaq 0x15afb(%rip), %r12     # 0x2db2c
cmpq %r15, %rdx
jbe 0x18092
movq (%rax,%r15,8), %rax
movq 0x40(%rax), %rsi
movq (%rax), %rdx
movl 0xc(%rax), %ecx
movl 0x20(%rax), %r8d
movsd 0x8(%rsi), %xmm0
movsbl 0x8(%rax), %r9d
movq %r14, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x2250
incq %r15
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0x18031
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2170
leaq 0x14837(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: load_BED_w_p_values(char*)
vector<t_annot_region*>* load_BED_w_p_values(char* regions_bed_fp)
{
	// Load the BED file with scores.
	vector<t_annot_region*>* regions = new vector<t_annot_region*>();
	FILE* f_reg = open_f(regions_bed_fp, "r");
	while(1)
	{
		char* cur_line = getline(f_reg);
		if(cur_line == NULL)
		{
			break;
		}

		char chrom[1000];
		int start;
		int end;
		double log_p_val = 0;

		if(sscanf(cur_line, "%s %d %d %*s %lf", chrom, &start, &end, &log_p_val) != 4)
		{
			fprintf(stderr, "Could not parse %s", cur_line);
			exit(0);
		}

		t_significance_info* cur_reg_sig_info = new t_significance_info();
		cur_reg_sig_info->log_p_val = log_p_val;
		cur_reg_sig_info->log_q_val = 0.0;

		t_annot_region* cur_reg = get_empty_region();
		cur_reg->chrom = t_string::copy_me_str(chrom);
		cur_reg->start = start;
		cur_reg->end = end;
		cur_reg->strand = '+';
		cur_reg->significance_info = cur_reg_sig_info;

		regions->push_back(cur_reg);
	} // reg file reading loop.
	fclose(f_reg);

	return(regions);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x14c2f(%rip), %rsi     # 0x2cd08
movq %r14, %rdi
callq 0x25d5a
movq %rax, %r14
movq %rax, %rdi
callq 0x25c1e
testq %rax, %rax
je 0x181dc
movq %rax, %r13
leaq 0x20(%rsp), %r12
leaq 0x10(%rsp), %rbp
leaq 0x18(%rsp), %r15
movq $0x0, 0x18(%rsp)
movq %r13, %rdi
leaq 0x15a25(%rip), %rsi     # 0x2db3f
movq %r12, %rdx
leaq 0x14(%rsp), %rcx
movq %rbp, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x2160
cmpl $0x4, %eax
jne 0x181f9
movl $0x10, %edi
callq 0x2180
movq %rax, %r13
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
movq $0x0, 0x8(%rax)
movl $0x50, %edi
callq 0x2180
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x26db4
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movl 0x14(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0x10(%rsp), %ecx
movl %ecx, 0x20(%rax)
movb $0x2b, 0x8(%rax)
movq %r13, 0x40(%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x181bb
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x181c8
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0xb74c
movq %r14, %rdi
callq 0x25c1e
movq %rax, %r13
testq %rax, %rax
jne 0x18107
movq %r14, %rdi
callq 0x2170
movq %rbx, %rax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x4c28
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_all_intervals_per_composite_intervals(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
vector<t_annot_region*>* get_all_intervals_per_composite_intervals(vector<t_annot_region*>* composite_intervals)
{
	vector<t_annot_region*>* all_intervals = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)composite_intervals->size(); i_reg++)
	{
		vector<t_annot_region*>* cur_intervals = composite_intervals->at(i_reg)->intervals;

		for(int i_int = 0; i_int < (int)cur_intervals->size(); i_int++)
		{
			all_intervals->push_back(cur_intervals->at(i_int));
		} // i_int loop.
	} // i_reg loop.

	return(all_intervals);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x18, %edi
callq 0x2180
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %rcx
movq 0x8(%rbx), %rsi
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x18ab9
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x18adf
movq (%rcx,%r15,8), %rax
movq 0x30(%rax), %r13
movq (%r13), %rdx
movq 0x8(%r13), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x18a9a
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x18acb
addq %rbp, %rdx
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x18a66
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x18a6e
movq %r14, %rdi
callq 0xb74c
incq %r12
movq (%r13), %rdx
movq 0x8(%r13), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %rbp
cmpq %rcx, %r12
jl 0x18a47
movq (%rbx), %rcx
movq 0x8(%rbx), %rsi
incq %r15
movq %rsi, %rax
subq %rcx, %rax
movq %rax, %rdx
sarq $0x3, %rdx
shrq $0x3, %rax
cltq
cmpq %rax, %r15
jl 0x18a1e
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13dfe(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x13dea(%rip), %rdi     # 0x2c8d0
movq %r15, %rsi
jmp 0x18ad8
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: coverage(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
double coverage(vector<t_annot_region*>* annot_regions)
{
	double covrg = 0.0;

	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		if(annot_regions->at(i_reg) != NULL)
		{
			if(annot_regions->at(i_reg)->end < annot_regions->at(i_reg)->start)
			{
				//printf("Region %d has its start index larger than its end index: %d, %d\n", i_reg, 
				//	annot_regions->at(i_reg)->start,
				//	annot_regions->at(i_reg)->end);
			}
			else
			{
				covrg += annot_regions->at(i_reg)->end - annot_regions->at(i_reg)->start + 1;
			}
		}
	} // i_reg loop.

	return(covrg);
}

// Assembly:
pushq %rax
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x18fc4
cmpq %rax, %rcx
je 0x18fca
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
testq %rdi, %rdi
je 0x18fba
movl 0x20(%rdi), %esi
subl 0xc(%rdi), %esi
jl 0x18fba
incl %esi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
addsd %xmm1, %xmm0
incq %rcx
cmpq %rcx, %rdx
jne 0x18f9c
jmp 0x18fc8
xorpd %xmm0, %xmm0
popq %rax
retq
leaq 0x138ff(%rip), %rdi     # 0x2c8d0
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: nuc_overlap(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
double nuc_overlap(vector<t_annot_region*>* annot_regions1, 
					vector<t_annot_region*>* annot_regions2)
{
	// Compute the coverage of overlap divided by the coverage of all regions.
	vector<t_annot_region*>* overlapping_regions = intersect_annot_regions(annot_regions1, annot_regions2, false);

	int overlap_cvg = (int)(coverage(overlapping_regions));
	int total_cvg = (int)(coverage(annot_regions1) + coverage(annot_regions2));

	if(total_cvg == 0)
	{
		return 0.0;
	}

	return((double)(2 * overlap_cvg) / total_cvg);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %edx, %edx
callq 0x19046
movq %rax, %rdi
callq 0x18f75
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x18f75
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x18f75
addsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
je 0x1903a
cvttsd2si 0x8(%rsp), %ecx
addl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
jmp 0x1903e
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: inter_region_distances(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
vector<int>* inter_region_distances(vector<t_annot_region*>* annot_regions)
{
	vector<char*>* chr_ids = get_chr_ids(annot_regions);

	vector<int>* inter_reg_dists = new vector<int>();

	for(int i_chr = 0; i_chr < (int)chr_ids->size(); i_chr++)
	{
		vector<t_annot_region*>* cur_chr_regs = get_regions_per_chromosome(annot_regions,
																			chr_ids->at(i_chr));

		// Dump the distances between consecutive regions.
		for(int i_reg = 0; (i_reg + 1) < (int)cur_chr_regs->size(); i_reg++)
		{
			signed int cur_dist = cur_chr_regs->at(i_reg+1)->start - cur_chr_regs->at(i_reg)->end;
		
			if(cur_dist < 0)
			{
				printf("Negative distance: <%d-%d> and <%d-%d>\n", 
					cur_chr_regs->at(i_reg)->start,
					cur_chr_regs->at(i_reg)->end,
					cur_chr_regs->at(i_reg+1)->start,
					cur_chr_regs->at(i_reg+1)->end);
			}

			inter_reg_dists->push_back(cur_dist);
		} // i_reg loop.

		cur_chr_regs->clear();
		delete(cur_chr_regs);
	} // i_chr loop.

	return(inter_reg_dists);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
callq 0x171f7
movq %rax, %rbx
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %rax
movq %rbx, 0x8(%rsp)
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x19b9c
leaq 0x142e1(%rip), %r13     # 0x2dd70
leaq 0x4(%rsp), %rbp
xorl %r12d, %r12d
cmpq %r12, %rdx
jbe 0x19bbf
movq (%rax,%r12,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x19bcb
movq %rax, %rbx
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq %rax, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpl $0x2, %edx
jl 0x19b4c
movl $0x1, %r14d
cmpq %r14, %rdx
jbe 0x19bae
movq -0x8(%rdi,%r14,8), %rsi
movq (%rdi,%r14,8), %rax
movl 0xc(%rax), %ecx
movl 0x20(%rsi), %edx
movl %ecx, %edi
subl %edx, %edi
movl %edi, 0x4(%rsp)
jns 0x19b04
movl 0xc(%rsi), %esi
movl 0x20(%rax), %r8d
movq %r13, %rdi
xorl %eax, %eax
callq 0x2050
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x19b1e
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x19b29
movq %r15, %rdi
movq %rbp, %rdx
callq 0xabfa
incq %r14
movq (%rbx), %rdi
movq 0x8(%rbx), %rax
movq %rax, %rcx
subq %rdi, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
jl 0x19ad1
cmpq %rdi, %rax
je 0x19b55
movq %rdi, 0x8(%rbx)
testq %rdi, %rdi
je 0x19b66
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %rbx, %rdi
callq 0x2190
incq %r12
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
movq %rcx, %rdx
sarq $0x3, %rdx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r12
jl 0x19a97
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12d1b(%rip), %rdi     # 0x2c8d0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x12d0a(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
jmp 0x19bb8
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_regions_per_chromosome(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char*)
vector<t_annot_region*>* get_regions_per_chromosome(vector<t_annot_region*>* annot_regions,
													char* chr_id)
{
	vector<t_annot_region*>* chr_regions = new vector<t_annot_region*>();

	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		//bool new_id = false;

		// Check if the the current chromosome id is included in the list of chromosome ids already collected, otherwise add it.
		if(strcmp(annot_regions->at(i_reg)->chrom, chr_id) == 0)
		{
			// Add the current region to the chromosome regions.
			chr_regions->push_back(annot_regions->at(i_reg));
		}
	} // i_reg loop.

	return(chr_regions);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, (%rsp)
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %r13
movq 0x8(%r14), %rdx
subq %r13, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x19c6e
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq %r12, %rdx
jbe 0x19c80
movq (%r13,%rbp), %rbx
movq (%rbx), %rdi
movq (%rsp), %rsi
callq 0x2240
testl %eax, %eax
jne 0x19c4b
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x19c3d
movq %rbx, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x19c4b
addq %rbp, %r13
movq %r15, %rdi
movq %r13, %rdx
callq 0xb74c
incq %r12
movq (%r14), %r13
movq 0x8(%r14), %rax
subq %r13, %rax
movq %rax, %rdx
sarq $0x3, %rdx
shrq $0x3, %rax
cltq
addq $0x8, %rbp
cmpq %rax, %r12
jl 0x19c0f
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12c49(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: exclude_annot_regions(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, bool)
vector<t_annot_region*>* exclude_annot_regions(vector<t_annot_region*>* annot_regions1,
													vector<t_annot_region*>* annot_regions2, 
													bool strand_specific)
{
	if(strand_specific)
	{
		vector<t_annot_region*>* excluded_regions = new vector<t_annot_region*>();

		vector<t_annot_region*>* reg1_pos_regs = get_regions_per_strand(annot_regions1, '+');
		vector<t_annot_region*>* reg1_neg_regs = get_regions_per_strand(annot_regions1, '-');

		vector<t_annot_region*>* reg2_pos_regs = get_regions_per_strand(annot_regions2, '+');
		vector<t_annot_region*>* reg2_neg_regs = get_regions_per_strand(annot_regions2, '-');

		// Do strand specific exclusion.
		vector<t_annot_region*>* reg1_min_reg2_pos = exclude_annot_regions(reg1_pos_regs, reg2_pos_regs);
		vector<t_annot_region*>* reg1_min_reg2_neg = exclude_annot_regions(reg1_neg_regs, reg2_neg_regs);

		// Add the excluded regions.
		excluded_regions->insert(excluded_regions->end(), reg1_min_reg2_pos->begin(), reg1_min_reg2_pos->end());
		excluded_regions->insert(excluded_regions->end(), reg1_min_reg2_neg->begin(), reg1_min_reg2_neg->end());

		return(excluded_regions);
	}
	else
	{
		vector<t_annot_region*>* excluded_regions = exclude_annot_regions(annot_regions1, annot_regions2);
		return(excluded_regions);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
testl %edx, %edx
je 0x1a251
movl $0x18, %edi
callq 0x2180
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r15, %rdi
movl $0x2b, %esi
callq 0x1a265
movq %rax, %r12
movq %r15, %rdi
movl $0x2d, %esi
callq 0x1a265
movq %rax, %r15
movq %r14, %rdi
movl $0x2b, %esi
callq 0x1a265
movq %rax, %r13
movq %r14, %rdi
movl $0x2d, %esi
callq 0x1a265
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a318
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a318
movq %rax, %r14
movq (%r12), %rdx
movq 0x8(%r12), %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb3f0
movq 0x8(%rbx), %rsi
movq (%r14), %rdx
movq 0x8(%r14), %rcx
movq %rbx, %rdi
callq 0xb3f0
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1a318
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_regions_per_strand(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, char)
vector<t_annot_region*>* get_regions_per_strand(vector<t_annot_region*>* annot_regions,
													char strand)
{
	vector<t_annot_region*>* chr_regions = new vector<t_annot_region*>();

	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		//bool new_id = false;

		// Check if the the current chromosome id is included in the list of chromosome ids already collected, otherwise add it.
		if(annot_regions->at(i_reg)->strand == strand)
		{
			// Add the current region to the chromosome regions.
			chr_regions->push_back(annot_regions->at(i_reg));
		}
	} // i_reg loop.

	return(chr_regions);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %rdx
movq 0x8(%r14), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x1a2f7
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x1a304
movq (%rdx,%r13), %rax
cmpb %bl, 0x8(%rax)
jne 0x1a2d3
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1a2c8
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1a2d3
addq %r13, %rdx
movq %r15, %rdi
callq 0xb74c
incq %r12
movq (%r14), %rdx
movq 0x8(%r14), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %r13
cmpq %rcx, %r12
jl 0x1a2a6
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x125c5(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: delete_annot_regions(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*)
void delete_annot_regions(vector<t_annot_region*>* region_list)
{
	for(int i_reg = 0; i_reg < (int)region_list->size(); i_reg++)
	{
		if(region_list->at(i_reg) != NULL)
		{
			delete [] region_list->at(i_reg)->chrom;

			if(region_list->at(i_reg)->name != NULL)
			{
				delete [] region_list->at(i_reg)->name;
			}

			delete(region_list->at(i_reg));
		}
	} // i_reg loop.

	region_list->clear();
	delete(region_list);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x8(%rbx), %rdx
movq %rdx, %rax
subq %rdi, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x1a943
xorl %r14d, %r14d
cmpq %r14, %rax
jbe 0x1a97d
movq (%rdi,%r14,8), %rax
testq %rax, %rax
je 0x1a923
movq (%rax), %rax
testq %rax, %rax
je 0x1a8d6
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x1a971
movq (%rdi,%r14,8), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x1a909
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x1a971
movq (%rdi,%r14,8), %rdi
movl $0x50, %esi
callq 0x2190
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
incq %r14
movq %rdx, %rcx
subq %rdi, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r14
jl 0x1a8ad
cmpq %rdi, %rdx
je 0x1a94c
movq %rdi, 0x8(%rbx)
testq %rdi, %rdi
je 0x1a95d
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2190
movl $0x18, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2190
leaq 0x11f58(%rip), %rdi     # 0x2c8d0
movq %r14, %rsi
jmp 0x1a98a
leaq 0x11f4c(%rip), %rdi     # 0x2c8d0
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_regions_per_end_max(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int)
vector<t_annot_region*>* get_regions_per_end_max(vector<t_annot_region*>* annot_regions, int end_max)
{
	vector<t_annot_region*>* end_max_regs = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		if(annot_regions->at(i_reg)->end < end_max)
		{
			end_max_regs->push_back(annot_regions->at(i_reg));
		}
	} // i_reg loop.

	return(end_max_regs);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %rdx
movq 0x8(%r14), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x1ac17
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x1ac24
movq (%rdx,%r13), %rax
cmpl %ebx, 0x20(%rax)
jge 0x1abf3
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1abe8
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1abf3
addq %r13, %rdx
movq %r15, %rdi
callq 0xb74c
incq %r12
movq (%r14), %rdx
movq 0x8(%r14), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %r13
cmpq %rcx, %r12
jl 0x1abc6
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x11ca5(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_regions_per_min_run(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int)
vector<t_annot_region*>* get_regions_per_min_run(vector<t_annot_region*>* annot_regions, int l_min_run)
{
	vector<t_annot_region*>* min_run_regs = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		if(annot_regions->at(i_reg)->end - annot_regions->at(i_reg)->start > l_min_run)
		{
			min_run_regs->push_back(annot_regions->at(i_reg));
		}
	} // i_reg loop.

	return(min_run_regs);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %rdx
movq 0x8(%r14), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x1accf
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x1acdc
movq (%rdx,%r13), %rax
movl 0x20(%rax), %ecx
subl 0xc(%rax), %ecx
cmpl %ebx, %ecx
jle 0x1acab
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1aca0
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1acab
addq %r13, %rdx
movq %r15, %rdi
callq 0xb74c
incq %r12
movq (%r14), %rdx
movq 0x8(%r14), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %r13
cmpq %rcx, %r12
jl 0x1ac79
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x11bed(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: get_regions_per_max_run(std::vector<t_annot_region*, std::allocator<t_annot_region*>>*, int)
vector<t_annot_region*>* get_regions_per_max_run(vector<t_annot_region*>* annot_regions, int l_max_run)
{
	vector<t_annot_region*>* min_run_regs = new vector<t_annot_region*>();
	for(int i_reg = 0; i_reg < (int)annot_regions->size(); i_reg++)
	{
		if(annot_regions->at(i_reg)->end - annot_regions->at(i_reg)->start < l_max_run)
		{
			min_run_regs->push_back(annot_regions->at(i_reg));
		}
	} // i_reg loop.

	return(min_run_regs);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%r14), %rdx
movq 0x8(%r14), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x1ad87
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x1ad94
movq (%rdx,%r13), %rax
movl 0x20(%rax), %ecx
subl 0xc(%rax), %ecx
cmpl %ebx, %ecx
jge 0x1ad63
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1ad58
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1ad63
addq %r13, %rdx
movq %r15, %rdi
callq 0xb74c
incq %r12
movq (%r14), %rdx
movq 0x8(%r14), %rcx
subq %rdx, %rcx
movq %rcx, %rax
sarq $0x3, %rax
shrq $0x3, %rcx
movslq %ecx, %rcx
addq $0x8, %r13
cmpq %rcx, %r12
jl 0x1ad31
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x11b35(%rip), %rdi     # 0x2c8d0
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270