Arithmetic coding implementation in C