#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 StrToBoolean(char *str) {
  if (str == NULL)
    return -1;
  if (!strcasecmp(str, "1") || !strcasecmp(str, "TRUE") ||
      !strcasecmp(str, "YES"))
    return 1;
  if (!strcasecmp(str, "0") || !strcasecmp(str, "FALSE") ||
      !strcasecmp(str, "NO"))
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<StrToBoolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <StrToBoolean+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e8 <StrToBoolean+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     117e <StrToBoolean+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     117e <StrToBoolean+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    118a <StrToBoolean+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11e8 <StrToBoolean+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11d5 <StrToBoolean+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     11d5 <StrToBoolean+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11e1 <StrToBoolean+0xd1>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <StrToBoolean+0xd8>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StrToBoolean>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1193 <StrToBoolean+0x83>
mov    %rdi,%rbx
lea    0xede(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     1198 <StrToBoolean+0x88>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1198 <StrToBoolean+0x88>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1198 <StrToBoolean+0x88>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1198 <StrToBoolean+0x88>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1198 <StrToBoolean+0x88>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %eax
sbb    %ebp,%ebp
jmp    1198 <StrToBoolean+0x88>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [5 x i8] c"TRUE\00"
@.str.2 = [4 x i8] c"YES\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [6 x i8] c"FALSE\00"
@.str.5 = [3 x i8] c"NO\00"
define i32 @StrToBoolean(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %6
%10 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
%21 = sext i1 %20 to i32
br label %22
22: ; preds = %18, %12, %15, %3, %6, %9, %1
%23 = phi i32 [ -1, %1 ], [ 1, %9 ], [ 1, %6 ], [ 1, %3 ], [ 0, %15 ], [ 0, %12 ], [ %21, %18 ]
ret i32 %23
}