Shifting signed integers (in fx2i and i2fx) is undefined behavior. The shifts are replaced with equivalent multiplication and division.
Internally, the random_int() function may shift a bit into the sign bit, which is undefined behavior. The masks are adjusted so this is no longer the case.