Multilevel synthesis of structured programs