#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*/ EINVAL;
int /*<<< orphan*/ errno;
scalar_t__ strcasecmp(char const *, char *);
int cfg_parse_boolean(const char *s) {
  if (!s) {
    errno = EINVAL;
    return -1;
  }
  if (strcasecmp(s, "true") == 0 || strcasecmp(s, "on") == 0 ||
      strcasecmp(s, "yes") == 0)
    return 1;
  if (strcasecmp(s, "false") == 0 || strcasecmp(s, "off") == 0 ||
      strcasecmp(s, "no") == 0)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<cfg_parse_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1145 <cfg_parse_boolean+0x35>
mov    0x2eaa(%rip),%rax
mov    (%rax),%ecx
mov    0x2ea9(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <cfg_parse_boolean+0xf0>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1193 <cfg_parse_boolean+0x83>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1193 <cfg_parse_boolean+0x83>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    119f <cfg_parse_boolean+0x8f>
movl   $0x1,-0x4(%rbp)
jmp    1200 <cfg_parse_boolean+0xf0>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11ed <cfg_parse_boolean+0xdd>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11ed <cfg_parse_boolean+0xdd>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f9 <cfg_parse_boolean+0xe9>
movl   $0x0,-0x4(%rbp)
jmp    1200 <cfg_parse_boolean+0xf0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_parse_boolean>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     119d <cfg_parse_boolean+0x8d>
mov    %rdi,%rbx
lea    0xeda(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11b4 <cfg_parse_boolean+0xa4>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b4 <cfg_parse_boolean+0xa4>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b4 <cfg_parse_boolean+0xa4>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11b4 <cfg_parse_boolean+0xa4>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b4 <cfg_parse_boolean+0xa4>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %rax
sbb    %ebp,%ebp
jmp    11b4 <cfg_parse_boolean+0xa4>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    0x2e33(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
@.str = [5 x i8] c"true\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [4 x i8] c"off\00"
@.str.5 = [3 x i8] c"no\00"
define i32 @cfg_parse_boolean(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @EINVAL
store i32 %4, i32* @errno
br label %24
5: ; preds = %1
%6 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %5
%9 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %8
%12 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %14
%18 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
%23 = sext i1 %22 to i32
br label %24
24: ; preds = %20, %14, %17, %5, %8, %11, %3
%25 = phi i32 [ -1, %3 ], [ 1, %11 ], [ 1, %8 ], [ 1, %5 ], [ 0, %17 ], [ 0, %14 ], [ %23, %20 ]
ret i32 %25
}