// File: /workspace/github_cpp_makefile_star2_O2/gersteinlab[P]MUSIC/src/ms_mapped_read_tools.cpp
// Function: sort_bucket_read_lines(char*)
vector<char*>* sort_bucket_read_lines(char* bucket_fp)
{
	// Load the reads.
	vector<char*>* bucket_read_lines = buffer_file(bucket_fp);	
	vector<int>* read_starts = new vector<int>();
	vector<t_read_line_sorting_info*>* sorting_info_list = new vector<t_read_line_sorting_info*>();
	for(int i_read = 0; i_read < (int)bucket_read_lines->size(); i_read++)
	{
		int cur_read_start = 0;
		sscanf(bucket_read_lines->at(i_read), "%*s %*s %d", &cur_read_start);

		t_read_line_sorting_info* cur_line_info = new t_read_line_sorting_info();
		cur_line_info->start = cur_read_start;
		cur_line_info->read_line = bucket_read_lines->at(i_read);

		sorting_info_list->push_back(cur_line_info);
	} // i_read loop.

	sort(sorting_info_list->begin(), sorting_info_list->end(), sort_read_line_info);
	vector<char*>* sorted_bucket_read_lines = new vector<char*>();

	for(int i_read = 0; i_read < (int)sorting_info_list->size(); i_read++)
	{
		sorted_bucket_read_lines->push_back(sorting_info_list->at(i_read)->read_line);

		delete sorting_info_list->at(i_read);
	} // i_read loop.

	delete(sorting_info_list);
	delete(read_starts);

	delete(bucket_read_lines);

	return(sorted_bucket_read_lines);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0x20089
movq %rax, %rbx
pushq $0x18
popq %r14
movq %r14, %rdi
callq 0x2170
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x10(%rsp)
andq $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x2170
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x4(%rsp), %r13
pushq $0x10
popq %rbp
leaq 0x8(%rsp), %r14
xorl %r12d, %r12d
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r12
jge 0xd96f
andl $0x0, 0x4(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7342
movq (%rax), %rdi
leaq 0x174b0(%rip), %rsi     # 0x24dd5
movq %r13, %rdx
xorl %eax, %eax
callq 0x2150
movq %rbp, %rdi
callq 0x2170
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq %rax, 0x8(%rsp)
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7342
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq %r15, %rdi
movq %r14, %rsi
callq 0xec9a
incq %r12
jmp 0xd8f9
movq (%r15), %rdi
movq 0x8(%r15), %rsi
leaq 0xba(%rip), %rdx        # 0xda37
callq 0xee73
pushq $0x18
popq %rdi
callq 0x2170
movq %rax, %r12
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %r14d, %r14d
pushq $0x10
popq %r13
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x3, %rax
cltq
movq %r15, %rdi
cmpq %rax, %r14
jge 0xd9e6
movq %r14, %rsi
callq 0xecd6
movq (%rax), %rsi
addq $0x8, %rsi
movq %r12, %rdi
callq 0xecb8
movq %r15, %rdi
movq %r14, %rsi
callq 0xecd6
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2180
incq %r14
jmp 0xd99f
callq 0xf502
pushq $0x18
popq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2180
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x7cec
movq %r15, %rdi
movq %r14, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x7cb8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2180
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq