#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 EXIT_SUCCESS;
int /*<<< orphan*/ FAIL(char *);
int /*<<< orphan*/ PASS(char *);
char *getenv(char *);
int main(int argc, const char *argv[]) {
  const char *rhs = getenv("DYLD_INSERT_LIBRARIES");
  if ((rhs != NULL) && (rhs[0] != '\0'))
    FAIL("insert-libraries-with-suid DYLD_INSERT_LIBRARIES not cleared");
  else
    PASS("insert-libraries-with-suid");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1182 <main+0x52>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1182 <main+0x52>
lea    0xe9e(%rip),%rdi
call   1050 <FAIL@plt>
jmp    118e <main+0x5e>
lea    0xeca(%rip),%rdi
call   1040 <PASS@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1155 <main+0x25>
cmpb   $0x0,(%rax)
je     1155 <main+0x25>
lea    0xec8(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1161 <main+0x31>
lea    0xef7(%rip),%rdi
call   1040 <PASS@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"DYLD_INSERT_LIBRARIES\00"
@.str.1 = [61 x i8] c"insert-libraries-with-suid DYLD_INSERT_LIBRARIES not cleared\00"
@.str.2 = [27 x i8] c"insert-libraries-with-suid\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i8* @getenv(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = call i32 @FAIL(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %20
18: ; preds = %10, %2
%19 = call i32 @PASS(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

LLVM IR (-O2):
@.str = [22 x i8] c"DYLD_INSERT_LIBRARIES\00"
@.str.1 = [61 x i8] c"insert-libraries-with-suid DYLD_INSERT_LIBRARIES not cleared\00"
@.str.2 = [27 x i8] c"insert-libraries-with-suid\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @FAIL(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %5, %2
%11 = tail call i32 @PASS(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}