// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
pushq %rax
movq 0xa0(%rdi), %rcx
cmpq %rsi, (%rcx)
jae 0x1bcf9f
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x1bcfa6
movq 0x58(%rdi), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %r9
addq $-0x18, %r9
xorl %edx, %edx
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rax, %r11
movq %r9, %r10
xorl %ebx, %ebx
movq %r10, %r14
subq %r11, %r14
sarq $0x3, %r14
imulq %r8, %r14
shrq %r14
leaq (%r14,%r14,2), %r14
leaq (%r11,%r14,8), %r14
cmpq %rsi, 0x8(%r14)
jbe 0x1bcf8d
movq (%r14), %rdx
cmpl 0x68(%rdi), %ebx
jae 0x1bcfb6
addq $-0x18, %r14
movq %r14, %r10
jmp 0x1bcf9b
jae 0x1bcfde
cmpl 0x68(%rdi), %ebx
jae 0x1bcfeb
addq $0x18, %r14
movq %r14, %r11
incl %ebx
jmp 0x1bcf5d
xorl %eax, %eax
jmp 0x1bd081
leaq 0x8(%rcx), %r8
movq 0x38(%rdi), %rax
leaq (%rcx,%rax,8), %rdi
xorl %edx, %edx
jmp 0x1bd018
cmpq $0x0, (%r11)
je 0x1bd089
movq (%r10), %rdi
testq %rdi, %rdi
je 0x1bd089
movq %rcx, %r8
cmpq %rax, %r11
jbe 0x1bcfd8
movq -0x18(%r11), %r8
addq $0x8, %r8
jmp 0x1bd018
movq (%r14), %rax
testq %rax, %rax
jne 0x1bd065
callq 0x683d4
movq (%r11), %r8
testq %r8, %r8
je 0x1bd08e
cmpq $0x0, (%r10)
je 0x1bd08e
addq $0x8, %r8
cmpq %r9, %r10
jae 0x1bd010
movq 0x18(%r10), %rdi
jmp 0x1bd018
movq 0x38(%rdi), %rax
leaq (%rcx,%rax,8), %rdi
addq $-0x8, %rdi
cmpq %rdi, %r8
jbe 0x1bd026
movq %rdx, %rax
jmp 0x1bd060
movq %rdi, %r9
subq %r8, %r9
sarq %r9
andq $-0x8, %r9
leaq (%r8,%r9), %rax
cmpq %rsi, (%r8,%r9)
jbe 0x1bd04c
cmpq %rsi, -0x8(%rax)
jb 0x1bd065
leaq -0x8(%rax), %rdi
movq %rax, %rdx
jmp 0x1bd05b
jae 0x1bd065
leaq 0x8(%rax), %r8
cmpq %rsi, 0x8(%rax)
jae 0x1bd077
movq %rdx, %rax
cmpq %rdi, %r8
jbe 0x1bd026
testq %rax, %rax
je 0x1bd06e
subq %rcx, %rax
sarq $0x3, %rax
jmp 0x1bd081
movq $-0x1, %rax
jmp 0x1bd081
subq %rcx, %r8
sarq $0x3, %r8
movq %r8, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
callq 0x68446
callq 0x6840d