> C is a language where there's no mandatory runtime.
The C language (and gcc) make a distinction between a freestanding environment (where there is actually a small mandatory runtime component, but it doesn't include printf or puts) and a hosted one (which does require the language-specified behaviour of printf and puts and the rest of the standard library). gcc by default compiles in hosted mode, where it's valid (conforming) to apply optimizations to standard library functions like printf, strlen etc.
gcc also supports a -ffreestanding option for freestanding environments, in which case it won't make assumptions about the meaning of an external function that happens to be called printf or strlen.
(If you're writing a kernel that includes a normal strlen function, then you might compile with -ffreestanding but #define strlen(s_) __builtin_strlen(s_), so that you still get strlen optimizations without any assumptions made about functions that happen to be named printf or the like.)