// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/eis-seqranges.c
// Function: gt_SRLAppendNewRange
void
gt_SRLAppendNewRange(struct seqRangeList *rangeList,
                  GtUword pos,
                  GtUword len,
                  Symbol esym)
{
  gt_assert(rangeList);
  if (len)
  {
    Symbol sym = MRAEncMapSymbol(rangeList->alphabet, esym);
    struct seqRange *p;
    GtUword *pSums;
    size_t numRanges = rangeList->numRanges,
      numSyms = gt_MRAEncGetSize(rangeList->alphabet),
      numNewRanges = len/rangeList->maxRangeLen
      + ((len%rangeList->maxRangeLen)?1:0);
    unsigned symBits = rangeList->symBits;
    if (numRanges + numNewRanges > rangeList->numRangesStorable)
    {
      size_t newSize = numRanges + 2 * numNewRanges;
      rangeList->ranges = gt_realloc(rangeList->ranges,
                                     sizeof (struct seqRange) * newSize);
      if (rangeList->partialSymSums)
        rangeList->partialSymSums =
          gt_realloc(rangeList->partialSymSums, sizeof (GtUword)
                     * numSyms * newSize);
      rangeList->numRangesStorable = newSize;
    }
    p = rangeList->ranges + numRanges;
    if (rangeList->partialSymSums)
      pSums = rangeList->partialSymSums + numSyms * numRanges;
    else
      pSums = NULL;
    while (len > rangeList->maxRangeLen)
    {
      p->startPos = pos;
      seqRangeSetSym(p, sym, symBits);
      seqRangeSetLen(p, rangeList->maxRangeLen, symBits);
      pos += rangeList->maxRangeLen;
      len -= rangeList->maxRangeLen;
      if (numRanges && pSums)
      {
        GtUword *spDest = pSums, *spSrc = pSums - numSyms;
        size_t i;
        for (i = 0; i < numSyms; ++i)
        {
          *spDest++ = *spSrc++;
        }
        pSums[seqRangeSym(p - 1, symBits)] += seqRangeLen(p - 1, symBits);
        pSums += numSyms;
      }
      else if (pSums)
      {
        memset(pSums, 0, sizeof (GtUword) * numSyms);
        pSums += numSyms;
      }
      ++p;
      ++numRanges;
    }
    if (len)
    {
      p->startPos = pos;
      seqRangeSetSym(p, sym, symBits);
      seqRangeSetLen(p, len, symBits);
      if (numRanges && pSums)
      {
        GtUword *spDest = pSums, *spSrc = pSums - numSyms;
        size_t i;
        for (i = 0; i < numSyms; ++i)
        {
          *spDest++ = *spSrc++;
        }
        pSums[seqRangeSym(p - 1, symBits)] += seqRangeLen(p - 1, symBits);
        pSums += numSyms;
      }
      else if (pSums)
      {
        memset(pSums, 0, sizeof (GtUword) * numSyms);
        pSums += numSyms;
      }
      ++numRanges;
    }
    gt_assert(numRanges == rangeList->numRanges + numNewRanges);
    rangeList->numRanges = numRanges;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0x30ea75
movq %rdx, %r13
testq %rdx, %rdx
je 0x30ea66
movq %rdi, %r12
movq %rsi, 0x18(%rsp)
movq 0x20(%rdi), %rdi
cmpl $0x1, (%rdi)
jne 0x30ea7a
movzbl %cl, %eax
movb 0x18(%rdi,%rax), %al
movb %al, (%rsp)
movq 0x8(%r12), %rbx
callq 0x19e077
movl %eax, %ecx
movq 0x30(%r12), %rsi
movq %r13, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %r14
movzwl %cx, %r15d
cmpq $0x1, %rdx
movq %r12, %rdx
sbbq $-0x1, %r14
movl 0x28(%r12), %eax
movq %rax, 0x8(%rsp)
leaq (%r14,%rbx), %rax
cmpq (%r12), %rax
movq %rbx, %rbp
movq %r14, 0x38(%rsp)
jbe 0x30e7ed
leaq (%rbx,%r14,2), %rbx
movq 0x10(%rdx), %rdi
movq %rbx, %rsi
shlq $0x4, %rsi
leaq 0xd33f3(%rip), %rdx     # 0x3e1ba1
movl $0x65, %ecx
callq 0x104461
movq %rax, 0x10(%r12)
movq 0x18(%r12), %rdi
testq %rdi, %rdi
je 0x30e7f3
movq %r15, %rsi
imulq %rbx, %rsi
shlq $0x3, %rsi
leaq 0xd33c8(%rip), %rdx     # 0x3e1ba1
movl $0x69, %ecx
callq 0x104461
movq %r12, %rdx
movq %rax, 0x18(%r12)
jmp 0x30e7f8
movq 0x18(%rdx), %rax
jmp 0x30e7ff
movq %r12, %rdx
xorl %eax, %eax
movq %rbx, (%rdx)
movq 0x30(%rdx), %rsi
movq %rbp, %rcx
movq %rbp, %rbx
shlq $0x4, %rbx
addq 0x10(%rdx), %rbx
imulq %r15, %rcx
testq %rax, %rax
leaq (%rax,%rcx,8), %r14
cmoveq %rax, %r14
movzbl (%rsp), %eax
movl %eax, 0x10(%rsp)
cmpq %r13, %rsi
movq %rdx, 0x20(%rsp)
jae 0x30e980
movq %r13, (%rsp)
movl $0x40, %eax
subl 0x8(%rsp), %eax
movl %eax, 0x14(%rsp)
leal (,%r15,8), %eax
movq %rax, 0x48(%rsp)
movq %r15, %rax
negq %rax
movq %rax, 0x40(%rsp)
movq 0x18(%rsp), %rcx
movq %rcx, 0x18(%rsp)
movq %rcx, (%rbx)
movq %rbx, 0x30(%rsp)
leaq 0x8(%rbx), %r12
movq %r12, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rbx
movq %rdx, %r13
movl %ebx, %edx
movl 0x10(%rsp), %ecx
callq 0x2f49e4
movq 0x30(%r13), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl 0x14(%rsp), %edx
callq 0x2f388c
movq %r13, %rbx
movq 0x30(%r13), %rdx
testq %rbp, %rbp
je 0x30e920
testq %r14, %r14
je 0x30e920
movq %rdx, 0x50(%rsp)
movq %rbp, 0x28(%rsp)
testq %r15, %r15
je 0x30e8d7
movq 0x40(%rsp), %rax
leaq (%r14,%rax,8), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rdx, (%r14,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x30e8c7
movq 0x30(%rsp), %rbx
leaq -0x8(%rbx), %r12
movq %r12, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
movl 0x14(%rsp), %edx
callq 0x2f37dc
movq %rax, %rbp
movq %r12, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x2f4934
movzbl %al, %eax
addq %rbp, (%r14,%rax,8)
leaq (%r14,%r15,8), %r14
movq 0x20(%rsp), %r13
movq 0x28(%rsp), %rbp
movq 0x50(%rsp), %rdx
jmp 0x30e94b
testq %r14, %r14
je 0x30e940
movq %r14, %rdi
xorl %esi, %esi
movq %rdx, %r13
movq 0x48(%rsp), %rdx
callq 0x173a0
movq %r13, %rdx
leaq (%r14,%r15,8), %r14
jmp 0x30e943
xorl %r14d, %r14d
movq %rbx, %r13
movq 0x30(%rsp), %rbx
movq 0x18(%rsp), %rcx
addq %rdx, %rcx
movq (%rsp), %rax
subq %rdx, %rax
addq $0x10, %rbx
incq %rbp
movq %rax, (%rsp)
cmpq 0x30(%r13), %rax
movq %r13, %rdx
ja 0x30e860
movq (%rsp), %r13
testq %r13, %r13
jne 0x30e985
jmp 0x30ea54
movq 0x18(%rsp), %rcx
movq %r13, (%rsp)
movq %rbp, 0x28(%rsp)
movq %rcx, (%rbx)
leaq 0x8(%rbx), %r12
movq %r12, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %r13
movl %r13d, %edx
movl 0x10(%rsp), %ecx
callq 0x2f49e4
movl $0x40, %eax
subl %r13d, %eax
movq %r12, %rdi
movq 0x28(%rsp), %rbp
movq %r13, %rsi
movl %eax, %r13d
movl %eax, %edx
movq (%rsp), %rcx
callq 0x2f388c
testq %rbp, %rbp
je 0x30ea30
testq %r14, %r14
je 0x30ea30
testq %r15, %r15
je 0x30e9fb
leal (,%r15,8), %ecx
movq %r14, %rax
subq %rcx, %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rdx, (%r14,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x30e9eb
addq $-0x8, %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movl %r13d, %edx
callq 0x2f37dc
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x2f4934
movzbl %al, %eax
addq %r15, (%r14,%rax,8)
movq 0x20(%rsp), %rdx
jmp 0x30ea51
testq %r14, %r14
movq 0x20(%rsp), %rdx
je 0x30ea51
shll $0x3, %r15d
movq %r14, %rdi
xorl %esi, %esi
movq %rdx, %rbx
movq %r15, %rdx
callq 0x173a0
movq %rbx, %rdx
incq %rbp
movq 0x38(%rsp), %rax
addq 0x8(%rdx), %rax
cmpq %rax, %rbp
jne 0x30ea7f
movq %rbp, 0x8(%rdx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x904d8
callq 0x173b0
callq 0x9049f