// File: /workspace/github_c_makefile_star2_O1/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 0x319101
movq %rsi, %r15
movq %rdi, %rbx
testq %rdx, %rdx
je 0x318edc
movq (%rdx), %r12
jmp 0x318ee3
movq 0x8(%rbx), %r12
shrq %r12
movq 0x8(%rbx), %rbp
testq %rbp, %rbp
je 0x3190bc
movq 0x10(%rbx), %r14
movq (%r14), %r13
cmpq %r15, %r13
jae 0x318f25
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 0x2fcc2c
addq %r13, %rax
cmpq %r15, %rax
jbe 0x318f2d
movq %r14, %r13
jmp 0x3190bf
testq %r12, %r12
je 0x318f90
movq %r12, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %r13
movq (%r14,%rax), %rax
cmpq %r15, %rax
jae 0x318f67
leaq 0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
movq %rax, 0x18(%rsp)
callq 0x2fcc2c
addq 0x18(%rsp), %rax
cmpq %r15, %rax
jbe 0x318f90
movq -0x10(%r13), %rax
movq %rax, 0x18(%rsp)
leaq -0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2fcc2c
addq 0x18(%rsp), %rax
cmpq %r15, %rax
jbe 0x3190bf
leaq 0x1(%r12), %rcx
cmpq %rcx, %rbp
jbe 0x319014
movq %rcx, %r13
shlq $0x4, %r13
movq (%r14,%r13), %rax
cmpq %r15, %rax
movq %rcx, 0x18(%rsp)
jae 0x318fdb
movq %rax, 0x20(%rsp)
movq %r12, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0x18, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2fcc2c
addq 0x20(%rsp), %rax
cmpq %r15, %rax
jbe 0x319014
movq %r12, %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 0x2fcc2c
movq 0x18(%rsp), %rcx
addq 0x20(%rsp), %rax
cmpq %r15, %rax
jbe 0x3190ee
testq %r12, %r12
je 0x319069
movq %r12, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %r13
movq -0x10(%r14,%rax), %r14
cmpq %r15, %r14
jae 0x319048
leaq -0x8(%r13), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2fcc2c
addq %r14, %rax
cmpq %r15, %rax
jbe 0x319069
movq -0x20(%r13), %r14
addq $-0x18, %r13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0x2fcc2c
addq %r14, %rax
cmpq %r15, %rax
jbe 0x3190d1
cmpq $0x3, %rbp
jb 0x3190bc
leaq 0x30(%rsp), %rdi
movq %r15, (%rdi)
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
addq $0x10, %rsi
decq %rdx
leaq 0x79(%rip), %r8         # 0x319106
movl $0x10, %ecx
movq %rbx, %r9
callq 0xda650
movq %rax, %r13
movq 0x28(%rsp), %rcx
testq %rcx, %rcx
je 0x3190bf
testq %r13, %r13
je 0x3190bf
movq %r13, %rax
subq 0x10(%rbx), %rax
sarq $0x4, %rax
movq %rax, (%rcx)
jmp 0x3190bf
xorl %r13d, %r13d
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decq %r12
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x3190e1
movq %r12, (%rax)
shlq $0x4, %r12
addq 0x10(%rbx), %r12
movq %r12, %r13
jmp 0x3190bf
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x3190fb
movq %rcx, (%rax)
addq 0x10(%rbx), %r13
jmp 0x3190bf
callq 0x92379