#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strrchr(char const *, char);
int compile_bf(const char *filename) {
  unsigned int ptr = 0;
  FILE *source;
  FILE *out;
  char *dest, *obj, *dot;
  int c, len, id;
  int jmpId = 0, jmpPtr = 0, bufSize = 0, getId = 0;
  int jmpStack[100];
  if ((source = fopen(filename, "rb")) == NULL) {
    fprintf(stderr, "Could not open file %s", filename);
    return -1;
  }
  dot = strrchr(filename, '.');
  if (dot)
    len = dot - filename;
  else
    len = strlen(filename);
  dest = malloc(len + 5);
  strncpy(dest, filename, len);
  strcpy(dest + len, ".asm");
  obj = malloc(len + 5);
  strncpy(obj, filename, len);
  strcpy(obj + len, ".o");
  if ((out = fopen(dest, "wb")) == NULL) {
    fprintf(stderr, "Could not create file %s", dest);
    return -1;
  }
  fputs("BITS 64\n\n", out);
  fputs("; ", out);
  fputs(dest, out);
  fputs("\n; compiled from ", out);
  fputs(filename, out);
  fputs("\n; assemble: nasm -f elf64 -o ", out);
  fputs(obj, out);
  fputs(" ", out);
  fputs(dest, out);
  fputs("\n; link: gcc -o <cmd> ", out);
  fputs(obj, out);
  fputs("\n;\n;\nglobal main\nextern putchar, getchar\n\nsection .bss\nbuf "
        "resb 8192\n\n",
        out);
  fputs("section .text\n", out);
  fputs("main:\n  xor rbx,rbx\n  mov rbx,buf+1\n", out);
  while ((c = fgetc(source)) != EOF) {
    switch (c) {
    case '>':
      fputs("; >\n  add rbx,8\n", out);
      break;
    case '<':
      fputs("; <\n  sub rbx,8\n", out);
      break;
    case '+':
      fputs("; +\n  mov rax,[rbx]\n  inc rax\n  mov [rbx],rax\n", out);
      break;
    case '-':
      fputs("; -\n  mov rax,[rbx]\n  dec rax\n  mov [rbx],rax\n", out);
      break;
    case '.':
      fputs("; .\n  mov rax,[rbx]\n  mov rdi,rax\n  call putchar\n", out);
      break;
    case ',':
      fputs("; ,\n.getch", out);
      fprintf(out, "%d", getId);
      fputs(":\n  call getchar\n  mov rdi,rax\n  cmp rax,0\n  jl .getch", out);
      fprintf(out, "%d", getId);
      fputs("\n  mov [rbx],rax\n", out);
      getId++;
      break;
    case '[':
      fputs("; [\n.loops", out);
      fprintf(out, "%d", jmpId);
      fputs(":\n  mov rax,[rbx]\n  cmp rax,0\n  je .loope", out);
      fprintf(out, "%d", jmpId);
      fputs("\n", out);
      jmpStack[jmpPtr] = jmpId;
      jmpId++;
      jmpPtr++;
      break;
    case ']':
      jmpPtr--;
      id = jmpStack[jmpPtr];
      fputs("; ]\n  mov rax,[rbx]\n  cmp rax,0\n  jne .loops", out);
      fprintf(out, "%d", id);
      fputs("\n.loope", out);
      fprintf(out, "%d", id);
      fputs(":\n", out);
      break;
    default:
      break;
    }
  }
  free(dest);
  free(obj);
  return 0;
}


x86 assembly (clang, -O0):
<compile_bf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeef(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1218 <compile_bf+0x78>
mov    0x2de1(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160a <compile_bf+0x46a>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1248 <compile_bf+0xa8>
mov    -0x40(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x48(%rbp)
jmp    1254 <compile_bf+0xb4>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
add    $0x5,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x48(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rdi
movslq -0x48(%rbp),%rax
add    %rax,%rdi
lea    0xe61(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x48(%rbp),%edi
add    $0x5,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x48(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rdi
movslq -0x48(%rbp),%rax
add    %rax,%rdi
lea    0xe30(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1306 <compile_bf+0x166>
mov    0x2cf3(%rip),%rax
movslq (%rax),%rdi
mov    -0x30(%rbp),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    160a <compile_bf+0x46a>
mov    -0x28(%rbp),%rsi
lea    0xdf9(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xdf3(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xd9d(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xdb3(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xdad(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xde4(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x20(%rbp),%rdi
call   1090 <fgetc@plt>
mov    %eax,-0x44(%rbp)
mov    0x2bfe(%rip),%rcx
cmp    (%rcx),%eax
je     15f1 <compile_bf+0x451>
mov    -0x44(%rbp),%eax
add    $0xffffffd5,%eax
mov    %eax,%ecx
mov    %rcx,-0x1f8(%rbp)
sub    $0x32,%eax
ja     15e7 <compile_bf+0x447>
mov    -0x1f8(%rbp),%rax
lea    0xbe8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rsi
lea    0xdae(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xdaa(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xda6(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xdc0(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xdda(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xdf7(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x5c(%rbp),%edx
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xde0(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x5c(%rbp),%edx
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd69(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    15ec <compile_bf+0x44c>
mov    -0x28(%rbp),%rsi
lea    0xdd4(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%edx
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdba(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%edx
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xc5d(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x50(%rbp),%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x1f0(%rbp,%rax,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    15ec <compile_bf+0x44c>
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
movslq -0x54(%rbp),%rax
mov    -0x1f0(%rbp,%rax,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd73(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%edx
lea    0xcf1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd7b(%rip),%rdi
call   1080 <fputs@plt>
mov    -0x28(%rbp),%rdi
mov    -0x4c(%rbp),%edx
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd5e(%rip),%rdi
call   1080 <fputs@plt>
jmp    15ec <compile_bf+0x44c>
jmp    15ec <compile_bf+0x44c>
jmp    13d7 <compile_bf+0x237>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile_bf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
mov    %rdi,%r15
lea    0xef1(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     1204 <compile_bf+0x44>
mov    %r15,%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     121d <compile_bf+0x5d>
mov    %rax,%rbx
sub    %r15d,%ebx
jmp    1227 <compile_bf+0x67>
mov    0x2dcd(%rip),%rax
movslq (%rax),%rdi
lea    0xeba(%rip),%rsi
mov    %r15,%rdx
jmp    13f1 <compile_bf+0x231>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0x5(%rbx),%ebp
mov    %ebp,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <strncpy@plt>
movslq %ebx,%rbx
lea    (%r14,%rbx,1),%rdi
lea    0xe97(%rip),%rsi
call   1050 <strcpy@plt>
mov    %ebp,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <strncpy@plt>
add    %rbp,%rbx
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcpy@plt>
lea    0xe6a(%rip),%rsi
mov    %r14,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13dd <compile_bf+0x21d>
mov    %rax,%rbx
lea    0xe6b(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
lea    0xe5c(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
lea    0xe3b(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
lea    0xe29(%rip),%rdi
mov    $0x1e,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   10a0 <fputc@plt>
mov    %r14,0x28(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
lea    0xe07(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbp,0x20(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <fputs@plt>
lea    0xdf5(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xe23(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xe19(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    0x18(%rsp),%rdi
call   1090 <fgetc@plt>
mov    0x2c29(%rip),%r12
cmp    (%r12),%eax
jne    140f <compile_bf+0x24f>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    13fd <compile_bf+0x23d>
mov    0x2bf4(%rip),%rax
movslq (%rax),%rdi
lea    0xd03(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbea(%rip),%r15
movl   $0x0,0x14(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
jmp    14dc <compile_bf+0x31c>
mov    0xc(%rsp),%ecx
movslq %ecx,%rax
add    $0xffffffff,%ecx
mov    %ecx,0xc(%rsp)
mov    0x2c(%rsp,%rax,4),%r13d
mov    $0x2c,%esi
mov    $0x1,%edx
lea    0xeaf(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r15,%rbp
lea    0xe2b(%rip),%r14
mov    %r14,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x7,%esi
mov    $0x1,%edx
lea    0xea9(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    0x2b46(%rip),%r12
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xe81(%rip),%rdi
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    0x18(%rsp),%rdi
call   1090 <fgetc@plt>
cmp    (%r12),%eax
je     13c5 <compile_bf+0x205>
add    $0xffffffd5,%eax
cmp    $0x32,%eax
ja     14c8 <compile_bf+0x308>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x2e,%esi
mov    $0x1,%edx
lea    0xcfe(%rip),%rdi
jmp    14c0 <compile_bf+0x300>
mov    $0xa,%esi
mov    $0x1,%edx
lea    0xd7b(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xd74(%rip),%r13
mov    %r13,%rsi
mov    0x14(%rsp),%ebp
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x36,%esi
mov    $0x1,%edx
lea    0xd56(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x11,%esi
mov    $0x1,%edx
lea    0xcdc(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
add    $0x1,%ebp
mov    %ebp,0x14(%rsp)
jmp    14c8 <compile_bf+0x308>
mov    $0x2e,%esi
mov    $0x1,%edx
lea    0xc9a(%rip),%rdi
jmp    14c0 <compile_bf+0x300>
mov    $0x31,%esi
mov    $0x1,%edx
lea    0xcb3(%rip),%rdi
jmp    14c0 <compile_bf+0x300>
mov    $0x10,%esi
mov    $0x1,%edx
lea    0xc2e(%rip),%rdi
jmp    14c0 <compile_bf+0x300>
mov    $0x10,%esi
mov    $0x1,%edx
lea    0xc07(%rip),%rdi
jmp    14c0 <compile_bf+0x300>
mov    $0xa,%esi
mov    $0x1,%edx
lea    0xce8(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xc9c(%rip),%r13
mov    %r13,%rsi
mov    0x10(%rsp),%ebp
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x29,%esi
mov    $0x1,%edx
lea    0xcc0(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   10a0 <fputc@plt>
mov    0xc(%rsp),%ecx
movslq %ecx,%rax
mov    %ebp,0x30(%rsp,%rax,4)
add    $0x1,%ebp
mov    %ebp,0x10(%rsp)
add    $0x1,%ecx
mov    %ecx,0xc(%rsp)
jmp    14c8 <compile_bf+0x308>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Could not open file %s\00"
@.str.2 = [5 x i8] c".asm\00"
@.str.3 = [3 x i8] c".o\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [25 x i8] c"Could not create file %s\00"
@.str.6 = [10 x i8] c"BITS 64\0A\0A\00"
@.str.7 = [3 x i8] c"; \00"
@.str.8 = [18 x i8] c"\0A; compiled from \00"
@.str.9 = [31 x i8] c"\0A; assemble: nasm -f elf64 -o \00"
@.str.10 = [2 x i8] c" \00"
@.str.11 = [23 x i8] c"\0A; link: gcc -o <cmd> \00"
@.str.12 = [71 x i8] c"\0A;\0A;\0Aglobal main\0Aextern putchar, getchar\0A\0Asection .bss\0Abuf resb 8192\0A\0A\00"
@.str.13 = [15 x i8] c"section .text\0A\00"
@.str.14 = [37 x i8] c"main:\0A xor rbx,rbx\0A mov rbx,buf+1\0A\00"
@EOF = global i32 0
@.str.15 = [17 x i8] c"; >\0A add rbx,8\0A\00"
@.str.16 = [17 x i8] c"; <\0A sub rbx,8\0A\00"
@.str.17 = [47 x i8] c"; +\0A mov rax,[rbx]\0A inc rax\0A mov [rbx],rax\0A\00"
@.str.18 = [47 x i8] c"; -\0A mov rax,[rbx]\0A dec rax\0A mov [rbx],rax\0A\00"
@.str.19 = [50 x i8] c"; .\0A mov rax,[rbx]\0A mov rdi,rax\0A call putchar\0A\00"
@.str.20 = [11 x i8] c"; ,\0A.getch\00"
@.str.21 = [3 x i8] c"%d\00"
@.str.22 = [55 x i8] c":\0A call getchar\0A mov rdi,rax\0A cmp rax,0\0A jl .getch\00"
@.str.23 = [18 x i8] c"\0A mov [rbx],rax\0A\00"
@.str.24 = [11 x i8] c"; [\0A.loops\00"
@.str.25 = [42 x i8] c":\0A mov rax,[rbx]\0A cmp rax,0\0A je .loope\00"
@.str.26 = [2 x i8] c"\0A\00"
@.str.27 = [45 x i8] c"; ]\0A mov rax,[rbx]\0A cmp rax,0\0A jne .loops\00"
@.str.28 = [8 x i8] c"\0A.loope\00"
@.str.29 = [3 x i8] c":\0A\00"
define i32 @compile_bf(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [100 x i32]
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%18 = load i8*, i8** %3
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %5
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %1
%22 = load i32, i32* @stderr
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i32*
%25 = load i8*, i8** %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 -1, i32* %2
br label %194
27: ; preds = %1
%28 = load i8*, i8** %3
%29 = call i8* @strrchr(i8* %28, i8 signext 46)
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %39
32: ; preds = %27
%33 = load i8*, i8** %9
%34 = load i8*, i8** %3
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
%38 = trunc i64 %37 to i32
store i32 %38, i32* %11
br label %42
39: ; preds = %27
%40 = load i8*, i8** %3
%41 = call i32 @strlen(i8* %40)
store i32 %41, i32* %11
br label %42
42: ; preds = %39, %32
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 5
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %7
%46 = load i8*, i8** %7
%47 = load i8*, i8** %3
%48 = load i32, i32* %11
%49 = call i32 @strncpy(i8* %46, i8* %47, i32 %48)
%50 = load i8*, i8** %7
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = call i32 @strcpy(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 5
%57 = call i8* @malloc(i32 %56)
store i8* %57, i8** %8
%58 = load i8*, i8** %8
%59 = load i8*, i8** %3
%60 = load i32, i32* %11
%61 = call i32 @strncpy(i8* %58, i8* %59, i32 %60)
%62 = load i8*, i8** %8
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = call i32 @strcpy(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%67 = load i8*, i8** %7
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %68, i32** %6
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %76
70: ; preds = %42
%71 = load i32, i32* @stderr
%72 = sext i32 %71 to i64
%73 = inttoptr i64 %72 to i32*
%74 = load i8*, i8** %7
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %74)
store i32 -1, i32* %2
br label %194
76: ; preds = %42
%77 = load i32*, i32** %6
%78 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32* %77)
%79 = load i32*, i32** %6
%80 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %79)
%81 = load i8*, i8** %7
%82 = load i32*, i32** %6
%83 = call i32 @fputs(i8* %81, i32* %82)
%84 = load i32*, i32** %6
%85 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32* %84)
%86 = load i8*, i8** %3
%87 = load i32*, i32** %6
%88 = call i32 @fputs(i8* %86, i32* %87)
%89 = load i32*, i32** %6
%90 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32* %89)
%91 = load i8*, i8** %8
%92 = load i32*, i32** %6
%93 = call i32 @fputs(i8* %91, i32* %92)
%94 = load i32*, i32** %6
%95 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %94)
%96 = load i8*, i8** %7
%97 = load i32*, i32** %6
%98 = call i32 @fputs(i8* %96, i32* %97)
%99 = load i32*, i32** %6
%100 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i32* %99)
%101 = load i8*, i8** %8
%102 = load i32*, i32** %6
%103 = call i32 @fputs(i8* %101, i32* %102)
%104 = load i32*, i32** %6
%105 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.12, i64 0, i64 0), i32* %104)
%106 = load i32*, i32** %6
%107 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i32* %106)
%108 = load i32*, i32** %6
%109 = call i32 @fputs(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i32* %108)
br label %110
110: ; preds = %188, %76
%111 = load i32*, i32** %5
%112 = call i32 @fgetc(i32* %111)
store i32 %112, i32* %10
%113 = load i32, i32* @EOF
%114 = icmp ne i32 %112, %113
br i1 %114, label %115, label %189
115: ; preds = %110
%116 = load i32, i32* %10
switch i32 %116, label %187 [
i32 62, label %117
i32 60, label %120
i32 43, label %123
i32 45, label %126
i32 46, label %129
i32 44, label %132
i32 91, label %147
i32 93, label %168
]
117: ; preds = %115
%118 = load i32*, i32** %6
%119 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0), i32* %118)
br label %188
120: ; preds = %115
%121 = load i32*, i32** %6
%122 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i32* %121)
br label %188
123: ; preds = %115
%124 = load i32*, i32** %6
%125 = call i32 @fputs(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i32* %124)
br label %188
126: ; preds = %115
%127 = load i32*, i32** %6
%128 = call i32 @fputs(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.18, i64 0, i64 0), i32* %127)
br label %188
129: ; preds = %115
%130 = load i32*, i32** %6
%131 = call i32 @fputs(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.19, i64 0, i64 0), i32* %130)
br label %188
132: ; preds = %115
%133 = load i32*, i32** %6
%134 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0), i32* %133)
%135 = load i32*, i32** %6
%136 = load i32, i32* %16
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %135, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %136)
%138 = load i32*, i32** %6
%139 = call i32 @fputs(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.22, i64 0, i64 0), i32* %138)
%140 = load i32*, i32** %6
%141 = load i32, i32* %16
%142 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %141)
%143 = load i32*, i32** %6
%144 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i64 0, i64 0), i32* %143)
%145 = load i32, i32* %16
%146 = add nsw i32 %145, 1
store i32 %146, i32* %16
br label %188
147: ; preds = %115
%148 = load i32*, i32** %6
%149 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0), i32* %148)
%150 = load i32*, i32** %6
%151 = load i32, i32* %13
%152 = call i32 (i32*, i8*, ...) @fprintf(i32* %150, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %151)
%153 = load i32*, i32** %6
%154 = call i32 @fputs(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.25, i64 0, i64 0), i32* %153)
%155 = load i32*, i32** %6
%156 = load i32, i32* %13
%157 = call i32 (i32*, i8*, ...) @fprintf(i32* %155, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %156)
%158 = load i32*, i32** %6
%159 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.26, i64 0, i64 0), i32* %158)
%160 = load i32, i32* %13
%161 = load i32, i32* %14
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [100 x i32], [100 x i32]* %17, i64 0, i64 %162
store i32 %160, i32* %163
%164 = load i32, i32* %13
%165 = add nsw i32 %164, 1
store i32 %165, i32* %13
%166 = load i32, i32* %14
%167 = add nsw i32 %166, 1
store i32 %167, i32* %14
br label %188
168: ; preds = %115
%169 = load i32, i32* %14
%170 = add nsw i32 %169, -1
store i32 %170, i32* %14
%171 = load i32, i32* %14
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [100 x i32], [100 x i32]* %17, i64 0, i64 %172
%174 = load i32, i32* %173
store i32 %174, i32* %12
%175 = load i32*, i32** %6
%176 = call i32 @fputs(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.27, i64 0, i64 0), i32* %175)
%177 = load i32*, i32** %6
%178 = load i32, i32* %12
%179 = call i32 (i32*, i8*, ...) @fprintf(i32* %177, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %178)
%180 = load i32*, i32** %6
%181 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0), i32* %180)
%182 = load i32*, i32** %6
%183 = load i32, i32* %12
%184 = call i32 (i32*, i8*, ...) @fprintf(i32* %182, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %183)
%185 = load i32*, i32** %6
%186 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i64 0, i64 0), i32* %185)
br label %188
187: ; preds = %115
br label %188
188: ; preds = %187, %168, %147, %132, %129, %126, %123, %120, %117
br label %110
189: ; preds = %110
%190 = load i8*, i8** %7
%191 = call i32 @free(i8* %190)
%192 = load i8*, i8** %8
%193 = call i32 @free(i8* %192)
store i32 0, i32* %2
br label %194
194: ; preds = %189, %70, %21
%195 = load i32, i32* %2
ret i32 %195
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Could not open file %s\00"
@.str.2 = [5 x i8] c".asm\00"
@.str.3 = [3 x i8] c".o\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [25 x i8] c"Could not create file %s\00"
@.str.6 = [10 x i8] c"BITS 64\0A\0A\00"
@.str.7 = [3 x i8] c"; \00"
@.str.8 = [18 x i8] c"\0A; compiled from \00"
@.str.9 = [31 x i8] c"\0A; assemble: nasm -f elf64 -o \00"
@.str.11 = [23 x i8] c"\0A; link: gcc -o <cmd> \00"
@.str.12 = [71 x i8] c"\0A;\0A;\0Aglobal main\0Aextern putchar, getchar\0A\0Asection .bss\0Abuf resb 8192\0A\0A\00"
@.str.13 = [15 x i8] c"section .text\0A\00"
@.str.14 = [37 x i8] c"main:\0A xor rbx,rbx\0A mov rbx,buf+1\0A\00"
@EOF = global i32 0
@.str.15 = [17 x i8] c"; >\0A add rbx,8\0A\00"
@.str.16 = [17 x i8] c"; <\0A sub rbx,8\0A\00"
@.str.17 = [47 x i8] c"; +\0A mov rax,[rbx]\0A inc rax\0A mov [rbx],rax\0A\00"
@.str.18 = [47 x i8] c"; -\0A mov rax,[rbx]\0A dec rax\0A mov [rbx],rax\0A\00"
@.str.19 = [50 x i8] c"; .\0A mov rax,[rbx]\0A mov rdi,rax\0A call putchar\0A\00"
@.str.20 = [11 x i8] c"; ,\0A.getch\00"
@.str.21 = [3 x i8] c"%d\00"
@.str.22 = [55 x i8] c":\0A call getchar\0A mov rdi,rax\0A cmp rax,0\0A jl .getch\00"
@.str.23 = [18 x i8] c"\0A mov [rbx],rax\0A\00"
@.str.24 = [11 x i8] c"; [\0A.loops\00"
@.str.25 = [42 x i8] c":\0A mov rax,[rbx]\0A cmp rax,0\0A je .loope\00"
@.str.27 = [45 x i8] c"; ]\0A mov rax,[rbx]\0A cmp rax,0\0A jne .loops\00"
@.str.28 = [8 x i8] c"\0A.loope\00"
@.str.29 = [3 x i8] c":\0A\00"
define i32 @compile_bf(i8* %0) {
%2 = alloca [100 x i32]
%3 = bitcast [100 x i32]* %2 to i8*
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %110
11: ; preds = %1
%12 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%13 = icmp eq i8* %12, null
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = ptrtoint i8* %12 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
br label %21
19: ; preds = %11
%20 = tail call i32 @strlen(i8* %0)
br label %21
21: ; preds = %19, %14
%22 = phi i32 [ %18, %14 ], [ %20, %19 ]
%23 = add nsw i32 %22, 5
%24 = tail call i8* @malloc(i32 %23)
%25 = tail call i32 @strncpy(i8* %24, i8* %0, i32 %22)
%26 = sext i32 %22 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = tail call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i8* @malloc(i32 %23)
%30 = tail call i32 @strncpy(i8* %29, i8* %0, i32 %22)
%31 = getelementptr inbounds i8, i8* %29, i64 %26
%32 = tail call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %40
35: ; preds = %21
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %24)
br label %110
40: ; preds = %21
%41 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 9, i64 1, i32* %33)
%42 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %33)
%43 = tail call i32 @fputs(i8* %24, i32* %33)
%44 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i64 17, i64 1, i32* %33)
%45 = tail call i32 @fputs(i8* %0, i32* %33)
%46 = tail call i64 @fwrite(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i64 30, i64 1, i32* %33)
%47 = tail call i32 @fputs(i8* %29, i32* %33)
%48 = tail call i32 @fputc(i32 32, i32* %33)
%49 = tail call i32 @fputs(i8* %24, i32* %33)
%50 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i64 22, i64 1, i32* %33)
%51 = tail call i32 @fputs(i8* %29, i32* %33)
%52 = tail call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.12, i64 0, i64 0), i64 70, i64 1, i32* %33)
%53 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i64 14, i64 1, i32* %33)
%54 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i64 36, i64 1, i32* %33)
%55 = tail call i32 @fgetc(i32* %4)
%56 = load i32, i32* @EOF
%57 = icmp eq i32 %55, %56
br i1 %57, label %107, label %58
58: ; preds = %40, %100
%59 = phi i32 [ %104, %100 ], [ %55, %40 ]
%60 = phi i32 [ %103, %100 ], [ 0, %40 ]
%61 = phi i32 [ %102, %100 ], [ 0, %40 ]
%62 = phi i32 [ %101, %100 ], [ 0, %40 ]
switch i32 %59, label %100 [
i32 62, label %63
i32 60, label %65
i32 43, label %67
i32 45, label %69
i32 46, label %71
i32 44, label %73
i32 91, label %80
i32 93, label %90
]
63: ; preds = %58
%64 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0), i64 16, i64 1, i32* %33)
br label %100
65: ; preds = %58
%66 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i64 16, i64 1, i32* %33)
br label %100
67: ; preds = %58
%68 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.17, i64 0, i64 0), i64 46, i64 1, i32* %33)
br label %100
69: ; preds = %58
%70 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.18, i64 0, i64 0), i64 46, i64 1, i32* %33)
br label %100
71: ; preds = %58
%72 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.19, i64 0, i64 0), i64 49, i64 1, i32* %33)
br label %100
73: ; preds = %58
%74 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0), i64 10, i64 1, i32* %33)
%75 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %60)
%76 = tail call i64 @fwrite(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.22, i64 0, i64 0), i64 54, i64 1, i32* %33)
%77 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %60)
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i64 0, i64 0), i64 17, i64 1, i32* %33)
%79 = add nsw i32 %60, 1
br label %100
80: ; preds = %58
%81 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0), i64 10, i64 1, i32* %33)
%82 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %62)
%83 = tail call i64 @fwrite(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.25, i64 0, i64 0), i64 41, i64 1, i32* %33)
%84 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %62)
%85 = tail call i32 @fputc(i32 10, i32* %33)
%86 = sext i32 %61 to i64
%87 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %86
store i32 %62, i32* %87
%88 = add nsw i32 %62, 1
%89 = add nsw i32 %61, 1
br label %100
90: ; preds = %58
%91 = add nsw i32 %61, -1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %92
%94 = load i32, i32* %93
%95 = tail call i64 @fwrite(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.27, i64 0, i64 0), i64 44, i64 1, i32* %33)
%96 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %94)
%97 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0), i64 7, i64 1, i32* %33)
%98 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.21, i64 0, i64 0), i32 %94)
%99 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.29, i64 0, i64 0), i64 2, i64 1, i32* %33)
br label %100
100: ; preds = %58, %90, %80, %73, %71, %69, %67, %65, %63
%101 = phi i32 [ %62, %58 ], [ %62, %90 ], [ %88, %80 ], [ %62, %73 ], [ %62, %71 ], [ %62, %69 ], [ %62, %67 ], [ %62, %65 ], [ %62, %63 ]
%102 = phi i32 [ %61, %58 ], [ %91, %90 ], [ %89, %80 ], [ %61, %73 ], [ %61, %71 ], [ %61, %69 ], [ %61, %67 ], [ %61, %65 ], [ %61, %63 ]
%103 = phi i32 [ %60, %58 ], [ %60, %90 ], [ %60, %80 ], [ %79, %73 ], [ %60, %71 ], [ %60, %69 ], [ %60, %67 ], [ %60, %65 ], [ %60, %63 ]
%104 = tail call i32 @fgetc(i32* %4)
%105 = load i32, i32* @EOF
%106 = icmp eq i32 %104, %105
br i1 %106, label %107, label %58
107: ; preds = %100, %40
%108 = tail call i32 @free(i8* %24)
%109 = tail call i32 @free(i8* %29)
br label %110
110: ; preds = %107, %35, %6
%111 = phi i32 [ -1, %6 ], [ -1, %35 ], [ 0, %107 ]
ret i32 %111
}