two phase code gen