#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_PRIVATE;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
void *mmap(int /*<<< orphan*/, size_t, int, int, int, int /*<<< orphan*/);
int dcAllocWX(size_t size, void **pp) {
  void *p = mmap(0, size, PROT_EXEC | PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANON, -1, 0);
  if (p == ((void *)-1))
    return -1;
  *pp = p;
  return 0;
}


x86 assembly (clang, -O0):
<dcAllocWX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2eb5(%rip),%rax
mov    (%rax),%edx
mov    0x2ec4(%rip),%rax
or     (%rax),%edx
mov    0x2e93(%rip),%rax
or     (%rax),%edx
mov    0x2e7a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e79(%rip),%rax
or     (%rax),%ecx
xor    %r9d,%r9d
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x20(%rbp)
jne    1183 <dcAllocWX+0x73>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <dcAllocWX+0x85>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcAllocWX>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    0x2ec0(%rip),%rax
mov    0x2ed1(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e9e(%rip),%rax
or     (%rax),%edx
mov    0x2e85(%rip),%rax
mov    0x2e86(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    $0xffffffff,%ebp
xor    %edi,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     1166 <dcAllocWX+0x56>
mov    %rax,(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@PROT_EXEC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
define i32 @dcAllocWX(i64 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8**
%6 = alloca i8*
store i64 %0, i64* %4
store i8** %1, i8*** %5
%7 = load i64, i64* %4
%8 = load i32, i32* @PROT_EXEC
%9 = load i32, i32* @PROT_READ
%10 = or i32 %8, %9
%11 = load i32, i32* @PROT_WRITE
%12 = or i32 %10, %11
%13 = load i32, i32* @MAP_PRIVATE
%14 = load i32, i32* @MAP_ANON
%15 = or i32 %13, %14
%16 = call i8* @mmap(i32 0, i64 %7, i32 %12, i32 %15, i32 -1, i32 0)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, inttoptr (i64 -1 to i8*)
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 -1, i32* %3
br label %23
20: ; preds = %2
%21 = load i8*, i8** %6
%22 = load i8**, i8*** %5
store i8* %21, i8** %22
store i32 0, i32* %3
br label %23
23: ; preds = %20, %19
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@PROT_EXEC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
define i32 @dcAllocWX(i64 %0, i8** nocapture writeonly %1) {
%3 = load i32, i32* @PROT_EXEC
%4 = load i32, i32* @PROT_READ
%5 = or i32 %4, %3
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %5, %6
%8 = load i32, i32* @MAP_PRIVATE
%9 = load i32, i32* @MAP_ANON
%10 = or i32 %9, %8
%11 = tail call i8* @mmap(i32 0, i64 %0, i32 %7, i32 %10, i32 -1, i32 0)
%12 = icmp eq i8* %11, inttoptr (i64 -1 to i8*)
br i1 %12, label %14, label %13
13: ; preds = %2
store i8* %11, i8** %1
br label %14
14: ; preds = %2, %13
%15 = phi i32 [ 0, %13 ], [ -1, %2 ]
ret i32 %15
}