This question already has an answer here:
In fact, you can find such an $f$ that is analytic. From this answer on MathOverflow:
A real-analytic solution in this case was constructed by H. Kneser, “Reelle analytische Lösungen der Gleichung $φ(φ(x))=e^x$ und verwandter Funktional-gleichungen”, J. Reine Angew. Math. 187 (1949), 56-67.
I’m afraid I don’t know the details of the construction, but hopefully this reference is helpful.
Other relevant threads: