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

/* Variables and functions */
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *clCreateCommandQueue(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/, scalar_t__ *);
int CreateCommandQueue(cl_command_queue *cmd_q, cl_context ctx,
                       cl_device_id dev) {
  cl_int status = 0;
  *cmd_q = clCreateCommandQueue(ctx, dev, 0, &status);
  assert(status == CL_SUCCESS);
  assert(*cmd_q != NULL);
  return 0;
}


x86 assembly (clang, -O0):
<CreateCommandQueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
xor    %edx,%edx
lea    -0x18(%rbp),%rcx
call   1030 <clCreateCommandQueue@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x2e80(%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>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateCommandQueue>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rcx
mov    %esi,%edi
mov    %edx,%esi
xor    %edx,%edx
call   1030 <clCreateCommandQueue@plt>
mov    %rax,(%rbx)
mov    0x8(%rsp),%rax
mov    0x2e90(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@CL_SUCCESS = global i64 0
define i32 @CreateCommandQueue(i32** nocapture %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%6 = call i32* @clCreateCommandQueue(i32 %1, i32 %2, i32 0, i64* %4)
store i32* %6, i32** %0
%7 = load i64, i64* %4
%8 = load i64, i64* @CL_SUCCESS
%9 = icmp eq i64 %7, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %0
%13 = icmp ne i32* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
ret i32 0
}