// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-bwtseq.c
// Function: initBWTSeqFromEncSeqIdx
static int
initBWTSeqFromEncSeqIdx(BWTSeq *bwtSeq, struct encIdxSeq *seqIdx,
                        MRAEnc *alphabet, GtUword *counts,
                        enum rangeSortMode *rangeSort,
                        const enum rangeSortMode *defaultRangeSort)
{
  size_t alphabetSize;
  Symbol bwtTerminatorFlat;
  EISHint hint;
  gt_assert(bwtSeq && seqIdx);
  bwtSeq->alphabet = alphabet;
  alphabetSize = gt_MRAEncGetSize(alphabet);
  if (!alphabetSize)
    /* weird error, shouldn't happen, but I prefer error return to
     * segfault in case someone tampered with the input */
    return 0;
  /* FIXME: this should probably be handled in chardef.h to have a
   * unique mapping */
  /* FIXME: this assumes there is exactly two ranges */
  gt_MRAEncAddSymbolToRange(alphabet, bwtTerminatorSym, 1);
  gt_assert(gt_MRAEncGetSize(alphabet) ==  alphabetSize + 1);
  alphabetSize = gt_MRAEncGetSize(alphabet);
  bwtSeq->bwtTerminatorFallback = bwtTerminatorFlat
    = MRAEncMapSymbol(alphabet, GT_UNDEFBWTCHAR);
  bwtSeq->bwtTerminatorFallbackRange = 1;
  bwtSeq->count = counts;
  bwtSeq->rangeSort = rangeSort;
  bwtSeq->seqIdx = seqIdx;
  bwtSeq->alphabetSize = alphabetSize;
  bwtSeq->hint = hint = newEISHint(seqIdx);
  {
    Symbol i;
    GtUword len = EISLength(seqIdx), *count = bwtSeq->count;
    count[0] = 0;
    for (i = 0; i < bwtTerminatorFlat; ++i)
      count[i + 1] = count[i]
        + EISSymTransformedRank(seqIdx, i, len, hint);
    /* handle character which the terminator has been mapped to specially */
    count[i + 1] = count[i]
      + EISSymTransformedRank(seqIdx, i, len, hint) - 1;
    gt_assert(count[i + 1] >= count[i]);
    /* now we can finish the rest of the symbols */
    for (i += 2; i < alphabetSize; ++i)
      count[i] = count[i - 1]
        + EISSymTransformedRank(seqIdx, i - 1, len, hint);
    /* and finally place the 1-count for the terminator */
    count[i] = count[i - 1] + 1;
#ifdef EIS_DEBUG
    gt_log_log("count[alphabetSize]="GT_WU", len="GT_WU"",count[alphabetSize],
               len);
    for (i = 0; i <= alphabetSize; ++i)
      gt_log_log("count[%u]="GT_WU"", (unsigned)i, count[i]);
#endif
    gt_assert(count[alphabetSize] == len);
  }
  gt_BWTSeqInitLocateHandling(bwtSeq, defaultRangeSort);
  return 1;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movq %r8, 0x58(%rsp)
movq %r9, 0x50(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0x225de5
cmpq $0x0, 0x70(%rsp)
jne 0x225e1d
movq 0x4161b4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f021d(%rip), %rsi    # 0x516013
leaq 0x34fb21(%rip), %rdx    # 0x57591e
leaq 0x34fb2b(%rip), %rcx    # 0x57592f
leaq 0x34f6b4(%rip), %r8     # 0x5754bf
movl $0x35, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x225e1f
movq 0x68(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x68(%rsp), %rdi
callq 0x22aeb0
movzwl %ax, %eax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0x225e57
movl $0x0, 0x84(%rsp)
jmp 0x22618c
movq 0x68(%rsp), %rdi
movl $0xfc, %esi
movl $0x1, %edx
callq 0x22b110
movq 0x68(%rsp), %rdi
callq 0x22aeb0
movzwl %ax, %eax
movq 0x48(%rsp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
je 0x225ebe
movq 0x416113(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f017c(%rip), %rsi    # 0x516013
leaq 0x34faa9(%rip), %rdx    # 0x575947
leaq 0x34fa8a(%rip), %rcx    # 0x57592f
leaq 0x34f613(%rip), %r8     # 0x5754bf
movl $0x40, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x225ec0
movq 0x68(%rsp), %rdi
callq 0x22aeb0
movzwl %ax, %eax
movq %rax, 0x48(%rsp)
movq 0x68(%rsp), %rdi
movl $0xfe, %esi
callq 0x226450
movb %al, %cl
movb %cl, 0x47(%rsp)
movq 0x78(%rsp), %rax
movb %cl, 0x24(%rax)
movq 0x78(%rsp), %rax
movl $0x1, 0x28(%rax)
movq 0x60(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x58(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rcx
movq 0x78(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x70(%rsp), %rdi
callq 0x2280f0
movq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq 0x78(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x70(%rsp), %rdi
callq 0x228110
movq %rax, 0x28(%rsp)
movq 0x78(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
movb $0x0, 0x37(%rsp)
movzbl 0x37(%rsp), %eax
movzbl 0x47(%rsp), %ecx
cmpl %ecx, %eax
jge 0x225fdf
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
movq 0x70(%rsp), %rdi
movb 0x37(%rsp), %al
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
movzbl %al, %esi
callq 0x228120
movq 0x18(%rsp), %rdx
addq %rax, %rdx
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movb 0x37(%rsp), %al
addb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0x225f7b
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rdi
movb 0x37(%rsp), %al
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
movzbl %al, %esi
callq 0x228120
movq 0x10(%rsp), %rdx
addq %rax, %rdx
subq $0x1, %rdx
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq 0x20(%rsp), %rcx
movzbl 0x37(%rsp), %edx
cmpq (%rcx,%rdx,8), %rax
jae 0x226089
movq 0x415f48(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2effb1(%rip), %rsi    # 0x516013
leaq 0x34f90d(%rip), %rdx    # 0x575976
leaq 0x34f8bf(%rip), %rcx    # 0x57592f
leaq 0x34f448(%rip), %r8     # 0x5754bf
movl $0x54, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x22608b
movzbl 0x37(%rsp), %eax
addl $0x2, %eax
movb %al, 0x37(%rsp)
movzbl 0x37(%rsp), %eax
cmpq 0x48(%rsp), %rax
jae 0x2260fd
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rdi
movzbl 0x37(%rsp), %eax
subl $0x1, %eax
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
movzbl %al, %esi
callq 0x228120
movq 0x8(%rsp), %rdx
addq %rax, %rdx
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movb 0x37(%rsp), %al
addb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0x226097
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq 0x20(%rsp), %rax
movzbl 0x37(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpq 0x28(%rsp), %rax
je 0x226170
movq 0x415e61(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2efeca(%rip), %rsi    # 0x516013
leaq 0x34f83f(%rip), %rdx    # 0x57598f
leaq 0x34f7d8(%rip), %rcx    # 0x57592f
leaq 0x34f361(%rip), %r8     # 0x5754bf
movl $0x61, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x226172
movq 0x78(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x223da0
movl $0x1, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopl (%rax,%rax)