#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
unsigned int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int puts(char *);
int main(int argc, char *argv[]) {
  static unsigned sqr[] = {0, 0, 0, 0, 0, 25, 36, 49, 64, 81, 100, 121, 144};
  unsigned char oldch, ch, i;
  unsigned TextLen;
  FILE *in, *out;
  if (argc != 3)
    return puts("MasterRay TextToBF\nTextToBF source destination\n\n  source   "
                "    Specify the text file.\n  destination  Specify the "
                "filename for the converted BrainFuck file."),
           0;
  if ((in = fopen(argv[1], "rb")) == NULL)
    return puts("Cannot open the source file specified."), 1;
  if ((out = fopen(argv[2], "wb")) == NULL)
    return puts("Cannot write in the destination file specified."), 2;
  fseek(in, 0, SEEK_END);
  TextLen = ftell(in);
  fseek(in, 0, SEEK_SET);
  for (oldch = 0; TextLen != 0; --TextLen) {
    ch = fgetc(in);
    if (ch == oldch)
      fwrite(".", 1, 1, out);
    else if ((unsigned char)(ch - oldch) <= 127) {
      ch -= oldch;
      if (ch < 16) {
        fwrite("+++++++++++++++", ch, 1, out);
        fwrite(".", 1, 1, out);
      } else {
        for (i = 5; sqr[i] <= ch; ++i)
          ;
        fwrite(">+++++++++++++++", i--, 1, out);
        fwrite("[<", 2, 1, out);
        if (ch % i > i / 2) {
          fwrite("+++++++++++++++", ch / i + 1, 1, out);
          fwrite(">-]<", 4, 1, out);
          fwrite("---------------", i - ch % i, 1, out);
        } else {
          fwrite("+++++++++++++++", ch / i, 1, out);
          fwrite(">-]<", 4, 1, out);
          fwrite("+++++++++++++++", ch % i, 1, out);
        }
        fwrite(".", 1, 1, out);
      }
      oldch += ch;
    } else if ((unsigned char)(ch - oldch) > 127) {
      ch = oldch - ch;
      if (ch < 16) {
        fwrite("---------------", ch, 1, out);
        fwrite(".", 1, 1, out);
      } else {
        for (i = 5; sqr[i] <= ch; ++i)
          ;
        fwrite(">+++++++++++++++", i--, 1, out);
        fwrite("[<", 2, 1, out);
        if (ch % i > i / 2) {
          fwrite("---------------", ch / i + 1, 1, out);
          fwrite(">-]<", 4, 1, out);
          fwrite("+++++++++++++++", i - ch % i, 1, out);
        } else {
          fwrite("---------------", ch / i, 1, out);
          fwrite(">-]<", 4, 1, out);
          fwrite("---------------", ch % i, 1, out);
        }
        fwrite(".", 1, 1, out);
      }
      oldch -= ch;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1679 <main+0x519>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xef5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11d2 <main+0x72>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1679 <main+0x519>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xee5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    120c <main+0xac>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
movl   $0x2,-0x4(%rbp)
jmp    1679 <main+0x519>
mov    -0x20(%rbp),%rdi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
movb   $0x0,-0x11(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1672 <main+0x512>
mov    -0x20(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
movzbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1286 <main+0x126>
mov    -0x28(%rbp),%rcx
lea    0xe4f(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    165f <main+0x4ff>
movzbl -0x12(%rbp),%eax
movzbl -0x11(%rbp),%ecx
sub    %ecx,%eax
movzbl %al,%eax
cmp    $0x7f,%eax
jg     1470 <main+0x310>
movzbl -0x11(%rbp),%ecx
movzbl -0x12(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x10,%eax
jge    12eb <main+0x18b>
movzbl -0x12(%rbp),%esi
mov    -0x28(%rbp),%rcx
lea    0xe35(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xdea(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    145e <main+0x2fe>
movb   $0x5,-0x13(%rbp)
movzbl -0x13(%rbp),%eax
mov    %eax,%ecx
lea    0x2d64(%rip),%rax
mov    (%rax,%rcx,4),%eax
movzbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
ja     131d <main+0x1bd>
jmp    1310 <main+0x1b0>
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    12ef <main+0x18f>
mov    -0x13(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x13(%rbp)
movzbl %al,%esi
mov    -0x28(%rbp),%rcx
lea    0xdc3(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xdbf(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
movzbl -0x13(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
cmp    %eax,%edx
jle    13e9 <main+0x289>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rcx
lea    0xd60(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xd5e(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x13(%rbp),%esi
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
sub    %edx,%esi
mov    -0x28(%rbp),%rcx
lea    0xd38(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
jmp    1447 <main+0x2e7>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x28(%rbp),%rcx
lea    0xcf9(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xcf7(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x28(%rbp),%rcx
lea    0xcbd(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xc72(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%ecx
movzbl -0x11(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x11(%rbp)
jmp    165a <main+0x4fa>
movzbl -0x12(%rbp),%eax
movzbl -0x11(%rbp),%ecx
sub    %ecx,%eax
movzbl %al,%eax
cmp    $0x7f,%eax
jle    1655 <main+0x4f5>
movzbl -0x11(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
mov    %al,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x10,%eax
jge    14d5 <main+0x375>
movzbl -0x12(%rbp),%esi
mov    -0x28(%rbp),%rcx
lea    0xc63(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xc00(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
jmp    1648 <main+0x4e8>
movb   $0x5,-0x13(%rbp)
movzbl -0x13(%rbp),%eax
mov    %eax,%ecx
lea    0x2b7a(%rip),%rax
mov    (%rax,%rcx,4),%eax
movzbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
ja     1507 <main+0x3a7>
jmp    14fa <main+0x39a>
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    14d9 <main+0x379>
mov    -0x13(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x13(%rbp)
movzbl %al,%esi
mov    -0x28(%rbp),%rcx
lea    0xbd9(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xbd5(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
movzbl -0x13(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%edx
cmp    %eax,%edx
jle    15d3 <main+0x473>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rcx
lea    0xb8e(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xb74(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x13(%rbp),%esi
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
sub    %edx,%esi
mov    -0x28(%rbp),%rcx
lea    0xb36(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
jmp    1631 <main+0x4d1>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x28(%rbp),%rcx
lea    0xb27(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xb0d(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x28(%rbp),%rcx
lea    0xaeb(%rip),%rdi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x28(%rbp),%rcx
lea    0xa88(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
movzbl -0x12(%rbp),%ecx
movzbl -0x11(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x11(%rbp)
jmp    165a <main+0x4fa>
jmp    165f <main+0x4ff>
jmp    1664 <main+0x504>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1244 <main+0xe4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    147f <main+0x30f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xf3e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1490 <main+0x320>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xf4c(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     14a4 <main+0x334>
mov    %rax,%r12
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rbx
xor    %r15d,%r15d
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
mov    %rbp,%rdi
call   1060 <ftell@plt>
mov    %eax,%ebp
mov    0x2def(%rip),%rax
mov    (%rax),%edx
mov    %rbx,(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <fseek@plt>
test   %ebp,%ebp
je     14bb <main+0x34b>
xor    %ebx,%ebx
lea    0xdf6(%rip),%r14
mov    (%rsp),%r15
jmp    122c <main+0xbc>
mov    %ebx,%r13d
mov    $0x2e,%edi
mov    %r12,%rsi
call   1050 <fputc@plt>
mov    %r13d,%ebx
add    $0xffffffff,%ebp
je     14b8 <main+0x348>
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %eax,%r13d
sub    %bl,%al
je     1210 <main+0xa0>
js     1266 <main+0xf6>
mov    %r12,%rbx
movzbl %al,%r12d
cmp    $0x10,%r12b
jae    128d <main+0x11d>
lea    0xedd(%rip),%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    %rbx,%r12
mov    %rbx,%rcx
call   1090 <fwrite@plt>
jmp    1213 <main+0xa3>
sub    %r13b,%bl
movzbl %bl,%ebx
cmp    $0x10,%bl
jae    1333 <main+0x1c3>
lea    0xeca(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
jmp    1213 <main+0xa3>
mov    $0x5,%al
nop
movzbl %al,%ecx
mov    %ecx,%eax
add    $0x1,%al
cmp    %r12d,(%r14,%rcx,4)
jbe    1290 <main+0x120>
lea    -0x2(%rax),%r15d
add    $0xff,%al
movzbl %al,%esi
lea    0xe80(%rip),%rdi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
lea    0xe7d(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
movzbl %r15b,%r15d
mov    %r12d,%eax
xor    %edx,%edx
div    %r15d
mov    %edx,%r12d
mov    %r15d,%ecx
shr    %ecx
cmp    %ecx,%edx
jbe    13e1 <main+0x271>
add    $0x1,%eax
lea    0xe35(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
lea    0xe32(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
sub    %r12d,%r15d
lea    0xe1b(%rip),%rdi
mov    %r15d,%esi
jmp    1419 <main+0x2a9>
mov    $0x5,%al
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%ecx
mov    %ecx,%eax
add    $0x1,%al
cmp    %ebx,(%r14,%rcx,4)
jbe    1340 <main+0x1d0>
lea    -0x2(%rax),%r15d
add    $0xff,%al
movzbl %al,%esi
lea    0xdd0(%rip),%rdi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
lea    0xdcd(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    %r12,%rcx
movzbl %r15b,%r12d
mov    %ebx,%eax
xor    %edx,%edx
div    %r12d
mov    %edx,%ebx
mov    %r12d,%edx
shr    %edx
cmp    %edx,%ebx
jbe    1432 <main+0x2c2>
add    $0x1,%eax
lea    0xd9c(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %ebx,%r15d
mov    %rcx,%rbx
call   1090 <fwrite@plt>
lea    0xd7e(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
sub    %r15d,%r12d
lea    0xd4f(%rip),%rdi
jmp    1416 <main+0x2a6>
lea    0xd46(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
lea    0xd40(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    (%rsp),%r15
mov    %rbx,%r12
jmp    1213 <main+0xa3>
lea    0xd0d(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %rcx,%r12
call   1090 <fwrite@plt>
lea    0xcef(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    (%rsp),%r15
jmp    1213 <main+0xa3>
xor    %r15d,%r15d
lea    0xbab(%rip),%rdi
call   1030 <puts@plt>
jmp    14bb <main+0x34b>
mov    $0x1,%r15d
lea    0xc36(%rip),%rdi
call   1030 <puts@plt>
jmp    14bb <main+0x34b>
mov    $0x2,%r15d
lea    0xc4c(%rip),%rdi
call   1030 <puts@plt>
jmp    14bb <main+0x34b>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.sqr = internal global [13 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 25, i32 36, i32 49, i32 64, i32 81, i32 100, i32 121, i32 144]
@.str = [156 x i8] c"MasterRay TextToBF\0ATextToBF source destination\0A\0A source Specify the text file.\0A destination Specify the filename for the converted BrainFuck file.\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"Cannot open the source file specified.\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [48 x i8] c"Cannot write in the destination file specified.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.5 = [2 x i8] c".\00"
@.str.6 = [16 x i8] c"+++++++++++++++\00"
@.str.7 = [17 x i8] c">+++++++++++++++\00"
@.str.8 = [3 x i8] c"[<\00"
@.str.9 = [5 x i8] c">-]<\00"
@.str.10 = [16 x i8] c"---------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @puts(i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %270
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %10
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %270
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %11
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %270
32: ; preds = %24
%33 = load i32*, i32** %10
%34 = load i32, i32* @SEEK_END
%35 = call i32 @fseek(i32* %33, i32 0, i32 %34)
%36 = load i32*, i32** %10
%37 = call i32 @ftell(i32* %36)
store i32 %37, i32* %9
%38 = load i32*, i32** %10
%39 = load i32, i32* @SEEK_SET
%40 = call i32 @fseek(i32* %38, i32 0, i32 %39)
store i8 0, i8* %6
br label %41
41: ; preds = %266, %32
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %269
44: ; preds = %41
%45 = load i32*, i32** %10
%46 = call zeroext i8 @fgetc(i32* %45)
store i8 %46, i8* %7
%47 = load i8, i8* %7
%48 = zext i8 %47 to i32
%49 = load i8, i8* %6
%50 = zext i8 %49 to i32
%51 = icmp eq i32 %48, %50
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = load i32*, i32** %11
%54 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32* %53)
br label %265
55: ; preds = %44
%56 = load i8, i8* %7
%57 = zext i8 %56 to i32
%58 = load i8, i8* %6
%59 = zext i8 %58 to i32
%60 = sub nsw i32 %57, %59
%61 = trunc i32 %60 to i8
%62 = zext i8 %61 to i32
%63 = icmp sle i32 %62, 127
br i1 %63, label %64, label %159
64: ; preds = %55
%65 = load i8, i8* %6
%66 = zext i8 %65 to i32
%67 = load i8, i8* %7
%68 = zext i8 %67 to i32
%69 = sub nsw i32 %68, %66
%70 = trunc i32 %69 to i8
store i8 %70, i8* %7
%71 = load i8, i8* %7
%72 = zext i8 %71 to i32
%73 = icmp slt i32 %72, 16
br i1 %73, label %74, label %81
74: ; preds = %64
%75 = load i8, i8* %7
%76 = zext i8 %75 to i32
%77 = load i32*, i32** %11
%78 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %76, i32 1, i32* %77)
%79 = load i32*, i32** %11
%80 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32* %79)
br label %152
81: ; preds = %64
store i8 5, i8* %8
br label %82
82: ; preds = %91, %81
%83 = load i8, i8* %8
%84 = zext i8 %83 to i64
%85 = getelementptr inbounds [13 x i32], [13 x i32]* @main.sqr, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = load i8, i8* %7
%88 = zext i8 %87 to i32
%89 = icmp ule i32 %86, %88
br i1 %89, label %90, label %94
90: ; preds = %82
br label %91
91: ; preds = %90
%92 = load i8, i8* %8
%93 = add i8 %92, 1
store i8 %93, i8* %8
br label %82
94: ; preds = %82
%95 = load i8, i8* %8
%96 = add i8 %95, -1
store i8 %96, i8* %8
%97 = zext i8 %95 to i32
%98 = load i32*, i32** %11
%99 = call i32 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %97, i32 1, i32* %98)
%100 = load i32*, i32** %11
%101 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2, i32 1, i32* %100)
%102 = load i8, i8* %7
%103 = zext i8 %102 to i32
%104 = load i8, i8* %8
%105 = zext i8 %104 to i32
%106 = srem i32 %103, %105
%107 = load i8, i8* %8
%108 = zext i8 %107 to i32
%109 = sdiv i32 %108, 2
%110 = icmp sgt i32 %106, %109
br i1 %110, label %111, label %132
111: ; preds = %94
%112 = load i8, i8* %7
%113 = zext i8 %112 to i32
%114 = load i8, i8* %8
%115 = zext i8 %114 to i32
%116 = sdiv i32 %113, %115
%117 = add nsw i32 %116, 1
%118 = load i32*, i32** %11
%119 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %117, i32 1, i32* %118)
%120 = load i32*, i32** %11
%121 = call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %120)
%122 = load i8, i8* %8
%123 = zext i8 %122 to i32
%124 = load i8, i8* %7
%125 = zext i8 %124 to i32
%126 = load i8, i8* %8
%127 = zext i8 %126 to i32
%128 = srem i32 %125, %127
%129 = sub nsw i32 %123, %128
%130 = load i32*, i32** %11
%131 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %129, i32 1, i32* %130)
br label %149
132: ; preds = %94
%133 = load i8, i8* %7
%134 = zext i8 %133 to i32
%135 = load i8, i8* %8
%136 = zext i8 %135 to i32
%137 = sdiv i32 %134, %136
%138 = load i32*, i32** %11
%139 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %137, i32 1, i32* %138)
%140 = load i32*, i32** %11
%141 = call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %140)
%142 = load i8, i8* %7
%143 = zext i8 %142 to i32
%144 = load i8, i8* %8
%145 = zext i8 %144 to i32
%146 = srem i32 %143, %145
%147 = load i32*, i32** %11
%148 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %146, i32 1, i32* %147)
br label %149
149: ; preds = %132, %111
%150 = load i32*, i32** %11
%151 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32* %150)
br label %152
152: ; preds = %149, %74
%153 = load i8, i8* %7
%154 = zext i8 %153 to i32
%155 = load i8, i8* %6
%156 = zext i8 %155 to i32
%157 = add nsw i32 %156, %154
%158 = trunc i32 %157 to i8
store i8 %158, i8* %6
br label %264
159: ; preds = %55
%160 = load i8, i8* %7
%161 = zext i8 %160 to i32
%162 = load i8, i8* %6
%163 = zext i8 %162 to i32
%164 = sub nsw i32 %161, %163
%165 = trunc i32 %164 to i8
%166 = zext i8 %165 to i32
%167 = icmp sgt i32 %166, 127
br i1 %167, label %168, label %263
168: ; preds = %159
%169 = load i8, i8* %6
%170 = zext i8 %169 to i32
%171 = load i8, i8* %7
%172 = zext i8 %171 to i32
%173 = sub nsw i32 %170, %172
%174 = trunc i32 %173 to i8
store i8 %174, i8* %7
%175 = load i8, i8* %7
%176 = zext i8 %175 to i32
%177 = icmp slt i32 %176, 16
br i1 %177, label %178, label %185
178: ; preds = %168
%179 = load i8, i8* %7
%180 = zext i8 %179 to i32
%181 = load i32*, i32** %11
%182 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %180, i32 1, i32* %181)
%183 = load i32*, i32** %11
%184 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32* %183)
br label %256
185: ; preds = %168
store i8 5, i8* %8
br label %186
186: ; preds = %195, %185
%187 = load i8, i8* %8
%188 = zext i8 %187 to i64
%189 = getelementptr inbounds [13 x i32], [13 x i32]* @main.sqr, i64 0, i64 %188
%190 = load i32, i32* %189
%191 = load i8, i8* %7
%192 = zext i8 %191 to i32
%193 = icmp ule i32 %190, %192
br i1 %193, label %194, label %198
194: ; preds = %186
br label %195
195: ; preds = %194
%196 = load i8, i8* %8
%197 = add i8 %196, 1
store i8 %197, i8* %8
br label %186
198: ; preds = %186
%199 = load i8, i8* %8
%200 = add i8 %199, -1
store i8 %200, i8* %8
%201 = zext i8 %199 to i32
%202 = load i32*, i32** %11
%203 = call i32 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %201, i32 1, i32* %202)
%204 = load i32*, i32** %11
%205 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2, i32 1, i32* %204)
%206 = load i8, i8* %7
%207 = zext i8 %206 to i32
%208 = load i8, i8* %8
%209 = zext i8 %208 to i32
%210 = srem i32 %207, %209
%211 = load i8, i8* %8
%212 = zext i8 %211 to i32
%213 = sdiv i32 %212, 2
%214 = icmp sgt i32 %210, %213
br i1 %214, label %215, label %236
215: ; preds = %198
%216 = load i8, i8* %7
%217 = zext i8 %216 to i32
%218 = load i8, i8* %8
%219 = zext i8 %218 to i32
%220 = sdiv i32 %217, %219
%221 = add nsw i32 %220, 1
%222 = load i32*, i32** %11
%223 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %221, i32 1, i32* %222)
%224 = load i32*, i32** %11
%225 = call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %224)
%226 = load i8, i8* %8
%227 = zext i8 %226 to i32
%228 = load i8, i8* %7
%229 = zext i8 %228 to i32
%230 = load i8, i8* %8
%231 = zext i8 %230 to i32
%232 = srem i32 %229, %231
%233 = sub nsw i32 %227, %232
%234 = load i32*, i32** %11
%235 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %233, i32 1, i32* %234)
br label %253
236: ; preds = %198
%237 = load i8, i8* %7
%238 = zext i8 %237 to i32
%239 = load i8, i8* %8
%240 = zext i8 %239 to i32
%241 = sdiv i32 %238, %240
%242 = load i32*, i32** %11
%243 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %241, i32 1, i32* %242)
%244 = load i32*, i32** %11
%245 = call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %244)
%246 = load i8, i8* %7
%247 = zext i8 %246 to i32
%248 = load i8, i8* %8
%249 = zext i8 %248 to i32
%250 = srem i32 %247, %249
%251 = load i32*, i32** %11
%252 = call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %250, i32 1, i32* %251)
br label %253
253: ; preds = %236, %215
%254 = load i32*, i32** %11
%255 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 1, i32* %254)
br label %256
256: ; preds = %253, %178
%257 = load i8, i8* %7
%258 = zext i8 %257 to i32
%259 = load i8, i8* %6
%260 = zext i8 %259 to i32
%261 = sub nsw i32 %260, %258
%262 = trunc i32 %261 to i8
store i8 %262, i8* %6
br label %263
263: ; preds = %256, %159
br label %264
264: ; preds = %263, %152
br label %265
265: ; preds = %264, %52
br label %266
266: ; preds = %265
%267 = load i32, i32* %9
%268 = add i32 %267, -1
store i32 %268, i32* %9
br label %41
269: ; preds = %41
store i32 0, i32* %3
br label %270
270: ; preds = %269, %30, %22, %14
%271 = load i32, i32* %3
ret i32 %271
}

LLVM IR (-O2):
@main.sqr = internal unnamed_addr constant [13 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 25, i32 36, i32 49, i32 64, i32 81, i32 100, i32 121, i32 144]
@.str = [156 x i8] c"MasterRay TextToBF\0ATextToBF source destination\0A\0A source Specify the text file.\0A destination Specify the filename for the converted BrainFuck file.\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"Cannot open the source file specified.\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [48 x i8] c"Cannot write in the destination file specified.\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [16 x i8] c"+++++++++++++++\00"
@.str.7 = [17 x i8] c">+++++++++++++++\00"
@.str.8 = [3 x i8] c"[<\00"
@.str.9 = [5 x i8] c">-]<\00"
@.str.10 = [16 x i8] c"---------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %99
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %99, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %99, label %14
14: ; preds = %9
%15 = load i32, i32* @SEEK_END
%16 = tail call i32 @fseek(i32* %7, i32 0, i32 %15)
%17 = tail call i32 @ftell(i32* %7)
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @fseek(i32* %7, i32 0, i32 %18)
%20 = icmp eq i32 %17, 0
br i1 %20, label %103, label %21
21: ; preds = %14, %94
%22 = phi i8 [ %95, %94 ], [ 0, %14 ]
%23 = phi i32 [ %97, %94 ], [ %17, %14 ]
%24 = tail call zeroext i8 @fgetc(i32* %7)
%25 = icmp eq i8 %24, %22
br i1 %25, label %94, label %26
26: ; preds = %21
%27 = sub i8 %24, %22
%28 = zext i8 %27 to i32
%29 = icmp sgt i8 %27, -1
br i1 %29, label %30, label %61
30: ; preds = %26
%31 = icmp ult i8 %27, 16
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %28, i32 1, i32* %12)
br label %94
34: ; preds = %30, %34
%35 = phi i8 [ %40, %34 ], [ 5, %30 ]
%36 = zext i8 %35 to i64
%37 = getelementptr inbounds [13 x i32], [13 x i32]* @main.sqr, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp ugt i32 %38, %28
%40 = add i8 %35, 1
br i1 %39, label %41, label %34
41: ; preds = %34
%42 = add i8 %35, -1
%43 = zext i8 %35 to i32
%44 = tail call i32 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %43, i32 1, i32* %12)
%45 = tail call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2, i32 1, i32* %12)
%46 = zext i8 %42 to i32
%47 = urem i32 %28, %46
%48 = lshr i32 %46, 1
%49 = icmp ugt i32 %47, %48
%50 = udiv i32 %28, %46
br i1 %49, label %51, label %57
51: ; preds = %41
%52 = add nuw nsw i32 %50, 1
%53 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %52, i32 1, i32* %12)
%54 = tail call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %12)
%55 = sub nsw i32 %46, %47
%56 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %55, i32 1, i32* %12)
br label %94
57: ; preds = %41
%58 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %50, i32 1, i32* %12)
%59 = tail call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %12)
%60 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %47, i32 1, i32* %12)
br label %94
61: ; preds = %26
%62 = sub i8 %22, %24
%63 = zext i8 %62 to i32
%64 = icmp ult i8 %62, 16
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %63, i32 1, i32* %12)
br label %94
67: ; preds = %61, %67
%68 = phi i8 [ %73, %67 ], [ 5, %61 ]
%69 = zext i8 %68 to i64
%70 = getelementptr inbounds [13 x i32], [13 x i32]* @main.sqr, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = icmp ugt i32 %71, %63
%73 = add i8 %68, 1
br i1 %72, label %74, label %67
74: ; preds = %67
%75 = add i8 %68, -1
%76 = zext i8 %68 to i32
%77 = tail call i32 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %76, i32 1, i32* %12)
%78 = tail call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2, i32 1, i32* %12)
%79 = zext i8 %75 to i32
%80 = urem i32 %63, %79
%81 = lshr i32 %79, 1
%82 = icmp ugt i32 %80, %81
%83 = udiv i32 %63, %79
br i1 %82, label %84, label %90
84: ; preds = %74
%85 = add nuw nsw i32 %83, 1
%86 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %85, i32 1, i32* %12)
%87 = tail call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %12)
%88 = sub nsw i32 %79, %80
%89 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %88, i32 1, i32* %12)
br label %94
90: ; preds = %74
%91 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %83, i32 1, i32* %12)
%92 = tail call i32 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4, i32 1, i32* %12)
%93 = tail call i32 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %80, i32 1, i32* %12)
br label %94
94: ; preds = %84, %90, %51, %57, %21, %65, %32
%95 = phi i8 [ %24, %32 ], [ %24, %65 ], [ %22, %21 ], [ %24, %57 ], [ %24, %51 ], [ %24, %90 ], [ %24, %84 ]
%96 = tail call i32 @fputc(i32 46, i32* %12)
%97 = add i32 %23, -1
%98 = icmp eq i32 %97, 0
br i1 %98, label %103, label %21
99: ; preds = %9, %4, %2
%100 = phi i8* [ getelementptr inbounds ([156 x i8], [156 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), %9 ]
%101 = phi i32 [ 0, %2 ], [ 1, %4 ], [ 2, %9 ]
%102 = tail call i32 @puts(i8* dereferenceable(1) %100)
br label %103
103: ; preds = %94, %99, %14
%104 = phi i32 [ 0, %14 ], [ %101, %99 ], [ 0, %94 ]
ret i32 %104
}