PNaCl: refactoring of arithmetic functions