#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*/ platform_name;
typedef int /*<<< orphan*/ device_name;
typedef char cl_ushort;
typedef int 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;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_NAME;
int /*<<< orphan*/ CL_DEVICE_TYPE_GPU;
int /*<<< orphan*/ CL_MEM_READ_ONLY;
int /*<<< orphan*/ CL_MEM_WRITE_ONLY;
int /*<<< orphan*/ CL_PLATFORM_NAME;
int /*<<< orphan*/ CL_PROGRAM_BUILD_LOG;
int /*<<< orphan*/ CL_SUCCESS;
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*/,
                                  size_t, 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 *,
                                             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*/,
                                       size_t, char *, int /*<<< orphan*/,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueWriteBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int /*<<< orphan*/,
                                        size_t, char *, int /*<<< orphan*/,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ clFinish(int /*<<< orphan*/);
int /*<<< orphan*/ clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetPlatformIDs(int, int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clGetPlatformInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                     int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetProgramBuildInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/, size_t, char *,
                                         size_t *);
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,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ memset(void *, int, size_t);
int /*<<< orphan*/ printf(char *, ...);
unsigned char *read_buffer(char *, size_t *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ write_buffer(char *, char const *, size_t);
int main(int argc, char const *argv[]) {
  cl_platform_id platform;
  cl_uint num_platforms;
  cl_int ret = clGetPlatformIDs(1, &platform, &num_platforms);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clGetPlatformIDs' failed\n");
    exit(1);
  }
  printf("Number of platforms: %d\n", num_platforms);
  printf("platform=%p\n", platform);
  char platform_name[100];
  ret = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(platform_name),
                          platform_name, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clGetPlatformInfo' failed\n");
    exit(1);
  }
  printf("platform.name='%s'\n\n", platform_name);
  cl_device_id device;
  cl_uint num_devices;
  ret = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &num_devices);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clGetDeviceIDs' failed\n");
    exit(1);
  }
  printf("Number of devices: %d\n", num_devices);
  printf("device=%p\n", device);
  char device_name[100];
  ret = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name),
                        device_name, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clGetDeviceInfo' failed\n");
    exit(1);
  }
  printf("device.name='%s'\n", device_name);
  printf("\n");
  cl_context context;
  context = clCreateContext(NULL, 1, &device, NULL, NULL, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clCreateContext' failed\n");
    exit(1);
  }
  printf("context=%p\n", context);
  cl_command_queue command_queue;
  command_queue = clCreateCommandQueue(context, device, 0, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clCreateCommandQueue' failed\n");
    exit(1);
  }
  printf("command_queue=%p\n", command_queue);
  printf("\n");
  unsigned char *source_code;
  size_t source_length;
  source_code = read_buffer("mad_sat_ushortushortushort.cl", &source_length);
  cl_program program;
  program = clCreateProgramWithSource(context, 1, (const char **)&source_code,
                                      &source_length, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clCreateProgramWithSource' failed\n");
    exit(1);
  }
  printf("program=%p\n", program);
  ret = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
  if (ret != CL_SUCCESS) {
    size_t size;
    char *log;
    clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL,
                          &size);
    log = malloc(size);
    clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, size, log,
                          NULL);
    printf("error: call to 'clBuildProgram' failed:\n%s\n", log);
    free(log);
    exit(1);
  }
  printf("program built\n");
  printf("\n");
  cl_kernel kernel;
  kernel = clCreateKernel(program, "mad_sat_ushortushortushort", &ret);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clCreateKernel' failed\n");
    exit(1);
  }
  size_t num_elem = 10;
  cl_ushort *src_0_host_buffer;
  src_0_host_buffer = malloc(num_elem * sizeof(cl_ushort));
  for (int i = 0; i < num_elem; i++)
    src_0_host_buffer[i] = (cl_ushort)(2);
  cl_mem src_0_device_buffer;
  src_0_device_buffer = clCreateBuffer(
      context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort), NULL, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: could not create source buffer\n");
    exit(1);
  }
  ret = clEnqueueWriteBuffer(command_queue, src_0_device_buffer, CL_TRUE, 0,
                             num_elem * sizeof(cl_ushort), src_0_host_buffer, 0,
                             NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueWriteBuffer' failed\n");
    exit(1);
  }
  cl_ushort *src_1_host_buffer;
  src_1_host_buffer = malloc(num_elem * sizeof(cl_ushort));
  for (int i = 0; i < num_elem; i++)
    src_1_host_buffer[i] = (cl_ushort)(2);
  cl_mem src_1_device_buffer;
  src_1_device_buffer = clCreateBuffer(
      context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort), NULL, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: could not create source buffer\n");
    exit(1);
  }
  ret = clEnqueueWriteBuffer(command_queue, src_1_device_buffer, CL_TRUE, 0,
                             num_elem * sizeof(cl_ushort), src_1_host_buffer, 0,
                             NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueWriteBuffer' failed\n");
    exit(1);
  }
  cl_ushort *src_2_host_buffer;
  src_2_host_buffer = malloc(num_elem * sizeof(cl_ushort));
  for (int i = 0; i < num_elem; i++)
    src_2_host_buffer[i] = (cl_ushort)(2);
  cl_mem src_2_device_buffer;
  src_2_device_buffer = clCreateBuffer(
      context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_ushort), NULL, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: could not create source buffer\n");
    exit(1);
  }
  ret = clEnqueueWriteBuffer(command_queue, src_2_device_buffer, CL_TRUE, 0,
                             num_elem * sizeof(cl_ushort), src_2_host_buffer, 0,
                             NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueWriteBuffer' failed\n");
    exit(1);
  }
  cl_ushort *dst_host_buffer;
  dst_host_buffer = malloc(num_elem * sizeof(cl_ushort));
  memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_ushort));
  cl_mem dst_device_buffer;
  dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
                                     num_elem * sizeof(cl_ushort), NULL, &ret);
  if (ret != CL_SUCCESS) {
    printf("error: could not create dst buffer\n");
    exit(1);
  }
  ret = CL_SUCCESS;
  ret |= clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_0_device_buffer);
  ret |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &src_1_device_buffer);
  ret |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &src_2_device_buffer);
  ret |= clSetKernelArg(kernel, 3, sizeof(cl_mem), &dst_device_buffer);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clSetKernelArg' failed\n");
    exit(1);
  }
  size_t global_work_size = num_elem;
  size_t local_work_size = num_elem;
  ret =
      clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global_work_size,
                             &local_work_size, 0, NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueNDRangeKernel' failed\n");
    exit(1);
  }
  clFinish(command_queue);
  ret = clEnqueueReadBuffer(command_queue, dst_device_buffer, CL_TRUE, 0,
                            num_elem * sizeof(cl_ushort), dst_host_buffer, 0,
                            NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueReadBuffer' failed\n");
    exit(1);
  }
  char dump_file[100];
  sprintf((char *)&dump_file, "%s.result", argv[0]);
  write_buffer(dump_file, (const char *)dst_host_buffer,
               num_elem * sizeof(cl_ushort));
  printf("Result dumped to %s\n", dump_file);
  free(dst_host_buffer);
  ret = clReleaseMemObject(dst_device_buffer);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseMemObject' failed\n");
    exit(1);
  }
  free(src_0_host_buffer);
  ret = clReleaseMemObject(src_0_device_buffer);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseMemObject' failed\n");
    exit(1);
  }
  free(src_1_host_buffer);
  ret = clReleaseMemObject(src_1_device_buffer);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseMemObject' failed\n");
    exit(1);
  }
  free(src_2_host_buffer);
  ret = clReleaseMemObject(src_2_device_buffer);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseMemObject' failed\n");
    exit(1);
  }
  ret = clReleaseKernel(kernel);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseKernel' failed\n");
    exit(1);
  }
  ret = clReleaseProgram(program);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseProgram' failed\n");
    exit(1);
  }
  ret = clReleaseCommandQueue(command_queue);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseCommandQueue' failed\n");
    exit(1);
  }
  ret = clReleaseContext(context);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clReleaseContext' failed\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2ca0(%rip),%rcx
cmp    (%rcx),%eax
je     1328 <main+0x58>
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x18(%rbp),%esi
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c6c(%rip),%rax
mov    (%rax),%esi
lea    -0x80(%rbp),%rcx
mov    $0x64,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1120 <clGetPlatformInfo@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2c32(%rip),%rcx
cmp    (%rcx),%eax
je     1396 <main+0xc6>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0x80(%rbp),%rsi
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c1e(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
lea    -0x84(%rbp),%rcx
lea    -0x88(%rbp),%r8
call   10a0 <clGetDeviceIDs@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2bcf(%rip),%rcx
cmp    (%rcx),%eax
je     13f9 <main+0x129>
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x88(%rbp),%esi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x84(%rbp),%esi
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x84(%rbp),%edi
mov    0x2b8a(%rip),%rax
mov    (%rax),%esi
lea    -0xf0(%rbp),%rcx
mov    $0x64,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   10b0 <clGetDeviceInfo@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2b55(%rip),%rcx
cmp    (%rcx),%eax
je     1473 <main+0x1a3>
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0xf0(%rbp),%rsi
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x1,%esi
lea    -0x84(%rbp),%rdx
lea    -0x1c(%rbp),%r9
mov    %r8,%rdi
mov    %r8,%rcx
call   1130 <clCreateContext@plt>
mov    %eax,-0xf4(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2ae2(%rip),%rcx
cmp    (%rcx),%eax
je     14e6 <main+0x216>
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf4(%rbp),%esi
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0xf4(%rbp),%edi
mov    -0x84(%rbp),%esi
xor    %edx,%edx
lea    -0x1c(%rbp),%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0xf8(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2a87(%rip),%rcx
cmp    (%rcx),%eax
je     1541 <main+0x271>
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%esi
lea    0xc2a(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xc20(%rip),%rdi
lea    -0x108(%rbp),%rsi
call   1150 <read_buffer@plt>
mov    %rax,-0x100(%rbp)
mov    -0xf4(%rbp),%edi
mov    $0x1,%esi
lea    -0x100(%rbp),%rdx
lea    -0x108(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1060 <clCreateProgramWithSource@plt>
mov    %eax,-0x10c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x29f9(%rip),%rcx
cmp    (%rcx),%eax
je     15cf <main+0x2ff>
lea    0xbea(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x10c(%rbp),%esi
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x10c(%rbp),%edi
mov    $0x1,%esi
lea    -0x84(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2996(%rip),%rcx
cmp    (%rcx),%eax
je     16ae <main+0x3de>
mov    -0x10c(%rbp),%edi
mov    -0x84(%rbp),%esi
mov    0x29ab(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x118(%rbp),%r9
mov    %r8,%rcx
call   1140 <clGetProgramBuildInfo@plt>
mov    -0x118(%rbp),%rdi
call   1170 <malloc@plt>
mov    %rax,-0x120(%rbp)
mov    -0x10c(%rbp),%edi
mov    -0x84(%rbp),%esi
mov    0x296f(%rip),%rax
mov    (%rax),%edx
mov    -0x118(%rbp),%rcx
mov    -0x120(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   1140 <clGetProgramBuildInfo@plt>
mov    -0x120(%rbp),%rsi
lea    0xb56(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x120(%rbp),%rdi
call   1040 <free@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    0xb5e(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0x9cb(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x10c(%rbp),%edi
lea    0xb4b(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   11b0 <clCreateKernel@plt>
mov    %eax,-0x124(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x28b8(%rip),%rcx
cmp    (%rcx),%eax
je     1710 <main+0x440>
lea    0xb3e(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
movq   $0xa,-0x130(%rbp)
mov    -0x130(%rbp),%rdi
shl    $0x0,%rdi
call   1170 <malloc@plt>
mov    %rax,-0x138(%rbp)
movl   $0x0,-0x13c(%rbp)
movslq -0x13c(%rbp),%rax
cmp    -0x130(%rbp),%rax
jae    1776 <main+0x4a6>
mov    -0x138(%rbp),%rax
movslq -0x13c(%rbp),%rcx
movb   $0x2,(%rax,%rcx,1)
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    173c <main+0x46c>
mov    -0xf4(%rbp),%edi
mov    0x282d(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1c(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x140(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x27fb(%rip),%rcx
cmp    (%rcx),%eax
je     17cd <main+0x4fd>
lea    0xaa9(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%edi
mov    -0x140(%rbp),%esi
mov    0x2808(%rip),%rax
mov    (%rax),%edx
mov    -0x130(%rbp),%r8
shl    $0x0,%r8
mov    -0x138(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11f0 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2785(%rip),%rcx
cmp    (%rcx),%eax
je     1843 <main+0x573>
lea    0xa5a(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x130(%rbp),%rdi
shl    $0x0,%rdi
call   1170 <malloc@plt>
mov    %rax,-0x148(%rbp)
movl   $0x0,-0x14c(%rbp)
movslq -0x14c(%rbp),%rax
cmp    -0x130(%rbp),%rax
jae    189e <main+0x5ce>
mov    -0x148(%rbp),%rax
movslq -0x14c(%rbp),%rcx
movb   $0x2,(%rax,%rcx,1)
mov    -0x14c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14c(%rbp)
jmp    1864 <main+0x594>
mov    -0xf4(%rbp),%edi
mov    0x2705(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1c(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x150(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x26d3(%rip),%rcx
cmp    (%rcx),%eax
je     18f5 <main+0x625>
lea    0x981(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%edi
mov    -0x150(%rbp),%esi
mov    0x26e0(%rip),%rax
mov    (%rax),%edx
mov    -0x130(%rbp),%r8
shl    $0x0,%r8
mov    -0x148(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11f0 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x265d(%rip),%rcx
cmp    (%rcx),%eax
je     196b <main+0x69b>
lea    0x932(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x130(%rbp),%rdi
shl    $0x0,%rdi
call   1170 <malloc@plt>
mov    %rax,-0x158(%rbp)
movl   $0x0,-0x15c(%rbp)
movslq -0x15c(%rbp),%rax
cmp    -0x130(%rbp),%rax
jae    19c6 <main+0x6f6>
mov    -0x158(%rbp),%rax
movslq -0x15c(%rbp),%rcx
movb   $0x2,(%rax,%rcx,1)
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    198c <main+0x6bc>
mov    -0xf4(%rbp),%edi
mov    0x25dd(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1c(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x160(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x25ab(%rip),%rcx
cmp    (%rcx),%eax
je     1a1d <main+0x74d>
lea    0x859(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%edi
mov    -0x160(%rbp),%esi
mov    0x25b8(%rip),%rax
mov    (%rax),%edx
mov    -0x130(%rbp),%r8
shl    $0x0,%r8
mov    -0x158(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11f0 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2535(%rip),%rcx
cmp    (%rcx),%eax
je     1a93 <main+0x7c3>
lea    0x80a(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x130(%rbp),%rdi
shl    $0x0,%rdi
call   1170 <malloc@plt>
mov    %rax,-0x168(%rbp)
mov    -0x168(%rbp),%rdi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
mov    $0x1,%esi
call   1110 <memset@plt>
mov    -0xf4(%rbp),%edi
mov    0x250d(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1c(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x16c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x24ab(%rip),%rcx
cmp    (%rcx),%eax
je     1b1d <main+0x84d>
lea    0x7ae(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    0x2484(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x124(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x140(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x124(%rbp),%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0x150(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x124(%rbp),%edi
mov    $0x2,%esi
mov    $0x4,%edx
lea    -0x160(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x124(%rbp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
lea    -0x16c(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x23f0(%rip),%rcx
cmp    (%rcx),%eax
je     1bd8 <main+0x908>
lea    0x717(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x130(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0xf8(%rbp),%edi
mov    -0x124(%rbp),%esi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x178(%rbp),%r8
lea    -0x180(%rbp),%r9
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   10d0 <clEnqueueNDRangeKernel@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2364(%rip),%rcx
cmp    (%rcx),%eax
je     1c64 <main+0x994>
lea    0x6b3(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%edi
call   1050 <clFinish@plt>
mov    -0xf8(%rbp),%edi
mov    -0x16c(%rbp),%esi
mov    0x2366(%rip),%rax
mov    (%rax),%edx
mov    -0x130(%rbp),%r8
shl    $0x0,%r8
mov    -0x168(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1180 <clEnqueueReadBuffer@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x22e3(%rip),%rcx
cmp    (%rcx),%eax
je     1ce5 <main+0xa15>
lea    0x662(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0x1f0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x669(%rip),%rsi
call   11c0 <sprintf@plt>
lea    -0x1f0(%rbp),%rdi
mov    -0x168(%rbp),%rsi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
call   10c0 <write_buffer@plt>
lea    -0x1f0(%rbp),%rsi
lea    0x642(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x168(%rbp),%rdi
call   1040 <free@plt>
mov    -0x16c(%rbp),%edi
call   11a0 <clReleaseMemObject@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2252(%rip),%rcx
cmp    (%rcx),%eax
je     1d76 <main+0xaa6>
lea    0x61d(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x138(%rbp),%rdi
call   1040 <free@plt>
mov    -0x140(%rbp),%edi
call   11a0 <clReleaseMemObject@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x220e(%rip),%rcx
cmp    (%rcx),%eax
je     1dba <main+0xaea>
lea    0x5d9(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x148(%rbp),%rdi
call   1040 <free@plt>
mov    -0x150(%rbp),%edi
call   11a0 <clReleaseMemObject@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x21ca(%rip),%rcx
cmp    (%rcx),%eax
je     1dfe <main+0xb2e>
lea    0x595(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x158(%rbp),%rdi
call   1040 <free@plt>
mov    -0x160(%rbp),%edi
call   11a0 <clReleaseMemObject@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2186(%rip),%rcx
cmp    (%rcx),%eax
je     1e42 <main+0xb72>
lea    0x551(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x124(%rbp),%edi
call   1070 <clReleaseKernel@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x214e(%rip),%rcx
cmp    (%rcx),%eax
je     1e7a <main+0xbaa>
lea    0x545(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x10c(%rbp),%edi
call   1090 <clReleaseProgram@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2116(%rip),%rcx
cmp    (%rcx),%eax
je     1eb2 <main+0xbe2>
lea    0x536(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%edi
call   1160 <clReleaseCommandQueue@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x20de(%rip),%rcx
cmp    (%rcx),%eax
je     1eea <main+0xc1a>
lea    0x528(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf4(%rbp),%edi
call   1190 <clReleaseContext@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x20a6(%rip),%rcx
cmp    (%rcx),%eax
je     1f22 <main+0xc52>
lea    0x51f(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
mov    %rsi,%r13
lea    0x38(%rsp),%rsi
lea    0x54(%rsp),%rdx
mov    $0x1,%edi
call   1110 <clGetPlatformIDs@plt>
mov    %eax,0x24(%rsp)
mov    0x2c85(%rip),%r12
cmp    (%r12),%eax
jne    19d3 <main+0x6e3>
mov    0x54(%rsp),%esi
lea    0xcd8(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x38(%rsp),%esi
lea    0xcdf(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x38(%rsp),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
lea    0x170(%rsp),%rcx
mov    $0x64,%edx
xor    %r8d,%r8d
call   1140 <clGetPlatformInfo@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19df <main+0x6ef>
lea    0xcae(%rip),%rdi
lea    0x170(%rsp),%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x38(%rsp),%edi
mov    0x2c2e(%rip),%rax
mov    (%rax),%esi
lea    0x28(%rsp),%rcx
lea    0x50(%rsp),%r8
mov    $0x1,%edx
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19eb <main+0x6fb>
mov    0x50(%rsp),%esi
lea    0xc7a(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%esi
lea    0xc7f(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x2bc3(%rip),%rax
mov    (%rax),%esi
lea    0x100(%rsp),%rcx
mov    $0x64,%edx
xor    %r8d,%r8d
call   10d0 <clGetDeviceInfo@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19f7 <main+0x707>
lea    0xc4c(%rip),%rdi
lea    0x100(%rsp),%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0x28(%rsp),%rdx
lea    0x24(%rsp),%r9
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1150 <clCreateContext@plt>
mov    %eax,%ebx
mov    0x24(%rsp),%eax
cmp    (%r12),%eax
jne    1a03 <main+0x713>
lea    0xc13(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%esi
lea    0x24(%rsp),%rcx
mov    %ebx,%edi
xor    %edx,%edx
call   1100 <clCreateCommandQueue@plt>
mov    %eax,%r14d
mov    0x24(%rsp),%eax
cmp    (%r12),%eax
jne    1a0f <main+0x71f>
lea    0xbec(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1120 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xbe3(%rip),%rdi
lea    0x88(%rsp),%rbp
mov    %rbp,%rsi
call   1170 <read_buffer@plt>
mov    %rax,0x80(%rsp)
lea    0x80(%rsp),%rdx
lea    0x24(%rsp),%r8
mov    %ebx,%edi
mov    $0x1,%esi
mov    %rbp,%rcx
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebp
mov    0x24(%rsp),%eax
cmp    (%r12),%eax
jne    1a1b <main+0x72b>
lea    0xbb6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1120 <printf@plt>
lea    0x28(%rsp),%rdx
mov    %ebp,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1a27 <main+0x737>
mov    %r14d,0x2c(%rsp)
mov    %ebx,0x30(%rsp)
lea    0xbe8(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xb98(%rip),%rsi
lea    0x24(%rsp),%rdx
mov    %ebp,%edi
call   11d0 <clCreateKernel@plt>
mov    %eax,%r14d
mov    0x24(%rsp),%eax
cmp    (%r12),%eax
jne    1a96 <main+0x7a6>
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%r15
movabs $0x202020202020202,%rax
02 02 02
mov    %rax,(%r15)
movw   $0x202,0x8(%r15)
mov    0x2a10(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%r8
mov    $0xa,%edx
mov    0x30(%rsp),%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x48(%rsp)
mov    0x24(%rsp),%ecx
cmp    (%r12),%ecx
jne    19bb <main+0x6cb>
mov    0x2a18(%rip),%rcx
mov    (%rcx),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    0x2c(%rsp),%edi
mov    %eax,%esi
xor    %ecx,%ecx
mov    %r15,0x68(%rsp)
mov    %r15,%r9
call   1210 <clEnqueueWriteBuffer@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19c7 <main+0x6d7>
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%rbx
movabs $0x202020202020202,%rax
02 02 02
mov    %rax,(%rbx)
movw   $0x202,0x8(%rbx)
mov    0x297f(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%r8
mov    $0xa,%edx
mov    0x30(%rsp),%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x44(%rsp)
mov    0x24(%rsp),%ecx
cmp    (%r12),%ecx
jne    19bb <main+0x6cb>
mov    %r14d,0x3c(%rsp)
mov    %r13,0x60(%rsp)
mov    0x297d(%rip),%r14
mov    (%r14),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    0x2c(%rsp),%edi
mov    %eax,%esi
xor    %ecx,%ecx
mov    %rbx,0x58(%rsp)
mov    %rbx,%r9
call   1210 <clEnqueueWriteBuffer@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19c7 <main+0x6d7>
mov    %ebp,0x4c(%rsp)
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%r15
movabs $0x202020202020202,%rax
02 02 02
mov    %rax,(%r15)
movw   $0x202,0x8(%r15)
mov    0x28de(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%r8
mov    $0xa,%edx
mov    0x30(%rsp),%ebx
mov    %ebx,%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x40(%rsp)
mov    0x24(%rsp),%ecx
cmp    (%r12),%ecx
jne    19bb <main+0x6cb>
mov    (%r14),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    0x2c(%rsp),%ebp
mov    %ebp,%edi
mov    %eax,%esi
xor    %ecx,%ecx
mov    %r15,%r9
call   1210 <clEnqueueWriteBuffer@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19c7 <main+0x6d7>
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%r13
mov    $0xa,%edx
mov    %rax,%rdi
mov    $0x1,%esi
call   1130 <memset@plt>
mov    0x2885(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%r8
mov    $0xa,%edx
mov    %ebx,%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x34(%rsp)
mov    0x24(%rsp),%eax
cmp    (%r12),%eax
jne    1a9f <main+0x7af>
lea    0x48(%rsp),%rcx
mov    0x3c(%rsp),%ebx
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     %eax,0x24(%rsp)
lea    0x44(%rsp),%rcx
mov    %ebx,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     %eax,0x24(%rsp)
lea    0x40(%rsp),%rcx
mov    %ebx,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     %eax,0x24(%rsp)
lea    0x34(%rsp),%rcx
mov    %ebx,%edi
mov    $0x3,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     0x24(%rsp),%eax
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1aa8 <main+0x7b8>
movq   $0xa,0x78(%rsp)
movq   $0xa,0x70(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x78(%rsp),%r8
lea    0x70(%rsp),%r9
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   10f0 <clEnqueueNDRangeKernel@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1ab1 <main+0x7c1>
mov    %ebp,%edi
call   1060 <clFinish@plt>
mov    0x34(%rsp),%esi
mov    (%r14),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    %ebp,%edi
xor    %ecx,%ecx
mov    %r13,%r9
call   11a0 <clEnqueueReadBuffer@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1aba <main+0x7ca>
mov    0x60(%rsp),%rax
mov    (%rax),%rdx
lea    0x880(%rip),%rsi
lea    0x90(%rsp),%r14
mov    %r14,%rdi
call   11e0 <sprintf@plt>
mov    $0xa,%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   10e0 <write_buffer@plt>
lea    0x863(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    0x34(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
mov    0x68(%rsp),%rdi
jne    19af <main+0x6bf>
call   1040 <free@plt>
mov    0x48(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19af <main+0x6bf>
mov    0x58(%rsp),%rdi
call   1040 <free@plt>
mov    0x44(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
mov    0x30(%rsp),%ebx
mov    0x2c(%rsp),%ebp
jne    19af <main+0x6bf>
mov    %r15,%rdi
call   1040 <free@plt>
mov    0x40(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    19af <main+0x6bf>
mov    0x3c(%rsp),%edi
call   1090 <clReleaseKernel@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1ac3 <main+0x7d3>
mov    0x4c(%rsp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1acc <main+0x7dc>
mov    %ebp,%edi
call   1180 <clReleaseCommandQueue@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1ad5 <main+0x7e5>
mov    %ebx,%edi
call   11b0 <clReleaseContext@plt>
mov    %eax,0x24(%rsp)
cmp    (%r12),%eax
jne    1ade <main+0x7ee>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x82d(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x91e(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x8e5(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0xa53(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0xa1d(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x9ea(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x9b6(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x982(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x949(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x90b(%rip),%rdi
jmp    1ae5 <main+0x7f5>
mov    0x28(%rsp),%esi
mov    0x25a6(%rip),%r14
mov    (%r14),%edx
lea    0x90(%rsp),%r9
mov    %ebp,%edi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1160 <clGetProgramBuildInfo@plt>
mov    0x90(%rsp),%rbx
mov    %rbx,%rdi
call   1190 <malloc@plt>
mov    %ebp,%edi
mov    %rax,%rbp
mov    0x28(%rsp),%esi
mov    (%r14),%edx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %r9d,%r9d
call   1160 <clGetProgramBuildInfo@plt>
lea    0x64d(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    $0x1,%edi
call   11f0 <exit@plt>
lea    0x869(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x7ea(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x7ba(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x782(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x74d(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x6f1(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x6bf(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x688(%rip),%rdi
jmp    1ae5 <main+0x7f5>
lea    0x656(%rip),%rdi
call   1080 <puts@plt>
mov    $0x1,%edi
call   11f0 <exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i32 0
@.str = [42 x i8] c"error: call to 'clGetPlatformIDs' failed\0A\00"
@.str.1 = [25 x i8] c"Number of platforms: %d\0A\00"
@.str.2 = [13 x i8] c"platform=%p\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.3 = [43 x i8] c"error: call to 'clGetPlatformInfo' failed\0A\00"
@.str.4 = [21 x i8] c"platform.name='%s'\0A\0A\00"
@CL_DEVICE_TYPE_GPU = global i32 0
@.str.5 = [40 x i8] c"error: call to 'clGetDeviceIDs' failed\0A\00"
@.str.6 = [23 x i8] c"Number of devices: %d\0A\00"
@.str.7 = [11 x i8] c"device=%p\0A\00"
@CL_DEVICE_NAME = global i32 0
@.str.8 = [41 x i8] c"error: call to 'clGetDeviceInfo' failed\0A\00"
@.str.9 = [18 x i8] c"device.name='%s'\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [41 x i8] c"error: call to 'clCreateContext' failed\0A\00"
@.str.12 = [12 x i8] c"context=%p\0A\00"
@.str.13 = [46 x i8] c"error: call to 'clCreateCommandQueue' failed\0A\00"
@.str.14 = [18 x i8] c"command_queue=%p\0A\00"
@.str.15 = [30 x i8] c"mad_sat_ushortushortushort.cl\00"
@.str.16 = [51 x i8] c"error: call to 'clCreateProgramWithSource' failed\0A\00"
@.str.17 = [12 x i8] c"program=%p\0A\00"
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.18 = [44 x i8] c"error: call to 'clBuildProgram' failed:\0A%s\0A\00"
@.str.19 = [15 x i8] c"program built\0A\00"
@.str.20 = [27 x i8] c"mad_sat_ushortushortushort\00"
@.str.21 = [40 x i8] c"error: call to 'clCreateKernel' failed\0A\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.22 = [39 x i8] c"error: could not create source buffer\0A\00"
@CL_TRUE = global i32 0
@.str.23 = [46 x i8] c"error: call to 'clEnqueueWriteBuffer' failed\0A\00"
@CL_MEM_WRITE_ONLY = global i32 0
@.str.24 = [36 x i8] c"error: could not create dst buffer\0A\00"
@.str.25 = [40 x i8] c"error: call to 'clSetKernelArg' failed\0A\00"
@.str.26 = [48 x i8] c"error: call to 'clEnqueueNDRangeKernel' failed\0A\00"
@.str.27 = [45 x i8] c"error: call to 'clEnqueueReadBuffer' failed\0A\00"
@.str.28 = [10 x i8] c"%s.result\00"
@.str.29 = [21 x i8] c"Result dumped to %s\0A\00"
@.str.30 = [44 x i8] c"error: call to 'clReleaseMemObject' failed\0A\00"
@.str.31 = [41 x i8] c"error: call to 'clReleaseKernel' failed\0A\00"
@.str.32 = [42 x i8] c"error: call to 'clReleaseProgram' failed\0A\00"
@.str.33 = [47 x i8] c"error: call to 'clReleaseCommandQueue' failed\0A\00"
@.str.34 = [42 x i8] c"error: call to 'clReleaseContext' failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [100 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
%18 = alloca i64
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i64
%22 = alloca i8*
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i32
%27 = alloca i32
%28 = alloca i8*
%29 = alloca i32
%30 = alloca i32
%31 = alloca i8*
%32 = alloca i32
%33 = alloca i64
%34 = alloca i64
%35 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%36 = call i32 @clGetPlatformIDs(i32 1, i32* %6, i32* %7)
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = load i32, i32* @CL_SUCCESS
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %2
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %6
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %6
%49 = load i32, i32* @CL_PLATFORM_NAME
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%51 = call i32 @clGetPlatformInfo(i32 %48, i32 %49, i32 100, i8* %50, i32* null)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = load i32, i32* @CL_SUCCESS
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %58
55: ; preds = %43
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %43
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = load i32, i32* %6
%62 = load i32, i32* @CL_DEVICE_TYPE_GPU
%63 = call i32 @clGetDeviceIDs(i32 %61, i32 %62, i32 1, i32* %10, i32* %11)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = load i32, i32* @CL_SUCCESS
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %58
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %58
%71 = load i32, i32* %11
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %10
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %73)
%75 = load i32, i32* %10
%76 = load i32, i32* @CL_DEVICE_NAME
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%78 = call i32 @clGetDeviceInfo(i32 %75, i32 %76, i32 100, i8* %77, i32* null)
store i32 %78, i32* %8
%79 = load i32, i32* %8
%80 = load i32, i32* @CL_SUCCESS
%81 = icmp ne i32 %79, %80
br i1 %81, label %82, label %85
82: ; preds = %70
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %70
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%89 = call i32 @clCreateContext(i32* null, i32 1, i32* %10, i32* null, i32* null, i32* %8)
store i32 %89, i32* %13
%90 = load i32, i32* %8
%91 = load i32, i32* @CL_SUCCESS
%92 = icmp ne i32 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %85
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %85
%97 = load i32, i32* %13
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %97)
%99 = load i32, i32* %13
%100 = load i32, i32* %10
%101 = call i32 @clCreateCommandQueue(i32 %99, i32 %100, i32 0, i32* %8)
store i32 %101, i32* %14
%102 = load i32, i32* %8
%103 = load i32, i32* @CL_SUCCESS
%104 = icmp ne i32 %102, %103
br i1 %104, label %105, label %108
105: ; preds = %96
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %96
%109 = load i32, i32* %14
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %109)
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%112 = call i8* @read_buffer(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.15, i64 0, i64 0), i64* %16)
store i8* %112, i8** %15
%113 = load i32, i32* %13
%114 = call i32 @clCreateProgramWithSource(i32 %113, i32 1, i8** %15, i64* %16, i32* %8)
store i32 %114, i32* %17
%115 = load i32, i32* %8
%116 = load i32, i32* @CL_SUCCESS
%117 = icmp ne i32 %115, %116
br i1 %117, label %118, label %121
118: ; preds = %108
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.16, i64 0, i64 0))
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %108
%122 = load i32, i32* %17
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %122)
%124 = load i32, i32* %17
%125 = call i32 @clBuildProgram(i32 %124, i32 1, i32* %10, i32* null, i32* null, i32* null)
store i32 %125, i32* %8
%126 = load i32, i32* %8
%127 = load i32, i32* @CL_SUCCESS
%128 = icmp ne i32 %126, %127
br i1 %128, label %129, label %147
129: ; preds = %121
%130 = load i32, i32* %17
%131 = load i32, i32* %10
%132 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%133 = call i32 @clGetProgramBuildInfo(i32 %130, i32 %131, i32 %132, i64 0, i8* null, i64* %18)
%134 = load i64, i64* %18
%135 = call i8* @malloc(i64 %134)
store i8* %135, i8** %19
%136 = load i32, i32* %17
%137 = load i32, i32* %10
%138 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%139 = load i64, i64* %18
%140 = load i8*, i8** %19
%141 = call i32 @clGetProgramBuildInfo(i32 %136, i32 %137, i32 %138, i64 %139, i8* %140, i64* null)
%142 = load i8*, i8** %19
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %142)
%144 = load i8*, i8** %19
%145 = call i32 @free(i8* %144)
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %121
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%150 = load i32, i32* %17
%151 = call i32 @clCreateKernel(i32 %150, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i64 0, i64 0), i32* %8)
store i32 %151, i32* %20
%152 = load i32, i32* %8
%153 = load i32, i32* @CL_SUCCESS
%154 = icmp ne i32 %152, %153
br i1 %154, label %155, label %158
155: ; preds = %147
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.21, i64 0, i64 0))
%157 = call i32 @exit(i32 1)
unreachable
158: ; preds = %147
store i64 10, i64* %21
%159 = load i64, i64* %21
%160 = mul i64 %159, 1
%161 = call i8* @malloc(i64 %160)
store i8* %161, i8** %22
store i32 0, i32* %23
br label %162
162: ; preds = %172, %158
%163 = load i32, i32* %23
%164 = sext i32 %163 to i64
%165 = load i64, i64* %21
%166 = icmp ult i64 %164, %165
br i1 %166, label %167, label %175
167: ; preds = %162
%168 = load i8*, i8** %22
%169 = load i32, i32* %23
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i8, i8* %168, i64 %170
store i8 2, i8* %171
br label %172
172: ; preds = %167
%173 = load i32, i32* %23
%174 = add nsw i32 %173, 1
store i32 %174, i32* %23
br label %162
175: ; preds = %162
%176 = load i32, i32* %13
%177 = load i32, i32* @CL_MEM_READ_ONLY
%178 = load i64, i64* %21
%179 = mul i64 %178, 1
%180 = call i32 @clCreateBuffer(i32 %176, i32 %177, i64 %179, i32* null, i32* %8)
store i32 %180, i32* %24
%181 = load i32, i32* %8
%182 = load i32, i32* @CL_SUCCESS
%183 = icmp ne i32 %181, %182
br i1 %183, label %184, label %187
184: ; preds = %175
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.22, i64 0, i64 0))
%186 = call i32 @exit(i32 1)
unreachable
187: ; preds = %175
%188 = load i32, i32* %14
%189 = load i32, i32* %24
%190 = load i32, i32* @CL_TRUE
%191 = load i64, i64* %21
%192 = mul i64 %191, 1
%193 = load i8*, i8** %22
%194 = call i32 @clEnqueueWriteBuffer(i32 %188, i32 %189, i32 %190, i32 0, i64 %192, i8* %193, i32 0, i32* null, i32* null)
store i32 %194, i32* %8
%195 = load i32, i32* %8
%196 = load i32, i32* @CL_SUCCESS
%197 = icmp ne i32 %195, %196
br i1 %197, label %198, label %201
198: ; preds = %187
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0))
%200 = call i32 @exit(i32 1)
unreachable
201: ; preds = %187
%202 = load i64, i64* %21
%203 = mul i64 %202, 1
%204 = call i8* @malloc(i64 %203)
store i8* %204, i8** %25
store i32 0, i32* %26
br label %205
205: ; preds = %215, %201
%206 = load i32, i32* %26
%207 = sext i32 %206 to i64
%208 = load i64, i64* %21
%209 = icmp ult i64 %207, %208
br i1 %209, label %210, label %218
210: ; preds = %205
%211 = load i8*, i8** %25
%212 = load i32, i32* %26
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds i8, i8* %211, i64 %213
store i8 2, i8* %214
br label %215
215: ; preds = %210
%216 = load i32, i32* %26
%217 = add nsw i32 %216, 1
store i32 %217, i32* %26
br label %205
218: ; preds = %205
%219 = load i32, i32* %13
%220 = load i32, i32* @CL_MEM_READ_ONLY
%221 = load i64, i64* %21
%222 = mul i64 %221, 1
%223 = call i32 @clCreateBuffer(i32 %219, i32 %220, i64 %222, i32* null, i32* %8)
store i32 %223, i32* %27
%224 = load i32, i32* %8
%225 = load i32, i32* @CL_SUCCESS
%226 = icmp ne i32 %224, %225
br i1 %226, label %227, label %230
227: ; preds = %218
%228 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.22, i64 0, i64 0))
%229 = call i32 @exit(i32 1)
unreachable
230: ; preds = %218
%231 = load i32, i32* %14
%232 = load i32, i32* %27
%233 = load i32, i32* @CL_TRUE
%234 = load i64, i64* %21
%235 = mul i64 %234, 1
%236 = load i8*, i8** %25
%237 = call i32 @clEnqueueWriteBuffer(i32 %231, i32 %232, i32 %233, i32 0, i64 %235, i8* %236, i32 0, i32* null, i32* null)
store i32 %237, i32* %8
%238 = load i32, i32* %8
%239 = load i32, i32* @CL_SUCCESS
%240 = icmp ne i32 %238, %239
br i1 %240, label %241, label %244
241: ; preds = %230
%242 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0))
%243 = call i32 @exit(i32 1)
unreachable
244: ; preds = %230
%245 = load i64, i64* %21
%246 = mul i64 %245, 1
%247 = call i8* @malloc(i64 %246)
store i8* %247, i8** %28
store i32 0, i32* %29
br label %248
248: ; preds = %258, %244
%249 = load i32, i32* %29
%250 = sext i32 %249 to i64
%251 = load i64, i64* %21
%252 = icmp ult i64 %250, %251
br i1 %252, label %253, label %261
253: ; preds = %248
%254 = load i8*, i8** %28
%255 = load i32, i32* %29
%256 = sext i32 %255 to i64
%257 = getelementptr inbounds i8, i8* %254, i64 %256
store i8 2, i8* %257
br label %258
258: ; preds = %253
%259 = load i32, i32* %29
%260 = add nsw i32 %259, 1
store i32 %260, i32* %29
br label %248
261: ; preds = %248
%262 = load i32, i32* %13
%263 = load i32, i32* @CL_MEM_READ_ONLY
%264 = load i64, i64* %21
%265 = mul i64 %264, 1
%266 = call i32 @clCreateBuffer(i32 %262, i32 %263, i64 %265, i32* null, i32* %8)
store i32 %266, i32* %30
%267 = load i32, i32* %8
%268 = load i32, i32* @CL_SUCCESS
%269 = icmp ne i32 %267, %268
br i1 %269, label %270, label %273
270: ; preds = %261
%271 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.22, i64 0, i64 0))
%272 = call i32 @exit(i32 1)
unreachable
273: ; preds = %261
%274 = load i32, i32* %14
%275 = load i32, i32* %30
%276 = load i32, i32* @CL_TRUE
%277 = load i64, i64* %21
%278 = mul i64 %277, 1
%279 = load i8*, i8** %28
%280 = call i32 @clEnqueueWriteBuffer(i32 %274, i32 %275, i32 %276, i32 0, i64 %278, i8* %279, i32 0, i32* null, i32* null)
store i32 %280, i32* %8
%281 = load i32, i32* %8
%282 = load i32, i32* @CL_SUCCESS
%283 = icmp ne i32 %281, %282
br i1 %283, label %284, label %287
284: ; preds = %273
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0))
%286 = call i32 @exit(i32 1)
unreachable
287: ; preds = %273
%288 = load i64, i64* %21
%289 = mul i64 %288, 1
%290 = call i8* @malloc(i64 %289)
store i8* %290, i8** %31
%291 = load i8*, i8** %31
%292 = load i64, i64* %21
%293 = mul i64 %292, 1
%294 = call i32 @memset(i8* %291, i32 1, i64 %293)
%295 = load i32, i32* %13
%296 = load i32, i32* @CL_MEM_WRITE_ONLY
%297 = load i64, i64* %21
%298 = mul i64 %297, 1
%299 = call i32 @clCreateBuffer(i32 %295, i32 %296, i64 %298, i32* null, i32* %8)
store i32 %299, i32* %32
%300 = load i32, i32* %8
%301 = load i32, i32* @CL_SUCCESS
%302 = icmp ne i32 %300, %301
br i1 %302, label %303, label %306
303: ; preds = %287
%304 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.24, i64 0, i64 0))
%305 = call i32 @exit(i32 1)
unreachable
306: ; preds = %287
%307 = load i32, i32* @CL_SUCCESS
store i32 %307, i32* %8
%308 = load i32, i32* %20
%309 = call i32 @clSetKernelArg(i32 %308, i32 0, i32 4, i32* %24)
%310 = load i32, i32* %8
%311 = or i32 %310, %309
store i32 %311, i32* %8
%312 = load i32, i32* %20
%313 = call i32 @clSetKernelArg(i32 %312, i32 1, i32 4, i32* %27)
%314 = load i32, i32* %8
%315 = or i32 %314, %313
store i32 %315, i32* %8
%316 = load i32, i32* %20
%317 = call i32 @clSetKernelArg(i32 %316, i32 2, i32 4, i32* %30)
%318 = load i32, i32* %8
%319 = or i32 %318, %317
store i32 %319, i32* %8
%320 = load i32, i32* %20
%321 = call i32 @clSetKernelArg(i32 %320, i32 3, i32 4, i32* %32)
%322 = load i32, i32* %8
%323 = or i32 %322, %321
store i32 %323, i32* %8
%324 = load i32, i32* %8
%325 = load i32, i32* @CL_SUCCESS
%326 = icmp ne i32 %324, %325
br i1 %326, label %327, label %330
327: ; preds = %306
%328 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.25, i64 0, i64 0))
%329 = call i32 @exit(i32 1)
unreachable
330: ; preds = %306
%331 = load i64, i64* %21
store i64 %331, i64* %33
%332 = load i64, i64* %21
store i64 %332, i64* %34
%333 = load i32, i32* %14
%334 = load i32, i32* %20
%335 = call i32 @clEnqueueNDRangeKernel(i32 %333, i32 %334, i32 1, i32* null, i64* %33, i64* %34, i32 0, i32* null, i32* null)
store i32 %335, i32* %8
%336 = load i32, i32* %8
%337 = load i32, i32* @CL_SUCCESS
%338 = icmp ne i32 %336, %337
br i1 %338, label %339, label %342
339: ; preds = %330
%340 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.26, i64 0, i64 0))
%341 = call i32 @exit(i32 1)
unreachable
342: ; preds = %330
%343 = load i32, i32* %14
%344 = call i32 @clFinish(i32 %343)
%345 = load i32, i32* %14
%346 = load i32, i32* %32
%347 = load i32, i32* @CL_TRUE
%348 = load i64, i64* %21
%349 = mul i64 %348, 1
%350 = load i8*, i8** %31
%351 = call i32 @clEnqueueReadBuffer(i32 %345, i32 %346, i32 %347, i32 0, i64 %349, i8* %350, i32 0, i32* null, i32* null)
store i32 %351, i32* %8
%352 = load i32, i32* %8
%353 = load i32, i32* @CL_SUCCESS
%354 = icmp ne i32 %352, %353
br i1 %354, label %355, label %358
355: ; preds = %342
%356 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.27, i64 0, i64 0))
%357 = call i32 @exit(i32 1)
unreachable
358: ; preds = %342
%359 = bitcast [100 x i8]* %35 to i8*
%360 = load i8**, i8*** %5
%361 = getelementptr inbounds i8*, i8** %360, i64 0
%362 = load i8*, i8** %361
%363 = call i32 @sprintf(i8* %359, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %362)
%364 = getelementptr inbounds [100 x i8], [100 x i8]* %35, i64 0, i64 0
%365 = load i8*, i8** %31
%366 = load i64, i64* %21
%367 = mul i64 %366, 1
%368 = call i32 @write_buffer(i8* %364, i8* %365, i64 %367)
%369 = getelementptr inbounds [100 x i8], [100 x i8]* %35, i64 0, i64 0
%370 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %369)
%371 = load i8*, i8** %31
%372 = call i32 @free(i8* %371)
%373 = load i32, i32* %32
%374 = call i32 @clReleaseMemObject(i32 %373)
store i32 %374, i32* %8
%375 = load i32, i32* %8
%376 = load i32, i32* @CL_SUCCESS
%377 = icmp ne i32 %375, %376
br i1 %377, label %378, label %381
378: ; preds = %358
%379 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%380 = call i32 @exit(i32 1)
unreachable
381: ; preds = %358
%382 = load i8*, i8** %22
%383 = call i32 @free(i8* %382)
%384 = load i32, i32* %24
%385 = call i32 @clReleaseMemObject(i32 %384)
store i32 %385, i32* %8
%386 = load i32, i32* %8
%387 = load i32, i32* @CL_SUCCESS
%388 = icmp ne i32 %386, %387
br i1 %388, label %389, label %392
389: ; preds = %381
%390 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%391 = call i32 @exit(i32 1)
unreachable
392: ; preds = %381
%393 = load i8*, i8** %25
%394 = call i32 @free(i8* %393)
%395 = load i32, i32* %27
%396 = call i32 @clReleaseMemObject(i32 %395)
store i32 %396, i32* %8
%397 = load i32, i32* %8
%398 = load i32, i32* @CL_SUCCESS
%399 = icmp ne i32 %397, %398
br i1 %399, label %400, label %403
400: ; preds = %392
%401 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%402 = call i32 @exit(i32 1)
unreachable
403: ; preds = %392
%404 = load i8*, i8** %28
%405 = call i32 @free(i8* %404)
%406 = load i32, i32* %30
%407 = call i32 @clReleaseMemObject(i32 %406)
store i32 %407, i32* %8
%408 = load i32, i32* %8
%409 = load i32, i32* @CL_SUCCESS
%410 = icmp ne i32 %408, %409
br i1 %410, label %411, label %414
411: ; preds = %403
%412 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%413 = call i32 @exit(i32 1)
unreachable
414: ; preds = %403
%415 = load i32, i32* %20
%416 = call i32 @clReleaseKernel(i32 %415)
store i32 %416, i32* %8
%417 = load i32, i32* %8
%418 = load i32, i32* @CL_SUCCESS
%419 = icmp ne i32 %417, %418
br i1 %419, label %420, label %423
420: ; preds = %414
%421 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.31, i64 0, i64 0))
%422 = call i32 @exit(i32 1)
unreachable
423: ; preds = %414
%424 = load i32, i32* %17
%425 = call i32 @clReleaseProgram(i32 %424)
store i32 %425, i32* %8
%426 = load i32, i32* %8
%427 = load i32, i32* @CL_SUCCESS
%428 = icmp ne i32 %426, %427
br i1 %428, label %429, label %432
429: ; preds = %423
%430 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.32, i64 0, i64 0))
%431 = call i32 @exit(i32 1)
unreachable
432: ; preds = %423
%433 = load i32, i32* %14
%434 = call i32 @clReleaseCommandQueue(i32 %433)
store i32 %434, i32* %8
%435 = load i32, i32* %8
%436 = load i32, i32* @CL_SUCCESS
%437 = icmp ne i32 %435, %436
br i1 %437, label %438, label %441
438: ; preds = %432
%439 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.33, i64 0, i64 0))
%440 = call i32 @exit(i32 1)
unreachable
441: ; preds = %432
%442 = load i32, i32* %13
%443 = call i32 @clReleaseContext(i32 %442)
store i32 %443, i32* %8
%444 = load i32, i32* %8
%445 = load i32, i32* @CL_SUCCESS
%446 = icmp ne i32 %444, %445
br i1 %446, label %447, label %450
447: ; preds = %441
%448 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.34, i64 0, i64 0))
%449 = call i32 @exit(i32 1)
unreachable
450: ; preds = %441
ret i32 0
}

LLVM IR (-O2):
@CL_SUCCESS = global i32 0
@.str.1 = [25 x i8] c"Number of platforms: %d\0A\00"
@.str.2 = [13 x i8] c"platform=%p\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.4 = [21 x i8] c"platform.name='%s'\0A\0A\00"
@CL_DEVICE_TYPE_GPU = global i32 0
@.str.6 = [23 x i8] c"Number of devices: %d\0A\00"
@.str.7 = [11 x i8] c"device=%p\0A\00"
@CL_DEVICE_NAME = global i32 0
@.str.9 = [18 x i8] c"device.name='%s'\0A\00"
@.str.12 = [12 x i8] c"context=%p\0A\00"
@.str.14 = [18 x i8] c"command_queue=%p\0A\00"
@.str.15 = [30 x i8] c"mad_sat_ushortushortushort.cl\00"
@.str.17 = [12 x i8] c"program=%p\0A\00"
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.18 = [44 x i8] c"error: call to 'clBuildProgram' failed:\0A%s\0A\00"
@.str.20 = [27 x i8] c"mad_sat_ushortushortushort\00"
@CL_MEM_READ_ONLY = global i32 0
@CL_TRUE = global i32 0
@CL_MEM_WRITE_ONLY = global i32 0
@.str.28 = [10 x i8] c"%s.result\00"
@.str.29 = [21 x i8] c"Result dumped to %s\0A\00"
@str = [14 x i8] c"program built\00"
@str.35 = [41 x i8] c"error: call to 'clReleaseContext' failed\00"
@str.36 = [46 x i8] c"error: call to 'clReleaseCommandQueue' failed\00"
@str.37 = [41 x i8] c"error: call to 'clReleaseProgram' failed\00"
@str.38 = [40 x i8] c"error: call to 'clReleaseKernel' failed\00"
@str.42 = [43 x i8] c"error: call to 'clReleaseMemObject' failed\00"
@str.43 = [44 x i8] c"error: call to 'clEnqueueReadBuffer' failed\00"
@str.44 = [47 x i8] c"error: call to 'clEnqueueNDRangeKernel' failed\00"
@str.45 = [39 x i8] c"error: call to 'clSetKernelArg' failed\00"
@str.46 = [35 x i8] c"error: could not create dst buffer\00"
@str.51 = [45 x i8] c"error: call to 'clEnqueueWriteBuffer' failed\00"
@str.52 = [38 x i8] c"error: could not create source buffer\00"
@str.53 = [39 x i8] c"error: call to 'clCreateKernel' failed\00"
@str.54 = [50 x i8] c"error: call to 'clCreateProgramWithSource' failed\00"
@str.55 = [45 x i8] c"error: call to 'clCreateCommandQueue' failed\00"
@str.56 = [40 x i8] c"error: call to 'clCreateContext' failed\00"
@str.57 = [40 x i8] c"error: call to 'clGetDeviceInfo' failed\00"
@str.58 = [39 x i8] c"error: call to 'clGetDeviceIDs' failed\00"
@str.59 = [42 x i8] c"error: call to 'clGetPlatformInfo' failed\00"
@str.60 = [41 x i8] c"error: call to 'clGetPlatformIDs' failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca i64
%19 = alloca [100 x i8]
%20 = bitcast i32* %3 to i8*
%21 = bitcast i32* %4 to i8*
%22 = bitcast i32* %5 to i8*
%23 = call i32 @clGetPlatformIDs(i32 1, i32* %3, i32* %4)
store i32 %23, i32* %5
%24 = load i32, i32* @CL_SUCCESS
%25 = icmp eq i32 %23, %24
br i1 %25, label %29, label %26
26: ; preds = %2
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.60, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%35 = load i32, i32* %3
%36 = load i32, i32* @CL_PLATFORM_NAME
%37 = call i32 @clGetPlatformInfo(i32 %35, i32 %36, i32 100, i8* %34, i32* null)
store i32 %37, i32* %5
%38 = load i32, i32* @CL_SUCCESS
%39 = icmp eq i32 %37, %38
br i1 %39, label %43, label %40
40: ; preds = %29
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.59, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %29
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%45 = bitcast i32* %7 to i8*
%46 = bitcast i32* %8 to i8*
%47 = load i32, i32* %3
%48 = load i32, i32* @CL_DEVICE_TYPE_GPU
%49 = call i32 @clGetDeviceIDs(i32 %47, i32 %48, i32 1, i32* %7, i32* %8)
store i32 %49, i32* %5
%50 = load i32, i32* @CL_SUCCESS
%51 = icmp eq i32 %49, %50
br i1 %51, label %55, label %52
52: ; preds = %43
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.58, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %43
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %7
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %58)
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%61 = load i32, i32* %7
%62 = load i32, i32* @CL_DEVICE_NAME
%63 = call i32 @clGetDeviceInfo(i32 %61, i32 %62, i32 100, i8* %60, i32* null)
store i32 %63, i32* %5
%64 = load i32, i32* @CL_SUCCESS
%65 = icmp eq i32 %63, %64
br i1 %65, label %69, label %66
66: ; preds = %55
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.57, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %55
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %60)
%71 = call i32 @putchar(i32 10)
%72 = call i32 @clCreateContext(i32* null, i32 1, i32* %7, i32* null, i32* null, i32* %5)
%73 = load i32, i32* %5
%74 = load i32, i32* @CL_SUCCESS
%75 = icmp eq i32 %73, %74
br i1 %75, label %79, label %76
76: ; preds = %69
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.56, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %69
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %72)
%81 = load i32, i32* %7
%82 = call i32 @clCreateCommandQueue(i32 %72, i32 %81, i32 0, i32* %5)
%83 = load i32, i32* %5
%84 = load i32, i32* @CL_SUCCESS
%85 = icmp eq i32 %83, %84
br i1 %85, label %89, label %86
86: ; preds = %79
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.55, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %79
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %82)
%91 = call i32 @putchar(i32 10)
%92 = bitcast i8** %10 to i8*
%93 = bitcast i64* %11 to i8*
%94 = call i8* @read_buffer(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.15, i64 0, i64 0), i64* %11)
store i8* %94, i8** %10
%95 = call i32 @clCreateProgramWithSource(i32 %72, i32 1, i8** %10, i64* %11, i32* %5)
%96 = load i32, i32* %5
%97 = load i32, i32* @CL_SUCCESS
%98 = icmp eq i32 %96, %97
br i1 %98, label %102, label %99
99: ; preds = %89
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.54, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %89
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %95)
%104 = call i32 @clBuildProgram(i32 %95, i32 1, i32* %7, i32* null, i32* null, i32* null)
store i32 %104, i32* %5
%105 = load i32, i32* @CL_SUCCESS
%106 = icmp eq i32 %104, %105
br i1 %106, label %120, label %107
107: ; preds = %102
%108 = bitcast i64* %12 to i8*
%109 = load i32, i32* %7
%110 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%111 = call i32 @clGetProgramBuildInfo(i32 %95, i32 %109, i32 %110, i64 0, i8* null, i64* %12)
%112 = load i64, i64* %12
%113 = call i8* @malloc(i64 %112)
%114 = load i32, i32* %7
%115 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%116 = call i32 @clGetProgramBuildInfo(i32 %95, i32 %114, i32 %115, i64 %112, i8* %113, i64* null)
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %113)
%118 = call i32 @free(i8* %113)
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %102
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%122 = call i32 @putchar(i32 10)
%123 = call i32 @clCreateKernel(i32 %95, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i64 0, i64 0), i32* %5)
%124 = load i32, i32* %5
%125 = load i32, i32* @CL_SUCCESS
%126 = icmp eq i32 %124, %125
br i1 %126, label %130, label %127
127: ; preds = %120
%128 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.53, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %120
%131 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%132 = bitcast i32* %13 to i8*
%133 = load i32, i32* @CL_MEM_READ_ONLY
%134 = call i32 @clCreateBuffer(i32 %72, i32 %133, i64 10, i32* null, i32* %5)
store i32 %134, i32* %13
%135 = load i32, i32* %5
%136 = load i32, i32* @CL_SUCCESS
%137 = icmp eq i32 %135, %136
br i1 %137, label %141, label %138
138: ; preds = %130
%139 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.52, i64 0, i64 0))
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %130
%142 = load i32, i32* @CL_TRUE
%143 = call i32 @clEnqueueWriteBuffer(i32 %82, i32 %134, i32 %142, i32 0, i64 10, i8* %131, i32 0, i32* null, i32* null)
store i32 %143, i32* %5
%144 = load i32, i32* @CL_SUCCESS
%145 = icmp eq i32 %143, %144
br i1 %145, label %149, label %146
146: ; preds = %141
%147 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.51, i64 0, i64 0))
%148 = call i32 @exit(i32 1)
unreachable
149: ; preds = %141
%150 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%151 = bitcast i32* %14 to i8*
%152 = load i32, i32* @CL_MEM_READ_ONLY
%153 = call i32 @clCreateBuffer(i32 %72, i32 %152, i64 10, i32* null, i32* %5)
store i32 %153, i32* %14
%154 = load i32, i32* %5
%155 = load i32, i32* @CL_SUCCESS
%156 = icmp eq i32 %154, %155
br i1 %156, label %160, label %157
157: ; preds = %149
%158 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.52, i64 0, i64 0))
%159 = call i32 @exit(i32 1)
unreachable
160: ; preds = %149
%161 = load i32, i32* @CL_TRUE
%162 = call i32 @clEnqueueWriteBuffer(i32 %82, i32 %153, i32 %161, i32 0, i64 10, i8* %150, i32 0, i32* null, i32* null)
store i32 %162, i32* %5
%163 = load i32, i32* @CL_SUCCESS
%164 = icmp eq i32 %162, %163
br i1 %164, label %168, label %165
165: ; preds = %160
%166 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.51, i64 0, i64 0))
%167 = call i32 @exit(i32 1)
unreachable
168: ; preds = %160
%169 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%170 = bitcast i32* %15 to i8*
%171 = load i32, i32* @CL_MEM_READ_ONLY
%172 = call i32 @clCreateBuffer(i32 %72, i32 %171, i64 10, i32* null, i32* %5)
store i32 %172, i32* %15
%173 = load i32, i32* %5
%174 = load i32, i32* @CL_SUCCESS
%175 = icmp eq i32 %173, %174
br i1 %175, label %179, label %176
176: ; preds = %168
%177 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.52, i64 0, i64 0))
%178 = call i32 @exit(i32 1)
unreachable
179: ; preds = %168
%180 = load i32, i32* @CL_TRUE
%181 = call i32 @clEnqueueWriteBuffer(i32 %82, i32 %172, i32 %180, i32 0, i64 10, i8* %169, i32 0, i32* null, i32* null)
store i32 %181, i32* %5
%182 = load i32, i32* @CL_SUCCESS
%183 = icmp eq i32 %181, %182
br i1 %183, label %187, label %184
184: ; preds = %179
%185 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.51, i64 0, i64 0))
%186 = call i32 @exit(i32 1)
unreachable
187: ; preds = %179
%188 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%189 = call i32 @memset(i8* %188, i32 1, i64 10)
%190 = bitcast i32* %16 to i8*
%191 = load i32, i32* @CL_MEM_WRITE_ONLY
%192 = call i32 @clCreateBuffer(i32 %72, i32 %191, i64 10, i32* null, i32* %5)
store i32 %192, i32* %16
%193 = load i32, i32* %5
%194 = load i32, i32* @CL_SUCCESS
%195 = icmp eq i32 %193, %194
br i1 %195, label %199, label %196
196: ; preds = %187
%197 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.46, i64 0, i64 0))
%198 = call i32 @exit(i32 1)
unreachable
199: ; preds = %187
%200 = call i32 @clSetKernelArg(i32 %123, i32 0, i32 4, i32* %13)
%201 = load i32, i32* %5
%202 = or i32 %201, %200
store i32 %202, i32* %5
%203 = call i32 @clSetKernelArg(i32 %123, i32 1, i32 4, i32* %14)
%204 = load i32, i32* %5
%205 = or i32 %204, %203
store i32 %205, i32* %5
%206 = call i32 @clSetKernelArg(i32 %123, i32 2, i32 4, i32* %15)
%207 = load i32, i32* %5
%208 = or i32 %207, %206
store i32 %208, i32* %5
%209 = call i32 @clSetKernelArg(i32 %123, i32 3, i32 4, i32* %16)
%210 = load i32, i32* %5
%211 = or i32 %210, %209
store i32 %211, i32* %5
%212 = load i32, i32* @CL_SUCCESS
%213 = icmp eq i32 %211, %212
br i1 %213, label %217, label %214
214: ; preds = %199
%215 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.45, i64 0, i64 0))
%216 = call i32 @exit(i32 1)
unreachable
217: ; preds = %199
%218 = bitcast i64* %17 to i8*
store i64 10, i64* %17
%219 = bitcast i64* %18 to i8*
store i64 10, i64* %18
%220 = call i32 @clEnqueueNDRangeKernel(i32 %82, i32 %123, i32 1, i32* null, i64* %17, i64* %18, i32 0, i32* null, i32* null)
store i32 %220, i32* %5
%221 = load i32, i32* @CL_SUCCESS
%222 = icmp eq i32 %220, %221
br i1 %222, label %226, label %223
223: ; preds = %217
%224 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.44, i64 0, i64 0))
%225 = call i32 @exit(i32 1)
unreachable
226: ; preds = %217
%227 = call i32 @clFinish(i32 %82)
%228 = load i32, i32* %16
%229 = load i32, i32* @CL_TRUE
%230 = call i32 @clEnqueueReadBuffer(i32 %82, i32 %228, i32 %229, i32 0, i64 10, i8* %188, i32 0, i32* null, i32* null)
store i32 %230, i32* %5
%231 = load i32, i32* @CL_SUCCESS
%232 = icmp eq i32 %230, %231
br i1 %232, label %236, label %233
233: ; preds = %226
%234 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.43, i64 0, i64 0))
%235 = call i32 @exit(i32 1)
unreachable
236: ; preds = %226
%237 = getelementptr inbounds [100 x i8], [100 x i8]* %19, i64 0, i64 0
%238 = load i8*, i8** %1
%239 = call i32 @sprintf(i8* %237, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %238)
%240 = call i32 @write_buffer(i8* %237, i8* %188, i64 10)
%241 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %237)
%242 = call i32 @free(i8* %188)
%243 = load i32, i32* %16
%244 = call i32 @clReleaseMemObject(i32 %243)
store i32 %244, i32* %5
%245 = load i32, i32* @CL_SUCCESS
%246 = icmp eq i32 %244, %245
br i1 %246, label %250, label %247
247: ; preds = %236
%248 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.42, i64 0, i64 0))
%249 = call i32 @exit(i32 1)
unreachable
250: ; preds = %236
%251 = call i32 @free(i8* %131)
%252 = load i32, i32* %13
%253 = call i32 @clReleaseMemObject(i32 %252)
store i32 %253, i32* %5
%254 = load i32, i32* @CL_SUCCESS
%255 = icmp eq i32 %253, %254
br i1 %255, label %259, label %256
256: ; preds = %250
%257 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.42, i64 0, i64 0))
%258 = call i32 @exit(i32 1)
unreachable
259: ; preds = %250
%260 = call i32 @free(i8* %150)
%261 = load i32, i32* %14
%262 = call i32 @clReleaseMemObject(i32 %261)
store i32 %262, i32* %5
%263 = load i32, i32* @CL_SUCCESS
%264 = icmp eq i32 %262, %263
br i1 %264, label %268, label %265
265: ; preds = %259
%266 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.42, i64 0, i64 0))
%267 = call i32 @exit(i32 1)
unreachable
268: ; preds = %259
%269 = call i32 @free(i8* %169)
%270 = load i32, i32* %15
%271 = call i32 @clReleaseMemObject(i32 %270)
store i32 %271, i32* %5
%272 = load i32, i32* @CL_SUCCESS
%273 = icmp eq i32 %271, %272
br i1 %273, label %277, label %274
274: ; preds = %268
%275 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.42, i64 0, i64 0))
%276 = call i32 @exit(i32 1)
unreachable
277: ; preds = %268
%278 = call i32 @clReleaseKernel(i32 %123)
store i32 %278, i32* %5
%279 = load i32, i32* @CL_SUCCESS
%280 = icmp eq i32 %278, %279
br i1 %280, label %284, label %281
281: ; preds = %277
%282 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.38, i64 0, i64 0))
%283 = call i32 @exit(i32 1)
unreachable
284: ; preds = %277
%285 = call i32 @clReleaseProgram(i32 %95)
store i32 %285, i32* %5
%286 = load i32, i32* @CL_SUCCESS
%287 = icmp eq i32 %285, %286
br i1 %287, label %291, label %288
288: ; preds = %284
%289 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.37, i64 0, i64 0))
%290 = call i32 @exit(i32 1)
unreachable
291: ; preds = %284
%292 = call i32 @clReleaseCommandQueue(i32 %82)
store i32 %292, i32* %5
%293 = load i32, i32* @CL_SUCCESS
%294 = icmp eq i32 %292, %293
br i1 %294, label %298, label %295
295: ; preds = %291
%296 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.36, i64 0, i64 0))
%297 = call i32 @exit(i32 1)
unreachable
298: ; preds = %291
%299 = call i32 @clReleaseContext(i32 %72)
store i32 %299, i32* %5
%300 = load i32, i32* @CL_SUCCESS
%301 = icmp eq i32 %299, %300
br i1 %301, label %305, label %302
302: ; preds = %298
%303 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.35, i64 0, i64 0))
%304 = call i32 @exit(i32 1)
unreachable
305: ; preds = %298
ret i32 0
}