#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 parse_int(char const *, int);
scalar_t__ streq(char const *, char *);
bool parse_bool(const char *value, bool default_value) {
  if (!value)
    return default_value;
  if (streq(value, "true") || streq(value, "on") || streq(value, "yes"))
    return true;
  if (streq(value, "false") || streq(value, "off") || streq(value, "no"))
    return false;
  return parse_int(value, default_value);
}


x86 assembly (clang, -O0):
<parse_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1145 <parse_bool+0x25>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1208 <parse_bool+0xe8>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
jne    1193 <parse_bool+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
jne    1193 <parse_bool+0x73>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
je     119f <parse_bool+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    1208 <parse_bool+0xe8>
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
jne    11ed <parse_bool+0xcd>
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
jne    11ed <parse_bool+0xcd>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <streq@plt>
cmp    $0x0,%rax
je     11f9 <parse_bool+0xd9>
movl   $0x0,-0x4(%rbp)
jmp    1208 <parse_bool+0xe8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <parse_int@plt>
mov    %eax,-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    %esi,%r14d
test   %rdi,%rdi
je     11be <parse_bool+0x9e>
mov    %rdi,%rbx
lea    0xec6(%rip),%rsi
call   1030 <streq@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <streq@plt>
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <streq@plt>
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1030 <streq@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <streq@plt>
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1030 <streq@plt>
test   %rax,%rax
jne    11c1 <parse_bool+0xa1>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <parse_int@plt>
mov    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.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 @parse_bool(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = load i32, i32* %5
store i32 %9, i32* %3
br label %40
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @streq(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i64 @streq(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = call i64 @streq(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %14, %10
store i32 1, i32* %3
br label %40
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call i64 @streq(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i64 @streq(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = call i64 @streq(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31, %27, %23
store i32 0, i32* %3
br label %40
36: ; preds = %31
%37 = load i8*, i8** %4
%38 = load i32, i32* %5
%39 = call i32 @parse_int(i8* %37, i32 %38)
store i32 %39, i32* %3
br label %40
40: ; preds = %36, %35, %22, %8
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.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 @parse_bool(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %24, label %4
4: ; preds = %2
%5 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = tail call i64 @streq(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @parse_int(i8* %0, i32 %1)
br label %24
24: ; preds = %13, %16, %19, %4, %7, %10, %2, %22
%25 = phi i32 [ %23, %22 ], [ %1, %2 ], [ 1, %10 ], [ 1, %7 ], [ 1, %4 ], [ 0, %19 ], [ 0, %16 ], [ 0, %13 ]
ret i32 %25
}