#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_command_queue;

/* Variables and functions */
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ CL_TRUE;
int /*<<< orphan*/ assert(int);
scalar_t__ clEnqueueWriteBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/, int,
                                float *, int /*<<< orphan*/,
                                int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int WriteToGPU(cl_command_queue cmd_q, cl_mem buf_dev, float *buf_host,
               int size) {
  cl_int status = clEnqueueWriteBuffer(cmd_q, buf_dev, CL_TRUE, 0, size,
                                       buf_host, 0, NULL, NULL);
  assert(status == CL_SUCCESS);
  return 0;
}


x86 assembly (clang, -O0):
<WriteToGPU>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1040 <clEnqueueWriteBuffer@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteToGPU>:
sub    $0x18,%rsp
mov    %ecx,%r8d
mov    %rdx,%r9
mov    0x2eb7(%rip),%rax
mov    (%rax),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
xor    %ecx,%ecx
call   1040 <clEnqueueWriteBuffer@plt>
mov    0x2e88(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@CL_TRUE = global i32 0
@CL_SUCCESS = global i64 0
define i32 @WriteToGPU(i32 %0, i32 %1, float* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float*
%8 = alloca i32
%9 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store float* %2, float** %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i32, i32* @CL_TRUE
%13 = load i32, i32* %8
%14 = load float*, float** %7
%15 = call i64 @clEnqueueWriteBuffer(i32 %10, i32 %11, i32 %12, i32 0, i32 %13, float* %14, i32 0, i32* null, i32* null)
store i64 %15, i64* %9
%16 = load i64, i64* %9
%17 = load i64, i64* @CL_SUCCESS
%18 = icmp eq i64 %16, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret i32 0
}

LLVM IR (-O2):
@CL_TRUE = global i32 0
@CL_SUCCESS = global i64 0
define i32 @WriteToGPU(i32 %0, i32 %1, float* %2, i32 %3) {
%5 = load i32, i32* @CL_TRUE
%6 = tail call i64 @clEnqueueWriteBuffer(i32 %0, i32 %1, i32 %5, i32 0, i32 %3, float* %2, i32 0, i32* null, i32* null)
%7 = load i64, i64* @CL_SUCCESS
%8 = icmp eq i64 %6, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
ret i32 0
}