The C compiler generally does not produce optimized C and compile that; it generally produces optimized assembly language or machine code.
The closest you can get is probably to compile a file to assembly with no optimization and again with highest optimization, and then compare the assembly output. You will have to have a good grasp of assembly language to do that. If you are using gcc
, read about the -S and -O switches for how to do (or not do) this.
Let me clarify some things about the compiler. The algorithms and data structures used by the code you wrote will never be changed by the compiler; the compiler will only be doing things that are exactly equivalent to your C code. That's why it wouldn't usually make sense for the compiler to produce optimized C.
If your goal is to write faster code, then, your best bet is to write better C by using better algorithms and data structures at the C level by carefully using the profiler.
If your goal is just to understand optimization, try Program Optimization and Compiler Optimization on Wikipedia for some general information.