In some examples I have read that if you want to find the integral of motion for some equation of motion, say on the form $\ddot{x}+ax=0$ for some constant $a$, you multiply the EOM by $$\dot{x}=q(x) \implies \ddot{x} = \frac{dq}{dt} = \frac{dq}{dx}\frac{dx}{dt}.$$ You then separate $q$ and $x$ and integrate both sides. If you then rearrange to get the integration constant (constant of motion I presume(?)) alone on either side you find some new equation on the form (in this case) $$\frac{\dot{x}^2}{2}+a\frac{x^2}{2} = C.$$
Assuming this is correct, is this a general procedure for finding integrals of motion for explicitly time independent EOMs? Is the multiplication of $\dot{x}$ just a mathematical trick or is there a physical interpretation of it?