#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;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int rc = 0, i = 0, ch = 0, echo = 1;
  size_t input_size = 0, output_size = 0;
  char *exec = NULL;
  char *input_filename = NULL, *output_filename = NULL;
  char *input_text = NULL, *output_text = NULL;
  FILE *input = NULL, *output = NULL;
  exec = argv[0];
  if (argc < 2) {
    usage(exec);
    rc = 1;
    goto cleanup;
  }
  if (argc > 2) {
    echo = 0;
  }
  if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
    usage(exec);
    rc = 1;
    goto cleanup;
  }
  input_filename = argv[1];
  input = fopen(input_filename, "rb");
  if (!input) {
    printf("Could not open %s\n", input_filename);
    rc = 1;
    goto cleanup;
  }
  (void)fseek(input, 0, SEEK_END);
  input_size = (size_t)ftell(input);
  (void)fseek(input, 0, SEEK_SET);
  if (input_size == 0) {
    printf("%s is empty\n", input_filename);
    rc = 1;
    goto cleanup;
  }
  input_text = malloc(sizeof(char) * (input_size + 1));
  output_text = malloc(sizeof(char) * (input_size + 1));
  if (!input_text || !output_text) {
    printf("Memory error\n");
    rc = 1;
    goto cleanup;
  }
  if (fread(input_text, 1, input_size, input) != input_size) {
    printf("Could not read %s\n", input_filename);
    rc = 1;
    goto cleanup;
  }
  for (i = 0, output_size = 0; i < (int)input_size; i++) {
    ch = (int)input_text[i];
    if (ch == 26) {
      continue;
    }
    if (ch < 0) {
      ch = (ch + 256) % 128;
    }
    output_text[output_size++] = (char)ch;
  }
  if (echo == 0) {
    output_filename = argv[2];
    output = fopen(output_filename, "w+");
    if (!output) {
      printf("Could not open %s\n", output_filename);
      rc = 1;
      goto cleanup;
    }
  } else {
    output = stdout;
  }
  if (fwrite(output_text, 1, output_size, output) != output_size) {
    printf("Could not write %s\n", output_filename);
    rc = 1;
    goto cleanup;
  }
  if (echo != 0 && output != NULL) {
    printf("\n");
  } else {
    printf("Wrote file %s\n", output_filename);
  }
cleanup:
  if (input) {
    (void)fclose(input);
  }
  if (output) {
    (void)fclose(output);
  }
  if (input_text) {
    free(input_text);
  }
  if (output_text) {
    free(output_text);
  }
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1254 <main+0xa4>
mov    -0x38(%rbp),%rdi
call   10b0 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
cmpl   $0x2,-0x8(%rbp)
jle    1265 <main+0xb5>
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12a1 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd71(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12b6 <main+0x106>
mov    -0x38(%rbp),%rdi
call   10b0 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xd3d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12ff <main+0x14f>
mov    -0x40(%rbp),%rsi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
mov    -0x60(%rbp),%rdi
mov    0x2cde(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x60(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x60(%rbp),%rdi
mov    0x2cad(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
cmpq   $0x0,-0x28(%rbp)
jne    135d <main+0x1ad>
mov    -0x40(%rbp),%rsi
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     13a1 <main+0x1f1>
cmpq   $0x0,-0x58(%rbp)
jne    13bb <main+0x20b>
lea    0xc85(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    -0x28(%rbp),%rax
je     13f9 <main+0x249>
mov    -0x40(%rbp),%rsi
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    %ecx,%eax
jge    147b <main+0x2cb>
mov    -0x50(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1a,-0x1c(%rbp)
jne    1435 <main+0x285>
jmp    146d <main+0x2bd>
cmpl   $0x0,-0x1c(%rbp)
jge    1452 <main+0x2a2>
mov    -0x1c(%rbp),%eax
add    $0x100,%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1408 <main+0x258>
cmpl   $0x0,-0x20(%rbp)
jne    14d3 <main+0x323>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xbb2(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    14ce <main+0x31e>
mov    -0x48(%rbp),%rsi
lea    0xb52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
jmp    14e1 <main+0x331>
mov    0x2af6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
cmp    -0x30(%rbp),%rax
je     151f <main+0x36f>
mov    -0x48(%rbp),%rsi
lea    0xb45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    155e <main+0x3ae>
cmpl   $0x0,-0x20(%rbp)
je     1547 <main+0x397>
cmpq   $0x0,-0x68(%rbp)
je     1547 <main+0x397>
lea    0xafe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1559 <main+0x3a9>
mov    -0x48(%rbp),%rsi
lea    0xb13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    155e <main+0x3ae>
cmpq   $0x0,-0x60(%rbp)
je     1572 <main+0x3c2>
mov    -0x60(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x68(%rbp)
je     1586 <main+0x3d6>
mov    -0x68(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x50(%rbp)
je     159a <main+0x3ea>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x58(%rbp)
je     15ae <main+0x3fe>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    (%rsi),%rbx
cmp    $0x1,%edi
jle    132e <main+0x15e>
mov    %rsi,%rbp
mov    %edi,%r12d
mov    0x8(%rsi),%rdi
lea    0xe05(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x15e>
mov    0x8(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x15e>
mov    0x8(%rbp),%r14
lea    0xddd(%rip),%rsi
mov    %r14,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     134e <main+0x17e>
mov    %rax,%r15
mov    0x2da0(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r15,%rdi
call   10a0 <ftell@plt>
mov    %rax,%rbx
mov    0x2d72(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
test   %rbx,%rbx
je     1361 <main+0x191>
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
lea    0x1(%rbx),%r13d
mov    %r13d,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
call   10b0 <malloc@plt>
test   %r14,%r14
mov    %rax,0x8(%rsp)
mov    %r14,0x10(%rsp)
je     137c <main+0x1ac>
test   %rax,%rax
je     137c <main+0x1ac>
mov    $0x1,%r13d
mov    %r14,%rdi
mov    $0x1,%esi
mov    0x20(%rsp),%r14
mov    %r14,%rdx
mov    %r15,%rcx
call   1060 <fread@plt>
cmp    %r14,%rax
jne    13a4 <main+0x1d4>
mov    %r15,%rbx
test   %r14d,%r14d
jle    13bf <main+0x1ef>
mov    %r14d,%ecx
and    $0x1,%r14d
cmp    $0x1,%rcx
mov    0x10(%rsp),%rsi
jne    1467 <main+0x297>
xor    %eax,%eax
xor    %r15d,%r15d
mov    0x8(%rsp),%rdi
test   %r14,%r14
je     13c7 <main+0x1f7>
mov    (%rsi,%rax,1),%al
cmp    $0x1a,%al
je     13c7 <main+0x1f7>
and    $0x7f,%al
mov    %al,(%rdi,%r15,1)
add    $0x1,%r15
jmp    13c7 <main+0x1f7>
mov    %rbx,%rdi
call   10d0 <usage@plt>
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb8(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1336 <main+0x166>
lea    0xcb8(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
jmp    1336 <main+0x166>
lea    0xce3(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    $0x1,%r13d
test   %r14,%r14
jne    14ca <main+0x2fa>
jmp    14d4 <main+0x304>
lea    0xc82(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rbp
jmp    14c2 <main+0x2f2>
xor    %r15d,%r15d
mov    0x8(%rsp),%rdi
cmp    $0x2,%r12d
jne    13dc <main+0x20c>
mov    0x2bfc(%rip),%rax
mov    (%rax),%rbp
xor    %r14d,%r14d
jmp    1400 <main+0x230>
mov    0x10(%rbp),%r14
lea    0xc59(%rip),%rsi
mov    %r14,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     14ae <main+0x2de>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
mov    $0x1,%r13d
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
call   10f0 <fwrite@plt>
cmp    %r15,%rax
jne    1447 <main+0x277>
xor    %r13d,%r13d
lea    0xc32(%rip),%rdi
cmp    $0x2,%r12d
jne    144e <main+0x27e>
test   %rbp,%rbp
je     144e <main+0x27e>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
xor    %r13d,%r13d
jmp    14c2 <main+0x2f2>
lea    0xbf5(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
test   %rbp,%rbp
jne    14c2 <main+0x2f2>
jmp    14ca <main+0x2fa>
sub    %r14,%rcx
xor    %eax,%eax
xor    %r15d,%r15d
mov    0x8(%rsp),%rdi
jmp    1483 <main+0x2b3>
add    $0x2,%rax
cmp    %rax,%rcx
je     130b <main+0x13b>
movzbl (%rsi,%rax,1),%edx
cmp    $0x1a,%dl
je     1497 <main+0x2c7>
and    $0x7f,%dl
mov    %dl,(%rdi,%r15,1)
add    $0x1,%r15
movzbl 0x1(%rsi,%rax,1),%edx
cmp    $0x1a,%dl
je     1476 <main+0x2a6>
and    $0x7f,%dl
mov    %dl,(%rdi,%r15,1)
add    $0x1,%r15
jmp    1476 <main+0x2a6>
lea    0xb58(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rbp
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     133c <main+0x16c>
call   1030 <free@plt>
jmp    133c <main+0x16c>

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

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [19 x i8] c"Could not open %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.4 = [13 x i8] c"%s is empty\0A\00"
@.str.6 = [19 x i8] c"Could not read %s\0A\00"
@.str.7 = [3 x i8] c"w+\00"
@stdout = global i32* null
@.str.8 = [20 x i8] c"Could not write %s\0A\00"
@.str.10 = [15 x i8] c"Wrote file %s\0A\00"
@str = [13 x i8] c"Memory error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @usage(i8* %3)
br label %139
7: ; preds = %2
%8 = icmp eq i32 %0, 2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13, %7
%18 = tail call i32 @usage(i8* %3)
br label %139
19: ; preds = %13
%20 = load i8*, i8** %9
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %139
25: ; preds = %19
%26 = load i32, i32* @SEEK_END
%27 = tail call i32 @fseek(i32* %21, i32 0, i32 %26)
%28 = tail call i64 @ftell(i32* %21)
%29 = load i32, i32* @SEEK_SET
%30 = tail call i32 @fseek(i32* %21, i32 0, i32 %29)
%31 = icmp eq i64 %28, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%34 = tail call i32 @fclose(i32* %21)
br label %139
35: ; preds = %25
%36 = trunc i64 %28 to i32
%37 = add i32 %36, 1
%38 = tail call i8* @malloc(i32 %37)
%39 = tail call i8* @malloc(i32 %37)
%40 = icmp ne i8* %38, null
%41 = icmp ne i8* %39, null
%42 = and i1 %40, %41
br i1 %42, label %43, label %123
43: ; preds = %35
%44 = tail call i64 @fread(i8* %38, i32 1, i64 %28, i32* %21)
%45 = icmp eq i64 %44, %28
br i1 %45, label %46, label %54
46: ; preds = %43
%47 = icmp sgt i32 %36, 0
br i1 %47, label %48, label %95
48: ; preds = %46
%49 = and i64 %28, 4294967295
%50 = and i64 %28, 1
%51 = icmp eq i64 %49, 1
br i1 %51, label %82, label %52
52: ; preds = %48
%53 = sub nsw i64 %49, %50
br label %56
54: ; preds = %43
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %20)
br label %127
56: ; preds = %77, %52
%57 = phi i64 [ 0, %52 ], [ %79, %77 ]
%58 = phi i64 [ 0, %52 ], [ %78, %77 ]
%59 = phi i64 [ 0, %52 ], [ %80, %77 ]
%60 = getelementptr inbounds i8, i8* %38, i64 %57
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 26
br i1 %62, label %67, label %63
63: ; preds = %56
%64 = and i8 %61, 127
%65 = add i64 %58, 1
%66 = getelementptr inbounds i8, i8* %39, i64 %58
store i8 %64, i8* %66
br label %67
67: ; preds = %56, %63
%68 = phi i64 [ %58, %56 ], [ %65, %63 ]
%69 = or i64 %57, 1
%70 = getelementptr inbounds i8, i8* %38, i64 %69
%71 = load i8, i8* %70
%72 = icmp eq i8 %71, 26
br i1 %72, label %77, label %73
73: ; preds = %67
%74 = and i8 %71, 127
%75 = add i64 %68, 1
%76 = getelementptr inbounds i8, i8* %39, i64 %68
store i8 %74, i8* %76
br label %77
77: ; preds = %73, %67
%78 = phi i64 [ %68, %67 ], [ %75, %73 ]
%79 = add nuw nsw i64 %57, 2
%80 = add i64 %59, 2
%81 = icmp eq i64 %80, %53
br i1 %81, label %82, label %56
82: ; preds = %77, %48
%83 = phi i64 [ undef, %48 ], [ %78, %77 ]
%84 = phi i64 [ 0, %48 ], [ %79, %77 ]
%85 = phi i64 [ 0, %48 ], [ %78, %77 ]
%86 = icmp eq i64 %50, 0
br i1 %86, label %95, label %87
87: ; preds = %82
%88 = getelementptr inbounds i8, i8* %38, i64 %84
%89 = load i8, i8* %88
%90 = icmp eq i8 %89, 26
br i1 %90, label %95, label %91
91: ; preds = %87
%92 = and i8 %89, 127
%93 = add i64 %85, 1
%94 = getelementptr inbounds i8, i8* %39, i64 %85
store i8 %92, i8* %94
br label %95
95: ; preds = %82, %91, %87, %46
%96 = phi i64 [ 0, %46 ], [ %83, %82 ], [ %85, %87 ], [ %93, %91 ]
br i1 %8, label %104, label %97
97: ; preds = %95
%98 = getelementptr inbounds i8*, i8** %1, i64 2
%99 = load i8*, i8** %98
%100 = tail call i32* @fopen(i8* %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%101 = icmp eq i32* %100, null
br i1 %101, label %102, label %106
102: ; preds = %97
%103 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %99)
br label %127
104: ; preds = %95
%105 = load i32*, i32** @stdout
br label %106
106: ; preds = %97, %104
%107 = phi i8* [ %99, %97 ], [ null, %104 ]
%108 = phi i32* [ %100, %97 ], [ %105, %104 ]
%109 = tail call i64 @fwrite(i8* %39, i32 1, i64 %96, i32* %108)
%110 = icmp eq i64 %109, %96
br i1 %110, label %111, label %117
111: ; preds = %106
%112 = icmp ne i32* %108, null
%113 = and i1 %8, %112
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = tail call i32 @putchar(i32 10)
%116 = tail call i32 @fclose(i32* %21)
br label %127
117: ; preds = %111, %106
%118 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), %106 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), %111 ]
%119 = phi i32 [ 1, %106 ], [ 0, %111 ]
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %118, i8* %107)
%121 = tail call i32 @fclose(i32* %21)
%122 = icmp eq i32* %108, null
br i1 %122, label %131, label %127
123: ; preds = %35
%124 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%125 = tail call i32 @fclose(i32* %21)
%126 = icmp eq i8* %38, null
br i1 %126, label %134, label %131
127: ; preds = %54, %102, %117, %114
%128 = phi i32* [ %108, %114 ], [ %108, %117 ], [ %21, %102 ], [ %21, %54 ]
%129 = phi i32 [ 0, %114 ], [ %119, %117 ], [ 1, %102 ], [ 1, %54 ]
%130 = tail call i32 @fclose(i32* %128)
br label %131
131: ; preds = %127, %117, %123
%132 = phi i32 [ 1, %123 ], [ %119, %117 ], [ %129, %127 ]
%133 = tail call i32 @free(i8* %38)
br label %134
134: ; preds = %131, %123
%135 = phi i32 [ %132, %131 ], [ 1, %123 ]
%136 = icmp eq i8* %39, null
br i1 %136, label %139, label %137
137: ; preds = %134
%138 = tail call i32 @free(i8* %39)
br label %139
139: ; preds = %32, %5, %17, %23, %137, %134
%140 = phi i32 [ %135, %137 ], [ %135, %134 ], [ 1, %23 ], [ 1, %17 ], [ 1, %5 ], [ 1, %32 ]
ret i32 %140
}