#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ help();
int /*<<< orphan*/ pack_nametable(unsigned char *, int, int, int, int,
                                  unsigned char **, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int strtol(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ version();
int main(int argc, char **argv) {
  unsigned char nametable[1024];
  int nametable_sz;
  unsigned char *out;
  int out_sz;
  int width = 32;
  int vram_address = 0x2000;
  int verbose = 0;
  int zero_terminate = 0;
  const char *input_filename = 0;
  const char *output_filename = 0;
  {
    char *p;
    while ((p = *(++argv))) {
      if (!strncmp("--", p, 2)) {
        const char *opt = &p[2];
        if (!strncmp("width=", opt, 6)) {
          width = strtol(&opt[6], 0, 0);
        } else if (!strncmp("vram-address=", opt, 13)) {
          vram_address = strtol(&opt[13], 0, 0);
        } else if (!strncmp("output=", opt, 7)) {
          output_filename = &opt[7];
        } else if (!strcmp("zero-terminate", opt)) {
          zero_terminate = 1;
        } else if (!strcmp("verbose", opt)) {
          verbose = 1;
        } else if (!strcmp("help", opt)) {
          help();
        } else if (!strcmp("usage", opt)) {
          usage();
        } else if (!strcmp("version", opt)) {
          version();
        } else {
          fprintf(stderr,
                  "packnam: unrecognized option `%s'\n"
                  "Try `packnam --help' or `packnam --usage' for more "
                  "information.\n",
                  p);
          return (-1);
        }
      } else {
        input_filename = p;
      }
    }
  }
  if (!input_filename) {
    fprintf(
        stderr,
        "packnam: no filename given\n"
        "Try `packnam --help' or `packnam --usage' for more information.\n");
    return (-1);
  }
  if (verbose)
    fprintf(stdout, "reading `%s'\n", input_filename);
  {
    FILE *fp = fopen(input_filename, "rb");
    if (!fp) {
      fprintf(stderr, "packnam: failed to open `%s' for reading\n",
              input_filename);
      return (-1);
    }
    nametable_sz = fread(nametable, 1, 1024, fp);
    fclose(fp);
  }
  if (verbose)
    fprintf(stdout, "processing\n");
  pack_nametable(nametable, nametable_sz, width, vram_address, zero_terminate,
                 &out, &out_sz);
  if (!output_filename)
    output_filename = "packnam.dat";
  if (verbose)
    fprintf(stdout, "writing data to `%s'\n", output_filename);
  {
    FILE *fp = fopen(output_filename, "wb");
    fwrite(out, 1, out_sz, fp);
    fclose(fp);
  }
  if (verbose)
    fprintf(stdout, "compressed size: %d%%\n", (out_sz * 100) / nametable_sz);
  free(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x20,-0x428(%rbp)
movl   $0x2000,-0x42c(%rbp)
movl   $0x0,-0x430(%rbp)
movl   $0x0,-0x434(%rbp)
movq   $0x0,-0x440(%rbp)
movq   $0x0,-0x448(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x450(%rbp)
cmp    $0x0,%rax
je     1469 <main+0x299>
mov    -0x450(%rbp),%rsi
lea    0xda7(%rip),%rdi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1456 <main+0x286>
mov    -0x450(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x458(%rbp)
mov    -0x458(%rbp),%rsi
lea    0xd77(%rip),%rdi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12be <main+0xee>
mov    -0x458(%rbp),%rdi
add    $0x6,%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <strtol@plt>
mov    %eax,-0x428(%rbp)
jmp    1451 <main+0x281>
mov    -0x458(%rbp),%rsi
lea    0xd3e(%rip),%rdi
mov    $0xd,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12fe <main+0x12e>
mov    -0x458(%rbp),%rdi
add    $0xd,%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <strtol@plt>
mov    %eax,-0x42c(%rbp)
jmp    144c <main+0x27c>
mov    -0x458(%rbp),%rsi
lea    0xd0c(%rip),%rdi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1336 <main+0x166>
mov    -0x458(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x448(%rbp)
jmp    1447 <main+0x277>
mov    -0x458(%rbp),%rsi
lea    0xcdc(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1361 <main+0x191>
movl   $0x1,-0x434(%rbp)
jmp    1442 <main+0x272>
mov    -0x458(%rbp),%rsi
lea    0xcc0(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    138c <main+0x1bc>
movl   $0x1,-0x430(%rbp)
jmp    143d <main+0x26d>
mov    -0x458(%rbp),%rsi
lea    0xc9d(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    13b4 <main+0x1e4>
mov    $0x0,%al
call   10d0 <help@plt>
jmp    1438 <main+0x268>
mov    -0x458(%rbp),%rsi
lea    0xc7a(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    13dc <main+0x20c>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    1433 <main+0x263>
mov    -0x458(%rbp),%rsi
lea    0xc58(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1404 <main+0x234>
mov    $0x0,%al
call   10a0 <version@plt>
jmp    142e <main+0x25e>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
mov    -0x450(%rbp),%rdx
lea    0xc2f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1673 <main+0x4a3>
jmp    1433 <main+0x263>
jmp    1438 <main+0x268>
jmp    143d <main+0x26d>
jmp    1442 <main+0x272>
jmp    1447 <main+0x277>
jmp    144c <main+0x27c>
jmp    1451 <main+0x281>
jmp    1464 <main+0x294>
mov    -0x450(%rbp),%rax
mov    %rax,-0x440(%rbp)
jmp    1227 <main+0x57>
cmpq   $0x0,-0x440(%rbp)
jne    149a <main+0x2ca>
mov    0x2b62(%rip),%rax
mov    (%rax),%edi
lea    0xc26(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1673 <main+0x4a3>
cmpl   $0x0,-0x430(%rbp)
je     14c5 <main+0x2f5>
mov    0x2b2a(%rip),%rax
mov    (%rax),%edi
mov    -0x440(%rbp),%rdx
lea    0xc4b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x440(%rbp),%rdi
lea    0xc44(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x460(%rbp)
cmpq   $0x0,-0x460(%rbp)
jne    1517 <main+0x347>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
mov    -0x440(%rbp),%rdx
lea    0xc16(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1673 <main+0x4a3>
lea    -0x410(%rbp),%rdi
mov    -0x460(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1050 <fread@plt>
mov    %eax,-0x414(%rbp)
mov    -0x460(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x430(%rbp)
je     156a <main+0x39a>
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x414(%rbp),%esi
mov    -0x428(%rbp),%edx
mov    -0x42c(%rbp),%ecx
mov    -0x434(%rbp),%r8d
lea    -0x420(%rbp),%r9
lea    -0x424(%rbp),%rax
mov    %rax,(%rsp)
call   10e0 <pack_nametable@plt>
cmpq   $0x0,-0x448(%rbp)
jne    15bd <main+0x3ed>
lea    0xb9a(%rip),%rax
mov    %rax,-0x448(%rbp)
cmpl   $0x0,-0x430(%rbp)
je     15e8 <main+0x418>
mov    0x2a07(%rip),%rax
mov    (%rax),%edi
mov    -0x448(%rbp),%rdx
lea    0xb7b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x448(%rbp),%rdi
lea    0xb7c(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x468(%rbp)
mov    -0x420(%rbp),%rdi
mov    -0x424(%rbp),%edx
mov    -0x468(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    -0x468(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x0,-0x430(%rbp)
je     1660 <main+0x490>
mov    0x2998(%rip),%rax
mov    (%rax),%edi
imul   $0x64,-0x424(%rbp),%eax
cltd
idivl  -0x414(%rbp)
mov    %eax,%edx
lea    0xb1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x420(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    0x8(%rsi),%rbx
test   %rbx,%rbx
je     14c5 <main+0x2f5>
mov    %rsi,%rbp
add    $0x10,%rbp
movl   $0x2000,0x14(%rsp)
movl   $0x20,0x18(%rsp)
lea    0xdf4(%rip),%r13
lea    0xdf0(%rip),%r14
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %r15d,%r15d
movl   $0x0,0x10(%rsp)
movl   $0x0,0x1c(%rsp)
jmp    1244 <main+0x74>
nop
mov    %rbx,%r15
mov    0x0(%rbp),%rbx
add    $0x8,%rbp
test   %rbx,%rbx
je     139d <main+0x1cd>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1230 <main+0x60>
lea    0x2(%rbx),%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     132b <main+0x15b>
lea    0xd8f(%rip),%rdi
mov    %r12,%rsi
mov    $0xd,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1344 <main+0x174>
lea    0xd81(%rip),%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     135d <main+0x18d>
lea    0xd6d(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     136b <main+0x19b>
lea    0xd65(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1378 <main+0x1a8>
lea    0xd56(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1385 <main+0x1b5>
lea    0xd44(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1391 <main+0x1c1>
lea    0xd33(%rip),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    158d <main+0x3bd>
xor    %eax,%eax
call   10a0 <version@plt>
jmp    1233 <main+0x63>
add    $0x8,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,0x18(%rsp)
jmp    1233 <main+0x63>
add    $0xf,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,0x14(%rsp)
jmp    1233 <main+0x63>
add    $0x9,%rbx
mov    %rbx,0x28(%rsp)
jmp    1233 <main+0x63>
movl   $0x1,0x10(%rsp)
jmp    1233 <main+0x63>
movl   $0x1,0x1c(%rsp)
jmp    1233 <main+0x63>
xor    %eax,%eax
call   10d0 <help@plt>
jmp    1233 <main+0x63>
xor    %eax,%eax
call   10b0 <usage@plt>
jmp    1233 <main+0x63>
test   %r15,%r15
je     14c5 <main+0x2f5>
mov    0x1c(%rsp),%ebx
test   %ebx,%ebx
je     13c8 <main+0x1f8>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xd48(%rip),%rsi
mov    %r15,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14e6 <main+0x316>
mov    %rax,%rbp
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1060 <fclose@plt>
test   %ebx,%ebx
je     1507 <main+0x337>
mov    0x2bc4(%rip),%r14
mov    (%r14),%edi
lea    0xd26(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0x30(%rsp),%rdi
lea    0x20(%rsp),%r9
mov    %r15d,%esi
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
call   10e0 <pack_nametable@plt>
mov    0x28(%rsp),%rax
test   %rax,%rax
lea    0xcf4(%rip),%rbp
cmovne %rax,%rbp
mov    (%r14),%edi
lea    0xcf2(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xcf7(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbp
mov    0x20(%rsp),%rdi
mov    0xc(%rsp),%edx
mov    $0x1,%esi
mov    %rax,%rcx
call   10f0 <fwrite@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    (%r14),%edi
imul   $0x64,0xc(%rsp),%eax
cltd
idiv   %r15d
lea    0xcbe(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    156f <main+0x39f>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
lea    0xbd8(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    157b <main+0x3ab>
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
lea    0xc24(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    157b <main+0x3ab>
lea    0xc(%rsp),%rax
mov    %rax,(%rsp)
lea    0x30(%rsp),%rdi
lea    0x20(%rsp),%r9
mov    %r15d,%esi
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%r8d
call   10e0 <pack_nametable@plt>
mov    0x28(%rsp),%rax
test   %rax,%rax
lea    0xc12(%rip),%rdi
cmovne %rax,%rdi
lea    0xc29(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    0x20(%rsp),%rdi
mov    0xc(%rsp),%edx
mov    $0x1,%esi
mov    %rax,%rcx
call   10f0 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a4c(%rip),%rax
mov    (%rax),%edi
lea    0xaad(%rip),%rsi
mov    %rbx,%rdx
jmp    14f9 <main+0x329>

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
@.str.1 = [7 x i8] c"width=\00"
@.str.2 = [14 x i8] c"vram-address=\00"
@.str.3 = [8 x i8] c"output=\00"
@.str.4 = [15 x i8] c"zero-terminate\00"
@.str.5 = [8 x i8] c"verbose\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [6 x i8] c"usage\00"
@.str.8 = [8 x i8] c"version\00"
@stderr = global i32 0
@.str.9 = [99 x i8] c"packnam: unrecognized option `%s'\0ATry `packnam --help' or `packnam --usage' for more information.\0A\00"
@.str.10 = [92 x i8] c"packnam: no filename given\0ATry `packnam --help' or `packnam --usage' for more information.\0A\00"
@stdout = global i32 0
@.str.11 = [14 x i8] c"reading `%s'\0A\00"
@.str.12 = [3 x i8] c"rb\00"
@.str.13 = [42 x i8] c"packnam: failed to open `%s' for reading\0A\00"
@.str.14 = [12 x i8] c"processing\0A\00"
@.str.15 = [12 x i8] c"packnam.dat\00"
@.str.16 = [22 x i8] c"writing data to `%s'\0A\00"
@.str.17 = [3 x i8] c"wb\00"
@.str.18 = [23 x i8] c"compressed size: %d%%\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32*
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 32, i32* %10
store i32 8192, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i8* null, i8** %14
store i8* null, i8** %15
br label %20
20: ; preds = %96, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %5
%23 = load i8*, i8** %22
store i8* %23, i8** %16
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %97
25: ; preds = %20
%26 = load i8*, i8** %16
%27 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26, i32 2)
%28 = icmp ne i32 %27, 0
br i1 %28, label %94, label %29
29: ; preds = %25
%30 = load i8*, i8** %16
%31 = getelementptr inbounds i8, i8* %30, i64 2
store i8* %31, i8** %17
%32 = load i8*, i8** %17
%33 = call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %32, i32 6)
%34 = icmp ne i32 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %29
%36 = load i8*, i8** %17
%37 = getelementptr inbounds i8, i8* %36, i64 6
%38 = call i32 @strtol(i8* %37, i32 0, i32 0)
store i32 %38, i32* %10
br label %93
39: ; preds = %29
%40 = load i8*, i8** %17
%41 = call i32 @strncmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %40, i32 13)
%42 = icmp ne i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i8*, i8** %17
%45 = getelementptr inbounds i8, i8* %44, i64 13
%46 = call i32 @strtol(i8* %45, i32 0, i32 0)
store i32 %46, i32* %11
br label %92
47: ; preds = %39
%48 = load i8*, i8** %17
%49 = call i32 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %48, i32 7)
%50 = icmp ne i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %47
%52 = load i8*, i8** %17
%53 = getelementptr inbounds i8, i8* %52, i64 7
store i8* %53, i8** %15
br label %91
54: ; preds = %47
%55 = load i8*, i8** %17
%56 = call i32 @strcmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %59, label %58
58: ; preds = %54
store i32 1, i32* %13
br label %90
59: ; preds = %54
%60 = load i8*, i8** %17
%61 = call i32 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %59
store i32 1, i32* %12
br label %89
64: ; preds = %59
%65 = load i8*, i8** %17
%66 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %65)
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = call i32 (...) @help()
br label %88
70: ; preds = %64
%71 = load i8*, i8** %17
%72 = call i32 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %71)
%73 = icmp ne i32 %72, 0
br i1 %73, label %76, label %74
74: ; preds = %70
%75 = call i32 (...) @usage()
br label %87
76: ; preds = %70
%77 = load i8*, i8** %17
%78 = call i32 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %76
%81 = call i32 (...) @version()
br label %86
82: ; preds = %76
%83 = load i32, i32* @stderr
%84 = load i8*, i8** %16
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.9, i64 0, i64 0), i8* %84)
store i32 -1, i32* %3
br label %168
86: ; preds = %80
br label %87
87: ; preds = %86, %74
br label %88
88: ; preds = %87, %68
br label %89
89: ; preds = %88, %63
br label %90
90: ; preds = %89, %58
br label %91
91: ; preds = %90, %51
br label %92
92: ; preds = %91, %43
br label %93
93: ; preds = %92, %35
br label %96
94: ; preds = %25
%95 = load i8*, i8** %16
store i8* %95, i8** %14
br label %96
96: ; preds = %94, %93
br label %20
97: ; preds = %20
%98 = load i8*, i8** %14
%99 = icmp ne i8* %98, null
br i1 %99, label %103, label %100
100: ; preds = %97
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %3
br label %168
103: ; preds = %97
%104 = load i32, i32* %12
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %103
%107 = load i32, i32* @stdout
%108 = load i8*, i8** %14
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %108)
br label %110
110: ; preds = %106, %103
%111 = load i8*, i8** %14
%112 = call i32* @fopen(i8* %111, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32* %112, i32** %18
%113 = load i32*, i32** %18
%114 = icmp ne i32* %113, null
br i1 %114, label %119, label %115
115: ; preds = %110
%116 = load i32, i32* @stderr
%117 = load i8*, i8** %14
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %117)
store i32 -1, i32* %3
br label %168
119: ; preds = %110
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%121 = load i32*, i32** %18
%122 = call i32 @fread(i8* %120, i32 1, i32 1024, i32* %121)
store i32 %122, i32* %7
%123 = load i32*, i32** %18
%124 = call i32 @fclose(i32* %123)
%125 = load i32, i32* %12
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %119
%128 = load i32, i32* @stdout
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
br label %130
130: ; preds = %127, %119
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%132 = load i32, i32* %7
%133 = load i32, i32* %10
%134 = load i32, i32* %11
%135 = load i32, i32* %13
%136 = call i32 @pack_nametable(i8* %131, i32 %132, i32 %133, i32 %134, i32 %135, i8** %8, i32* %9)
%137 = load i8*, i8** %15
%138 = icmp ne i8* %137, null
br i1 %138, label %140, label %139
139: ; preds = %130
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8** %15
br label %140
140: ; preds = %139, %130
%141 = load i32, i32* %12
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %147
143: ; preds = %140
%144 = load i32, i32* @stdout
%145 = load i8*, i8** %15
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0), i8* %145)
br label %147
147: ; preds = %143, %140
%148 = load i8*, i8** %15
%149 = call i32* @fopen(i8* %148, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
store i32* %149, i32** %19
%150 = load i8*, i8** %8
%151 = load i32, i32* %9
%152 = load i32*, i32** %19
%153 = call i32 @fwrite(i8* %150, i32 1, i32 %151, i32* %152)
%154 = load i32*, i32** %19
%155 = call i32 @fclose(i32* %154)
%156 = load i32, i32* %12
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %165
158: ; preds = %147
%159 = load i32, i32* @stdout
%160 = load i32, i32* %9
%161 = mul nsw i32 %160, 100
%162 = load i32, i32* %7
%163 = sdiv i32 %161, %162
%164 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %163)
br label %165
165: ; preds = %158, %147
%166 = load i8*, i8** %8
%167 = call i32 @free(i8* %166)
store i32 0, i32* %3
br label %168
168: ; preds = %165, %115, %100, %82
%169 = load i32, i32* %3
ret i32 %169
}

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
@.str.1 = [7 x i8] c"width=\00"
@.str.2 = [14 x i8] c"vram-address=\00"
@.str.3 = [8 x i8] c"output=\00"
@.str.4 = [15 x i8] c"zero-terminate\00"
@.str.5 = [8 x i8] c"verbose\00"
@.str.6 = [5 x i8] c"help\00"
@.str.7 = [6 x i8] c"usage\00"
@.str.8 = [8 x i8] c"version\00"
@stderr = global i32 0
@.str.9 = [99 x i8] c"packnam: unrecognized option `%s'\0ATry `packnam --help' or `packnam --usage' for more information.\0A\00"
@.str.10 = [92 x i8] c"packnam: no filename given\0ATry `packnam --help' or `packnam --usage' for more information.\0A\00"
@stdout = global i32 0
@.str.11 = [14 x i8] c"reading `%s'\0A\00"
@.str.12 = [3 x i8] c"rb\00"
@.str.13 = [42 x i8] c"packnam: failed to open `%s' for reading\0A\00"
@.str.14 = [12 x i8] c"processing\0A\00"
@.str.15 = [12 x i8] c"packnam.dat\00"
@.str.16 = [22 x i8] c"writing data to `%s'\0A\00"
@.str.17 = [3 x i8] c"wb\00"
@.str.18 = [23 x i8] c"compressed size: %d%%\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = bitcast i8** %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %77, label %12
12: ; preds = %2, %62
%13 = phi i8* [ %70, %62 ], [ %10, %2 ]
%14 = phi i8** [ %69, %62 ], [ %9, %2 ]
%15 = phi i32 [ %68, %62 ], [ 32, %2 ]
%16 = phi i8* [ %67, %62 ], [ null, %2 ]
%17 = phi i8* [ %66, %62 ], [ null, %2 ]
%18 = phi i32 [ %65, %62 ], [ 0, %2 ]
%19 = phi i32 [ %64, %62 ], [ 0, %2 ]
%20 = phi i32 [ %63, %62 ], [ 8192, %2 ]
%21 = tail call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13, i32 2)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %62
23: ; preds = %12
%24 = getelementptr inbounds i8, i8* %13, i64 2
%25 = tail call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32 6)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = getelementptr inbounds i8, i8* %13, i64 8
%29 = tail call i32 @strtol(i8* %28, i32 0, i32 0)
br label %62
30: ; preds = %23
%31 = tail call i32 @strncmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 13)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = getelementptr inbounds i8, i8* %13, i64 15
%35 = tail call i32 @strtol(i8* %34, i32 0, i32 0)
br label %62
36: ; preds = %30
%37 = tail call i32 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %24, i32 7)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = getelementptr inbounds i8, i8* %13, i64 9
br label %62
41: ; preds = %36
%42 = tail call i32 @strcmp(i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%43 = icmp eq i32 %42, 0
br i1 %43, label %62, label %44
44: ; preds = %41
%45 = tail call i32 @strcmp(i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%46 = icmp eq i32 %45, 0
br i1 %46, label %62, label %47
47: ; preds = %44
%48 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = tail call i32 (...) @help()
br label %62
52: ; preds = %47
%53 = tail call i32 @strcmp(i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %24)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = tail call i32 (...) @usage()
br label %62
57: ; preds = %52
%58 = tail call i32 @strcmp(i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %24)
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %72
60: ; preds = %57
%61 = tail call i32 (...) @version()
br label %62
62: ; preds = %27, %39, %55, %60, %50, %33, %41, %44, %12
%63 = phi i32 [ %20, %12 ], [ %20, %44 ], [ %20, %41 ], [ %20, %27 ], [ %35, %33 ], [ %20, %39 ], [ %20, %50 ], [ %20, %55 ], [ %20, %60 ]
%64 = phi i32 [ %19, %12 ], [ 1, %44 ], [ %19, %41 ], [ %19, %27 ], [ %19, %33 ], [ %19, %39 ], [ %19, %50 ], [ %19, %55 ], [ %19, %60 ]
%65 = phi i32 [ %18, %12 ], [ %18, %44 ], [ 1, %41 ], [ %18, %27 ], [ %18, %33 ], [ %18, %39 ], [ %18, %50 ], [ %18, %55 ], [ %18, %60 ]
%66 = phi i8* [ %13, %12 ], [ %17, %44 ], [ %17, %41 ], [ %17, %27 ], [ %17, %33 ], [ %17, %39 ], [ %17, %50 ], [ %17, %55 ], [ %17, %60 ]
%67 = phi i8* [ %16, %12 ], [ %16, %44 ], [ %16, %41 ], [ %16, %27 ], [ %16, %33 ], [ %40, %39 ], [ %16, %50 ], [ %16, %55 ], [ %16, %60 ]
%68 = phi i32 [ %15, %12 ], [ %15, %44 ], [ %15, %41 ], [ %29, %27 ], [ %15, %33 ], [ %15, %39 ], [ %15, %50 ], [ %15, %55 ], [ %15, %60 ]
%69 = getelementptr inbounds i8*, i8** %14, i64 1
%70 = load i8*, i8** %69
%71 = icmp eq i8* %70, null
br i1 %71, label %75, label %12
72: ; preds = %57
%73 = load i32, i32* @stderr
%74 = tail call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.9, i64 0, i64 0), i8* %13)
br label %124
75: ; preds = %62
%76 = icmp eq i8* %66, null
br i1 %76, label %77, label %80
77: ; preds = %2, %75
%78 = load i32, i32* @stderr
%79 = tail call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
br label %124
80: ; preds = %75
%81 = icmp eq i32 %64, 0
br i1 %81, label %85, label %82
82: ; preds = %80
%83 = load i32, i32* @stdout
%84 = tail call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %66)
br label %85
85: ; preds = %82, %80
%86 = tail call i32* @fopen(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i32, i32* @stderr
%90 = tail call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %66)
br label %124
91: ; preds = %85
%92 = call i32 @fread(i8* %6, i32 1, i32 1024, i32* %86)
%93 = tail call i32 @fclose(i32* %86)
br i1 %81, label %112, label %94
94: ; preds = %91
%95 = load i32, i32* @stdout
%96 = tail call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%97 = call i32 @pack_nametable(i8* %6, i32 %92, i32 %68, i32 %63, i32 %65, i8** %4, i32* %5)
%98 = icmp eq i8* %67, null
%99 = select i1 %98, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %67
%100 = load i32, i32* @stdout
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0), i8* %99)
%102 = call i32* @fopen(i8* %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%103 = load i8*, i8** %4
%104 = load i32, i32* %5
%105 = call i32 @fwrite(i8* %103, i32 1, i32 %104, i32* %102)
%106 = call i32 @fclose(i32* %102)
%107 = load i32, i32* @stdout
%108 = load i32, i32* %5
%109 = mul nsw i32 %108, 100
%110 = sdiv i32 %109, %92
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %110)
br label %121
112: ; preds = %91
%113 = call i32 @pack_nametable(i8* %6, i32 %92, i32 %68, i32 %63, i32 %65, i8** %4, i32* %5)
%114 = icmp eq i8* %67, null
%115 = select i1 %114, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* %67
%116 = call i32* @fopen(i8* %115, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%117 = load i8*, i8** %4
%118 = load i32, i32* %5
%119 = call i32 @fwrite(i8* %117, i32 1, i32 %118, i32* %116)
%120 = call i32 @fclose(i32* %116)
br label %121
121: ; preds = %112, %94
%122 = load i8*, i8** %4
%123 = call i32 @free(i8* %122)
br label %124
124: ; preds = %88, %72, %121, %77
%125 = phi i32 [ 0, %121 ], [ -1, %77 ], [ -1, %72 ], [ -1, %88 ]
ret i32 %125
}