// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/./range_source.h
// Function: Branch::curtail(AllocOnlyPool<RangeState>&, int, bool)
void curtail(AllocOnlyPool<RangeState>& rpool, int seedLen, bool qualOrder) {
		assert(!curtailed_);
		assert(!exhausted_);
		if(ranges_ == NULL) {
			exhausted_ = true;
			curtailed_ = true;
			return;
		}
		uint16_t lowestCost = 0xffff;
		// Iterate over positions in the path looking for the cost of
		// the lowest-cost non-eliminated position
		uint32_t eliminatedStretch = 0;
		int i = (int)depth0_;
		i = max(0, i - rdepth_);
		// TODO: It matters whether an insertion/deletion at given
		// position would be a gap open or a gap extension
		for(; i <= len_; i++) {
			if(!eliminated(i)) {
				eliminatedStretch = 0;
				uint16_t stratum = (rdepth_ + i < seedLen) ? (1 << 14) : 0;
				uint16_t cost = (qualOrder ? /*TODO*/ ranges_[i].eq.flags.quallo : 0) | stratum;
				if(cost < lowestCost) lowestCost = cost;
			} else if(i < rangesSz_) {
				eliminatedStretch++;
			}
		}
		if(lowestCost > 0 && lowestCost != 0xffff) {
			// This branch's cost will change when curtailed; the
			// caller should re-insert it into the priority queue so
			// that the new cost takes effect.
			cost_ += lowestCost;
		} else if(lowestCost == 0xffff) {
			// This branch is totally exhausted; there are no more
			// valid outgoing paths from any positions within it.
			// Remove it from the PathManager and mark it as exhausted.
			// The caller should delete it.
			exhausted_ = true;
			if(ranges_ != NULL) {
				assert_gt(rangesSz_, 0);
				if(rpool.free(ranges_, rangesSz_)) {
					ranges_ = NULL;
					rangesSz_ = 0;
				}
			}
		} else {
			// Just mark it as curtailed and keep the same cost
		}
		if(ranges_ != NULL) {
			// Try to trim off no-longer-relevant elements of the
			// ranges_ array
			assert(!exhausted_);
			assert_gt(rangesSz_, 0);
			uint32_t trim = (rangesSz_ - len_ - 1) + eliminatedStretch;
			assert_leq(trim, rangesSz_);
			if(rpool.free(ranges_ + rangesSz_ - trim, trim)) {
				rangesSz_ -= trim;
				if(rangesSz_ == 0) {
					ranges_ = NULL;
				}
			}
		}
		curtailed_ = true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rsi
testq %rsi, %rsi
je 0x2d9eb
movzwl 0x4(%rbx), %eax
movzwl 0xc(%rbx), %r9d
subl %r9d, %eax
movzwl 0xe(%rbx), %r8d
xorl %r15d, %r15d
cmpl %r8d, %eax
jle 0x2d9f7
movb $0x1, 0x83(%rbx)
movzwl 0x20(%rbx), %edx
movq %r14, %rdi
callq 0x2db5a
testb %al, %al
je 0x2da93
movq $0x0, 0x18(%rbx)
movw $0x0, 0x20(%rbx)
jmp 0x2daf5
movb $0x1, 0x83(%rbx)
jmp 0x2daf5
xorl %r15d, %r15d
testl %eax, %eax
cmovlel %r15d, %eax
cmpl %r8d, %eax
movl %eax, %edi
cmovbel %r8d, %edi
movzwl 0x20(%rbx), %r8d
movslq %edx, %rdx
incl %edi
subq %r9, %rdx
leaq (%rax,%rax,2), %r9
shlq $0x4, %r9
leaq (%r9,%rsi), %r10
addq $0x28, %r10
movw $0xffff, %r9w           # imm = 0xFFFF
cmpq %r8, %rax
jae 0x2da36
cmpb $0x0, (%r10)
je 0x2da3f
cmpq %r8, %rax
adcl $0x0, %r15d
jmp 0x2da76
xorl %r15d, %r15d
movl $0x0, %r11d
testb %cl, %cl
je 0x2da58
movq -0x8(%r10), %r11
shrq $0x29, %r11
andl $0x7f, %r11d
xorl %ebp, %ebp
cmpq %rdx, %rax
setl %bpl
shll $0xe, %ebp
movzwl %r11w, %r11d
orl %ebp, %r11d
cmpw %r9w, %r11w
cmovael %r9d, %r11d
movl %r11d, %r9d
incq %rax
addq $0x30, %r10
cmpq %rax, %rdi
jne 0x2da2b
leal -0x1(%r9), %eax
cmpw $-0x3, %ax
ja 0x2da99
addw %r9w, 0x10(%rbx)
jmp 0x2daa4
movq 0x18(%rbx), %rsi
jmp 0x2daa4
cmpw $-0x1, %r9w
je 0x2d9bd
testq %rsi, %rsi
je 0x2daf5
movzwl 0x20(%rbx), %eax
movzwl 0xe(%rbx), %ecx
notl %ecx
addl %eax, %r15d
addl %ecx, %r15d
leaq (%rax,%rax,2), %rax
shll $0x4, %eax
addq %rax, %rsi
movq %r15, %rax
negq %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rsi, %rax
movq %r14, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x2db5a
testb %al, %al
je 0x2daf5
subw %r15w, 0x20(%rbx)
jne 0x2daf5
movq $0x0, 0x18(%rbx)
movb $0x1, 0x82(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop