// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./ebwt_search_backtrack.h
// Function: EbwtRangeSourceDriver::initRangeSource(SStringExpandable<char, 25, 2, 0> const&)
virtual void initRangeSource(const BTString& qual) {
		// If seedLen_ is huge, then it will always cover the whole
		// alignment
		assert_eq(len_, qual.length());
		uint32_t s = (seedLen_ > 0 ? min(seedLen_, len_) : len_);
		uint32_t sLeft  = s >> 1;
		uint32_t sRight = s >> 1;
		// If seed has odd length, then nudge appropriate half up by 1
		if((s & 1) != 0) { if(nudgeLeft_) sLeft++; else sRight++; }
		uint32_t rev0Off = cextToDepth(rev0Off_, sRight, s, len_);
		uint32_t rev1Off = cextToDepth(rev1Off_, sRight, s, len_);
		uint32_t rev2Off = cextToDepth(rev2Off_, sRight, s, len_);
		uint32_t rev3Off = cextToDepth(rev3Off_, sRight, s, len_);
		// Truncate the pattern if necessary
		uint32_t qlen = (uint32_t)qual.length();
		if(seed_) {
			if(len_ > s) {
				rs_->setQlen(s);
				qlen = s;
			}
			assert(!rs_->reportExacts());
		}
		// If there are any Ns in the unrevisitable region, then this
		// driver is guaranteed to yield no fruit.
		uint16_t minCost = 0;
		if(rs_->reportExacts()) {
			// Keep minCost at 0
		} else if (!rs_->halfAndHalf() && rev0Off < s) {
			// Exacts not allowed, so there must be at least 1 mismatch
			// outside of the unrevisitable area
			minCost = 1 << 14;
			if(qualOrder_) {
				uint8_t lowQual = 0xff;
				for(uint32_t d = rev0Off; d < s; d++) {
					uint8_t lowAtPos;
					lowAtPos = qual[qlen - d - 1];
					if(lowAtPos < lowQual) lowQual = lowAtPos;
				}
				assert_lt(lowQual, 0xff);
				minCost += mmPenalty(maqPenalty_, phredCharToPhredQual(lowQual));
			}
		} else if(rs_->halfAndHalf() && sRight > 0 && sRight < (s-1)) {
			// Half-and-half constraints are active, so there must be
			// at least 1 mismatch in both halves of the seed
			assert(rs_->halfAndHalf());
			minCost = (seed_ ? 3 : 2) << 14;
			if(qualOrder_) {
				assert(rs_->halfAndHalf() == 2 || rs_->halfAndHalf() == 3);
				uint8_t lowQual1 = 0xff;
				for(uint32_t d = 0; d < sRight; d++) {
					uint8_t lowAtPos;
					lowAtPos = qual[qlen - d - 1];
					if(lowAtPos < lowQual1) lowQual1 = lowAtPos;
				}
				assert_lt(lowQual1, 0xff);
				minCost += mmPenalty(maqPenalty_, phredCharToPhredQual(lowQual1));
				uint8_t lowQual2_1 = 0xff;
				uint8_t lowQual2_2 = 0xff;
				for(uint32_t d = sRight; d < s; d++) {
					uint8_t lowAtPos;
					lowAtPos = qual[qlen - d - 1];
					if(lowAtPos < lowQual2_1) {
						if(lowQual2_1 != 0xff) {
							lowQual2_2 = lowQual2_1;
						}
						lowQual2_1 = lowAtPos;
					} else if(lowAtPos < lowQual2_2) {
						lowQual2_2 = lowAtPos;
					}
				}
				assert_lt(lowQual2_1, 0xff);
				minCost += mmPenalty(maqPenalty_, phredCharToPhredQual(lowQual2_1));
				if(rs_->halfAndHalf() > 2 && lowQual2_2 != 0xff) {
					minCost += mmPenalty(maqPenalty_, phredCharToPhredQual(lowQual2_2));
				}
			}
		}
		if(verbose_) cout << "initRangeSource minCost: " << minCost << endl;
		this->minCostAdjustment_ = minCost;
		rs_->setOffs(sRight,   // depth of far edge of hi-half (only matters where half-and-half is possible)
		             s,        // depth of far edge of lo-half (only matters where half-and-half is possible)
		             rev0Off,  // depth above which we cannot backtrack
		             rev1Off,  // depth above which we may backtrack just once
		             rev2Off,  // depth above which we may backtrack just twice
		             rev3Off); // depth above which we may backtrack just three times
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movl 0x10(%rdi), %r8d
movl 0x1c0(%rdi), %r14d
leal -0x1(%r14), %eax
cmpl %r8d, %eax
cmovael %r8d, %r14d
movl %r14d, %eax
shrl %eax
movl %r14d, %ecx
andl $0x1, %ecx
negl %ecx
movzbl 0x1c4(%rdi), %ebp
xorl $0x1, %ebp
andl %ecx, %ebp
addl %eax, %ebp
movl 0x1c8(%rdi), %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x270b0
movl %eax, %r15d
movl 0x10(%rbx), %r8d
movl 0x1cc(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x270b0
movl %eax, %r12d
movl 0x10(%rbx), %r8d
movl 0x1d0(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x270b0
movl %eax, 0x18(%rsp)
movl 0x10(%rbx), %r8d
movl 0x1d4(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x270b0
movl 0x20(%r13), %edx
cmpb $0x1, 0x1b0(%rbx)
jne 0x26bad
cmpl %r14d, 0x10(%rbx)
jbe 0x26bad
movq 0x1b8(%rbx), %rdx
movq 0x18(%rdx), %rcx
movl 0x20(%rcx), %ecx
cmpl %r14d, %ecx
cmovael %r14d, %ecx
movq %rcx, 0x50(%rdx)
movl %r14d, %edx
movq 0x1b8(%rbx), %r10
cmpb $0x0, 0x8c(%r10)
movl %r15d, 0x10(%rsp)
movl %r12d, 0x1c(%rsp)
je 0x26c4d
xorl %r12d, %r12d
cmpb $0x1, 0x1d8(%rbx)
jne 0x26c0c
movq 0x3b3d1(%rip), %rdi     # 0x61fb0
leaq 0x23e8d(%rip), %rsi     # 0x4aa73
movl %eax, %r15d
callq 0x94e0
movzwl %r12w, %esi
movq %rax, %rdi
callq 0x98b0
movq %rax, %rdi
callq 0x9210
movl %r15d, %eax
movq 0x1b8(%rbx), %r10
movw %r12w, 0xc(%rbx)
movl %ebp, 0x98(%r10)
movl %r14d, 0x9c(%r10)
movl 0x10(%rsp), %ecx
movl %ecx, 0x74(%r10)
movl 0x1c(%rsp), %ecx
movl %ecx, 0x78(%r10)
movl 0x18(%rsp), %ecx
movl %ecx, 0x7c(%r10)
movl %eax, 0x80(%r10)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x90(%r10), %ecx
testl %ecx, %ecx
setne %sil
cmpl %r14d, %r15d
setae %dil
orb %sil, %dil
jne 0x26cb2
movw $0x4000, %r12w          # imm = 0x4000
cmpb $0x1, 0x1b2(%rbx)
jne 0x26bcf
movq 0x8(%r13), %rcx
movl 0x10(%rsp), %r8d
movl %r8d, %esi
movl %r14d, %edi
notl %r8d
addl %edx, %r8d
movb $-0x1, %dl
cmpq %rdi, %rsi
jae 0x26d27
movl %r8d, %r9d
movzbl (%rcx,%r9), %r9d
cmpb %dl, %r9b
movzbl %dl, %edx
cmovbl %r9d, %edx
incq %rsi
decl %r8d
jmp 0x26c8f
leal -0x1(%r14), %esi
xorl %r12d, %r12d
cmpl %esi, %ebp
jae 0x26bcf
testl %ebp, %ebp
je 0x26bcf
testl %ecx, %ecx
je 0x26bcf
movl 0x1b0(%rbx), %r12d
orl $0x2, %r12d
shll $0xe, %r12d
cmpb $0x1, 0x1b2(%rbx)
jne 0x26bcf
movl %ecx, 0xc(%rsp)
movq %r10, 0x20(%rsp)
movl %eax, 0x8(%rsp)
movq 0x8(%r13), %rdi
movl %ebp, %r8d
leal -0x1(%rdx), %esi
movb $-0x1, %r9b
movq %r8, %r10
subq $0x1, %r10
jb 0x26d5b
movl %esi, %r11d
movzbl (%rdi,%r11), %r11d
movzbl %r9b, %r9d
cmpb %r9b, %r11b
cmovbl %r11d, %r9d
decl %esi
jmp 0x26d0a
leal -0x21(%rdx), %ecx
xorl %esi, %esi
cmpb $0x21, %dl
movzbl %cl, %ecx
cmovbl %esi, %ecx
cmpb $0x1, 0x1b1(%rbx)
jne 0x26d4b
movzbl %cl, %ecx
leaq 0x3ddc8(%rip), %rdx     # 0x64b10
movb (%rdx,%rcx), %cl
movzbl %cl, %r12d
orl $0x4000, %r12d          # imm = 0x4000
jmp 0x26bcf
movb 0x1b1(%rbx), %cl
leal -0x21(%r9), %r10d
xorl %r11d, %r11d
cmpb $0x21, %r9b
movzbl %r10b, %r9d
cmovbl %r11d, %r9d
movl %ecx, %eax
cmpb $0x1, %cl
jne 0x26d8a
movzbl %r9b, %r9d
leaq 0x3dd8a(%rip), %r10     # 0x64b10
movb (%r10,%r9), %r9b
movzbl %r9b, %ecx
movl %ecx, 0x14(%rsp)
movl %r14d, %r10d
movl %ebp, %r11d
notl %r11d
addl %edx, %r11d
movb $-0x1, %r13b
movb $-0x1, %dl
cmpq %r10, %r8
jae 0x26de2
movl %r11d, %esi
movzbl (%rdi,%rsi), %esi
cmpb $-0x1, %r13b
movzbl %dl, %r9d
movzbl %r13b, %r15d
movl %r15d, %ecx
cmovel %r9d, %ecx
cmpb %dl, %sil
cmovbl %esi, %r9d
cmpb %r13b, %sil
cmovbl %esi, %r15d
cmovbl %ecx, %r9d
incq %r8
decl %r11d
movl %r15d, %r13d
movl %r9d, %edx
jmp 0x26da3
movzwl 0x14(%rsp), %edi
orl %r12d, %edi
movl %edi, %r12d
leal -0x21(%r13), %edi
xorl %r8d, %r8d
cmpb $0x21, %r13b
movzbl %dil, %edi
cmovbl %r8d, %edi
movl %eax, %r9d
testb %al, %al
je 0x26e16
movzbl %dil, %edi
leaq 0x3dcfe(%rip), %r8      # 0x64b10
movb (%r8,%rdi), %dil
movl 0x8(%rsp), %eax
movq 0x20(%rsp), %r10
movl 0xc(%rsp), %ecx
movzbl %dil, %edi
addl %edi, %r12d
cmpl $0x3, %ecx
jl 0x26bcf
cmpb $-0x1, %dl
je 0x26bcf
leal -0x21(%rdx), %ecx
xorl %esi, %esi
cmpb $0x21, %dl
movzbl %cl, %ecx
cmovbl %esi, %ecx
testb %r9b, %r9b
je 0x26e5c
movzbl %cl, %ecx
leaq 0x3dcb7(%rip), %rdx     # 0x64b10
movb (%rdx,%rcx), %cl
movzbl %cl, %ecx
addl %ecx, %r12d
jmp 0x26bcf
nop