// File: /workspace/github_c_makefile_star2_O1/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 0x318c03
movq %rdx, %rbx
testq %rdx, %rdx
je 0x318bf4
movq %rdi, %r13
movq %rsi, 0x28(%rsp)
movq 0x20(%rdi), %rdi
cmpl $0x1, (%rdi)
jne 0x318c08
movzbl %cl, %eax
movb 0x18(%rdi,%rax), %r12b
movq 0x8(%r13), %r14
callq 0x1a67a7
movl %eax, %ecx
movq %rbx, %rax
xorl %edx, %edx
divq 0x30(%r13)
movzwl %cx, %r15d
cmpq $0x1, %rdx
sbbq $-0x1, %rax
movl 0x28(%r13), %ecx
movq %rcx, (%rsp)
movq %rax, 0x38(%rsp)
addq %r14, %rax
cmpq (%r13), %rax
movq %r14, %rbp
jbe 0x318987
movq %rbx, 0x10(%rsp)
movq 0x38(%rsp), %rax
leaq (%r14,%rax,2), %rbx
movq 0x10(%r13), %rdi
movq %rbx, %rsi
shlq $0x4, %rsi
leaq 0xd294d(%rip), %rdx     # 0x3eb291
movl $0x65, %ecx
callq 0x1094e6
movq %rax, 0x10(%r13)
movq 0x18(%r13), %rdi
testq %rdi, %rdi
je 0x31897b
movq %r15, %rsi
imulq %rbx, %rsi
shlq $0x3, %rsi
leaq 0xd2924(%rip), %rdx     # 0x3eb291
movl $0x69, %ecx
callq 0x1094e6
movq %rax, 0x18(%r13)
movq %rbx, (%r13)
movq %rbp, %r14
movq 0x10(%rsp), %rbx
movq %r14, %rdx
shlq $0x4, %rdx
addq 0x10(%r13), %rdx
movq %r14, %rax
imulq %r15, %rax
movq 0x18(%r13), %rcx
testq %rcx, %rcx
leaq (%rcx,%rax,8), %r14
cmoveq %rcx, %r14
movzbl %r12b, %eax
movl %eax, 0x18(%rsp)
cmpq %rbx, 0x30(%r13)
movq %r13, 0x30(%rsp)
jae 0x318b02
movl $0x40, %eax
subl (%rsp), %eax
movl %eax, 0x1c(%rsp)
leal (,%r15,8), %eax
movq %rax, 0x48(%rsp)
movq %r15, %rax
negq %rax
movq %rax, 0x40(%rsp)
movq %rbp, %r12
movq 0x28(%rsp), %rax
movq %rbx, 0x10(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, (%rdx)
movq %rdx, 0x8(%rsp)
leaq 0x8(%rdx), %rbp
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rbx
movq (%rsp), %r13
movl %r13d, %edx
movl 0x18(%rsp), %ecx
callq 0x2fdeb3
movq 0x30(%rbx), %rcx
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %r13
movl 0x1c(%rsp), %edx
callq 0x2fcd13
movq 0x30(%rbx), %rcx
testq %r12, %r12
je 0x318ab4
testq %r14, %r14
je 0x318ab4
movq %rcx, 0x50(%rsp)
movq %r12, 0x20(%rsp)
testq %r15, %r15
je 0x318a67
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 0x318a57
movq 0x8(%rsp), %rbp
leaq -0x8(%rbp), %r12
movq %r12, %rdi
movq (%rsp), %r13
movq %r13, %rsi
movl 0x1c(%rsp), %edx
callq 0x2fcc2c
movq %rax, %rbx
movq %r12, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x2fddcc
movzbl %al, %eax
addq %rbx, (%r14,%rax,8)
leaq (%r14,%r15,8), %r14
movq 0x30(%rsp), %r13
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %rbx
movq 0x50(%rsp), %rcx
jmp 0x318ae1
testq %r14, %r14
je 0x318ad4
movq %r14, %rdi
xorl %esi, %esi
movq 0x48(%rsp), %rdx
movq %rcx, %rbx
callq 0x173a0
movq %rbx, %rcx
leaq (%r14,%r15,8), %r14
jmp 0x318ad7
xorl %r14d, %r14d
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rbp
movq 0x28(%rsp), %rax
addq %rcx, %rax
subq %rcx, %rbx
addq $0x10, %rbp
incq %r12
cmpq 0x30(%r13), %rbx
movq %rbp, %rdx
ja 0x3189eb
jmp 0x318b0a
movq %rbp, %r12
movq 0x28(%rsp), %rax
movq %r12, 0x20(%rsp)
testq %rbx, %rbx
je 0x318bbd
movq %rax, (%rdx)
movq %rdx, 0x8(%rsp)
leaq 0x8(%rdx), %r12
movq %r12, %rdi
xorl %esi, %esi
movq (%rsp), %r13
movl %r13d, %edx
movl 0x18(%rsp), %ecx
callq 0x2fdeb3
movl $0x40, %ebp
subl %r13d, %ebp
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %edx
movq %rbx, %rcx
callq 0x2fcd13
movq 0x20(%rsp), %r12
testq %r12, %r12
je 0x318bc4
testq %r14, %r14
je 0x318bc4
testq %r15, %r15
je 0x318b85
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 0x318b75
movq 0x8(%rsp), %rbx
addq $-0x8, %rbx
movq %rbx, %rdi
movq (%rsp), %r13
movq %r13, %rsi
movl %ebp, %edx
callq 0x2fcc2c
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x2fddcc
movzbl %al, %eax
addq %r15, (%r14,%rax,8)
movq 0x30(%rsp), %r13
jmp 0x318bdf
movq 0x20(%rsp), %r12
jmp 0x318be2
testq %r14, %r14
movq 0x30(%rsp), %r13
je 0x318bdf
shll $0x3, %r15d
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x173a0
incq %r12
movq 0x38(%rsp), %rax
addq 0x8(%r13), %rax
cmpq %rax, %r12
jne 0x318c0d
movq %r12, 0x8(%r13)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x92297
callq 0x173b0
callq 0x9225e