#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 */
char *GetConfigValue(char const *, char const *, char *);
scalar_t__ atoi(char const *);
scalar_t__ strcasecmp(char const *, char *);
int GetConfigValueBool(const char *blockName, const char *keyName, int def) {
  const char *val = GetConfigValue(blockName, keyName, "");
  if (!val[0])
    return !!def;
  return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 ||
          strcasecmp(val, "on") == 0 || atoi(val) != 0);
}


x86 assembly (clang, -O0):
<GetConfigValueBool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xeb2(%rip),%rdx
call   1050 <GetConfigValue@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1180 <GetConfigValueBool+0x50>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1204 <GetConfigValueBool+0xd4>
mov    -0x28(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     11f9 <GetConfigValueBool+0xc9>
mov    -0x28(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     11f9 <GetConfigValueBool+0xc9>
mov    -0x28(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     11f9 <GetConfigValueBool+0xc9>
mov    -0x28(%rbp),%rdi
call   1040 <atoi@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetConfigValueBool>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
lea    0xec8(%rip),%rdx
call   1050 <GetConfigValue@plt>
cmpb   $0x0,(%rax)
je     1195 <GetConfigValueBool+0x65>
mov    %rax,%rbx
lea    0xeb0(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%bpl
test   %rax,%rax
je     119b <GetConfigValueBool+0x6b>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     119b <GetConfigValueBool+0x6b>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     119b <GetConfigValueBool+0x6b>
mov    %rbx,%rdi
call   1040 <atoi@plt>
test   %rax,%rax
jmp    1197 <GetConfigValueBool+0x67>
test   %ebp,%ebp
setne  %bpl
movzbl %bpl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"on\00"
define i32 @GetConfigValueBool(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = call i8* @GetConfigValue(i8* %9, i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %3
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
store i32 %21, i32* %4
br label %41
22: ; preds = %3
%23 = load i8*, i8** %8
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = call i64 @strcasecmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %26
%31 = load i8*, i8** %8
%32 = call i64 @strcasecmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %8
%36 = call i64 @atoi(i8* %35)
%37 = icmp ne i64 %36, 0
br label %38
38: ; preds = %34, %30, %26, %22
%39 = phi i1 [ true, %30 ], [ true, %26 ], [ true, %22 ], [ %37, %34 ]
%40 = zext i1 %39 to i32
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %16
%42 = load i32, i32* %4
ret i32 %42
}

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