restructure gen + use -o for compilation