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


x86 assembly (clang, -O0):
<mmap_no_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
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3039,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rsi
lea    0xe53(%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 0x3e8(%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    $0x3039,%edx
call   1050 <memset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmap_no_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
xor    %edi,%edi
mov    $0x3039,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e3c(%rip),%rax
xor    %edi,%edi
cmp    (%rax),%rbx
setne  %dil
call   1060 <assert@plt>
lea    0xe67(%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,0x3e8(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    $0x3039,%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_no_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(i32* null, i32 12345, 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 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %1
%17 = getelementptr i8, i8* %16, i64 10
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i8*, i8** %1
%24 = getelementptr i8, i8* %23, i64 1000
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8*, i8** %1
%31 = call i32 @memset(i8* %30, i32 -1, i32 12345)
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_no_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(i32* null, i32 12345, 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 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %7)
%13 = getelementptr i8, i8* %7, i64 10
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = getelementptr i8, i8* %7, i64 1000
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32 @memset(i8* %7, i32 -1, i32 12345)
ret void
}