// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/eis-seqranges.c
// Function: gt_SRLFindPositionLast
struct seqRange *
gt_SRLFindPositionLast(struct seqRangeList *rangeList, GtUword pos,
                    seqRangeListSearchHint *hint)
{
  /* no ranges no matches in ranges */
  seqRangeListSearchHint hintCopy;
  size_t numRanges;
  struct seqRange *ranges;
  GT_UNUSED unsigned symBits;
  gt_assert(rangeList);
  ranges = rangeList->ranges;
  symBits = rangeList->symBits;
  if (hint)
    hintCopy = *hint;
  else
    gt_SRLInitListSearchHint(rangeList, &hintCopy);
  if ((numRanges = rangeList->numRanges) == 0)
  {
    return NULL;
  }
  if (ranges[0].startPos > pos)
    return NULL;
  else if (ranges[numRanges - 1].startPos <= pos)
  {
    return ranges + numRanges - 1;
  }
  else if ((hintCopy < numRanges - 1) && rangeLastMatch(hintCopy))
  {
    return ranges + hintCopy;
  }
  else if ((hintCopy < numRanges - 2) && rangeLastMatch(hintCopy + 1))
  {
    ++hintCopy;
    if (hint)
      *hint = hintCopy;
    return ranges + hintCopy;
  }
  else if (hintCopy && rangeLastMatch(hintCopy - 1))
  {
    --hintCopy;
    if (hint)
      *hint = hintCopy;
    return ranges + hintCopy;
  }
  else if (numRanges > 2)
  {
    GtUword searchPos = pos;
    struct seqRange *searchRes =
      bsearch(&searchPos, ranges, rangeList->numRanges - 1,
              sizeof (struct seqRange), posSeqRangeLastCompare);
    if (searchRes && hint)
      *hint = searchRes - ranges;
    return searchRes;
  }
  else /* numRanges <= 2 */
    return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2ae249
movq %rdx, %rbx
testq %rdx, %rdx
je 0x2ae13d
movq (%rbx), %rcx
movq 0x8(%rdi), %r8
jmp 0x2ae147
movq 0x8(%rdi), %r8
movq %r8, %rcx
shrq %rcx
testq %r8, %r8
je 0x2ae155
movq 0x10(%rdi), %r14
cmpq %rsi, (%r14)
jbe 0x2ae15f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq -0x1(%r8), %rdx
movq %rdx, %rax
shlq $0x4, %rax
cmpq %rsi, (%r14,%rax)
jbe 0x2ae1c0
cmpq %rdx, %rcx
jae 0x2ae18b
movq %rcx, %rax
shlq $0x4, %rax
cmpq %rsi, (%r14,%rax)
ja 0x2ae18b
addq %r14, %rax
cmpq %rsi, 0x10(%rax)
ja 0x2ae157
leaq -0x2(%r8), %rax
cmpq %rax, %rcx
jae 0x2ae1ce
leaq 0x1(%rcx), %rax
movq %rax, %rdi
shlq $0x4, %rdi
cmpq %rsi, (%r14,%rdi)
ja 0x2ae1ce
movq %rcx, %r9
shlq $0x4, %r9
cmpq %rsi, 0x20(%r14,%r9)
jbe 0x2ae1ce
addq %rdi, %r14
testq %rbx, %rbx
je 0x2ae1fb
movq %rax, (%rbx)
jmp 0x2ae1fb
shlq $0x4, %r8
leaq (%r14,%r8), %rax
addq $-0x10, %rax
jmp 0x2ae157
testq %rcx, %rcx
je 0x2ae203
movq %rcx, %rax
shlq $0x4, %rax
cmpq %rsi, -0x10(%r14,%rax)
ja 0x2ae203
addq %r14, %rax
cmpq %rsi, (%rax)
jbe 0x2ae203
decq %rcx
testq %rbx, %rbx
je 0x2ae1f4
movq %rcx, (%rbx)
shlq $0x4, %rcx
addq %rcx, %r14
movq %r14, %rax
jmp 0x2ae157
cmpq $0x3, %r8
jb 0x2ae155
movq %rsp, %rdi
movq %rsi, (%rdi)
leaq 0x67(%rip), %r8         # 0x2ae281
pushq $0x10
popq %rcx
movq %r14, %rsi
callq 0x17940
testq %rbx, %rbx
je 0x2ae157
testq %rax, %rax
je 0x2ae157
movq %rax, %rcx
subq %r14, %rcx
sarq $0x4, %rcx
movq %rcx, (%rbx)
jmp 0x2ae157
movq 0x189d18(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x36db9(%rip), %rsi     # 0x2e5013
leaq 0xd3d39(%rip), %rdx     # 0x381f9a
leaq 0xd3e26(%rip), %rcx     # 0x38208e
leaq 0xd3d11(%rip), %r8      # 0x381f80
movl $0x196, %r9d            # imm = 0x196
xorl %eax, %eax
callq 0x17a50
callq 0x17390