timer.cpp converted to C