// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/eis-bwtseq-extinfo.c
// Function: gt_createBWTSeqGeneric
EISeq *
gt_createBWTSeqGeneric(const struct bwtParam *params,
                       indexCreateFunc createIndex,
                       SASeqSrc *src,
                       const enum rangeSortMode rangeSort[],
                       const SpecialsRankLookup *sprTable,
                       GtError *err)
{
  struct encIdxSeq *baseSeqIdx = NULL;
  struct addLocateInfoState varState;
  bool varStateIsInitialized = false;
  unsigned locateInterval;
  BWTSeqContextRetrieverFactory *buildContextMap = NULL;
  gt_assert(src && params && err);
  gt_error_check(err);
  locateInterval = params->locateInterval;
  do
  {
    struct locateHeaderWriteInfo locHeaderData
      = { src, locateInterval, params->featureToggles };
    struct sortModeHeader sortModeHeader;
    void *p[] = { &locHeaderData , &sortModeHeader };
    uint16_t headerIDs[] = { LOCATE_INFO_IN_INDEX_HEADERID,
                             RANK_SORT_HEADERID };
    uint32_t headerSizes[] = { LOCATE_HEADER_SIZE,
                               0 };
    headerWriteFunc headerFuncs[] = { writeLocateInfoHeader,
                                      writeRankSortHeader };
    size_t numHeaders = 0;
    unsigned bitsPerOrigRank = 0;
    GtUword totalLen = SASSGetLength(src);
    const MRAEnc *alphabet = SASSGetMRAEnc(src);
    MRAEnc *baseAlphabet = SASSNewMRAEnc(src);
    /* FIXME: this  has to work also when locateInterval == 0 and
     * sprTable != NULL */
    if (params->ctxMapILog != CTX_MAP_ILOG_NOMAP)
      buildContextMap = gt_newBWTSeqContextRetrieverFactory(totalLen,
                                                         params->ctxMapILog);
    if (locateInterval)
    {
      ++numHeaders;
      if (sortModeHeaderNeeded(alphabet, rangeSort, sprTable))
      {
        GtUword
#ifndef NDEBUG
          origSeqLen = gt_encseq_total_length(
                                                gt_SPRTGetOrigEncseq(sprTable)),
#endif
          maxRank;
        gt_assert(origSeqLen == totalLen - 1);
        maxRank = specialsRank(sprTable, totalLen - 1);
        bitsPerOrigRank = sortModeHeader.bitsPerOrigRank
          = requiredUlongBits(maxRank);
        sortModeHeader.alphabet = alphabet;
        sortModeHeader.rangeSort = rangeSort;
        headerSizes[1] = computeSortModeHeaderSize(alphabet);
        ++numHeaders;
      }
      {
        SeqDataReader readSfxIdx = SASSCreateReader(src, SFX_REQUEST_SUFTAB);
        if (SDRIsValid(readSfxIdx))
        {
          initAddLocateInfoState(
            &varState, SASSGetOrigSeqAccessor(src), readSfxIdx,
            alphabet, SASSGetSeqStats(src), rangeSort, totalLen, params,
            bitsPerOrigRank?sprTable:NULL, bitsPerOrigRank,
            buildContextMap);
          varStateIsInitialized = true;
        }
        else
        {
          gt_error_set(err, "error: locate sampling requested but not available"
                       " for project %s\n", gt_str_get(params->projectName));
        }
      }
    }
    if (!(baseSeqIdx
          = createIndex(totalLen, gt_str_get(params->projectName), baseAlphabet,
                        SASSGetSeqStats(src),
                        SASSCreateReader(src, SFX_REQUEST_BWTTAB),
                        &params->seqParams, numHeaders,
                        headerIDs, headerSizes, headerFuncs, p,
                        locateInterval?addLocateInfo:NULL,
                        /* one bit per position if using bitmap */
                        (params->featureToggles & BWTLocateBitmap)?1:0,
                        locateInterval?locBitsUpperBounds:NULL, &varState,
                        err)))
      break;
    if (buildContextMap)
    {
      if (!gt_BWTSCRFFinished(buildContextMap))
      {
        fputs("error: context table construction incomplete!\n", stderr);
      }
      else
      {
        BWTSeqContextRetriever *ctxRetrieve =
          gt_BWTSCRFGet(buildContextMap, NULL, gt_str_get(params->projectName));
        gt_deleteBWTSeqCR(ctxRetrieve);
      }
    }
  } while (0);
  if (buildContextMap)
    gt_deleteBWTSeqContextRetrieverFactory(buildContextMap);
  if (varStateIsInitialized)
    destructAddLocateInfoState(&varState);
  return baseSeqIdx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
testq %rdi, %rdi
je 0x144d71
movq %rdx, %r13
testq %rdx, %rdx
je 0x144d71
testq %r9, %r9
je 0x144d71
movq %r8, %r15
movq %rcx, %r14
movq %rdi, %rbx
movq %rsi, 0x60(%rsp)
movq %r9, 0x48(%rsp)
movq %r9, %rdi
callq 0x89eb7
testb %al, %al
jne 0x144d9f
movl 0x14(%rbx), %ebp
leaq 0x148(%rsp), %rax
movq %r13, (%rax)
movl %ebp, 0x8(%rax)
movl 0x10(%rbx), %ecx
movl %ecx, 0xc(%rax)
movq %rax, 0xf0(%rsp)
leaq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl $0x4580457, 0x44(%rsp)  # imm = 0x4580457
movq $0x10, 0x50(%rsp)
movaps 0x2eeeab(%rip), %xmm0   # 0x4336d0
movaps %xmm0, 0x130(%rsp)
movq (%r13), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%r13), %r12
testq %r12, %r12
jne 0x14484d
movq %r13, %rdi
callq *0x40(%r13)
movq %rax, %r12
movq %rax, 0x48(%r13)
movq %r13, %rdi
callq *0x40(%r13)
movl 0x1c(%rbx), %ecx
cmpl $-0x2, %ecx
movq %rax, 0x58(%rsp)
jne 0x14486c
movq $0x0, 0x38(%rsp)
jmp 0x14487e
movswl %cx, %esi
movq 0x20(%rsp), %rdi
callq 0x143894
movq %rax, 0x38(%rsp)
testl %ebp, %ebp
je 0x144920
movl 0x4(%r12), %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq %rdx, %rcx
je 0x1448a5
cmpl $0x2, (%r14,%rdx,4)
sete %sil
orb %sil, %al
incq %rdx
jmp 0x14488f
testq %r15, %r15
sete %cl
notb %al
orb %cl, %al
testb $0x1, %al
movq %r15, 0x10(%rsp)
jne 0x144949
movq %r15, %rdi
callq 0x149fe8
movq %rax, %rdi
callq 0x7055e
movq 0x20(%rsp), %rcx
decq %rcx
cmpq %rcx, %rax
jne 0x144dcd
movq %r15, %rdi
movq %rax, %rsi
callq *(%r15)
movq %rax, %rdi
callq 0x28a939
movl %eax, 0x8(%rsp)
movl %eax, 0x108(%rsp)
movq %r12, 0x110(%rsp)
movq %r14, 0x118(%rsp)
movl 0x4(%r12), %eax
leal 0x4(%rax,%rax), %eax
movl %eax, 0x54(%rsp)
pushq $0x2
popq %rax
movq %rax, 0x30(%rsp)
jmp 0x144959
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
jmp 0x144c23
pushq $0x1
popq %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x8(%rsp)
pushq $0x1
popq %rsi
movq %r13, %rdi
callq *0x8(%r13)
testq %rdx, %rdx
je 0x1449a3
movq %rax, %rcx
movq %rdx, %rbp
movups 0x28(%r13), %xmm0
movq 0x20(%r13), %rax
testq %rax, %rax
movq %r13, 0x28(%rsp)
je 0x1449d0
movq %r13, %rdi
movq %rcx, %r15
movaps %xmm0, 0x120(%rsp)
callq *%rax
movaps 0x120(%rsp), %xmm0
movq %r15, %rcx
movq %rax, 0x18(%rsp)
jmp 0x1449d9
movq 0x20(%rbx), %rdi
callq 0xad1fa
leaq 0x1fdf67(%rip), %rsi    # 0x34291a
movq $0x0, 0x8(%rsp)
movq 0x48(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dbb
jmp 0x144c0b
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r15
cmoveq %rax, %r15
movq %r12, 0x78(%rsp)
movq 0x20(%rsp), %r13
movq %r13, 0x68(%rsp)
movq %r14, 0x80(%rsp)
movq %rcx, 0x88(%rsp)
movq %rbp, 0x90(%rsp)
movups %xmm0, 0x98(%rsp)
movl 0x10(%rbx), %eax
movl %eax, 0xc0(%rsp)
movq %rbx, %rdi
callq 0x148c97
movl %eax, 0x10(%rsp)
movl 0x14(%rbx), %ebp
decq %r13
movl %ebp, 0xa8(%rsp)
movq %r13, %rdi
callq 0x28a939
movl %eax, 0xb0(%rsp)
movq %r15, 0xb8(%rsp)
testq %rbp, %rbp
je 0x144a62
testb $0x4, 0x10(%rbx)
jne 0x144a95
movq %r13, %rdi
jmp 0x144aa0
andq $0x0, 0x70(%rsp)
andl $0x0, 0xb4(%rsp)
andl $0x0, 0xac(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xc8(%rsp)
movups %xmm0, 0xd8(%rsp)
movq 0x28(%rsp), %r13
jmp 0x144bf7
movq %r13, %rax
xorl %edx, %edx
divq %rbp
movq %rax, %rdi
movq 0x28(%rsp), %r13
callq 0x28a939
movl %eax, 0xac(%rsp)
movl 0x10(%rsp), %r15d
movq %r15, 0xc8(%rsp)
movq %r15, 0xd8(%rsp)
movq %r15, %rdi
shlq $0x4, %rdi
leaq 0x1fde0c(%rip), %rsi    # 0x3428e0
movl $0x120, %edx            # imm = 0x120
callq 0x93160
movq %rax, 0xd0(%rsp)
shlq $0x3, %r15
movq %r15, %rdi
leaq 0x1fddec(%rip), %rsi    # 0x3428e0
movl $0x122, %edx            # imm = 0x122
callq 0x93160
movq %rax, 0xe0(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0xb4(%rsp)
testb $0x4, 0x10(%rbx)
sete %al
cmpl $0x1, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x144bc5
movq 0x20(%rsp), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rbp
movq %rsi, %rcx
shrq %rcx
subq %rax, %rsi
cmpq %rsi, %rcx
cmovbq %rcx, %rsi
cmpq $0x0, 0x18(%rsp)
je 0x144bf2
movq %rsi, 0x8(%rsp)
xorl %r15d, %r15d
xorl %ebp, %ebp
cmpq $0x100, %r15            # imm = 0x100
je 0x144bcd
cmpl $0x1, (%r12)
jne 0x144d6c
movq 0x8(%r12), %rax
movl 0x4(%r12), %ecx
decl %ecx
cmpw $0xff, (%rax,%rcx,2)
je 0x144b94
movq %r12, %rdi
callq 0x146065
cmpb $-0x1, 0x18(%r12,%r15)
je 0x144bc0
movzbl %r15b, %esi
movq %r12, %rdi
callq 0x14603f
movzbl %al, %esi
movq %r12, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x1493cf
testl %eax, %eax
jne 0x144bc0
movq 0x18(%rsp), %rax
movq (%rax), %rax
addq (%rax,%r15,8), %rbp
incq %r15
jmp 0x144b5c
andq $0x0, 0x70(%rsp)
jmp 0x144bf7
movq 0x20(%rsp), %rax
subq %rbp, %rax
movq 0x8(%rsp), %rsi
cmpq %rbp, %rsi
jae 0x144be8
cmpq %rax, %rsi
cmovaeq %rax, %rsi
jmp 0x144bf2
cmpq %rax, %rbp
cmovbq %rbp, %rax
movq %rax, %rsi
movq %rsi, 0x70(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0xe8(%rsp)
movb $0x1, %al
movq %rax, 0x8(%rsp)
leaq 0x33a(%rip), %rax       # 0x144f4c
movq %rax, 0x18(%rsp)
leaq 0x8b1(%rip), %rax       # 0x1454cf
movq %rax, 0x10(%rsp)
movq 0x20(%rbx), %rdi
callq 0xad1fa
movq %rax, %r14
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x144c42
movq %r13, %rdi
callq *%rax
movq %rax, %r15
jmp 0x144c45
xorl %r15d, %r15d
pushq $0x2
popq %rsi
movq %r13, %rdi
callq *0x8(%r13)
movq %rdx, %r9
movl 0x10(%rbx), %r10d
andl $0x1, %r10d
subq $0x8, %rsp
leaq 0x70(%rsp), %r11
leaq 0xf8(%rsp), %r13
leaq 0x138(%rsp), %r12
leaq 0x58(%rsp), %rbp
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq 0x60(%rsp), %rdx
movq %r15, %rcx
movq %rax, %r8
pushq 0x50(%rsp)
pushq %r11
pushq 0x28(%rsp)
pushq %r10
pushq 0x40(%rsp)
pushq %r13
pushq %r12
pushq %rbp
leaq 0x8c(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
pushq %rbx
callq *0xc0(%rsp)
addq $0x60, %rsp
movq %rax, %r14
testq %rax, %rax
movq 0x38(%rsp), %r15
je 0x144cfa
testq %r15, %r15
je 0x144cfa
movq %r15, %rdi
callq 0x143c1f
testb %al, %al
je 0x144d54
movq 0x20(%rbx), %rdi
callq 0xad1fa
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x143c2a
movq %rax, %rdi
callq 0x14417b
jmp 0x144cff
testq %r15, %r15
je 0x144d07
movq %r15, %rdi
callq 0x143a12
cmpb $0x0, 0x8(%rsp)
je 0x144d3f
movq 0xd0(%rsp), %rdi
leaq 0x1fdbc3(%rip), %rbx    # 0x3428e0
movq %rbx, %rsi
movl $0x151, %edx            # imm = 0x151
callq 0x936f9
movq 0xe0(%rsp), %rdi
movq %rbx, %rsi
movl $0x152, %edx            # imm = 0x152
callq 0x936f9
movq %r14, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2f320d(%rip), %rax    # 0x437f68
movq (%rax), %rsi
leaq 0x1fdbf8(%rip), %rdi    # 0x34295d
callq 0x17870
jmp 0x144cff
callq 0x17390
movq 0x2f31f0(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a0291(%rip), %rsi    # 0x2e5013
leaq 0x1fdb2b(%rip), %rdx    # 0x3428b4
leaq 0x1fdb39(%rip), %rcx    # 0x3428c9
leaq 0x1fdb49(%rip), %r8     # 0x3428e0
movl $0x21f, %r9d            # imm = 0x21F
jmp 0x144df9
movq 0x2f31c2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a0263(%rip), %rsi    # 0x2e5013
leaq 0x1a0408(%rip), %rdx    # 0x2e51bf
leaq 0x1fdb0b(%rip), %rcx    # 0x3428c9
leaq 0x1fdb1b(%rip), %r8     # 0x3428e0
movl $0x220, %r9d            # imm = 0x220
jmp 0x144df9
movq 0x2f3194(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a0235(%rip), %rsi    # 0x2e5013
leaq 0x1fdb1a(%rip), %rdx    # 0x3428ff
leaq 0x1fdadd(%rip), %rcx    # 0x3428c9
leaq 0x1fdaed(%rip), %r8     # 0x3428e0
movl $0x243, %r9d            # imm = 0x243
xorl %eax, %eax
callq 0x17a50
callq 0x17390