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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ puts(char *);
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  char *input_name;
  FILE *input_file;
  char *output_name;
  FILE *output_file;
  char *variable_name;
  if (4 != argc) {
    puts("Usage: bin2h [input] [output] [variable]");
    return EXIT_FAILURE;
  }
  input_name = argv[1];
  output_name = argv[2];
  variable_name = argv[3];
  input_file = fopen(input_name, "rb");
  if (NULL == input_file) {
    printf("Could not open input file '%s': %s\n", input_name, strerror(errno));
    return EXIT_FAILURE;
  }
  output_file = fopen(output_name, "w");
  if (NULL == output_file) {
    printf("Could not open output file '%s': %s\n", output_name,
           strerror(errno));
    return EXIT_FAILURE;
  }
  if (fprintf(output_file, "static const unsigned char %s[] = {",
              variable_name) < 0) {
    printf("Could not write to output file '%s': %s\n", output_name,
           strerror(ferror(output_file)));
    return EXIT_FAILURE;
  }
  while (0 == feof(input_file)) {
    unsigned char buffer[4096];
    size_t i, count = fread(buffer, 1, sizeof(buffer), input_file);
    if (sizeof(buffer) != count) {
      if (0 == feof(input_file) || 0 != ferror(input_file)) {
        printf("Could not read from input file '%s': %s\n", input_name,
               strerror(ferror(input_file)));
        return EXIT_FAILURE;
      }
    }
    for (i = 0; i < count; ++i) {
      if ((i & 15) == 0) {
        if (fprintf(output_file, "\n  ") < 0) {
          printf("Could not write to output file '%s': %s\n", output_name,
                 strerror(ferror(output_file)));
          return EXIT_FAILURE;
        }
      }
      if (fprintf(output_file, "0x%2.2x, ", buffer[i]) < 0) {
        printf("Could not write to output file '%s': %s\n", output_name,
               strerror(ferror(output_file)));
        return EXIT_FAILURE;
      }
    }
  }
  if (fprintf(output_file, "\n};\n") < 0) {
    printf("Could not write to output file '%s': %s\n", output_name,
           strerror(ferror(output_file)));
    return EXIT_FAILURE;
  }
  if (fclose(output_file) < 0) {
    printf("Could not close output file '%s': %s\n", output_name,
           strerror(ferror(output_file)));
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1090,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     11d4 <main+0x44>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1259 <main+0xc9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
mov    -0x1058(%rbp),%rsi
mov    %rax,%rdx
lea    0xde9(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
mov    -0x28(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    12ba <main+0x12a>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1060(%rbp)
mov    0x2d55(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
mov    -0x1060(%rbp),%rsi
mov    %rax,%rdx
lea    0xdae(%rip),%rdi
call   1070 <printf@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmp    $0x0,%rax
jge    131d <main+0x18d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1068(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1068(%rbp),%rsi
mov    %rax,%rdx
lea    0xd94(%rip),%rdi
call   1070 <printf@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
jmp    1322 <main+0x192>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1509 <main+0x379>
lea    -0x1040(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1050 <fread@plt>
mov    %rax,-0x1050(%rbp)
mov    $0x1000,%eax
cmp    -0x1050(%rbp),%rax
je     13e2 <main+0x252>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     139a <main+0x20a>
mov    -0x20(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     13dd <main+0x24d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x1070(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1070(%rbp),%rsi
mov    %rax,%rdx
lea    0xcfd(%rip),%rdi
call   1070 <printf@plt>
mov    0x2c05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
jmp    13e2 <main+0x252>
movq   $0x0,-0x1048(%rbp)
mov    -0x1048(%rbp),%rax
cmp    -0x1050(%rbp),%rax
jae    1504 <main+0x374>
mov    -0x1048(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    147a <main+0x2ea>
mov    -0x30(%rbp),%rdi
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmp    $0x0,%rax
jge    1475 <main+0x2e5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1078(%rbp),%rsi
mov    %rax,%rdx
lea    0xc3c(%rip),%rdi
call   1070 <printf@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
jmp    147a <main+0x2ea>
mov    -0x30(%rbp),%rdi
mov    -0x1048(%rbp),%rax
movzbl -0x1040(%rbp,%rax,1),%edx
ff
lea    0xc5d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmp    $0x0,%rax
jge    14e8 <main+0x358>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1080(%rbp),%rsi
mov    %rax,%rdx
lea    0xbc9(%rip),%rdi
call   1070 <printf@plt>
mov    0x2afa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
jmp    14ed <main+0x35d>
mov    -0x1048(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1048(%rbp)
jmp    13ed <main+0x25d>
jmp    1322 <main+0x192>
mov    -0x30(%rbp),%rdi
lea    0xbe7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmp    $0x0,%rax
jge    1568 <main+0x3d8>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1088(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1088(%rbp),%rsi
mov    %rax,%rdx
lea    0xb49(%rip),%rdi
call   1070 <printf@plt>
mov    0x2a7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
cmp    $0x0,%rax
jge    15be <main+0x42e>
mov    -0x28(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
mov    -0x1090(%rbp),%rsi
mov    %rax,%rdx
lea    0xb58(%rip),%rdi
call   1070 <printf@plt>
mov    0x2a24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15ca <main+0x43a>
mov    0x2a0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
cmp    $0x4,%edi
jne    124a <main+0xba>
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%rbp
lea    0xe6c(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1258 <main+0xc8>
mov    %rax,%r12
lea    0xe78(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1273 <main+0xe3>
mov    %rax,%rbx
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %rax,%rax
js     128b <main+0xfb>
mov    %r12,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     12c8 <main+0x138>
lea    0xeda(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %rax,%rax
js     128b <main+0xfb>
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %rax,%rax
js     139e <main+0x20e>
mov    0x2d88(%rip),%rax
jmp    12b4 <main+0x124>
lea    0xdaf(%rip),%rdi
call   1030 <puts@plt>
jmp    12ad <main+0x11d>
mov    0x2d81(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
lea    0xdbe(%rip),%rdi
mov    %r15,%rsi
jmp    12a5 <main+0x115>
mov    0x2d66(%rip),%rax
mov    (%rax),%rdi
call   10b0 <strerror@plt>
lea    0xdc9(%rip),%rdi
jmp    12a2 <main+0x112>
mov    %rbx,%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
lea    0xdf9(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1070 <printf@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rdi
lea    0xe1d(%rip),%r13
mov    %r14,0x8(%rsp)
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
mov    %rax,%rbp
cmp    $0x1000,%rax
je     131d <main+0x18d>
mov    %r12,%rdi
call   1090 <feof@plt>
test   %rax,%rax
je     13ba <main+0x22a>
mov    %r12,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    13ba <main+0x22a>
test   %rbp,%rbp
je     135d <main+0x1cd>
xor    %r14d,%r14d
test   $0xf,%r14b
jne    133c <main+0x1ac>
mov    %rbx,%rdi
lea    0xdbd(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %rax,%rax
js     137d <main+0x1ed>
movzbl 0x10(%rsp,%r14,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
test   %rax,%rax
js     137d <main+0x1ed>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1320 <main+0x190>
mov    %r12,%rdi
call   1090 <feof@plt>
test   %rax,%rax
mov    0x8(%rsp),%r14
lea    0x10(%rsp),%rdi
je     12d9 <main+0x149>
jmp    121a <main+0x8a>
mov    %rbx,%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
lea    0xd07(%rip),%rdi
mov    0x8(%rsp),%rsi
jmp    12a5 <main+0x115>
mov    %rbx,%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
lea    0xd4b(%rip),%rdi
jmp    12a2 <main+0x112>
mov    %r12,%rdi
call   1040 <ferror@plt>
mov    %rax,%rdi
call   10b0 <strerror@plt>
lea    0xcf3(%rip),%rdi
mov    %r15,%rsi
jmp    12a5 <main+0x115>

LLVM IR (-O0):
@.str = [41 x i8] c"Usage: bin2h [input] [output] [variable]\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [36 x i8] c"Could not open input file '%s': %s\0A\00"
@errno = global i64 0
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [37 x i8] c"Could not open output file '%s': %s\0A\00"
@.str.5 = [36 x i8] c"static const unsigned char %s[] = {\00"
@.str.6 = [41 x i8] c"Could not write to output file '%s': %s\0A\00"
@.str.7 = [41 x i8] c"Could not read from input file '%s': %s\0A\00"
@.str.8 = [4 x i8] c"\0A \00"
@.str.9 = [10 x i8] c"0x%2.2x, \00"
@.str.10 = [5 x i8] c"\0A};\0A\00"
@.str.11 = [38 x i8] c"Could not close output file '%s': %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca [4096 x i8]
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 4, %14
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %154
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %8
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
store i8* %28, i8** %10
%29 = load i8*, i8** %6
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %7
%31 = load i32*, i32** %7
%32 = icmp eq i32* null, %31
br i1 %32, label %33, label %39
33: ; preds = %19
%34 = load i8*, i8** %6
%35 = load i64, i64* @errno
%36 = call i8* @strerror(i64 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %154
39: ; preds = %19
%40 = load i8*, i8** %8
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %9
%42 = load i32*, i32** %9
%43 = icmp eq i32* null, %42
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i8*, i8** %8
%46 = load i64, i64* @errno
%47 = call i8* @strerror(i64 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %45, i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %154
50: ; preds = %39
%51 = load i32*, i32** %9
%52 = load i8*, i8** %10
%53 = call i64 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %50
%56 = load i8*, i8** %8
%57 = load i32*, i32** %9
%58 = call i64 @ferror(i32* %57)
%59 = call i8* @strerror(i64 %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %56, i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %3
br label %154
62: ; preds = %50
br label %63
63: ; preds = %129, %62
%64 = load i32*, i32** %7
%65 = call i64 @feof(i32* %64)
%66 = icmp eq i64 0, %65
br i1 %66, label %67, label %130
67: ; preds = %63
%68 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%69 = load i32*, i32** %7
%70 = call i64 @fread(i8* %68, i32 1, i32 4096, i32* %69)
store i64 %70, i64* %13
%71 = load i64, i64* %13
%72 = icmp ne i64 4096, %71
br i1 %72, label %73, label %89
73: ; preds = %67
%74 = load i32*, i32** %7
%75 = call i64 @feof(i32* %74)
%76 = icmp eq i64 0, %75
br i1 %76, label %81, label %77
77: ; preds = %73
%78 = load i32*, i32** %7
%79 = call i64 @ferror(i32* %78)
%80 = icmp ne i64 0, %79
br i1 %80, label %81, label %88
81: ; preds = %77, %73
%82 = load i8*, i8** %6
%83 = load i32*, i32** %7
%84 = call i64 @ferror(i32* %83)
%85 = call i8* @strerror(i64 %84)
%86 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %82, i8* %85)
%87 = load i32, i32* @EXIT_FAILURE
store i32 %87, i32* %3
br label %154
88: ; preds = %77
br label %89
89: ; preds = %88, %67
store i64 0, i64* %12
br label %90
90: ; preds = %126, %89
%91 = load i64, i64* %12
%92 = load i64, i64* %13
%93 = icmp ult i64 %91, %92
br i1 %93, label %94, label %129
94: ; preds = %90
%95 = load i64, i64* %12
%96 = and i64 %95, 15
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %110
98: ; preds = %94
%99 = load i32*, i32** %9
%100 = call i64 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%101 = icmp slt i64 %100, 0
br i1 %101, label %102, label %109
102: ; preds = %98
%103 = load i8*, i8** %8
%104 = load i32*, i32** %9
%105 = call i64 @ferror(i32* %104)
%106 = call i8* @strerror(i64 %105)
%107 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %103, i8* %106)
%108 = load i32, i32* @EXIT_FAILURE
store i32 %108, i32* %3
br label %154
109: ; preds = %98
br label %110
110: ; preds = %109, %94
%111 = load i32*, i32** %9
%112 = load i64, i64* %12
%113 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = call i64 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %115)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %125
118: ; preds = %110
%119 = load i8*, i8** %8
%120 = load i32*, i32** %9
%121 = call i64 @ferror(i32* %120)
%122 = call i8* @strerror(i64 %121)
%123 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %119, i8* %122)
%124 = load i32, i32* @EXIT_FAILURE
store i32 %124, i32* %3
br label %154
125: ; preds = %110
br label %126
126: ; preds = %125
%127 = load i64, i64* %12
%128 = add i64 %127, 1
store i64 %128, i64* %12
br label %90
129: ; preds = %90
br label %63
130: ; preds = %63
%131 = load i32*, i32** %9
%132 = call i64 (i32*, i8*, ...) @fprintf(i32* %131, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%133 = icmp slt i64 %132, 0
br i1 %133, label %134, label %141
134: ; preds = %130
%135 = load i8*, i8** %8
%136 = load i32*, i32** %9
%137 = call i64 @ferror(i32* %136)
%138 = call i8* @strerror(i64 %137)
%139 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %135, i8* %138)
%140 = load i32, i32* @EXIT_FAILURE
store i32 %140, i32* %3
br label %154
141: ; preds = %130
%142 = load i32*, i32** %9
%143 = call i64 @fclose(i32* %142)
%144 = icmp slt i64 %143, 0
br i1 %144, label %145, label %152
145: ; preds = %141
%146 = load i8*, i8** %8
%147 = load i32*, i32** %9
%148 = call i64 @ferror(i32* %147)
%149 = call i8* @strerror(i64 %148)
%150 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %146, i8* %149)
%151 = load i32, i32* @EXIT_FAILURE
store i32 %151, i32* %3
br label %154
152: ; preds = %141
%153 = load i32, i32* @EXIT_SUCCESS
store i32 %153, i32* %3
br label %154
154: ; preds = %152, %145, %134, %118, %102, %81, %55, %44, %33, %16
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@.str = [41 x i8] c"Usage: bin2h [input] [output] [variable]\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [36 x i8] c"Could not open input file '%s': %s\0A\00"
@errno = global i64 0
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [37 x i8] c"Could not open output file '%s': %s\0A\00"
@.str.5 = [36 x i8] c"static const unsigned char %s[] = {\00"
@.str.6 = [41 x i8] c"Could not write to output file '%s': %s\0A\00"
@.str.7 = [41 x i8] c"Could not read from input file '%s': %s\0A\00"
@.str.8 = [4 x i8] c"\0A \00"
@.str.9 = [10 x i8] c"0x%2.2x, \00"
@.str.10 = [5 x i8] c"\0A};\0A\00"
@.str.11 = [38 x i8] c"Could not close output file '%s': %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = icmp eq i32 %0, 4
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
br label %106
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %22
17: ; preds = %8
%18 = load i64, i64* @errno
%19 = tail call i8* @strerror(i64 %18)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
br label %106
22: ; preds = %8
%23 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = tail call i8* @strerror(i64 %26)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
br label %106
30: ; preds = %22
%31 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%32 = icmp slt i64 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %30
%34 = tail call i64 @feof(i32* %15)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %88
36: ; preds = %33
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
br label %43
38: ; preds = %30
%39 = tail call i64 @ferror(i32* %23)
%40 = tail call i8* @strerror(i64 %39)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %12, i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
br label %106
43: ; preds = %36, %85
%44 = call i64 @fread(i8* %37, i32 1, i32 4096, i32* %15)
%45 = icmp eq i64 %44, 4096
br i1 %45, label %58, label %46
46: ; preds = %43
%47 = tail call i64 @feof(i32* %15)
%48 = icmp eq i64 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = tail call i64 @ferror(i32* %15)
%51 = icmp eq i64 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %49, %46
%53 = tail call i64 @ferror(i32* %15)
%54 = tail call i8* @strerror(i64 %53)
%55 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %10, i8* %54)
br label %83
56: ; preds = %49
%57 = icmp eq i64 %44, 0
br i1 %57, label %85, label %58
58: ; preds = %43, %56
br label %61
59: ; preds = %72
%60 = icmp eq i64 %78, %44
br i1 %60, label %85, label %61
61: ; preds = %58, %59
%62 = phi i64 [ %78, %59 ], [ 0, %58 ]
%63 = and i64 %62, 15
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %61
%66 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = tail call i64 @ferror(i32* %23)
%70 = tail call i8* @strerror(i64 %69)
%71 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %12, i8* %70)
br label %83
72: ; preds = %65, %61
%73 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %62
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %75)
%77 = icmp slt i64 %76, 0
%78 = add nuw i64 %62, 1
br i1 %77, label %79, label %59
79: ; preds = %72
%80 = tail call i64 @ferror(i32* %23)
%81 = tail call i8* @strerror(i64 %80)
%82 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %12, i8* %81)
br label %83
83: ; preds = %79, %68, %52
%84 = load i32, i32* @EXIT_FAILURE
br label %106
85: ; preds = %59, %56
%86 = tail call i64 @feof(i32* %15)
%87 = icmp eq i64 %86, 0
br i1 %87, label %43, label %88
88: ; preds = %85, %33
%89 = tail call i64 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = tail call i64 @ferror(i32* %23)
%93 = tail call i8* @strerror(i64 %92)
%94 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8* %12, i8* %93)
%95 = load i32, i32* @EXIT_FAILURE
br label %106
96: ; preds = %88
%97 = tail call i64 @fclose(i32* %23)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %104
99: ; preds = %96
%100 = tail call i64 @ferror(i32* %23)
%101 = tail call i8* @strerror(i64 %100)
%102 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %12, i8* %101)
%103 = load i32, i32* @EXIT_FAILURE
br label %106
104: ; preds = %96
%105 = load i32, i32* @EXIT_SUCCESS
br label %106
106: ; preds = %83, %104, %99, %91, %38, %25, %17, %5
%107 = phi i32 [ %7, %5 ], [ %21, %17 ], [ %29, %25 ], [ %42, %38 ], [ %95, %91 ], [ %103, %99 ], [ %105, %104 ], [ %84, %83 ]
ret i32 %107
}