#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 EINVAL;
int /*<<< orphan*/ assert(char const *);
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char const *, char *);
int parse_boolean(const char *v) {
  assert(v);
  if ((strcmp((v), ("1")) == 0) || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' ||
      v[0] == 'T' || (strcasecmp((v), ("on")) == 0))
    return 1;
  else if ((strcmp((v), ("0")) == 0) || v[0] == 'n' || v[0] == 'N' ||
           v[0] == 'f' || v[0] == 'F' || (strcasecmp((v), ("off")) == 0))
    return 0;
  return -EINVAL;
}


x86 assembly (clang, -O0):
<parse_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b9 <parse_boolean+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
je     11b9 <parse_boolean+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
je     11b9 <parse_boolean+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x74,%eax
je     11b9 <parse_boolean+0x89>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x54,%eax
je     11b9 <parse_boolean+0x89>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c5 <parse_boolean+0x95>
movl   $0x1,-0x4(%rbp)
jmp    1258 <parse_boolean+0x128>
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1239 <parse_boolean+0x109>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
je     1239 <parse_boolean+0x109>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
je     1239 <parse_boolean+0x109>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x66,%eax
je     1239 <parse_boolean+0x109>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x46,%eax
je     1239 <parse_boolean+0x109>
mov    -0x10(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1245 <parse_boolean+0x115>
movl   $0x0,-0x4(%rbp)
jmp    1258 <parse_boolean+0x128>
jmp    124a <parse_boolean+0x11a>
xor    %eax,%eax
mov    0x2d8d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_boolean>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <assert@plt>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     116f <parse_boolean+0x3f>
mov    (%rbx),%al
add    $0xac,%al
cmp    $0x25,%al
ja     1178 <parse_boolean+0x48>
movzbl %al,%eax
movabs $0x2100000021,%rcx
bt     %rax,%rcx
jae    1178 <parse_boolean+0x48>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     116f <parse_boolean+0x3f>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     116f <parse_boolean+0x3f>
mov    (%rbx),%al
add    $0xba,%al
rol    $0x5,%al
cmp    $0x6,%al
jae    11ba <parse_boolean+0x8a>
movzbl %al,%eax
mov    $0x33,%ecx
bt     %eax,%ecx
jb     116f <parse_boolean+0x3f>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     116f <parse_boolean+0x3f>
mov    0x2e0b(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    116f <parse_boolean+0x3f>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [4 x i8] c"off\00"
@EINVAL = global i32 0
define i32 @parse_boolean(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %37, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 121
br i1 %14, label %37, label %15
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 89
br i1 %20, label %37, label %21
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 116
br i1 %26, label %37, label %27
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 84
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i64 @strcasecmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33, %27, %21, %15, %9, %1
store i32 1, i32* %2
br label %75
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %70, label %42
42: ; preds = %38
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 110
br i1 %47, label %70, label %48
48: ; preds = %42
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 78
br i1 %53, label %70, label %54
54: ; preds = %48
%55 = load i8*, i8** %3
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 102
br i1 %59, label %70, label %60
60: ; preds = %54
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 0
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 70
br i1 %65, label %70, label %66
66: ; preds = %60
%67 = load i8*, i8** %3
%68 = call i64 @strcasecmp(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %66, %60, %54, %48, %42, %38
store i32 0, i32* %2
br label %75
71: ; preds = %66
br label %72
72: ; preds = %71
%73 = load i32, i32* @EINVAL
%74 = sub nsw i32 0, %73
store i32 %74, i32* %2
br label %75
75: ; preds = %72, %70, %37
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [4 x i8] c"off\00"
@EINVAL = global i32 0
define i32 @parse_boolean(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %1
%6 = load i8, i8* %0
switch i8 %6, label %7 [
i8 121, label %28
i8 89, label %28
i8 116, label %28
i8 84, label %28
]
7: ; preds = %5
%8 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %28, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %28, label %13
13: ; preds = %10
%14 = load i8, i8* %0
%15 = add i8 %14, -70
%16 = tail call i8 @llvm.fshl.i8(i8 %15, i8 %15, i8 5)
%17 = icmp ult i8 %16, 6
br i1 %17, label %24, label %18
18: ; preds = %24, %13
%19 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = load i32, i32* @EINVAL
%23 = sub nsw i32 0, %22
br label %28
24: ; preds = %13
%25 = lshr i8 51, %16
%26 = and i8 %25, 1
%27 = icmp eq i8 %26, 0
br i1 %27, label %18, label %28
28: ; preds = %24, %10, %18, %1, %7, %5, %5, %5, %5, %21
%29 = phi i32 [ %23, %21 ], [ 1, %5 ], [ 1, %5 ], [ 1, %5 ], [ 1, %5 ], [ 1, %7 ], [ 1, %1 ], [ 0, %18 ], [ 0, %10 ], [ 0, %24 ]
ret i32 %29
}