#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *inFile;
  FILE *outCFile;
  FILE *outHFile;
  unsigned char ch;
  unsigned char cnt;
  if (argc < 5) {
    fprintf(stdout, "Usage: bin2c infile.bin outfile.c outfile.h array_name "
                    "[array_attribute [header_for_attribute]]\n");
    return -1;
  }
  inFile = fopen(argv[1], "rb");
  if (!inFile) {
    fprintf(stderr, "ERROR: Couldn't open data file '%s'.\n", argv[1]);
    return -1;
  }
  outCFile = fopen(argv[2], "w");
  if (!outCFile) {
    fclose(inFile);
    fprintf(stderr, "ERROR: Couldn't create output source file '%s'.\n",
            argv[2]);
    return -1;
  }
  outHFile = fopen(argv[3], "w");
  if (!outHFile) {
    fclose(outCFile);
    fclose(inFile);
    fprintf(stderr, "ERROR: Couldn't create output header file '%s'.\n",
            argv[3]);
    return -1;
  }
  fprintf(outHFile, "/* This file is autogenerated, do not edit. */\n\n");
  fprintf(outHFile, "#ifndef CHAR\n"
                    "#define CHAR char\n"
                    "#endif\n\n");
  fprintf(outHFile, "extern CHAR %s[];\n", argv[4]);
  fclose(outHFile);
  fprintf(outCFile, "/* This file is autogenerated, do not edit. */\n\n");
  if (argc >= 7) {
    fprintf(outCFile, "#include \"%s\"\n", argv[6]);
  }
  fprintf(outCFile, "#include \"%s\"\n\n", argv[3]);
  if (argc >= 6) {
    fprintf(outCFile, "%s ", argv[5]);
  }
  fprintf(outCFile, "CHAR %s[] =\n{", argv[4]);
  cnt = 0;
  ch = fgetc(inFile);
  while (!feof(inFile)) {
    if ((cnt % 16) == 0) {
      fprintf(outCFile, "\n   ");
      cnt = 0;
    }
    fprintf(outCFile, " 0x%02x,", (unsigned int)ch);
    ++cnt;
    ch = fgetc(inFile);
  }
  fprintf(outCFile, "\n    0x00");
  fprintf(outCFile, "\n};\n");
  fclose(outCFile);
  fclose(inFile);
  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   $0x5,-0x8(%rbp)
jge    1194 <main+0x44>
mov    0x2e61(%rip),%rax
mov    (%rax),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <main+0x2e6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xebe(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e3 <main+0x93>
mov    0x2e22(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <main+0x2e6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123b <main+0xeb>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2dca(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <main+0x2e6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129c <main+0x14c>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d69(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <main+0x2e6>
mov    -0x28(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x7,-0x8(%rbp)
jl     1319 <main+0x1c9>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x6,-0x8(%rbp)
jl     1357 <main+0x207>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movb   $0x0,-0x2a(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x29(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    139f <main+0x24f>
jmp    13f9 <main+0x2a9>
movzbl -0x2a(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13ca <main+0x27a>
mov    -0x20(%rbp),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movb   $0x0,-0x2a(%rbp)
mov    -0x20(%rbp),%rdi
movzbl -0x29(%rbp),%edx
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x2a(%rbp),%al
add    $0x1,%al
mov    %al,-0x2a(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x29(%rbp)
jmp    1381 <main+0x231>
mov    -0x20(%rbp),%rdi
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
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    $0x4,%edi
jg     119a <main+0x3a>
mov    0x2e61(%rip),%rax
mov    (%rax),%rcx
lea    0xe7f(%rip),%rdi
mov    $0x60,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    $0xffffffff,%ebp
jmp    139c <main+0x23c>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xeb7(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1292 <main+0x132>
mov    %rax,%r12
mov    0x10(%r15),%rdi
lea    0xec4(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12a9 <main+0x149>
mov    %rax,%r14
mov    0x18(%r15),%rdi
lea    0xea8(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12c8 <main+0x168>
mov    %rax,%rbx
lea    0xef4(%rip),%r13
mov    $0x30,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xf09(%rip),%rdi
mov    $0x27,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    0x20(%r15),%rdx
lea    0xf14(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x30,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
cmp    $0x7,%ebp
jb     12fe <main+0x19e>
mov    0x30(%r15),%rdx
lea    0xeec(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x18(%r15),%rdx
lea    0xee6(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1318 <main+0x1b8>
mov    0x2d47(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%r15),%rdx
lea    0xdbd(%rip),%rsi
jmp    12ed <main+0x18d>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x2d28(%rip),%rax
movslq (%rax),%rdi
mov    0x10(%r15),%rdx
lea    0xdc6(%rip),%rsi
jmp    12ed <main+0x18d>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x2d01(%rip),%rax
movslq (%rax),%rdi
mov    0x18(%r15),%rdx
lea    0xdd0(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    139c <main+0x23c>
mov    0x18(%r15),%rdx
lea    0xe60(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    $0x6,%ebp
jne    132d <main+0x1cd>
mov    0x28(%r15),%rdx
lea    0xe56(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x20(%r15),%rdx
lea    0xe45(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     13ad <main+0x24d>
lea    0xe38(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xe29(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddc(%rip),%r13
xor    %r15d,%r15d
jmp    13ee <main+0x28e>
nopl   0x0(%rax)
movzbl %bl,%edx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r15b
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    135a <main+0x1fa>
test   $0xf,%r15b
jne    13c0 <main+0x260>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xd86(%rip),%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
xor    %r15d,%r15d
jmp    13c0 <main+0x260>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [97 x i8] c"Usage: bin2c infile.bin outfile.c outfile.h array_name [array_attribute [header_for_attribute]]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"ERROR: Couldn't open data file '%s'.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [49 x i8] c"ERROR: Couldn't create output source file '%s'.\0A\00"
@.str.5 = [49 x i8] c"ERROR: Couldn't create output header file '%s'.\0A\00"
@.str.6 = [49 x i8] c"/* This file is autogenerated, do not edit. */\0A\0A\00"
@.str.7 = [40 x i8] c"#ifndef CHAR\0A#define CHAR char\0A#endif\0A\0A\00"
@.str.8 = [19 x i8] c"extern CHAR %s[];\0A\00"
@.str.9 = [15 x i8] c"#include \22%s\22\0A\00"
@.str.10 = [16 x i8] c"#include \22%s\22\0A\0A\00"
@.str.11 = [4 x i8] c"%s \00"
@.str.12 = [14 x i8] c"CHAR %s[] =\0A{\00"
@.str.13 = [5 x i8] c"\0A \00"
@.str.14 = [9 x i8] c" 0x%02x,\00"
@.str.15 = [10 x i8] c"\0A 0x00\00"
@.str.16 = [5 x i8] c"\0A};\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 i8
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** @stdout
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %142
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** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %31, label %23
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %29)
store i32 -1, i32* %3
br label %142
31: ; preds = %16
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %35, i32** %7
%36 = load i32*, i32** %7
%37 = icmp ne i32* %36, null
br i1 %37, label %48, label %38
38: ; preds = %31
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
%41 = load i32, i32* @stderr
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i32*
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %46)
store i32 -1, i32* %3
br label %142
48: ; preds = %31
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 3
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %52, i32** %8
%53 = load i32*, i32** %8
%54 = icmp ne i32* %53, null
br i1 %54, label %67, label %55
55: ; preds = %48
%56 = load i32*, i32** %7
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
%60 = load i32, i32* @stderr
%61 = sext i32 %60 to i64
%62 = inttoptr i64 %61 to i32*
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 3
%65 = load i8*, i8** %64
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %65)
store i32 -1, i32* %3
br label %142
67: ; preds = %48
%68 = load i32*, i32** %8
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32*, i32** %8
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%72 = load i32*, i32** %8
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 4
%75 = load i8*, i8** %74
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %75)
%77 = load i32*, i32** %8
%78 = call i32 @fclose(i32* %77)
%79 = load i32*, i32** %7
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%81 = load i32, i32* %4
%82 = icmp sge i32 %81, 7
br i1 %82, label %83, label %89
83: ; preds = %67
%84 = load i32*, i32** %7
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 6
%87 = load i8*, i8** %86
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %83, %67
%90 = load i32*, i32** %7
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 3
%93 = load i8*, i8** %92
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %93)
%95 = load i32, i32* %4
%96 = icmp sge i32 %95, 6
br i1 %96, label %97, label %103
97: ; preds = %89
%98 = load i32*, i32** %7
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 5
%101 = load i8*, i8** %100
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %101)
br label %103
103: ; preds = %97, %89
%104 = load i32*, i32** %7
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 4
%107 = load i8*, i8** %106
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %107)
store i8 0, i8* %10
%109 = load i32*, i32** %6
%110 = call zeroext i8 @fgetc(i32* %109)
store i8 %110, i8* %9
br label %111
111: ; preds = %124, %103
%112 = load i32*, i32** %6
%113 = call i32 @feof(i32* %112)
%114 = icmp ne i32 %113, 0
%115 = xor i1 %114, true
br i1 %115, label %116, label %133
116: ; preds = %111
%117 = load i8, i8* %10
%118 = zext i8 %117 to i32
%119 = srem i32 %118, 16
%120 = icmp eq i32 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %116
%122 = load i32*, i32** %7
%123 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
store i8 0, i8* %10
br label %124
124: ; preds = %121, %116
%125 = load i32*, i32** %7
%126 = load i8, i8* %9
%127 = zext i8 %126 to i32
%128 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i32 %127)
%129 = load i8, i8* %10
%130 = add i8 %129, 1
store i8 %130, i8* %10
%131 = load i32*, i32** %6
%132 = call zeroext i8 @fgetc(i32* %131)
store i8 %132, i8* %9
br label %111
133: ; preds = %111
%134 = load i32*, i32** %7
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%136 = load i32*, i32** %7
%137 = call i32 (i32*, i8*, ...) @fprintf(i32* %136, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%138 = load i32*, i32** %7
%139 = call i32 @fclose(i32* %138)
%140 = load i32*, i32** %6
%141 = call i32 @fclose(i32* %140)
store i32 0, i32* %3
br label %142
142: ; preds = %133, %55, %38, %23, %13
%143 = load i32, i32* %3
ret i32 %143
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [97 x i8] c"Usage: bin2c infile.bin outfile.c outfile.h array_name [array_attribute [header_for_attribute]]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [38 x i8] c"ERROR: Couldn't open data file '%s'.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [49 x i8] c"ERROR: Couldn't create output source file '%s'.\0A\00"
@.str.5 = [49 x i8] c"ERROR: Couldn't create output header file '%s'.\0A\00"
@.str.6 = [49 x i8] c"/* This file is autogenerated, do not edit. */\0A\0A\00"
@.str.7 = [40 x i8] c"#ifndef CHAR\0A#define CHAR char\0A#endif\0A\0A\00"
@.str.8 = [19 x i8] c"extern CHAR %s[];\0A\00"
@.str.9 = [15 x i8] c"#include \22%s\22\0A\00"
@.str.10 = [16 x i8] c"#include \22%s\22\0A\0A\00"
@.str.11 = [4 x i8] c"%s \00"
@.str.12 = [14 x i8] c"CHAR %s[] =\0A{\00"
@.str.13 = [5 x i8] c"\0A \00"
@.str.14 = [9 x i8] c" 0x%02x,\00"
@.str.15 = [10 x i8] c"\0A 0x00\00"
@.str.16 = [5 x i8] c"\0A};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32*, i32** @stdout
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i64 96, i64 1, i32* %5)
br label %92
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load i8*, i8** %8
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %92
18: ; preds = %7
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = tail call i32 @fclose(i32* %10)
%25 = load i32, i32* @stderr
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = load i8*, i8** %19
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %92
30: ; preds = %18
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = tail call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = tail call i32 @fclose(i32* %21)
%37 = tail call i32 @fclose(i32* %10)
%38 = load i32, i32* @stderr
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i32*
%41 = load i8*, i8** %31
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %41)
br label %92
43: ; preds = %30
%44 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i64 48, i64 1, i32* %33)
%45 = tail call i64 @fwrite(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i64 39, i64 1, i32* %33)
%46 = getelementptr inbounds i8*, i8** %1, i64 4
%47 = load i8*, i8** %46
%48 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %47)
%49 = tail call i32 @fclose(i32* %33)
%50 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i64 48, i64 1, i32* %21)
%51 = icmp ugt i32 %0, 6
br i1 %51, label %52, label %58
52: ; preds = %43
%53 = getelementptr inbounds i8*, i8** %1, i64 6
%54 = load i8*, i8** %53
%55 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %31
%57 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %56)
br label %62
58: ; preds = %43
%59 = load i8*, i8** %31
%60 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %59)
%61 = icmp eq i32 %0, 6
br i1 %61, label %62, label %66
62: ; preds = %52, %58
%63 = getelementptr inbounds i8*, i8** %1, i64 5
%64 = load i8*, i8** %63
%65 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %64)
br label %66
66: ; preds = %62, %58
%67 = load i8*, i8** %46
%68 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %67)
%69 = tail call zeroext i8 @fgetc(i32* %10)
%70 = tail call i32 @feof(i32* %10)
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %87
72: ; preds = %66, %79
%73 = phi i8 [ %83, %79 ], [ 0, %66 ]
%74 = phi i8 [ %84, %79 ], [ %69, %66 ]
%75 = and i8 %73, 15
%76 = icmp eq i8 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i64 4, i64 1, i32* %21)
br label %79
79: ; preds = %77, %72
%80 = phi i8 [ 0, %77 ], [ %73, %72 ]
%81 = zext i8 %74 to i32
%82 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i32 %81)
%83 = add i8 %80, 1
%84 = tail call zeroext i8 @fgetc(i32* %10)
%85 = tail call i32 @feof(i32* %10)
%86 = icmp eq i32 %85, 0
br i1 %86, label %72, label %87
87: ; preds = %79, %66
%88 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i64 9, i64 1, i32* %21)
%89 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i64 4, i64 1, i32* %21)
%90 = tail call i32 @fclose(i32* %21)
%91 = tail call i32 @fclose(i32* %10)
br label %92
92: ; preds = %87, %35, %23, %12, %4
%93 = phi i32 [ -1, %4 ], [ 0, %87 ], [ -1, %35 ], [ -1, %23 ], [ -1, %12 ]
ret i32 %93
}