#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;
void *MAP_FAILED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ die(char *);
void *mmap(int /*<<< orphan*/ *, int, int, int, int, int /*<<< orphan*/);
void *setup_stack() {
  void *m = mmap(NULL, 512 * 1024 * 1024, PROT_READ | PROT_WRITE,
                 MAP_PRIVATE | MAP_ANON, -1, 0);
  if (m == MAP_FAILED) {
    die("setup_stack");
  }
  return m;
}


x86 assembly (clang, -O0):
<setup_stack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edx
mov    0x2ea0(%rip),%rax
or     (%rax),%edx
mov    0x2e87(%rip),%rax
mov    (%rax),%ecx
mov    0x2e86(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x20000000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
jne    1187 <setup_stack+0x67>
lea    0xe7e(%rip),%rdi
call   1040 <die@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_stack>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e8e(%rip),%rax
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x20000000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e5c(%rip),%rax
cmp    (%rax),%rbx
jne    1175 <setup_stack+0x55>
lea    0xe90(%rip),%rdi
call   1040 <die@plt>
mov    %rbx,%rax
pop    %rbx
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_FAILED = global i8* null
@.str = [12 x i8] c"setup_stack\00"
define i8* @setup_stack() {
%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_PRIVATE
%6 = load i32, i32* @MAP_ANON
%7 = or i32 %5, %6
%8 = call i8* @mmap(i32* null, i32 536870912, i32 %4, i32 %7, i32 -1, i32 0)
store i8* %8, i8** %1
%9 = load i8*, i8** %1
%10 = load i8*, i8** @MAP_FAILED
%11 = icmp eq i8* %9, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = load i8*, i8** %1
ret i8* %15
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MAP_FAILED = global i8* null
@.str = [12 x i8] c"setup_stack\00"
define i8* @setup_stack() {
%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 = tail call i8* @mmap(i32* null, i32 536870912, i32 %3, i32 %6, i32 -1, i32 0)
%8 = load i8*, i8** @MAP_FAILED
%9 = icmp eq i8* %7, %8
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
ret i8* %7
}