// File: BenLangmead[P]bowtie/./range_source.h
// Function: CostAwareRangeSourceDriver<EbwtRangeSource>::sortActives()
void sortActives() {
		TRangeSrcDrPtrVec& vec = active_;
		size_t sz = vec.size();
		// Selection sort / removal outer loop
		for(size_t i = 0; i < sz;) {
			// Remove elements that we're done with
			if(vec[i]->done && !vec[i]->foundRange) {
				vec.erase(i);
				if(sz == 0) break;
				else sz--;
				continue;
			}
			uint16_t minCost = vec[i]->minCost;
			size_t minOff = i;
			// Selection sort inner loop
			for(size_t j = i+1; j < sz; j++) {
				if(vec[j]->done && !vec[j]->foundRange) {
					// We'll get rid of this guy later
					continue;
				}
				if(vec[j]->minCost < minCost) {
					minCost = vec[j]->minCost;
					minOff = j;
				} else if(vec[j]->minCost == minCost) {
					// Possibly randomly pick the other
					if(rand_.nextU32() & 0x1000) {
						minOff = j;
					}
				}
			}
			// Do the swap, if necessary
			if(i != minOff) {
				assert_leq(minCost, vec[i]->minCost);
				TRangeSrcDrPtr tmp = vec[i];
				vec[i] = vec[minOff];
				vec[minOff] = tmp;
			}
			i++;
		}
		if(delayedRange_ == NULL && sz > 0) {
			assert_geq(this->minCost, this->minCostAdjustment_);
			assert_geq(vec[0]->minCost, this->minCost);
			this->minCost = vec[0]->minCost;
		}
		assert(sortedActives());
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
addq $0x30, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4a490
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4ac3d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
testb $0x1, 0x9(%rax)
je 0x4aad2
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
testb $0x1, 0x8(%rax)
jne 0x4aad2
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4ad40
cmpq $0x0, -0x18(%rbp)
jne 0x4aac4
jmp 0x4ac3d
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x4aa71
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movw 0xa(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x4abca
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
testb $0x1, 0x9(%rax)
je 0x4ab3a
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
testb $0x1, 0x8(%rax)
jne 0x4ab3a
jmp 0x4abb9
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movzwl 0xa(%rax), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4ab78
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movw 0xa(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x4abb7
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movzwl 0xa(%rax), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jne 0x4abb5
movq -0x48(%rbp), %rdi
addq $0x58, %rdi
callq 0x47b20
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x4abb3
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x4abb5
jmp 0x4abb7
jmp 0x4abb9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x4aafe
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x4ac2c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4a4b0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a4b0
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x4a4b0
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x4aa71
movq -0x48(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0x4ac6e
cmpq $0x0, -0x18(%rbp)
jbe 0x4ac6e
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4a4b0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq (%rcx), %rcx
movw 0xa(%rcx), %cx
movw %cx, 0xa(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop