#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned char EOF;
unsigned char *calloc(int, int);
int /*<<< orphan*/ error(char *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(unsigned char *);
size_t get_bit(unsigned char, int);
int get_inst(unsigned char);
size_t get_loc(unsigned char);
size_t get_reg(unsigned char);
int /*<<< orphan*/ print_state(unsigned char *, unsigned char *,
                               unsigned char **, unsigned char **);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  unsigned char ip;
  unsigned char ir;
  unsigned char *mem;
  unsigned char *reg;
  FILE *input;
  int i;
  unsigned char c;
  unsigned char state;
  ip = 0;
  ir = 0;
  input = NULL;
  state = 1;
  mem = calloc(16, sizeof(unsigned char));
  reg = calloc(2, sizeof(unsigned char));
  if (argc < 2) {
    printf("No input.\n");
    return 1;
  }
  input = fopen(argv[1], "r");
  if (input == NULL)
    error("Could not open file");
  for (i = 0; (i < 16) && ((c = fgetc(input)) != EOF); i++)
    mem[i] = c;
  while (state == 1) {
    ir = mem[ip];
    switch (get_inst(ir)) {
    case 0x00:
      reg[get_reg(ir)] = mem[get_loc(ir)];
      break;
    case 0x01:
      mem[get_loc(ir)] = reg[get_reg(ir)];
      break;
    case 0x02:
      reg[get_reg(ir)] = get_loc(ir);
      break;
    case 0x03:
      ip = get_loc(ir) - 1;
      break;
    case 0x04:
      if (reg[get_reg(ir)] == 0)
        ip = get_loc(ir) - 1;
      break;
    case 0x05:
      reg[get_reg(ir)] = reg[get_bit(ir, 1)] + reg[get_bit(ir, 0)];
      break;
    case 0x06:
      reg[get_reg(ir)] = reg[get_bit(ir, 1)] - reg[get_bit(ir, 0)];
      break;
    case 0x07:
      print_state(&ip, &ir, &reg, &mem);
      state = 0;
      break;
    }
    if (state == 1)
      ip++;
  }
  free(mem);
  free(reg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
movq   $0x0,-0x30(%rbp)
movb   $0x1,-0x36(%rbp)
mov    $0x10,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1225 <main+0x75>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    156b <main+0x3bb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1254 <main+0xa4>
lea    0xdde(%rip),%rdi
call   1090 <error@plt>
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x10,-0x34(%rbp)
mov    %al,-0x37(%rbp)
jge    128b <main+0xdb>
mov    -0x30(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x35(%rbp)
movzbl %al,%eax
mov    0x2d68(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x37(%rbp)
mov    -0x37(%rbp),%al
test   $0x1,%al
jne    129b <main+0xeb>
jmp    12b7 <main+0x107>
mov    -0x35(%rbp),%dl
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    125b <main+0xab>
jmp    12bc <main+0x10c>
movzbl -0x36(%rbp),%eax
cmp    $0x1,%eax
jne    1552 <main+0x3a2>
mov    -0x20(%rbp),%rax
movzbl -0x11(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%edi
call   1080 <get_inst@plt>
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x7,%eax
ja     1538 <main+0x388>
mov    -0x40(%rbp),%rax
lea    0xd06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
movzbl -0x12(%rbp),%edi
call   10d0 <get_loc@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x49(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    -0x49(%rbp),%dl
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1538 <main+0x388>
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x61(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
movzbl -0x12(%rbp),%edi
call   10d0 <get_loc@plt>
mov    -0x61(%rbp),%dl
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1538 <main+0x388>
movzbl -0x12(%rbp),%edi
call   10d0 <get_loc@plt>
mov    %al,-0x79(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    -0x79(%rbp),%dl
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1538 <main+0x388>
movzbl -0x12(%rbp),%edi
call   10d0 <get_loc@plt>
sub    $0x1,%rax
mov    %al,-0x11(%rbp)
jmp    1538 <main+0x388>
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1404 <main+0x254>
movzbl -0x12(%rbp),%edi
call   10d0 <get_loc@plt>
sub    $0x1,%rax
mov    %al,-0x11(%rbp)
jmp    1538 <main+0x388>
mov    -0x28(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x1,%esi
movzbl -0x12(%rbp),%edi
call   10b0 <get_bit@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x98(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa0(%rbp)
xor    %esi,%esi
movzbl -0x12(%rbp),%edi
call   10b0 <get_bit@plt>
mov    -0xa0(%rbp),%rcx
mov    %rax,%rdx
mov    -0x98(%rbp),%eax
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %al,-0x91(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    -0x91(%rbp),%dl
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1538 <main+0x388>
mov    -0x28(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    $0x1,%esi
movzbl -0x12(%rbp),%edi
call   10b0 <get_bit@plt>
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0xb8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xc0(%rbp)
xor    %esi,%esi
movzbl -0x12(%rbp),%edi
call   10b0 <get_bit@plt>
mov    -0xc0(%rbp),%rcx
mov    %rax,%rdx
mov    -0xb8(%rbp),%eax
movzbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
mov    %al,-0xb1(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
movzbl -0x12(%rbp),%edi
call   1040 <get_reg@plt>
mov    -0xb1(%rbp),%dl
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1538 <main+0x388>
lea    -0x11(%rbp),%rdi
lea    -0x12(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   10c0 <print_state@plt>
movb   $0x0,-0x36(%rbp)
movzbl -0x36(%rbp),%eax
cmp    $0x1,%eax
jne    154d <main+0x39d>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    12bc <main+0x10c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
movb   $0x0,0x7(%rsp)
mov    $0x1,%ebp
mov    $0x10,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
mov    %rax,0x10(%rsp)
mov    $0x2,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,0x8(%rsp)
cmp    $0x1,%r15d
jg     120c <main+0x5c>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
jmp    14d6 <main+0x326>
mov    0x8(%r14),%rdi
lea    0xe09(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1230 <main+0x80>
lea    0xdf7(%rip),%rdi
call   1090 <error@plt>
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    0x2da9(%rip),%rbp
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x1(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x2(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x3(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x4(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x5(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x6(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x7(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x8(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0x9(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xa(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xb(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xc(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xd(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xe(%rbx)
mov    %r14,%rdi
call   1060 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1356 <main+0x1a6>
mov    %al,0xf(%rbx)
xor    %eax,%eax
lea    0xca1(%rip),%r14
jmp    1390 <main+0x1e0>
movzbl 0x6(%rsp),%edi
call   10d0 <get_loc@plt>
add    $0xff,%al
mov    %al,0x7(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x7(%rsp),%eax
add    $0x1,%al
mov    %al,0x7(%rsp)
mov    0x10(%rsp),%rbx
movzbl %al,%eax
movzbl (%rbx,%rax,1),%edi
mov    %dil,0x6(%rsp)
call   1080 <get_inst@plt>
cmp    $0x7,%eax
ja     1380 <main+0x1d0>
mov    %eax,%eax
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x10(%rsp),%rbx
movzbl 0x6(%rsp),%edi
call   10d0 <get_loc@plt>
movzbl (%rbx,%rax,1),%ebx
jmp    148f <main+0x2df>
mov    0x8(%rsp),%rbx
movzbl 0x6(%rsp),%edi
call   1050 <get_reg@plt>
movzbl (%rbx,%rax,1),%ebx
mov    0x10(%rsp),%rbp
movzbl 0x6(%rsp),%edi
call   10d0 <get_loc@plt>
jmp    149e <main+0x2ee>
movzbl 0x6(%rsp),%edi
call   10d0 <get_loc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rbp
movzbl 0x6(%rsp),%edi
call   1050 <get_reg@plt>
mov    %bl,0x0(%rbp,%rax,1)
jmp    1380 <main+0x1d0>
mov    0x8(%rsp),%rbx
movzbl 0x6(%rsp),%edi
call   1050 <get_reg@plt>
cmpb   $0x0,(%rbx,%rax,1)
jne    1380 <main+0x1d0>
jmp    1361 <main+0x1b1>
mov    0x8(%rsp),%rbx
movzbl 0x6(%rsp),%edi
mov    $0x1,%esi
call   10b0 <get_bit@plt>
movzbl (%rbx,%rax,1),%ebx
mov    0x8(%rsp),%rbp
movzbl 0x6(%rsp),%edi
xor    %esi,%esi
call   10b0 <get_bit@plt>
add    0x0(%rbp,%rax,1),%bl
jmp    148f <main+0x2df>
mov    0x8(%rsp),%rbx
movzbl 0x6(%rsp),%edi
mov    $0x1,%esi
call   10b0 <get_bit@plt>
movzbl (%rbx,%rax,1),%ebx
mov    0x8(%rsp),%rbp
movzbl 0x6(%rsp),%edi
xor    %esi,%esi
call   10b0 <get_bit@plt>
sub    0x0(%rbp,%rax,1),%bl
mov    0x8(%rsp),%rbp
movzbl 0x6(%rsp),%edi
call   1050 <get_reg@plt>
mov    %bl,0x0(%rbp,%rax,1)
jmp    1380 <main+0x1d0>
lea    0x7(%rsp),%rdi
lea    0x6(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   10c0 <print_state@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"No input.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Could not open file\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
store i8 0, i8* %7
store i32* null, i32** %10
store i8 1, i8* %13
%14 = call i8* @calloc(i32 16, i32 1)
store i8* %14, i8** %8
%15 = call i8* @calloc(i32 2, i32 1)
store i8* %15, i8** %9
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %164
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %10
%25 = load i32*, i32** %10
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %20
store i32 0, i32* %11
br label %30
30: ; preds = %48, %29
%31 = load i32, i32* %11
%32 = icmp slt i32 %31, 16
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32*, i32** %10
%35 = call zeroext i8 @fgetc(i32* %34)
store i8 %35, i8* %12
%36 = zext i8 %35 to i32
%37 = load i8, i8* @EOF
%38 = zext i8 %37 to i32
%39 = icmp ne i32 %36, %38
br label %40
40: ; preds = %33, %30
%41 = phi i1 [ false, %30 ], [ %39, %33 ]
br i1 %41, label %42, label %51
42: ; preds = %40
%43 = load i8, i8* %12
%44 = load i8*, i8** %8
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %42
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %30
51: ; preds = %40
br label %52
52: ; preds = %158, %51
%53 = load i8, i8* %13
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %159
56: ; preds = %52
%57 = load i8*, i8** %8
%58 = load i8, i8* %6
%59 = zext i8 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
store i8 %61, i8* %7
%62 = load i8, i8* %7
%63 = call i32 @get_inst(i8 zeroext %62)
switch i32 %63, label %151 [
i32 0, label %64
i32 1, label %74
i32 2, label %84
i32 3, label %92
i32 4, label %97
i32 5, label %111
i32 6, label %130
i32 7, label %149
]
64: ; preds = %56
%65 = load i8*, i8** %8
%66 = load i8, i8* %7
%67 = call i64 @get_loc(i8 zeroext %66)
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = load i8*, i8** %9
%71 = load i8, i8* %7
%72 = call i64 @get_reg(i8 zeroext %71)
%73 = getelementptr inbounds i8, i8* %70, i64 %72
store i8 %69, i8* %73
br label %151
74: ; preds = %56
%75 = load i8*, i8** %9
%76 = load i8, i8* %7
%77 = call i64 @get_reg(i8 zeroext %76)
%78 = getelementptr inbounds i8, i8* %75, i64 %77
%79 = load i8, i8* %78
%80 = load i8*, i8** %8
%81 = load i8, i8* %7
%82 = call i64 @get_loc(i8 zeroext %81)
%83 = getelementptr inbounds i8, i8* %80, i64 %82
store i8 %79, i8* %83
br label %151
84: ; preds = %56
%85 = load i8, i8* %7
%86 = call i64 @get_loc(i8 zeroext %85)
%87 = trunc i64 %86 to i8
%88 = load i8*, i8** %9
%89 = load i8, i8* %7
%90 = call i64 @get_reg(i8 zeroext %89)
%91 = getelementptr inbounds i8, i8* %88, i64 %90
store i8 %87, i8* %91
br label %151
92: ; preds = %56
%93 = load i8, i8* %7
%94 = call i64 @get_loc(i8 zeroext %93)
%95 = sub i64 %94, 1
%96 = trunc i64 %95 to i8
store i8 %96, i8* %6
br label %151
97: ; preds = %56
%98 = load i8*, i8** %9
%99 = load i8, i8* %7
%100 = call i64 @get_reg(i8 zeroext %99)
%101 = getelementptr inbounds i8, i8* %98, i64 %100
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %110
105: ; preds = %97
%106 = load i8, i8* %7
%107 = call i64 @get_loc(i8 zeroext %106)
%108 = sub i64 %107, 1
%109 = trunc i64 %108 to i8
store i8 %109, i8* %6
br label %110
110: ; preds = %105, %97
br label %151
111: ; preds = %56
%112 = load i8*, i8** %9
%113 = load i8, i8* %7
%114 = call i64 @get_bit(i8 zeroext %113, i32 1)
%115 = getelementptr inbounds i8, i8* %112, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = load i8*, i8** %9
%119 = load i8, i8* %7
%120 = call i64 @get_bit(i8 zeroext %119, i32 0)
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = load i8, i8* %121
%123 = zext i8 %122 to i32
%124 = add nsw i32 %117, %123
%125 = trunc i32 %124 to i8
%126 = load i8*, i8** %9
%127 = load i8, i8* %7
%128 = call i64 @get_reg(i8 zeroext %127)
%129 = getelementptr inbounds i8, i8* %126, i64 %128
store i8 %125, i8* %129
br label %151
130: ; preds = %56
%131 = load i8*, i8** %9
%132 = load i8, i8* %7
%133 = call i64 @get_bit(i8 zeroext %132, i32 1)
%134 = getelementptr inbounds i8, i8* %131, i64 %133
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = load i8*, i8** %9
%138 = load i8, i8* %7
%139 = call i64 @get_bit(i8 zeroext %138, i32 0)
%140 = getelementptr inbounds i8, i8* %137, i64 %139
%141 = load i8, i8* %140
%142 = zext i8 %141 to i32
%143 = sub nsw i32 %136, %142
%144 = trunc i32 %143 to i8
%145 = load i8*, i8** %9
%146 = load i8, i8* %7
%147 = call i64 @get_reg(i8 zeroext %146)
%148 = getelementptr inbounds i8, i8* %145, i64 %147
store i8 %144, i8* %148
br label %151
149: ; preds = %56
%150 = call i32 @print_state(i8* %6, i8* %7, i8** %9, i8** %8)
store i8 0, i8* %13
br label %151
151: ; preds = %56, %149, %130, %111, %110, %92, %84, %74, %64
%152 = load i8, i8* %13
%153 = zext i8 %152 to i32
%154 = icmp eq i32 %153, 1
br i1 %154, label %155, label %158
155: ; preds = %151
%156 = load i8, i8* %6
%157 = add i8 %156, 1
store i8 %157, i8* %6
br label %158
158: ; preds = %155, %151
br label %52
159: ; preds = %52
%160 = load i8*, i8** %8
%161 = call i32 @free(i8* %160)
%162 = load i8*, i8** %9
%163 = call i32 @free(i8* %162)
store i32 0, i32* %3
br label %164
164: ; preds = %159, %18
%165 = load i32, i32* %3
ret i32 %165
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Could not open file\00"
@EOF = global i8 0
@str = [10 x i8] c"No input.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i8** %5 to i8*
%8 = bitcast i8** %6 to i8*
store i8 0, i8* %3
%9 = tail call dereferenceable_or_null(16) i8* @calloc(i32 16, i32 1)
store i8* %9, i8** %5
%10 = tail call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
store i8* %10, i8** %6
%11 = icmp slt i32 %0, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %196
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = tail call zeroext i8 @fgetc(i32* %17)
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %101, label %25
25: ; preds = %21
store i8 %22, i8* %9
%26 = tail call zeroext i8 @fgetc(i32* %17)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %101, label %29
29: ; preds = %25
%30 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %26, i8* %30
%31 = tail call zeroext i8 @fgetc(i32* %17)
%32 = load i8, i8* @EOF
%33 = icmp eq i8 %31, %32
br i1 %33, label %101, label %34
34: ; preds = %29
%35 = getelementptr inbounds i8, i8* %9, i64 2
store i8 %31, i8* %35
%36 = tail call zeroext i8 @fgetc(i32* %17)
%37 = load i8, i8* @EOF
%38 = icmp eq i8 %36, %37
br i1 %38, label %101, label %39
39: ; preds = %34
%40 = getelementptr inbounds i8, i8* %9, i64 3
store i8 %36, i8* %40
%41 = tail call zeroext i8 @fgetc(i32* %17)
%42 = load i8, i8* @EOF
%43 = icmp eq i8 %41, %42
br i1 %43, label %101, label %44
44: ; preds = %39
%45 = getelementptr inbounds i8, i8* %9, i64 4
store i8 %41, i8* %45
%46 = tail call zeroext i8 @fgetc(i32* %17)
%47 = load i8, i8* @EOF
%48 = icmp eq i8 %46, %47
br i1 %48, label %101, label %49
49: ; preds = %44
%50 = getelementptr inbounds i8, i8* %9, i64 5
store i8 %46, i8* %50
%51 = tail call zeroext i8 @fgetc(i32* %17)
%52 = load i8, i8* @EOF
%53 = icmp eq i8 %51, %52
br i1 %53, label %101, label %54
54: ; preds = %49
%55 = getelementptr inbounds i8, i8* %9, i64 6
store i8 %51, i8* %55
%56 = tail call zeroext i8 @fgetc(i32* %17)
%57 = load i8, i8* @EOF
%58 = icmp eq i8 %56, %57
br i1 %58, label %101, label %59
59: ; preds = %54
%60 = getelementptr inbounds i8, i8* %9, i64 7
store i8 %56, i8* %60
%61 = tail call zeroext i8 @fgetc(i32* %17)
%62 = load i8, i8* @EOF
%63 = icmp eq i8 %61, %62
br i1 %63, label %101, label %64
64: ; preds = %59
%65 = getelementptr inbounds i8, i8* %9, i64 8
store i8 %61, i8* %65
%66 = tail call zeroext i8 @fgetc(i32* %17)
%67 = load i8, i8* @EOF
%68 = icmp eq i8 %66, %67
br i1 %68, label %101, label %69
69: ; preds = %64
%70 = getelementptr inbounds i8, i8* %9, i64 9
store i8 %66, i8* %70
%71 = tail call zeroext i8 @fgetc(i32* %17)
%72 = load i8, i8* @EOF
%73 = icmp eq i8 %71, %72
br i1 %73, label %101, label %74
74: ; preds = %69
%75 = getelementptr inbounds i8, i8* %9, i64 10
store i8 %71, i8* %75
%76 = tail call zeroext i8 @fgetc(i32* %17)
%77 = load i8, i8* @EOF
%78 = icmp eq i8 %76, %77
br i1 %78, label %101, label %79
79: ; preds = %74
%80 = getelementptr inbounds i8, i8* %9, i64 11
store i8 %76, i8* %80
%81 = tail call zeroext i8 @fgetc(i32* %17)
%82 = load i8, i8* @EOF
%83 = icmp eq i8 %81, %82
br i1 %83, label %101, label %84
84: ; preds = %79
%85 = getelementptr inbounds i8, i8* %9, i64 12
store i8 %81, i8* %85
%86 = tail call zeroext i8 @fgetc(i32* %17)
%87 = load i8, i8* @EOF
%88 = icmp eq i8 %86, %87
br i1 %88, label %101, label %89
89: ; preds = %84
%90 = getelementptr inbounds i8, i8* %9, i64 13
store i8 %86, i8* %90
%91 = tail call zeroext i8 @fgetc(i32* %17)
%92 = load i8, i8* @EOF
%93 = icmp eq i8 %91, %92
br i1 %93, label %101, label %94
94: ; preds = %89
%95 = getelementptr inbounds i8, i8* %9, i64 14
store i8 %91, i8* %95
%96 = tail call zeroext i8 @fgetc(i32* %17)
%97 = load i8, i8* @EOF
%98 = icmp eq i8 %96, %97
br i1 %98, label %101, label %99
99: ; preds = %94
%100 = getelementptr inbounds i8, i8* %9, i64 15
store i8 %96, i8* %100
br label %101
101: ; preds = %99, %94, %89, %84, %79, %74, %69, %64, %59, %54, %49, %44, %39, %34, %29, %25, %21
br label %102
102: ; preds = %101, %186
%103 = phi i8 [ %188, %186 ], [ 0, %101 ]
%104 = phi i8* [ %189, %186 ], [ %9, %101 ]
%105 = zext i8 %103 to i64
%106 = getelementptr inbounds i8, i8* %104, i64 %105
%107 = load i8, i8* %106
store i8 %107, i8* %4
%108 = call i32 @get_inst(i8 zeroext %107)
switch i32 %108, label %186 [
i32 0, label %109
i32 1, label %119
i32 2, label %129
i32 3, label %137
i32 4, label %142
i32 5, label %154
i32 6, label %170
i32 7, label %190
]
109: ; preds = %102
%110 = load i8*, i8** %5
%111 = load i8, i8* %4
%112 = call i64 @get_loc(i8 zeroext %111)
%113 = getelementptr inbounds i8, i8* %110, i64 %112
%114 = load i8, i8* %113
%115 = load i8*, i8** %6
%116 = load i8, i8* %4
%117 = call i64 @get_reg(i8 zeroext %116)
%118 = getelementptr inbounds i8, i8* %115, i64 %117
store i8 %114, i8* %118
br label %186
119: ; preds = %102
%120 = load i8*, i8** %6
%121 = load i8, i8* %4
%122 = call i64 @get_reg(i8 zeroext %121)
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = load i8, i8* %123
%125 = load i8*, i8** %5
%126 = load i8, i8* %4
%127 = call i64 @get_loc(i8 zeroext %126)
%128 = getelementptr inbounds i8, i8* %125, i64 %127
store i8 %124, i8* %128
br label %186
129: ; preds = %102
%130 = load i8, i8* %4
%131 = call i64 @get_loc(i8 zeroext %130)
%132 = trunc i64 %131 to i8
%133 = load i8*, i8** %6
%134 = load i8, i8* %4
%135 = call i64 @get_reg(i8 zeroext %134)
%136 = getelementptr inbounds i8, i8* %133, i64 %135
store i8 %132, i8* %136
br label %186
137: ; preds = %102
%138 = load i8, i8* %4
%139 = call i64 @get_loc(i8 zeroext %138)
%140 = trunc i64 %139 to i8
%141 = add i8 %140, -1
store i8 %141, i8* %3
br label %186
142: ; preds = %102
%143 = load i8*, i8** %6
%144 = load i8, i8* %4
%145 = call i64 @get_reg(i8 zeroext %144)
%146 = getelementptr inbounds i8, i8* %143, i64 %145
%147 = load i8, i8* %146
%148 = icmp eq i8 %147, 0
br i1 %148, label %149, label %186
149: ; preds = %142
%150 = load i8, i8* %4
%151 = call i64 @get_loc(i8 zeroext %150)
%152 = trunc i64 %151 to i8
%153 = add i8 %152, -1
store i8 %153, i8* %3
br label %186
154: ; preds = %102
%155 = load i8*, i8** %6
%156 = load i8, i8* %4
%157 = call i64 @get_bit(i8 zeroext %156, i32 1)
%158 = getelementptr inbounds i8, i8* %155, i64 %157
%159 = load i8, i8* %158
%160 = load i8*, i8** %6
%161 = load i8, i8* %4
%162 = call i64 @get_bit(i8 zeroext %161, i32 0)
%163 = getelementptr inbounds i8, i8* %160, i64 %162
%164 = load i8, i8* %163
%165 = add i8 %164, %159
%166 = load i8*, i8** %6
%167 = load i8, i8* %4
%168 = call i64 @get_reg(i8 zeroext %167)
%169 = getelementptr inbounds i8, i8* %166, i64 %168
store i8 %165, i8* %169
br label %186
170: ; preds = %102
%171 = load i8*, i8** %6
%172 = load i8, i8* %4
%173 = call i64 @get_bit(i8 zeroext %172, i32 1)
%174 = getelementptr inbounds i8, i8* %171, i64 %173
%175 = load i8, i8* %174
%176 = load i8*, i8** %6
%177 = load i8, i8* %4
%178 = call i64 @get_bit(i8 zeroext %177, i32 0)
%179 = getelementptr inbounds i8, i8* %176, i64 %178
%180 = load i8, i8* %179
%181 = sub i8 %175, %180
%182 = load i8*, i8** %6
%183 = load i8, i8* %4
%184 = call i64 @get_reg(i8 zeroext %183)
%185 = getelementptr inbounds i8, i8* %182, i64 %184
store i8 %181, i8* %185
br label %186
186: ; preds = %109, %119, %129, %137, %142, %149, %154, %170, %102
%187 = load i8, i8* %3
%188 = add i8 %187, 1
store i8 %188, i8* %3
%189 = load i8*, i8** %5
br label %102
190: ; preds = %102
%191 = call i32 @print_state(i8* %3, i8* %4, i8** %6, i8** %5)
%192 = load i8*, i8** %5
%193 = call i32 @free(i8* %192)
%194 = load i8*, i8** %6
%195 = call i32 @free(i8* %194)
br label %196
196: ; preds = %190, %12
%197 = phi i32 [ 1, %12 ], [ 0, %190 ]
ret i32 %197
}