#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 */
struct stat {
  long st_size;
  int /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(long);
int /*<<< orphan*/ printf(char *, ...);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  FILE *f;
  struct stat s;
  unsigned char *buf, *ptr;
  const char *output;
  long i, j;
  if (argc != 2 && argc != 3) {
    printf("Usage: mk_header <input> [output]\n"
           "Default output file is \"output.h\"\n");
    return 1;
  }
  if (stat(argv[1], &s) == -1 || !S_ISREG(s.st_mode)) {
    printf("Couldn't stat %s\n", argv[1]);
    return 1;
  }
  if (s.st_size == 0) {
    printf("%s is an empty file\n", argv[1]);
    return 1;
  }
  buf = (unsigned char *)malloc(s.st_size);
  if (buf == NULL) {
    printf("Couldn't malloc %ld bytes\n", (long)s.st_size);
    return 1;
  }
  f = fopen(argv[1], "rb");
  if (f == NULL) {
    printf("Couldn't open %s\n", argv[1]);
    return 1;
  }
  if (fread(buf, 1, s.st_size, f) != (size_t)s.st_size) {
    fclose(f);
    free(buf);
    printf("Error reading %s\n", argv[1]);
    return 1;
  }
  fclose(f);
  output = (argc == 3) ? argv[2] : "output.h";
  f = fopen(output, "wb");
  if (!f) {
    free(buf);
    printf("Couldn't open %s\n", output);
    return 1;
  }
  for (i = 0, j = 0, ptr = buf; i < s.st_size; ++i) {
    fprintf(f, "0x%02x", *ptr++);
    if (i == s.st_size - 1)
      break;
    fprintf(f, ",");
    if (++j < 16)
      fprintf(f, " ");
    else {
      j = 0;
      fprintf(f, "\n");
    }
  }
  fprintf(f, "\n");
  fclose(f);
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d4 <main+0x44>
cmpl   $0x3,-0x8(%rbp)
je     11d4 <main+0x44>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0xffffffff,%eax
je     11ff <main+0x6f>
mov    -0x20(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%eax
jne    1221 <main+0x91>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
cmpq   $0x0,-0x28(%rbp)
jne    124e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
mov    -0x28(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1284 <main+0xf4>
mov    -0x28(%rbp),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12c9 <main+0x139>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    -0x28(%rbp),%rax
je     131d <main+0x18d>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x3,-0x8(%rbp)
jne    1341 <main+0x1b1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1351 <main+0x1c1>
lea    0xd66(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    1351 <main+0x1c1>
mov    -0x58(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xd53(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    139f <main+0x20f>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rsi
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    149d <main+0x30d>
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    1472 <main+0x2e2>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movzbl (%rax),%edx
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jne    1403 <main+0x273>
jmp    1472 <main+0x2e2>
mov    -0x18(%rbp),%rdi
lea    0xcb3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
cmp    $0x10,%rax
jge    1442 <main+0x2b2>
mov    -0x18(%rbp),%rdi
lea    0xc8d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    145c <main+0x2cc>
movq   $0x0,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xbee(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1461 <main+0x2d1>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    13b7 <main+0x227>
mov    -0x18(%rbp),%rdi
lea    0xbc6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    126d <main+0xbd>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
cmp    $0xffffffff,%eax
je     127b <main+0xcb>
mov    0x10(%rsp),%edi
call   10b0 <S_ISREG@plt>
test   %eax,%eax
je     127b <main+0xcb>
mov    0x8(%rsp),%r15
test   %r15,%r15
je     12a5 <main+0xf5>
mov    %r15,%rdi
call   10c0 <malloc@plt>
test   %rax,%rax
je     12b2 <main+0x102>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe1c(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12be <main+0x10e>
mov    %rax,%r13
mov    $0x1,%r12d
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1050 <fread@plt>
mov    %rax,(%rsp)
mov    %r13,%rdi
call   1060 <fclose@plt>
cmp    %r15,(%rsp)
jne    12cb <main+0x11b>
cmp    $0x3,%ebp
jne    12e3 <main+0x133>
mov    0x10(%rbx),%rbp
jmp    12ea <main+0x13a>
lea    0xe08(%rip),%rdi
call   1040 <puts@plt>
jmp    128d <main+0xdd>
mov    0x8(%rbx),%rsi
lea    0xd7a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rsi
lea    0xd62(%rip),%rdi
jmp    1286 <main+0xd6>
lea    0xd6e(%rip),%rdi
mov    %r15,%rsi
jmp    1286 <main+0xd6>
mov    0x8(%rbx),%rsi
lea    0xd7c(%rip),%rdi
jmp    1286 <main+0xd6>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rsi
lea    0xd79(%rip),%rdi
jmp    13b9 <main+0x209>
lea    0xd7f(%rip),%rbp
lea    0xd81(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13a7 <main+0x1f7>
mov    %rax,%rbx
test   %r15,%r15
jle    1382 <main+0x1d2>
movzbl (%r14),%edx
lea    0xd60(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <fprintf@plt>
cmp    $0x1,%r15
je     1382 <main+0x1d2>
mov    $0x1,%ebp
xor    %r13d,%r13d
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
lea    0x1(%r13),%r12
cmp    $0xf,%r13
mov    $0xa,%edi
mov    $0x20,%eax
cmovl  %eax,%edi
mov    $0x0,%eax
cmovge %rax,%r12
mov    %rbx,%rsi
call   1080 <fputc@plt>
movzbl (%r14,%rbp,1),%edx
mov    %rbx,%rdi
lea    0xd06(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
add    $0x1,%rbp
mov    %r12,%r13
cmp    %rbp,%r15
jne    132d <main+0x17d>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
jmp    1293 <main+0xe3>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xc8f(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1293 <main+0xe3>

LLVM IR (-O0):
%struct.stat = type { i64, i32 }
@.str = [69 x i8] c"Usage: mk_header <input> [output]\0ADefault output file is \22output.h\22\0A\00"
@.str.1 = [18 x i8] c"Couldn't stat %s\0A\00"
@.str.2 = [21 x i8] c"%s is an empty file\0A\00"
@.str.3 = [27 x i8] c"Couldn't malloc %ld bytes\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.6 = [18 x i8] c"Error reading %s\0A\00"
@.str.7 = [9 x i8] c"output.h\00"
@.str.8 = [3 x i8] c"wb\00"
@.str.9 = [7 x i8] c"0x%02x\00"
@.str.10 = [2 x i8] c",\00"
@.str.11 = [2 x i8] c" \00"
@.str.12 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.stat
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %150
20: ; preds = %15, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @stat(i8* %23, %struct.stat* %7)
%25 = icmp eq i32 %24, -1
br i1 %25, label %31, label %26
26: ; preds = %20
%27 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%28 = load i32, i32* %27
%29 = call i32 @S_ISREG(i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %26, %20
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %150
36: ; preds = %26
%37 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %43)
store i32 1, i32* %3
br label %150
45: ; preds = %36
%46 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%47 = load i64, i64* %46
%48 = call i64 @malloc(i64 %47)
%49 = inttoptr i64 %48 to i8*
store i8* %49, i8** %8
%50 = load i8*, i8** %8
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %56
52: ; preds = %45
%53 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%54 = load i64, i64* %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %54)
store i32 1, i32* %3
br label %150
56: ; preds = %45
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %60, i32** %6
%61 = load i32*, i32** %6
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %68
63: ; preds = %56
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %66)
store i32 1, i32* %3
br label %150
68: ; preds = %56
%69 = load i8*, i8** %8
%70 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%71 = load i64, i64* %70
%72 = load i32*, i32** %6
%73 = call i64 @fread(i8* %69, i32 1, i64 %71, i32* %72)
%74 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%75 = load i64, i64* %74
%76 = icmp ne i64 %73, %75
br i1 %76, label %77, label %86
77: ; preds = %68
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
%80 = load i8*, i8** %8
%81 = call i32 @free(i8* %80)
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 1
%84 = load i8*, i8** %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %84)
store i32 1, i32* %3
br label %150
86: ; preds = %68
%87 = load i32*, i32** %6
%88 = call i32 @fclose(i32* %87)
%89 = load i32, i32* %4
%90 = icmp eq i32 %89, 3
br i1 %90, label %91, label %95
91: ; preds = %86
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 2
%94 = load i8*, i8** %93
br label %96
95: ; preds = %86
br label %96
96: ; preds = %95, %91
%97 = phi i8* [ %94, %91 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %95 ]
store i8* %97, i8** %10
%98 = load i8*, i8** %10
%99 = call i32* @fopen(i8* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %99, i32** %6
%100 = load i32*, i32** %6
%101 = icmp ne i32* %100, null
br i1 %101, label %107, label %102
102: ; preds = %96
%103 = load i8*, i8** %8
%104 = call i32 @free(i8* %103)
%105 = load i8*, i8** %10
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %105)
store i32 1, i32* %3
br label %150
107: ; preds = %96
store i64 0, i64* %11
store i64 0, i64* %12
%108 = load i8*, i8** %8
store i8* %108, i8** %9
br label %109
109: ; preds = %140, %107
%110 = load i64, i64* %11
%111 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%112 = load i64, i64* %111
%113 = icmp slt i64 %110, %112
br i1 %113, label %114, label %143
114: ; preds = %109
%115 = load i32*, i32** %6
%116 = load i8*, i8** %9
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %9
%118 = load i8, i8* %116
%119 = zext i8 %118 to i32
%120 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %119)
%121 = load i64, i64* %11
%122 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%123 = load i64, i64* %122
%124 = sub nsw i64 %123, 1
%125 = icmp eq i64 %121, %124
br i1 %125, label %126, label %127
126: ; preds = %114
br label %143
127: ; preds = %114
%128 = load i32*, i32** %6
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%130 = load i64, i64* %12
%131 = add nsw i64 %130, 1
store i64 %131, i64* %12
%132 = icmp slt i64 %131, 16
br i1 %132, label %133, label %136
133: ; preds = %127
%134 = load i32*, i32** %6
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %139
136: ; preds = %127
store i64 0, i64* %12
%137 = load i32*, i32** %6
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %139
139: ; preds = %136, %133
br label %140
140: ; preds = %139
%141 = load i64, i64* %11
%142 = add nsw i64 %141, 1
store i64 %142, i64* %11
br label %109
143: ; preds = %126, %109
%144 = load i32*, i32** %6
%145 = call i32 (i32*, i8*, ...) @fprintf(i32* %144, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%146 = load i32*, i32** %6
%147 = call i32 @fclose(i32* %146)
%148 = load i8*, i8** %8
%149 = call i32 @free(i8* %148)
store i32 0, i32* %3
br label %150
150: ; preds = %143, %102, %77, %63, %52, %40, %31, %18
%151 = load i32, i32* %3
ret i32 %151
}

LLVM IR (-O2):
%struct.stat = type { i64, i32 }
@.str.1 = [18 x i8] c"Couldn't stat %s\0A\00"
@.str.2 = [21 x i8] c"%s is an empty file\0A\00"
@.str.3 = [27 x i8] c"Couldn't malloc %ld bytes\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.6 = [18 x i8] c"Error reading %s\0A\00"
@.str.7 = [9 x i8] c"output.h\00"
@.str.8 = [3 x i8] c"wb\00"
@.str.9 = [7 x i8] c"0x%02x\00"
@str = [68 x i8] c"Usage: mk_header <input> [output]\0ADefault output file is \22output.h\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = and i32 %0, -2
%6 = icmp eq i32 %5, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
br label %90
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @stat(i8* %11, %struct.stat* %3)
%13 = icmp eq i32 %12, -1
br i1 %13, label %19, label %14
14: ; preds = %9
%15 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%16 = load i32, i32* %15
%17 = tail call i32 @S_ISREG(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14, %9
%20 = load i8*, i8** %10
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %90
22: ; preds = %14
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%24 = load i64, i64* %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8*, i8** %10
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %90
29: ; preds = %22
%30 = tail call i64 @malloc(i64 %24)
%31 = inttoptr i64 %30 to i8*
%32 = icmp eq i64 %30, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i64 %24)
br label %90
35: ; preds = %29
%36 = load i8*, i8** %10
%37 = tail call i32* @fopen(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i8*, i8** %10
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %90
42: ; preds = %35
%43 = tail call i64 @fread(i8* %31, i32 1, i64 %24, i32* %37)
%44 = icmp eq i64 %43, %24
%45 = tail call i32 @fclose(i32* %37)
br i1 %44, label %50, label %46
46: ; preds = %42
%47 = tail call i32 @free(i8* %31)
%48 = load i8*, i8** %10
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %48)
br label %90
50: ; preds = %42
%51 = icmp eq i32 %0, 3
br i1 %51, label %52, label %55
52: ; preds = %50
%53 = getelementptr inbounds i8*, i8** %1, i64 2
%54 = load i8*, i8** %53
br label %55
55: ; preds = %50, %52
%56 = phi i8* [ %54, %52 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %50 ]
%57 = tail call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%58 = icmp eq i32* %57, null
br i1 %58, label %67, label %59
59: ; preds = %55
%60 = icmp sgt i64 %24, 0
br i1 %60, label %61, label %86
61: ; preds = %59
%62 = add nsw i64 %24, -1
%63 = load i8, i8* %31
%64 = zext i8 %63 to i32
%65 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %64)
%66 = icmp eq i64 %62, 0
br i1 %66, label %86, label %70
67: ; preds = %55
%68 = tail call i32 @free(i8* %31)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %56)
br label %90
70: ; preds = %61, %70
%71 = phi i8* [ %74, %70 ], [ %31, %61 ]
%72 = phi i64 [ %81, %70 ], [ 0, %61 ]
%73 = phi i64 [ %79, %70 ], [ 0, %61 ]
%74 = getelementptr inbounds i8, i8* %71, i64 1
%75 = tail call i32 @fputc(i32 44, i32* %57)
%76 = icmp slt i64 %73, 15
%77 = add nsw i64 %73, 1
%78 = select i1 %76, i32 32, i32 10
%79 = select i1 %76, i64 %77, i64 0
%80 = tail call i32 @fputc(i32 %78, i32* %57)
%81 = add nuw nsw i64 %72, 1
%82 = load i8, i8* %74
%83 = zext i8 %82 to i32
%84 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %83)
%85 = icmp eq i64 %81, %62
br i1 %85, label %86, label %70
86: ; preds = %70, %61, %59
%87 = tail call i32 @fputc(i32 10, i32* %57)
%88 = tail call i32 @fclose(i32* %57)
%89 = tail call i32 @free(i8* %31)
br label %90
90: ; preds = %86, %67, %46, %39, %33, %26, %19, %7
%91 = phi i32 [ 1, %7 ], [ 1, %19 ], [ 1, %26 ], [ 1, %33 ], [ 1, %39 ], [ 1, %46 ], [ 0, %86 ], [ 1, %67 ]
ret i32 %91
}