On p.464 of Spivak's mechanics book, the author proves the equivalence of Maupertuis' principle and stationary action principle by considering variation of some path $c(t)$, such that other paths in the variation have the same energy as $c(t)$ and the same end points, but are not necessarily defined on the same time interval. His proof becomes sketchy towards the end and refers to a lemma in the addendum (p.473). However that lemma and its corollary seem to deal with variation with integral constraint, and assume all maps are defined on the same interval. How is that useful in our situation, where "energy is constant" seems like a non-integral constraint (and moreover maps are defined on different intervals)?
I am trying to apply the theorem about variation with non-integral constraint and see what I can get (here I am assuming all paths are defined on the same interval, so this probably will not give what I want, but it shouldn't give anything wrong). We are considering the action defined by $\int Adt$, where $$A=\frac{\partial L}{\partial\dot{x}}\cdot\dot{x}.$$ The energy $E$ is equal to $A-L$. For a path to be stationary for this action among all paths with the same endpoints and same energy $E=C$, it has to satisfy the Euler-Lagrange equations for $$A+\lambda(t)(A-L-C),$$ where $\lambda(t)$ is some unknown function. The equations reduce to the following if my calculation is right:
$$(1+\lambda(t))\left[\frac{d}{dt}\frac{\partial A}{\partial\dot{x}}-\frac{\partial A}{\partial x}\right]-\lambda(t)\left[\frac{d}{dt}\frac{\partial L}{\partial\dot{x}}-\frac{\partial L}{\partial x}\right]+\dot{\lambda}(t)\left(\frac{\partial A}{\partial\dot{x}}-\frac{\partial L}{\partial\dot{x}}\right)=0.$$
But this doesn't seem right because if $c(t)$ is a true trajectory, then the first two terms should vanish, which implies the last term is also zero, but there is no reason why $A-L$ being constant should imply $\frac{\partial A}{\partial\dot{x}}-\frac{\partial L}{\partial\dot{x}}=0$. Where did I make a mistake?