Let $g(x)=f(x)^2+f'(x)^2$. Then $g'(x)=2f'(x)(f(x)+f''(x))$. It is sufficient to verify $g(x)\le\max\{A,B\}$ at critical points and as $x\to \pm\infty$.. At critical points of $g$ we have
- either $f'(x)=0$. Then $g(x)=f(x)^2\le A$.
- or $f(x)+f''(x)=0$. Then $g(x)=f(x)^2+f'(x)^2=f''(x)^2+f'(x)^2\le B$.
As $x\to \infty$ beyond critical points, $g'(x)$ has constant sign, hence $f'(x)$ does not cross $0$ and so $f$ is monotonic. Since $f$ is bounded, we conclude that $a:=\lim_{x\to\infty}f(x)$ exists.
Let $\epsilon>0$ be given, wlog. $\epsilon<\frac12$. Then there exists $x_0$ such that both $|f(x)-a|<\epsilon$ and $|f^2(x)-a^2|<\frac12\epsilon$ for all $x>x_0$. Then for any $x>x_0$ we have $f(x+2)-f(x)=2f'(\xi)$ for some $\xi\in(x,x+2)$. For this $\xi$ we conlcude $|f'(\xi)|<\epsilon$ and then $g(\xi)=f(\xi)^2+f'(\xi)^2$ differs from $a^2$ by less than $\epsilon$. As it lacks critical points, we must have $g(x)\to a^2\le A$. The same argument works as $x\to-\infty$.