#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*/ term;
typedef int /*<<< orphan*/ size;
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
char *basename(char *);
char *calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <lex-file>\n", basename(argv[0]));
    return 1;
  }
  int size;
  char term;
  int histogram[8192];
  char *examples[4][8192];
  for (int i = 0; i < 8192; i++) {
    histogram[i] = 0;
  }
  int count = 0;
  for (int i = 1; i < argc; i++) {
    int fd = open(argv[i], O_RDONLY, 0);
    off_t pos = 0;
    off_t length = lseek(fd, 0, SEEK_END);
    lseek(fd, 0, SEEK_SET);
    while (pos < length) {
      read(fd, &size, sizeof(size));
      if (size < 0) {
        fprintf(stderr, "error at byte %ld, found negative length\n",
                (long int)pos);
        return 2;
      }
      if (size > 1000) {
        fprintf(stderr, "warning at byte %ld, found length of %d\n",
                (long int)pos, size);
      }
      pos += sizeof(size);
      if (size < 8192) {
        histogram[size]++;
        for (int j = 0; j < 4; j++) {
          if (!examples[j][size]) {
            examples[j][size] = calloc(1, size + 1);
            read(fd, examples[j][size], size);
            lseek(fd, pos, SEEK_SET);
            break;
          }
        }
      }
      pos = lseek(fd, size, SEEK_CUR);
      read(fd, &term, sizeof(term));
      if (term != '\0') {
        fprintf(stderr,
                "error at byte %ld, missing NUL, found 0x%02x instead\n",
                (long int)pos, term);
        return 2;
      }
      pos++;
      count++;
    }
  }
  printf("# found %d lexical entries\n", count);
  printf("# len\tfreq\n");
  for (int i = 0; i < 8192; i++) {
    if (histogram[i] > 0)
      printf("%d\t%d\t\n", i, histogram[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x48050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d1 <main+0x61>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4804c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <basename@plt>
mov    -0x4804c(%rbp),%edi
mov    %rax,%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1570 <main+0x400>
movl   $0x0,-0x48024(%rbp)
cmpl   $0x2000,-0x48024(%rbp)
jge    1211 <main+0xa1>
movslq -0x48024(%rbp),%rax
movl   $0x0,-0x8020(%rbp,%rax,4)
mov    -0x48024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48024(%rbp)
jmp    11db <main+0x6b>
movl   $0x0,-0x48028(%rbp)
movl   $0x1,-0x4802c(%rbp)
mov    -0x4802c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14dd <main+0x36d>
mov    -0x10(%rbp),%rax
movslq -0x4802c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <open@plt>
mov    %eax,-0x48030(%rbp)
movq   $0x0,-0x48038(%rbp)
mov    -0x48030(%rbp),%edi
mov    0x2d77(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %rax,-0x48040(%rbp)
mov    -0x48030(%rbp),%edi
mov    0x2d32(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x48038(%rbp),%rax
cmp    -0x48040(%rbp),%rax
jge    14c4 <main+0x354>
mov    -0x48030(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1050 <read@plt>
cmpl   $0x0,-0x14(%rbp)
jge    12f5 <main+0x185>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
mov    -0x48038(%rbp),%rdx
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1570 <main+0x400>
cmpl   $0x3e8,-0x14(%rbp)
jle    1323 <main+0x1b3>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    -0x48038(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48038(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48038(%rbp)
cmpl   $0x2000,-0x14(%rbp)
jge    142f <main+0x2bf>
movslq -0x14(%rbp),%rax
mov    -0x8020(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x8020(%rbp,%rax,4)
movl   $0x0,-0x48044(%rbp)
cmpl   $0x4,-0x48044(%rbp)
jge    142a <main+0x2ba>
movslq -0x48044(%rbp),%rcx
lea    -0x48020(%rbp),%rax
shl    $0x10,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1411 <main+0x2a1>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1060 <calloc@plt>
mov    %rax,%rdx
movslq -0x48044(%rbp),%rcx
lea    -0x48020(%rbp),%rax
shl    $0x10,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48030(%rbp),%edi
movslq -0x48044(%rbp),%rcx
lea    -0x48020(%rbp),%rax
shl    $0x10,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1050 <read@plt>
mov    -0x48030(%rbp),%edi
mov    -0x48038(%rbp),%rax
mov    %eax,%esi
mov    0x2bbb(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
jmp    142a <main+0x2ba>
jmp    1416 <main+0x2a6>
mov    -0x48044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48044(%rbp)
jmp    1361 <main+0x1f1>
jmp    142f <main+0x2bf>
mov    -0x48030(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2ba1(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    %rax,-0x48038(%rbp)
mov    -0x48030(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1050 <read@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
je     149e <main+0x32e>
mov    0x2b51(%rip),%rax
mov    (%rax),%edi
mov    -0x48038(%rbp),%rdx
movsbl -0x15(%rbp),%ecx
lea    0xbde(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1570 <main+0x400>
mov    -0x48038(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48038(%rbp)
mov    -0x48028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48028(%rbp)
jmp    1297 <main+0x127>
jmp    14c9 <main+0x359>
mov    -0x4802c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4802c(%rbp)
jmp    1225 <main+0xb5>
mov    -0x48028(%rbp),%esi
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x48048(%rbp)
cmpl   $0x2000,-0x48048(%rbp)
jge    1569 <main+0x3f9>
movslq -0x48048(%rbp),%rax
cmpl   $0x0,-0x8020(%rbp,%rax,4)
jle    1550 <main+0x3e0>
mov    -0x48048(%rbp),%esi
movslq -0x48048(%rbp),%rax
mov    -0x8020(%rbp,%rax,4),%edx
lea    0xb7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1555 <main+0x3e5>
mov    -0x48048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48048(%rbp)
jmp    1509 <main+0x399>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x48050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48028,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jg     11d8 <main+0x48>
mov    0x2e18(%rip),%rax
mov    (%rax),%ebx
mov    0x0(%rbp),%rdi
call   10a0 <basename@plt>
lea    0xe3e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    1475 <main+0x2e5>
mov    %edi,%ebx
lea    0x20(%rsp),%rdi
mov    $0x8000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    %ebx,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r14b
mov    $0x1,%eax
mov    0x2dd7(%rip),%rcx
mov    0x2de0(%rip),%r15
mov    0x2db1(%rip),%r13
xor    %ebx,%ebx
mov    %rbp,0x10(%rsp)
jmp    1252 <main+0xc2>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
add    $0x1,%rax
cmp    0x8(%rsp),%rax
setb   %r14b
mov    0x10(%rsp),%rbp
mov    0x2d9a(%rip),%rcx
mov    0x2da3(%rip),%r15
mov    0x2d74(%rip),%r13
je     1425 <main+0x295>
mov    %rax,0x18(%rsp)
mov    0x0(%rbp,%rax,8),%rdi
mov    (%rcx),%esi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%ebp
mov    (%r15),%edx
mov    %eax,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %rax,%r12
mov    0x0(%r13),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
test   %r12,%r12
jle    1220 <main+0x90>
mov    %r14b,0x2(%rsp)
xor    %r14d,%r14d
mov    $0x4,%edx
mov    %ebp,%edi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <read@plt>
mov    0x4(%rsp),%r13d
test   %r13d,%r13d
js     13e3 <main+0x253>
cmp    $0x3e9,%r13d
jb     12e9 <main+0x159>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    %r14,%rdx
mov    %r13d,%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x4(%rsp),%r13d
cmp    $0x1fff,%r13d
jg     139c <main+0x20c>
movslq %r13d,%rax
addl   $0x1,0x20(%rsp,%rax,4)
cmpq   $0x0,0x8020(%rsp,%rax,8)
je     1330 <main+0x1a0>
cmpq   $0x0,0x18020(%rsp,%rax,8)
je     133d <main+0x1ad>
cmpq   $0x0,0x28020(%rsp,%rax,8)
je     134a <main+0x1ba>
cmpq   $0x0,0x38020(%rsp,%rax,8)
jne    139c <main+0x20c>
lea    (%rsp,%rax,8),%r15
add    $0x38020,%r15
jmp    1360 <main+0x1d0>
xchg   %ax,%ax
lea    (%rsp,%rax,8),%r15
add    $0x8020,%r15
jmp    1360 <main+0x1d0>
lea    (%rsp,%rax,8),%r15
add    $0x18020,%r15
jmp    1360 <main+0x1d0>
lea    (%rsp,%rax,8),%r15
add    $0x28020,%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%r13),%esi
mov    $0x1,%edi
call   1080 <calloc@plt>
mov    %rax,(%r15)
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <read@plt>
add    $0x4,%r14d
mov    0x2c35(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <lseek@plt>
mov    0x4(%rsp),%r13d
mov    0x2c3d(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r13d,%esi
call   1050 <lseek@plt>
mov    %rax,%r14
mov    $0x1,%edx
mov    %ebp,%edi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1070 <read@plt>
movsbl 0x3(%rsp),%ecx
test   %ecx,%ecx
jne    13ff <main+0x26f>
add    $0x1,%r14
add    $0x1,%ebx
cmp    %r12,%r14
jl     1290 <main+0x100>
jmp    1220 <main+0x90>
mov    0x2bde(%rip),%rax
mov    (%rax),%edi
lea    0xc23(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1419 <main+0x289>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xc5a(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
testb  $0x1,0x2(%rsp)
jne    1475 <main+0x2e5>
lea    0xc73(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc87(%rip),%rdi
call   1030 <puts@plt>
lea    0xc73(%rip),%rbx
xor    %ebp,%ebp
jmp    145d <main+0x2cd>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0x2000,%rbp
je     1473 <main+0x2e3>
mov    0x20(%rsp,%rbp,4),%edx
test   %edx,%edx
jle    1450 <main+0x2c0>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1450 <main+0x2c0>
xor    %eax,%eax
add    $0x48028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <lex-file>\0A\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [42 x i8] c"error at byte %ld, found negative length\0A\00"
@.str.2 = [41 x i8] c"warning at byte %ld, found length of %d\0A\00"
@SEEK_CUR = global i32 0
@.str.3 = [54 x i8] c"error at byte %ld, missing NUL, found 0x%02x instead\0A\00"
@.str.4 = [28 x i8] c"# found %d lexical entries\0A\00"
@.str.5 = [12 x i8] c"# len\09freq\0A\00"
@.str.6 = [8 x i8] c"%d\09%d\09\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca [8192 x i32]
%9 = alloca [4 x [8192 x i8*]]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i8* @basename(i8* %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %181
27: ; preds = %2
store i32 0, i32* %10
br label %28
28: ; preds = %35, %27
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 8192
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [8192 x i32], [8192 x i32]* %8, i64 0, i64 %33
store i32 0, i32* %34
br label %35
35: ; preds = %31
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %28
38: ; preds = %28
store i32 0, i32* %11
store i32 1, i32* %12
br label %39
39: ; preds = %153, %38
%40 = load i32, i32* %12
%41 = load i32, i32* %4
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %156
43: ; preds = %39
%44 = load i8**, i8*** %5
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* @O_RDONLY
%50 = call i32 @open(i8* %48, i32 %49, i32 0)
store i32 %50, i32* %13
store i64 0, i64* %14
%51 = load i32, i32* %13
%52 = load i32, i32* @SEEK_END
%53 = call i64 @lseek(i32 %51, i32 0, i32 %52)
store i64 %53, i64* %15
%54 = load i32, i32* %13
%55 = load i32, i32* @SEEK_SET
%56 = call i64 @lseek(i32 %54, i32 0, i32 %55)
br label %57
57: ; preds = %147, %43
%58 = load i64, i64* %14
%59 = load i64, i64* %15
%60 = icmp slt i64 %58, %59
br i1 %60, label %61, label %152
61: ; preds = %57
%62 = load i32, i32* %13
%63 = call i32 (i32, ...) @read(i32 %62, i32* %6, i64 4)
%64 = load i32, i32* %6
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = load i64, i64* %14
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 %68)
store i32 2, i32* %3
br label %181
70: ; preds = %61
%71 = load i32, i32* %6
%72 = icmp sgt i32 %71, 1000
br i1 %72, label %73, label %78
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = load i64, i64* %14
%76 = load i32, i32* %6
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %75, i32 %76)
br label %78
78: ; preds = %73, %70
%79 = load i64, i64* %14
%80 = add i64 %79, 4
store i64 %80, i64* %14
%81 = load i32, i32* %6
%82 = icmp slt i32 %81, 8192
br i1 %82, label %83, label %131
83: ; preds = %78
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [8192 x i32], [8192 x i32]* %8, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = add nsw i32 %87, 1
store i32 %88, i32* %86
store i32 0, i32* %16
br label %89
89: ; preds = %127, %83
%90 = load i32, i32* %16
%91 = icmp slt i32 %90, 4
br i1 %91, label %92, label %130
92: ; preds = %89
%93 = load i32, i32* %16
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %9, i64 0, i64 %94
%96 = load i32, i32* %6
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %95, i64 0, i64 %97
%99 = load i8*, i8** %98
%100 = icmp ne i8* %99, null
br i1 %100, label %126, label %101
101: ; preds = %92
%102 = load i32, i32* %6
%103 = add nsw i32 %102, 1
%104 = call i8* @calloc(i32 1, i32 %103)
%105 = load i32, i32* %16
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %9, i64 0, i64 %106
%108 = load i32, i32* %6
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %107, i64 0, i64 %109
store i8* %104, i8** %110
%111 = load i32, i32* %13
%112 = load i32, i32* %16
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %9, i64 0, i64 %113
%115 = load i32, i32* %6
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [8192 x i8*], [8192 x i8*]* %114, i64 0, i64 %116
%118 = load i8*, i8** %117
%119 = load i32, i32* %6
%120 = call i32 (i32, ...) @read(i32 %111, i8* %118, i32 %119)
%121 = load i32, i32* %13
%122 = load i64, i64* %14
%123 = trunc i64 %122 to i32
%124 = load i32, i32* @SEEK_SET
%125 = call i64 @lseek(i32 %121, i32 %123, i32 %124)
br label %130
126: ; preds = %92
br label %127
127: ; preds = %126
%128 = load i32, i32* %16
%129 = add nsw i32 %128, 1
store i32 %129, i32* %16
br label %89
130: ; preds = %101, %89
br label %131
131: ; preds = %130, %78
%132 = load i32, i32* %13
%133 = load i32, i32* %6
%134 = load i32, i32* @SEEK_CUR
%135 = call i64 @lseek(i32 %132, i32 %133, i32 %134)
store i64 %135, i64* %14
%136 = load i32, i32* %13
%137 = call i32 (i32, ...) @read(i32 %136, i8* %7, i64 1)
%138 = load i8, i8* %7
%139 = sext i8 %138 to i32
%140 = icmp ne i32 %139, 0
br i1 %140, label %141, label %147
141: ; preds = %131
%142 = load i32, i32* @stderr
%143 = load i64, i64* %14
%144 = load i8, i8* %7
%145 = sext i8 %144 to i32
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %142, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i64 %143, i32 %145)
store i32 2, i32* %3
br label %181
147: ; preds = %131
%148 = load i64, i64* %14
%149 = add nsw i64 %148, 1
store i64 %149, i64* %14
%150 = load i32, i32* %11
%151 = add nsw i32 %150, 1
store i32 %151, i32* %11
br label %57
152: ; preds = %57
br label %153
153: ; preds = %152
%154 = load i32, i32* %12
%155 = add nsw i32 %154, 1
store i32 %155, i32* %12
br label %39
156: ; preds = %39
%157 = load i32, i32* %11
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %157)
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %17
br label %160
160: ; preds = %177, %156
%161 = load i32, i32* %17
%162 = icmp slt i32 %161, 8192
br i1 %162, label %163, label %180
163: ; preds = %160
%164 = load i32, i32* %17
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [8192 x i32], [8192 x i32]* %8, i64 0, i64 %165
%167 = load i32, i32* %166
%168 = icmp sgt i32 %167, 0
br i1 %168, label %169, label %176
169: ; preds = %163
%170 = load i32, i32* %17
%171 = load i32, i32* %17
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [8192 x i32], [8192 x i32]* %8, i64 0, i64 %172
%174 = load i32, i32* %173
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %170, i32 %174)
br label %176
176: ; preds = %169, %163
br label %177
177: ; preds = %176
%178 = load i32, i32* %17
%179 = add nsw i32 %178, 1
store i32 %179, i32* %17
br label %160
180: ; preds = %160
store i32 0, i32* %3
br label %181
181: ; preds = %180, %141, %66, %20
%182 = load i32, i32* %3
ret i32 %182
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <lex-file>\0A\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [42 x i8] c"error at byte %ld, found negative length\0A\00"
@.str.2 = [41 x i8] c"warning at byte %ld, found length of %d\0A\00"
@SEEK_CUR = global i32 0
@.str.3 = [54 x i8] c"error at byte %ld, missing NUL, found 0x%02x instead\0A\00"
@.str.4 = [28 x i8] c"# found %d lexical entries\0A\00"
@.str.6 = [8 x i8] c"%d\09%d\09\0A\00"
@str = [11 x i8] c"# len\09freq\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [8192 x i32]
%6 = bitcast [8192 x i32]* %5 to i8*
%7 = alloca [4 x [8192 x i8*]]
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i8* @basename(i8* %11)
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %117
14: ; preds = %2
%15 = bitcast i32* %3 to i8*
%16 = bitcast [4 x [8192 x i8*]]* %7 to i8*
%17 = zext i32 %0 to i64
%18 = zext i32 %0 to i64
br label %19
19: ; preds = %14, %94
%20 = phi i64 [ 1, %14 ], [ %96, %94 ]
%21 = phi i1 [ true, %14 ], [ %97, %94 ]
%22 = phi i32 [ 0, %14 ], [ %95, %94 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %20
%24 = load i8*, i8** %23
%25 = load i32, i32* @O_RDONLY
%26 = call i32 @open(i8* %24, i32 %25, i32 0)
%27 = load i32, i32* @SEEK_END
%28 = call i64 @lseek(i32 %26, i32 0, i32 %27)
%29 = load i32, i32* @SEEK_SET
%30 = call i64 @lseek(i32 %26, i32 0, i32 %29)
%31 = icmp sgt i64 %28, 0
br i1 %31, label %32, label %94
32: ; preds = %19, %90
%33 = phi i64 [ %91, %90 ], [ 0, %19 ]
%34 = phi i32 [ %92, %90 ], [ %22, %19 ]
%35 = call i32 (i32, ...) @read(i32 %26, i32* %3, i64 4)
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i64 %33)
br label %99
41: ; preds = %32
%42 = icmp ugt i32 %36, 1000
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %33, i32 %36)
%46 = load i32, i32* %3
%47 = icmp slt i32 %46, 8192
br i1 %47, label %48, label %79
48: ; preds = %41, %43
%49 = phi i32 [ %46, %43 ], [ %36, %41 ]
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [8192 x i32], [8192 x i32]* %5, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
store i32 %53, i32* %51
%54 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %7, i64 0, i64 0, i64 %50
%55 = load i8*, i8** %54
%56 = icmp eq i8* %55, null
br i1 %56, label %69, label %57
57: ; preds = %48
%58 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %7, i64 0, i64 1, i64 %50
%59 = load i8*, i8** %58
%60 = icmp eq i8* %59, null
br i1 %60, label %69, label %61
61: ; preds = %57
%62 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %7, i64 0, i64 2, i64 %50
%63 = load i8*, i8** %62
%64 = icmp eq i8* %63, null
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = getelementptr inbounds [4 x [8192 x i8*]], [4 x [8192 x i8*]]* %7, i64 0, i64 3, i64 %50
%67 = load i8*, i8** %66
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %79
69: ; preds = %65, %61, %57, %48
%70 = phi i8** [ %54, %48 ], [ %58, %57 ], [ %62, %61 ], [ %66, %65 ]
%71 = add nsw i32 %49, 1
%72 = call i8* @calloc(i32 1, i32 %71)
store i8* %72, i8** %70
%73 = call i32 (i32, ...) @read(i32 %26, i8* %72, i32 %49)
%74 = trunc i64 %33 to i32
%75 = add i32 %74, 4
%76 = load i32, i32* @SEEK_SET
%77 = call i64 @lseek(i32 %26, i32 %75, i32 %76)
%78 = load i32, i32* %3
br label %79
79: ; preds = %65, %69, %43
%80 = phi i32 [ %78, %69 ], [ %46, %43 ], [ %49, %65 ]
%81 = load i32, i32* @SEEK_CUR
%82 = call i64 @lseek(i32 %26, i32 %80, i32 %81)
%83 = call i32 (i32, ...) @read(i32 %26, i8* %4, i64 1)
%84 = load i8, i8* %4
%85 = icmp eq i8 %84, 0
br i1 %85, label %90, label %86
86: ; preds = %79
%87 = sext i8 %84 to i32
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i64 %82, i32 %87)
br label %99
90: ; preds = %79
%91 = add nsw i64 %82, 1
%92 = add nsw i32 %34, 1
%93 = icmp slt i64 %91, %28
br i1 %93, label %32, label %94
94: ; preds = %90, %19
%95 = phi i32 [ %22, %19 ], [ %92, %90 ]
%96 = add nuw nsw i64 %20, 1
%97 = icmp ult i64 %96, %17
%98 = icmp eq i64 %96, %18
br i1 %98, label %100, label %19
99: ; preds = %86, %38
br i1 %21, label %115, label %100
100: ; preds = %94, %99
%101 = phi i32 [ %34, %99 ], [ %95, %94 ]
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %101)
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %104
104: ; preds = %100, %112
%105 = phi i64 [ 0, %100 ], [ %113, %112 ]
%106 = getelementptr inbounds [8192 x i32], [8192 x i32]* %5, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = icmp sgt i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %104
%110 = trunc i64 %105 to i32
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %110, i32 %107)
br label %112
112: ; preds = %104, %109
%113 = add nuw nsw i64 %105, 1
%114 = icmp eq i64 %113, 8192
br i1 %114, label %115, label %104
115: ; preds = %112, %99
%116 = phi i32 [ 2, %99 ], [ 0, %112 ]
br label %117
117: ; preds = %115, %9
%118 = phi i32 [ 1, %9 ], [ %116, %115 ]
ret i32 %118
}