// File: /workspace/github_c_makefile_star2_O3/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 0x19a5e9
movq %rdx, %r13
testq %rdx, %rdx
je 0x19a5e9
testq %r9, %r9
je 0x19a5e9
movq %r8, %r12
movq %rcx, %r14
movq %rdi, %rbx
movq %rsi, 0x70(%rsp)
movq %r9, 0x58(%rsp)
movq %r9, %rdi
callq 0xfcc32
testb %al, %al
jne 0x19a5ee
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, 0x100(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movl $0x4580457, 0x44(%rsp)  # imm = 0x4580457
movq $0x10, 0x60(%rsp)
movaps 0x31a60b(%rip), %xmm0   # 0x4b46b0
movaps %xmm0, 0x130(%rsp)
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%r13), %r15
testq %r15, %r15
jne 0x19a0cd
movq %r13, %rdi
callq *0x40(%r13)
movq %rax, %r15
movq %rax, 0x48(%r13)
movq %r13, %rdi
callq *0x40(%r13)
movq %rax, 0x68(%rsp)
movl 0x1c(%rbx), %eax
cmpl $-0x2, %eax
jne 0x19a0ec
movq $0x0, 0x10(%rsp)
jmp 0x19a0fe
movswl %ax, %esi
movq 0x18(%rsp), %rdi
callq 0x199420
movq %rax, 0x10(%rsp)
xorl %eax, %eax
testl %ebp, %ebp
je 0x19a1f8
movl 0x4(%r15), %r8d
movl $0x1, %edi
testq %r8, %r8
movq %rbx, 0x48(%rsp)
je 0x19a1a6
xorl %edx, %edx
xorl %ecx, %ecx
cmpl $0x2, (%r14,%rdx,4)
sete %sil
orb %sil, %cl
incq %rdx
cmpq %rdx, %r8
jne 0x19a123
testq %r12, %r12
sete %al
notb %cl
orb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
jne 0x19a1a6
movq %r12, %rdi
callq 0x19ec91
movq %rax, %rdi
callq 0xe7b9c
movq 0x18(%rsp), %rcx
decq %rcx
cmpq %rcx, %rax
jne 0x19a5f3
movq %r12, %rdi
movq %rax, %rsi
callq *(%r12)
movq %rax, %rdi
callq 0x2f09dd
movl %eax, 0x118(%rsp)
movq %r15, 0x120(%rsp)
movq %r14, 0x128(%rsp)
movl 0x4(%r15), %ecx
leal 0x4(,%rcx,2), %ecx
movl %ecx, 0x64(%rsp)
movl $0x2, %edi
movq %rax, (%rsp)
movq %r12, %rbp
movq %rdi, 0x50(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq *0x8(%r13)
testq %rdx, %rdx
je 0x19a220
movq %rax, %rcx
movq %rdx, %rbx
movups 0x28(%r13), %xmm0
movq 0x20(%r13), %rax
testq %rax, %rax
movq %r13, 0x38(%rsp)
je 0x19a252
movq %r13, %rdi
movq %rcx, %r12
movaps %xmm0, 0x20(%rsp)
callq *%rax
movaps 0x20(%rsp), %xmm0
movq %r12, %rcx
movq %rax, 0x8(%rsp)
jmp 0x19a25b
movq $0x0, (%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x8(%rsp)
jmp 0x19a4a7
movq 0x48(%rsp), %rbx
movq 0x20(%rbx), %rdi
callq 0x11b0a1
leaq 0x208415(%rip), %rsi    # 0x3a264a
movq $0x0, 0x8(%rsp)
movq 0x58(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xfcb67
jmp 0x19a490
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
cmpl $0x0, (%rsp)
movq %rbp, %r13
cmoveq %rax, %r13
movq %r15, 0x88(%rsp)
movq 0x18(%rsp), %r12
movq %r12, 0x78(%rsp)
movq %r14, 0x90(%rsp)
movq %rcx, 0x98(%rsp)
movq %rbx, 0xa0(%rsp)
movups %xmm0, 0xa8(%rsp)
movq 0x48(%rsp), %rbx
movl 0x10(%rbx), %eax
movl %eax, 0xd0(%rsp)
movq %rbx, %rdi
callq 0x19d837
movl %eax, 0x20(%rsp)
movl 0x14(%rbx), %ebp
decq %r12
movl %ebp, 0xb8(%rsp)
movq %r12, %rdi
callq 0x2f09dd
movl %eax, 0xc0(%rsp)
movq %r13, 0xc8(%rsp)
testq %rbp, %rbp
je 0x19a41c
testb $0x4, 0x10(%rbx)
je 0x19a2f3
movq %r12, %rax
xorl %edx, %edx
divq %rbp
movq %rax, %r12
movq 0x38(%rsp), %r13
movq %r12, %rdi
callq 0x2f09dd
movl %eax, 0xbc(%rsp)
movl 0x20(%rsp), %r12d
movq %r12, 0xd8(%rsp)
movq %r12, 0xe8(%rsp)
movq %r12, %rdi
shlq $0x4, %rdi
leaq 0x2082e6(%rip), %rsi    # 0x3a2610
movl $0x120, %edx            # imm = 0x120
callq 0x104226
movq %rax, 0xe0(%rsp)
shlq $0x3, %r12
movq %r12, %rdi
leaq 0x2082c6(%rip), %rsi    # 0x3a2610
movl $0x122, %edx            # imm = 0x122
callq 0x104226
movq %rax, 0xf0(%rsp)
movq (%rsp), %rax
movl %eax, 0xc4(%rsp)
testb $0x4, 0x10(%rbx)
sete %al
cmpl $0x1, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x19a457
movq 0x18(%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, 0x8(%rsp)
je 0x19a474
movq %rsi, (%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpl $0x1, (%r15)
jne 0x19a5e4
movq 0x8(%r15), %rax
movl 0x4(%r15), %ecx
decl %ecx
cmpw $0xff, (%rax,%rcx,2)
movb 0x18(%r15,%r12), %al
je 0x19a3d6
cmpb $-0x1, %al
je 0x19a3f6
movzbl %al, %esi
movq %r15, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x19e32c
testl %eax, %eax
jne 0x19a3f6
movq 0x8(%rsp), %rax
movq (%rax), %rax
addq (%rax,%r12,8), %rbp
incq %r12
cmpq $0x100, %r12            # imm = 0x100
jne 0x19a3b1
movq 0x18(%rsp), %rax
subq %rbp, %rax
movq (%rsp), %rsi
cmpq %rbp, %rsi
jae 0x19a46a
cmpq %rax, %rsi
cmovaeq %rax, %rsi
jmp 0x19a474
movq $0x0, 0x80(%rsp)
xorl %eax, %eax
movl %eax, 0xc4(%rsp)
movl %eax, 0xbc(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xd8(%rsp)
movups %xmm0, 0xe8(%rsp)
movq 0x10(%rsp), %rax
movq 0x38(%rsp), %r13
jmp 0x19a481
movq $0x0, 0x80(%rsp)
movq 0x10(%rsp), %rax
jmp 0x19a481
cmpq %rax, %rbp
cmovbq %rbp, %rax
movq %rax, %rsi
movq 0x10(%rsp), %rax
movq %rsi, 0x80(%rsp)
movq %rax, 0xf8(%rsp)
movb $0x1, %al
movq %rax, 0x8(%rsp)
leaq 0x241(%rip), %rax       # 0x19a6d8
movq %rax, 0x20(%rsp)
leaq 0x749(%rip), %rax       # 0x19abec
movq %rax, (%rsp)
movq 0x20(%rbx), %rdi
callq 0x11b0a1
movq %rax, %r14
movq 0x20(%r13), %rax
testq %rax, %rax
je 0x19a4c6
movq %r13, %rdi
callq *%rax
movq %rax, %r15
jmp 0x19a4c9
xorl %r15d, %r15d
movq %r13, %rdi
movl $0x2, %esi
callq *0x8(%r13)
movq %rdx, %r9
movl 0x10(%rbx), %r10d
andl $0x1, %r10d
subq $0x8, %rsp
leaq 0x80(%rsp), %r11
leaq 0x108(%rsp), %r13
leaq 0x138(%rsp), %r12
leaq 0x68(%rsp), %rbp
movq 0x20(%rsp), %rdi
movq %r14, %rsi
movq 0x70(%rsp), %rdx
movq %r15, %rcx
movq %rax, %r8
pushq 0x60(%rsp)
pushq %r11
pushq 0x18(%rsp)
pushq %r10
pushq 0x48(%rsp)
pushq %r13
pushq %r12
pushq %rbp
leaq 0x8c(%rsp), %rax
pushq %rax
pushq 0xa0(%rsp)
pushq %rbx
callq *0xd0(%rsp)
addq $0x60, %rsp
movq %rax, %r14
testq %rax, %rax
movq 0x10(%rsp), %r15
je 0x19a583
testq %r15, %r15
je 0x19a583
movq %r15, %rdi
callq 0x19971e
testb %al, %al
je 0x19a5dd
movq 0x20(%rbx), %rdi
callq 0x11b0a1
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x199729
movq %rax, %rdi
callq 0x199c73
jmp 0x19a588
testq %r15, %r15
je 0x19a590
movq %r15, %rdi
callq 0x19958f
cmpb $0x0, 0x8(%rsp)
je 0x19a5c8
movq 0xe0(%rsp), %rdi
leaq 0x20806a(%rip), %rbx    # 0x3a2610
movq %rbx, %rsi
movl $0x151, %edx            # imm = 0x151
callq 0x1045eb
movq 0xf0(%rsp), %rdi
movq %rbx, %rsi
movl $0x152, %edx            # imm = 0x152
callq 0x1045eb
movq %r14, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5ecb5
jmp 0x19a588
callq 0x173b0
callq 0x5ec43
callq 0x5ecd1
callq 0x5ec7c