When compiling under
g++ -O3
this actually seems to be slower when running time ./reverse < in > /dev/null
as it takes about 4.5 seconds.