#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 */
typedef int /*<<< orphan*/ yes;

/* Variables and functions */
char *cfg_get_str(char *, char *, char *);
scalar_t__ strcasecmp(char *, char *);
int cfg_get_bool(char *dname, char *sname, char *ename, int def) {
  static char *yes[] = {"true", "yes", "on", "1"};
  char *val;
  int i;
  int retval = 0;
  val = cfg_get_str(dname, sname, ename);
  if (NULL == val)
    return def;
  for (i = 0; i < sizeof(yes) / sizeof(yes[0]); i++)
    if (0 == strcasecmp(val, yes[i]))
      retval = 1;
  return retval;
}


x86 assembly (clang, -O0):
<cfg_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)
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <cfg_get_str@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x30(%rbp),%rax
jne    116a <cfg_get_bool+0x4a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <cfg_get_bool+0xa5>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x4,%rax
jae    11bf <cfg_get_bool+0x9f>
mov    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rcx
lea    0x2eb2(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <cfg_get_bool+0x8c>
movl   $0x1,-0x38(%rbp)
jmp    11b1 <cfg_get_bool+0x91>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1171 <cfg_get_bool+0x51>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_get_bool>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
call   1040 <cfg_get_str@plt>
test   %rax,%rax
je     1197 <cfg_get_bool+0x77>
mov    %rax,%rbp
lea    0xec3(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
sete   %r14b
lea    0xeb2(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
sete   %bl
lea    0xea1(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
sete   %r15b
lea    0xe8e(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
sete   %al
or     %r15b,%al
or     %r14b,%bl
or     %al,%bl
movzbl %bl,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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