Transplant the TC2.0 code into standard C