#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 *getenv(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int dcc_getenv_bool(const char *name, int default_value) {
  const char *e;
  e = getenv(name);
  if (!e || !*e)
    return default_value;
  if (!strcmp(e, "1"))
    return 1;
  else if (!strcmp(e, "0"))
    return 0;
  else
    return default_value;
}


x86 assembly (clang, -O0):
<dcc_getenv_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1154 <dcc_getenv_bool+0x34>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    115f <dcc_getenv_bool+0x3f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11af <dcc_getenv_bool+0x8f>
mov    -0x20(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1184 <dcc_getenv_bool+0x64>
movl   $0x1,-0x4(%rbp)
jmp    11af <dcc_getenv_bool+0x8f>
mov    -0x20(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a9 <dcc_getenv_bool+0x89>
movl   $0x0,-0x4(%rbp)
jmp    11af <dcc_getenv_bool+0x8f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcc_getenv_bool>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <getenv@plt>
test   %rax,%rax
je     1165 <dcc_getenv_bool+0x45>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     1165 <dcc_getenv_bool+0x45>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1160 <dcc_getenv_bool+0x40>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
cmove  %eax,%ebp
jmp    1165 <dcc_getenv_bool+0x45>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @dcc_getenv_bool(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = call i8* @getenv(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11, %2
%16 = load i32, i32* %5
store i32 %16, i32* %3
br label %29
17: ; preds = %11
%18 = load i8*, i8** %6
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i32 1, i32* %3
br label %29
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i32 0, i32* %3
br label %29
27: ; preds = %22
%28 = load i32, i32* %5
store i32 %28, i32* %3
br label %29
29: ; preds = %27, %26, %21, %15
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @dcc_getenv_bool(i8* nocapture %0, i32 %1) {
%3 = tail call i8* @getenv(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i32 0, i32 %1
br label %15
15: ; preds = %11, %8, %2, %5
%16 = phi i32 [ %1, %5 ], [ %1, %2 ], [ 1, %8 ], [ %14, %11 ]
ret i32 %16
}