#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_program;
typedef char cl_platform_id;
typedef int cl_int;
typedef char cl_device_id;
typedef scalar_t__ cl_context_properties;
typedef int /*<<< orphan*/ cl_context;

/* Variables and functions */
scalar_t__ CL_CONTEXT_PLATFORM;
int /*<<< orphan*/ CL_DEVICE_TYPE_ALL;
int /*<<< orphan*/ CL_PROGRAM_BINARY_SIZES;
int /*<<< orphan*/ CL_PROGRAM_BUILD_LOG;
int CL_SUCCESS;
int clBuildProgram(int /*<<< orphan*/, int, char *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clCreateContext(scalar_t__ *, int, char *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int *);
int /*<<< orphan*/ clCreateProgramWithSource(int /*<<< orphan*/, int,
                                             char const **, size_t *, int *);
int clGetDeviceIDs(char, int /*<<< orphan*/, int, char *, int *);
int clGetPlatformIDs(int, char *, int *);
int clGetProgramBuildInfo(int /*<<< orphan*/, char, int /*<<< orphan*/, size_t,
                          char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetProgramInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                    size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clReleaseContext(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseProgram(int /*<<< orphan*/);
int /*<<< orphan*/ device_list();
int /*<<< orphan*/ free(char *);
char *loadTextFile(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char const *);
int build(int dev, char *filename) {
  int i, j = 0, n = -1;
  cl_uint num_platforms = 0, old_num_platforms;
  cl_uint num_devices = 0, old_num_devices;
  cl_int ret;
  cl_platform_id *cl_pid = NULL;
  cl_device_id *cl_cid = NULL;
  cl_context context;
  cl_program program;
  const char *source;
  char *build_log;
  size_t src_len, binary_size;
  cl_context_properties props[] = {CL_CONTEXT_PLATFORM, 0, 0};
  ret = clGetPlatformIDs(0, 0, &num_platforms);
  if (ret) {
    printf("clGetPlatformIDs() Failed\n");
    return 1;
  }
  old_num_platforms = num_platforms;
  if (!num_platforms) {
    printf("So we can't come out to play.\n");
    return 1;
  }
  cl_pid = malloc(sizeof(cl_platform_id) * num_platforms);
  if (!cl_pid) {
    printf("malloc() failed\n");
    return 1;
  }
  memset(cl_pid, 0, sizeof(cl_platform_id) * num_platforms);
  ret = clGetPlatformIDs(num_platforms, cl_pid, &num_platforms);
  if (ret) {
    printf("clGetPlatformIDs() Failed the second time - %d\n", ret);
    goto build_pid;
  }
  if (num_platforms != old_num_platforms) {
    printf("There are %d platforms. That's bad.\n", num_platforms);
    goto build_pid;
  }
  for (i = 0; i < num_platforms; i++) {
    ret = clGetDeviceIDs(cl_pid[i], CL_DEVICE_TYPE_ALL, 0, 0, &num_devices);
    if (ret) {
      printf("\tclGetDeviceIDs() failed\n");
      goto build_pid;
    }
    if (!num_devices) {
      printf("\tThis platform has no devices.\n");
      continue;
    }
    cl_cid = malloc(sizeof(cl_device_id) * num_devices);
    if (!cl_cid) {
      printf("\tmalloc(cl_cid) failed\n");
      goto build_pid;
    }
    old_num_devices = num_devices;
    ret = clGetDeviceIDs(cl_pid[i], CL_DEVICE_TYPE_ALL, num_devices, cl_cid,
                         &num_devices);
    if (ret) {
      printf("\tclGetDeviceIDs() failed the second time\n");
      goto build_cid;
    }
    for (j = 0; j < num_devices; j++) {
      n++;
      if (dev == n)
        break;
    }
    if (dev == n)
      break;
    free(cl_cid);
  }
  if (dev > n) {
    printf("I could not find device number %d.\n", dev);
    device_list();
    goto build_pid;
  }
  props[1] = (cl_context_properties)cl_pid[i];
  context = clCreateContext(props, 1, &cl_cid[j], NULL, NULL, &ret);
  if (!context) {
    printf("clCreateContext() failed\n");
    goto build_cid;
  }
  source = loadTextFile(filename);
  if (!source) {
    printf("fopen(\"%s\") failed\n", filename);
    goto build_cid;
  }
  src_len = strlen(source);
  program = clCreateProgramWithSource(context, 1, &source, &src_len, &ret);
  if (ret != CL_SUCCESS) {
    printf("clCreateProgramWithSource() failed\n");
    goto build_context;
  }
  ret = clBuildProgram(program, 1, &cl_cid[j], NULL, NULL, NULL);
  if (ret != CL_SUCCESS) {
    build_log = malloc(1000000);
    if (!build_log) {
      printf("Failed to malloc() build log.\n");
      goto build_program;
    }
    memset(build_log, 0, 1000000);
    binary_size = 1000000;
    ret = clGetProgramBuildInfo(program, cl_cid[j], CL_PROGRAM_BUILD_LOG,
                                binary_size, build_log, NULL);
    printf("Building \"%s\" failed:\n%s", filename, build_log);
    free(build_log);
  } else {
    clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t),
                     &binary_size, NULL);
    printf("Success: %zu bytes.\n", binary_size);
  }
build_program:
  clReleaseProgram(program);
build_context:
  clReleaseContext(context);
  free((char *)source);
build_cid:
  free(cl_cid);
build_pid:
  free(cl_pid);
  return 0;
}


x86 assembly (clang, -O0):
<build>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x70(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
call   10a0 <clGetPlatformIDs@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1292 <build+0x92>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16eb <build+0x4eb>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    12bc <build+0xbc>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16eb <build+0x4eb>
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12f4 <build+0xf4>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16eb <build+0x4eb>
mov    -0x38(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   10c0 <memset@plt>
mov    -0x20(%rbp),%edi
mov    -0x38(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   10a0 <clGetPlatformIDs@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     133c <build+0x13c>
mov    -0x30(%rbp),%esi
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16db <build+0x4db>
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     135e <build+0x15e>
mov    -0x20(%rbp),%esi
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16db <build+0x4db>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    14b8 <build+0x2b8>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x2c55(%rip),%rcx
mov    (%rcx),%esi
xor    %edx,%edx
xor    %ecx,%ecx
lea    -0x28(%rbp),%r8
movsbl %al,%edi
call   1070 <clGetDeviceIDs@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     13b5 <build+0x1b5>
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16db <build+0x4db>
cmpl   $0x0,-0x28(%rbp)
jne    13d2 <build+0x1d2>
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    14aa <build+0x2aa>
movslq -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1100 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1403 <build+0x203>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16db <build+0x4db>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x2bbd(%rip),%rcx
mov    (%rcx),%esi
mov    -0x28(%rbp),%edx
mov    -0x40(%rbp),%rcx
lea    -0x28(%rbp),%r8
movsbl %al,%edi
call   1070 <clGetDeviceIDs@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1450 <build+0x250>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16d2 <build+0x4d2>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1490 <build+0x290>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    147d <build+0x27d>
jmp    1490 <build+0x290>
jmp    1482 <build+0x282>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1457 <build+0x257>
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    14a1 <build+0x2a1>
jmp    14b8 <build+0x2b8>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1365 <build+0x165>
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    14e1 <build+0x2e1>
mov    -0x8(%rbp),%esi
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    $0x0,%al
call   1120 <device_list@plt>
jmp    16db <build+0x4db>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbq (%rax,%rcx,1),%rax
mov    %rax,-0x78(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x40(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x30(%rbp),%r9
mov    %r8,%rcx
call   10e0 <clCreateContext@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    1537 <build+0x337>
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16d2 <build+0x4d2>
mov    -0x10(%rbp),%rdi
call   10d0 <loadTextFile@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1566 <build+0x366>
mov    -0x10(%rbp),%rsi
lea    0xc00(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16d2 <build+0x4d2>
mov    -0x50(%rbp),%rdi
call   1080 <strlen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x44(%rbp),%edi
mov    $0x1,%esi
lea    -0x50(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1050 <clCreateProgramWithSource@plt>
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%eax
mov    0x2a27(%rip),%rcx
cmp    (%rcx),%eax
je     15b4 <build+0x3b4>
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16c1 <build+0x4c1>
mov    -0x48(%rbp),%edi
mov    -0x40(%rbp),%rdx
movslq -0x18(%rbp),%rax
add    %rax,%rdx
mov    $0x1,%esi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    0x29dc(%rip),%rcx
cmp    (%rcx),%eax
je     1683 <build+0x483>
mov    $0xf4240,%edi
call   1100 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1618 <build+0x418>
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16b9 <build+0x4b9>
mov    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4240,%edx
call   10c0 <memset@plt>
movq   $0xf4240,-0x68(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x40(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x299b(%rip),%rcx
mov    (%rcx),%edx
mov    -0x68(%rbp),%rcx
mov    -0x58(%rbp),%r8
xor    %esi,%esi
mov    %esi,%r9d
movsbl %al,%esi
call   10f0 <clGetProgramBuildInfo@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x58(%rbp),%rdx
lea    0xb43(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
jmp    16b4 <build+0x4b4>
mov    -0x48(%rbp),%edi
mov    0x295b(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%edx
lea    -0x68(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <clGetProgramInfo@plt>
mov    -0x68(%rbp),%rsi
lea    0xb1d(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    16b9 <build+0x4b9>
mov    -0x48(%rbp),%edi
call   1060 <clReleaseProgram@plt>
mov    -0x44(%rbp),%edi
call   1110 <clReleaseContext@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x40(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x48(%rsp)
lea    0x8(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10b0 <clGetPlatformIDs@plt>
test   %eax,%eax
je     127c <build+0x6c>
lea    0xf58(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%ebx
test   %ebx,%ebx
je     12c3 <build+0xb3>
mov    %ebx,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     12cc <build+0xbc>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   10d0 <memset@plt>
mov    0x8(%rsp),%edi
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   10b0 <clGetPlatformIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
je     12d5 <build+0xc5>
lea    0xd41(%rip),%rdi
mov    %eax,%esi
jmp    1311 <build+0x101>
lea    0xdf1(%rip),%rdi
jmp    1263 <build+0x53>
lea    0xe06(%rip),%rdi
jmp    1263 <build+0x53>
mov    0x8(%rsp),%esi
cmp    %ebx,%esi
jne    130a <build+0xfa>
test   %ebx,%ebx
jle    144c <build+0x23c>
mov    $0x1,%eax
sub    %ebp,%eax
mov    %rax,0x30(%rsp)
mov    $0xffffffff,%eax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %eax,%eax
mov    %rax,0x18(%rsp)
jmp    1345 <build+0x135>
lea    0xd1f(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r14,%rdi
call   1040 <free@plt>
xor    %eax,%eax
jmp    126d <build+0x5d>
lea    0xe15(%rip),%rdi
call   1060 <puts@plt>
add    $0x1,%r12
movslq 0x8(%rsp),%rax
cmp    %rax,%r12
jge    1463 <build+0x253>
movsbl (%r14,%r12,1),%edi
mov    0x2c87(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0xc(%rsp),%r8
call   1080 <clGetDeviceIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    15b5 <build+0x3a5>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1327 <build+0x117>
mov    %ebx,%edi
call   1110 <malloc@plt>
test   %rax,%rax
je     1642 <build+0x432>
mov    %rax,%r15
movsbl (%r14,%r12,1),%edi
mov    0x2c44(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edx
mov    %r15,%rcx
lea    0xc(%rsp),%r8
call   1080 <clGetDeviceIDs@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    1653 <build+0x443>
mov    %r15,0x18(%rsp)
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    13e2 <build+0x1d2>
mov    0x10(%rsp),%rdi
mov    %edi,%eax
not    %eax
add    %ebp,%eax
lea    -0x1(%r15),%ecx
cmp    %ecx,%eax
cmovae %ecx,%eax
add    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x20,%eax
ja     13ec <build+0x1dc>
xor    %eax,%eax
jmp    1405 <build+0x1f5>
xor    %r15d,%r15d
mov    0x10(%rsp),%rdi
jmp    142d <build+0x21d>
mov    %eax,%edx
and    $0x1f,%edx
mov    $0x20,%esi
cmove  %esi,%edx
sub    %edx,%eax
add    %eax,%edi
mov    %eax,%edx
nop
add    $0xffffffe0,%edx
jne    1400 <build+0x1f0>
mov    %eax,%edx
sub    %r15d,%edx
mov    0x30(%rsp),%rsi
add    %edi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %ecx,%esi
je     1445 <build+0x235>
add    $0xffffffff,%ecx
cmp    %ecx,%edx
jne    1420 <build+0x210>
sub    %ecx,%edi
cmp    %ebp,%edi
je     1485 <build+0x275>
mov    %rdi,0x10(%rsp)
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
jmp    1333 <build+0x123>
sub    %ecx,%eax
mov    %eax,%r15d
jmp    1485 <build+0x275>
xor    %r12d,%r12d
mov    $0xffffffff,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
cmp    %ebp,0x10(%rsp)
jge    1485 <build+0x275>
lea    0xbe5(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
xor    %eax,%eax
call   1130 <device_list@plt>
jmp    1318 <build+0x108>
mov    %r12d,%eax
movsbq (%r14,%rax,1),%rax
mov    %rax,0x48(%rsp)
movslq %r15d,%rbp
mov    0x18(%rsp),%r15
add    %r15,%rbp
lea    0x40(%rsp),%rdi
lea    0x4(%rsp),%r9
mov    $0x1,%esi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10f0 <clCreateContext@plt>
test   %eax,%eax
je     1578 <build+0x368>
mov    %eax,%ebx
mov    %r13,%rdi
call   10e0 <loadTextFile@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     1589 <build+0x379>
mov    %rax,%rdi
call   1090 <strlen@plt>
mov    %rax,0x38(%rsp)
lea    0x28(%rsp),%rdx
lea    0x38(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <clCreateProgramWithSource@plt>
mov    %eax,%r12d
mov    0x4(%rsp),%eax
mov    0x2ab1(%rip),%r15
cmp    (%r15),%eax
jne    159f <build+0x38f>
mov    %r12d,%edi
mov    $0x1,%esi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,0x4(%rsp)
cmp    (%r15),%eax
jne    15c6 <build+0x3b6>
mov    0x2aa4(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rcx
mov    %r12d,%edi
mov    $0x8,%edx
xor    %r8d,%r8d
call   10a0 <clGetProgramInfo@plt>
mov    0x20(%rsp),%rsi
lea    0xb3f(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x18(%rsp),%r15
jmp    166d <build+0x45d>
lea    0xb6a(%rip),%rdi
call   1060 <puts@plt>
jmp    1686 <build+0x476>
lea    0xae9(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
jmp    1686 <build+0x476>
lea    0xb7a(%rip),%rdi
call   1060 <puts@plt>
mov    0x18(%rsp),%r15
jmp    1675 <build+0x465>
lea    0xbe6(%rip),%rdi
call   1060 <puts@plt>
jmp    1318 <build+0x108>
mov    $0xf4240,%edi
call   1110 <malloc@plt>
test   %rax,%rax
mov    0x18(%rsp),%r15
je     1661 <build+0x451>
mov    %rax,%rdi
mov    %rax,0x10(%rsp)
xor    %esi,%esi
mov    $0xf4240,%edx
call   10d0 <memset@plt>
movq   $0xf4240,0x20(%rsp)
movsbl 0x0(%rbp),%esi
mov    0x29da(%rip),%rax
mov    (%rax),%edx
mov    $0xf4240,%ecx
mov    %r12d,%edi
mov    0x10(%rsp),%rbp
mov    %rbp,%r8
xor    %r9d,%r9d
call   1100 <clGetProgramBuildInfo@plt>
mov    %eax,0x4(%rsp)
lea    0xa62(%rip),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
jmp    166d <build+0x45d>
lea    0xb19(%rip),%rdi
call   1060 <puts@plt>
jmp    1318 <build+0x108>
lea    0xb1f(%rip),%rdi
call   1060 <puts@plt>
jmp    1686 <build+0x476>
lea    0xa9a(%rip),%rdi
call   1060 <puts@plt>
mov    %r12d,%edi
call   1070 <clReleaseProgram@plt>
mov    %ebx,%edi
call   1120 <clReleaseContext@plt>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
jmp    1318 <build+0x108>

LLVM IR (-O0):
@CL_CONTEXT_PLATFORM = global i64 0
@.str = [27 x i8] c"clGetPlatformIDs() Failed\0A\00"
@.str.1 = [31 x i8] c"So we can't come out to play.\0A\00"
@.str.2 = [17 x i8] c"malloc() failed\0A\00"
@.str.3 = [48 x i8] c"clGetPlatformIDs() Failed the second time - %d\0A\00"
@.str.4 = [37 x i8] c"There are %d platforms. That's bad.\0A\00"
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.5 = [26 x i8] c"\09clGetDeviceIDs() failed\0A\00"
@.str.6 = [32 x i8] c"\09This platform has no devices.\0A\00"
@.str.7 = [24 x i8] c"\09malloc(cl_cid) failed\0A\00"
@.str.8 = [42 x i8] c"\09clGetDeviceIDs() failed the second time\0A\00"
@.str.9 = [36 x i8] c"I could not find device number %d.\0A\00"
@.str.10 = [26 x i8] c"clCreateContext() failed\0A\00"
@.str.11 = [20 x i8] c"fopen(\22%s\22) failed\0A\00"
@CL_SUCCESS = global i32 0
@.str.12 = [36 x i8] c"clCreateProgramWithSource() failed\0A\00"
@.str.13 = [31 x i8] c"Failed to malloc() build log.\0A\00"
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.14 = [25 x i8] c"Building \22%s\22 failed:\0A%s\00"
@CL_PROGRAM_BINARY_SIZES = global i32 0
@.str.15 = [21 x i8] c"Success: %zu bytes.\0A\00"
define i32 @build(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
%22 = alloca [3 x i64]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 0, i32* %7
store i32 -1, i32* %8
store i32 0, i32* %9
store i32 0, i32* %11
store i8* null, i8** %14
store i8* null, i8** %15
%23 = getelementptr inbounds [3 x i64], [3 x i64]* %22, i64 0, i64 0
%24 = load i64, i64* @CL_CONTEXT_PLATFORM
store i64 %24, i64* %23
%25 = getelementptr inbounds i64, i64* %23, i64 1
store i64 0, i64* %25
%26 = getelementptr inbounds i64, i64* %25, i64 1
store i64 0, i64* %26
%27 = call i32 @clGetPlatformIDs(i32 0, i8* null, i32* %9)
store i32 %27, i32* %13
%28 = load i32, i32* %13
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %243
32: ; preds = %2
%33 = load i32, i32* %9
store i32 %33, i32* %10
%34 = load i32, i32* %9
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %243
38: ; preds = %32
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = mul i64 1, %40
%42 = trunc i64 %41 to i32
%43 = call i8* @malloc(i32 %42)
store i8* %43, i8** %14
%44 = load i8*, i8** %14
%45 = icmp ne i8* %44, null
br i1 %45, label %48, label %46
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %243
48: ; preds = %38
%49 = load i8*, i8** %14
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = mul i64 1, %51
%53 = trunc i64 %52 to i32
%54 = call i32 @memset(i8* %49, i32 0, i32 %53)
%55 = load i32, i32* %9
%56 = load i8*, i8** %14
%57 = call i32 @clGetPlatformIDs(i32 %55, i8* %56, i32* %9)
store i32 %57, i32* %13
%58 = load i32, i32* %13
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %48
%61 = load i32, i32* %13
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %240
63: ; preds = %48
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i32, i32* %9
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %68)
br label %240
70: ; preds = %63
store i32 0, i32* %6
br label %71
71: ; preds = %141, %70
%72 = load i32, i32* %6
%73 = load i32, i32* %9
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %144
75: ; preds = %71
%76 = load i8*, i8** %14
%77 = load i32, i32* %6
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8, i8* %79
%81 = load i32, i32* @CL_DEVICE_TYPE_ALL
%82 = call i32 @clGetDeviceIDs(i8 signext %80, i32 %81, i32 0, i8* null, i32* %11)
store i32 %82, i32* %13
%83 = load i32, i32* %13
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %75
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %240
87: ; preds = %75
%88 = load i32, i32* %11
%89 = icmp ne i32 %88, 0
br i1 %89, label %92, label %90
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %141
92: ; preds = %87
%93 = load i32, i32* %11
%94 = sext i32 %93 to i64
%95 = mul i64 1, %94
%96 = trunc i64 %95 to i32
%97 = call i8* @malloc(i32 %96)
store i8* %97, i8** %15
%98 = load i8*, i8** %15
%99 = icmp ne i8* %98, null
br i1 %99, label %102, label %100
100: ; preds = %92
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %240
102: ; preds = %92
%103 = load i32, i32* %11
store i32 %103, i32* %12
%104 = load i8*, i8** %14
%105 = load i32, i32* %6
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8, i8* %107
%109 = load i32, i32* @CL_DEVICE_TYPE_ALL
%110 = load i32, i32* %11
%111 = load i8*, i8** %15
%112 = call i32 @clGetDeviceIDs(i8 signext %108, i32 %109, i32 %110, i8* %111, i32* %11)
store i32 %112, i32* %13
%113 = load i32, i32* %13
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %102
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
br label %237
117: ; preds = %102
store i32 0, i32* %7
br label %118
118: ; preds = %130, %117
%119 = load i32, i32* %7
%120 = load i32, i32* %11
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %133
122: ; preds = %118
%123 = load i32, i32* %8
%124 = add nsw i32 %123, 1
store i32 %124, i32* %8
%125 = load i32, i32* %4
%126 = load i32, i32* %8
%127 = icmp eq i32 %125, %126
br i1 %127, label %128, label %129
128: ; preds = %122
br label %133
129: ; preds = %122
br label %130
130: ; preds = %129
%131 = load i32, i32* %7
%132 = add nsw i32 %131, 1
store i32 %132, i32* %7
br label %118
133: ; preds = %128, %118
%134 = load i32, i32* %4
%135 = load i32, i32* %8
%136 = icmp eq i32 %134, %135
br i1 %136, label %137, label %138
137: ; preds = %133
br label %144
138: ; preds = %133
%139 = load i8*, i8** %15
%140 = call i32 @free(i8* %139)
br label %141
141: ; preds = %138, %90
%142 = load i32, i32* %6
%143 = add nsw i32 %142, 1
store i32 %143, i32* %6
br label %71
144: ; preds = %137, %71
%145 = load i32, i32* %4
%146 = load i32, i32* %8
%147 = icmp sgt i32 %145, %146
br i1 %147, label %148, label %152
148: ; preds = %144
%149 = load i32, i32* %4
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i32 %149)
%151 = call i32 (...) @device_list()
br label %240
152: ; preds = %144
%153 = load i8*, i8** %14
%154 = load i32, i32* %6
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds i8, i8* %153, i64 %155
%157 = load i8, i8* %156
%158 = sext i8 %157 to i64
%159 = getelementptr inbounds [3 x i64], [3 x i64]* %22, i64 0, i64 1
store i64 %158, i64* %159
%160 = getelementptr inbounds [3 x i64], [3 x i64]* %22, i64 0, i64 0
%161 = load i8*, i8** %15
%162 = load i32, i32* %7
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %161, i64 %163
%165 = call i32 @clCreateContext(i64* %160, i32 1, i8* %164, i32* null, i32* null, i32* %13)
store i32 %165, i32* %16
%166 = load i32, i32* %16
%167 = icmp ne i32 %166, 0
br i1 %167, label %170, label %168
168: ; preds = %152
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %237
170: ; preds = %152
%171 = load i8*, i8** %5
%172 = call i8* @loadTextFile(i8* %171)
store i8* %172, i8** %18
%173 = load i8*, i8** %18
%174 = icmp ne i8* %173, null
br i1 %174, label %178, label %175
175: ; preds = %170
%176 = load i8*, i8** %5
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %176)
br label %237
178: ; preds = %170
%179 = load i8*, i8** %18
%180 = call i64 @strlen(i8* %179)
store i64 %180, i64* %20
%181 = load i32, i32* %16
%182 = call i32 @clCreateProgramWithSource(i32 %181, i32 1, i8** %18, i64* %20, i32* %13)
store i32 %182, i32* %17
%183 = load i32, i32* %13
%184 = load i32, i32* @CL_SUCCESS
%185 = icmp ne i32 %183, %184
br i1 %185, label %186, label %188
186: ; preds = %178
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0))
br label %232
188: ; preds = %178
%189 = load i32, i32* %17
%190 = load i8*, i8** %15
%191 = load i32, i32* %7
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i8, i8* %190, i64 %192
%194 = call i32 @clBuildProgram(i32 %189, i32 1, i8* %193, i32* null, i32* null, i32* null)
store i32 %194, i32* %13
%195 = load i32, i32* %13
%196 = load i32, i32* @CL_SUCCESS
%197 = icmp ne i32 %195, %196
br i1 %197, label %198, label %222
198: ; preds = %188
%199 = call i8* @malloc(i32 1000000)
store i8* %199, i8** %19
%200 = load i8*, i8** %19
%201 = icmp ne i8* %200, null
br i1 %201, label %204, label %202
202: ; preds = %198
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0))
br label %229
204: ; preds = %198
%205 = load i8*, i8** %19
%206 = call i32 @memset(i8* %205, i32 0, i32 1000000)
store i64 1000000, i64* %21
%207 = load i32, i32* %17
%208 = load i8*, i8** %15
%209 = load i32, i32* %7
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i8, i8* %208, i64 %210
%212 = load i8, i8* %211
%213 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%214 = load i64, i64* %21
%215 = load i8*, i8** %19
%216 = call i32 @clGetProgramBuildInfo(i32 %207, i8 signext %212, i32 %213, i64 %214, i8* %215, i32* null)
store i32 %216, i32* %13
%217 = load i8*, i8** %5
%218 = load i8*, i8** %19
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* %217, i8* %218)
%220 = load i8*, i8** %19
%221 = call i32 @free(i8* %220)
br label %228
222: ; preds = %188
%223 = load i32, i32* %17
%224 = load i32, i32* @CL_PROGRAM_BINARY_SIZES
%225 = call i32 @clGetProgramInfo(i32 %223, i32 %224, i32 8, i64* %21, i32* null)
%226 = load i64, i64* %21
%227 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0), i64 %226)
br label %228
228: ; preds = %222, %204
br label %229
229: ; preds = %228, %202
%230 = load i32, i32* %17
%231 = call i32 @clReleaseProgram(i32 %230)
br label %232
232: ; preds = %229, %186
%233 = load i32, i32* %16
%234 = call i32 @clReleaseContext(i32 %233)
%235 = load i8*, i8** %18
%236 = call i32 @free(i8* %235)
br label %237
237: ; preds = %232, %175, %168, %115
%238 = load i8*, i8** %15
%239 = call i32 @free(i8* %238)
br label %240
240: ; preds = %237, %148, %100, %85, %67, %60
%241 = load i8*, i8** %14
%242 = call i32 @free(i8* %241)
store i32 0, i32* %3
br label %243
243: ; preds = %240, %46, %36, %30
%244 = load i32, i32* %3
ret i32 %244
}

LLVM IR (-O2):
@CL_CONTEXT_PLATFORM = global i64 0
@.str.3 = [48 x i8] c"clGetPlatformIDs() Failed the second time - %d\0A\00"
@.str.4 = [37 x i8] c"There are %d platforms. That's bad.\0A\00"
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.9 = [36 x i8] c"I could not find device number %d.\0A\00"
@.str.11 = [20 x i8] c"fopen(\22%s\22) failed\0A\00"
@CL_SUCCESS = global i32 0
@CL_PROGRAM_BUILD_LOG = global i32 0
@.str.14 = [25 x i8] c"Building \22%s\22 failed:\0A%s\00"
@CL_PROGRAM_BINARY_SIZES = global i32 0
@.str.15 = [21 x i8] c"Success: %zu bytes.\0A\00"
@str = [30 x i8] c"So we can't come out to play.\00"
@str.16 = [16 x i8] c"malloc() failed\00"
@str.17 = [25 x i8] c"clCreateContext() failed\00"
@str.18 = [30 x i8] c"Failed to malloc() build log.\00"
@str.19 = [35 x i8] c"clCreateProgramWithSource() failed\00"
@str.20 = [31 x i8] c"\09This platform has no devices.\00"
@str.21 = [23 x i8] c"\09malloc(cl_cid) failed\00"
@str.22 = [41 x i8] c"\09clGetDeviceIDs() failed the second time\00"
@str.23 = [25 x i8] c"\09clGetDeviceIDs() failed\00"
@str.24 = [26 x i8] c"clGetPlatformIDs() Failed\00"
define i32 @build(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca [3 x i64]
%10 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%11 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%12 = bitcast i32* %5 to i8*
%13 = bitcast i8** %6 to i8*
%14 = bitcast i64* %7 to i8*
%15 = bitcast i64* %8 to i8*
%16 = bitcast [3 x i64]* %9 to i8*
%17 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 0
%18 = load i64, i64* @CL_CONTEXT_PLATFORM
store i64 %18, i64* %17
%19 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 1
%20 = bitcast i64* %19 to i8*
%21 = call i32 @clGetPlatformIDs(i32 0, i8* null, i32* %3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.24, i64 0, i64 0))
br label %191
25: ; preds = %2
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %191
30: ; preds = %25
%31 = call i8* @malloc(i32 %26)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.16, i64 0, i64 0))
br label %191
35: ; preds = %30
%36 = call i32 @memset(i8* %31, i32 0, i32 %26)
%37 = load i32, i32* %3
%38 = call i32 @clGetPlatformIDs(i32 %37, i8* %31, i32* %3)
store i32 %38, i32* %5
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %189
42: ; preds = %35
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, %26
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = icmp sgt i32 %26, 0
br i1 %46, label %49, label %123
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %43)
br label %189
49: ; preds = %45, %115
%50 = phi i64 [ %119, %115 ], [ 0, %45 ]
%51 = phi i32 [ %118, %115 ], [ 0, %45 ]
%52 = phi i8* [ %117, %115 ], [ null, %45 ]
%53 = phi i32 [ %116, %115 ], [ -1, %45 ]
%54 = getelementptr inbounds i8, i8* %31, i64 %50
%55 = load i8, i8* %54
%56 = load i32, i32* @CL_DEVICE_TYPE_ALL
%57 = call i32 @clGetDeviceIDs(i8 signext %55, i32 %56, i32 0, i8* null, i32* %4)
store i32 %57, i32* %5
%58 = icmp eq i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %49
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.23, i64 0, i64 0))
br label %189
61: ; preds = %49
%62 = load i32, i32* %4
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.20, i64 0, i64 0))
br label %115
66: ; preds = %61
%67 = call i8* @malloc(i32 %62)
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.21, i64 0, i64 0))
br label %189
71: ; preds = %66
%72 = load i8, i8* %54
%73 = load i32, i32* @CL_DEVICE_TYPE_ALL
%74 = call i32 @clGetDeviceIDs(i8 signext %72, i32 %73, i32 %62, i8* %67, i32* %4)
store i32 %74, i32* %5
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %99
76: ; preds = %71
%77 = load i32, i32* %4
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %109
79: ; preds = %76
%80 = xor i32 %53, -1
%81 = add i32 %80, %0
%82 = add i32 %77, -1
%83 = call i32 @llvm.umin.i32(i32 %81, i32 %82)
%84 = add i32 %83, 1
%85 = icmp ult i32 %84, 33
br i1 %85, label %86, label %89
86: ; preds = %95, %79
%87 = phi i32 [ 0, %79 ], [ %93, %95 ]
%88 = phi i32 [ %53, %79 ], [ %94, %95 ]
br label %101
89: ; preds = %79
%90 = and i32 %84, 31
%91 = icmp eq i32 %90, 0
%92 = select i1 %91, i32 32, i32 %90
%93 = sub i32 %84, %92
%94 = add i32 %53, %93
br label %95
95: ; preds = %95, %89
%96 = phi i32 [ 0, %89 ], [ %97, %95 ]
%97 = add nuw i32 %96, 32
%98 = icmp eq i32 %97, %93
br i1 %98, label %86, label %95
99: ; preds = %71
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.22, i64 0, i64 0))
br label %186
101: ; preds = %86, %106
%102 = phi i32 [ %107, %106 ], [ %87, %86 ]
%103 = phi i32 [ %104, %106 ], [ %88, %86 ]
%104 = add nsw i32 %103, 1
%105 = icmp eq i32 %104, %0
br i1 %105, label %132, label %106
106: ; preds = %101
%107 = add nuw nsw i32 %102, 1
%108 = icmp eq i32 %107, %77
br i1 %108, label %109, label %101
109: ; preds = %106, %76
%110 = phi i32 [ 0, %76 ], [ %77, %106 ]
%111 = phi i32 [ %53, %76 ], [ %104, %106 ]
%112 = icmp eq i32 %111, %0
br i1 %112, label %132, label %113
113: ; preds = %109
%114 = call i32 @free(i8* %67)
br label %115
115: ; preds = %113, %64
%116 = phi i32 [ %111, %113 ], [ %53, %64 ]
%117 = phi i8* [ %67, %113 ], [ %52, %64 ]
%118 = phi i32 [ %110, %113 ], [ %51, %64 ]
%119 = add nuw nsw i64 %50, 1
%120 = load i32, i32* %3
%121 = sext i32 %120 to i64
%122 = icmp slt i64 %119, %121
br i1 %122, label %49, label %123
123: ; preds = %115, %45
%124 = phi i64 [ 0, %45 ], [ %119, %115 ]
%125 = phi i32 [ -1, %45 ], [ %116, %115 ]
%126 = phi i8* [ null, %45 ], [ %117, %115 ]
%127 = phi i32 [ 0, %45 ], [ %118, %115 ]
%128 = icmp slt i32 %125, %0
br i1 %128, label %129, label %132
129: ; preds = %123
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i32 %0)
%131 = call i32 (...) @device_list()
br label %189
132: ; preds = %109, %101, %123
%133 = phi i32 [ %127, %123 ], [ %102, %101 ], [ %110, %109 ]
%134 = phi i8* [ %126, %123 ], [ %67, %101 ], [ %67, %109 ]
%135 = phi i64 [ %124, %123 ], [ %50, %101 ], [ %50, %109 ]
%136 = and i64 %135, 4294967295
%137 = getelementptr inbounds i8, i8* %31, i64 %136
%138 = load i8, i8* %137
%139 = sext i8 %138 to i64
store i64 %139, i64* %19
%140 = sext i32 %133 to i64
%141 = getelementptr inbounds i8, i8* %134, i64 %140
%142 = call i32 @clCreateContext(i64* %17, i32 1, i8* %141, i32* null, i32* null, i32* %5)
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %132
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
br label %186
146: ; preds = %132
%147 = call i8* @loadTextFile(i8* %1)
store i8* %147, i8** %6
%148 = icmp eq i8* %147, null
br i1 %148, label %149, label %151
149: ; preds = %146
%150 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %1)
br label %186
151: ; preds = %146
%152 = call i64 @strlen(i8* %147)
store i64 %152, i64* %7
%153 = call i32 @clCreateProgramWithSource(i32 %142, i32 1, i8** %6, i64* %7, i32* %5)
%154 = load i32, i32* %5
%155 = load i32, i32* @CL_SUCCESS
%156 = icmp eq i32 %154, %155
br i1 %156, label %159, label %157
157: ; preds = %151
%158 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.19, i64 0, i64 0))
br label %182
159: ; preds = %151
%160 = call i32 @clBuildProgram(i32 %153, i32 1, i8* %141, i32* null, i32* null, i32* null)
store i32 %160, i32* %5
%161 = load i32, i32* @CL_SUCCESS
%162 = icmp eq i32 %160, %161
br i1 %162, label %175, label %163
163: ; preds = %159
%164 = call dereferenceable_or_null(1000000) i8* @malloc(i32 1000000)
%165 = icmp eq i8* %164, null
br i1 %165, label %166, label %168
166: ; preds = %163
%167 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.18, i64 0, i64 0))
br label %180
168: ; preds = %163
%169 = call i32 @memset(i8* %164, i32 0, i32 1000000)
store i64 1000000, i64* %8
%170 = load i8, i8* %141
%171 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%172 = call i32 @clGetProgramBuildInfo(i32 %153, i8 signext %170, i32 %171, i64 1000000, i8* %164, i32* null)
store i32 %172, i32* %5
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8* %1, i8* %164)
%174 = call i32 @free(i8* %164)
br label %180
175: ; preds = %159
%176 = load i32, i32* @CL_PROGRAM_BINARY_SIZES
%177 = call i32 @clGetProgramInfo(i32 %153, i32 %176, i32 8, i64* %8, i32* null)
%178 = load i64, i64* %8
%179 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0), i64 %178)
br label %180
180: ; preds = %168, %175, %166
%181 = call i32 @clReleaseProgram(i32 %153)
br label %182
182: ; preds = %180, %157
%183 = call i32 @clReleaseContext(i32 %142)
%184 = load i8*, i8** %6
%185 = call i32 @free(i8* %184)
br label %186
186: ; preds = %182, %149, %144, %99
%187 = phi i8* [ %67, %99 ], [ %134, %182 ], [ %134, %149 ], [ %134, %144 ]
%188 = call i32 @free(i8* %187)
br label %189
189: ; preds = %186, %129, %69, %59, %47, %40
%190 = call i32 @free(i8* %31)
br label %191
191: ; preds = %189, %33, %28, %23
%192 = phi i32 [ 1, %23 ], [ 0, %189 ], [ 1, %33 ], [ 1, %28 ]
ret i32 %192
}