compiles, runs and calculates gains. Their correctness is untested