#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 */
struct stat {
  int /*<<< orphan*/ st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fstat(int, struct stat *);
int /*<<< orphan*/ handle_pcf(void *);
int /*<<< orphan*/ init_data_buffer();
void *mmap(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ output_interesting_cursors(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s input.pcf output.h\n", argv[0]);
    return EXIT_FAILURE;
  }
  int fd = open(argv[1], O_RDONLY);
  struct stat filestat;
  fstat(fd, &filestat);
  void *fontbuf = mmap(NULL, filestat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
  handle_pcf(fontbuf);
  init_data_buffer();
  FILE *file = fopen(argv[2], "w");
  output_interesting_cursors(file);
  fclose(file);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11dd <main+0x4d>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe39(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1271 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10b0 <fstat@plt>
mov    -0x18(%rbp),%esi
mov    0x2dec(%rip),%rax
mov    (%rax),%edx
mov    0x2da3(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <handle_pcf@plt>
mov    $0x0,%al
call   1030 <init_data_buffer@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <output_interesting_cursors@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1216 <main+0x86>
mov    0x8(%rbx),%rdi
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
call   10b0 <fstat@plt>
mov    (%rsp),%esi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
mov    0x2dec(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rdi
call   1050 <handle_pcf@plt>
xor    %eax,%eax
call   1030 <init_data_buffer@plt>
mov    0x10(%rbx),%rdi
lea    0xe29(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <output_interesting_cursors@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2dac(%rip),%rax
jmp    1235 <main+0xa5>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdd7(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s input.pcf output.h\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str.1 = [2 x i8] c"w\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca i8*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %45
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = call i32 @open(i8* %22, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = call i32 @fstat(i32 %25, %struct.stat* %7)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @MAP_PRIVATE
%31 = load i32, i32* %6
%32 = call i8* @mmap(i32* null, i32 %28, i32 %29, i32 %30, i32 %31, i32 0)
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = call i32 @handle_pcf(i8* %33)
%35 = call i32 (...) @init_data_buffer()
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %9
%40 = load i32*, i32** %9
%41 = call i32 @output_interesting_cursors(i32* %40)
%42 = load i32*, i32** %9
%43 = call i32 @fclose(i32* %42)
%44 = load i32, i32* @EXIT_SUCCESS
store i32 %44, i32* %3
br label %45
45: ; preds = %19, %12
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s input.pcf output.h\0A\00"
@EXIT_FAILURE = global i32 0
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_PRIVATE = global i32 0
@.str.1 = [2 x i8] c"w\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp eq i32 %0, 3
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
br label %30
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = bitcast %struct.stat* %3 to i8*
%16 = call i32 @fstat(i32 %14, %struct.stat* %3)
%17 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%18 = load i32, i32* %17
%19 = load i32, i32* @PROT_READ
%20 = load i32, i32* @MAP_PRIVATE
%21 = tail call i8* @mmap(i32* null, i32 %18, i32 %19, i32 %20, i32 %14, i32 0)
%22 = tail call i32 @handle_pcf(i8* %21)
%23 = tail call i32 (...) @init_data_buffer()
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @output_interesting_cursors(i32* %26)
%28 = tail call i32 @fclose(i32* %26)
%29 = load i32, i32* @EXIT_SUCCESS
br label %30
30: ; preds = %10, %5
%31 = phi i32 [ %9, %5 ], [ %29, %10 ]
ret i32 %31
}