#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*/ fprintf(int /*<<< orphan*/, char *, int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main() {
  int program_counter = 0;
  int accumulator = 0;
  int instruction = 0;
  int memory[100];
  memory[0] = 1;
  while (1) {
    instruction = memory[program_counter];
    program_counter++;
    int opcode = instruction / 100;
    int operand = instruction % 100;
    switch (opcode) {
    case 0:
      scanf("%d", &memory[operand]);
      break;
    case 1:
      accumulator = memory[operand];
      break;
    case 2:
      accumulator += memory[operand];
      break;
    case 3:
      if (accumulator < 0) {
        program_counter = operand;
      }
      break;
    case 4: {
      int left_shift = operand / 10;
      int right_shift = operand % 10;
      accumulator = (accumulator * pow(10, left_shift)) / accumulator *
                    pow(10, right_shift);
      break;
    }
    case 5:
      printf("%d\n", memory[operand]);
      break;
    case 6:
      memory[operand] = accumulator;
      break;
    case 7:
      accumulator -= memory[operand];
      break;
    case 8:
      memory[99] = 800 + program_counter;
      program_counter = operand;
      break;
    case 9:
      return 0;
      break;
    default:
      fprintf(stderr, "Invalid opcode '%d'. Expected range is [0;9].\n",
              opcode);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x1a0(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movslq -0x10(%rbp),%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,-0x1a4(%rbp)
movslq -0x10(%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,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%eax
mov    %rax,-0x1b8(%rbp)
sub    $0x9,%rax
ja     1354 <main+0x214>
mov    -0x1b8(%rbp),%rax
lea    0xe10(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe13(%rip),%rdi
call   1050 <scanf@plt>
jmp    137b <main+0x23b>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0xc(%rbp)
jmp    137b <main+0x23b>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    137b <main+0x23b>
cmpl   $0x0,-0xc(%rbp)
jge    1261 <main+0x121>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    137b <main+0x23b>
mov    -0x1a8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1ac(%rbp)
mov    -0x1a8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1b0(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c0(%rbp)
mov    -0x1ac(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x1c0(%rbp),%eax
imul   %ecx,%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x1bc(%rbp)
mov    -0x1b0(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x1bc(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    137b <main+0x23b>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xd37(%rip),%rdi
call   1030 <printf@plt>
jmp    137b <main+0x23b>
mov    -0xc(%rbp),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    137b <main+0x23b>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    137b <main+0x23b>
mov    -0x8(%rbp),%eax
add    $0x320,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    137b <main+0x23b>
movl   $0x0,-0x4(%rbp)
jmp    1380 <main+0x240>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
mov    -0x1a4(%rbp),%edx
lea    0xcc5(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1380 <main+0x240>
jmp    1171 <main+0x31>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
movl   $0x1,(%rsp)
xor    %ebp,%ebp
mov    $0x1,%eax
lea    0xe9a(%rip),%r12
lea    0xebb(%rip),%r14
lea    0xeb7(%rip),%r15
xor    %ecx,%ecx
jmp    1198 <main+0x58>
cltq
lea    (%rsp,%rax,4),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rax
mov    (%rsp,%rax,4),%eax
mov    %ebx,%ecx
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
add    %esi,%edx
cmp    $0x9,%edx
ja     1261 <main+0x121>
lea    0x1(%rcx),%ebx
imul   $0x64,%edx,%esi
sub    %esi,%eax
movslq (%r12,%rdx,4),%rdx
add    %r12,%rdx
jmp    *%rdx
cltq
mov    (%rsp,%rax,4),%ebp
jmp    1190 <main+0x50>
cltq
add    (%rsp,%rax,4),%ebp
jmp    1190 <main+0x50>
test   %ebp,%ebp
cmovs  %eax,%ebx
jmp    1190 <main+0x50>
movsbl %al,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0xa,%edx
add    %cl,%dl
movsbl %dl,%esi
movzbl %sil,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movsbl %al,%ebp
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%r13d
mov    $0xa,%edi
mov    %ebp,%esi
call   1060 <pow@plt>
mov    %eax,%ebp
imul   %r13d,%ebp
jmp    1190 <main+0x50>
cltq
mov    (%rsp,%rax,4),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1190 <main+0x50>
cltq
mov    %ebp,(%rsp,%rax,4)
jmp    1190 <main+0x50>
cltq
sub    (%rsp,%rax,4),%ebp
jmp    1190 <main+0x50>
add    $0x321,%ecx
mov    %ecx,0x18c(%rsp)
mov    %eax,%ebx
jmp    1190 <main+0x50>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    127f <main+0x13f>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@stderr = global i32 0
@.str.2 = [47 x i8] c"Invalid opcode '%d'. Expected range is [0;9].\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
store i32 1, i32* %10
br label %11
11: ; preds = %0, %88
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %13
%15 = load i32, i32* %14
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 100
store i32 %19, i32* %6
%20 = load i32, i32* %4
%21 = srem i32 %20, 100
store i32 %21, i32* %7
%22 = load i32, i32* %6
switch i32 %22, label %84 [
i32 0, label %23
i32 1, label %28
i32 2, label %33
i32 3, label %40
i32 4, label %46
i32 5, label %60
i32 6, label %66
i32 7, label %71
i32 8, label %78
i32 9, label %83
]
23: ; preds = %11
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
br label %88
28: ; preds = %11
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %3
br label %88
33: ; preds = %11
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, %37
store i32 %39, i32* %3
br label %88
40: ; preds = %11
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = load i32, i32* %7
store i32 %44, i32* %2
br label %45
45: ; preds = %43, %40
br label %88
46: ; preds = %11
%47 = load i32, i32* %7
%48 = sdiv i32 %47, 10
store i32 %48, i32* %8
%49 = load i32, i32* %7
%50 = srem i32 %49, 10
store i32 %50, i32* %9
%51 = load i32, i32* %3
%52 = load i32, i32* %8
%53 = call i32 @pow(i32 10, i32 %52)
%54 = mul nsw i32 %51, %53
%55 = load i32, i32* %3
%56 = sdiv i32 %54, %55
%57 = load i32, i32* %9
%58 = call i32 @pow(i32 10, i32 %57)
%59 = mul nsw i32 %56, %58
store i32 %59, i32* %3
br label %88
60: ; preds = %11
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %64)
br label %88
66: ; preds = %11
%67 = load i32, i32* %3
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %69
store i32 %67, i32* %70
br label %88
71: ; preds = %11
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = load i32, i32* %3
%77 = sub nsw i32 %76, %75
store i32 %77, i32* %3
br label %88
78: ; preds = %11
%79 = load i32, i32* %2
%80 = add nsw i32 800, %79
%81 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 99
store i32 %80, i32* %81
%82 = load i32, i32* %7
store i32 %82, i32* %2
br label %88
83: ; preds = %11
store i32 0, i32* %1
br label %89
84: ; preds = %11
%85 = load i32, i32* @stderr
%86 = load i32, i32* %6
%87 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %86)
store i32 1, i32* %1
br label %89
88: ; preds = %78, %71, %66, %60, %46, %45, %33, %28, %23
br label %11
89: ; preds = %84, %83
%90 = load i32, i32* %1
ret i32 %90
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@stderr = global i32 0
@.str.2 = [47 x i8] c"Invalid opcode '%d'. Expected range is [0;9].\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
store i32 1, i32* %3
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 99
br label %5
5: ; preds = %55, %0
%6 = phi i32 [ 1, %0 ], [ %60, %55 ]
%7 = phi i32 [ 0, %0 ], [ %56, %55 ]
%8 = phi i32 [ 0, %0 ], [ %57, %55 ]
%9 = add nsw i32 %8, 1
%10 = sdiv i32 %6, 100
%11 = srem i32 %6, 100
switch i32 %10, label %52 [
i32 0, label %12
i32 1, label %16
i32 2, label %20
i32 3, label %25
i32 4, label %28
i32 5, label %37
i32 6, label %42
i32 7, label %45
i32 8, label %50
i32 9, label %61
]
12: ; preds = %5
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
br label %55
16: ; preds = %5
%17 = sext i32 %11 to i64
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %17
%19 = load i32, i32* %18
br label %55
20: ; preds = %5
%21 = sext i32 %11 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nsw i32 %23, %7
br label %55
25: ; preds = %5
%26 = icmp slt i32 %7, 0
%27 = select i1 %26, i32 %11, i32 %9
br label %55
28: ; preds = %5
%29 = trunc i32 %11 to i8
%30 = sdiv i8 %29, 10
%31 = sext i8 %30 to i32
%32 = srem i8 %29, 10
%33 = sext i8 %32 to i32
%34 = call i32 @pow(i32 10, i32 %31)
%35 = call i32 @pow(i32 10, i32 %33)
%36 = mul nsw i32 %35, %34
br label %55
37: ; preds = %5
%38 = sext i32 %11 to i64
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %55
42: ; preds = %5
%43 = sext i32 %11 to i64
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %43
store i32 %7, i32* %44
br label %55
45: ; preds = %5
%46 = sext i32 %11 to i64
%47 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = sub nsw i32 %7, %48
br label %55
50: ; preds = %5
%51 = add nsw i32 %8, 801
store i32 %51, i32* %4
br label %55
52: ; preds = %5
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %61
55: ; preds = %25, %12, %16, %20, %28, %37, %42, %45, %50
%56 = phi i32 [ %7, %50 ], [ %49, %45 ], [ %7, %42 ], [ %7, %37 ], [ %36, %28 ], [ %24, %20 ], [ %19, %16 ], [ %7, %12 ], [ %7, %25 ]
%57 = phi i32 [ %11, %50 ], [ %9, %45 ], [ %9, %42 ], [ %9, %37 ], [ %9, %28 ], [ %9, %20 ], [ %9, %16 ], [ %9, %12 ], [ %27, %25 ]
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %58
%60 = load i32, i32* %59
br label %5
61: ; preds = %5, %52
%62 = phi i32 [ 1, %52 ], [ 0, %5 ]
ret i32 %62
}