#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 /*<<< orphan*/ fail(char *);
void *mmap(void *, size_t, int, int, int, int /*<<< orphan*/);
void os_init(int argc, char **argv, void *data, size_t data_size) {
  if (mmap(data, data_size, PROT_READ | PROT_WRITE,
           MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data)
    fail("mmap of data segment failed");
}


x86 assembly (clang, -O0):
<os_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2eb2(%rip),%rax
mov    (%rax),%edx
mov    0x2e89(%rip),%rax
or     (%rax),%edx
mov    0x2e78(%rip),%rax
mov    (%rax),%ecx
mov    0x2e67(%rip),%rax
or     (%rax),%ecx
mov    0x2e56(%rip),%rax
or     (%rax),%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    -0x18(%rbp),%rax
je     1190 <os_init+0x70>
lea    0xe75(%rip),%rdi
call   1030 <fail@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_init>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    0x2ea9(%rip),%rsi
mov    (%rsi),%r8d
or     (%rax),%r8d
mov    0x2e94(%rip),%rsi
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
or     (%rsi),%eax
mov    %rdx,%rbx
mov    0x2e6f(%rip),%rdx
or     (%rdx),%eax
mov    %rbx,%rdi
mov    %rcx,%rsi
mov    %r8d,%edx
mov    %eax,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    %rbx,%rax
je     117e <os_init+0x5e>
lea    0xe88(%rip),%rdi
pop    %rbx
jmp    1030 <fail@plt>
pop    %rbx
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FIXED = global i32 0
@.str = [28 x i8] c"mmap of data segment failed\00"
define void @os_init(i32 %0, i8** %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i64
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i8*, i8** %7
%10 = load i64, i64* %8
%11 = load i32, i32* @PROT_READ
%12 = load i32, i32* @PROT_WRITE
%13 = or i32 %11, %12
%14 = load i32, i32* @MAP_ANON
%15 = load i32, i32* @MAP_PRIVATE
%16 = or i32 %14, %15
%17 = load i32, i32* @MAP_FIXED
%18 = or i32 %16, %17
%19 = call i8* @mmap(i8* %9, i64 %10, i32 %13, i32 %18, i32 -1, i32 0)
%20 = load i8*, i8** %7
%21 = icmp ne i8* %19, %20
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = call i32 @fail(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %4
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_FIXED = global i32 0
@.str = [28 x i8] c"mmap of data segment failed\00"
define void @os_init(i32 %0, i8** nocapture readnone %1, i8* %2, i64 %3) {
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %6, %5
%8 = load i32, i32* @MAP_ANON
%9 = load i32, i32* @MAP_PRIVATE
%10 = or i32 %9, %8
%11 = load i32, i32* @MAP_FIXED
%12 = or i32 %10, %11
%13 = tail call i8* @mmap(i8* %2, i64 %3, i32 %7, i32 %12, i32 -1, i32 0)
%14 = icmp eq i8* %13, %2
br i1 %14, label %17, label %15
15: ; preds = %4
%16 = tail call i32 @fail(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %4
ret void
}