Shrink write_int code from 1418 to 630 bytes