#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*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
void help(void) {
  FILE *fd;
  int c;
  if ((fd = fopen("/usr/lib/cpm.hlp", "r")) == NULL)
    printf("Can't find help file (cpm.hlp) \n");
  else
    while ((c = getc(fd)) != EOF)
      putchar(c);
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    117a <help+0x3a>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <help+0x6c>
jmp    117f <help+0x3f>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <help+0x67>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
jmp    117f <help+0x3f>
jmp    11ac <help+0x6c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     119c <help+0x5c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e7a(%rip),%r14
cmp    (%r14),%eax
je     1194 <help+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r14),%eax
jne    1180 <help+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe70(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/usr/lib/cpm.hlp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [33 x i8] c"Can't find help file (cpm.hlp) \0A\00"
@EOF = global i32 0
define void @help() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %17
7: ; preds = %0
br label %8
8: ; preds = %13, %7
%9 = load i32*, i32** %1
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %2
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %2
%15 = call i32 @putchar(i32 %14)
br label %8
16: ; preds = %8
br label %17
17: ; preds = %16, %5
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"/usr/lib/cpm.hlp\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [32 x i8] c"Can't find help file (cpm.hlp) \00"
define void @help() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %7, label %3
3: ; preds = %0
%4 = tail call i32 @getc(i32* %1)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %15, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %15
9: ; preds = %3, %9
%10 = phi i32 [ %12, %9 ], [ %4, %3 ]
%11 = tail call i32 @putchar(i32 %10)
%12 = tail call i32 @getc(i32* %1)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %9
15: ; preds = %9, %3, %7
ret void
}