// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/eis-seqranges.c
// Function: gt_SRLAllSymbolsCountInSeqRegion
GtUword
gt_SRLAllSymbolsCountInSeqRegion(struct seqRangeList *rangeList,
                              GtUword start,
                              GtUword end,
                              seqRangeListSearchHint *hint)
{
  const struct seqRange *p;
  if (rangeList->numRanges == 0)
    return 0;
  p = gt_SRLFindPositionNext(rangeList, start, hint);
  if (p)
  {
    if (rangeList->partialSymSums)
    {
      const struct seqRange *q = gt_SRLFindPositionLast(rangeList, end, hint);
      if (!q)
      {
        /* in case
         * - end precedes first region
         * or
         * - start is after last region
         * no symbols can be encoded in range
         */
        return 0;
      }
      {
        size_t pOff = p - rangeList->ranges, qOff = q - rangeList->ranges;
        size_t numSyms = gt_MRAEncGetSize(rangeList->alphabet);
        GtUword symCount = 0;
        Symbol sym;
        unsigned symBits = rangeList->symBits;
        for (sym = 0; sym < numSyms; ++sym)
        {
          symCount += rangeList->partialSymSums[qOff * numSyms + sym]
            - rangeList->partialSymSums[pOff * numSyms + sym];
          /* two special cases: start might be inside p and end inside q */
        }
        if (start >= p->startPos)
          symCount -= start - p->startPos;

        {
          regionLength lastOverlap = GT_MIN(end - q->startPos,
                                         seqRangeLen(q, symBits));
          symCount += lastOverlap;
        }
        return symCount;
      }
    }
    else
    {
      GtUword symCount = 0;
      GtUword s = GT_MAX(start, p->startPos);
      struct seqRange *maxRange = rangeList->ranges + rangeList->numRanges - 1;
      unsigned symBits = rangeList->symBits;
      while (s < end)
      {
        symCount += GT_MIN(p->startPos + seqRangeLen(p, symBits), end) - s;
        if (p == maxRange)
          break;
        s = (++p)->startPos;
      }
      return symCount;
    }
  }
  else
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpq $0x0, 0x8(%rdi)
je 0x3199e2
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq %rcx, %rdx
callq 0x318eb5
testq %rax, %rax
je 0x3199e2
movq %rax, %r15
cmpq $0x0, 0x18(%r12)
je 0x31993e
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x31916d
testq %rax, %rax
je 0x3199e2
movq %rax, %r13
movq %rax, 0x8(%rsp)
movq 0x10(%r12), %rbp
movq 0x20(%r12), %rdi
callq 0x1a67a7
movl 0x28(%r12), %esi
testw %ax, %ax
je 0x3199f7
movzwl %ax, %eax
movq %r13, %rcx
subq %rbp, %rcx
sarq $0x4, %rcx
movq %r15, %rdx
subq %rbp, %rdx
sarq $0x4, %rdx
movq 0x18(%r12), %rdi
imulq %rax, %rcx
leaq (%rdi,%rcx,8), %rcx
imulq %rax, %rdx
leaq (%rdi,%rdx,8), %rdx
xorl %r8d, %r8d
xorl %r12d, %r12d
addq (%rcx,%r8,8), %r12
subq (%rdx,%r8,8), %r12
incq %r8
movzbl %r8b, %edi
cmpl %eax, %edi
jb 0x319926
jmp 0x3199fa
movq (%r15), %rax
cmpq %r14, %rax
cmovaq %rax, %r14
cmpq %rbx, %r14
jae 0x3199e2
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
shlq $0x4, %rax
addq %rcx, %rax
addq $-0x10, %rax
movq %rax, 0x10(%rsp)
movl 0x28(%r12), %eax
movl $0x40, %ecx
movq %rax, 0x8(%rsp)
subl %eax, %ecx
movl %ecx, (%rsp)
xorl %r12d, %r12d
movq %rbx, %rbp
movq (%r15), %rbx
leaq 0x8(%r15), %r13
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movl (%rsp), %edx
callq 0x2fcc2c
movq %rax, %rcx
addq %rbx, %rcx
movq %rbp, %rbx
movq %rbp, %rax
cmpq %rbp, %rcx
jae 0x3199c6
movq (%r15), %rbx
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movl (%rsp), %edx
callq 0x2fcc2c
addq %rbx, %rax
movq %rbp, %rbx
subq %r14, %rax
addq %rax, %r12
cmpq 0x10(%rsp), %r15
je 0x3199e5
movq 0x10(%r15), %r14
addq $0x10, %r15
cmpq %rbx, %r14
jb 0x319982
jmp 0x3199e5
xorl %r12d, %r12d
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
xorl %eax, %eax
subq (%r15), %r14
cmovaeq %r14, %rax
movq %rbx, %r15
movq 0x8(%rsp), %rbp
subq (%rbp), %r15
subq %rax, %r12
addq $0x8, %r13
movl $0x40, %r14d
subl %esi, %r14d
movq %r13, %rdi
movl %r14d, %edx
movq %rsi, (%rsp)
callq 0x2fcc2c
cmpq %rax, %r15
jae 0x319a39
subq (%rbp), %rbx
jmp 0x319a4b
movq %r13, %rdi
movq (%rsp), %rsi
movl %r14d, %edx
callq 0x2fcc2c
movq %rax, %rbx
movzwl %bx, %eax
addq %rax, %r12
jmp 0x3199e5