#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int *numeros = malloc(4000000);
  int in_num, action;
  int register ct = -1, i;
  scanf(" %d", &in_num);
  for (i = 0; i < in_num; ++i) {
    scanf(" %d", &action);
    if (action == 1) {
      ct++;
      scanf(" %d", &numeros[ct]);
    } else if (action == 2) {
      if (ct >= 0)
        ct--;
    } else {
      if (ct < 0) {
        printf("Empty!\n");
      } else {
        printf("%d\n", numeros[ct]);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3d0900,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
lea    0xea5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122f <main+0xff>
lea    0xe82(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    11ba <main+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe50(%rip),%rdi
call   1050 <scanf@plt>
jmp    121c <main+0xec>
cmpl   $0x2,-0x18(%rbp)
jne    11dc <main+0xac>
cmpl   $0x0,-0x1c(%rbp)
jl     11d7 <main+0xa7>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1217 <main+0xe7>
cmpl   $0x0,-0x1c(%rbp)
jge    11f9 <main+0xc9>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1212 <main+0xe2>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1217 <main+0xe7>
jmp    121c <main+0xec>
jmp    1221 <main+0xf1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <main+0x3b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xea1(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    1204 <main+0xc4>
mov    $0xffffffff,%ebp
lea    0xe83(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xe7b(%rip),%r13
xor    %r12d,%r12d
jmp    11a3 <main+0x63>
xchg   %ax,%ax
mov    %ebp,%eax
sar    $0x1f,%eax
not    %eax
add    %eax,%ebp
add    $0x1,%r12d
cmp    (%rsp),%r12d
jge    1204 <main+0xc4>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1190 <main+0x50>
cmp    $0x1,%eax
jne    11e0 <main+0xa0>
movslq %ebp,%rax
add    $0x1,%ebp
lea    (%r14,%rax,4),%rsi
add    $0x4,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
jmp    1199 <main+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
js     11f6 <main+0xb6>
mov    %ebp,%eax
mov    (%r14,%rax,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1199 <main+0x59>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
jmp    1199 <main+0x59>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [8 x i8] c"Empty!\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @malloc(i32 4000000)
store i32* %7, i32** %2
store i32 -1, i32* %5
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %6
br label %9
9: ; preds = %50, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %53
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load i32*, i32** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %23)
br label %49
25: ; preds = %13
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %5
%33 = add nsw i32 %32, -1
store i32 %33, i32* %5
br label %34
34: ; preds = %31, %28
br label %48
35: ; preds = %25
%36 = load i32, i32* %5
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %47
40: ; preds = %35
%41 = load i32*, i32** %2
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %40, %38
br label %48
48: ; preds = %47, %34
br label %49
49: ; preds = %48, %17
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %9
53: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [7 x i8] c"Empty!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32* @malloc(i32 4000000)
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %37
9: ; preds = %0, %32
%10 = phi i32 [ %34, %32 ], [ 0, %0 ]
%11 = phi i32 [ %33, %32 ], [ -1, %0 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
switch i32 %13, label %23 [
i32 1, label %14
i32 2, label %19
]
14: ; preds = %9
%15 = add nsw i32 %11, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %3, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %17)
br label %32
19: ; preds = %9
%20 = ashr i32 %11, 31
%21 = xor i32 %20, -1
%22 = add nsw i32 %11, %21
br label %32
23: ; preds = %9
%24 = icmp slt i32 %11, 0
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %32
27: ; preds = %23
%28 = zext i32 %11 to i64
%29 = getelementptr inbounds i32, i32* %3, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %19, %14, %25, %27
%33 = phi i32 [ %15, %14 ], [ %11, %25 ], [ %11, %27 ], [ %22, %19 ]
%34 = add nuw nsw i32 %10, 1
%35 = load i32, i32* %1
%36 = icmp slt i32 %34, %35
br i1 %36, label %9, label %37
37: ; preds = %32, %0
ret i32 0
}