#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 int /*<<< orphan*/ 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;
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("ilogb_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, "ilogb_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_float *dst_host_buffer;
  dst_host_buffer = malloc(num_elem * sizeof(cl_float));
  memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_float));
  cl_mem dst_device_buffer;
  dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY,
                                     num_elem * sizeof(cl_float), 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_float), 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_float));
  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    %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    0xbdb(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    -0x10c(%rbp),%esi
lea    0xbf0(%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    0xb47(%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    0xb4f(%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    0xb3c(%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    0xb20(%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    0xa8b(%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    0xa3c(%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    0x275d(%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,-0x14c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x26fb(%rip),%rcx
cmp    (%rcx),%eax
je     18cd <main+0x5fd>
lea    0x9e0(%rip),%rdi
mov    $0x0,%al
call   1100 <printf@plt>
mov    $0x1,%edi
call   11d0 <exit@plt>
mov    0x26d4(%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    -0x14c(%rbp),%rcx
call   11e0 <clSetKernelArg@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2684(%rip),%rcx
cmp    (%rcx),%eax
je     1944 <main+0x674>
lea    0x98d(%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    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x25f8(%rip),%rcx
cmp    (%rcx),%eax
je     19d0 <main+0x700>
lea    0x929(%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    0x25fa(%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    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2577(%rip),%rcx
cmp    (%rcx),%eax
je     1a51 <main+0x781>
lea    0x8d8(%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    0x8df(%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    0x8b8(%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    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x24e6(%rip),%rcx
cmp    (%rcx),%eax
je     1ae2 <main+0x812>
lea    0x893(%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    0x24a2(%rip),%rcx
cmp    (%rcx),%eax
je     1b26 <main+0x856>
lea    0x84f(%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    0x246a(%rip),%rcx
cmp    (%rcx),%eax
je     1b5e <main+0x88e>
lea    0x843(%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    0x2432(%rip),%rcx
cmp    (%rcx),%eax
je     1b96 <main+0x8c6>
lea    0x834(%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    0x23fa(%rip),%rcx
cmp    (%rcx),%eax
je     1bce <main+0x8fe>
lea    0x826(%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    0x23c2(%rip),%rcx
cmp    (%rcx),%eax
je     1c06 <main+0x936>
lea    0x81d(%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    %eax,0x1c(%rsp)
mov    0x2c85(%rip),%r12
cmp    (%r12),%eax
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    0x1c(%rsp),%r9
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1150 <clCreateContext@plt>
mov    %eax,%ebp
mov    0x1c(%rsp),%eax
cmp    (%r12),%eax
jne    1833 <main+0x543>
lea    0xc13(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1120 <printf@plt>
mov    0x20(%rsp),%esi
lea    0x1c(%rsp),%rcx
mov    %ebp,%edi
xor    %edx,%edx
call   1100 <clCreateCommandQueue@plt>
mov    %eax,%esi
mov    0x1c(%rsp),%eax
cmp    (%r12),%eax
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    0x1c(%rsp),%r8
mov    %ebp,%edi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebx
mov    0x1c(%rsp),%eax
cmp    (%r12),%eax
jne    184b <main+0x55b>
lea    0xbb1(%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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    1857 <main+0x567>
lea    0xbdd(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xb9c(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %ebx,0x34(%rsp)
mov    %ebx,%edi
call   11d0 <clCreateKernel@plt>
mov    %eax,%r13d
mov    0x1c(%rsp),%eax
cmp    (%r12),%eax
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    0x1c(%rsp),%r8
mov    $0xa,%edx
mov    %ebp,0x2c(%rsp)
mov    %ebp,%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x30(%rsp)
mov    0x1c(%rsp),%ecx
cmp    (%r12),%ecx
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    0x1c(%rsp),%r8
mov    $0xa,%edx
mov    0x2c(%rsp),%edi
xor    %ecx,%ecx
call   10a0 <clCreateBuffer@plt>
mov    %eax,0x24(%rsp)
mov    0x1c(%rsp),%eax
cmp    (%r12),%eax
jne    18db <main+0x5eb>
lea    0x30(%rsp),%rcx
mov    %r13d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     %eax,0x1c(%rsp)
lea    0x24(%rsp),%rcx
mov    %r13d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   1200 <clSetKernelArg@plt>
or     0x1c(%rsp),%eax
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    18f6 <main+0x606>
mov    (%r15),%rdx
lea    0x9d0(%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    0x9b6(%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    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    17f7 <main+0x507>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x30(%rsp),%edi
call   11c0 <clReleaseMemObject@plt>
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
mov    0x2c(%rsp),%ebx
jne    17f7 <main+0x507>
mov    %r13d,%edi
call   1090 <clReleaseKernel@plt>
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    18ff <main+0x60f>
mov    0x34(%rsp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    1908 <main+0x618>
mov    %ebp,%edi
call   1180 <clReleaseCommandQueue@plt>
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    1911 <main+0x621>
mov    %ebx,%edi
call   11b0 <clReleaseContext@plt>
mov    %eax,0x1c(%rsp)
cmp    (%r12),%eax
jne    191a <main+0x62a>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9c7(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xc05(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xbcf(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb9c(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb68(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xb34(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xafb(%rip),%rdi
jmp    1921 <main+0x631>
lea    0xabd(%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    0x814(%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    0xa21(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x9f2(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x9bc(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x990(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x960(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x928(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x8f3(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x897(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x865(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x82e(%rip),%rdi
jmp    1921 <main+0x631>
lea    0x7fc(%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 = [15 x i8] c"ilogb_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 = [12 x i8] c"ilogb_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 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 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 i32 @clGetPlatformIDs(i32 1, i32* %6, i32* %7)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = load i32, i32* @CL_SUCCESS
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
%38 = load i32, i32* %7
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %6
%43 = load i32, i32* @CL_PLATFORM_NAME
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%45 = call i32 @clGetPlatformInfo(i32 %42, i32 %43, i32 100, i8* %44, i32* null)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = load i32, i32* @CL_SUCCESS
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %52
49: ; preds = %37
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %37
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %53)
%55 = load i32, i32* %6
%56 = load i32, i32* @CL_DEVICE_TYPE_GPU
%57 = call i32 @clGetDeviceIDs(i32 %55, i32 %56, i32 1, i32* %10, i32* %11)
store i32 %57, i32* %8
%58 = load i32, i32* %8
%59 = load i32, i32* @CL_SUCCESS
%60 = icmp ne i32 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %52
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %52
%65 = load i32, i32* %11
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %10
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %10
%70 = load i32, i32* @CL_DEVICE_NAME
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%72 = call i32 @clGetDeviceInfo(i32 %69, i32 %70, i32 100, i8* %71, i32* null)
store i32 %72, i32* %8
%73 = load i32, i32* %8
%74 = load i32, i32* @CL_SUCCESS
%75 = icmp ne i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %64
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %64
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%83 = call i32 @clCreateContext(i32* null, i32 1, i32* %10, i32* null, i32* null, i32* %8)
store i32 %83, i32* %13
%84 = load i32, i32* %8
%85 = load i32, i32* @CL_SUCCESS
%86 = icmp ne i32 %84, %85
br i1 %86, label %87, label %90
87: ; preds = %79
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %79
%91 = load i32, i32* %13
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %13
%94 = load i32, i32* %10
%95 = call i32 @clCreateCommandQueue(i32 %93, i32 %94, i32 0, i32* %8)
store i32 %95, i32* %14
%96 = load i32, i32* %8
%97 = load i32, i32* @CL_SUCCESS
%98 = icmp ne i32 %96, %97
br i1 %98, label %99, label %102
99: ; preds = %90
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %90
%103 = load i32, i32* %14
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%106 = call i8* @read_buffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64* %16)
store i8* %106, i8** %15
%107 = load i32, i32* %13
%108 = call i32 @clCreateProgramWithSource(i32 %107, i32 1, i8** %15, i64* %16, i32* %8)
store i32 %108, i32* %17
%109 = load i32, i32* %8
%110 = load i32, i32* @CL_SUCCESS
%111 = icmp ne i32 %109, %110
br i1 %111, label %112, label %115
112: ; preds = %102
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.16, i64 0, i64 0))
%114 = call i32 @exit(i32 1)
unreachable
115: ; preds = %102
%116 = load i32, i32* %17
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %17
%119 = call i32 @clBuildProgram(i32 %118, i32 1, i32* %10, i32* null, i32* null, i32* null)
store i32 %119, i32* %8
%120 = load i32, i32* %8
%121 = load i32, i32* @CL_SUCCESS
%122 = icmp ne i32 %120, %121
br i1 %122, label %123, label %141
123: ; preds = %115
%124 = load i32, i32* %17
%125 = load i32, i32* %10
%126 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%127 = call i32 @clGetProgramBuildInfo(i32 %124, i32 %125, i32 %126, i64 0, i8* null, i64* %18)
%128 = load i64, i64* %18
%129 = call i8* @malloc(i64 %128)
store i8* %129, i8** %19
%130 = load i32, i32* %17
%131 = load i32, i32* %10
%132 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%133 = load i64, i64* %18
%134 = load i8*, i8** %19
%135 = call i32 @clGetProgramBuildInfo(i32 %130, i32 %131, i32 %132, i64 %133, i8* %134, i64* null)
%136 = load i8*, i8** %19
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %136)
%138 = load i8*, i8** %19
%139 = call i32 @free(i8* %138)
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %115
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%144 = load i32, i32* %17
%145 = call i32 @clCreateKernel(i32 %144, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i32* %8)
store i32 %145, i32* %20
%146 = load i32, i32* %8
%147 = load i32, i32* @CL_SUCCESS
%148 = icmp ne i32 %146, %147
br i1 %148, label %149, label %152
149: ; preds = %141
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.21, i64 0, i64 0))
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %141
store i64 10, i64* %21
%153 = load i64, i64* %21
%154 = mul i64 %153, 1
%155 = call i8* @malloc(i64 %154)
store i8* %155, i8** %22
store i32 0, i32* %23
br label %156
156: ; preds = %166, %152
%157 = load i32, i32* %23
%158 = sext i32 %157 to i64
%159 = load i64, i64* %21
%160 = icmp ult i64 %158, %159
br i1 %160, label %161, label %169
161: ; preds = %156
%162 = load i8*, i8** %22
%163 = load i32, i32* %23
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i8, i8* %162, i64 %164
store i8 2, i8* %165
br label %166
166: ; preds = %161
%167 = load i32, i32* %23
%168 = add nsw i32 %167, 1
store i32 %168, i32* %23
br label %156
169: ; preds = %156
%170 = load i32, i32* %13
%171 = load i32, i32* @CL_MEM_READ_ONLY
%172 = load i64, i64* %21
%173 = mul i64 %172, 1
%174 = call i32 @clCreateBuffer(i32 %170, i32 %171, i64 %173, i32* null, i32* %8)
store i32 %174, i32* %24
%175 = load i32, i32* %8
%176 = load i32, i32* @CL_SUCCESS
%177 = icmp ne i32 %175, %176
br i1 %177, label %178, label %181
178: ; preds = %169
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.22, i64 0, i64 0))
%180 = call i32 @exit(i32 1)
unreachable
181: ; preds = %169
%182 = load i32, i32* %14
%183 = load i32, i32* %24
%184 = load i32, i32* @CL_TRUE
%185 = load i64, i64* %21
%186 = mul i64 %185, 1
%187 = load i8*, i8** %22
%188 = call i32 @clEnqueueWriteBuffer(i32 %182, i32 %183, i32 %184, i32 0, i64 %186, i8* %187, i32 0, i32* null, i32* null)
store i32 %188, i32* %8
%189 = load i32, i32* %8
%190 = load i32, i32* @CL_SUCCESS
%191 = icmp ne i32 %189, %190
br i1 %191, label %192, label %195
192: ; preds = %181
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.23, i64 0, i64 0))
%194 = call i32 @exit(i32 1)
unreachable
195: ; preds = %181
%196 = load i64, i64* %21
%197 = mul i64 %196, 1
%198 = call i8* @malloc(i64 %197)
store i8* %198, i8** %25
%199 = load i8*, i8** %25
%200 = load i64, i64* %21
%201 = mul i64 %200, 1
%202 = call i32 @memset(i8* %199, i32 1, i64 %201)
%203 = load i32, i32* %13
%204 = load i32, i32* @CL_MEM_WRITE_ONLY
%205 = load i64, i64* %21
%206 = mul i64 %205, 1
%207 = call i32 @clCreateBuffer(i32 %203, i32 %204, i64 %206, i32* null, i32* %8)
store i32 %207, i32* %26
%208 = load i32, i32* %8
%209 = load i32, i32* @CL_SUCCESS
%210 = icmp ne i32 %208, %209
br i1 %210, label %211, label %214
211: ; preds = %195
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.24, i64 0, i64 0))
%213 = call i32 @exit(i32 1)
unreachable
214: ; preds = %195
%215 = load i32, i32* @CL_SUCCESS
store i32 %215, i32* %8
%216 = load i32, i32* %20
%217 = call i32 @clSetKernelArg(i32 %216, i32 0, i32 4, i32* %24)
%218 = load i32, i32* %8
%219 = or i32 %218, %217
store i32 %219, i32* %8
%220 = load i32, i32* %20
%221 = call i32 @clSetKernelArg(i32 %220, i32 1, i32 4, i32* %26)
%222 = load i32, i32* %8
%223 = or i32 %222, %221
store i32 %223, i32* %8
%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 = %214
%228 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.25, i64 0, i64 0))
%229 = call i32 @exit(i32 1)
unreachable
230: ; preds = %214
%231 = load i64, i64* %21
store i64 %231, i64* %27
%232 = load i64, i64* %21
store i64 %232, i64* %28
%233 = load i32, i32* %14
%234 = load i32, i32* %20
%235 = call i32 @clEnqueueNDRangeKernel(i32 %233, i32 %234, i32 1, i32* null, i64* %27, i64* %28, i32 0, i32* null, i32* null)
store i32 %235, i32* %8
%236 = load i32, i32* %8
%237 = load i32, i32* @CL_SUCCESS
%238 = icmp ne i32 %236, %237
br i1 %238, label %239, label %242
239: ; preds = %230
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.26, i64 0, i64 0))
%241 = call i32 @exit(i32 1)
unreachable
242: ; preds = %230
%243 = load i32, i32* %14
%244 = call i32 @clFinish(i32 %243)
%245 = load i32, i32* %14
%246 = load i32, i32* %26
%247 = load i32, i32* @CL_TRUE
%248 = load i64, i64* %21
%249 = mul i64 %248, 1
%250 = load i8*, i8** %25
%251 = call i32 @clEnqueueReadBuffer(i32 %245, i32 %246, i32 %247, i32 0, i64 %249, i8* %250, i32 0, i32* null, i32* null)
store i32 %251, i32* %8
%252 = load i32, i32* %8
%253 = load i32, i32* @CL_SUCCESS
%254 = icmp ne i32 %252, %253
br i1 %254, label %255, label %258
255: ; preds = %242
%256 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.27, i64 0, i64 0))
%257 = call i32 @exit(i32 1)
unreachable
258: ; preds = %242
%259 = bitcast [100 x i8]* %29 to i8*
%260 = load i8**, i8*** %5
%261 = getelementptr inbounds i8*, i8** %260, i64 0
%262 = load i8*, i8** %261
%263 = call i32 @sprintf(i8* %259, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %262)
%264 = getelementptr inbounds [100 x i8], [100 x i8]* %29, i64 0, i64 0
%265 = load i8*, i8** %25
%266 = load i64, i64* %21
%267 = mul i64 %266, 1
%268 = call i32 @write_buffer(i8* %264, i8* %265, i64 %267)
%269 = getelementptr inbounds [100 x i8], [100 x i8]* %29, i64 0, i64 0
%270 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %269)
%271 = load i8*, i8** %25
%272 = call i32 @free(i8* %271)
%273 = load i32, i32* %26
%274 = call i32 @clReleaseMemObject(i32 %273)
store i32 %274, i32* %8
%275 = load i32, i32* %8
%276 = load i32, i32* @CL_SUCCESS
%277 = icmp ne i32 %275, %276
br i1 %277, label %278, label %281
278: ; preds = %258
%279 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%280 = call i32 @exit(i32 1)
unreachable
281: ; preds = %258
%282 = load i8*, i8** %22
%283 = call i32 @free(i8* %282)
%284 = load i32, i32* %24
%285 = call i32 @clReleaseMemObject(i32 %284)
store i32 %285, i32* %8
%286 = load i32, i32* %8
%287 = load i32, i32* @CL_SUCCESS
%288 = icmp ne i32 %286, %287
br i1 %288, label %289, label %292
289: ; preds = %281
%290 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0))
%291 = call i32 @exit(i32 1)
unreachable
292: ; preds = %281
%293 = load i32, i32* %20
%294 = call i32 @clReleaseKernel(i32 %293)
store i32 %294, i32* %8
%295 = load i32, i32* %8
%296 = load i32, i32* @CL_SUCCESS
%297 = icmp ne i32 %295, %296
br i1 %297, label %298, label %301
298: ; preds = %292
%299 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.31, i64 0, i64 0))
%300 = call i32 @exit(i32 1)
unreachable
301: ; preds = %292
%302 = load i32, i32* %17
%303 = call i32 @clReleaseProgram(i32 %302)
store i32 %303, i32* %8
%304 = load i32, i32* %8
%305 = load i32, i32* @CL_SUCCESS
%306 = icmp ne i32 %304, %305
br i1 %306, label %307, label %310
307: ; preds = %301
%308 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.32, i64 0, i64 0))
%309 = call i32 @exit(i32 1)
unreachable
310: ; preds = %301
%311 = load i32, i32* %14
%312 = call i32 @clReleaseCommandQueue(i32 %311)
store i32 %312, i32* %8
%313 = load i32, i32* %8
%314 = load i32, i32* @CL_SUCCESS
%315 = icmp ne i32 %313, %314
br i1 %315, label %316, label %319
316: ; preds = %310
%317 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.33, i64 0, i64 0))
%318 = call i32 @exit(i32 1)
unreachable
319: ; preds = %310
%320 = load i32, i32* %13
%321 = call i32 @clReleaseContext(i32 %320)
store i32 %321, i32* %8
%322 = load i32, i32* %8
%323 = load i32, i32* @CL_SUCCESS
%324 = icmp ne i32 %322, %323
br i1 %324, label %325, label %328
325: ; preds = %319
%326 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.34, i64 0, i64 0))
%327 = call i32 @exit(i32 1)
unreachable
328: ; preds = %319
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 = [15 x i8] c"ilogb_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 = [12 x i8] c"ilogb_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 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 i64
%16 = alloca i64
%17 = alloca [100 x i8]
%18 = bitcast i32* %3 to i8*
%19 = bitcast i32* %4 to i8*
%20 = bitcast i32* %5 to i8*
%21 = call i32 @clGetPlatformIDs(i32 1, i32* %3, i32* %4)
store i32 %21, i32* %5
%22 = load i32, i32* @CL_SUCCESS
%23 = icmp eq i32 %21, %22
br i1 %23, label %27, label %24
24: ; preds = %2
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.54, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%33 = load i32, i32* %3
%34 = load i32, i32* @CL_PLATFORM_NAME
%35 = call i32 @clGetPlatformInfo(i32 %33, i32 %34, i32 100, i8* %32, i32* null)
store i32 %35, i32* %5
%36 = load i32, i32* @CL_SUCCESS
%37 = icmp eq i32 %35, %36
br i1 %37, label %41, label %38
38: ; preds = %27
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.53, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %27
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%43 = bitcast i32* %7 to i8*
%44 = bitcast i32* %8 to i8*
%45 = load i32, i32* %3
%46 = load i32, i32* @CL_DEVICE_TYPE_GPU
%47 = call i32 @clGetDeviceIDs(i32 %45, i32 %46, i32 1, i32* %7, i32* %8)
store i32 %47, i32* %5
%48 = load i32, i32* @CL_SUCCESS
%49 = icmp eq i32 %47, %48
br i1 %49, label %53, label %50
50: ; preds = %41
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.52, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %41
%54 = load i32, i32* %8
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %7
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%59 = load i32, i32* %7
%60 = load i32, i32* @CL_DEVICE_NAME
%61 = call i32 @clGetDeviceInfo(i32 %59, i32 %60, i32 100, i8* %58, i32* null)
store i32 %61, i32* %5
%62 = load i32, i32* @CL_SUCCESS
%63 = icmp eq i32 %61, %62
br i1 %63, label %67, label %64
64: ; preds = %53
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.51, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %53
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %58)
%69 = call i32 @putchar(i32 10)
%70 = call i32 @clCreateContext(i32* null, i32 1, i32* %7, i32* null, i32* null, i32* %5)
%71 = load i32, i32* %5
%72 = load i32, i32* @CL_SUCCESS
%73 = icmp eq i32 %71, %72
br i1 %73, label %77, label %74
74: ; preds = %67
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.50, i64 0, i64 0))
%76 = call i32 @exit(i32 1)
unreachable
77: ; preds = %67
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %70)
%79 = load i32, i32* %7
%80 = call i32 @clCreateCommandQueue(i32 %70, i32 %79, i32 0, i32* %5)
%81 = load i32, i32* %5
%82 = load i32, i32* @CL_SUCCESS
%83 = icmp eq i32 %81, %82
br i1 %83, label %87, label %84
84: ; preds = %77
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.49, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %77
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i32 %80)
%89 = call i32 @putchar(i32 10)
%90 = bitcast i8** %10 to i8*
%91 = bitcast i64* %11 to i8*
%92 = call i8* @read_buffer(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i64* %11)
store i8* %92, i8** %10
%93 = call i32 @clCreateProgramWithSource(i32 %70, i32 1, i8** %10, i64* %11, i32* %5)
%94 = load i32, i32* %5
%95 = load i32, i32* @CL_SUCCESS
%96 = icmp eq i32 %94, %95
br i1 %96, label %100, label %97
97: ; preds = %87
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.48, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %87
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i32 %93)
%102 = call i32 @clBuildProgram(i32 %93, i32 1, i32* %7, i32* null, i32* null, i32* null)
store i32 %102, i32* %5
%103 = load i32, i32* @CL_SUCCESS
%104 = icmp eq i32 %102, %103
br i1 %104, label %118, label %105
105: ; preds = %100
%106 = bitcast i64* %12 to i8*
%107 = load i32, i32* %7
%108 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%109 = call i32 @clGetProgramBuildInfo(i32 %93, i32 %107, i32 %108, i64 0, i8* null, i64* %12)
%110 = load i64, i64* %12
%111 = call i8* @malloc(i64 %110)
%112 = load i32, i32* %7
%113 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%114 = call i32 @clGetProgramBuildInfo(i32 %93, i32 %112, i32 %113, i64 %110, i8* %111, i64* null)
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.18, i64 0, i64 0), i8* %111)
%116 = call i32 @free(i8* %111)
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %100
%119 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%120 = call i32 @putchar(i32 10)
%121 = call i32 @clCreateKernel(i32 %93, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i32* %5)
%122 = load i32, i32* %5
%123 = load i32, i32* @CL_SUCCESS
%124 = icmp eq i32 %122, %123
br i1 %124, label %128, label %125
125: ; preds = %118
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.47, i64 0, i64 0))
%127 = call i32 @exit(i32 1)
unreachable
128: ; preds = %118
%129 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%130 = bitcast i32* %13 to i8*
%131 = load i32, i32* @CL_MEM_READ_ONLY
%132 = call i32 @clCreateBuffer(i32 %70, i32 %131, i64 10, i32* null, i32* %5)
store i32 %132, i32* %13
%133 = load i32, i32* %5
%134 = load i32, i32* @CL_SUCCESS
%135 = icmp eq i32 %133, %134
br i1 %135, label %139, label %136
136: ; preds = %128
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.46, i64 0, i64 0))
%138 = call i32 @exit(i32 1)
unreachable
139: ; preds = %128
%140 = load i32, i32* @CL_TRUE
%141 = call i32 @clEnqueueWriteBuffer(i32 %80, i32 %132, i32 %140, i32 0, i64 10, i8* %129, i32 0, i32* null, i32* null)
store i32 %141, i32* %5
%142 = load i32, i32* @CL_SUCCESS
%143 = icmp eq i32 %141, %142
br i1 %143, label %147, label %144
144: ; preds = %139
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.45, i64 0, i64 0))
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %139
%148 = call dereferenceable_or_null(10) i8* @malloc(i64 10)
%149 = call i32 @memset(i8* %148, i32 1, i64 10)
%150 = bitcast i32* %14 to i8*
%151 = load i32, i32* @CL_MEM_WRITE_ONLY
%152 = call i32 @clCreateBuffer(i32 %70, i32 %151, i64 10, i32* null, i32* %5)
store i32 %152, i32* %14
%153 = load i32, i32* %5
%154 = load i32, i32* @CL_SUCCESS
%155 = icmp eq i32 %153, %154
br i1 %155, label %159, label %156
156: ; preds = %147
%157 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.44, i64 0, i64 0))
%158 = call i32 @exit(i32 1)
unreachable
159: ; preds = %147
%160 = call i32 @clSetKernelArg(i32 %121, i32 0, i32 4, i32* %13)
%161 = load i32, i32* %5
%162 = or i32 %161, %160
store i32 %162, i32* %5
%163 = call i32 @clSetKernelArg(i32 %121, i32 1, i32 4, i32* %14)
%164 = load i32, i32* %5
%165 = or i32 %164, %163
store i32 %165, i32* %5
%166 = load i32, i32* @CL_SUCCESS
%167 = icmp eq i32 %165, %166
br i1 %167, label %171, label %168
168: ; preds = %159
%169 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.43, i64 0, i64 0))
%170 = call i32 @exit(i32 1)
unreachable
171: ; preds = %159
%172 = bitcast i64* %15 to i8*
store i64 10, i64* %15
%173 = bitcast i64* %16 to i8*
store i64 10, i64* %16
%174 = call i32 @clEnqueueNDRangeKernel(i32 %80, i32 %121, i32 1, i32* null, i64* %15, i64* %16, i32 0, i32* null, i32* null)
store i32 %174, i32* %5
%175 = load i32, i32* @CL_SUCCESS
%176 = icmp eq i32 %174, %175
br i1 %176, label %180, label %177
177: ; preds = %171
%178 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.42, i64 0, i64 0))
%179 = call i32 @exit(i32 1)
unreachable
180: ; preds = %171
%181 = call i32 @clFinish(i32 %80)
%182 = load i32, i32* %14
%183 = load i32, i32* @CL_TRUE
%184 = call i32 @clEnqueueReadBuffer(i32 %80, i32 %182, i32 %183, i32 0, i64 10, i8* %148, i32 0, i32* null, i32* null)
store i32 %184, i32* %5
%185 = load i32, i32* @CL_SUCCESS
%186 = icmp eq i32 %184, %185
br i1 %186, label %190, label %187
187: ; preds = %180
%188 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.41, i64 0, i64 0))
%189 = call i32 @exit(i32 1)
unreachable
190: ; preds = %180
%191 = getelementptr inbounds [100 x i8], [100 x i8]* %17, i64 0, i64 0
%192 = load i8*, i8** %1
%193 = call i32 @sprintf(i8* %191, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.28, i64 0, i64 0), i8* %192)
%194 = call i32 @write_buffer(i8* %191, i8* %148, i64 10)
%195 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.29, i64 0, i64 0), i8* %191)
%196 = call i32 @free(i8* %148)
%197 = load i32, i32* %14
%198 = call i32 @clReleaseMemObject(i32 %197)
store i32 %198, i32* %5
%199 = load i32, i32* @CL_SUCCESS
%200 = icmp eq i32 %198, %199
br i1 %200, label %204, label %201
201: ; preds = %190
%202 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.40, i64 0, i64 0))
%203 = call i32 @exit(i32 1)
unreachable
204: ; preds = %190
%205 = call i32 @free(i8* %129)
%206 = load i32, i32* %13
%207 = call i32 @clReleaseMemObject(i32 %206)
store i32 %207, i32* %5
%208 = load i32, i32* @CL_SUCCESS
%209 = icmp eq i32 %207, %208
br i1 %209, label %213, label %210
210: ; preds = %204
%211 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.40, i64 0, i64 0))
%212 = call i32 @exit(i32 1)
unreachable
213: ; preds = %204
%214 = call i32 @clReleaseKernel(i32 %121)
store i32 %214, i32* %5
%215 = load i32, i32* @CL_SUCCESS
%216 = icmp eq i32 %214, %215
br i1 %216, label %220, label %217
217: ; preds = %213
%218 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.38, i64 0, i64 0))
%219 = call i32 @exit(i32 1)
unreachable
220: ; preds = %213
%221 = call i32 @clReleaseProgram(i32 %93)
store i32 %221, i32* %5
%222 = load i32, i32* @CL_SUCCESS
%223 = icmp eq i32 %221, %222
br i1 %223, label %227, label %224
224: ; preds = %220
%225 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.37, i64 0, i64 0))
%226 = call i32 @exit(i32 1)
unreachable
227: ; preds = %220
%228 = call i32 @clReleaseCommandQueue(i32 %80)
store i32 %228, i32* %5
%229 = load i32, i32* @CL_SUCCESS
%230 = icmp eq i32 %228, %229
br i1 %230, label %234, label %231
231: ; preds = %227
%232 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.36, i64 0, i64 0))
%233 = call i32 @exit(i32 1)
unreachable
234: ; preds = %227
%235 = call i32 @clReleaseContext(i32 %70)
store i32 %235, i32* %5
%236 = load i32, i32* @CL_SUCCESS
%237 = icmp eq i32 %235, %236
br i1 %237, label %241, label %238
238: ; preds = %234
%239 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.35, i64 0, i64 0))
%240 = call i32 @exit(i32 1)
unreachable
241: ; preds = %234
ret i32 0
}