#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 */
struct stat {
  scalar_t__ st_size;
};
typedef scalar_t__ off_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fread(void *, scalar_t__, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ fwrite(void *, scalar_t__, int, int /*<<< orphan*/ *);
void *malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, char *);
int main(int argc, char **argv) {
  FILE *in, *out;
  char *in_s, *out_s;
  struct stat statbuf;
  void *data;
  off_t size;
  int i;
  if (argc < 5) {
    if (argc > 1 && strcasecmp("--help", argv[1]) == 0) {
      printf("Usage: %s -i infile -o outfile\n", argv[0]);
      return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
  }
  for (i = 1; i < argc; ++i) {
    if (strcasecmp("-i", argv[i]) == 0) {
      if (i < argc)
        in_s = argv[i + 1];
      else
        return EXIT_FAILURE;
    } else if (strcasecmp("-o", argv[i]) == 0) {
      if (i < argc)
        out_s = argv[i + 1];
      else
        return EXIT_FAILURE;
    }
  }
  in = fopen(in_s, "r");
  if (in == NULL) {
    fprintf(stderr, "Error: Could not open file \"%s\"\n", in_s);
    return EXIT_FAILURE;
  }
  if (stat(in_s, &statbuf) == -1) {
    fprintf(stderr, "Error: Could not stat file \"%s\"\n", in_s);
    return EXIT_FAILURE;
  }
  size = statbuf.st_size - 32;
  data = malloc(size);
  fread(data, size, 1, in);
  if (ferror(in)) {
    fprintf(stderr, "Error: Reading from \"%s\"\n", in_s);
    return EXIT_FAILURE;
  }
  if (fclose(in) == EOF)
    fprintf(stderr, "Warning: Could not close file \"%s\"\n", in_s);
  out = fopen(out_s, "w");
  if (out == NULL) {
    fprintf(stderr, "Error: Could not open file \"%s\"\n", out_s);
    return EXIT_FAILURE;
  }
  fwrite(data, size, 1, out);
  if (ferror(out)) {
    fprintf(stderr, "Error: Writing to \"%s\"\n", out_s);
    return EXIT_FAILURE;
  }
  if (fclose(out) == EOF)
    fprintf(stderr, "Warning: Could not close file \"%s\"\n", out_s);
  free(data);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    122d <main+0x7d>
cmpl   $0x1,-0x8(%rbp)
jle    121c <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe17(%rip),%rdi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    121c <main+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe01(%rip),%rdi
call   1080 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1314 <main+0x164>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdd4(%rip),%rdi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    129e <main+0xee>
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1288 <main+0xd8>
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
jmp    1299 <main+0xe9>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
jmp    1301 <main+0x151>
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd79(%rip),%rdi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12fc <main+0x14c>
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e6 <main+0x136>
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    12f7 <main+0x147>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
jmp    12fc <main+0x14c>
jmp    1301 <main+0x151>
jmp    1306 <main+0x156>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1234 <main+0x84>
mov    -0x28(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    135d <main+0x1ad>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xce8(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2c7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
jne    139d <main+0x1ed>
mov    0x2c5e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xcc9(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2c3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    -0x38(%rbp),%rax
sub    $0x20,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1060 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     1409 <main+0x259>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xc7e(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2bcf(%rip),%rcx
cmp    (%rcx),%rax
jne    143b <main+0x28b>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xc55(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xc69(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1484 <main+0x2d4>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xbc1(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2b56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    -0x20(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     14d7 <main+0x327>
mov    0x2b24(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xbf0(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x2b03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    151e <main+0x36e>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2b01(%rip),%rcx
cmp    (%rcx),%rax
jne    1509 <main+0x359>
mov    0x2ae1(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
lea    0xb87(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2aaf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jge    120a <main+0x5a>
mov    0x2e03(%rip),%rbp
cmp    $0x2,%edi
jl     1394 <main+0x1e4>
mov    0x8(%rbx),%rsi
lea    0xe1f(%rip),%rdi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1394 <main+0x1e4>
mov    (%rbx),%rsi
lea    0xe0e(%rip),%rdi
call   1080 <printf@plt>
mov    0x2dc3(%rip),%rbp
jmp    1394 <main+0x1e4>
mov    %edi,%r14d
mov    $0x1,%r12d
lea    0xe0d(%rip),%r15
jmp    1234 <main+0x84>
nopl   0x0(%rax)
mov    0x8(%rbx,%r12,8),%r13
add    $0x1,%r12
mov    %r12,%rcx
mov    %rcx,%r12
cmp    %r14,%rcx
je     126d <main+0xbd>
mov    (%rbx,%r12,8),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
je     1220 <main+0x70>
lea    0xddb(%rip),%rdi
mov    %rbp,%rsi
call   1040 <strcasecmp@plt>
lea    0x1(%r12),%rcx
test   %rax,%rax
jne    122c <main+0x7c>
mov    0x8(%rbx,%r12,8),%rax
mov    %rax,0x8(%rsp)
jmp    122c <main+0x7c>
lea    0xdb9(%rip),%rsi
mov    %r13,%rbp
mov    %r13,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1375 <main+0x1c5>
mov    %rax,%rbx
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
je     12e6 <main+0x136>
mov    0x10(%rsp),%r13
add    $0xffffffffffffffe0,%r13
mov    %r13,%rdi
call   10b0 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fread@plt>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     12fb <main+0x14b>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
jmp    1385 <main+0x1d5>
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
jmp    1385 <main+0x1d5>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x2cde(%rip),%r14
cmp    (%r14),%rax
jne    1327 <main+0x177>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
lea    0xd6c(%rip),%rsi
mov    %rbp,%rdx
call   1090 <fprintf@plt>
lea    0xd81(%rip),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1375 <main+0x1c5>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     13a6 <main+0x1f6>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
lea    0xd3e(%rip),%rsi
jmp    1385 <main+0x1d5>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
lea    0xcaa(%rip),%rsi
mov    %rbp,%rdx
call   1090 <fprintf@plt>
mov    0x2c3c(%rip),%rbp
mov    0x0(%rbp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1070 <fclose@plt>
cmp    (%r14),%rax
jne    13cb <main+0x21b>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
lea    0xcc8(%rip),%rsi
mov    %rbp,%rdx
call   1090 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    11fe <main+0x4e>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [32 x i8] c"Usage: %s -i infile -o outfile\0A\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.5 = [33 x i8] c"Error: Could not open file \22%s\22\0A\00"
@.str.6 = [33 x i8] c"Error: Could not stat file \22%s\22\0A\00"
@.str.7 = [26 x i8] c"Error: Reading from \22%s\22\0A\00"
@EOF = global i64 0
@.str.8 = [36 x i8] c"Warning: Could not close file \22%s\22\0A\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [24 x i8] c"Error: Writing to \22%s\22\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 i8*
%9 = alloca i8*
%10 = alloca %struct.stat
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 5
br i1 %15, label %16, label %33
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_SUCCESS
store i32 %30, i32* %3
br label %169
31: ; preds = %19, %16
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %3
br label %169
33: ; preds = %2
store i32 1, i32* %13
br label %34
34: ; preds = %84, %33
%35 = load i32, i32* %13
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %87
38: ; preds = %34
%39 = load i8**, i8*** %5
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %60
46: ; preds = %38
%47 = load i32, i32* %13
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = load i32, i32* %13
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %51, i64 %54
%56 = load i8*, i8** %55
store i8* %56, i8** %8
br label %59
57: ; preds = %46
%58 = load i32, i32* @EXIT_FAILURE
store i32 %58, i32* %3
br label %169
59: ; preds = %50
br label %83
60: ; preds = %38
%61 = load i8**, i8*** %5
%62 = load i32, i32* %13
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %82
68: ; preds = %60
%69 = load i32, i32* %13
%70 = load i32, i32* %4
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %79
72: ; preds = %68
%73 = load i8**, i8*** %5
%74 = load i32, i32* %13
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %73, i64 %76
%78 = load i8*, i8** %77
store i8* %78, i8** %9
br label %81
79: ; preds = %68
%80 = load i32, i32* @EXIT_FAILURE
store i32 %80, i32* %3
br label %169
81: ; preds = %72
br label %82
82: ; preds = %81, %60
br label %83
83: ; preds = %82, %59
br label %84
84: ; preds = %83
%85 = load i32, i32* %13
%86 = add nsw i32 %85, 1
store i32 %86, i32* %13
br label %34
87: ; preds = %34
%88 = load i8*, i8** %8
%89 = call i32* @fopen(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %89, i32** %6
%90 = load i32*, i32** %6
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %97
92: ; preds = %87
%93 = load i32, i32* @stderr
%94 = load i8*, i8** %8
%95 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %94)
%96 = load i32, i32* @EXIT_FAILURE
store i32 %96, i32* %3
br label %169
97: ; preds = %87
%98 = load i8*, i8** %8
%99 = call i32 @stat(i8* %98, %struct.stat* %10)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %106
101: ; preds = %97
%102 = load i32, i32* @stderr
%103 = load i8*, i8** %8
%104 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %103)
%105 = load i32, i32* @EXIT_FAILURE
store i32 %105, i32* %3
br label %169
106: ; preds = %97
%107 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%108 = load i64, i64* %107
%109 = sub nsw i64 %108, 32
store i64 %109, i64* %12
%110 = load i64, i64* %12
%111 = call i8* @malloc(i64 %110)
store i8* %111, i8** %11
%112 = load i8*, i8** %11
%113 = load i64, i64* %12
%114 = load i32*, i32** %6
%115 = call i32 @fread(i8* %112, i64 %113, i32 1, i32* %114)
%116 = load i32*, i32** %6
%117 = call i64 @ferror(i32* %116)
%118 = icmp ne i64 %117, 0
br i1 %118, label %119, label %124
119: ; preds = %106
%120 = load i32, i32* @stderr
%121 = load i8*, i8** %8
%122 = call i32 @fprintf(i32 %120, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %121)
%123 = load i32, i32* @EXIT_FAILURE
store i32 %123, i32* %3
br label %169
124: ; preds = %106
%125 = load i32*, i32** %6
%126 = call i64 @fclose(i32* %125)
%127 = load i64, i64* @EOF
%128 = icmp eq i64 %126, %127
br i1 %128, label %129, label %133
129: ; preds = %124
%130 = load i32, i32* @stderr
%131 = load i8*, i8** %8
%132 = call i32 @fprintf(i32 %130, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %131)
br label %133
133: ; preds = %129, %124
%134 = load i8*, i8** %9
%135 = call i32* @fopen(i8* %134, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %135, i32** %7
%136 = load i32*, i32** %7
%137 = icmp eq i32* %136, null
br i1 %137, label %138, label %143
138: ; preds = %133
%139 = load i32, i32* @stderr
%140 = load i8*, i8** %9
%141 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %140)
%142 = load i32, i32* @EXIT_FAILURE
store i32 %142, i32* %3
br label %169
143: ; preds = %133
%144 = load i8*, i8** %11
%145 = load i64, i64* %12
%146 = load i32*, i32** %7
%147 = call i32 @fwrite(i8* %144, i64 %145, i32 1, i32* %146)
%148 = load i32*, i32** %7
%149 = call i64 @ferror(i32* %148)
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %156
151: ; preds = %143
%152 = load i32, i32* @stderr
%153 = load i8*, i8** %9
%154 = call i32 @fprintf(i32 %152, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %153)
%155 = load i32, i32* @EXIT_FAILURE
store i32 %155, i32* %3
br label %169
156: ; preds = %143
%157 = load i32*, i32** %7
%158 = call i64 @fclose(i32* %157)
%159 = load i64, i64* @EOF
%160 = icmp eq i64 %158, %159
br i1 %160, label %161, label %165
161: ; preds = %156
%162 = load i32, i32* @stderr
%163 = load i8*, i8** %9
%164 = call i32 @fprintf(i32 %162, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %163)
br label %165
165: ; preds = %161, %156
%166 = load i8*, i8** %11
%167 = call i32 @free(i8* %166)
%168 = load i32, i32* @EXIT_SUCCESS
store i32 %168, i32* %3
br label %169
169: ; preds = %165, %151, %138, %119, %101, %92, %79, %57, %31, %25
%170 = load i32, i32* %3
ret i32 %170
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [7 x i8] c"--help\00"
@.str.1 = [32 x i8] c"Usage: %s -i infile -o outfile\0A\00"
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"-i\00"
@.str.3 = [3 x i8] c"-o\00"
@.str.4 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.5 = [33 x i8] c"Error: Could not open file \22%s\22\0A\00"
@.str.6 = [33 x i8] c"Error: Could not stat file \22%s\22\0A\00"
@.str.7 = [26 x i8] c"Error: Reading from \22%s\22\0A\00"
@EOF = global i64 0
@.str.8 = [36 x i8] c"Warning: Could not close file \22%s\22\0A\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [24 x i8] c"Error: Writing to \22%s\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 5
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %18
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %94
10: ; preds = %8
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %94
15: ; preds = %10
%16 = load i8*, i8** %1
%17 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %94
18: ; preds = %6, %37
%19 = phi i64 [ 1, %6 ], [ %38, %37 ]
%20 = phi i8* [ undef, %6 ], [ %40, %37 ]
%21 = phi i8* [ undef, %6 ], [ %39, %37 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %19
%23 = load i8*, i8** %22
%24 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %18
%27 = add nuw nsw i64 %19, 1
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
br label %37
30: ; preds = %18
%31 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%32 = icmp eq i64 %31, 0
%33 = add nuw nsw i64 %19, 1
br i1 %32, label %34, label %37
34: ; preds = %30
%35 = getelementptr inbounds i8*, i8** %1, i64 %33
%36 = load i8*, i8** %35
br label %37
37: ; preds = %30, %26, %34
%38 = phi i64 [ %27, %26 ], [ %33, %34 ], [ %33, %30 ]
%39 = phi i8* [ %21, %26 ], [ %36, %34 ], [ %21, %30 ]
%40 = phi i8* [ %29, %26 ], [ %20, %34 ], [ %20, %30 ]
%41 = icmp eq i64 %38, %7
br i1 %41, label %42, label %18
42: ; preds = %37
%43 = tail call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %94
48: ; preds = %42
%49 = call i32 @stat(i8* %40, %struct.stat* %3)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = tail call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %40)
br label %94
54: ; preds = %48
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%56 = load i64, i64* %55
%57 = add nsw i64 %56, -32
%58 = tail call i8* @malloc(i64 %57)
%59 = tail call i32 @fread(i8* %58, i64 %57, i32 1, i32* %43)
%60 = tail call i64 @ferror(i32* %43)
%61 = icmp eq i64 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %54
%63 = load i32, i32* @stderr
%64 = tail call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %40)
br label %94
65: ; preds = %54
%66 = tail call i64 @fclose(i32* %43)
%67 = load i64, i64* @EOF
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = tail call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %40)
br label %72
72: ; preds = %69, %65
%73 = tail call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = tail call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %39)
br label %94
78: ; preds = %72
%79 = tail call i32 @fwrite(i8* %58, i64 %57, i32 1, i32* %73)
%80 = tail call i64 @ferror(i32* %73)
%81 = icmp eq i64 %80, 0
br i1 %81, label %85, label %82
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = tail call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %39)
br label %94
85: ; preds = %78
%86 = tail call i64 @fclose(i32* %73)
%87 = load i64, i64* @EOF
%88 = icmp eq i64 %86, %87
br i1 %88, label %89, label %92
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = tail call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* %39)
br label %92
92: ; preds = %89, %85
%93 = tail call i32 @free(i8* %58)
br label %94
94: ; preds = %8, %10, %92, %82, %75, %62, %51, %45, %15
%95 = phi i32* [ @EXIT_SUCCESS, %15 ], [ @EXIT_FAILURE, %45 ], [ @EXIT_FAILURE, %51 ], [ @EXIT_FAILURE, %62 ], [ @EXIT_FAILURE, %75 ], [ @EXIT_FAILURE, %82 ], [ @EXIT_SUCCESS, %92 ], [ @EXIT_FAILURE, %10 ], [ @EXIT_FAILURE, %8 ]
%96 = load i32, i32* %95
ret i32 %96
}