Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients