You can change some things in the code, things like ints storing very low values, an int takes 16 bits, and doing maths on then take longer than doing maths in a uint8_t that is only 8 bits and can have a max value of 255, see if you can use it instead, and using ints over longs and things like those.