I found that I need to use the following facts in a paper that I am writing.

Let $f\in C^\infty(\mathbb R)$, then

If $f(0)=0$, then $f(x)=x g(x)$ for some $g\in C^\infty(\mathbb R)$.

If $f$ is even, i.e. $f(-x)=f(x)$ for all $x$, then $f(x)=g(x^2)$ for some $g\in C^\infty(\mathbb R)$.

These facts are trivial for analytic functions (just look at the Taylor series). In the smooth case, one can prove them by analyzing the derivatives of $f(x)/x$ and $f(\sqrt x)$, respectively, and showing that they have certain limits at 0. However this is somewhat cumbersome (especially if one wants to analyze how $g$ depends on $f$). This is not a problem for me because the facts fall into the category "you should be able to prove this yourself if you are reading my paper". But I would like to know if there is a nicer proof.

For the first statement, I know the following trick (which can be found in textbooks): define $$ g(x) = \int_0^1 f'(tx) \ dt $$ and observe that $f(x)=xg(x)$, and $g\in C^\infty$ since the function $t\mapsto f'(tx)$ under the integral is smooth in the parameter $x$. As a bonus, this argument also shows easily that $g$ (as a point of $C^\infty$) depends smoothly on $f$. (This is another fact that I need to use.)

Is there a similarly nice proof of the second statement? And, by the way, is there a textbook reference for it?

**Added.** Here is a more precise mathematical question that more or less formalizes what I mean. The function $g$ such that $f(x)=g(x^2)$ is uniquely defined only on $\mathbb R_+$, and its extension to negative arguments involves some choice.

Is there a canonical way to associate $g$ to $f$? Even more precisely, can one make a mapping $f\mapsto g$ which is linear, preserves the pointwise multiplication, and is continuous as a map from $C^\infty$ to $C^\infty$?