Avoid left-shifting integers into the sign bit, which is undefined. Found with UndefinedBehaviorSanitizer.