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


x86 assembly (clang, -O0):
<get_gpu_strat_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_gpu_strat_envvar+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11cf <get_gpu_strat_envvar+0x8f>
lea    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <get_env_util@plt>
cmp    $0x0,%eax
jne    11c2 <get_gpu_strat_envvar+0x82>
cmpq   $0x0,-0x10(%rbp)
je     11b6 <get_gpu_strat_envvar+0x76>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
jmp    11bd <get_gpu_strat_envvar+0x7d>
movl   $0x0,-0x14(%rbp)
jmp    11c9 <get_gpu_strat_envvar+0x89>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gpu_strat_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_gpu_strat_envvar+0x55>
lea    0xe98(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <get_env_util@plt>
test   %eax,%eax
jne    1195 <get_gpu_strat_envvar+0x55>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1195 <get_gpu_strat_envvar+0x55>
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@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 = [32 x i8] c"CLARMOR_ALTERNATE_GPU_DETECTION\00"
define i32 @get_gpu_strat_envvar() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i8* null, i8** %2
%4 = call i32* @getenv(i8* getelementptr inbounds ([32 x i8], [32 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 %23
7: ; preds = %0
%8 = call i32 @get_env_util(i8** %2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %20, 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 @strtol(i8* %14, i32* null, i32 0)
store i32 %15, i32* %3
%16 = load i8*, i8** %2
%17 = call i32 @free(i8* %16)
br label %19
18: ; preds = %10
store i32 0, i32* %3
br label %19
19: ; preds = %18, %13
br label %21
20: ; preds = %7
store i32 0, i32* %3
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %3
store i32 %22, i32* %1
br label %23
23: ; preds = %21, %6
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [32 x i8] c"CLARMOR_ALTERNATE_GPU_DETECTION\00"
define i32 @get_gpu_strat_envvar() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = tail call i32* @getenv(i8* getelementptr inbounds ([32 x i8], [32 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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = call i32 @strtol(i8* nocapture %9, i32* null, i32 0)
%13 = load i8*, i8** %1
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %11, %8, %5, %0
%16 = phi i32 [ 0, %0 ], [ %12, %11 ], [ 0, %8 ], [ 0, %5 ]
ret i32 %16
}