bsearch performs a binary search over a sorted array. It accepts the search key, an untyped array base, the element count, the element size, and a comparison-function pointer. section 11.4
typedef int compare_function(void const*, void const*);
void* bsearch(void const* key, void const* base,
size_t n, size_t size,
compare_function* compar);
void qsort(void* base,
size_t n, size_t size,
compare_function* compar);
The prototype shows how bsearch combines void pointers, element size, element count, and a comparator to remain type-generic. section 11.4
The comparator receives pointers to elements, casts them to the appropriate type, and returns a negative value when the first precedes the second, zero when they compare equal, or a positive value otherwise. section 11.4
Safe integer comparison
Compare integers with explicit relational tests rather than returning *a - *b: subtraction can overflow when the operands are far apart.

