#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
scalar_t__ i8086ReadStrConfig(char *, char const *, char const *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char toupper(char);
int i8086ReadBoolConfig(const char *filename, const char *name, int defValue) {
  char *str;
  int len, ret = defValue;
  str = (char *)calloc(256, sizeof(char));
  if (i8086ReadStrConfig(str, filename, name) != 0) {
    len = strlen(str);
    {
      int i = 0;
      while (str[i] != '\0') {
        str[i] = toupper(str[i]);
        i++;
      }
    };
    if (len == 1) {
      if ((str[0] == '0') || (str[0] == 'N'))
        ret = 0;
      else
        ret = 1;
    } else {
      if (strcmp(str, "NO") == 0)
        ret = 0;
      else
        ret = 1;
    }
  }
  free(str);
  return ret;
}


x86 assembly (clang, -O0):
<i8086ReadBoolConfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <i8086ReadStrConfig@plt>
cmp    $0x0,%rax
je     1274 <i8086ReadBoolConfig+0x114>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11fb <i8086ReadBoolConfig+0x9b>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ba <i8086ReadBoolConfig+0x5a>
cmpl   $0x1,-0x24(%rbp)
jne    123d <i8086ReadBoolConfig+0xdd>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     1225 <i8086ReadBoolConfig+0xc5>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
jne    1231 <i8086ReadBoolConfig+0xd1>
movl   $0x0,-0x28(%rbp)
jmp    1238 <i8086ReadBoolConfig+0xd8>
movl   $0x1,-0x28(%rbp)
jmp    126f <i8086ReadBoolConfig+0x10f>
mov    -0x20(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1263 <i8086ReadBoolConfig+0x103>
movl   $0x0,-0x28(%rbp)
jmp    126a <i8086ReadBoolConfig+0x10a>
movl   $0x1,-0x28(%rbp)
jmp    126f <i8086ReadBoolConfig+0x10f>
jmp    1274 <i8086ReadBoolConfig+0x114>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i8086ReadBoolConfig>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x100,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <i8086ReadStrConfig@plt>
test   %rax,%rax
je     11f7 <i8086ReadBoolConfig+0x97>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    (%r15),%al
test   %al,%al
je     11c6 <i8086ReadBoolConfig+0x66>
mov    %r15,%rbx
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11b0 <i8086ReadBoolConfig+0x50>
cmp    $0x1,%ebp
jne    11df <i8086ReadBoolConfig+0x7f>
mov    (%r15),%al
cmp    $0x30,%al
setne  %cl
cmp    $0x4e,%al
setne  %al
and    %cl,%al
movzbl %al,%ebp
jmp    11f7 <i8086ReadBoolConfig+0x97>
lea    0xe1a(%rip),%rsi
mov    %r15,%rdi
call   1080 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"NO\00"
define i32 @i8086ReadBoolConfig(i8* %0, i8* %1, i32 %2) {
%4 = tail call i64 @calloc(i32 256, i32 1)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i64 @i8086ReadStrConfig(i8* %5, i8* %0, i8* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %3
%9 = tail call i32 @strlen(i8* %5)
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %8, %12
%13 = phi i64 [ %17, %12 ], [ 0, %8 ]
%14 = phi i8 [ %19, %12 ], [ %10, %8 ]
%15 = phi i8* [ %18, %12 ], [ %5, %8 ]
%16 = tail call signext i8 @toupper(i8 signext %14)
store i8 %16, i8* %15
%17 = add nuw i64 %13, 1
%18 = getelementptr inbounds i8, i8* %5, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %12
21: ; preds = %12, %8
%22 = icmp eq i32 %9, 1
br i1 %22, label %23, label %29
23: ; preds = %21
%24 = load i8, i8* %5
%25 = icmp ne i8 %24, 48
%26 = icmp ne i8 %24, 78
%27 = and i1 %25, %26
%28 = zext i1 %27 to i32
br label %33
29: ; preds = %21
%30 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %23, %29, %3
%34 = phi i32 [ %2, %3 ], [ %32, %29 ], [ %28, %23 ]
%35 = tail call i32 @free(i8* %5)
ret i32 %34
}