The compiler assumes that you have given it a valid C program, and optimizes accordingly.
A valid C program is not allowed to fall off the end of a non-void function without returning a value if the return value is used. This means that if the optimizer sees a function which will always do this, it "knows" that you never call it (as if you did, your program would be invalid). Since the function is never called, there's no point in emitting any code for the body of the function. It still needs to emit a small stub, as you could legally take the address of it.
As it so happens your program does call this function. This makes your program not a valid C program, and so the standard says nothing about how it should behave.
A valid C program is not allowed to fall off the end of a non-void function without returning a value if the return value is used. This means that if the optimizer sees a function which will always do this, it "knows" that you never call it (as if you did, your program would be invalid). Since the function is never called, there's no point in emitting any code for the body of the function. It still needs to emit a small stub, as you could legally take the address of it.
As it so happens your program does call this function. This makes your program not a valid C program, and so the standard says nothing about how it should behave.