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

/* Variables and functions */
int /*<<< orphan*/ CL_CONTEXT_PLATFORM;
int CL_DEVICE_TYPE_CPU;
int CL_DEVICE_TYPE_GPU;
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int clCreateContextFromType(int /*<<< orphan*/ *, int, 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 | CL_DEVICE_TYPE_CPU,
                                 NULL, NULL, &status);
  assert(status == CL_SUCCESS);
  assert(*ctx);
  return 0;
}


x86 assembly (clang, -O0):
<CreateContext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e9a(%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
mov    0x2e74(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1040 <clCreateContextFromType@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%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    0x2ea1(%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    0x2e80(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0x14(%rsp),%rdi
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <clCreateContextFromType@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rax
mov    0x2e4b(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1030 <assert@plt>
mov    (%rbx),%edi
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_DEVICE_TYPE_CPU = 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 = load i32, i32* @CL_DEVICE_TYPE_CPU
%15 = or i32 %13, %14
%16 = call i32 @clCreateContextFromType(i32* %12, i32 %15, i32* null, i32* null, i64* %6)
%17 = load i32*, i32** %3
store i32 %16, i32* %17
%18 = load i64, i64* %6
%19 = load i64, i64* @CL_SUCCESS
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32*, i32** %3
%24 = load i32, i32* %23
%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_DEVICE_TYPE_CPU = 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 = load i32, i32* @CL_DEVICE_TYPE_CPU
%13 = or i32 %12, %11
%14 = call i32 @clCreateContextFromType(i32* %6, i32 %13, i32* null, i32* null, i64* %4)
store i32 %14, i32* %0
%15 = load i64, i64* %4
%16 = load i64, i64* @CL_SUCCESS
%17 = icmp eq i64 %15, %16
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %0
%21 = call i32 @assert(i32 %20)
ret i32 0
}