// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./range_cache.h
// Function: RangeCache::tunnel(unsigned int, unsigned int, RangeCacheEntry&)
bool tunnel(TIndexOffU top, TIndexOffU bot, RangeCacheEntry& ent) {
		assert_gt(bot, top);
		TUVec tops;
		const TIndexOffU spread = bot - top;
		SideLocus tloc, bloc;
		SideLocus::initFromTopBot(top, bot, ebwt_->_eh, ebwt_->_ebwt, tloc, bloc);
		TIndexOffU newtop = top, newbot = bot;
		TIndexOffU jumps = 0;
		// Walk left through the tunnel
		while(true) {
			if(ebwt_->rowL(tloc) != ebwt_->rowL(bloc)) {
				// Different characters at top and bot positions of
				// BWT; this means that the calls to mapLF below are
				// guaranteed to yield rows in two different character-
				// sections of the BWT.
				break;
			}
			// Advance top and bot
			newtop = ebwt_->mapLF(tloc);
			newbot = ebwt_->mapLF(bloc);
			assert_geq(newbot, newtop);
			assert_leq(newbot - newtop, spread);
			// If the new spread is the same as the old spread, we can
			// be confident that the new range includes all of the same
			// suffixes as the last range (though longer by 1 char)
			if((newbot - newtop) == spread) {
				// Check if newtop is already cached
				TMapItr itr = map_.find(newtop);
				jumps++;
				if(itr != map_.end()) {
					// This range, which is further to the left in the
					// same tunnel as the query range, has a cache
					// entry already, so use that
					TIndexOffU idx = itr->second;
					TIndexOffU *ents = pool_.get(idx);
					if((ents[0] & CACHE_WRAPPER_BIT) != 0) {
						// The cache entry we found was a wrapper; make
						// a new wrapper that points to that wrapper's
						// target, with the appropriate number of jumps
						jumps += (ents[0] & ~CACHE_WRAPPER_BIT);
						idx = ents[1];
					}
					// Allocate a new wrapper
					TIndexOffU newentIdx = pool_.alloc(2);
					if(newentIdx != RANGE_CACHE_BAD_ALLOC) {
						// We successfully made a new wrapper entry;
						// now populate it and install it in map_
						TIndexOffU *newent = pool_.get(newentIdx); // get ptr to it
						assert_eq(0, newent[0]);
						newent[0] = CACHE_WRAPPER_BIT | jumps; // set jumps
						newent[1] = idx;                // set target
						assert(map_.find(top) == map_.end());
						map_[top] = newentIdx;
						if(sanity_) assert(repOk());
					}
					// Initialize the entry
					ent.init(pool_, top, jumps, idx, ebwt_);
					return true;
				}
				// Save this range
				tops.push_back(newtop);
				SideLocus::initFromTopBot(newtop, newbot, ebwt_->_eh, ebwt_->_ebwt, tloc, bloc);
			} else {
				// Not all the suffixes were preserved, so we can't
				// link the source range's cached result to this
				// range's cached results
				break;
			}
			assert_eq(jumps, tops.size());
		}
		assert_eq(jumps, tops.size());
		// Try to create a new cache entry for the leftmost range in
		// the tunnel (which might be the query range)
		TIndexOffU newentIdx = pool_.alloc(spread + 1);
		if(newentIdx != RANGE_CACHE_BAD_ALLOC) {
			// Successfully allocated new range cache entry; install it
			TIndexOffU *newent = pool_.get(newentIdx);
			assert_eq(0, newent[0]);
			// Store cache-range length in first word
			newent[0] = spread;
			assert_lt(newent[0], CACHE_WRAPPER_BIT);
			assert_eq(spread, newent[0]);
			TIndexOffU entTop = top;
			TIndexOffU jumps = 0;
			if(tops.size() > 0) {
				entTop = tops.back();
				jumps = (TIndexOff)tops.size();
			}
			// Cache the entry for the end of the tunnel
			assert(map_.find(entTop) == map_.end());
			map_[entTop] = newentIdx;
			if(sanity_) assert(repOk());
			ent.init(pool_, entTop, jumps, newentIdx, ebwt_);
			assert_eq(spread, newent[0]);
			if(jumps > 0) {
				assert_neq(entTop, top);
				// Cache a wrapper entry for the query range (if possible)
				TIndexOffU wrapentIdx = pool_.alloc(2);
				if(wrapentIdx != RANGE_CACHE_BAD_ALLOC) {
					TIndexOffU *wrapent = pool_.get(wrapentIdx);
					assert_eq(0, wrapent[0]);
					wrapent[0] = CACHE_WRAPPER_BIT | jumps;
					wrapent[1] = newentIdx;
					assert(map_.find(top) == map_.end());
					map_[top] = wrapentIdx;
					if(sanity_) assert(repOk());
				}
			}
			return true;
		} else {
			// Could not allocate new range cache entry
			return false;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, 0x18(%rsp)
movl %esi, %r15d
movq %rdi, %rbx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
leaq 0x48(%rsp), %rcx
movq %rax, (%rcx)
andq $0x0, 0x8(%rcx)
movq $0x80, 0x10(%rcx)
andq $0x0, 0x18(%rcx)
leaq 0x38(%rsp), %r13
andq $0x0, (%r13)
movl %esi, 0x8(%rsp)
andw $0x0, 0x8(%r13)
movl %edx, %eax
subl %esi, %eax
movq %rax, 0x20(%rsp)
movb $0x1, %al
movb %al, 0xa(%r13)
orw $-0x1, 0xc(%r13)
movb $-0x1, %cl
leaq 0x28(%rsp), %rbp
andq $0x0, (%rbp)
movb %cl, 0xe(%r13)
andw $0x0, 0x8(%rbp)
movb %al, 0xa(%rbp)
orw $-0x1, 0xc(%rbp)
movb %cl, 0xe(%rbp)
movq 0x58(%rdi), %rax
movq 0xb8(%rax), %rcx
addq $0xf8, %rax
movl %esi, %edi
movl %edx, %esi
movq %rax, %rdx
movq %r13, %r8
movq %rbp, %r9
callq 0x238ee
leaq 0x4(%rsp), %rax
movl %r15d, (%rax)
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rbx), %r14
pushq $0x1
popq %r15
movq 0x58(%rbx), %rdi
movq 0xb8(%rdi), %rax
movl 0x38(%rsp), %ecx
addq %rax, %rcx
movswq 0x44(%rsp), %rdx
movzbl (%rdx,%rcx), %edx
movb 0x46(%rsp), %cl
addb %cl, %cl
shrl %cl, %edx
movl 0x28(%rsp), %ecx
addq %rax, %rcx
movswq 0x34(%rsp), %rax
movzbl (%rax,%rcx), %eax
movb 0x36(%rsp), %cl
addb %cl, %cl
shrl %cl, %eax
xorl %edx, %eax
testb $0x3, %al
jne 0x29135
movq %r13, %rsi
callq 0x15eac
movl %eax, 0x4(%rsp)
movq 0x58(%rbx), %rdi
movq %rbp, %rsi
callq 0x15eac
movl %eax, %r12d
subl 0x4(%rsp), %eax
cmpl 0x20(%rsp), %eax
jne 0x29135
movq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2930c
cmpq %r14, %rax
jne 0x2920a
leaq 0x48(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x1bf46
movl 0x4(%rsp), %edi
movq 0x58(%rbx), %rdx
movq 0xb8(%rdx), %rcx
addq $0xf8, %rdx
movl %r12d, %esi
movq %r13, %r8
movq %rbp, %r9
callq 0x238ee
incl %r15d
jmp 0x2907a
leaq 0x38(%rbx), %r12
movq 0x20(%rsp), %r13
leal 0x1(%r13), %esi
movq %r12, %rdi
callq 0x2935e
xorl %ebp, %ebp
cmpl $-0x1, %eax
je 0x29296
movl %eax, %r14d
movq 0x40(%rbx), %rax
movl %r14d, %r15d
movl %r13d, (%rax,%r15,4)
movl 0x8(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x29184
movq 0x50(%rsp), %rcx
movl -0x4(%rcx,%rax,4), %ecx
movl %ecx, 0xc(%rsp)
movl %eax, %ebp
leaq 0xc(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x2938e
movl %r14d, (%rax)
movl 0xc(%rsp), %eax
movq 0x58(%rbx), %rcx
movq 0x18(%rsp), %rdx
movq %rcx, 0x18(%rdx)
movl %eax, (%rdx)
movl %ebp, 0x4(%rdx)
movq 0x40(%rbx), %rax
leaq 0x4(%rax,%r15,4), %rax
movl -0x4(%rax), %ecx
movl %ecx, 0x8(%rdx)
movq %rax, 0x10(%rdx)
testl %ebp, %ebp
je 0x29293
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x2935e
cmpl $-0x1, %eax
je 0x29293
movl %eax, %r12d
movq 0x40(%rbx), %rax
movl %r12d, %ecx
orl $0x80000000, %ebp       # imm = 0x80000000
movl %ebp, (%rax,%rcx,4)
movl %r14d, 0x4(%rax,%rcx,4)
leaq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x2938e
movl %r12d, (%rax)
jmp 0x29293
movl 0x24(%rax), %r14d
leaq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rax
movl (%rax,%r14,4), %ecx
testl %ecx, %ecx
jns 0x2922c
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addl %ecx, %r15d
movl 0x4(%rax,%r14,4), %r14d
pushq $0x2
popq %rsi
callq 0x2935e
cmpl $-0x1, %eax
je 0x29263
movl %eax, %ebp
movq 0x40(%rbx), %rax
movl %ebp, %ecx
movl %r15d, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
movl %r14d, 0x4(%rax,%rcx,4)
leaq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x2938e
movl %ebp, (%rax)
movl 0x8(%rsp), %eax
movq 0x58(%rbx), %rcx
movq 0x18(%rsp), %rdx
movq %rcx, 0x18(%rdx)
movl %eax, (%rdx)
movl %r15d, 0x4(%rdx)
movq 0x40(%rbx), %rax
movl %r14d, %ecx
leaq (%rax,%rcx,4), %rax
addq $0x4, %rax
movl -0x4(%rax), %ecx
movl %ecx, 0x8(%rdx)
movq %rax, 0x10(%rdx)
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x1c1c4
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x292b9
jmp 0x292b9
jmp 0x292b9
jmp 0x292b9
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x1c1c4
movq %rbx, %rdi
callq 0x9950