Q:

something similar to stdlib bsearch that returns immediately smaller element

Is there something similar to bsearch built in, that returns the immediately smaller element if the same element is not present and NULL only if the element is already smaller than all other elements.  This would require the user to check if the return value's key is same as the function argument, but it would be very useful in its own right. 
Thanks. 

A:

As far as I can say there is no such function in the standard library.  But it should not be to hard to do this on your own or find a library.