#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*/ strcasecmp(char *, char *);
int /*<<< orphan*/ ui_cmd_gettok_str(char *, char **, char **);
int ui_cmd_gettok_bool(char *input, char **token, char **remainder) {
  ui_cmd_gettok_str(input, token, remainder);
  if (!*token) {
    return -1;
  } else if (!strcasecmp(*token, "on")) {
    return 1;
  } else if (!strcasecmp(*token, "off")) {
    return 0;
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<ui_cmd_gettok_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ui_cmd_gettok_str@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    115f <ui_cmd_gettok_bool+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <ui_cmd_gettok_bool+0x96>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1187 <ui_cmd_gettok_bool+0x67>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <ui_cmd_gettok_bool+0x96>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11af <ui_cmd_gettok_bool+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <ui_cmd_gettok_bool+0x96>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_cmd_gettok_bool>:
push   %rbx
mov    %rsi,%rbx
call   1040 <ui_cmd_gettok_str@plt>
mov    (%rbx),%rbx
test   %rbx,%rbx
je     1159 <ui_cmd_gettok_bool+0x39>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1160 <ui_cmd_gettok_bool+0x40>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %eax
sbb    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @ui_cmd_gettok_bool(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%8 = load i8*, i8** %5
%9 = load i8**, i8*** %6
%10 = load i8**, i8*** %7
%11 = call i32 @ui_cmd_gettok_str(i8* %8, i8** %9, i8** %10)
%12 = load i8**, i8*** %6
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i32 -1, i32* %4
br label %29
16: ; preds = %3
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = call i32 @strcasecmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16
store i32 1, i32* %4
br label %29
22: ; preds = %16
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = call i32 @strcasecmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %22
store i32 0, i32* %4
br label %29
28: ; preds = %22
store i32 -1, i32* %4
br label %29
29: ; preds = %28, %27, %21, %15
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @ui_cmd_gettok_bool(i8* %0, i8** %1, i8** %2) {
%4 = tail call i32 @ui_cmd_gettok_str(i8* %0, i8** %1, i8** %2)
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = tail call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
%13 = sext i1 %12 to i32
br label %14
14: ; preds = %10, %7, %3
%15 = phi i32 [ -1, %3 ], [ 1, %7 ], [ %13, %10 ]
ret i32 %15
}