#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;
int MAP_FIXED;
int MAP_PRIVATE;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
void *mmap(void *, int, int /*<<< orphan*/, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  void *Map = mmap((void *)0x0000016000000000ULL, 0x1000, PROT_READ,
                   MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
  if (Map == (void *)-1)
    fprintf(stderr, "map failed\n");
  else
    fprintf(stderr, "mapped %p\n", Map);
  Map = mmap((void *)0x0000016000000000ULL, 0x1000, PROT_READ,
             MAP_ANON | MAP_PRIVATE, -1, 0);
  fprintf(stderr, "mapped %p\n", Map);
  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    0x2ebb(%rip),%rax
mov    (%rax),%edx
mov    0x2e8a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e79(%rip),%rax
or     (%rax),%ecx
mov    0x2e68(%rip),%rax
or     (%rax),%ecx
movabs $0x16000000000,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x18(%rbp)
jne    11a8 <main+0x88>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11c3 <main+0xa3>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
mov    0x2dfd(%rip),%rax
mov    (%rax),%ecx
mov    0x2dec(%rip),%rax
or     (%rax),%ecx
movabs $0x16000000000,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
movabs $0x16000000000,%r14
mov    0x2ebe(%rip),%r12
mov    0x2e8f(%rip),%r15
mov    0x2e80(%rip),%r13
mov    0x0(%r13),%ecx
or     (%r15),%ecx
mov    (%r12),%edx
mov    0x2e66(%rip),%rax
or     (%rax),%ecx
mov    %r14,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
cmp    $0xffffffffffffffff,%rax
je     1194 <main+0x74>
lea    0xe84(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a2 <main+0x82>
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r12),%edx
mov    0x0(%r13),%ecx
or     (%r15),%ecx
mov    %r14,%rdi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    (%rbx),%edi
lea    0xe40(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@MAP_ANON = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FIXED = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"map failed\0A\00"
@.str.1 = [11 x i8] c"mapped %p\0A\00"
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* @PROT_READ
%8 = load i32, i32* @MAP_ANON
%9 = load i32, i32* @MAP_PRIVATE
%10 = or i32 %8, %9
%11 = load i32, i32* @MAP_FIXED
%12 = or i32 %10, %11
%13 = call i8* @mmap(i8* inttoptr (i64 1511828488192 to i8*), i32 4096, i32 %7, i32 %12, i32 -1, i32 0)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = icmp eq i8* %14, inttoptr (i64 -1 to i8*)
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %23
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %6
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16
%24 = load i32, i32* @PROT_READ
%25 = load i32, i32* @MAP_ANON
%26 = load i32, i32* @MAP_PRIVATE
%27 = or i32 %25, %26
%28 = call i8* @mmap(i8* inttoptr (i64 1511828488192 to i8*), i32 4096, i32 %24, i32 %27, i32 -1, i32 0)
store i8* %28, i8** %6
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %6
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %30)
ret i32 0
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@MAP_ANON = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FIXED = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"map failed\0A\00"
@.str.1 = [11 x i8] c"mapped %p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @MAP_ANON
%5 = load i32, i32* @MAP_PRIVATE
%6 = or i32 %5, %4
%7 = load i32, i32* @MAP_FIXED
%8 = or i32 %6, %7
%9 = tail call i8* @mmap(i8* inttoptr (i64 1511828488192 to i8*), i32 4096, i32 %3, i32 %8, i32 -1, i32 0)
%10 = icmp eq i8* %9, inttoptr (i64 -1 to i8*)
%11 = load i32, i32* @stderr
br i1 %10, label %12, label %14
12: ; preds = %2
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %2
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %16
16: ; preds = %14, %12
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @MAP_ANON
%19 = load i32, i32* @MAP_PRIVATE
%20 = or i32 %19, %18
%21 = tail call i8* @mmap(i8* inttoptr (i64 1511828488192 to i8*), i32 4096, i32 %17, i32 %20, i32 -1, i32 0)
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %21)
ret i32 0
}