// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/encseq2offset.c
// Function: gt_encseqtable2sequenceoffsets
GtUword *gt_encseqtable2sequenceoffsets(
                                    GtUword *totallength,
                                    GtSpecialcharinfo *specialcharinfo,
                                    const Suffixarray *suffixarraytable,
                                    unsigned int numofindexes)
{
  unsigned int idx;
  GtUchar lastofprevious, firstofcurrent;
  GtUword tmplength, GT_UNUSED numofsequences = 0, *sequenceoffsettable;
  uint64_t tmpspecialcharacters,
           tmpwildcards,
           tmpspecialranges,
           tmpwildcardranges,
           tmprealspecialranges,
           tmprealwildcardranges,
           tmpoffset;

  gt_assert(numofindexes > 0);
  sequenceoffsettable = gt_malloc(sizeof (*sequenceoffsettable) * numofindexes);
  tmpspecialcharacters = (uint64_t) (numofindexes-1);
  tmpwildcards = 0;
  tmpspecialranges = 0;
  tmpwildcardranges = 0;
  tmprealspecialranges = 0;
  tmprealwildcardranges = 0;
  for (idx=0; idx<numofindexes; idx++)
  {
    if (idx == 0)
    {
      tmplength = 0;
      sequenceoffsettable[idx] = 0;
    } else
    {
      tmplength = gt_encseq_total_length(suffixarraytable[idx - 1].encseq);
      sequenceoffsettable[idx] = sequenceoffsettable[idx-1] + tmplength + 1UL;
    }
    numofsequences += gt_encseq_num_of_sequences(suffixarraytable[idx].encseq);
    tmpspecialcharacters
      += (uint64_t) gt_encseq_specialcharacters(suffixarraytable[idx].encseq);
    tmpwildcards
      += (uint64_t) gt_encseq_wildcards(suffixarraytable[idx].encseq);
    tmpspecialranges
      += (uint64_t) gt_encseq_specialranges(suffixarraytable[idx].encseq);
    tmpwildcardranges
      += (uint64_t) gt_encseq_wildcardranges(suffixarraytable[idx].encseq);
    tmprealspecialranges
      += (uint64_t) gt_encseq_realspecialranges(suffixarraytable[idx].encseq);
    tmprealwildcardranges
      += (uint64_t) gt_encseq_realwildcardranges(suffixarraytable[idx].encseq);
    if (idx > 0)
    {
      /* Random access */
      lastofprevious
        = gt_encseq_get_encoded_char(suffixarraytable[idx-1].encseq,
                                     tmplength-1,
                                     suffixarraytable[idx - 1].readmode);
      /* Random access */
      firstofcurrent
        = gt_encseq_get_encoded_char(suffixarraytable[idx].encseq,
                                     0,
                                     suffixarraytable[idx].readmode);
      if (GT_ISSPECIAL(lastofprevious))
      {
        if (GT_ISSPECIAL(firstofcurrent))
        {
          tmpspecialranges--;
          tmprealspecialranges--;
        }
      } else
      {
        if (GT_ISNOTSPECIAL(firstofcurrent))
        {
          tmpspecialranges++;
          tmprealspecialranges++;
        }
      }
    }
    tmpoffset = (uint64_t) sequenceoffsettable[idx] +
       (uint64_t) gt_encseq_total_length(suffixarraytable[idx].encseq);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmpoffset);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmpspecialcharacters);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmpwildcards);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmpspecialranges);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmpwildcardranges);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmprealspecialranges);
    (void) CALLCASTFUNC(uint64_t,unsigned_long,tmprealwildcardranges);
    printf("# seqlen[%u] = "GT_WU"\n",
           idx,
           gt_encseq_total_length(suffixarraytable[idx].encseq));
  }
  tmplength = gt_encseq_total_length(suffixarraytable[numofindexes -1].encseq);
  *totallength = sequenceoffsettable[numofindexes-1] + tmplength;
  specialcharinfo->specialcharacters = (GtUword) tmpspecialcharacters;
  specialcharinfo->wildcards = (GtUword) tmpwildcards;
  specialcharinfo->specialranges = (GtUword) tmpspecialranges;
  specialcharinfo->wildcardranges = (GtUword) tmpwildcardranges;
  specialcharinfo->realspecialranges = (GtUword) tmprealspecialranges;
  specialcharinfo->realwildcardranges = (GtUword) tmprealwildcardranges;
  specialcharinfo->lengthofspecialprefix
    = gt_encseq_lengthofspecialprefix(suffixarraytable[0].encseq);
  specialcharinfo->lengthofwildcardprefix
    = gt_encseq_lengthofwildcardprefix(suffixarraytable[0].encseq);
  specialcharinfo->lengthofspecialsuffix
    = gt_encseq_lengthofspecialsuffix(suffixarraytable[idx-1].encseq);
  specialcharinfo->lengthofwildcardsuffix
    = gt_encseq_lengthofwildcardsuffix(suffixarraytable[idx-1].encseq);
  gt_assert(numofsequences > 0);
#ifndef NDEBUG
  gt_GtSpecialcharinfo_check(specialcharinfo,numofsequences - 1);
#endif
  return sequenceoffsettable;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0x58(%rsp)
movq %rdi, 0x50(%rsp)
testl %ecx, %ecx
je 0x30fe2d
movl %ecx, %r12d
movq %rdx, %r13
movl %ecx, %eax
movq %rax, 0x60(%rsp)
leaq (,%rax,8), %rdi
leaq 0xd21ef(%rip), %rsi     # 0x3e1d8e
movl $0x29, %edx
callq 0x104226
movq %rax, %r14
decl %r12d
pxor %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movq %r13, 0x48(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq %r12, 0x40(%rsp)
xorl %ebp, %ebp
movq %rax, 0x18(%rsp)
testq %r15, %r15
movq %rbp, 0x38(%rsp)
je 0x30fc14
movq -0x100(%r13), %rdi
callq 0xe7b9c
movq %rax, %rbx
movq -0x8(%r14,%r15,8), %rax
addq %rbx, %rax
incq %rax
movq %rax, (%r14,%r15,8)
decq %rbx
jmp 0x30fc22
movq $0x0, (%r14)
movq $-0x1, %rbx
movq (%r13), %rdi
callq 0xe7bac
movq %rax, 0x80(%rsp)
movq (%r13), %rdi
callq 0xec58b
movq %rax, 0x78(%rsp)
movq (%r13), %rdi
callq 0xec68e
movq %rax, 0x70(%rsp)
movq (%r13), %rdi
callq 0xec5a3
movq %rax, %rbp
movq (%r13), %rdi
callq 0xec69f
movq %rax, 0x68(%rsp)
movq (%r13), %rdi
callq 0xec63b
movq %rax, %r14
movq (%r13), %rdi
callq 0xec6b0
movq %rax, %rcx
movq %rbp, %xmm0
movq %r14, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa (%rsp), %xmm1
paddq %xmm0, %xmm1
movdqa %xmm1, (%rsp)
testq %r15, %r15
je 0x30fcee
movq %rcx, %r14
movq -0x100(%r13), %rdi
movl -0xb8(%r13), %edx
movq %rbx, %rsi
callq 0xe7bbc
movl %eax, %ebx
movq (%r13), %rdi
movl 0x48(%r13), %edx
xorl %esi, %esi
callq 0xe7bbc
cmpb $-0x2, %bl
movq 0x38(%rsp), %rbp
jb 0x30fcfa
cmpb $-0x2, %al
movq 0x18(%rsp), %rax
jb 0x30fd15
movdqa (%rsp), %xmm0
paddq 0x452c4(%rip), %xmm0    # 0x354fb0
jmp 0x30fd10
movq 0x18(%rsp), %r14
movq 0x38(%rsp), %rbp
jmp 0x30fd1b
cmpb $-0x3, %al
movq 0x18(%rsp), %rax
ja 0x30fd15
movdqa (%rsp), %xmm0
psubq 0x452a0(%rip), %xmm0    # 0x354fb0
movdqa %xmm0, (%rsp)
movq %r14, %rcx
movq %rax, %r14
addq 0x80(%rsp), %rbp
addq 0x78(%rsp), %r12
movq 0x70(%rsp), %rax
addq %rax, 0x20(%rsp)
movq 0x68(%rsp), %rax
addq %rax, 0x28(%rsp)
addq %rcx, 0x30(%rsp)
movq (%r13), %rdi
callq 0xe7b9c
movq (%r13), %rdi
callq 0xe7b9c
leaq 0xd204e(%rip), %rdi     # 0x3e1da8
movl %r15d, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x17070
incq %r15
addq $0x100, %r13            # imm = 0x100
cmpq %r15, 0x60(%rsp)
jne 0x30fbe7
movq 0x40(%rsp), %rbx
movq %rbx, %rax
shlq $0x8, %rax
movq 0x48(%rsp), %r15
movq (%r15,%rax), %rdi
callq 0xe7b9c
addq (%r14,%rbx,8), %rax
movq 0x50(%rsp), %rcx
movq %rax, (%rcx)
movq 0x58(%rsp), %rbx
movq %r12, (%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x30(%rbx)
movaps (%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x38(%rbx)
movq (%r15), %rdi
callq 0xec67e
movq %rax, 0x18(%rbx)
movq (%r15), %rdi
callq 0xec6c1
movq %rax, 0x40(%rbx)
movq -0x100(%r13), %rdi
callq 0xec686
movq %rax, 0x20(%rbx)
movq -0x100(%r13), %rdi
callq 0xec6c9
movq %rax, 0x48(%rbx)
testq %rbp, %rbp
je 0x30fe32
decq %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xec84a
movq %r14, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x906d7
callq 0x9069e
nop