Take $x(0)=x_0$ and $x(T)=x_T$. Minimize $$I=\int_0^TL(x,\dot{x})\,dt\;\;\text{with}\;\;L=(\dot{x}+x)^2$$ by solving the Euler-Lagrange equation, $$\frac{\partial L}{d x}=\frac{d}{dt}\frac{\partial L}{\partial \dot{x}}.$$ The solution is $$x(t)=a e^t+be^{-t},\;\;a=\frac{e^T x_T-x_0}{e^{2 T}-1},\;\;b= \frac{e^{2T} x_0-e^T x_T}{e^{2 T}-1}.$$ The resulting integral is $$I=(\coth T-1) \left(x_0-e^T x_T\right)^2.$$ We still need to minimize this by varying $x_0$ and $x_T$ in the interval $[m,M]$, at fixed $T$. We need to consider several cases: • If $mM\leq 0$, we can just take $x_0=0=x_T$ and reach the minimal $I=0$. • If $mM>0$ and $T\leq\ln(M/m)$ we can take $x_0=me^T$, $x_T=m$ to reach the minimal $I=0$. • If $mM>0$ and $T>\ln(M/m)$ I presume (but I'm not certain) that the minimum is reached at the end points of the interval, $x_0=M$, $x_T=m$, with $I=(\coth T-1) \left(M-e^T m\right)^2$.