// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
movl $0x18, %edi
callq 0x2180
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0xafd0(%rip), %rsi      # 0x2cd08
movq %r14, %rdi
callq 0x25d5a
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0x25c1e
testq %rax, %rax
je 0x21e7a
movq %rax, %r13
leaq 0x20(%rsp), %r14
movq %r13, %rdi
callq 0x26856
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %r15
movl $0x10, %edi
callq 0x2040
movq %rax, %rbp
movq %r13, %rdi
callq 0x26856
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %r12
movq %r13, %rdi
callq 0x26856
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %r10
movq %r12, (%rbp)
movq %rax, 0x8(%rbp)
subq $0x8, %rsp
movq %r13, %rdi
leaq 0xc4e0(%rip), %rsi      # 0x2e2a3
movq %r14, %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %r15, %r9
xorl %eax, %eax
pushq %r10
pushq %r12
leaq 0x1f(%rsp), %r10
pushq %r10
callq 0x2160
addq $0x20, %rsp
cmpl $0x7, %eax
jne 0x21e99
callq 0x15644
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0x26db4
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movl 0x14(%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, 0xc(%rcx)
movl 0x10(%rsp), %eax
movl %eax, 0x20(%rcx)
movq %r15, %rdi
callq 0x26db4
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
movb 0x7(%rsp), %al
movb %al, 0x8(%rcx)
movq %rbp, 0x48(%rcx)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x21e4f
movq %rcx, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0x21e5c
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0xb74c
movq %r15, %rdi
callq 0x2220
movq 0x18(%rsp), %rdi
callq 0x25c1e
movq %rax, %r13
testq %rax, %rax
jne 0x21d5e
movq 0x18(%rsp), %rdi
callq 0x2170
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x51d3