#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 */
typedef int /*<<< orphan*/ unsec_vars;

/* Variables and functions */
int /*<<< orphan*/ linker_env_unset(char const *const);
void linker_env_secure(void) {
  static const char *const unsec_vars[] = {
      "GCONV_PATH",
      "GETCONF_DIR",
      "HOSTALIASES",
      "LD_AUDIT",
      "LD_DEBUG",
      "LD_DEBUG_OUTPUT",
      "LD_DYNAMIC_WEAK",
      "LD_LIBRARY_PATH",
      "LD_ORIGIN_PATH",
      "LD_PRELOAD",
      "LD_PROFILE",
      "LD_SHOW_AUXV",
      "LD_USE_LOAD_BIAS",
      "LOCALDOMAIN",
      "LOCPATH",
      "MALLOC_TRACE",
      "MALLOC_CHECK_",
      "NIS_PATH",
      "NLSPATH",
      "RESOLV_HOST_CONF",
      "RES_OPTIONS",
      "TMPDIR",
      "TZDIR",
      "LD_AOUT_LIBRARY_PATH",
      "LD_AOUT_PRELOAD",
  };
  const char *const *cp = unsec_vars;
  const char *const *endp = cp + sizeof(unsec_vars) / sizeof(unsec_vars[0]);
  while (cp < endp) {
    linker_env_unset(*cp);
    cp++;
  }
}


x86 assembly (clang, -O0):
<linker_env_secure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x2c31(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    115c <linker_env_secure+0x4c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <linker_env_unset@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1131 <linker_env_secure+0x21>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linker_env_secure>:
push   %r14
push   %rbx
push   %rax
lea    0x2c35(%rip),%rbx
lea    0x2cf6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%rdi
call   1030 <linker_env_unset@plt>
add    $0x8,%rbx
cmp    %r14,%rbx
jb     1130 <linker_env_secure+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@linker_env_secure.unsec_vars = internal constant [25 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.24, i32 0, i32 0)]
@.str = [11 x i8] c"GCONV_PATH\00"
@.str.1 = [12 x i8] c"GETCONF_DIR\00"
@.str.2 = [12 x i8] c"HOSTALIASES\00"
@.str.3 = [9 x i8] c"LD_AUDIT\00"
@.str.4 = [9 x i8] c"LD_DEBUG\00"
@.str.5 = [16 x i8] c"LD_DEBUG_OUTPUT\00"
@.str.6 = [16 x i8] c"LD_DYNAMIC_WEAK\00"
@.str.7 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.8 = [15 x i8] c"LD_ORIGIN_PATH\00"
@.str.9 = [11 x i8] c"LD_PRELOAD\00"
@.str.10 = [11 x i8] c"LD_PROFILE\00"
@.str.11 = [13 x i8] c"LD_SHOW_AUXV\00"
@.str.12 = [17 x i8] c"LD_USE_LOAD_BIAS\00"
@.str.13 = [12 x i8] c"LOCALDOMAIN\00"
@.str.14 = [8 x i8] c"LOCPATH\00"
@.str.15 = [13 x i8] c"MALLOC_TRACE\00"
@.str.16 = [14 x i8] c"MALLOC_CHECK_\00"
@.str.17 = [9 x i8] c"NIS_PATH\00"
@.str.18 = [8 x i8] c"NLSPATH\00"
@.str.19 = [17 x i8] c"RESOLV_HOST_CONF\00"
@.str.20 = [12 x i8] c"RES_OPTIONS\00"
@.str.21 = [7 x i8] c"TMPDIR\00"
@.str.22 = [6 x i8] c"TZDIR\00"
@.str.23 = [21 x i8] c"LD_AOUT_LIBRARY_PATH\00"
@.str.24 = [16 x i8] c"LD_AOUT_PRELOAD\00"
define void @linker_env_secure() {
%1 = alloca i8**
%2 = alloca i8**
store i8** getelementptr inbounds ([25 x i8*], [25 x i8*]* @linker_env_secure.unsec_vars, i64 0, i64 0), i8*** %1
%3 = load i8**, i8*** %1
%4 = getelementptr inbounds i8*, i8** %3, i64 25
store i8** %4, i8*** %2
br label %5
5: ; preds = %9, %0
%6 = load i8**, i8*** %1
%7 = load i8**, i8*** %2
%8 = icmp ult i8** %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load i8**, i8*** %1
%11 = load i8*, i8** %10
%12 = call i32 @linker_env_unset(i8* %11)
%13 = load i8**, i8*** %1
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %1
br label %5
15: ; preds = %5
ret void
}

LLVM IR (-O2):
@linker_env_secure.unsec_vars = internal constant [25 x i8*] [i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.24, i32 0, i32 0)]
@.str = [11 x i8] c"GCONV_PATH\00"
@.str.1 = [12 x i8] c"GETCONF_DIR\00"
@.str.2 = [12 x i8] c"HOSTALIASES\00"
@.str.3 = [9 x i8] c"LD_AUDIT\00"
@.str.4 = [9 x i8] c"LD_DEBUG\00"
@.str.5 = [16 x i8] c"LD_DEBUG_OUTPUT\00"
@.str.6 = [16 x i8] c"LD_DYNAMIC_WEAK\00"
@.str.7 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.8 = [15 x i8] c"LD_ORIGIN_PATH\00"
@.str.9 = [11 x i8] c"LD_PRELOAD\00"
@.str.10 = [11 x i8] c"LD_PROFILE\00"
@.str.11 = [13 x i8] c"LD_SHOW_AUXV\00"
@.str.12 = [17 x i8] c"LD_USE_LOAD_BIAS\00"
@.str.13 = [12 x i8] c"LOCALDOMAIN\00"
@.str.14 = [8 x i8] c"LOCPATH\00"
@.str.15 = [13 x i8] c"MALLOC_TRACE\00"
@.str.16 = [14 x i8] c"MALLOC_CHECK_\00"
@.str.17 = [9 x i8] c"NIS_PATH\00"
@.str.18 = [8 x i8] c"NLSPATH\00"
@.str.19 = [17 x i8] c"RESOLV_HOST_CONF\00"
@.str.20 = [12 x i8] c"RES_OPTIONS\00"
@.str.21 = [7 x i8] c"TMPDIR\00"
@.str.22 = [6 x i8] c"TZDIR\00"
@.str.23 = [21 x i8] c"LD_AOUT_LIBRARY_PATH\00"
@.str.24 = [16 x i8] c"LD_AOUT_PRELOAD\00"
define void @linker_env_secure() {
br label %1
1: ; preds = %0, %1
%2 = phi i8** [ getelementptr inbounds ([25 x i8*], [25 x i8*]* @linker_env_secure.unsec_vars, i64 0, i64 0), %0 ], [ %5, %1 ]
%3 = load i8*, i8** %2
%4 = tail call i32 @linker_env_unset(i8* %3)
%5 = getelementptr inbounds i8*, i8** %2, i64 1
%6 = icmp ult i8** %5, getelementptr inbounds ([25 x i8*], [25 x i8*]* @linker_env_secure.unsec_vars, i64 1, i64 0)
br i1 %6, label %1, label %7
7: ; preds = %1
ret void
}