#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 config_file {
  int dummy;
};

/* Variables and functions */
char *config_get(struct config_file *, char const *, char const *,
                 int /*<<< orphan*/ *);
scalar_t__ strcasecmp(char const *, char *);
int /*<<< orphan*/ string_to_int(char const *, int *);
int config_get_bool(struct config_file *f, const char *section,
                    const char *item, int _default) {
  const char *value;
  int i;
  value = config_get(f, section, item, NULL);
  if (!value)
    return _default;
  if (!string_to_int(value, &i))
    return !!i;
  if (strcasecmp(value, "yes") == 0 || strcasecmp(value, "true") == 0 ||
      strcasecmp(value, "on") == 0)
    return 1;
  if (strcasecmp(value, "no") == 0 || strcasecmp(value, "false") == 0 ||
      strcasecmp(value, "off") == 0)
    return 0;
  return _default;
}


x86 assembly (clang, -O0):
<config_get_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <config_get@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1176 <config_get_bool+0x46>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125e <config_get_bool+0x12e>
mov    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
call   1050 <string_to_int@plt>
cmp    $0x0,%eax
jne    11a4 <config_get_bool+0x74>
cmpl   $0x0,-0x34(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    125e <config_get_bool+0x12e>
mov    -0x30(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <config_get_bool+0xc2>
mov    -0x30(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11f2 <config_get_bool+0xc2>
mov    -0x30(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11fe <config_get_bool+0xce>
movl   $0x1,-0x4(%rbp)
jmp    125e <config_get_bool+0x12e>
mov    -0x30(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     124c <config_get_bool+0x11c>
mov    -0x30(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     124c <config_get_bool+0x11c>
mov    -0x30(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1258 <config_get_bool+0x128>
movl   $0x0,-0x4(%rbp)
jmp    125e <config_get_bool+0x12e>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_get_bool>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
xor    %ecx,%ecx
call   1040 <config_get@plt>
test   %rax,%rax
je     11e6 <config_get_bool+0xb6>
mov    %rax,%rbx
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   1050 <string_to_int@plt>
test   %eax,%eax
je     11eb <config_get_bool+0xbb>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11f6 <config_get_bool+0xc6>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f6 <config_get_bool+0xc6>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f6 <config_get_bool+0xc6>
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11f6 <config_get_bool+0xc6>
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f6 <config_get_bool+0xc6>
lea    0xe40(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmove  %ecx,%r14d
mov    %r14d,%ebp
jmp    11f6 <config_get_bool+0xc6>
xor    %ebp,%ebp
cmpl   $0x0,0xc(%rsp)
setne  %bpl
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.config_file = type { i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"false\00"
@.str.5 = [4 x i8] c"off\00"
define i32 @config_get_bool(%struct.config_file* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.config_file*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store %struct.config_file* %0, %struct.config_file** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load %struct.config_file*, %struct.config_file** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = call i8* @config_get(%struct.config_file* %12, i8* %13, i8* %14, i32* null)
store i8* %15, i8** %10
%16 = load i8*, i8** %10
%17 = icmp ne i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %4
%19 = load i32, i32* %9
store i32 %19, i32* %5
br label %58
20: ; preds = %4
%21 = load i8*, i8** %10
%22 = call i32 @string_to_int(i8* %21, i32* %11)
%23 = icmp ne i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %20
%25 = load i32, i32* %11
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
%28 = xor i1 %27, true
%29 = zext i1 %28 to i32
store i32 %29, i32* %5
br label %58
30: ; preds = %20
%31 = load i8*, i8** %10
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %42, label %34
34: ; preds = %30
%35 = load i8*, i8** %10
%36 = call i64 @strcasecmp(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %10
%40 = call i64 @strcasecmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38, %34, %30
store i32 1, i32* %5
br label %58
43: ; preds = %38
%44 = load i8*, i8** %10
%45 = call i64 @strcasecmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %55, label %47
47: ; preds = %43
%48 = load i8*, i8** %10
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %55, label %51
51: ; preds = %47
%52 = load i8*, i8** %10
%53 = call i64 @strcasecmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %51, %47, %43
store i32 0, i32* %5
br label %58
56: ; preds = %51
%57 = load i32, i32* %9
store i32 %57, i32* %5
br label %58
58: ; preds = %56, %55, %42, %24, %18
%59 = load i32, i32* %5
ret i32 %59
}

LLVM IR (-O2):
%struct.config_file = type { i32 }
@.str = [4 x i8] c"yes\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"false\00"
@.str.5 = [4 x i8] c"off\00"
define i32 @config_get_bool(%struct.config_file* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i8* @config_get(%struct.config_file* %0, i8* %1, i8* %2, i32* null)
%8 = icmp eq i8* %7, null
br i1 %8, label %35, label %9
9: ; preds = %4
%10 = call i32 @string_to_int(i8* %7, i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
br label %35
16: ; preds = %9
%17 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %16
%20 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %35, label %22
22: ; preds = %19
%23 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %22
%26 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %25
%29 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i32 0, i32 %3
br label %35
35: ; preds = %31, %25, %28, %16, %19, %22, %4, %12
%36 = phi i32 [ %15, %12 ], [ %3, %4 ], [ 1, %22 ], [ 1, %19 ], [ 1, %16 ], [ 0, %28 ], [ 0, %25 ], [ %34, %31 ]
ret i32 %36
}