#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 PROT_READ;
int PROT_WRITE;
int *mmap(void *, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int *m = mmap(0x0, 4096, PROT_READ | PROT_WRITE,
                MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
  if (m != (int *)-1)
    printf("succeeded?!\n");
  m = mmap((void *)0x1000, 4096, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
  if (m != (int *)-1)
    printf("succeeded?!\n");
  m = mmap((void *)0xa000, 4096, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
  if (m != (int *)-1)
    printf("succeeded?!\n");
  m = mmap((void *)0x10000, 4096, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
  if (m == (int *)-1)
    printf("failed?!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%edx
mov    0x2e99(%rip),%rax
or     (%rax),%edx
mov    0x2e80(%rip),%rax
mov    (%rax),%ecx
mov    0x2e7f(%rip),%rax
or     (%rax),%ecx
mov    0x2e66(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x10(%rbp)
je     1194 <main+0x74>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
mov    0x2e34(%rip),%rax
or     (%rax),%edx
mov    0x2e1b(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1a(%rip),%rax
or     (%rax),%ecx
mov    0x2e01(%rip),%rax
or     (%rax),%ecx
mov    $0x1000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x10(%rbp)
je     11fa <main+0xda>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
mov    0x2dce(%rip),%rax
or     (%rax),%edx
mov    0x2db5(%rip),%rax
mov    (%rax),%ecx
mov    0x2db4(%rip),%rax
or     (%rax),%ecx
mov    0x2d9b(%rip),%rax
or     (%rax),%ecx
mov    $0xa000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x10(%rbp)
je     1260 <main+0x140>
lea    0xda5(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
mov    0x2d68(%rip),%rax
or     (%rax),%edx
mov    0x2d4f(%rip),%rax
mov    (%rax),%ecx
mov    0x2d4e(%rip),%rax
or     (%rax),%ecx
mov    0x2d35(%rip),%rax
or     (%rax),%ecx
mov    $0x10000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x10(%rbp)
jne    12c6 <main+0x1a6>
lea    0xd4c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2ec8(%rip),%r14
mov    0x2ea1(%rip),%r12
mov    (%r12),%edx
or     (%r14),%edx
mov    0x2e83(%rip),%r15
mov    0x2e84(%rip),%rbx
mov    (%rbx),%ecx
or     (%r15),%ecx
mov    0x2e68(%rip),%r13
or     0x0(%r13),%ecx
xor    %edi,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     1183 <main+0x63>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    (%rbx),%ecx
or     (%r15),%ecx
or     0x0(%r13),%ecx
mov    $0x1000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     11bd <main+0x9d>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    (%rbx),%ecx
or     (%r15),%ecx
or     0x0(%r13),%ecx
mov    $0xa000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     11f7 <main+0xd7>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
mov    (%r12),%edx
or     (%r14),%edx
mov    (%rbx),%ecx
or     (%r15),%ecx
or     0x0(%r13),%ecx
mov    $0x10000,%edi
mov    $0x1000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
jne    1231 <main+0x111>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FIXED = global i32 0
@.str = [13 x i8] c"succeeded?!\0A\00"
@.str.1 = [10 x i8] c"failed?!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%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_ANON
%8 = or i32 %6, %7
%9 = load i32, i32* @MAP_FIXED
%10 = or i32 %8, %9
%11 = call i32* @mmap(i8* null, i32 4096, i32 %5, i32 %10, i32 -1, i32 0)
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = icmp ne i32* %12, inttoptr (i64 -1 to i32*)
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @PROT_WRITE
%19 = or i32 %17, %18
%20 = load i32, i32* @MAP_PRIVATE
%21 = load i32, i32* @MAP_ANON
%22 = or i32 %20, %21
%23 = load i32, i32* @MAP_FIXED
%24 = or i32 %22, %23
%25 = call i32* @mmap(i8* inttoptr (i64 4096 to i8*), i32 4096, i32 %19, i32 %24, i32 -1, i32 0)
store i32* %25, i32** %2
%26 = load i32*, i32** %2
%27 = icmp ne i32* %26, inttoptr (i64 -1 to i32*)
br i1 %27, label %28, label %30
28: ; preds = %16
%29 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %16
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %31, %32
%34 = load i32, i32* @MAP_PRIVATE
%35 = load i32, i32* @MAP_ANON
%36 = or i32 %34, %35
%37 = load i32, i32* @MAP_FIXED
%38 = or i32 %36, %37
%39 = call i32* @mmap(i8* inttoptr (i64 40960 to i8*), i32 4096, i32 %33, i32 %38, i32 -1, i32 0)
store i32* %39, i32** %2
%40 = load i32*, i32** %2
%41 = icmp ne i32* %40, inttoptr (i64 -1 to i32*)
br i1 %41, label %42, label %44
42: ; preds = %30
%43 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %30
%45 = load i32, i32* @PROT_READ
%46 = load i32, i32* @PROT_WRITE
%47 = or i32 %45, %46
%48 = load i32, i32* @MAP_PRIVATE
%49 = load i32, i32* @MAP_ANON
%50 = or i32 %48, %49
%51 = load i32, i32* @MAP_FIXED
%52 = or i32 %50, %51
%53 = call i32* @mmap(i8* inttoptr (i64 65536 to i8*), i32 4096, i32 %47, i32 %52, i32 -1, i32 0)
store i32* %53, i32** %2
%54 = load i32*, i32** %2
%55 = icmp eq i32* %54, inttoptr (i64 -1 to i32*)
br i1 %55, label %56, label %58
56: ; preds = %44
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %56, %44
ret i32 0
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FIXED = global i32 0
@str = [9 x i8] c"failed?!\00"
@str.4 = [12 x i8] c"succeeded?!\00"
define i32 @main() {
%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_ANON
%6 = or i32 %5, %4
%7 = load i32, i32* @MAP_FIXED
%8 = or i32 %6, %7
%9 = tail call i32* @mmap(i8* null, i32 4096, i32 %3, i32 %8, i32 -1, i32 0)
%10 = icmp eq i32* %9, inttoptr (i64 -1 to i32*)
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i32, i32* @PROT_READ
%15 = load i32, i32* @PROT_WRITE
%16 = or i32 %15, %14
%17 = load i32, i32* @MAP_PRIVATE
%18 = load i32, i32* @MAP_ANON
%19 = or i32 %18, %17
%20 = load i32, i32* @MAP_FIXED
%21 = or i32 %19, %20
%22 = tail call i32* @mmap(i8* inttoptr (i64 4096 to i8*), i32 4096, i32 %16, i32 %21, i32 -1, i32 0)
%23 = icmp eq i32* %22, inttoptr (i64 -1 to i32*)
br i1 %23, label %26, label %24
24: ; preds = %13
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %13
%27 = load i32, i32* @PROT_READ
%28 = load i32, i32* @PROT_WRITE
%29 = or i32 %28, %27
%30 = load i32, i32* @MAP_PRIVATE
%31 = load i32, i32* @MAP_ANON
%32 = or i32 %31, %30
%33 = load i32, i32* @MAP_FIXED
%34 = or i32 %32, %33
%35 = tail call i32* @mmap(i8* inttoptr (i64 40960 to i8*), i32 4096, i32 %29, i32 %34, i32 -1, i32 0)
%36 = icmp eq i32* %35, inttoptr (i64 -1 to i32*)
br i1 %36, label %39, label %37
37: ; preds = %26
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %26
%40 = load i32, i32* @PROT_READ
%41 = load i32, i32* @PROT_WRITE
%42 = or i32 %41, %40
%43 = load i32, i32* @MAP_PRIVATE
%44 = load i32, i32* @MAP_ANON
%45 = or i32 %44, %43
%46 = load i32, i32* @MAP_FIXED
%47 = or i32 %45, %46
%48 = tail call i32* @mmap(i8* inttoptr (i64 65536 to i8*), i32 4096, i32 %42, i32 %47, i32 -1, i32 0)
%49 = icmp eq i32* %48, inttoptr (i64 -1 to i32*)
br i1 %49, label %50, label %52
50: ; preds = %39
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %52
52: ; preds = %50, %39
ret i32 0
}