#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, ...);
int dump_font(const char *filename, const char *name) {
  int c;
  FILE *f;
  int j;
  f = fopen(filename, "rb");
  if (!f) {
    perror(filename);
    exit(1);
  }
  printf("static unsigned char const font_%s[] = {\n", name);
  j = 0;
  for (;;) {
    c = getc(f);
    if (c == EOF)
      break;
    if ((j & 7) == 0)
      printf("   ");
    j++;
    printf(" 0x%02x,", c);
    if ((j & 7) == 0)
      printf("\n");
  }
  if ((j & 7) != 0)
    printf("\n");
  printf("};\n\n");
  fclose(f);
  return j;
}


x86 assembly (clang, -O0):
<dump_font>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a2 <dump_font+0x42>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
jne    11de <dump_font+0x7e>
jmp    1237 <dump_font+0xd7>
mov    -0x24(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    11fb <dump_font+0x9b>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1232 <dump_font+0xd2>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bb <dump_font+0x5b>
mov    -0x24(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
je     1254 <dump_font+0xf4>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_font>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe68(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1266 <dump_font+0xe6>
mov    %rax,%r12
lea    0xe53(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   10a0 <getc@plt>
mov    0x2e1d(%rip),%r13
cmp    0x0(%r13),%eax
je     1241 <dump_font+0xc1>
mov    %eax,%ebx
lea    0xe53(%rip),%r14
lea    0xe50(%rip),%r15
xor    %ebp,%ebp
jmp    1200 <dump_font+0x80>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   10a0 <getc@plt>
mov    %eax,%ebx
cmp    0x0(%r13),%eax
je     1231 <dump_font+0xb1>
test   $0x7,%bpl
jne    1210 <dump_font+0x90>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   $0x7,%bpl
jne    11f0 <dump_font+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <dump_font+0x70>
test   $0x7,%bpl
je     1241 <dump_font+0xc1>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [42 x i8] c"static unsigned char const font_%s[] = {\0A\00"
@EOF = global i32 0
@.str.2 = [4 x i8] c" \00"
@.str.3 = [9 x i8] c" 0x%02x,\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [5 x i8] c"};\0A\0A\00"
define i32 @dump_font(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @perror(i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 0, i32* %7
br label %19
19: ; preds = %42, %16
%20 = load i32*, i32** %6
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %19
br label %43
26: ; preds = %19
%27 = load i32, i32* %7
%28 = and i32 %27, 7
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %7
%38 = and i32 %37, 7
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %32
br label %19
43: ; preds = %25
%44 = load i32, i32* %7
%45 = and i32 %44, 7
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
%53 = load i32, i32* %7
ret i32 %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [42 x i8] c"static unsigned char const font_%s[] = {\0A\00"
@EOF = global i32 0
@.str.2 = [4 x i8] c" \00"
@.str.3 = [9 x i8] c" 0x%02x,\00"
@str = [4 x i8] c"};\0A\00"
define i32 @dump_font(i8* nocapture %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @perror(i8* %0)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = tail call i32 @getc(i32* %3)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %36, label %13
13: ; preds = %8, %27
%14 = phi i32 [ %28, %27 ], [ %10, %8 ]
%15 = phi i32 [ %21, %27 ], [ 0, %8 ]
%16 = and i32 %15, 7
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = add nuw nsw i32 %15, 1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%23 = and i32 %21, 7
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 @putchar(i32 10)
br label %27
27: ; preds = %25, %20
%28 = tail call i32 @getc(i32* %3)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %13
31: ; preds = %27
%32 = and i32 %21, 7
%33 = icmp eq i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = tail call i32 @putchar(i32 10)
br label %36
36: ; preds = %8, %34, %31
%37 = phi i32 [ %21, %34 ], [ %21, %31 ], [ 0, %8 ]
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%39 = tail call i32 @fclose(i32* %3)
ret i32 %37
}