Convert lsysf.c to C++