#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 MAP_ANONYMOUS;
char *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
char *mmap(void *, unsigned long, int, int, int, int /*<<< orphan*/);
int validate_lower_address_hint(void) {
  char *ptr;
  ptr = mmap((void *)(1UL << 45), 17179869184UL, PROT_READ | PROT_WRITE,
             MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (ptr == MAP_FAILED)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<validate_lower_address_hint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ed9(%rip),%rax
mov    (%rax),%edx
mov    0x2ea8(%rip),%rax
or     (%rax),%edx
mov    0x2e97(%rip),%rax
mov    (%rax),%ecx
mov    0x2ea6(%rip),%rax
or     (%rax),%ecx
movabs $0x200000000000,%rdi
movabs $0x400000000,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
jne    1182 <validate_lower_address_hint+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1189 <validate_lower_address_hint+0x79>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_lower_address_hint>:
push   %rax
mov    0x2ee0(%rip),%rax
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e9e(%rip),%rax
mov    0x2eaf(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
movabs $0x200000000000,%rdi
movabs $0x400000000,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    0x2e62(%rip),%rdx
xor    %ecx,%ecx
cmp    (%rdx),%rax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FAILED = global i8* null
define i32 @validate_lower_address_hint() {
%1 = alloca i32
%2 = alloca i8*
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %3, %4
%6 = load i32, i32* @MAP_PRIVATE
%7 = load i32, i32* @MAP_ANONYMOUS
%8 = or i32 %6, %7
%9 = call i8* @mmap(i8* inttoptr (i64 35184372088832 to i8*), i64 17179869184, i32 %5, i32 %8, i32 -1, i32 0)
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = load i8*, i8** @MAP_FAILED
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 0, i32* %1
br label %15
14: ; preds = %0
store i32 1, i32* %1
br label %15
15: ; preds = %14, %13
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FAILED = global i8* null
define i32 @validate_lower_address_hint() {
%1 = load i32, i32* @PROT_READ
%2 = load i32, i32* @PROT_WRITE
%3 = or i32 %2, %1
%4 = load i32, i32* @MAP_PRIVATE
%5 = load i32, i32* @MAP_ANONYMOUS
%6 = or i32 %5, %4
%7 = tail call i8* @mmap(i8* inttoptr (i64 35184372088832 to i8*), i64 17179869184, i32 %3, i32 %6, i32 -1, i32 0)
%8 = load i8*, i8** @MAP_FAILED
%9 = icmp ne i8* %7, %8
%10 = zext i1 %9 to i32
ret i32 %10
}