// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-bwtseq-extinfo.c
// Function: addLocateInfo
static BitOffset
addLocateInfo(BitString cwDest, BitOffset cwOffset,
              BitString varDest, BitOffset varOffset,
              GT_UNUSED GtUword start, GtUword len, void *cbState)
{
  BitOffset bitsWritten = 0;
  struct addLocateInfoState *state = cbState;
  unsigned bitsPerBWTPos, bitsPerOrigPos, bitsPerOrigRank;
  int retcode;
  unsigned locateInterval;
  gt_assert(varDest && cbState);
  locateInterval = state->locateInterval;
  /* 0. resize caches if necessary */
  if (locateInterval && len > state->revMapQueueSize)
  {
    state->revMapQueue = gt_realloc(state->revMapQueue,
                                    len * sizeof (state->revMapQueue[0]));
    state->revMapQueueSize = len;
  }
  if (state->sprTable && len > state->origRanksQueueSize)
  {
    state->origRanksQueue = gt_realloc(state->origRanksQueue,
                                          len *
                                          sizeof (state->origRanksQueue[0]));
    state->origRanksQueueSize = len;
  }
  bitsPerBWTPos = requiredUlongBits(len - 1);
  bitsPerOrigPos = state->bitsPerOrigPos;
  bitsPerOrigRank = state->bitsPerOrigRank;
  {
    GtUword i, mapVal;
    size_t revMapQueueLen = 0, origRanksQueueLen = 0;
    int reversiblySorted = state->featureToggles & BWTReversiblySorted,
      locateBitmap = state->featureToggles & BWTLocateBitmap;
    /* read len suffix array indices from suftab */
    /* TODO: decide  on reasonable buffering of mapVal */
    for (i = 0; i < len; ++i)
    {
      /* add locate data if necessary */
      if (locateInterval)
      {
        int insertExtraLocateMark = 0;
        /* 1.a read array index*/
        if ((retcode = SDRRead(state->readUlong, &mapVal, 1)) != 1)
          return (BitOffset)-1;
        /* 1.b find current symbol and compare to special ranges */
        insertExtraLocateMark = !reversiblySorted &&
          isSortModeTransition(state->origSeqAccess, state->seqLen,
                               state->alphabet, state->rangeSort,
                               mapVal);
        /* 1.c check wether the index into the original sequence is an
         * even multiple of the sampling interval, or a not-reversible
         * sort mode transition occurred */
        if (!(mapVal % locateInterval) || insertExtraLocateMark)
        {
          /* 1.c.1 enter index into cache */
          state->revMapQueue[revMapQueueLen].bwtPos = i;
          state->revMapQueue[revMapQueueLen].origPos
            = reversiblySorted ? mapVal/state->locateInterval : mapVal;
          ++revMapQueueLen;
          /* 1.c.2 mark position in bwt sequence */
          if (locateBitmap)
            bsSetBit(cwDest, cwOffset + i);
        }
        else
          if (locateBitmap)
            gt_bsClearBit(cwDest, cwOffset + i);
      }
      /* and add data for extra sort information */
      if (bitsPerOrigRank)
      {
        Symbol BWTSym;
        const MRAEnc *alphabet = state->alphabet;
        if (mapVal != 0)
          accessSequence(state->origSeqAccess, &BWTSym, mapVal - 1, 1);
        else
          BWTSym = GT_UNDEFBWTCHAR;
        if (state->rangeSort[MRAEncGetRangeOfSymbol(
                alphabet, MRAEncMapSymbol(alphabet, BWTSym))]
            == SORTMODE_RANK)
        {
          state->origRanksQueue[origRanksQueueLen++] =
            specialsRank(state->sprTable,
                         mapVal != 0 ? mapVal - 1 : state->seqLen - 1);
        }
      }
      if (state->ctxFactory)
      {
        gt_BWTSCRFMapAdvance(state->ctxFactory, &mapVal, 1);
      }
    }
    /* 2. copy revMapQueue into output */
    if (locateInterval)
    {
      int locateCount = state->featureToggles & BWTLocateCount;
      if (locateCount)
      {
        unsigned bitsPerCount = requiredUlongBits(len);
        gt_bsStoreUlong(varDest, varOffset + bitsWritten, bitsPerCount,
                      revMapQueueLen);
        bitsWritten += bitsPerCount;
      }
      for (i = 0; i < revMapQueueLen; ++i)
      {
        if (locateCount)
        {
          gt_bsStoreUlong(varDest, varOffset + bitsWritten, bitsPerBWTPos,
                        state->revMapQueue[i].bwtPos);
          bitsWritten += bitsPerBWTPos;
        }
        gt_bsStoreUlong(varDest, varOffset + bitsWritten, bitsPerOrigPos,
                      state->revMapQueue[i].origPos);
        bitsWritten += bitsPerOrigPos;
      }
    }
    if (bitsPerOrigRank)
    {
      unsigned bitsPerOrigRank = state->bitsPerOrigRank;
      if (origRanksQueueLen)
      {
        gt_bsStoreUniformUlongArray(varDest, varOffset + bitsWritten,
                                  bitsPerOrigRank, origRanksQueueLen,
#if defined (_LP64) || defined (_WIN64)
                             (uint64_t*) state->origRanksQueue);
#else
                             (uint32_t*) state->origRanksQueue);
#endif
        bitsWritten += bitsPerOrigRank * origRanksQueueLen;
      }
    }
  }
  return bitsWritten;
}

// Assembly:
subq $0xd8, %rsp
movq 0xe0(%rsp), %rax
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
movq %r8, 0xa8(%rsp)
movq %r9, 0xa0(%rsp)
movq $0x0, 0x98(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, 0xb8(%rsp)
je 0x2224a1
cmpq $0x0, 0xe0(%rsp)
jne 0x2224d9
movq 0x419af8(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f3b61(%rip), %rsi    # 0x516013
leaq 0x352ae1(%rip), %rdx    # 0x574f9a
leaq 0x352aed(%rip), %rcx    # 0x574fad
leaq 0x3527cd(%rip), %r8     # 0x574c94
movl $0x18a, %r9d            # imm = 0x18A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2224db
movq 0x90(%rsp), %rax
movl 0x40(%rax), %eax
movl %eax, 0x7c(%rsp)
cmpl $0x0, 0x7c(%rsp)
je 0x222553
movq 0xa0(%rsp), %rax
movq 0x90(%rsp), %rcx
cmpq 0x60(%rcx), %rax
jbe 0x222553
movq 0x90(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0xa0(%rsp), %rsi
shlq $0x4, %rsi
leaq 0x35276e(%rip), %rdx    # 0x574c94
movl $0x190, %ecx            # imm = 0x190
callq 0xe8540
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0xa0(%rsp), %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x60(%rax)
movq 0x90(%rsp), %rax
cmpq $0x0, 0x50(%rax)
je 0x2225c4
movq 0xa0(%rsp), %rax
movq 0x90(%rsp), %rcx
cmpq 0x70(%rcx), %rax
jbe 0x2225c4
movq 0x90(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0xa0(%rsp), %rsi
shlq $0x3, %rsi
leaq 0x3526fd(%rip), %rdx    # 0x574c94
movl $0x197, %ecx            # imm = 0x197
callq 0xe8540
movq %rax, %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0xa0(%rsp), %rcx
movq 0x90(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0xa0(%rsp), %rdi
subq $0x1, %rdi
callq 0x46ec80
movl %eax, 0x8c(%rsp)
movq 0x90(%rsp), %rax
movl 0x44(%rax), %eax
movl %eax, 0x88(%rsp)
movq 0x90(%rsp), %rax
movl 0x4c(%rax), %eax
movl %eax, 0x84(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq 0x90(%rsp), %rax
movl 0x58(%rax), %eax
andl $0x4, %eax
movl %eax, 0x54(%rsp)
movq 0x90(%rsp), %rax
movl 0x58(%rax), %eax
andl $0x1, %eax
movl %eax, 0x50(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jae 0x222939
cmpl $0x0, 0x7c(%rsp)
je 0x2227e5
movl $0x0, 0x4c(%rsp)
movq 0x90(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x28(%rax), %rsi
leaq 0x68(%rsp), %rdx
movl $0x1, %ecx
callq 0x224250
movl %eax, 0x80(%rsp)
cmpl $0x1, %eax
je 0x2226a1
movq $-0x1, 0xd0(%rsp)
jmp 0x222b09
xorl %eax, %eax
cmpl $0x0, 0x54(%rsp)
movb %al, 0x33(%rsp)
jne 0x2226f5
movq 0x90(%rsp), %rax
movq 0x90(%rsp), %rcx
movq (%rcx), %rdx
movq 0x90(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq 0x90(%rsp), %rsi
movq 0x18(%rsi), %r8
movq 0x68(%rsp), %r9
movq 0x30(%rax), %rdi
movq 0x38(%rax), %rsi
callq 0x224290
cmpl $0x0, %eax
setne %al
movb %al, 0x33(%rsp)
movb 0x33(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x4c(%rsp)
movq 0x68(%rsp), %rax
movl 0x7c(%rsp), %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
je 0x222721
cmpl $0x0, 0x4c(%rsp)
je 0x2227c0
movq 0x70(%rsp), %rcx
movq 0x90(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x60(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
cmpl $0x0, 0x54(%rsp)
je 0x222764
movq 0x68(%rsp), %rax
movq 0x90(%rsp), %rcx
movl 0x40(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x28(%rsp)
jmp 0x22276e
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rcx
movq 0x90(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x60(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
cmpl $0x0, 0x50(%rsp)
je 0x2227be
movq 0xc8(%rsp), %rdi
movq 0xc0(%rsp), %rsi
addq 0x70(%rsp), %rsi
callq 0x2244a0
jmp 0x2227e3
cmpl $0x0, 0x50(%rsp)
je 0x2227e1
movq 0xc8(%rsp), %rdi
movq 0xc0(%rsp), %rsi
addq 0x70(%rsp), %rsi
callq 0x224540
jmp 0x2227e3
jmp 0x2227e5
cmpl $0x0, 0x84(%rsp)
je 0x2228f4
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x222837
movq 0x90(%rsp), %rax
movq 0x68(%rsp), %rcx
subq $0x1, %rcx
movq 0x30(%rax), %rdi
movq 0x38(%rax), %rsi
leaq 0x4b(%rsp), %rdx
movl $0x1, %r8d
callq 0x2245e0
jmp 0x22283c
movb $-0x2, 0x4b(%rsp)
movq 0x90(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movzbl 0x4b(%rsp), %esi
callq 0x2241b0
movq 0x18(%rsp), %rdi
movzbl %al, %esi
callq 0x224620
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, %ecx
cmpl $0x2, (%rax,%rcx,4)
jne 0x2228f2
movq 0x90(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x2228ab
movq 0x68(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x2228bf
movq 0x90(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x221e70
movq %rax, %rdx
movq 0x90(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x58(%rsp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x58(%rsp)
movq %rdx, (%rax,%rcx,8)
jmp 0x2228f4
movq 0x90(%rsp), %rax
cmpq $0x0, 0x80(%rax)
je 0x222924
movq 0x90(%rsp), %rax
movq 0x80(%rax), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0x21f9b0
jmp 0x222926
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x22263f
cmpl $0x0, 0x7c(%rsp)
je 0x222a8a
movq 0x90(%rsp), %rax
movl 0x58(%rax), %eax
andl $0x2, %eax
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x2229a8
movq 0xa0(%rsp), %rdi
callq 0x46ec80
movl %eax, 0x38(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
addq 0x98(%rsp), %rsi
movl 0x38(%rsp), %edx
movq 0x60(%rsp), %rcx
callq 0x4770f0
movl 0x38(%rsp), %eax
addq 0x98(%rsp), %rax
movq %rax, 0x98(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x60(%rsp), %rax
jae 0x222a88
cmpl $0x0, 0x3c(%rsp)
je 0x222a1e
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
addq 0x98(%rsp), %rsi
movl 0x8c(%rsp), %edx
movq 0x90(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x70(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
callq 0x4770f0
movl 0x8c(%rsp), %eax
addq 0x98(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
addq 0x98(%rsp), %rsi
movl 0x88(%rsp), %edx
movq 0x90(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x70(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
callq 0x4770f0
movl 0x88(%rsp), %eax
addq 0x98(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x2229b1
jmp 0x222a8a
cmpl $0x0, 0x84(%rsp)
je 0x222af9
movq 0x90(%rsp), %rax
movl 0x4c(%rax), %eax
movl %eax, 0x34(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0x222af7
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
addq 0x98(%rsp), %rsi
movl 0x34(%rsp), %edx
movq 0x58(%rsp), %rcx
movq 0x90(%rsp), %rax
movq 0x78(%rax), %r8
callq 0x4780f0
movl 0x34(%rsp), %eax
imulq 0x58(%rsp), %rax
addq 0x98(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x222af9
movq 0x98(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
addq $0xd8, %rsp
retq
nopl (%rax)