#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__ checkword(int, int);
int /*<<< orphan*/ dump(int, int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int memory[100] = {0}, i, err = 0;
  int operationCode = 0, instructionRegister = 0;
  int accumulator = 0, operand = 0;
  printf("*** Welcome to the Simpletron! ***\n"
         "*** Please enter your program one instruction ***\n"
         "*** (or data word) at a time. I will type the ***\n"
         "*** location number and a question mark (?).  ***\n"
         "*** You then type the word for that location. ***\n"
         "*** Type the sentinel -99999 to stop entering ***\n"
         "*** your program. ***\n");
  for (i = 0; i < 100; i++) {
    while (1) {
      printf("%.2d ?? ", i);
      scanf("%d", &memory[i]);
      if (memory[i] == -99999) {
        memory[i] = 0;
        i = 100;
        break;
      }
      if (checkword(memory[i], 100)) {
        printf("*** Invalid instruction: %d\n", memory[i]);
        printf("*** Please retype it or exit.\n");
      } else
        break;
    }
  }
  printf("*** Program loading completed ***\n"
         "*** Program execution begins  ***\n");
  for (i = 0; i < 100; i++) {
    instructionRegister = memory[i];
    operationCode = instructionRegister / 100;
    operand = instructionRegister % 100;
    if (operationCode >= 40)
      --operand;
    switch (operationCode) {
    case 10:
      printf("Insert a word: ");
      scanf("%d", &memory[operand]);
      break;
    case 11:
      printf("\nMemory location: %.2d\nWord: %d\nASCII: %c\n", operand,
             memory[operand], memory[operand]);
      break;
    case 20:
      accumulator = memory[operand];
      break;
    case 21:
      memory[operand] = accumulator;
      break;
    case 30:
      accumulator += memory[operand];
      if (accumulator > +9999 || accumulator < -9999)
        err = 1;
      break;
    case 31:
      accumulator -= memory[operand];
      if (accumulator > +9999 || accumulator < -9999)
        err = 1;
      break;
    case 32:
      accumulator /= memory[operand];
      if (!memory[operand])
        err = 2;
      break;
    case 33:
      accumulator *= memory[operand];
      if (accumulator > +9999 || accumulator < -9999)
        err = 1;
      break;
    case 40:
      i = operand;
      break;
    case 41:
      if (accumulator < 0)
        i = operand;
      break;
    case 42:
      if (!accumulator)
        i = operand;
      break;
    case 43:
      printf("*** Simpletron execution terminated ***\n");
      dump(accumulator, i, memory);
      return 0;
      break;
    case 0:
      break;
    default:
      printf("*** unknown error: %d\n", instructionRegister);
      exit(-1);
    }
    if (err) {
      switch (err) {
      case 1:
        printf("*** Out of the accumulator limit ***\n");
        break;
      case 2:
        printf("*** Attempt to divide by zero ***\n");
        break;
      }
      printf("*** Simpletron execution abnormally terminated ***\n");
      dump(accumulator, i, memory);
      exit(-1);
    }
  }
  dump(accumulator, i, memory);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x0,-0x1a8(%rbp)
movl   $0x0,-0x1ac(%rbp)
movl   $0x0,-0x1b0(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x0,-0x1b8(%rbp)
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    12c3 <main+0x163>
jmp    11e1 <main+0x81>
mov    -0x1a4(%rbp),%esi
lea    0xff6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xfdc(%rip),%rdi
call   1070 <scanf@plt>
movslq -0x1a4(%rbp),%rax
cmpl   $0xfffe7961,-0x1a0(%rbp,%rax,4)
61 79 fe ff
jne    124f <main+0xef>
movslq -0x1a4(%rbp),%rax
movl   $0x0,-0x1a0(%rbp,%rax,4)
movl   $0x64,-0x1a4(%rbp)
jmp    12aa <main+0x14a>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edi
mov    $0x64,%esi
call   1060 <checkword@plt>
cmp    $0x0,%rax
je     12a0 <main+0x140>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xf6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a5 <main+0x145>
jmp    12aa <main+0x14a>
jmp    11e1 <main+0x81>
jmp    12af <main+0x14f>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11cf <main+0x6f>
lea    0xf62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    166f <main+0x50f>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1ac(%rbp)
mov    -0x1b0(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1b8(%rbp)
cmpl   $0x28,-0x1ac(%rbp)
jl     1340 <main+0x1e0>
mov    -0x1b8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1b8(%rbp)
mov    -0x1ac(%rbp),%eax
mov    %rax,-0x1c0(%rbp)
sub    $0x2b,%rax
ja     15ac <main+0x44c>
mov    -0x1c0(%rbp),%rax
lea    0xc9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x1b8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1070 <scanf@plt>
jmp    15ca <main+0x46a>
mov    -0x1b8(%rbp),%esi
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    15ca <main+0x46a>
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    %eax,-0x1b4(%rbp)
jmp    15ca <main+0x46a>
mov    -0x1b4(%rbp),%ecx
movslq -0x1b8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    15ca <main+0x46a>
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
add    -0x1b4(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
cmpl   $0x270f,-0x1b4(%rbp)
jg     1443 <main+0x2e3>
cmpl   $0xffffd8f1,-0x1b4(%rbp)
d8 ff ff
jge    144d <main+0x2ed>
movl   $0x1,-0x1a8(%rbp)
jmp    15ca <main+0x46a>
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0x1b4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1b4(%rbp)
cmpl   $0x270f,-0x1b4(%rbp)
jg     148e <main+0x32e>
cmpl   $0xffffd8f1,-0x1b4(%rbp)
d8 ff ff
jge    1498 <main+0x338>
movl   $0x1,-0x1a8(%rbp)
jmp    15ca <main+0x46a>
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
mov    -0x1b4(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x1b4(%rbp)
movslq -0x1b8(%rbp),%rax
cmpl   $0x0,-0x1a0(%rbp,%rax,4)
jne    14d9 <main+0x379>
movl   $0x2,-0x1a8(%rbp)
jmp    15ca <main+0x46a>
movslq -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
imul   -0x1b4(%rbp),%eax
mov    %eax,-0x1b4(%rbp)
cmpl   $0x270f,-0x1b4(%rbp)
jg     1519 <main+0x3b9>
cmpl   $0xffffd8f1,-0x1b4(%rbp)
d8 ff ff
jge    1523 <main+0x3c3>
movl   $0x1,-0x1a8(%rbp)
jmp    15ca <main+0x46a>
mov    -0x1b8(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
jmp    15ca <main+0x46a>
cmpl   $0x0,-0x1b4(%rbp)
jge    1552 <main+0x3f2>
mov    -0x1b8(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
jmp    15ca <main+0x46a>
cmpl   $0x0,-0x1b4(%rbp)
jne    1570 <main+0x410>
mov    -0x1b8(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
jmp    15ca <main+0x46a>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b4(%rbp),%edi
mov    -0x1a4(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
call   1050 <dump@plt>
movl   $0x0,-0x4(%rbp)
jmp    168e <main+0x52e>
jmp    15ca <main+0x46a>
mov    -0x1b0(%rbp),%esi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x1a8(%rbp)
je     1656 <main+0x4f6>
mov    -0x1a8(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
sub    $0x1,%eax
je     1605 <main+0x4a5>
jmp    15f1 <main+0x491>
mov    -0x1c4(%rbp),%eax
sub    $0x2,%eax
je     1618 <main+0x4b8>
jmp    1626 <main+0x4c6>
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1626 <main+0x4c6>
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b4(%rbp),%edi
mov    -0x1a4(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
call   1050 <dump@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    165b <main+0x4fb>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    12db <main+0x17b>
mov    -0x1b4(%rbp),%edi
mov    -0x1a4(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
call   1050 <dump@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xf92(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0b(%rip),%r12
lea    0xf0d(%rip),%r13
lea    0x1191(%rip),%r14
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rbx
mov    %r15d,%r14d
lea    (%rsp,%r14,4),%rbp
add    $0x10,%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    0x10(%rsp,%r14,4),%edi
mov    %rbx,%r14
lea    0xed1(%rip),%rbx
cmp    $0xfffe7961,%edi
je     1263 <main+0xf3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x64,%esi
call   1070 <checkword@plt>
test   %rax,%rax
je     1250 <main+0xe0>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
mov    0x0(%rbp),%edi
cmp    $0xfffe7961,%edi
jne    1200 <main+0x90>
jmp    1263 <main+0xf3>
nopl   0x0(%rax)
lea    0x1(%r15),%eax
cmp    $0x63,%r15d
mov    %eax,%r15d
jb     11b6 <main+0x46>
jmp    126a <main+0xfa>
movl   $0x0,0x0(%rbp)
lea    0xfed(%rip),%rdi
call   1030 <puts@plt>
lea    0xd83(%rip),%r12
lea    0xe35(%rip),%r13
lea    0xe5e(%rip),%rbp
lea    0x1065(%rip),%rax
mov    %rax,0x8(%rsp)
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    12ce <main+0x15e>
lea    0xe34(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %r15d,%rax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %r13,%rdi
call   1080 <scanf@plt>
nop
lea    0x1(%rbx),%eax
cmp    $0x63,%ebx
mov    %eax,%ebx
jge    13e9 <main+0x279>
movslq %ebx,%rax
movslq 0x10(%rsp,%rax,4),%rsi
xor    %eax,%eax
cmp    $0xfa0,%rsi
setge  %dl
imul   $0x51eb851f,%rsi,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rcx
add    %edi,%ecx
cmp    $0x2b,%ecx
ja     1427 <main+0x2b7>
imul   $0x64,%ecx,%edi
mov    %esi,%r15d
sub    %edi,%r15d
mov    %dl,%al
sub    %eax,%r15d
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
movslq %r15d,%rax
mov    0x10(%rsp,%rax,4),%ecx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12c0 <main+0x150>
movslq %r15d,%rax
mov    0x10(%rsp,%rax,4),%r14d
jmp    12c0 <main+0x150>
movslq %r15d,%rax
mov    %r14d,0x10(%rsp,%rax,4)
jmp    12c0 <main+0x150>
movslq %r15d,%rax
mov    0x10(%rsp,%rax,4),%ecx
lea    (%rcx,%r14,1),%eax
add    %r14d,%ecx
add    $0xffffd8f0,%ecx
mov    %eax,%r14d
cmp    $0xffffb1e1,%ecx
jae    12c0 <main+0x150>
jmp    144b <main+0x2db>
movslq %r15d,%rax
sub    0x10(%rsp,%rax,4),%r14d
lea    -0x2710(%r14),%eax
cmp    $0xffffb1e1,%eax
jae    12c0 <main+0x150>
jmp    144b <main+0x2db>
movslq %r15d,%rax
mov    0x10(%rsp,%rax,4),%ecx
mov    %r14d,%eax
cltd
idiv   %ecx
mov    %eax,%r14d
test   %ecx,%ecx
jne    12c0 <main+0x150>
jmp    143f <main+0x2cf>
movslq %r15d,%rax
imul   0x10(%rsp,%rax,4),%r14d
lea    -0x2710(%r14),%eax
cmp    $0xffffb1e0,%eax
ja     12c0 <main+0x150>
jmp    144b <main+0x2db>
mov    %r15d,%ebx
jmp    12c0 <main+0x150>
test   %r14d,%r14d
cmovs  %r15d,%ebx
jmp    12c0 <main+0x150>
test   %r14d,%r14d
cmove  %r15d,%ebx
jmp    12c0 <main+0x150>
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    $0x64,%esi
call   1060 <dump@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    %ebx,%esi
jmp    13f6 <main+0x286>
lea    0xce6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    0xe5c(%rip),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    %ebx,%esi
call   1060 <dump@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [308 x i8] c"*** Welcome to the Simpletron! ***\0A*** Please enter your program one instruction ***\0A*** (or data word) at a time. I will type the ***\0A*** location number and a question mark (?). ***\0A*** You then type the word for that location. ***\0A*** Type the sentinel -99999 to stop entering ***\0A*** your program. ***\0A\00"
@.str.1 = [9 x i8] c"%.2d ?? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"*** Invalid instruction: %d\0A\00"
@.str.4 = [31 x i8] c"*** Please retype it or exit.\0A\00"
@.str.5 = [69 x i8] c"*** Program loading completed ***\0A*** Program execution begins ***\0A\00"
@.str.6 = [16 x i8] c"Insert a word: \00"
@.str.7 = [43 x i8] c"\0AMemory location: %.2d\0AWord: %d\0AASCII: %c\0A\00"
@.str.8 = [41 x i8] c"*** Simpletron execution terminated ***\0A\00"
@.str.9 = [23 x i8] c"*** unknown error: %d\0A\00"
@.str.10 = [38 x i8] c"*** Out of the accumulator limit ***\0A\00"
@.str.11 = [35 x i8] c"*** Attempt to divide by zero ***\0A\00"
@.str.12 = [52 x i8] c"*** Simpletron execution abnormally terminated ***\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 = bitcast [100 x i32]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([308 x i8], [308 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %48, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %51
14: ; preds = %11
br label %15
15: ; preds = %14, %46
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -99999
br i1 %26, label %27, label %31
27: ; preds = %15
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %29
store i32 0, i32* %30
store i32 100, i32* %3
br label %47
31: ; preds = %15
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i64 @checkword(i32 %35, i32 100)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %31
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %46
45: ; preds = %31
br label %47
46: ; preds = %38
br label %15
47: ; preds = %45, %27
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %11
51: ; preds = %11
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %53
53: ; preds = %197, %51
%54 = load i32, i32* %3
%55 = icmp slt i32 %54, 100
br i1 %55, label %56, label %200
56: ; preds = %53
%57 = load i32, i32* %3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %58
%60 = load i32, i32* %59
store i32 %60, i32* %6
%61 = load i32, i32* %6
%62 = sdiv i32 %61, 100
store i32 %62, i32* %5
%63 = load i32, i32* %6
%64 = srem i32 %63, 100
store i32 %64, i32* %8
%65 = load i32, i32* %5
%66 = icmp sge i32 %65, 40
br i1 %66, label %67, label %70
67: ; preds = %56
%68 = load i32, i32* %8
%69 = add nsw i32 %68, -1
store i32 %69, i32* %8
br label %70
70: ; preds = %67, %56
%71 = load i32, i32* %5
switch i32 %71, label %176 [
i32 10, label %72
i32 11, label %78
i32 20, label %89
i32 21, label %94
i32 30, label %99
i32 31, label %113
i32 32, label %127
i32 33, label %141
i32 40, label %155
i32 41, label %157
i32 42, label %163
i32 43, label %169
i32 0, label %175
]
72: ; preds = %70
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %75
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %76)
br label %180
78: ; preds = %70
%79 = load i32, i32* %8
%80 = load i32, i32* %8
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = load i32, i32* %8
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %79, i32 %83, i32 %87)
br label %180
89: ; preds = %70
%90 = load i32, i32* %8
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %91
%93 = load i32, i32* %92
store i32 %93, i32* %7
br label %180
94: ; preds = %70
%95 = load i32, i32* %7
%96 = load i32, i32* %8
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %97
store i32 %95, i32* %98
br label %180
99: ; preds = %70
%100 = load i32, i32* %8
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = load i32, i32* %7
%105 = add nsw i32 %104, %103
store i32 %105, i32* %7
%106 = load i32, i32* %7
%107 = icmp sgt i32 %106, 9999
br i1 %107, label %111, label %108
108: ; preds = %99
%109 = load i32, i32* %7
%110 = icmp slt i32 %109, -9999
br i1 %110, label %111, label %112
111: ; preds = %108, %99
store i32 1, i32* %4
br label %112
112: ; preds = %111, %108
br label %180
113: ; preds = %70
%114 = load i32, i32* %8
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %115
%117 = load i32, i32* %116
%118 = load i32, i32* %7
%119 = sub nsw i32 %118, %117
store i32 %119, i32* %7
%120 = load i32, i32* %7
%121 = icmp sgt i32 %120, 9999
br i1 %121, label %125, label %122
122: ; preds = %113
%123 = load i32, i32* %7
%124 = icmp slt i32 %123, -9999
br i1 %124, label %125, label %126
125: ; preds = %122, %113
store i32 1, i32* %4
br label %126
126: ; preds = %125, %122
br label %180
127: ; preds = %70
%128 = load i32, i32* %8
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %129
%131 = load i32, i32* %130
%132 = load i32, i32* %7
%133 = sdiv i32 %132, %131
store i32 %133, i32* %7
%134 = load i32, i32* %8
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %135
%137 = load i32, i32* %136
%138 = icmp ne i32 %137, 0
br i1 %138, label %140, label %139
139: ; preds = %127
store i32 2, i32* %4
br label %140
140: ; preds = %139, %127
br label %180
141: ; preds = %70
%142 = load i32, i32* %8
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %143
%145 = load i32, i32* %144
%146 = load i32, i32* %7
%147 = mul nsw i32 %146, %145
store i32 %147, i32* %7
%148 = load i32, i32* %7
%149 = icmp sgt i32 %148, 9999
br i1 %149, label %153, label %150
150: ; preds = %141
%151 = load i32, i32* %7
%152 = icmp slt i32 %151, -9999
br i1 %152, label %153, label %154
153: ; preds = %150, %141
store i32 1, i32* %4
br label %154
154: ; preds = %153, %150
br label %180
155: ; preds = %70
%156 = load i32, i32* %8
store i32 %156, i32* %3
br label %180
157: ; preds = %70
%158 = load i32, i32* %7
%159 = icmp slt i32 %158, 0
br i1 %159, label %160, label %162
160: ; preds = %157
%161 = load i32, i32* %8
store i32 %161, i32* %3
br label %162
162: ; preds = %160, %157
br label %180
163: ; preds = %70
%164 = load i32, i32* %7
%165 = icmp ne i32 %164, 0
br i1 %165, label %168, label %166
166: ; preds = %163
%167 = load i32, i32* %8
store i32 %167, i32* %3
br label %168
168: ; preds = %166, %163
br label %180
169: ; preds = %70
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%171 = load i32, i32* %7
%172 = load i32, i32* %3
%173 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%174 = call i32 @dump(i32 %171, i32 %172, i32* %173)
store i32 0, i32* %1
br label %205
175: ; preds = %70
br label %180
176: ; preds = %70
%177 = load i32, i32* %6
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %177)
%179 = call i32 @exit(i32 -1)
unreachable
180: ; preds = %175, %168, %162, %155, %154, %140, %126, %112, %94, %89, %78, %72
%181 = load i32, i32* %4
%182 = icmp ne i32 %181, 0
br i1 %182, label %183, label %196
183: ; preds = %180
%184 = load i32, i32* %4
switch i32 %184, label %189 [
i32 1, label %185
i32 2, label %187
]
185: ; preds = %183
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
br label %189
187: ; preds = %183
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0))
br label %189
189: ; preds = %183, %187, %185
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%191 = load i32, i32* %7
%192 = load i32, i32* %3
%193 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%194 = call i32 @dump(i32 %191, i32 %192, i32* %193)
%195 = call i32 @exit(i32 -1)
unreachable
196: ; preds = %180
br label %197
197: ; preds = %196
%198 = load i32, i32* %3
%199 = add nsw i32 %198, 1
store i32 %199, i32* %3
br label %53
200: ; preds = %53
%201 = load i32, i32* %7
%202 = load i32, i32* %3
%203 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%204 = call i32 @dump(i32 %201, i32 %202, i32* %203)
store i32 0, i32* %1
br label %205
205: ; preds = %200, %169
%206 = load i32, i32* %1
ret i32 %206
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%.2d ?? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [29 x i8] c"*** Invalid instruction: %d\0A\00"
@.str.6 = [16 x i8] c"Insert a word: \00"
@.str.7 = [43 x i8] c"\0AMemory location: %.2d\0AWord: %d\0AASCII: %c\0A\00"
@.str.9 = [23 x i8] c"*** unknown error: %d\0A\00"
@str = [307 x i8] c"*** Welcome to the Simpletron! ***\0A*** Please enter your program one instruction ***\0A*** (or data word) at a time. I will type the ***\0A*** location number and a question mark (?). ***\0A*** You then type the word for that location. ***\0A*** Type the sentinel -99999 to stop entering ***\0A*** your program. ***\00"
@str.13 = [68 x i8] c"*** Program loading completed ***\0A*** Program execution begins ***\00"
@str.14 = [34 x i8] c"*** Attempt to divide by zero ***\00"
@str.15 = [51 x i8] c"*** Simpletron execution abnormally terminated ***\00"
@str.16 = [37 x i8] c"*** Out of the accumulator limit ***\00"
@str.17 = [40 x i8] c"*** Simpletron execution terminated ***\00"
@str.18 = [30 x i8] c"*** Please retype it or exit.\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([307 x i8], [307 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %25
%5 = phi i32 [ 0, %0 ], [ %26, %25 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = zext i32 %5 to i64
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %7
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, -99999
br i1 %11, label %12, label %13
12: ; preds = %4, %17
store i32 0, i32* %8
br label %28
13: ; preds = %4, %17
%14 = phi i32 [ %23, %17 ], [ %10, %4 ]
%15 = call i64 @checkword(i32 %14, i32 100)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.18, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -99999
br i1 %24, label %12, label %13
25: ; preds = %13
%26 = add nuw nsw i32 %5, 1
%27 = icmp ult i32 %5, 99
br i1 %27, label %4, label %28
28: ; preds = %25, %12
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.13, i64 0, i64 0))
br label %30
30: ; preds = %28, %107
%31 = phi i32 [ 0, %28 ], [ %108, %107 ]
%32 = phi i32 [ 0, %28 ], [ %110, %107 ]
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = sdiv i32 %35, 100
%37 = srem i32 %35, 100
%38 = icmp sgt i32 %35, 3999
%39 = sext i1 %38 to i32
%40 = add nsw i32 %37, %39
switch i32 %36, label %89 [
i32 10, label %41
i32 11, label %46
i32 20, label %51
i32 21, label %55
i32 30, label %58
i32 31, label %65
i32 32, label %72
i32 33, label %92
i32 40, label %78
i32 41, label %79
i32 42, label %82
i32 43, label %85
i32 0, label %107
]
41: ; preds = %30
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%43 = sext i32 %40 to i64
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %43
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %44)
br label %107
46: ; preds = %30
%47 = sext i32 %40 to i64
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %40, i32 %49, i32 %49)
br label %107
51: ; preds = %30
%52 = sext i32 %40 to i64
%53 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %52
%54 = load i32, i32* %53
br label %107
55: ; preds = %30
%56 = sext i32 %40 to i64
%57 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %56
store i32 %31, i32* %57
br label %107
58: ; preds = %30
%59 = sext i32 %40 to i64
%60 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = add nsw i32 %61, %31
%63 = add i32 %62, -10000
%64 = icmp ult i32 %63, -19999
br i1 %64, label %99, label %107
65: ; preds = %30
%66 = sext i32 %40 to i64
%67 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = sub nsw i32 %31, %68
%70 = add i32 %69, -10000
%71 = icmp ult i32 %70, -19999
br i1 %71, label %99, label %107
72: ; preds = %30
%73 = sext i32 %40 to i64
%74 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = sdiv i32 %31, %75
%77 = icmp eq i32 %75, 0
br i1 %77, label %99, label %107
78: ; preds = %30
br label %107
79: ; preds = %30
%80 = icmp slt i32 %31, 0
%81 = select i1 %80, i32 %40, i32 %32
br label %107
82: ; preds = %30
%83 = icmp eq i32 %31, 0
%84 = select i1 %83, i32 %40, i32 %32
br label %107
85: ; preds = %30
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.17, i64 0, i64 0))
%87 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%88 = call i32 @dump(i32 %31, i32 %32, i32* %87)
br label %115
89: ; preds = %30
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %35)
%91 = call i32 @exit(i32 -1)
unreachable
92: ; preds = %30
%93 = sext i32 %40 to i64
%94 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = mul nsw i32 %95, %31
%97 = add i32 %96, -10000
%98 = icmp ult i32 %97, -19999
br i1 %98, label %99, label %107
99: ; preds = %72, %92, %58, %65
%100 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0), %65 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0), %58 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0), %92 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.14, i64 0, i64 0), %72 ]
%101 = phi i32 [ %69, %65 ], [ %62, %58 ], [ %96, %92 ], [ %76, %72 ]
%102 = call i32 @puts(i8* dereferenceable(1) %100)
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%104 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%105 = call i32 @dump(i32 %101, i32 %32, i32* %104)
%106 = call i32 @exit(i32 -1)
unreachable
107: ; preds = %82, %79, %41, %46, %51, %55, %78, %30, %72, %65, %58, %92
%108 = phi i32 [ %96, %92 ], [ %62, %58 ], [ %69, %65 ], [ %76, %72 ], [ %31, %82 ], [ %31, %79 ], [ %31, %41 ], [ %31, %46 ], [ %54, %51 ], [ %31, %55 ], [ %31, %78 ], [ %31, %30 ]
%109 = phi i32 [ %32, %92 ], [ %32, %58 ], [ %32, %65 ], [ %32, %72 ], [ %84, %82 ], [ %81, %79 ], [ %32, %41 ], [ %32, %46 ], [ %32, %51 ], [ %32, %55 ], [ %40, %78 ], [ %32, %30 ]
%110 = add nsw i32 %109, 1
%111 = icmp slt i32 %109, 99
br i1 %111, label %30, label %112
112: ; preds = %107
%113 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%114 = call i32 @dump(i32 %108, i32 100, i32* %113)
br label %115
115: ; preds = %112, %85
ret i32 0
}