accumulate and output a pseudo-main function containing all top-levels.