// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/eis-bwtseq.c
// Function: gt_packedindexmstatsforward
GtUword gt_packedindexmstatsforward(const BWTSeq *bwtSeq,
                                       GtUword *witnessleftbound,
                                       const GtUchar *qstart,
                                       const GtUchar *qend)
{
  GtUchar cc;
  const GtUchar *qptr;
  GtUword prevlbound;
  struct matchBound bwtbound;
  GtUwordPair seqpospair;
  Symbol curSym;
  GtUword matchlength;
  const MRAEnc *alphabet;

  gt_assert(bwtSeq && qstart && qstart < qend);
  alphabet = BWTSeqGetAlphabet(bwtSeq);
  qptr = qstart;
  cc = *qptr;
#undef SKDEBUG
#ifdef SKDEBUG
  printf("# start cc=%u\n",cc);
#endif
  if (GT_ISSPECIAL(cc))
  {
    return 0;
  }
  curSym = MRAEncMapSymbol(alphabet, cc);
  bwtbound.start = bwtSeq->count[curSym];
  bwtbound.end = bwtSeq->count[curSym+1];
  if (bwtbound.start >= bwtbound.end)
  {
    return 0;
  }
#ifdef SKDEBUG
  printf("# bounds="GT_WU","GT_WU" = "GT_WU""
          "occurrences\n",
         bwtbound.start,
         bwtbound.end,
         bwtbound.end - bwtbound.start);
#endif
  prevlbound = bwtbound.start;
  for (qptr++; qptr < qend; qptr++)
  {
    cc = *qptr;
#ifdef SKDEBUG
    printf("# cc=%u\n",cc);
#endif
    if (GT_ISSPECIAL (cc))
    {
      break;
    }
    curSym = MRAEncMapSymbol(alphabet, cc);
    seqpospair = BWTSeqTransformedPosPairOcc(bwtSeq, curSym,
                                             bwtbound.start,bwtbound.end);
    bwtbound.start = bwtSeq->count[curSym] + seqpospair.a;
    bwtbound.end = bwtSeq->count[curSym] + seqpospair.b;
#ifdef SKDEBUG
    printf("# bounds="GT_WU","GT_WU" = "GT_WU""
            "occurrences\n",
           bwtbound.start,
           bwtbound.end,
           bwtbound.end - bwtbound.start);
#endif
    if (bwtbound.start >= bwtbound.end)
    {
      break;
    }
    prevlbound = bwtbound.start;
  }
  matchlength = (GtUword) (qptr - qstart);
  if (witnessleftbound != NULL)
  {
    *witnessleftbound = prevlbound;
  }
  return matchlength;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, (%rsp)
testq %rdi, %rdi
je 0x146e79
movq %rdx, %r15
testq %rdx, %rdx
je 0x146e79
cmpq (%rsp), %r15
jae 0x146e79
movb (%r15), %al
cmpb $-0x3, %al
ja 0x146e65
movq %rsi, %r14
movq %rdi, %r12
movq 0x8(%rdi), %rdi
movzbl %al, %esi
movq %rdi, 0x10(%rsp)
callq 0x146cd2
movq 0x38(%r12), %rcx
movzbl %al, %edx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rbx
cmpq %rbx, %rax
jae 0x146e65
movq %r14, 0x8(%rsp)
pushq $0x1
popq %rcx
movq %rax, %r13
movq %rcx, %rbp
leaq (%r15,%rcx), %rax
cmpq (%rsp), %rax
jae 0x146e56
movb (%rax), %al
cmpb $-0x3, %al
ja 0x146e56
movzbl %al, %esi
movq 0x10(%rsp), %rdi
callq 0x146cd2
movzbl %al, %r14d
movq %r12, %rdi
movl %r14d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x146cf8
movq %rdx, %rbx
movq 0x38(%r12), %rcx
movq (%rcx,%r14,8), %rcx
addq %rcx, %rax
addq %rcx, %rbx
leaq 0x1(%rbp), %rcx
cmpq %rbx, %rax
jb 0x146e03
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x146e67
movq %r13, (%rax)
jmp 0x146e67
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2f10e8(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x19e189(%rip), %rsi    # 0x2e5013
leaq 0x1fc313(%rip), %rdx    # 0x3431a4
leaq 0x1fc32e(%rip), %rcx    # 0x3431c6
leaq 0x1fc2c1(%rip), %r8     # 0x343160
movl $0x12f, %r9d            # imm = 0x12F
xorl %eax, %eax
callq 0x17a50
callq 0x17390