// File: BenLangmead[P]bowtie/./ebwt.h
// Function: Ebwt::countBt2Side(SideLocus const&, int) const
inline TIndexOffU Ebwt::countBt2Side(const SideLocus& l, int c) const {
	assert_range(0, 3, c);
	assert_range(0, (int)this->_eh._sideBwtSz-1, (int)l._by);
	assert_range(0, 3, (int)l._bp);
	const uint8_t *side = l.side(this->ebwt());
	TIndexOffU cCnt = countUpTo(l, c);
	assert_leq(cCnt, this->_eh._sideBwtLen);
	if(c == 0 && l._sideByteOff <= _zEbwtByteOff && l._sideByteOff + l._by >= _zEbwtByteOff) {
		// Adjust for the fact that we represented $ with an 'A', but
		// shouldn't count it as an 'A' here
		if((l._sideByteOff + l._by > _zEbwtByteOff) ||
		   (l._sideByteOff + l._by == _zEbwtByteOff && l._bp > _zEbwtBpOff))
		{
			cCnt--; // Adjust for '$' looking like an 'A'
		}
	}
	TIndexOffU ret;
	// Now factor in the occ[] count at the side break
	const uint8_t *acgt8 = side + _eh._sideBwtSz;
	const TIndexOffU *acgt = reinterpret_cast<const TIndexOffU*>(acgt8);
	assert_leq(acgt[0], this->_eh._numSides * this->_eh._sideBwtLen); // b/c it's used as padding
	assert_leq(acgt[1], this->_eh._len);
	assert_leq(acgt[2], this->_eh._len);
	assert_leq(acgt[3], this->_eh._len);
	ret = acgt[c] + cCnt + this->fchr()[c];
#ifndef NDEBUG
	assert_leq(ret, this->fchr()[c+1]); // can't have jumpded into next char's section
	if(c == 0) {
		assert_leq(cCnt, this->_eh._sideBwtLen);
	} else {
		assert_leq(ret, this->_eh._bwtLen);
	}
#endif
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x3, -0x1c(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq 0x1ad4e(%rip), %rcx     # 0x3f0bd
movl $0x8c1, %r8d            # imm = 0x8C1
callq 0xf360
movq -0x68(%rbp), %rax
movl $0x0, -0x20(%rbp)
movl 0x190(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movswl 0x14(%rax), %eax
movl %eax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq 0x1ad0e(%rip), %rcx     # 0x3f0bd
movl $0x8c2, %r8d            # imm = 0x8C2
callq 0xf360
movl $0x0, -0x2c(%rbp)
movl $0x3, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsbl 0x16(%rax), %eax
movl %eax, -0x34(%rbp)
leaq -0x2c(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x34(%rbp), %rdx
leaq 0x1acd7(%rip), %rcx     # 0x3f0bd
movl $0x8c3, %r8d            # imm = 0x8C3
callq 0xf360
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x1a9b0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x23610
movq -0x68(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x264d0
movq -0x68(%rbp), %rcx
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x194(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x244f8
movq 0x25b7c(%rip), %rdi     # 0x49fc0
leaq 0x1ad58(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1ad54(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movl 0x194(%rax), %esi
callq 0x5530
movq %rax, %rdi
leaq 0x1d131(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x25aea(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x25b1e(%rip), %rdi     # 0x49fc0
leaq 0x1ac14(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1c2d2(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8c6, %esi            # imm = 0x8C6
callq 0x5750
movq %rax, %rdi
movq 0x25aac(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1c18a(%rip), %rdi     # 0x4066a
leaq 0x1abd6(%rip), %rsi     # 0x3f0bd
movl $0x8c6, %edx            # imm = 0x8C6
leaq 0x1bcc8(%rip), %rcx     # 0x401bb
callq 0x51e0
cmpl $0x0, -0x14(%rbp)
jne 0x2458b
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq 0x70(%rcx), %rax
ja 0x2458b
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdx
movswq 0x14(%rdx), %rdx
addq %rdx, %rax
cmpq 0x70(%rcx), %rax
jb 0x2458b
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdx
movswq 0x14(%rdx), %rdx
addq %rdx, %rax
cmpq 0x70(%rcx), %rax
ja 0x2457d
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdx
movswq 0x14(%rdx), %rdx
addq %rdx, %rax
cmpq 0x70(%rcx), %rax
jne 0x24589
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
movsbq 0x16(%rax), %rax
cmpq 0x78(%rcx), %rax
jle 0x24589
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2458b
movq -0x68(%rbp), %rdx
movq -0x40(%rbp), %rax
movl 0x190(%rdx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq (%rax), %rax
movq 0x1a0(%rdx), %rcx
movl 0x194(%rdx), %edx
imulq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x24692
movq 0x259f0(%rip), %rdi     # 0x49fc0
leaq 0x1abcc(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1abc5(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq 0x1a0(%rax), %rsi
movl 0x194(%rax), %eax
imulq %rax, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1cf97(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x25950(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x25984(%rip), %rdi     # 0x49fc0
leaq 0x1aa7a(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1c138(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8d4, %esi            # imm = 0x8D4
callq 0x5750
movq %rax, %rdi
movq 0x25912(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1bff0(%rip), %rdi     # 0x4066a
leaq 0x1aa3c(%rip), %rsi     # 0x3f0bd
movl $0x8d4, %edx            # imm = 0x8D4
leaq 0x1bb2e(%rip), %rcx     # 0x401bb
callq 0x51e0
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
cmpq 0x108(%rcx), %rax
jbe 0x2476b
movq 0x2590e(%rip), %rdi     # 0x49fc0
leaq 0x1aaea(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1aae2(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1cebe(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x25877(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x258ab(%rip), %rdi     # 0x49fc0
leaq 0x1a9a1(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1c05f(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8d5, %esi            # imm = 0x8D5
callq 0x5750
movq %rax, %rdi
movq 0x25839(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1bf17(%rip), %rdi     # 0x4066a
leaq 0x1a963(%rip), %rsi     # 0x3f0bd
movl $0x8d5, %edx            # imm = 0x8D5
leaq 0x1ba55(%rip), %rcx     # 0x401bb
callq 0x51e0
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
cmpq 0x108(%rcx), %rax
jbe 0x24844
movq 0x25835(%rip), %rdi     # 0x49fc0
leaq 0x1aa11(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1aa09(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1cde5(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x2579e(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x257d2(%rip), %rdi     # 0x49fc0
leaq 0x1a8c8(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1bf86(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8d6, %esi            # imm = 0x8D6
callq 0x5750
movq %rax, %rdi
movq 0x25760(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1be3e(%rip), %rdi     # 0x4066a
leaq 0x1a88a(%rip), %rsi     # 0x3f0bd
movl $0x8d6, %edx            # imm = 0x8D6
leaq 0x1b97c(%rip), %rcx     # 0x401bb
callq 0x51e0
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
cmpq 0x108(%rcx), %rax
jbe 0x2491d
movq 0x2575c(%rip), %rdi     # 0x49fc0
leaq 0x1a938(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1a930(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq 0x108(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1cd0c(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x256c5(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x256f9(%rip), %rdi     # 0x49fc0
leaq 0x1a7ef(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1bead(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8d7, %esi            # imm = 0x8D7
callq 0x5750
movq %rax, %rdi
movq 0x25687(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1bd65(%rip), %rdi     # 0x4066a
leaq 0x1a7b1(%rip), %rsi     # 0x3f0bd
movl $0x8d7, %edx            # imm = 0x8D7
leaq 0x1b8a3(%rip), %rcx     # 0x401bb
callq 0x51e0
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
callq 0x26720
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movq -0x80(%rbp), %rax
movslq -0x14(%rbp), %rdx
addq (%rcx,%rdx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x26720
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
cmpq (%rcx,%rdx,8), %rax
jbe 0x24a4a
movq 0x25641(%rip), %rdi     # 0x49fc0
leaq 0x1a81d(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1a819(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq -0x68(%rbp), %rdi
movq %rax, -0x88(%rbp)
callq 0x26720
movq -0x88(%rbp), %rdi
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1cbdf(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x25598(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x255cc(%rip), %rdi     # 0x49fc0
leaq 0x1a6c2(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1bd80(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8da, %esi            # imm = 0x8DA
callq 0x5750
movq %rax, %rdi
movq 0x2555a(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1bc38(%rip), %rdi     # 0x4066a
leaq 0x1a684(%rip), %rsi     # 0x3f0bd
movl $0x8da, %edx            # imm = 0x8DA
leaq 0x1b776(%rip), %rcx     # 0x401bb
callq 0x51e0
cmpl $0x0, -0x14(%rbp)
jne 0x24b2b
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
movl 0x194(%rcx), %ecx
cmpq %rcx, %rax
jbe 0x24b26
movq 0x2554e(%rip), %rdi     # 0x49fc0
leaq 0x1a72a(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1a726(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movl 0x194(%rax), %esi
callq 0x5530
movq %rax, %rdi
leaq 0x1cb03(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x254bc(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x254f0(%rip), %rdi     # 0x49fc0
leaq 0x1a5e6(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1bca4(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8dc, %esi            # imm = 0x8DC
callq 0x5750
movq %rax, %rdi
movq 0x2547e(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1bb5c(%rip), %rdi     # 0x4066a
leaq 0x1a5a8(%rip), %rsi     # 0x3f0bd
movl $0x8dc, %edx            # imm = 0x8DC
leaq 0x1b69a(%rip), %rcx     # 0x401bb
callq 0x51e0
jmp 0x24bfe
movq -0x68(%rbp), %rcx
movq -0x50(%rbp), %rax
cmpq 0x110(%rcx), %rax
jbe 0x24bfc
movq 0x25479(%rip), %rdi     # 0x49fc0
leaq 0x1a655(%rip), %rsi     # 0x3f1a3
callq 0x5360
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1a651(%rip), %rsi     # 0x3f1ba
callq 0x5360
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq 0x110(%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x1ca2d(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x253e6(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x2541a(%rip), %rdi     # 0x49fc0
leaq 0x1a510(%rip), %rsi     # 0x3f0bd
callq 0x5360
movq %rax, %rdi
leaq 0x1bbce(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x8de, %esi            # imm = 0x8DE
callq 0x5750
movq %rax, %rdi
movq 0x253a8(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x1ba86(%rip), %rdi     # 0x4066a
leaq 0x1a4d2(%rip), %rsi     # 0x3f0bd
movl $0x8de, %edx            # imm = 0x8DE
leaq 0x1b5c4(%rip), %rcx     # 0x401bb
callq 0x51e0
jmp 0x24bfe
movq -0x50(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)