#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 */
char EOF;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ isprint(char);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
size_t strcspn(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  int i, j, len, res, total;
  char **inputs, chr, chrhex[10], buf[1024], filename[65535];
  FILE *f = NULL, *out;
  if (argc < 3) {
    fprintf(stderr, "usage: %s [inputfile ...] [outputfile.h]\n", argv[0]);
    return -1;
  }
  out = fopen(argv[argc - 1], "ab");
  if (!out) {
    perror(argv[argc - 1]);
    return -1;
  }
  inputs = (char **)calloc(1, sizeof(char *) * argc);
  for (i = 1; i < argc - 1; i++) {
    strcpy(filename, argv[i]);
    f = fopen(filename, "r");
    perror(filename);
    if (!f)
      continue;
    while (strcspn(filename, "/") < strlen(filename)) {
      j = strlen(filename) - strcspn(filename, "/") - 1;
      memmove(filename, &filename[strcspn(filename, "/") + 1], j);
      filename[j] = '\0';
    }
    while (strcspn(filename, ".") < strlen(filename))
      filename[strcspn(filename, ".")] = '_';
    sprintf(buf, "char %s[] = { ", filename);
    total = 0;
    len = strlen(buf);
    while ((res = fwrite(buf + total, 1, len - total, out)) < (len - total) &&
           (res > 0))
      total += res;
    while ((chr = fgetc(f)) != EOF) {
      if (isprint(chr) && (chr != '%') && (chr != '\\') && (chr != '\''))
        sprintf(chrhex, "\'%c\', ", chr);
      else
        sprintf(chrhex, "\'\\x%02X\', ", chr);
      len = strlen(chrhex);
      while (fwrite(chrhex, 1, strlen(chrhex), out) == 0)
        perror("chrhex");
    }
    sprintf(buf, "0 };\n\n");
    total = 0;
    len = strlen(buf);
    while ((res = fwrite(buf + total, 1, len - total, out)) < (len - total) &&
           (res > 0))
      total += res;
    fclose(f);
  }
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x10448(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1226 <main+0x56>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdeb(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1679 <main+0x4a9>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdec(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10450(%rbp)
cmpq   $0x0,-0x10450(%rbp)
jne    127a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1679 <main+0x4a9>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
mov    $0x1,%edi
call   1080 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1666 <main+0x496>
lea    -0x10440(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
lea    -0x10440(%rbp),%rdi
lea    0xd5d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10448(%rbp)
lea    -0x10440(%rbp),%rdi
call   10d0 <perror@plt>
cmpq   $0x0,-0x10448(%rbp)
jne    12fb <main+0x12b>
jmp    1658 <main+0x488>
jmp    1300 <main+0x130>
lea    -0x10440(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,-0x10458(%rbp)
lea    -0x10440(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x10458(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    13c6 <main+0x1f6>
lea    -0x10440(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x10468(%rbp)
lea    -0x10440(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,%rcx
mov    -0x10468(%rbp),%rax
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x18(%rbp)
lea    -0x10440(%rbp),%rax
mov    %rax,-0x10460(%rbp)
lea    -0x10440(%rbp),%rdi
lea    0xc9c(%rip),%rsi
call   1070 <strcspn@plt>
mov    -0x10460(%rbp),%rdi
add    $0x1,%rax
lea    -0x10440(%rbp),%rsi
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   10b0 <memmove@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x10440(%rbp,%rax,1)
jmp    1300 <main+0x130>
jmp    13cb <main+0x1fb>
lea    -0x10440(%rbp),%rdi
lea    0xc58(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,-0x10470(%rbp)
lea    -0x10440(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x10470(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    1426 <main+0x256>
lea    -0x10440(%rbp),%rdi
lea    0xc1d(%rip),%rsi
call   1070 <strcspn@plt>
movb   $0x5f,-0x10440(%rbp,%rax,1)
5f
jmp    13cb <main+0x1fb>
lea    -0x440(%rbp),%rdi
lea    -0x10440(%rbp),%rdx
lea    0xbf8(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
movl   $0x0,-0x24(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x440(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%edx
sub    -0x24(%rbp),%edx
mov    -0x10450(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%edx
sub    -0x24(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x10471(%rbp)
jge    14a5 <main+0x2d5>
cmpl   $0x0,-0x20(%rbp)
setg   %al
mov    %al,-0x10471(%rbp)
mov    -0x10471(%rbp),%al
test   $0x1,%al
jne    14b8 <main+0x2e8>
jmp    14c6 <main+0x2f6>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1458 <main+0x288>
jmp    14cb <main+0x2fb>
mov    -0x10448(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%eax
mov    0x2b04(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     15b3 <main+0x3e3>
movsbl -0x31(%rbp),%edi
call   10a0 <isprint@plt>
cmp    $0x0,%rax
je     1544 <main+0x374>
movsbl -0x31(%rbp),%eax
cmp    $0x25,%eax
je     1544 <main+0x374>
movsbl -0x31(%rbp),%eax
cmp    $0x5c,%eax
je     1544 <main+0x374>
movsbl -0x31(%rbp),%eax
cmp    $0x27,%eax
je     1544 <main+0x374>
lea    -0x3b(%rbp),%rdi
movsbl -0x31(%rbp),%edx
lea    0xb0a(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
jmp    155a <main+0x38a>
lea    -0x3b(%rbp),%rdi
movsbl -0x31(%rbp),%edx
lea    0xaf6(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
lea    -0x3b(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x3b(%rbp),%rax
mov    %rax,-0x10480(%rbp)
lea    -0x3b(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x10480(%rbp),%rdi
mov    %eax,%edx
mov    -0x10450(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
cmp    $0x0,%eax
jne    15ae <main+0x3de>
lea    0xab0(%rip),%rdi
call   10d0 <perror@plt>
jmp    1566 <main+0x396>
jmp    14cb <main+0x2fb>
lea    -0x440(%rbp),%rdi
lea    0xa9a(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
movl   $0x0,-0x24(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x440(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%edx
sub    -0x24(%rbp),%edx
mov    -0x10450(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%edx
sub    -0x24(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x10481(%rbp)
jge    162b <main+0x45b>
cmpl   $0x0,-0x20(%rbp)
setg   %al
mov    %al,-0x10481(%rbp)
mov    -0x10481(%rbp),%al
test   $0x1,%al
jne    163e <main+0x46e>
jmp    164c <main+0x47c>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    15de <main+0x40e>
mov    -0x10448(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1299 <main+0xc9>
mov    -0x10450(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10438,%rsp
mov    %rsi,%r13
cmp    $0x2,%edi
jg     120c <main+0x3c>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0xe03(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    14e5 <main+0x315>
mov    %edi,%ebp
lea    -0x1(%rbp),%eax
mov    %rax,0x8(%rsp)
mov    0x0(%r13,%rax,8),%rdi
lea    0xe08(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14f7 <main+0x327>
mov    %rax,%r14
shl    $0x3,%ebp
mov    $0x1,%edi
mov    %ebp,%esi
call   1080 <calloc@plt>
mov    $0x1,%ebp
lea    0x430(%rsp),%r15
lea    0x26(%rsp),%r12
mov    %r13,0x10(%rsp)
mov    0x0(%r13,%rbp,8),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
lea    0xdbd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   10d0 <perror@plt>
mov    %rbx,(%rsp)
test   %rbx,%rbx
je     14cc <main+0x2fc>
mov    %rbp,0x18(%rsp)
mov    %r15,%rdi
lea    0xd93(%rip),%r13
mov    %r13,%rsi
call   1070 <strcspn@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jae    1315 <main+0x145>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <strcspn@plt>
lea    (%rax,%r15,1),%rsi
add    $0x1,%rsi
mov    %eax,%ebx
not    %ebx
add    %ebp,%ebx
mov    %r15,%rdi
mov    %ebx,%edx
call   10b0 <memmove@plt>
movslq %ebx,%rax
movb   $0x0,0x430(%rsp,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <strcspn@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jb     12c0 <main+0xf0>
mov    %r15,%rdi
lea    0xd12(%rip),%rbp
nop
mov    %rbp,%rsi
call   1070 <strcspn@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jae    1360 <main+0x190>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strcspn@plt>
movb   $0x5f,0x430(%rsp,%rax,1)
5f
mov    %r15,%rdi
jmp    1320 <main+0x150>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
lea    0xcc2(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
cs nopw 0x0(%rax,%rax,1)
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
mov    %r13d,%ebx
sub    %eax,%ebx
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
cmp    %ebx,%eax
jge    13b9 <main+0x1e9>
add    %eax,%ebp
test   %eax,%eax
jg     1390 <main+0x1c0>
mov    (%rsp),%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
mov    0x2c1d(%rip),%rbx
jmp    13db <main+0x20b>
nopl   (%rax)
mov    (%rsp),%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
cmp    (%rbx),%al
je     1470 <main+0x2a0>
movsbl %bpl,%r13d
mov    %r13d,%edi
call   10a0 <isprint@plt>
test   %rax,%rax
je     1420 <main+0x250>
add    $0xdb,%bpl
lea    0xc43(%rip),%rsi
cmp    $0x37,%bpl
ja     1427 <main+0x257>
movzbl %bpl,%eax
movabs $0x80000000000005,%rcx
bt     %rax,%rcx
lea    0xc24(%rip),%rsi
jae    1427 <main+0x257>
lea    0xc22(%rip),%rsi
mov    %r12,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
test   %eax,%eax
jne    13d0 <main+0x200>
lea    0xbef(%rip),%rdi
call   10d0 <perror@plt>
jmp    143c <main+0x26c>
nopl   0x0(%rax)
movl   $0xa0a3b,0x33(%rsp)
movl   $0x3b7d2030,0x30(%rsp)
3b
lea    0x30(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
xor    %ebp,%ebp
nop
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x30,%rdi
mov    %r13d,%ebx
sub    %eax,%ebx
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
cmp    %ebx,%eax
jge    14b9 <main+0x2e9>
add    %eax,%ebp
test   %eax,%eax
jg     1490 <main+0x2c0>
mov    (%rsp),%rdi
call   1040 <fclose@plt>
mov    0x10(%rsp),%r13
mov    0x18(%rsp),%rbp
add    $0x1,%rbp
cmp    0x8(%rsp),%rbp
jne    1259 <main+0x89>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x10438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rax
mov    0x0(%r13,%rax,8),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%eax
jmp    14e5 <main+0x315>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"usage: %s [inputfile ...] [outputfile.h]\0A\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [15 x i8] c"char %s[] = { \00"
@EOF = global i8 0
@.str.6 = [7 x i8] c"'%c', \00"
@.str.7 = [11 x i8] c"'\\x%02X', \00"
@.str.8 = [7 x i8] c"chrhex\00"
@.str.9 = [7 x i8] c"0 };\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 i32
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i8
%13 = alloca [10 x i8]
%14 = alloca [1024 x i8]
%15 = alloca [65535 x i8]
%16 = alloca i32*
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %16
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 -1, i32* %3
br label %223
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %17
%34 = load i32*, i32** %17
%35 = icmp ne i32* %34, null
br i1 %35, label %44, label %36
36: ; preds = %26
%37 = load i8**, i8*** %5
%38 = load i32, i32* %4
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @perror(i8* %42)
store i32 -1, i32* %3
br label %223
44: ; preds = %26
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = mul i64 8, %46
%48 = trunc i64 %47 to i32
%49 = call i64 @calloc(i32 1, i32 %48)
%50 = inttoptr i64 %49 to i8**
store i8** %50, i8*** %11
store i32 1, i32* %6
br label %51
51: ; preds = %217, %44
%52 = load i32, i32* %6
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 1
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %220
56: ; preds = %51
%57 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%58 = load i8**, i8*** %5
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %58, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @strcpy(i8* %57, i8* %62)
%64 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %65, i32** %16
%66 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%67 = call i32 @perror(i8* %66)
%68 = load i32*, i32** %16
%69 = icmp ne i32* %68, null
br i1 %69, label %71, label %70
70: ; preds = %56
br label %217
71: ; preds = %56
br label %72
72: ; preds = %79, %71
%73 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%74 = call i64 @strcspn(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%75 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = sext i32 %76 to i64
%78 = icmp ult i64 %74, %77
br i1 %78, label %79, label %98
79: ; preds = %72
%80 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%81 = call i32 @strlen(i8* %80)
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%84 = call i64 @strcspn(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%85 = sub i64 %82, %84
%86 = sub i64 %85, 1
%87 = trunc i64 %86 to i32
store i32 %87, i32* %7
%88 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%89 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%90 = call i64 @strcspn(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%91 = add i64 %90, 1
%92 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 %91
%93 = load i32, i32* %7
%94 = call i32 @memmove(i8* %88, i8* %92, i32 %93)
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 %96
store i8 0, i8* %97
br label %72
98: ; preds = %72
br label %99
99: ; preds = %106, %98
%100 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%101 = call i64 @strcspn(i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%102 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%103 = call i32 @strlen(i8* %102)
%104 = sext i32 %103 to i64
%105 = icmp ult i64 %101, %104
br i1 %105, label %106, label %110
106: ; preds = %99
%107 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%108 = call i64 @strcspn(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%109 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 %108
store i8 95, i8* %109
br label %99
110: ; preds = %99
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%112 = getelementptr inbounds [65535 x i8], [65535 x i8]* %15, i64 0, i64 0
%113 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %112)
store i32 0, i32* %10
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%115 = call i32 @strlen(i8* %114)
store i32 %115, i32* %8
br label %116
116: ; preds = %135, %110
%117 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%118 = load i32, i32* %10
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
%121 = load i32, i32* %8
%122 = load i32, i32* %10
%123 = sub nsw i32 %121, %122
%124 = load i32*, i32** %17
%125 = call i32 @fwrite(i8* %120, i32 1, i32 %123, i32* %124)
store i32 %125, i32* %9
%126 = load i32, i32* %8
%127 = load i32, i32* %10
%128 = sub nsw i32 %126, %127
%129 = icmp slt i32 %125, %128
br i1 %129, label %130, label %133
130: ; preds = %116
%131 = load i32, i32* %9
%132 = icmp sgt i32 %131, 0
br label %133
133: ; preds = %130, %116
%134 = phi i1 [ false, %116 ], [ %132, %130 ]
br i1 %134, label %135, label %139
135: ; preds = %133
%136 = load i32, i32* %9
%137 = load i32, i32* %10
%138 = add nsw i32 %137, %136
store i32 %138, i32* %10
br label %116
139: ; preds = %133
br label %140
140: ; preds = %185, %139
%141 = load i32*, i32** %16
%142 = call signext i8 @fgetc(i32* %141)
store i8 %142, i8* %12
%143 = sext i8 %142 to i32
%144 = load i8, i8* @EOF
%145 = sext i8 %144 to i32
%146 = icmp ne i32 %143, %145
br i1 %146, label %147, label %186
147: ; preds = %140
%148 = load i8, i8* %12
%149 = call i64 @isprint(i8 signext %148)
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %168
151: ; preds = %147
%152 = load i8, i8* %12
%153 = sext i8 %152 to i32
%154 = icmp ne i32 %153, 37
br i1 %154, label %155, label %168
155: ; preds = %151
%156 = load i8, i8* %12
%157 = sext i8 %156 to i32
%158 = icmp ne i32 %157, 92
br i1 %158, label %159, label %168
159: ; preds = %155
%160 = load i8, i8* %12
%161 = sext i8 %160 to i32
%162 = icmp ne i32 %161, 39
br i1 %162, label %163, label %168
163: ; preds = %159
%164 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%165 = load i8, i8* %12
%166 = sext i8 %165 to i32
%167 = call i32 (i8*, i8*, ...) @sprintf(i8* %164, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %166)
br label %173
168: ; preds = %159, %155, %151, %147
%169 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%170 = load i8, i8* %12
%171 = sext i8 %170 to i32
%172 = call i32 (i8*, i8*, ...) @sprintf(i8* %169, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %171)
br label %173
173: ; preds = %168, %163
%174 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%175 = call i32 @strlen(i8* %174)
store i32 %175, i32* %8
br label %176
176: ; preds = %183, %173
%177 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%178 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%179 = call i32 @strlen(i8* %178)
%180 = load i32*, i32** %17
%181 = call i32 @fwrite(i8* %177, i32 1, i32 %179, i32* %180)
%182 = icmp eq i32 %181, 0
br i1 %182, label %183, label %185
183: ; preds = %176
%184 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %176
185: ; preds = %176
br label %140
186: ; preds = %140
%187 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%188 = call i32 (i8*, i8*, ...) @sprintf(i8* %187, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %10
%189 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%190 = call i32 @strlen(i8* %189)
store i32 %190, i32* %8
br label %191
191: ; preds = %210, %186
%192 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%193 = load i32, i32* %10
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i8, i8* %192, i64 %194
%196 = load i32, i32* %8
%197 = load i32, i32* %10
%198 = sub nsw i32 %196, %197
%199 = load i32*, i32** %17
%200 = call i32 @fwrite(i8* %195, i32 1, i32 %198, i32* %199)
store i32 %200, i32* %9
%201 = load i32, i32* %8
%202 = load i32, i32* %10
%203 = sub nsw i32 %201, %202
%204 = icmp slt i32 %200, %203
br i1 %204, label %205, label %208
205: ; preds = %191
%206 = load i32, i32* %9
%207 = icmp sgt i32 %206, 0
br label %208
208: ; preds = %205, %191
%209 = phi i1 [ false, %191 ], [ %207, %205 ]
br i1 %209, label %210, label %214
210: ; preds = %208
%211 = load i32, i32* %9
%212 = load i32, i32* %10
%213 = add nsw i32 %212, %211
store i32 %213, i32* %10
br label %191
214: ; preds = %208
%215 = load i32*, i32** %16
%216 = call i32 @fclose(i32* %215)
br label %217
217: ; preds = %214, %70
%218 = load i32, i32* %6
%219 = add nsw i32 %218, 1
store i32 %219, i32* %6
br label %51
220: ; preds = %51
%221 = load i32*, i32** %17
%222 = call i32 @fclose(i32* %221)
store i32 0, i32* %3
br label %223
223: ; preds = %220, %36, %20
%224 = load i32, i32* %3
ret i32 %224
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"usage: %s [inputfile ...] [outputfile.h]\0A\00"
@.str.1 = [3 x i8] c"ab\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [15 x i8] c"char %s[] = { \00"
@EOF = global i8 0
@.str.6 = [7 x i8] c"'%c', \00"
@.str.7 = [11 x i8] c"'\\x%02X', \00"
@.str.8 = [7 x i8] c"chrhex\00"
@.str.9 = [7 x i8] c"0 };\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [65535 x i8]
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %127
14: ; preds = %2
%15 = add nsw i32 %0, -1
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i8*, i8** %17
%23 = tail call i32 @perror(i8* %22)
br label %127
24: ; preds = %14
%25 = shl i32 %0, 3
%26 = tail call i64 @calloc(i32 1, i32 %25)
br label %27
27: ; preds = %24, %122
%28 = phi i64 [ 1, %24 ], [ %123, %122 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @strcpy(i8* %8, i8* %30)
%32 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @perror(i8* %8)
%34 = icmp eq i32* %32, null
br i1 %34, label %122, label %35
35: ; preds = %27
%36 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @strlen(i8* %8)
%38 = sext i32 %37 to i64
%39 = icmp ult i64 %36, %38
br i1 %39, label %45, label %40
40: ; preds = %45, %35
%41 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%42 = call i32 @strlen(i8* %8)
%43 = sext i32 %42 to i64
%44 = icmp ult i64 %41, %43
br i1 %44, label %60, label %67
45: ; preds = %35, %45
%46 = call i32 @strlen(i8* %8)
%47 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = trunc i64 %47 to i32
%49 = xor i32 %48, -1
%50 = add i32 %46, %49
%51 = add i64 %47, 1
%52 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 %51
%53 = call i32 @memmove(i8* %8, i8* %52, i32 %50)
%54 = sext i32 %50 to i64
%55 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 %54
store i8 0, i8* %55
%56 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @strlen(i8* %8)
%58 = sext i32 %57 to i64
%59 = icmp ult i64 %56, %58
br i1 %59, label %45, label %40
60: ; preds = %40, %60
%61 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%62 = getelementptr inbounds [65535 x i8], [65535 x i8]* %5, i64 0, i64 %61
store i8 95, i8* %62
%63 = call i64 @strcspn(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @strlen(i8* %8)
%65 = sext i32 %64 to i64
%66 = icmp ult i64 %63, %65
br i1 %66, label %60, label %67
67: ; preds = %60, %40
%68 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%69 = call i32 @strlen(i8* %7)
br label %70
70: ; preds = %70, %67
%71 = phi i32 [ 0, %67 ], [ %79, %70 ]
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %72
%74 = sub nsw i32 %69, %71
%75 = call i32 @fwrite(i8* %73, i32 1, i32 %74, i32* %19)
%76 = icmp slt i32 %75, %74
%77 = icmp sgt i32 %75, 0
%78 = and i1 %76, %77
%79 = add nsw i32 %75, %71
br i1 %78, label %70, label %80
80: ; preds = %70
%81 = call signext i8 @fgetc(i32* %32)
%82 = load i8, i8* @EOF
%83 = icmp eq i8 %81, %82
br i1 %83, label %108, label %88
84: ; preds = %103, %96
%85 = call signext i8 @fgetc(i32* %32)
%86 = load i8, i8* @EOF
%87 = icmp eq i8 %85, %86
br i1 %87, label %108, label %88
88: ; preds = %80, %84
%89 = phi i8 [ %85, %84 ], [ %81, %80 ]
%90 = sext i8 %89 to i32
%91 = call i64 @isprint(i8 signext %89)
%92 = freeze i64 %91
%93 = icmp eq i64 %92, 0
br i1 %93, label %95, label %94
94: ; preds = %88
switch i8 %89, label %96 [
i8 92, label %95
i8 39, label %95
i8 37, label %95
]
95: ; preds = %94, %94, %94, %88
br label %96
96: ; preds = %94, %95
%97 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %95 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %94 ]
%98 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) %97, i32 %90)
%99 = call i32 @strlen(i8* %6)
%100 = call i32 @strlen(i8* %6)
%101 = call i32 @fwrite(i8* %6, i32 1, i32 %100, i32* %19)
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %84
103: ; preds = %96, %103
%104 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%105 = call i32 @strlen(i8* %6)
%106 = call i32 @fwrite(i8* %6, i32 1, i32 %105, i32* %19)
%107 = icmp eq i32 %106, 0
br i1 %107, label %103, label %84
108: ; preds = %84, %80
%109 = call i32 @strlen(i8* %7)
br label %110
110: ; preds = %110, %108
%111 = phi i32 [ 0, %108 ], [ %119, %110 ]
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %112
%114 = sub nsw i32 %109, %111
%115 = call i32 @fwrite(i8* %113, i32 1, i32 %114, i32* %19)
%116 = icmp slt i32 %115, %114
%117 = icmp sgt i32 %115, 0
%118 = and i1 %116, %117
%119 = add nsw i32 %115, %111
br i1 %118, label %110, label %120
120: ; preds = %110
%121 = call i32 @fclose(i32* %32)
br label %122
122: ; preds = %27, %120
%123 = add nuw nsw i64 %28, 1
%124 = icmp eq i64 %123, %16
br i1 %124, label %125, label %27
125: ; preds = %122
%126 = call i32 @fclose(i32* %19)
br label %127
127: ; preds = %125, %21, %10
%128 = phi i32 [ -1, %10 ], [ 0, %125 ], [ -1, %21 ]
ret i32 %128
}