C version optimized

7 seconds regular compilation - 5 with O3.