#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_del(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_del_cb(char *full_cmd, char **argv, int argc) {
  char *last_arg = argv[argc - 1];
  if (argc > 1) {
    fh_cli_write("Usage: %s <alias>\n", full_cmd);
    return 0;
  }
  if (last_arg[strlen(last_arg) - 1] == '?') {
    fh_cli_write("\n");
    fh_cli_print("<Alias>", "Alias to delete");
    return 0;
  } else if (argc != 1) {
    fh_cli_write("Incomplete command: %s\n", full_cmd);
    return 0;
  }
  if (fh_cli_alias_del(argv[0]) == 0) {
    fh_cli_write("Deleting alias: %s\n", argv[0]);
    fh_cli_alias_save();
  }
  return 0;
}


x86 assembly (clang, -O0):
<alias_del_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   $0x1,-0x1c(%rbp)
jle    11a0 <alias_del_cb+0x50>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <alias_del_cb+0x10d>
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    11f7 <alias_del_cb+0xa7>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
lea    0xe34(%rip),%rdi
lea    0xe35(%rip),%rsi
call   1070 <fh_cli_print@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <alias_del_cb+0x10d>
cmpl   $0x1,-0x1c(%rbp)
je     121f <alias_del_cb+0xcf>
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <alias_del_cb+0x10d>
jmp    1224 <alias_del_cb+0xd4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1060 <fh_cli_alias_del@plt>
cmp    $0x0,%rax
jne    1256 <alias_del_cb+0x106>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <fh_cli_write@plt>
mov    $0x0,%al
call   1050 <fh_cli_alias_save@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alias_del_cb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    $0x2,%edx
jl     1172 <alias_del_cb+0x22>
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
jmp    11dd <alias_del_cb+0x8d>
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    11b3 <alias_del_cb+0x63>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
lea    0xe6e(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <fh_cli_print@plt>
jmp    11dd <alias_del_cb+0x8d>
cmp    $0x1,%ebp
jne    11ea <alias_del_cb+0x9a>
mov    (%r15),%rdi
call   1060 <fh_cli_alias_del@plt>
test   %rax,%rax
jne    11dd <alias_del_cb+0x8d>
mov    (%r15),%rsi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <fh_cli_write@plt>
xor    %eax,%eax
call   1050 <fh_cli_alias_save@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3a(%rip),%rdi
jmp    1166 <alias_del_cb+0x16>

LLVM IR (-O0):
@.str = [19 x i8] c"Usage: %s <alias>\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"<Alias>\00"
@.str.3 = [16 x i8] c"Alias to delete\00"
@.str.4 = [24 x i8] c"Incomplete command: %s\0A\00"
@.str.5 = [20 x i8] c"Deleting alias: %s\0A\00"
define i32 @alias_del_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, 1
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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 0, i32* %4
br label %53
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 %33
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 = 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))
store i32 0, i32* %4
br label %53
33: ; preds = %20
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %5
%38 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %37)
store i32 0, i32* %4
br label %53
39: ; preds = %33
br label %40
40: ; preds = %39
%41 = load i8**, i8*** %6
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i64 @fh_cli_alias_del(i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %40
%47 = load i8**, i8*** %6
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %49)
%51 = call i32 (...) @fh_cli_alias_save()
br label %52
52: ; preds = %46, %40
store i32 0, i32* %4
br label %53
53: ; preds = %52, %36, %30, %17
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage: %s <alias>\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"<Alias>\00"
@.str.3 = [16 x i8] c"Alias to delete\00"
@.str.4 = [24 x i8] c"Incomplete command: %s\0A\00"
@.str.5 = [20 x i8] c"Deleting alias: %s\0A\00"
define i32 @alias_del_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, 1
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %33
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 %21
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 = 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 %33
21: ; preds = %11
%22 = icmp eq i32 %2, 1
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %33
25: ; preds = %21
%26 = load i8*, i8** %1
%27 = tail call i64 @fh_cli_alias_del(i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8*, i8** %1
%31 = tail call i32 (i8*, ...) @fh_cli_write(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = tail call i32 (...) @fh_cli_alias_save()
br label %33
33: ; preds = %25, %29, %23, %18, %9
ret i32 0
}