// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/randomcodes.c
// Function: gt_randomcodes_find_accu
GtUword gt_randomcodes_find_accu(const GtRandomcodesinfo *fci,
                                       GtUword code)
{
  const GtUword *found = NULL, *leftptr = NULL, *midptr, *rightptr = NULL;

  if (code <= fci->allrandomcodes[0])
  {
    return 0;
  }
  if (fci->binsearchcache.spaceGtIndexwithcodeRC != NULL)
  {
    const GtIndexwithcodeRC *leftic, *midic, *rightic;
    unsigned int depth;

    leftic = fci->binsearchcache.spaceGtIndexwithcodeRC;
    rightic = fci->binsearchcache.spaceGtIndexwithcodeRC +
              fci->binsearchcache.nextfreeGtIndexwithcodeRC - 1;
    for (depth = 0; /* Nothing */; depth++)
    {
      midic = leftic + GT_DIV2((GtUword) (rightic-leftic));
      if (code < midic->code)
      {
        found = midic->ptr;
        if (depth < fci->binsearchcache.depth)
        {
          rightic = midic - 1;
        } else
        {
          gt_assert(leftic->ptr != NULL && rightic->ptr != NULL);
          if (leftic > fci->binsearchcache.spaceGtIndexwithcodeRC)
          {
            leftptr = (leftic-1)->ptr + 1;
          } else
          {
            gt_assert(code > fci->allrandomcodes[0]);
            leftptr = fci->allrandomcodes + 1;
          }
          rightptr = rightic->ptr - 1;
          break;
        }
      } else
      {
        if (code > midic->code)
        {
          if (depth < fci->binsearchcache.depth)
          {
            leftic = midic + 1;
          } else
          {
            gt_assert(leftic->ptr != NULL && rightic->ptr != NULL);
            leftptr = leftic->ptr + 1;
            if (rightic < fci->binsearchcache.spaceGtIndexwithcodeRC +
                          fci->binsearchcache.nextfreeGtIndexwithcodeRC - 1)
            {
              rightptr = (rightic+1)->ptr - 1;
            } else
            {
              rightptr = fci->allrandomcodes + fci->differentcodes - 1;
            }
            break;
          }
        } else
        {
          gt_assert(midic->ptr != NULL);
          return (GtUword) (midic->ptr - fci->allrandomcodes);
        }
      }
    }
    gt_assert(leftptr != NULL && rightptr != NULL);
  } else
  {
    leftptr = fci->allrandomcodes + 1;
    rightptr = fci->allrandomcodes + fci->differentcodes - 1;
  }
  while (leftptr <= rightptr)
  {
    midptr = leftptr + GT_DIV2((GtUword) (rightptr-leftptr));
    if (code < *midptr)
    {
      rightptr = midptr - 1;
      if (code > *rightptr)
      {
        return (GtUword) (midptr - fci->allrandomcodes);
      }
      found = midptr;
    } else
    {
      if (code > *midptr)
      {
        leftptr = midptr + 1;
        if (code <= *leftptr)
        {
          return (GtUword) (leftptr - fci->allrandomcodes);
        }
      } else
      {
        gt_assert(midptr != NULL);
        return (GtUword) (midptr - fci->allrandomcodes);
      }
    }
  }
 return (found != NULL) ? (GtUword) (found - fci->allrandomcodes)
                         : ULONG_MAX;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0xa0(%rdi), %rcx
cmpq %rsi, (%rcx)
jae 0x16c8a5
movq 0x48(%rdi), %r9
testq %r9, %r9
je 0x16c8ac
imulq $0x18, 0x58(%rdi), %rax
leaq (%r9,%rax), %r10
addq $-0x18, %r10
xorl %r8d, %r8d
pushq $0x18
popq %r14
movq %r9, %rbx
movq %r10, %r11
xorl %ebp, %ebp
movq %r11, %rax
subq %rbx, %rax
cqto
idivq %r14
shrq %rax
imulq $0x18, %rax, %rdx
leaq (%rbx,%rdx), %rax
cmpq %rsi, 0x8(%rbx,%rdx)
jbe 0x16c893
movq (%rax), %r8
cmpl 0x68(%rdi), %ebp
jae 0x16c8bd
addq $-0x18, %rax
movq %rax, %r11
jmp 0x16c8a1
jae 0x16c8e5
cmpl 0x68(%rdi), %ebp
jae 0x16c8fd
addq $0x18, %rax
movq %rax, %rbx
incl %ebp
jmp 0x16c865
xorl %eax, %eax
jmp 0x16c985
leaq 0x8(%rcx), %rdx
movq 0x38(%rdi), %rax
leaq (%rcx,%rax,8), %rdi
xorl %r8d, %r8d
jmp 0x16c92a
cmpq $0x0, (%rbx)
je 0x16c98a
movq (%r11), %rdi
testq %rdi, %rdi
je 0x16c98a
movq %rcx, %rdx
cmpq %r9, %rbx
jbe 0x16c8df
movq -0x18(%rbx), %rdx
addq $0x8, %rdx
jmp 0x16c92a
movq (%rax), %rax
testq %rax, %rax
je 0x16c9e6
subq %rcx, %rax
sarq $0x3, %rax
jmp 0x16c985
movq (%rbx), %rdx
testq %rdx, %rdx
je 0x16c9b8
cmpq $0x0, (%r11)
je 0x16c9b8
addq $0x8, %rdx
cmpq %r10, %r11
jae 0x16c922
movq 0x18(%r11), %rdi
jmp 0x16c92a
movq 0x38(%rdi), %rax
leaq (%rcx,%rax,8), %rdi
addq $-0x8, %rdi
cmpq %rdi, %rdx
ja 0x16c971
movq %rdi, %r9
subq %rdx, %r9
sarq %r9
andq $-0x8, %r9
leaq (%rdx,%r9), %rax
cmpq %rsi, (%rdx,%r9)
jbe 0x16c959
leaq -0x8(%rax), %rdi
movq %rax, %r8
cmpq %rsi, -0x8(%rax)
jae 0x16c92e
jmp 0x16c8f1
jae 0x16c8f1
leaq 0x8(%rax), %rdx
cmpq %rsi, 0x8(%rax)
jb 0x16c92e
subq %rcx, %rdx
sarq $0x3, %rdx
movq %rdx, %rax
jmp 0x16c985
testq %r8, %r8
je 0x16c982
subq %rcx, %r8
sarq $0x3, %r8
movq %r8, %rax
jmp 0x16c985
pushq $-0x1
popq %rax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x2cb5d7(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x178678(%rip), %rsi    # 0x2e5013
leaq 0x1dfa06(%rip), %rdx    # 0x34c3a8
leaq 0x1dfa2b(%rip), %rcx    # 0x34c3d4
leaq 0x1dfa3d(%rip), %r8     # 0x34c3ed
movl $0xb3, %r9d
jmp 0x16ca12
movq 0x2cb5a9(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17864a(%rip), %rsi    # 0x2e5013
leaq 0x1df9d8(%rip), %rdx    # 0x34c3a8
leaq 0x1df9fd(%rip), %rcx    # 0x34c3d4
leaq 0x1dfa0f(%rip), %r8     # 0x34c3ed
movl $0xc8, %r9d
jmp 0x16ca12
movq 0x2cb57b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17861c(%rip), %rsi    # 0x2e5013
leaq 0x1dfa07(%rip), %rdx    # 0x34c405
leaq 0x1df9cf(%rip), %rcx    # 0x34c3d4
leaq 0x1df9e1(%rip), %r8     # 0x34c3ed
movl $0xd6, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390