#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 PATH_MAX;
int /*<<< orphan*/ copy_file(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int print_help(char *self_name, char *project_path) {
  char help_file_path[PATH_MAX];
  sprintf(help_file_path, "%s/%s", project_path, "help_menu");
  FILE *help_file = fopen(help_file_path, "r");
  if (help_file == NULL) {
    fprintf(stderr, "ERRO ao abrir arquivo com informações de ajuda.\n");
    return ((-1));
  }
  printf("uso: %s", self_name);
  copy_file(stdout, help_file);
  return ((0));
}


x86 assembly (clang, -O0):
<print_help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
lea    0xe69(%rip),%rsi
lea    0xe68(%rip),%rcx
call   1070 <sprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ea <print_help+0x9a>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    121a <print_help+0xca>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
call   1030 <copy_file@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_help>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rsi,%rdx
mov    %rdi,%r14
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe82(%rip),%rsi
lea    0xe81(%rip),%rcx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c8 <print_help+0x78>
mov    %rax,%rbx
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1030 <copy_file@plt>
xor    %eax,%eax
jmp    11e2 <print_help+0x92>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [10 x i8] c"help_menu\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [51 x i8] c"ERRO ao abrir arquivo com informa\C3\A7\C3\B5es de ajuda.\0A\00"
@.str.4 = [8 x i8] c"uso: %s\00"
@stdout = global i32 0
define i32 @print_help(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i32, i32* @PATH_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
%14 = load i8*, i8** %5
%15 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %9
br label %28
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @stdout
%26 = load i32*, i32** %8
%27 = call i32 @copy_file(i32 %25, i32* %26)
store i32 0, i32* %3
store i32 1, i32* %9
br label %28
28: ; preds = %22, %19
%29 = load i8*, i8** %6
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [10 x i8] c"help_menu\00"
@.str.2 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.3 = [51 x i8] c"ERRO ao abrir arquivo com informa\C3\A7\C3\B5es de ajuda.\0A\00"
@.str.4 = [8 x i8] c"uso: %s\00"
@stdout = global i32 0
define i32 @print_help(i8* %0, i8* %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
br label %16
12: ; preds = %2
%13 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%14 = load i32, i32* @stdout
%15 = tail call i32 @copy_file(i32 %14, i32* %7)
br label %16
16: ; preds = %12, %9
%17 = phi i32 [ -1, %9 ], [ 0, %12 ]
ret i32 %17
}