// File: BenLangmead[P]bowtie/./blockwise_sa.h
// Function: KarkkainenBlockwiseSA<SString<char>>::tieBreakingLcp(unsigned int, unsigned int, unsigned int&, bool&)
inline
bool KarkkainenBlockwiseSA<TStr>::tieBreakingLcp(TIndexOffU aOff,
						 TIndexOffU bOff,
						 TIndexOffU& lcp,
						 bool& lcpIsSoft)
{
	const TStr& t = this->text();
	TIndexOffU c = 0;
	TIndexOffU tlen = TIndexOffU(t.length());
	assert_leq(aOff, tlen);
	assert_leq(bOff, tlen);
	assert(_dc != NULL);
	uint32_t dcDist = _dc->tieBreakOff(aOff, bOff);
	lcpIsSoft = false; // hard until proven soft
	while(c < dcDist &&    // we haven't hit the tie breaker
	      c < tlen-aOff && // we haven't fallen off of LHS suffix
	      c < tlen-bOff && // we haven't fallen off of RHS suffix
	      t[aOff+c] == t[bOff+c]) // we haven't hit a mismatch
		c++;
	lcp = c;
	if(c == tlen-aOff) {
		// Fell off LHS (a), a is greater
		return false;
	} else if(c == tlen-bOff) {
		// Fell off RHS (b), b is greater
		return true;
	} else if(c == dcDist) {
		// Hit a tie-breaker element
		lcpIsSoft = true;
		assert_neq(dcDist, 0xffffffff);
		return _dc->breakTie(aOff+c, bOff+c) < 0;
	} else {
		assert_neq(t[aOff+c], t[bOff+c]);
		return t[aOff+c] < t[bOff+c];
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x48(%rbp)
callq 0x271c0
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x30(%rbp), %rdi
callq 0x14c10
movq %rax, %rcx
movq -0x48(%rbp), %rax
movl %ecx, -0x38(%rbp)
movq 0x78(%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x30b20
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movl -0x34(%rbp), %ecx
xorl %eax, %eax
cmpl -0x3c(%rbp), %ecx
movb %al, -0x49(%rbp)
jae 0x30a4c
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %edx
subl -0x14(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x49(%rbp)
jae 0x30a4c
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %edx
subl -0x18(%rbp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x49(%rbp)
jae 0x30a4c
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x14c30
movsbl (%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x14c30
movq %rax, %rcx
movl -0x50(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x30a55
jmp 0x30a63
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x309de
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
movl -0x38(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jne 0x30a82
movb $0x0, -0x1(%rbp)
jmp 0x30b0a
movl -0x34(%rbp), %eax
movl -0x38(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jne 0x30a95
movb $0x1, -0x1(%rbp)
jmp 0x30b0a
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jne 0x30acb
movq -0x48(%rbp), %rax
movq -0x28(%rbp), %rcx
movb $0x1, (%rcx)
movq 0x78(%rax), %rdi
movl -0x14(%rbp), %esi
addl -0x34(%rbp), %esi
movl -0x18(%rbp), %edx
addl -0x34(%rbp), %edx
callq 0x30cb0
cmpq $0x0, %rax
setl %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x30b0a
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x14c30
movsbl (%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x14c30
movq %rax, %rcx
movl -0x54(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop