Fix a bug in live range calculation.

See the gigantic comment in the commit for more details.