// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
testq %rdi, %rdi
je 0x30ef84
movq %rsi, %r15
movq %rdi, %rbx
testq %rdx, %rdx
je 0x30ed61
movq (%rdx), %rbp
movq 0x8(%rbx), %r12
jmp 0x30ed6b
movq 0x8(%rbx), %r12
movq %r12, %rbp
shrq %rbp
testq %r12, %r12
je 0x30ef3f
movq 0x10(%rbx), %r14
movq (%r14), %r13
cmpq %r15, %r13
jae 0x30eda9
movq %rdx, 0x28(%rsp)
movl 0x28(%rbx), %esi
leaq 0x8(%r14), %rdi
movl $0x40, %edx
subl %esi, %edx
movq %rsi, 0x10(%rsp)
movl %edx, 0xc(%rsp)
callq 0x2f37dc
addq %r13, %rax
cmpq %r15, %rax
jbe 0x30edb1
movq %r14, %r13
jmp 0x30ef42
testq %rbp, %rbp
je 0x30ee14
movq %rbp, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %r13
movq (%r14,%rax), %rax
cmpq %r15, %rax
jae 0x30edeb
leaq 0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
movq %rax, 0x18(%rsp)
callq 0x2f37dc
addq 0x18(%rsp), %rax
cmpq %r15, %rax
jbe 0x30ee14
movq -0x10(%r13), %rax
movq %rax, 0x18(%rsp)
leaq -0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2f37dc
addq 0x18(%rsp), %rax
cmpq %r15, %rax
jbe 0x30ef42
leaq 0x1(%rbp), %rcx
cmpq %rcx, %r12
jbe 0x30ee97
movq %rcx, %r13
shlq $0x4, %r13
movq (%r14,%r13), %rax
cmpq %r15, %rax
movq %rcx, 0x18(%rsp)
jae 0x30ee5e
movq %rax, 0x20(%rsp)
movq %rbp, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0x18, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2f37dc
addq 0x20(%rsp), %rax
cmpq %r15, %rax
jbe 0x30ee97
movq %rbp, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0x8, %rdi
movq -0x8(%rdi), %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2f37dc
movq 0x18(%rsp), %rcx
addq 0x20(%rsp), %rax
cmpq %r15, %rax
jbe 0x30ef71
testq %rbp, %rbp
je 0x30eeec
movq %rbp, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %r13
movq -0x10(%r14,%rax), %r14
cmpq %r15, %r14
jae 0x30eecb
leaq -0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2f37dc
addq %r14, %rax
cmpq %r15, %rax
jbe 0x30eeec
movq -0x20(%r13), %r14
addq $-0x18, %r13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2f37dc
addq %r14, %rax
cmpq %r15, %rax
jbe 0x30ef54
cmpq $0x3, %r12
jb 0x30ef3f
leaq 0x30(%rsp), %rdi
movq %r15, (%rdi)
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
addq $0x10, %rsi
decq %rdx
leaq 0x79(%rip), %r8         # 0x30ef89
movl $0x10, %ecx
movq %rbx, %r9
callq 0xd7ff0
movq %rax, %r13
movq 0x28(%rsp), %rcx
testq %rcx, %rcx
je 0x30ef42
testq %r13, %r13
je 0x30ef42
movq %r13, %rax
subq 0x10(%rbx), %rax
sarq $0x4, %rax
movq %rax, (%rcx)
jmp 0x30ef42
xorl %r13d, %r13d
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %rbp
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x30ef64
movq %rbp, (%rax)
shlq $0x4, %rbp
addq 0x10(%rbx), %rbp
movq %rbp, %r13
jmp 0x30ef42
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x30ef7e
movq %rcx, (%rax)
addq 0x10(%rbx), %r13
jmp 0x30ef42
callq 0x905ba