// File: BenLangmead[P]bowtie/./reference.h
// Function: BitPairReference::getStretchNaive(unsigned int*, unsigned long, unsigned long, unsigned long) const
int getStretchNaive(uint32_t *destU32,
	                    size_t tidx,
	                    size_t toff,
	                    size_t count) const
	{
		uint8_t *dest = (uint8_t*)destU32;
		uint64_t reci = refRecOffs_[tidx];   // first record for target reference sequence
		uint64_t recf = refRecOffs_[tidx+1]; // last record (exclusive) for target seq
		assert_gt(recf, reci);
		uint64_t cur = 0;
		uint64_t bufOff = refOffs_[tidx];
		uint64_t off = 0;
		// For all records pertaining to the target reference sequence...
		for(uint64_t i = reci; i < recf; i++) {
			assert_geq(toff, off);
			off += recs_[i].off;
			for(; toff < off && count > 0; toff++) {
				dest[cur++] = 4;
				count--;
			}
			if(count == 0) break;
			assert_geq(toff, off);
			if(toff < off + recs_[i].len) {
				bufOff += (TIndexOffU)(toff - off); // move bufOff pointer forward
			} else {
				bufOff += recs_[i].len;
			}
			off += recs_[i].len;
			for(; toff < off && count > 0; toff++) {
				assert_lt(bufOff, bufSz_);
				const uint64_t bufElt = (bufOff) >> 2;
				const uint64_t shift = (bufOff & 3) << 1;
				dest[cur++] = (buf_[bufElt] >> shift) & 3;
				bufOff++;
				count--;
			}
			if(count == 0) break;
			assert_geq(toff, off);
		} // end for loop over records
		// In any chars are left after scanning all the records,
		// they must be ambiguous
		while(count > 0) {
			count--;
			dest[cur++] = 4;
		}
		assert_eq(0, count);
		return 0;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
addq $0x4c0, %rdi            # imm = 0x4C0
movq -0x18(%rbp), %rsi
callq 0x2bbc0
movq -0x78(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x38(%rbp)
addq $0x4c0, %rdi            # imm = 0x4C0
movq -0x18(%rbp), %rsi
addq $0x1, %rsi
callq 0x2bbc0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
ja 0x2b518
movq 0x1eb56(%rip), %rdi     # 0x49fc0
leaq 0x13c87(%rip), %rsi     # 0x3f0f8
callq 0x5360
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x13c82(%rip), %rsi     # 0x3f10e
callq 0x5360
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x16111(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1eaca(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1eafe(%rip), %rdi     # 0x49fc0
leaq 0x1537e(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x152b2(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1af, %esi            # imm = 0x1AF
callq 0x5750
movq %rax, %rdi
movq 0x1ea8c(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1516a(%rip), %rdi     # 0x4066a
leaq 0x15340(%rip), %rsi     # 0x40847
movl $0x1af, %edx            # imm = 0x1AF
leaq 0x15409(%rip), %rcx     # 0x4091c
callq 0x51e0
movq -0x78(%rbp), %rdi
movq $0x0, -0x48(%rbp)
addq $0x460, %rdi            # imm = 0x460
movq -0x18(%rbp), %rsi
callq 0x2bbc0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x2ba4e
movq -0x20(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x2b61c
movq 0x1ea52(%rip), %rdi     # 0x49fc0
leaq 0x13c90(%rip), %rsi     # 0x3f205
callq 0x5360
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x13c8c(%rip), %rsi     # 0x3f21c
callq 0x5360
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1600d(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1e9c6(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1e9fa(%rip), %rdi     # 0x49fc0
leaq 0x1527a(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x151ae(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1b5, %esi            # imm = 0x1B5
callq 0x5750
movq %rax, %rdi
movq 0x1e988(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x15066(%rip), %rdi     # 0x4066a
leaq 0x1523c(%rip), %rsi     # 0x40847
movl $0x1b5, %edx            # imm = 0x1B5
leaq 0x15305(%rip), %rcx     # 0x4091c
callq 0x51e0
movq -0x78(%rbp), %rdi
addq $0x400, %rdi            # imm = 0x400
movq -0x60(%rbp), %rsi
callq 0x22d20
movq (%rax), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x79(%rbp)
jae 0x2b655
cmpq $0x0, -0x28(%rbp)
seta %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x2b65e
jmp 0x2b68f
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rbp)
movb $0x4, (%rax,%rcx)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2b63b
cmpq $0x0, -0x28(%rbp)
jne 0x2b69b
jmp 0x2ba4e
movq -0x20(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x2b75e
movq 0x1e910(%rip), %rdi     # 0x49fc0
leaq 0x13b4e(%rip), %rsi     # 0x3f205
callq 0x5360
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x13b4a(%rip), %rsi     # 0x3f21c
callq 0x5360
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x15ecb(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1e884(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1e8b8(%rip), %rdi     # 0x49fc0
leaq 0x15138(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x1506c(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1bc, %esi            # imm = 0x1BC
callq 0x5750
movq %rax, %rdi
movq 0x1e846(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x14f24(%rip), %rdi     # 0x4066a
leaq 0x150fa(%rip), %rsi     # 0x40847
movl $0x1bc, %edx            # imm = 0x1BC
leaq 0x151c3(%rip), %rcx     # 0x4091c
callq 0x51e0
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
addq $0x400, %rdi            # imm = 0x400
movq -0x60(%rbp), %rsi
callq 0x22d20
movq -0x90(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
addq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jae 0x2b7b4
movq -0x20(%rbp), %rax
subq -0x58(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x2b7d4
movq -0x78(%rbp), %rdi
addq $0x400, %rdi            # imm = 0x400
movq -0x60(%rbp), %rsi
callq 0x22d20
movq 0x8(%rax), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x78(%rbp), %rdi
addq $0x400, %rdi            # imm = 0x400
movq -0x60(%rbp), %rsi
callq 0x22d20
movq 0x8(%rax), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x91(%rbp)
jae 0x2b814
cmpq $0x0, -0x28(%rbp)
seta %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x2b823
jmp 0x2b96c
movq -0x78(%rbp), %rcx
movq -0x50(%rbp), %rax
cmpq 0x550(%rcx), %rax
jb 0x2b8f4
movq 0x1e781(%rip), %rdi     # 0x49fc0
leaq 0x13a01(%rip), %rsi     # 0x3f247
callq 0x5360
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x139fc(%rip), %rsi     # 0x3f25d
callq 0x5360
movq %rax, %rdi
movq -0x78(%rbp), %rax
movq 0x550(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x15d35(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1e6ee(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1e722(%rip), %rdi     # 0x49fc0
leaq 0x14fa2(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x14ed6(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1c4, %esi            # imm = 0x1C4
callq 0x5750
movq %rax, %rdi
movq 0x1e6b0(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x14d8e(%rip), %rdi     # 0x4066a
leaq 0x14f64(%rip), %rsi     # 0x40847
movl $0x1c4, %edx            # imm = 0x1C4
leaq 0x1502d(%rip), %rcx     # 0x4091c
callq 0x51e0
movq -0x78(%rbp), %rax
movq -0x50(%rbp), %rcx
shrq $0x2, %rcx
movq %rcx, -0x68(%rbp)
movq -0x50(%rbp), %rcx
andq $0x3, %rcx
shlq %rcx
movq %rcx, -0x70(%rbp)
movq 0x540(%rax), %rax
movq -0x68(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x70(%rbp), %rcx
sarl %cl, %eax
andl $0x3, %eax
movb %al, %dl
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x48(%rbp)
movb %dl, (%rax,%rcx)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2b7f4
cmpq $0x0, -0x28(%rbp)
jne 0x2b978
jmp 0x2ba4e
movq -0x20(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x2ba3b
movq 0x1e633(%rip), %rdi     # 0x49fc0
leaq 0x13871(%rip), %rsi     # 0x3f205
callq 0x5360
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1386d(%rip), %rsi     # 0x3f21c
callq 0x5360
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x15bee(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1e5a7(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1e5db(%rip), %rdi     # 0x49fc0
leaq 0x14e5b(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x14d8f(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1cc, %esi            # imm = 0x1CC
callq 0x5750
movq %rax, %rdi
movq 0x1e569(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x14c47(%rip), %rdi     # 0x4066a
leaq 0x14e1d(%rip), %rsi     # 0x40847
movl $0x1cc, %edx            # imm = 0x1CC
leaq 0x14ee6(%rip), %rcx     # 0x4091c
callq 0x51e0
jmp 0x2ba3d
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x2b54b
jmp 0x2ba50
cmpq $0x0, -0x28(%rbp)
jbe 0x2ba7c
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rbp)
movb $0x4, (%rax,%rcx)
jmp 0x2ba50
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
je 0x2bbab
movq 0x1e531(%rip), %rdi     # 0x49fc0
leaq 0x13683(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x13680(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq -0x132de(%rip), %rsi    # 0x187e0
callq 0x5120
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq -0x132c7(%rip), %rsi    # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x1364e(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1362e(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq -0x13330(%rip), %rsi    # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq -0x1331b(%rip), %rsi    # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x15a7e(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x1e437(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x1e46b(%rip), %rdi     # 0x49fc0
leaq 0x14ceb(%rip), %rsi     # 0x40847
callq 0x5360
movq %rax, %rdi
leaq 0x14c1f(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1d4, %esi            # imm = 0x1D4
callq 0x5750
movq %rax, %rdi
movq 0x1e3f9(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x14ad7(%rip), %rdi     # 0x4066a
leaq 0x14cad(%rip), %rsi     # 0x40847
movl $0x1d4, %edx            # imm = 0x1D4
leaq 0x14d76(%rip), %rcx     # 0x4091c
callq 0x51e0
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)