// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/eis-seqranges.c
// Function: gt_SRLFindPositionNext
struct seqRange *
gt_SRLFindPositionNext(struct seqRangeList *rangeList, GtUword pos,
                    seqRangeListSearchHint *hint)
{
  /* no ranges no matches in ranges */
  seqRangeListSearchHint hintCopy;
  size_t numRanges;
  struct seqRange *ranges;
  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
      || pos < ranges[0].startPos + seqRangeLen(ranges + 0, symBits))
  {
    return ranges + 0;
  }
  else if (hintCopy && rangeNextMatch(hintCopy))
  {
    return ranges + hintCopy;
  }
  else if ((numRanges > hintCopy + 1) && rangeNextMatch(hintCopy + 1))
  {
    ++hintCopy;
    if (hint)
      *hint = hintCopy;
    return rangeList->ranges + hintCopy;
  }
  else if (hintCopy && rangeNextMatch(hintCopy - 1))
  {
    --hintCopy;
    if (hint)
      *hint = hintCopy;
    return rangeList->ranges + hintCopy;
  }
  else if (numRanges > 2)
  {
    GtUword searchPos = pos;
    struct seqRange *searchRes =
      gt_bsearch_data(&searchPos, rangeList->ranges + 1,
                      rangeList->numRanges - 1, sizeof (struct seqRange),
                      posSeqRangeNextCompare, rangeList);
    if (searchRes && hint)
      *hint = searchRes - rangeList->ranges;
    return searchRes;
  }
  else /* numRanges <= 2 */
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x2ae092
movq %rsi, %r15
movq %rdi, %rbx
testq %rdx, %rdx
je 0x2ade95
movq (%rdx), %r14
movq 0x8(%rbx), %rbp
jmp 0x2ade9f
movq 0x8(%rbx), %rbp
movq %rbp, %r14
shrq %r14
testq %rbp, %rbp
je 0x2ae04d
movq 0x10(%rbx), %r12
movq (%r12), %r13
cmpq %r15, %r13
jae 0x2aded1
movq %rdx, 0x18(%rsp)
movl 0x28(%rbx), %esi
movq %r12, %rdi
movl %esi, 0x4(%rsp)
callq 0x2adb40
addq %r13, %rax
cmpq %r15, %rax
jbe 0x2aded9
movq %r12, %r13
jmp 0x2ae050
testq %r14, %r14
je 0x2adf31
movq %r14, %rax
shlq $0x4, %rax
leaq (%r12,%rax), %r13
movq (%r12,%rax), %rax
cmpq %r15, %rax
jae 0x2adf0d
movq %r13, %rdi
movl 0x4(%rsp), %esi
movq %rax, 0x8(%rsp)
callq 0x2adb40
addq 0x8(%rsp), %rax
cmpq %r15, %rax
jbe 0x2adf31
leaq -0x10(%r13), %rdi
movq -0x10(%r13), %rax
movq %rax, 0x8(%rsp)
movl 0x4(%rsp), %esi
callq 0x2adb40
addq 0x8(%rsp), %rax
cmpq %r15, %rax
jbe 0x2ae050
leaq 0x1(%r14), %rcx
cmpq %rcx, %rbp
jbe 0x2adfa6
movq %rcx, %r13
shlq $0x4, %r13
movq (%r12,%r13), %rax
cmpq %r15, %rax
movq %rcx, 0x8(%rsp)
jae 0x2adf76
movq %rax, 0x10(%rsp)
movq %r14, %rax
shlq $0x4, %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
movl 0x4(%rsp), %esi
callq 0x2adb40
addq 0x10(%rsp), %rax
cmpq %r15, %rax
jbe 0x2adfa6
movq %r14, %rax
shlq $0x4, %rax
leaq (%r12,%rax), %rdi
movq (%r12,%rax), %rax
movq %rax, 0x10(%rsp)
movl 0x4(%rsp), %esi
callq 0x2adb40
movq 0x8(%rsp), %rcx
addq 0x10(%rsp), %rax
cmpq %r15, %rax
jbe 0x2ae07f
testq %r14, %r14
je 0x2adffc
movq %r14, %r13
shlq $0x4, %r13
movq -0x10(%r12,%r13), %rax
cmpq %r15, %rax
jae 0x2adfdc
leaq (%r12,%r13), %rdi
addq $-0x10, %rdi
movl 0x4(%rsp), %esi
movq %rax, 0x8(%rsp)
callq 0x2adb40
addq 0x8(%rsp), %rax
cmpq %r15, %rax
jbe 0x2adffc
addq %r13, %r12
movq -0x20(%r12), %r13
addq $-0x20, %r12
movq %r12, %rdi
movl 0x4(%rsp), %esi
callq 0x2adb40
addq %r13, %rax
cmpq %r15, %rax
jbe 0x2ae062
cmpq $0x3, %rbp
jb 0x2ae04d
leaq 0x20(%rsp), %rdi
movq %r15, (%rdi)
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
addq $0x10, %rsi
decq %rdx
leaq 0xaa(%rip), %r8         # 0x2ae0ca
pushq $0x10
popq %rcx
movq %rbx, %r9
callq 0x5fb54
movq %rax, %r13
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x2ae050
testq %r13, %r13
je 0x2ae050
movq %r13, %rax
subq 0x10(%rbx), %rax
sarq $0x4, %rax
movq %rax, (%rcx)
jmp 0x2ae050
xorl %r13d, %r13d
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %r14
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x2ae072
movq %r14, (%rax)
shlq $0x4, %r14
addq 0x10(%rbx), %r14
movq %r14, %r13
jmp 0x2ae050
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x2ae08c
movq %rcx, (%rax)
addq 0x10(%rbx), %r13
jmp 0x2ae050
movq 0x189ecf(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x36f70(%rip), %rsi     # 0x2e5013
leaq 0xd3ef0(%rip), %rdx     # 0x381f9a
leaq 0xd3fc6(%rip), %rcx     # 0x382077
leaq 0xd3ec8(%rip), %r8      # 0x381f80
movl $0x140, %r9d            # imm = 0x140
xorl %eax, %eax
callq 0x17a50
callq 0x17390