// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
testq %rsi, %rsi
je 0xbc8e3
movq %r8, %r14
testq %r8, %r8
je 0xbc8e3
movq %r9, %rbx
testq %r9, %r9
je 0xbc8e3
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbc754
callq 0x70bd9
cmpq %r15, %rax
jne 0xbc8e8
testl %r15d, %r15d
je 0xbc7ac
movq 0x60(%rsp), %rbp
movq %r15, 0x20(%rsp)
movq %r12, 0x10(%rsp)
movl %r15d, %eax
sarl %eax
movslq %eax, %rsi
imulq %r14, %rsi
addq %r12, %rsi
movq %rsi, 0x8(%rsp)
movq %r13, %rdi
movq %rbp, %rdx
callq *%rbx
testl %eax, %eax
je 0xbc7b3
movq 0x8(%rsp), %rcx
addq %r14, %rcx
xorl %edx, %edx
testl %eax, %eax
setg %dl
cmovgq %rcx, %r12
subl %edx, %r15d
movl %r15d, %eax
sarl %eax
cmpl $0x1, %r15d
movl %eax, %r15d
ja 0xbc768
xorl %eax, %eax
jmp 0xbc8d4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xbc8cf
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x6ec0e
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %r15
je 0xbc7f4
movq 0x8(%rsp), %rax
subq %r15, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70790
movq 0x8(%rsp), %rsi
subq %r14, %rsi
movq %rsi, (%rsp)
cmpq %r15, %rsi
jb 0xbc85c
movq %r14, %r12
negq %r12
movq 0x10(%rsp), %r15
movq %r13, %rdi
movq %rbp, %rdx
callq *%rbx
testl %eax, %eax
jne 0xbc85c
movl $0x8, %edx
movq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x6ec0e
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbc84c
movq (%rsp), %rax
subq %r15, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70790
movq (%rsp), %rsi
addq %r12, %rsi
movq %rsi, (%rsp)
cmpq %r15, %rsi
jae 0xbc810
movq 0x20(%rsp), %rax
imulq %r14, %rax
addq 0x10(%rsp), %rax
movq 0x8(%rsp), %rsi
addq %r14, %rsi
movq %rsi, (%rsp)
cmpq %rax, %rsi
movq 0x18(%rsp), %r15
jae 0xbc8cf
movq %rax, %r12
movq %r13, %rdi
movq %rbp, %rdx
callq *%rbx
testl %eax, %eax
jne 0xbc8cf
movl $0x8, %edx
movq %r15, %rdi
movq %rsp, %rsi
callq 0x6ec0e
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbc8bf
movq (%rsp), %rax
subq 0x10(%rsp), %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x70790
movq (%rsp), %rsi
addq %r14, %rsi
movq %rsi, (%rsp)
cmpq %r12, %rsi
jb 0xbc883
movq 0x8(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x29886
callq 0x298bd