Added original C code from December 2010.