#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 /*<<< orphan*/ FAIL(char *);
int /*<<< orphan*/ PASS(char *);
int /*<<< orphan*/ RTLD_NOLOAD;
void *dlopen(char const *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  const char *path = argv[1];
  void *handle = dlopen(path, RTLD_NOLOAD);
  if (handle != NULL)
    FAIL("dlopen-RTLD_NOLOAD-fallback, dlopen(% RTLD_NOLOAD) should have "
         "failed");
  else
    PASS("dlopen-RTLD_NOLOAD-fallback");
  return 0;
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1030 <dlopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1184 <main+0x54>
lea    0xe86(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1190 <main+0x60>
lea    0xebb(%rip),%rdi
call   1040 <PASS@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
call   1030 <dlopen@plt>
test   %rax,%rax
je     1156 <main+0x26>
lea    0xeb1(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1162 <main+0x32>
lea    0xee9(%rip),%rdi
call   1040 <PASS@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@RTLD_NOLOAD = global i32 0
@.str = [70 x i8] c"dlopen-RTLD_NOLOAD-fallback, dlopen(% RTLD_NOLOAD) should have failed\00"
@.str.1 = [28 x i8] c"dlopen-RTLD_NOLOAD-fallback\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i32, i32* @RTLD_NOLOAD
%13 = call i8* @dlopen(i8* %11, i32 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @FAIL(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = call i32 @PASS(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret i32 0
}

LLVM IR (-O2):
@RTLD_NOLOAD = global i32 0
@.str = [70 x i8] c"dlopen-RTLD_NOLOAD-fallback, dlopen(% RTLD_NOLOAD) should have failed\00"
@.str.1 = [28 x i8] c"dlopen-RTLD_NOLOAD-fallback\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @RTLD_NOLOAD
%6 = tail call i8* @dlopen(i8* %4, i32 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @FAIL(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = tail call i32 @PASS(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
ret i32 0
}