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

/* Variables and functions */
int /*<<< orphan*/ CL_MEM_READ_WRITE;
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                   size_t const, int /*<<< orphan*/ *,
                                   scalar_t__ *);
int CreateBuffer(cl_mem *a_dev, cl_mem *b_dev, cl_mem *c_dev, cl_context ctx,
                 const size_t size) {
  cl_int status = 0;
  *a_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, size, NULL, &status);
  assert(status == CL_SUCCESS);
  *b_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, size, NULL, &status);
  assert(status == CL_SUCCESS);
  *c_dev = clCreateBuffer(ctx, CL_MEM_READ_WRITE, size, NULL, &status);
  assert(status == CL_SUCCESS);
  assert(*a_dev != NULL);
  assert(*b_dev != NULL);
  assert(*c_dev != NULL);
  return 0;
}


x86 assembly (clang, -O0):
<CreateBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x1c(%rbp),%edi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x1c(%rbp),%edi
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
call   1030 <clCreateBuffer@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x2ddf(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateBuffer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %ecx,%ebp
mov    %rdx,0x10(%rsp)
mov    %rsi,%r13
mov    %rdi,%r15
movq   $0x0,0x8(%rsp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%r14
mov    %ecx,%edi
mov    %r8,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
call   1030 <clCreateBuffer@plt>
mov    %rax,(%r15)
mov    0x8(%rsp),%rax
mov    0x2e65(%rip),%r12
xor    %edi,%edi
cmp    (%r12),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
call   1030 <clCreateBuffer@plt>
mov    %rax,0x0(%r13)
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    (%r12),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %rbx,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
call   1030 <clCreateBuffer@plt>
mov    0x10(%rsp),%rbx
mov    %rax,(%rbx)
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    (%r12),%rax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%r15)
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0x0(%r13)
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x18,%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_SUCCESS = global i64 0
define i32 @CreateBuffer(i32** %0, i32** %1, i32** %2, i32 %3, i64 %4) {
%6 = alloca i32**
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
store i32** %0, i32*** %6
store i32** %1, i32*** %7
store i32** %2, i32*** %8
store i32 %3, i32* %9
store i64 %4, i64* %10
store i64 0, i64* %11
%12 = load i32, i32* %9
%13 = load i32, i32* @CL_MEM_READ_WRITE
%14 = load i64, i64* %10
%15 = call i32* @clCreateBuffer(i32 %12, i32 %13, i64 %14, i32* null, i64* %11)
%16 = load i32**, i32*** %6
store i32* %15, i32** %16
%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* %9
%23 = load i32, i32* @CL_MEM_READ_WRITE
%24 = load i64, i64* %10
%25 = call i32* @clCreateBuffer(i32 %22, i32 %23, i64 %24, i32* null, i64* %11)
%26 = load i32**, i32*** %7
store i32* %25, i32** %26
%27 = load i64, i64* %11
%28 = load i64, i64* @CL_SUCCESS
%29 = icmp eq i64 %27, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %9
%33 = load i32, i32* @CL_MEM_READ_WRITE
%34 = load i64, i64* %10
%35 = call i32* @clCreateBuffer(i32 %32, i32 %33, i64 %34, i32* null, i64* %11)
%36 = load i32**, i32*** %8
store i32* %35, i32** %36
%37 = load i64, i64* %11
%38 = load i64, i64* @CL_SUCCESS
%39 = icmp eq i64 %37, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i32**, i32*** %6
%43 = load i32*, i32** %42
%44 = icmp ne i32* %43, null
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i32**, i32*** %7
%48 = load i32*, i32** %47
%49 = icmp ne i32* %48, null
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i32**, i32*** %8
%53 = load i32*, i32** %52
%54 = icmp ne i32* %53, null
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
ret i32 0
}

LLVM IR (-O2):
@CL_MEM_READ_WRITE = global i32 0
@CL_SUCCESS = global i64 0
define i32 @CreateBuffer(i32** nocapture %0, i32** nocapture %1, i32** nocapture %2, i32 %3, i64 %4) {
%6 = alloca i64
%7 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%8 = load i32, i32* @CL_MEM_READ_WRITE
%9 = call i32* @clCreateBuffer(i32 %3, i32 %8, i64 %4, i32* null, i64* %6)
store i32* %9, i32** %0
%10 = load i64, i64* %6
%11 = load i64, i64* @CL_SUCCESS
%12 = icmp eq i64 %10, %11
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* @CL_MEM_READ_WRITE
%16 = call i32* @clCreateBuffer(i32 %3, i32 %15, i64 %4, i32* null, i64* %6)
store i32* %16, i32** %1
%17 = load i64, i64* %6
%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 = call i32* @clCreateBuffer(i32 %3, i32 %22, i64 %4, i32* null, i64* %6)
store i32* %23, i32** %2
%24 = load i64, i64* %6
%25 = load i64, i64* @CL_SUCCESS
%26 = icmp eq i64 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32*, i32** %0
%30 = icmp ne i32* %29, null
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32*, i32** %1
%34 = icmp ne i32* %33, null
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32*, i32** %2
%38 = icmp ne i32* %37, null
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
ret i32 0
}