"static int y; /* uninitialized /
_Bool cond = f();
int x = cond ? 2 : y; / Is it legal to fold this to int x = 2; ? /
Hopefully, you'll agree that that is a reasonable optimization. Now consider this code:"
Do not agree. That's not an optimization it's just false reasoning. Reasonable would be to either ignore it so the code depends on the uniitialized data, whatever it is, or to flag an error. Also according to the standard, static variable of arithmetic type are initialized to zero by default so there is no UB at all.
Second example has the same problem.
Third example has, for example, assumptions that C does not let the compiler make e.g. that z is a restricted pointer. Imagine that f(int c) { z = getsamepointer(); z +=1;return *z; }
And none of those optimizations existed in the 1980s.