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

/* Variables and functions */
int /*<<< orphan*/ CL_CONTEXT_PLATFORM;
int /*<<< orphan*/ CL_DEVICE_TYPE_GPU;
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *clCreateContextFromType(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *, scalar_t__ *);
int CreateContext(cl_context *ctx, cl_platform_id platform) {
  cl_context_properties prop[3] = {CL_CONTEXT_PLATFORM,
                                   (cl_context_properties)platform, 0};
  cl_int status = 0;
  *ctx = clCreateContextFromType(prop, CL_DEVICE_TYPE_GPU, NULL, NULL, &status);
  assert(status == CL_SUCCESS);
  assert(*ctx != NULL);
  return 0;
}


x86 assembly (clang, -O0):
<CreateContext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1040 <clCreateContextFromType@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateContext>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    %esi,0x18(%rsp)
movl   $0x0,0x1c(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdi
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <clCreateContextFromType@plt>
mov    %rax,(%rbx)
mov    0x8(%rsp),%rax
mov    0x2e5b(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,(%rbx)
setne  %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@CL_CONTEXT_PLATFORM = global i32 0
@CL_DEVICE_TYPE_GPU = global i32 0
@CL_SUCCESS = global i64 0
define i32 @CreateContext(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca [3 x i32]
%6 = alloca i64
store i32** %0, i32*** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%8 = load i32, i32* @CL_CONTEXT_PLATFORM
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
%10 = load i32, i32* %4
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
store i32 0, i32* %11
store i64 0, i64* %6
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%13 = load i32, i32* @CL_DEVICE_TYPE_GPU
%14 = call i32* @clCreateContextFromType(i32* %12, i32 %13, i32* null, i32* null, i64* %6)
%15 = load i32**, i32*** %3
store i32* %14, i32** %15
%16 = load i64, i64* %6
%17 = load i64, i64* @CL_SUCCESS
%18 = icmp eq i64 %16, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32**, i32*** %3
%22 = load i32*, i32** %21
%23 = icmp ne i32* %22, null
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@CL_CONTEXT_PLATFORM = global i32 0
@CL_DEVICE_TYPE_GPU = global i32 0
@CL_SUCCESS = global i64 0
define i32 @CreateContext(i32** nocapture %0, i32 %1) {
%3 = alloca [3 x i32]
%4 = alloca i64
%5 = bitcast [3 x i32]* %3 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%7 = load i32, i32* @CL_CONTEXT_PLATFORM
store i32 %7, i32* %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 %1, i32* %8
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 0, i32* %9
%10 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%11 = load i32, i32* @CL_DEVICE_TYPE_GPU
%12 = call i32* @clCreateContextFromType(i32* %6, i32 %11, i32* null, i32* null, i64* %4)
store i32* %12, i32** %0
%13 = load i64, i64* %4
%14 = load i64, i64* @CL_SUCCESS
%15 = icmp eq i64 %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32*, i32** %0
%19 = icmp ne i32* %18, null
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
ret i32 0
}