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

/* Variables and functions */
int O_RDONLY;
char *basename(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int filesize(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
unsigned char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int open(char *, int);
int read(int, unsigned char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ write_cfile(unsigned char *, int, int /*<<< orphan*/ *,
                               char *);
int main(int argc, char *argv[]) {
  char *cname;
  int i;
  FILE *cfile, *hfile;
  char cfilename[256], hfilename[256];
  if (argc < 3) {
    fprintf(stderr, "Usage: bin2c cname file1 [file2 [file3 ...]]\n");
    return 1;
  }
  cname = argv[1];
  snprintf(cfilename, 256, "%s.c", cname);
  cfile = fopen(cfilename, "w+");
  if (cfile == NULL) {
    fprintf(stderr, "Couldn't open %s\n", cfilename);
    return 2;
  }
  snprintf(hfilename, 256, "%s.h", cname);
  hfile = fopen(hfilename, "w+");
  if (hfile == NULL) {
    fprintf(stderr, "Couldn't open %s\n", hfilename);
    fclose(cfile);
    return 3;
  }
  fprintf(cfile, "/* Generated by bin2c */\n\n");
  fprintf(cfile, "#include \"%s\"\n\n", basename(hfilename));
  fprintf(hfile, "/* Generated by bin2c */\n\n");
  for (i = 0; i < argc - 2; i++) {
    unsigned char *buf;
    off_t len;
    off_t orig_len;
    char *ext;
    char *array = argv[2 + i];
    int fd = open(array, O_RDONLY | 0);
    if (fd < 0) {
      fprintf(stderr, "Can not open %s\n", argv[2 + i]);
      fclose(cfile);
      fclose(hfile);
      return 4;
    }
    orig_len = filesize(fd);
    len = (orig_len + 3) & ~3;
    buf = malloc(len);
    if (read(fd, buf, orig_len) < orig_len) {
      fprintf(stderr, "Short read, aborting\n");
      return 5;
    }
    if (len > orig_len)
      memset(buf + orig_len, 0, len - orig_len);
    ext = strchr(array, '.');
    if (ext != NULL)
      *ext = '\0';
    write_cfile(buf, len, cfile, array);
    fprintf(hfile, "extern unsigned char %s[%ld];\n", array, len);
    close(fd);
  }
  fclose(cfile);
  fclose(hfile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1217 <main+0x47>
mov    0x2dde(%rip),%rax
movslq (%rax),%rdi
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1544 <main+0x374>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x100,%esi
lea    0xdf4(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x130(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    128c <main+0xbc>
mov    0x2d70(%rip),%rax
movslq (%rax),%rdi
lea    -0x130(%rbp),%rdx
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1544 <main+0x374>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x100,%esi
lea    0xda5(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12fe <main+0x12e>
mov    0x2d07(%rip),%rax
movslq (%rax),%rdi
lea    -0x230(%rbp),%rdx
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x3,-0x4(%rbp)
jmp    1544 <main+0x374>
mov    -0x28(%rbp),%rdi
lea    0xd44(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x260(%rbp)
lea    -0x230(%rbp),%rdi
call   10a0 <basename@plt>
mov    -0x260(%rbp),%rdi
mov    %rax,%rdx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd03(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    152b <main+0x35b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rdi
mov    0x2c59(%rip),%rax
mov    (%rax),%esi
or     $0x0,%esi
call   10d0 <open@plt>
mov    %eax,-0x254(%rbp)
cmpl   $0x0,-0x254(%rbp)
jge    13f3 <main+0x223>
mov    0x2c25(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x4,-0x4(%rbp)
jmp    1544 <main+0x374>
mov    -0x254(%rbp),%edi
call   10e0 <filesize@plt>
mov    %eax,-0x240(%rbp)
mov    -0x240(%rbp),%eax
add    $0x3,%eax
and    $0xfffffffc,%eax
mov    %eax,-0x23c(%rbp)
mov    -0x23c(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x238(%rbp)
mov    -0x254(%rbp),%edi
mov    -0x238(%rbp),%rsi
mov    -0x240(%rbp),%edx
call   1080 <read@plt>
cmp    -0x240(%rbp),%eax
jge    1470 <main+0x2a0>
mov    0x2b85(%rip),%rax
movslq (%rax),%rdi
lea    0xc2c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x5,-0x4(%rbp)
jmp    1544 <main+0x374>
mov    -0x23c(%rbp),%eax
cmp    -0x240(%rbp),%eax
jle    14a6 <main+0x2d6>
mov    -0x238(%rbp),%rdi
movslq -0x240(%rbp),%rax
add    %rax,%rdi
mov    -0x23c(%rbp),%edx
sub    -0x240(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x250(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x248(%rbp)
cmpq   $0x0,-0x248(%rbp)
je     14d6 <main+0x306>
mov    -0x248(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x238(%rbp),%rdi
mov    -0x23c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x250(%rbp),%rcx
call   10c0 <write_cfile@plt>
mov    -0x30(%rbp),%rdi
mov    -0x250(%rbp),%rdx
mov    -0x23c(%rbp),%ecx
lea    0xb94(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x254(%rbp),%edi
call   1070 <close@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1358 <main+0x188>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rdi,0x8(%rsp)
cmp    $0x2,%edi
jg     1225 <main+0x45>
mov    0x2dd6(%rip),%rax
movslq (%rax),%rcx
lea    0xdf4(%rip),%rdi
mov    $0x2d,%esi
mov    $0x1,%edx
call   1100 <fwrite@plt>
mov    $0x1,%eax
jmp    14a8 <main+0x2c8>
mov    %rsi,%r14
mov    0x8(%rsi),%rbp
lea    0xdfb(%rip),%rdx
lea    0x120(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rbp,%rcx
call   1050 <snprintf@plt>
lea    0xde1(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     13e2 <main+0x202>
lea    0xdda(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rbp,%rcx
call   1050 <snprintf@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     140c <main+0x22c>
mov    %rax,%r15
lea    0xda8(%rip),%rbx
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    (%rsp),%rbp
mov    %rbp,%rcx
call   1100 <fwrite@plt>
lea    0x20(%rsp),%rdi
call   10a0 <basename@plt>
lea    0xd99(%rip),%rsi
mov    %rbp,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r15,%rcx
call   1100 <fwrite@plt>
mov    0x8(%rsp),%rax
add    $0xfffffffe,%eax
mov    %rax,0x8(%rsp)
xor    %ebx,%ebx
mov    %r14,0x18(%rsp)
mov    %r15,0x10(%rsp)
jmp    135a <main+0x17a>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r12d,%esi
mov    (%rsp),%rdx
mov    %rbp,%rcx
call   10c0 <write_cfile@plt>
mov    0x10(%rsp),%r15
mov    %r15,%rdi
lea    0xd6e(%rip),%rsi
mov    %rbp,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r13d,%edi
call   1070 <close@plt>
add    $0x1,%rbx
cmp    %rbx,0x8(%rsp)
mov    0x18(%rsp),%r14
je     1439 <main+0x259>
mov    0x10(%r14,%rbx,8),%rbp
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10d0 <open@plt>
test   %eax,%eax
js     144e <main+0x26e>
mov    %eax,%r13d
mov    %eax,%edi
call   10e0 <filesize@plt>
mov    %eax,%r15d
lea    0x3(%r15),%r12d
and    $0xfffffffc,%r12d
mov    %r12d,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
mov    %rax,%rsi
mov    %r15d,%edx
call   1080 <read@plt>
cmp    %r15d,%eax
jl     1483 <main+0x2a3>
mov    %r12d,%edx
sub    %r15d,%edx
jle    13c4 <main+0x1e4>
movslq %r15d,%rdi
add    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %rbp,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1310 <main+0x130>
movb   $0x0,(%rax)
jmp    1310 <main+0x130>
mov    0x2bef(%rip),%rax
movslq (%rax),%rdi
lea    0xc43(%rip),%rsi
lea    0x120(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
jmp    14a8 <main+0x2c8>
mov    0x2bc5(%rip),%rax
movslq (%rax),%rdi
lea    0xc19(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    $0x3,%eax
jmp    14a8 <main+0x2c8>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    14a8 <main+0x2c8>
mov    0x2b83(%rip),%rax
movslq (%rax),%rdi
mov    0x10(%r14,%rbx,8),%rdx
lea    0xc14(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    $0x4,%eax
jmp    14a8 <main+0x2c8>
mov    0x2b4e(%rip),%rax
movslq (%rax),%rcx
lea    0xbf5(%rip),%rdi
mov    $0x15,%esi
mov    $0x1,%edx
call   1100 <fwrite@plt>
mov    $0x5,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"Usage: bin2c cname file1 [file2 [file3 ...]]\0A\00"
@.str.1 = [5 x i8] c"%s.c\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.4 = [5 x i8] c"%s.h\00"
@.str.5 = [27 x i8] c"/* Generated by bin2c */\0A\0A\00"
@.str.6 = [16 x i8] c"#include \22%s\22\0A\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [17 x i8] c"Can not open %s\0A\00"
@.str.8 = [22 x i8] c"Short read, aborting\0A\00"
@.str.9 = [31 x i8] c"extern unsigned char %s[%ld];\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %159
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %6
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%30 = load i8*, i8** %6
%31 = call i32 @snprintf(i8* %29, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %8
%34 = load i32*, i32** %8
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %42
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = sext i32 %37 to i64
%39 = inttoptr i64 %38 to i32*
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %40)
store i32 2, i32* %3
br label %159
42: ; preds = %25
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%44 = load i8*, i8** %6
%45 = call i32 @snprintf(i8* %43, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %47, i32** %9
%48 = load i32*, i32** %9
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %58
50: ; preds = %42
%51 = load i32, i32* @stderr
%52 = sext i32 %51 to i64
%53 = inttoptr i64 %52 to i32*
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = load i32*, i32** %8
%57 = call i32 @fclose(i32* %56)
store i32 3, i32* %3
br label %159
58: ; preds = %42
%59 = load i32*, i32** %8
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%61 = load i32*, i32** %8
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%63 = call i8* @basename(i8* %62)
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %63)
%65 = load i32*, i32** %9
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %67
67: ; preds = %151, %58
%68 = load i32, i32* %7
%69 = load i32, i32* %4
%70 = sub nsw i32 %69, 2
%71 = icmp slt i32 %68, %70
br i1 %71, label %72, label %154
72: ; preds = %67
%73 = load i8**, i8*** %5
%74 = load i32, i32* %7
%75 = add nsw i32 2, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %73, i64 %76
%78 = load i8*, i8** %77
store i8* %78, i8** %16
%79 = load i8*, i8** %16
%80 = load i32, i32* @O_RDONLY
%81 = or i32 %80, 0
%82 = call i32 @open(i8* %79, i32 %81)
store i32 %82, i32* %17
%83 = load i32, i32* %17
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %100
85: ; preds = %72
%86 = load i32, i32* @stderr
%87 = sext i32 %86 to i64
%88 = inttoptr i64 %87 to i32*
%89 = load i8**, i8*** %5
%90 = load i32, i32* %7
%91 = add nsw i32 2, %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %89, i64 %92
%94 = load i8*, i8** %93
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %94)
%96 = load i32*, i32** %8
%97 = call i32 @fclose(i32* %96)
%98 = load i32*, i32** %9
%99 = call i32 @fclose(i32* %98)
store i32 4, i32* %3
br label %159
100: ; preds = %72
%101 = load i32, i32* %17
%102 = call i32 @filesize(i32 %101)
store i32 %102, i32* %14
%103 = load i32, i32* %14
%104 = add nsw i32 %103, 3
%105 = and i32 %104, -4
store i32 %105, i32* %13
%106 = load i32, i32* %13
%107 = call i8* @malloc(i32 %106)
store i8* %107, i8** %12
%108 = load i32, i32* %17
%109 = load i8*, i8** %12
%110 = load i32, i32* %14
%111 = call i32 @read(i32 %108, i8* %109, i32 %110)
%112 = load i32, i32* %14
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %119
114: ; preds = %100
%115 = load i32, i32* @stderr
%116 = sext i32 %115 to i64
%117 = inttoptr i64 %116 to i32*
%118 = call i32 (i32*, i8*, ...) @fprintf(i32* %117, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
store i32 5, i32* %3
br label %159
119: ; preds = %100
%120 = load i32, i32* %13
%121 = load i32, i32* %14
%122 = icmp sgt i32 %120, %121
br i1 %122, label %123, label %132
123: ; preds = %119
%124 = load i8*, i8** %12
%125 = load i32, i32* %14
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8, i8* %124, i64 %126
%128 = load i32, i32* %13
%129 = load i32, i32* %14
%130 = sub nsw i32 %128, %129
%131 = call i32 @memset(i8* %127, i32 0, i32 %130)
br label %132
132: ; preds = %123, %119
%133 = load i8*, i8** %16
%134 = call i8* @strchr(i8* %133, i8 signext 46)
store i8* %134, i8** %15
%135 = load i8*, i8** %15
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %139
137: ; preds = %132
%138 = load i8*, i8** %15
store i8 0, i8* %138
br label %139
139: ; preds = %137, %132
%140 = load i8*, i8** %12
%141 = load i32, i32* %13
%142 = load i32*, i32** %8
%143 = load i8*, i8** %16
%144 = call i32 @write_cfile(i8* %140, i32 %141, i32* %142, i8* %143)
%145 = load i32*, i32** %9
%146 = load i8*, i8** %16
%147 = load i32, i32* %13
%148 = call i32 (i32*, i8*, ...) @fprintf(i32* %145, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %146, i32 %147)
%149 = load i32, i32* %17
%150 = call i32 @close(i32 %149)
br label %151
151: ; preds = %139
%152 = load i32, i32* %7
%153 = add nsw i32 %152, 1
store i32 %153, i32* %7
br label %67
154: ; preds = %67
%155 = load i32*, i32** %8
%156 = call i32 @fclose(i32* %155)
%157 = load i32*, i32** %9
%158 = call i32 @fclose(i32* %157)
store i32 0, i32* %3
br label %159
159: ; preds = %154, %114, %85, %50, %36, %20
%160 = load i32, i32* %3
ret i32 %160
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"Usage: bin2c cname file1 [file2 [file3 ...]]\0A\00"
@.str.1 = [5 x i8] c"%s.c\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.4 = [5 x i8] c"%s.h\00"
@.str.5 = [27 x i8] c"/* Generated by bin2c */\0A\0A\00"
@.str.6 = [16 x i8] c"#include \22%s\22\0A\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [17 x i8] c"Can not open %s\0A\00"
@.str.8 = [22 x i8] c"Short read, aborting\0A\00"
@.str.9 = [31 x i8] c"extern unsigned char %s[%ld];\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 45, i64 1, i32* %11)
br label %91
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %91
24: ; preds = %13
%25 = call i32 @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%26 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%33 = call i32 @fclose(i32* %17)
br label %91
34: ; preds = %24
%35 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i64 26, i64 1, i32* %17)
%36 = call i8* @basename(i8* %6)
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i64 26, i64 1, i32* %26)
%39 = add nsw i32 %0, -2
%40 = zext i32 %39 to i64
br label %41
41: ; preds = %34, %82
%42 = phi i64 [ 0, %34 ], [ %86, %82 ]
%43 = add nuw nsw i64 %42, 2
%44 = getelementptr inbounds i8*, i8** %1, i64 %43
%45 = load i8*, i8** %44
%46 = load i32, i32* @O_RDONLY
%47 = call i32 @open(i8* %45, i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %59
49: ; preds = %41
%50 = and i64 %43, 4294967295
%51 = getelementptr inbounds i8*, i8** %1, i64 %50
%52 = load i32, i32* @stderr
%53 = sext i32 %52 to i64
%54 = inttoptr i64 %53 to i32*
%55 = load i8*, i8** %51
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = call i32 @fclose(i32* %17)
%58 = call i32 @fclose(i32* %26)
br label %91
59: ; preds = %41
%60 = call i32 @filesize(i32 %47)
%61 = add nsw i32 %60, 3
%62 = and i32 %61, -4
%63 = call i8* @malloc(i32 %62)
%64 = call i32 @read(i32 %47, i8* %63, i32 %60)
%65 = icmp slt i32 %64, %60
br i1 %65, label %66, label %71
66: ; preds = %59
%67 = load i32, i32* @stderr
%68 = sext i32 %67 to i64
%69 = inttoptr i64 %68 to i32*
%70 = call i64 @fwrite(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i64 21, i64 1, i32* %69)
br label %91
71: ; preds = %59
%72 = icmp sgt i32 %62, %60
br i1 %72, label %73, label %78
73: ; preds = %71
%74 = sext i32 %60 to i64
%75 = getelementptr inbounds i8, i8* %63, i64 %74
%76 = sub nsw i32 %62, %60
%77 = call i32 @memset(i8* %75, i32 0, i32 %76)
br label %78
78: ; preds = %73, %71
%79 = call i8* @strchr(i8* dereferenceable(1) %45, i8 signext 46)
%80 = icmp eq i8* %79, null
br i1 %80, label %82, label %81
81: ; preds = %78
store i8 0, i8* %79
br label %82
82: ; preds = %81, %78
%83 = call i32 @write_cfile(i8* %63, i32 %62, i32* %17, i8* %45)
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %45, i32 %62)
%85 = call i32 @close(i32 %47)
%86 = add nuw nsw i64 %42, 1
%87 = icmp eq i64 %86, %40
br i1 %87, label %88, label %41
88: ; preds = %82
%89 = call i32 @fclose(i32* %17)
%90 = call i32 @fclose(i32* %26)
br label %91
91: ; preds = %49, %66, %88, %28, %19, %8
%92 = phi i32 [ 1, %8 ], [ 2, %19 ], [ 3, %28 ], [ 0, %88 ], [ 4, %49 ], [ 5, %66 ]
ret i32 %92
}