The y
in your code is a local variable. Despite what many people think these are not allocated. They may or may not have some space reserved for them on the stack, but this is only guaranteed to happen if, after optimizations, their address is taken.
In all other cases they may not have space reserved on the stack at all. Or there may be some space on the stack that they use, but the same space is reused for multiple variables or even, in some cases, for passing arguments to functions that you are calling.
When space is reserved on the stack (which, may or may not happen) that space is generally reserved all at once upon function entry. However this is an implementation detail. It's done like that as it's the fastest way to do it. There is no requirement for it to be done the way and an implementation may very well dynamically change the size of the current stack frame (on most modern processors it's a stupid thing to do, but such an implementation would still be correct).