#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 check_set_evar(char *, char *);
int /*<<< orphan*/ setenv(char *, char *, int);
void update_environment(char *base_path) {
  int modval = 0;
  modval |= check_set_evar("DYLD_LIBRARY_PATH", "PIN_APP_DYLD_LIBRARY_PATH");
  modval |=
      check_set_evar("DYLD_INSERT_LIBRARIES", "PIN_APP_DYLD_INSERT_LIBRARIES");
  modval |=
      check_set_evar("DYLD_BIND_AT_LAUNCH", "PIN_APP_DYLD_BIND_AT_LAUNCH");
  if (modval) {
    setenv("PIN_DYLD_RESTORE_REQUIRED", "t", 1);
  }
  (void)base_path;
}


x86 assembly (clang, -O0):
<update_environment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xece(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1040 <check_set_evar@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xecf(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1040 <check_set_evar@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xed4(%rip),%rdi
lea    0xec5(%rip),%rsi
call   1040 <check_set_evar@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a0 <update_environment+0x80>
lea    0xec5(%rip),%rdi
lea    0xed8(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_environment>:
push   %rbp
push   %rbx
push   %rax
lea    0xede(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1040 <check_set_evar@plt>
mov    %eax,%ebx
lea    0xee3(%rip),%rdi
lea    0xed4(%rip),%rsi
call   1040 <check_set_evar@plt>
mov    %eax,%ebp
or     %ebx,%ebp
lea    0xeea(%rip),%rdi
lea    0xedb(%rip),%rsi
call   1040 <check_set_evar@plt>
or     %ebp,%eax
je     1184 <update_environment+0x64>
lea    0xee7(%rip),%rdi
lea    0xefa(%rip),%rsi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <setenv@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"DYLD_LIBRARY_PATH\00"
@.str.1 = [26 x i8] c"PIN_APP_DYLD_LIBRARY_PATH\00"
@.str.2 = [22 x i8] c"DYLD_INSERT_LIBRARIES\00"
@.str.3 = [30 x i8] c"PIN_APP_DYLD_INSERT_LIBRARIES\00"
@.str.4 = [20 x i8] c"DYLD_BIND_AT_LAUNCH\00"
@.str.5 = [28 x i8] c"PIN_APP_DYLD_BIND_AT_LAUNCH\00"
@.str.6 = [26 x i8] c"PIN_DYLD_RESTORE_REQUIRED\00"
@.str.7 = [2 x i8] c"t\00"
define void @update_environment(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = call i32 @check_set_evar(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* %3
%6 = or i32 %5, %4
store i32 %6, i32* %3
%7 = call i32 @check_set_evar(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = or i32 %8, %7
store i32 %9, i32* %3
%10 = call i32 @check_set_evar(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = or i32 %11, %10
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @setenv(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %17
17: ; preds = %15, %1
%18 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"DYLD_LIBRARY_PATH\00"
@.str.1 = [26 x i8] c"PIN_APP_DYLD_LIBRARY_PATH\00"
@.str.2 = [22 x i8] c"DYLD_INSERT_LIBRARIES\00"
@.str.3 = [30 x i8] c"PIN_APP_DYLD_INSERT_LIBRARIES\00"
@.str.4 = [20 x i8] c"DYLD_BIND_AT_LAUNCH\00"
@.str.5 = [28 x i8] c"PIN_APP_DYLD_BIND_AT_LAUNCH\00"
@.str.6 = [26 x i8] c"PIN_DYLD_RESTORE_REQUIRED\00"
@.str.7 = [2 x i8] c"t\00"
define void @update_environment(i8* nocapture readnone %0) {
%2 = tail call i32 @check_set_evar(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @check_set_evar(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%4 = or i32 %3, %2
%5 = tail call i32 @check_set_evar(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%6 = or i32 %4, %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @setenv(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 1)
br label %10
10: ; preds = %8, %1
ret void
}