Convert l-ec.cpp to C