Intermediate code and typechecking