I don't have a full answer, but I can offer here a small improvement on my other answer. Namely, what was important was not that it worked on a bounded interval, but rather, that it works outside a bounded interval.
Theorem. For any function g on the reals, there are numerous functions f such that f(f(x)) = g(x), for all x except those in a given fixed tiny interval.
Proof. Suppose g is a function on the reals and that I is a given interval, no matter how small. Let h be a bijection of R - I with I. Let f(x) = h(x), if x is outside I, and f(x) = g(h-1(x)), if x is in I. Thus, f first translates x into I, if it is outside I, and otherwise, untranslates and computes g, if it is in I. It follows that f(f(x)) = g(x) for all x outside I. There are 2|R| many such h's, and hence also this many f's.QED
If g is continuous, then this f can be chosen also to be continuous.
By using a Cantor set instead of an interval, one can find a function f that solves f(f(x)) = g(x) except on a set of measure zero.