#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 */
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char const *, char *);
bool bc_str_to_bool(const char *str) {
  if (str == NULL)
    return false;
  if (0 == strcmp(str, "1"))
    return true;
  if (0 == strcasecmp(str, "y"))
    return true;
  if (0 == strcasecmp(str, "yes"))
    return true;
  if (0 == strcasecmp(str, "true"))
    return true;
  if (0 == strcasecmp(str, "on"))
    return true;
  return false;
}


x86 assembly (clang, -O0):
<bc_str_to_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <bc_str_to_bool+0x23>
movl   $0x0,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    116d <bc_str_to_bool+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
mov    -0x10(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1197 <bc_str_to_bool+0x77>
movl   $0x1,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c1 <bc_str_to_bool+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11eb <bc_str_to_bool+0xcb>
movl   $0x1,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
mov    -0x10(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1215 <bc_str_to_bool+0xf5>
movl   $0x1,-0x4(%rbp)
jmp    121c <bc_str_to_bool+0xfc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bc_str_to_bool>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1197 <bc_str_to_bool+0x77>
mov    %rdi,%rbx
lea    0xece(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1199 <bc_str_to_bool+0x79>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1199 <bc_str_to_bool+0x79>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1199 <bc_str_to_bool+0x79>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1199 <bc_str_to_bool+0x79>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    1199 <bc_str_to_bool+0x79>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [3 x i8] c"on\00"
define i32 @bc_str_to_bool(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 0, i32* %2
br label %33
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 0, %9
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 1, i32* %2
br label %33
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 0, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 1, i32* %2
br label %33
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 0, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 1, i32* %2
br label %33
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 0, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %2
br label %33
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i64 @strcasecmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 0, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %2
br label %33
32: ; preds = %27
store i32 0, i32* %2
br label %33
33: ; preds = %32, %31, %26, %21, %16, %11, %6
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [5 x i8] c"true\00"
@.str.4 = [3 x i8] c"on\00"
define i32 @bc_str_to_bool(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %6
%10 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %9, %6, %3, %1
%20 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 1, %6 ], [ 1, %9 ], [ 1, %12 ], [ %18, %15 ]
ret i32 %20
}