partial code of codegen.c