#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 */
struct string {
  int dummy;
};

/* Variables and functions */
scalar_t__ caseless_eq(struct string const *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           unsigned int);
int /*<<< orphan*/ print_str(int /*<<< orphan*/, struct string const *);
int /*<<< orphan*/ stderr;
int str_to_bool(const struct string *s, const char *filename,
                unsigned int lineno) {
  if (caseless_eq(s, "yes", 3) || caseless_eq(s, "true", 4) ||
      caseless_eq(s, "1", 1))
    return 1;
  else if (caseless_eq(s, "no", 2) || caseless_eq(s, "false", 5) ||
           caseless_eq(s, "0", 1))
    return 0;
  fprintf(stderr, "%s:%u: not a boolean value: ", filename, lineno);
  print_str(stderr, s);
  return -1;
}


x86 assembly (clang, -O0):
<str_to_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x3,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
jne    11a0 <str_to_bool+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x4,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
jne    11a0 <str_to_bool+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x1,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
je     11ac <str_to_bool+0x7c>
movl   $0x1,-0x4(%rbp)
jmp    124f <str_to_bool+0x11f>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x2,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
jne    1209 <str_to_bool+0xd9>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
mov    $0x5,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
jne    1209 <str_to_bool+0xd9>
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x1,%edx
call   1050 <caseless_eq@plt>
cmp    $0x0,%rax
je     1215 <str_to_bool+0xe5>
movl   $0x0,-0x4(%rbp)
jmp    124f <str_to_bool+0x11f>
jmp    121a <str_to_bool+0xea>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xde5(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1030 <print_str@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_to_bool>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
mov    $0x3,%edx
call   1050 <caseless_eq@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <caseless_eq@plt>
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
lea    0xe86(%rip),%rsi
mov    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <caseless_eq@plt>
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1050 <caseless_eq@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <caseless_eq@plt>
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <caseless_eq@plt>
test   %rax,%rax
jne    1213 <str_to_bool+0xe3>
mov    0x2df2(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe1e(%rip),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
call   1030 <print_str@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.string = type { i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"false\00"
@.str.5 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"%s:%u: not a boolean value: \00"
define i32 @str_to_bool(%struct.string* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.string*
%6 = alloca i8*
%7 = alloca i32
store %struct.string* %0, %struct.string** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load %struct.string*, %struct.string** %5
%9 = call i64 @caseless_eq(%struct.string* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%10 = icmp ne i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %3
%12 = load %struct.string*, %struct.string** %5
%13 = call i64 @caseless_eq(%struct.string* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%14 = icmp ne i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load %struct.string*, %struct.string** %5
%17 = call i64 @caseless_eq(%struct.string* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %11, %3
store i32 1, i32* %4
br label %42
20: ; preds = %15
%21 = load %struct.string*, %struct.string** %5
%22 = call i64 @caseless_eq(%struct.string* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%23 = icmp ne i64 %22, 0
br i1 %23, label %32, label %24
24: ; preds = %20
%25 = load %struct.string*, %struct.string** %5
%26 = call i64 @caseless_eq(%struct.string* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%27 = icmp ne i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load %struct.string*, %struct.string** %5
%30 = call i64 @caseless_eq(%struct.string* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28, %24, %20
store i32 0, i32* %4
br label %42
33: ; preds = %28
br label %34
34: ; preds = %33
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %6
%37 = load i32, i32* %7
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %36, i32 %37)
%39 = load i32, i32* @stderr
%40 = load %struct.string*, %struct.string** %5
%41 = call i32 @print_str(i32 %39, %struct.string* %40)
store i32 -1, i32* %4
br label %42
42: ; preds = %34, %32, %19
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
%struct.string = type { i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"false\00"
@.str.5 = [2 x i8] c"0\00"
@stderr = global i32 0
@.str.6 = [29 x i8] c"%s:%u: not a boolean value: \00"
define i32 @str_to_bool(%struct.string* %0, i8* %1, i32 %2) {
%4 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = tail call i64 @caseless_eq(%struct.string* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %1, i32 %2)
%24 = load i32, i32* @stderr
%25 = tail call i32 @print_str(i32 %24, %struct.string* %0)
br label %26
26: ; preds = %12, %15, %18, %3, %6, %9, %21
%27 = phi i32 [ -1, %21 ], [ 1, %9 ], [ 1, %6 ], [ 1, %3 ], [ 0, %18 ], [ 0, %15 ], [ 0, %12 ]
ret i32 %27
}