#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 /*<<< orphan*/ scanf(char *, int *);
main() {
  int instructionCounter, operationCode, operand;
  signed accumulator, instructionRegister;
  int memory[100];
  accumulator = +0000;
  instructionRegister = +0000;
  instructionCounter = 00;
  operationCode = 00;
  operand = 00;
  printf("***WELCOME TO SIMPLETRON***");
  for (instructionCounter = 0; instructionCounter <= 99; instructionCounter++) {
    while (operand <= 99) {
      scanf("%d", &memory[instructionCounter]);
      instructionRegister = memory[instructionCounter];
      operationCode = instructionRegister / 100;
      operand = instructionRegister % 100;
      switch (operationCode) {
      case 10: {
        scanf("%d", &memory[operand]);
        break;
      }
      case 11: {
        printf("%d\n", memory[operand]);
        break;
      }
      case 20: {
        accumulator = memory[operand];
        break;
      }
      case 21: {
        memory[operand] = accumulator;
        break;
      }
      case 30: {
        accumulator += memory[operand];
        break;
      }
      case 31: {
        accumulator -= memory[operand];
        break;
      }
      case 32: {
        accumulator *= memory[operand];
        break;
      }
      case 33: {
        accumulator /= memory[operand];
        break;
      }
      case 40: {
        operand = instructionCounter;
        break;
      }
      case 42: {
        if (accumulator == 0) {
          operand = instructionCounter;
        }
        break;
      }
      case 41: {
        if (accumulator < 0) {
          operand = instructionCounter;
        }
        break;
      }
      case -99999: {
        break;
      }
      default: {
        printf("%s\n", "invalid choice");
        break;
      }
      }
    }
  }
  printf("%s\n", "program over");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x63,-0x8(%rbp)
jg     1407 <main+0x2e7>
jmp    1179 <main+0x59>
cmpl   $0x63,-0x10(%rbp)
jg     13f4 <main+0x2d4>
movslq -0x8(%rbp),%rax
lea    -0x1b0(%rbp,%rax,4),%rsi
ff
lea    0xe86(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
movslq -0x18(%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,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
sub    $0xfffe7961,%eax
je     13d5 <main+0x2b5>
jmp    11ff <main+0xdf>
mov    -0x1b4(%rbp),%eax
sub    $0xa,%eax
je     12db <main+0x1bb>
jmp    1213 <main+0xf3>
mov    -0x1b4(%rbp),%eax
sub    $0xb,%eax
je     12fe <main+0x1de>
jmp    1227 <main+0x107>
mov    -0x1b4(%rbp),%eax
sub    $0x14,%eax
je     131c <main+0x1fc>
jmp    123b <main+0x11b>
mov    -0x1b4(%rbp),%eax
sub    $0x15,%eax
je     132f <main+0x20f>
jmp    124f <main+0x12f>
mov    -0x1b4(%rbp),%eax
sub    $0x1e,%eax
je     1342 <main+0x222>
jmp    1263 <main+0x143>
mov    -0x1b4(%rbp),%eax
sub    $0x1f,%eax
je     1358 <main+0x238>
jmp    1277 <main+0x157>
mov    -0x1b4(%rbp),%eax
sub    $0x20,%eax
je     1370 <main+0x250>
jmp    128b <main+0x16b>
mov    -0x1b4(%rbp),%eax
sub    $0x21,%eax
je     1387 <main+0x267>
jmp    129f <main+0x17f>
mov    -0x1b4(%rbp),%eax
sub    $0x28,%eax
je     13a0 <main+0x280>
jmp    12b3 <main+0x193>
mov    -0x1b4(%rbp),%eax
sub    $0x29,%eax
je     13c0 <main+0x2a0>
jmp    12c7 <main+0x1a7>
mov    -0x1b4(%rbp),%eax
sub    $0x2a,%eax
je     13ab <main+0x28b>
jmp    13da <main+0x2ba>
movslq -0x10(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd28(%rip),%rdi
call   1040 <scanf@plt>
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
mov    %eax,-0x14(%rbp)
jmp    13ef <main+0x2cf>
mov    -0x14(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x1b0(%rbp,%rax,4)
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    13ef <main+0x2cf>
movslq -0x10(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    13ef <main+0x2cf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    13ef <main+0x2cf>
cmpl   $0x0,-0x14(%rbp)
jne    13bb <main+0x29b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    13ef <main+0x2cf>
cmpl   $0x0,-0x14(%rbp)
jge    13d0 <main+0x2b0>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    13ef <main+0x2cf>
jmp    13ef <main+0x2cf>
lea    0xc42(%rip),%rdi
lea    0xc3f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <main+0x59>
jmp    13f9 <main+0x2d9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x4a>
lea    0xc15(%rip),%rdi
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
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
lea    0xf3c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf4a(%rip),%r13
mov    %rsp,%r14
lea    0xf47(%rip),%r15
lea    0xe99(%rip),%rbx
lea    0xf35(%rip),%r12
xor    %ebp,%ebp
jmp    1180 <main+0x50>
mov    %r15,%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
movslq (%rsp),%rax
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
lea    (%rdx,%rsi,1),%ecx
add    %esi,%edx
add    $0xfffffff6,%edx
cmp    $0x20,%edx
ja     11cc <main+0x9c>
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
movslq (%rbx,%rdx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
cltq
lea    (%rsp,%rax,4),%rsi
mov    %r13,%rdi
call   1050 <scanf@plt>
jmp    1180 <main+0x50>
cmp    $0xfffe7961,%ecx
je     1180 <main+0x50>
jmp    1172 <main+0x42>
cltq
mov    (%rsp,%rax,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x50>
cltq
mov    (%rsp,%rax,4),%ebp
jmp    1180 <main+0x50>
cltq
mov    %ebp,(%rsp,%rax,4)
jmp    1180 <main+0x50>
cltq
add    (%rsp,%rax,4),%ebp
jmp    1180 <main+0x50>
cltq
sub    (%rsp,%rax,4),%ebp
jmp    1180 <main+0x50>
cltq
imul   (%rsp,%rax,4),%ebp
jmp    1180 <main+0x50>
movslq %eax,%rcx
mov    %ebp,%eax
cltd
idivl  (%rsp,%rcx,4)
mov    %eax,%ebp
jmp    1180 <main+0x50>

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

LLVM IR (-O2):
@.str = [28 x i8] c"***WELCOME TO SIMPLETRON***\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.4 = [15 x i8] c"invalid choice\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
br label %5
5: ; preds = %11, %0
%6 = phi i32 [ 0, %0 ], [ %12, %11 ]
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = sdiv i32 %8, 100
%10 = srem i32 %8, 100
switch i32 %9, label %49 [
i32 10, label %13
i32 11, label %17
i32 20, label %22
i32 21, label %26
i32 30, label %29
i32 31, label %34
i32 32, label %39
i32 33, label %44
i32 40, label %11
i32 42, label %11
i32 41, label %11
i32 -99999, label %11
]
11: ; preds = %5, %5, %5, %5, %49, %44, %39, %34, %29, %26, %22, %17, %13
%12 = phi i32 [ %6, %49 ], [ %6, %5 ], [ %48, %44 ], [ %43, %39 ], [ %38, %34 ], [ %33, %29 ], [ %6, %26 ], [ %25, %22 ], [ %6, %17 ], [ %6, %13 ], [ %6, %5 ], [ %6, %5 ], [ %6, %5 ]
br label %5
13: ; preds = %5
%14 = sext i32 %10 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
br label %11
17: ; preds = %5
%18 = sext i32 %10 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %11
22: ; preds = %5
%23 = sext i32 %10 to i64
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
br label %11
26: ; preds = %5
%27 = sext i32 %10 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %27
store i32 %6, i32* %28
br label %11
29: ; preds = %5
%30 = sext i32 %10 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = add nsw i32 %32, %6
br label %11
34: ; preds = %5
%35 = sext i32 %10 to i64
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = sub nsw i32 %6, %37
br label %11
39: ; preds = %5
%40 = sext i32 %10 to i64
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = mul nsw i32 %42, %6
br label %11
44: ; preds = %5
%45 = sext i32 %10 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = sdiv i32 %6, %47
br label %11
49: ; preds = %5
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %11
}