#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;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
struct word_list_struct *read_a_paragraph(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ write_a_paragraph(struct word_list_struct *,
                                     int /*<<< orphan*/ *);
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;
  if (argc != 3) {
    printf("\n\nusage: para in-file out-file ");
    printf("\n%s\n", "Para Version 1 - January 1999");
    exit(1);
  }
  if (argc == 3) {
    strcpy(in_file_name, argv[1]);
    strcpy(out_file_name, argv[2]);
  }
  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);
  }
  while (file_done == 0) {
    word_list = read_a_paragraph(in_file, &file_done);
    write_a_paragraph(word_list, out_file);
  }
  fclose(in_file);
  fclose(out_file);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%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   $0x3,-0x8(%rbp)
je     1210 <main+0xa0>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe28(%rip),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    123f <main+0xcf>
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    -0x80(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x168(%rbp)
cmp    $0x0,%rax
jne    127c <main+0x10c>
lea    -0x80(%rbp),%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
lea    -0xf0(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x170(%rbp)
cmp    $0x0,%rax
jne    12bf <main+0x14f>
lea    -0xf0(%rbp),%rsi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
jmp    12c4 <main+0x154>
cmpl   $0x0,-0x178(%rbp)
jne    1303 <main+0x193>
mov    -0x168(%rbp),%rdi
lea    -0x178(%rbp),%rsi
call   1050 <read_a_paragraph@plt>
mov    %rax,-0x1a0(%rbp)
mov    -0x1a0(%rbp),%rdi
mov    -0x170(%rbp),%rsi
call   1040 <write_a_paragraph@plt>
jmp    12c4 <main+0x154>
mov    -0x168(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x170(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
movl   $0x0,0xc(%rsp)
cmp    $0x3,%edi
jne    122c <main+0xbc>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x80(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe8a(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1259 <main+0xe9>
mov    %rax,%r14
lea    0xe90(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     126a <main+0xfa>
mov    %rax,%rbx
lea    0xc(%rsp),%r15
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <read_a_paragraph@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <write_a_paragraph@plt>
cmpl   $0x0,0xc(%rsp)
je     11f0 <main+0x80>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xddf(%rip),%rdi
lea    0xddd(%rip),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xde6(%rip),%rdi
lea    0x80(%rsp),%rsi
jmp    1276 <main+0x106>
lea    0xdd5(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.word_list_struct = type { i32 }
@.str = [32 x i8] c"\0A\0Ausage: para in-file out-file \00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
@.str.2 = [30 x i8] c"Para Version 1 - January 1999\00"
@.str.3 = [3 x i8] c"rt\00"
@.str.4 = [30 x i8] c"\0AERROR Could not open file %s\00"
@.str.5 = [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*
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
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 3
br i1 %23, label %24, label %28
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 3
br i1 %30, label %31, label %42
31: ; preds = %28
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %32, i8* %35)
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @strcpy(i8* %37, i8* %40)
br label %42
42: ; preds = %31, %28
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %44, i32** %9
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = call i32 @exit(i32 2)
unreachable
50: ; preds = %42
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %52, i32** %10
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 2)
unreachable
58: ; preds = %50
br label %59
59: ; preds = %62, %58
%60 = load i32, i32* %12
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %59
%63 = load i32*, i32** %9
%64 = call %struct.word_list_struct* @read_a_paragraph(i32* %63, i32* %12)
store %struct.word_list_struct* %64, %struct.word_list_struct** %20
%65 = load %struct.word_list_struct*, %struct.word_list_struct** %20
%66 = load i32*, i32** %10
%67 = call i32 @write_a_paragraph(%struct.word_list_struct* %65, i32* %66)
br label %59
68: ; preds = %59
%69 = load i32*, i32** %9
%70 = call i32 @fclose(i32* %69)
%71 = load i32*, i32** %10
%72 = call i32 @fclose(i32* %71)
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
%struct.word_list_struct = type { i32 }
@.str = [32 x i8] c"\0A\0Ausage: para in-file out-file \00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
@.str.2 = [30 x i8] c"Para Version 1 - January 1999\00"
@.str.3 = [3 x i8] c"rt\00"
@.str.4 = [30 x i8] c"\0AERROR Could not open file %s\00"
@.str.5 = [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 i32
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = icmp eq i32 %0, 3
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%12 = 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 ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %6, i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %7, i8* %19)
%21 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%25 = call i32 @exit(i32 2)
unreachable
26: ; preds = %14
%27 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%31 = call i32 @exit(i32 2)
unreachable
32: ; preds = %26, %32
%33 = call %struct.word_list_struct* @read_a_paragraph(i32* %21, i32* %5)
%34 = call i32 @write_a_paragraph(%struct.word_list_struct* %33, i32* %27)
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 0
br i1 %36, label %32, label %37
37: ; preds = %32
%38 = call i32 @fclose(i32* %21)
%39 = call i32 @fclose(i32* %27)
ret i32 0
}