Stack emulator in C