LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_filter_utils.cpp
// Function: get_next_2_exp(int, int&, int&)
void get_next_2_exp(int val, int& larger_exp_val, int& expon)
{
	int cur_val = 1;
	int cur_exp = 0;
	while(cur_val < val)
	{
		cur_exp++;
		cur_val *= 2;
	}

	expon = cur_exp;
	larger_exp_val = cur_val;
}

// Assembly:
cmpl $0x2, %edi
jl 0x1308b
movl $0x1, %eax
xorl %ecx, %ecx
incl %ecx
addl %eax, %eax
cmpl %edi, %eax
jl 0x13081
jmp 0x13092
xorl %ecx, %ecx
movl $0x1, %eax
movl %ecx, (%rdx)
movl %eax, (%rsi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_filter_utils.cpp
// Function: mapability_aware_median_filter(double*, int, double*, int, double, int)
double* mapability_aware_median_filter(double* signal_profile, int l_profile,
	double* scaled_mapability_profile, int l_mapability_profile,
	double max_mapable_signal_2_use_in_filter,
	int l_mapability_filtering_win)
{
	// Generate the signal profile to input to the filtering.
	double* input_signal_profile = new double[l_profile + 2];
	for(int i = 1; i <= l_profile; i++)
	{
		if(l_mapability_profile > i)
		{
			if(scaled_mapability_profile[i] > max_mapable_signal_2_use_in_filter)
			{
				input_signal_profile[i] = -1;
			}
			else
			{
				input_signal_profile[i] = signal_profile[i];
			}
		}
		else
		{
			input_signal_profile[i] = signal_profile[i];
		}
	} // i loop.

if(__DUMP_FILTER_MSGS__)
{
	fprintf(stderr, "Mapability aware filtering.\n");
}

	double* mapable_median_profile = median_filter_data(input_signal_profile,
													l_profile, 
													l_mapability_filtering_win,
													-1);

	double* filtered_signal = new double[l_profile + 5];

	// Compare the actual signal profile with the 
	for(int i = 1; i <= l_profile; i++)
	{
		filtered_signal[i] = MAX(mapable_median_profile[i], signal_profile[i]);
	} // i loop.

	delete [] mapable_median_profile;
	delete [] input_signal_profile;

	return(filtered_signal);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0xc(%rsp)
movsd %xmm0, 0x10(%rsp)
movl %ecx, %r13d
movq %rdx, %r12
movl %esi, %ebx
movq %rdi, %r14
movslq %esi, %rbp
leaq 0x10(,%rbp,8), %rax
cmpl $-0x2, %ebp
movq $-0x1, %rdi
cmovgeq %rax, %rdi
callq 0x2040
movq %rax, %r15
testl %ebp, %ebp
jle 0x1538e
movslq %r13d, %rax
leal 0x1(%rbx), %ecx
movl $0x1, %edx
movsd 0x15d0d(%rip), %xmm0    # 0x2b070
cmpq %rax, %rdx
jge 0x1537a
movsd (%r12,%rdx,8), %xmm1
ucomisd 0x10(%rsp), %xmm1
movapd %xmm0, %xmm1
ja 0x15380
movsd (%r14,%rdx,8), %xmm1
movsd %xmm1, (%r15,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x15363
cmpb $0x0, 0x24e38(%rip)     # 0x3a1cd
jne 0x15413
movq %r15, %rdi
movl %ebx, %esi
movl 0xc(%rsp), %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1323e
movq %rax, %r12
leaq 0x28(,%rbp,8), %rax
cmpl $-0x5, %ebx
movq $-0x1, %rdi
cmovgeq %rax, %rdi
callq 0x2040
movq %rax, %r13
testl %ebx, %ebx
jle 0x153f1
incl %ebx
movl $0x1, %eax
movsd (%r12,%rax,8), %xmm0
maxsd (%r14,%rax,8), %xmm0
movsd %xmm0, (%r13,%rax,8)
incq %rax
cmpq %rax, %rbx
jne 0x153d6
movq %r12, %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x49e0
jmp 0x15397
// File: /workspace/github_cpp_makefile_star2_O1/gersteinlab[P]MUSIC/src/ms_filter_utils.cpp
// Function: get_origin_of_symmetry(double*, int, int, int&, int)
bool get_origin_of_symmetry(double* filtered_data, int l_signal, int search_start_i, int& origin, int l_mirror_check)
{
	if(search_start_i < l_mirror_check)
	{
		search_start_i = l_mirror_check;
	}

	for(int i_c = l_mirror_check; i_c < l_signal-l_mirror_check; i_c++)
	{
		bool current_origin_check = true;
		for(int i = 0; 
			current_origin_check && i < l_mirror_check; 
			i++)
		{
			if(fabs(filtered_data[i_c+i] - filtered_data[i_c-i]) > 0.00001)
			{
				current_origin_check = false;
			}
		} // i loop.

		if(current_origin_check)
		{
			fprintf(stderr, "Found origin of symmetry @ %d\n", i_c);
			origin = i_c;
			return(true);
		}
	} // i_c loop.

	return(false);
}

// Assembly:
subl %r8d, %esi
cmpl %r8d, %esi
setg %al
jle 0x154f8
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
testl %r8d, %r8d
jle 0x154cb
movslq %r8d, %rcx
movslq %esi, %rdx
leaq (%rdi,%rcx,8), %rdi
movapd 0x1858e(%rip), %xmm0    # 0x2d9e0
movsd 0x191b6(%rip), %xmm1    # 0x2e610
movl %r8d, %r14d
movl %eax, %ebp
movq %rcx, %r9
movb $0x1, %r10b
movl $0x1, %r15d
xorl %r11d, %r11d
movsd -0x8(%rdi,%r15,8), %xmm2
subsd (%rdi,%r11), %xmm2
andpd %xmm0, %xmm2
xorl %r12d, %r12d
ucomisd %xmm1, %xmm2
ja 0x1548c
movzbl %r10b, %r12d
movl %r12d, %r10d
testb $0x1, %r12b
je 0x154a5
leaq 0x1(%r15), %r12
addq $-0x8, %r11
cmpq %rcx, %r15
movq %r12, %r15
jl 0x1546e
testb $0x1, %r10b
jne 0x154d0
movq %r9, %r14
incq %r14
cmpq %rdx, %r14
setl %bpl
cmpl %r14d, %esi
je 0x154ee
addq $0x8, %rdi
movq %r14, %r9
testl %r8d, %r8d
jg 0x15462
jmp 0x154ce
movl %r8d, %r14d
movl %eax, %ebp
movq 0x24b09(%rip), %rax     # 0x39fe0
movq (%rax), %rdi
leaq 0x193a6(%rip), %rsi     # 0x2e887
movl %r14d, %edx
xorl %eax, %eax
callq 0x2250
movl %r14d, (%rbx)
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
andb $0x1, %al
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x1596d
movl %ebp, %r13d
shrl $0x1f, %r13d
addl %ebp, %r13d
sarl %r13d
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x1597f
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 0x273e0
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 0x1597f
movq (%rcx,%r15,8), %rcx
movb 0x8(%rcx), %cl
movb %cl, 0x8(%rax)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x1593f
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x1594a
movq %r14, %rdi
movq %rsp, %rdx
callq 0xb976
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 0x158a1
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17f50(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x15f72
xorpd %xmm2, %xmm2
xorl %r12d, %r12d
xorl %r15d, %r15d
xorpd %xmm3, %xmm3
cmpq %r15, %rax
jbe 0x15f82
movq (%rdx,%r12), %rax
movl 0x20(%rax), %ebp
subl 0xc(%rax), %ebp
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x15f0f
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x15f2f
addq %r12, %rdx
movq %r14, %rdi
movsd %xmm3, 0x8(%rsp)
callq 0xb976
movsd 0x8(%rsp), %xmm3
xorpd %xmm2, %xmm2
movsd (%rsp), %xmm1
ucomisd %xmm2, %xmm1
jne 0x15f37
jnp 0x15f72
incl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0x15f72
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 0x15ee8
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1794d(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x16187
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movl $0x1, %r10d
movl %esi, %r11d
testl %esi, %esi
jg 0x16140
cmpq %r8, %rdx
jbe 0x1619a
movq (%r9,%r8,8), %rbx
movl 0x20(%rbx), %r11d
subl 0xc(%rbx), %r11d
cmpq %r8, %rdx
je 0x1618e
movq (%r9,%r8,8), %rbx
cmpb $0x2b, 0x8(%rbx)
jne 0x16166
testb %cl, %cl
je 0x16160
movl 0xc(%rbx), %ebp
subl %r11d, %ebp
cmovlel %r10d, %ebp
movl %ebp, 0xc(%rbx)
testb %al, %al
jne 0x1617b
jmp 0x1617f
testb %al, %al
je 0x16177
movl 0xc(%rbx), %ebp
subl %r11d, %ebp
cmovlel %r10d, %ebp
movl %ebp, 0xc(%rbx)
testb %cl, %cl
je 0x1617f
addl %r11d, 0x20(%rbx)
incq %r8
cmpq %r8, %rdi
jne 0x16128
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x17741(%rip), %rdi     # 0x2d8d6
movq %rdx, %rsi
jmp 0x161a4
leaq 0x17735(%rip), %rdi     # 0x2d8d6
movq %r8, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x158ee(%rip), %rsi     # 0x2baae
callq 0x26387
movq %rax, %r14
movq (%rbx), %rbp
movq 0x8(%rbx), %rdx
subq %rbp, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x162ab
leaq 0x1870b(%rip), %r12     # 0x2e8f0
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x162c1
movq (%rbp,%r15,8), %r13
movzbl 0x8(%r13), %eax
cmpl $0x2d, %eax
je 0x16205
cmpl $0x2b, %eax
jne 0x16269
cmpq $0x0, 0x18(%r13)
jne 0x16228
movl $0x5, %edi
callq 0x2040
movq %rax, 0x18(%r13)
movq (%rbp,%r15,8), %rax
movq 0x18(%rax), %rax
movw $0x2e, (%rax)
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x162c1
movq (%rax,%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 0x16288
movq (%r13), %rdx
movl 0xc(%r13), %ecx
decl %ecx
movl 0x20(%r13), %r8d
movq %r14, %rdi
leaq 0x18681(%rip), %rsi     # 0x2e902
xorl %eax, %eax
callq 0x2250
incq %r15
movq (%rbx), %rbp
movq 0x8(%rbx), %rax
subq %rbp, %rax
movq %rax, %rdx
sarq $0x3, %rdx
shrq $0x3, %rax
cltq
cmpq %rax, %r15
jl 0x161e8
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2170
leaq 0x1760e(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x16b9d
cmpl %ecx, %edx
je 0x16b9d
movslq %edx, %r9
movq (%rsi), %r10
movq 0x8(%rsi), %r8
subq %r10, %r8
sarq $0x3, %r8
cmpq %r9, %r8
jbe 0x16bf3
movq (%r10,%r9,8), %r9
movl 0xc(%r9), %r9d
cmpl %eax, %r9d
je 0x16bcd
jg 0x16b54
jl 0x16b50
movl %ecx, %edx
movl %eax, %ecx
callq 0x4bd1
cmpl $0x2, %r11d
jl 0x16bef
movq (%rsi), %rdi
movq 0x8(%rsi), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movl %edx, %esi
cmpq %rsi, %rcx
jbe 0x16bff
movq (%rdi,%rsi,8), %rsi
cmpl %eax, 0xc(%rsi)
jl 0x16bef
leal -0x1(%rdx), %esi
cmpl $0x1, %edx
movl %esi, %edx
jg 0x16bb1
jmp 0x16bed
cmpl $0x2, %r11d
jl 0x16bef
movl %edx, %esi
cmpq %rsi, %r8
jbe 0x16c0b
movq (%r10,%rsi,8), %rcx
cmpl %eax, 0xc(%rcx)
jl 0x16bef
leal -0x1(%rdx), %ecx
cmpl $0x1, %edx
movl %ecx, %edx
jg 0x16bd3
xorl %edx, %edx
movl %edx, %eax
popq %rcx
retq
leaq 0x16cdc(%rip), %rdi     # 0x2d8d6
movq %r9, %rsi
jmp 0x16c12
leaq 0x16cd0(%rip), %rdi     # 0x2d8d6
movq %rcx, %rdx
jmp 0x16c15
leaq 0x16cc4(%rip), %rdi     # 0x2d8d6
movq %r8, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x16d09
xorl %r14d, %r14d
cmpq %r14, %rdx
jbe 0x16d6e
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x16c58
callq 0x2220
movq 0x10(%rbx), %rax
movq (%rax,%r14,8), %r15
testq %r15, %r15
je 0x16c86
movq (%r15), %rdi
testq %rdi, %rdi
je 0x16c79
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 0x16cb4
movq (%r15), %rdi
testq %rdi, %rdi
je 0x16ca7
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 0x16ce1
movq (%r15), %rdi
testq %rdi, %rdi
je 0x16cd4
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 0x16c41
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x16d17
callq 0x2220
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x16d25
callq 0x2220
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x16d32
callq 0x2220
movq 0x18(%rbx), %r14
testq %r14, %r14
je 0x16d5c
movq (%r14), %rdi
testq %rdi, %rdi
je 0x16d4f
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 0x16b61(%rip), %rdi     # 0x2d8d6
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
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 0x17300
movq %r15, %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, (%r14)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
jmp 0x17307
movq $0x0, (%r14)
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x17332
movq %r15, %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, 0x18(%r14)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
jmp 0x1733a
movq $0x0, 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
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rbx), %rcx
movq %rbx, 0x18(%rsp)
movq 0x8(%rbx), %r14
movq %rcx, 0x8(%rsp)
subq %rcx, %r14
sarq $0x3, %r14
testl %r14d, %r14d
jle 0x176bc
xorl %r15d, %r15d
movq %rax, 0x10(%rsp)
movq (%rax), %rcx
movq 0x8(%rax), %rbp
movq %rbp, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
subq %rcx, %rbp
sarq $0x3, %rbp
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
movb $0x1, %bl
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x1762c
cmpq %r13, %rbp
je 0x176da
cmpq %r15, %r14
jbe 0x176cb
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %rdi
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rsi
callq 0x2240
testl %eax, %eax
movzbl %bl, %ebx
cmovel %eax, %ebx
incq %r13
testb $0x1, %bl
jne 0x175e9
jmp 0x1768a
cmpq %r15, %r14
jbe 0x176cb
movq 0x8(%rsp), %rbx
movq (%rbx,%r15,8), %rax
movq (%rax), %rdi
callq 0x20d0
leaq 0x2(%rax), %rdi
callq 0x2040
movq %rax, %r13
movq %rax, 0x30(%rsp)
movq (%rbx,%r15,8), %rax
movq (%rax), %rsi
movq %r13, %rdi
callq 0x2150
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
cmpq 0x10(%rdi), %rsi
je 0x17680
movq %r13, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x1768a
leaq 0x30(%rsp), %rdx
callq 0x12d32
incq %r15
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rsp)
subq %rcx, %rax
movq %rax, %r14
sarq $0x3, %r14
shrq $0x3, %rax
cltq
cmpq %rax, %r15
movq 0x10(%rsp), %rax
jl 0x175c0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16204(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
movq %r14, %rdx
jmp 0x176e7
leaq 0x161f5(%rip), %rdi     # 0x2d8d6
movq %rbp, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x17e10
cmpb $0x23, (%rbx)
je 0x17e10
addq $0x2, %rax
movq %rax, %rdi
callq 0x2040
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2150
leaq 0x16758(%rip), %rsi     # 0x2e53e
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2160
leaq 0x16f9e(%rip), %rsi     # 0x2ed98
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_O1/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
setle %bl
jle 0x18255
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rdx, %rdi
negq %rdi
movq %rsi, %r9
negq %r9
movl $0x1, %r10d
leaq (%rdi,%r10), %rcx
cmpq $0x1, %rcx
je 0x18279
movq -0x8(%rax,%r10,8), %r11
movl 0xc(%r11), %ecx
movl 0x20(%r11), %r8d
cmpl %r8d, %ecx
jg 0x1825c
cmpq %rsi, %r10
setae %bl
leaq (%r9,%r10), %rcx
incq %rcx
incq %r10
cmpq $0x1, %rcx
jne 0x18223
andb $0x1, %bl
movl %ebx, %eax
popq %rbx
retq
movq 0x21d7d(%rip), %rax     # 0x39fe0
movq (%rax), %rdi
movq (%r11), %rdx
leaq 0x16c58(%rip), %rsi     # 0x2eec8
xorl %eax, %eax
callq 0x2250
jmp 0x18255
leaq 0x15656(%rip), %rdi     # 0x2d8d6
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x137e5(%rip), %rsi     # 0x2baae
movq %rax, %rdi
callq 0x26387
movq %rax, %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x18345
xorl %r15d, %r15d
leaq 0x1683c(%rip), %r12     # 0x2eb2c
cmpq %r15, %rdx
jbe 0x18358
movq (%rax,%r15,8), %rax
movq 0x40(%rax), %rsi
movq (%rax), %rdx
movl 0xc(%rax), %ecx
movl 0x20(%rax), %r8d
movsd (%rsi), %xmm0
divsd 0x156ad(%rip), %xmm0    # 0x2d9c0
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 0x182f0
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2170
leaq 0x15577(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x13730(%rip), %rsi     # 0x2baae
movq %rax, %rdi
callq 0x26387
movq %rax, %r14
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x183f3
xorl %r15d, %r15d
leaq 0x16787(%rip), %r12     # 0x2eb2c
cmpq %r15, %rdx
jbe 0x18406
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 0x183a5
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2170
leaq 0x154c9(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x158bb(%rip), %rsi     # 0x2dd08
movq %r14, %rdi
callq 0x26387
movq %rax, %r14
leaq 0x20(%rsp), %r12
leaq 0x18(%rsp), %r15
movq %r14, %rdi
callq 0x26258
testq %rax, %rax
je 0x18548
movq %rax, %r13
movq $0x0, 0x18(%rsp)
movq %rax, %rdi
leaq 0x166b6(%rip), %rsi     # 0x2eb3f
movq %r12, %rdx
leaq 0x14(%rsp), %rcx
leaq 0x10(%rsp), %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x2160
cmpl $0x4, %eax
jne 0x18565
movl $0x10, %edi
callq 0x2180
movq %rax, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
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 0x273e0
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 %rbp, 0x40(%rax)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x18532
movq %rax, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x1853f
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0xb976
testq %r13, %r13
jne 0x18462
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 0x4d93
// File: /workspace/github_cpp_makefile_star2_O1/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), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x18e60
xorl %r15d, %r15d
cmpq %r15, %rdx
jbe 0x18e86
movq (%rax,%r15,8), %rax
movq 0x30(%rax), %r13
movq (%r13), %rdx
movq 0x8(%r13), %rax
subq %rdx, %rax
sarq $0x3, %rax
testl %eax, %eax
jle 0x18e3c
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x18e72
addq %rbp, %rdx
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x18e0f
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x18e17
movq %r14, %rdi
callq 0xb976
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 0x18df0
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 0x18dc7
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14a5d(%rip), %rdi     # 0x2d8d6
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x14a49(%rip), %rdi     # 0x2d8d6
movq %r15, %rsi
jmp 0x18e7f
// File: /workspace/github_cpp_makefile_star2_O1/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 0x19371
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorpd %xmm0, %xmm0
xorl %edi, %edi
cmpq %rax, %rcx
je 0x19377
movq (%rax,%rdi,8), %r9
testq %r9, %r9
je 0x19367
movl 0x20(%r9), %r8d
subl 0xc(%r9), %r8d
jl 0x19367
incl %r8d
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
addsd %xmm1, %xmm0
incq %rdi
cmpq %rdi, %rsi
jne 0x19340
jmp 0x19375
xorpd %xmm0, %xmm0
popq %rax
retq
leaq 0x14558(%rip), %rdi     # 0x2d8d6
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x193f3
movq %rax, %rdi
callq 0x1931c
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x1931c
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
callq 0x1931c
addsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
je 0x193e7
cvttsd2si 0x8(%rsp), %ecx
addl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
jmp 0x193eb
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x1756e
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 0x19fd9
leaq 0x14ea4(%rip), %r13     # 0x2ed70
leaq 0x4(%rsp), %rbp
xorl %r12d, %r12d
cmpq %r12, %rdx
jbe 0x19ffc
movq (%rax,%r12,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x1a008
movq %rax, %rbx
movq (%rax), %rdi
movq 0x8(%rax), %rax
movq %rax, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
cmpl $0x2, %edx
jl 0x19f89
movl $0x1, %r14d
cmpq %r14, %rdx
jbe 0x19feb
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 0x19f41
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 0x19f5b
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r15)
jmp 0x19f66
movq %r15, %rdi
movq %rbp, %rdx
callq 0xadd0
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 0x19f0e
cmpq %rdi, %rax
je 0x19f92
movq %rdi, 0x8(%rbx)
testq %rdi, %rdi
je 0x19fa3
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 0x19ed4
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x138e4(%rip), %rdi     # 0x2d8d6
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270
leaq 0x138d3(%rip), %rdi     # 0x2d8d6
movq %r12, %rsi
jmp 0x19ff5
// File: /workspace/github_cpp_makefile_star2_O1/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 0x1a0ab
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq %r12, %rdx
jbe 0x1a0bd
movq (%r13,%rbp), %rbx
movq (%rbx), %rdi
movq (%rsp), %rsi
callq 0x2240
testl %eax, %eax
jne 0x1a088
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1a07a
movq %rbx, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1a088
addq %rbp, %r13
movq %r15, %rdi
movq %r13, %rdx
callq 0xb976
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 0x1a04c
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13812(%rip), %rdi     # 0x2d8d6
movq %r12, %rsi
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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 0x1a686
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 0x1a69a
movq %rax, %r12
movq %r15, %rdi
movl $0x2d, %esi
callq 0x1a69a
movq %rax, %r15
movq %r14, %rdi
movl $0x2b, %esi
callq 0x1a69a
movq %rax, %r13
movq %r14, %rdi
movl $0x2d, %esi
callq 0x1a69a
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x1a74d
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a74d
movq %rax, %r14
movq 0x8(%rbx), %rsi
movq (%r12), %rdx
movq 0x8(%r12), %rcx
movq %rbx, %rdi
callq 0xb5e2
movq 0x8(%rbx), %rsi
movq (%r14), %rdx
movq 0x8(%r14), %rcx
movq %rbx, %rdi
callq 0xb5e2
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 0x1a74d
// File: /workspace/github_cpp_makefile_star2_O1/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 0x1a72c
xorl %r13d, %r13d
xorl %r12d, %r12d
cmpq %r12, %rax
jbe 0x1a739
movq (%rdx,%r13), %rax
cmpb %bl, 0x8(%rax)
jne 0x1a708
movq 0x8(%r15), %rsi
cmpq 0x10(%r15), %rsi
je 0x1a6fd
movq %rax, (%rsi)
addq $0x8, 0x8(%r15)
jmp 0x1a708
addq %r13, %rdx
movq %r15, %rdi
callq 0xb976
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 0x1a6db
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x13196(%rip), %rdi     # 0x2d8d6
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2270
// File: /workspace/github_cpp_makefile_star2_O1/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), %rax
movq %rax, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
testl %edx, %edx
jle 0x1ad91
xorl %r14d, %r14d
cmpq %r14, %rdx
jbe 0x1adbf
movq (%rdi,%r14,8), %rax
testq %rax, %rax
je 0x1ad6a
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1ad1b
callq 0x2220
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x1adbf
movq (%rax,%r14,8), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x1ad44
callq 0x2220
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r14, %rdx
jbe 0x1adbf
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x1ad6a
movl $0x50, %esi
callq 0x2190
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 0x1acfc
cmpq %rdi, %rax
je 0x1ad9a
movq %rdi, 0x8(%rbx)
testq %rdi, %rdi
je 0x1adab
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 0x12b10(%rip), %rdi     # 0x2d8d6
movq %r14, %rsi
xorl %eax, %eax
callq 0x2270