#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*/ *);
int /*<<< orphan*/ hexdump(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
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 *basename;
  char *p;
  int i, size;
  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__) || "
              "defined(__OpenBSD__)\n");
  fprintf(fo, "#if !defined(__ICC)\n");
  fprintf(fo, "#define HAVE_INCBIN\n");
  fprintf(fo, "#endif\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(fontname, basename);
    for (p = fontname; *p; ++p) {
      if (*p == '/' || *p == '.' || *p == '\\' || *p == '-')
        *p = '_';
    }
    fseek(fi, 0, SEEK_END);
    size = ftell(fi);
    fseek(fi, 0, SEEK_SET);
    fprintf(fo, "\n#ifdef HAVE_INCBIN\n");
    fprintf(fo, "const int fz_font_%s_size = %d;\n", fontname, size);
    fprintf(fo, "asm(\".section .rodata\");\n");
    fprintf(fo, "asm(\".global fz_font_%s\");\n", fontname);
    fprintf(fo, "asm(\".type fz_font_%s STT_OBJECT\");\n", fontname);
    fprintf(fo, "asm(\".size fz_font_%s, %d\");\n", fontname, size);
    fprintf(fo, "asm(\".balign 64\");\n");
    fprintf(fo, "asm(\"fz_font_%s:\");\n", fontname);
    fprintf(fo, "asm(\".incbin \\\"%s\\\"\");\n", argv[i]);
    fprintf(fo, "#else\n");
    fprintf(fo, "const int fz_font_%s_size = %d;\n", fontname, size);
    fprintf(fo, "const char fz_font_%s[] = {\n", fontname);
    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    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c7 <main+0x47>
mov    0x2e2e(%rip),%rax
mov    (%rax),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1216 <main+0x96>
mov    0x2de7(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
mov    -0x18(%rbp),%rdi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x2,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15ee <main+0x46e>
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe22(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1313 <main+0x193>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    1361 <main+0x1e1>
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x5c,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
je     1386 <main+0x206>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    139c <main+0x21c>
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
cmpb   $0x0,(%rax)
je     143f <main+0x2bf>
mov    -0x130(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1419 <main+0x299>
mov    -0x130(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1419 <main+0x299>
mov    -0x130(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     1419 <main+0x299>
mov    -0x130(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1423 <main+0x2a3>
mov    -0x130(%rbp),%rax
movb   $0x5f,(%rax)
jmp    1428 <main+0x2a8>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
jmp    13bd <main+0x23d>
mov    -0x20(%rbp),%rdi
mov    0x2b9e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x138(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2b63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x18(%rbp),%rdi
lea    0xc91(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x138(%rbp),%ecx
lea    0xc87(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc96(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xc97(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xc9a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x138(%rbp),%ecx
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xcac(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xca7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc9b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xca1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    -0x138(%rbp),%ecx
lea    0xba7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <hexdump@plt>
mov    -0x18(%rbp),%rdi
lea    0xc6e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xb13(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    129e <main+0x11e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     162d <main+0x4ad>
mov    0x29d0(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x2,%edi
jg     11cb <main+0x3b>
mov    0x2e2b(%rip),%rax
mov    (%rax),%rcx
lea    0xe49(%rip),%rdi
mov    $0x23,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
jmp    154f <main+0x3bf>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe49(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     14ef <main+0x35f>
mov    %rax,%rbx
lea    0xe5f(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
lea    0xe5f(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe8e(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe8a(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe86(%rip),%r14
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %ebp,%eax
mov    %rax,0x8(%rsp)
mov    $0x2,%r14d
movabs $0x800000000007,%r13
mov    %r15,%rbp
mov    %r15,(%rsp)
jmp    1460 <main+0x2d0>
nopl   0x0(%rax)
mov    0x2d21(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r12,%rdi
call   1070 <ftell@plt>
mov    %eax,%r15d
mov    0x2ceb(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    $0x14,%esi
mov    $0x1,%edx
lea    0xe10(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe13(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x19,%esi
mov    $0x1,%edx
lea    0xe11(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe19(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xe21(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xe32(%rip),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x13,%esi
mov    $0x1,%edx
lea    0xe32(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xe34(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rsp),%rax
mov    (%rax,%r14,8),%rdx
mov    %rbx,%rdi
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xe2d(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
lea    0xd40(%rip),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
lea    0xe0b(%rip),%rsi
mov    %rbp,%rdx
mov    (%rsp),%rbp
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <hexdump@plt>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xdfe(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    $0x7,%esi
mov    $0x1,%edx
lea    0xc9c(%rip),%rdi
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
add    $0x1,%r14
cmp    0x8(%rsp),%r14
je     1526 <main+0x396>
mov    0x0(%rbp,%r14,8),%rdi
lea    0xc79(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1506 <main+0x376>
mov    %rax,%r12
mov    0x0(%rbp,%r14,8),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
jne    14a6 <main+0x316>
mov    %rbp,%rdi
mov    $0x5c,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     14ad <main+0x31d>
add    $0x1,%rax
mov    %rax,%rbp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    14d4 <main+0x344>
nop
test   %cl,%cl
je     12c0 <main+0x130>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
movzbl (%r15),%ecx
lea    -0x2d(%rcx),%edx
cmp    $0x2f,%dl
ja     14c0 <main+0x330>
movzbl %dl,%edx
bt     %rdx,%r13
jae    14c0 <main+0x330>
movb   $0x5f,(%r15)
jmp    14d0 <main+0x340>
mov    0x2ae2(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%r15),%rdx
lea    0xb23(%rip),%rsi
jmp    1548 <main+0x3b8>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2ac3(%rip),%rax
mov    (%rax),%rdi
mov    0x0(%rbp,%r14,8),%rdx
lea    0xbc4(%rip),%rsi
jmp    1548 <main+0x3b8>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1566 <main+0x3d6>
mov    0x2a9e(%rip),%rax
mov    (%rax),%rdi
mov    0x8(%rbp),%rdx
lea    0xce2(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    1554 <main+0x3c4>

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

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 = [72 x i8] c"#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)\0A\00"
@.str.5 = [21 x i8] c"#if !defined(__ICC)\0A\00"
@.str.6 = [21 x i8] c"#define HAVE_INCBIN\0A\00"
@.str.7 = [8 x i8] c"#endif\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [42 x i8] c"fontdump: could not open input file '%s'\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [21 x i8] c"\0A#ifdef HAVE_INCBIN\0A\00"
@.str.11 = [33 x i8] c"const int fz_font_%s_size = %d;\0A\00"
@.str.12 = [26 x i8] c"asm(\22.section .rodata\22);\0A\00"
@.str.13 = [28 x i8] c"asm(\22.global fz_font_%s\22);\0A\00"
@.str.14 = [37 x i8] c"asm(\22.type fz_font_%s STT_OBJECT\22);\0A\00"
@.str.15 = [30 x i8] c"asm(\22.size fz_font_%s, %d\22);\0A\00"
@.str.16 = [20 x i8] c"asm(\22.balign 64\22);\0A\00"
@.str.17 = [21 x i8] c"asm(\22fz_font_%s:\22);\0A\00"
@.str.18 = [24 x i8] c"asm(\22.incbin \\\22%s\\\22\22);\0A\00"
@.str.19 = [7 x i8] c"#else\0A\00"
@.str.20 = [29 x i8] c"const char fz_font_%s[] = {\0A\00"
@.str.21 = [4 x i8] c"};\0A\00"
@.str.22 = [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 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 35, i64 1, i32* %7)
br label %89
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32*, i32** @stderr
%16 = load i8*, i8** %10
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %89
18: ; preds = %9
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i64 24, i64 1, i32* %12)
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0), i64 71, i64 1, i32* %12)
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i64 20, i64 1, i32* %12)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i64 20, i64 1, i32* %12)
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 7, i64 1, i32* %12)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 7, i64 1, i32* %12)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 7, i64 1, i32* %12)
%26 = zext i32 %0 to i64
br label %27
27: ; preds = %18, %57
%28 = phi i64 [ 2, %18 ], [ %80, %57 ]
%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.8, 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* %12)
%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.9, i64 0, i64 0), i8* %36)
br label %89
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* %4, i8* %49)
br label %51
51: ; preds = %55, %48
%52 = phi i8* [ %4, %48 ], [ %56, %55 ]
%53 = load i8, i8* %52
switch i8 %53, label %55 [
i8 0, label %57
i8 47, label %54
i8 46, label %54
i8 92, label %54
i8 45, label %54
]
54: ; preds = %51, %51, %51, %51
store i8 95, i8* %52
br label %55
55: ; preds = %51, %54
%56 = getelementptr inbounds i8, i8* %52, i64 1
br label %51
57: ; preds = %51
%58 = load i32, i32* @SEEK_END
%59 = call i32 @fseek(i32* %31, i32 0, i32 %58)
%60 = call i32 @ftell(i32* %31)
%61 = load i32, i32* @SEEK_SET
%62 = call i32 @fseek(i32* %31, i32 0, i32 %61)
%63 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i64 20, i64 1, i32* %12)
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %4, i32 %60)
%65 = call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0), i64 25, i64 1, i32* %12)
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0), i8* %4)
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0), i8* %4)
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.15, i64 0, i64 0), i8* %4, i32 %60)
%69 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0), i64 19, i64 1, i32* %12)
%70 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* %4)
%71 = load i8*, i8** %29
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0), i8* %71)
%73 = call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.19, i64 0, i64 0), i64 6, i64 1, i32* %12)
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %4, i32 %60)
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0), i8* %4)
%76 = call i32 @hexdump(i32* %12, i32* %31)
%77 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.21, i64 0, i64 0), i64 3, i64 1, i32* %12)
%78 = call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i64 7, i64 1, i32* %12)
%79 = call i64 @fclose(i32* %31)
%80 = add nuw nsw i64 %28, 1
%81 = icmp eq i64 %80, %26
br i1 %81, label %82, label %27
82: ; preds = %57
%83 = call i64 @fclose(i32* %12)
%84 = icmp eq i64 %83, 0
br i1 %84, label %89, label %85
85: ; preds = %82
%86 = load i32*, i32** @stderr
%87 = load i8*, i8** %10
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.22, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %82, %85, %33, %14, %6
%90 = phi i32 [ 1, %6 ], [ 1, %33 ], [ 1, %85 ], [ 1, %14 ], [ 0, %82 ]
ret i32 %90
}