generic binary search in c