// File: gersteinlab[P]MUSIC/src/ms_genome_sequence_tools.cpp
// Function: load_BED_with_ancestral_derived_seqs(char*)
vector<t_annot_region*>* load_BED_with_ancestral_derived_seqs(char* bed_w_seq_fp)
{
	vector<t_annot_region*>* regs_w_seqs = new vector<t_annot_region*>();

	FILE* f_bed_w_seq = open_f(bed_w_seq_fp, "r");

	while(1)
	{
		char* cur_line = getline(f_bed_w_seq);
		if(cur_line == NULL)
		{
			break;
		}

		char chrom[100];
		int start;
		int end;
		char strand;
		char* name = new char[t_string::string_length(cur_line) + 2];
		char** cur_anc_der_seqs = new char*[2];
		char* cur_ancestral_seq = new char[t_string::string_length(cur_line) + 2];
		char* cur_derived_seq = new char[t_string::string_length(cur_line) + 2];
		cur_anc_der_seqs[0] = cur_ancestral_seq;
		cur_anc_der_seqs[1] = cur_derived_seq;

		if(sscanf(cur_line, "%s %d %d %s %*s %c %s %s", chrom, &start, &end, name, &strand, 
			cur_ancestral_seq, cur_derived_seq) != 7)
		{
			fprintf(stderr, "Could not parse the sequence bed file line:\n%s\n", cur_line);
			exit(0);
		}

		t_annot_region* cur_region = get_empty_region();
		cur_region->chrom = t_string::copy_me_str(chrom);
		cur_region->start = start;
		cur_region->end = end;
		cur_region->name = t_string::copy_me_str(name);
		cur_region->strand = strand;

		// The sequence is stored in the data entry.
		cur_region->data = (void*)cur_anc_der_seqs;

		regs_w_seqs->push_back(cur_region);

		delete [] name;
	} // file reading loop.

	fclose(f_bed_w_seq);

	return(regs_w_seqs);
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x20(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x20(%rsp), %rdi
callq 0xc670
movq 0x20(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0xe0(%rsp), %rdi
leaq 0x184ab(%rip), %rsi     # 0x550ce
callq 0x455f0
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x45400
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0xc8(%rsp)
jne 0x3cc55
jmp 0x3cde1
movq 0xc8(%rsp), %rdi
callq 0x47640
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, 0x48(%rsp)
movl $0x10, %edi
callq 0x2040
movq %rax, 0x40(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x47640
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, 0x38(%rsp)
movq 0xc8(%rsp), %rdi
callq 0x47640
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, (%rax)
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xc8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq 0x48(%rsp), %r9
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %rax
leaq 0x199ab(%rip), %rsi     # 0x566a4
leaq 0x5c(%rsp), %rcx
leaq 0x58(%rsp), %r8
leaq 0x57(%rsp), %r11
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x2170
cmpl $0x7, %eax
je 0x3cd49
movq 0x282b7(%rip), %rax     # 0x64fe0
movq (%rax), %rdi
movq 0xc8(%rsp), %rdx
leaq 0x19982(%rip), %rsi     # 0x566bd
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x21f0
callq 0x27b00
movq %rax, 0x28(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x47b60
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movl 0x5c(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0x58(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, 0x20(%rax)
movq 0x48(%rsp), %rdi
callq 0x47b60
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movb 0x57(%rsp), %cl
movq 0x28(%rsp), %rax
movb %cl, 0x8(%rax)
movq 0x40(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0xd8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xc8c0
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x3cddc
movq 0x18(%rsp), %rdi
callq 0x2220
jmp 0x3cc30
movq 0xd0(%rsp), %rdi
callq 0x2180
movq 0xd8(%rsp), %rax
addq $0xe8, %rsp
retq
nop