Is there any program which does this?
I mean, V8 does this at runtime under the hood, but is there any way to output the c++ code?
The only project I found still working in that direction is JXcore. Initially, they planned to switch from V8 to a LLVM based JS engine in version 2. That goal seems to have moved to "Down the Road" currently and isn't even in the roadmap anymore.
Mozilla was looking into using LLVM in 2009 and stopped that efforts too.