// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0x4b12f3
movq 0x18acde(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x64d47(%rip), %rsi     # 0x516013
leaq 0x105ef3(%rip), %rdx    # 0x5b71c6
leaq 0x105fe0(%rip), %rcx    # 0x5b72ba
leaq 0x105ecb(%rip), %r8     # 0x5b71ac
movl $0x196, %r9d            # imm = 0x196
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x4b12f5
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x1c(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x4b1326
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
jmp 0x4b1335
movq 0x48(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4b08e0
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
jne 0x4b1357
movq $0x0, 0x50(%rsp)
jmp 0x4b15b3
movq 0x20(%rsp), %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
jbe 0x4b1374
movq $0x0, 0x50(%rsp)
jmp 0x4b15b3
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x4b13b2
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $-0x10, %rax
movq %rax, 0x50(%rsp)
jmp 0x4b15b3
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x4b141a
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x4b141a
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
jbe 0x4b141a
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
jmp 0x4b15b3
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jae 0x4b14b1
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x4b14b1
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
addq $0x1, %rcx
addq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
jbe 0x4b14b1
movq 0x30(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x4b1496
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
jmp 0x4b15b3
cmpq $0x0, 0x30(%rsp)
je 0x4b1536
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
ja 0x4b1536
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
subq $0x1, %rcx
addq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq 0x40(%rsp), %rax
jbe 0x4b1536
movq 0x30(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x4b151e
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x50(%rsp)
jmp 0x4b15b3
cmpq $0x2, 0x28(%rsp)
jbe 0x4b15aa
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rsi
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdx
subq $0x1, %rdx
leaq 0x10(%rsp), %rdi
movl $0x10, %ecx
leaq 0x55(%rip), %r8         # 0x4b15c0
callq 0x198e0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x4b159e
cmpq $0x0, 0x38(%rsp)
je 0x4b159e
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rax
subq %rax, %rcx
sarq $0x4, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x4b15b3
movq $0x0, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopl (%rax)