Optimal control, differential equations and smooth optimization