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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetpos(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ fsetpos(int /*<<< orphan*/ *, char *);
char getc(int /*<<< orphan*/ *);
void *getchar();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *tmpfile();
int main(int argc, char *argv[]) {
  char array[30000];
  char *ptr = array;
  int inst;
  int numo_braces = 0;
  fpos_t positions[1024];
  fpos_t *pos = positions;
  FILE *file = NULL;
  if (argc > 2) {
    fprintf(stderr, "Usage: %s [FILE]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (--argc > 0) {
    file = fopen(argv[1], "r");
    if (file == NULL) {
      perror("Error while opening file");
      exit(EXIT_FAILURE);
    }
  } else {
    file = tmpfile();
    if (file == NULL) {
      perror("Error while creating tmpfile");
      exit(EXIT_FAILURE);
    }
    printf("%% ");
    while ((inst = getchar()) != EOF) {
      if (inst == '\n')
        printf("%% ");
      putc(inst, file);
    }
    printf("\n--Start--\n");
    fseek(file, 0, SEEK_SET);
  }
  memset(array, 0, 30000);
  memset(positions, 0, 1024);
  while ((inst = getc(file)) != EOF) {
    switch (inst) {
    case '[':
      ++numo_braces;
      break;
    case ']':
      --numo_braces;
      break;
    }
    if (numo_braces < 0) {
      fprintf(stderr, "Error: unmatched ']'\n");
      fclose(file);
      exit(EXIT_FAILURE);
    }
  }
  if (numo_braces > 0) {
    fprintf(stderr, "Error: unmatched '['\n");
    fclose(file);
    exit(EXIT_FAILURE);
  }
  fseek(file, 0, SEEK_SET);
  while ((inst = getc(file)) != EOF) {
    switch (inst) {
    case '>':
      ++ptr;
      break;
    case '<':
      --ptr;
      break;
    case '+':
      ++*ptr;
      break;
    case '-':
      --*ptr;
      break;
    case '.':
      putchar(*ptr);
      break;
    case ',':
      *ptr = getchar();
      break;
    case '[':
      if (*ptr != 0)
        fgetpos(file, (++pos));
      else {
        numo_braces = 1;
        while (numo_braces > 0) {
          switch ((char)getc(file)) {
          case '[':
            ++numo_braces;
            break;
          case ']':
            --numo_braces;
            break;
          }
        }
      }
      break;
    case ']':
      if (*ptr != 0)
        fsetpos(file, pos);
      else
        --pos;
      break;
    case '#':
    case ';':
      while (getc(file) != '\n')
        ;
    }
  }
  fclose(file);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7980,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x7540(%rbp),%rax
mov    %rax,-0x7548(%rbp)
movl   $0x0,-0x7550(%rbp)
lea    -0x7950(%rbp),%rax
mov    %rax,-0x7958(%rbp)
movq   $0x0,-0x7960(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1270 <main+0x80>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    12ca <main+0xda>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x7960(%rbp)
cmpq   $0x0,-0x7960(%rbp)
jne    12c5 <main+0xd5>
lea    0xe4e(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    137b <main+0x18b>
mov    $0x0,%al
call   1080 <tmpfile@plt>
mov    %rax,-0x7960(%rbp)
cmpq   $0x0,-0x7960(%rbp)
jne    1300 <main+0x110>
lea    0xe2c(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    %eax,-0x754c(%rbp)
mov    0x2cc8(%rip),%rcx
cmp    (%rcx),%eax
je     1358 <main+0x168>
cmpl   $0xa,-0x754c(%rbp)
jne    1341 <main+0x151>
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
mov    -0x754c(%rbp),%edi
mov    -0x7960(%rbp),%rsi
call   1090 <putc@plt>
jmp    130c <main+0x11c>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x7960(%rbp),%rdi
mov    0x2c5e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
lea    -0x7540(%rbp),%rdi
xor    %esi,%esi
mov    $0x7530,%edx
call   1070 <memset@plt>
lea    -0x7950(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    -0x7960(%rbp),%rdi
call   1110 <getc@plt>
movsbl %al,%eax
mov    %eax,-0x754c(%rbp)
mov    0x2c2b(%rip),%rcx
cmp    (%rcx),%eax
je     1459 <main+0x269>
mov    -0x754c(%rbp),%eax
mov    %eax,-0x7964(%rbp)
sub    $0x5b,%eax
je     13f3 <main+0x203>
jmp    13df <main+0x1ef>
mov    -0x7964(%rbp),%eax
sub    $0x5d,%eax
je     1407 <main+0x217>
jmp    1416 <main+0x226>
mov    -0x7550(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7550(%rbp)
jmp    1416 <main+0x226>
mov    -0x7550(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7550(%rbp)
cmpl   $0x0,-0x7550(%rbp)
jge    1454 <main+0x264>
mov    0x2bae(%rip),%rax
mov    (%rax),%edi
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x7960(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    13a1 <main+0x1b1>
cmpl   $0x0,-0x7550(%rbp)
jle    1497 <main+0x2a7>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x7960(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x7960(%rbp),%rdi
mov    0x2b2b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x7960(%rbp),%rdi
call   1110 <getc@plt>
movsbl %al,%eax
mov    %eax,-0x754c(%rbp)
mov    0x2b1e(%rip),%rcx
cmp    (%rcx),%eax
je     16a7 <main+0x4b7>
mov    -0x754c(%rbp),%eax
add    $0xffffffdd,%eax
mov    %eax,%ecx
mov    %rcx,-0x7970(%rbp)
sub    $0x3a,%eax
ja     16a2 <main+0x4b2>
mov    -0x7970(%rbp),%rax
lea    0xb05(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x7548(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7548(%rbp)
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x7548(%rbp)
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
mov    (%rax),%cl
add    $0x1,%cl
mov    %cl,(%rax)
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
mov    (%rax),%cl
add    $0xff,%cl
mov    %cl,(%rax)
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    16a2 <main+0x4b2>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    %al,%cl
mov    -0x7548(%rbp),%rax
mov    %cl,(%rax)
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     15b9 <main+0x3c9>
mov    -0x7960(%rbp),%rdi
mov    -0x7958(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x7958(%rbp)
call   1060 <fgetpos@plt>
jmp    1634 <main+0x444>
movl   $0x1,-0x7550(%rbp)
cmpl   $0x0,-0x7550(%rbp)
jle    162f <main+0x43f>
mov    -0x7960(%rbp),%rdi
call   1110 <getc@plt>
movsbl %al,%eax
mov    %eax,-0x7974(%rbp)
sub    $0x5b,%eax
je     1607 <main+0x417>
jmp    15f3 <main+0x403>
mov    -0x7974(%rbp),%eax
sub    $0x5d,%eax
je     161b <main+0x42b>
jmp    162a <main+0x43a>
mov    -0x7550(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7550(%rbp)
jmp    162a <main+0x43a>
mov    -0x7550(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7550(%rbp)
jmp    15c3 <main+0x3d3>
jmp    1634 <main+0x444>
jmp    16a2 <main+0x4b2>
mov    -0x7548(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1664 <main+0x474>
mov    -0x7960(%rbp),%rdi
mov    -0x7958(%rbp),%rsi
call   10f0 <fsetpos@plt>
jmp    1676 <main+0x486>
mov    -0x7958(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x7958(%rbp)
jmp    16a2 <main+0x4b2>
jmp    1680 <main+0x490>
mov    -0x7960(%rbp),%rdi
call   1110 <getc@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     169d <main+0x4ad>
jmp    1680 <main+0x490>
jmp    16a2 <main+0x4b2>
jmp    14ae <main+0x2be>
mov    -0x7960(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2906(%rip),%rax
mov    (%rax),%eax
add    $0x7980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7938,%rsp
cmp    $0x3,%edi
jge    1499 <main+0x299>
cmp    $0x2,%edi
jne    1243 <main+0x43>
mov    0x8(%rsi),%rdi
lea    0xed4(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    129b <main+0x9b>
lea    0xec2(%rip),%rdi
jmp    14ce <main+0x2ce>
xor    %eax,%eax
call   1090 <tmpfile@plt>
test   %rax,%rax
je     14c7 <main+0x2c7>
mov    %rax,%r12
lea    0xed9(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %rax,%rbx
mov    0x2d75(%rip),%rbp
cmp    %ebx,0x0(%rbp)
jne    142e <main+0x22e>
lea    0xee3(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
lea    0x400(%rsp),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x7530,%edx
call   1080 <memset@plt>
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    0x2d1b(%rip),%rbx
jmp    12db <main+0xdb>
nop
add    $0xffffffff,%ebp
test   %ebp,%ebp
js     146c <main+0x26c>
mov    %r12,%rdi
call   1120 <getc@plt>
movsbl %al,%eax
cmp    %eax,(%rbx)
je     12f9 <main+0xf9>
cmp    $0x5d,%eax
je     12d0 <main+0xd0>
cmp    $0x5b,%eax
jne    12d3 <main+0xd3>
add    $0x1,%ebp
jmp    12d3 <main+0xd3>
test   %ebp,%ebp
jne    14b5 <main+0x2b5>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %r12,%rdi
call   1120 <getc@plt>
movsbl %al,%eax
cmp    %eax,(%rbx)
jne    1346 <main+0x146>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%eax
add    $0x7938,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb3(%rip),%r13
jmp    136f <main+0x16f>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %al,(%r14)
nopl   0x0(%rax)
mov    %r12,%rdi
call   1120 <getc@plt>
movsbl %al,%eax
cmp    %eax,(%rbx)
je     1323 <main+0x123>
add    $0xffffffdd,%eax
cmp    $0x3a,%eax
ja     1360 <main+0x160>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1120 <getc@plt>
cmp    $0xa,%al
jne    1390 <main+0x190>
jmp    1360 <main+0x160>
addb   $0x1,(%r14)
jmp    1360 <main+0x160>
addb   $0xff,(%r14)
jmp    1360 <main+0x160>
movsbl (%r14),%edi
call   1030 <putchar@plt>
jmp    1360 <main+0x160>
add    $0xffffffffffffffff,%r14
jmp    1360 <main+0x160>
add    $0x1,%r14
jmp    1360 <main+0x160>
cmpb   $0x0,(%r14)
je     13ee <main+0x1ee>
add    $0x1,%r15
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fgetpos@plt>
jmp    1360 <main+0x160>
cmpb   $0x0,(%r14)
je     1425 <main+0x225>
mov    %r12,%rdi
mov    %r15,%rsi
call   1100 <fsetpos@plt>
jmp    1360 <main+0x160>
mov    $0x1,%ebp
jmp    140b <main+0x20b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebp
test   %ebp,%ebp
jle    1360 <main+0x160>
mov    %r12,%rdi
call   1120 <getc@plt>
movsbl %al,%eax
cmp    $0x5d,%eax
je     1400 <main+0x200>
cmp    $0x5b,%eax
jne    1403 <main+0x203>
add    $0x1,%ebp
jmp    1403 <main+0x203>
add    $0xffffffffffffffff,%r15
jmp    1360 <main+0x160>
lea    0xd01(%rip),%r14
jmp    145d <main+0x25d>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r12,%rsi
call   10a0 <putc@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %rax,%rbx
cmp    %ebx,0x0(%rbp)
je     127c <main+0x7c>
cmp    $0xa,%ebx
jne    1440 <main+0x240>
mov    %r14,%rdi
call   1060 <printf@plt>
jmp    1440 <main+0x240>
mov    0x2b65(%rip),%rax
mov    (%rax),%edi
lea    0xcbe(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xc40(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    148b <main+0x28b>
mov    0x2b1c(%rip),%rax
mov    (%rax),%edi
lea    0xc8b(%rip),%rsi
jmp    147c <main+0x27c>
lea    0xc4b(%rip),%rdi
call   10f0 <perror@plt>
jmp    148b <main+0x28b>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Error while opening file\00"
@.str.3 = [29 x i8] c"Error while creating tmpfile\00"
@.str.4 = [4 x i8] c"%% \00"
@EOF = global i32 0
@.str.5 = [12 x i8] c"\0A--Start--\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [22 x i8] c"Error: unmatched ']'\0A\00"
@.str.7 = [22 x i8] c"Error: unmatched '['\0A\00"
@EXIT_SUCCESS = global i32 0
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 [1024 x i8]
%11 = alloca i8*
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = getelementptr inbounds [30000 x i8], [30000 x i8]* %6, i64 0, i64 0
store i8* %13, i8** %7
store i32 0, i32* %9
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
store i8* %14, i8** %11
store i32* null, i32** %12
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
store i32 %27, i32* %4
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %25
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %12
%34 = load i32*, i32** %12
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %29
br label %70
41: ; preds = %25
%42 = call i32* (...) @tmpfile()
store i32* %42, i32** %12
%43 = load i32*, i32** %12
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %41
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %61, %49
%52 = call i8* (...) @getchar()
%53 = ptrtoint i8* %52 to i32
store i32 %53, i32* %8
%54 = load i32, i32* @EOF
%55 = icmp ne i32 %53, %54
br i1 %55, label %56, label %65
56: ; preds = %51
%57 = load i32, i32* %8
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
%62 = load i32, i32* %8
%63 = load i32*, i32** %12
%64 = call i32 @putc(i32 %62, i32* %63)
br label %51
65: ; preds = %51
%66 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%67 = load i32*, i32** %12
%68 = load i32, i32* @SEEK_SET
%69 = call i32 @fseek(i32* %67, i32 0, i32 %68)
br label %70
70: ; preds = %65, %40
%71 = getelementptr inbounds [30000 x i8], [30000 x i8]* %6, i64 0, i64 0
%72 = call i32 @memset(i8* %71, i32 0, i32 30000)
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%74 = call i32 @memset(i8* %73, i32 0, i32 1024)
br label %75
75: ; preds = %99, %70
%76 = load i32*, i32** %12
%77 = call signext i8 @getc(i32* %76)
%78 = sext i8 %77 to i32
store i32 %78, i32* %8
%79 = load i32, i32* @EOF
%80 = icmp ne i32 %78, %79
br i1 %80, label %81, label %100
81: ; preds = %75
%82 = load i32, i32* %8
switch i32 %82, label %89 [
i32 91, label %83
i32 93, label %86
]
83: ; preds = %81
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 1
store i32 %85, i32* %9
br label %89
86: ; preds = %81
%87 = load i32, i32* %9
%88 = add nsw i32 %87, -1
store i32 %88, i32* %9
br label %89
89: ; preds = %81, %86, %83
%90 = load i32, i32* %9
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %99
92: ; preds = %89
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%95 = load i32*, i32** %12
%96 = call i32 @fclose(i32* %95)
%97 = load i32, i32* @EXIT_FAILURE
%98 = call i32 @exit(i32 %97)
unreachable
99: ; preds = %89
br label %75
100: ; preds = %75
%101 = load i32, i32* %9
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %110
103: ; preds = %100
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%106 = load i32*, i32** %12
%107 = call i32 @fclose(i32* %106)
%108 = load i32, i32* @EXIT_FAILURE
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %100
%111 = load i32*, i32** %12
%112 = load i32, i32* @SEEK_SET
%113 = call i32 @fseek(i32* %111, i32 0, i32 %112)
br label %114
114: ; preds = %192, %110
%115 = load i32*, i32** %12
%116 = call signext i8 @getc(i32* %115)
%117 = sext i8 %116 to i32
store i32 %117, i32* %8
%118 = load i32, i32* @EOF
%119 = icmp ne i32 %117, %118
br i1 %119, label %120, label %193
120: ; preds = %114
%121 = load i32, i32* %8
switch i32 %121, label %192 [
i32 62, label %122
i32 60, label %125
i32 43, label %128
i32 45, label %132
i32 46, label %136
i32 44, label %140
i32 91, label %144
i32 93, label %171
i32 35, label %184
i32 59, label %184
]
122: ; preds = %120
%123 = load i8*, i8** %7
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %7
br label %192
125: ; preds = %120
%126 = load i8*, i8** %7
%127 = getelementptr inbounds i8, i8* %126, i32 -1
store i8* %127, i8** %7
br label %192
128: ; preds = %120
%129 = load i8*, i8** %7
%130 = load i8, i8* %129
%131 = add i8 %130, 1
store i8 %131, i8* %129
br label %192
132: ; preds = %120
%133 = load i8*, i8** %7
%134 = load i8, i8* %133
%135 = add i8 %134, -1
store i8 %135, i8* %133
br label %192
136: ; preds = %120
%137 = load i8*, i8** %7
%138 = load i8, i8* %137
%139 = call i32 @putchar(i8 signext %138)
br label %192
140: ; preds = %120
%141 = call i8* (...) @getchar()
%142 = ptrtoint i8* %141 to i8
%143 = load i8*, i8** %7
store i8 %142, i8* %143
br label %192
144: ; preds = %120
%145 = load i8*, i8** %7
%146 = load i8, i8* %145
%147 = sext i8 %146 to i32
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %154
149: ; preds = %144
%150 = load i32*, i32** %12
%151 = load i8*, i8** %11
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %11
%153 = call i32 @fgetpos(i32* %150, i8* %152)
br label %170
154: ; preds = %144
store i32 1, i32* %9
br label %155
155: ; preds = %168, %154
%156 = load i32, i32* %9
%157 = icmp sgt i32 %156, 0
br i1 %157, label %158, label %169
158: ; preds = %155
%159 = load i32*, i32** %12
%160 = call signext i8 @getc(i32* %159)
%161 = sext i8 %160 to i32
switch i32 %161, label %168 [
i32 91, label %162
i32 93, label %165
]
162: ; preds = %158
%163 = load i32, i32* %9
%164 = add nsw i32 %163, 1
store i32 %164, i32* %9
br label %168
165: ; preds = %158
%166 = load i32, i32* %9
%167 = add nsw i32 %166, -1
store i32 %167, i32* %9
br label %168
168: ; preds = %158, %165, %162
br label %155
169: ; preds = %155
br label %170
170: ; preds = %169, %149
br label %192
171: ; preds = %120
%172 = load i8*, i8** %7
%173 = load i8, i8* %172
%174 = sext i8 %173 to i32
%175 = icmp ne i32 %174, 0
br i1 %175, label %176, label %180
176: ; preds = %171
%177 = load i32*, i32** %12
%178 = load i8*, i8** %11
%179 = call i32 @fsetpos(i32* %177, i8* %178)
br label %183
180: ; preds = %171
%181 = load i8*, i8** %11
%182 = getelementptr inbounds i8, i8* %181, i32 -1
store i8* %182, i8** %11
br label %183
183: ; preds = %180, %176
br label %192
184: ; preds = %120, %120
br label %185
185: ; preds = %190, %184
%186 = load i32*, i32** %12
%187 = call signext i8 @getc(i32* %186)
%188 = sext i8 %187 to i32
%189 = icmp ne i32 %188, 10
br i1 %189, label %190, label %191
190: ; preds = %185
br label %185
191: ; preds = %185
br label %192
192: ; preds = %191, %120, %183, %170, %140, %136, %132, %128, %125, %122
br label %114
193: ; preds = %114
%194 = load i32*, i32** %12
%195 = call i32 @fclose(i32* %194)
%196 = load i32, i32* @EXIT_SUCCESS
ret i32 %196
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"Error while opening file\00"
@.str.3 = [29 x i8] c"Error while creating tmpfile\00"
@.str.4 = [4 x i8] c"%% \00"
@EOF = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [22 x i8] c"Error: unmatched ']'\0A\00"
@.str.7 = [22 x i8] c"Error: unmatched '['\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [11 x i8] c"\0A--Start--\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [30000 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [30000 x i8], [30000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = icmp eq i32 %0, 2
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %55
21: ; preds = %16
%22 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %14
%26 = tail call i32* (...) @tmpfile()
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i8* (...) @getchar()
%35 = ptrtoint i8* %34 to i64
%36 = trunc i64 %35 to i32
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %37, %36
br i1 %38, label %51, label %39
39: ; preds = %32, %44
%40 = phi i32 [ %48, %44 ], [ %36, %32 ]
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = tail call i32 @putc(i32 %40, i32* %26)
%46 = tail call i8* (...) @getchar()
%47 = ptrtoint i8* %46 to i64
%48 = trunc i64 %47 to i32
%49 = load i32, i32* @EOF
%50 = icmp eq i32 %49, %48
br i1 %50, label %51, label %39
51: ; preds = %44, %32
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%53 = load i32, i32* @SEEK_SET
%54 = tail call i32 @fseek(i32* %26, i32 0, i32 %53)
br label %55
55: ; preds = %16, %51
%56 = phi i32* [ %19, %16 ], [ %26, %51 ]
%57 = call i32 @memset(i8* %5, i32 0, i32 30000)
%58 = call i32 @memset(i8* %6, i32 0, i32 1024)
br label %59
59: ; preds = %70, %55
%60 = phi i32 [ 0, %55 ], [ %71, %70 ]
%61 = call signext i8 @getc(i32* %56)
%62 = sext i8 %61 to i32
%63 = load i32, i32* @EOF
%64 = icmp eq i32 %63, %62
br i1 %64, label %79, label %65
65: ; preds = %59
switch i32 %62, label %70 [
i32 91, label %66
i32 93, label %68
]
66: ; preds = %65
%67 = add nuw nsw i32 %60, 1
br label %70
68: ; preds = %65
%69 = add nsw i32 %60, -1
br label %70
70: ; preds = %65, %68, %66
%71 = phi i32 [ %60, %65 ], [ %69, %68 ], [ %67, %66 ]
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %59
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%76 = call i32 @fclose(i32* %56)
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %59
%80 = icmp eq i32 %60, 0
br i1 %80, label %87, label %81
81: ; preds = %79
%82 = load i32, i32* @stderr
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%84 = call i32 @fclose(i32* %56)
%85 = load i32, i32* @EXIT_FAILURE
%86 = call i32 @exit(i32 %85)
unreachable
87: ; preds = %79
%88 = load i32, i32* @SEEK_SET
%89 = call i32 @fseek(i32* %56, i32 0, i32 %88)
%90 = call signext i8 @getc(i32* %56)
%91 = sext i8 %90 to i32
%92 = load i32, i32* @EOF
%93 = icmp eq i32 %92, %91
br i1 %93, label %150, label %94
94: ; preds = %87, %143
%95 = phi i32 [ %147, %143 ], [ %91, %87 ]
%96 = phi i8* [ %145, %143 ], [ %6, %87 ]
%97 = phi i8* [ %144, %143 ], [ %5, %87 ]
switch i32 %95, label %143 [
i32 62, label %99
i32 60, label %101
i32 43, label %103
i32 45, label %106
i32 46, label %109
i32 44, label %112
i32 91, label %116
i32 93, label %133
i32 35, label %98
i32 59, label %98
]
98: ; preds = %94, %94
br label %140
99: ; preds = %94
%100 = getelementptr inbounds i8, i8* %97, i64 1
br label %143
101: ; preds = %94
%102 = getelementptr inbounds i8, i8* %97, i64 -1
br label %143
103: ; preds = %94
%104 = load i8, i8* %97
%105 = add i8 %104, 1
store i8 %105, i8* %97
br label %143
106: ; preds = %94
%107 = load i8, i8* %97
%108 = add i8 %107, -1
store i8 %108, i8* %97
br label %143
109: ; preds = %94
%110 = load i8, i8* %97
%111 = call i32 @putchar(i8 signext %110)
br label %143
112: ; preds = %94
%113 = call i8* (...) @getchar()
%114 = ptrtoint i8* %113 to i64
%115 = trunc i64 %114 to i8
store i8 %115, i8* %97
br label %143
116: ; preds = %94
%117 = load i8, i8* %97
%118 = icmp eq i8 %117, 0
br i1 %118, label %122, label %119
119: ; preds = %116
%120 = getelementptr inbounds i8, i8* %96, i64 1
%121 = call i32 @fgetpos(i32* %56, i8* %120)
br label %143
122: ; preds = %116, %130
%123 = phi i32 [ %131, %130 ], [ 1, %116 ]
%124 = call signext i8 @getc(i32* %56)
%125 = sext i8 %124 to i32
switch i32 %125, label %130 [
i32 91, label %126
i32 93, label %128
]
126: ; preds = %122
%127 = add nuw nsw i32 %123, 1
br label %130
128: ; preds = %122
%129 = add nsw i32 %123, -1
br label %130
130: ; preds = %122, %128, %126
%131 = phi i32 [ %123, %122 ], [ %129, %128 ], [ %127, %126 ]
%132 = icmp sgt i32 %131, 0
br i1 %132, label %122, label %143
133: ; preds = %94
%134 = load i8, i8* %97
%135 = icmp eq i8 %134, 0
br i1 %135, label %138, label %136
136: ; preds = %133
%137 = call i32 @fsetpos(i32* %56, i8* %96)
br label %143
138: ; preds = %133
%139 = getelementptr inbounds i8, i8* %96, i64 -1
br label %143
140: ; preds = %98, %140
%141 = call signext i8 @getc(i32* %56)
%142 = icmp eq i8 %141, 10
br i1 %142, label %143, label %140
143: ; preds = %140, %130, %136, %138, %119, %94, %112, %109, %106, %103, %101, %99
%144 = phi i8* [ %97, %94 ], [ %97, %136 ], [ %97, %138 ], [ %97, %119 ], [ %97, %112 ], [ %97, %109 ], [ %97, %106 ], [ %97, %103 ], [ %102, %101 ], [ %100, %99 ], [ %97, %130 ], [ %97, %140 ]
%145 = phi i8* [ %96, %94 ], [ %96, %136 ], [ %139, %138 ], [ %120, %119 ], [ %96, %112 ], [ %96, %109 ], [ %96, %106 ], [ %96, %103 ], [ %96, %101 ], [ %96, %99 ], [ %96, %130 ], [ %96, %140 ]
%146 = call signext i8 @getc(i32* %56)
%147 = sext i8 %146 to i32
%148 = load i32, i32* @EOF
%149 = icmp eq i32 %148, %147
br i1 %149, label %150, label %94
150: ; preds = %143, %87
%151 = call i32 @fclose(i32* %56)
%152 = load i32, i32* @EXIT_SUCCESS
ret i32 %152
}