Coudln't the `for()` be replaced by `offset2 = 1 << (i  * 8)`