// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %rdi, 0x20(%rsp)
testq %rsi, %rsi
je 0x9f9a2
movq %r8, %r14
testq %r8, %r8
je 0x9f9a2
movq %r9, %rbx
testq %r9, %r9
je 0x9f9a2
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x9f80d
callq 0x4df60
cmpq %r15, %rax
jne 0x9f9cc
movq %r15, %rax
movq %r12, 0x18(%rsp)
movq %r12, %r15
movq %rax, 0x28(%rsp)
movl %eax, %ebp
testl %ebp, %ebp
je 0x9f856
movl %ebp, %eax
sarl %eax
movslq %eax, %r12
imulq %r14, %r12
addq %r15, %r12
movq %r13, %rdi
movq %r12, %rsi
movq 0x70(%rsp), %rdx
callq *%rbx
testl %eax, %eax
je 0x9f85e
addq %r14, %r12
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
cmovgq %r12, %r15
subl %ecx, %ebp
sarl %ebp
jmp 0x9f81f
xorl %r12d, %r12d
jmp 0x9f990
movq %r12, 0x10(%rsp)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x9f990
leaq 0x10(%rsp), %rbp
pushq $0x8
popq %rdx
movq %rbp, %rsi
callq 0x4b801
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x9f8a2
movq 0x10(%rsp), %rax
subq 0x18(%rsp), %rax
xorl %edx, %edx
divq %r14
movq %rax, %rsi
callq 0x4d737
movq %r14, %rax
negq %rax
movq %rax, 0x30(%rsp)
leaq 0x8(%rsp), %r12
movq 0x18(%rsp), %r15
movq (%rbp), %rsi
addq 0x30(%rsp), %rsi
movq %rsi, 0x8(%rsp)
cmpq %r15, %rsi
movq %r15, %rbp
jb 0x9f918
movq %r13, %rdi
movq 0x70(%rsp), %rdx
callq *%rbx
testl %eax, %eax
jne 0x9f918
movq 0x20(%rsp), %rdi
movq %r12, %rsi
pushq $0x8
popq %rdx
callq 0x4b801
movq %rbp, %r15
movq %r12, %rbp
cmpq $0x0, 0x78(%rsp)
je 0x9f8b7
movq 0x8(%rsp), %rax
subq %r15, %rax
xorl %edx, %edx
divq %r14
movq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x4d737
movq %r12, %rbp
jmp 0x9f8b7
movq 0x28(%rsp), %r15
imulq %r14, %r15
addq %rbp, %r15
leaq 0x10(%rsp), %rax
leaq 0x8(%rsp), %rbp
movq 0x20(%rsp), %r12
movq (%rax), %rsi
addq %r14, %rsi
movq %rsi, 0x8(%rsp)
cmpq %r15, %rsi
jae 0x9f98b
movq %r13, %rdi
movq 0x70(%rsp), %rdx
callq *%rbx
testl %eax, %eax
jne 0x9f98b
movq %r12, %rdi
movq %rbp, %rsi
pushq $0x8
popq %rdx
callq 0x4b801
movq %rbp, %rax
cmpq $0x0, 0x78(%rsp)
je 0x9f933
movq 0x8(%rsp), %rax
subq 0x18(%rsp), %rax
xorl %edx, %edx
divq %r14
movq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x4d737
movq %rbp, %rax
jmp 0x9f933
movq 0x10(%rsp), %r12
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8e60f(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2a6b3(%rip), %rsi     # 0xca066
leaq 0x4b9cd(%rip), %rdx     # 0xeb387
leaq 0x4b9dc(%rip), %rcx     # 0xeb39d
leaq 0x4b759(%rip), %r8      # 0xeb121
pushq $0x20
jmp 0x9f9f4
movq 0x8e5e5(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2a689(%rip), %rsi     # 0xca066
leaq 0x4b9c9(%rip), %rdx     # 0xeb3ad
leaq 0x4b9b2(%rip), %rcx     # 0xeb39d
leaq 0x4b72f(%rip), %r8      # 0xeb121
pushq $0x21
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300