Fix and cleanup get_line_number's binary search
Fix and cleanup get_line_number's binary search

- Return 1 instead of crashing if `xs` is the empty list
- Work around integer overflow when computing the averages
- Clarify the comments
- Document the loop invariants
- Don't use tail recursion (in case we want to rewrite this in Titan)

titan-lang/titan-v0,titan-lang/titan-v0,titan-lang/titan-v0