// File: BenLangmead[P]bowtie/./ebwt.h
// Function: Ebwt::sanityCheckUpToSide(long) const
void Ebwt::sanityCheckUpToSide(TIndexOff upToSide) const {
	assert(isInMemory());
	TIndexOffU occ[] = {0, 0, 0, 0};
	ASSERT_ONLY(TIndexOffU occ_save[] = {0, 0});
	TIndexOffU cur = 0; // byte pointer
	const EbwtParams& eh = this->_eh;
	bool fw = false;
	while(cur < (TIndexOffU)(upToSide * eh._sideSz)) {
		assert_leq(cur + eh._sideSz, eh._ebwtTotLen);
		for(uint32_t i = 0; i < eh._sideBwtSz; i++) {
			uint8_t by = this->_ebwt[cur + (fw ? i : eh._sideBwtSz-i-1)];
			for(int j = 0; j < 4; j++) {
				// Unpack from lowest to highest bit pair
				int twoBit = unpack_2b_from_8b(by, fw ? j : 3-j);
				occ[twoBit]++;
				//if(_verbose) cout << "ACGT"[twoBit];
			}
			assert_eq(0, (occ[0] + occ[1] + occ[2] + occ[3]) % 4);
		}
		assert_eq(0, (occ[0] + occ[1] + occ[2] + occ[3]) % eh._sideBwtLen);
		if(fw) {
			// Finished forward bucket; check saved [G] and [T]
			// against the two uint32_ts encoded here
			ASSERT_ONLY(TIndexOffU *u32ebwt = reinterpret_cast<TIndexOffU*>(&this->_ebwt[cur + eh._sideBwtSz]));
			ASSERT_ONLY(TIndexOffU gs = u32ebwt[0]);
			ASSERT_ONLY(TIndexOffU ts = u32ebwt[1]);
			assert_eq(gs, occ_save[0]);
			assert_eq(ts, occ_save[1]);
			fw = false;
		} else {
			// Finished backward bucket; check current [A] and [C]
			// against the two uint32_ts encoded here
			ASSERT_ONLY(TIndexOffU *u32ebwt = reinterpret_cast<TIndexOffU*>(&this->_ebwt[cur + eh._sideBwtSz]));
			ASSERT_ONLY(TIndexOffU as = u32ebwt[0]);
			ASSERT_ONLY(TIndexOffU cs = u32ebwt[1]);
			assert(as == occ[0] || as == occ[0]-1); // one 'a' is a skipped '$' and doesn't count toward occ[]
			assert_eq(cs, occ[1]);
			ASSERT_ONLY(occ_save[0] = occ[2]); // save gs
			ASSERT_ONLY(occ_save[1] = occ[3]); // save ts
			fw = true;
		}
		cur += eh._sideSz;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x18060
testb $0x1, %al
jne 0x6e39
jmp 0x6e3b
jmp 0x6e5a
leaq 0x3826e(%rip), %rdi     # 0x3f0b0
leaq 0x38274(%rip), %rsi     # 0x3f0bd
movl $0x630, %edx            # imm = 0x630
leaq 0x3831e(%rip), %rcx     # 0x3f173
callq 0x51e0
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x5190
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x5190
movq -0xa0(%rbp), %rax
movq $0x0, -0x48(%rbp)
addq $0x108, %rax            # imm = 0x108
movq %rax, -0x50(%rbp)
movb $0x0, -0x51(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movq -0x50(%rbp), %rdx
movl 0x84(%rdx), %edx
imulq %rdx, %rcx
cmpq %rcx, %rax
jae 0x7851
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x84(%rcx), %ecx
addq %rcx, %rax
movq -0x50(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jbe 0x6fa1
movq 0x430e1(%rip), %rdi     # 0x49fc0
leaq 0x382bd(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rax
movl 0x84(%rax), %eax
addq %rax, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x382ac(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x50(%rbp), %rax
movq 0xa8(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x3a688(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x43041(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x43075(%rip), %rdi     # 0x49fc0
leaq 0x3816b(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x39829(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x637, %esi            # imm = 0x637
callq 0x5750
movq %rax, %rdi
movq 0x43003(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x396e1(%rip), %rdi     # 0x4066a
leaq 0x3812d(%rip), %rsi     # 0x3f0bd
movl $0x637, %edx            # imm = 0x637
leaq 0x381d7(%rip), %rcx     # 0x3f173
callq 0x51e0
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x88(%rcx), %eax
jae 0x71fc
movq -0xa0(%rbp), %rax
movq 0xc8(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa8(%rbp)
testb $0x1, -0x51(%rbp)
je 0x6fec
movl -0x58(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x7002
movq -0x50(%rbp), %rax
movl 0x88(%rax), %eax
subl -0x58(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xb4(%rbp)
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl -0xb4(%rbp), %edx
movl %edx, %edx
addq %rdx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x59(%rbp)
movl $0x0, -0x60(%rbp)
cmpl $0x4, -0x60(%rbp)
jge 0x708a
movb -0x59(%rbp), %al
movb %al, -0xb5(%rbp)
testb $0x1, -0x51(%rbp)
je 0x7048
movl -0x60(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x7056
movl $0x3, %eax
subl -0x60(%rbp), %eax
movl %eax, -0xbc(%rbp)
movb -0xb5(%rbp), %al
movl -0xbc(%rbp), %esi
movzbl %al, %edi
callq 0x6990
movl %eax, -0x64(%rbp)
movslq -0x64(%rbp), %rax
movq -0x30(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp,%rax,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x7028
movq -0x30(%rbp), %rcx
addq -0x28(%rbp), %rcx
addq -0x20(%rbp), %rcx
addq -0x18(%rbp), %rcx
andq $0x3, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x71ec
movq 0x42f10(%rip), %rdi     # 0x49fc0
leaq 0x38062(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x3805f(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11701(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x11718(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x3802d(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x30(%rbp), %rsi
addq -0x28(%rbp), %rsi
addq -0x20(%rbp), %rsi
addq -0x18(%rbp), %rsi
andq $0x3, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37ffd(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x1169f(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x30(%rbp), %rsi
addq -0x28(%rbp), %rsi
addq -0x20(%rbp), %rsi
addq -0x18(%rbp), %rsi
andq $0x3, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x116a4(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x3a43d(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x42df6(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x42e2a(%rip), %rdi     # 0x49fc0
leaq 0x37f20(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x395de(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x640, %esi            # imm = 0x640
callq 0x5750
movq %rax, %rdi
movq 0x42db8(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x39496(%rip), %rdi     # 0x4066a
leaq 0x37ee2(%rip), %rsi     # 0x3f0bd
movl $0x640, %edx            # imm = 0x640
leaq 0x37f8c(%rip), %rcx     # 0x3f173
callq 0x51e0
jmp 0x71ee
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x6fa8
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x8c(%rcx), %ecx
xorl %edx, %edx
divq %rcx
xorl %eax, %eax
cmpq %rdx, %rax
je 0x7385
movq 0x42d93(%rip), %rdi     # 0x49fc0
leaq 0x37ee5(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x37ee2(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11584(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x1159b(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x37eb0(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x8c(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37e72(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11514(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x30(%rbp), %rax
addq -0x28(%rbp), %rax
addq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq -0x50(%rbp), %rcx
movl 0x8c(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1150b(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x3a2a4(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x42c5d(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x42c91(%rip), %rdi     # 0x49fc0
leaq 0x37d87(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x39445(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x642, %esi            # imm = 0x642
callq 0x5750
movq %rax, %rdi
movq 0x42c1f(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x392fd(%rip), %rdi     # 0x4066a
leaq 0x37d49(%rip), %rsi     # 0x3f0bd
movl $0x642, %edx            # imm = 0x642
leaq 0x37df3(%rip), %rcx     # 0x3f173
callq 0x51e0
testb $0x1, -0x51(%rbp)
je 0x763f
movq -0xa0(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdx
movl 0x88(%rdx), %edx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x7501
movq 0x42bdf(%rip), %rdi     # 0x49fc0
leaq 0x37d31(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
movq -0x78(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37d2c(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x113ce(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x78(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x113e3(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x37cf8(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37cd8(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x1137a(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1138f(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x3a128(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x42ae1(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x42b15(%rip), %rdi     # 0x49fc0
leaq 0x37c0b(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x392c9(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x649, %esi            # imm = 0x649
callq 0x5750
movq %rax, %rdi
movq 0x42aa3(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x39181(%rip), %rdi     # 0x4066a
leaq 0x37bcd(%rip), %rsi     # 0x3f0bd
movl $0x649, %edx            # imm = 0x649
leaq 0x37c77(%rip), %rcx     # 0x3f173
callq 0x51e0
movq -0x80(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x7636
movq 0x42aaa(%rip), %rdi     # 0x49fc0
leaq 0x37bfc(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
movq -0x80(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37bf7(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11299(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x80(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x112ae(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x37bc3(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37ba3(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11245(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1125a(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x39ff3(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x429ac(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x429e0(%rip), %rdi     # 0x49fc0
leaq 0x37ad6(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x39194(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x64a, %esi            # imm = 0x64A
callq 0x5750
movq %rax, %rdi
movq 0x4296e(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x3904c(%rip), %rdi     # 0x4066a
leaq 0x37a98(%rip), %rsi     # 0x3f0bd
movl $0x64a, %edx            # imm = 0x64A
leaq 0x37b42(%rip), %rcx     # 0x3f173
callq 0x51e0
movb $0x0, -0x51(%rbp)
jmp 0x783a
movq -0xa0(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %rdx
movl 0x88(%rdx), %edx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rcx
movb $0x1, %al
cmpq -0x30(%rbp), %rcx
movb %al, -0xbd(%rbp)
je 0x76bb
movq -0x90(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
sete %al
movb %al, -0xbd(%rbp)
movb -0xbd(%rbp), %al
testb $0x1, %al
jne 0x76c7
jmp 0x76c9
jmp 0x76e8
leaq 0x37af1(%rip), %rdi     # 0x3f1c1
leaq 0x379e6(%rip), %rsi     # 0x3f0bd
movl $0x652, %edx            # imm = 0x652
leaq 0x37a90(%rip), %rcx     # 0x3f173
callq 0x51e0
movq -0x98(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x7826
movq 0x428c0(%rip), %rdi     # 0x49fc0
leaq 0x37a12(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
movq -0x98(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x37a0a(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x110ac(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x98(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x110be(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x379d3(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x379b3(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x11055(%rip), %rsi     # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1106a(%rip), %rsi     # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x39e03(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x427bc(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x427f0(%rip), %rdi     # 0x49fc0
leaq 0x378e6(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x38fa4(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x653, %esi            # imm = 0x653
callq 0x5750
movq %rax, %rdi
movq 0x4277e(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x38e5c(%rip), %rdi     # 0x4066a
leaq 0x378a8(%rip), %rsi     # 0x3f0bd
movl $0x653, %edx            # imm = 0x653
leaq 0x37952(%rip), %rcx     # 0x3f173
callq 0x51e0
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movb $0x1, -0x51(%rbp)
movq -0x50(%rbp), %rax
movl 0x84(%rax), %eax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x6e97
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)