#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_PRIVATE;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ buf_init(void *, int);
scalar_t__ mmap(int /*<<< orphan*/, int, int, int, int, int /*<<< orphan*/);
scalar_t__ processor_bind(int);
void *buf_create(int cpu_alloc) {
  void *buf;
  if (processor_bind(cpu_alloc) != 0) {
    return (NULL);
  }
  buf = (void *)mmap(0, 256 * 1024 * 1024, PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (buf != NULL) {
    buf_init(buf, 256 * 1024 * 1024);
  }
  return (buf);
}


x86 assembly (clang, -O0):
<buf_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <processor_bind@plt>
cmp    $0x0,%rax
je     115a <buf_create+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    11c2 <buf_create+0x92>
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
mov    0x2e5e(%rip),%rax
or     (%rax),%edx
mov    0x2e65(%rip),%rax
or     (%rax),%edx
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
mov    0x2e5b(%rip),%rax
or     (%rax),%ecx
xor    %r9d,%r9d
mov    $0x10000000,%esi
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ba <buf_create+0x8a>
mov    -0x18(%rbp),%rdi
mov    $0x10000000,%esi
call   1050 <buf_init@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buf_create>:
push   %rbx
call   1040 <processor_bind@plt>
test   %rax,%rax
je     113f <buf_create+0xf>
xor    %ebx,%ebx
jmp    1196 <buf_create+0x66>
mov    0x2eb2(%rip),%rax
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e80(%rip),%rax
or     (%rax),%edx
mov    0x2e5f(%rip),%rax
mov    0x2e78(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x10000000,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1196 <buf_create+0x66>
mov    %rbx,%rdi
mov    $0x10000000,%esi
call   1050 <buf_init@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
define i8* @buf_create(i32 %0) {
%2 = tail call i64 @processor_bind(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %6, %5
%8 = load i32, i32* @PROT_EXEC
%9 = or i32 %7, %8
%10 = load i32, i32* @MAP_PRIVATE
%11 = load i32, i32* @MAP_ANONYMOUS
%12 = or i32 %11, %10
%13 = tail call i64 @mmap(i32 0, i32 268435456, i32 %9, i32 %12, i32 -1, i32 0)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %18, label %16
16: ; preds = %4
%17 = tail call i32 @buf_init(i8* %14, i32 268435456)
br label %18
18: ; preds = %4, %16, %1
%19 = phi i8* [ null, %1 ], [ %14, %16 ], [ %14, %4 ]
ret i8* %19
}