// File: /workspace/github_cpp_makefile_star2_O1/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 $0x18, %rsp
movq %rdi, %rbx
movl 0x10(%rdi), %eax
movl 0x1c0(%rdi), %ecx
cmpl %ecx, %eax
movl $0x10, %edi
movl $0x1c0, %edx            # imm = 0x1C0
cmovbq %rdi, %rdx
testl %ecx, %ecx
cmoveq %rdi, %rdx
movl 0x1c8(%rbx), %r14d
leal -0x1(%r14), %ecx
cmpl $0x3, %ecx
ja 0x2fd68
movl (%rbx,%rdx), %r15d
movl %r15d, %edx
shrl %edx
movl %r15d, %edi
andl $0x1, %edi
negl %edi
movzbl 0x1c4(%rbx), %ebp
xorl $0x1, %ebp
andl %edi, %ebp
addl %edx, %ebp
leaq 0x239f2(%rip), %rdx     # 0x533ac
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %r15d, %r13d
jmpq *%rcx
xorl %r13d, %r13d
jmp 0x2f9d3
movl %eax, %r13d
jmp 0x2f9d3
movl %ebp, %r13d
movl 0x1cc(%rbx), %r14d
leal -0x1(%r14), %ecx
cmpl $0x3, %ecx
ja 0x2fd68
leaq 0x239ce(%rip), %rdx     # 0x533bc
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %r15d, %r8d
jmpq *%rcx
xorl %r8d, %r8d
jmp 0x2fa07
movl %eax, %r8d
jmp 0x2fa07
movl %ebp, %r8d
movl 0x1d0(%rbx), %r14d
leal -0x1(%r14), %ecx
cmpl $0x3, %ecx
ja 0x2fd68
leaq 0x239aa(%rip), %rdx     # 0x533cc
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %r15d, 0x14(%rsp)
jmpq *%rcx
movl $0x0, 0x14(%rsp)
jmp 0x2fa44
movl %eax, 0x14(%rsp)
jmp 0x2fa44
movl %ebp, 0x14(%rsp)
movl 0x1d4(%rbx), %r14d
leal -0x1(%r14), %ecx
cmpl $0x3, %ecx
ja 0x2fd68
leaq 0x2397d(%rip), %rdx     # 0x533dc
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %r15d, %r9d
jmpq *%rcx
xorl %r9d, %r9d
jmp 0x2fa78
movl %eax, %r9d
jmp 0x2fa78
movl %ebp, %r9d
movl 0x20(%rsi), %ecx
cmpb $0x1, 0x1b0(%rbx)
jne 0x2faa5
cmpl %r15d, %eax
jbe 0x2faa5
movq 0x1b8(%rbx), %rax
movq 0x18(%rax), %rcx
movl 0x20(%rcx), %ecx
cmpl %r15d, %ecx
cmovael %r15d, %ecx
movq %rcx, 0x50(%rax)
movl %r15d, %ecx
movq 0x1b8(%rbx), %rax
cmpb $0x0, 0x8c(%rax)
je 0x2fb6e
xorl %r12d, %r12d
cmpb $0x1, 0x1d8(%rbx)
jne 0x2fb30
movq 0x3b4e4(%rip), %r14     # 0x6afb0
leaq 0x26f55(%rip), %rsi     # 0x56a28
movl $0x19, %edx
movq %r14, %rdi
movl %r13d, 0x10(%rsp)
movl %r8d, 0xc(%rsp)
movl %r9d, %r13d
callq 0x9560
movzwl %r12w, %esi
movq %r14, %rdi
callq 0x92e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r14, %rdi
callq 0x9050
movq %rax, %rdi
callq 0x92f0
movl %r13d, %r9d
movl 0xc(%rsp), %r8d
movl 0x10(%rsp), %r13d
movw %r12w, 0xc(%rbx)
movq 0x1b8(%rbx), %rax
movl %ebp, 0x98(%rax)
movl %r15d, 0x9c(%rax)
movl %r13d, 0x74(%rax)
movl %r8d, 0x78(%rax)
movl 0x14(%rsp), %ecx
movl %ecx, 0x7c(%rax)
movl %r9d, 0x80(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x90(%rax), %eax
testl %eax, %eax
setne %dl
cmpl %r15d, %r13d
setae %dil
orb %dl, %dil
jne 0x2fbfd
movw $0x4000, %r12w          # imm = 0x4000
cmpb $0x1, 0x1b2(%rbx)
jne 0x2fabc
movb $-0x1, %al
cmpl %r15d, %r13d
jae 0x2fbca
movq 0x8(%rsi), %rdx
movl %r13d, %eax
movl %r13d, %esi
notl %esi
addl %ecx, %esi
movq %r15, %rcx
subq %rax, %rcx
movb $-0x1, %al
movl %esi, %edi
movzbl (%rdx,%rdi), %edi
movzbl %al, %eax
cmpb %al, %dil
cmovbl %edi, %eax
decl %esi
decq %rcx
jne 0x2fbb4
leal -0x21(%rax), %ecx
xorl %edx, %edx
cmpb $0x21, %al
movzbl %cl, %eax
cmovbl %edx, %eax
cmpb $0x1, 0x1b1(%rbx)
jne 0x2fbed
movzbl %al, %eax
leaq 0x3df16(%rip), %rcx     # 0x6db00
movb (%rcx,%rax), %al
movzbl %al, %r12d
orl $0x4000, %r12d          # imm = 0x4000
jmp 0x2fabc
leal -0x1(%r15), %edx
xorl %r12d, %r12d
cmpl %edx, %ebp
jae 0x2fabc
testl %ebp, %ebp
je 0x2fabc
testl %eax, %eax
je 0x2fabc
movl 0x1b0(%rbx), %r12d
orl $0x2, %r12d
shll $0xe, %r12d
cmpb $0x1, 0x1b2(%rbx)
jne 0x2fabc
movl %r9d, 0x10(%rsp)
movl %r8d, 0xc(%rsp)
movq 0x8(%rsi), %rdx
movl %ebp, %edi
leal -0x1(%rcx), %r9d
movb $-0x1, %r8b
movq %rdi, %r10
movl %r9d, %r11d
movzbl (%rdx,%r11), %r11d
movzbl %r8b, %r8d
cmpb %r8b, %r11b
cmovbl %r11d, %r8d
decl %r9d
decq %r10
jne 0x2fc52
movb 0x1b1(%rbx), %dl
leal -0x21(%r8), %r9d
xorl %r10d, %r10d
cmpb $0x21, %r8b
movzbl %r9b, %r8d
cmovbl %r10d, %r8d
cmpb $0x1, %dl
jne 0x2fc9a
movzbl %r8b, %r8d
leaq 0x3de6a(%rip), %r9      # 0x6db00
movb (%r9,%r8), %r8b
movzbl %r8b, %r8d
orl %r8d, %r12d
movb $-0x1, %r9b
movb $-0x1, %r8b
cmpl %r15d, %ebp
jae 0x2fcf6
movq 0x8(%rsi), %rsi
movl %ebp, %r10d
notl %r10d
addl %ecx, %r10d
movb $-0x1, %r8b
movb $-0x1, %r9b
movl %r10d, %ecx
movzbl (%rsi,%rcx), %ecx
cmpb $-0x1, %r9b
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movl %r9d, %r11d
cmovel %r8d, %r11d
cmpb %r8b, %cl
cmovbl %ecx, %r8d
cmpb %r9b, %cl
cmovbl %ecx, %r9d
cmovbl %r11d, %r8d
incq %rdi
decl %r10d
cmpq %r15, %rdi
jb 0x2fcbf
leal -0x21(%r9), %ecx
xorl %esi, %esi
cmpb $0x21, %r9b
movzbl %cl, %ecx
cmovbl %esi, %ecx
testb %dl, %dl
je 0x2fd17
movzbl %cl, %ecx
leaq 0x3ddec(%rip), %rsi     # 0x6db00
movb (%rsi,%rcx), %cl
movl 0x10(%rsp), %r9d
movzbl %cl, %ecx
addl %ecx, %r12d
cmpl $0x3, %eax
jl 0x2fd5e
cmpb $-0x1, %r8b
je 0x2fd5e
leal -0x21(%r8), %eax
xorl %ecx, %ecx
cmpb $0x21, %r8b
movzbl %al, %eax
cmovbl %ecx, %eax
testb %dl, %dl
je 0x2fd4e
movzbl %al, %eax
leaq 0x3ddb5(%rip), %rcx     # 0x6db00
movb (%rcx,%rax), %al
movl 0xc(%rsp), %r8d
movzbl %al, %eax
addl %eax, %r12d
jmp 0x2fabc
movl 0xc(%rsp), %r8d
jmp 0x2fabc
movq 0x3b281(%rip), %rdi     # 0x6aff0
leaq 0x26ccc(%rip), %rsi     # 0x56a42
callq 0x9490
movq %rax, %rdi
movl %r14d, %esi
callq 0x9910
movl $0x4, %edi
callq 0x9200
movl $0x1, (%rax)
movq 0x3b19b(%rip), %rsi     # 0x6af38
movq %rax, %rdi
xorl %edx, %edx
callq 0x98f0
nop