#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fputc(char, int /*<<< orphan*/ *);
int fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
bool file_to_header(const char *varName, const char *inputFileName,
                    const char *outputFileName) {
  FILE *inputFile;
  FILE *outputFile;
  inputFile = fopen(inputFileName, "r");
  if (inputFile == NULL) {
    return false;
  }
  outputFile = fopen(outputFileName, "w");
  if (outputFile != NULL) {
    int c = 0;
    int columnStart = 0;
    int column = 0;
    size_t objSize = 0;
    char variableCrap[75];
    fputs("/* DO NOT EDIT: Generated with bin-embed by Christian Gunderman "
          "*/\r\n#include <stdlib.h>\r\n\r\n",
          outputFile);
    sprintf(variableCrap, "const int %s[] = {", varName);
    column = columnStart = strlen(variableCrap);
    fputs(variableCrap, outputFile);
    while ((c = fgetc(inputFile)) != EOF) {
      char byteAsString[10];
      sprintf(byteAsString, "0x%02x, ", c);
      if (fputs(byteAsString, outputFile) == EOF) {
        return false;
      }
      column += strlen(byteAsString);
      if (column >= 76) {
        int i = 0;
        if (fputs("\r\n", outputFile) == EOF) {
          return false;
        }
        for (i = 0; i < columnStart; i++) {
          if (fputc(' ', outputFile) == EOF) {
            return false;
          }
        }
        column = columnStart;
      }
      objSize++;
    }
    sprintf(variableCrap, "};\r\nconst size_t %sSize = %lu;", varName,
            (unsigned long)objSize);
    fputs(variableCrap, outputFile);
    fclose(outputFile);
  }
  fclose(inputFile);
  return true;
}


x86 assembly (clang, -O0):
<file_to_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b2 <file_to_header+0x42>
movl   $0x0,-0x4(%rbp)
jmp    13a0 <file_to_header+0x230>
mov    -0x20(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1390 <file_to_header+0x220>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe0b(%rip),%rdi
call   1050 <fputs@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    %eax,-0x3c(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    0x2d9c(%rip),%rcx
cmp    (%rcx),%eax
je     135a <file_to_header+0x1ea>
lea    -0xaa(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe0e(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xaa(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <fputs@plt>
mov    0x2d65(%rip),%rcx
cmp    (%rcx),%eax
jne    1297 <file_to_header+0x127>
movl   $0x0,-0x4(%rbp)
jmp    13a0 <file_to_header+0x230>
lea    -0xaa(%rbp),%rdi
call   1040 <strlen@plt>
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x4c,-0x3c(%rbp)
jl     1349 <file_to_header+0x1d9>
movl   $0x0,-0xb0(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xd95(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d14(%rip),%rcx
cmp    (%rcx),%eax
jne    12e8 <file_to_header+0x178>
movl   $0x0,-0x4(%rbp)
jmp    13a0 <file_to_header+0x230>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1343 <file_to_header+0x1d3>
mov    -0x30(%rbp),%rsi
mov    $0x20,%edi
call   1070 <fputc@plt>
mov    0x2cd2(%rip),%rcx
cmp    (%rcx),%eax
jne    132a <file_to_header+0x1ba>
movl   $0x0,-0x4(%rbp)
jmp    13a0 <file_to_header+0x230>
jmp    132f <file_to_header+0x1bf>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    12f2 <file_to_header+0x182>
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1239 <file_to_header+0xc9>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_to_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,%rbp
mov    %rsi,%rax
mov    %rdi,%r12
lea    0xe5f(%rip),%rsi
mov    %rax,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     133f <file_to_header+0x1bf>
mov    %rax,%rbx
lea    0xe46(%rip),%rsi
mov    %rbp,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1276 <file_to_header+0xf6>
mov    %rax,%r15
lea    0xe2d(%rip),%rdi
mov    $0x5b,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xe70(%rip),%rsi
lea    0x30(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2dbc(%rip),%r13
cmp    0x0(%r13),%eax
mov    %r12,0x18(%rsp)
jne    1288 <file_to_header+0x108>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xe37(%rip),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    0x18(%rsp),%rdx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    1341 <file_to_header+0x1c1>
lea    0x26(%rsp),%rbx
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
mov    %r14d,%r12d
jmp    12bc <file_to_header+0x13c>
nopl   0x0(%rax)
addq   $0x1,0x8(%rsp)
mov    0x10(%rsp),%rdi
call   1060 <fgetc@plt>
cmp    (%rbx),%eax
mov    %rbx,%r13
lea    0x26(%rsp),%rbx
je     123e <file_to_header+0xbe>
mov    %rbx,%rdi
lea    0xdad(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
cmp    0x0(%r13),%eax
je     133f <file_to_header+0x1bf>
mov    %r13,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %eax,%r12d
cmp    $0x4c,%r12d
mov    %r13,%rbx
jl     12a0 <file_to_header+0x120>
lea    0xd5f(%rip),%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
cmp    (%rbx),%eax
je     133f <file_to_header+0x1bf>
mov    %r14d,%eax
mov    %r14d,%r13d
mov    %r14d,%r12d
test   %r14d,%r14d
jle    12a0 <file_to_header+0x120>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
mov    %r15,%rsi
call   1070 <fputc@plt>
cmp    (%rbx),%eax
je     133f <file_to_header+0x1bf>
add    $0xffffffff,%r13d
jne    1320 <file_to_header+0x1a0>
mov    %r14d,%r12d
jmp    12a0 <file_to_header+0x120>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [92 x i8] c"/* DO NOT EDIT: Generated with bin-embed by Christian Gunderman */\0D\0A#include <stdlib.h>\0D\0A\0D\0A\00"
@.str.3 = [19 x i8] c"const int %s[] = {\00"
@EOF = global i32 0
@.str.4 = [9 x i8] c"0x%02x, \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [31 x i8] c"};\0D\0Aconst size_t %sSize = %lu;\00"
define i32 @file_to_header(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca [75 x i8]
%15 = alloca [10 x i8]
%16 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%17 = load i8*, i8** %6
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %8
%19 = load i32*, i32** %8
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 0, i32* %4
br label %99
22: ; preds = %3
%23 = load i8*, i8** %7
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %9
%25 = load i32*, i32** %9
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %96
27: ; preds = %22
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i64 0, i64* %13
%28 = load i32*, i32** %9
%29 = call i32 @fputs(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i32* %28)
%30 = getelementptr inbounds [75 x i8], [75 x i8]* %14, i64 0, i64 0
%31 = load i8*, i8** %5
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [75 x i8], [75 x i8]* %14, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %11
store i32 %34, i32* %12
%35 = getelementptr inbounds [75 x i8], [75 x i8]* %14, i64 0, i64 0
%36 = load i32*, i32** %9
%37 = call i32 @fputs(i8* %35, i32* %36)
br label %38
38: ; preds = %83, %27
%39 = load i32*, i32** %8
%40 = call i32 @fgetc(i32* %39)
store i32 %40, i32* %10
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %86
43: ; preds = %38
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%45 = load i32, i32* %10
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%48 = load i32*, i32** %9
%49 = call i32 @fputs(i8* %47, i32* %48)
%50 = load i32, i32* @EOF
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %43
store i32 0, i32* %4
br label %99
53: ; preds = %43
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%55 = call i32 @strlen(i8* %54)
%56 = load i32, i32* %12
%57 = add nsw i32 %56, %55
store i32 %57, i32* %12
%58 = load i32, i32* %12
%59 = icmp sge i32 %58, 76
br i1 %59, label %60, label %83
60: ; preds = %53
store i32 0, i32* %16
%61 = load i32*, i32** %9
%62 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %61)
%63 = load i32, i32* @EOF
%64 = icmp eq i32 %62, %63
br i1 %64, label %65, label %66
65: ; preds = %60
store i32 0, i32* %4
br label %99
66: ; preds = %60
store i32 0, i32* %16
br label %67
67: ; preds = %78, %66
%68 = load i32, i32* %16
%69 = load i32, i32* %11
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %81
71: ; preds = %67
%72 = load i32*, i32** %9
%73 = call i32 @fputc(i8 signext 32, i32* %72)
%74 = load i32, i32* @EOF
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %77
76: ; preds = %71
store i32 0, i32* %4
br label %99
77: ; preds = %71
br label %78
78: ; preds = %77
%79 = load i32, i32* %16
%80 = add nsw i32 %79, 1
store i32 %80, i32* %16
br label %67
81: ; preds = %67
%82 = load i32, i32* %11
store i32 %82, i32* %12
br label %83
83: ; preds = %81, %53
%84 = load i64, i64* %13
%85 = add i64 %84, 1
store i64 %85, i64* %13
br label %38
86: ; preds = %38
%87 = getelementptr inbounds [75 x i8], [75 x i8]* %14, i64 0, i64 0
%88 = load i8*, i8** %5
%89 = load i64, i64* %13
%90 = call i32 (i8*, i8*, ...) @sprintf(i8* %87, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %88, i64 %89)
%91 = getelementptr inbounds [75 x i8], [75 x i8]* %14, i64 0, i64 0
%92 = load i32*, i32** %9
%93 = call i32 @fputs(i8* %91, i32* %92)
%94 = load i32*, i32** %9
%95 = call i32 @fclose(i32* %94)
br label %96
96: ; preds = %86, %22
%97 = load i32*, i32** %8
%98 = call i32 @fclose(i32* %97)
store i32 1, i32* %4
br label %99
99: ; preds = %96, %76, %65, %52, %21
%100 = load i32, i32* %4
ret i32 %100
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [92 x i8] c"/* DO NOT EDIT: Generated with bin-embed by Christian Gunderman */\0D\0A#include <stdlib.h>\0D\0A\0D\0A\00"
@.str.3 = [19 x i8] c"const int %s[] = {\00"
@EOF = global i32 0
@.str.4 = [9 x i8] c"0x%02x, \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [31 x i8] c"};\0D\0Aconst size_t %sSize = %lu;\00"
define i32 @file_to_header(i8* %0, i8* nocapture %1, i8* nocapture %2) {
%4 = alloca [75 x i8]
%5 = alloca [10 x i8]
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %64, label %8
8: ; preds = %3
%9 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %62, label %11
11: ; preds = %8
%12 = getelementptr inbounds [75 x i8], [75 x i8]* %4, i64 0, i64 0
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i64 91, i64 1, i32* %9)
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%15 = call i32 @strlen(i8* %12)
%16 = call i32 @fputs(i8* %12, i32* %9)
%17 = call i32 @fgetc(i32* %6)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %56, label %20
20: ; preds = %11
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%22 = icmp sgt i32 %15, 0
br label %23
23: ; preds = %20, %50
%24 = phi i32 [ %17, %20 ], [ %53, %50 ]
%25 = phi i64 [ 0, %20 ], [ %52, %50 ]
%26 = phi i32 [ %15, %20 ], [ %51, %50 ]
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%28 = call i32 @fputs(i8* %21, i32* %9)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %23
br label %64
32: ; preds = %23
%33 = call i32 @strlen(i8* %21)
%34 = add nsw i32 %33, %26
%35 = icmp sgt i32 %34, 75
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %9)
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %41, label %40
40: ; preds = %36
br i1 %22, label %44, label %50
41: ; preds = %36
br label %64
42: ; preds = %44
%43 = icmp eq i32 %49, %15
br i1 %43, label %50, label %44
44: ; preds = %40, %42
%45 = phi i32 [ %49, %42 ], [ 0, %40 ]
%46 = call i32 @fputc(i8 signext 32, i32* %9)
%47 = load i32, i32* @EOF
%48 = icmp eq i32 %46, %47
%49 = add nuw nsw i32 %45, 1
br i1 %48, label %61, label %42
50: ; preds = %42, %40, %32
%51 = phi i32 [ %34, %32 ], [ %15, %40 ], [ %15, %42 ]
%52 = add i64 %25, 1
%53 = call i32 @fgetc(i32* %6)
%54 = load i32, i32* @EOF
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %23
56: ; preds = %50, %11
%57 = phi i64 [ 0, %11 ], [ %52, %50 ]
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %0, i64 %57)
%59 = call i32 @fputs(i8* %12, i32* %9)
%60 = call i32 @fclose(i32* %9)
br label %62
61: ; preds = %44
br label %64
62: ; preds = %56, %8
%63 = call i32 @fclose(i32* %6)
br label %64
64: ; preds = %61, %41, %31, %3, %62
%65 = phi i32 [ 1, %62 ], [ 0, %61 ], [ 0, %3 ], [ 0, %31 ], [ 0, %41 ]
ret i32 %65
}