// File: /workspace/github_cpp_makefile_star2_O1/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 0x2dd5c
movzwl 0x4(%rbx), %eax
movzwl 0xc(%rbx), %r10d
subl %r10d, %eax
movzwl 0xe(%rbx), %r8d
cmpl %r8d, %eax
jle 0x2dd68
movw $0xffff, %dx            # imm = 0xFFFF
xorl %r15d, %r15d
jmp 0x2ddf2
movb $0x1, 0x83(%rbx)
jmp 0x2de7e
xorl %r15d, %r15d
testl %eax, %eax
cmovlel %r15d, %eax
cmpl %r8d, %eax
movl %eax, %edi
cmovbel %r8d, %edi
movzwl 0x20(%rbx), %r8d
movslq %edx, %r9
incl %edi
subq %r10, %r9
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
leaq (%rdx,%rsi), %r10
addq $0x28, %r10
movw $0xffff, %dx            # imm = 0xFFFF
cmpq %r8, %rax
jae 0x2dda6
cmpb $0x0, (%r10)
je 0x2ddaf
cmpq %r8, %rax
adcl $0x0, %r15d
jmp 0x2dde6
xorl %r15d, %r15d
movl $0x0, %r11d
testb %cl, %cl
je 0x2ddc8
movq -0x8(%r10), %r11
shrq $0x29, %r11
andl $0x7f, %r11d
xorl %ebp, %ebp
cmpq %r9, %rax
setl %bpl
shll $0xe, %ebp
movzwl %r11w, %r11d
orl %ebp, %r11d
cmpw %dx, %r11w
cmovael %edx, %r11d
movl %r11d, %edx
incq %rax
addq $0x30, %r10
cmpq %rax, %rdi
jne 0x2dd9b
leal -0x1(%rdx), %eax
cmpw $-0x3, %ax
ja 0x2de01
addw %dx, 0x10(%rbx)
jmp 0x2de2c
cmpw $-0x1, %dx
jne 0x2de2c
movb $0x1, 0x83(%rbx)
movzwl 0x20(%rbx), %edx
movq %r14, %rdi
callq 0x2dee2
testb %al, %al
je 0x2de2c
movq $0x0, 0x18(%rbx)
movw $0x0, 0x20(%rbx)
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x2de7e
movzwl 0x20(%rbx), %ecx
movzwl 0xe(%rbx), %edx
notl %edx
addl %ecx, %r15d
addl %edx, %r15d
leaq (%rcx,%rcx,2), %rcx
shll $0x4, %ecx
addq %rcx, %rax
movq %r15, %rcx
negq %rcx
leaq (%rcx,%rcx,2), %rsi
shlq $0x4, %rsi
addq %rax, %rsi
movq %r14, %rdi
movl %r15d, %edx
callq 0x2dee2
testb %al, %al
je 0x2de7e
subw %r15w, 0x20(%rbx)
jne 0x2de7e
movq $0x0, 0x18(%rbx)
movb $0x1, 0x82(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq