#include #include int binsrch(int64_t, int64_t *, size_t); int binsrch(int64_t t, int64_t *x, size_t n) // John Louis Bentley, { // "Programming Pearls" int l = 0, u = (int)n - 1, m; while (l <= u) { m = (l + u) / 2; // JDK-5045582! (l, u < 2^31) if (x[m] < t) l = m + 1; else if (x[m] == t) return m; else // x[m] > t u = m - 1; } return -1; }