#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ getenv(char *);
int /*<<< orphan*/ hexdump(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *, int);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strcpy(char *, char *);
char *strrchr(char *, char);
int main(int argc, char **argv) {
  FILE *fo;
  FILE *fi;
  char fontname[256];
  char origname[256];
  char *basename;
  char *p;
  int i, len;
  if (argc < 3) {
    fprintf(stderr, "usage: fontdump output.c input.dat\n");
    return 1;
  }
  fo = fopen(argv[1], "wb");
  if (!fo) {
    fprintf(stderr, "fontdump: could not open output file '%s'\n", argv[1]);
    return 1;
  }
  fprintf(fo, "#ifndef __STRICT_ANSI__\n");
  fprintf(fo, "#if defined(__linux__) || defined(__FreeBSD__)\n");
  fprintf(fo, "#define HAVE_INCBIN\n");
  fprintf(fo, "#endif\n");
  fprintf(fo, "#endif\n");
  for (i = 2; i < argc; i++) {
    fi = fopen(argv[i], "rb");
    if (!fi) {
      fclose(fo);
      fprintf(stderr, "fontdump: could not open input file '%s'\n", argv[i]);
      return 1;
    }
    basename = strrchr(argv[i], '/');
    if (!basename)
      basename = strrchr(argv[i], '\\');
    if (basename)
      basename++;
    else
      basename = argv[i];
    strcpy(origname, basename);
    p = strrchr(origname, '.');
    if (p)
      *p = 0;
    strcpy(fontname, origname);
    p = fontname;
    while (*p) {
      if (*p == '/' || *p == '.' || *p == '\\' || *p == '-')
        *p = '_';
      p++;
    }
    fseek(fi, 0, SEEK_END);
    len = ftell(fi);
    fseek(fi, 0, SEEK_SET);
    if (getenv("verbose"))
      printf("\t{\"%s\",pdf_font_%s,%d},\n", origname, fontname, len);
    fprintf(fo, "\n#ifdef HAVE_INCBIN\n");
    fprintf(fo, "extern const unsigned char pdf_font_%s[%d];\n", fontname, len);
    fprintf(fo, "asm(\".globl pdf_font_%s\");\n", fontname);
    fprintf(fo, "asm(\".balign 8\");\n");
    fprintf(fo, "asm(\"pdf_font_%s:\");\n", fontname);
    fprintf(fo, "asm(\".incbin \\\"%s\\\"\");\n", argv[i]);
    fprintf(fo, "#else\n");
    fprintf(fo, "static const unsigned char pdf_font_%s[%d] = {\n", fontname,
            len);
    hexdump(fo, fi);
    fprintf(fo, "};\n");
    fprintf(fo, "#endif\n");
    fclose(fi);
  }
  if (fclose(fo)) {
    fprintf(stderr, "fontdump: could not close output file '%s'\n", argv[1]);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11e7 <main+0x47>
mov    0x2e0e(%rip),%rax
mov    (%rax),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1641 <main+0x4a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2e(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1236 <main+0x96>
mov    0x2dc7(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1641 <main+0x4a1>
mov    -0x18(%rbp),%rdi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x234(%rbp)
mov    -0x234(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15fb <main+0x45b>
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf9(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    130f <main+0x16f>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1641 <main+0x4a1>
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x228(%rbp)
cmpq   $0x0,-0x228(%rbp)
jne    135d <main+0x1bd>
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x5c,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x228(%rbp)
cmpq   $0x0,-0x228(%rbp)
je     1382 <main+0x1e2>
mov    -0x228(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x228(%rbp)
jmp    1398 <main+0x1f8>
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x228(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x228(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x220(%rbp),%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x230(%rbp)
cmpq   $0x0,-0x230(%rbp)
je     13db <main+0x23b>
mov    -0x230(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rax
cmpb   $0x0,(%rax)
je     1479 <main+0x2d9>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1458 <main+0x2b8>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1458 <main+0x2b8>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1458 <main+0x2b8>
mov    -0x230(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1462 <main+0x2c2>
mov    -0x230(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x230(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x230(%rbp)
jmp    13fc <main+0x25c>
mov    -0x20(%rbp),%rdi
mov    0x2b64(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1090 <ftell@plt>
mov    %eax,-0x238(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2b29(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10b0 <fseek@plt>
lea    0xc2e(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     14e6 <main+0x346>
lea    -0x220(%rbp),%rsi
lea    -0x120(%rbp),%rdx
mov    -0x238(%rbp),%ecx
lea    0xc0c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc15(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x238(%rbp),%ecx
lea    0xc0b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xc1f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc29(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xc23(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x234(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc18(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc1e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x238(%rbp),%ecx
lea    0xc06(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <hexdump@plt>
mov    -0x18(%rbp),%rdi
lea    0xc17(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xad9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x234(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x234(%rbp)
jmp    129a <main+0xfa>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
cmp    $0x0,%rax
je     163a <main+0x49a>
mov    0x29c3(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xbb9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1641 <main+0x4a1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jg     11eb <main+0x3b>
mov    0x2e0b(%rip),%rax
mov    (%rax),%rcx
lea    0xe29(%rip),%rdi
mov    $0x23,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
jmp    1542 <main+0x392>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe29(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14e2 <main+0x332>
mov    %rax,%rbx
lea    0xe3f(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10d0 <fwrite@plt>
lea    0xe3f(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xe56(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
lea    0xe52(%rip),%r14
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %ebp,%eax
mov    %rax,0x8(%rsp)
mov    $0x2,%r14d
movabs $0x800000000007,%r13
mov    %r15,%rbp
mov    %r15,(%rsp)
jmp    13c4 <main+0x214>
nopl   0x0(%rax,%rax,1)
mov    $0x14,%esi
mov    $0x1,%edx
lea    0xe45(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe48(%rip),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x12,%esi
mov    $0x1,%edx
lea    0xe5f(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe60(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rsp),%rbp
mov    0x0(%rbp,%r14,8),%rdx
mov    %rbx,%rdi
lea    0xe59(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xe59(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe4e(%rip),%rsi
lea    0x110(%rsp),%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <hexdump@plt>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe50(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    $0x7,%esi
mov    $0x1,%edx
lea    0xd0b(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
add    $0x1,%r14
cmp    0x8(%rsp),%r14
je     1519 <main+0x369>
mov    0x0(%rbp,%r14,8),%rdi
lea    0xce8(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14f9 <main+0x349>
mov    %rax,%r12
mov    0x0(%rbp,%r14,8),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
jne    140a <main+0x25a>
mov    %rbp,%rdi
mov    $0x5c,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     1411 <main+0x261>
add    $0x1,%rax
mov    %rax,%rbp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    $0x2e,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     1436 <main+0x286>
movb   $0x0,(%rax)
lea    0x110(%rsp),%rbp
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rax
jmp    1464 <main+0x2b4>
test   %cl,%cl
je     1480 <main+0x2d0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rax
movzbl (%rax),%ecx
lea    -0x2d(%rcx),%edx
cmp    $0x2f,%dl
ja     1450 <main+0x2a0>
movzbl %dl,%edx
bt     %rdx,%r13
jae    1450 <main+0x2a0>
movb   $0x5f,(%rax)
jmp    1460 <main+0x2b0>
nopl   (%rax)
mov    0x2b61(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r12,%rdi
call   1090 <ftell@plt>
mov    %eax,%r15d
mov    0x2b2b(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
lea    0xc2d(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     12b0 <main+0x100>
lea    0xc20(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
call   1060 <printf@plt>
jmp    12b0 <main+0x100>
mov    0x2aef(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%r15),%rdx
lea    0xb30(%rip),%rsi
jmp    153b <main+0x38b>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2ad0(%rip),%rax
mov    (%rax),%rdi
mov    0x0(%rbp,%r14,8),%rdx
lea    0xba4(%rip),%rsi
jmp    153b <main+0x38b>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
je     1559 <main+0x3a9>
mov    0x2aab(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%rbp),%rdx
lea    0xca5(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    1547 <main+0x397>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [36 x i8] c"usage: fontdump output.c input.dat\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [43 x i8] c"fontdump: could not open output file '%s'\0A\00"
@.str.3 = [25 x i8] c"#ifndef __STRICT_ANSI__\0A\00"
@.str.4 = [48 x i8] c"#if defined(__linux__) || defined(__FreeBSD__)\0A\00"
@.str.5 = [21 x i8] c"#define HAVE_INCBIN\0A\00"
@.str.6 = [8 x i8] c"#endif\0A\00"
@.str.7 = [3 x i8] c"rb\00"
@.str.8 = [42 x i8] c"fontdump: could not open input file '%s'\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.9 = [8 x i8] c"verbose\00"
@.str.10 = [25 x i8] c"\09{\22%s\22,pdf_font_%s,%d},\0A\00"
@.str.11 = [21 x i8] c"\0A#ifdef HAVE_INCBIN\0A\00"
@.str.12 = [45 x i8] c"extern const unsigned char pdf_font_%s[%d];\0A\00"
@.str.13 = [28 x i8] c"asm(\22.globl pdf_font_%s\22);\0A\00"
@.str.14 = [19 x i8] c"asm(\22.balign 8\22);\0A\00"
@.str.15 = [22 x i8] c"asm(\22pdf_font_%s:\22);\0A\00"
@.str.16 = [24 x i8] c"asm(\22.incbin \\\22%s\\\22\22);\0A\00"
@.str.17 = [7 x i8] c"#else\0A\00"
@.str.18 = [48 x i8] c"static const unsigned char pdf_font_%s[%d] = {\0A\00"
@.str.19 = [4 x i8] c"};\0A\00"
@.str.20 = [44 x i8] c"fontdump: could not close output file '%s'\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 [256 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32*, i32** @stderr
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %205
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %32, label %26
26: ; preds = %19
%27 = load i32*, i32** @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %205
32: ; preds = %19
%33 = load i32*, i32** %6
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32*, i32** %6
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%37 = load i32*, i32** %6
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%39 = load i32*, i32** %6
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%41 = load i32*, i32** %6
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 2, i32* %12
br label %43
43: ; preds = %191, %32
%44 = load i32, i32* %12
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %194
47: ; preds = %43
%48 = load i8**, i8*** %5
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %53, i32** %7
%54 = load i32*, i32** %7
%55 = icmp ne i32* %54, null
br i1 %55, label %66, label %56
56: ; preds = %47
%57 = load i32*, i32** %6
%58 = call i64 @fclose(i32* %57)
%59 = load i32*, i32** @stderr
%60 = load i8**, i8*** %5
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %60, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i8* %64)
store i32 1, i32* %3
br label %205
66: ; preds = %47
%67 = load i8**, i8*** %5
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = call i8* @strrchr(i8* %71, i8 signext 47)
store i8* %72, i8** %10
%73 = load i8*, i8** %10
%74 = icmp ne i8* %73, null
br i1 %74, label %82, label %75
75: ; preds = %66
%76 = load i8**, i8*** %5
%77 = load i32, i32* %12
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
%80 = load i8*, i8** %79
%81 = call i8* @strrchr(i8* %80, i8 signext 92)
store i8* %81, i8** %10
br label %82
82: ; preds = %75, %66
%83 = load i8*, i8** %10
%84 = icmp ne i8* %83, null
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i8*, i8** %10
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %10
br label %94
88: ; preds = %82
%89 = load i8**, i8*** %5
%90 = load i32, i32* %12
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %89, i64 %91
%93 = load i8*, i8** %92
store i8* %93, i8** %10
br label %94
94: ; preds = %88, %85
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%96 = load i8*, i8** %10
%97 = call i32 @strcpy(i8* %95, i8* %96)
%98 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%99 = call i8* @strrchr(i8* %98, i8 signext 46)
store i8* %99, i8** %11
%100 = load i8*, i8** %11
%101 = icmp ne i8* %100, null
br i1 %101, label %102, label %104
102: ; preds = %94
%103 = load i8*, i8** %11
store i8 0, i8* %103
br label %104
104: ; preds = %102, %94
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%106 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%107 = call i32 @strcpy(i8* %105, i8* %106)
%108 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8* %108, i8** %11
br label %109
109: ; preds = %135, %104
%110 = load i8*, i8** %11
%111 = load i8, i8* %110
%112 = icmp ne i8 %111, 0
br i1 %112, label %113, label %138
113: ; preds = %109
%114 = load i8*, i8** %11
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 47
br i1 %117, label %133, label %118
118: ; preds = %113
%119 = load i8*, i8** %11
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 46
br i1 %122, label %133, label %123
123: ; preds = %118
%124 = load i8*, i8** %11
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 92
br i1 %127, label %133, label %128
128: ; preds = %123
%129 = load i8*, i8** %11
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp eq i32 %131, 45
br i1 %132, label %133, label %135
133: ; preds = %128, %123, %118, %113
%134 = load i8*, i8** %11
store i8 95, i8* %134
br label %135
135: ; preds = %133, %128
%136 = load i8*, i8** %11
%137 = getelementptr inbounds i8, i8* %136, i32 1
store i8* %137, i8** %11
br label %109
138: ; preds = %109
%139 = load i32*, i32** %7
%140 = load i32, i32* @SEEK_END
%141 = call i32 @fseek(i32* %139, i32 0, i32 %140)
%142 = load i32*, i32** %7
%143 = call i32 @ftell(i32* %142)
store i32 %143, i32* %13
%144 = load i32*, i32** %7
%145 = load i32, i32* @SEEK_SET
%146 = call i32 @fseek(i32* %144, i32 0, i32 %145)
%147 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%148 = icmp ne i64 %147, 0
br i1 %148, label %149, label %154
149: ; preds = %138
%150 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%151 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%152 = load i32, i32* %13
%153 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %150, i8* %151, i32 %152)
br label %154
154: ; preds = %149, %138
%155 = load i32*, i32** %6
%156 = call i32 (i32*, i8*, ...) @fprintf(i32* %155, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%157 = load i32*, i32** %6
%158 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%159 = load i32, i32* %13
%160 = call i32 (i32*, i8*, ...) @fprintf(i32* %157, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* %158, i32 %159)
%161 = load i32*, i32** %6
%162 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%163 = call i32 (i32*, i8*, ...) @fprintf(i32* %161, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), i8* %162)
%164 = load i32*, i32** %6
%165 = call i32 (i32*, i8*, ...) @fprintf(i32* %164, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%166 = load i32*, i32** %6
%167 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %166, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i8* %167)
%169 = load i32*, i32** %6
%170 = load i8**, i8*** %5
%171 = load i32, i32* %12
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8*, i8** %170, i64 %172
%174 = load i8*, i8** %173
%175 = call i32 (i32*, i8*, ...) @fprintf(i32* %169, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0), i8* %174)
%176 = load i32*, i32** %6
%177 = call i32 (i32*, i8*, ...) @fprintf(i32* %176, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0))
%178 = load i32*, i32** %6
%179 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%180 = load i32, i32* %13
%181 = call i32 (i32*, i8*, ...) @fprintf(i32* %178, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.18, i64 0, i64 0), i8* %179, i32 %180)
%182 = load i32*, i32** %6
%183 = load i32*, i32** %7
%184 = call i32 @hexdump(i32* %182, i32* %183)
%185 = load i32*, i32** %6
%186 = call i32 (i32*, i8*, ...) @fprintf(i32* %185, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%187 = load i32*, i32** %6
%188 = call i32 (i32*, i8*, ...) @fprintf(i32* %187, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%189 = load i32*, i32** %7
%190 = call i64 @fclose(i32* %189)
br label %191
191: ; preds = %154
%192 = load i32, i32* %12
%193 = add nsw i32 %192, 1
store i32 %193, i32* %12
br label %43
194: ; preds = %43
%195 = load i32*, i32** %6
%196 = call i64 @fclose(i32* %195)
%197 = icmp ne i64 %196, 0
br i1 %197, label %198, label %204
198: ; preds = %194
%199 = load i32*, i32** @stderr
%200 = load i8**, i8*** %5
%201 = getelementptr inbounds i8*, i8** %200, i64 1
%202 = load i8*, i8** %201
%203 = call i32 (i32*, i8*, ...) @fprintf(i32* %199, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i8* %202)
store i32 1, i32* %3
br label %205
204: ; preds = %194
store i32 0, i32* %3
br label %205
205: ; preds = %204, %198, %56, %26, %16
%206 = load i32, i32* %3
ret i32 %206
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [36 x i8] c"usage: fontdump output.c input.dat\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [43 x i8] c"fontdump: could not open output file '%s'\0A\00"
@.str.3 = [25 x i8] c"#ifndef __STRICT_ANSI__\0A\00"
@.str.4 = [48 x i8] c"#if defined(__linux__) || defined(__FreeBSD__)\0A\00"
@.str.5 = [21 x i8] c"#define HAVE_INCBIN\0A\00"
@.str.6 = [8 x i8] c"#endif\0A\00"
@.str.7 = [3 x i8] c"rb\00"
@.str.8 = [42 x i8] c"fontdump: could not open input file '%s'\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.9 = [8 x i8] c"verbose\00"
@.str.10 = [25 x i8] c"\09{\22%s\22,pdf_font_%s,%d},\0A\00"
@.str.11 = [21 x i8] c"\0A#ifdef HAVE_INCBIN\0A\00"
@.str.12 = [45 x i8] c"extern const unsigned char pdf_font_%s[%d];\0A\00"
@.str.13 = [28 x i8] c"asm(\22.globl pdf_font_%s\22);\0A\00"
@.str.14 = [19 x i8] c"asm(\22.balign 8\22);\0A\00"
@.str.15 = [22 x i8] c"asm(\22pdf_font_%s:\22);\0A\00"
@.str.16 = [24 x i8] c"asm(\22.incbin \\\22%s\\\22\22);\0A\00"
@.str.17 = [7 x i8] c"#else\0A\00"
@.str.18 = [48 x i8] c"static const unsigned char pdf_font_%s[%d] = {\0A\00"
@.str.19 = [4 x i8] c"};\0A\00"
@.str.20 = [44 x i8] c"fontdump: could not close output file '%s'\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 %11
8: ; preds = %2
%9 = load i32*, i32** @stderr
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 35, i64 1, i32* %9)
br label %95
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = load i32*, i32** @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %95
20: ; preds = %11
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 24, i64 1, i32* %14)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i64 47, i64 1, i32* %14)
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 20, i64 1, i32* %14)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %14)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %14)
%26 = zext i32 %0 to i64
br label %27
27: ; preds = %20, %72
%28 = phi i64 [ 2, %20 ], [ %86, %72 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = call i64 @fclose(i32* %14)
%35 = load i32*, i32** @stderr
%36 = load i8*, i8** %29
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i8* %36)
br label %95
38: ; preds = %27
%39 = load i8*, i8** %29
%40 = call i8* @strrchr(i8* dereferenceable(1) %39, i8 signext 47)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = call i8* @strrchr(i8* dereferenceable(1) %39, i8 signext 92)
%44 = icmp eq i8* %43, null
br i1 %44, label %48, label %45
45: ; preds = %38, %42
%46 = phi i8* [ %43, %42 ], [ %40, %38 ]
%47 = getelementptr inbounds i8, i8* %46, i64 1
br label %48
48: ; preds = %42, %45
%49 = phi i8* [ %47, %45 ], [ %39, %42 ]
%50 = call i32 @strcpy(i8* %6, i8* %49)
%51 = call i8* @strrchr(i8* %6, i8 signext 46)
%52 = icmp eq i8* %51, null
br i1 %52, label %54, label %53
53: ; preds = %48
store i8 0, i8* %51
br label %54
54: ; preds = %53, %48
%55 = call i32 @strcpy(i8* %5, i8* %6)
br label %56
56: ; preds = %60, %54
%57 = phi i8* [ %5, %54 ], [ %61, %60 ]
%58 = load i8, i8* %57
switch i8 %58, label %60 [
i8 0, label %62
i8 47, label %59
i8 46, label %59
i8 92, label %59
i8 45, label %59
]
59: ; preds = %56, %56, %56, %56
store i8 95, i8* %57
br label %60
60: ; preds = %56, %59
%61 = getelementptr inbounds i8, i8* %57, i64 1
br label %56
62: ; preds = %56
%63 = load i32, i32* @SEEK_END
%64 = call i32 @fseek(i32* %31, i32 0, i32 %63)
%65 = call i32 @ftell(i32* %31)
%66 = load i32, i32* @SEEK_SET
%67 = call i32 @fseek(i32* %31, i32 0, i32 %66)
%68 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %62
%71 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %6, i8* %5, i32 %65)
br label %72
72: ; preds = %70, %62
%73 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i64 20, i64 1, i32* %14)
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* %5, i32 %65)
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), i8* %5)
%76 = call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i64 18, i64 1, i32* %14)
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i8* %5)
%78 = load i8*, i8** %29
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0), i8* %78)
%80 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.17, i64 0, i64 0), i64 6, i64 1, i32* %14)
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.18, i64 0, i64 0), i8* %5, i32 %65)
%82 = call i32 @hexdump(i32* %14, i32* %31)
%83 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i64 3, i64 1, i32* %14)
%84 = call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %14)
%85 = call i64 @fclose(i32* %31)
%86 = add nuw nsw i64 %28, 1
%87 = icmp eq i64 %86, %26
br i1 %87, label %88, label %27
88: ; preds = %72
%89 = call i64 @fclose(i32* %14)
%90 = icmp eq i64 %89, 0
br i1 %90, label %95, label %91
91: ; preds = %88
%92 = load i32*, i32** @stderr
%93 = load i8*, i8** %12
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %88, %91, %33, %16, %8
%96 = phi i32 [ 1, %8 ], [ 1, %33 ], [ 1, %91 ], [ 1, %16 ], [ 0, %88 ]
ret i32 %96
}