#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 *readStringKey(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
char tolower(char);
bool readBoolKey(char *key, bool defaultValue, char *configFile) {
  int i;
  char *keyVal = readStringKey(key, "False", configFile);
  if (!keyVal)
    return false;
  for (i = 0; keyVal[i]; i++) {
    keyVal[i] = tolower(keyVal[i]);
  }
  if (!strcmp(keyVal, "true") || !strcmp(keyVal, "on") ||
      !strcmp(keyVal, "yes")) {
    return true;
  } else if (!strcmp(keyVal, "false") || !strcmp(keyVal, "off") ||
             !strcmp(keyVal, "no")) {
    return false;
  } else {
    return defaultValue;
  }
}


x86 assembly (clang, -O0):
<readBoolKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xeae(%rip),%rsi
call   1050 <readStringKey@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1172 <readBoolKey+0x42>
movl   $0x0,-0x4(%rbp)
jmp    126b <readBoolKey+0x13b>
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11b7 <readBoolKey+0x87>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1179 <readBoolKey+0x49>
mov    -0x30(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1202 <readBoolKey+0xd2>
mov    -0x30(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1202 <readBoolKey+0xd2>
mov    -0x30(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    120e <readBoolKey+0xde>
movl   $0x1,-0x4(%rbp)
jmp    126b <readBoolKey+0x13b>
mov    -0x30(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1259 <readBoolKey+0x129>
mov    -0x30(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     1259 <readBoolKey+0x129>
mov    -0x30(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1265 <readBoolKey+0x135>
movl   $0x0,-0x4(%rbp)
jmp    126b <readBoolKey+0x13b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readBoolKey>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
lea    0xec2(%rip),%rsi
call   1050 <readStringKey@plt>
test   %rax,%rax
je     11f9 <readBoolKey+0xc9>
mov    %rax,%rbp
mov    (%rax),%al
test   %al,%al
je     1176 <readBoolKey+0x46>
mov    %rbp,%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <readBoolKey+0x30>
lea    0xe89(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     11fb <readBoolKey+0xcb>
lea    0xe76(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11fb <readBoolKey+0xcb>
lea    0xe66(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11fb <readBoolKey+0xcb>
lea    0xe57(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11f9 <readBoolKey+0xc9>
lea    0xe4a(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    $0x0,%ebx
test   %eax,%eax
je     11fb <readBoolKey+0xcb>
lea    0xe36(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
cmove  %eax,%r14d
mov    %r14d,%ebx
jmp    11fb <readBoolKey+0xcb>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"False\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [6 x i8] c"false\00"
@.str.5 = [4 x i8] c"off\00"
@.str.6 = [3 x i8] c"no\00"
define i32 @readBoolKey(i8* %0, i32 %1, i8* %2) {
%4 = tail call i8* @readStringKey(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %37, label %6
6: ; preds = %3
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %14, %9 ], [ 0, %6 ]
%11 = phi i8 [ %16, %9 ], [ %7, %6 ]
%12 = phi i8* [ %15, %9 ], [ %4, %6 ]
%13 = tail call signext i8 @tolower(i8 signext %11)
store i8 %13, i8* %12
%14 = add nuw i64 %10, 1
%15 = getelementptr inbounds i8, i8* %4, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %6
%19 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %37, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %37, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %37, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i32 0, i32 %1
br label %37
37: ; preds = %33, %27, %30, %18, %21, %24, %3
%38 = phi i32 [ 0, %3 ], [ 1, %24 ], [ 1, %21 ], [ 1, %18 ], [ 0, %30 ], [ 0, %27 ], [ %36, %33 ]
ret i32 %38
}