I have been looking at disassembled c recently (all compiled with gcc). I noticed every function begins with
push rbp
mov rbp, rsp
And ends with
pop rbp
Or the equivalent registers. I’ve heard this referee to as setting up a new stack for the function, but how does this actually benefit the code. Wouldn’t the code work exactly the same without it, as rbp can’t be accessed or chanced in c (without inline assembly) and pointers and variables are all offsets from rsp