#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 *);
int /*<<< orphan*/ RTLD_LAZY;
void *dlopen(char *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  void *handle = dlopen("/junk/path/libfoo.dylib", RTLD_LAZY);
  if (handle != NULL)
    FAIL("dlopen-DYLD_FALLBACK_LIBRARY_PATH unexpected found dylib");
  else
    PASS("dlopen-DYLD_FALLBACK_LIBRARY_PATH");
  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)
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0xeaa(%rip),%rdi
call   1030 <dlopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117b <main+0x4b>
lea    0xea7(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1187 <main+0x57>
lea    0xecf(%rip),%rdi
call   1040 <PASS@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
call   1030 <dlopen@plt>
test   %rax,%rax
je     1159 <main+0x29>
lea    0xec6(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1165 <main+0x35>
lea    0xef1(%rip),%rdi
call   1040 <PASS@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/junk/path/libfoo.dylib\00"
@RTLD_LAZY = global i32 0
@.str.1 = [57 x i8] c"dlopen-DYLD_FALLBACK_LIBRARY_PATH unexpected found dylib\00"
@.str.2 = [34 x i8] c"dlopen-DYLD_FALLBACK_LIBRARY_PATH\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 = load i32, i32* @RTLD_LAZY
%8 = call i8* @dlopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @FAIL(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %15
13: ; preds = %2
%14 = call i32 @PASS(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}

LLVM IR (-O2):
@.str = [24 x i8] c"/junk/path/libfoo.dylib\00"
@RTLD_LAZY = global i32 0
@.str.1 = [57 x i8] c"dlopen-DYLD_FALLBACK_LIBRARY_PATH unexpected found dylib\00"
@.str.2 = [34 x i8] c"dlopen-DYLD_FALLBACK_LIBRARY_PATH\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @RTLD_LAZY
%4 = tail call i8* @dlopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @FAIL(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %2
%9 = tail call i32 @PASS(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
}