#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;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ handle_fatal_error(char *);
void *mmap(int /*<<< orphan*/, int, int, int, int, int /*<<< orphan*/);
void *create_shared_memory() {
  void *shared_memory = mmap(0, (5 + 2) * sizeof(int), PROT_READ | PROT_WRITE,
                             MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  if (shared_memory == (void *)-1) {
    handle_fatal_error("Error allocating shared memory using mmap!\n");
  }
  return shared_memory;
}


x86 assembly (clang, -O0):
<create_shared_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edx
mov    0x2e90(%rip),%rax
or     (%rax),%edx
mov    0x2ea7(%rip),%rax
mov    (%rax),%ecx
mov    0x2e8e(%rip),%rax
or     (%rax),%ecx
xor    %r9d,%r9d
mov    $0x1c,%esi
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x8(%rbp)
jne    1183 <create_shared_memory+0x63>
lea    0xe82(%rip),%rdi
call   1040 <handle_fatal_error@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_shared_memory>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2eae(%rip),%rax
mov    0x2e97(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x1c,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
cmp    $0xffffffffffffffff,%rax
jne    116f <create_shared_memory+0x4f>
lea    0xe96(%rip),%rdi
call   1040 <handle_fatal_error@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [44 x i8] c"Error allocating shared memory using mmap!\0A\00"
define i8* @create_shared_memory() {
%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_SHARED
%6 = load i32, i32* @MAP_ANONYMOUS
%7 = or i32 %5, %6
%8 = call i8* @mmap(i32 0, i32 28, i32 %4, i32 %7, i32 -1, i32 0)
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, inttoptr (i64 -1 to i8*)
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @handle_fatal_error(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i8*, i8** %1
ret i8* %14
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [44 x i8] c"Error allocating shared memory using mmap!\0A\00"
define i8* @create_shared_memory() {
%1 = load i32, i32* @PROT_READ
%2 = load i32, i32* @PROT_WRITE
%3 = or i32 %2, %1
%4 = load i32, i32* @MAP_SHARED
%5 = load i32, i32* @MAP_ANONYMOUS
%6 = or i32 %5, %4
%7 = tail call i8* @mmap(i32 0, i32 28, i32 %3, i32 %6, i32 -1, i32 0)
%8 = icmp eq i8* %7, inttoptr (i64 -1 to i8*)
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @handle_fatal_error(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
ret i8* %7
}