If we start from
$ m\ddot{x} = -\frac{dV}{dx} $
How could one derive/construct principle of least action? i.e. find out that this quantity
$ S = \int_{t_0}^{t_1}dt\left(\frac{m\dot{x}^2}{2} - V(x) \right)$
needs to be minimized. Assuming it's true and then proving it is is very easy and it's written in every textbook but that's not what I'm asking for. I want to go in other direction, not assuming I know the answer. All I know are Newton's laws and that $ F = -dV/dx$.
I thought of simply inverting the steps of derivation of Euler-Lagrange equation but they seem unintuitive and the reasoning behind them is unclear except that I know the answer in advance (which I want to assume that I don't).
I guess this is inverse of optimization problem? Given a solution finding out what does it optimize?