#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*/ atoi(int);
scalar_t__ strcasecmp(int, char const *);
int mc_bool_value(const char *value) {
  static struct boolean_type_t {
    const char *name;
    int value;
  } _boolean_type[] = {{"true", 1},    {"false", 0},  {"ok", 1},  {"error", 0},
                       {"success", 1}, {"failed", 0}, {"yes", 1}, {"no", 0},
                       {"null", 0},    {"none", 0},   {"nil", 0}, {NULL, 0}};
  int idx = 0;
  if (!value) {
    return 0;
  }
  while (_boolean_type[idx].name) {
    if (0 == strcasecmp(value, _boolean_type[idx].name)) {
      return _boolean_type[idx].value;
    }
    idx += 1;
  }
  return !!atoi(value);
}


x86 assembly (clang, -O0):
<mc_bool_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <mc_bool_value+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11e1 <mc_bool_value+0xc1>
jmp    114f <mc_bool_value+0x2f>
movslq -0x14(%rbp),%rcx
lea    0x2ee6(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     11c4 <mc_bool_value+0xa4>
mov    -0x10(%rbp),%rax
mov    %eax,%edi
movslq -0x14(%rbp),%rcx
lea    0x2ec4(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11b6 <mc_bool_value+0x96>
movslq -0x14(%rbp),%rcx
lea    0x2e9c(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e1 <mc_bool_value+0xc1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <mc_bool_value+0x2f>
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1040 <atoi@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mc_bool_value>:
push   %rbx
test   %rdi,%rdi
je     122a <mc_bool_value+0x10a>
mov    %rdi,%rbx
lea    0xecc(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     122e <mc_bool_value+0x10e>
lea    0xebc(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1232 <mc_bool_value+0x112>
lea    0xeab(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1239 <mc_bool_value+0x119>
lea    0xe97(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1240 <mc_bool_value+0x120>
lea    0xe86(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1247 <mc_bool_value+0x127>
lea    0xe77(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     124e <mc_bool_value+0x12e>
lea    0xe67(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1255 <mc_bool_value+0x135>
lea    0xe54(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     125c <mc_bool_value+0x13c>
lea    0xe44(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1263 <mc_bool_value+0x143>
lea    0xe36(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     126a <mc_bool_value+0x14a>
lea    0xe28(%rip),%rsi
mov    %ebx,%edi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1271 <mc_bool_value+0x151>
mov    %ebx,%edi
call   1040 <atoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x1,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x2,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x3,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x4,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x5,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x6,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x7,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x8,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0x9,%eax
jmp    1276 <mc_bool_value+0x156>
mov    $0xa,%eax
shl    $0x4,%rax
lea    0x2adf(%rip),%rcx
mov    0x8(%rax,%rcx,1),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.boolean_type_t = type { i8*, i32 }
@mc_bool_value._boolean_type = internal global [12 x %struct.boolean_type_t] [%struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i32 0 }, %struct.boolean_type_t zeroinitializer]
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
@.str.2 = [3 x i8] c"ok\00"
@.str.3 = [6 x i8] c"error\00"
@.str.4 = [8 x i8] c"success\00"
@.str.5 = [7 x i8] c"failed\00"
@.str.6 = [4 x i8] c"yes\00"
@.str.7 = [3 x i8] c"no\00"
@.str.8 = [5 x i8] c"null\00"
@.str.9 = [5 x i8] c"none\00"
@.str.10 = [4 x i8] c"nil\00"
define i32 @mc_bool_value(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %43
8: ; preds = %1
br label %9
9: ; preds = %32, %8
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [12 x %struct.boolean_type_t], [12 x %struct.boolean_type_t]* @mc_bool_value._boolean_type, i64 0, i64 %11
%13 = getelementptr inbounds %struct.boolean_type_t, %struct.boolean_type_t* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %35
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = ptrtoint i8* %17 to i32
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [12 x %struct.boolean_type_t], [12 x %struct.boolean_type_t]* @mc_bool_value._boolean_type, i64 0, i64 %20
%22 = getelementptr inbounds %struct.boolean_type_t, %struct.boolean_type_t* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i64 @strcasecmp(i32 %18, i8* %23)
%25 = icmp eq i64 0, %24
br i1 %25, label %26, label %32
26: ; preds = %16
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [12 x %struct.boolean_type_t], [12 x %struct.boolean_type_t]* @mc_bool_value._boolean_type, i64 0, i64 %28
%30 = getelementptr inbounds %struct.boolean_type_t, %struct.boolean_type_t* %29, i32 0, i32 1
%31 = load i32, i32* %30
store i32 %31, i32* %2
br label %43
32: ; preds = %16
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %9
35: ; preds = %9
%36 = load i8*, i8** %3
%37 = ptrtoint i8* %36 to i32
%38 = call i32 @atoi(i32 %37)
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
%41 = xor i1 %40, true
%42 = zext i1 %41 to i32
store i32 %42, i32* %2
br label %43
43: ; preds = %35, %26, %7
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
%struct.boolean_type_t = type { i8*, i32 }
@mc_bool_value._boolean_type = internal unnamed_addr constant [12 x %struct.boolean_type_t] [%struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i32 1 }, %struct.boolean_type_t { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i32 0 }, %struct.boolean_type_t { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0), i32 0 }, %struct.boolean_type_t zeroinitializer]
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
@.str.2 = [3 x i8] c"ok\00"
@.str.3 = [6 x i8] c"error\00"
@.str.4 = [8 x i8] c"success\00"
@.str.5 = [7 x i8] c"failed\00"
@.str.6 = [4 x i8] c"yes\00"
@.str.7 = [3 x i8] c"no\00"
@.str.8 = [5 x i8] c"null\00"
@.str.9 = [5 x i8] c"none\00"
@.str.10 = [4 x i8] c"nil\00"
define i32 @mc_bool_value(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %46, label %3
3: ; preds = %1
%4 = ptrtoint i8* %0 to i64
%5 = trunc i64 %4 to i32
%6 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %3
%9 = phi i64 [ 0, %3 ], [ 1, %12 ], [ 2, %15 ], [ 3, %18 ], [ 4, %21 ], [ 5, %24 ], [ 6, %27 ], [ 7, %30 ], [ 8, %33 ], [ 9, %36 ], [ 10, %39 ]
%10 = getelementptr inbounds [12 x %struct.boolean_type_t], [12 x %struct.boolean_type_t]* @mc_bool_value._boolean_type, i64 0, i64 %9, i32 1
%11 = load i32, i32* %10
br label %46
12: ; preds = %3
%13 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %8, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %8, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %8, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %8, label %24
24: ; preds = %21
%25 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %8, label %27
27: ; preds = %24
%28 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %8, label %30
30: ; preds = %27
%31 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %8, label %33
33: ; preds = %30
%34 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %8, label %36
36: ; preds = %33
%37 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %8, label %39
39: ; preds = %36
%40 = tail call i64 @strcasecmp(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %8, label %42
42: ; preds = %39
%43 = tail call i32 @atoi(i32 %5)
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i32
br label %46
46: ; preds = %1, %42, %8
%47 = phi i32 [ %11, %8 ], [ %45, %42 ], [ 0, %1 ]
ret i32 %47
}