// File: 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 %rbx
subq $0x31630, %rsp          # imm = 0x31630
movq %rdi, 0x31628(%rsp)
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x88(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x88(%rsp), %rdi
callq 0xc670
movq 0x88(%rsp), %rax
movq %rax, 0x31620(%rsp)
movq 0x31628(%rsp), %rdi
leaq 0x28f01(%rip), %rsi     # 0x550ce
callq 0x455f0
movq %rax, 0x31618(%rsp)
movq 0x31618(%rsp), %rdi
callq 0x45400
movq %rax, 0x31610(%rsp)
cmpq $0x0, 0x31610(%rsp)
je 0x2c718
movq 0x31610(%rsp), %rdi
callq 0x2b460
andb $0x1, %al
movb %al, 0x3160f(%rsp)
testb $0x1, 0x3160f(%rsp)
jne 0x2c6e1
movq 0x31610(%rsp), %rdi
leaq 0x31220(%rsp), %rdx
leaq 0x30e30(%rsp), %rcx
leaq 0x18780(%rsp), %r10
leaq 0xe0(%rsp), %rax
leaq 0x29cd2(%rip), %rsi     # 0x55f23
leaq 0x30e2f(%rsp), %r8
leaq 0x30e28(%rsp), %r9
leaq 0x30e24(%rsp), %rbx
leaq 0x30e20(%rsp), %r11
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x2170
cmpl $0x8, %eax
jne 0x2c6b8
movl $0x50, %edi
callq 0x2190
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rax, 0xd8(%rsp)
leaq 0x30e30(%rsp), %rdi
callq 0x47b60
movq %rax, %rcx
movq 0xd8(%rsp), %rax
movq %rcx, (%rax)
movq 0xd8(%rsp), %rax
movq (%rax), %rdi
callq 0x22350
movl 0x30e28(%rsp), %edi
xorl %esi, %esi
movl $0x1, %edx
movl %edx, 0x4c(%rsp)
callq 0x1fd20
movl 0x4c(%rsp), %edx
movl %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0x30e24(%rsp), %edi
movl %edx, %esi
callq 0x1fd20
movl %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, 0x20(%rax)
movb 0x30e2f(%rsp), %cl
movq 0xd8(%rsp), %rax
movb %cl, 0x8(%rax)
leaq 0x31220(%rsp), %rdi
callq 0x47b60
movq %rax, %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x18(%rax)
movl $0x18, %edi
movq %rdi, 0x58(%rsp)
callq 0x2190
movaps 0x60(%rsp), %xmm0
movq %rax, %rdi
movq %rdi, 0x50(%rsp)
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0xc670
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdi
movq 0xd8(%rsp), %rax
movq %rcx, 0x30(%rax)
callq 0x2190
movaps 0x60(%rsp), %xmm0
movq %rax, %rdi
movq %rdi, 0x78(%rsp)
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0xc670
movq 0x78(%rsp), %rax
movq %rax, 0xd0(%rsp)
movl $0x8, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x80(%rsp)
leaq 0x18780(%rsp), %rsi
callq 0x472e0
jmp 0x2c3f5
movq 0x80(%rsp), %rax
movq %rax, 0xc8(%rsp)
movl $0x8, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x40(%rsp)
leaq 0xe0(%rsp), %rsi
callq 0x472e0
jmp 0x2c429
movq 0x40(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x47fd0
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x47fd0
movq %rax, 0xa0(%rsp)
movq 0xa8(%rsp), %rdi
callq 0xc2a0
movq %rax, 0x38(%rsp)
movq 0xa0(%rsp), %rdi
callq 0xc2a0
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
je 0x2c506
movq 0x38b4d(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movq 0x31610(%rsp), %rdx
leaq 0x29a96(%rip), %rsi     # 0x55f3b
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x21f0
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
movl $0x8, %esi
callq 0x21a0
jmp 0x2c736
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
movl $0x8, %esi
callq 0x21a0
jmp 0x2c736
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0xa8(%rsp), %rdi
callq 0xc2a0
movq %rax, %rcx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jge 0x2c68d
movl $0x50, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x28(%rsp)
xorl %esi, %esi
movl $0x50, %edx
callq 0x2110
movq 0x28(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x30e30(%rsp), %rdi
callq 0x47b60
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, (%rax)
movq 0x90(%rsp), %rax
movq (%rax), %rdi
callq 0x22350
movq 0xa8(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xc2c0
movl (%rax), %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1fd20
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0xa0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xc2c0
movl (%rax), %edi
movl $0x1, %edx
movl %edx, %esi
callq 0x1fd20
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, 0x20(%rax)
movq 0xa0(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xc2c0
movl (%rax), %eax
movl %eax, 0x30(%rsp)
movq 0xa8(%rsp), %rdi
movslq 0x9c(%rsp), %rsi
callq 0xc2c0
movq %rax, %rcx
movl 0x30(%rsp), %eax
cmpl (%rcx), %eax
jge 0x2c650
movq 0x389b0(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movq 0x31610(%rsp), %rdx
leaq 0x2992e(%rip), %rsi     # 0x55f70
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x21f0
movb 0x30e2f(%rsp), %cl
movq 0x90(%rsp), %rax
movb %cl, 0x8(%rax)
movq 0xd0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xc8c0
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x2c511
movq 0xd0(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x31620(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xc8c0
jmp 0x2c6df
movq 0x38921(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movq 0x31610(%rsp), %rdx
leaq 0x298d1(%rip), %rsi     # 0x55fa2
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x21f0
jmp 0x2c6e1
movq 0x31610(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x2c6fe
movq 0x20(%rsp), %rdi
callq 0x2220
movq 0x31618(%rsp), %rdi
callq 0x45400
movq %rax, 0x31610(%rsp)
jmp 0x2c1ef
movq 0x31618(%rsp), %rdi
callq 0x2180
movq 0x31620(%rsp), %rax
addq $0x31630, %rsp          # imm = 0x31630
popq %rbx
retq
movq 0xc0(%rsp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)