I remember we did something similar for one of the #ICFPC contests! It actually was a way smoother experience than I have expected.
https://github.com/Vlad-Shcherbina/icfpc2014-tbd/blob/master/production/gcc_ast_converter.py
@jonn whoa what is this gcc ast thing 👀
how would type inference work here 🤔
here's my code, pretty dumb so far: https://jb55.com/s/567a44110d947423.txt