#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*/ free(char *);
int /*<<< orphan*/ get_env_util(char **, char *);
int /*<<< orphan*/ *getenv(char *);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int get_print_backtrace_envvar(void) {
  char *print_backtrace_envvar = NULL;
  if (getenv("CLARMOR_PRINT_BACKTRACE") == NULL)
    return 0;
  else {
    unsigned int ret_val = 0;
    if (!get_env_util(&print_backtrace_envvar, "CLARMOR_PRINT_BACKTRACE")) {
      if (print_backtrace_envvar != NULL) {
        ret_val = strtoul(print_backtrace_envvar, NULL, 0);
        free(print_backtrace_envvar);
      }
    }
    return ret_val;
  }
}


x86 assembly (clang, -O0):
<get_print_backtrace_envvar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
jne    1172 <get_print_backtrace_envvar+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <get_print_backtrace_envvar+0x83>
movl   $0x0,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <get_env_util@plt>
cmp    $0x0,%eax
jne    11bd <get_print_backtrace_envvar+0x7d>
cmpq   $0x0,-0x10(%rbp)
je     11b8 <get_print_backtrace_envvar+0x78>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    11bd <get_print_backtrace_envvar+0x7d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_print_backtrace_envvar>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeab(%rip),%rdi
call   1030 <getenv@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1195 <get_print_backtrace_envvar+0x55>
lea    0xe98(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <get_env_util@plt>
test   %eax,%eax
jne    1195 <get_print_backtrace_envvar+0x55>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1195 <get_print_backtrace_envvar+0x55>
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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