The function is exactly identical to the C reference, only with the constant propagated and the loop unrolled manually.