Optimizing number theory with copy analysis