#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_uint;
typedef int /*<<< orphan*/ cl_program;
typedef int /*<<< orphan*/ *cl_platform_id;
typedef int /*<<< orphan*/ cl_mem;
typedef int /*<<< orphan*/ cl_kernel;
typedef int /*<<< orphan*/ cl_int;
typedef int /*<<< orphan*/ *cl_device_id;
typedef int /*<<< orphan*/ cl_context;
typedef int /*<<< orphan*/ cl_command_queue;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_TYPE_ALL;
int /*<<< orphan*/ CL_MEM_READ_ONLY;
int /*<<< orphan*/ CL_MEM_WRITE_ONLY;
int /*<<< orphan*/ CL_TRUE;
int /*<<< orphan*/ clBuildProgram(int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ **, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                  int const, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateCommandQueue(int /*<<< orphan*/,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateContext(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/ **, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateKernel(int /*<<< orphan*/, char *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateProgramWithSource(int /*<<< orphan*/, int,
                                             char const **, size_t const *,
                                             int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueNDRangeKernel(
    int /*<<< orphan*/, int /*<<< orphan*/, int, int /*<<< orphan*/ *, size_t *,
    size_t *, int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueReadBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int const, int *, int /*<<< orphan*/,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueWriteBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int /*<<< orphan*/,
                                        int const, int *, int /*<<< orphan*/,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ clFinish(int /*<<< orphan*/);
int /*<<< orphan*/ clFlush(int /*<<< orphan*/);
int /*<<< orphan*/ clGetDeviceIDs(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetPlatformIDs(int, int /*<<< orphan*/ **,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ clReleaseCommandQueue(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseContext(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseKernel(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseMemObject(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseProgram(int /*<<< orphan*/);
int /*<<< orphan*/ clSetKernelArg(int /*<<< orphan*/, int, int, void *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ stderr;
int main(void) {
  int i;
  const int LIST_SIZE = 1024;
  int *A = (int *)malloc(sizeof(int) * LIST_SIZE);
  int *B = (int *)malloc(sizeof(int) * LIST_SIZE);
  for (i = 0; i < LIST_SIZE; i++) {
    A[i] = i;
    B[i] = LIST_SIZE - i;
  }
  FILE *fp;
  char *source_str;
  size_t source_size;
  fp = fopen("vector_add_kernel.cl", "r");
  if (!fp) {
    fprintf(stderr, "Failed to load kernel.\n");
    exit(1);
  }
  source_str = (char *)malloc((0x100000));
  source_size = fread(source_str, 1, (0x100000), fp);
  fclose(fp);
  cl_platform_id platform_id = NULL;
  cl_device_id device_id = NULL;
  cl_uint ret_num_devices;
  cl_uint ret_num_platforms;
  cl_int ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
  ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 1, &device_id,
                       &ret_num_devices);
  cl_context context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret);
  cl_command_queue command_queue =
      clCreateCommandQueue(context, device_id, 0, &ret);
  cl_mem a_mem_obj = clCreateBuffer(context, CL_MEM_READ_ONLY,
                                    LIST_SIZE * sizeof(int), NULL, &ret);
  cl_mem b_mem_obj = clCreateBuffer(context, CL_MEM_READ_ONLY,
                                    LIST_SIZE * sizeof(int), NULL, &ret);
  cl_mem c_mem_obj = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
                                    LIST_SIZE * sizeof(int), NULL, &ret);
  ret = clEnqueueWriteBuffer(command_queue, a_mem_obj, CL_TRUE, 0,
                             LIST_SIZE * sizeof(int), A, 0, NULL, NULL);
  ret = clEnqueueWriteBuffer(command_queue, b_mem_obj, CL_TRUE, 0,
                             LIST_SIZE * sizeof(int), B, 0, NULL, NULL);
  cl_program program =
      clCreateProgramWithSource(context, 1, (const char **)&source_str,
                                (const size_t *)&source_size, &ret);
  ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
  cl_kernel kernel = clCreateKernel(program, "vector_add", &ret);
  ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&a_mem_obj);
  ret = clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&b_mem_obj);
  ret = clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *)&c_mem_obj);
  size_t global_item_size = LIST_SIZE;
  size_t local_item_size = 64;
  ret =
      clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global_item_size,
                             &local_item_size, 0, NULL, NULL);
  int *C = (int *)malloc(sizeof(int) * LIST_SIZE);
  ret = clEnqueueReadBuffer(command_queue, c_mem_obj, CL_TRUE, 0,
                            LIST_SIZE * sizeof(int), C, 0, NULL, NULL);
  for (i = 0; i < LIST_SIZE; i++)
    printf("%d + %d = %d\n", A[i], B[i], C[i]);
  ret = clFlush(command_queue);
  ret = clFinish(command_queue);
  ret = clReleaseKernel(kernel);
  ret = clReleaseProgram(program);
  ret = clReleaseMemObject(a_mem_obj);
  ret = clReleaseMemObject(b_mem_obj);
  ret = clReleaseMemObject(c_mem_obj);
  ret = clReleaseCommandQueue(command_queue);
  ret = clReleaseContext(context);
  free(A);
  free(B);
  free(C);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x400,-0xc(%rbp)
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    1328 <main+0x78>
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    $0x400,%edx
sub    -0x8(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12ec <main+0x3c>
lea    0xcd1(%rip),%rdi
lea    0xcdf(%rip),%rsi
call   1190 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1369 <main+0xb9>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xcbd(%rip),%rsi
call   1130 <fprintf@plt>
mov    $0x1,%edi
call   11b0 <exit@plt>
mov    $0x100000,%edi
call   1150 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100000,%edx
call   1070 <fread@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   10d0 <fclose@plt>
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    $0x1,%edi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1100 <clGetPlatformIDs@plt>
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2c0d(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
lea    -0x48(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,-0x54(%rbp)
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x1,%esi
lea    -0x48(%rbp),%rdx
lea    -0x54(%rbp),%r9
mov    %r8,%rdi
mov    %r8,%rcx
call   1120 <clCreateContext@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edi
mov    -0x48(%rbp),%rsi
xor    %edx,%edx
lea    -0x54(%rbp),%rcx
call   10f0 <clCreateCommandQueue@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2b9f(%rip),%rax
mov    (%rax),%esi
mov    $0x1000,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x54(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x60(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2b7e(%rip),%rax
mov    (%rax),%esi
mov    $0x1000,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x54(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x64(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2b7d(%rip),%rax
mov    (%rax),%esi
mov    $0x1000,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x54(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x68(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    0x2b61(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%r9
xor    %ecx,%ecx
mov    $0x1000,%r8d
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11d0 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x54(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x2b23(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%r9
xor    %ecx,%ecx
mov    $0x1000,%r8d
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11d0 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x1,%esi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x54(%rbp),%r8
call   1060 <clCreateProgramWithSource@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%edi
mov    $0x1,%esi
lea    -0x48(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x54(%rbp)
mov    -0x6c(%rbp),%edi
lea    0xaf4(%rip),%rsi
lea    -0x54(%rbp),%rdx
call   11a0 <clCreateKernel@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%edi
lea    -0x60(%rbp),%rcx
xor    %esi,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x54(%rbp)
mov    -0x70(%rbp),%edi
lea    -0x64(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x54(%rbp)
mov    -0x70(%rbp),%edi
lea    -0x68(%rbp),%rcx
mov    $0x2,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x54(%rbp)
movq   $0x400,-0x78(%rbp)
movq   $0x40,-0x80(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x70(%rbp),%esi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x78(%rbp),%r8
lea    -0x80(%rbp),%r9
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   10e0 <clEnqueueNDRangeKernel@plt>
mov    %eax,-0x54(%rbp)
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    0x29f1(%rip),%rax
mov    (%rax),%edx
mov    -0x88(%rbp),%r9
xor    %ecx,%ecx
mov    $0x1000,%r8d
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1160 <clEnqueueReadBuffer@plt>
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    167d <main+0x3cd>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x88(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0x9d0(%rip),%rdi
call   1110 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1632 <main+0x382>
mov    -0x5c(%rbp),%edi
call   1090 <clFlush@plt>
mov    %eax,-0x54(%rbp)
mov    -0x5c(%rbp),%edi
call   1050 <clFinish@plt>
mov    %eax,-0x54(%rbp)
mov    -0x70(%rbp),%edi
call   1080 <clReleaseKernel@plt>
mov    %eax,-0x54(%rbp)
mov    -0x6c(%rbp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %eax,-0x54(%rbp)
mov    -0x60(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,-0x54(%rbp)
mov    -0x64(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,-0x54(%rbp)
mov    -0x68(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,-0x54(%rbp)
mov    -0x5c(%rbp),%edi
call   1140 <clReleaseCommandQueue@plt>
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%edi
call   1170 <clReleaseContext@plt>
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x88(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,%r14
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,%rbx
add    $0x1000,%rax
cmp    %rax,%r14
jae    1349 <main+0x99>
mov    %r14,%rax
add    $0x1000,%rax
cmp    %rax,%rbx
jae    1349 <main+0x99>
mov    $0x400,%eax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,(%r14,%rcx,4)
mov    %eax,(%rbx,%rcx,4)
lea    0x1(%rcx),%edx
mov    %edx,0x4(%r14,%rcx,4)
lea    -0x1(%rax),%edx
mov    %edx,0x4(%rbx,%rcx,4)
lea    0x2(%rcx),%edx
mov    %edx,0x8(%r14,%rcx,4)
lea    -0x2(%rax),%edx
mov    %edx,0x8(%rbx,%rcx,4)
lea    0x3(%rcx),%edx
mov    %edx,0xc(%r14,%rcx,4)
lea    -0x3(%rax),%edx
mov    %edx,0xc(%rbx,%rcx,4)
add    $0xfffffffc,%eax
add    $0x4,%rcx
cmp    $0x400,%rcx
jne    1300 <main+0x50>
jmp    1426 <main+0x176>
movdqa 0xcaf(%rip),%xmm3
xor    %eax,%eax
movdqa 0xcb4(%rip),%xmm8
movdqa 0xcbb(%rip),%xmm9
movdqa 0xcc2(%rip),%xmm10
movdqa 0xcc9(%rip),%xmm11
movdqa 0xcd1(%rip),%xmm5
movdqa 0xcd9(%rip),%xmm6
movdqa 0xce1(%rip),%xmm7
movdqa 0xce9(%rip),%xmm1
movdqa %xmm3,%xmm0
nopl   0x0(%rax,%rax,1)
movdqa %xmm3,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm3,(%r14,%rax,4)
movdqu %xmm2,0x10(%r14,%rax,4)
movdqa %xmm9,%xmm2
psubd  %xmm0,%xmm2
movdqa %xmm10,%xmm4
psubd  %xmm0,%xmm4
movdqu %xmm2,(%rbx,%rax,4)
movdqu %xmm4,0x10(%rbx,%rax,4)
movdqa %xmm3,%xmm2
paddd  %xmm11,%xmm2
movdqa %xmm3,%xmm4
paddd  %xmm5,%xmm4
movdqu %xmm2,0x20(%r14,%rax,4)
movdqu %xmm4,0x30(%r14,%rax,4)
movdqa %xmm6,%xmm2
psubd  %xmm0,%xmm2
movdqa %xmm7,%xmm4
psubd  %xmm0,%xmm4
movdqu %xmm2,0x20(%rbx,%rax,4)
movdqu %xmm4,0x30(%rbx,%rax,4)
add    $0x10,%rax
paddd  %xmm1,%xmm3
paddd  %xmm1,%xmm0
cmp    $0x400,%rax
jne    13a0 <main+0xf0>
lea    0xc73(%rip),%rdi
lea    0xc81(%rip),%rsi
call   1190 <fopen@plt>
test   %rax,%rax
je     17d1 <main+0x521>
mov    %rax,%rbp
mov    $0x100000,%edi
call   1150 <malloc@plt>
mov    %rax,0x68(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x100000,%edx
mov    %rbp,%rcx
call   1070 <fread@plt>
mov    %rax,0x60(%rsp)
mov    %rbp,%rdi
call   10d0 <fclose@plt>
movq   $0x0,0x48(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x48(%rsp),%rsi
lea    0x70(%rsp),%rdx
mov    $0x1,%edi
call   1100 <clGetPlatformIDs@plt>
mov    %eax,0x20(%rsp)
mov    0x48(%rsp),%rdi
mov    0x2b2c(%rip),%rax
mov    (%rax),%esi
lea    0x38(%rsp),%r12
lea    0x74(%rsp),%r8
mov    $0x1,%edx
mov    %r12,%rcx
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,0x20(%rsp)
xor    %r15d,%r15d
lea    0x20(%rsp),%rbp
xor    %edi,%edi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbp,%r9
call   1120 <clCreateContext@plt>
mov    %eax,%r13d
mov    0x38(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
mov    %rbp,%rcx
call   10f0 <clCreateCommandQueue@plt>
mov    %eax,0x2c(%rsp)
mov    0x2ab9(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    $0x1000,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r12d
mov    %eax,0x34(%rsp)
mov    0x2a97(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    $0x1000,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x24(%rsp)
mov    %eax,0x30(%rsp)
mov    0x2a94(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    $0x1000,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x28(%rsp)
mov    0x2a7d(%rip),%rax
mov    (%rax),%edx
pxor   %xmm0,%xmm0
movdqu %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    0x2c(%rsp),%ebp
mov    %ebp,%edi
mov    %r12d,%esi
xor    %ecx,%ecx
mov    $0x1000,%r8d
mov    %r14,%r9
call   11d0 <clEnqueueWriteBuffer@plt>
mov    %eax,0x20(%rsp)
mov    0x2a46(%rip),%rax
mov    (%rax),%edx
pxor   %xmm0,%xmm0
movdqu %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebp,%edi
mov    %ebp,%r12d
mov    0x24(%rsp),%esi
xor    %ecx,%ecx
mov    $0x1000,%r8d
mov    %rbx,%r9
call   11d0 <clEnqueueWriteBuffer@plt>
mov    %eax,0x20(%rsp)
lea    0x68(%rsp),%rdx
lea    0x60(%rsp),%rcx
mov    %r13d,0x24(%rsp)
mov    %r13d,%edi
mov    $0x1,%esi
lea    0x20(%rsp),%r13
mov    %r13,%r8
call   1060 <clCreateProgramWithSource@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x1,%esi
lea    0x38(%rsp),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,0x20(%rsp)
lea    0xab3(%rip),%rsi
mov    %ebp,0x44(%rsp)
mov    %ebp,%edi
mov    %r13,%rdx
call   11a0 <clCreateKernel@plt>
mov    %eax,%r13d
lea    0x34(%rsp),%rcx
mov    %eax,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,0x20(%rsp)
lea    0x30(%rsp),%rcx
mov    %r13d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,0x20(%rsp)
lea    0x28(%rsp),%rcx
mov    %r13d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,0x20(%rsp)
movq   $0x400,0x58(%rsp)
movq   $0x40,0x50(%rsp)
pxor   %xmm0,%xmm0
movdqu %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x58(%rsp),%r8
lea    0x50(%rsp),%r9
mov    %r12d,%edi
mov    %r13d,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   10e0 <clEnqueueNDRangeKernel@plt>
mov    %eax,0x20(%rsp)
mov    $0x1000,%edi
call   1150 <malloc@plt>
mov    %rax,%rbp
mov    0x28(%rsp),%esi
mov    0x2913(%rip),%rax
mov    (%rax),%edx
pxor   %xmm0,%xmm0
movdqu %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r12d,%edi
xor    %ecx,%ecx
mov    $0x1000,%r8d
mov    %rbp,%r9
call   1160 <clEnqueueReadBuffer@plt>
mov    %eax,0x20(%rsp)
lea    0x9d4(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%r15,4),%esi
mov    (%rbx,%r15,4),%edx
mov    0x0(%rbp,%r15,4),%ecx
mov    %r12,%rdi
call   1110 <printf@plt>
add    $0x1,%r15
cmp    $0x400,%r15
jne    1710 <main+0x460>
mov    0x2c(%rsp),%r15d
mov    %r15d,%edi
call   1090 <clFlush@plt>
mov    %eax,0x20(%rsp)
mov    %r15d,%edi
call   1050 <clFinish@plt>
mov    %eax,0x20(%rsp)
mov    %r13d,%edi
call   1080 <clReleaseKernel@plt>
mov    %eax,0x20(%rsp)
mov    0x44(%rsp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %eax,0x20(%rsp)
mov    0x34(%rsp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,0x20(%rsp)
mov    0x30(%rsp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,0x20(%rsp)
mov    0x28(%rsp),%edi
call   1180 <clReleaseMemObject@plt>
mov    %eax,0x20(%rsp)
mov    %r15d,%edi
call   1140 <clReleaseCommandQueue@plt>
mov    %eax,0x20(%rsp)
mov    0x24(%rsp),%edi
call   1170 <clReleaseContext@plt>
mov    %eax,0x20(%rsp)
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x27f0(%rip),%rax
mov    (%rax),%edi
lea    0x8d6(%rip),%rsi
call   1130 <fprintf@plt>
mov    $0x1,%edi
call   11b0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"vector_add_kernel.cl\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Failed to load kernel.\0A\00"
@CL_DEVICE_TYPE_ALL = global i32 0
@CL_MEM_READ_ONLY = global i32 0
@CL_MEM_WRITE_ONLY = global i32 0
@CL_TRUE = global i32 0
@.str.3 = [11 x i8] c"vector_add\00"
@.str.4 = [14 x i8] c"%d + %d = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i64
%22 = alloca i64
%23 = alloca i32*
store i32 0, i32* %1
store i32 1024, i32* %3
%24 = call i64 @malloc(i32 4096)
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %4
%26 = call i64 @malloc(i32 4096)
%27 = inttoptr i64 %26 to i32*
store i32* %27, i32** %5
store i32 0, i32* %2
br label %28
28: ; preds = %43, %0
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 1024
br i1 %30, label %31, label %46
31: ; preds = %28
%32 = load i32, i32* %2
%33 = load i32*, i32** %4
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
%37 = load i32, i32* %2
%38 = sub nsw i32 1024, %37
%39 = load i32*, i32** %5
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
br label %43
43: ; preds = %31
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %28
46: ; preds = %28
%47 = call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %47, i32** %6
%48 = load i32*, i32** %6
%49 = icmp ne i32* %48, null
br i1 %49, label %54, label %50
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %46
%55 = call i64 @malloc(i32 1048576)
%56 = inttoptr i64 %55 to i8*
store i8* %56, i8** %7
%57 = load i8*, i8** %7
%58 = load i32*, i32** %6
%59 = call i64 @fread(i8* %57, i32 1, i32 1048576, i32* %58)
store i64 %59, i64* %8
%60 = load i32*, i32** %6
%61 = call i32 @fclose(i32* %60)
store i32* null, i32** %9
store i32* null, i32** %10
%62 = call i32 @clGetPlatformIDs(i32 1, i32** %9, i32* %12)
store i32 %62, i32* %13
%63 = load i32*, i32** %9
%64 = load i32, i32* @CL_DEVICE_TYPE_ALL
%65 = call i32 @clGetDeviceIDs(i32* %63, i32 %64, i32 1, i32** %10, i32* %11)
store i32 %65, i32* %13
%66 = call i32 @clCreateContext(i32* null, i32 1, i32** %10, i32* null, i32* null, i32* %13)
store i32 %66, i32* %14
%67 = load i32, i32* %14
%68 = load i32*, i32** %10
%69 = call i32 @clCreateCommandQueue(i32 %67, i32* %68, i32 0, i32* %13)
store i32 %69, i32* %15
%70 = load i32, i32* %14
%71 = load i32, i32* @CL_MEM_READ_ONLY
%72 = call i32 @clCreateBuffer(i32 %70, i32 %71, i32 4096, i32* null, i32* %13)
store i32 %72, i32* %16
%73 = load i32, i32* %14
%74 = load i32, i32* @CL_MEM_READ_ONLY
%75 = call i32 @clCreateBuffer(i32 %73, i32 %74, i32 4096, i32* null, i32* %13)
store i32 %75, i32* %17
%76 = load i32, i32* %14
%77 = load i32, i32* @CL_MEM_WRITE_ONLY
%78 = call i32 @clCreateBuffer(i32 %76, i32 %77, i32 4096, i32* null, i32* %13)
store i32 %78, i32* %18
%79 = load i32, i32* %15
%80 = load i32, i32* %16
%81 = load i32, i32* @CL_TRUE
%82 = load i32*, i32** %4
%83 = call i32 @clEnqueueWriteBuffer(i32 %79, i32 %80, i32 %81, i32 0, i32 4096, i32* %82, i32 0, i32* null, i32* null)
store i32 %83, i32* %13
%84 = load i32, i32* %15
%85 = load i32, i32* %17
%86 = load i32, i32* @CL_TRUE
%87 = load i32*, i32** %5
%88 = call i32 @clEnqueueWriteBuffer(i32 %84, i32 %85, i32 %86, i32 0, i32 4096, i32* %87, i32 0, i32* null, i32* null)
store i32 %88, i32* %13
%89 = load i32, i32* %14
%90 = call i32 @clCreateProgramWithSource(i32 %89, i32 1, i8** %7, i64* %8, i32* %13)
store i32 %90, i32* %19
%91 = load i32, i32* %19
%92 = call i32 @clBuildProgram(i32 %91, i32 1, i32** %10, i32* null, i32* null, i32* null)
store i32 %92, i32* %13
%93 = load i32, i32* %19
%94 = call i32 @clCreateKernel(i32 %93, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32* %13)
store i32 %94, i32* %20
%95 = load i32, i32* %20
%96 = bitcast i32* %16 to i8*
%97 = call i32 @clSetKernelArg(i32 %95, i32 0, i32 4, i8* %96)
store i32 %97, i32* %13
%98 = load i32, i32* %20
%99 = bitcast i32* %17 to i8*
%100 = call i32 @clSetKernelArg(i32 %98, i32 1, i32 4, i8* %99)
store i32 %100, i32* %13
%101 = load i32, i32* %20
%102 = bitcast i32* %18 to i8*
%103 = call i32 @clSetKernelArg(i32 %101, i32 2, i32 4, i8* %102)
store i32 %103, i32* %13
store i64 1024, i64* %21
store i64 64, i64* %22
%104 = load i32, i32* %15
%105 = load i32, i32* %20
%106 = call i32 @clEnqueueNDRangeKernel(i32 %104, i32 %105, i32 1, i32* null, i64* %21, i64* %22, i32 0, i32* null, i32* null)
store i32 %106, i32* %13
%107 = call i64 @malloc(i32 4096)
%108 = inttoptr i64 %107 to i32*
store i32* %108, i32** %23
%109 = load i32, i32* %15
%110 = load i32, i32* %18
%111 = load i32, i32* @CL_TRUE
%112 = load i32*, i32** %23
%113 = call i32 @clEnqueueReadBuffer(i32 %109, i32 %110, i32 %111, i32 0, i32 4096, i32* %112, i32 0, i32* null, i32* null)
store i32 %113, i32* %13
store i32 0, i32* %2
br label %114
114: ; preds = %134, %54
%115 = load i32, i32* %2
%116 = icmp slt i32 %115, 1024
br i1 %116, label %117, label %137
117: ; preds = %114
%118 = load i32*, i32** %4
%119 = load i32, i32* %2
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i32, i32* %118, i64 %120
%122 = load i32, i32* %121
%123 = load i32*, i32** %5
%124 = load i32, i32* %2
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i32, i32* %123, i64 %125
%127 = load i32, i32* %126
%128 = load i32*, i32** %23
%129 = load i32, i32* %2
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %128, i64 %130
%132 = load i32, i32* %131
%133 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %122, i32 %127, i32 %132)
br label %134
134: ; preds = %117
%135 = load i32, i32* %2
%136 = add nsw i32 %135, 1
store i32 %136, i32* %2
br label %114
137: ; preds = %114
%138 = load i32, i32* %15
%139 = call i32 @clFlush(i32 %138)
store i32 %139, i32* %13
%140 = load i32, i32* %15
%141 = call i32 @clFinish(i32 %140)
store i32 %141, i32* %13
%142 = load i32, i32* %20
%143 = call i32 @clReleaseKernel(i32 %142)
store i32 %143, i32* %13
%144 = load i32, i32* %19
%145 = call i32 @clReleaseProgram(i32 %144)
store i32 %145, i32* %13
%146 = load i32, i32* %16
%147 = call i32 @clReleaseMemObject(i32 %146)
store i32 %147, i32* %13
%148 = load i32, i32* %17
%149 = call i32 @clReleaseMemObject(i32 %148)
store i32 %149, i32* %13
%150 = load i32, i32* %18
%151 = call i32 @clReleaseMemObject(i32 %150)
store i32 %151, i32* %13
%152 = load i32, i32* %15
%153 = call i32 @clReleaseCommandQueue(i32 %152)
store i32 %153, i32* %13
%154 = load i32, i32* %14
%155 = call i32 @clReleaseContext(i32 %154)
store i32 %155, i32* %13
%156 = load i32*, i32** %4
%157 = call i32 @free(i32* %156)
%158 = load i32*, i32** %5
%159 = call i32 @free(i32* %158)
%160 = load i32*, i32** %23
%161 = call i32 @free(i32* %160)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"vector_add_kernel.cl\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Failed to load kernel.\0A\00"
@CL_DEVICE_TYPE_ALL = global i32 0
@CL_MEM_READ_ONLY = global i32 0
@CL_MEM_WRITE_ONLY = global i32 0
@CL_TRUE = global i32 0
@.str.3 = [11 x i8] c"vector_add\00"
@.str.4 = [14 x i8] c"%d + %d = %d\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = tail call i64 @malloc(i32 4096)
%14 = inttoptr i64 %13 to i32*
%15 = tail call i64 @malloc(i32 4096)
%16 = inttoptr i64 %15 to i32*
%17 = inttoptr i64 %15 to i8*
%18 = inttoptr i64 %13 to i8*
%19 = getelementptr i32, i32* %14, i64 1024
%20 = bitcast i32* %19 to i8*
%21 = getelementptr i32, i32* %16, i64 1024
%22 = bitcast i32* %21 to i8*
%23 = icmp ult i8* %18, %22
%24 = icmp ult i8* %17, %20
%25 = and i1 %23, %24
br i1 %25, label %58, label %26
26: ; preds = %0, %26
%27 = phi i64 [ %54, %26 ], [ 0, %0 ]
%28 = phi <4 x i32> [ %55, %26 ], [ <i32 0, i32 1, i32 2, i32 3>, %0 ]
%29 = phi <4 x i32> [ %56, %26 ], [ <i32 0, i32 1, i32 2, i32 3>, %0 ]
%30 = add <4 x i32> %28, <i32 4, i32 4, i32 4, i32 4>
%31 = getelementptr inbounds i32, i32* %14, i64 %27
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %32
%33 = getelementptr inbounds i32, i32* %31, i64 4
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %16, i64 %27
%36 = sub <4 x i32> <i32 1024, i32 1024, i32 1024, i32 1024>, %29
%37 = sub <4 x i32> <i32 1020, i32 1020, i32 1020, i32 1020>, %29
%38 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %36, <4 x i32>* %38
%39 = getelementptr inbounds i32, i32* %35, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> %37, <4 x i32>* %40
%41 = or i64 %27, 8
%42 = add <4 x i32> %28, <i32 8, i32 8, i32 8, i32 8>
%43 = add <4 x i32> %28, <i32 12, i32 12, i32 12, i32 12>
%44 = getelementptr inbounds i32, i32* %14, i64 %41
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %42, <4 x i32>* %45
%46 = getelementptr inbounds i32, i32* %44, i64 4
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> %43, <4 x i32>* %47
%48 = getelementptr inbounds i32, i32* %16, i64 %41
%49 = sub <4 x i32> <i32 1016, i32 1016, i32 1016, i32 1016>, %29
%50 = sub <4 x i32> <i32 1012, i32 1012, i32 1012, i32 1012>, %29
%51 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> %49, <4 x i32>* %51
%52 = getelementptr inbounds i32, i32* %48, i64 4
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %53
%54 = add nuw nsw i64 %27, 16
%55 = add <4 x i32> %28, <i32 16, i32 16, i32 16, i32 16>
%56 = add <4 x i32> %29, <i32 16, i32 16, i32 16, i32 16>
%57 = icmp eq i64 %54, 1024
br i1 %57, label %85, label %26
58: ; preds = %0, %58
%59 = phi i64 [ %83, %58 ], [ 0, %0 ]
%60 = getelementptr inbounds i32, i32* %14, i64 %59
%61 = trunc i64 %59 to i32
store i32 %61, i32* %60
%62 = getelementptr inbounds i32, i32* %16, i64 %59
%63 = trunc i64 %59 to i32
%64 = sub nuw nsw i32 1024, %63
store i32 %64, i32* %62
%65 = or i64 %59, 1
%66 = getelementptr inbounds i32, i32* %14, i64 %65
%67 = trunc i64 %65 to i32
store i32 %67, i32* %66
%68 = getelementptr inbounds i32, i32* %16, i64 %65
%69 = trunc i64 %65 to i32
%70 = sub nuw nsw i32 1024, %69
store i32 %70, i32* %68
%71 = or i64 %59, 2
%72 = getelementptr inbounds i32, i32* %14, i64 %71
%73 = trunc i64 %71 to i32
store i32 %73, i32* %72
%74 = getelementptr inbounds i32, i32* %16, i64 %71
%75 = trunc i64 %71 to i32
%76 = sub nuw nsw i32 1024, %75
store i32 %76, i32* %74
%77 = or i64 %59, 3
%78 = getelementptr inbounds i32, i32* %14, i64 %77
%79 = trunc i64 %77 to i32
store i32 %79, i32* %78
%80 = getelementptr inbounds i32, i32* %16, i64 %77
%81 = trunc i64 %77 to i32
%82 = sub nuw nsw i32 1024, %81
store i32 %82, i32* %80
%83 = add nuw nsw i64 %59, 4
%84 = icmp eq i64 %83, 1024
br i1 %84, label %85, label %58
85: ; preds = %26, %58
%86 = bitcast i8** %1 to i8*
%87 = bitcast i64* %2 to i8*
%88 = tail call i32* @fopen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = load i32, i32* @stderr
%92 = tail call i32 @fprintf(i32 %91, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%93 = tail call i32 @exit(i32 1)
unreachable
94: ; preds = %85
%95 = tail call i64 @malloc(i32 1048576)
%96 = inttoptr i64 %95 to i8*
store i8* %96, i8** %1
%97 = tail call i64 @fread(i8* %96, i32 1, i32 1048576, i32* %88)
store i64 %97, i64* %2
%98 = tail call i32 @fclose(i32* %88)
%99 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%100 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%101 = bitcast i32* %5 to i8*
%102 = bitcast i32* %6 to i8*
%103 = bitcast i32* %7 to i8*
%104 = call i32 @clGetPlatformIDs(i32 1, i32** %3, i32* %6)
store i32 %104, i32* %7
%105 = load i32*, i32** %3
%106 = load i32, i32* @CL_DEVICE_TYPE_ALL
%107 = call i32 @clGetDeviceIDs(i32* %105, i32 %106, i32 1, i32** %4, i32* %5)
store i32 %107, i32* %7
%108 = call i32 @clCreateContext(i32* null, i32 1, i32** %4, i32* null, i32* null, i32* %7)
%109 = load i32*, i32** %4
%110 = call i32 @clCreateCommandQueue(i32 %108, i32* %109, i32 0, i32* %7)
%111 = bitcast i32* %8 to i8*
%112 = load i32, i32* @CL_MEM_READ_ONLY
%113 = call i32 @clCreateBuffer(i32 %108, i32 %112, i32 4096, i32* null, i32* %7)
store i32 %113, i32* %8
%114 = bitcast i32* %9 to i8*
%115 = load i32, i32* @CL_MEM_READ_ONLY
%116 = call i32 @clCreateBuffer(i32 %108, i32 %115, i32 4096, i32* null, i32* %7)
store i32 %116, i32* %9
%117 = bitcast i32* %10 to i8*
%118 = load i32, i32* @CL_MEM_WRITE_ONLY
%119 = call i32 @clCreateBuffer(i32 %108, i32 %118, i32 4096, i32* null, i32* %7)
store i32 %119, i32* %10
%120 = load i32, i32* @CL_TRUE
%121 = call i32 @clEnqueueWriteBuffer(i32 %110, i32 %113, i32 %120, i32 0, i32 4096, i32* %14, i32 0, i32* null, i32* null)
store i32 %121, i32* %7
%122 = load i32, i32* @CL_TRUE
%123 = call i32 @clEnqueueWriteBuffer(i32 %110, i32 %116, i32 %122, i32 0, i32 4096, i32* %16, i32 0, i32* null, i32* null)
store i32 %123, i32* %7
%124 = call i32 @clCreateProgramWithSource(i32 %108, i32 1, i8** %1, i64* %2, i32* %7)
%125 = call i32 @clBuildProgram(i32 %124, i32 1, i32** %4, i32* null, i32* null, i32* null)
store i32 %125, i32* %7
%126 = call i32 @clCreateKernel(i32 %124, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%127 = call i32 @clSetKernelArg(i32 %126, i32 0, i32 4, i8* %111)
store i32 %127, i32* %7
%128 = call i32 @clSetKernelArg(i32 %126, i32 1, i32 4, i8* %114)
store i32 %128, i32* %7
%129 = call i32 @clSetKernelArg(i32 %126, i32 2, i32 4, i8* %117)
store i32 %129, i32* %7
%130 = bitcast i64* %11 to i8*
store i64 1024, i64* %11
%131 = bitcast i64* %12 to i8*
store i64 64, i64* %12
%132 = call i32 @clEnqueueNDRangeKernel(i32 %110, i32 %126, i32 1, i32* null, i64* %11, i64* %12, i32 0, i32* null, i32* null)
store i32 %132, i32* %7
%133 = call i64 @malloc(i32 4096)
%134 = inttoptr i64 %133 to i32*
%135 = load i32, i32* %10
%136 = load i32, i32* @CL_TRUE
%137 = call i32 @clEnqueueReadBuffer(i32 %110, i32 %135, i32 %136, i32 0, i32 4096, i32* %134, i32 0, i32* null, i32* null)
store i32 %137, i32* %7
br label %138
138: ; preds = %94, %138
%139 = phi i64 [ 0, %94 ], [ %147, %138 ]
%140 = getelementptr inbounds i32, i32* %14, i64 %139
%141 = load i32, i32* %140
%142 = getelementptr inbounds i32, i32* %16, i64 %139
%143 = load i32, i32* %142
%144 = getelementptr inbounds i32, i32* %134, i64 %139
%145 = load i32, i32* %144
%146 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %141, i32 %143, i32 %145)
%147 = add nuw nsw i64 %139, 1
%148 = icmp eq i64 %147, 1024
br i1 %148, label %149, label %138
149: ; preds = %138
%150 = call i32 @clFlush(i32 %110)
store i32 %150, i32* %7
%151 = call i32 @clFinish(i32 %110)
store i32 %151, i32* %7
%152 = call i32 @clReleaseKernel(i32 %126)
store i32 %152, i32* %7
%153 = call i32 @clReleaseProgram(i32 %124)
store i32 %153, i32* %7
%154 = load i32, i32* %8
%155 = call i32 @clReleaseMemObject(i32 %154)
store i32 %155, i32* %7
%156 = load i32, i32* %9
%157 = call i32 @clReleaseMemObject(i32 %156)
store i32 %157, i32* %7
%158 = load i32, i32* %10
%159 = call i32 @clReleaseMemObject(i32 %158)
store i32 %159, i32* %7
%160 = call i32 @clReleaseCommandQueue(i32 %110)
store i32 %160, i32* %7
%161 = call i32 @clReleaseContext(i32 %108)
store i32 %161, i32* %7
%162 = call i32 @free(i32* %14)
%163 = call i32 @free(i32* %16)
%164 = call i32 @free(i32* %134)
ret i32 0
}