modular reduction algorithm over $F_{2^m}$ doesn't seem to work when order of polynomial being reduced is small
In the for loop $i$ is going from the $2m - 2$'th bit (more specifically, the coefficient of $x^i$) downto the $m$'th, where $m$ is the order of the reduction polynomial ($128$). So you never actually get to $x^{127}$ and so nothing is ever added to $C\{j\}$ and thus the return value is $0$.


Actually, $C$ starts off initialized to the input polynomial $c(z)$, and so by not adding anything, the final $C$ value is precisely the initial value, which is the correct answer.

They could have written the algorithm clearer by explicitly stating that, and using the same case for $C$ consistently...