start porting generator to c