Observable state is the contents of variables and similar entities, together with output, as they evolve during execution. A C compiler may change internal computations or remove variables when the executable preserves those observable states. This freedom belongs to C’s abstract state machine, which permits different platform implementations. section 5.1
Eliminating an unobservable computation
Given double x = 5.0; double y = 3.0; x = (x * 1.5) - y; printf("x is %g\n", x);, a compiler can calculate x as 4.5 before execution and emit printf("x is 4.5\n");. The intermediate assignments disappear because neither their timing nor their temporary state is observable. section 5.1
Optimization remains valid only when it preserves observable results. Reordering or combining operations can become invalid if an intermediate value is used, output is produced, or an operation such as overflow can terminate the program. Type therefore determines optimization opportunities. section 5.1.4
double x = 5.0;
double y = 3.0;
...
x = (x * 1.5) - y;
printf("x is %g\n", x);
Trace the arithmetic from source expressions to the final observable terminal output. section 5.1
