#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*/ prerror(char *, char const *);
scalar_t__ strcasecmp(char const *, char *);
scalar_t__ strcmp(char const *, char *);
int parse_bool(const char *str, const char *param) {
  if (strcmp(str, "1") == 0)
    return 1;
  if (strcmp(str, "0") == 0)
    return 0;
  if (strcasecmp(str, "true") == 0)
    return 1;
  if (strcasecmp(str, "false") == 0)
    return 0;
  if (strcasecmp(str, "yes") == 0)
    return 1;
  if (strcasecmp(str, "no") == 0)
    return 0;
  if (strcasecmp(str, "on") == 0)
    return 1;
  if (strcasecmp(str, "off") == 0)
    return 0;
  if (param) {
    prerror("%s boolean parsing error. Format: BOOL\n", param);
  }
  return -1;
}


x86 assembly (clang, -O0):
<parse_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1166 <parse_bool+0x36>
movl   $0x1,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118c <parse_bool+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11b2 <parse_bool+0x82>
movl   $0x1,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11d8 <parse_bool+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11fe <parse_bool+0xce>
movl   $0x1,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1224 <parse_bool+0xf4>
movl   $0x0,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    124a <parse_bool+0x11a>
movl   $0x1,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
mov    -0x10(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1270 <parse_bool+0x140>
movl   $0x0,-0x4(%rbp)
jmp    1292 <parse_bool+0x162>
cmpq   $0x0,-0x18(%rbp)
je     128b <parse_bool+0x15b>
mov    -0x18(%rbp),%rsi
lea    0xd97(%rip),%rdi
call   1050 <prerror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_bool>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rsi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     120a <parse_bool+0xda>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1208 <parse_bool+0xd8>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     120a <parse_bool+0xda>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1208 <parse_bool+0xd8>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     120a <parse_bool+0xda>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1208 <parse_bool+0xd8>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     120a <parse_bool+0xda>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x0,%ebp
test   %rax,%rax
je     120a <parse_bool+0xda>
mov    $0xffffffff,%ebp
test   %r14,%r14
je     120a <parse_bool+0xda>
lea    0xe1f(%rip),%rdi
mov    %r14,%rsi
call   1050 <prerror@plt>
jmp    120a <parse_bool+0xda>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [4 x i8] c"yes\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [3 x i8] c"on\00"
@.str.7 = [4 x i8] c"off\00"
@.str.8 = [40 x i8] c"%s boolean parsing error. Format: BOOL\0A\00"
define i32 @parse_bool(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%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 %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %52
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 0, i32* %3
br label %52
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @strcasecmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %3
br label %52
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcasecmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %3
br label %52
25: ; preds = %20
%26 = load i8*, i8** %4
%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 %29, label %30
29: ; preds = %25
store i32 1, i32* %3
br label %52
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 0, i32* %3
br label %52
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i64 @strcasecmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 1, i32* %3
br label %52
40: ; preds = %35
%41 = load i8*, i8** %4
%42 = call i64 @strcasecmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 0, i32* %3
br label %52
45: ; preds = %40
%46 = load i8*, i8** %5
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i8*, i8** %5
%50 = call i32 @prerror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %45
store i32 -1, i32* %3
br label %52
52: ; preds = %51, %44, %39, %34, %29, %24, %19, %14, %9
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [4 x i8] c"yes\00"
@.str.5 = [3 x i8] c"no\00"
@.str.6 = [3 x i8] c"on\00"
@.str.7 = [4 x i8] c"off\00"
@.str.8 = [40 x i8] c"%s boolean parsing error. Format: BOOL\0A\00"
define i32 @parse_bool(i8* %0, i8* %1) {
%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 %30, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %30, label %8
8: ; preds = %5
%9 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %30, label %11
11: ; preds = %8
%12 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %30, label %17
17: ; preds = %14
%18 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %17
%21 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = icmp eq i8* %1, null
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @prerror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %1)
br label %30
30: ; preds = %26, %28, %23, %20, %17, %14, %11, %8, %5, %2
%31 = phi i32 [ 1, %2 ], [ 0, %5 ], [ 1, %8 ], [ 0, %11 ], [ 1, %14 ], [ 0, %17 ], [ 1, %20 ], [ 0, %23 ], [ -1, %28 ], [ -1, %26 ]
ret i32 %31
}