#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
char *qt_internal_get_env_str(char const *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char const *, char *);
scalar_t__ strtoul(char const *, char **, int /*<<< orphan*/);
unsigned char __attribute__((visibility("hidden")))
qt_internal_get_env_bool(const char *envariable, unsigned char dflt) {
  const char *str;
  unsigned char tmp = dflt;
  const char *dflt_str;
  if (dflt) {
    dflt_str = "yes";
  } else {
    dflt_str = "no";
  }
  str = qt_internal_get_env_str(envariable, dflt_str);
  if (str && *str) {
    char *errptr;
    tmp = (strtoul(str, &errptr, 0) != 0);
    if (*errptr != 0) {
      if (!strcasecmp(str, "yes") || !strcasecmp(str, "true")) {
        tmp = 1;
      } else if (!strcasecmp(str, "no") || !strcasecmp(str, "false")) {
        tmp = 0;
      } else {
        fprintf(stderr, "unparsable %s (%s)\n", envariable, str);
        tmp = dflt;
      }
    }
    do {
    } while (0);
  }
  return tmp;
}


x86 assembly (clang, -O0):
<qt_internal_get_env_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x19(%rbp)
cmpb   $0x0,-0x9(%rbp)
je     1172 <qt_internal_get_env_bool+0x32>
lea    0xe97(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    117d <qt_internal_get_env_bool+0x3d>
lea    0xe8b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <qt_internal_get_env_str@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1289 <qt_internal_get_env_bool+0x149>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1289 <qt_internal_get_env_bool+0x149>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x19(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127a <qt_internal_get_env_bool+0x13a>
mov    -0x18(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1209 <qt_internal_get_env_bool+0xc9>
mov    -0x18(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1212 <qt_internal_get_env_bool+0xd2>
movb   $0x1,-0x19(%rbp)
jmp    1275 <qt_internal_get_env_bool+0x135>
mov    -0x18(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
je     1244 <qt_internal_get_env_bool+0x104>
mov    -0x18(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    124d <qt_internal_get_env_bool+0x10d>
movb   $0x0,-0x19(%rbp)
jmp    1270 <qt_internal_get_env_bool+0x130>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdad(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x9(%rbp),%al
mov    %al,-0x19(%rbp)
jmp    1275 <qt_internal_get_env_bool+0x135>
jmp    127a <qt_internal_get_env_bool+0x13a>
jmp    127f <qt_internal_get_env_bool+0x13f>
jmp    1284 <qt_internal_get_env_bool+0x144>
jmp    1289 <qt_internal_get_env_bool+0x149>
movzbl -0x19(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qt_internal_get_env_bool>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
test   %esi,%esi
lea    0xeaf(%rip),%rax
lea    0xea4(%rip),%rsi
cmove  %rax,%rsi
call   1050 <qt_internal_get_env_str@plt>
test   %rax,%rax
je     120c <qt_internal_get_env_bool+0xcc>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     120c <qt_internal_get_env_bool+0xcc>
mov    %rsp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <strtoul@plt>
test   %rax,%rax
setne  %r15b
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1209 <qt_internal_get_env_bool+0xc9>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    $0x1,%r15b
test   %eax,%eax
je     1209 <qt_internal_get_env_bool+0xc9>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1209 <qt_internal_get_env_bool+0xc9>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1206 <qt_internal_get_env_bool+0xc6>
lea    0xe32(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1206 <qt_internal_get_env_bool+0xc6>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    %ebp,%r15d
jmp    1209 <qt_internal_get_env_bool+0xc9>
xor    %r15d,%r15d
mov    %r15d,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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