I am wondering if it is possible to have a program that interprets programming code and is capable of turning that code into an optimized circuit. Is this possible, and if so, does it exist?
Yes, it is certainly possible.
There are compilers that will compile from code to circuits. Classic examples would be VHDL or AHDL compilers, but you can certainly do this for any other language, to the extent that you have an upper bound on the running time of the program or that you have an upper bound on the memory use of the program and are willing to have a circuit that contains stateful elements.
In fact, you can walk down to Fry's and buy something that basically has the form you asked for: it's called a computer. That's more or less what a computer does: it takes code written in a programming language and executes it efficiently, using an optimized circuit. The circuit is fixed (it is the gates in the processor) and part of its input is data that depends upon the program you are executing (which is stored in the RAM of the computer). However, you could consider this a larger circuit where part of it is hardcoded (i.e., the program part of the input is hardcoded); then you can view a computer running a program as a big circuit with part that is universal and identical for all programs (the gates of the processor) and part that depends on the program (the hardcoded input), and this immediately gives a mapping from programs to circuits. The mapping is implemented by a compiler.
there are different ways to interpret your question but based on comments (incl yours) some of this may be helpful. there is a lot of research in converting higher level programming constructs into FPGAs, field programmable gate arrays, basically hardware where circuits are dynamically reconfigurable. (aka reconfigurable computing).
there is also a special language eg "C for FPGAs", a subset of full C, that is customized for this purpose.
as for getting efficient circuits for particular programs, that is another area of research/ optimization eg circuit optimization/ minimization/ compression. there are also optimization heuristics built as input preprocessors into most SAT solvers. more generally this is known as logic optimization and there are various techniques/ tools for that. also the general theory/ application of optimizing compilers has some overlap with circuit optimization. one simple, near "toy" example or model of a compiler optimization in some cases is short circuit evaluation. the general area you refer to is also an active area of research both theoretical/ applied & there are many related papers on the subject.
FPGA code is just another kind of code, and it's convertible.
I guess if you're making a real machine, it could be written in C, but I'm doing one now and I'm just using sub-procedures in place of the electric modules, and it seems to be like it could work, and you can even do it on the GPU to get that awesome speed out of it.
The variables are the same between gates and code.
The variables just mark where the gates are linking and it perfectly converts (you just do them as normal), FPGA code is probably the same and does this I bet!
Just using the C code directly to make a circuit I'm not doing but its close if it works or not, but I'm talking about handcrafting the code to make it easily convertible works, and makes the conversion process less of a headache.
If you use a virtual machine to run it, it goes slower, it's best if it's direct code what you're running 'cause then you can get more out of your computer, when you're debugging what's going to be the final circuit.