#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 *append3(char *, char *, char const *);
int /*<<< orphan*/ check_retval(int, char *);
int get_gcc_version_string(int *, int *);
char *getenv(char *);
int setenv(char *, char *, int const);
int /*<<< orphan*/ unsetenv(char *);
void update_environment(char *base_path) {
  int r;
  int gcc_major = 0, gcc_minor = 0;
  const int overwrite = 1;
  char *pin_ld_library_path = 0;
  char *new_ld_library_path = 0;
  const char *pin_runtime_dir = "runtime";
  const char *glibc_lib_dir = "glibc";
  const char *cpp_lib_dir = "cpplibs";
  char *ld_library_path = 0;
  char *ld_assume_kernel = 0;
  char *base_path32 = 0;
  char *base_path64 = 0;
  char *pin_runtime_libs32 = 0;
  char *pin_runtime_libs64 = 0;
  char *pin_glibc_libs32 = 0;
  char *pin_glibc_libs64 = 0;
  char *pin_cpp_libs32 = 0;
  char *pin_cpp_libs64 = 0;
  char *incoming_ld_preload = 0;
  char *incoming_ld_bind_now = 0;
  int getGccPassed = 0;
  base_path32 = append3(base_path, "/", "ia32");
  base_path64 = append3(base_path, "/", "intel64");
  pin_runtime_libs32 = append3(base_path32, "/", pin_runtime_dir);
  pin_runtime_libs64 = append3(base_path64, "/", pin_runtime_dir);
  pin_glibc_libs32 = append3(pin_runtime_libs32, "/", glibc_lib_dir);
  pin_glibc_libs64 = append3(pin_runtime_libs64, "/", glibc_lib_dir);
  pin_cpp_libs32 = append3(pin_runtime_libs32, "/", cpp_lib_dir);
  ;
  pin_cpp_libs64 = append3(pin_runtime_libs64, "/", cpp_lib_dir);
  ;
  ld_library_path = getenv("LD_LIBRARY_PATH");
  pin_ld_library_path = ld_library_path;
  pin_ld_library_path = append3(pin_glibc_libs32, ":", pin_ld_library_path);
  pin_ld_library_path = append3(pin_glibc_libs64, ":", pin_ld_library_path);
  getGccPassed = get_gcc_version_string(&gcc_major, &gcc_minor);
  if (!getGccPassed || gcc_major < 4 || (gcc_major == 4 && gcc_minor < 5)) {
    pin_ld_library_path = append3(pin_cpp_libs32, ":", pin_ld_library_path);
    pin_ld_library_path = append3(pin_cpp_libs64, ":", pin_ld_library_path);
  }
  pin_ld_library_path = append3(pin_runtime_libs32, ":", pin_ld_library_path);
  pin_ld_library_path = append3(pin_runtime_libs64, ":", pin_ld_library_path);
  new_ld_library_path = ld_library_path;
  if (!getGccPassed || gcc_major < 4 || (gcc_major == 4 && gcc_minor < 5)) {
    new_ld_library_path = append3(pin_cpp_libs32, ":", new_ld_library_path);
    new_ld_library_path = append3(pin_cpp_libs64, ":", new_ld_library_path);
  }
  new_ld_library_path = append3(pin_runtime_libs32, ":", new_ld_library_path);
  new_ld_library_path = append3(pin_runtime_libs64, ":", new_ld_library_path);
  r = setenv("PIN_LD_RESTORE_REQUIRED", "t", overwrite);
  check_retval(r, "setenv PIN_LD_RESTORE_REQUIRED");
  r = setenv("PIN_VM_LD_LIBRARY_PATH", pin_ld_library_path, overwrite);
  check_retval(r, "setenv PIN_VM_LD_LIBRARY_PATH");
  if (ld_library_path) {
    r = setenv("PIN_APP_LD_LIBRARY_PATH", ld_library_path, overwrite);
    check_retval(r, "setenv PIN_APP_LD_LIBRARY_PATH");
  }
  r = setenv("LD_LIBRARY_PATH", new_ld_library_path, overwrite);
  check_retval(r, "setenv LD_LIBRARY_PATH");
  ld_assume_kernel = getenv("LD_ASSUME_KERNEL");
  if (ld_assume_kernel) {
    r = setenv("PIN_APP_LD_ASSUME_KERNEL", ld_assume_kernel, overwrite);
    check_retval(r, "setenv PIN_APP_LD_ASSUME_KERNEL");
    unsetenv("LD_ASSUME_KERNEL");
  }
  incoming_ld_bind_now = getenv("LD_BIND_NOW");
  if (incoming_ld_bind_now) {
    r = setenv("PIN_APP_LD_BIND_NOW", incoming_ld_bind_now, overwrite);
    check_retval(r, "setenv PIN_APP_LD_BIND_NOW");
    unsetenv("LD_BIND_NOW");
  }
  incoming_ld_preload = getenv("LD_PRELOAD");
  if (incoming_ld_preload) {
    r = setenv("PIN_APP_LD_PRELOAD", incoming_ld_preload, overwrite);
    check_retval(r, "setenv PIN_APP_LD_PRELOAD");
    unsetenv("LD_PRELOAD");
  }
}


x86 assembly (clang, -O0):
<update_environment>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe62(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe5d(%rip),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x98(%rbp)
movq   $0x0,-0xa0(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xde0(%rip),%rsi
lea    0xddb(%rip),%rdx
call   1060 <append3@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdc5(%rip),%rsi
lea    0xdc5(%rip),%rdx
call   1060 <append3@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xda6(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd8e(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xd76(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xd5e(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x80(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd46(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x88(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd2b(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x90(%rbp)
lea    0xd8e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd07(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xcef(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <get_gcc_version_string@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
je     137d <update_environment+0x21d>
cmpl   $0x4,-0x10(%rbp)
jl     137d <update_environment+0x21d>
cmpl   $0x4,-0x10(%rbp)
jne    13b3 <update_environment+0x253>
cmpl   $0x5,-0x14(%rbp)
jge    13b3 <update_environment+0x253>
mov    -0x88(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc96(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc7b(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc63(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xc4b(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0xa4(%rbp)
je     1416 <update_environment+0x2b6>
cmpl   $0x4,-0x10(%rbp)
jl     1416 <update_environment+0x2b6>
cmpl   $0x4,-0x10(%rbp)
jne    144c <update_environment+0x2ec>
cmpl   $0x5,-0x14(%rbp)
jge    144c <update_environment+0x2ec>
mov    -0x88(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xbfd(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x28(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xbe2(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x28(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xbca(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x28(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xbb2(%rip),%rsi
call   1060 <append3@plt>
mov    %rax,-0x28(%rbp)
lea    0xbad(%rip),%rdi
lea    0xb9d(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb88(%rip),%rsi
call   1070 <check_retval@plt>
mov    -0x20(%rbp),%rsi
lea    0xb9e(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb80(%rip),%rsi
call   1070 <check_retval@plt>
cmpq   $0x0,-0x48(%rbp)
je     14ff <update_environment+0x39f>
mov    -0x48(%rbp),%rsi
lea    0xb8a(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb6c(%rip),%rsi
call   1070 <check_retval@plt>
mov    -0x28(%rbp),%rsi
lea    0xb82(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb64(%rip),%rsi
call   1070 <check_retval@plt>
lea    0xb7e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1574 <update_environment+0x414>
mov    -0x50(%rbp),%rsi
lea    0xb57(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb39(%rip),%rsi
call   1070 <check_retval@plt>
lea    0xb3c(%rip),%rdi
call   1080 <unsetenv@plt>
lea    0xb50(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
je     15cb <update_environment+0x46b>
mov    -0xa0(%rbp),%rsi
lea    0xb20(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xb02(%rip),%rsi
call   1070 <check_retval@plt>
lea    0xb05(%rip),%rdi
call   1080 <unsetenv@plt>
lea    0xb14(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1622 <update_environment+0x4c2>
mov    -0x98(%rbp),%rsi
lea    0xae4(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xac6(%rip),%rsi
call   1070 <check_retval@plt>
lea    0xac9(%rip),%rdi
call   1080 <unsetenv@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_environment>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe8e(%rip),%r13
lea    0xe89(%rip),%rdx
mov    %r13,%rsi
call   1060 <append3@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rdx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <append3@plt>
mov    %rax,%rbp
lea    0xe4a(%rip),%r15
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1060 <append3@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1060 <append3@plt>
mov    %rax,%r15
lea    0xe29(%rip),%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <append3@plt>
mov    %rax,%r14
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <append3@plt>
mov    %rax,%r12
lea    0xe06(%rip),%rbp
mov    %rbx,0x18(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <append3@plt>
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1060 <append3@plt>
mov    %rax,%rbp
lea    0xe54(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r13
lea    0xdde(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <get_gcc_version_string@plt>
mov    %eax,%r14d
test   %eax,%eax
mov    %rbp,0x20(%rsp)
je     1291 <update_environment+0x131>
cmpl   $0x4,0xc(%rsp)
jl     1291 <update_environment+0x131>
jne    12b9 <update_environment+0x159>
cmpl   $0x4,0x8(%rsp)
jg     12b9 <update_environment+0x159>
lea    0xd8d(%rip),%r12
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <append3@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %rax,%rbx
lea    0xd65(%rip),%rbp
mov    0x18(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <append3@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %rax,%r12
test   %r14d,%r14d
je     12fc <update_environment+0x19c>
cmpl   $0x4,0xc(%rsp)
jl     12fc <update_environment+0x19c>
mov    %r13,%rdx
jne    1326 <update_environment+0x1c6>
cmpl   $0x4,0x8(%rsp)
mov    %r13,%rdx
jg     1326 <update_environment+0x1c6>
lea    0xd22(%rip),%rbx
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <append3@plt>
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %rax,%rdx
lea    0xcf8(%rip),%rbx
mov    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <append3@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <append3@plt>
mov    %rax,%rbp
lea    0xcde(%rip),%rdi
lea    0xcce(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xcbf(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xcd7(%rip),%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xcbc(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
test   %r13,%r13
je     13ba <update_environment+0x25a>
lea    0xcce(%rip),%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xcb3(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xccb(%rip),%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xcb0(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xcc8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     141b <update_environment+0x2bb>
lea    0xcaf(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xc94(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xc95(%rip),%rdi
call   1080 <unsetenv@plt>
lea    0xca9(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     145a <update_environment+0x2fa>
lea    0xc90(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xc75(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xc76(%rip),%rdi
call   1080 <unsetenv@plt>
lea    0xc85(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1499 <update_environment+0x339>
lea    0xc6c(%rip),%rdi
mov    %rax,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xc51(%rip),%rsi
mov    %eax,%edi
call   1070 <check_retval@plt>
lea    0xc52(%rip),%rdi
call   1080 <unsetenv@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"runtime\00"
@.str.1 = [6 x i8] c"glibc\00"
@.str.2 = [8 x i8] c"cpplibs\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [5 x i8] c"ia32\00"
@.str.5 = [8 x i8] c"intel64\00"
@.str.6 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.7 = [2 x i8] c":\00"
@.str.8 = [24 x i8] c"PIN_LD_RESTORE_REQUIRED\00"
@.str.9 = [2 x i8] c"t\00"
@.str.10 = [31 x i8] c"setenv PIN_LD_RESTORE_REQUIRED\00"
@.str.11 = [23 x i8] c"PIN_VM_LD_LIBRARY_PATH\00"
@.str.12 = [30 x i8] c"setenv PIN_VM_LD_LIBRARY_PATH\00"
@.str.13 = [24 x i8] c"PIN_APP_LD_LIBRARY_PATH\00"
@.str.14 = [31 x i8] c"setenv PIN_APP_LD_LIBRARY_PATH\00"
@.str.15 = [23 x i8] c"setenv LD_LIBRARY_PATH\00"
@.str.16 = [17 x i8] c"LD_ASSUME_KERNEL\00"
@.str.17 = [25 x i8] c"PIN_APP_LD_ASSUME_KERNEL\00"
@.str.18 = [32 x i8] c"setenv PIN_APP_LD_ASSUME_KERNEL\00"
@.str.19 = [12 x i8] c"LD_BIND_NOW\00"
@.str.20 = [20 x i8] c"PIN_APP_LD_BIND_NOW\00"
@.str.21 = [27 x i8] c"setenv PIN_APP_LD_BIND_NOW\00"
@.str.22 = [11 x i8] c"LD_PRELOAD\00"
@.str.23 = [19 x i8] c"PIN_APP_LD_PRELOAD\00"
@.str.24 = [26 x i8] c"setenv PIN_APP_LD_PRELOAD\00"
define void @update_environment(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %5
store i32 1, i32* %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i8* null, i8** %14
store i8* null, i8** %15
store i8* null, i8** %16
store i8* null, i8** %17
store i8* null, i8** %18
store i8* null, i8** %19
store i8* null, i8** %20
store i8* null, i8** %21
store i8* null, i8** %22
store i8* null, i8** %23
store i32 0, i32* %24
%25 = load i8*, i8** %2
%26 = call i8* @append3(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i8* %26, i8** %14
%27 = load i8*, i8** %2
%28 = call i8* @append3(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i8* %28, i8** %15
%29 = load i8*, i8** %14
%30 = load i8*, i8** %9
%31 = call i8* @append3(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %30)
store i8* %31, i8** %16
%32 = load i8*, i8** %15
%33 = load i8*, i8** %9
%34 = call i8* @append3(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %33)
store i8* %34, i8** %17
%35 = load i8*, i8** %16
%36 = load i8*, i8** %10
%37 = call i8* @append3(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %36)
store i8* %37, i8** %18
%38 = load i8*, i8** %17
%39 = load i8*, i8** %10
%40 = call i8* @append3(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %39)
store i8* %40, i8** %19
%41 = load i8*, i8** %16
%42 = load i8*, i8** %11
%43 = call i8* @append3(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %42)
store i8* %43, i8** %20
%44 = load i8*, i8** %17
%45 = load i8*, i8** %11
%46 = call i8* @append3(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %45)
store i8* %46, i8** %21
%47 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
store i8* %47, i8** %12
%48 = load i8*, i8** %12
store i8* %48, i8** %7
%49 = load i8*, i8** %18
%50 = load i8*, i8** %7
%51 = call i8* @append3(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %50)
store i8* %51, i8** %7
%52 = load i8*, i8** %19
%53 = load i8*, i8** %7
%54 = call i8* @append3(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %53)
store i8* %54, i8** %7
%55 = call i32 @get_gcc_version_string(i32* %4, i32* %5)
store i32 %55, i32* %24
%56 = load i32, i32* %24
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %1
%59 = load i32, i32* %4
%60 = icmp slt i32 %59, 4
br i1 %60, label %67, label %61
61: ; preds = %58
%62 = load i32, i32* %4
%63 = icmp eq i32 %62, 4
br i1 %63, label %64, label %74
64: ; preds = %61
%65 = load i32, i32* %5
%66 = icmp slt i32 %65, 5
br i1 %66, label %67, label %74
67: ; preds = %64, %58, %1
%68 = load i8*, i8** %20
%69 = load i8*, i8** %7
%70 = call i8* @append3(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %69)
store i8* %70, i8** %7
%71 = load i8*, i8** %21
%72 = load i8*, i8** %7
%73 = call i8* @append3(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %72)
store i8* %73, i8** %7
br label %74
74: ; preds = %67, %64, %61
%75 = load i8*, i8** %16
%76 = load i8*, i8** %7
%77 = call i8* @append3(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %76)
store i8* %77, i8** %7
%78 = load i8*, i8** %17
%79 = load i8*, i8** %7
%80 = call i8* @append3(i8* %78, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %79)
store i8* %80, i8** %7
%81 = load i8*, i8** %12
store i8* %81, i8** %8
%82 = load i32, i32* %24
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %93
84: ; preds = %74
%85 = load i32, i32* %4
%86 = icmp slt i32 %85, 4
br i1 %86, label %93, label %87
87: ; preds = %84
%88 = load i32, i32* %4
%89 = icmp eq i32 %88, 4
br i1 %89, label %90, label %100
90: ; preds = %87
%91 = load i32, i32* %5
%92 = icmp slt i32 %91, 5
br i1 %92, label %93, label %100
93: ; preds = %90, %84, %74
%94 = load i8*, i8** %20
%95 = load i8*, i8** %8
%96 = call i8* @append3(i8* %94, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %95)
store i8* %96, i8** %8
%97 = load i8*, i8** %21
%98 = load i8*, i8** %8
%99 = call i8* @append3(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %98)
store i8* %99, i8** %8
br label %100
100: ; preds = %93, %90, %87
%101 = load i8*, i8** %16
%102 = load i8*, i8** %8
%103 = call i8* @append3(i8* %101, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %102)
store i8* %103, i8** %8
%104 = load i8*, i8** %17
%105 = load i8*, i8** %8
%106 = call i8* @append3(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %105)
store i8* %106, i8** %8
%107 = call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
store i32 %107, i32* %3
%108 = load i32, i32* %3
%109 = call i32 @check_retval(i32 %108, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
%110 = load i8*, i8** %7
%111 = call i32 @setenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %110, i32 1)
store i32 %111, i32* %3
%112 = load i32, i32* %3
%113 = call i32 @check_retval(i32 %112, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%114 = load i8*, i8** %12
%115 = icmp ne i8* %114, null
br i1 %115, label %116, label %121
116: ; preds = %100
%117 = load i8*, i8** %12
%118 = call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %117, i32 1)
store i32 %118, i32* %3
%119 = load i32, i32* %3
%120 = call i32 @check_retval(i32 %119, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
br label %121
121: ; preds = %116, %100
%122 = load i8*, i8** %8
%123 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %122, i32 1)
store i32 %123, i32* %3
%124 = load i32, i32* %3
%125 = call i32 @check_retval(i32 %124, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%126 = call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
store i8* %126, i8** %13
%127 = load i8*, i8** %13
%128 = icmp ne i8* %127, null
br i1 %128, label %129, label %135
129: ; preds = %121
%130 = load i8*, i8** %13
%131 = call i32 @setenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %130, i32 1)
store i32 %131, i32* %3
%132 = load i32, i32* %3
%133 = call i32 @check_retval(i32 %132, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.18, i64 0, i64 0))
%134 = call i32 @unsetenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
br label %135
135: ; preds = %129, %121
%136 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
store i8* %136, i8** %23
%137 = load i8*, i8** %23
%138 = icmp ne i8* %137, null
br i1 %138, label %139, label %145
139: ; preds = %135
%140 = load i8*, i8** %23
%141 = call i32 @setenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i8* %140, i32 1)
store i32 %141, i32* %3
%142 = load i32, i32* %3
%143 = call i32 @check_retval(i32 %142, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%144 = call i32 @unsetenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
br label %145
145: ; preds = %139, %135
%146 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
store i8* %146, i8** %22
%147 = load i8*, i8** %22
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %155
149: ; preds = %145
%150 = load i8*, i8** %22
%151 = call i32 @setenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.23, i64 0, i64 0), i8* %150, i32 1)
store i32 %151, i32* %3
%152 = load i32, i32* %3
%153 = call i32 @check_retval(i32 %152, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.24, i64 0, i64 0))
%154 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
br label %155
155: ; preds = %149, %145
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"runtime\00"
@.str.1 = [6 x i8] c"glibc\00"
@.str.2 = [8 x i8] c"cpplibs\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [5 x i8] c"ia32\00"
@.str.5 = [8 x i8] c"intel64\00"
@.str.6 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.7 = [2 x i8] c":\00"
@.str.8 = [24 x i8] c"PIN_LD_RESTORE_REQUIRED\00"
@.str.9 = [2 x i8] c"t\00"
@.str.10 = [31 x i8] c"setenv PIN_LD_RESTORE_REQUIRED\00"
@.str.11 = [23 x i8] c"PIN_VM_LD_LIBRARY_PATH\00"
@.str.12 = [30 x i8] c"setenv PIN_VM_LD_LIBRARY_PATH\00"
@.str.13 = [24 x i8] c"PIN_APP_LD_LIBRARY_PATH\00"
@.str.14 = [31 x i8] c"setenv PIN_APP_LD_LIBRARY_PATH\00"
@.str.15 = [23 x i8] c"setenv LD_LIBRARY_PATH\00"
@.str.16 = [17 x i8] c"LD_ASSUME_KERNEL\00"
@.str.17 = [25 x i8] c"PIN_APP_LD_ASSUME_KERNEL\00"
@.str.18 = [32 x i8] c"setenv PIN_APP_LD_ASSUME_KERNEL\00"
@.str.19 = [12 x i8] c"LD_BIND_NOW\00"
@.str.20 = [20 x i8] c"PIN_APP_LD_BIND_NOW\00"
@.str.21 = [27 x i8] c"setenv PIN_APP_LD_BIND_NOW\00"
@.str.22 = [11 x i8] c"LD_PRELOAD\00"
@.str.23 = [19 x i8] c"PIN_APP_LD_PRELOAD\00"
@.str.24 = [26 x i8] c"setenv PIN_APP_LD_PRELOAD\00"
define void @update_environment(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = tail call i8* @append3(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i8* @append3(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i8* @append3(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @append3(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = tail call i8* @append3(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i8* @append3(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i8* @append3(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i8* @append3(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%15 = tail call i8* @append3(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %14)
%16 = tail call i8* @append3(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %15)
%17 = call i32 @get_gcc_version_string(i32* %2, i32* %3)
%18 = icmp eq i32 %17, 0
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 4
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %27, label %22
22: ; preds = %1
%23 = icmp eq i32 %19, 4
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 5
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %27, label %30
27: ; preds = %22, %1
%28 = call i8* @append3(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %16)
%29 = call i8* @append3(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %22
%31 = phi i8* [ %29, %27 ], [ %16, %22 ]
%32 = call i8* @append3(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %31)
%33 = call i8* @append3(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 4
%36 = select i1 %18, i1 true, i1 %35
br i1 %36, label %42, label %37
37: ; preds = %30
%38 = icmp eq i32 %34, 4
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 5
%41 = select i1 %38, i1 %40, i1 false
br i1 %41, label %42, label %45
42: ; preds = %37, %30
%43 = call i8* @append3(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %14)
%44 = call i8* @append3(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %37
%46 = phi i8* [ %44, %42 ], [ %14, %37 ]
%47 = call i8* @append3(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %46)
%48 = call i8* @append3(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* %47)
%49 = call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%50 = call i32 @check_retval(i32 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
%51 = call i32 @setenv(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %33, i32 1)
%52 = call i32 @check_retval(i32 %51, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%53 = icmp eq i8* %14, null
br i1 %53, label %57, label %54
54: ; preds = %45
%55 = call i32 @setenv(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i8* %14, i32 1)
%56 = call i32 @check_retval(i32 %55, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
br label %57
57: ; preds = %54, %45
%58 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* %48, i32 1)
%59 = call i32 @check_retval(i32 %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0))
%60 = call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
%61 = icmp eq i8* %60, null
br i1 %61, label %66, label %62
62: ; preds = %57
%63 = call i32 @setenv(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* %60, i32 1)
%64 = call i32 @check_retval(i32 %63, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.18, i64 0, i64 0))
%65 = call i32 @unsetenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
br label %66
66: ; preds = %62, %57
%67 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%68 = icmp eq i8* %67, null
br i1 %68, label %73, label %69
69: ; preds = %66
%70 = call i32 @setenv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.20, i64 0, i64 0), i8* %67, i32 1)
%71 = call i32 @check_retval(i32 %70, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.21, i64 0, i64 0))
%72 = call i32 @unsetenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
br label %73
73: ; preds = %69, %66
%74 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
%75 = icmp eq i8* %74, null
br i1 %75, label %80, label %76
76: ; preds = %73
%77 = call i32 @setenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.23, i64 0, i64 0), i8* %74, i32 1)
%78 = call i32 @check_retval(i32 %77, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.24, i64 0, i64 0))
%79 = call i32 @unsetenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0))
br label %80
80: ; preds = %76, %73
ret void
}