#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 /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char inst[4], temp;
  int num, sp[100] = {0}, from, to, mt, i, j;
  char block[100][1000];
  scanf("%d\n", &num);
  while (1) {
    scanf(" %s", inst);
    if (strcmp(inst, "quit") == 0)
      break;
    if (strcmp(inst, "push") == 0) {
      scanf(" %d %c\n", &mt, &temp);
      block[mt - 1][sp[mt - 1]] = temp;
      sp[mt - 1]++;
    } else if (strcmp(inst, "move") == 0) {
      scanf("%d %d\n", &from, &to);
      block[to - 1][sp[to - 1]] = block[from - 1][sp[from - 1] - 1];
      sp[to - 1]++;
      sp[from - 1]--;
    } else {
      scanf("%d\n", &mt);
      printf("%c\n", block[mt - 1][sp[mt - 1] - 1]);
      sp[mt - 1]--;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18860,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11a8 <main+0x68>
jmp    1394 <main+0x254>
lea    -0x8(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1233 <main+0xf3>
lea    0xe45(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
lea    -0x9(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x9(%rbp),%dl
mov    -0x1ac(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x18860(%rbp),%rax
imul   $0x3e8,%rcx,%rcx
add    %rcx,%rax
mov    -0x1ac(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movslq -0x1a0(%rbp,%rcx,4),%rcx
ff
mov    %dl,(%rax,%rcx,1)
mov    -0x1ac(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    138f <main+0x24f>
lea    -0x8(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1313 <main+0x1d3>
lea    0xdc7(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
lea    -0x1a8(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x18860(%rbp),%rax
imul   $0x3e8,%rcx,%rcx
add    %rcx,%rax
mov    -0x1a4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    -0x1a0(%rbp,%rcx,4),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x1a8(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x18860(%rbp),%rax
imul   $0x3e8,%rcx,%rcx
add    %rcx,%rax
mov    -0x1a8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movslq -0x1a0(%rbp,%rcx,4),%rcx
ff
mov    %dl,(%rax,%rcx,1)
mov    -0x1a8(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    138a <main+0x24a>
lea    0xd04(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1ac(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x18860(%rbp),%rax
imul   $0x3e8,%rcx,%rcx
add    %rcx,%rax
mov    -0x1ac(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    -0x1a0(%rbp,%rcx,4),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
lea    0xcad(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x1ac(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x1a0(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    138f <main+0x24f>
jmp    1177 <main+0x37>
xor    %eax,%eax
add    $0x18860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18858,%rsp
lea    0x20(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xeb5(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe84(%rip),%rdi
lea    0x18(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     130f <main+0x1cf>
lea    0xe5f(%rip),%r14
lea    0x18(%rsp),%rbx
lea    0xc(%rsp),%r12
lea    0xe45(%rip),%rbp
lea    0xe42(%rip),%r15
lea    0xe4d(%rip),%r13
jmp    1235 <main+0xf5>
nopl   0x0(%rax,%rax,1)
lea    0xe37(%rip),%rdi
mov    %r12,%rsi
lea    0xb(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
movzbl 0xb(%rsp),%eax
movslq 0xc(%rsp),%rcx
lea    -0x1(%rcx),%rdx
movslq 0x1c(%rsp,%rcx,4),%rsi
imul   $0x3e8,%rdx,%rdx
add    %rsp,%rdx
add    $0x1b0,%rdx
mov    %al,(%rsi,%rdx,1)
lea    0x1(%rsi),%eax
mov    %eax,0x1c(%rsp,%rcx,4)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     130f <main+0x1cf>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11d0 <main+0x90>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a0 <main+0x160>
lea    0xdc2(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rax
movslq 0x1c(%rsp,%rax,4),%rcx
add    $0xffffffffffffffff,%rax
imul   $0x3e8,%rax,%rax
add    %rsp,%rax
add    $0x1b0,%rax
movsbl -0x1(%rcx,%rax,1),%esi
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
jmp    1305 <main+0x1c5>
nopl   0x0(%rax)
lea    0xd74(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
movslq 0x14(%rsp),%rax
lea    -0x1(%rax),%rcx
movslq 0x1c(%rsp,%rax,4),%rdx
imul   $0x3e8,%rcx,%rcx
add    %rsp,%rcx
add    $0x1b0,%rcx
movzbl -0x1(%rdx,%rcx,1),%ecx
movslq 0x10(%rsp),%rdx
lea    -0x1(%rdx),%rsi
movslq 0x1c(%rsp,%rdx,4),%rdi
imul   $0x3e8,%rsi,%rsi
add    %rsp,%rsi
add    $0x1b0,%rsi
mov    %cl,(%rdi,%rsi,1)
lea    0x1(%rdi),%ecx
mov    %ecx,0x1c(%rsp,%rdx,4)
addl   $0xffffffff,0x1c(%rsp,%rax,4)
jmp    1214 <main+0xd4>
xor    %eax,%eax
add    $0x18858,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"push\00"
@.str.4 = [8 x i8] c" %d %c\0A\00"
@.str.5 = [5 x i8] c"move\00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [100 x [1000 x i8]]
store i32 0, i32* %1
%12 = bitcast [100 x i32]* %5 to i8*
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %14
14: ; preds = %0, %110
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
br label %111
21: ; preds = %14
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %45
25: ; preds = %21
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %8, i8* %3)
%27 = load i8, i8* %3
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %11, i64 0, i64 %30
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %31, i64 0, i64 %37
store i8 %27, i8* %38
%39 = load i32, i32* %8
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
store i32 %44, i32* %42
br label %110
45: ; preds = %21
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %87
49: ; preds = %45
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32* %6, i32* %7)
%51 = load i32, i32* %6
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %11, i64 0, i64 %53
%55 = load i32, i32* %6
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1000 x i8], [1000 x i8]* %54, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = load i32, i32* %7
%65 = sub nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %11, i64 0, i64 %66
%68 = load i32, i32* %7
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [1000 x i8], [1000 x i8]* %67, i64 0, i64 %73
store i8 %63, i8* %74
%75 = load i32, i32* %7
%76 = sub nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = add nsw i32 %79, 1
store i32 %80, i32* %78
%81 = load i32, i32* %6
%82 = sub nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = add nsw i32 %85, -1
store i32 %86, i32* %84
br label %109
87: ; preds = %45
%88 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %8)
%89 = load i32, i32* %8
%90 = sub nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %11, i64 0, i64 %91
%93 = load i32, i32* %8
%94 = sub nsw i32 %93, 1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = sub nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [1000 x i8], [1000 x i8]* %92, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8 signext %101)
%103 = load i32, i32* %8
%104 = sub nsw i32 %103, 1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = add nsw i32 %107, -1
store i32 %108, i32* %106
br label %109
109: ; preds = %87, %49
br label %110
110: ; preds = %109, %25
br label %14
111: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"push\00"
@.str.4 = [8 x i8] c" %d %c\0A\00"
@.str.5 = [5 x i8] c"move\00"
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x [1000 x i8]]
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%10 = bitcast i32* %3 to i8*
%11 = bitcast [100 x i32]* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %8, i64 0, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%18 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %80, label %20
20: ; preds = %0, %76
%21 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %7, i8* %2)
%25 = load i8, i8* %2
%26 = load i32, i32* %7
%27 = add nsw i32 %26, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %8, i64 0, i64 %28, i64 %31
store i8 %25, i8* %32
%33 = add nsw i32 %30, 1
store i32 %33, i32* %29
br label %76
34: ; preds = %20
%35 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %58
37: ; preds = %34
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32* %5, i32* %6)
%39 = load i32, i32* %5
%40 = add nsw i32 %39, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %8, i64 0, i64 %41, i64 %45
%47 = load i8, i8* %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, -1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %8, i64 0, i64 %50, i64 %53
store i8 %47, i8* %54
%55 = add nsw i32 %52, 1
store i32 %55, i32* %51
%56 = load i32, i32* %42
%57 = add nsw i32 %56, -1
store i32 %57, i32* %42
br label %76
58: ; preds = %34
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %7)
%60 = load i32, i32* %7
%61 = add nsw i32 %60, -1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = add nsw i32 %64, -1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x [1000 x i8]], [100 x [1000 x i8]]* %8, i64 0, i64 %62, i64 %66
%68 = load i8, i8* %67
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8 signext %68)
%70 = load i32, i32* %7
%71 = add nsw i32 %70, -1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = add nsw i32 %74, -1
store i32 %75, i32* %73
br label %76
76: ; preds = %37, %58, %23
%77 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%78 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %20
80: ; preds = %76, %0
ret i32 0
}