add c reference implementation