I got the following question in which the correct answer is B. I don't understand why A is not correct, because the compiler is doing optimization on the code and I didn't find any information about a preproccessor that is doing that.
Because the right answer is B ;)
A compiler doesn't have to make code improvement to produce correct machine code. it's main task is to produce machine code from source code by performing syntactic and semantic analysis on source code and the if the code is OK produce machine code.
A compiler can produce correct machine code without optimization
In gcc for example you can choose optimization level with option -O