Suppose that $f$ and $g$ are two smooth functions defined on $R^n$. Assume that $(a-\epsilon, b+\epsilon)$ contains no critical point of $g$. Then $g^{-1}[a,b]$ it homomorphic to $g^{-1}(a)\times [a,b]$. Now we consider the critical points of the function $f$ restricted on $g=c$, $f|_{g=c}$, $c\in [a,b]$. My aim is to show that there is a bijection between critical points of $f|_{g=a}$ and $f|_{g=b}$.

There are counterexamples to my guess. For example, $f,g:\mathbb{R}^2\to \mathbb{R}$, $f(x,y)=x^3-xy$, $g(x,y)=y$. Then $g$ has no critical points, $f|_{g=1}$ has two critical points, but $f|_{g=0}$ has one critical point, and $f|_{g=-1}$ has no critical points.

Maybe some conditions on $f$ would be enough, like $f$ also has no critical points. Is there a theorem on this?