Reference for checking primitive recursiveness
This is known as a Ritchie-Cobham property, or a honesty property of primitive-recursive functions.  See for instance Theorem VIII.8.8, page 297 in P.G. Odifreddi, Classical Recursion Theory, vol. 2, 1999.

Odifreddi refers to


Kleene, General recursive functions of natural numbers, Math. Ann. 112:727--742, 1936,
Cobham, The intrinsic computational difficulty of functions, Log. Meth. Phil. Sci. 2:24--20, 1964,
Meyer, Depth of nesting and the Grzegorczyk hierarchy, Not. Am. Math. Soc. 12, 1965.