#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*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *inFile;
  FILE *outCFile;
  FILE *outHFile;
  unsigned char ch;
  unsigned char cnt;
  if (argc < 5) {
    printf("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) {
    printf("ERROR: Couldn't open data file '%s'.\n", argv[1]);
    return -1;
  }
  outCFile = fopen(argv[2], "w");
  if (!outCFile) {
    fclose(inFile);
    printf("ERROR: Couldn't create output source file '%s'.\n", argv[2]);
    return -1;
  }
  outHFile = fopen(argv[3], "w");
  if (!outHFile) {
    fclose(outCFile);
    fclose(inFile);
    printf("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    119a <main+0x3a>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141e <main+0x2be>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11df <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141e <main+0x2be>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe9c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122d <main+0xcd>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141e <main+0x2be>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1284 <main+0x124>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    141e <main+0x2be>
mov    -0x28(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x7,-0x8(%rbp)
jl     1301 <main+0x1a1>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpl   $0x6,-0x8(%rbp)
jl     133f <main+0x1df>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movb   $0x0,-0x2a(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x29(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1387 <main+0x227>
jmp    13e1 <main+0x281>
movzbl -0x2a(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13b2 <main+0x252>
mov    -0x20(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movb   $0x0,-0x2a(%rbp)
mov    -0x20(%rbp),%rdi
movzbl -0x29(%rbp),%edx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x2a(%rbp),%al
add    $0x1,%al
mov    %al,-0x2a(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x29(%rbp)
jmp    1369 <main+0x209>
mov    -0x20(%rbp),%rdi
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <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     11a6 <main+0x26>
lea    0xfb0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    1383 <main+0x203>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe4a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1297 <main+0x117>
mov    %rax,%r12
mov    0x10(%r15),%rdi
lea    0xe57(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a4 <main+0x124>
mov    %rax,%r14
mov    0x18(%r15),%rdi
lea    0xe3b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12b9 <main+0x139>
mov    %rax,%rbx
lea    0xe87(%rip),%r13
mov    $0x30,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe9c(%rip),%rdi
mov    $0x27,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    0x20(%r15),%rdx
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x30,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
cmp    $0x7,%ebp
jb     12e5 <main+0x165>
mov    0x30(%r15),%rdx
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x18(%r15),%rdx
lea    0xe7d(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12ff <main+0x17f>
mov    0x8(%r15),%rsi
lea    0xd61(%rip),%rdi
jmp    12d4 <main+0x154>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x10(%r15),%rsi
lea    0xd74(%rip),%rdi
jmp    12d4 <main+0x154>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    0x18(%r15),%rsi
lea    0xd88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebp
jmp    1383 <main+0x203>
mov    0x18(%r15),%rdx
lea    0xe18(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    $0x6,%ebp
jne    1314 <main+0x194>
mov    0x28(%r15),%rdx
lea    0xe0e(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x20(%r15),%rdx
lea    0xdfd(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r12,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1394 <main+0x214>
lea    0xdf0(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
lea    0xde1(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10a0 <fwrite@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd94(%rip),%r13
xor    %r15d,%r15d
jmp    13ce <main+0x24e>
movzbl %bl,%edx
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r15b
mov    %r12,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1341 <main+0x1c1>
test   $0xf,%r15b
jne    13a0 <main+0x220>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xd45(%rip),%rdi
mov    %r14,%rcx
call   10a0 <fwrite@plt>
xor    %r15d,%r15d
jmp    13a0 <main+0x220>

LLVM IR (-O0):
@.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"
@.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 %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %132
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %27, label %22
22: ; preds = %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 -1, i32* %3
br label %132
27: ; preds = %15
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %31, i32** %7
%32 = load i32*, i32** %7
%33 = icmp ne i32* %32, null
br i1 %33, label %41, label %34
34: ; preds = %27
%35 = load i32*, i32** %6
%36 = call i32 @fclose(i32* %35)
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %39)
store i32 -1, i32* %3
br label %132
41: ; preds = %27
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %45, i32** %8
%46 = load i32*, i32** %8
%47 = icmp ne i32* %46, null
br i1 %47, label %57, label %48
48: ; preds = %41
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %55)
store i32 -1, i32* %3
br label %132
57: ; preds = %41
%58 = load i32*, i32** %8
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%60 = load i32*, i32** %8
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
%62 = load i32*, i32** %8
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 4
%65 = load i8*, i8** %64
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %65)
%67 = load i32*, i32** %8
%68 = call i32 @fclose(i32* %67)
%69 = load i32*, i32** %7
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%71 = load i32, i32* %4
%72 = icmp sge i32 %71, 7
br i1 %72, label %73, label %79
73: ; preds = %57
%74 = load i32*, i32** %7
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 6
%77 = load i8*, i8** %76
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %77)
br label %79
79: ; preds = %73, %57
%80 = load i32*, i32** %7
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 3
%83 = load i8*, i8** %82
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %4
%86 = icmp sge i32 %85, 6
br i1 %86, label %87, label %93
87: ; preds = %79
%88 = load i32*, i32** %7
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 5
%91 = load i8*, i8** %90
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %87, %79
%94 = load i32*, i32** %7
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 4
%97 = load i8*, i8** %96
%98 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %97)
store i8 0, i8* %10
%99 = load i32*, i32** %6
%100 = call zeroext i8 @fgetc(i32* %99)
store i8 %100, i8* %9
br label %101
101: ; preds = %114, %93
%102 = load i32*, i32** %6
%103 = call i32 @feof(i32* %102)
%104 = icmp ne i32 %103, 0
%105 = xor i1 %104, true
br i1 %105, label %106, label %123
106: ; preds = %101
%107 = load i8, i8* %10
%108 = zext i8 %107 to i32
%109 = srem i32 %108, 16
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %106
%112 = load i32*, i32** %7
%113 = call i32 (i32*, i8*, ...) @fprintf(i32* %112, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
store i8 0, i8* %10
br label %114
114: ; preds = %111, %106
%115 = load i32*, i32** %7
%116 = load i8, i8* %9
%117 = zext i8 %116 to i32
%118 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i32 %117)
%119 = load i8, i8* %10
%120 = add i8 %119, 1
store i8 %120, i8* %10
%121 = load i32*, i32** %6
%122 = call zeroext i8 @fgetc(i32* %121)
store i8 %122, i8* %9
br label %101
123: ; preds = %101
%124 = load i32*, i32** %7
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %124, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%126 = load i32*, i32** %7
%127 = call i32 (i32*, i8*, ...) @fprintf(i32* %126, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%128 = load i32*, i32** %7
%129 = call i32 @fclose(i32* %128)
%130 = load i32*, i32** %6
%131 = call i32 @fclose(i32* %130)
store i32 0, i32* %3
br label %132
132: ; preds = %123, %48, %34, %22, %13
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.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"
@str = [96 x i8] c"Usage: bin2c infile.bin outfile.c outfile.h array_name [array_attribute [header_for_attribute]]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @str, i64 0, i64 0))
br label %82
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %82
14: ; preds = %6
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i32 @fclose(i32* %9)
%21 = load i8*, i8** %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* %21)
br label %82
23: ; preds = %14
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = tail call i32 @fclose(i32* %17)
%30 = tail call i32 @fclose(i32* %9)
%31 = load i8*, i8** %24
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %31)
br label %82
33: ; preds = %23
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i64 48, i64 1, i32* %26)
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i64 39, i64 1, i32* %26)
%36 = getelementptr inbounds i8*, i8** %1, i64 4
%37 = load i8*, i8** %36
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %37)
%39 = tail call i32 @fclose(i32* %26)
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i64 48, i64 1, i32* %17)
%41 = icmp ugt i32 %0, 6
br i1 %41, label %42, label %48
42: ; preds = %33
%43 = getelementptr inbounds i8*, i8** %1, i64 6
%44 = load i8*, i8** %43
%45 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %24
%47 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %46)
br label %52
48: ; preds = %33
%49 = load i8*, i8** %24
%50 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %49)
%51 = icmp eq i32 %0, 6
br i1 %51, label %52, label %56
52: ; preds = %42, %48
%53 = getelementptr inbounds i8*, i8** %1, i64 5
%54 = load i8*, i8** %53
%55 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %52, %48
%57 = load i8*, i8** %36
%58 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %57)
%59 = tail call zeroext i8 @fgetc(i32* %9)
%60 = tail call i32 @feof(i32* %9)
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %77
62: ; preds = %56, %69
%63 = phi i8 [ %73, %69 ], [ 0, %56 ]
%64 = phi i8 [ %74, %69 ], [ %59, %56 ]
%65 = and i8 %63, 15
%66 = icmp eq i8 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i64 4, i64 1, i32* %17)
br label %69
69: ; preds = %67, %62
%70 = phi i8 [ 0, %67 ], [ %63, %62 ]
%71 = zext i8 %64 to i32
%72 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i32 %71)
%73 = add i8 %70, 1
%74 = tail call zeroext i8 @fgetc(i32* %9)
%75 = tail call i32 @feof(i32* %9)
%76 = icmp eq i32 %75, 0
br i1 %76, label %62, label %77
77: ; preds = %69, %56
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i64 9, i64 1, i32* %17)
%79 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i64 4, i64 1, i32* %17)
%80 = tail call i32 @fclose(i32* %17)
%81 = tail call i32 @fclose(i32* %9)
br label %82
82: ; preds = %77, %28, %19, %11, %4
%83 = phi i32 [ -1, %4 ], [ 0, %77 ], [ -1, %28 ], [ -1, %19 ], [ -1, %11 ]
ret i32 %83
}