// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/eis-bwtseq.c
// Function: getMatchBound
static inline void
getMatchBound(const BWTSeq *bwtSeq, const Symbol *query, size_t queryLen,
              struct matchBound *match, bool forward)
{
  const Symbol *qptr, *qend;
  unsigned int cc;
  const Mbtab *mbptr;
  GtPrebwtstate prebwt;

  gt_assert(bwtSeq && query);
  if (forward)
  {
    qptr = query;
    qend = query + queryLen;
  } else
  {
    qptr = query + queryLen - 1;
    qend = query - 1;
  }
  gt_assert(GT_ISNOTSPECIAL(*qptr));
  cc = (unsigned int) *qptr;
  prebwt.mbtab = gt_bwtseq2mbtab((const FMindex *) bwtSeq);
  if (prebwt.mbtab != NULL)
  {
    prebwt.numofchars = gt_bwtseq2numofchars((const FMindex *) bwtSeq);
    prebwt.maxdepth = gt_bwtseq2maxdepth((const FMindex *) bwtSeq);
    prebwt.code = 0;
    prebwt.depth = 0;
    mbptr = gt_prebwt_next(&prebwt,cc);
    match->start = mbptr->lowerbound;
    match->end = mbptr->upperbound;
  } else
  {
    prebwt.numofchars = GT_UNDEF_UINT;
    prebwt.maxdepth = GT_UNDEF_UINT;
    prebwt.code = 0;
    prebwt.depth = GT_UNDEF_UINT;
    match->start = bwtSeq->count[cc];
    match->end   = bwtSeq->count[cc + 1];
  }
  qptr = forward ? (qptr+1) : (qptr-1);
  while (match->start < match->end && qptr != qend)
  {
    GtUwordPair occPair;

    gt_assert(GT_ISNOTSPECIAL(*qptr));
    cc = (unsigned int) *qptr;
    if (prebwt.mbtab != NULL && prebwt.depth < prebwt.maxdepth)
    {
      mbptr = gt_prebwt_next(&prebwt,cc);
      match->start = mbptr->lowerbound;
      match->end = mbptr->upperbound;
    } else
    {
      occPair = BWTSeqTransformedPosPairOcc(bwtSeq, (Symbol) cc, match->start,
                                            match->end);
      match->start = bwtSeq->count[cc] + occPair.a;
      match->end   = bwtSeq->count[cc] + occPair.b;
    }
    qptr = forward ? (qptr+1) : (qptr-1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testq %rdi, %rdi
je 0x19c20b
testq %rsi, %rsi
je 0x19c20b
movl %r8d, %r12d
leaq (%rsi,%rdx), %rax
leaq (%rsi,%rdx), %r13
decq %r13
leaq -0x1(%rsi), %r14
testb %r12b, %r12b
cmovneq %rax, %r14
cmovneq %rsi, %r13
movzbl (%r13), %ebp
cmpq $0xfe, %rbp
jae 0x19c210
movq %rcx, %rbx
movq %rdi, %r15
callq 0x1a0058
testq %rax, %rax
movq %r15, 0x30(%rsp)
movq %rax, 0x18(%rsp)
je 0x19c0e3
movq %r15, %rdi
callq 0x1a008e
movl %r12d, 0x8(%rsp)
movl %eax, %r12d
movq %r15, %rdi
callq 0x1a0073
movq 0x18(%rsp), %rdi
movl %eax, 0x4(%rsp)
movq 0x8(%rdi), %rax
movl %ebp, %edx
shll $0x4, %edx
leaq (%rax,%rdx), %rcx
movq (%rax,%rdx), %rax
movq %rax, (%rbx)
movl %r12d, %edx
movl 0x8(%rsp), %r12d
movq %rdx, 0x10(%rsp)
movl $0x1, %r15d
jmp 0x19c10e
movq %rax, %rdi
movq 0x38(%r15), %rax
leaq (%rax,%rbp,8), %rcx
movq (%rcx), %rax
movq %rax, (%rbx)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, 0x10(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rbx)
movzbl %r12b, %r9d
decq %r9
orq $0x1, %r9
leaq (%r9,%r13), %rdx
cmpq %rcx, %rax
setb %sil
cmpq %r14, %rdx
setne %dl
andb %sil, %dl
cmpb $0x1, %dl
jne 0x19c1f7
leaq (%r9,%r9), %rsi
movq %r14, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movzbl (%r13,%r9), %r12d
cmpq $0xfe, %r12
jae 0x19c206
testq %rdi, %rdi
je 0x19c194
cmpl 0x4(%rsp), %r15d
jae 0x19c194
imulq 0x10(%rsp), %rbp
addq %r12, %rbp
movl %r15d, %eax
incl %r15d
movq 0x8(%rdi,%rax,8), %rcx
movq %rbp, %rdx
shlq $0x4, %rdx
movq (%rcx,%rdx), %rax
movq %rax, (%rbx)
movq 0x8(%rcx,%rdx), %rcx
jmp 0x19c1de
movq %rbp, 0x8(%rsp)
movq %rbx, %r14
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %esi
movq %rax, %rdx
movq %r9, %rbp
callq 0x19be96
movq %rbp, %r9
movq 0x18(%rsp), %rdi
movq 0x38(%rbx), %rsi
movq %r14, %rbx
movq 0x28(%rsp), %r14
movq 0x8(%rsp), %rbp
addq (%rsi,%r12,8), %rax
movq %rdx, %rcx
movq %rax, (%rbx)
addq (%rsi,%r12,8), %rcx
movq 0x20(%rsp), %rsi
movq %rcx, 0x8(%rbx)
cmpq %rcx, %rax
jae 0x19c1f7
leaq (%rsi,%r13), %rdx
addq %r9, %r13
cmpq %r14, %rdx
jne 0x19c14c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5fa36
callq 0x5f9c4
callq 0x5f9fd