#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 word_list_struct {
  int dummy;
};
struct line_list_struct {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fill_string(char *, int, char);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ lpp(int, int);
int /*<<< orphan*/ print_report_header(int /*<<< orphan*/ *, int *, int *,
                                       char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
struct line_list_struct *read_a_record(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ write_a_record(struct line_list_struct *,
                                  int /*<<< orphan*/ *, int *, int *, char *,
                                  int, int, int);
int main(int argc, char *argv[]) {
  char in_file_name[100], out_file_name[100], title[100];
  FILE *in_file, *out_file;
  int double_space = 0, file_done = 0, i, line_counter = 0, lines = 66,
      page_counter = 1, print_date = 0, print_page = 0, print_title = 0;
  struct word_list_struct *word_list, *temp;
  struct line_list_struct *line_list;
  if (argc < 2) {
    printf("\n\nusage: kf in-file out-file -d -p -n # -l # -t ..."
           "\n         -d     = put the date in the header"
           "\n         -p     = put the page number in the header"
           "\n         -l #   = there are # lines per page (%d default)"
           "\n         -n #   = start numbering the pages with #"
           "\n         -ds    = double space print the output"
           "\n         -t ... = put the following title in the header",
           66);
    printf("\n%s\n", "kf Version 1 - December 1999");
    exit(1);
  }
  if (argc > 1) {
    strcpy(in_file_name, argv[1]);
    strcpy(out_file_name, argv[2]);
    fill_string(title, 100, '\0');
    i = 3;
    while (i < argc) {
      if (strcmp(argv[i], "-ds") == 0)
        double_space = 1;
      if (strcmp(argv[i], "-d") == 0)
        print_date = 1;
      if (strcmp(argv[i], "-p") == 0)
        print_page = 1;
      if (strcmp(argv[i], "-l") == 0) {
        i++;
        lines = atoi(argv[i]);
      }
      if (strcmp(argv[i], "-n") == 0) {
        i++;
        page_counter = atoi(argv[i]);
      }
      if (strcmp(argv[i], "-t") == 0) {
        i++;
        strcpy(title, " ");
        while (i < argc) {
          strcat(title, argv[i]);
          strcat(title, " ");
          i++;
        }
      }
      i++;
    }
  }
  lpp(lines, 1);
  if ((in_file = fopen(in_file_name, "rt")) == NULL) {
    printf("\nERROR Could not open file %s", in_file_name);
    exit(2);
  }
  if ((out_file = fopen(out_file_name, "wt")) == NULL) {
    printf("\nERROR Could not open file %s", out_file_name);
    exit(2);
  }
  print_report_header(out_file, &line_counter, &page_counter, title, print_date,
                      print_page);
  while (file_done == 0) {
    line_list = read_a_record(in_file, &file_done);
    write_a_record(line_list, out_file, &line_counter, &page_counter, title,
                   print_date, print_page, double_space);
  }
  fclose(in_file);
  fclose(out_file);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x174(%rbp)
movl   $0x0,-0x178(%rbp)
movl   $0x0,-0x180(%rbp)
movl   $0x42,-0x184(%rbp)
movl   $0x1,-0x188(%rbp)
movl   $0x0,-0x18c(%rbp)
movl   $0x0,-0x190(%rbp)
movl   $0x0,-0x194(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1275 <main+0xa5>
lea    0xdb6(%rip),%rdi
mov    $0x42,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf0d(%rip),%rdi
lea    0xf0b(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jle    14af <main+0x2df>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x160(%rbp),%rdi
mov    $0x64,%esi
xor    %edx,%edx
call   10c0 <fill_string@plt>
movl   $0x3,-0x17c(%rbp)
mov    -0x17c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14aa <main+0x2da>
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xea6(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12ff <main+0x12f>
movl   $0x1,-0x174(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe7b(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    132e <main+0x15e>
movl   $0x1,-0x18c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4f(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    135d <main+0x18d>
movl   $0x1,-0x190(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe23(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13ab <main+0x1db>
mov    -0x17c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x184(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdd8(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13f9 <main+0x229>
mov    -0x17c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x188(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd8d(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1496 <main+0x2c6>
mov    -0x17c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17c(%rbp)
lea    -0x160(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x17c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1491 <main+0x2c1>
lea    -0x160(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x17c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10d0 <strcat@plt>
lea    -0x160(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x17c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17c(%rbp)
jmp    1440 <main+0x270>
jmp    1496 <main+0x2c6>
mov    -0x17c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17c(%rbp)
jmp    12c1 <main+0xf1>
jmp    14af <main+0x2df>
mov    -0x184(%rbp),%edi
mov    $0x1,%esi
call   10f0 <lpp@plt>
lea    -0x80(%rbp),%rdi
lea    0xcd7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x168(%rbp)
cmp    $0x0,%rax
jne    14fc <main+0x32c>
lea    -0x80(%rbp),%rsi
lea    0xcb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
lea    -0xf0(%rbp),%rdi
lea    0xcb8(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x170(%rbp)
cmp    $0x0,%rax
jne    153f <main+0x36f>
lea    -0xf0(%rbp),%rsi
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
mov    -0x170(%rbp),%rdi
lea    -0x160(%rbp),%rcx
mov    -0x18c(%rbp),%r8d
mov    -0x190(%rbp),%r9d
lea    -0x180(%rbp),%rsi
lea    -0x188(%rbp),%rdx
call   1040 <print_report_header@plt>
cmpl   $0x0,-0x178(%rbp)
jne    15de <main+0x40e>
mov    -0x168(%rbp),%rdi
lea    -0x178(%rbp),%rsi
call   1080 <read_a_record@plt>
mov    %rax,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rdi
mov    -0x170(%rbp),%rsi
lea    -0x160(%rbp),%r8
mov    -0x18c(%rbp),%r9d
mov    -0x190(%rbp),%r10d
mov    -0x174(%rbp),%eax
lea    -0x180(%rbp),%rdx
lea    -0x188(%rbp),%rcx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1070 <write_a_record@plt>
jmp    156e <main+0x39e>
mov    -0x168(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x170(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x188,%rsp
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x1,0x14(%rsp)
cmp    $0x1,%edi
jle    14fb <main+0x32b>
mov    %rsi,%r13
mov    %edi,%ebx
mov    0x8(%rsi),%rsi
lea    0x120(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%r13),%rsi
lea    0xb0(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0x40(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x64,%esi
xor    %edx,%edx
call   10c0 <fill_string@plt>
movl   $0x42,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x0,%eax
mov    %rax,0x20(%rsp)
cmp    $0x4,%ebx
jb     141c <main+0x24c>
lea    -0x1(%rbx),%eax
mov    %eax,0x3c(%rsp)
movl   $0x42,0x10(%rsp)
mov    $0x3,%r14d
xor    %eax,%eax
mov    %rax,0x20(%rsp)
lea    0x40(%rsp),%r12
movl   $0x0,0xc(%rsp)
xor    %ebp,%ebp
mov    %rbx,0x28(%rsp)
jmp    12b2 <main+0xe2>
mov    %eax,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x30(%rsp),%rbp
add    $0x1,%r14d
cmp    %ebx,%r14d
jge    141c <main+0x24c>
movslq %r14d,%r15
mov    0x0(%r13,%r15,8),%rdi
lea    0xecb(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
mov    $0x1,%ebx
mov    0x20(%rsp),%rax
cmove  %ebx,%eax
mov    %rax,0x20(%rsp)
mov    0x0(%r13,%r15,8),%rdi
lea    0xea9(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
mov    0xc(%rsp),%eax
cmove  %ebx,%eax
mov    %eax,0xc(%rsp)
mov    0x0(%r13,%r15,8),%rdi
lea    0xe8d(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
cmove  %ebx,%ebp
mov    %rbp,0x30(%rsp)
mov    0x0(%r13,%r15,8),%rdi
lea    0xe74(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1340 <main+0x170>
mov    0x0(%r13,%r15,8),%rbp
jmp    135c <main+0x18c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %r14d,%r15
add    $0x1,%r14d
mov    0x8(%r13,%r15,8),%rbp
add    $0x1,%r15
mov    %rbp,%rdi
call   10b0 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    %rbp,%rdi
lea    0xe33(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1380 <main+0x1b0>
mov    0x0(%r13,%r15,8),%rbp
jmp    1398 <main+0x1c8>
nopw   0x0(%rax,%rax,1)
movslq %r14d,%rax
add    $0x1,%r14d
mov    0x8(%r13,%rax,8),%rbp
mov    %rbp,%rdi
call   10b0 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x28(%rsp),%rbx
mov    %rbp,%rdi
lea    0xdf5(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jne    12a0 <main+0xd0>
mov    %r12,%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x1(%r14),%eax
cmp    %ebx,%eax
jge    1291 <main+0xc1>
cltq
lea    0x0(,%rax,8),%r15
add    %r13,%r15
mov    0x3c(%rsp),%eax
mov    %eax,%ebx
sub    %r14d,%ebx
xor    %ebp,%ebp
lea    0xdb0(%rip),%r14
nop
mov    (%r15,%rbp,8),%rsi
mov    %r12,%rdi
call   10d0 <strcat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    13f0 <main+0x220>
mov    0x28(%rsp),%rbx
mov    %ebx,%r14d
jmp    12a0 <main+0xd0>
mov    %rbp,%r13
mov    0x10(%rsp),%edi
mov    $0x1,%esi
call   10f0 <lpp@plt>
lea    0xd6d(%rip),%rsi
lea    0x120(%rsp),%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     152d <main+0x35d>
mov    %rax,%rbx
lea    0xd6e(%rip),%rsi
lea    0xb0(%rsp),%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
mov    0xc(%rsp),%r14d
je     153e <main+0x36e>
mov    %rax,%rbp
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x40(%rsp),%rcx
mov    %rax,%rdi
mov    %r14d,%r8d
mov    %r13d,%r9d
call   1040 <print_report_header@plt>
lea    0x1c(%rsp),%r15
mov    0x20(%rsp),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <read_a_record@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x40(%rsp),%r8
mov    %r14d,%r9d
push   %r12
push   %r13
call   1070 <write_a_record@plt>
add    $0x10,%rsp
cmpl   $0x0,0x1c(%rsp)
je     14a0 <main+0x2d0>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x188,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xafe(%rip),%rdi
mov    $0x42,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc55(%rip),%rdi
lea    0xc53(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xc70(%rip),%rdi
lea    0x120(%rsp),%rsi
jmp    154d <main+0x37d>
lea    0xc5f(%rip),%rdi
lea    0xb0(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.word_list_struct = type { i32 }
%struct.line_list_struct = type { i32 }
@.str = [362 x i8] c"\0A\0Ausage: kf in-file out-file -d -p -n # -l # -t ...\0A -d = put the date in the header\0A -p = put the page number in the header\0A -l # = there are # lines per page (%d default)\0A -n # = start numbering the pages with #\0A -ds = double space print the output\0A -t ... = put the following title in the header\00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
@.str.2 = [29 x i8] c"kf Version 1 - December 1999\00"
@.str.3 = [4 x i8] c"-ds\00"
@.str.4 = [3 x i8] c"-d\00"
@.str.5 = [3 x i8] c"-p\00"
@.str.6 = [3 x i8] c"-l\00"
@.str.7 = [3 x i8] c"-n\00"
@.str.8 = [3 x i8] c"-t\00"
@.str.9 = [2 x i8] c" \00"
@.str.10 = [3 x i8] c"rt\00"
@.str.11 = [30 x i8] c"\0AERROR Could not open file %s\00"
@.str.12 = [3 x i8] c"wt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.word_list_struct*
%21 = alloca %struct.word_list_struct*
%22 = alloca %struct.line_list_struct*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %14
store i32 66, i32* %15
store i32 1, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([362 x i8], [362 x i8]* @.str, i64 0, i64 0), i32 66)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 1
br i1 %31, label %32, label %144
32: ; preds = %29
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = call i32 @strcpy(i8* %38, i8* %41)
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%44 = call i32 @fill_string(i8* %43, i32 100, i8 signext 0)
store i32 3, i32* %13
br label %45
45: ; preds = %140, %32
%46 = load i32, i32* %13
%47 = load i32, i32* %4
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %143
49: ; preds = %45
%50 = load i8**, i8*** %5
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %49
store i32 1, i32* %11
br label %58
58: ; preds = %57, %49
%59 = load i8**, i8*** %5
%60 = load i32, i32* %13
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %58
store i32 1, i32* %17
br label %67
67: ; preds = %66, %58
%68 = load i8**, i8*** %5
%69 = load i32, i32* %13
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %67
store i32 1, i32* %18
br label %76
76: ; preds = %75, %67
%77 = load i8**, i8*** %5
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %93
84: ; preds = %76
%85 = load i32, i32* %13
%86 = add nsw i32 %85, 1
store i32 %86, i32* %13
%87 = load i8**, i8*** %5
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %87, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 @atoi(i8* %91)
store i32 %92, i32* %15
br label %93
93: ; preds = %84, %76
%94 = load i8**, i8*** %5
%95 = load i32, i32* %13
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %94, i64 %96
%98 = load i8*, i8** %97
%99 = call i64 @strcmp(i8* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %110
101: ; preds = %93
%102 = load i32, i32* %13
%103 = add nsw i32 %102, 1
store i32 %103, i32* %13
%104 = load i8**, i8*** %5
%105 = load i32, i32* %13
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8*, i8** %104, i64 %106
%108 = load i8*, i8** %107
%109 = call i32 @atoi(i8* %108)
store i32 %109, i32* %16
br label %110
110: ; preds = %101, %93
%111 = load i8**, i8*** %5
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8*, i8** %111, i64 %113
%115 = load i8*, i8** %114
%116 = call i64 @strcmp(i8* %115, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%117 = icmp eq i64 %116, 0
br i1 %117, label %118, label %140
118: ; preds = %110
%119 = load i32, i32* %13
%120 = add nsw i32 %119, 1
store i32 %120, i32* %13
%121 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%122 = call i32 @strcpy(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %123
123: ; preds = %127, %118
%124 = load i32, i32* %13
%125 = load i32, i32* %4
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %139
127: ; preds = %123
%128 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%129 = load i8**, i8*** %5
%130 = load i32, i32* %13
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i8*, i8** %129, i64 %131
%133 = load i8*, i8** %132
%134 = call i32 @strcat(i8* %128, i8* %133)
%135 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%136 = call i32 @strcat(i8* %135, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%137 = load i32, i32* %13
%138 = add nsw i32 %137, 1
store i32 %138, i32* %13
br label %123
139: ; preds = %123
br label %140
140: ; preds = %139, %110
%141 = load i32, i32* %13
%142 = add nsw i32 %141, 1
store i32 %142, i32* %13
br label %45
143: ; preds = %45
br label %144
144: ; preds = %143, %29
%145 = load i32, i32* %15
%146 = call i32 @lpp(i32 %145, i32 1)
%147 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%148 = call i32* @fopen(i8* %147, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %148, i32** %9
%149 = icmp eq i32* %148, null
br i1 %149, label %150, label %154
150: ; preds = %144
%151 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %151)
%153 = call i32 @exit(i32 2)
unreachable
154: ; preds = %144
%155 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%156 = call i32* @fopen(i8* %155, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32* %156, i32** %10
%157 = icmp eq i32* %156, null
br i1 %157, label %158, label %162
158: ; preds = %154
%159 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %159)
%161 = call i32 @exit(i32 2)
unreachable
162: ; preds = %154
%163 = load i32*, i32** %10
%164 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%165 = load i32, i32* %17
%166 = load i32, i32* %18
%167 = call i32 @print_report_header(i32* %163, i32* %14, i32* %16, i8* %164, i32 %165, i32 %166)
br label %168
168: ; preds = %171, %162
%169 = load i32, i32* %12
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %181
171: ; preds = %168
%172 = load i32*, i32** %9
%173 = call %struct.line_list_struct* @read_a_record(i32* %172, i32* %12)
store %struct.line_list_struct* %173, %struct.line_list_struct** %22
%174 = load %struct.line_list_struct*, %struct.line_list_struct** %22
%175 = load i32*, i32** %10
%176 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%177 = load i32, i32* %17
%178 = load i32, i32* %18
%179 = load i32, i32* %11
%180 = call i32 @write_a_record(%struct.line_list_struct* %174, i32* %175, i32* %14, i32* %16, i8* %176, i32 %177, i32 %178, i32 %179)
br label %168
181: ; preds = %168
%182 = load i32*, i32** %9
%183 = call i32 @fclose(i32* %182)
%184 = load i32*, i32** %10
%185 = call i32 @fclose(i32* %184)
%186 = load i32, i32* %3
ret i32 %186
}

LLVM IR (-O2):
%struct.word_list_struct = type { i32 }
%struct.line_list_struct = type { i32 }
@.str = [362 x i8] c"\0A\0Ausage: kf in-file out-file -d -p -n # -l # -t ...\0A -d = put the date in the header\0A -p = put the page number in the header\0A -l # = there are # lines per page (%d default)\0A -n # = start numbering the pages with #\0A -ds = double space print the output\0A -t ... = put the following title in the header\00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
@.str.2 = [29 x i8] c"kf Version 1 - December 1999\00"
@.str.3 = [4 x i8] c"-ds\00"
@.str.4 = [3 x i8] c"-d\00"
@.str.5 = [3 x i8] c"-p\00"
@.str.6 = [3 x i8] c"-l\00"
@.str.7 = [3 x i8] c"-n\00"
@.str.8 = [3 x i8] c"-t\00"
@.str.9 = [2 x i8] c" \00"
@.str.10 = [3 x i8] c"rt\00"
@.str.11 = [30 x i8] c"\0AERROR Could not open file %s\00"
@.str.12 = [3 x i8] c"wt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%14 = bitcast i32* %8 to i8*
store i32 1, i32* %8
%15 = icmp slt i32 %0, 2
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([362 x i8], [362 x i8]* @.str, i64 0, i64 0), i32 66)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %9, i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %10, i8* %25)
%27 = call i32 @fill_string(i8* %11, i32 100, i8 signext 0)
%28 = icmp ugt i32 %0, 3
br i1 %28, label %29, label %100
29: ; preds = %20, %96
%30 = phi i32 [ %40, %96 ], [ 0, %20 ]
%31 = phi i32 [ %98, %96 ], [ 3, %20 ]
%32 = phi i32 [ %63, %96 ], [ 66, %20 ]
%33 = phi i32 [ %44, %96 ], [ 0, %20 ]
%34 = phi i32 [ %48, %96 ], [ 0, %20 ]
%35 = sext i32 %31 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i32 1, i32 %30
%41 = load i8*, i8** %36
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i32 1, i32 %33
%45 = load i8*, i8** %36
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
%48 = select i1 %47, i32 1, i32 %34
%49 = load i8*, i8** %36
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %29
%53 = load i8*, i8** %36
br label %60
54: ; preds = %29
%55 = add nsw i32 %31, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %1, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @atoi(i8* %58)
br label %60
60: ; preds = %52, %54
%61 = phi i8* [ %58, %54 ], [ %53, %52 ]
%62 = phi i64 [ %56, %54 ], [ %35, %52 ]
%63 = phi i32 [ %59, %54 ], [ %32, %52 ]
%64 = phi i32 [ %55, %54 ], [ %31, %52 ]
%65 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %60
%68 = getelementptr inbounds i8*, i8** %1, i64 %62
%69 = load i8*, i8** %68
br label %76
70: ; preds = %60
%71 = add nsw i32 %64, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %1, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @atoi(i8* %74)
store i32 %75, i32* %8
br label %76
76: ; preds = %67, %70
%77 = phi i8* [ %74, %70 ], [ %69, %67 ]
%78 = phi i32 [ %71, %70 ], [ %64, %67 ]
%79 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %96
81: ; preds = %76
%82 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%83 = add i32 %78, 1
%84 = icmp slt i32 %83, %0
br i1 %84, label %85, label %96
85: ; preds = %81
%86 = sext i32 %83 to i64
br label %87
87: ; preds = %85, %87
%88 = phi i64 [ %86, %85 ], [ %93, %87 ]
%89 = getelementptr inbounds i8*, i8** %1, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 @strcat(i8* %11, i8* %90)
%92 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%93 = add nsw i64 %88, 1
%94 = trunc i64 %93 to i32
%95 = icmp eq i32 %94, %0
br i1 %95, label %96, label %87
96: ; preds = %87, %81, %76
%97 = phi i32 [ %78, %76 ], [ %83, %81 ], [ %0, %87 ]
%98 = add nsw i32 %97, 1
%99 = icmp slt i32 %98, %0
br i1 %99, label %29, label %100
100: ; preds = %96, %20
%101 = phi i32 [ 0, %20 ], [ %48, %96 ]
%102 = phi i32 [ 0, %20 ], [ %44, %96 ]
%103 = phi i32 [ 66, %20 ], [ %63, %96 ]
%104 = phi i32 [ 0, %20 ], [ %40, %96 ]
%105 = call i32 @lpp(i32 %103, i32 1)
%106 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%107 = icmp eq i32* %106, null
br i1 %107, label %108, label %111
108: ; preds = %100
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %9)
%110 = call i32 @exit(i32 2)
unreachable
111: ; preds = %100
%112 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%113 = icmp eq i32* %112, null
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i8* %10)
%116 = call i32 @exit(i32 2)
unreachable
117: ; preds = %111
%118 = call i32 @print_report_header(i32* %112, i32* %7, i32* %8, i8* %11, i32 %102, i32 %101)
br label %119
119: ; preds = %117, %119
%120 = call %struct.line_list_struct* @read_a_record(i32* %106, i32* %6)
%121 = call i32 @write_a_record(%struct.line_list_struct* %120, i32* %112, i32* %7, i32* %8, i8* %11, i32 %102, i32 %101, i32 %104)
%122 = load i32, i32* %6
%123 = icmp eq i32 %122, 0
br i1 %123, label %119, label %124
124: ; preds = %119
%125 = call i32 @fclose(i32* %106)
%126 = call i32 @fclose(i32* %112)
ret i32 0
}