#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 */
typedef int cl_mem;
typedef scalar_t__ cl_int;
typedef int /*<<< orphan*/ cl_context;

/* Variables and functions */
int CL_MEM_READ_WRITE;
int CL_MEM_USE_HOST_PTR;
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int clCreateBuffer(int /*<<< orphan*/, int, size_t const, void *, scalar_t__ *);
int CreateBuffer(cl_mem *a_dev, cl_mem *b_dev, cl_mem *c_dev_gpu,
                 cl_mem *c_dev_cpu, cl_context ctx, void *a_host, void *b_host,
                 void *c_host_gpu, void *c_host_cpu, const size_t size) {
  cl_int status = 0;
  *a_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, size,
                          a_host, &status);
  assert(status == CL_SUCCESS);
  *b_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, size,
                          b_host, &status);
  assert(status == CL_SUCCESS);
  *c_dev_gpu = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
                              size, c_host_gpu, &status);
  assert(status == CL_SUCCESS);
  *c_dev_cpu = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
                              size, c_host_cpu, &status);
  assert(status == CL_SUCCESS);
  assert(*a_dev);
  assert(*b_dev);
  assert(*c_dev_gpu);
  assert(*c_dev_cpu);
  return 0;
}


x86 assembly (clang, -O0):
<CreateBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
mov    0x2e75(%rip),%rax
or     (%rax),%esi
mov    0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x24(%rbp),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
mov    0x2e2c(%rip),%rax
or     (%rax),%esi
mov    0x28(%rbp),%rdx
mov    0x10(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x24(%rbp),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    0x2de3(%rip),%rax
or     (%rax),%esi
mov    0x28(%rbp),%rdx
mov    0x18(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x2dad(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x24(%rbp),%edi
mov    0x2dab(%rip),%rax
mov    (%rax),%esi
mov    0x2d9a(%rip),%rax
or     (%rax),%esi
mov    0x28(%rbp),%rdx
mov    0x20(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x2d64(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%ebp
mov    %rcx,0x20(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbx
mov    %rdi,0x18(%rsp)
mov    0x78(%rsp),%rdx
movq   $0x0,0x8(%rsp)
mov    0x2e8a(%rip),%rax
mov    0x2e7b(%rip),%r12
mov    (%r12),%esi
or     (%rax),%esi
lea    0x8(%rsp),%r13
mov    %r8d,%edi
mov    %r9,%rcx
mov    %r13,%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rax
mov    0x2e44(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1040 <assert@plt>
mov    (%r12),%esi
mov    0x2e43(%rip),%rbx
or     (%rbx),%esi
mov    %ebp,%edi
mov    0x78(%rsp),%r12
mov    %r12,%rdx
mov    0x60(%rsp),%rcx
mov    %r13,%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,(%r15)
mov    0x8(%rsp),%rax
xor    %edi,%edi
mov    0x2e01(%rip),%r15
cmp    (%r15),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
or     (%rbx),%esi
mov    %ebp,%edi
mov    %r12,%rdx
mov    0x68(%rsp),%rcx
mov    %r13,%r8
call   1030 <clCreateBuffer@plt>
mov    %eax,(%r14)
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
mov    0x2dca(%rip),%rax
or     (%rax),%esi
mov    %ebp,%edi
mov    %r12,%rdx
mov    0x70(%rsp),%rcx
mov    %r13,%r8
call   1030 <clCreateBuffer@plt>
mov    0x20(%rsp),%rbp
mov    %eax,0x0(%rbp)
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x18(%rsp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
mov    0x10(%rsp),%rax
mov    (%rax),%edi
call   1040 <assert@plt>
mov    (%r14),%edi
call   1040 <assert@plt>
mov    0x0(%rbp),%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CL_MEM_READ_WRITE = global i32 0
@CL_MEM_USE_HOST_PTR = global i32 0
@CL_SUCCESS = global i64 0
define i32 @CreateBuffer(i32* %0, i32* %1, i32* %2, i32* %3, i32 %4, i8* %5, i8* %6, i8* %7, i8* %8, i64 %9) {
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
store i32* %0, i32** %11
store i32* %1, i32** %12
store i32* %2, i32** %13
store i32* %3, i32** %14
store i32 %4, i32* %15
store i8* %5, i8** %16
store i8* %6, i8** %17
store i8* %7, i8** %18
store i8* %8, i8** %19
store i64 %9, i64* %20
store i64 0, i64* %21
%22 = load i32, i32* %15
%23 = load i32, i32* @CL_MEM_READ_WRITE
%24 = load i32, i32* @CL_MEM_USE_HOST_PTR
%25 = or i32 %23, %24
%26 = load i64, i64* %20
%27 = load i8*, i8** %16
%28 = call i32 @clCreateBuffer(i32 %22, i32 %25, i64 %26, i8* %27, i64* %21)
%29 = load i32*, i32** %11
store i32 %28, i32* %29
%30 = load i64, i64* %21
%31 = load i64, i64* @CL_SUCCESS
%32 = icmp eq i64 %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %15
%36 = load i32, i32* @CL_MEM_READ_WRITE
%37 = load i32, i32* @CL_MEM_USE_HOST_PTR
%38 = or i32 %36, %37
%39 = load i64, i64* %20
%40 = load i8*, i8** %17
%41 = call i32 @clCreateBuffer(i32 %35, i32 %38, i64 %39, i8* %40, i64* %21)
%42 = load i32*, i32** %12
store i32 %41, i32* %42
%43 = load i64, i64* %21
%44 = load i64, i64* @CL_SUCCESS
%45 = icmp eq i64 %43, %44
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* %15
%49 = load i32, i32* @CL_MEM_READ_WRITE
%50 = load i32, i32* @CL_MEM_USE_HOST_PTR
%51 = or i32 %49, %50
%52 = load i64, i64* %20
%53 = load i8*, i8** %18
%54 = call i32 @clCreateBuffer(i32 %48, i32 %51, i64 %52, i8* %53, i64* %21)
%55 = load i32*, i32** %13
store i32 %54, i32* %55
%56 = load i64, i64* %21
%57 = load i64, i64* @CL_SUCCESS
%58 = icmp eq i64 %56, %57
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i32, i32* %15
%62 = load i32, i32* @CL_MEM_READ_WRITE
%63 = load i32, i32* @CL_MEM_USE_HOST_PTR
%64 = or i32 %62, %63
%65 = load i64, i64* %20
%66 = load i8*, i8** %19
%67 = call i32 @clCreateBuffer(i32 %61, i32 %64, i64 %65, i8* %66, i64* %21)
%68 = load i32*, i32** %14
store i32 %67, i32* %68
%69 = load i64, i64* %21
%70 = load i64, i64* @CL_SUCCESS
%71 = icmp eq i64 %69, %70
%72 = zext i1 %71 to i32
%73 = call i32 @assert(i32 %72)
%74 = load i32*, i32** %11
%75 = load i32, i32* %74
%76 = call i32 @assert(i32 %75)
%77 = load i32*, i32** %12
%78 = load i32, i32* %77
%79 = call i32 @assert(i32 %78)
%80 = load i32*, i32** %13
%81 = load i32, i32* %80
%82 = call i32 @assert(i32 %81)
%83 = load i32*, i32** %14
%84 = load i32, i32* %83
%85 = call i32 @assert(i32 %84)
ret i32 0
}

LLVM IR (-O2):
@CL_MEM_READ_WRITE = global i32 0
@CL_MEM_USE_HOST_PTR = global i32 0
@CL_SUCCESS = global i64 0
define i32 @CreateBuffer(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, i32 %4, i8* %5, i8* %6, i8* %7, i8* %8, i64 %9) {
%11 = alloca i64
%12 = bitcast i64* %11 to i8*
store i64 0, i64* %11
%13 = load i32, i32* @CL_MEM_READ_WRITE
%14 = load i32, i32* @CL_MEM_USE_HOST_PTR
%15 = or i32 %14, %13
%16 = call i32 @clCreateBuffer(i32 %4, i32 %15, i64 %9, i8* %5, i64* %11)
store i32 %16, i32* %0
%17 = load i64, i64* %11
%18 = load i64, i64* @CL_SUCCESS
%19 = icmp eq i64 %17, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* @CL_MEM_READ_WRITE
%23 = load i32, i32* @CL_MEM_USE_HOST_PTR
%24 = or i32 %23, %22
%25 = call i32 @clCreateBuffer(i32 %4, i32 %24, i64 %9, i8* %6, i64* %11)
store i32 %25, i32* %1
%26 = load i64, i64* %11
%27 = load i64, i64* @CL_SUCCESS
%28 = icmp eq i64 %26, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* @CL_MEM_READ_WRITE
%32 = load i32, i32* @CL_MEM_USE_HOST_PTR
%33 = or i32 %32, %31
%34 = call i32 @clCreateBuffer(i32 %4, i32 %33, i64 %9, i8* %7, i64* %11)
store i32 %34, i32* %2
%35 = load i64, i64* %11
%36 = load i64, i64* @CL_SUCCESS
%37 = icmp eq i64 %35, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i32, i32* @CL_MEM_READ_WRITE
%41 = load i32, i32* @CL_MEM_USE_HOST_PTR
%42 = or i32 %41, %40
%43 = call i32 @clCreateBuffer(i32 %4, i32 %42, i64 %9, i8* %8, i64* %11)
store i32 %43, i32* %3
%44 = load i64, i64* %11
%45 = load i64, i64* @CL_SUCCESS
%46 = icmp eq i64 %44, %45
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32, i32* %0
%50 = call i32 @assert(i32 %49)
%51 = load i32, i32* %1
%52 = call i32 @assert(i32 %51)
%53 = load i32, i32* %2
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* %3
%56 = call i32 @assert(i32 %55)
ret i32 0
}