#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 */
struct cli {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, ...);
int /*<<< orphan*/ cli_send(struct cli *, char *, scalar_t__);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int _set_alternative(struct cli *cli, int argc, char *argv[]) {
  if (argc <= 0) {
    {
      char *__tmp;
      asprintf(&__tmp, "> "
                       "argc <= 0 is invalid"
                       "\n\r");
      cli_send(cli, __tmp, strlen(__tmp) + 1);
      free(__tmp);
    };
    return (-1);
  }
  {
    char *__tmp;
    asprintf(&__tmp,
             "argv[0] = %s"
             "\n\r",
             argv[0]);
    cli_send(cli, __tmp, strlen(__tmp) + 1);
    free(__tmp);
  };
  if (0 == strcmp(argv[0], "on")) {
    {
      char *__tmp;
      asprintf(&__tmp, "turn on"
                       "\n\r");
      cli_send(cli, __tmp, strlen(__tmp) + 1);
      free(__tmp);
    };
  } else if (0 == strcmp(argv[0], "off")) {
    {
      char *__tmp;
      asprintf(&__tmp, "turn off"
                       "\n\r");
      cli_send(cli, __tmp, strlen(__tmp) + 1);
      free(__tmp);
    };
  } else if (0 == strcmp(argv[0], "fuzzy")) {
    {
      char *__tmp;
      asprintf(&__tmp, "fuzzy mode"
                       "\n\r");
      cli_send(cli, __tmp, strlen(__tmp) + 1);
      free(__tmp);
    };
  }
  return (0);
}


x86 assembly (clang, -O0):
<_set_alternative>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11c4 <_set_alternative+0x74>
lea    -0x28(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <cli_send@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    137b <_set_alternative+0x22b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    -0x30(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <cli_send@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xe07(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1281 <_set_alternative+0x131>
lea    -0x38(%rbp),%rdi
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <cli_send@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    1374 <_set_alternative+0x224>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xda6(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12f5 <_set_alternative+0x1a5>
lea    -0x40(%rbp),%rdi
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <cli_send@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    136f <_set_alternative+0x21f>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xd41(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    136a <_set_alternative+0x21a>
lea    -0x48(%rbp),%rdi
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1070 <cli_send@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    136f <_set_alternative+0x21f>
jmp    1374 <_set_alternative+0x224>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_set_alternative>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %esi,%esi
jle    11ec <_set_alternative+0x9c>
mov    %rdx,%rbx
mov    (%rdx),%rdx
lea    0xeaa(%rip),%rsi
xor    %r15d,%r15d
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <asprintf@plt>
mov    (%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <cli_send@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    (%rbx),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1229 <_set_alternative+0xd9>
mov    (%rbx),%rdi
lea    0xe77(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1232 <_set_alternative+0xe2>
mov    (%rbx),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    126a <_set_alternative+0x11a>
lea    0xe60(%rip),%rsi
jmp    1239 <_set_alternative+0xe9>
lea    0xe0d(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <asprintf@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <cli_send@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    $0xffffffff,%r15d
jmp    126a <_set_alternative+0x11a>
lea    0xdfb(%rip),%rsi
jmp    123c <_set_alternative+0xec>
lea    0xe00(%rip),%rsi
xor    %r15d,%r15d
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <asprintf@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <cli_send@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cli = type { i32 }
@.str = [25 x i8] c"> argc <= 0 is invalid\0A\0D\00"
@.str.1 = [15 x i8] c"argv[0] = %s\0A\0D\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [10 x i8] c"turn on\0A\0D\00"
@.str.4 = [4 x i8] c"off\00"
@.str.5 = [11 x i8] c"turn off\0A\0D\00"
@.str.6 = [6 x i8] c"fuzzy\00"
@.str.7 = [13 x i8] c"fuzzy mode\0A\0D\00"
define i32 @_set_alternative(%struct.cli* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.cli*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store %struct.cli* %0, %struct.cli** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%13 = load i32, i32* %6
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %3
%16 = call i32 (i8**, i8*, ...) @asprintf(i8** %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%17 = load %struct.cli*, %struct.cli** %5
%18 = load i8*, i8** %8
%19 = load i8*, i8** %8
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = call i32 @cli_send(%struct.cli* %17, i8* %18, i64 %21)
%23 = load i8*, i8** %8
%24 = call i32 @free(i8* %23)
store i32 -1, i32* %4
br label %88
25: ; preds = %3
%26 = load i8**, i8*** %7
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i8**, i8*, ...) @asprintf(i8** %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load %struct.cli*, %struct.cli** %5
%31 = load i8*, i8** %9
%32 = load i8*, i8** %9
%33 = call i64 @strlen(i8* %32)
%34 = add nsw i64 %33, 1
%35 = call i32 @cli_send(%struct.cli* %30, i8* %31, i64 %34)
%36 = load i8*, i8** %9
%37 = call i32 @free(i8* %36)
%38 = load i8**, i8*** %7
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i64 0, %41
br i1 %42, label %43, label %53
43: ; preds = %25
%44 = call i32 (i8**, i8*, ...) @asprintf(i8** %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%45 = load %struct.cli*, %struct.cli** %5
%46 = load i8*, i8** %10
%47 = load i8*, i8** %10
%48 = call i64 @strlen(i8* %47)
%49 = add nsw i64 %48, 1
%50 = call i32 @cli_send(%struct.cli* %45, i8* %46, i64 %49)
%51 = load i8*, i8** %10
%52 = call i32 @free(i8* %51)
br label %87
53: ; preds = %25
%54 = load i8**, i8*** %7
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%58 = icmp eq i64 0, %57
br i1 %58, label %59, label %69
59: ; preds = %53
%60 = call i32 (i8**, i8*, ...) @asprintf(i8** %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%61 = load %struct.cli*, %struct.cli** %5
%62 = load i8*, i8** %11
%63 = load i8*, i8** %11
%64 = call i64 @strlen(i8* %63)
%65 = add nsw i64 %64, 1
%66 = call i32 @cli_send(%struct.cli* %61, i8* %62, i64 %65)
%67 = load i8*, i8** %11
%68 = call i32 @free(i8* %67)
br label %86
69: ; preds = %53
%70 = load i8**, i8*** %7
%71 = getelementptr inbounds i8*, i8** %70, i64 0
%72 = load i8*, i8** %71
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%74 = icmp eq i64 0, %73
br i1 %74, label %75, label %85
75: ; preds = %69
%76 = call i32 (i8**, i8*, ...) @asprintf(i8** %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%77 = load %struct.cli*, %struct.cli** %5
%78 = load i8*, i8** %12
%79 = load i8*, i8** %12
%80 = call i64 @strlen(i8* %79)
%81 = add nsw i64 %80, 1
%82 = call i32 @cli_send(%struct.cli* %77, i8* %78, i64 %81)
%83 = load i8*, i8** %12
%84 = call i32 @free(i8* %83)
br label %85
85: ; preds = %75, %69
br label %86
86: ; preds = %85, %59
br label %87
87: ; preds = %86, %43
store i32 0, i32* %4
br label %88
88: ; preds = %87, %15
%89 = load i32, i32* %4
ret i32 %89
}

LLVM IR (-O2):
%struct.cli = type { i32 }
@.str = [25 x i8] c"> argc <= 0 is invalid\0A\0D\00"
@.str.1 = [15 x i8] c"argv[0] = %s\0A\0D\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [10 x i8] c"turn on\0A\0D\00"
@.str.4 = [4 x i8] c"off\00"
@.str.5 = [11 x i8] c"turn off\0A\0D\00"
@.str.6 = [6 x i8] c"fuzzy\00"
@.str.7 = [13 x i8] c"fuzzy mode\0A\0D\00"
define i32 @_set_alternative(%struct.cli* %0, i32 %1, i8** nocapture %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = icmp slt i32 %1, 1
br i1 %9, label %10, label %19
10: ; preds = %3
%11 = bitcast i8** %4 to i8*
%12 = call i32 (i8**, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* dereferenceable(1) %13)
%15 = add nsw i64 %14, 1
%16 = call i32 @cli_send(%struct.cli* %0, i8* %13, i64 %15)
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
br label %67
19: ; preds = %3
%20 = bitcast i8** %5 to i8*
%21 = load i8*, i8** %2
%22 = call i32 (i8**, i8*, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %5
%24 = call i64 @strlen(i8* dereferenceable(1) %23)
%25 = add nsw i64 %24, 1
%26 = call i32 @cli_send(%struct.cli* %0, i8* %23, i64 %25)
%27 = load i8*, i8** %5
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %2
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %19
%33 = bitcast i8** %6 to i8*
%34 = call i32 (i8**, i8*, ...) @asprintf(i8** %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%35 = load i8*, i8** %6
%36 = call i64 @strlen(i8* dereferenceable(1) %35)
%37 = add nsw i64 %36, 1
%38 = call i32 @cli_send(%struct.cli* %0, i8* %35, i64 %37)
%39 = load i8*, i8** %6
%40 = call i32 @free(i8* %39)
br label %67
41: ; preds = %19
%42 = load i8*, i8** %2
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = bitcast i8** %7 to i8*
%47 = call i32 (i8**, i8*, ...) @asprintf(i8** %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%48 = load i8*, i8** %7
%49 = call i64 @strlen(i8* dereferenceable(1) %48)
%50 = add nsw i64 %49, 1
%51 = call i32 @cli_send(%struct.cli* %0, i8* %48, i64 %50)
%52 = load i8*, i8** %7
%53 = call i32 @free(i8* %52)
br label %67
54: ; preds = %41
%55 = load i8*, i8** %2
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = bitcast i8** %8 to i8*
%60 = call i32 (i8**, i8*, ...) @asprintf(i8** %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%61 = load i8*, i8** %8
%62 = call i64 @strlen(i8* dereferenceable(1) %61)
%63 = add nsw i64 %62, 1
%64 = call i32 @cli_send(%struct.cli* %0, i8* %61, i64 %63)
%65 = load i8*, i8** %8
%66 = call i32 @free(i8* %65)
br label %67
67: ; preds = %32, %54, %58, %45, %10
%68 = phi i32 [ -1, %10 ], [ 0, %45 ], [ 0, %58 ], [ 0, %54 ], [ 0, %32 ]
ret i32 %68
}