Here's what works on my Mac, compiled with clang -m32.
#include <stdio.h>
int main() {
int i; // Another stack variable
printf("%s\n", **(char ***)(&i + 8)); // argv[0]
return 0;
}
Of course, this won't work at all on x86_64 because arguments are passed on registers instead of the stack.