#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*/ get_env_util(char **, char *);
int /*<<< orphan*/ *getenv(char *);
char *get_tool_perf_outfile_envvar(void) {
  char *perf_envvar = NULL;
  if (getenv("CLARMOR_PERFSTAT_OUTFILE") == NULL) {
    return 0;
  } else {
    char *ret_val;
    if (!get_env_util(&perf_envvar, "CLARMOR_PERFSTAT_OUTFILE")) {
      if (perf_envvar != NULL) {
        ret_val = perf_envvar;
      } else
        ret_val = NULL;
    } else
      ret_val = NULL;
    return ret_val;
  }
}


x86 assembly (clang, -O0):
<get_tool_perf_outfile_envvar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    0xec9(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
jne    1153 <get_tool_perf_outfile_envvar+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <get_tool_perf_outfile_envvar+0x81>
lea    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <get_env_util@plt>
cmp    $0x0,%eax
jne    1191 <get_tool_perf_outfile_envvar+0x71>
cmpq   $0x0,-0x10(%rbp)
je     1184 <get_tool_perf_outfile_envvar+0x64>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    118c <get_tool_perf_outfile_envvar+0x6c>
movq   $0x0,-0x18(%rbp)
jmp    1199 <get_tool_perf_outfile_envvar+0x79>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tool_perf_outfile_envvar>:
push   %rax
movq   $0x0,(%rsp)
lea    0xed0(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1153 <get_tool_perf_outfile_envvar+0x33>
lea    0xebf(%rip),%rsi
mov    %rsp,%rdi
call   1040 <get_env_util@plt>
test   %eax,%eax
jne    1153 <get_tool_perf_outfile_envvar+0x33>
mov    (%rsp),%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c"CLARMOR_PERFSTAT_OUTFILE\00"
define i8* @get_tool_perf_outfile_envvar() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = tail call i32* @getenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @get_env_util(i8** %1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = load i8*, i8** %1
%9 = select i1 %7, i8* %8, i8* null
br label %10
10: ; preds = %0, %5
%11 = phi i8* [ %9, %5 ], [ null, %0 ]
ret i8* %11
}