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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
size_t fread(unsigned char **, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(unsigned char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  if (argc < 4) {
    fprintf(stderr,
            "usage: %s [input] [output[.h]] [variable name]\n"
            "if output file exists, it will be overwritten.\n"
            "stdin and stdout supported; use - for input and/or output.\n",
            argv[0]);
    return 1;
  }
  FILE *in, *out;
  if (!strncmp(argv[1], "-", 1)) {
    in = stdin;
  } else if (!(in = fopen(argv[1], "r"))) {
    fprintf(stderr, "input: %s: error: %s\n", argv[1], strerror(errno));
    return 1;
  } else if (in) {
    fseek(in, 0, SEEK_END);
    if (!ftell(in)) {
      fprintf(stderr, "input: %s: error: %s\n", argv[1], "file is empty");
      return 1;
    }
    rewind(in);
  }
  if (!strncmp(argv[2], "-", 1)) {
    out = stdout;
  } else if (!(out = fopen(argv[2], "w+"))) {
    fprintf(stderr, "output: %s: error: %s\n", argv[2], strerror(errno));
    return 1;
  }
  unsigned char buf[1 << 8];
  memset(&buf, 0, sizeof(buf));
  fprintf(out, "\n%s %s[] = {", "uint8_t", argv[3]);
  size_t read, ctr;
  while (!feof(in)) {
    read = fread(&buf, 1, 1 << 8, in);
    ctr = 0;
    while (ctr < read) {
      if (!(ctr % (1 << 4))) {
        fputs("\n   ", out);
      } else if (!(ctr % (1 << 3))) {
        fputs(" ", out);
      }
      fprintf(out,
              " "
              "0x%02X"
              ",",
              buf[ctr++]);
    }
  }
  fputs("\n};\n\n", out);
  if (in != stdin) {
    fclose(in);
  }
  if (out != stdout) {
    fclose(out);
  }
  fprintf(stderr, "%s: conversion done\n", argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    120d <main+0x4d>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1574 <main+0x3b4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1242 <main+0x82>
mov    0x2daa(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1330 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12ba <main+0xfa>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x13c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x138(%rbp)
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1574 <main+0x3b4>
cmpq   $0x0,-0x18(%rbp)
je     1326 <main+0x166>
mov    -0x18(%rbp),%rdi
mov    0x2d18(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <ftell@plt>
cmp    $0x0,%eax
jne    131d <main+0x15d>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd9b(%rip),%rsi
lea    0xdaa(%rip),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1574 <main+0x3b4>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
jmp    132b <main+0x16b>
jmp    1330 <main+0x170>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1365 <main+0x1a5>
mov    0x2c67(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    13e2 <main+0x222>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd4e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    13dd <main+0x21d>
mov    0x2c42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x148(%rbp)
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x14c(%rbp),%edi
mov    -0x148(%rbp),%rdx
mov    %rax,%rcx
lea    0xcfb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1574 <main+0x3b4>
jmp    13e2 <main+0x222>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xcd2(%rip),%rsi
lea    0xcd8(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1436 <main+0x276>
jmp    1505 <main+0x345>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100,%edx
call   1040 <fread@plt>
mov    %rax,-0x128(%rbp)
movq   $0x0,-0x130(%rbp)
mov    -0x130(%rbp),%rax
cmp    -0x128(%rbp),%rax
jae    1500 <main+0x340>
mov    -0x130(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
jne    14a0 <main+0x2e0>
mov    -0x20(%rbp),%rsi
lea    0xc5b(%rip),%rdi
call   1070 <fputs@plt>
jmp    14ca <main+0x30a>
mov    -0x130(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    14c5 <main+0x305>
mov    -0x20(%rbp),%rsi
lea    0xc34(%rip),%rdi
call   1070 <fputs@plt>
jmp    14ca <main+0x30a>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movzbl -0x120(%rbp,%rax,1),%edx
ff
lea    0xc02(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1462 <main+0x2a2>
jmp    1418 <main+0x258>
mov    -0x20(%rbp),%rsi
lea    0xbef(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x18(%rbp),%rax
mov    0x2ac0(%rip),%rcx
cmp    (%rcx),%rax
je     1532 <main+0x372>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    0x2a83(%rip),%rcx
cmp    (%rcx),%rax
je     154f <main+0x38f>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a7a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xb9f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbp
cmp    $0x3,%edi
jg     1209 <main+0x39>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe03(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    146d <main+0x29d>
mov    0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     126b <main+0x9b>
mov    0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12ca <main+0xfa>
mov    %rax,%r15
mov    0x2da3(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r15,%rdi
call   10a0 <ftell@plt>
test   %eax,%eax
je     144b <main+0x27b>
mov    %r15,%rdi
call   1060 <rewind@plt>
jmp    1275 <main+0xa5>
mov    0x2d6e(%rip),%rax
mov    (%rax),%r15
mov    0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     12f9 <main+0x129>
mov    0x10(%rbp),%rdi
lea    0xe29(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1303 <main+0x133>
mov    0x2d23(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%rbp),%rbp
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xdfd(%rip),%rsi
jmp    12ec <main+0x11c>
mov    0x2cff(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rbp),%rbp
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xdb2(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
jmp    1466 <main+0x296>
mov    0x2cc0(%rip),%rax
mov    (%rax),%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    %rbp,0x8(%rsp)
mov    0x18(%rbp),%rcx
lea    0xdb8(%rip),%rsi
lea    0xdbe(%rip),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r15,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
je     13a8 <main+0x1d8>
lea    0xdb8(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    0x2c80(%rip),%rax
cmp    (%rax),%r15
je     136d <main+0x19d>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x2c4c(%rip),%rax
cmp    (%rax),%rbx
mov    0x8(%rsp),%rbp
je     1386 <main+0x1b6>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xd6b(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1472 <main+0x2a2>
lea    0xd42(%rip),%r13
lea    0xd40(%rip),%rbp
jmp    13d0 <main+0x200>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1340 <main+0x170>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x100,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     13c0 <main+0x1f0>
mov    %rax,%r14
xor    %r12d,%r12d
jmp    1430 <main+0x260>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
movzbl 0x10(%rsp,%r12,1),%edx
add    $0x1,%r12
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
cmp    %r12,%r14
je     13c0 <main+0x1f0>
test   $0xf,%r12b
je     1400 <main+0x230>
test   $0x7,%r12b
jne    1415 <main+0x245>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
jmp    1415 <main+0x245>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xc3f(%rip),%rsi
lea    0xc4e(%rip),%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [154 x i8] c"usage: %s [input] [output[.h]] [variable name]\0Aif output file exists, it will be overwritten.\0Astdin and stdout supported; use - for input and/or output.\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"input: %s: error: %s\0A\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.4 = [14 x i8] c"file is empty\00"
@stdout = global i32* null
@.str.5 = [3 x i8] c"w+\00"
@.str.6 = [23 x i8] c"output: %s: error: %s\0A\00"
@.str.7 = [13 x i8] c"\0A%s %s[] = {\00"
@.str.8 = [8 x i8] c"uint8_t\00"
@.str.9 = [5 x i8] c"\0A \00"
@.str.10 = [2 x i8] c" \00"
@.str.11 = [9 x i8] c" 0x%02X,\00"
@.str.12 = [6 x i8] c"\0A};\0A\0A\00"
@.str.13 = [21 x i8] c"%s: conversion done\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 [256 x i8]
%9 = alloca i64
%10 = alloca i64
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, 4
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %154
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strncmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = load i32*, i32** @stdin
store i32* %26, i32** %6
br label %62
27: ; preds = %19
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %31, i32** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %41, label %33
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %39)
store i32 1, i32* %3
br label %154
41: ; preds = %27
%42 = load i32*, i32** %6
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %60
44: ; preds = %41
%45 = load i32*, i32** %6
%46 = load i32, i32* @SEEK_END
%47 = call i32 @fseek(i32* %45, i32 0, i32 %46)
%48 = load i32*, i32** %6
%49 = call i32 @ftell(i32* %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %57, label %51
51: ; preds = %44
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %154
57: ; preds = %44
%58 = load i32*, i32** %6
%59 = call i32 @rewind(i32* %58)
br label %60
60: ; preds = %57, %41
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61, %25
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = call i32 @strncmp(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %62
%69 = load i32*, i32** @stdout
store i32* %69, i32** %7
br label %85
70: ; preds = %62
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %74, i32** %7
%75 = icmp ne i32* %74, null
br i1 %75, label %84, label %76
76: ; preds = %70
%77 = load i32, i32* @stderr
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 2
%80 = load i8*, i8** %79
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %80, i8* %82)
store i32 1, i32* %3
br label %154
84: ; preds = %70
br label %85
85: ; preds = %84, %68
%86 = bitcast [256 x i8]* %8 to i8**
%87 = call i32 @memset(i8** %86, i32 0, i32 256)
%88 = load i32*, i32** %7
%89 = ptrtoint i32* %88 to i32
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 3
%92 = load i8*, i8** %91
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %92)
br label %94
94: ; preds = %131, %85
%95 = load i32*, i32** %6
%96 = call i32 @feof(i32* %95)
%97 = icmp ne i32 %96, 0
%98 = xor i1 %97, true
br i1 %98, label %99, label %132
99: ; preds = %94
%100 = bitcast [256 x i8]* %8 to i8**
%101 = load i32*, i32** %6
%102 = call i64 @fread(i8** %100, i32 1, i32 256, i32* %101)
store i64 %102, i64* %9
store i64 0, i64* %10
br label %103
103: ; preds = %122, %99
%104 = load i64, i64* %10
%105 = load i64, i64* %9
%106 = icmp ult i64 %104, %105
br i1 %106, label %107, label %131
107: ; preds = %103
%108 = load i64, i64* %10
%109 = urem i64 %108, 16
%110 = icmp ne i64 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %107
%112 = load i32*, i32** %7
%113 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %112)
br label %122
114: ; preds = %107
%115 = load i64, i64* %10
%116 = urem i64 %115, 8
%117 = icmp ne i64 %116, 0
br i1 %117, label %121, label %118
118: ; preds = %114
%119 = load i32*, i32** %7
%120 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %119)
br label %121
121: ; preds = %118, %114
br label %122
122: ; preds = %121, %111
%123 = load i32*, i32** %7
%124 = ptrtoint i32* %123 to i32
%125 = load i64, i64* %10
%126 = add i64 %125, 1
store i64 %126, i64* %10
%127 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %125
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %129)
br label %103
131: ; preds = %103
br label %94
132: ; preds = %94
%133 = load i32*, i32** %7
%134 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i32* %133)
%135 = load i32*, i32** %6
%136 = load i32*, i32** @stdin
%137 = icmp ne i32* %135, %136
br i1 %137, label %138, label %141
138: ; preds = %132
%139 = load i32*, i32** %6
%140 = call i32 @fclose(i32* %139)
br label %141
141: ; preds = %138, %132
%142 = load i32*, i32** %7
%143 = load i32*, i32** @stdout
%144 = icmp ne i32* %142, %143
br i1 %144, label %145, label %148
145: ; preds = %141
%146 = load i32*, i32** %7
%147 = call i32 @fclose(i32* %146)
br label %148
148: ; preds = %145, %141
%149 = load i32, i32* @stderr
%150 = load i8**, i8*** %5
%151 = getelementptr inbounds i8*, i8** %150, i64 0
%152 = load i8*, i8** %151
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i8* %152)
store i32 0, i32* %3
br label %154
154: ; preds = %148, %76, %51, %33, %13
%155 = load i32, i32* %3
ret i32 %155
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [154 x i8] c"usage: %s [input] [output[.h]] [variable name]\0Aif output file exists, it will be overwritten.\0Astdin and stdout supported; use - for input and/or output.\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"input: %s: error: %s\0A\00"
@errno = global i32 0
@SEEK_END = global i32 0
@.str.4 = [14 x i8] c"file is empty\00"
@stdout = global i32* null
@.str.5 = [3 x i8] c"w+\00"
@.str.6 = [23 x i8] c"output: %s: error: %s\0A\00"
@.str.7 = [13 x i8] c"\0A%s %s[] = {\00"
@.str.8 = [8 x i8] c"uint8_t\00"
@.str.9 = [5 x i8] c"\0A \00"
@.str.11 = [9 x i8] c" 0x%02X,\00"
@.str.12 = [6 x i8] c"\0A};\0A\0A\00"
@.str.13 = [21 x i8] c"%s: conversion done\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = icmp slt i32 %0, 4
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %106
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strncmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = load i32*, i32** @stdin
br label %37
16: ; preds = %9
%17 = load i8*, i8** %10
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %10
%23 = load i32, i32* @errno
%24 = tail call i8* @strerror(i32 %23)
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %22, i8* %24)
br label %106
26: ; preds = %16
%27 = load i32, i32* @SEEK_END
%28 = tail call i32 @fseek(i32* %18, i32 0, i32 %27)
%29 = tail call i32 @ftell(i32* %18)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %10
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %106
35: ; preds = %26
%36 = tail call i32 @rewind(i32* %18)
br label %37
37: ; preds = %35, %14
%38 = phi i32* [ %18, %35 ], [ %15, %14 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 2
%40 = load i8*, i8** %39
%41 = tail call i32 @strncmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = load i32*, i32** @stdout
br label %55
45: ; preds = %37
%46 = load i8*, i8** %39
%47 = tail call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %39
%52 = load i32, i32* @errno
%53 = tail call i8* @strerror(i32 %52)
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %51, i8* %53)
br label %106
55: ; preds = %45, %43
%56 = phi i32* [ %47, %45 ], [ %44, %43 ]
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%58 = bitcast [256 x i8]* %3 to i8**
%59 = call i32 @memset(i8** %58, i32 0, i32 256)
%60 = ptrtoint i32* %56 to i64
%61 = trunc i64 %60 to i32
%62 = getelementptr inbounds i8*, i8** %1, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %63)
%65 = call i32 @feof(i32* %38)
%66 = icmp eq i32 %65, 0
br i1 %66, label %70, label %91
67: ; preds = %84, %70
%68 = call i32 @feof(i32* %38)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %91
70: ; preds = %55, %67
%71 = call i64 @fread(i8** %58, i32 1, i32 256, i32* %38)
%72 = icmp eq i64 %71, 0
br i1 %72, label %67, label %73
73: ; preds = %70, %84
%74 = phi i64 [ %85, %84 ], [ 0, %70 ]
%75 = and i64 %74, 15
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i64 4, i64 1, i32* %56)
br label %84
79: ; preds = %73
%80 = and i64 %74, 7
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 @fputc(i32 32, i32* %56)
br label %84
84: ; preds = %79, %82, %77
%85 = add nuw i64 %74, 1
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %74
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %88)
%90 = icmp eq i64 %85, %71
br i1 %90, label %67, label %73
91: ; preds = %67, %55
%92 = call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i64 5, i64 1, i32* %56)
%93 = load i32*, i32** @stdin
%94 = icmp eq i32* %38, %93
br i1 %94, label %97, label %95
95: ; preds = %91
%96 = call i32 @fclose(i32* %38)
br label %97
97: ; preds = %95, %91
%98 = load i32*, i32** @stdout
%99 = icmp eq i32* %56, %98
br i1 %99, label %102, label %100
100: ; preds = %97
%101 = call i32 @fclose(i32* %56)
br label %102
102: ; preds = %100, %97
%103 = load i32, i32* @stderr
%104 = load i8*, i8** %1
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i8* %104)
br label %106
106: ; preds = %20, %31, %49, %102, %5
%107 = phi i32 [ 1, %5 ], [ 0, %102 ], [ 1, %49 ], [ 1, %31 ], [ 1, %20 ]
ret i32 %107
}