loop unrolling rewritten