#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;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ getpagesize();
void *mmap(int /*<<< orphan*/ *, int /*<<< orphan*/, int, int, int,
           int /*<<< orphan*/);
void *allocate_page() {
  void *page;
  page = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE,
              MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  if (page == MAP_FAILED) {
    assert(!"mmap");
  }
  return page;
}


x86 assembly (clang, -O0):
<allocate_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <getpagesize@plt>
mov    %eax,%esi
mov    0x2eb0(%rip),%rax
mov    (%rax),%edx
mov    0x2e7f(%rip),%rax
or     (%rax),%edx
mov    0x2e86(%rip),%rax
mov    (%rax),%ecx
mov    0x2e65(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
jne    1196 <allocate_page+0x66>
xor    %edi,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocate_page>:
push   %rbx
xor    %eax,%eax
call   1050 <getpagesize@plt>
mov    0x2eb9(%rip),%rcx
mov    0x2e8a(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2e8f(%rip),%rsi
mov    0x2e70(%rip),%rcx
mov    (%rcx),%ecx
or     (%rsi),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e48(%rip),%rax
cmp    (%rax),%rbx
jne    1184 <allocate_page+0x54>
xor    %edi,%edi
call   1040 <assert@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str = [5 x i8] c"mmap\00"
define i8* @allocate_page() {
%1 = alloca i8*
%2 = call i32 (...) @getpagesize()
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %3, %4
%6 = load i32, i32* @MAP_ANONYMOUS
%7 = load i32, i32* @MAP_PRIVATE
%8 = or i32 %6, %7
%9 = call i8* @mmap(i32* null, i32 %2, i32 %5, i32 %8, i32 -1, i32 0)
store i8* %9, i8** %1
%10 = load i8*, i8** %1
%11 = load i8*, i8** @MAP_FAILED
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @assert(i32 0)
br label %15
15: ; preds = %13, %0
%16 = load i8*, i8** %1
ret i8* %16
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
define i8* @allocate_page() {
%1 = tail call i32 (...) @getpagesize()
%2 = load i32, i32* @PROT_READ
%3 = load i32, i32* @PROT_WRITE
%4 = or i32 %3, %2
%5 = load i32, i32* @MAP_ANONYMOUS
%6 = load i32, i32* @MAP_PRIVATE
%7 = or i32 %6, %5
%8 = tail call i8* @mmap(i32* null, i32 %1, i32 %4, i32 %7, i32 -1, i32 0)
%9 = load i8*, i8** @MAP_FAILED
%10 = icmp eq i8* %8, %9
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @assert(i32 0)
br label %13
13: ; preds = %11, %0
ret i8* %8
}