#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 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 char cl_int;
typedef char cl_float;
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;
char CL_SUCCESS;
int /*<<< orphan*/ CL_TRUE;
char clBuildProgram(int /*<<< orphan*/, int, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                                  size_t, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ clCreateCommandQueue(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, char *);
int /*<<< orphan*/ clCreateContext(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ clCreateKernel(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ clCreateProgramWithSource(int /*<<< orphan*/, int,
                                             char const **, size_t *, char *);
char clEnqueueNDRangeKernel(int /*<<< orphan*/, int /*<<< orphan*/, int,
                            int /*<<< orphan*/ *, size_t *, size_t *,
                            int /*<<< orphan*/, int /*<<< orphan*/ *,
                            int /*<<< orphan*/ *);
char clEnqueueReadBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/, size_t, char *,
                         int /*<<< orphan*/, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *);
char clEnqueueWriteBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/, size_t,
                          char *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ clFinish(int /*<<< orphan*/);
char clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                    int /*<<< orphan*/ *, int *);
char clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int, char *,
                     int /*<<< orphan*/ *);
char clGetPlatformIDs(int, int /*<<< orphan*/ *, int *);
char clGetPlatformInfo(int /*<<< orphan*/, int /*<<< orphan*/, int, char *,
                       int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetProgramBuildInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/, size_t, char *,
                                         size_t *);
char clReleaseCommandQueue(int /*<<< orphan*/);
char clReleaseContext(int /*<<< orphan*/);
char clReleaseKernel(int /*<<< orphan*/);
char clReleaseMemObject(int /*<<< orphan*/);
char clReleaseProgram(int /*<<< orphan*/);
char 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("isfinite_float.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, "isfinite_float", &ret);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clCreateKernel' failed\n");
    exit(1);
  }
  size_t num_elem = 10;
  cl_float *src_0_host_buffer;
  src_0_host_buffer = malloc(num_elem * sizeof(cl_float));
  for (int i = 0; i < num_elem; i++)
    src_0_host_buffer[i] = (cl_float)(2.0);
  cl_mem src_0_device_buffer;
  src_0_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY,
                                       num_elem * sizeof(cl_float), 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_float), src_0_host_buffer, 0,
                             NULL, NULL);
  if (ret != CL_SUCCESS) {
    printf("error: call to 'clEnqueueWriteBuffer' failed\n");
    exit(1);
  }
  cl_int *dst_host_buffer;
  dst_host_buffer = malloc(num_elem * sizeof(cl_int));
  memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_int));
  cl_mem dst_device_buffer;
  dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
                                     num_elem * sizeof(cl_int), 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), &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_int), 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_int));
  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);
  }
  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    $0x1f0,%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2c9f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     132c <main+0x5c>
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x18(%rbp),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c68(%rip),%rax
mov    (%rax),%esi
lea    -0x80(%rbp),%rcx
mov    $0x64,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1120 <clGetPlatformInfo@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2c2d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     139e <main+0xce>
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0x80(%rbp),%rsi
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2c16(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
lea    -0x84(%rbp),%rcx
lea    -0x88(%rbp),%r8
call   10a0 <clGetDeviceIDs@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2bc6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1405 <main+0x135>
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x88(%rbp),%esi
lea    0xca6(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x84(%rbp),%esi
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x84(%rbp),%edi
mov    0x2b7e(%rip),%rax
mov    (%rax),%esi
lea    -0xf0(%rbp),%rcx
mov    $0x64,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   10b0 <clGetDeviceInfo@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2b48(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1483 <main+0x1b3>
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0xf0(%rbp),%rsi
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xbef(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x1,%esi
lea    -0x84(%rbp),%rdx
lea    -0x19(%rbp),%r9
mov    %r8,%rdi
mov    %r8,%rcx
call   1130 <clCreateContext@plt>
mov    %eax,-0xf4(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2ad1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     14fa <main+0x22a>
lea    0xc2c(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf4(%rbp),%esi
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0xf4(%rbp),%edi
mov    -0x84(%rbp),%esi
xor    %edx,%edx
lea    -0x19(%rbp),%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0xf8(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2a72(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1559 <main+0x289>
lea    0xc02(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0xf8(%rbp),%esi
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xb1a(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0xc08(%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    -0x19(%rbp),%r8
call   1060 <clCreateProgramWithSource@plt>
mov    %eax,-0x10c(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x29e0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     15eb <main+0x31b>
lea    0xbc2(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x10c(%rbp),%esi
lea    0xbd7(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2979(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     16ce <main+0x3fe>
mov    -0x10c(%rbp),%edi
mov    -0x84(%rbp),%esi
mov    0x298b(%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    0x294f(%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    0xb2a(%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    0xb32(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
lea    0x9ab(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x10c(%rbp),%edi
lea    0xb1f(%rip),%rsi
lea    -0x19(%rbp),%rdx
call   11b0 <clCreateKernel@plt>
mov    %eax,-0x124(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2897(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1734 <main+0x464>
lea    0xb02(%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    179a <main+0x4ca>
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    1760 <main+0x490>
mov    -0xf4(%rbp),%edi
mov    0x2809(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x19(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x140(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x27d6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     17f5 <main+0x525>
lea    0xa69(%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    0x27e0(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x275c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     186f <main+0x59f>
lea    0xa16(%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)
mov    -0x148(%rbp),%rdi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
mov    $0x1,%esi
call   1110 <memset@plt>
mov    -0xf4(%rbp),%edi
mov    0x2731(%rip),%rax
mov    (%rax),%esi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x19(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x14c(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x26ce(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     18fd <main+0x62d>
lea    0x9b6(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    0x26a4(%rip),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x124(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x140(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
movsbl %al,%ecx
movsbl -0x19(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x19(%rbp)
mov    -0x124(%rbp),%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0x14c(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
movsbl %al,%ecx
movsbl -0x19(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2647(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1984 <main+0x6b4>
lea    0x953(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x130(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0xf8(%rbp),%edi
mov    -0x124(%rbp),%esi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x158(%rbp),%r8
lea    -0x160(%rbp),%r9
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   10d0 <clEnqueueNDRangeKernel@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x25b7(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1a14 <main+0x744>
lea    0x8eb(%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    -0x14c(%rbp),%esi
mov    0x25b6(%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   1180 <clEnqueueReadBuffer@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2532(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1a99 <main+0x7c9>
lea    0x896(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
lea    -0x1d0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x89d(%rip),%rsi
call   11c0 <sprintf@plt>
lea    -0x1d0(%rbp),%rdi
mov    -0x148(%rbp),%rsi
mov    -0x130(%rbp),%rdx
shl    $0x0,%rdx
call   10c0 <write_buffer@plt>
lea    -0x1d0(%rbp),%rsi
lea    0x876(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    -0x148(%rbp),%rdi
call   1040 <free@plt>
mov    -0x14c(%rbp),%edi
call   11a0 <clReleaseMemObject@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x249d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1b2e <main+0x85e>
lea    0x84d(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2455(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1b76 <main+0x8a6>
lea    0x805(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2419(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1bb2 <main+0x8e2>
lea    0x7f5(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x23dd(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1bee <main+0x91e>
lea    0x7e2(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x23a1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1c2a <main+0x95a>
lea    0x7d0(%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    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
mov    0x2365(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1c66 <main+0x996>
lea    0x7c3(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
mov    %rsi,%r15
lea    0x28(%rsp),%rsi
lea    0x3c(%rsp),%rdx
mov    $0x1,%edi
call   1110 <clGetPlatformIDs@plt>
mov    %al,0x1f(%rsp)
mov    0x2c85(%rip),%r12
cmp    (%r12),%al
jne    1803 <main+0x513>
mov    0x3c(%rsp),%esi
lea    0xcd8(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%esi
lea    0xcdf(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
lea    0x140(%rsp),%rcx
mov    $0x64,%edx
xor    %r8d,%r8d
call   1140 <clGetPlatformInfo@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    180f <main+0x51f>
lea    0xcae(%rip),%rdi
lea    0x140(%rsp),%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x2c2e(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rcx
lea    0x38(%rsp),%r8
mov    $0x1,%edx
call   10c0 <clGetDeviceIDs@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    181b <main+0x52b>
mov    0x38(%rsp),%esi
lea    0xc7a(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x20(%rsp),%esi
lea    0xc7f(%rip),%rdi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x20(%rsp),%edi
mov    0x2bc3(%rip),%rax
mov    (%rax),%esi
lea    0xd0(%rsp),%rcx
mov    $0x64,%edx
xor    %r8d,%r8d
call   10d0 <clGetDeviceInfo@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    1827 <main+0x537>
lea    0xc4c(%rip),%rdi
lea    0xd0(%rsp),%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0x20(%rsp),%rdx
lea    0x1f(%rsp),%r9
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1150 <clCreateContext@plt>
mov    %eax,%ebp
mov    0x1f(%rsp),%al
cmp    (%r12),%al
jne    1833 <main+0x543>
lea    0xc13(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x20(%rsp),%esi
lea    0x1f(%rsp),%rcx
mov    %ebp,%edi
xor    %edx,%edx
call   1100 <clCreateCommandQueue@plt>
mov    %eax,%esi
mov    0x1f(%rsp),%al
cmp    (%r12),%al
jne    183f <main+0x54f>
lea    0xbed(%rip),%rdi
mov    %esi,%r14d
xor    %eax,%eax
call   1120 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xbe4(%rip),%rdi
lea    0x58(%rsp),%rbx
mov    %rbx,%rsi
call   1170 <read_buffer@plt>
mov    %rax,0x50(%rsp)
lea    0x50(%rsp),%rdx
lea    0x1f(%rsp),%r8
mov    %ebp,%edi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebx
mov    0x1f(%rsp),%al
cmp    (%r12),%al
jne    184b <main+0x55b>
lea    0xbb4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1120 <printf@plt>
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    1857 <main+0x567>
lea    0xbe3(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xb9f(%rip),%rsi
lea    0x1f(%rsp),%rdx
mov    %ebx,0x34(%rsp)
mov    %ebx,%edi
call   11d0 <clCreateKernel@plt>
mov    %eax,%r13d
mov    0x1f(%rsp),%al
cmp    (%r12),%al
jne    18c0 <main+0x5d0>
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%rbx
movabs $0x202020202020202,%rax
02 02 02
mov    %rax,(%rbx)
movw   $0x202,0x8(%rbx)
mov    0x2a20(%rip),%rax
mov    (%rax),%esi
lea    0x1f(%rsp),%r8
mov    $0xa,%edx
mov    %ebp,0x2c(%rsp)
mov    %ebp,%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x30(%rsp)
mov    0x1f(%rsp),%cl
cmp    (%r12),%cl
jne    18c9 <main+0x5d9>
mov    0x2a26(%rip),%rcx
mov    (%rcx),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    %r14d,%ebp
mov    %r14d,%edi
mov    %eax,%esi
xor    %ecx,%ecx
mov    %rbx,%r9
call   1210 <clEnqueueWriteBuffer@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    18d2 <main+0x5e2>
mov    $0xa,%edi
call   1190 <malloc@plt>
mov    %rax,%r14
mov    $0xa,%edx
mov    %rax,%rdi
mov    $0x1,%esi
call   1130 <memset@plt>
mov    0x29c1(%rip),%rax
mov    (%rax),%esi
lea    0x1f(%rsp),%r8
mov    $0xa,%edx
mov    0x2c(%rsp),%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x24(%rsp)
mov    0x1f(%rsp),%al
cmp    (%r12),%al
jne    18db <main+0x5eb>
lea    0x30(%rsp),%rcx
mov    %r13d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     %al,0x1f(%rsp)
lea    0x24(%rsp),%rcx
mov    %r13d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     0x1f(%rsp),%al
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    18e4 <main+0x5f4>
movq   $0xa,0x48(%rsp)
movq   $0xa,0x40(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x48(%rsp),%r8
lea    0x40(%rsp),%r9
mov    %ebp,%edi
mov    %r13d,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   10f0 <clEnqueueNDRangeKernel@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    18ed <main+0x5fd>
mov    %ebp,%edi
call   1060 <clFinish@plt>
mov    0x24(%rsp),%esi
mov    0x2903(%rip),%rax
mov    (%rax),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    $0xa,%r8d
mov    %ebp,%edi
xor    %ecx,%ecx
mov    %r14,%r9
call   11a0 <clEnqueueReadBuffer@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    18f6 <main+0x606>
mov    (%r15),%rdx
lea    0x9d6(%rip),%rsi
lea    0x60(%rsp),%r15
mov    %r15,%rdi
call   11e0 <sprintf@plt>
mov    $0xa,%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   10e0 <write_buffer@plt>
lea    0x9bc(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1120 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    0x24(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    17f7 <main+0x507>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x30(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
mov    0x2c(%rsp),%ebx
jne    17f7 <main+0x507>
mov    %r13d,%edi
call   1090 <clReleaseKernel@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    18ff <main+0x60f>
mov    0x34(%rsp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    1908 <main+0x618>
mov    %ebp,%edi
call   1180 <clReleaseCommandQueue@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    1911 <main+0x621>
mov    %ebx,%edi
call   11b0 <clReleaseContext@plt>
mov    %al,0x1f(%rsp)
cmp    (%r12),%al
jne    191a <main+0x62a>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9cd(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xc0b(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xbd5(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xba2(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb6e(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb3a(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb01(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xac3(%rip),%rdi
jmp    1921 <main+0x631>
mov    0x20(%rsp),%esi
mov    0x2776(%rip),%r14
mov    (%r14),%edx
lea    0x60(%rsp),%r9
mov    %ebx,%edi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1160 <clGetProgramBuildInfo@plt>
mov    0x60(%rsp),%r15
mov    %r15,%rdi
call   1190 <malloc@plt>
mov    %rax,%rbp
mov    0x20(%rsp),%esi
mov    (%r14),%edx
mov    %ebx,%edi
mov    %r15,%rcx
mov    %rax,%r8
xor    %r9d,%r9d
call   1160 <clGetProgramBuildInfo@plt>
lea    0x817(%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    0xa27(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x9f8(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x9c2(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x996(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x966(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x92e(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x8f9(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x89d(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x86b(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x834(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x802(%rip),%rdi
call   1080 <puts@plt>
mov    $0x1,%edi
call   11f0 <exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i8 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 = [18 x i8] c"isfinite_float.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 = [15 x i8] c"isfinite_float\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 i8
%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 i64
%28 = alloca i64
%29 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%30 = call signext i8 @clGetPlatformIDs(i32 1, i32* %6, i32* %7)
store i8 %30, i8* %8
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = load i8, i8* @CL_SUCCESS
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %32, %34
br i1 %35, label %36, label %39
36: ; preds = %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %2
%40 = load i32, i32* %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %6
%45 = load i32, i32* @CL_PLATFORM_NAME
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%47 = call signext i8 @clGetPlatformInfo(i32 %44, i32 %45, i32 100, i8* %46, i32* null)
store i8 %47, i8* %8
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = load i8, i8* @CL_SUCCESS
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %49, %51
br i1 %52, label %53, label %56
53: ; preds = %39
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %39
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %57)
%59 = load i32, i32* %6
%60 = load i32, i32* @CL_DEVICE_TYPE_GPU
%61 = call signext i8 @clGetDeviceIDs(i32 %59, i32 %60, i32 1, i32* %10, i32* %11)
store i8 %61, i8* %8
%62 = load i8, i8* %8
%63 = sext i8 %62 to i32
%64 = load i8, i8* @CL_SUCCESS
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %63, %65
br i1 %66, label %67, label %70
67: ; preds = %56
%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 = %56
%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 signext i8 @clGetDeviceInfo(i32 %75, i32 %76, i32 100, i8* %77, i32* null)
store i8 %78, i8* %8
%79 = load i8, i8* %8
%80 = sext i8 %79 to i32
%81 = load i8, i8* @CL_SUCCESS
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %80, %82
br i1 %83, label %84, label %87
84: ; preds = %70
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %70
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%91 = call i32 @clCreateContext(i32* null, i32 1, i32* %10, i32* null, i32* null, i8* %8)
store i32 %91, i32* %13
%92 = load i8, i8* %8
%93 = sext i8 %92 to i32
%94 = load i8, i8* @CL_SUCCESS
%95 = sext i8 %94 to i32
%96 = icmp ne i32 %93, %95
br i1 %96, label %97, label %100
97: ; preds = %87
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %87
%101 = load i32, i32* %13
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %101)
%103 = load i32, i32* %13
%104 = load i32, i32* %10
%105 = call i32 @clCreateCommandQueue(i32 %103, i32 %104, i32 0, i8* %8)
store i32 %105, i32* %14
%106 = load i8, i8* %8
%107 = sext i8 %106 to i32
%108 = load i8, i8* @CL_SUCCESS
%109 = sext i8 %108 to i32
%110 = icmp ne i32 %107, %109
br i1 %110, label %111, label %114
111: ; preds = %100
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0))
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %100
%115 = load i32, i32* %14
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %115)
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%118 = call i8* @read_buffer(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i64* %16)
store i8* %118, i8** %15
%119 = load i32, i32* %13
%120 = call i32 @clCreateProgramWithSource(i32 %119, i32 1, i8** %15, i64* %16, i8* %8)
store i32 %120, i32* %17
%121 = load i8, i8* %8
%122 = sext i8 %121 to i32
%123 = load i8, i8* @CL_SUCCESS
%124 = sext i8 %123 to i32
%125 = icmp ne i32 %122, %124
br i1 %125, label %126, label %129
126: ; preds = %114
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.16, i64 0, i64 0))
%128 = call i32 @exit(i32 1)
unreachable
129: ; preds = %114
%130 = load i32, i32* %17
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %130)
%132 = load i32, i32* %17
%133 = call signext i8 @clBuildProgram(i32 %132, i32 1, i32* %10, i32* null, i32* null, i32* null)
store i8 %133, i8* %8
%134 = load i8, i8* %8
%135 = sext i8 %134 to i32
%136 = load i8, i8* @CL_SUCCESS
%137 = sext i8 %136 to i32
%138 = icmp ne i32 %135, %137
br i1 %138, label %139, label %157
139: ; preds = %129
%140 = load i32, i32* %17
%141 = load i32, i32* %10
%142 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%143 = call i32 @clGetProgramBuildInfo(i32 %140, i32 %141, i32 %142, i64 0, i8* null, i64* %18)
%144 = load i64, i64* %18
%145 = call i8* @malloc(i64 %144)
store i8* %145, i8** %19
%146 = load i32, i32* %17
%147 = load i32, i32* %10
%148 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%149 = load i64, i64* %18
%150 = load i8*, i8** %19
%151 = call i32 @clGetProgramBuildInfo(i32 %146, i32 %147, i32 %148, i64 %149, i8* %150, i64* null)
%152 = load i8*, i8** %19
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %152)
%154 = load i8*, i8** %19
%155 = call i32 @free(i8* %154)
%156 = call i32 @exit(i32 1)
unreachable
157: ; preds = %129
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%160 = load i32, i32* %17
%161 = call i32 @clCreateKernel(i32 %160, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.20, i64 0, i64 0), i8* %8)
store i32 %161, i32* %20
%162 = load i8, i8* %8
%163 = sext i8 %162 to i32
%164 = load i8, i8* @CL_SUCCESS
%165 = sext i8 %164 to i32
%166 = icmp ne i32 %163, %165
br i1 %166, label %167, label %170
167: ; preds = %157
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.21, i64 0, i64 0))
%169 = call i32 @exit(i32 1)
unreachable
170: ; preds = %157
store i64 10, i64* %21
%171 = load i64, i64* %21
%172 = mul i64 %171, 1
%173 = call i8* @malloc(i64 %172)
store i8* %173, i8** %22
store i32 0, i32* %23
br label %174
174: ; preds = %184, %170
%175 = load i32, i32* %23
%176 = sext i32 %175 to i64
%177 = load i64, i64* %21
%178 = icmp ult i64 %176, %177
br i1 %178, label %179, label %187
179: ; preds = %174
%180 = load i8*, i8** %22
%181 = load i32, i32* %23
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %180, i64 %182
store i8 2, i8* %183
br label %184
184: ; preds = %179
%185 = load i32, i32* %23
%186 = add nsw i32 %185, 1
store i32 %186, i32* %23
br label %174
187: ; preds = %174
%188 = load i32, i32* %13
%189 = load i32, i32* @CL_MEM_READ_ONLY
%190 = load i64, i64* %21
%191 = mul i64 %190, 1
%192 = call i32 @clCreateBuffer(i32 %188, i32 %189, i64 %191, i32* null, i8* %8)
store i32 %192, i32* %24
%193 = load i8, i8* %8
%194 = sext i8 %193 to i32
%195 = load i8, i8* @CL_SUCCESS
%196 = sext i8 %195 to i32
%197 = icmp ne i32 %194, %196
br i1 %197, label %198, label %201
198: ; preds = %187
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.22, i64 0, i64 0))
%200 = call i32 @exit(i32 1)
unreachable
201: ; preds = %187
%202 = load i32, i32* %14
%203 = load i32, i32* %24
%204 = load i32, i32* @CL_TRUE
%205 = load i64, i64* %21
%206 = mul i64 %205, 1
%207 = load i8*, i8** %22
%208 = call signext i8 @clEnqueueWriteBuffer(i32 %202, i32 %203, i32 %204, i32 0, i64 %206, i8* %207, i32 0, i32* null, i32* null)
store i8 %208, i8* %8
%209 = load i8, i8* %8
%210 = sext i8 %209 to i32
%211 = load i8, i8* @CL_SUCCESS
%212 = sext i8 %211 to i32
%213 = icmp ne i32 %210, %212
br i1 %213, label %214, label %217
214: ; preds = %201
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0))
%216 = call i32 @exit(i32 1)
unreachable
217: ; preds = %201
%218 = load i64, i64* %21
%219 = mul i64 %218, 1
%220 = call i8* @malloc(i64 %219)
store i8* %220, i8** %25
%221 = load i8*, i8** %25
%222 = load i64, i64* %21
%223 = mul i64 %222, 1
%224 = call i32 @memset(i8* %221, i32 1, i64 %223)
%225 = load i32, i32* %13
%226 = load i32, i32* @CL_MEM_WRITE_ONLY
%227 = load i64, i64* %21
%228 = mul i64 %227, 1
%229 = call i32 @clCreateBuffer(i32 %225, i32 %226, i64 %228, i32* null, i8* %8)
store i32 %229, i32* %26
%230 = load i8, i8* %8
%231 = sext i8 %230 to i32
%232 = load i8, i8* @CL_SUCCESS
%233 = sext i8 %232 to i32
%234 = icmp ne i32 %231, %233
br i1 %234, label %235, label %238
235: ; preds = %217
%236 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.24, i64 0, i64 0))
%237 = call i32 @exit(i32 1)
unreachable
238: ; preds = %217
%239 = load i8, i8* @CL_SUCCESS
store i8 %239, i8* %8
%240 = load i32, i32* %20
%241 = call signext i8 @clSetKernelArg(i32 %240, i32 0, i32 4, i32* %24)
%242 = sext i8 %241 to i32
%243 = load i8, i8* %8
%244 = sext i8 %243 to i32
%245 = or i32 %244, %242
%246 = trunc i32 %245 to i8
store i8 %246, i8* %8
%247 = load i32, i32* %20
%248 = call signext i8 @clSetKernelArg(i32 %247, i32 1, i32 4, i32* %26)
%249 = sext i8 %248 to i32
%250 = load i8, i8* %8
%251 = sext i8 %250 to i32
%252 = or i32 %251, %249
%253 = trunc i32 %252 to i8
store i8 %253, i8* %8
%254 = load i8, i8* %8
%255 = sext i8 %254 to i32
%256 = load i8, i8* @CL_SUCCESS
%257 = sext i8 %256 to i32
%258 = icmp ne i32 %255, %257
br i1 %258, label %259, label %262
259: ; preds = %238
%260 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.25, i64 0, i64 0))
%261 = call i32 @exit(i32 1)
unreachable
262: ; preds = %238
%263 = load i64, i64* %21
store i64 %263, i64* %27
%264 = load i64, i64* %21
store i64 %264, i64* %28
%265 = load i32, i32* %14
%266 = load i32, i32* %20
%267 = call signext i8 @clEnqueueNDRangeKernel(i32 %265, i32 %266, i32 1, i32* null, i64* %27, i64* %28, i32 0, i32* null, i32* null)
store i8 %267, i8* %8
%268 = load i8, i8* %8
%269 = sext i8 %268 to i32
%270 = load i8, i8* @CL_SUCCESS
%271 = sext i8 %270 to i32
%272 = icmp ne i32 %269, %271
br i1 %272, label %273, label %276
273: ; preds = %262
%274 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.26, i64 0, i64 0))
%275 = call i32 @exit(i32 1)
unreachable
276: ; preds = %262
%277 = load i32, i32* %14
%278 = call i32 @clFinish(i32 %277)
%279 = load i32, i32* %14
%280 = load i32, i32* %26
%281 = load i32, i32* @CL_TRUE
%282 = load i64, i64* %21
%283 = mul i64 %282, 1
%284 = load i8*, i8** %25
%285 = call signext i8 @clEnqueueReadBuffer(i32 %279, i32 %280, i32 %281, i32 0, i64 %283, i8* %284, i32 0, i32* null, i32* null)
store i8 %285, i8* %8
%286 = load i8, i8* %8
%287 = sext i8 %286 to i32
%288 = load i8, i8* @CL_SUCCESS
%289 = sext i8 %288 to i32
%290 = icmp ne i32 %287, %289
br i1 %290, label %291, label %294
291: ; preds = %276
%292 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.27, i64 0, i64 0))
%293 = call i32 @exit(i32 1)
unreachable
294: ; preds = %276
%295 = bitcast [100 x i8]* %29 to i8*
%296 = load i8**, i8*** %5
%297 = getelementptr inbounds i8*, i8** %296, i64 0
%298 = load i8*, i8** %297
%299 = call i32 @sprintf(i8* %295, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %298)
%300 = getelementptr inbounds [100 x i8], [100 x i8]* %29, i64 0, i64 0
%301 = load i8*, i8** %25
%302 = load i64, i64* %21
%303 = mul i64 %302, 1
%304 = call i32 @write_buffer(i8* %300, i8* %301, i64 %303)
%305 = getelementptr inbounds [100 x i8], [100 x i8]* %29, i64 0, i64 0
%306 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %305)
%307 = load i8*, i8** %25
%308 = call i32 @free(i8* %307)
%309 = load i32, i32* %26
%310 = call signext i8 @clReleaseMemObject(i32 %309)
store i8 %310, i8* %8
%311 = load i8, i8* %8
%312 = sext i8 %311 to i32
%313 = load i8, i8* @CL_SUCCESS
%314 = sext i8 %313 to i32
%315 = icmp ne i32 %312, %314
br i1 %315, label %316, label %319
316: ; preds = %294
%317 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%318 = call i32 @exit(i32 1)
unreachable
319: ; preds = %294
%320 = load i8*, i8** %22
%321 = call i32 @free(i8* %320)
%322 = load i32, i32* %24
%323 = call signext i8 @clReleaseMemObject(i32 %322)
store i8 %323, i8* %8
%324 = load i8, i8* %8
%325 = sext i8 %324 to i32
%326 = load i8, i8* @CL_SUCCESS
%327 = sext i8 %326 to i32
%328 = icmp ne i32 %325, %327
br i1 %328, label %329, label %332
329: ; preds = %319
%330 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%331 = call i32 @exit(i32 1)
unreachable
332: ; preds = %319
%333 = load i32, i32* %20
%334 = call signext i8 @clReleaseKernel(i32 %333)
store i8 %334, i8* %8
%335 = load i8, i8* %8
%336 = sext i8 %335 to i32
%337 = load i8, i8* @CL_SUCCESS
%338 = sext i8 %337 to i32
%339 = icmp ne i32 %336, %338
br i1 %339, label %340, label %343
340: ; preds = %332
%341 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.31, i64 0, i64 0))
%342 = call i32 @exit(i32 1)
unreachable
343: ; preds = %332
%344 = load i32, i32* %17
%345 = call signext i8 @clReleaseProgram(i32 %344)
store i8 %345, i8* %8
%346 = load i8, i8* %8
%347 = sext i8 %346 to i32
%348 = load i8, i8* @CL_SUCCESS
%349 = sext i8 %348 to i32
%350 = icmp ne i32 %347, %349
br i1 %350, label %351, label %354
351: ; preds = %343
%352 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.32, i64 0, i64 0))
%353 = call i32 @exit(i32 1)
unreachable
354: ; preds = %343
%355 = load i32, i32* %14
%356 = call signext i8 @clReleaseCommandQueue(i32 %355)
store i8 %356, i8* %8
%357 = load i8, i8* %8
%358 = sext i8 %357 to i32
%359 = load i8, i8* @CL_SUCCESS
%360 = sext i8 %359 to i32
%361 = icmp ne i32 %358, %360
br i1 %361, label %362, label %365
362: ; preds = %354
%363 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.33, i64 0, i64 0))
%364 = call i32 @exit(i32 1)
unreachable
365: ; preds = %354
%366 = load i32, i32* %13
%367 = call signext i8 @clReleaseContext(i32 %366)
store i8 %367, i8* %8
%368 = load i8, i8* %8
%369 = sext i8 %368 to i32
%370 = load i8, i8* @CL_SUCCESS
%371 = sext i8 %370 to i32
%372 = icmp ne i32 %369, %371
br i1 %372, label %373, label %376
373: ; preds = %365
%374 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.34, i64 0, i64 0))
%375 = call i32 @exit(i32 1)
unreachable
376: ; preds = %365
ret i32 0
}

LLVM IR (-O2):
@CL_SUCCESS = global i8 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 = [18 x i8] c"isfinite_float.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 = [15 x i8] c"isfinite_float\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.40 = [43 x i8] c"error: call to 'clReleaseMemObject' failed\00"
@str.41 = [44 x i8] c"error: call to 'clEnqueueReadBuffer' failed\00"
@str.42 = [47 x i8] c"error: call to 'clEnqueueNDRangeKernel' failed\00"
@str.43 = [39 x i8] c"error: call to 'clSetKernelArg' failed\00"
@str.44 = [35 x i8] c"error: could not create dst buffer\00"
@str.45 = [45 x i8] c"error: call to 'clEnqueueWriteBuffer' failed\00"
@str.46 = [38 x i8] c"error: could not create source buffer\00"
@str.47 = [39 x i8] c"error: call to 'clCreateKernel' failed\00"
@str.48 = [50 x i8] c"error: call to 'clCreateProgramWithSource' failed\00"
@str.49 = [45 x i8] c"error: call to 'clCreateCommandQueue' failed\00"
@str.50 = [40 x i8] c"error: call to 'clCreateContext' failed\00"
@str.51 = [40 x i8] c"error: call to 'clGetDeviceInfo' failed\00"
@str.52 = [39 x i8] c"error: call to 'clGetDeviceIDs' failed\00"
@str.53 = [42 x i8] c"error: call to 'clGetPlatformInfo' failed\00"
@str.54 = [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 i8
%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 i64
%16 = alloca i64
%17 = alloca [100 x i8]
%18 = bitcast i32* %3 to i8*
%19 = bitcast i32* %4 to i8*
%20 = call signext i8 @clGetPlatformIDs(i32 1, i32* %3, i32* %4)
store i8 %20, i8* %5
%21 = load i8, i8* @CL_SUCCESS
%22 = icmp eq i8 %20, %21
br i1 %22, label %26, label %23
23: ; preds = %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.54, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%32 = load i32, i32* %3
%33 = load i32, i32* @CL_PLATFORM_NAME
%34 = call signext i8 @clGetPlatformInfo(i32 %32, i32 %33, i32 100, i8* %31, i32* null)
store i8 %34, i8* %5
%35 = load i8, i8* @CL_SUCCESS
%36 = icmp eq i8 %34, %35
br i1 %36, label %40, label %37
37: ; preds = %26
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.53, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %31)
%42 = bitcast i32* %7 to i8*
%43 = bitcast i32* %8 to i8*
%44 = load i32, i32* %3
%45 = load i32, i32* @CL_DEVICE_TYPE_GPU
%46 = call signext i8 @clGetDeviceIDs(i32 %44, i32 %45, i32 1, i32* %7, i32* %8)
store i8 %46, i8* %5
%47 = load i8, i8* @CL_SUCCESS
%48 = icmp eq i8 %46, %47
br i1 %48, label %52, label %49
49: ; preds = %40
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.52, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %40
%53 = load i32, i32* %8
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %7
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%58 = load i32, i32* %7
%59 = load i32, i32* @CL_DEVICE_NAME
%60 = call signext i8 @clGetDeviceInfo(i32 %58, i32 %59, i32 100, i8* %57, i32* null)
store i8 %60, i8* %5
%61 = load i8, i8* @CL_SUCCESS
%62 = icmp eq i8 %60, %61
br i1 %62, label %66, label %63
63: ; preds = %52
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.51, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %52
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %57)
%68 = call i32 @putchar(i32 10)
%69 = call i32 @clCreateContext(i32* null, i32 1, i32* %7, i32* null, i32* null, i8* %5)
%70 = load i8, i8* %5
%71 = load i8, i8* @CL_SUCCESS
%72 = icmp eq i8 %70, %71
br i1 %72, label %76, label %73
73: ; preds = %66
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.50, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %66
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %69)
%78 = load i32, i32* %7
%79 = call i32 @clCreateCommandQueue(i32 %69, i32 %78, i32 0, i8* %5)
%80 = load i8, i8* %5
%81 = load i8, i8* @CL_SUCCESS
%82 = icmp eq i8 %80, %81
br i1 %82, label %86, label %83
83: ; preds = %76
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.49, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %76
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %79)
%88 = call i32 @putchar(i32 10)
%89 = bitcast i8** %10 to i8*
%90 = bitcast i64* %11 to i8*
%91 = call i8* @read_buffer(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i64* %11)
store i8* %91, i8** %10
%92 = call i32 @clCreateProgramWithSource(i32 %69, i32 1, i8** %10, i64* %11, i8* %5)
%93 = load i8, i8* %5
%94 = load i8, i8* @CL_SUCCESS
%95 = icmp eq i8 %93, %94
br i1 %95, label %99, label %96
96: ; preds = %86
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.48, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %86
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %92)
%101 = call signext i8 @clBuildProgram(i32 %92, i32 1, i32* %7, i32* null, i32* null, i32* null)
store i8 %101, i8* %5
%102 = load i8, i8* @CL_SUCCESS
%103 = icmp eq i8 %101, %102
br i1 %103, label %117, label %104
104: ; preds = %99
%105 = bitcast i64* %12 to i8*
%106 = load i32, i32* %7
%107 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%108 = call i32 @clGetProgramBuildInfo(i32 %92, i32 %106, i32 %107, i64 0, i8* null, i64* %12)
%109 = load i64, i64* %12
%110 = call i8* @malloc(i64 %109)
%111 = load i32, i32* %7
%112 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%113 = call i32 @clGetProgramBuildInfo(i32 %92, i32 %111, i32 %112, i64 %109, i8* %110, i64* null)
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %110)
%115 = call i32 @free(i8* %110)
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %99
%118 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%119 = call i32 @putchar(i32 10)
%120 = call i32 @clCreateKernel(i32 %92, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.20, i64 0, i64 0), i8* %5)
%121 = load i8, i8* %5
%122 = load i8, i8* @CL_SUCCESS
%123 = icmp eq i8 %121, %122
br i1 %123, label %127, label %124
124: ; preds = %117
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.47, i64 0, i64 0))
%126 = call i32 @exit(i32 1)
unreachable
127: ; preds = %117
%128 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%129 = bitcast i32* %13 to i8*
%130 = load i32, i32* @CL_MEM_READ_ONLY
%131 = call i32 @clCreateBuffer(i32 %69, i32 %130, i64 10, i32* null, i8* %5)
store i32 %131, i32* %13
%132 = load i8, i8* %5
%133 = load i8, i8* @CL_SUCCESS
%134 = icmp eq i8 %132, %133
br i1 %134, label %138, label %135
135: ; preds = %127
%136 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.46, i64 0, i64 0))
%137 = call i32 @exit(i32 1)
unreachable
138: ; preds = %127
%139 = load i32, i32* @CL_TRUE
%140 = call signext i8 @clEnqueueWriteBuffer(i32 %79, i32 %131, i32 %139, i32 0, i64 10, i8* %128, i32 0, i32* null, i32* null)
store i8 %140, i8* %5
%141 = load i8, i8* @CL_SUCCESS
%142 = icmp eq i8 %140, %141
br i1 %142, label %146, label %143
143: ; preds = %138
%144 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.45, i64 0, i64 0))
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %138
%147 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%148 = call i32 @memset(i8* %147, i32 1, i64 10)
%149 = bitcast i32* %14 to i8*
%150 = load i32, i32* @CL_MEM_WRITE_ONLY
%151 = call i32 @clCreateBuffer(i32 %69, i32 %150, i64 10, i32* null, i8* %5)
store i32 %151, i32* %14
%152 = load i8, i8* %5
%153 = load i8, i8* @CL_SUCCESS
%154 = icmp eq i8 %152, %153
br i1 %154, label %158, label %155
155: ; preds = %146
%156 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.44, i64 0, i64 0))
%157 = call i32 @exit(i32 1)
unreachable
158: ; preds = %146
%159 = call signext i8 @clSetKernelArg(i32 %120, i32 0, i32 4, i32* %13)
%160 = load i8, i8* %5
%161 = or i8 %160, %159
store i8 %161, i8* %5
%162 = call signext i8 @clSetKernelArg(i32 %120, i32 1, i32 4, i32* %14)
%163 = load i8, i8* %5
%164 = or i8 %163, %162
store i8 %164, i8* %5
%165 = load i8, i8* @CL_SUCCESS
%166 = icmp eq i8 %164, %165
br i1 %166, label %170, label %167
167: ; preds = %158
%168 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.43, i64 0, i64 0))
%169 = call i32 @exit(i32 1)
unreachable
170: ; preds = %158
%171 = bitcast i64* %15 to i8*
store i64 10, i64* %15
%172 = bitcast i64* %16 to i8*
store i64 10, i64* %16
%173 = call signext i8 @clEnqueueNDRangeKernel(i32 %79, i32 %120, i32 1, i32* null, i64* %15, i64* %16, i32 0, i32* null, i32* null)
store i8 %173, i8* %5
%174 = load i8, i8* @CL_SUCCESS
%175 = icmp eq i8 %173, %174
br i1 %175, label %179, label %176
176: ; preds = %170
%177 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.42, i64 0, i64 0))
%178 = call i32 @exit(i32 1)
unreachable
179: ; preds = %170
%180 = call i32 @clFinish(i32 %79)
%181 = load i32, i32* %14
%182 = load i32, i32* @CL_TRUE
%183 = call signext i8 @clEnqueueReadBuffer(i32 %79, i32 %181, i32 %182, i32 0, i64 10, i8* %147, i32 0, i32* null, i32* null)
store i8 %183, i8* %5
%184 = load i8, i8* @CL_SUCCESS
%185 = icmp eq i8 %183, %184
br i1 %185, label %189, label %186
186: ; preds = %179
%187 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.41, i64 0, i64 0))
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %179
%190 = getelementptr inbounds [100 x i8], [100 x i8]* %17, i64 0, i64 0
%191 = load i8*, i8** %1
%192 = call i32 @sprintf(i8* %190, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %191)
%193 = call i32 @write_buffer(i8* %190, i8* %147, i64 10)
%194 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %190)
%195 = call i32 @free(i8* %147)
%196 = load i32, i32* %14
%197 = call signext i8 @clReleaseMemObject(i32 %196)
store i8 %197, i8* %5
%198 = load i8, i8* @CL_SUCCESS
%199 = icmp eq i8 %197, %198
br i1 %199, label %203, label %200
200: ; preds = %189
%201 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.40, i64 0, i64 0))
%202 = call i32 @exit(i32 1)
unreachable
203: ; preds = %189
%204 = call i32 @free(i8* %128)
%205 = load i32, i32* %13
%206 = call signext i8 @clReleaseMemObject(i32 %205)
store i8 %206, i8* %5
%207 = load i8, i8* @CL_SUCCESS
%208 = icmp eq i8 %206, %207
br i1 %208, label %212, label %209
209: ; preds = %203
%210 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.40, i64 0, i64 0))
%211 = call i32 @exit(i32 1)
unreachable
212: ; preds = %203
%213 = call signext i8 @clReleaseKernel(i32 %120)
store i8 %213, i8* %5
%214 = load i8, i8* @CL_SUCCESS
%215 = icmp eq i8 %213, %214
br i1 %215, label %219, label %216
216: ; preds = %212
%217 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.38, i64 0, i64 0))
%218 = call i32 @exit(i32 1)
unreachable
219: ; preds = %212
%220 = call signext i8 @clReleaseProgram(i32 %92)
store i8 %220, i8* %5
%221 = load i8, i8* @CL_SUCCESS
%222 = icmp eq i8 %220, %221
br i1 %222, label %226, label %223
223: ; preds = %219
%224 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.37, i64 0, i64 0))
%225 = call i32 @exit(i32 1)
unreachable
226: ; preds = %219
%227 = call signext i8 @clReleaseCommandQueue(i32 %79)
store i8 %227, i8* %5
%228 = load i8, i8* @CL_SUCCESS
%229 = icmp eq i8 %227, %228
br i1 %229, label %233, label %230
230: ; preds = %226
%231 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.36, i64 0, i64 0))
%232 = call i32 @exit(i32 1)
unreachable
233: ; preds = %226
%234 = call signext i8 @clReleaseContext(i32 %69)
store i8 %234, i8* %5
%235 = load i8, i8* @CL_SUCCESS
%236 = icmp eq i8 %234, %235
br i1 %236, label %240, label %237
237: ; preds = %233
%238 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.35, i64 0, i64 0))
%239 = call i32 @exit(i32 1)
unreachable
240: ; preds = %233
ret i32 0
}