// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/eis-blockcomp.c
// Function: blockCompSeqPosPairRangeRank
static void
blockCompSeqPosPairRangeRank(struct encIdxSeq *eSeqIdx, AlphabetRangeID range,
                             GtUword posA, GtUword posB,
                             GtUword *rankCounts, union EISHint *hint)
{
  struct blockCompositionSeq *seqIdx;
  gt_assert(eSeqIdx && eSeqIdx->classInfo == &blockCompositionSeqClass);
  seqIdx = encIdxSeq2blockCompositionSeq(eSeqIdx);
  gt_assert(range < MRAEncGetNumRanges(EISGetAlphabet(eSeqIdx)));
  switch (seqIdx->modes[range])
  {
  case BLOCK_COMPOSITION_INCLUDE:
    {
      BitOffset varDataMemOffset, cwIdxMemOffset;
      struct superBlock *sBlock;
      AlphabetRangeSize rsize = MRAEncGetRangeSize(eSeqIdx->alphabet, range);
      /* Only when both positions are in same bucket, special treatment
       * makes sense. */
      GtUword bucketNum = bucketNumFromPos(seqIdx, posA);
      if (bucketNum != bucketNumFromPos(seqIdx, posB))
      {
        blockCompSeqRangeRank(eSeqIdx, range, posA, rankCounts, hint);
        blockCompSeqRangeRank(eSeqIdx, range, posB, rankCounts + rsize, hint);
        return;
      }
#ifdef USE_SBLOCK_CACHE
      sBlock = cacheFetchSuperBlock(seqIdx, bucketNum,
                                    &hint->bcHint.sBlockCache);
#else
      sBlock = fetchSuperBlock(seqIdx, bucketNum, NULL);
#endif
      {
        GtUword blockNumA = blockNumFromPos(seqIdx, posA),
          blockNumB = blockNumFromPos(seqIdx, posB);
        unsigned blockSize = seqIdx->blockSize,
          inBucketBlockNumA = blockNumA % seqIdx->bucketBlocks,
          inBucketBlockNumB = blockNumB % seqIdx->bucketBlocks;
        sBlockGetPartialSymSums(sBlock, seqIdx, rankCounts);
        walkCompIndicesPrefix(
          seqIdx, sBlock, inBucketBlockNumA, cwIdxMemOffset,
          addSymCountsFromComposition(&seqIdx->compositionTable,
                                      seqIdx->blockMapAlphabetSize, compIndex,
                                      rankCounts);,
          varDataMemOffset);
        memcpy(rankCounts + rsize, rankCounts, rsize * sizeof (rankCounts[0]));
        adjustRanksForBlock(seqIdx, sBlock, posA, blockSize, rankCounts,
                            cwIdxMemOffset, varDataMemOffset);
        walkCompIndices(
          seqIdx, sBlock, inBucketBlockNumB - inBucketBlockNumA, cwIdxMemOffset,
          addSymCountsFromComposition(&seqIdx->compositionTable,
                                      seqIdx->blockMapAlphabetSize, compIndex,
                                      rankCounts + rsize);,
          varDataMemOffset);
        adjustRanksForBlock(seqIdx, sBlock, posB, blockSize,
                            rankCounts + rsize,
                            cwIdxMemOffset, varDataMemOffset);
        {
          GtUword base = bucketBasePos(seqIdx, bucketNum);
          rankCounts[seqIdx->blockEncFallback]
            -= gt_SRLAllSymbolsCountInSeqRegion(
              seqIdx->rangeEncs, base, posA, &hint->bcHint.rangeHint);
          rankCounts[rsize + seqIdx->blockEncFallback]
            -= gt_SRLAllSymbolsCountInSeqRegion(
              seqIdx->rangeEncs, base, posB, &hint->bcHint.rangeHint);
        }
      }
#ifndef USE_SBLOCK_CACHE
      deleteSuperBlock(sBlock);
#endif
    }
    break;
  case REGIONS_LIST:
    {
      AlphabetRangeSize sym,
        rangeEncNumSyms = gt_MRAEncGetSize(seqIdx->rangeMapAlphabet);
      for (sym = 0; sym < rangeEncNumSyms; ++sym)
        rankCounts[sym] = gt_SRLSymbolCountInSeqRegion(
          seqIdx->rangeEncs, 0, posA,
          MRAEncRevMapSymbol(seqIdx->rangeMapAlphabet, sym),
          &hint->bcHint.rangeHint);
      for (sym = 0; sym < rangeEncNumSyms; ++sym)
        rankCounts[sym + rangeEncNumSyms]
          = gt_SRLSymbolCountInSeqRegion(
            seqIdx->rangeEncs, 0, posB,
            MRAEncRevMapSymbol(seqIdx->rangeMapAlphabet, sym),
            &hint->bcHint.rangeHint);
    }
    break;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, 0x8(%rsp)
testq %rdi, %rdi
je 0x30c37c
movq %rdi, %r14
leaq 0x1acc23(%rip), %rax    # 0x4b8bb0
cmpq %rax, (%rdi)
jne 0x30c37c
movl %esi, %ebp
movq 0x8(%r14), %rax
cmpl %esi, 0x4(%rax)
jbe 0x30c381
movq %r9, %r13
movq %rdx, %r15
movq %rcx, 0x20(%rsp)
movq 0xa8(%r14), %rdx
movl %ebp, %ecx
movl (%rdx,%rcx,4), %edx
cmpl $0x2, %edx
je 0x30c272
cmpl $0x1, %edx
jne 0x30c324
movq 0x10(%rax), %rax
movzwl (%rax,%rcx,2), %r12d
movl 0xb4(%r14), %ecx
imull 0xb0(%r14), %ecx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
movq 0x20(%rsp), %rbx
movq %rbx, %rax
xorl %edx, %edx
divq %rcx
cmpq %rax, %rsi
jne 0x30c333
movq %r12, 0x18(%rsp)
movq %r14, %rdi
movq %rsi, 0x38(%rsp)
movq %r13, 0x40(%rsp)
movq %r13, %rdx
callq 0x30cc26
movq %rax, %r13
movl 0xb0(%r14), %edi
movl 0xb4(%r14), %esi
movq %r15, 0x30(%rsp)
movq %r15, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %rcx
movq %rbx, %rax
xorl %edx, %edx
movq %rsi, 0x28(%rsp)
divq %rsi
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rbx
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, 0x48(%rsp)
movl 0x4(%r13), %esi
movq 0x10(%r13), %rdi
movzwl 0xc4(%r14), %edx
movl 0xe0(%r14), %ecx
movq 0xd0(%r14), %r8
movq 0x8(%rsp), %r9
callq 0x2f3abd
movl (%r13), %r12d
movq %r13, 0x10(%rsp)
movl 0x4(%r13), %eax
movl 0xc0(%r14), %ecx
movl 0xe0(%r14), %edx
addq %rcx, %rdx
movl 0xb8(%r14), %r13d
addq %rdx, %r13
addq %rax, %r13
testq %rbx, %rbx
movq %rbx, 0x50(%rsp)
je 0x30c12b
movl 0x68(%r14), %edx
movl %ebx, %ebp
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r13, %rsi
movq %rdx, %r15
callq 0x2f2688
movl %eax, %ebx
cmpq %rbx, 0x48(%r14)
jbe 0x30c372
movzwl 0xc4(%r14), %ecx
movl 0x60(%r14), %edx
movq 0x58(%r14), %rdi
movq %rdx, %rsi
imulq %rcx, %rsi
imulq %rbx, %rsi
movq 0x8(%rsp), %r8
callq 0x2f44ef
movq 0x50(%r14), %rax
leaq (%rbx,%rbx,2), %rcx
movl 0x8(%rax,%rcx,8), %eax
addq %rax, %r12
movq %r15, %rdx
addq %r15, %r13
decl %ebp
jne 0x30c0cd
movq 0x18(%rsp), %rdx
shll $0x3, %edx
movq 0x8(%rsp), %rbx
leaq (%rbx,%rdx), %rdi
movq %rdi, 0x18(%rsp)
movq %rbx, %rsi
callq 0x17660
movq %r12, (%rsp)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %rbx, %r8
movq %r13, %r9
callq 0x30d183
movq 0x48(%rsp), %r15
subl 0x50(%rsp), %r15d
je 0x30c1dc
movl 0x68(%r14), %ebx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq %r13, %rsi
movl %ebx, %edx
callq 0x2f2688
movl %eax, %ebp
cmpq %rbp, 0x48(%r14)
jbe 0x30c377
movzwl 0xc4(%r14), %ecx
movl 0x60(%r14), %edx
movq 0x58(%r14), %rdi
movq %rdx, %rsi
imulq %rcx, %rsi
imulq %rbp, %rsi
movq 0x18(%rsp), %r8
callq 0x2f44ef
movq 0x50(%r14), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movl 0x8(%rax,%rcx,8), %eax
addq %rax, %r12
addq %rbx, %r13
decl %r15d
jne 0x30c17a
movq %r12, (%rsp)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %r15
movq %r15, %rdx
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %rbp
movq %rbp, %r8
movq %r13, %r9
callq 0x30d183
movl 0xb0(%r14), %eax
movl 0xb4(%r14), %ecx
movq 0x38(%rsp), %r12
imulq %rax, %r12
imulq %rcx, %r12
movq 0x70(%r14), %rdi
movq 0x40(%rsp), %rbx
addq $0x20, %rbx
movq %r12, %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq 0x30f6e7
movzbl 0xc6(%r14), %ecx
movq 0x8(%rsp), %rdx
subq %rax, (%rdx,%rcx,8)
movq 0x70(%r14), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x30f6e7
movzbl 0xc6(%r14), %ecx
subq %rax, (%rbp,%rcx,8)
jmp 0x30c324
movq 0xa0(%r14), %rdi
callq 0x19e077
testw %ax, %ax
je 0x30c324
movq %r15, %rbx
addq $0x20, %r13
movw %ax, 0x10(%rsp)
movzwl %ax, %r15d
xorl %r12d, %r12d
movq 0x8(%rsp), %rbp
movq 0xa0(%r14), %rax
cmpl $0x1, (%rax)
jne 0x30c36d
movq 0x70(%r14), %rdi
movzbl %r12b, %ecx
movzbl 0x118(%rax,%rcx), %ecx
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %r8
callq 0x30f462
movq %rax, (%rbp,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x30c29f
cmpw $0x0, 0x10(%rsp)
je 0x30c324
movq 0x8(%rsp), %rax
leaq (%rax,%r15,8), %rbx
xorl %r12d, %r12d
movq 0xa0(%r14), %rax
cmpl $0x1, (%rax)
jne 0x30c36d
movq 0x70(%r14), %rdi
movzbl %r12b, %ecx
movzbl 0x118(%rax,%rcx), %ecx
xorl %esi, %esi
movq 0x20(%rsp), %rdx
movq %r13, %r8
callq 0x30f462
movq %rax, (%rbx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x30c2ed
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
movq 0x8(%rsp), %r15
movq %r15, %rcx
movq %r13, %r8
callq 0x30bd15
leaq (%r15,%r12,8), %rcx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %r13, %r8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x30bd15
callq 0x173b0
callq 0x8fd87
callq 0x8fdc0
callq 0x8fdf9
callq 0x8fd4e