// File: /workspace/github_cpp_makefile_star2_O3/gersteinlab[P]MUSIC/src/ms_annot_region_tools.cpp
// Function: load_Interval(char*)
vector<t_annot_region*>* load_Interval(char* interval_fp)
{
	vector<t_annot_region*>* composite_interval_regions = new vector<t_annot_region*>();

	FILE* f_interval = open_f(interval_fp, "r");
	char* cur_line = getline(f_interval);
	while(cur_line != NULL)
	{
		bool skip_line = check_line_skip(cur_line);

		if(!skip_line)
		{
			// ENST00000469418.1|ENST00000480075.1     chr7    -       19757   35479   4       19757,20834,31060,35335 19895,21029,31606,35479
			char region_name[1000];
			char cur_chrom[1000];
			char cur_strand;
			int cur_start;
			int cur_end;
			int n_intervals;
			char int_starts[100000];
			char int_ends[100000];

			if(sscanf(cur_line, "%s %s %c %d %d %d %s %s", region_name, cur_chrom, 
				&cur_strand, &cur_start, &cur_end, &n_intervals, int_starts, int_ends) == 8)
			{
				t_annot_region* new_int_comp_region = new t_annot_region();
				new_int_comp_region->chrom = t_string::copy_me_str(cur_chrom);
				normalize_chr_id(new_int_comp_region->chrom);
				new_int_comp_region->start = translate_coord(cur_start, INTERVAL_COORDS::start_base, CODEBASE_COORDS::start_base);
				new_int_comp_region->end = translate_coord(cur_end, INTERVAL_COORDS::end_base, CODEBASE_COORDS::end_base);
				new_int_comp_region->strand = cur_strand;
				new_int_comp_region->name = t_string::copy_me_str(region_name);
				new_int_comp_region->intervals = new vector<t_annot_region*>();

				// Allocate the interval.
				vector<t_annot_region*>* intervals = new vector<t_annot_region*>();
				t_string* starts_str = new t_string(int_starts);
				t_string* ends_str = new t_string(int_ends);
				vector<int>* starts = starts_str->get_integers_in_string();
				vector<int>* ends = ends_str->get_integers_in_string();

				if(starts->size() != ends->size())
				{
					fprintf(stderr, "The number of starts is not the same as ends in:\n%s\n", cur_line);
					exit(0);
				}

				// Parse all the intervals.
				for(int i_int = 0; i_int < (int)starts->size(); i_int++)
				{
					t_annot_region* new_interval = new t_annot_region();
					new_interval->chrom = t_string::copy_me_str(cur_chrom);
					normalize_chr_id(new_interval->chrom);
					new_interval->start = translate_coord(starts->at(i_int), INTERVAL_COORDS::start_base, CODEBASE_COORDS::start_base);
					new_interval->end = translate_coord(ends->at(i_int), INTERVAL_COORDS::end_base, CODEBASE_COORDS::end_base);

					if(ends->at(i_int) < starts->at(i_int))
					{
						fprintf(stderr, "One of the starts is larger than the end for:\n%s\n", cur_line);
						exit(0);
					}

					new_interval->strand = cur_strand;

					intervals->push_back(new_interval);
				} // i_int loop.

				new_int_comp_region->intervals = intervals;

				composite_interval_regions->push_back(new_int_comp_region);
			}
			else
			{
				fprintf(stderr, "Could not parse:\n%s\n", cur_line);
				exit(0);
			}
		} // skip_line check.

		delete [] cur_line;

		// Read the next line.
		cur_line = getline(f_interval);
	}
	fclose(f_interval);

	return(composite_interval_regions);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x31568, %rsp          # imm = 0x31568
movq %rdi, %rbx
movl $0x18, %edi
callq 0x2180
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x1466c(%rip), %rsi     # 0x2cd08
movq %rbx, %rdi
callq 0x25d5a
movq %rax, %rbx
movq %rax, %rdi
callq 0x25c1e
testq %rax, %rax
je 0x18971
movq %rax, %r15
leaq 0x820(%rsp), %r14
leaq 0x40(%rsp), %r13
leaq 0x430(%rsp), %r12
movq %rbp, 0x30(%rsp)
movq %rbx, 0x28(%rsp)
movq %r15, %rdi
callq 0x17a51
testb %al, %al
jne 0x18955
movq %r15, %rdi
leaq 0x1546f(%rip), %rsi     # 0x2db63
movq %r13, %rdx
movq %r12, %rcx
leaq 0xf(%rsp), %r8
leaq 0x24(%rsp), %r9
xorl %eax, %eax
leaq 0x18ec0(%rsp), %r10
pushq %r10
pushq %r14
leaq 0x4c(%rsp), %r10
pushq %r10
leaq 0x38(%rsp), %r10
pushq %r10
callq 0x2160
addq $0x20, %rsp
cmpl $0x8, %eax
jne 0x189b1
movl $0x50, %edi
callq 0x2180
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movq %rax, 0x10(%rsp)
movq %r12, %rdi
callq 0x26db4
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x12c04
movl 0x24(%rsp), %eax
incl %eax
movq 0x10(%rsp), %rcx
movl %eax, 0xc(%rcx)
movl 0x20(%rsp), %eax
movl %eax, 0x20(%rcx)
movb 0xf(%rsp), %al
movb %al, 0x8(%rcx)
movq %r13, %rdi
callq 0x26db4
movq 0x10(%rsp), %rbx
movq %rax, 0x18(%rbx)
movl $0x18, %edi
callq 0x2180
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %r13d, %r13d
movq %r13, 0x10(%rax)
movq %rax, 0x30(%rbx)
movl $0x18, %edi
callq 0x2180
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r13, 0x10(%rax)
movl $0x8, %edi
callq 0x2180
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2665c
movl $0x8, %edi
callq 0x2180
movq %rax, %r13
movq %rax, %rdi
leaq 0x18ec0(%rsp), %rsi
callq 0x2665c
movq %rbx, %rdi
callq 0x270bc
movq %rax, %r14
movq %r13, %rdi
callq 0x270bc
movq %rax, %rbx
movq 0x8(%r14), %rax
subq (%r14), %rax
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x189a9
shrq $0x2, %rax
testl %eax, %eax
jle 0x18914
xorl %r13d, %r13d
movl $0x50, %edi
callq 0x2180
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x40(%rax)
movq %rax, 0x18(%rsp)
movq %r12, %rdi
callq 0x26db4
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rax
movq (%rax), %rdi
callq 0x12c04
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x1898e
movl (%rax,%r13,4), %edx
incl %edx
movq 0x18(%rsp), %rcx
movl %edx, 0xc(%rcx)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
subq %rsi, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x18998
movl (%rsi,%r13,4), %edx
movl %edx, 0x20(%rcx)
cmpl (%rax,%r13,4), %edx
jl 0x18990
movb 0xf(%rsp), %al
movb %al, 0x8(%rcx)
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
je 0x188ee
movq %rcx, (%rsi)
addq $0x8, 0x8(%rbp)
jmp 0x188fb
movq %rbp, %rdi
leaq 0x18(%rsp), %rdx
callq 0xb74c
movq 0x8(%r14), %rax
subq (%r14), %rax
incq %r13
shrq $0x2, %rax
cltq
cmpq %rax, %r13
jl 0x18844
movq 0x10(%rsp), %rax
movq %rbp, 0x30(%rax)
movq 0x30(%rsp), %rbp
movq 0x8(%rbp), %rsi
cmpq 0x10(%rbp), %rsi
je 0x18936
movq %rax, (%rsi)
addq $0x8, 0x8(%rbp)
jmp 0x18943
movq %rbp, %rdi
leaq 0x10(%rsp), %rdx
callq 0xb74c
movq 0x28(%rsp), %rbx
leaq 0x820(%rsp), %r14
leaq 0x40(%rsp), %r13
movq %r15, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x25c1e
movq %rax, %r15
testq %rax, %rax
jne 0x186da
movq %rbx, %rdi
callq 0x2170
movq %rbp, %rax
addq $0x31568, %rsp          # imm = 0x31568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18998
movq %r15, %rdi
callq 0x4c91
leaq 0x13f31(%rip), %rdi     # 0x2c8d0
movq %r13, %rsi
xorl %eax, %eax
callq 0x2270
movq %r15, %rdi
callq 0x4c6e
movq %r15, %rdi
callq 0x4c4b
movq %rax, %r14
movq %r13, %rbx
jmp 0x189c4
movq %rax, %r14
movl $0x8, %esi
movq %rbx, %rdi
callq 0x2190
movq %r14, %rdi
callq 0x22e0