#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*/ assert(char *);
int /*<<< orphan*/ fh_cli_help();
int /*<<< orphan*/ fh_cli_print(char *, char *);
int /*<<< orphan*/ fh_cli_write(char *);
int strlen(char *);
int help_cb(char *full_cmd, char **argv, int argc) {
  char *last_arg = argv[argc - 1];
  assert(full_cmd);
  if (last_arg[strlen(last_arg) - 1] == '?') {
    fh_cli_write("\n");
    fh_cli_print("<Enter>", "Display the CLI help");
    return 0;
  }
  fh_cli_help();
  return 0;
}


x86 assembly (clang, -O0):
<help_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3f,%eax
jne    11d6 <help_cb+0x86>
lea    0xe4e(%rip),%rdi
call   1040 <fh_cli_write@plt>
lea    0xe44(%rip),%rdi
lea    0xe45(%rip),%rsi
call   1070 <fh_cli_print@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <help_cb+0x94>
mov    $0x0,%al
call   1060 <fh_cli_help@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help_cb>:
push   %rbx
movslq %edx,%rax
mov    -0x8(%rsi,%rax,8),%rbx
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x3f,-0x1(%rax,%rbx,1)
jne    1190 <help_cb+0x40>
lea    0xe8a(%rip),%rdi
call   1040 <fh_cli_write@plt>
lea    0xe80(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fh_cli_print@plt>
jmp    1197 <help_cb+0x47>
xor    %eax,%eax
call   1060 <fh_cli_help@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [8 x i8] c"<Enter>\00"
@.str.2 = [21 x i8] c"Display the CLI help\00"
define i32 @help_cb(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%9 = load i8**, i8*** %6
%10 = load i32, i32* %7
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %9, i64 %12
%14 = load i8*, i8** %13
store i8* %14, i8** %8
%15 = load i8*, i8** %5
%16 = call i32 @assert(i8* %15)
%17 = load i8*, i8** %8
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 63
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = call i32 @fh_cli_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @fh_cli_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %31
29: ; preds = %3
%30 = call i32 (...) @fh_cli_help()
store i32 0, i32* %4
br label %31
31: ; preds = %29, %26
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [8 x i8] c"<Enter>\00"
@.str.2 = [21 x i8] c"Display the CLI help\00"
define i32 @help_cb(i8* %0, i8** nocapture %1, i32 %2) {
%4 = add nsw i32 %2, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8*, i8** %1, i64 %5
%7 = load i8*, i8** %6
%8 = tail call i32 @assert(i8* %0)
%9 = tail call i32 @strlen(i8* %7)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 63
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = tail call i32 @fh_cli_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @fh_cli_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %3
%19 = tail call i32 (...) @fh_cli_help()
br label %20
20: ; preds = %18, %15
ret i32 0
}