Why are caller and callee compiled from two separate .c files, and what do the flags in xtensa-esp32-elf-gcc -O3 -S -o callee.s callee.c do?
In separate files the compiler can't see callee's body while compiling caller, so it can't inline it and the call stays visible. -S stops after producing assembly, -O3 optimises hard, and -o names the output file.
At -O3 GCC aggressively inlines small functions: it pastes the body of callee into caller instead of calling it. With both in one file, caller would compile to a multiply and an add, with no call8, no entry in between and nothing left to show about calling conventions. Putting callee in its own file hides its body: when GCC compiles caller.c it sees only the declaration int callee(int u, int v);, so it must emit a real call.
The flags:
-Sstops after compilation and writes human-readable assembly (.s) instead of an object file. Without it, GCC would go on to assemble and link.-O3is the highest standard optimisation level. That is why the code is so short: values stay in registers, with no stack traffic.-o callee.snames the output file.
The same separation trick, or the attribute __attribute__((noinline)), is how you keep a function call intact when you want to study it.
Go deeper:
Wikipedia — Inline expansion — what inlining does and when compilers do it.
GCC — Xtensa Options — the Xtensa-specific flags, including
-mabi=windowedand-mabi=call0.