#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 */
scalar_t__ fh_cli_alias_add(char *, char *);
int /*<<< orphan*/ fh_cli_alias_save();
int /*<<< orphan*/ fh_cli_print(char *, char *);
int /*<<< orphan*/ fh_cli_write(char *, ...);
int strlen(char *);
int alias_add_cb(char *full_cmd, char **argv, int argc) {
  char *last_arg = argv[argc - 1];
  if (argc > 2) {
    fh_cli_write("Usage: %s <alias> \"<cmd>\"\n", full_cmd);
    return 0;
  }
  if (last_arg[strlen(last_arg) - 1] == '?') {
    fh_cli_write("\n");
    if (argc == 1) {
      fh_cli_print("<Alias>", "Define an alias");
    }
    fh_cli_print("<cmd>", "Command corresponding to your alias");
    return 0;
  } else if (argc != 2) {
    fh_cli_write("Incomplete command: %s\n", full_cmd);
    return 0;
  }
  if (fh_cli_alias_add(argv[0], argv[1]) == 0) {
    fh_cli_write("Adding alias: %s -> %s\n", argv[0], argv[1]);
    fh_cli_alias_save();
  }
  return 0;
}


x86 assembly (clang, -O0):
<alias_add_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)
cmpl   $0x2,-0x1c(%rbp)
jle    11a0 <alias_add_cb+0x50>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
movl   $0x0,-0x4(%rbp)
jmp    128a <alias_add_cb+0x13a>
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    1214 <alias_add_cb+0xc4>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    11f5 <alias_add_cb+0xa5>
lea    0xe32(%rip),%rdi
lea    0xe33(%rip),%rsi
call   1070 <fh_cli_print@plt>
lea    0xe37(%rip),%rdi
lea    0xe36(%rip),%rsi
call   1070 <fh_cli_print@plt>
movl   $0x0,-0x4(%rbp)
jmp    128a <alias_add_cb+0x13a>
cmpl   $0x2,-0x1c(%rbp)
je     123c <alias_add_cb+0xec>
mov    -0x10(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
movl   $0x0,-0x4(%rbp)
jmp    128a <alias_add_cb+0x13a>
jmp    1241 <alias_add_cb+0xf1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1050 <fh_cli_alias_add@plt>
cmp    $0x0,%rax
jne    1283 <alias_add_cb+0x133>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
mov    $0x0,%al
call   1060 <fh_cli_alias_save@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alias_add_cb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    $0x3,%edx
jl     1175 <alias_add_cb+0x25>
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
jmp    1200 <alias_add_cb+0xb0>
mov    %edx,%ebp
mov    %rsi,%r15
movslq %edx,%rax
mov    -0x8(%rsi,%rax,8),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x3f,-0x1(%rax,%rbx,1)
jne    11ce <alias_add_cb+0x7e>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
cmp    $0x1,%ebp
jne    11b9 <alias_add_cb+0x69>
lea    0xe6e(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <fh_cli_print@plt>
lea    0xe73(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1070 <fh_cli_print@plt>
jmp    1200 <alias_add_cb+0xb0>
cmp    $0x2,%ebp
jne    120d <alias_add_cb+0xbd>
mov    (%r15),%rdi
mov    0x8(%r15),%rsi
call   1050 <fh_cli_alias_add@plt>
test   %rax,%rax
jne    1200 <alias_add_cb+0xb0>
mov    (%r15),%rsi
mov    0x8(%r15),%rdx
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
xor    %eax,%eax
call   1060 <fh_cli_alias_save@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe49(%rip),%rdi
jmp    1166 <alias_add_cb+0x16>

LLVM IR (-O0):
@.str = [27 x i8] c"Usage: %s <alias> \22<cmd>\22\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"<Alias>\00"
@.str.3 = [16 x i8] c"Define an alias\00"
@.str.4 = [6 x i8] c"<cmd>\00"
@.str.5 = [36 x i8] c"Command corresponding to your alias\00"
@.str.6 = [24 x i8] c"Incomplete command: %s\0A\00"
@.str.7 = [24 x i8] c"Adding alias: %s -> %s\0A\00"
define i32 @alias_add_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 i32, i32* %7
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 0, i32* %4
br label %64
20: ; preds = %3
%21 = load i8*, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 @strlen(i8* %22)
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 63
br i1 %29, label %30, label %38
30: ; preds = %20
%31 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @fh_cli_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
%37 = call i32 @fh_cli_print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %4
br label %64
38: ; preds = %20
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 2
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %5
%43 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %42)
store i32 0, i32* %4
br label %64
44: ; preds = %38
br label %45
45: ; preds = %44
%46 = load i8**, i8*** %6
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = load i8**, i8*** %6
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @fh_cli_alias_add(i8* %48, i8* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %45
%55 = load i8**, i8*** %6
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = load i8**, i8*** %6
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %57, i8* %60)
%62 = call i32 (...) @fh_cli_alias_save()
br label %63
63: ; preds = %54, %45
store i32 0, i32* %4
br label %64
64: ; preds = %63, %41, %36, %17
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
@.str = [27 x i8] c"Usage: %s <alias> \22<cmd>\22\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"<Alias>\00"
@.str.3 = [16 x i8] c"Define an alias\00"
@.str.4 = [6 x i8] c"<cmd>\00"
@.str.5 = [36 x i8] c"Command corresponding to your alias\00"
@.str.6 = [24 x i8] c"Incomplete command: %s\0A\00"
@.str.7 = [24 x i8] c"Adding alias: %s -> %s\0A\00"
define i32 @alias_add_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 = icmp sgt i32 %2, 2
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %40
11: ; preds = %3
%12 = tail call i32 @strlen(i8* %7)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %7, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 63
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32 %2, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @fh_cli_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = tail call i32 @fh_cli_print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %40
25: ; preds = %11
%26 = icmp eq i32 %2, 2
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %40
29: ; preds = %25
%30 = load i8*, i8** %1
%31 = getelementptr inbounds i8*, i8** %1, i64 1
%32 = load i8*, i8** %31
%33 = tail call i64 @fh_cli_alias_add(i8* %30, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = load i8*, i8** %1
%37 = load i8*, i8** %31
%38 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %36, i8* %37)
%39 = tail call i32 (...) @fh_cli_alias_save()
br label %40
40: ; preds = %29, %35, %27, %23, %9
ret i32 0
}