#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int main() {
  int stack[100010], n, i, index;
  char word[10];
  while (scanf("%d", &n) != EOF) {
    index = 0;
    for (i = 0; i < n; i++) {
      scanf("%s", &word);
      if (!strcmp(word, "PUSH")) {
        scanf("%d", &stack[index]);
        index++;
      } else if (!strcmp(word, "POP")) {
        if (index == 0)
          printf("-1\n");
        else {
          index--;
          printf("%d\n", stack[index]);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ad0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x61ab4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     1284 <main+0x154>
movl   $0x0,-0x61abc(%rbp)
movl   $0x0,-0x61ab8(%rbp)
mov    -0x61ab8(%rbp),%eax
cmp    -0x61ab4(%rbp),%eax
jge    127f <main+0x14f>
lea    0xe6f(%rip),%rdi
lea    -0x61ac6(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x61ac6(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f5 <main+0xc5>
movslq -0x61abc(%rbp),%rax
lea    -0x61ab0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x61abc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61abc(%rbp)
jmp    1266 <main+0x136>
lea    -0x61ac6(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1261 <main+0x131>
cmpl   $0x0,-0x61abc(%rbp)
jne    1231 <main+0x101>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <main+0x12c>
mov    -0x61abc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x61abc(%rbp)
movslq -0x61abc(%rbp),%rax
mov    -0x61ab0(%rbp,%rax,4),%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <main+0x131>
jmp    1266 <main+0x136>
jmp    126b <main+0x13b>
mov    -0x61ab8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61ab8(%rbp)
jmp    117b <main+0x4b>
jmp    1142 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x61ad0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61ab8,%rsp
lea    0xeb8(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <main+0x42>
xor    %eax,%eax
add    $0x61ab8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8a(%rip),%r14
lea    0x6(%rsp),%rbx
mov    $0x48535550,%ebp
lea    0xe76(%rip),%r15
jmp    11a9 <main+0x79>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%rax
je     115e <main+0x2e>
cmpl   $0x0,(%rsp)
jle    1190 <main+0x60>
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    11e3 <main+0xb3>
nopw   0x0(%rax,%rax,1)
movslq %r13d,%rax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r13d
add    $0x1,%r12d
cmp    (%rsp),%r12d
jge    1190 <main+0x60>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x6(%rsp),%eax
xor    %ebp,%eax
movzbl 0xa(%rsp),%ecx
or     %eax,%ecx
je     11c0 <main+0x90>
cmpl   $0x504f50,0x6(%rsp)
jne    11d9 <main+0xa9>
test   %r13d,%r13d
je     1229 <main+0xf9>
movslq %r13d,%rax
add    $0xffffffff,%r13d
mov    0xc(%rsp,%rax,4),%esi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d9 <main+0xa9>
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
xor    %r13d,%r13d
jmp    11d9 <main+0xa9>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"PUSH\00"
@.str.3 = [4 x i8] c"POP\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@str = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca [100010 x i32]
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = bitcast [100010 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %46, label %14
10: ; preds = %41, %14
%11 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %46, label %14
14: ; preds = %0, %10
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %14, %41
%18 = phi i32 [ %42, %41 ], [ 0, %14 ]
%19 = phi i32 [ %43, %41 ], [ 0, %14 ]
%20 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %3)
%21 = call i32 @bcmp(i8* dereferenceable(5) %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = sext i32 %18 to i64
%25 = getelementptr inbounds [100010 x i32], [100010 x i32]* %1, i64 0, i64 %24
%26 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = add nsw i32 %18, 1
br label %41
28: ; preds = %17
%29 = call i32 @bcmp(i8* dereferenceable(4) %6, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = icmp eq i32 %18, 0
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %41
35: ; preds = %31
%36 = add nsw i32 %18, -1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100010 x i32], [100010 x i32]* %1, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %23, %33, %35, %28
%42 = phi i32 [ %18, %28 ], [ 0, %33 ], [ %36, %35 ], [ %27, %23 ]
%43 = add nuw nsw i32 %19, 1
%44 = load i32, i32* %2
%45 = icmp slt i32 %43, %44
br i1 %45, label %17, label %10
46: ; preds = %10, %0
ret i32 0
}