// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-seqranges.c
// Function: gt_SRLSymbolCountInSeqRegion
GtUword
gt_SRLSymbolCountInSeqRegion(struct seqRangeList *rangeList,
                          GtUword start,
                          GtUword end,
                          Symbol esym,
                          seqRangeListSearchHint *hint)
{
  const struct seqRange *p;
  if (rangeList->numRanges == 0)
    return 0;
  p = gt_SRLFindPositionNext(rangeList, start, NULL);
  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;
        Symbol sym = MRAEncMapSymbol(rangeList->alphabet, esym);
        unsigned symBits = rangeList->symBits;
        symCount = rangeList->partialSymSums[qOff * numSyms + sym]
          - rangeList->partialSymSums[pOff * numSyms + sym];
        /* two special cases: start might be inside p and end inside q */
        if (sym == seqRangeSym(p, symBits) && start >= p->startPos)
          symCount -= start - p->startPos;
        if (sym == seqRangeSym(q, symBits))
        {
          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);
      Symbol sym = MRAEncMapSymbol(rangeList->alphabet, esym);
      unsigned symBits = rangeList->symBits;
      struct seqRange *maxRange = rangeList->ranges + rangeList->numRanges - 1;
      while (s < end)
      {
        if (seqRangeSym(p, symBits) == sym)
          symCount += GT_MIN(p->startPos + seqRangeLen(p, symBits), end) - s;
        if (p == maxRange)
          break;
        s = (++p)->startPos;
      }
      return symCount;
    }
  }
  else
    return 0;
}

// Assembly:
subq $0xc8, %rsp
movb %cl, %al
movq %rdi, 0xb8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdx, 0xa8(%rsp)
movb %al, 0xa7(%rsp)
movq %r8, 0x98(%rsp)
movq 0xb8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4b1bf0
movq $0x0, 0xc0(%rsp)
jmp 0x4b2006
movq 0xb8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4b0c80
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x90(%rsp)
je 0x4b1ffa
movq 0xb8(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4b1e5e
movq 0xb8(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x98(%rsp), %rdx
callq 0x4b12a0
movq %rax, 0x88(%rsp)
cmpq $0x0, 0x88(%rsp)
jne 0x4b1c74
movq $0x0, 0xc0(%rsp)
jmp 0x4b2006
movq 0x90(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
sarq $0x4, %rax
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq %rcx, %rax
sarq $0x4, %rax
movq %rax, 0x78(%rsp)
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x22aeb0
movzwl %ax, %eax
movq %rax, 0x70(%rsp)
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
movzbl 0xa7(%rsp), %esi
callq 0x4b05e0
movb %al, 0x67(%rsp)
movq 0xb8(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x60(%rsp)
movq 0xb8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x78(%rsp), %rcx
imulq 0x70(%rsp), %rcx
movzbl 0x67(%rsp), %edx
addq %rdx, %rcx
movq (%rax,%rcx,8), %rax
movq 0xb8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x80(%rsp), %rdx
imulq 0x70(%rsp), %rdx
movzbl 0x67(%rsp), %esi
addq %rsi, %rdx
subq (%rcx,%rdx,8), %rax
movq %rax, 0x68(%rsp)
movzbl 0x67(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0x90(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x4b06d0
movb %al, %cl
movl 0x34(%rsp), %eax
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x4b1da6
movq 0xb0(%rsp), %rax
movq 0x90(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x4b1da6
movq 0xb0(%rsp), %rcx
movq 0x90(%rsp), %rax
subq (%rax), %rcx
movq 0x68(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x68(%rsp)
movzbl 0x67(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x88(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x4b06d0
movb %al, %cl
movl 0x30(%rsp), %eax
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x4b1e4c
movq 0xa8(%rsp), %rax
movq 0x88(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x28(%rsp)
movq 0x88(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x4b1e1d
movq 0xa8(%rsp), %rax
movq 0x88(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x20(%rsp)
jmp 0x4b1e33
movq 0x88(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x4b06a0
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movw %ax, 0x5e(%rsp)
movzwl 0x5e(%rsp), %eax
addq 0x68(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x4b2006
movq $0x0, 0x50(%rsp)
movq 0xb0(%rsp), %rax
movq 0x90(%rsp), %rcx
cmpq (%rcx), %rax
jbe 0x4b1e8b
movq 0xb0(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x4b1e9b
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
movzbl 0xa7(%rsp), %esi
callq 0x4b05e0
movb %al, 0x47(%rsp)
movq 0xb8(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x40(%rsp)
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xb8(%rsp), %rcx
movq 0x8(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $-0x10, %rax
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x4b1feb
movq 0x90(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x4b06d0
movzbl %al, %eax
movzbl 0x47(%rsp), %ecx
cmpl %ecx, %eax
jne 0x4b1fb5
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x90(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq 0x10(%rsp), %rax
addq %rcx, %rax
cmpq 0xa8(%rsp), %rax
jae 0x4b1f94
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x90(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x4b06a0
movq %rax, %rcx
movq (%rsp), %rax
addq %rcx, %rax
movq %rax, 0x8(%rsp)
jmp 0x4b1fa1
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
subq 0x48(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x90(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x4b1fc6
jmp 0x4b1feb
movq 0x90(%rsp), %rax
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, 0x90(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x4b1ef9
movq 0x50(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x4b2006
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)