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

/* Variables and functions */
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ assert(int);
scalar_t__ clEnqueueNDRangeKernel(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ *, size_t const *,
                                  size_t const *, int /*<<< orphan*/,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ clFinish(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
int RunKernel(cl_command_queue cmd_q, cl_kernel kernel, int hA, int wB,
              const char *info) {
  printf("\nStart executing %s\n", info);
  int hC = hA;
  int wC = wB;
  const size_t local_size[2] = {16, 16};
  const size_t global_size[2] = {(wC + 15) / 16 * 16, (hC + 15) / 16 * 16};
  cl_int status = clEnqueueNDRangeKernel(cmd_q, kernel, 2, NULL, global_size,
                                         local_size, 0, NULL, NULL);
  assert(status == CL_SUCCESS);
  status = clFinish(cmd_q);
  assert(status == CL_SUCCESS);
  printf("Finish executing %s\n", info);
  return 0;
}


x86 assembly (clang, -O0):
<RunKernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb2(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0xf,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
shl    $0x4,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xf,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
shl    $0x4,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x40(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1040 <clEnqueueNDRangeKernel@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    0x2de2(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x4(%rbp),%edi
call   1030 <clFinish@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    0x2dbb(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    0xdd5(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RunKernel>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %r8,%r14
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xed0(%rip),%rdi
mov    %r8,%rsi
call   1050 <printf@plt>
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movd   %ebp,%xmm0
movd   %ebx,%xmm1
punpckldq %xmm0,%xmm1
paddd  0xe78(%rip),%xmm1
movdqa %xmm1,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1c,%xmm0
paddd  %xmm1,%xmm0
pand   0xe6e(%rip),%xmm0
pxor   %xmm1,%xmm1
pxor   %xmm2,%xmm2
pcmpgtd %xmm0,%xmm2
punpckldq %xmm2,%xmm0
movdqa %xmm0,0x20(%rsp)
movdqu %xmm1,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x20(%rsp),%r8
lea    0x30(%rsp),%r9
mov    %r12d,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1040 <clEnqueueNDRangeKernel@plt>
mov    0x2df8(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1060 <assert@plt>
mov    %r12d,%edi
call   1030 <clFinish@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe32(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AStart executing %s\0A\00"
@__const.RunKernel.local_size = [2 x i64] [i64 16, i64 16]
@CL_SUCCESS = global i64 0
@.str.1 = [21 x i8] c"Finish executing %s\0A\00"
define i32 @RunKernel(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [2 x i64]
%14 = alloca [2 x i64]
%15 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%16 = load i8*, i8** %10
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* %8
store i32 %18, i32* %11
%19 = load i32, i32* %9
store i32 %19, i32* %12
%20 = bitcast [2 x i64]* %13 to i8*
%21 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%22 = load i32, i32* %12
%23 = add nsw i32 %22, 15
%24 = sdiv i32 %23, 16
%25 = mul nsw i32 %24, 16
%26 = sext i32 %25 to i64
store i64 %26, i64* %21
%27 = getelementptr inbounds i64, i64* %21, i64 1
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 15
%30 = sdiv i32 %29, 16
%31 = mul nsw i32 %30, 16
%32 = sext i32 %31 to i64
store i64 %32, i64* %27
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%36 = getelementptr inbounds [2 x i64], [2 x i64]* %13, i64 0, i64 0
%37 = call i64 @clEnqueueNDRangeKernel(i32 %33, i32 %34, i32 2, i32* null, i64* %35, i64* %36, i32 0, i32* null, i32* null)
store i64 %37, i64* %15
%38 = load i64, i64* %15
%39 = load i64, i64* @CL_SUCCESS
%40 = icmp eq i64 %38, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %6
%44 = call i64 @clFinish(i32 %43)
store i64 %44, i64* %15
%45 = load i64, i64* %15
%46 = load i64, i64* @CL_SUCCESS
%47 = icmp eq i64 %45, %46
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i8*, i8** %10
%51 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AStart executing %s\0A\00"
@__const.RunKernel.local_size = [2 x i64] [i64 16, i64 16]
@CL_SUCCESS = global i64 0
@.str.1 = [21 x i8] c"Finish executing %s\0A\00"
define i32 @RunKernel(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [2 x i64]
%7 = alloca <2 x i64>
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = bitcast [2 x i64]* %6 to i8*
%10 = bitcast <2 x i64>* %7 to i8*
%11 = getelementptr inbounds <2 x i64>, <2 x i64>* %7, i64 0, i64 0
%12 = insertelement <2 x i32> poison, i32 %3, i64 0
%13 = insertelement <2 x i32> %12, i32 %2, i64 1
%14 = add nsw <2 x i32> %13, <i32 15, i32 15>
%15 = sdiv <2 x i32> %14, <i32 16, i32 16>
%16 = shl nsw <2 x i32> %15, <i32 4, i32 4>
%17 = sext <2 x i32> %16 to <2 x i64>
store <2 x i64> %17, <2 x i64>* %7
%18 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
%19 = call i64 @clEnqueueNDRangeKernel(i32 %0, i32 %1, i32 2, i32* null, i64* %11, i64* %18, i32 0, i32* null, i32* null)
%20 = load i64, i64* @CL_SUCCESS
%21 = icmp eq i64 %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i64 @clFinish(i32 %0)
%25 = load i64, i64* @CL_SUCCESS
%26 = icmp eq i64 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}