1. A method for code optimization, comprising: disassembling object code that has been compiled and linked; analyzing the disassembled code so as to identify a callee function in the code, the callee function including store and restore instructions with respect to a non-volatile register, and further to identify in the code a call instruction to the callee function located inside a caller function; and modifying the code so as to move at least one of the store and restore instructions with respect to the non-volatile register from the callee function to the caller function.