#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) {
      numeros++;
      if (ct >= 0)
        ct--;
    } else {
      if (ct < 0) {
        printf("Empty!\n");
      } else {
        printf("%d\n", numeros[0]);
      }
    }
  }
  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    1236 <main+0x106>
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    1223 <main+0xf3>
cmpl   $0x2,-0x18(%rbp)
jne    11e8 <main+0xb8>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11e3 <main+0xb3>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    121e <main+0xee>
cmpl   $0x0,-0x1c(%rbp)
jge    1205 <main+0xd5>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <main+0xe9>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <main+0xee>
jmp    1223 <main+0xf3>
jmp    1228 <main+0xf8>
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,%rbx
lea    0xea1(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    1200 <main+0xc0>
mov    $0xffffffff,%ebp
lea    0xe83(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xe7b(%rip),%r13
xor    %r12d,%r12d
jmp    11a7 <main+0x67>
xchg   %ax,%ax
add    $0x4,%rbx
mov    %ebp,%eax
sar    $0x1f,%eax
not    %eax
add    %eax,%ebp
add    $0x1,%r12d
cmp    (%rsp),%r12d
jge    1200 <main+0xc0>
mov    %r14,%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    (%rbx,%rax,4),%rsi
add    $0x4,%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
jmp    119d <main+0x5d>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
js     11f2 <main+0xb2>
mov    (%rbx),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119d <main+0x5d>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
jmp    119d <main+0x5d>
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 %37
28: ; preds = %25
%29 = load i32*, i32** %2
%30 = getelementptr inbounds i32, i32* %29, i32 1
store i32* %30, i32** %2
%31 = load i32, i32* %5
%32 = icmp sge i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32, i32* %5
%35 = add nsw i32 %34, -1
store i32 %35, i32* %5
br label %36
36: ; preds = %33, %28
br label %48
37: ; preds = %25
%38 = load i32, i32* %5
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %47
42: ; preds = %37
%43 = load i32*, i32** %2
%44 = getelementptr inbounds i32, i32* %43, i64 0
%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 = %42, %40
br label %48
48: ; preds = %47, %36
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 %38
9: ; preds = %0, %32
%10 = phi i32 [ %35, %32 ], [ 0, %0 ]
%11 = phi i32 [ %34, %32 ], [ -1, %0 ]
%12 = phi i32* [ %33, %32 ], [ %3, %0 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %25 [
i32 1, label %15
i32 2, label %20
]
15: ; preds = %9
%16 = add nsw i32 %11, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %12, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %18)
br label %32
20: ; preds = %9
%21 = getelementptr inbounds i32, i32* %12, i64 1
%22 = ashr i32 %11, 31
%23 = xor i32 %22, -1
%24 = add nsw i32 %11, %23
br label %32
25: ; preds = %9
%26 = icmp slt i32 %11, 0
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %32
29: ; preds = %25
%30 = load i32, i32* %12
%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 = %20, %15, %27, %29
%33 = phi i32* [ %12, %15 ], [ %12, %27 ], [ %12, %29 ], [ %21, %20 ]
%34 = phi i32 [ %16, %15 ], [ %11, %27 ], [ %11, %29 ], [ %24, %20 ]
%35 = add nuw nsw i32 %10, 1
%36 = load i32, i32* %1
%37 = icmp slt i32 %35, %36
br i1 %37, label %9, label %38
38: ; preds = %32, %0
ret i32 0
}