Let $f: \mathbb R^n \rightarrow \mathbb R^n$ be a continuously differentiable map, and $C \subset \mathbb R^n$ be a smooth submanifold of codimension at least 2. Assume that $f$ is locally injective on $\mathbb R^n \backslash C$ and its restriction $f|C$ is locally injective. Could it happen that $f$ is not locally injective?
A rotation around a line in $\mathbb R^3$ could have been a counterexample, but it is not differentiable at points of the line.
A polynomial $p\in\Bbb C[z]$ of degree at least two is an analytic map $\Bbb R^2\to\Bbb R^2$ which is locally injective precisely at the points outside of $C=\{z\in\Bbb C\,:\, p'(z)=0\}$.
$C$ is a zero-dimensional embedded submanifold. Since $C$ is a discrete set, every function having domain $C$ is locally injective.
Added: The same counterexample can be replicated in $\Bbb R^{n+2}\cong \Bbb C\times\Bbb R^n$ with the map $f(z,v)=(p(z),v)$. This time $C=\{z\in\Bbb C\,:\, p'(z)=0\}\times\Bbb R^n$.