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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void help(char *argv[]) {
  if (argv[1]) {
    fprintf(stderr, "Error: Invalid arguments.\n");
    fprintf(stderr, "Usage: %s\n", argv[0]);
  } else {
    printf("Available built-in commands:\n");
    printf("- echo\n");
    printf("- exit\n");
    printf("- quit\n");
    printf("- cd\n");
    printf("- chdir\n");
    printf("- history\n");
    printf("- version\n");
    printf("- help\n");
  }
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1175 <help+0x55>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11e1 <help+0xc1>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help>:
push   %r14
push   %rbx
push   %rax
cmpq   $0x0,0x8(%rdi)
je     1161 <help+0x41>
mov    %rdi,%rbx
mov    0x2eab(%rip),%r14
mov    (%r14),%edi
lea    0xec1(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
mov    (%rbx),%rdx
lea    0xec8(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fprintf@plt>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Error: Invalid arguments.\0A\00"
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@.str.2 = [30 x i8] c"Available built-in commands:\0A\00"
@.str.3 = [8 x i8] c"- echo\0A\00"
@.str.4 = [8 x i8] c"- exit\0A\00"
@.str.5 = [8 x i8] c"- quit\0A\00"
@.str.6 = [6 x i8] c"- cd\0A\00"
@.str.7 = [9 x i8] c"- chdir\0A\00"
@.str.8 = [11 x i8] c"- history\0A\00"
@.str.9 = [11 x i8] c"- version\0A\00"
@.str.10 = [8 x i8] c"- help\0A\00"
define void @help(i8** %0) {
%2 = alloca i8**
store i8** %0, i8*** %2
%3 = load i8**, i8*** %2
%4 = getelementptr inbounds i8*, i8** %3, i64 1
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %2
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %25
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %25
25: ; preds = %15, %7
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Error: Invalid arguments.\0A\00"
@.str.1 = [11 x i8] c"Usage: %s\0A\00"
@str = [29 x i8] c"Available built-in commands:\00"
@str.11 = [7 x i8] c"- echo\00"
@str.12 = [7 x i8] c"- exit\00"
@str.13 = [7 x i8] c"- quit\00"
@str.14 = [5 x i8] c"- cd\00"
@str.15 = [8 x i8] c"- chdir\00"
@str.16 = [10 x i8] c"- history\00"
@str.17 = [10 x i8] c"- version\00"
@str.18 = [7 x i8] c"- help\00"
define void @help(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %0
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %21
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.12, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.13, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.16, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.17, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.18, i64 0, i64 0))
br label %21
21: ; preds = %11, %5
ret void
}