// File: /workspace/github_cpp_makefile_star2_O1/BenLangmead[P]bowtie/./range_source.h
// Function: CostAwareRangeSourceDriver<EbwtRangeSource>::foundFirstRange(Range*)
bool foundFirstRange(Range* r) {
		assert(r != NULL);
		assert(checkRange(r));
		this->foundRange = true;
		lastRange_ = r;
		if(strandFix_) {
			// We found a range but there may be an equally good range
			// on the other strand; let's try to get it.
			const size_t sz = active_.size();
			for(size_t i = 1; i < sz; i++) {
				// Same mate, different orientation?
				if(rss_[i]->mate1() == r->mate1 && rss_[i]->fw() != r->fw) {
					// Yes; see if it has the same cost
					TRangeSrcDrPtr p = active_[i];
					uint16_t minCost = max(this->minCost, p->minCost);
					if(minCost > r->cost) break;
					// Yes, it has the same cost
					assert_eq(minCost, r->cost); // can't be better
					// Advance it until it's done, we've found a range,
					// or its cost increases
					if(this->verbose_) cout << " Looking for opposite range to avoid strand bias:" << endl;
					while(!p->done && !p->foundRange) {
						p->advance(ADV_COST_CHANGES);
						assert_geq(p->minCost, minCost);
						if(p->minCost > minCost) break;
					}
					if(p->foundRange) {
						// Found one!  Now we have to choose which one
						// to give out first; we choose randomly using
						// the size of the ranges as weights.
						delayedRange_ = &p->range();
						assert(checkRange(delayedRange_));
						size_t tot = (delayedRange_->bot - delayedRange_->top) +
						             (lastRange_->bot    - lastRange_->top);
						uint32_t rq = rand_.nextU32() % tot;
						// We picked this range, not the first one
						if(rq < (delayedRange_->bot - delayedRange_->top)) {
							Range *tmp = lastRange_;
							lastRange_ = delayedRange_;
							delayedRange_ = tmp;
						}
						p->foundRange = false;
					}
					// Return true iff we need to force a re-sort
					return true;
				}
			}
			// OK, now we have a choice of two equally good ranges from
			// each strand.
		}
		return false;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movb $0x1, 0x8(%rdi)
movq %rsi, 0x70(%rdi)
cmpb $0x1, 0x51(%rdi)
jne 0x309c6
movq %rdi, %rbx
movq 0x48(%rdi), %r14
cmpq $0x2, %r14
jb 0x309c6
movq %rsi, %r15
movl $0x1, %r12d
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdi
movq (%rdi), %rax
callq *0x38(%rax)
cmpb %al, 0x15(%r15)
jne 0x3099e
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
cmpb %al, 0x14(%r15)
jne 0x309a8
incq %r12
cmpq %r12, %r14
jne 0x30976
jmp 0x309c6
movq 0x38(%rbx), %rax
movq (%rax,%r12,8), %r14
movzwl 0xa(%rbx), %eax
movzwl 0xa(%r14), %ebp
cmpw %bp, %ax
cmoval %eax, %ebp
cmpw 0x8(%r15), %bp
jbe 0x309d3
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x88(%rbx)
jne 0x30a1e
movq 0x3a5cd(%rip), %r15     # 0x6afb0
leaq 0x26075(%rip), %rsi     # 0x56a5f
movl $0x31, %edx
movq %r15, %rdi
callq 0x9560
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r15, %rdi
callq 0x9050
movq %rax, %rdi
callq 0x92f0
cmpb $0x0, 0x9(%r14)
jne 0x30a41
cmpb $0x0, 0x8(%r14)
jne 0x30a41
movq (%r14), %rax
movq %r14, %rdi
movl $0x2, %esi
callq *0x20(%rax)
cmpw %bp, 0xa(%r14)
jbe 0x30a1e
movb $0x1, %bpl
cmpb $0x1, 0x8(%r14)
jne 0x309c8
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %rax, %rcx
movq %rax, 0x78(%rbx)
movl 0x4(%rax), %edi
movq 0x70(%rbx), %rsi
addl 0x4(%rsi), %edi
movl (%rax), %eax
addl (%rsi), %eax
subl %eax, %edi
movl 0x58(%rbx), %edx
movl 0x5c(%rbx), %r8d
movl 0x60(%rbx), %eax
imull %edx, %eax
addl %r8d, %eax
movl %eax, %r9d
shrl $0x10, %r9d
imull %edx, %eax
addl %r8d, %eax
movl %eax, 0x60(%rbx)
xorl %r9d, %eax
movl $0x0, 0x64(%rbx)
xorl %edx, %edx
divl %edi
movl 0x4(%rcx), %eax
subl (%rcx), %eax
cmpl %eax, %edx
jae 0x30aae
movq %rcx, 0x70(%rbx)
movq %rsi, 0x78(%rbx)
movb $0x0, 0x8(%r14)
jmp 0x309c8