// File: 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:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x452c0
movq %rax, 0x98(%rsp)
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x48(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x48(%rsp), %rdi
callq 0xc290
movq 0x48(%rsp), %rax
movq %rax, 0x90(%rsp)
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x50(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x50(%rsp), %rdi
callq 0x1fa90
movq 0x50(%rsp), %rax
movq %rax, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x98(%rsp), %rdi
callq 0xc220
movq %rax, %rcx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0x1d8a8
movl $0x0, 0x80(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x84(%rsp), %rsi
callq 0xc240
movq (%rax), %rdi
leaq 0x355b7(%rip), %rsi     # 0x52dd1
leaq 0x80(%rsp), %rdx
movb $0x0, %al
callq 0x2170
movl $0x10, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x38(%rsp)
xorl %esi, %esi
movl $0x10, %edx
callq 0x2110
movq 0x38(%rsp), %rax
movq %rax, 0x78(%rsp)
movl 0x80(%rsp), %ecx
movq 0x78(%rsp), %rax
movl %ecx, (%rax)
movq 0x98(%rsp), %rdi
movslq 0x84(%rsp), %rsi
callq 0xc240
movq (%rax), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1faa0
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x1d7c9
movq 0x88(%rsp), %rdi
callq 0x1fb60
movq %rax, 0x70(%rsp)
movq 0x88(%rsp), %rdi
callq 0x1fb90
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0x163(%rip), %rdx       # 0x1da40
callq 0x1fb10
movl $0x18, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x30(%rsp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x30(%rsp), %rdi
callq 0xc630
movq 0x30(%rsp), %rax
movq %rax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x88(%rsp), %rdi
callq 0x1fbc0
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1d9aa
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x88(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0x1fc50
movq 0x18(%rsp), %rdi
movq (%rax), %rsi
addq $0x8, %rsi
callq 0x1fbe0
movq 0x88(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0x1fc50
movq (%rax), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x1d998
movq 0x20(%rsp), %rdi
movl $0x10, %esi
callq 0x21a0
jmp 0x1d99a
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x1d91c
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x1d9d6
movq 0x10(%rsp), %rdi
callq 0x1fc90
movq 0x10(%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
movq 0x90(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x1da02
movq 0x8(%rsp), %rdi
callq 0xc5d0
movq 0x8(%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
movq 0x98(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x1da2b
movq (%rsp), %rdi
callq 0xc570
movq (%rsp), %rdi
movl $0x18, %esi
callq 0x21a0
movq 0x60(%rsp), %rax
addq $0xa8, %rsp
retq
nopl (%rax,%rax)