#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 scalar_t__ cl_program;
typedef scalar_t__ cl_mem;
typedef scalar_t__ cl_kernel;
typedef int /*<<< orphan*/ cl_int;
typedef int /*<<< orphan*/ cl_float4;
typedef int /*<<< orphan*/ cl_device_id;
typedef scalar_t__ cl_context;
typedef scalar_t__ cl_command_queue;

/* Variables and functions */
int /*<<< orphan*/ CL_CONTEXT_DEVICES;
int CL_MEM_COPY_HOST_PTR;
int CL_MEM_READ_ONLY;
int CL_MEM_READ_WRITE;
int /*<<< orphan*/ CL_SUCCESS;
int /*<<< orphan*/ CL_TRUE;
int /*<<< orphan*/ clBuildProgram(scalar_t__, int /*<<< orphan*/,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ clCreateBuffer(scalar_t__, int, int, void *, int /*<<< orphan*/ *);
scalar_t__ clCreateCommandQueue(scalar_t__, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/ *);
scalar_t__ clCreateKernel(scalar_t__, char *, int /*<<< orphan*/ *);
scalar_t__ clCreateProgramWithSource(scalar_t__, int, char const **,
                                     int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueNDRangeKernel(scalar_t__, scalar_t__, int,
                                          int /*<<< orphan*/ *, size_t *,
                                          size_t *, int /*<<< orphan*/,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ clEnqueueReadBuffer(scalar_t__, scalar_t__,
                                       int /*<<< orphan*/, int /*<<< orphan*/,
                                       int, void *, int /*<<< orphan*/,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetContextInfo(scalar_t__, int /*<<< orphan*/, size_t,
                                    int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ clReleaseCommandQueue(scalar_t__);
int /*<<< orphan*/ clReleaseContext(scalar_t__);
int /*<<< orphan*/ clReleaseKernel(scalar_t__);
int /*<<< orphan*/ clReleaseProgram(scalar_t__);
int /*<<< orphan*/ clSetKernelArg(scalar_t__, int, int, void *);
int /*<<< orphan*/ delete_memobjs(scalar_t__ *, int);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
scalar_t__ malloc(size_t);
scalar_t__ poclu_create_any_context();
int exec_trig_kernel(const char *program_source, int n, void *srcA, void *dst) {
  cl_context context;
  cl_command_queue cmd_queue;
  cl_device_id *devices;
  cl_program program;
  cl_kernel kernel;
  cl_mem memobjs[2];
  size_t global_work_size[1];
  size_t local_work_size[1];
  size_t cb;
  cl_int err;
  float c = 7.3f;
  context = poclu_create_any_context();
  if (context == (cl_context)0)
    return -1;
  clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &cb);
  devices = (cl_device_id *)malloc(cb);
  clGetContextInfo(context, CL_CONTEXT_DEVICES, cb, devices, NULL);
  cmd_queue = clCreateCommandQueue(context, devices[0], 0, NULL);
  if (cmd_queue == (cl_command_queue)0) {
    clReleaseContext(context);
    free(devices);
    return -1;
  }
  free(devices);
  memobjs[0] = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
                              sizeof(cl_float4) * n, srcA, NULL);
  if (memobjs[0] == (cl_mem)0) {
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  memobjs[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(cl_float4) * n,
                              NULL, NULL);
  if (memobjs[1] == (cl_mem)0) {
    delete_memobjs(memobjs, 1);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  program = clCreateProgramWithSource(
      context, 1, (const char **)&program_source, NULL, NULL);
  if (program == (cl_program)0) {
    delete_memobjs(memobjs, 2);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
  if (err != CL_SUCCESS) {
    delete_memobjs(memobjs, 2);
    clReleaseProgram(program);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  kernel = clCreateKernel(program, "trig", NULL);
  if (kernel == (cl_kernel)0) {
    delete_memobjs(memobjs, 2);
    clReleaseProgram(program);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  err = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&memobjs[0]);
  err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&memobjs[1]);
  err |= clSetKernelArg(kernel, 2, sizeof(float), (void *)&c);
  if (err != CL_SUCCESS) {
    delete_memobjs(memobjs, 2);
    clReleaseKernel(kernel);
    clReleaseProgram(program);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  global_work_size[0] = n;
  local_work_size[0] = 2;
  err = clEnqueueNDRangeKernel(cmd_queue, kernel, 1, NULL, global_work_size,
                               local_work_size, 0, NULL, NULL);
  if (err != CL_SUCCESS) {
    delete_memobjs(memobjs, 2);
    clReleaseKernel(kernel);
    clReleaseProgram(program);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  err = clEnqueueReadBuffer(cmd_queue, memobjs[1], CL_TRUE, 0,
                            n * sizeof(cl_float4), dst, 0, NULL, NULL);
  if (err != CL_SUCCESS) {
    delete_memobjs(memobjs, 2);
    clReleaseKernel(kernel);
    clReleaseProgram(program);
    clReleaseCommandQueue(cmd_queue);
    clReleaseContext(context);
    return -1;
  }
  delete_memobjs(memobjs, 2);
  clReleaseKernel(kernel);
  clReleaseProgram(program);
  clReleaseCommandQueue(cmd_queue);
  clReleaseContext(context);
  return 0;
}


x86 assembly (clang, -O0):
<exec_trig_kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movss  0xdce(%rip),%xmm0
movss  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   10d0 <poclu_create_any_context@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1259 <exec_trig_kernel+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x30(%rbp),%rdi
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x78(%rbp),%r8
mov    %rcx,%rdx
call   1040 <clGetContextInfo@plt>
mov    -0x78(%rbp),%rdi
call   10f0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
mov    -0x78(%rbp),%rdx
mov    -0x40(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetContextInfo@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <clCreateCommandQueue@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12e4 <exec_trig_kernel+0xd4>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
mov    -0x40(%rbp),%rdi
call   1050 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x40(%rbp),%rdi
call   1050 <free@plt>
mov    -0x30(%rbp),%rdi
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    0x2cc7(%rip),%rax
or     (%rax),%esi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <clCreateBuffer@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1348 <exec_trig_kernel+0x138>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x30(%rbp),%rdi
mov    0x2c8d(%rip),%rax
mov    (%rax),%esi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1090 <clCreateBuffer@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    13a7 <exec_trig_kernel+0x197>
lea    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   1060 <delete_memobjs@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
lea    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1070 <clCreateProgramWithSource@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13fc <exec_trig_kernel+0x1ec>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rdx
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    0x2b96(%rip),%rcx
cmp    (%rcx),%eax
je     145f <exec_trig_kernel+0x24f>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x48(%rbp),%rdi
lea    0xb9a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1120 <clCreateKernel@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    14b7 <exec_trig_kernel+0x2a7>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rcx
xor    %esi,%esi
mov    $0x8,%edx
call   1130 <clSetKernelArg@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x60(%rbp),%rcx
add    $0x8,%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1130 <clSetKernelArg@plt>
or     -0x7c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x80(%rbp),%rcx
mov    $0x2,%esi
mov    $0x4,%edx
call   1130 <clSetKernelArg@plt>
or     -0x7c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    0x2aa2(%rip),%rcx
cmp    (%rcx),%eax
je     155c <exec_trig_kernel+0x34c>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x50(%rbp),%rdi
call   1080 <clReleaseKernel@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
movslq -0x14(%rbp),%rax
mov    %rax,-0x68(%rbp)
movq   $0x2,-0x70(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x50(%rbp),%rsi
lea    -0x68(%rbp),%r8
lea    -0x70(%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   10b0 <clEnqueueNDRangeKernel@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    0x2a06(%rip),%rcx
cmp    (%rcx),%eax
je     15f8 <exec_trig_kernel+0x3e8>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x50(%rbp),%rdi
call   1080 <clReleaseKernel@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x29e1(%rip),%rax
mov    (%rax),%edx
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%r8d
mov    -0x28(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1100 <clEnqueueReadBuffer@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    0x2971(%rip),%rcx
cmp    (%rcx),%eax
je     168d <exec_trig_kernel+0x47d>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x50(%rbp),%rdi
call   1080 <clReleaseKernel@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16c6 <exec_trig_kernel+0x4b6>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x50(%rbp),%rdi
call   1080 <clReleaseKernel@plt>
mov    -0x48(%rbp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1110 <clReleaseContext@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_trig_kernel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %esi,%r14d
mov    %rdi,0x60(%rsp)
movl   $0x40e9999a,0x3c(%rsp)
40
xor    %eax,%eax
call   10d0 <poclu_create_any_context@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     1515 <exec_trig_kernel+0x305>
mov    %rax,%r12
mov    %rbx,0x48(%rsp)
mov    0x2d7f(%rip),%rbx
mov    (%rbx),%esi
lea    0x40(%rsp),%r8
mov    %rax,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <clGetContextInfo@plt>
mov    0x40(%rsp),%rdi
call   10f0 <malloc@plt>
mov    %rax,%rbp
mov    (%rbx),%esi
mov    0x40(%rsp),%rdx
mov    %r12,%rdi
mov    %rax,%rcx
xor    %r8d,%r8d
call   1040 <clGetContextInfo@plt>
mov    0x0(%rbp),%esi
mov    %r12,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   10c0 <clCreateCommandQueue@plt>
test   %rax,%rax
je     1496 <exec_trig_kernel+0x286>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1050 <free@plt>
mov    0x2d08(%rip),%rax
mov    0x2d09(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0x0(,%r14,4),%r13d
mov    %r12,%rdi
mov    %r13d,%edx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1090 <clCreateBuffer@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     14ff <exec_trig_kernel+0x2ef>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
mov    %r13d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <clCreateBuffer@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     14a8 <exec_trig_kernel+0x298>
lea    0x60(%rsp),%rdx
mov    %r12,%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <clCreateProgramWithSource@plt>
test   %rax,%rax
je     14cd <exec_trig_kernel+0x2bd>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    0x2c69(%rip),%rcx
cmp    (%rcx),%eax
jne    14b9 <exec_trig_kernel+0x2a9>
lea    0xcb2(%rip),%rsi
mov    %rbp,%rdi
xor    %edx,%edx
call   1120 <clCreateKernel@plt>
test   %rax,%rax
je     14b9 <exec_trig_kernel+0x2a9>
mov    %rax,%r15
mov    %rbp,0x30(%rsp)
lea    0x28(%rsp),%rbp
lea    0x20(%rsp),%rcx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1130 <clSetKernelArg@plt>
mov    %eax,0x38(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rbp,%rcx
call   1130 <clSetKernelArg@plt>
mov    %eax,%ebp
or     0x38(%rsp),%ebp
lea    0x3c(%rsp),%rcx
mov    %r15,%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1130 <clSetKernelArg@plt>
or     %ebp,%eax
mov    0x2be7(%rip),%rcx
cmp    (%rcx),%eax
jne    14de <exec_trig_kernel+0x2ce>
movslq %r14d,%rax
mov    %rax,0x58(%rsp)
movq   $0x2,0x50(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0x58(%rsp),%r8
lea    0x50(%rsp),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   10b0 <clEnqueueNDRangeKernel@plt>
mov    0x2b9c(%rip),%rcx
cmp    (%rcx),%eax
jne    14de <exec_trig_kernel+0x2ce>
mov    0x28(%rsp),%rsi
mov    0x2bb8(%rip),%rax
mov    (%rax),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %rbx,%rdi
mov    %rcx,%rbp
xor    %ecx,%ecx
mov    %r13d,%r8d
mov    0x48(%rsp),%r9
call   1100 <clEnqueueReadBuffer@plt>
xor    %r13d,%r13d
cmp    0x0(%rbp),%eax
setne  %r13b
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    %r15,%rdi
call   1080 <clReleaseKernel@plt>
mov    0x30(%rsp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    %rbx,%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    %r12,%rdi
call   1110 <clReleaseContext@plt>
neg    %r13d
jmp    1515 <exec_trig_kernel+0x305>
mov    %r12,%rdi
call   1110 <clReleaseContext@plt>
mov    %rbp,%rdi
call   1050 <free@plt>
jmp    1515 <exec_trig_kernel+0x305>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
call   1060 <delete_memobjs@plt>
jmp    14ff <exec_trig_kernel+0x2ef>
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    %rbp,%rdi
jmp    14fa <exec_trig_kernel+0x2ea>
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
jmp    14ff <exec_trig_kernel+0x2ef>
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    %r15,%rdi
call   1080 <clReleaseKernel@plt>
mov    0x30(%rsp),%rdi
call   10a0 <clReleaseProgram@plt>
mov    %rbx,%rdi
call   10e0 <clReleaseCommandQueue@plt>
mov    %r12,%rdi
call   1110 <clReleaseContext@plt>
mov    $0xffffffff,%r13d
mov    %r13d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CL_CONTEXT_DEVICES = global i32 0
@CL_MEM_READ_ONLY = global i32 0
@CL_MEM_COPY_HOST_PTR = global i32 0
@CL_MEM_READ_WRITE = global i32 0
@CL_SUCCESS = global i32 0
@.str = [5 x i8] c"trig\00"
@CL_TRUE = global i32 0
define i32 @exec_trig_kernel(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32*
%13 = alloca i64
%14 = alloca i64
%15 = alloca [2 x i64]
%16 = alloca [1 x i64]
%17 = alloca [1 x i64]
%18 = alloca i64
%19 = alloca i32
%20 = alloca float
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store float 0x401D333340000000, float* %20
%21 = call i64 (...) @poclu_create_any_context()
store i64 %21, i64* %10
%22 = load i64, i64* %10
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %4
store i32 -1, i32* %5
br label %221
25: ; preds = %4
%26 = load i64, i64* %10
%27 = load i32, i32* @CL_CONTEXT_DEVICES
%28 = call i32 @clGetContextInfo(i64 %26, i32 %27, i64 0, i32* null, i64* %18)
%29 = load i64, i64* %18
%30 = call i64 @malloc(i64 %29)
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %12
%32 = load i64, i64* %10
%33 = load i32, i32* @CL_CONTEXT_DEVICES
%34 = load i64, i64* %18
%35 = load i32*, i32** %12
%36 = call i32 @clGetContextInfo(i64 %32, i32 %33, i64 %34, i32* %35, i64* null)
%37 = load i64, i64* %10
%38 = load i32*, i32** %12
%39 = getelementptr inbounds i32, i32* %38, i64 0
%40 = load i32, i32* %39
%41 = call i64 @clCreateCommandQueue(i64 %37, i32 %40, i32 0, i32* null)
store i64 %41, i64* %11
%42 = load i64, i64* %11
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %25
%45 = load i64, i64* %10
%46 = call i32 @clReleaseContext(i64 %45)
%47 = load i32*, i32** %12
%48 = call i32 @free(i32* %47)
store i32 -1, i32* %5
br label %221
49: ; preds = %25
%50 = load i32*, i32** %12
%51 = call i32 @free(i32* %50)
%52 = load i64, i64* %10
%53 = load i32, i32* @CL_MEM_READ_ONLY
%54 = load i32, i32* @CL_MEM_COPY_HOST_PTR
%55 = or i32 %53, %54
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = mul i64 4, %57
%59 = trunc i64 %58 to i32
%60 = load i8*, i8** %8
%61 = call i64 @clCreateBuffer(i64 %52, i32 %55, i32 %59, i8* %60, i32* null)
%62 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
store i64 %61, i64* %62
%63 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%64 = load i64, i64* %63
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %49
%67 = load i64, i64* %11
%68 = call i32 @clReleaseCommandQueue(i64 %67)
%69 = load i64, i64* %10
%70 = call i32 @clReleaseContext(i64 %69)
store i32 -1, i32* %5
br label %221
71: ; preds = %49
%72 = load i64, i64* %10
%73 = load i32, i32* @CL_MEM_READ_WRITE
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = mul i64 4, %75
%77 = trunc i64 %76 to i32
%78 = call i64 @clCreateBuffer(i64 %72, i32 %73, i32 %77, i8* null, i32* null)
%79 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
store i64 %78, i64* %79
%80 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%81 = load i64, i64* %80
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %90
83: ; preds = %71
%84 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%85 = call i32 @delete_memobjs(i64* %84, i32 1)
%86 = load i64, i64* %11
%87 = call i32 @clReleaseCommandQueue(i64 %86)
%88 = load i64, i64* %10
%89 = call i32 @clReleaseContext(i64 %88)
store i32 -1, i32* %5
br label %221
90: ; preds = %71
%91 = load i64, i64* %10
%92 = call i64 @clCreateProgramWithSource(i64 %91, i32 1, i8** %6, i32* null, i32* null)
store i64 %92, i64* %13
%93 = load i64, i64* %13
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %102
95: ; preds = %90
%96 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%97 = call i32 @delete_memobjs(i64* %96, i32 2)
%98 = load i64, i64* %11
%99 = call i32 @clReleaseCommandQueue(i64 %98)
%100 = load i64, i64* %10
%101 = call i32 @clReleaseContext(i64 %100)
store i32 -1, i32* %5
br label %221
102: ; preds = %90
%103 = load i64, i64* %13
%104 = call i32 @clBuildProgram(i64 %103, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %104, i32* %19
%105 = load i32, i32* %19
%106 = load i32, i32* @CL_SUCCESS
%107 = icmp ne i32 %105, %106
br i1 %107, label %108, label %117
108: ; preds = %102
%109 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%110 = call i32 @delete_memobjs(i64* %109, i32 2)
%111 = load i64, i64* %13
%112 = call i32 @clReleaseProgram(i64 %111)
%113 = load i64, i64* %11
%114 = call i32 @clReleaseCommandQueue(i64 %113)
%115 = load i64, i64* %10
%116 = call i32 @clReleaseContext(i64 %115)
store i32 -1, i32* %5
br label %221
117: ; preds = %102
%118 = load i64, i64* %13
%119 = call i64 @clCreateKernel(i64 %118, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* null)
store i64 %119, i64* %14
%120 = load i64, i64* %14
%121 = icmp eq i64 %120, 0
br i1 %121, label %122, label %131
122: ; preds = %117
%123 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%124 = call i32 @delete_memobjs(i64* %123, i32 2)
%125 = load i64, i64* %13
%126 = call i32 @clReleaseProgram(i64 %125)
%127 = load i64, i64* %11
%128 = call i32 @clReleaseCommandQueue(i64 %127)
%129 = load i64, i64* %10
%130 = call i32 @clReleaseContext(i64 %129)
store i32 -1, i32* %5
br label %221
131: ; preds = %117
%132 = load i64, i64* %14
%133 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%134 = bitcast i64* %133 to i8*
%135 = call i32 @clSetKernelArg(i64 %132, i32 0, i32 8, i8* %134)
store i32 %135, i32* %19
%136 = load i64, i64* %14
%137 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%138 = bitcast i64* %137 to i8*
%139 = call i32 @clSetKernelArg(i64 %136, i32 1, i32 8, i8* %138)
%140 = load i32, i32* %19
%141 = or i32 %140, %139
store i32 %141, i32* %19
%142 = load i64, i64* %14
%143 = bitcast float* %20 to i8*
%144 = call i32 @clSetKernelArg(i64 %142, i32 2, i32 4, i8* %143)
%145 = load i32, i32* %19
%146 = or i32 %145, %144
store i32 %146, i32* %19
%147 = load i32, i32* %19
%148 = load i32, i32* @CL_SUCCESS
%149 = icmp ne i32 %147, %148
br i1 %149, label %150, label %161
150: ; preds = %131
%151 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%152 = call i32 @delete_memobjs(i64* %151, i32 2)
%153 = load i64, i64* %14
%154 = call i32 @clReleaseKernel(i64 %153)
%155 = load i64, i64* %13
%156 = call i32 @clReleaseProgram(i64 %155)
%157 = load i64, i64* %11
%158 = call i32 @clReleaseCommandQueue(i64 %157)
%159 = load i64, i64* %10
%160 = call i32 @clReleaseContext(i64 %159)
store i32 -1, i32* %5
br label %221
161: ; preds = %131
%162 = load i32, i32* %7
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds [1 x i64], [1 x i64]* %16, i64 0, i64 0
store i64 %163, i64* %164
%165 = getelementptr inbounds [1 x i64], [1 x i64]* %17, i64 0, i64 0
store i64 2, i64* %165
%166 = load i64, i64* %11
%167 = load i64, i64* %14
%168 = getelementptr inbounds [1 x i64], [1 x i64]* %16, i64 0, i64 0
%169 = getelementptr inbounds [1 x i64], [1 x i64]* %17, i64 0, i64 0
%170 = call i32 @clEnqueueNDRangeKernel(i64 %166, i64 %167, i32 1, i32* null, i64* %168, i64* %169, i32 0, i32* null, i32* null)
store i32 %170, i32* %19
%171 = load i32, i32* %19
%172 = load i32, i32* @CL_SUCCESS
%173 = icmp ne i32 %171, %172
br i1 %173, label %174, label %185
174: ; preds = %161
%175 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%176 = call i32 @delete_memobjs(i64* %175, i32 2)
%177 = load i64, i64* %14
%178 = call i32 @clReleaseKernel(i64 %177)
%179 = load i64, i64* %13
%180 = call i32 @clReleaseProgram(i64 %179)
%181 = load i64, i64* %11
%182 = call i32 @clReleaseCommandQueue(i64 %181)
%183 = load i64, i64* %10
%184 = call i32 @clReleaseContext(i64 %183)
store i32 -1, i32* %5
br label %221
185: ; preds = %161
%186 = load i64, i64* %11
%187 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%188 = load i64, i64* %187
%189 = load i32, i32* @CL_TRUE
%190 = load i32, i32* %7
%191 = sext i32 %190 to i64
%192 = mul i64 %191, 4
%193 = trunc i64 %192 to i32
%194 = load i8*, i8** %9
%195 = call i32 @clEnqueueReadBuffer(i64 %186, i64 %188, i32 %189, i32 0, i32 %193, i8* %194, i32 0, i32* null, i32* null)
store i32 %195, i32* %19
%196 = load i32, i32* %19
%197 = load i32, i32* @CL_SUCCESS
%198 = icmp ne i32 %196, %197
br i1 %198, label %199, label %210
199: ; preds = %185
%200 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%201 = call i32 @delete_memobjs(i64* %200, i32 2)
%202 = load i64, i64* %14
%203 = call i32 @clReleaseKernel(i64 %202)
%204 = load i64, i64* %13
%205 = call i32 @clReleaseProgram(i64 %204)
%206 = load i64, i64* %11
%207 = call i32 @clReleaseCommandQueue(i64 %206)
%208 = load i64, i64* %10
%209 = call i32 @clReleaseContext(i64 %208)
store i32 -1, i32* %5
br label %221
210: ; preds = %185
%211 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%212 = call i32 @delete_memobjs(i64* %211, i32 2)
%213 = load i64, i64* %14
%214 = call i32 @clReleaseKernel(i64 %213)
%215 = load i64, i64* %13
%216 = call i32 @clReleaseProgram(i64 %215)
%217 = load i64, i64* %11
%218 = call i32 @clReleaseCommandQueue(i64 %217)
%219 = load i64, i64* %10
%220 = call i32 @clReleaseContext(i64 %219)
store i32 0, i32* %5
br label %221
221: ; preds = %210, %199, %174, %150, %122, %108, %95, %83, %66, %44, %24
%222 = load i32, i32* %5
ret i32 %222
}

LLVM IR (-O2):
@CL_CONTEXT_DEVICES = global i32 0
@CL_MEM_READ_ONLY = global i32 0
@CL_MEM_COPY_HOST_PTR = global i32 0
@CL_MEM_READ_WRITE = global i32 0
@CL_SUCCESS = global i32 0
@.str = [5 x i8] c"trig\00"
@CL_TRUE = global i32 0
define i32 @exec_trig_kernel(i8* %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca [2 x i64]
%7 = alloca [1 x i64]
%8 = alloca [1 x i64]
%9 = alloca i64
%10 = alloca float
store i8* %0, i8** %5
%11 = bitcast [2 x i64]* %6 to i8*
%12 = bitcast [1 x i64]* %7 to i8*
%13 = bitcast [1 x i64]* %8 to i8*
%14 = bitcast i64* %9 to i8*
%15 = bitcast float* %10 to i8*
store float 0x401D333340000000, float* %10
%16 = tail call i64 (...) @poclu_create_any_context()
%17 = icmp eq i64 %16, 0
br i1 %17, label %118, label %18
18: ; preds = %4
%19 = load i32, i32* @CL_CONTEXT_DEVICES
%20 = call i32 @clGetContextInfo(i64 %16, i32 %19, i64 0, i32* null, i64* %9)
%21 = load i64, i64* %9
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i32*
%24 = load i32, i32* @CL_CONTEXT_DEVICES
%25 = load i64, i64* %9
%26 = call i32 @clGetContextInfo(i64 %16, i32 %24, i64 %25, i32* %23, i64* null)
%27 = load i32, i32* %23
%28 = call i64 @clCreateCommandQueue(i64 %16, i32 %27, i32 0, i32* null)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = call i32 @clReleaseContext(i64 %16)
%32 = call i32 @free(i32* %23)
br label %118
33: ; preds = %18
%34 = call i32 @free(i32* %23)
%35 = load i32, i32* @CL_MEM_READ_ONLY
%36 = load i32, i32* @CL_MEM_COPY_HOST_PTR
%37 = or i32 %36, %35
%38 = sext i32 %1 to i64
%39 = shl i32 %1, 2
%40 = call i64 @clCreateBuffer(i64 %16, i32 %37, i32 %39, i8* %2, i32* null)
%41 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
store i64 %40, i64* %41
%42 = icmp eq i64 %40, 0
br i1 %42, label %43, label %46
43: ; preds = %33
%44 = call i32 @clReleaseCommandQueue(i64 %28)
%45 = call i32 @clReleaseContext(i64 %16)
br label %118
46: ; preds = %33
%47 = load i32, i32* @CL_MEM_READ_WRITE
%48 = call i64 @clCreateBuffer(i64 %16, i32 %47, i32 %39, i8* null, i32* null)
%49 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 1
store i64 %48, i64* %49
%50 = icmp eq i64 %48, 0
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = call i32 @delete_memobjs(i64* %41, i32 1)
%53 = call i32 @clReleaseCommandQueue(i64 %28)
%54 = call i32 @clReleaseContext(i64 %16)
br label %118
55: ; preds = %46
%56 = call i64 @clCreateProgramWithSource(i64 %16, i32 1, i8** %5, i32* null, i32* null)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = call i32 @delete_memobjs(i64* %41, i32 2)
%60 = call i32 @clReleaseCommandQueue(i64 %28)
%61 = call i32 @clReleaseContext(i64 %16)
br label %118
62: ; preds = %55
%63 = call i32 @clBuildProgram(i64 %56, i32 0, i32* null, i32* null, i32* null, i32* null)
%64 = load i32, i32* @CL_SUCCESS
%65 = icmp eq i32 %63, %64
br i1 %65, label %71, label %66
66: ; preds = %62
%67 = call i32 @delete_memobjs(i64* %41, i32 2)
%68 = call i32 @clReleaseProgram(i64 %56)
%69 = call i32 @clReleaseCommandQueue(i64 %28)
%70 = call i32 @clReleaseContext(i64 %16)
br label %118
71: ; preds = %62
%72 = call i64 @clCreateKernel(i64 %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* null)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = call i32 @delete_memobjs(i64* %41, i32 2)
%76 = call i32 @clReleaseProgram(i64 %56)
%77 = call i32 @clReleaseCommandQueue(i64 %28)
%78 = call i32 @clReleaseContext(i64 %16)
br label %118
79: ; preds = %71
%80 = call i32 @clSetKernelArg(i64 %72, i32 0, i32 8, i8* %11)
%81 = bitcast i64* %49 to i8*
%82 = call i32 @clSetKernelArg(i64 %72, i32 1, i32 8, i8* %81)
%83 = or i32 %82, %80
%84 = call i32 @clSetKernelArg(i64 %72, i32 2, i32 4, i8* %15)
%85 = or i32 %83, %84
%86 = load i32, i32* @CL_SUCCESS
%87 = icmp eq i32 %85, %86
br i1 %87, label %94, label %88
88: ; preds = %79
%89 = call i32 @delete_memobjs(i64* %41, i32 2)
%90 = call i32 @clReleaseKernel(i64 %72)
%91 = call i32 @clReleaseProgram(i64 %56)
%92 = call i32 @clReleaseCommandQueue(i64 %28)
%93 = call i32 @clReleaseContext(i64 %16)
br label %118
94: ; preds = %79
%95 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 0
store i64 %38, i64* %95
%96 = getelementptr inbounds [1 x i64], [1 x i64]* %8, i64 0, i64 0
store i64 2, i64* %96
%97 = call i32 @clEnqueueNDRangeKernel(i64 %28, i64 %72, i32 1, i32* null, i64* %95, i64* %96, i32 0, i32* null, i32* null)
%98 = load i32, i32* @CL_SUCCESS
%99 = icmp eq i32 %97, %98
br i1 %99, label %106, label %100
100: ; preds = %94
%101 = call i32 @delete_memobjs(i64* %41, i32 2)
%102 = call i32 @clReleaseKernel(i64 %72)
%103 = call i32 @clReleaseProgram(i64 %56)
%104 = call i32 @clReleaseCommandQueue(i64 %28)
%105 = call i32 @clReleaseContext(i64 %16)
br label %118
106: ; preds = %94
%107 = load i64, i64* %49
%108 = load i32, i32* @CL_TRUE
%109 = call i32 @clEnqueueReadBuffer(i64 %28, i64 %107, i32 %108, i32 0, i32 %39, i8* %3, i32 0, i32* null, i32* null)
%110 = load i32, i32* @CL_SUCCESS
%111 = icmp ne i32 %109, %110
%112 = call i32 @delete_memobjs(i64* %41, i32 2)
%113 = call i32 @clReleaseKernel(i64 %72)
%114 = call i32 @clReleaseProgram(i64 %56)
%115 = call i32 @clReleaseCommandQueue(i64 %28)
%116 = call i32 @clReleaseContext(i64 %16)
%117 = sext i1 %111 to i32
br label %118
118: ; preds = %106, %4, %100, %88, %74, %66, %58, %51, %43, %30
%119 = phi i32 [ -1, %30 ], [ -1, %43 ], [ -1, %51 ], [ -1, %58 ], [ -1, %66 ], [ -1, %74 ], [ -1, %88 ], [ -1, %100 ], [ -1, %4 ], [ %117, %106 ]
ret i32 %119
}