#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ cl_program;
typedef int /*<<< orphan*/ cl_platform_id;
typedef int /*<<< orphan*/ cl_mem;
typedef int /*<<< orphan*/ cl_kernel;
typedef int /*<<< orphan*/ cl_device_id;
typedef int /*<<< orphan*/ cl_context;
typedef int /*<<< orphan*/ cl_command_queue;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_TYPE_ACCELERATOR;
int /*<<< orphan*/ CL_DEVICE_TYPE_CPU;
int /*<<< orphan*/ CL_MEM_READ_ONLY;
int /*<<< orphan*/ CL_PLATFORM_NAME;
int /*<<< orphan*/ CL_PLATFORM_VENDOR;
int /*<<< orphan*/ CL_PROGRAM_BUILD_LOG;
int CL_SUCCESS;
int /*<<< orphan*/ CL_TRUE;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int clBuildProgram(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateCommandQueue(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int *);
int /*<<< orphan*/ clCreateContext(int /*<<< orphan*/, int,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clCreateKernel(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ clCreateProgramWithBinary(int /*<<< orphan*/, int,
                                             int /*<<< orphan*/ *, size_t *,
                                             unsigned char const **, int *,
                                             int *);
int clEnqueueNDRangeKernel(int /*<<< orphan*/, int /*<<< orphan*/, int,
                           int /*<<< orphan*/ *, size_t *, size_t *,
                           int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int clEnqueueWriteBuffer(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/, int, int *,
                         int /*<<< orphan*/, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *);
int clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clGetPlatformIDs(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clGetPlatformInfo(int /*<<< orphan*/, int /*<<< orphan*/, int, void *,
                      int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetProgramBuildInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/, int, 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 clSetKernelArg(int /*<<< orphan*/, int /*<<< orphan*/, int,
                   int /*<<< orphan*/ *);
int load_file_to_memory(char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int err;
  int check_status = 0;
  int h_a[8];
  size_t global[1];
  size_t local[1];
  cl_platform_id platform_id;
  cl_device_id device_id;
  cl_context context;
  cl_command_queue commands;
  cl_program program;
  cl_kernel kernel;
  char cl_platform_vendor[1001];
  char cl_platform_name[1001];
  cl_mem d_a;
  if (argc != 2) {
    printf("Usage: %s xclbin\n", argv[0]);
    return EXIT_FAILURE;
  }
  int i = 0;
  for (i = 0; i < 8; i++) {
    h_a[i] = i;
  }
  err = clGetPlatformIDs(1, &platform_id, NULL);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to find an OpenCL platform!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  err = clGetPlatformInfo(platform_id, CL_PLATFORM_VENDOR, 1000,
                          (void *)cl_platform_vendor, NULL);
  if (err != CL_SUCCESS) {
    printf("Error: clGetPlatformInfo(CL_PLATFORM_VENDOR) failed!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  printf("INFO: CL_PLATFORM_VENDOR %s\n", cl_platform_vendor);
  err = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, 1000,
                          (void *)cl_platform_name, NULL);
  if (err != CL_SUCCESS) {
    printf("Error: clGetPlatformInfo(CL_PLATFORM_NAME) failed!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  printf("INFO: CL_PLATFORM_NAME %s\n", cl_platform_name);
  int fpga = 0;
  err = clGetDeviceIDs(platform_id,
                       fpga ? CL_DEVICE_TYPE_ACCELERATOR : CL_DEVICE_TYPE_CPU,
                       1, &device_id, NULL);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to create a device group!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
  if (!context) {
    printf("Error: Failed to create a compute context!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  commands = clCreateCommandQueue(context, device_id, 0, &err);
  if (!commands) {
    printf("Error: Failed to create a command commands!\n");
    printf("Error: code %i\n", err);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  int status;
  unsigned char *kernelbinary0, *kernelbinary1;
  char *xclbin = argv[1];
  printf("INFO: loading xclbin %s\n", xclbin);
  int n_i0 = load_file_to_memory(xclbin, (char **)&kernelbinary0);
  if (n_i0 < 0) {
    printf("failed to load kernel from xclbin: %s\n", xclbin);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  size_t n0 = n_i0;
  program = clCreateProgramWithBinary(context, 1, &device_id, &n0,
                                      (const unsigned char **)&kernelbinary0,
                                      &status, &err);
  if ((!program) || (err != CL_SUCCESS)) {
    printf("Error: Failed to create compute program from binary %d!\n", err);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
  if (err != CL_SUCCESS) {
    size_t len;
    char buffer[2048];
    printf("Error: Failed to build program executable!\n");
    clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG,
                          sizeof(buffer), buffer, &len);
    printf("%s\n", buffer);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  kernel = clCreateKernel(program, "hello_world", &err);
  if (!kernel || err != CL_SUCCESS) {
    printf("Error: Failed to create compute kernel!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  d_a = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(int) * 8, NULL, NULL);
  if (!d_a) {
    printf("Error: Failed to allocate device memory!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  err = clEnqueueWriteBuffer(commands, d_a, CL_TRUE, 0, sizeof(int) * 8, h_a, 0,
                             NULL, NULL);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to write to source array a!\n");
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  err = 0;
  err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &d_a);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to set kernel arguments! %d\n", err);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  global[0] = (8) * (1);
  local[0] = (1);
  err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, (size_t *)&global,
                               (size_t *)&local, 0, NULL, NULL);
  if (err) {
    printf("Error: Failed to execute kernel! %d\n", err);
    printf("Test failed\n");
    return EXIT_FAILURE;
  }
  clReleaseMemObject(d_a);
  clReleaseProgram(program);
  clReleaseKernel(kernel);
  clReleaseCommandQueue(commands);
  clReleaseContext(context);
  printf("INFO: Test completed successfully\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1290 <main+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
movl   $0x0,-0x858(%rbp)
movl   $0x0,-0x858(%rbp)
cmpl   $0x8,-0x858(%rbp)
jge    12d6 <main+0x96>
mov    -0x858(%rbp),%ecx
movslq -0x858(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x858(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x858(%rbp)
jmp    12a4 <main+0x64>
mov    $0x1,%edi
lea    -0x54(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10a0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2cab(%rip),%rcx
cmp    (%rcx),%eax
je     132a <main+0xea>
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x54(%rbp),%edi
mov    0x2c5c(%rip),%rax
mov    (%rax),%esi
lea    -0x460(%rbp),%rcx
mov    $0x3e8,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   10c0 <clGetPlatformInfo@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2c47(%rip),%rcx
cmp    (%rcx),%eax
je     138e <main+0x14e>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
lea    -0x460(%rbp),%rsi
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x54(%rbp),%edi
mov    0x2c23(%rip),%rax
mov    (%rax),%esi
lea    -0x850(%rbp),%rcx
mov    $0x3e8,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   10c0 <clGetPlatformInfo@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2bce(%rip),%rcx
cmp    (%rcx),%eax
je     1407 <main+0x1c7>
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
lea    -0x850(%rbp),%rsi
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
movl   $0x0,-0x85c(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x1094(%rbp)
cmpl   $0x0,-0x85c(%rbp)
je     1450 <main+0x210>
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1098(%rbp)
jmp    145f <main+0x21f>
mov    0x2b71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1098(%rbp)
mov    -0x1094(%rbp),%edi
mov    -0x1098(%rbp),%esi
mov    $0x1,%edx
lea    -0x58(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <clGetDeviceIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2b15(%rip),%rcx
cmp    (%rcx),%eax
je     14c0 <main+0x280>
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2b0a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
xor    %edi,%edi
mov    $0x1,%esi
lea    -0x58(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x14(%rbp),%r9
mov    %r8,%rcx
call   10d0 <clCreateContext@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jne    1516 <main+0x2d6>
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xb3f(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2ab4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%esi
xor    %edx,%edx
lea    -0x14(%rbp),%rcx
call   1090 <clCreateCommandQueue@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jne    1572 <main+0x332>
lea    0xc06(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xc22(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xae3(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2a58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x878(%rbp)
mov    -0x878(%rbp),%rsi
lea    0xbef(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x878(%rbp),%rdi
lea    -0x868(%rbp),%rsi
call   1140 <load_file_to_memory@plt>
mov    %eax,-0x87c(%rbp)
cmpl   $0x0,-0x87c(%rbp)
jge    15f0 <main+0x3b0>
mov    -0x878(%rbp),%rsi
lea    0xbcd(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xa65(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x29da(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
movslq -0x87c(%rbp),%rax
mov    %rax,-0x888(%rbp)
mov    -0x5c(%rbp),%edi
mov    $0x1,%esi
lea    -0x58(%rbp),%rdx
lea    -0x888(%rbp),%rcx
lea    -0x868(%rbp),%r8
lea    -0x860(%rbp),%r9
lea    -0x14(%rbp),%rax
mov    %rax,(%rsp)
call   1130 <clCreateProgramWithBinary@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     164b <main+0x40b>
mov    -0x14(%rbp),%eax
mov    0x295d(%rip),%rcx
cmp    (%rcx),%eax
je     167b <main+0x43b>
mov    -0x14(%rbp),%esi
lea    0xb69(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x9da(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x294f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x64(%rbp),%edi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rdx
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2900(%rip),%rcx
cmp    (%rcx),%eax
je     1711 <main+0x4d1>
lea    0xb48(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x64(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    0x291d(%rip),%rax
mov    (%rax),%edx
lea    -0x1090(%rbp),%r8
mov    $0x800,%ecx
lea    -0x890(%rbp),%r9
call   10e0 <clGetProgramBuildInfo@plt>
lea    -0x1090(%rbp),%rsi
lea    0xacf(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x944(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x28b9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x64(%rbp),%edi
lea    0xb08(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1120 <clCreateKernel@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x68(%rbp)
je     1743 <main+0x503>
mov    -0x14(%rbp),%eax
mov    0x2865(%rip),%rcx
cmp    (%rcx),%eax
je     1770 <main+0x530>
lea    0xae5(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x8e5(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x285a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x5c(%rbp),%edi
mov    0x282e(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1050 <clCreateBuffer@plt>
mov    %eax,-0x854(%rbp)
cmpl   $0x0,-0x854(%rbp)
jne    17ce <main+0x58e>
lea    0xab0(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x887(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x27fc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x60(%rbp),%edi
mov    -0x854(%rbp),%esi
mov    0x280a(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%r9
xor    %ecx,%ecx
mov    $0x20,%r8d
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1160 <clEnqueueWriteBuffer@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2787(%rip),%rcx
cmp    (%rcx),%eax
je     184e <main+0x60e>
lea    0xa5a(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x807(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x277c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
movl   $0x0,-0x14(%rbp)
mov    -0x68(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x854(%rbp),%rcx
call   1150 <clSetKernelArg@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2728(%rip),%rcx
cmp    (%rcx),%eax
je     18b0 <main+0x670>
mov    -0x14(%rbp),%esi
lea    0xa23(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x7a5(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x271a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
movq   $0x8,-0x48(%rbp)
movq   $0x1,-0x50(%rbp)
mov    -0x60(%rbp),%edi
mov    -0x68(%rbp),%esi
lea    -0x48(%rbp),%r8
lea    -0x50(%rbp),%r9
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1080 <clEnqueueNDRangeKernel@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1934 <main+0x6f4>
mov    -0x14(%rbp),%esi
lea    0x9ca(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0x721(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2696(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1979 <main+0x739>
mov    -0x854(%rbp),%edi
call   1110 <clReleaseMemObject@plt>
mov    -0x64(%rbp),%edi
call   1060 <clReleaseProgram@plt>
mov    -0x68(%rbp),%edi
call   1040 <clReleaseKernel@plt>
mov    -0x60(%rbp),%edi
call   10f0 <clReleaseCommandQueue@plt>
mov    -0x5c(%rbp),%edi
call   1100 <clReleaseContext@plt>
lea    0x997(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2644(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1050,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    1529 <main+0x2d9>
movaps 0xd8e(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xd92(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0x28(%rsp),%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   10b0 <clGetPlatformIDs@plt>
mov    0x2d0d(%rip),%rbx
cmp    (%rbx),%eax
jne    153d <main+0x2ed>
mov    0x28(%rsp),%edi
mov    0x2cea(%rip),%rax
mov    (%rax),%esi
lea    0x460(%rsp),%rcx
mov    $0x3e8,%edx
xor    %r8d,%r8d
call   10d0 <clGetPlatformInfo@plt>
cmp    (%rbx),%eax
jne    1546 <main+0x2f6>
lea    0xd5e(%rip),%rdi
lea    0x460(%rsp),%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
lea    0x70(%rsp),%rcx
mov    $0x3e8,%edx
xor    %r8d,%r8d
call   10d0 <clGetPlatformInfo@plt>
cmp    (%rbx),%eax
jne    154f <main+0x2ff>
lea    0xd3e(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x28(%rsp),%edi
mov    0x2ca0(%rip),%rax
mov    (%rax),%esi
lea    0x24(%rsp),%rcx
mov    $0x1,%edx
xor    %r8d,%r8d
call   1080 <clGetDeviceIDs@plt>
mov    %eax,0x20(%rsp)
cmp    (%rbx),%eax
jne    1558 <main+0x308>
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%r9
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10e0 <clCreateContext@plt>
test   %eax,%eax
je     1561 <main+0x311>
mov    %eax,%r12d
mov    0x24(%rsp),%esi
lea    0x20(%rsp),%r14
mov    %eax,%edi
xor    %edx,%edx
mov    %r14,%rcx
call   10a0 <clCreateCommandQueue@plt>
test   %eax,%eax
je     1592 <main+0x342>
mov    %eax,%r15d
mov    0x8(%rbp),%rbp
lea    0xce1(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0x40(%rsp),%rsi
mov    %rbp,%rdi
call   1150 <load_file_to_memory@plt>
test   %eax,%eax
js     15ab <main+0x35b>
mov    %eax,%eax
mov    %rax,0x38(%rsp)
mov    %r14,(%rsp)
lea    0x24(%rsp),%rdx
lea    0x38(%rsp),%rcx
lea    0x40(%rsp),%r8
lea    0x4c(%rsp),%r9
mov    %r12d,%edi
mov    $0x1,%esi
call   1140 <clCreateProgramWithBinary@plt>
mov    0x20(%rsp),%esi
test   %eax,%eax
je     15be <main+0x36e>
cmp    (%rbx),%esi
jne    15be <main+0x36e>
mov    %eax,%r14d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,0x20(%rsp)
cmp    (%rbx),%eax
jne    15ce <main+0x37e>
lea    0xcd2(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %r14d,%edi
call   1130 <clCreateKernel@plt>
test   %eax,%eax
je     160c <main+0x3bc>
mov    %eax,%ebp
mov    0x20(%rsp),%eax
cmp    (%rbx),%eax
jne    160c <main+0x3bc>
mov    0x2b65(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    $0x20,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <clCreateBuffer@plt>
mov    %eax,0x2c(%rsp)
test   %eax,%eax
je     1618 <main+0x3c8>
mov    0x2b76(%rip),%rcx
mov    (%rcx),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x50(%rsp),%r9
mov    %r15d,%edi
mov    %eax,%esi
xor    %ecx,%ecx
mov    $0x20,%r8d
call   1170 <clEnqueueWriteBuffer@plt>
mov    %eax,0x20(%rsp)
cmp    (%rbx),%eax
jne    1624 <main+0x3d4>
movl   $0x0,0x20(%rsp)
lea    0x2c(%rsp),%rcx
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1160 <clSetKernelArg@plt>
mov    %eax,0x20(%rsp)
cmp    (%rbx),%eax
jne    1630 <main+0x3e0>
movq   $0x8,0x850(%rsp)
movq   $0x1,0x30(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x850(%rsp),%r8
lea    0x30(%rsp),%r9
mov    %r15d,%edi
mov    %ebp,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1090 <clEnqueueNDRangeKernel@plt>
mov    %eax,0x20(%rsp)
test   %eax,%eax
je     163b <main+0x3eb>
lea    0xc08(%rip),%rdi
mov    %eax,%esi
jmp    15c5 <main+0x375>
mov    0x0(%rbp),%rsi
lea    0xaec(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
jmp    1579 <main+0x329>
lea    0xdba(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xd7c(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xd40(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xd0f(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xbe7(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb4(%rip),%rdi
call   1040 <puts@plt>
mov    0x2a40(%rip),%rax
mov    (%rax),%eax
add    $0x1050,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbe1(%rip),%rdi
call   1040 <puts@plt>
mov    0x20(%rsp),%esi
lea    0xac1(%rip),%rdi
jmp    15c5 <main+0x375>
lea    0xae1(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
jmp    156d <main+0x31d>
lea    0xaf5(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
jmp    156d <main+0x31d>
lea    0xc6e(%rip),%rdi
call   1040 <puts@plt>
mov    0x24(%rsp),%esi
mov    0x29fb(%rip),%rax
mov    (%rax),%edx
lea    0x850(%rsp),%rbx
lea    0x30(%rsp),%r9
mov    %r14d,%edi
mov    $0x800,%ecx
mov    %rbx,%r8
call   10f0 <clGetProgramBuildInfo@plt>
mov    %rbx,%rdi
jmp    1568 <main+0x318>
lea    0xb93(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xbaf(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xbee(%rip),%rdi
jmp    1568 <main+0x318>
lea    0xac8(%rip),%rdi
mov    %eax,%esi
jmp    15c5 <main+0x375>
mov    0x2c(%rsp),%edi
call   1120 <clReleaseMemObject@plt>
mov    %r14d,%edi
call   1070 <clReleaseProgram@plt>
mov    %ebp,%edi
call   1050 <clReleaseKernel@plt>
mov    %r15d,%edi
call   1100 <clReleaseCommandQueue@plt>
mov    %r12d,%edi
call   1110 <clReleaseContext@plt>
lea    0xb8d(%rip),%rdi
call   1040 <puts@plt>
mov    0x2942(%rip),%rax
jmp    1580 <main+0x330>

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s xclbin\0A\00"
@EXIT_FAILURE = global i32 0
@CL_SUCCESS = global i32 0
@.str.1 = [43 x i8] c"Error: Failed to find an OpenCL platform!\0A\00"
@.str.2 = [13 x i8] c"Test failed\0A\00"
@CL_PLATFORM_VENDOR = global i32 0
@.str.3 = [54 x i8] c"Error: clGetPlatformInfo(CL_PLATFORM_VENDOR) failed!\0A\00"
@.str.4 = [29 x i8] c"INFO: CL_PLATFORM_VENDOR %s\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.5 = [52 x i8] c"Error: clGetPlatformInfo(CL_PLATFORM_NAME) failed!\0A\00"
@.str.6 = [27 x i8] c"INFO: CL_PLATFORM_NAME %s\0A\00"
@CL_DEVICE_TYPE_ACCELERATOR = global i32 0
@CL_DEVICE_TYPE_CPU = global i32 0
@.str.7 = [41 x i8] c"Error: Failed to create a device group!\0A\00"
@.str.8 = [44 x i8] c"Error: Failed to create a compute context!\0A\00"
@.str.9 = [45 x i8] c"Error: Failed to create a command commands!\0A\00"
@.str.10 = [16 x i8] c"Error: code %i\0A\00"
@.str.11 = [25 x i8] c"INFO: loading xclbin %s\0A\00"
@.str.12 = [39 x i8] c"failed to load kernel from xclbin: %s\0A\00"
@.str.13 = [57 x i8] c"Error: Failed to create compute program from binary %d!\0A\00"
@.str.14 = [44 x i8] c"Error: Failed to build program executable!\0A\00"
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.15 = [4 x i8] c"%s\0A\00"
@.str.16 = [12 x i8] c"hello_world\00"
@.str.17 = [41 x i8] c"Error: Failed to create compute kernel!\0A\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.18 = [42 x i8] c"Error: Failed to allocate device memory!\0A\00"
@CL_TRUE = global i32 0
@.str.19 = [43 x i8] c"Error: Failed to write to source array a!\0A\00"
@.str.20 = [43 x i8] c"Error: Failed to set kernel arguments! %d\0A\00"
@.str.21 = [37 x i8] c"Error: Failed to execute kernel! %d\0A\00"
@.str.22 = [35 x i8] c"INFO: Test completed successfully\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [8 x i32]
%9 = alloca [1 x i64]
%10 = alloca [1 x i64]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [1001 x i8]
%18 = alloca [1001 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i32
%27 = alloca i64
%28 = alloca i64
%29 = alloca [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 2
br i1 %31, label %32, label %38
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @EXIT_FAILURE
store i32 %37, i32* %3
br label %248
38: ; preds = %2
store i32 0, i32* %20
store i32 0, i32* %20
br label %39
39: ; preds = %47, %38
%40 = load i32, i32* %20
%41 = icmp slt i32 %40, 8
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i32, i32* %20
%44 = load i32, i32* %20
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 %45
store i32 %43, i32* %46
br label %47
47: ; preds = %42
%48 = load i32, i32* %20
%49 = add nsw i32 %48, 1
store i32 %49, i32* %20
br label %39
50: ; preds = %39
%51 = call i32 @clGetPlatformIDs(i32 1, i32* %11, i32* null)
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = load i32, i32* @CL_SUCCESS
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
store i32 %58, i32* %3
br label %248
59: ; preds = %50
%60 = load i32, i32* %11
%61 = load i32, i32* @CL_PLATFORM_VENDOR
%62 = getelementptr inbounds [1001 x i8], [1001 x i8]* %17, i64 0, i64 0
%63 = call i32 @clGetPlatformInfo(i32 %60, i32 %61, i32 1000, i8* %62, i32* null)
store i32 %63, i32* %6
%64 = load i32, i32* %6
%65 = load i32, i32* @CL_SUCCESS
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %59
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%70 = load i32, i32* @EXIT_FAILURE
store i32 %70, i32* %3
br label %248
71: ; preds = %59
%72 = getelementptr inbounds [1001 x i8], [1001 x i8]* %17, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%74 = load i32, i32* %11
%75 = load i32, i32* @CL_PLATFORM_NAME
%76 = getelementptr inbounds [1001 x i8], [1001 x i8]* %18, i64 0, i64 0
%77 = call i32 @clGetPlatformInfo(i32 %74, i32 %75, i32 1000, i8* %76, i32* null)
store i32 %77, i32* %6
%78 = load i32, i32* %6
%79 = load i32, i32* @CL_SUCCESS
%80 = icmp ne i32 %78, %79
br i1 %80, label %81, label %85
81: ; preds = %71
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
store i32 %84, i32* %3
br label %248
85: ; preds = %71
%86 = getelementptr inbounds [1001 x i8], [1001 x i8]* %18, i64 0, i64 0
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %86)
store i32 0, i32* %21
%88 = load i32, i32* %11
%89 = load i32, i32* %21
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %85
%92 = load i32, i32* @CL_DEVICE_TYPE_ACCELERATOR
br label %95
93: ; preds = %85
%94 = load i32, i32* @CL_DEVICE_TYPE_CPU
br label %95
95: ; preds = %93, %91
%96 = phi i32 [ %92, %91 ], [ %94, %93 ]
%97 = call i32 @clGetDeviceIDs(i32 %88, i32 %96, i32 1, i32* %12, i32* null)
store i32 %97, i32* %6
%98 = load i32, i32* %6
%99 = load i32, i32* @CL_SUCCESS
%100 = icmp ne i32 %98, %99
br i1 %100, label %101, label %105
101: ; preds = %95
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
store i32 %104, i32* %3
br label %248
105: ; preds = %95
%106 = call i32 @clCreateContext(i32 0, i32 1, i32* %12, i32* null, i32* null, i32* %6)
store i32 %106, i32* %13
%107 = load i32, i32* %13
%108 = icmp ne i32 %107, 0
br i1 %108, label %113, label %109
109: ; preds = %105
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
store i32 %112, i32* %3
br label %248
113: ; preds = %105
%114 = load i32, i32* %13
%115 = load i32, i32* %12
%116 = call i32 @clCreateCommandQueue(i32 %114, i32 %115, i32 0, i32* %6)
store i32 %116, i32* %14
%117 = load i32, i32* %14
%118 = icmp ne i32 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %113
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
%121 = load i32, i32* %6
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %121)
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%124 = load i32, i32* @EXIT_FAILURE
store i32 %124, i32* %3
br label %248
125: ; preds = %113
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 1
%128 = load i8*, i8** %127
store i8* %128, i8** %25
%129 = load i8*, i8** %25
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %129)
%131 = load i8*, i8** %25
%132 = call i32 @load_file_to_memory(i8* %131, i8** %23)
store i32 %132, i32* %26
%133 = load i32, i32* %26
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %140
135: ; preds = %125
%136 = load i8*, i8** %25
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* %136)
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%139 = load i32, i32* @EXIT_FAILURE
store i32 %139, i32* %3
br label %248
140: ; preds = %125
%141 = load i32, i32* %26
%142 = sext i32 %141 to i64
store i64 %142, i64* %27
%143 = load i32, i32* %13
%144 = call i32 @clCreateProgramWithBinary(i32 %143, i32 1, i32* %12, i64* %27, i8** %23, i32* %22, i32* %6)
store i32 %144, i32* %15
%145 = load i32, i32* %15
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %151
147: ; preds = %140
%148 = load i32, i32* %6
%149 = load i32, i32* @CL_SUCCESS
%150 = icmp ne i32 %148, %149
br i1 %150, label %151, label %156
151: ; preds = %147, %140
%152 = load i32, i32* %6
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.13, i64 0, i64 0), i32 %152)
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%155 = load i32, i32* @EXIT_FAILURE
store i32 %155, i32* %3
br label %248
156: ; preds = %147
%157 = load i32, i32* %15
%158 = call i32 @clBuildProgram(i32 %157, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %158, i32* %6
%159 = load i32, i32* %6
%160 = load i32, i32* @CL_SUCCESS
%161 = icmp ne i32 %159, %160
br i1 %161, label %162, label %173
162: ; preds = %156
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.14, i64 0, i64 0))
%164 = load i32, i32* %15
%165 = load i32, i32* %12
%166 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%167 = getelementptr inbounds [2048 x i8], [2048 x i8]* %29, i64 0, i64 0
%168 = call i32 @clGetProgramBuildInfo(i32 %164, i32 %165, i32 %166, i32 2048, i8* %167, i64* %28)
%169 = getelementptr inbounds [2048 x i8], [2048 x i8]* %29, i64 0, i64 0
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %169)
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%172 = load i32, i32* @EXIT_FAILURE
store i32 %172, i32* %3
br label %248
173: ; preds = %156
%174 = load i32, i32* %15
%175 = call i32 @clCreateKernel(i32 %174, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32* %6)
store i32 %175, i32* %16
%176 = load i32, i32* %16
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %182
178: ; preds = %173
%179 = load i32, i32* %6
%180 = load i32, i32* @CL_SUCCESS
%181 = icmp ne i32 %179, %180
br i1 %181, label %182, label %186
182: ; preds = %178, %173
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.17, i64 0, i64 0))
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%185 = load i32, i32* @EXIT_FAILURE
store i32 %185, i32* %3
br label %248
186: ; preds = %178
%187 = load i32, i32* %13
%188 = load i32, i32* @CL_MEM_READ_ONLY
%189 = call i32 @clCreateBuffer(i32 %187, i32 %188, i32 32, i32* null, i32* null)
store i32 %189, i32* %19
%190 = load i32, i32* %19
%191 = icmp ne i32 %190, 0
br i1 %191, label %196, label %192
192: ; preds = %186
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.18, i64 0, i64 0))
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%195 = load i32, i32* @EXIT_FAILURE
store i32 %195, i32* %3
br label %248
196: ; preds = %186
%197 = load i32, i32* %14
%198 = load i32, i32* %19
%199 = load i32, i32* @CL_TRUE
%200 = getelementptr inbounds [8 x i32], [8 x i32]* %8, i64 0, i64 0
%201 = call i32 @clEnqueueWriteBuffer(i32 %197, i32 %198, i32 %199, i32 0, i32 32, i32* %200, i32 0, i32* null, i32* null)
store i32 %201, i32* %6
%202 = load i32, i32* %6
%203 = load i32, i32* @CL_SUCCESS
%204 = icmp ne i32 %202, %203
br i1 %204, label %205, label %209
205: ; preds = %196
%206 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.19, i64 0, i64 0))
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%208 = load i32, i32* @EXIT_FAILURE
store i32 %208, i32* %3
br label %248
209: ; preds = %196
store i32 0, i32* %6
%210 = load i32, i32* %16
%211 = call i32 @clSetKernelArg(i32 %210, i32 0, i32 4, i32* %19)
store i32 %211, i32* %6
%212 = load i32, i32* %6
%213 = load i32, i32* @CL_SUCCESS
%214 = icmp ne i32 %212, %213
br i1 %214, label %215, label %220
215: ; preds = %209
%216 = load i32, i32* %6
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.20, i64 0, i64 0), i32 %216)
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%219 = load i32, i32* @EXIT_FAILURE
store i32 %219, i32* %3
br label %248
220: ; preds = %209
%221 = getelementptr inbounds [1 x i64], [1 x i64]* %9, i64 0, i64 0
store i64 8, i64* %221
%222 = getelementptr inbounds [1 x i64], [1 x i64]* %10, i64 0, i64 0
store i64 1, i64* %222
%223 = load i32, i32* %14
%224 = load i32, i32* %16
%225 = bitcast [1 x i64]* %9 to i64*
%226 = bitcast [1 x i64]* %10 to i64*
%227 = call i32 @clEnqueueNDRangeKernel(i32 %223, i32 %224, i32 1, i32* null, i64* %225, i64* %226, i32 0, i32* null, i32* null)
store i32 %227, i32* %6
%228 = load i32, i32* %6
%229 = icmp ne i32 %228, 0
br i1 %229, label %230, label %235
230: ; preds = %220
%231 = load i32, i32* %6
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0), i32 %231)
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%234 = load i32, i32* @EXIT_FAILURE
store i32 %234, i32* %3
br label %248
235: ; preds = %220
%236 = load i32, i32* %19
%237 = call i32 @clReleaseMemObject(i32 %236)
%238 = load i32, i32* %15
%239 = call i32 @clReleaseProgram(i32 %238)
%240 = load i32, i32* %16
%241 = call i32 @clReleaseKernel(i32 %240)
%242 = load i32, i32* %14
%243 = call i32 @clReleaseCommandQueue(i32 %242)
%244 = load i32, i32* %13
%245 = call i32 @clReleaseContext(i32 %244)
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.22, i64 0, i64 0))
%247 = load i32, i32* @EXIT_SUCCESS
store i32 %247, i32* %3
br label %248
248: ; preds = %235, %230, %215, %205, %192, %182, %162, %151, %135, %119, %109, %101, %81, %67, %55, %32
%249 = load i32, i32* %3
ret i32 %249
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s xclbin\0A\00"
@EXIT_FAILURE = global i32 0
@CL_SUCCESS = global i32 0
@CL_PLATFORM_VENDOR = global i32 0
@.str.4 = [29 x i8] c"INFO: CL_PLATFORM_VENDOR %s\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.6 = [27 x i8] c"INFO: CL_PLATFORM_NAME %s\0A\00"
@CL_DEVICE_TYPE_ACCELERATOR = global i32 0
@CL_DEVICE_TYPE_CPU = global i32 0
@.str.10 = [16 x i8] c"Error: code %i\0A\00"
@.str.11 = [25 x i8] c"INFO: loading xclbin %s\0A\00"
@.str.12 = [39 x i8] c"failed to load kernel from xclbin: %s\0A\00"
@.str.13 = [57 x i8] c"Error: Failed to create compute program from binary %d!\0A\00"
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.16 = [12 x i8] c"hello_world\00"
@CL_MEM_READ_ONLY = global i32 0
@CL_TRUE = global i32 0
@.str.20 = [43 x i8] c"Error: Failed to set kernel arguments! %d\0A\00"
@.str.21 = [37 x i8] c"Error: Failed to execute kernel! %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [43 x i8] c"Error: Failed to create a compute context!\00"
@str.24 = [44 x i8] c"Error: Failed to create a command commands!\00"
@str.27 = [40 x i8] c"Error: Failed to create compute kernel!\00"
@str.29 = [41 x i8] c"Error: Failed to allocate device memory!\00"
@str.31 = [34 x i8] c"INFO: Test completed successfully\00"
@str.34 = [42 x i8] c"Error: Failed to write to source array a!\00"
@str.36 = [43 x i8] c"Error: Failed to build program executable!\00"
@str.39 = [40 x i8] c"Error: Failed to create a device group!\00"
@str.41 = [51 x i8] c"Error: clGetPlatformInfo(CL_PLATFORM_NAME) failed!\00"
@str.43 = [53 x i8] c"Error: clGetPlatformInfo(CL_PLATFORM_VENDOR) failed!\00"
@str.45 = [42 x i8] c"Error: Failed to find an OpenCL platform!\00"
@str.46 = [12 x i8] c"Test failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = alloca [1 x i64]
%6 = alloca [1 x i64]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1001 x i8]
%10 = alloca [1001 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca [2048 x i8]
%17 = bitcast i32* %3 to i8*
%18 = bitcast [8 x i32]* %4 to i8*
%19 = bitcast [1 x i64]* %5 to i8*
%20 = bitcast [1 x i64]* %6 to i8*
%21 = bitcast i32* %7 to i8*
%22 = bitcast i32* %8 to i8*
%23 = getelementptr inbounds [1001 x i8], [1001 x i8]* %9, i64 0, i64 0
%24 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 0
%25 = bitcast i32* %11 to i8*
%26 = icmp eq i32 %0, 2
br i1 %26, label %27, label %35
27: ; preds = %2
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%29 = bitcast [8 x i32]* %4 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %29
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %31
%32 = call i32 @clGetPlatformIDs(i32 1, i32* %7, i32* null)
%33 = load i32, i32* @CL_SUCCESS
%34 = icmp eq i32 %32, %33
br i1 %34, label %43, label %39
35: ; preds = %2
%36 = load i8*, i8** %1
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
br label %189
39: ; preds = %27
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.45, i64 0, i64 0))
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
br label %189
43: ; preds = %27
%44 = load i32, i32* %7
%45 = load i32, i32* @CL_PLATFORM_VENDOR
%46 = call i32 @clGetPlatformInfo(i32 %44, i32 %45, i32 1000, i8* %23, i32* null)
%47 = load i32, i32* @CL_SUCCESS
%48 = icmp eq i32 %46, %47
br i1 %48, label %53, label %49
49: ; preds = %43
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.43, i64 0, i64 0))
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
br label %189
53: ; preds = %43
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%55 = load i32, i32* %7
%56 = load i32, i32* @CL_PLATFORM_NAME
%57 = call i32 @clGetPlatformInfo(i32 %55, i32 %56, i32 1000, i8* %24, i32* null)
%58 = load i32, i32* @CL_SUCCESS
%59 = icmp eq i32 %57, %58
br i1 %59, label %64, label %60
60: ; preds = %53
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.41, i64 0, i64 0))
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
br label %189
64: ; preds = %53
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%66 = load i32, i32* %7
%67 = load i32, i32* @CL_DEVICE_TYPE_CPU
%68 = call i32 @clGetDeviceIDs(i32 %66, i32 %67, i32 1, i32* %8, i32* null)
store i32 %68, i32* %3
%69 = load i32, i32* @CL_SUCCESS
%70 = icmp eq i32 %68, %69
br i1 %70, label %75, label %71
71: ; preds = %64
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.39, i64 0, i64 0))
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
br label %189
75: ; preds = %64
%76 = call i32 @clCreateContext(i32 0, i32 1, i32* %8, i32* null, i32* null, i32* %3)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
br label %189
82: ; preds = %75
%83 = load i32, i32* %8
%84 = call i32 @clCreateCommandQueue(i32 %76, i32 %83, i32 0, i32* %3)
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %92
86: ; preds = %82
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.24, i64 0, i64 0))
%88 = load i32, i32* %3
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %88)
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%91 = load i32, i32* @EXIT_FAILURE
br label %189
92: ; preds = %82
%93 = bitcast i32* %12 to i8*
%94 = bitcast i8** %13 to i8*
%95 = getelementptr inbounds i8*, i8** %1, i64 1
%96 = load i8*, i8** %95
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i8* %96)
%98 = call i32 @load_file_to_memory(i8* %96, i8** %13)
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %92
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* %96)
%102 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
br label %187
104: ; preds = %92
%105 = bitcast i64* %14 to i8*
%106 = zext i32 %98 to i64
store i64 %106, i64* %14
%107 = call i32 @clCreateProgramWithBinary(i32 %76, i32 1, i32* %8, i64* %14, i8** %13, i32* %12, i32* %3)
%108 = icmp ne i32 %107, 0
%109 = load i32, i32* %3
%110 = load i32, i32* @CL_SUCCESS
%111 = icmp eq i32 %109, %110
%112 = select i1 %108, i1 %111, i1 false
br i1 %112, label %117, label %113
113: ; preds = %104
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.13, i64 0, i64 0), i32 %109)
%115 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
br label %185
117: ; preds = %104
%118 = call i32 @clBuildProgram(i32 %107, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %118, i32* %3
%119 = load i32, i32* @CL_SUCCESS
%120 = icmp eq i32 %118, %119
br i1 %120, label %131, label %121
121: ; preds = %117
%122 = bitcast i64* %15 to i8*
%123 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.36, i64 0, i64 0))
%125 = load i32, i32* %8
%126 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%127 = call i32 @clGetProgramBuildInfo(i32 %107, i32 %125, i32 %126, i32 2048, i8* %123, i64* %15)
%128 = call i32 @puts(i8* %123)
%129 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%130 = load i32, i32* @EXIT_FAILURE
br label %185
131: ; preds = %117
%132 = call i32 @clCreateKernel(i32 %107, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32* %3)
%133 = icmp eq i32 %132, 0
br i1 %133, label %138, label %134
134: ; preds = %131
%135 = load i32, i32* %3
%136 = load i32, i32* @CL_SUCCESS
%137 = icmp eq i32 %135, %136
br i1 %137, label %142, label %138
138: ; preds = %134, %131
%139 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.27, i64 0, i64 0))
%140 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%141 = load i32, i32* @EXIT_FAILURE
br label %185
142: ; preds = %134
%143 = load i32, i32* @CL_MEM_READ_ONLY
%144 = call i32 @clCreateBuffer(i32 %76, i32 %143, i32 32, i32* null, i32* null)
store i32 %144, i32* %11
%145 = icmp eq i32 %144, 0
br i1 %145, label %146, label %150
146: ; preds = %142
%147 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.29, i64 0, i64 0))
%148 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%149 = load i32, i32* @EXIT_FAILURE
br label %185
150: ; preds = %142
%151 = load i32, i32* @CL_TRUE
%152 = call i32 @clEnqueueWriteBuffer(i32 %84, i32 %144, i32 %151, i32 0, i32 32, i32* %28, i32 0, i32* null, i32* null)
store i32 %152, i32* %3
%153 = load i32, i32* @CL_SUCCESS
%154 = icmp eq i32 %152, %153
br i1 %154, label %159, label %155
155: ; preds = %150
%156 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.34, i64 0, i64 0))
%157 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
br label %185
159: ; preds = %150
store i32 0, i32* %3
%160 = call i32 @clSetKernelArg(i32 %132, i32 0, i32 4, i32* %11)
store i32 %160, i32* %3
%161 = load i32, i32* @CL_SUCCESS
%162 = icmp eq i32 %160, %161
br i1 %162, label %167, label %163
163: ; preds = %159
%164 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.20, i64 0, i64 0), i32 %160)
%165 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%166 = load i32, i32* @EXIT_FAILURE
br label %185
167: ; preds = %159
%168 = getelementptr inbounds [1 x i64], [1 x i64]* %5, i64 0, i64 0
store i64 8, i64* %168
%169 = getelementptr inbounds [1 x i64], [1 x i64]* %6, i64 0, i64 0
store i64 1, i64* %169
%170 = call i32 @clEnqueueNDRangeKernel(i32 %84, i32 %132, i32 1, i32* null, i64* %168, i64* %169, i32 0, i32* null, i32* null)
store i32 %170, i32* %3
%171 = icmp eq i32 %170, 0
br i1 %171, label %176, label %172
172: ; preds = %167
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.21, i64 0, i64 0), i32 %170)
%174 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.46, i64 0, i64 0))
%175 = load i32, i32* @EXIT_FAILURE
br label %185
176: ; preds = %167
%177 = load i32, i32* %11
%178 = call i32 @clReleaseMemObject(i32 %177)
%179 = call i32 @clReleaseProgram(i32 %107)
%180 = call i32 @clReleaseKernel(i32 %132)
%181 = call i32 @clReleaseCommandQueue(i32 %84)
%182 = call i32 @clReleaseContext(i32 %76)
%183 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.31, i64 0, i64 0))
%184 = load i32, i32* @EXIT_SUCCESS
br label %185
185: ; preds = %176, %172, %163, %155, %146, %138, %121, %113
%186 = phi i32 [ %116, %113 ], [ %130, %121 ], [ %141, %138 ], [ %158, %155 ], [ %166, %163 ], [ %175, %172 ], [ %184, %176 ], [ %149, %146 ]
br label %187
187: ; preds = %185, %100
%188 = phi i32 [ %103, %100 ], [ %186, %185 ]
br label %189
189: ; preds = %39, %49, %60, %187, %86, %78, %71, %35
%190 = phi i32 [ %38, %35 ], [ %42, %39 ], [ %52, %49 ], [ %63, %60 ], [ %74, %71 ], [ %188, %187 ], [ %91, %86 ], [ %81, %78 ]
ret i32 %190
}