// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x18
popq %rdi
callq 0x2170
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x18(%rsp)
andq $0x0, 0x10(%rax)
leaq 0xa087(%rip), %rsi      # 0x26d08
movq %r14, %rdi
callq 0x2027c
movq %rax, %r14
leaq 0x20(%rsp), %r13
movq %r14, %rdi
callq 0x2017f
testq %rax, %rax
je 0x1cd9c
movq %rax, %r15
movq %rax, %rdi
callq 0x20d90
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %rbp
pushq $0x10
popq %rdi
callq 0x2040
movq %rax, %r12
movq %r15, %rdi
callq 0x20d90
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %rbx
movq %r15, %rdi
callq 0x20d90
addl $0x2, %eax
movslq %eax, %rdi
callq 0x2040
movq %rax, %r10
movq %rbx, (%r12)
movq %rax, 0x8(%r12)
subq $0x8, %rsp
movq %r15, %rdi
leaq 0xb59a(%rip), %rsi      # 0x282a3
movq %r13, %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %rbp, %r9
xorl %eax, %eax
pushq %r10
pushq %rbx
leaq 0x1f(%rsp), %r10
pushq %r10
callq 0x2150
addq $0x20, %rsp
cmpl $0x7, %eax
jne 0x1cdbb
callq 0x11e71
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x21062
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 %rbp, %rdi
callq 0x21062
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
movb 0x7(%rsp), %al
movb %al, 0x8(%rcx)
movq %r12, 0x48(%rcx)
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7448
movq %rbp, %rdi
callq 0x2210
jmp 0x1cc91
movq %r14, %rdi
callq 0x2160
movq 0x18(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1821e(%rip), %rax     # 0x34fe0
movq (%rax), %rdi
leaq 0xb4f0(%rip), %rsi      # 0x282bc
movq %r15, %rdx
xorl %eax, %eax
callq 0x2240
xorl %edi, %edi
callq 0x21d0