// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, 0xc(%rsp)
movq %rdi, %rbx
cmpq $0x0, 0x18(%rdi)
je 0x25234
movl %edx, %r12d
movq %rsi, 0x10(%rsp)
movzwl 0x4(%rbx), %r13d
movzwl 0xc(%rbx), %eax
subl %eax, %r13d
xorl %r15d, %r15d
testl %r13d, %r13d
cmovlel %r15d, %r13d
imulq $0x30, %r13, %rbp
addq $0x20, %rbp
movw $0xffff, %r14w          # imm = 0xFFFF
movzwl 0xe(%rbx), %eax
cmpq %rax, %r13
ja 0x25223
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2534e
testb %al, %al
je 0x251da
movzwl 0x20(%rbx), %eax
cmpq %rax, %r13
adcl $0x0, %r15d
jmp 0x2521a
xorl %r15d, %r15d
movl $0x0, %eax
cmpb $0x0, 0xc(%rsp)
je 0x251f8
movq 0x18(%rbx), %rax
movq (%rax,%rbp), %rax
shrq $0x29, %rax
andl $0x7f, %eax
movzwl 0xc(%rbx), %ecx
addl %r13d, %ecx
xorl %edx, %edx
cmpl %r12d, %ecx
setl %dl
shll $0xe, %edx
movzwl %ax, %eax
orl %edx, %eax
cmpw %r14w, %ax
cmovael %r14d, %eax
movl %eax, %r14d
incq %r13
addq $0x30, %rbp
jmp 0x251b5
leal -0x1(%r14), %eax
cmpw $-0x3, %ax
ja 0x2523d
addw %r14w, 0x10(%rbx)
jmp 0x25244
movb $0x1, 0x83(%rbx)
jmp 0x252bc
cmpw $-0x1, %r14w
je 0x25290
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x252bc
movzwl 0x20(%rbx), %ecx
movzwl 0xe(%rbx), %edx
notl %edx
addl %ecx, %r15d
addl %edx, %r15d
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %r15, %rcx
negq %rcx
imulq $0x30, %rcx, %rsi
addq %rax, %rsi
movq 0x10(%rsp), %rdi
movl %r15d, %edx
callq 0x25370
testb %al, %al
je 0x252bc
subw %r15w, 0x20(%rbx)
jne 0x252bc
andq $0x0, 0x18(%rbx)
jmp 0x252bc
movb $0x1, 0x83(%rbx)
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x252bc
movzwl 0x20(%rbx), %edx
movq 0x10(%rsp), %rdi
callq 0x25370
testb %al, %al
je 0x25244
andq $0x0, 0x18(%rbx)
andw $0x0, 0x20(%rbx)
movb $0x1, 0x82(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq