#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 cl_uint;
typedef int /*<<< orphan*/ cl_platform_id;
typedef int cl_int;
typedef int /*<<< orphan*/ cl_device_id;
typedef int /*<<< orphan*/ cl_context;
typedef int /*<<< orphan*/ cl_command_queue;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_MAX_COMPUTE_UNITS;
int /*<<< orphan*/ CL_DEVICE_MAX_WORK_GROUP_SIZE;
int /*<<< orphan*/ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS;
int /*<<< orphan*/ CL_DEVICE_MAX_WORK_ITEM_SIZES;
int /*<<< orphan*/ CL_DEVICE_TYPE_ALL;
int CL_PLATFORM_EXTENSIONS;
size_t CL_PLATFORM_NAME;
size_t CL_PLATFORM_PROFILE;
size_t CL_PLATFORM_VENDOR;
size_t CL_PLATFORM_VERSION;
int /*<<< orphan*/ clCreateCommandQueue(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int *);
int /*<<< orphan*/ clCreateContext(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int *);
int clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                   int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   ...);
int clGetPlatformIDs(int, int /*<<< orphan*/ *, int *);
int clGetPlatformInfo(int /*<<< orphan*/, int, int, char *,
                      int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
cl_int prepare_platform(cl_context *context, cl_command_queue *cmd_q) {
  cl_int error;
  cl_platform_id *platforms = NULL;
  cl_uint num_platforms;
  cl_uint ui, uj;
  char platform_param[5][128];
  cl_device_id *devices = NULL;
  cl_uint num_devices;
  cl_uint max_cu, max_dim;
  size_t max_wi_size[3], max_wg_size;
  if (error = clGetPlatformIDs(0, NULL, &num_platforms)) {
    printf("clGetPlatformIDs failed with %d\n", error);
    goto err;
  }
  platforms = malloc(num_platforms * sizeof(cl_platform_id));
  if (error = clGetPlatformIDs(num_platforms, platforms, NULL)) {
    printf("clGetPlatformIDs failed with %d\n", error);
    goto err;
  }
  printf("Number of platforms: %d\n", num_platforms);
  for (ui = 0; ui < num_platforms; ui++) {
    for (uj = CL_PLATFORM_PROFILE; uj <= CL_PLATFORM_EXTENSIONS; uj++) {
      error = clGetPlatformInfo(platforms[ui], uj, 128,
                                platform_param[uj - CL_PLATFORM_PROFILE], NULL);
      if (error)
        platform_param[uj - CL_PLATFORM_PROFILE][0] = '\0';
    }
    printf("\nPlatform:  %s\n"
           "profile:   %s\n"
           "version:   %s\n"
           "vendor:    %s\n"
           "extersion: %s\n\n",
           platform_param[CL_PLATFORM_NAME - CL_PLATFORM_PROFILE],
           platform_param[CL_PLATFORM_PROFILE - CL_PLATFORM_PROFILE],
           platform_param[CL_PLATFORM_VERSION - CL_PLATFORM_PROFILE],
           platform_param[CL_PLATFORM_VENDOR - CL_PLATFORM_PROFILE],
           platform_param[CL_PLATFORM_EXTENSIONS - CL_PLATFORM_PROFILE]);
    if (error = clGetDeviceIDs(platforms[ui], CL_DEVICE_TYPE_ALL, 0, NULL,
                               &num_devices)) {
      printf("clGetDeviceIDs failed with %d\n", error);
      goto err;
    }
    devices = malloc(num_devices * sizeof(cl_device_id));
    if (error = clGetDeviceIDs(platforms[ui], CL_DEVICE_TYPE_ALL, num_devices,
                               devices, NULL)) {
      printf("clGetDeviceIDs failed with %d\n", error);
      goto err;
    }
    for (uj = 0; uj < num_devices; uj++) {
      clGetDeviceInfo(devices[uj], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint),
                      &max_cu, NULL);
      clGetDeviceInfo(devices[uj], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
                      sizeof(cl_uint), &max_dim, NULL);
      clGetDeviceInfo(devices[uj], CL_DEVICE_MAX_WORK_ITEM_SIZES,
                      3 * sizeof(size_t), &max_wi_size, NULL);
      clGetDeviceInfo(devices[uj], CL_DEVICE_MAX_WORK_GROUP_SIZE,
                      sizeof(size_t), &max_wg_size, NULL);
      printf("Device %d\n"
             "max compute units:        %u\n"
             "max work item dimensions: %u\n"
             "max work iteam sizes:     [%zu, %zu, %zu]\n"
             "max work group size:      %zu\n\n",
             uj, max_cu, max_dim, max_wi_size[0], max_wi_size[1],
             max_wi_size[2], max_wg_size);
    }
  }
  if (!(*context = clCreateContext(NULL, 1, devices, NULL, NULL, &error))) {
    printf("clCreateContext failed with %d\n", error);
    goto err;
  }
  if (!(*cmd_q = clCreateCommandQueue(*context, devices[0], 0, &error))) {
    printf("clCreateCommandQueue failed with %d\n", error);
  }
err:
  if (platforms)
    free(platforms);
  if (devices)
    free(devices);
  return error;
}


x86 assembly (clang, -O0):
<prepare_platform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x2b8(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x24(%rbp),%rdx
call   1070 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11e7 <prepare_platform+0x57>
mov    -0x14(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     122c <prepare_platform+0x9c>
mov    -0x14(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
mov    -0x24(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1582 <prepare_platform+0x3f2>
mov    0x2d59(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2d29(%rip),%rcx
cmp    (%rcx),%eax
jg     12e7 <prepare_platform+0x157>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x2c(%rbp),%esi
movslq -0x2c(%rbp),%rax
mov    0x2d28(%rip),%rcx
sub    (%rcx),%rax
lea    -0x2b0(%rbp),%rcx
shl    $0x7,%rax
add    %rax,%rcx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <clGetPlatformInfo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12d4 <prepare_platform+0x144>
movslq -0x2c(%rbp),%rcx
mov    0x2cf0(%rip),%rax
sub    (%rax),%rcx
lea    -0x2b0(%rbp),%rax
shl    $0x7,%rcx
add    %rcx,%rax
movb   $0x0,(%rax)
jmp    12d9 <prepare_platform+0x149>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    125d <prepare_platform+0xcd>
mov    0x2cd2(%rip),%rax
mov    (%rax),%rax
mov    0x2cb8(%rip),%rcx
sub    (%rcx),%rax
lea    -0x2b0(%rbp),%rsi
shl    $0x7,%rax
add    %rax,%rsi
mov    0x2ca0(%rip),%rax
mov    (%rax),%rax
mov    0x2c96(%rip),%rcx
sub    (%rcx),%rax
lea    -0x2b0(%rbp),%rdx
shl    $0x7,%rax
add    %rax,%rdx
mov    0x2c76(%rip),%rax
mov    (%rax),%rax
mov    0x2c74(%rip),%rcx
sub    (%rcx),%rax
lea    -0x2b0(%rbp),%rcx
shl    $0x7,%rax
add    %rax,%rcx
mov    0x2c44(%rip),%rax
mov    (%rax),%rax
mov    0x2c52(%rip),%rdi
sub    (%rdi),%rax
lea    -0x2b0(%rbp),%r8
shl    $0x7,%rax
add    %rax,%r8
mov    0x2c1a(%rip),%rax
movslq (%rax),%rax
mov    0x2c30(%rip),%rdi
sub    (%rdi),%rax
lea    -0x2b0(%rbp),%r9
shl    $0x7,%rax
add    %rax,%r9
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2c1f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x2bc(%rbp),%r8
call   1040 <clGetDeviceIDs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     13e7 <prepare_platform+0x257>
mov    -0x14(%rbp),%esi
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
movslq -0x2bc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x2b8(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2bbe(%rip),%rax
mov    (%rax),%esi
mov    -0x2bc(%rbp),%edx
mov    -0x2b8(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetDeviceIDs@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     144d <prepare_platform+0x2bd>
mov    -0x14(%rbp),%esi
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x2bc(%rbp),%eax
jge    156f <prepare_platform+0x3df>
mov    -0x2b8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2b70(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x2c0(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1050 <clGetDeviceInfo@plt>
mov    -0x2b8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2b11(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x2c4(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1050 <clGetDeviceInfo@plt>
mov    -0x2b8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2b02(%rip),%rax
mov    (%rax),%esi
mov    $0x18,%edx
lea    -0x2e0(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1050 <clGetDeviceInfo@plt>
mov    -0x2b8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2af3(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%edx
lea    -0x2e8(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1050 <clGetDeviceInfo@plt>
mov    -0x2c(%rbp),%esi
mov    -0x2c0(%rbp),%edx
mov    -0x2c4(%rbp),%ecx
mov    -0x2e0(%rbp),%r8
mov    -0x2d8(%rbp),%r9
mov    -0x2d0(%rbp),%r10
mov    -0x2e8(%rbp),%rax
lea    0xb51(%rip),%rdi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1454 <prepare_platform+0x2c4>
jmp    1574 <prepare_platform+0x3e4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1244 <prepare_platform+0xb4>
mov    -0x2b8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x1,%esi
lea    -0x14(%rbp),%r9
mov    %r8,%rdi
mov    %r8,%rcx
call   10a0 <clCreateContext@plt>
mov    -0x8(%rbp),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
jne    15c7 <prepare_platform+0x437>
mov    -0x14(%rbp),%esi
lea    0xb75(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x2b8(%rbp),%rax
mov    (%rax),%esi
xor    %edx,%edx
lea    -0x14(%rbp),%rcx
call   1060 <clCreateCommandQueue@plt>
mov    -0x10(%rbp),%rcx
mov    %eax,(%rcx)
cmp    $0x0,%eax
jne    1601 <prepare_platform+0x471>
mov    -0x14(%rbp),%esi
lea    0xb56(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1606 <prepare_platform+0x476>
cmpq   $0x0,-0x20(%rbp)
je     161a <prepare_platform+0x48a>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x2b8(%rbp)
je     1634 <prepare_platform+0x4a4>
mov    -0x2b8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_platform>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2e8,%rsp
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x8(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1070 <clGetPlatformIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
je     11cf <prepare_platform+0x3f>
lea    0xe3c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    121f <prepare_platform+0x8f>
mov    0x8(%rsp),%ebx
lea    0x0(,%rbx,4),%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
mov    %ebx,%edi
mov    %rax,%rsi
xor    %edx,%edx
call   1070 <clGetPlatformIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
je     1235 <prepare_platform+0xa5>
lea    0xe03(%rip),%rdi
xor    %r14d,%r14d
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r13,%r13
jne    1570 <prepare_platform+0x3e0>
test   %r14,%r14
je     121f <prepare_platform+0x8f>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%eax
add    $0x2e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%esi
lea    0xde1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <printf@plt>
cmpl   $0x0,0x8(%rsp)
mov    %r15,0x20(%rsp)
mov    %rbp,0x28(%rsp)
jle    150c <prepare_platform+0x37c>
mov    0x2d4a(%rip),%r12
mov    0x2d63(%rip),%rbx
mov    0x2d64(%rip),%r15
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    %r13,0x30(%rsp)
jmp    12c5 <prepare_platform+0x135>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%rdx
add    $0x1,%rdx
movslq 0x8(%rsp),%rax
mov    %rdx,%rcx
mov    %rdx,0x10(%rsp)
cmp    %rax,%rdx
mov    0x30(%rsp),%r13
mov    0x2d1b(%rip),%rbx
mov    0x2cf4(%rip),%r12
mov    %rbp,%r15
jge    150c <prepare_platform+0x37c>
mov    (%r12),%rax
mov    0x2cc0(%rip),%rcx
mov    (%rcx),%ecx
cmp    %eax,%ecx
jl     135b <prepare_platform+0x1cb>
movslq %eax,%rbp
mov    %rbp,%rcx
shl    $0x7,%rcx
lea    (%rsp,%rcx,1),%rbx
add    $0x60,%rbx
nopl   0x0(%rax)
mov    0x10(%rsp),%rcx
mov    0x0(%r13,%rcx,4),%edi
shl    $0x7,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
mov    %ebp,%esi
mov    $0x80,%edx
xor    %r8d,%r8d
call   1090 <clGetPlatformInfo@plt>
test   %eax,%eax
je     1328 <prepare_platform+0x198>
mov    (%r12),%rax
shl    $0x7,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
movb   $0x0,(%rcx)
mov    0x2c61(%rip),%rax
movslq (%rax),%rcx
cmp    %rcx,%rbp
jge    1350 <prepare_platform+0x1c0>
add    $0x1,%rbp
mov    (%r12),%rax
sub    $0xffffffffffffff80,%rbx
jmp    12f0 <prepare_platform+0x160>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12),%rax
mov    0x2c75(%rip),%rbx
mov    0x10(%rsp),%r12
movslq %ecx,%rdx
mov    0x2c56(%rip),%rcx
mov    (%rcx),%rcx
sub    %rax,%rcx
shl    $0x7,%rcx
lea    (%rsp,%rcx,1),%rsi
add    $0x60,%rsi
mov    0x2c25(%rip),%rcx
mov    (%rcx),%rcx
sub    %rax,%rcx
shl    $0x7,%rcx
add    %rsp,%rcx
add    $0x60,%rcx
mov    0x2bfd(%rip),%rdi
mov    (%rdi),%rdi
sub    %rax,%rdi
shl    $0x7,%rdi
lea    (%rsp,%rdi,1),%r8
add    $0x60,%r8
sub    %rax,%rdx
shl    $0x7,%rdx
lea    (%rsp,%rdx,1),%r9
add    $0x60,%r9
lea    0xc77(%rip),%rdi
lea    0x60(%rsp),%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x0(%r13,%r12,4),%edi
mov    (%rbx),%esi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0xc(%rsp),%r8
call   1040 <clGetDeviceIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    1560 <prepare_platform+0x3d0>
mov    0xc(%rsp),%ebp
lea    0x0(,%rbp,4),%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    0x0(%r13,%r12,4),%edi
mov    (%rbx),%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1040 <clGetDeviceIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    1560 <prepare_platform+0x3d0>
cmpl   $0x0,0xc(%rsp)
mov    0x2bb9(%rip),%r12
lea    0x1c(%rsp),%rcx
mov    %r15,%rbp
lea    0xc64(%rip),%rbx
jle    1290 <prepare_platform+0x100>
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    (%r14,%r13,4),%edi
mov    (%r12),%esi
mov    $0x4,%edx
mov    %rcx,%r15
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <clGetDeviceInfo@plt>
mov    (%r14,%r13,4),%edi
mov    0x2b43(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    0x18(%rsp),%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <clGetDeviceInfo@plt>
mov    (%r14,%r13,4),%edi
mov    0x0(%rbp),%esi
mov    $0x18,%edx
lea    0x40(%rsp),%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <clGetDeviceInfo@plt>
mov    (%r14,%r13,4),%edi
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%edx
lea    0x38(%rsp),%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <clGetDeviceInfo@plt>
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x40(%rsp),%r8
mov    0x48(%rsp),%r9
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %eax,%eax
push   0x38(%rsp)
push   0x58(%rsp)
call   1080 <printf@plt>
mov    %r15,%rcx
add    $0x10,%rsp
add    $0x1,%r13
movslq 0xc(%rsp),%rax
cmp    %rax,%r13
jl     1450 <prepare_platform+0x2c0>
jmp    1290 <prepare_platform+0x100>
lea    0x4(%rsp),%r9
xor    %edi,%edi
mov    $0x1,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <clCreateContext@plt>
mov    0x28(%rsp),%rcx
mov    %eax,(%rcx)
test   %eax,%eax
je     1586 <prepare_platform+0x3f6>
mov    (%r14),%esi
lea    0x4(%rsp),%rcx
mov    %eax,%edi
xor    %edx,%edx
call   1060 <clCreateCommandQueue@plt>
mov    0x20(%rsp),%rcx
mov    %eax,(%rcx)
test   %eax,%eax
jne    1209 <prepare_platform+0x79>
mov    0x4(%rsp),%esi
lea    0xbf5(%rip),%rdi
jmp    1202 <prepare_platform+0x72>
lea    0xb1c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
test   %r14,%r14
jne    1217 <prepare_platform+0x87>
jmp    121f <prepare_platform+0x8f>
mov    0x4(%rsp),%esi
lea    0xb9f(%rip),%rdi
jmp    1202 <prepare_platform+0x72>

LLVM IR (-O0):
@.str = [33 x i8] c"clGetPlatformIDs failed with %d\0A\00"
@.str.1 = [25 x i8] c"Number of platforms: %d\0A\00"
@CL_PLATFORM_PROFILE = global i64 0
@CL_PLATFORM_EXTENSIONS = global i32 0
@.str.2 = [73 x i8] c"\0APlatform: %s\0Aprofile: %s\0Aversion: %s\0Avendor: %s\0Aextersion: %s\0A\0A\00"
@CL_PLATFORM_NAME = global i64 0
@CL_PLATFORM_VERSION = global i64 0
@CL_PLATFORM_VENDOR = global i64 0
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.3 = [31 x i8] c"clGetDeviceIDs failed with %d\0A\00"
@CL_DEVICE_MAX_COMPUTE_UNITS = global i32 0
@CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = global i32 0
@CL_DEVICE_MAX_WORK_ITEM_SIZES = global i32 0
@CL_DEVICE_MAX_WORK_GROUP_SIZE = global i32 0
@.str.4 = [142 x i8] c"Device %d\0Amax compute units: %u\0Amax work item dimensions: %u\0Amax work iteam sizes: [%zu, %zu, %zu]\0Amax work group size: %zu\0A\0A\00"
@.str.5 = [32 x i8] c"clCreateContext failed with %d\0A\00"
@.str.6 = [37 x i8] c"clCreateCommandQueue failed with %d\0A\00"
define i32 @prepare_platform(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [5 x [128 x i8]]
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [3 x i64]
%16 = alloca i64
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32* null, i32** %6
store i32* null, i32** %11
%17 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %7)
store i32 %17, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %207
22: ; preds = %2
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 4
%26 = trunc i64 %25 to i32
%27 = call i32* @malloc(i32 %26)
store i32* %27, i32** %6
%28 = load i32, i32* %7
%29 = load i32*, i32** %6
%30 = call i32 @clGetPlatformIDs(i32 %28, i32* %29, i32* null)
store i32 %30, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %22
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %207
35: ; preds = %22
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %36)
store i32 0, i32* %8
br label %38
38: ; preds = %183, %35
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %186
42: ; preds = %38
%43 = load i64, i64* @CL_PLATFORM_PROFILE
%44 = trunc i64 %43 to i32
store i32 %44, i32* %9
br label %45
45: ; preds = %73, %42
%46 = load i32, i32* %9
%47 = load i32, i32* @CL_PLATFORM_EXTENSIONS
%48 = icmp sle i32 %46, %47
br i1 %48, label %49, label %76
49: ; preds = %45
%50 = load i32*, i32** %6
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
%54 = load i32, i32* %53
%55 = load i32, i32* %9
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = load i64, i64* @CL_PLATFORM_PROFILE
%59 = sub i64 %57, %58
%60 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %59
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %60, i64 0, i64 0
%62 = call i32 @clGetPlatformInfo(i32 %54, i32 %55, i32 128, i8* %61, i32* null)
store i32 %62, i32* %5
%63 = load i32, i32* %5
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %49
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = load i64, i64* @CL_PLATFORM_PROFILE
%69 = sub i64 %67, %68
%70 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %69
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %70, i64 0, i64 0
store i8 0, i8* %71
br label %72
72: ; preds = %65, %49
br label %73
73: ; preds = %72
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %45
76: ; preds = %45
%77 = load i64, i64* @CL_PLATFORM_NAME
%78 = load i64, i64* @CL_PLATFORM_PROFILE
%79 = sub i64 %77, %78
%80 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %79
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %80, i64 0, i64 0
%82 = load i64, i64* @CL_PLATFORM_PROFILE
%83 = load i64, i64* @CL_PLATFORM_PROFILE
%84 = sub i64 %82, %83
%85 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %84
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %85, i64 0, i64 0
%87 = load i64, i64* @CL_PLATFORM_VERSION
%88 = load i64, i64* @CL_PLATFORM_PROFILE
%89 = sub i64 %87, %88
%90 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %89
%91 = getelementptr inbounds [128 x i8], [128 x i8]* %90, i64 0, i64 0
%92 = load i64, i64* @CL_PLATFORM_VENDOR
%93 = load i64, i64* @CL_PLATFORM_PROFILE
%94 = sub i64 %92, %93
%95 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %94
%96 = getelementptr inbounds [128 x i8], [128 x i8]* %95, i64 0, i64 0
%97 = load i32, i32* @CL_PLATFORM_EXTENSIONS
%98 = sext i32 %97 to i64
%99 = load i64, i64* @CL_PLATFORM_PROFILE
%100 = sub i64 %98, %99
%101 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %10, i64 0, i64 %100
%102 = getelementptr inbounds [128 x i8], [128 x i8]* %101, i64 0, i64 0
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* %81, i8* %86, i8* %91, i8* %96, i8* %102)
%104 = load i32*, i32** %6
%105 = load i32, i32* %8
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i32, i32* %104, i64 %106
%108 = load i32, i32* %107
%109 = load i32, i32* @CL_DEVICE_TYPE_ALL
%110 = call i32 @clGetDeviceIDs(i32 %108, i32 %109, i32 0, i32* null, i32* %12)
store i32 %110, i32* %5
%111 = icmp ne i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %76
%113 = load i32, i32* %5
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %113)
br label %207
115: ; preds = %76
%116 = load i32, i32* %12
%117 = sext i32 %116 to i64
%118 = mul i64 %117, 4
%119 = trunc i64 %118 to i32
%120 = call i32* @malloc(i32 %119)
store i32* %120, i32** %11
%121 = load i32*, i32** %6
%122 = load i32, i32* %8
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %121, i64 %123
%125 = load i32, i32* %124
%126 = load i32, i32* @CL_DEVICE_TYPE_ALL
%127 = load i32, i32* %12
%128 = load i32*, i32** %11
%129 = call i32 @clGetDeviceIDs(i32 %125, i32 %126, i32 %127, i32* %128, i32* null)
store i32 %129, i32* %5
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %115
%132 = load i32, i32* %5
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %132)
br label %207
134: ; preds = %115
store i32 0, i32* %9
br label %135
135: ; preds = %179, %134
%136 = load i32, i32* %9
%137 = load i32, i32* %12
%138 = icmp slt i32 %136, %137
br i1 %138, label %139, label %182
139: ; preds = %135
%140 = load i32*, i32** %11
%141 = load i32, i32* %9
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i32, i32* %140, i64 %142
%144 = load i32, i32* %143
%145 = load i32, i32* @CL_DEVICE_MAX_COMPUTE_UNITS
%146 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %144, i32 %145, i32 4, i32* %13, i8* null)
%147 = load i32*, i32** %11
%148 = load i32, i32* %9
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i32, i32* %147, i64 %149
%151 = load i32, i32* %150
%152 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
%153 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %151, i32 %152, i32 4, i32* %14, i8* null)
%154 = load i32*, i32** %11
%155 = load i32, i32* %9
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i32, i32* %154, i64 %156
%158 = load i32, i32* %157
%159 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_SIZES
%160 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %158, i32 %159, i32 24, [3 x i64]* %15, i8* null)
%161 = load i32*, i32** %11
%162 = load i32, i32* %9
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i32, i32* %161, i64 %163
%165 = load i32, i32* %164
%166 = load i32, i32* @CL_DEVICE_MAX_WORK_GROUP_SIZE
%167 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %165, i32 %166, i32 8, i64* %16, i8* null)
%168 = load i32, i32* %9
%169 = load i32, i32* %13
%170 = load i32, i32* %14
%171 = getelementptr inbounds [3 x i64], [3 x i64]* %15, i64 0, i64 0
%172 = load i64, i64* %171
%173 = getelementptr inbounds [3 x i64], [3 x i64]* %15, i64 0, i64 1
%174 = load i64, i64* %173
%175 = getelementptr inbounds [3 x i64], [3 x i64]* %15, i64 0, i64 2
%176 = load i64, i64* %175
%177 = load i64, i64* %16
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.4, i64 0, i64 0), i32 %168, i32 %169, i32 %170, i64 %172, i64 %174, i64 %176, i64 %177)
br label %179
179: ; preds = %139
%180 = load i32, i32* %9
%181 = add nsw i32 %180, 1
store i32 %181, i32* %9
br label %135
182: ; preds = %135
br label %183
183: ; preds = %182
%184 = load i32, i32* %8
%185 = add nsw i32 %184, 1
store i32 %185, i32* %8
br label %38
186: ; preds = %38
%187 = load i32*, i32** %11
%188 = call i32 @clCreateContext(i32* null, i32 1, i32* %187, i32* null, i32* null, i32* %5)
%189 = load i32*, i32** %3
store i32 %188, i32* %189
%190 = icmp ne i32 %188, 0
br i1 %190, label %194, label %191
191: ; preds = %186
%192 = load i32, i32* %5
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %192)
br label %207
194: ; preds = %186
%195 = load i32*, i32** %3
%196 = load i32, i32* %195
%197 = load i32*, i32** %11
%198 = getelementptr inbounds i32, i32* %197, i64 0
%199 = load i32, i32* %198
%200 = call i32 @clCreateCommandQueue(i32 %196, i32 %199, i32 0, i32* %5)
%201 = load i32*, i32** %4
store i32 %200, i32* %201
%202 = icmp ne i32 %200, 0
br i1 %202, label %206, label %203
203: ; preds = %194
%204 = load i32, i32* %5
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %204)
br label %206
206: ; preds = %203, %194
br label %207
207: ; preds = %206, %191, %131, %112, %32, %19
%208 = load i32*, i32** %6
%209 = icmp ne i32* %208, null
br i1 %209, label %210, label %213
210: ; preds = %207
%211 = load i32*, i32** %6
%212 = call i32 @free(i32* %211)
br label %213
213: ; preds = %210, %207
%214 = load i32*, i32** %11
%215 = icmp ne i32* %214, null
br i1 %215, label %216, label %219
216: ; preds = %213
%217 = load i32*, i32** %11
%218 = call i32 @free(i32* %217)
br label %219
219: ; preds = %216, %213
%220 = load i32, i32* %5
ret i32 %220
}

LLVM IR (-O2):
@.str = [33 x i8] c"clGetPlatformIDs failed with %d\0A\00"
@.str.1 = [25 x i8] c"Number of platforms: %d\0A\00"
@CL_PLATFORM_PROFILE = global i64 0
@CL_PLATFORM_EXTENSIONS = global i32 0
@.str.2 = [73 x i8] c"\0APlatform: %s\0Aprofile: %s\0Aversion: %s\0Avendor: %s\0Aextersion: %s\0A\0A\00"
@CL_PLATFORM_NAME = global i64 0
@CL_PLATFORM_VERSION = global i64 0
@CL_PLATFORM_VENDOR = global i64 0
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.3 = [31 x i8] c"clGetDeviceIDs failed with %d\0A\00"
@CL_DEVICE_MAX_COMPUTE_UNITS = global i32 0
@CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = global i32 0
@CL_DEVICE_MAX_WORK_ITEM_SIZES = global i32 0
@CL_DEVICE_MAX_WORK_GROUP_SIZE = global i32 0
@.str.4 = [142 x i8] c"Device %d\0Amax compute units: %u\0Amax work item dimensions: %u\0Amax work iteam sizes: [%zu, %zu, %zu]\0Amax work group size: %zu\0A\0A\00"
@.str.5 = [32 x i8] c"clCreateContext failed with %d\0A\00"
@.str.6 = [37 x i8] c"clCreateCommandQueue failed with %d\0A\00"
define i32 @prepare_platform(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x [128 x i8]]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x i64]
%10 = alloca i64
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 0, i64 0
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast [3 x i64]* %9 to i8*
%18 = bitcast i64* %10 to i8*
%19 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %4)
store i32 %19, i32* %3
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %166
23: ; preds = %2
%24 = load i32, i32* %4
%25 = shl i32 %24, 2
%26 = call i32* @malloc(i32 %25)
%27 = call i32 @clGetPlatformIDs(i32 %24, i32* %26, i32* null)
store i32 %27, i32* %3
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %151
31: ; preds = %23
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %137
36: ; preds = %31
%37 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 0
%38 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 1
%39 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 2
br label %40
40: ; preds = %36, %132
%41 = phi i64 [ 0, %36 ], [ %133, %132 ]
%42 = phi i32* [ null, %36 ], [ %97, %132 ]
%43 = load i64, i64* @CL_PLATFORM_PROFILE
%44 = trunc i64 %43 to i32
%45 = load i32, i32* @CL_PLATFORM_EXTENSIONS
%46 = icmp slt i32 %45, %44
br i1 %46, label %73, label %47
47: ; preds = %40
%48 = getelementptr inbounds i32, i32* %26, i64 %41
%49 = shl i64 %43, 32
%50 = ashr exact i64 %49, 32
br label %51
51: ; preds = %68, %47
%52 = phi i64 [ %43, %47 ], [ %70, %68 ]
%53 = phi i64 [ %50, %47 ], [ %69, %68 ]
%54 = load i32, i32* %48
%55 = sub i64 %53, %52
%56 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %55, i64 0
%57 = trunc i64 %53 to i32
%58 = call i32 @clGetPlatformInfo(i32 %54, i32 %57, i32 128, i8* %56, i32* null)
%59 = icmp eq i32 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %51
%61 = load i64, i64* @CL_PLATFORM_PROFILE
%62 = sub i64 %53, %61
%63 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %62, i64 0
store i8 0, i8* %63
br label %64
64: ; preds = %51, %60
%65 = load i32, i32* @CL_PLATFORM_EXTENSIONS
%66 = sext i32 %65 to i64
%67 = icmp slt i64 %53, %66
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = add nsw i64 %53, 1
%70 = load i64, i64* @CL_PLATFORM_PROFILE
br label %51
71: ; preds = %64
%72 = load i64, i64* @CL_PLATFORM_PROFILE
br label %73
73: ; preds = %40, %71
%74 = phi i32 [ %65, %71 ], [ %45, %40 ]
%75 = phi i64 [ %72, %71 ], [ %43, %40 ]
%76 = sext i32 %74 to i64
%77 = load i64, i64* @CL_PLATFORM_NAME
%78 = sub i64 %77, %75
%79 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %78, i64 0
%80 = load i64, i64* @CL_PLATFORM_VERSION
%81 = sub i64 %80, %75
%82 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %81, i64 0
%83 = load i64, i64* @CL_PLATFORM_VENDOR
%84 = sub i64 %83, %75
%85 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %84, i64 0
%86 = sub i64 %76, %75
%87 = getelementptr inbounds [5 x [128 x i8]], [5 x [128 x i8]]* %5, i64 0, i64 %86, i64 0
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* %79, i8* %13, i8* %82, i8* %85, i8* %87)
%89 = getelementptr inbounds i32, i32* %26, i64 %41
%90 = load i32, i32* %89
%91 = load i32, i32* @CL_DEVICE_TYPE_ALL
%92 = call i32 @clGetDeviceIDs(i32 %90, i32 %91, i32 0, i32* null, i32* %6)
store i32 %92, i32* %3
%93 = icmp eq i32 %92, 0
br i1 %93, label %94, label %154
94: ; preds = %73
%95 = load i32, i32* %6
%96 = shl i32 %95, 2
%97 = call i32* @malloc(i32 %96)
%98 = load i32, i32* %89
%99 = load i32, i32* @CL_DEVICE_TYPE_ALL
%100 = call i32 @clGetDeviceIDs(i32 %98, i32 %99, i32 %95, i32* %97, i32* null)
store i32 %100, i32* %3
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %154
102: ; preds = %94
%103 = load i32, i32* %6
%104 = icmp sgt i32 %103, 0
br i1 %104, label %105, label %132
105: ; preds = %102, %105
%106 = phi i64 [ %128, %105 ], [ 0, %102 ]
%107 = getelementptr inbounds i32, i32* %97, i64 %106
%108 = load i32, i32* %107
%109 = load i32, i32* @CL_DEVICE_MAX_COMPUTE_UNITS
%110 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %108, i32 %109, i32 4, i32* %7, i8* null)
%111 = load i32, i32* %107
%112 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
%113 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %111, i32 %112, i32 4, i32* %8, i8* null)
%114 = load i32, i32* %107
%115 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_SIZES
%116 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %114, i32 %115, i32 24, [3 x i64]* %9, i8* null)
%117 = load i32, i32* %107
%118 = load i32, i32* @CL_DEVICE_MAX_WORK_GROUP_SIZE
%119 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %117, i32 %118, i32 8, i64* %10, i8* null)
%120 = load i32, i32* %7
%121 = load i32, i32* %8
%122 = load i64, i64* %37
%123 = load i64, i64* %38
%124 = load i64, i64* %39
%125 = load i64, i64* %10
%126 = trunc i64 %106 to i32
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([142 x i8], [142 x i8]* @.str.4, i64 0, i64 0), i32 %126, i32 %120, i32 %121, i64 %122, i64 %123, i64 %124, i64 %125)
%128 = add nuw nsw i64 %106, 1
%129 = load i32, i32* %6
%130 = sext i32 %129 to i64
%131 = icmp slt i64 %128, %130
br i1 %131, label %105, label %132
132: ; preds = %105, %102
%133 = add nuw nsw i64 %41, 1
%134 = load i32, i32* %4
%135 = sext i32 %134 to i64
%136 = icmp slt i64 %133, %135
br i1 %136, label %40, label %137
137: ; preds = %132, %31
%138 = phi i32* [ null, %31 ], [ %97, %132 ]
%139 = call i32 @clCreateContext(i32* null, i32 1, i32* %138, i32* null, i32* null, i32* %3)
store i32 %139, i32* %0
%140 = icmp eq i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %137
%142 = load i32, i32* %3
%143 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %142)
br label %151
144: ; preds = %137
%145 = load i32, i32* %138
%146 = call i32 @clCreateCommandQueue(i32 %139, i32 %145, i32 0, i32* %3)
store i32 %146, i32* %1
%147 = icmp eq i32 %146, 0
br i1 %147, label %148, label %151
148: ; preds = %144
%149 = load i32, i32* %3
%150 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %149)
br label %151
151: ; preds = %144, %148, %141, %29
%152 = phi i32* [ null, %29 ], [ %138, %144 ], [ %138, %148 ], [ %138, %141 ]
%153 = icmp eq i32* %26, null
br i1 %153, label %161, label %158
154: ; preds = %94, %73
%155 = phi i32 [ %92, %73 ], [ %100, %94 ]
%156 = phi i32* [ %42, %73 ], [ %97, %94 ]
%157 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %155)
br label %158
158: ; preds = %154, %151
%159 = phi i32* [ %152, %151 ], [ %156, %154 ]
%160 = call i32 @free(i32* %26)
br label %161
161: ; preds = %158, %151
%162 = phi i32* [ %159, %158 ], [ %152, %151 ]
%163 = icmp eq i32* %162, null
br i1 %163, label %166, label %164
164: ; preds = %161
%165 = call i32 @free(i32* %162)
br label %166
166: ; preds = %21, %164, %161
%167 = load i32, i32* %3
ret i32 %167
}