A conjugate gradient-based BPTT-like optimal control algorithm