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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fread(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fstat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ generate_summary(char *, int, char **, char **, char **,
                                    char **);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s <filename>\n\n", argv[0]);
    exit(-1);
  }
  FILE *file = fopen(argv[1], "r");
  if (!file) {
    fprintf(stderr, "Could not open %s.\n", argv[1]);
    return -1;
  }
  struct stat fileinfo;
  fstat(fileno(file), &fileinfo);
  int size = fileinfo.st_size;
  char *buf = (char *)malloc(sizeof(char) * size);
  int i;
  for (i = 0; i < size;) {
    i += fread((void *)&(buf[i]), sizeof(char), size - i, file);
  }
  char *title, *body, *metakeyw, *metadesc;
  generate_summary(buf, size, &title, &body, &metakeyw, &metadesc);
  printf("%s\n", body);
  free(buf);
  free(title);
  free(body);
  free(metakeyw);
  free(metadesc);
  fclose(file);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ed <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe22(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1239 <main+0x89>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdf1(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    130c <main+0x15c>
mov    -0x18(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   10d0 <fstat@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12aa <main+0xfa>
mov    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
mov    -0x24(%rbp),%edx
sub    -0x34(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,%rcx
movslq -0x34(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x34(%rbp)
jmp    126d <main+0xbd>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x50(%rbp),%r8
lea    -0x58(%rbp),%r9
call   1070 <generate_summary@plt>
mov    -0x48(%rbp),%rsi
lea    0xd5c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    12c2 <main+0x112>
mov    0x8(%rbx),%rdi
lea    0xe46(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1299 <main+0xe9>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <fileno@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   10d0 <fstat@plt>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    122e <main+0x7e>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movslq %eax,%rbx
lea    (%r15,%rbx,1),%rdi
mov    %ebp,%edx
sub    %ebx,%edx
mov    $0x1,%esi
mov    %r14,%rcx
call   1040 <fread@plt>
add    %ebx,%eax
cmp    %eax,%ebp
jg     1210 <main+0x60>
lea    0x20(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <generate_summary@plt>
mov    0x8(%rsp),%rsi
lea    0xdd5(%rip),%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    12b7 <main+0x107>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xd6c(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd34(%rip),%rdi
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [23 x i8] c"Usage: %s <filename>\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Could not open %s.\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %36, label %30
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 -1, i32* %3
br label %84
36: ; preds = %23
%37 = load i32*, i32** %6
%38 = call i32 @fileno(i32* %37)
%39 = call i32 @fstat(i32 %38, %struct.stat* %7)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%41 = load i32, i32* %40
store i32 %41, i32* %8
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = mul i64 1, %43
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %9
store i32 0, i32* %10
br label %48
48: ; preds = %52, %36
%49 = load i32, i32* %10
%50 = load i32, i32* %8
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %66
52: ; preds = %48
%53 = load i8*, i8** %9
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i32, i32* %8
%58 = load i32, i32* %10
%59 = sub nsw i32 %57, %58
%60 = load i32*, i32** %6
%61 = call i64 @fread(i8* %56, i32 1, i32 %59, i32* %60)
%62 = load i32, i32* %10
%63 = sext i32 %62 to i64
%64 = add nsw i64 %63, %61
%65 = trunc i64 %64 to i32
store i32 %65, i32* %10
br label %48
66: ; preds = %48
%67 = load i8*, i8** %9
%68 = load i32, i32* %8
%69 = call i32 @generate_summary(i8* %67, i32 %68, i8** %11, i8** %12, i8** %13, i8** %14)
%70 = load i8*, i8** %12
%71 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %9
%73 = call i32 @free(i8* %72)
%74 = load i8*, i8** %11
%75 = call i32 @free(i8* %74)
%76 = load i8*, i8** %12
%77 = call i32 @free(i8* %76)
%78 = load i8*, i8** %13
%79 = call i32 @free(i8* %78)
%80 = load i8*, i8** %14
%81 = call i32 @free(i8* %80)
%82 = load i32*, i32** %6
%83 = call i32 @fclose(i32* %82)
br label %84
84: ; preds = %66, %30
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [23 x i8] c"Usage: %s <filename>\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"Could not open %s.\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %58
22: ; preds = %13
%23 = bitcast %struct.stat* %3 to i8*
%24 = tail call i32 @fileno(i32* %16)
%25 = call i32 @fstat(i32 %24, %struct.stat* %3)
%26 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%27 = load i32, i32* %26
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i8*
%30 = icmp sgt i32 %27, 0
br i1 %30, label %31, label %40
31: ; preds = %22, %31
%32 = phi i32 [ %38, %31 ], [ 0, %22 ]
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = sub nsw i32 %27, %32
%36 = tail call i64 @fread(i8* %34, i32 1, i32 %35, i32* %16)
%37 = trunc i64 %36 to i32
%38 = add i32 %32, %37
%39 = icmp sgt i32 %27, %38
br i1 %39, label %31, label %40
40: ; preds = %31, %22
%41 = bitcast i8** %4 to i8*
%42 = bitcast i8** %5 to i8*
%43 = bitcast i8** %6 to i8*
%44 = bitcast i8** %7 to i8*
%45 = call i32 @generate_summary(i8* %29, i32 %27, i8** %4, i8** %5, i8** %6, i8** %7)
%46 = load i8*, i8** %5
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %46)
%48 = call i32 @free(i8* %29)
%49 = load i8*, i8** %4
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %5
%52 = call i32 @free(i8* %51)
%53 = load i8*, i8** %6
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %7
%56 = call i32 @free(i8* %55)
%57 = call i32 @fclose(i32* %16)
br label %58
58: ; preds = %40, %18
%59 = phi i32 [ 0, %40 ], [ -1, %18 ]
ret i32 %59
}