// File: /workspace/github_cpp_makefile_star2_O1/BenLangmead[P]bowtie/./ebwt.h
// Function: Ebwt::joinedToTextOff(unsigned long, unsigned long, unsigned long&, unsigned long&, unsigned long&) const
void Ebwt::joinedToTextOff(TIndexOffU qlen, TIndexOffU off,
				 TIndexOffU& tidx,
				 TIndexOffU& textoff,
				 TIndexOffU& tlen) const
{
	TIndexOffU top = 0;
	TIndexOffU bot = _nFrag; // 1 greater than largest addressable element
	TIndexOffU elt = OFF_MASK;
	// Begin binary search
	while(true) {
		ASSERT_ONLY(TIndexOffU oldelt = elt);
		elt = top + ((bot - top) >> 1);
		assert_neq(oldelt, elt); // must have made progress
		TIndexOffU lower = _rstarts[elt*3];
		TIndexOffU upper;
		if(elt == _nFrag-1) {
			upper = _eh._len;
		} else {
			upper = _rstarts[((elt+1)*3)];
		}
		assert_gt(upper, lower);
		TIndexOffU fraglen = upper - lower;
		if(lower <= off) {
			if(upper > off) { // not last element, but it's within
				// off is in this range; check if it falls off
				if(off + qlen > upper) {
					// it falls off; signal no-go and return
					tidx = OFF_MASK;
					assert_lt(elt, _nFrag-1);
					return;
				}
				tidx = _rstarts[(elt*3)+1];
				assert_lt(tidx, this->_nPat);
				assert_leq(fraglen, this->_plen[tidx]);
				// it doesn't fall off; now calculate textoff.
				// Initially it's the number of characters that precede
				// the alignment in the fragment
				uint32_t fragoff = off - _rstarts[(elt*3)];
				if(!this->_fw) {
					fragoff = fraglen - fragoff - 1;
					fragoff -= (qlen-1);
				}
				// Add the alignment's offset into the fragment
				// ('fragoff') to the fragment's offset within the text
				textoff = fragoff + _rstarts[(elt*3)+2];
				assert_lt(textoff, this->_plen[tidx]);
				break; // done with binary search
			} else {
				// 'off' belongs somewhere in the region between elt
				// and bot
				top = elt;
			}
		} else {
			// 'off' belongs somewhere in the region between top and
			// elt
			bot = elt;
		}
		// continue with binary search
	}
	tlen = this->_plen[tidx];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, %r15
movq %rdi, %rbx
movq 0x88(%rdi), %rcx
leaq 0x108(%rdi), %rax
leaq (%rdx,%rsi), %r9
movq $-0x1, %r14
xorl %r8d, %r8d
movq %r14, %r13
movq %rcx, %r14
subq %r8, %r14
shrq %r14
addq %r8, %r14
cmpq %r14, %r13
je 0x6d9d
movq 0x88(%rbx), %r11
movq 0x98(%rbx), %rdi
leaq (%r14,%r14,2), %r10
leaq (%rdi,%r10,8), %r12
addq $0x18, %r12
movq -0x18(%r12), %rbp
decq %r11
cmpq %r11, %r14
cmoveq %rax, %r12
movq (%r12), %r12
movq %r12, %r13
subq %rbp, %r13
jbe 0x6ec7
xorl %r11d, %r11d
cmpq %rdx, %rbp
jbe 0x6ccd
movq %r14, %rcx
jmp 0x6d69
cmpq %rdx, %r12
jbe 0x6cf8
cmpq %r12, %r9
jbe 0x6cfd
movq $-0x1, (%r15)
movq 0x88(%rbx), %rdi
decq %rdi
movl $0x1, %r11d
cmpq %rdi, %r14
jb 0x6d69
jmp 0x7172
movq %r14, %r8
jmp 0x6d69
movq 0x8(%rdi,%r10,8), %rdi
movq %rdi, (%r15)
cmpq 0x80(%rbx), %rdi
jae 0x6f6a
movq 0x90(%rbx), %r11
cmpq (%r11,%rdi,8), %r13
ja 0x70c4
movq 0x98(%rbx), %rdi
movq %rdx, %r11
subq (%rdi,%r10,8), %r11
subl %esi, %r13d
subl %r11d, %r13d
cmpb $0x0, 0x10(%rbx)
cmovneq %r11, %r13
movl %r13d, %r12d
addq 0x10(%rdi,%r10,8), %r12
movq 0x8(%rsp), %rdi
movq %r12, (%rdi)
movq 0x90(%rbx), %rdi
movq (%r15), %r10
movl $0x3, %r11d
cmpq (%rdi,%r10,8), %r12
jae 0x7011
testl %r11d, %r11d
je 0x6c6c
cmpl $0x3, %r11d
jne 0x6d8e
movq 0x90(%rbx), %rax
movq (%r15), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30214(%rip), %rbx     # 0x36fb8
leaq 0x2655c(%rip), %rsi     # 0x2d307
movq %rbx, %rdi
callq 0x4310
movq %rax, %rdi
movq %r13, %rsi
callq 0x40c0
leaq 0x26387(%rip), %r15     # 0x2d14c
movq %rax, %rdi
movq %r15, %rsi
callq 0x4310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movq %r13, %rsi
callq 0x40c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x26345(%rip), %rsi     # 0x2d151
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movq %r14, %rsi
callq 0x40c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x4310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rax,%rcx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x284af(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x2625d(%rip), %r14     # 0x2d0da
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4310
leaq 0x27889(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa15, %esi            # imm = 0xA15
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x27745(%rip), %rdi     # 0x2e5f8
leaq 0x26468(%rip), %rcx     # 0x2d322
movq %r14, %rsi
movl $0xa15, %edx            # imm = 0xA15
callq 0x41c0
movq 0x300ea(%rip), %rbx     # 0x36fb8
leaq 0x26240(%rip), %rsi     # 0x2d115
movq %rbx, %rdi
callq 0x4310
movq %rax, %rdi
movq %r12, %rsi
callq 0x40c0
leaq 0x2623c(%rip), %rsi     # 0x2d12b
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movq %rbp, %rsi
callq 0x40c0
leaq 0x2840c(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x261ba(%rip), %r14     # 0x2d0da
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4310
leaq 0x277e6(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa1d, %esi            # imm = 0xA1D
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x276a2(%rip), %rdi     # 0x2e5f8
leaq 0x263c5(%rip), %rcx     # 0x2d322
movq %r14, %rsi
movl $0xa1d, %edx            # imm = 0xA1D
callq 0x41c0
movq 0x30047(%rip), %r14     # 0x36fb8
leaq 0x262ec(%rip), %rsi     # 0x2d264
movq %r14, %rdi
callq 0x4310
movq (%r15), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x262e8(%rip), %rsi     # 0x2d27a
movq %rax, %rdi
callq 0x4310
movq 0x80(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x28365(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x26113(%rip), %rbx     # 0x2d0da
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x2773f(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa29, %esi            # imm = 0xA29
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x275fb(%rip), %rdi     # 0x2e5f8
leaq 0x2631e(%rip), %rcx     # 0x2d322
movq %rbx, %rsi
movl $0xa29, %edx            # imm = 0xA29
callq 0x41c0
movq 0x2ffa0(%rip), %r14     # 0x36fb8
leaq 0x26245(%rip), %rsi     # 0x2d264
movq %r14, %rdi
callq 0x4310
movq 0x8(%rsp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x2623c(%rip), %rsi     # 0x2d27a
movq %rax, %rdi
callq 0x4310
movq 0x90(%rbx), %rcx
movq (%r15), %rdx
movq (%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x282b2(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x26060(%rip), %rbx     # 0x2d0da
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x2768c(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa36, %esi            # imm = 0xA36
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x27548(%rip), %rdi     # 0x2e5f8
leaq 0x2626b(%rip), %rcx     # 0x2d322
movq %rbx, %rsi
movl $0xa36, %edx            # imm = 0xA36
callq 0x41c0
movq 0x2feed(%rip), %r14     # 0x36fb8
leaq 0x260ee(%rip), %rsi     # 0x2d1c0
movq %r14, %rdi
callq 0x4310
movq %rax, %rdi
movq %r13, %rsi
callq 0x40c0
leaq 0x260eb(%rip), %rsi     # 0x2d1d7
movq %rax, %rdi
callq 0x4310
movq 0x90(%rbx), %rcx
movq (%r15), %rdx
movq (%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x28204(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x25fb2(%rip), %rbx     # 0x2d0da
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x275de(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa2a, %esi            # imm = 0xA2A
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x2749a(%rip), %rdi     # 0x2e5f8
leaq 0x261bd(%rip), %rcx     # 0x2d322
movq %rbx, %rsi
movl $0xa2a, %edx            # imm = 0xA2A
callq 0x41c0
movq 0x2fe3f(%rip), %r15     # 0x36fb8
leaq 0x260e4(%rip), %rsi     # 0x2d264
movq %r15, %rdi
callq 0x4310
movq %rax, %rdi
movq %r14, %rsi
callq 0x40c0
leaq 0x260e0(%rip), %rsi     # 0x2d27a
movq %rax, %rdi
callq 0x4310
movq 0x88(%rbx), %rsi
decq %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x2815a(%rip), %rsi     # 0x2f315
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x25f08(%rip), %rbx     # 0x2d0da
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x27534(%rip), %rsi     # 0x2e718
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa25, %esi            # imm = 0xA25
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x273f0(%rip), %rdi     # 0x2e5f8
leaq 0x26113(%rip), %rcx     # 0x2d322
movq %rbx, %rsi
movl $0xa25, %edx            # imm = 0xA25
callq 0x41c0