Given $\bar x \in \mathbb R$, minimize
$$ J(u) = \int_0^T |x(t) - \bar x|^2 \,{\rm d} t + \int_0^T u^2(t) \,{\rm d} t $$
where $x(t)$ solves the following ODE
$$ x''(t) + \sin (x(t)) = u(t) $$
with initial conditions $x(0) = x_0$ and $x'(0)= x_1$, can you point out a reference where the existence (and uniqueness?) of a minimizer and the first-order optimality conditions are analyzed in detail?
I know some resources for the linearized harmonic oscillator $x''(t) + x(t) = u(t)$.