#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 scalar_t__ ssize_t;
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ bu_handle_version(int, char **);
int /*<<< orphan*/ bu_missing_argument(char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ has_arg(int, char **, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stdout;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  if (has_arg(argc, argv, "-h") || has_arg(argc, argv, "--help")) {
    puts("Usage: man [-k] PAGE...");
    puts("");
    puts("Prints the specified manual page(s).");
    puts("");
    puts("PAGE  The page(s) to print.");
    return 1;
  }
  if (bu_handle_version(argc, argv)) {
    return 0;
  }
  if (argc < 2) {
    bu_missing_argument(argv[0]);
    return 1;
  }
  char path[8192] = "./doc/";
  strncpy(path + strlen(path), argv[1], sizeof(path) - strlen(path));
  strncpy(path + strlen(path), ".rst", sizeof(path) - strlen(path));
  int fd = open(path, O_RDONLY);
  char buf[8192] = {0};
  ssize_t bytes_read = 1;
  while (bytes_read > 0) {
    bytes_read = read(fd, buf, sizeof(buf));
    fputs(buf, stdout);
    memset(buf, 0, sizeof(buf));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe39(%rip),%rdx
call   1050 <has_arg@plt>
cmp    $0x0,%rax
jne    11f3 <main+0x53>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdx
call   1050 <has_arg@plt>
cmp    $0x0,%rax
je     123b <main+0x9b>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
lea    0xe28(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    141c <main+0x27c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10b0 <bu_handle_version@plt>
cmp    $0x0,%rax
je     125d <main+0xbd>
movl   $0x0,-0x4(%rbp)
jmp    141c <main+0x27c>
cmpl   $0x2,-0x8(%rbp)
jge    127f <main+0xdf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <bu_missing_argument@plt>
movl   $0x1,-0x4(%rbp)
jmp    141c <main+0x27c>
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1080 <memset@plt>
movb   $0x2e,-0x2010(%rbp)
movb   $0x2f,-0x200f(%rbp)
movb   $0x64,-0x200e(%rbp)
movb   $0x6f,-0x200d(%rbp)
movb   $0x63,-0x200c(%rbp)
movb   $0x2f,-0x200b(%rbp)
lea    -0x2010(%rbp),%rax
mov    %rax,-0x4050(%rbp)
lea    -0x2010(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x4050(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4048(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x4040(%rbp)
lea    -0x2010(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x4048(%rbp),%rdi
mov    -0x4040(%rbp),%rsi
movslq %eax,%rcx
mov    $0x2000,%eax
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x4038(%rbp)
lea    -0x2010(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x4038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4030(%rbp)
lea    -0x2010(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x4030(%rbp),%rdi
movslq %eax,%rcx
mov    $0x2000,%eax
sub    %rcx,%rax
mov    %eax,%edx
lea    0xce5(%rip),%rsi
call   1030 <strncpy@plt>
lea    -0x2010(%rbp),%rdi
mov    0x2c57(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x2014(%rbp)
lea    -0x4020(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1080 <memset@plt>
movq   $0x1,-0x4028(%rbp)
cmpq   $0x0,-0x4028(%rbp)
jle    1415 <main+0x275>
mov    -0x2014(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    $0x2000,%edx
call   1090 <read@plt>
mov    %rax,-0x4028(%rbp)
lea    -0x4020(%rbp),%rdi
mov    0x2be2(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs@plt>
lea    -0x4020(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1080 <memset@plt>
jmp    13bc <main+0x21c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4008,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe37(%rip),%rdx
call   1060 <has_arg@plt>
test   %rax,%rax
jne    11e9 <main+0x39>
lea    0xe29(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <has_arg@plt>
test   %rax,%rax
je     1234 <main+0x84>
lea    0xe1a(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe1c(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe2b(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%eax
add    $0x4008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
mov    %rbx,%rsi
call   10c0 <bu_handle_version@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1226 <main+0x76>
cmp    $0x1,%ebp
jg     1257 <main+0xa7>
mov    (%rbx),%rdi
call   10d0 <bu_missing_argument@plt>
jmp    1221 <main+0x71>
mov    %rsp,%r14
mov    $0x2000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
movl   $0x6f642f2e,(%rsp)
movw   $0x2f63,0x4(%rsp)
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
mov    0x8(%rbx),%r15
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    $0x2000,%ebx
mov    $0x2000,%edx
sub    %eax,%edx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
mov    %r14,%rdi
call   1070 <strlen@plt>
sub    %eax,%ebx
lea    0xd9c(%rip),%rsi
mov    %rbp,%rdi
mov    %ebx,%edx
call   1040 <strncpy@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10b0 <open@plt>
mov    %eax,%r14d
lea    0x2000(%rsp),%rbp
mov    $0x2000,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
mov    0x2cd5(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x2000,%edx
call   10a0 <read@plt>
mov    %rax,%rbx
mov    (%r15),%esi
mov    %rbp,%rdi
call   1080 <fputs@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1090 <memset@plt>
test   %rbx,%rbx
jg     1310 <main+0x160>
xor    %eax,%eax
jmp    1226 <main+0x76>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [24 x i8] c"Usage: man [-k] PAGE...\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [37 x i8] c"Prints the specified manual page(s).\00"
@.str.5 = [28 x i8] c"PAGE The page(s) to print.\00"
@.str.6 = [5 x i8] c".rst\00"
@O_RDONLY = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8192 x i8]
%7 = alloca i32
%8 = alloca [8192 x i8]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i64 @has_arg(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i64 @has_arg(i32 %15, i8** %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14, %2
%20 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %90
25: ; preds = %14
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i64 @bu_handle_version(i32 %26, i8** %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %3
br label %90
31: ; preds = %25
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @bu_missing_argument(i8* %37)
store i32 1, i32* %3
br label %90
39: ; preds = %31
%40 = bitcast [8192 x i8]* %6 to i8*
%41 = bitcast i8* %40 to [8192 x i8]*
%42 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 0
store i8 46, i8* %42
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 1
store i8 47, i8* %43
%44 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 2
store i8 100, i8* %44
%45 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 3
store i8 111, i8* %45
%46 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 4
store i8 99, i8* %46
%47 = getelementptr inbounds [8192 x i8], [8192 x i8]* %41, i32 0, i32 5
store i8 47, i8* %47
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%49 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = sext i32 %57 to i64
%59 = sub i64 8192, %58
%60 = trunc i64 %59 to i32
%61 = call i32 @strncpy(i8* %52, i8* %55, i32 %60)
%62 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%63 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%64 = call i32 @strlen(i8* %63)
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
%67 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%68 = call i32 @strlen(i8* %67)
%69 = sext i32 %68 to i64
%70 = sub i64 8192, %69
%71 = trunc i64 %70 to i32
%72 = call i32 @strncpy(i8* %66, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%74 = load i32, i32* @O_RDONLY
%75 = call i32 @open(i8* %73, i32 %74)
store i32 %75, i32* %7
%76 = bitcast [8192 x i8]* %8 to i8*
store i64 1, i64* %9
br label %77
77: ; preds = %80, %39
%78 = load i64, i64* %9
%79 = icmp sgt i64 %78, 0
br i1 %79, label %80, label %89
80: ; preds = %77
%81 = load i32, i32* %7
%82 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%83 = call i64 @read(i32 %81, i8* %82, i32 8192)
store i64 %83, i64* %9
%84 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%85 = load i32, i32* @stdout
%86 = call i32 @fputs(i8* %84, i32 %85)
%87 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%88 = call i32 @memset(i8* %87, i32 0, i32 8192)
br label %77
89: ; preds = %77
store i32 0, i32* %3
br label %90
90: ; preds = %89, %34, %30, %19
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [24 x i8] c"Usage: man [-k] PAGE...\00"
@.str.4 = [37 x i8] c"Prints the specified manual page(s).\00"
@.str.5 = [28 x i8] c"PAGE The page(s) to print.\00"
@.str.6 = [5 x i8] c".rst\00"
@O_RDONLY = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [8192 x i8]
%4 = alloca [8192 x i8]
%5 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i64 @has_arg(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7, %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @putchar(i32 10)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %55
16: ; preds = %7
%17 = tail call i64 @bu_handle_version(i32 %0, i8** %1)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %55
19: ; preds = %16
%20 = icmp slt i32 %0, 2
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i8*, i8** %1
%23 = tail call i32 @bu_missing_argument(i8* %22)
br label %55
24: ; preds = %19
%25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
store i8 46, i8* %25
%26 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 1
store i8 47, i8* %26
%27 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 2
store i8 100, i8* %27
%28 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 3
store i8 111, i8* %28
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 4
store i8 99, i8* %29
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 5
store i8 47, i8* %30
%31 = call i32 @strlen(i8* %25)
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %32
%34 = getelementptr inbounds i8*, i8** %1, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %25)
%37 = sub i32 8192, %36
%38 = call i32 @strncpy(i8* %33, i8* %35, i32 %37)
%39 = call i32 @strlen(i8* %25)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 %40
%42 = call i32 @strlen(i8* %25)
%43 = sub i32 8192, %42
%44 = call i32 @strncpy(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = load i32, i32* @O_RDONLY
%46 = call i32 @open(i8* %25, i32 %45)
%47 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
br label %48
48: ; preds = %24, %48
%49 = call i64 @read(i32 %46, i8* %47, i32 8192)
%50 = load i32, i32* @stdout
%51 = call i32 @fputs(i8* %47, i32 %50)
%52 = call i32 @memset(i8* %47, i32 0, i32 8192)
%53 = icmp sgt i64 %49, 0
br i1 %53, label %48, label %54
54: ; preds = %48
br label %55
55: ; preds = %16, %54, %21, %10
%56 = phi i32 [ 1, %10 ], [ 1, %21 ], [ 0, %54 ], [ 0, %16 ]
ret i32 %56
}