#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 */

/* Variables and functions */
long atol(char *);
char *decode(char *, char *, long);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *s;
  long int offset = 0;
  printf("PilFont V1.0, Copyright (C) 1998 David Turnbull\n"
         "PilFont comes with ABSOLUTELY NO WARRANTY\n\n");
  if (argc < 3 || argc > 4)
    goto help;
  if (argc == 4)
    offset = atol(argv[3]);
  s = decode(argv[1], argv[2], offset);
  if (!s)
    exit(0);
  printf("ERROR: %s\n\n", s);
  exit(1);
help:
  printf("Extracts a Pilot font resource to an ASCII\n"
         "file that can be compiled with PilRC.\n\n"
         " usage:  pilfont infile outfile {offset}\n\n");
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
jl     1180 <main+0x40>
cmpl   $0x4,-0x8(%rbp)
jle    1185 <main+0x45>
jmp    11eb <main+0xab>
cmpl   $0x4,-0x8(%rbp)
jne    11a0 <main+0x60>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <decode@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cf <main+0x8f>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    -0x5(%rbx),%eax
cmp    $0xfffffffe,%eax
jae    1183 <main+0x33>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmp    $0x4,%ebx
jne    1196 <main+0x46>
mov    0x18(%r14),%rdi
call   1060 <atol@plt>
mov    %rax,%rdx
jmp    1198 <main+0x48>
xor    %edx,%edx
mov    0x8(%r14),%rdi
mov    0x10(%r14),%rsi
call   1050 <decode@plt>
test   %rax,%rax
jne    11b1 <main+0x61>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe48(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [92 x i8] c"PilFont V1.0, Copyright (C) 1998 David Turnbull\0APilFont comes with ABSOLUTELY NO WARRANTY\0A\0A\00"
@.str.1 = [12 x i8] c"ERROR: %s\0A\0A\00"
@.str.2 = [125 x i8] c"Extracts a Pilot font resource to an ASCII\0Afile that can be compiled with PilRC.\0A\0A usage: pilfont infile outfile {offset}\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 4
br i1 %13, label %14, label %15
14: ; preds = %11, %2
br label %40
15: ; preds = %11
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i64 @atol(i8* %21)
store i64 %22, i64* %7
br label %23
23: ; preds = %18, %15
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = load i64, i64* %7
%31 = call i8* @decode(i8* %26, i8* %29, i64 %30)
store i8* %31, i8** %6
%32 = load i8*, i8** %6
%33 = icmp ne i8* %32, null
br i1 %33, label %36, label %34
34: ; preds = %23
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %23
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %14
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"ERROR: %s\0A\0A\00"
@str = [91 x i8] c"PilFont V1.0, Copyright (C) 1998 David Turnbull\0APilFont comes with ABSOLUTELY NO WARRANTY\0A\00"
@str.3 = [124 x i8] c"Extracts a Pilot font resource to an ASCII\0Afile that can be compiled with PilRC.\0A\0A usage: pilfont infile outfile {offset}\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str, i64 0, i64 0))
%4 = add i32 %0, -5
%5 = icmp ult i32 %4, -2
br i1 %5, label %25, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 4
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i64 @atol(i8* %10)
br label %12
12: ; preds = %8, %6
%13 = phi i64 [ %11, %8 ], [ 0, %6 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i8* @decode(i8* %15, i8* %17, i64 %13)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %12
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @str.3, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
}