#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_ANON;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(void *, int, int);
void *mmap(void *, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, void *);
void mmap_with_hint(void) {
  void *addr = mmap((((void *)0x12345000)), ((99)), (PROT_READ | PROT_WRITE),
                    MAP_ANON | MAP_PRIVATE, -1, 0);
  assert(addr != MAP_FAILED);
  assert(addr >= (void *)0x12345000);
  printf("mmap returned pointer: %p\n", addr);
  assert(*(char *)(addr + 10) == 0);
  assert(*(char *)(addr + 50) == 0);
  memset(addr, -1, 99);
}


x86 assembly (clang, -O0):
<mmap_with_hint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edx
mov    0x2e80(%rip),%rax
or     (%rax),%edx
mov    0x2e6f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e5e(%rip),%rax
or     (%rax),%ecx
mov    $0x12345000,%edi
mov    $0x63,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x12345000,%eax
cmp    %rax,-0x8(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl 0xa(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
movsbl 0x32(%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x63,%edx
call   1050 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmap_with_hint>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e76(%rip),%rax
mov    0x2e67(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    $0x12345000,%edi
mov    $0x63,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e39(%rip),%rax
xor    %edi,%edi
cmp    (%rax),%rbx
setne  %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmp    $0x12345000,%rbx
setae  %dil
call   1060 <assert@plt>
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
cmpb   $0x0,0xa(%rbx)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0x0,0x32(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x63,%edx
pop    %rbx
jmp    1050 <memset@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [27 x i8] c"mmap returned pointer: %p\0A\00"
define void @mmap_with_hint() {
%1 = alloca i8*
%2 = load i32, i32* @PROT_READ
%3 = load i32, i32* @PROT_WRITE
%4 = or i32 %2, %3
%5 = load i32, i32* @MAP_ANON
%6 = load i32, i32* @MAP_PRIVATE
%7 = or i32 %5, %6
%8 = call i8* @mmap(i8* inttoptr (i64 305418240 to i8*), i32 99, i32 %4, i32 %7, i32 -1, i32 0)
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = load i8*, i8** @MAP_FAILED
%11 = icmp ne i8* %9, %10
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %1
%15 = icmp uge i8* %14, inttoptr (i64 305418240 to i8*)
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %1
%19 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %1
%21 = getelementptr i8, i8* %20, i64 10
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i8*, i8** %1
%28 = getelementptr i8, i8* %27, i64 50
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i8*, i8** %1
%35 = call i32 @memset(i8* %34, i32 -1, i32 99)
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [27 x i8] c"mmap returned pointer: %p\0A\00"
define void @mmap_with_hint() {
%1 = load i32, i32* @PROT_READ
%2 = load i32, i32* @PROT_WRITE
%3 = or i32 %2, %1
%4 = load i32, i32* @MAP_ANON
%5 = load i32, i32* @MAP_PRIVATE
%6 = or i32 %5, %4
%7 = tail call i8* @mmap(i8* inttoptr (i64 305418240 to i8*), i32 99, 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
%11 = tail call i32 @assert(i32 %10)
%12 = icmp uge i8* %7, inttoptr (i64 305418240 to i8*)
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %7)
%16 = getelementptr i8, i8* %7, i64 10
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = getelementptr i8, i8* %7, i64 50
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @memset(i8* %7, i32 -1, i32 99)
ret void
}