#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int memory[100];
  memory[0] = 1;
  memory[99] = 800;
  int pc = 0;
  int accumulator = 0;
  int instruction = 0;
  while (1) {
    instruction = memory[pc];
    ++pc;
    int opcode = instruction / 100;
    int address = instruction % 100;
    switch (opcode) {
      int card = 0;
    case 0:
      scanf("%d", &card);
      memory[address] = card;
      break;
    case 5:
      printf("%d\n", memory[address]);
      break;
    case 9:
      return 0;
      break;
    default:
      printf("opcode '%d' not yet implemented! Panicking!\n", opcode);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1a0(%rbp)
movl   $0x320,-0x14(%rbp)
movl   $0x0,-0x1a4(%rbp)
movl   $0x0,-0x1a8(%rbp)
movl   $0x0,-0x1ac(%rbp)
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
movslq -0x1ac(%rbp),%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,-0x1b0(%rbp)
movslq -0x1ac(%rbp),%rcx
mov    %ecx,%eax
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x1b0(%rbp),%eax
mov    %eax,-0x1bc(%rbp)
test   %eax,%eax
je     120e <main+0xee>
jmp    11e6 <main+0xc6>
mov    -0x1bc(%rbp),%eax
sub    $0x5,%eax
je     123a <main+0x11a>
jmp    11fa <main+0xda>
mov    -0x1bc(%rbp),%eax
sub    $0x9,%eax
je     1259 <main+0x139>
jmp    1265 <main+0x145>
lea    0xdeb(%rip),%rdi
lea    -0x1b8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1b8(%rbp),%ecx
movslq -0x1b4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    1283 <main+0x163>
movslq -0x1b4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdb4(%rip),%rdi
call   1030 <printf@plt>
jmp    1283 <main+0x163>
movl   $0x0,-0x4(%rbp)
jmp    1288 <main+0x168>
mov    -0x1b0(%rbp),%esi
lea    0xd95(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1288 <main+0x168>
jmp    1161 <main+0x41>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a0,%rsp
movl   $0x1,0x10(%rsp)
movl   $0x320,0x19c(%rsp)
lea    0x14(%rsp),%r13
mov    $0x1,%eax
lea    0xeac(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xea3(%rip),%r12
jmp    118e <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
movslq %ebx,%rcx
mov    %eax,0x10(%rsp,%rcx,4)
mov    0x0(%r13),%eax
add    $0x4,%r13
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x25,%rsi
add    %eax,%esi
imul   $0x64,%esi,%eax
sub    %eax,%ebx
test   %esi,%esi
je     1170 <main+0x50>
cmp    $0x5,%esi
jne    11c4 <main+0xa4>
movslq %ebx,%rax
mov    0x10(%rsp,%rax,4),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
jmp    1186 <main+0x66>
cmp    $0x9,%esi
jne    11cd <main+0xad>
xor    %eax,%eax
jmp    11de <main+0xbe>
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [45 x i8] c"opcode '%d' not yet implemented! Panicking!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
store i32 1, i32* %9
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 99
store i32 800, i32* %10
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %11
11: ; preds = %0, %39
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %13
%15 = load i32, i32* %14
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 100
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = srem i32 %20, 100
store i32 %21, i32* %7
%22 = load i32, i32* %6
switch i32 %22, label %36 [
i32 0, label %23
i32 5, label %29
i32 9, label %35
]
23: ; preds = %11
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %27
store i32 %25, i32* %28
br label %39
29: ; preds = %11
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %39
35: ; preds = %11
store i32 0, i32* %1
br label %40
36: ; preds = %11
%37 = load i32, i32* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %37)
store i32 1, i32* %1
br label %40
39: ; preds = %29, %23
br label %11
40: ; preds = %36, %35
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [45 x i8] c"opcode '%d' not yet implemented! Panicking!\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
store i32 1, i32* %4
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 99
store i32 800, i32* %5
br label %6
6: ; preds = %24, %0
%7 = phi i32 [ %26, %24 ], [ 1, %0 ]
%8 = phi i64 [ %9, %24 ], [ 0, %0 ]
%9 = add nuw i64 %8, 1
%10 = sdiv i32 %7, 100
%11 = srem i32 %7, 100
switch i32 %10, label %22 [
i32 0, label %12
i32 5, label %17
i32 9, label %27
]
12: ; preds = %6
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %15
store i32 %14, i32* %16
br label %24
17: ; preds = %6
%18 = sext i32 %11 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %24
22: ; preds = %6
%23 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %27
24: ; preds = %12, %17
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %9
%26 = load i32, i32* %25
br label %6
27: ; preds = %6, %22
%28 = phi i32 [ 1, %22 ], [ 0, %6 ]
ret i32 %28
}