Wouldn't it be easier to set an optimization flag and get the compiler to do the loop unrolling?