// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rcx, 0x90(%rsp)
movq 0xa8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4b2067
movq $0x0, 0xb0(%rsp)
jmp 0x4b23fd
movq 0xa8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x4b0c80
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
je 0x4b23f1
movq 0xa8(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4b2293
movq 0xa8(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x4b12a0
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x4b20ef
movq $0x0, 0xb0(%rsp)
jmp 0x4b23fd
movq 0x88(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
sarq $0x4, %rax
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
sarq $0x4, %rax
movq %rax, 0x70(%rsp)
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x22aeb0
movzwl %ax, %eax
movq %rax, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq 0xa8(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x58(%rsp)
movb $0x0, 0x5f(%rsp)
movzbl 0x5f(%rsp), %eax
cmpq 0x68(%rsp), %rax
jae 0x4b21cd
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x70(%rsp), %rcx
imulq 0x68(%rsp), %rcx
movzbl 0x5f(%rsp), %edx
addq %rdx, %rcx
movq (%rax,%rcx,8), %rax
movq 0xa8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x78(%rsp), %rdx
imulq 0x68(%rsp), %rdx
movzbl 0x5f(%rsp), %esi
addq %rsi, %rdx
subq (%rcx,%rdx,8), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
movb 0x5f(%rsp), %al
addb $0x1, %al
movb %al, 0x5f(%rsp)
jmp 0x4b2165
movq 0xa0(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x4b2202
movq 0xa0(%rsp), %rcx
movq 0x88(%rsp), %rax
subq (%rax), %rcx
movq 0x60(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0x98(%rsp), %rax
movq 0x80(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x28(%rsp)
movq 0x80(%rsp), %rdi
movl 0x58(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x4b2252
movq 0x98(%rsp), %rax
movq 0x80(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x20(%rsp)
jmp 0x4b2268
movq 0x80(%rsp), %rdi
movl 0x58(%rsp), %esi
callq 0x4b06a0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movw %ax, 0x56(%rsp)
movzwl 0x56(%rsp), %eax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x4b23fd
movq $0x0, 0x48(%rsp)
movq 0xa0(%rsp), %rax
movq 0x88(%rsp), %rcx
cmpq (%rcx), %rax
jbe 0x4b22c0
movq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x4b22d0
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xa8(%rsp), %rcx
movq 0x8(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $-0x10, %rax
movq %rax, 0x38(%rsp)
movq 0xa8(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x34(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x98(%rsp), %rax
jae 0x4b23e2
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x88(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rax
cmpq 0x98(%rsp), %rax
jae 0x4b238b
movq 0x88(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x88(%rsp), %rdi
movl 0x34(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq (%rsp), %rax
addq %rcx, %rax
movq %rax, 0x8(%rsp)
jmp 0x4b2398
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
subq 0x40(%rsp), %rax
addq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x88(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x4b23bd
jmp 0x4b23e2
movq 0x88(%rsp), %rax
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, 0x88(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x4b2311
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x4b23fd
movq $0x0, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
addq $0xb8, %rsp
retq
nopl (%rax)