Store both endpoints of each interval to make the code clearer
Replace custom binary search with function bsearch from stdlib.h