// File: /workspace/github_c_makefile_star2_O1/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 0x3165e5
movq %rdi, %r14
leaq 0x1ad9dd(%rip), %rax    # 0x4c3bc0
cmpq %rax, (%rdi)
jne 0x3165e5
movl %esi, %ebx
movq 0x8(%r14), %rax
cmpl %esi, 0x4(%rax)
jbe 0x3165ea
movq %r9, %rbp
movq %rcx, %r15
movq %rdx, %r13
movq 0xa8(%r14), %rdx
movl %ebx, %ecx
movl (%rdx,%rcx,4), %edx
cmpl $0x2, %edx
je 0x3164d2
cmpl $0x1, %edx
jne 0x31658b
testq %rax, %rax
je 0x3165ef
movq 0x10(%rax), %rax
movzwl (%rax,%rcx,2), %edi
movl 0xb4(%r14), %ecx
imull 0xb0(%r14), %ecx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
movq %r15, %rax
xorl %edx, %edx
divq %rcx
cmpq %rax, %rsi
movq %rdi, 0x18(%rsp)
movq %r14, %rdi
jne 0x31659a
movq %rsi, 0x38(%rsp)
movq %rbp, 0x40(%rsp)
movq %rbp, %rdx
callq 0x316e82
movq %rax, %rbx
movl 0xb0(%r14), %edi
movl 0xb4(%r14), %esi
movq %r13, %rax
xorl %edx, %edx
divq %rsi
movq %rax, %rcx
movq %r15, 0x20(%rsp)
movq %r15, %rax
xorl %edx, %edx
movq %rsi, 0x28(%rsp)
divq %rsi
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rbp
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, 0x48(%rsp)
movq 0x10(%rbx), %rdi
movl 0x4(%rbx), %esi
movzwl 0xc4(%r14), %edx
movl 0xe0(%r14), %ecx
movq 0xd0(%r14), %r8
movq 0x8(%rsp), %r9
callq 0x2fcf78
movl (%rbx), %r12d
movq %rbx, 0x10(%rsp)
movl 0x4(%rbx), %eax
movl 0xe0(%r14), %ecx
movl 0xc0(%r14), %edx
addq %rcx, %rdx
movl 0xb8(%r14), %ebx
addq %rdx, %rbx
addq %rax, %rbx
testq %rbp, %rbp
movq %r13, 0x30(%rsp)
movq %rbp, 0x50(%rsp)
je 0x31638a
movl 0x68(%r14), %edx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq %rbx, %rsi
movq %rdx, %r15
callq 0x2fba84
movl %eax, %r13d
cmpq %r13, 0x48(%r14)
jbe 0x3165db
movzwl 0xc4(%r14), %ecx
movl 0x60(%r14), %edx
movq 0x58(%r14), %rdi
movq %rdx, %rsi
imulq %rcx, %rsi
imulq %r13, %rsi
movq 0x8(%rsp), %r8
callq 0x2fd986
movq 0x50(%r14), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
movl 0x8(%rax,%rcx,8), %eax
addq %rax, %r12
movq %r15, %rdx
addq %r15, %rbx
decl %ebp
jne 0x316324
movq 0x18(%rsp), %rdx
shll $0x3, %edx
movq 0x8(%rsp), %r13
leaq (%rdx,%r13), %rdi
movq %rdi, 0x18(%rsp)
movq %r13, %rsi
callq 0x17660
movq %r12, (%rsp)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x317393
movq 0x48(%rsp), %r15
subl 0x50(%rsp), %r15d
je 0x31643c
movl 0x68(%r14), %r13d
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movq %rbx, %rsi
movl %r13d, %edx
callq 0x2fba84
movl %eax, %ebp
cmpq %rbp, 0x48(%r14)
jbe 0x3165e0
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 0x2fd986
movq 0x50(%r14), %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
movl 0x8(%rax,%rcx,8), %eax
addq %rax, %r12
addq %r13, %rbx
decl %r15d
jne 0x3163d9
movq %r12, (%rsp)
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %r12
movq %r12, %rdx
movq 0x28(%rsp), %rcx
movq 0x18(%rsp), %r13
movq %r13, %r8
movq %rbx, %r9
callq 0x317393
movl 0xb0(%r14), %eax
movq 0x38(%rsp), %rcx
imulq %rax, %rcx
movl 0xb4(%r14), %ebx
imulq %rcx, %rbx
movq 0x70(%r14), %rdi
movq 0x40(%rsp), %r15
addq $0x20, %r15
movq %rbx, %rsi
movq 0x30(%rsp), %rdx
movq %r15, %rcx
callq 0x319873
movzbl 0xc6(%r14), %ecx
movq 0x8(%rsp), %rdx
subq %rax, (%rdx,%rcx,8)
movq 0x70(%r14), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x319873
movzbl 0xc6(%r14), %ecx
subq %rax, (%r13,%rcx,8)
jmp 0x31658b
movq %r13, %rbx
movq %r15, 0x20(%rsp)
movq 0xa0(%r14), %rdi
callq 0x1a67a7
movzwl %ax, %r12d
movw %ax, 0x10(%rsp)
testw %ax, %ax
je 0x316539
leaq 0x20(%rbp), %r15
xorl %r13d, %r13d
movq 0xa0(%r14), %rax
cmpl $0x1, (%rax)
jne 0x3165d6
movq 0x70(%r14), %rdi
movzbl %r13b, %ecx
movzbl 0x118(%rax,%rcx), %ecx
xorl %esi, %esi
movq %rbx, %rdx
movq %r15, %r8
callq 0x3195ee
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x3164fb
cmpw $0x0, 0x10(%rsp)
movq 0x20(%rsp), %r13
je 0x31658b
movq 0x8(%rsp), %rax
leaq (%rax,%r12,8), %rbx
addq $0x20, %rbp
xorl %r15d, %r15d
movq 0xa0(%r14), %rax
cmpl $0x1, (%rax)
jne 0x3165d6
movq 0x70(%r14), %rdi
movzbl %r15b, %ecx
movzbl 0x118(%rax,%rcx), %ecx
xorl %esi, %esi
movq %r13, %rdx
movq %rbp, %r8
callq 0x3195ee
movq %rax, (%rbx,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x316556
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, %esi
movq %r13, %rdx
movq 0x8(%rsp), %r12
movq %r12, %rcx
movq %rbp, %r8
callq 0x315f6b
movq 0x18(%rsp), %rax
leaq (%r12,%rax,8), %rcx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movq %rbp, %r8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x315f6b
callq 0x173b0
callq 0x91b0f
callq 0x91b48
callq 0x91bb8
callq 0x91ad6
callq 0x91b81