I’ve no idea why GCC organizes its stack the way it does (though I guess you could crack open its source or this paper and find out), but I can tell you how to guarantee the order of specific stack variables if for some reason you need to. Simply put them in a struct:
void function1() {
struct {
int x;
int y;
int z;
int *ret;
} locals;
}
If my memory serves me correctly, spec guarantees that &ret > &z > &y > &x. I left my K&R at work so I can’t quote chapter and verse though.