Differentiable Dynamics And Motion Synthesis For Legged Robots