Show this function defined on a smooth manifold is (not) smooth
Let $\tilde f:(-\infty,1) \to [0, 1)$ be a smooth function such that $\tilde f|_{(-\infty,-1]} = \{0\} $, $\tilde f|_{(-1,1)}: (-1,1) \to (0,1)$ is diffeomorphism and $\tilde f$ is strictly increasing on $(-1, 1)$. Let $\phi: (0,1) \to (-1,1)$ be the diffeomorphism $(\tilde f|_{(-1,1)})^{-1}$, then $\tilde f\circ \phi (x) = x$ for $x\in(0,1)$.
Let $\tilde g: (-\infty,1) \to \mathbb R$ be the function that $\tilde g(x) = \tilde f\circ \phi(x)$ for $x \in (0,1)$ and $\tilde g(x) = 0$ otherwise. Then the one sided derivatives of $\tilde g$ at $0$ are different and thus $\tilde g$ is not differentiable at $0$.
To construct a counterexample, we only need to let $M = (-\infty, 1), \ B= (-1,1),\ U = (0,1)$ and $f(x) = \tilde f(x)$ for $x < 0$. Then $\tilde g(x) = g(x)$ for $x < \phi^{-1}(0)$, and $g$ is not differentiable at $0$.