Fix a potentially undefined right shift by replacing it with two smaller right shifts.