// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %r9, 0x18(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, 0x10(%rsp)
movq %rsi, %r9
movq 0x88(%rdi), %rbx
movq 0x98(%rdi), %rsi
movq %rbx, %rcx
shrq %rcx
leaq -0x1(%rbx), %rax
movq %rdi, 0x8(%rsp)
leaq 0x108(%rdi), %r8
leaq 0x18(%rsi), %r10
xorl %r11d, %r11d
movq %rcx, %r15
leaq (%rcx,%rcx,2), %rcx
cmpq %rax, %r15
leaq (%r10,%rcx,8), %r14
cmoveq %r8, %r14
movq (%rsi,%rcx,8), %rbp
movq (%r14), %r12
movq %r12, %r13
subq %rbp, %r13
jbe 0x6fae
movq %r15, %r14
cmpq %rdx, %rbp
ja 0x6d0d
movq %rbx, %r14
movq %r15, %r11
cmpq %rdx, %r12
ja 0x6e4b
movq %r14, %rcx
subq %r11, %rcx
shrq %rcx
addq %r11, %rcx
movq %r14, %rbx
cmpq %rcx, %r15
jne 0x6cd1
movq 0x30290(%rip), %rbx     # 0x36fb8
leaq 0x25668(%rip), %rsi     # 0x2c397
movq %rbx, %rdi
callq 0x4310
movq %rax, %rdi
movq %r15, %rsi
callq 0x40c0
leaq 0x25493(%rip), %r14     # 0x2c1dc
movq %rax, %rdi
movq %r14, %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 %r15, %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 0x25451(%rip), %rsi     # 0x2c1e1
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movq %r15, %rsi
callq 0x40c0
movq %rax, %rdi
movq %r14, %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 %r15, %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 0x275bb(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x25369(%rip), %r14     # 0x2c16a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4310
leaq 0x26995(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa15, %esi            # imm = 0xA15
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x26851(%rip), %rdi     # 0x2d688
leaq 0x25574(%rip), %rcx     # 0x2c3b2
movq %r14, %rsi
movl $0xa15, %edx            # imm = 0xA15
callq 0x41c0
leaq (%rdx,%r9), %rdi
cmpq %r12, %rdi
jbe 0x6f26
movq 0x10(%rsp), %rax
movq $-0x1, (%rax)
movq 0x8(%rsp), %rbx
movq 0x88(%rbx), %rax
decq %rax
cmpq %rax, %r15
jb 0x6f9f
movq 0x30135(%rip), %r14     # 0x36fb8
leaq 0x2546a(%rip), %rsi     # 0x2c2f4
movq %r14, %rdi
callq 0x4310
movq %rax, %rdi
movq %r15, %rsi
callq 0x40c0
leaq 0x25466(%rip), %rsi     # 0x2c30a
movq %rax, %rdi
callq 0x4310
movq 0x88(%rbx), %rsi
decq %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x274e0(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x2528e(%rip), %rbx     # 0x2c16a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x268ba(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa25, %esi            # imm = 0xA25
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x26776(%rip), %rdi     # 0x2d688
leaq 0x25499(%rip), %rcx     # 0x2c3b2
movq %rbx, %rsi
movl $0xa25, %edx            # imm = 0xA25
callq 0x41c0
movq 0x8(%rsi,%rcx,8), %rax
movq 0x10(%rsp), %r14
movq %rax, (%r14)
movq 0x8(%rsp), %rbx
cmpq 0x80(%rbx), %rax
jae 0x7051
movq 0x90(%rbx), %rdi
cmpq (%rdi,%rax,8), %r13
ja 0x70f8
movq 0x98(%rbx), %rax
subq (%rax,%rcx,8), %rdx
addl %edx, %r9d
subl %r9d, %r13d
cmpb $0x0, 0x10(%rbx)
cmovneq %rdx, %r13
movl %r13d, %edx
addq 0x10(%rax,%rcx,8), %rdx
movq 0x20(%rsp), %r12
movq %rdx, (%r12)
movq 0x90(%rbx), %rax
movq (%r14), %rcx
movq (%rax,%rcx,8), %rax
cmpq %rax, %rdx
jae 0x71a6
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30003(%rip), %rbx     # 0x36fb8
leaq 0x251e9(%rip), %rsi     # 0x2c1a5
movq %rbx, %rdi
callq 0x4310
movq %rax, %rdi
movq %r12, %rsi
callq 0x40c0
leaq 0x251e5(%rip), %rsi     # 0x2c1bb
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movq %rbp, %rsi
callq 0x40c0
leaq 0x273b5(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x25163(%rip), %r14     # 0x2c16a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4310
leaq 0x2678f(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa1d, %esi            # imm = 0xA1D
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x2664b(%rip), %rdi     # 0x2d688
leaq 0x2536e(%rip), %rcx     # 0x2c3b2
movq %r14, %rsi
movl $0xa1d, %edx            # imm = 0xA1D
callq 0x41c0
movq 0x2ff60(%rip), %r15     # 0x36fb8
leaq 0x25295(%rip), %rsi     # 0x2c2f4
movq %r15, %rdi
callq 0x4310
movq (%r14), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x25291(%rip), %rsi     # 0x2c30a
movq %rax, %rdi
callq 0x4310
movq 0x80(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x2730e(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x250bc(%rip), %rbx     # 0x2c16a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x266e8(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa29, %esi            # imm = 0xA29
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x265a4(%rip), %rdi     # 0x2d688
leaq 0x252c7(%rip), %rcx     # 0x2c3b2
movq %rbx, %rsi
movl $0xa29, %edx            # imm = 0xA29
callq 0x41c0
movq 0x2feb9(%rip), %r15     # 0x36fb8
leaq 0x2514a(%rip), %rsi     # 0x2c250
movq %r15, %rdi
callq 0x4310
movq %rax, %rdi
movq %r13, %rsi
callq 0x40c0
leaq 0x25147(%rip), %rsi     # 0x2c267
movq %rax, %rdi
callq 0x4310
movq 0x90(%rbx), %rcx
movq (%r14), %rdx
movq (%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x27260(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x2500e(%rip), %rbx     # 0x2c16a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x2663a(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa2a, %esi            # imm = 0xA2A
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x264f6(%rip), %rdi     # 0x2d688
leaq 0x25219(%rip), %rcx     # 0x2c3b2
movq %rbx, %rsi
movl $0xa2a, %edx            # imm = 0xA2A
callq 0x41c0
movq 0x2fe0b(%rip), %r15     # 0x36fb8
leaq 0x25140(%rip), %rsi     # 0x2c2f4
movq %r15, %rdi
callq 0x4310
movq (%r12), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x2513b(%rip), %rsi     # 0x2c30a
movq %rax, %rdi
callq 0x4310
movq 0x90(%rbx), %rcx
movq (%r14), %rdx
movq (%rcx,%rdx,8), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0x271b1(%rip), %rsi     # 0x2e3a5
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
callq 0x4150
leaq 0x24f5f(%rip), %rbx     # 0x2c16a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4310
leaq 0x2658b(%rip), %rsi     # 0x2d7a8
movq %rax, %rdi
callq 0x4310
movq %rax, %rdi
movl $0xa36, %esi            # imm = 0xA36
callq 0x4610
movq %rax, %rdi
callq 0x4150
leaq 0x26447(%rip), %rdi     # 0x2d688
leaq 0x2516a(%rip), %rcx     # 0x2c3b2
movq %rbx, %rsi
movl $0xa36, %edx            # imm = 0xA36
callq 0x41c0
nop