// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/bsearch.c
// Function: bsearch_generic
static void* bsearch_generic(GtArray *members, const void *key,
                             const void *base, size_t nmemb, size_t size,
                             GtCompareWithData compar, void *data,
                             GtBittab *b)
{
  char *baseptr = (char *)base, *tmp_ptr,
   *ptr; /* the current element we consider */
  int limit, rval;

  gt_assert(key && size && compar);
  gt_assert(!b || gt_bittab_size(b) == nmemb);

  /* the actual binary search */
  for (limit = nmemb; limit != 0; limit >>= 1) {
    ptr = baseptr + (limit >> 1) * size;
    if ((rval = compar(key, ptr, data)) == 0) {
      /* element found */
      if (members)
        gt_array_add(members, ptr);
      else
        return ptr; /* because we got no <members> array */
      if (b) {
        /* mark found element */
        gt_bittab_set_bit(b, (ptr - (char *)base) / size);
      }
      /* looking left for equal elements */
      for (tmp_ptr = ptr - size;
           tmp_ptr >= (char *)base && !compar(key, tmp_ptr, data);
           tmp_ptr -= size) {
        gt_array_add(members, tmp_ptr);
        if (b)
          gt_bittab_set_bit(
            b, (tmp_ptr - (char *)base) / size); /* mark found element */
      }
      /* looking right for equal elements */
      for (tmp_ptr = ptr + size;
           tmp_ptr <(char *) base + nmemb * size && !compar(key, tmp_ptr, data);
           tmp_ptr += size) {
        gt_array_add(members, tmp_ptr);
        if (b)
          gt_bittab_set_bit(
            b, (tmp_ptr - (char *)base) / size); /* mark found element */
      }
      return ptr;
    }
    if (rval > 0) {
      baseptr = ptr + size;
      limit--;
    }
  }
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, 0x10(%rsp)
testq %rsi, %rsi
je 0xbd94d
movq %r8, %r14
testq %r8, %r8
je 0xbd94d
movq %r9, %rbx
testq %r9, %r9
je 0xbd94d
movq %rcx, %r15
movq %rdx, %rbp
movq %rsi, %r13
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd7c0
callq 0x71194
cmpq %r15, %rax
jne 0xbd952
testl %r15d, %r15d
je 0xbd80e
movq %r15, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movl %r15d, %eax
sarl %eax
movslq %eax, %r12
imulq %r14, %r12
addq %rbp, %r12
movq %r13, %rdi
movq %r12, %rsi
movq 0x60(%rsp), %rdx
callq *%rbx
testl %eax, %eax
je 0xbd823
addq %r14, %r12
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
cmovgq %r12, %rbp
subl %ecx, %r15d
movl %r15d, %eax
sarl %eax
cmpl $0x1, %r15d
movl %eax, %r15d
ja 0xbd7cf
xorl %r12d, %r12d
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x8(%rsp)
cmpq $0x0, 0x10(%rsp)
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rbp
je 0xbd811
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq 0x10(%rsp), %rdi
callq 0x6f240
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd86d
movq 0x8(%rsp), %rax
subq %rbp, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70d40
movq 0x8(%rsp), %r12
movq %r12, %rsi
subq %r14, %rsi
movq %rsi, (%rsp)
cmpq %rbp, %rsi
jb 0xbd8da
movq %r14, %r12
negq %r12
movq %r13, %rdi
movq 0x60(%rsp), %rdx
callq *%rbx
testl %eax, %eax
jne 0xbd8d5
movl $0x8, %edx
movq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x6f240
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd8c5
movq (%rsp), %rax
subq %rbp, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70d40
movq (%rsp), %rsi
addq %r12, %rsi
movq %rsi, (%rsp)
cmpq %rbp, %rsi
jae 0xbd887
movq 0x8(%rsp), %r12
imulq %r14, %r15
addq %rbp, %r15
leaq (%r12,%r14), %rsi
movq %rsi, (%rsp)
cmpq %r15, %rsi
jae 0xbd811
movq %rsp, %r12
movq %r13, %rdi
movq 0x60(%rsp), %rdx
callq *%rbx
testl %eax, %eax
jne 0xbd943
movl $0x8, %edx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x6f240
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd933
movq (%rsp), %rax
subq %rbp, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70d40
movq (%rsp), %rsi
addq %r14, %rsi
movq %rsi, (%rsp)
cmpq %r15, %rsi
jb 0xbd8f5
movq 0x8(%rsp), %r12
jmp 0xbd811
callq 0x296c4
callq 0x296fb