#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 */
int EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ die_errno(char *);
int fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int putchar(unsigned char);
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  if (argc < 2) {
    die("no program file given");
  }
  unsigned char tape[30000];
  memset(tape, 0, 30000);
  unsigned char *pointer = tape;
  FILE *program = fopen(argv[1], "r");
  if (program == NULL) {
    die_errno("couldn't open program");
  }
  int ret;
  int bracket_depth;
  unsigned char command;
  while ((ret = fgetc(program)) != EOF) {
    command = (unsigned char)ret;
    switch (command) {
    case '>':
      if (pointer - tape < 30000 - 1) {
        pointer++;
      } else {
        die("attempting memory access after end of tape");
      }
      break;
    case '<':
      if (pointer - tape > 0) {
        pointer--;
      } else {
        die("attempting memory access before beginning of tape");
      }
      break;
    case '+':
      (*pointer)++;
      break;
    case '-':
      (*pointer)--;
      break;
    case '.':
      if (putchar(*pointer) == EOF) {
        die("putchar failed");
      }
      break;
    case ',':
      if ((ret = getchar()) == EOF) {
        if (ferror(stdin) != 0) {
          die("getchar failed");
        }
      } else {
        *pointer = (unsigned char)ret;
      }
      break;
    case '[':
      if (*pointer == 0) {
        bracket_depth = 1;
        while (bracket_depth > 0) {
          if ((ret = fgetc(program)) == EOF) {
            if (ferror(program) != 0) {
              die("fgetc on program file failed");
            } else {
              die("no matching ] found");
            }
          }
          if (ret == '[') {
            bracket_depth++;
          } else if (ret == ']') {
            bracket_depth--;
          }
        }
      }
      break;
    case ']':
      if (*pointer != 0) {
        bracket_depth = 1;
        while (bracket_depth > 0) {
          if (fseek(program, -2, SEEK_CUR) == -1) {
            die_errno("fseek on program file failed");
          }
          if ((ret = fgetc(program)) == EOF) {
            if (ferror(program) != 0) {
              die("fgetc on program file failed");
            } else {
              die("no matching [ found");
            }
          }
          if (ret == ']') {
            bracket_depth++;
          } else if (ret == '[') {
            bracket_depth--;
          }
        }
      }
      break;
    }
  }
  if (ferror(program) != 0) {
    die("fgetc on program file failed");
  }
  if (fclose(program) == EOF) {
    die_errno("fclose on program file failed");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7570,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cf <main+0x2f>
lea    0xf02(%rip),%rdi
call   10c0 <die@plt>
lea    -0x7540(%rbp),%rdi
xor    %esi,%esi
mov    $0x7530,%edx
call   1060 <memset@plt>
lea    -0x7540(%rbp),%rax
mov    %rax,-0x7548(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xee3(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x7550(%rbp)
cmpq   $0x0,-0x7550(%rbp)
jne    1225 <main+0x85>
lea    0xec4(%rip),%rdi
call   10a0 <die_errno@plt>
jmp    122a <main+0x8a>
mov    -0x7550(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x7554(%rbp)
mov    0x2d95(%rip),%rcx
cmp    (%rcx),%eax
je     159f <main+0x3ff>
mov    -0x7554(%rbp),%al
mov    %al,-0x7559(%rbp)
movzbl -0x7559(%rbp),%eax
add    $0xffffffd5,%eax
mov    %eax,%ecx
mov    %rcx,-0x7568(%rbp)
sub    $0x32,%eax
ja     159a <main+0x3fa>
mov    -0x7568(%rbp),%rax
lea    0xd7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x7548(%rbp),%rax
lea    -0x7540(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x752f,%rax
jge    12be <main+0x11e>
mov    -0x7548(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7548(%rbp)
jmp    12ca <main+0x12a>
lea    0xe35(%rip),%rdi
call   10c0 <die@plt>
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
lea    -0x7540(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x0,%rax
jle    1301 <main+0x161>
mov    -0x7548(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x7548(%rbp)
jmp    130d <main+0x16d>
lea    0xe1d(%rip),%rdi
call   10c0 <die@plt>
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
mov    (%rax),%cl
add    $0xff,%cl
mov    %cl,(%rax)
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
movzbl (%rax),%edi
call   1030 <putchar@plt>
mov    0x2c8a(%rip),%rcx
cmp    (%rcx),%eax
jne    1362 <main+0x1c2>
lea    0xdfa(%rip),%rdi
call   10c0 <die@plt>
jmp    159a <main+0x3fa>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x7554(%rbp)
mov    0x2c5d(%rip),%rcx
cmp    (%rcx),%eax
jne    13ad <main+0x20d>
mov    0x2c56(%rip),%rax
mov    (%rax),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     13a8 <main+0x208>
lea    0xdc3(%rip),%rdi
call   10c0 <die@plt>
jmp    13be <main+0x21e>
mov    -0x7554(%rbp),%eax
mov    %al,%cl
mov    -0x7548(%rbp),%rax
mov    %cl,(%rax)
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1492 <main+0x2f2>
movl   $0x1,-0x7558(%rbp)
cmpl   $0x0,-0x7558(%rbp)
jle    148d <main+0x2ed>
mov    -0x7550(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x7554(%rbp)
mov    0x2bd2(%rip),%rcx
cmp    (%rcx),%eax
jne    1446 <main+0x2a6>
mov    -0x7550(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1435 <main+0x295>
lea    0xd4a(%rip),%rdi
call   10c0 <die@plt>
jmp    1441 <main+0x2a1>
lea    0xd56(%rip),%rdi
call   10c0 <die@plt>
jmp    1446 <main+0x2a6>
cmpl   $0x5b,-0x7554(%rbp)
jne    1467 <main+0x2c7>
mov    -0x7558(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7558(%rbp)
jmp    1488 <main+0x2e8>
cmpl   $0x5d,-0x7554(%rbp)
jne    1483 <main+0x2e3>
mov    -0x7558(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7558(%rbp)
jmp    1488 <main+0x2e8>
jmp    13e0 <main+0x240>
jmp    1492 <main+0x2f2>
jmp    159a <main+0x3fa>
mov    -0x7548(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     1595 <main+0x3f5>
movl   $0x1,-0x7558(%rbp)
cmpl   $0x0,-0x7558(%rbp)
jle    1590 <main+0x3f0>
mov    -0x7550(%rbp),%rdi
mov    0x2b19(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffe,%esi
call   1090 <fseek@plt>
cmp    $0xffffffff,%eax
jne    14f0 <main+0x350>
lea    0xcbb(%rip),%rdi
call   10a0 <die_errno@plt>
mov    -0x7550(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x7554(%rbp)
mov    0x2acf(%rip),%rcx
cmp    (%rcx),%eax
jne    1549 <main+0x3a9>
mov    -0x7550(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     1538 <main+0x398>
lea    0xc47(%rip),%rdi
call   10c0 <die@plt>
jmp    1544 <main+0x3a4>
lea    0xc84(%rip),%rdi
call   10c0 <die@plt>
jmp    1549 <main+0x3a9>
cmpl   $0x5d,-0x7554(%rbp)
jne    156a <main+0x3ca>
mov    -0x7558(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7558(%rbp)
jmp    158b <main+0x3eb>
cmpl   $0x5b,-0x7554(%rbp)
jne    1586 <main+0x3e6>
mov    -0x7558(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7558(%rbp)
jmp    158b <main+0x3eb>
jmp    14b4 <main+0x314>
jmp    1595 <main+0x3f5>
jmp    159a <main+0x3fa>
jmp    122a <main+0x8a>
mov    -0x7550(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     15c1 <main+0x421>
lea    0xbb9(%rip),%rdi
call   10c0 <die@plt>
mov    -0x7550(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a04(%rip),%rcx
cmp    (%rcx),%eax
jne    15e8 <main+0x448>
lea    0xbf4(%rip),%rdi
call   10a0 <die_errno@plt>
xor    %eax,%eax
add    $0x7570,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7548,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11c5 <main+0x25>
lea    0xf0c(%rip),%rdi
call   10c0 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x7530,%edx
call   1060 <memset@plt>
mov    0x8(%rbx),%rdi
lea    0xf01(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11fa <main+0x5a>
lea    0xeef(%rip),%rdi
call   10a0 <die_errno@plt>
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    0x2dcf(%rip),%r12
cmp    (%r12),%eax
lea    0x10(%rsp),%rbx
jne    125b <main+0xbb>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     122d <main+0x8d>
lea    0xf4d(%rip),%rdi
call   10c0 <die@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
cmp    (%r12),%eax
jne    1247 <main+0xa7>
lea    0xf95(%rip),%rdi
call   10a0 <die_errno@plt>
xor    %eax,%eax
add    $0x7548,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d86(%rip),%r15
mov    %rbx,0x8(%rsp)
jmp    128e <main+0xee>
mov    0x8(%rsp),%rax
addb   $0xff,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <fgetc@plt>
cmp    (%r12),%eax
je     1214 <main+0x74>
add    $0xd5,%al
cmp    $0x32,%al
ja     1280 <main+0xe0>
movzbl %al,%eax
lea    0xd62(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%rax
addb   $0x1,(%rax)
jmp    1280 <main+0xe0>
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    (%r12),%eax
jne    1450 <main+0x2b0>
mov    0x2d17(%rip),%rax
mov    (%rax),%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     1280 <main+0xe0>
lea    0xe89(%rip),%rdi
call   10c0 <die@plt>
jmp    1280 <main+0xe0>
mov    0x8(%rsp),%rax
movzbl (%rax),%edi
call   1030 <putchar@plt>
cmp    (%r12),%eax
jne    1280 <main+0xe0>
lea    0xe59(%rip),%rdi
call   10c0 <die@plt>
jmp    1280 <main+0xe0>
mov    0x8(%rsp),%rcx
mov    %rcx,%rax
sub    %rbx,%rax
test   %rax,%rax
jle    146d <main+0x2cd>
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rsp)
jmp    1280 <main+0xe0>
mov    0x8(%rsp),%rcx
mov    %rcx,%rax
sub    %rbx,%rax
cmp    $0x752e,%rax
jg     145c <main+0x2bc>
add    $0x1,%rcx
mov    %rcx,0x8(%rsp)
jmp    1280 <main+0xe0>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    1280 <main+0xe0>
mov    $0x1,%ebx
jmp    137b <main+0x1db>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebx
test   %ebx,%ebx
jle    147e <main+0x2de>
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
jne    13ad <main+0x20d>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
lea    0xdd8(%rip),%rdi
lea    0xdee(%rip),%rax
cmove  %rax,%rdi
call   10c0 <die@plt>
cmp    $0x5d,%ebp
je     1370 <main+0x1d0>
cmp    $0x5b,%ebp
jne    1373 <main+0x1d3>
add    $0x1,%ebx
jmp    1373 <main+0x1d3>
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1280 <main+0xe0>
mov    $0x1,%ebp
jmp    13eb <main+0x24b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
test   %ebp,%ebp
jle    1280 <main+0xe0>
mov    (%r15),%edx
mov    %r14,%rdi
mov    $0xfffffffe,%esi
call   1090 <fseek@plt>
cmp    $0xffffffff,%eax
jne    140c <main+0x26c>
lea    0xd9f(%rip),%rdi
call   10a0 <die_errno@plt>
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%r13d
cmp    (%r12),%eax
jne    143f <main+0x29f>
mov    %r14,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
lea    0xd46(%rip),%rdi
lea    0xd8d(%rip),%rax
cmove  %rax,%rdi
call   10c0 <die@plt>
cmp    $0x5b,%r13d
je     13e0 <main+0x240>
cmp    $0x5d,%r13d
jne    13e3 <main+0x243>
add    $0x1,%ebp
jmp    13e3 <main+0x243>
mov    0x8(%rsp),%rcx
mov    %al,(%rcx)
jmp    1280 <main+0xe0>
lea    0xc97(%rip),%rdi
call   10c0 <die@plt>
jmp    1280 <main+0xe0>
lea    0xcb1(%rip),%rdi
call   10c0 <die@plt>
jmp    1280 <main+0xe0>
lea    0x10(%rsp),%rbx
jmp    1280 <main+0xe0>

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

LLVM IR (-O2):
@.str = [22 x i8] c"no program file given\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"couldn't open program\00"
@EOF = global i32 0
@.str.3 = [43 x i8] c"attempting memory access after end of tape\00"
@.str.4 = [50 x i8] c"attempting memory access before beginning of tape\00"
@.str.5 = [15 x i8] c"putchar failed\00"
@stdin = global i32* null
@.str.6 = [15 x i8] c"getchar failed\00"
@.str.7 = [29 x i8] c"fgetc on program file failed\00"
@.str.8 = [20 x i8] c"no matching ] found\00"
@SEEK_CUR = global i32 0
@.str.9 = [29 x i8] c"fseek on program file failed\00"
@.str.10 = [20 x i8] c"no matching [ found\00"
@.str.11 = [30 x i8] c"fclose on program file failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [30000 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds [30000 x i8], [30000 x i8]* %3, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 30000)
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @die_errno(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %7
%17 = call i32 @fgetc(i32* %12)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %120, label %20
20: ; preds = %16
%21 = ptrtoint [30000 x i8]* %3 to i64
br label %22
22: ; preds = %20, %115
%23 = phi i32 [ %17, %20 ], [ %117, %115 ]
%24 = phi i8* [ %8, %20 ], [ %116, %115 ]
%25 = trunc i32 %23 to i8
switch i8 %25, label %115 [
i8 62, label %26
i8 60, label %34
i8 43, label %42
i8 45, label %45
i8 46, label %48
i8 44, label %55
i8 91, label %67
i8 93, label %88
]
26: ; preds = %22
%27 = ptrtoint i8* %24 to i64
%28 = sub i64 %27, %21
%29 = icmp slt i64 %28, 29999
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = getelementptr inbounds i8, i8* %24, i64 1
br label %115
32: ; preds = %26
%33 = call i32 @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %115
34: ; preds = %22
%35 = ptrtoint i8* %24 to i64
%36 = sub i64 %35, %21
%37 = icmp sgt i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = getelementptr inbounds i8, i8* %24, i64 -1
br label %115
40: ; preds = %34
%41 = call i32 @die(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
br label %115
42: ; preds = %22
%43 = load i8, i8* %24
%44 = add i8 %43, 1
store i8 %44, i8* %24
br label %115
45: ; preds = %22
%46 = load i8, i8* %24
%47 = add i8 %46, -1
store i8 %47, i8* %24
br label %115
48: ; preds = %22
%49 = load i8, i8* %24
%50 = call i32 @putchar(i8 zeroext %49)
%51 = load i32, i32* @EOF
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %115
53: ; preds = %48
%54 = call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %115
55: ; preds = %22
%56 = call i32 (...) @getchar()
%57 = load i32, i32* @EOF
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %65
59: ; preds = %55
%60 = load i32*, i32** @stdin
%61 = call i64 @ferror(i32* %60)
%62 = icmp eq i64 %61, 0
br i1 %62, label %115, label %63
63: ; preds = %59
%64 = call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %115
65: ; preds = %55
%66 = trunc i32 %56 to i8
store i8 %66, i8* %24
br label %115
67: ; preds = %22
%68 = load i8, i8* %24
%69 = icmp eq i8 %68, 0
br i1 %69, label %70, label %115
70: ; preds = %67, %85
%71 = phi i32 [ %86, %85 ], [ 1, %67 ]
%72 = call i32 @fgetc(i32* %12)
%73 = load i32, i32* @EOF
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %80
75: ; preds = %70
%76 = call i64 @ferror(i32* %12)
%77 = icmp eq i64 %76, 0
%78 = select i1 %77, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0)
%79 = call i32 @die(i8* %78)
br label %80
80: ; preds = %75, %70
switch i32 %72, label %85 [
i32 91, label %81
i32 93, label %83
]
81: ; preds = %80
%82 = add nuw nsw i32 %71, 1
br label %85
83: ; preds = %80
%84 = add nsw i32 %71, -1
br label %85
85: ; preds = %80, %83, %81
%86 = phi i32 [ %82, %81 ], [ %84, %83 ], [ %71, %80 ]
%87 = icmp sgt i32 %86, 0
br i1 %87, label %70, label %115
88: ; preds = %22
%89 = load i8, i8* %24
%90 = icmp eq i8 %89, 0
br i1 %90, label %115, label %91
91: ; preds = %88, %112
%92 = phi i32 [ %113, %112 ], [ 1, %88 ]
%93 = load i32, i32* @SEEK_CUR
%94 = call i32 @fseek(i32* %12, i32 -2, i32 %93)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %91
%97 = call i32 @die_errno(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %98
98: ; preds = %96, %91
%99 = call i32 @fgetc(i32* %12)
%100 = load i32, i32* @EOF
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = call i64 @ferror(i32* %12)
%104 = icmp eq i64 %103, 0
%105 = select i1 %104, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0)
%106 = call i32 @die(i8* %105)
br label %107
107: ; preds = %102, %98
switch i32 %99, label %112 [
i32 93, label %108
i32 91, label %110
]
108: ; preds = %107
%109 = add nuw nsw i32 %92, 1
br label %112
110: ; preds = %107
%111 = add nsw i32 %92, -1
br label %112
112: ; preds = %107, %110, %108
%113 = phi i32 [ %109, %108 ], [ %111, %110 ], [ %92, %107 ]
%114 = icmp sgt i32 %113, 0
br i1 %114, label %91, label %115
115: ; preds = %112, %85, %88, %67, %65, %63, %59, %48, %53, %38, %40, %30, %32, %22, %45, %42
%116 = phi i8* [ %24, %22 ], [ %24, %88 ], [ %24, %67 ], [ %24, %63 ], [ %24, %59 ], [ %24, %65 ], [ %24, %53 ], [ %24, %48 ], [ %24, %45 ], [ %24, %42 ], [ %39, %38 ], [ %24, %40 ], [ %31, %30 ], [ %24, %32 ], [ %24, %85 ], [ %24, %112 ]
%117 = call i32 @fgetc(i32* %12)
%118 = load i32, i32* @EOF
%119 = icmp eq i32 %117, %118
br i1 %119, label %120, label %22
120: ; preds = %115, %16
%121 = call i64 @ferror(i32* %12)
%122 = icmp eq i64 %121, 0
br i1 %122, label %125, label %123
123: ; preds = %120
%124 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %125
125: ; preds = %123, %120
%126 = call i32 @fclose(i32* %12)
%127 = load i32, i32* @EOF
%128 = icmp eq i32 %126, %127
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = call i32 @die_errno(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
br label %131
131: ; preds = %129, %125
ret i32 0
}