#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;
int /*<<< orphan*/ copytable(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                             int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
unsigned int filecheck(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
unsigned int getlong(int /*<<< orphan*/ *);
int getushort(int /*<<< orphan*/ *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putlong(int /*<<< orphan*/ *, unsigned int);
int /*<<< orphan*/ putshort(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strrchr(char *, char);
void handlefont(char *filename, int which, FILE *ttc, int offset) {
  char outfile[2000], *pt;
  FILE *ttf;
  int i, cnt, *offsets, *lengths, head, tag, pos, headpos;
  strcpy(outfile, filename);
  pt = strrchr(outfile, '.');
  if (pt == NULL)
    pt = outfile + strlen(outfile);
  sprintf(pt, "_%02d.ttf", which);
  ttf = fopen(outfile, "wb");
  if (ttf == NULL) {
    fprintf(stderr, "Failed to open %s for output.\n", outfile);
    return;
  }
  printf("%s ", outfile);
  fseek(ttc, offset, SEEK_SET);
  putlong(ttf, getlong(ttc));
  putshort(ttf, cnt = getushort(ttc));
  putshort(ttf, getushort(ttc));
  putshort(ttf, getushort(ttc));
  putshort(ttf, getushort(ttc));
  offsets = malloc(cnt * sizeof(int));
  lengths = malloc(cnt * sizeof(int));
  head = -1;
  for (i = 0; i < cnt; ++i) {
    tag = getlong(ttc);
    if (tag == ((('h') << 24) | (('e') << 16) | (('a') << 8) | ('d')))
      head = i;
    putlong(ttf, tag);
    putlong(ttf, getlong(ttc));
    putlong(ttf, offsets[i] = getlong(ttc));
    putlong(ttf, lengths[i] = getlong(ttc));
  }
  headpos = -1;
  for (i = 0; i < cnt; ++i) {
    pos = ftell(ttf);
    copytable(ttf, ttc, offsets[i], lengths[i]);
    if (i == head) {
      fseek(ttf, pos + 8, SEEK_SET);
      putlong(ttf, 0);
      headpos = pos;
    }
    fseek(ttf, 12 + i * 16 + 8, SEEK_SET);
    putlong(ttf, pos);
    fseek(ttf, 0, SEEK_END);
  }
  if (headpos != -1) {
    unsigned int checksum;
    checksum = filecheck(ttf);
    checksum = 0xb1b0afba - checksum;
    fseek(ttf, headpos + 2 * sizeof(int), SEEK_SET);
    putlong(ttf, checksum);
  }
  fclose(ttf);
  free(offsets);
  free(lengths);
}


x86 assembly (clang, -O0):
<handlefont>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x7f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0x7f0(%rbp),%rdi
mov    $0x2e,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x7f8(%rbp)
cmpq   $0x0,-0x7f8(%rbp)
jne    129f <handlefont+0x7f>
lea    -0x7f0(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x7f0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x838(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x7f8(%rbp)
mov    -0x7f8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd50(%rip),%rsi
call   1140 <sprintf@plt>
lea    -0x7f0(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x800(%rbp)
cmpq   $0x0,-0x800(%rbp)
jne    12fe <handlefont+0xde>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    -0x7f0(%rbp),%rdx
lea    0xd19(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    16bc <handlefont+0x49c>
lea    -0x7f0(%rbp),%rsi
lea    0xd20(%rip),%rdi
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2cb1(%rip),%rax
mov    (%rax),%edx
call   10e0 <fseek@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x860(%rbp)
mov    -0x18(%rbp),%rdi
call   1110 <getlong@plt>
mov    -0x860(%rbp),%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x858(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <getushort@plt>
mov    -0x858(%rbp),%rdi
mov    %eax,%esi
mov    %esi,-0x808(%rbp)
call   1040 <putshort@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x850(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <getushort@plt>
mov    -0x850(%rbp),%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x848(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <getushort@plt>
mov    -0x848(%rbp),%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <getushort@plt>
mov    -0x840(%rbp),%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
movslq -0x808(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x810(%rbp)
movslq -0x808(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x818(%rbp)
movl   $0xffffffff,-0x81c(%rbp)
ff ff ff
movl   $0x0,-0x804(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
jge    151f <handlefont+0x2ff>
mov    -0x18(%rbp),%rdi
call   1110 <getlong@plt>
mov    %eax,-0x820(%rbp)
cmpl   $0x68656164,-0x820(%rbp)
61 65 68
jne    1468 <handlefont+0x248>
mov    -0x804(%rbp),%eax
mov    %eax,-0x81c(%rbp)
mov    -0x800(%rbp),%rdi
mov    -0x820(%rbp),%esi
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x878(%rbp)
mov    -0x18(%rbp),%rdi
call   1110 <getlong@plt>
mov    -0x878(%rbp),%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x870(%rbp)
mov    -0x18(%rbp),%rdi
call   1110 <getlong@plt>
mov    -0x870(%rbp),%rdi
mov    %eax,%esi
mov    -0x810(%rbp),%rax
movslq -0x804(%rbp),%rcx
mov    %esi,(%rax,%rcx,4)
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rax
mov    %rax,-0x868(%rbp)
mov    -0x18(%rbp),%rdi
call   1110 <getlong@plt>
mov    -0x868(%rbp),%rdi
mov    %eax,%esi
mov    -0x818(%rbp),%rax
movslq -0x804(%rbp),%rcx
mov    %esi,(%rax,%rcx,4)
call   1100 <putlong@plt>
mov    -0x804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x804(%rbp)
jmp    142b <handlefont+0x20b>
movl   $0xffffffff,-0x828(%rbp)
ff ff ff
movl   $0x0,-0x804(%rbp)
mov    -0x804(%rbp),%eax
cmp    -0x808(%rbp),%eax
jge    1634 <handlefont+0x414>
mov    -0x800(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %eax,-0x824(%rbp)
mov    -0x800(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x810(%rbp),%rax
movslq -0x804(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x818(%rbp),%rax
movslq -0x804(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
call   10a0 <copytable@plt>
mov    -0x804(%rbp),%eax
cmp    -0x81c(%rbp),%eax
jne    15d3 <handlefont+0x3b3>
mov    -0x800(%rbp),%rdi
mov    -0x824(%rbp),%esi
add    $0x8,%esi
mov    0x2a1e(%rip),%rax
mov    (%rax),%edx
call   10e0 <fseek@plt>
mov    -0x800(%rbp),%rdi
xor    %esi,%esi
call   1100 <putlong@plt>
mov    -0x824(%rbp),%eax
mov    %eax,-0x828(%rbp)
mov    -0x800(%rbp),%rdi
mov    -0x804(%rbp),%esi
shl    $0x4,%esi
add    $0xc,%esi
add    $0x8,%esi
mov    0x29e0(%rip),%rax
mov    (%rax),%edx
call   10e0 <fseek@plt>
mov    -0x800(%rbp),%rdi
mov    -0x824(%rbp),%esi
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rdi
mov    0x29d1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    -0x804(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x804(%rbp)
jmp    1533 <handlefont+0x313>
cmpl   $0xffffffff,-0x828(%rbp)
je     1698 <handlefont+0x478>
mov    -0x800(%rbp),%rdi
call   1120 <filecheck@plt>
mov    %eax,-0x82c(%rbp)
mov    $0xb1b0afba,%eax
sub    -0x82c(%rbp),%eax
mov    %eax,-0x82c(%rbp)
mov    -0x800(%rbp),%rdi
movslq -0x828(%rbp),%rax
add    $0x8,%rax
mov    %eax,%esi
mov    0x2951(%rip),%rax
mov    (%rax),%edx
call   10e0 <fseek@plt>
mov    -0x800(%rbp),%rdi
mov    -0x82c(%rbp),%esi
call   1100 <putlong@plt>
mov    -0x800(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x810(%rbp),%rdi
call   1030 <free@plt>
mov    -0x818(%rbp),%rdi
call   1030 <free@plt>
add    $0x880,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handlefont>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %esi,%r14d
mov    %rdi,%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
mov    $0x2e,%esi
call   1090 <strrchr@plt>
test   %rax,%rax
jne    126f <handlefont+0x4f>
lea    0x30(%rsp),%rdi
call   1070 <strlen@plt>
cltq
add    %rsp,%rax
add    $0x30,%rax
lea    0xd8a(%rip),%rsi
mov    %rax,%rdi
mov    %r14d,%edx
call   1140 <sprintf@plt>
lea    0xd82(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1130 <fopen@plt>
test   %rax,%rax
je     149e <handlefont+0x27e>
mov    %rax,%r15
lea    0xd87(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1080 <printf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   10e0 <fseek@plt>
mov    %r13,%rdi
call   1110 <getlong@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    %r13,%rdi
call   10f0 <getushort@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
mov    %r13,%rdi
call   10f0 <getushort@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
mov    %r13,%rdi
call   10f0 <getushort@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
mov    %r13,0x28(%rsp)
mov    %r13,%rdi
call   10f0 <getushort@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <putshort@plt>
lea    0x0(,%rbx,4),%ebp
mov    %ebp,%edi
call   10d0 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %ebp,%edi
call   10d0 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %ebx,%ebx
jle    14ee <handlefont+0x2ce>
mov    %rbx,0x10(%rsp)
mov    %ebx,%eax
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
mov    0x18(%rsp),%r13
mov    0x28(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %rax,%r14
call   1110 <getlong@plt>
cmp    $0x68656164,%eax
cmove  %ebx,%ebp
mov    %r15,%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    %r12,%rdi
call   1110 <getlong@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    %r12,%rdi
call   1110 <getlong@plt>
mov    0x20(%rsp),%rcx
mov    %eax,(%rcx,%rbx,4)
mov    %r15,%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    %r12,%rdi
call   1110 <getlong@plt>
mov    %eax,0x0(%r13,%rbx,4)
mov    %r15,%rdi
mov    %eax,%esi
call   1100 <putlong@plt>
mov    %r14,%rax
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1370 <handlefont+0x150>
cmpl   $0x0,0x10(%rsp)
mov    0x2be8(%rip),%rbx
jle    14ee <handlefont+0x2ce>
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
mov    $0x14,%ebp
xor    %r12d,%r12d
jmp    1449 <handlefont+0x229>
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   10e0 <fseek@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   1100 <putlong@plt>
mov    0x2bba(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
add    $0x1,%r12
add    $0x10,%ebp
mov    %r14,%rax
cmp    %r12,%r14
je     14ba <handlefont+0x29a>
mov    %r15,%rdi
call   10c0 <ftell@plt>
mov    %eax,%r13d
mov    0x20(%rsp),%rax
mov    (%rax,%r12,4),%edx
mov    0x18(%rsp),%rax
mov    (%rax,%r12,4),%ecx
mov    %r15,%rdi
mov    0x28(%rsp),%rsi
call   10a0 <copytable@plt>
cmp    %r12,0x10(%rsp)
jne    1410 <handlefont+0x1f0>
mov    %r13d,%esi
add    $0x8,%esi
mov    (%rbx),%edx
mov    %r15,%rdi
call   10e0 <fseek@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1100 <putlong@plt>
mov    %r13d,0xc(%rsp)
jmp    1410 <handlefont+0x1f0>
mov    0x2b33(%rip),%rax
mov    (%rax),%edi
lea    0xb5f(%rip),%rsi
lea    0x30(%rsp),%rdx
call   10b0 <fprintf@plt>
jmp    150a <handlefont+0x2ea>
mov    0xc(%rsp),%ebp
cmp    $0xffffffff,%ebp
je     14ee <handlefont+0x2ce>
mov    %r15,%rdi
call   1120 <filecheck@plt>
mov    $0xb1b0afba,%r14d
sub    %eax,%r14d
add    $0x8,%ebp
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   10e0 <fseek@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1100 <putlong@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"_%02d.ttf\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Failed to open %s for output.\0A\00"
@.str.3 = [4 x i8] c"%s \00"
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @handlefont(i8* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [2000 x i8]
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%21 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%25 = call i8* @strrchr(i8* %24, i8 signext 46)
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %34
28: ; preds = %4
%29 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8* %33, i8** %10
br label %34
34: ; preds = %28, %4
%35 = load i8*, i8** %10
%36 = load i32, i32* %6
%37 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %11
%40 = load i32*, i32** %11
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %46
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %196
46: ; preds = %34
%47 = getelementptr inbounds [2000 x i8], [2000 x i8]* %9, i64 0, i64 0
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load i32*, i32** %7
%50 = load i32, i32* %8
%51 = load i32, i32* @SEEK_SET
%52 = call i32 @fseek(i32* %49, i32 %50, i32 %51)
%53 = load i32*, i32** %11
%54 = load i32*, i32** %7
%55 = call i32 @getlong(i32* %54)
%56 = call i32 @putlong(i32* %53, i32 %55)
%57 = load i32*, i32** %11
%58 = load i32*, i32** %7
%59 = call i32 @getushort(i32* %58)
store i32 %59, i32* %13
%60 = call i32 @putshort(i32* %57, i32 %59)
%61 = load i32*, i32** %11
%62 = load i32*, i32** %7
%63 = call i32 @getushort(i32* %62)
%64 = call i32 @putshort(i32* %61, i32 %63)
%65 = load i32*, i32** %11
%66 = load i32*, i32** %7
%67 = call i32 @getushort(i32* %66)
%68 = call i32 @putshort(i32* %65, i32 %67)
%69 = load i32*, i32** %11
%70 = load i32*, i32** %7
%71 = call i32 @getushort(i32* %70)
%72 = call i32 @putshort(i32* %69, i32 %71)
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = mul i64 %74, 4
%76 = trunc i64 %75 to i32
%77 = call i32* @malloc(i32 %76)
store i32* %77, i32** %14
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = mul i64 %79, 4
%81 = trunc i64 %80 to i32
%82 = call i32* @malloc(i32 %81)
store i32* %82, i32** %15
store i32 -1, i32* %16
store i32 0, i32* %12
br label %83
83: ; preds = %118, %46
%84 = load i32, i32* %12
%85 = load i32, i32* %13
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %121
87: ; preds = %83
%88 = load i32*, i32** %7
%89 = call i32 @getlong(i32* %88)
store i32 %89, i32* %17
%90 = load i32, i32* %17
%91 = icmp eq i32 %90, 1751474532
br i1 %91, label %92, label %94
92: ; preds = %87
%93 = load i32, i32* %12
store i32 %93, i32* %16
br label %94
94: ; preds = %92, %87
%95 = load i32*, i32** %11
%96 = load i32, i32* %17
%97 = call i32 @putlong(i32* %95, i32 %96)
%98 = load i32*, i32** %11
%99 = load i32*, i32** %7
%100 = call i32 @getlong(i32* %99)
%101 = call i32 @putlong(i32* %98, i32 %100)
%102 = load i32*, i32** %11
%103 = load i32*, i32** %7
%104 = call i32 @getlong(i32* %103)
%105 = load i32*, i32** %14
%106 = load i32, i32* %12
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i32, i32* %105, i64 %107
store i32 %104, i32* %108
%109 = call i32 @putlong(i32* %102, i32 %104)
%110 = load i32*, i32** %11
%111 = load i32*, i32** %7
%112 = call i32 @getlong(i32* %111)
%113 = load i32*, i32** %15
%114 = load i32, i32* %12
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %113, i64 %115
store i32 %112, i32* %116
%117 = call i32 @putlong(i32* %110, i32 %112)
br label %118
118: ; preds = %94
%119 = load i32, i32* %12
%120 = add nsw i32 %119, 1
store i32 %120, i32* %12
br label %83
121: ; preds = %83
store i32 -1, i32* %19
store i32 0, i32* %12
br label %122
122: ; preds = %168, %121
%123 = load i32, i32* %12
%124 = load i32, i32* %13
%125 = icmp slt i32 %123, %124
br i1 %125, label %126, label %171
126: ; preds = %122
%127 = load i32*, i32** %11
%128 = call i32 @ftell(i32* %127)
store i32 %128, i32* %18
%129 = load i32*, i32** %11
%130 = load i32*, i32** %7
%131 = load i32*, i32** %14
%132 = load i32, i32* %12
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i32, i32* %131, i64 %133
%135 = load i32, i32* %134
%136 = load i32*, i32** %15
%137 = load i32, i32* %12
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i32, i32* %136, i64 %138
%140 = load i32, i32* %139
%141 = call i32 @copytable(i32* %129, i32* %130, i32 %135, i32 %140)
%142 = load i32, i32* %12
%143 = load i32, i32* %16
%144 = icmp eq i32 %142, %143
br i1 %144, label %145, label %154
145: ; preds = %126
%146 = load i32*, i32** %11
%147 = load i32, i32* %18
%148 = add nsw i32 %147, 8
%149 = load i32, i32* @SEEK_SET
%150 = call i32 @fseek(i32* %146, i32 %148, i32 %149)
%151 = load i32*, i32** %11
%152 = call i32 @putlong(i32* %151, i32 0)
%153 = load i32, i32* %18
store i32 %153, i32* %19
br label %154
154: ; preds = %145, %126
%155 = load i32*, i32** %11
%156 = load i32, i32* %12
%157 = mul nsw i32 %156, 16
%158 = add nsw i32 12, %157
%159 = add nsw i32 %158, 8
%160 = load i32, i32* @SEEK_SET
%161 = call i32 @fseek(i32* %155, i32 %159, i32 %160)
%162 = load i32*, i32** %11
%163 = load i32, i32* %18
%164 = call i32 @putlong(i32* %162, i32 %163)
%165 = load i32*, i32** %11
%166 = load i32, i32* @SEEK_END
%167 = call i32 @fseek(i32* %165, i32 0, i32 %166)
br label %168
168: ; preds = %154
%169 = load i32, i32* %12
%170 = add nsw i32 %169, 1
store i32 %170, i32* %12
br label %122
171: ; preds = %122
%172 = load i32, i32* %19
%173 = icmp ne i32 %172, -1
br i1 %173, label %174, label %189
174: ; preds = %171
%175 = load i32*, i32** %11
%176 = call i32 @filecheck(i32* %175)
store i32 %176, i32* %20
%177 = load i32, i32* %20
%178 = sub i32 -1313820742, %177
store i32 %178, i32* %20
%179 = load i32*, i32** %11
%180 = load i32, i32* %19
%181 = sext i32 %180 to i64
%182 = add i64 %181, 8
%183 = trunc i64 %182 to i32
%184 = load i32, i32* @SEEK_SET
%185 = call i32 @fseek(i32* %179, i32 %183, i32 %184)
%186 = load i32*, i32** %11
%187 = load i32, i32* %20
%188 = call i32 @putlong(i32* %186, i32 %187)
br label %189
189: ; preds = %174, %171
%190 = load i32*, i32** %11
%191 = call i32 @fclose(i32* %190)
%192 = load i32*, i32** %14
%193 = call i32 @free(i32* %192)
%194 = load i32*, i32** %15
%195 = call i32 @free(i32* %194)
br label %196
196: ; preds = %189, %42
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"_%02d.ttf\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [31 x i8] c"Failed to open %s for output.\0A\00"
@.str.3 = [4 x i8] c"%s \00"
@SEEK_SET = global i32 0
@SEEK_END = global i32 0
define void @handlefont(i8* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca [2000 x i8]
%6 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* %0)
%8 = call i8* @strrchr(i8* %6, i8 signext 46)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = call i32 @strlen(i8* %6)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 %12
br label %14
14: ; preds = %10, %4
%15 = phi i8* [ %13, %10 ], [ %8, %4 ]
%16 = call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1)
%17 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %104
22: ; preds = %14
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%24 = load i32, i32* @SEEK_SET
%25 = call i32 @fseek(i32* %2, i32 %3, i32 %24)
%26 = call i32 @getlong(i32* %2)
%27 = call i32 @putlong(i32* %17, i32 %26)
%28 = call i32 @getushort(i32* %2)
%29 = call i32 @putshort(i32* %17, i32 %28)
%30 = call i32 @getushort(i32* %2)
%31 = call i32 @putshort(i32* %17, i32 %30)
%32 = call i32 @getushort(i32* %2)
%33 = call i32 @putshort(i32* %17, i32 %32)
%34 = call i32 @getushort(i32* %2)
%35 = call i32 @putshort(i32* %17, i32 %34)
%36 = shl i32 %28, 2
%37 = call i32* @malloc(i32 %36)
%38 = call i32* @malloc(i32 %36)
%39 = icmp sgt i32 %28, 0
br i1 %39, label %40, label %100
40: ; preds = %22
%41 = zext i32 %28 to i64
br label %46
42: ; preds = %46
%43 = zext i32 %52 to i64
br i1 %39, label %44, label %100
44: ; preds = %42
%45 = zext i32 %28 to i64
br label %64
46: ; preds = %40, %46
%47 = phi i64 [ 0, %40 ], [ %62, %46 ]
%48 = phi i32 [ -1, %40 ], [ %52, %46 ]
%49 = call i32 @getlong(i32* %2)
%50 = icmp eq i32 %49, 1751474532
%51 = trunc i64 %47 to i32
%52 = select i1 %50, i32 %51, i32 %48
%53 = call i32 @putlong(i32* %17, i32 %49)
%54 = call i32 @getlong(i32* %2)
%55 = call i32 @putlong(i32* %17, i32 %54)
%56 = call i32 @getlong(i32* %2)
%57 = getelementptr inbounds i32, i32* %37, i64 %47
store i32 %56, i32* %57
%58 = call i32 @putlong(i32* %17, i32 %56)
%59 = call i32 @getlong(i32* %2)
%60 = getelementptr inbounds i32, i32* %38, i64 %47
store i32 %59, i32* %60
%61 = call i32 @putlong(i32* %17, i32 %59)
%62 = add nuw nsw i64 %47, 1
%63 = icmp eq i64 %62, %41
br i1 %63, label %42, label %46
64: ; preds = %44, %79
%65 = phi i64 [ 0, %44 ], [ %89, %79 ]
%66 = phi i32 [ -1, %44 ], [ %80, %79 ]
%67 = call i32 @ftell(i32* %17)
%68 = getelementptr inbounds i32, i32* %37, i64 %65
%69 = load i32, i32* %68
%70 = getelementptr inbounds i32, i32* %38, i64 %65
%71 = load i32, i32* %70
%72 = call i32 @copytable(i32* %17, i32* %2, i32 %69, i32 %71)
%73 = icmp eq i64 %65, %43
br i1 %73, label %74, label %79
74: ; preds = %64
%75 = add nsw i32 %67, 8
%76 = load i32, i32* @SEEK_SET
%77 = call i32 @fseek(i32* %17, i32 %75, i32 %76)
%78 = call i32 @putlong(i32* %17, i32 0)
br label %79
79: ; preds = %74, %64
%80 = phi i32 [ %67, %74 ], [ %66, %64 ]
%81 = trunc i64 %65 to i32
%82 = shl nsw i32 %81, 4
%83 = add nuw i32 %82, 20
%84 = load i32, i32* @SEEK_SET
%85 = call i32 @fseek(i32* %17, i32 %83, i32 %84)
%86 = call i32 @putlong(i32* %17, i32 %67)
%87 = load i32, i32* @SEEK_END
%88 = call i32 @fseek(i32* %17, i32 0, i32 %87)
%89 = add nuw nsw i64 %65, 1
%90 = icmp eq i64 %89, %45
br i1 %90, label %91, label %64
91: ; preds = %79
%92 = icmp eq i32 %80, -1
br i1 %92, label %100, label %93
93: ; preds = %91
%94 = call i32 @filecheck(i32* %17)
%95 = sub i32 -1313820742, %94
%96 = add i32 %80, 8
%97 = load i32, i32* @SEEK_SET
%98 = call i32 @fseek(i32* %17, i32 %96, i32 %97)
%99 = call i32 @putlong(i32* %17, i32 %95)
br label %100
100: ; preds = %22, %42, %93, %91
%101 = call i32 @fclose(i32* %17)
%102 = call i32 @free(i32* %37)
%103 = call i32 @free(i32* %38)
br label %104
104: ; preds = %100, %19
ret void
}