// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-bwtseq-extinfo.c
// Function: gt_BWTSeqLocateMatch
GtUword
gt_BWTSeqLocateMatch(const BWTSeq *bwtSeq, GtUword pos,
                  struct extBitsRetrieval *extBits)
{
  if (bwtSeq->featureToggles & BWTLocateBitmap)
  {
    GtUword nextLocate = pos;
    unsigned locateOffset = 0;
    while (!gt_BWTSeqPosHasLocateInfo(bwtSeq, nextLocate, extBits))
      nextLocate = BWTSeqLFMap(bwtSeq, nextLocate, extBits), ++locateOffset;
    EISRetrieveExtraBits(bwtSeq->seqIdx, nextLocate,
                         EBRF_RETRIEVE_CWBITS | EBRF_RETRIEVE_VARBITS,
                         extBits, bwtSeq->hint);
    {
      GtUword maxPosVal = ((bwtSeq->featureToggles & BWTReversiblySorted)?
                          (BWTSeqLength(bwtSeq) - 1)
                          /bwtSeq->locateSampleInterval:
                          BWTSeqLength(bwtSeq) - 1);
      unsigned bitsPerCount = requiredUlongBits(extBits->len),
        bitsPerBWTPos = requiredUlongBits(extBits->len - 1),
        bitsPerOrigPos = requiredUlongBits(maxPosVal);
      BitOffset locateRecordIndex =
        gt_bs1BitsCount(extBits->cwPart, extBits->cwOffset,
                     nextLocate - extBits->start),
        locateRecordOffset = ((bwtSeq->featureToggles & BWTLocateCount?
                               bitsPerBWTPos:0) + bitsPerOrigPos)
        * locateRecordIndex
        + ((bwtSeq->featureToggles & BWTLocateCount)?bitsPerCount:0);
      GtUword matchPos =
        gt_bsGetUlong(
          extBits->varPart, extBits->varOffset + locateRecordOffset
          + ((bwtSeq->featureToggles & BWTLocateCount)?bitsPerBWTPos:0),
          bitsPerOrigPos);
      if (bwtSeq->featureToggles & BWTReversiblySorted)
        matchPos = matchPos * bwtSeq->locateSampleInterval;
      matchPos += locateOffset;
      gt_assert(!(bwtSeq->featureToggles & BWTLocateCount)
             || gt_bsGetUlong(extBits->varPart,
                            extBits->varOffset + locateRecordOffset,
                            bitsPerBWTPos)
             == nextLocate - extBits->start);
      return matchPos;
    }
  }
  else if (bwtSeq->featureToggles & BWTLocateCount)
  {
    BitOffset markOffset;
    GtUword nextLocate = pos, matchPos;
    unsigned locateOffset = 0;  /* mark is at most locateInterval
                                 * positions away */
    unsigned bitsPerOrigPos
      = requiredUlongBits(((bwtSeq->featureToggles & BWTReversiblySorted)?
                            (BWTSeqLength(bwtSeq) - 1)
                            /bwtSeq->locateSampleInterval:
                            BWTSeqLength(bwtSeq) - 1));
    while ((markOffset = searchLocateCountMark(bwtSeq, nextLocate,
                                               extBits)) == 0)
    {
      nextLocate = BWTSeqLFMap(bwtSeq, nextLocate, extBits);
      ++locateOffset;
      gt_assert(locateOffset <= BWTSeqLength(bwtSeq));
    }
    matchPos = gt_bsGetUlong(extBits->varPart, markOffset, bitsPerOrigPos);
    if (bwtSeq->featureToggles & BWTReversiblySorted)
        matchPos = matchPos * bwtSeq->locateSampleInterval;
    matchPos += locateOffset;
    return matchPos;
  }
  /* Internal error: Trying to locate in BWT sequence index without locate
     information. */
   abort();
   return 0; /* shut up compiler */
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2235bc
movq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl $0x0, 0x9c(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x222ea0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2232ac
jmp 0x2232e4
movq 0xb8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x223780
movq %rax, 0xa0(%rsp)
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x223281
movq 0xb8(%rsp), %rax
movq (%rax), %rdi
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rcx
movq 0xb8(%rsp), %rax
movq 0x18(%rax), %r8
movl $0x2, %edx
callq 0x222f70
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x223350
movq 0xb8(%rsp), %rdi
callq 0x223960
subq $0x1, %rax
movq 0xb8(%rsp), %rcx
movl 0x20(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x40(%rsp)
jmp 0x223366
movq 0xb8(%rsp), %rdi
callq 0x223960
subq $0x1, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x46ec80
movl %eax, 0x8c(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rdi
subq $0x1, %rdi
callq 0x46ec80
movl %eax, 0x88(%rsp)
movq 0x90(%rsp), %rdi
callq 0x46ec80
movl %eax, 0x84(%rsp)
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0xa8(%rsp), %rax
movq (%rax), %rsi
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rax
subq 0x10(%rax), %rdx
callq 0x4707b0
movq %rax, 0x78(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x223410
movl 0x88(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x223418
xorl %eax, %eax
movl %eax, 0x3c(%rsp)
jmp 0x223418
movl 0x3c(%rsp), %eax
addl 0x84(%rsp), %eax
movl %eax, %eax
imulq 0x78(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x223450
movl 0x8c(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x223458
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
jmp 0x223458
movq 0x30(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0xa8(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2234b2
movl 0x88(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x2234ba
xorl %eax, %eax
movl %eax, 0x14(%rsp)
jmp 0x2234ba
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x14(%rsp), %eax
movl %eax, %eax
addq %rax, %rsi
movl 0x84(%rsp), %edx
callq 0x476ec0
movq %rax, 0x68(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x22350a
movq 0x68(%rsp), %rax
movq 0xb8(%rsp), %rcx
movl 0x20(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x68(%rsp)
movl 0x9c(%rsp), %eax
addq 0x68(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2235a8
movq 0xa8(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rsi
addq 0x70(%rsp), %rsi
movl 0x88(%rsp), %edx
callq 0x476ec0
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rdx
subq 0x10(%rdx), %rcx
cmpq %rcx, %rax
je 0x2235a8
movq 0x418a29(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f2a92(%rip), %rsi    # 0x516013
leaq 0x3517fb(%rip), %rdx    # 0x574d83
leaq 0x351899(%rip), %rcx    # 0x574e28
leaq 0x3516fe(%rip), %r8     # 0x574c94
movl $0x2e5, %r9d            # imm = 0x2E5
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2235aa
movq 0x68(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x223769
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x223762
movq 0xb0(%rsp), %rax
movq %rax, 0x58(%rsp)
movl $0x0, 0x4c(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x223623
movq 0xb8(%rsp), %rdi
callq 0x223960
subq $0x1, %rax
movq 0xb8(%rsp), %rcx
movl 0x20(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x8(%rsp)
jmp 0x223639
movq 0xb8(%rsp), %rdi
callq 0x223960
subq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
callq 0x46ec80
movl %eax, 0x48(%rsp)
movq 0xb8(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x223070
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
jne 0x2236fa
movq 0xb8(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0x223780
movq %rax, 0x58(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movq %rax, (%rsp)
movq 0xb8(%rsp), %rdi
callq 0x223960
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jbe 0x2236f3
movq 0x4188de(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f2947(%rip), %rsi    # 0x516013
leaq 0x35176a(%rip), %rdx    # 0x574e3d
leaq 0x35174e(%rip), %rcx    # 0x574e28
leaq 0x3515b3(%rip), %r8     # 0x574c94
movl $0x2f9, %r9d            # imm = 0x2F9
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2236f5
jmp 0x223647
movq 0xa8(%rsp), %rax
movq 0x28(%rax), %rdi
movq 0x60(%rsp), %rsi
movl 0x48(%rsp), %edx
callq 0x476ec0
movq %rax, 0x50(%rsp)
movq 0xb8(%rsp), %rax
movl 0x40(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x223745
movq 0x50(%rsp), %rax
movq 0xb8(%rsp), %rcx
movl 0x20(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x50(%rsp)
movl 0x4c(%rsp), %eax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x223769
jmp 0x223764
callq 0x19370
movq 0xc0(%rsp), %rax
addq $0xc8, %rsp
retq
nopl (%rax)