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

/* Variables and functions */
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ clCreateKernel(int /*<<< orphan*/, char *, scalar_t__ *);
int CreateKernel(cl_kernel *kernel, cl_context ctx, cl_program program) {
  cl_int status = 0;
  kernel[0] = clCreateKernel(program, "MatrixMult_naive", &status);
  assert(status == CL_SUCCESS);
  kernel[1] = clCreateKernel(program, "MatrixMult_opt", &status);
  assert(status == CL_SUCCESS);
  return 0;
}


x86 assembly (clang, -O0):
<CreateKernel>:
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    -0x10(%rbp),%edi
lea    0xebc(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <clCreateKernel@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%edi
lea    0xe97(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <clCreateKernel@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateKernel>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
movq   $0x0,(%rsp)
lea    0xec5(%rip),%rsi
mov    %rsp,%r14
mov    %edx,%edi
mov    %r14,%rdx
call   1040 <clCreateKernel@plt>
mov    %eax,(%rbx)
mov    (%rsp),%rax
mov    0x2e8b(%rip),%r15
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1030 <assert@plt>
lea    0xea7(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
call   1040 <clCreateKernel@plt>
mov    %eax,0x4(%rbx)
mov    (%rsp),%rax
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"MatrixMult_naive\00"
@CL_SUCCESS = global i64 0
@.str.1 = [15 x i8] c"MatrixMult_opt\00"
define i32 @CreateKernel(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* %6
%9 = call i32 @clCreateKernel(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64* %7)
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 0
store i32 %9, 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* %6
%18 = call i32 @clCreateKernel(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64* %7)
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %18, i32* %20
%21 = load i64, i64* %7
%22 = load i64, i64* @CL_SUCCESS
%23 = icmp eq i64 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"MatrixMult_naive\00"
@CL_SUCCESS = global i64 0
@.str.1 = [15 x i8] c"MatrixMult_opt\00"
define i32 @CreateKernel(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%6 = call i32 @clCreateKernel(i32 %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 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 = call i32 @clCreateKernel(i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%13 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %12, i32* %13
%14 = load i64, i64* %4
%15 = load i64, i64* @CL_SUCCESS
%16 = icmp eq i64 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret i32 0
}