#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 /*<<< orphan*/ CL_DEVICE_TYPE_CPU;
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__ clCreateContextFromType(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   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);
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.3;
  context = clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU, NULL, NULL, NULL);
  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    0x2d82(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdi
mov    %r8,%rdx
mov    %r8,%rcx
call   1110 <clCreateContextFromType@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    126e <exec_trig_kernel+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
mov    -0x30(%rbp),%rdi
mov    0x2d5f(%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   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d35(%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    12f9 <exec_trig_kernel+0xe9>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
mov    -0x40(%rbp),%rdi
call   1050 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
mov    -0x40(%rbp),%rdi
call   1050 <free@plt>
mov    -0x30(%rbp),%rdi
mov    0x2cab(%rip),%rax
mov    (%rax),%esi
mov    0x2cb2(%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    135d <exec_trig_kernel+0x14d>
mov    -0x38(%rbp),%rdi
call   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
mov    -0x30(%rbp),%rdi
mov    0x2c78(%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    13bc <exec_trig_kernel+0x1ac>
lea    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   1060 <delete_memobjs@plt>
mov    -0x38(%rbp),%rdi
call   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
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    1411 <exec_trig_kernel+0x201>
lea    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    -0x38(%rbp),%rdi
call   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
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    0x2b79(%rip),%rcx
cmp    (%rcx),%eax
je     1474 <exec_trig_kernel+0x264>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
mov    -0x48(%rbp),%rdi
lea    0xb85(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1120 <clCreateKernel@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    14cc <exec_trig_kernel+0x2bc>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
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    0x2a85(%rip),%rcx
cmp    (%rcx),%eax
je     1571 <exec_trig_kernel+0x361>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
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    0x29e9(%rip),%rcx
cmp    (%rcx),%eax
je     160d <exec_trig_kernel+0x3fd>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x29cc(%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   10f0 <clEnqueueReadBuffer@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    0x2954(%rip),%rcx
cmp    (%rcx),%eax
je     16a2 <exec_trig_kernel+0x492>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <clReleaseContext@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16db <exec_trig_kernel+0x4cb>
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   10d0 <clReleaseCommandQueue@plt>
mov    -0x30(%rbp),%rdi
call   1100 <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
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1110 <clCreateContextFromType@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     1525 <exec_trig_kernel+0x315>
mov    %rax,%r12
mov    %rbx,0x48(%rsp)
mov    0x2d6f(%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   10e0 <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     14a6 <exec_trig_kernel+0x296>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1050 <free@plt>
mov    0x2cf0(%rip),%rax
mov    0x2cf9(%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     150f <exec_trig_kernel+0x2ff>
mov    0x2cdf(%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     14b8 <exec_trig_kernel+0x2a8>
lea    0x60(%rsp),%rdx
mov    %r12,%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <clCreateProgramWithSource@plt>
test   %rax,%rax
je     14dd <exec_trig_kernel+0x2cd>
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    0x2c51(%rip),%rcx
cmp    (%rcx),%eax
jne    14c9 <exec_trig_kernel+0x2b9>
lea    0xca2(%rip),%rsi
mov    %rbp,%rdi
xor    %edx,%edx
call   1120 <clCreateKernel@plt>
test   %rax,%rax
je     14c9 <exec_trig_kernel+0x2b9>
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    0x2bcf(%rip),%rcx
cmp    (%rcx),%eax
jne    14ee <exec_trig_kernel+0x2de>
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    0x2b84(%rip),%rcx
cmp    (%rcx),%eax
jne    14ee <exec_trig_kernel+0x2de>
mov    0x28(%rsp),%rsi
mov    0x2ba8(%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   10f0 <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   10d0 <clReleaseCommandQueue@plt>
mov    %r12,%rdi
call   1100 <clReleaseContext@plt>
neg    %r13d
jmp    1525 <exec_trig_kernel+0x315>
mov    %r12,%rdi
call   1100 <clReleaseContext@plt>
mov    %rbp,%rdi
call   1050 <free@plt>
jmp    1525 <exec_trig_kernel+0x315>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
call   1060 <delete_memobjs@plt>
jmp    150f <exec_trig_kernel+0x2ff>
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
mov    %rbp,%rdi
jmp    150a <exec_trig_kernel+0x2fa>
lea    0x20(%rsp),%rdi
mov    $0x2,%esi
call   1060 <delete_memobjs@plt>
jmp    150f <exec_trig_kernel+0x2ff>
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   10d0 <clReleaseCommandQueue@plt>
mov    %r12,%rdi
call   1100 <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_DEVICE_TYPE_CPU = global i32 0
@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 = load i32, i32* @CL_DEVICE_TYPE_CPU
%22 = call i64 @clCreateContextFromType(i32* null, i32 %21, i32* null, i32* null, i32* null)
store i64 %22, i64* %10
%23 = load i64, i64* %10
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %4
store i32 -1, i32* %5
br label %222
26: ; preds = %4
%27 = load i64, i64* %10
%28 = load i32, i32* @CL_CONTEXT_DEVICES
%29 = call i32 @clGetContextInfo(i64 %27, i32 %28, i64 0, i32* null, i64* %18)
%30 = load i64, i64* %18
%31 = call i64 @malloc(i64 %30)
%32 = inttoptr i64 %31 to i32*
store i32* %32, i32** %12
%33 = load i64, i64* %10
%34 = load i32, i32* @CL_CONTEXT_DEVICES
%35 = load i64, i64* %18
%36 = load i32*, i32** %12
%37 = call i32 @clGetContextInfo(i64 %33, i32 %34, i64 %35, i32* %36, i64* null)
%38 = load i64, i64* %10
%39 = load i32*, i32** %12
%40 = getelementptr inbounds i32, i32* %39, i64 0
%41 = load i32, i32* %40
%42 = call i64 @clCreateCommandQueue(i64 %38, i32 %41, i32 0, i32* null)
store i64 %42, i64* %11
%43 = load i64, i64* %11
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %26
%46 = load i64, i64* %10
%47 = call i32 @clReleaseContext(i64 %46)
%48 = load i32*, i32** %12
%49 = call i32 @free(i32* %48)
store i32 -1, i32* %5
br label %222
50: ; preds = %26
%51 = load i32*, i32** %12
%52 = call i32 @free(i32* %51)
%53 = load i64, i64* %10
%54 = load i32, i32* @CL_MEM_READ_ONLY
%55 = load i32, i32* @CL_MEM_COPY_HOST_PTR
%56 = or i32 %54, %55
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = mul i64 4, %58
%60 = trunc i64 %59 to i32
%61 = load i8*, i8** %8
%62 = call i64 @clCreateBuffer(i64 %53, i32 %56, i32 %60, i8* %61, i32* null)
%63 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
store i64 %62, i64* %63
%64 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%65 = load i64, i64* %64
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %50
%68 = load i64, i64* %11
%69 = call i32 @clReleaseCommandQueue(i64 %68)
%70 = load i64, i64* %10
%71 = call i32 @clReleaseContext(i64 %70)
store i32 -1, i32* %5
br label %222
72: ; preds = %50
%73 = load i64, i64* %10
%74 = load i32, i32* @CL_MEM_READ_WRITE
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = mul i64 4, %76
%78 = trunc i64 %77 to i32
%79 = call i64 @clCreateBuffer(i64 %73, i32 %74, i32 %78, i8* null, i32* null)
%80 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
store i64 %79, i64* %80
%81 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%82 = load i64, i64* %81
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %72
%85 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%86 = call i32 @delete_memobjs(i64* %85, i32 1)
%87 = load i64, i64* %11
%88 = call i32 @clReleaseCommandQueue(i64 %87)
%89 = load i64, i64* %10
%90 = call i32 @clReleaseContext(i64 %89)
store i32 -1, i32* %5
br label %222
91: ; preds = %72
%92 = load i64, i64* %10
%93 = call i64 @clCreateProgramWithSource(i64 %92, i32 1, i8** %6, i32* null, i32* null)
store i64 %93, i64* %13
%94 = load i64, i64* %13
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %91
%97 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%98 = call i32 @delete_memobjs(i64* %97, i32 2)
%99 = load i64, i64* %11
%100 = call i32 @clReleaseCommandQueue(i64 %99)
%101 = load i64, i64* %10
%102 = call i32 @clReleaseContext(i64 %101)
store i32 -1, i32* %5
br label %222
103: ; preds = %91
%104 = load i64, i64* %13
%105 = call i32 @clBuildProgram(i64 %104, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %105, i32* %19
%106 = load i32, i32* %19
%107 = load i32, i32* @CL_SUCCESS
%108 = icmp ne i32 %106, %107
br i1 %108, label %109, label %118
109: ; preds = %103
%110 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%111 = call i32 @delete_memobjs(i64* %110, i32 2)
%112 = load i64, i64* %13
%113 = call i32 @clReleaseProgram(i64 %112)
%114 = load i64, i64* %11
%115 = call i32 @clReleaseCommandQueue(i64 %114)
%116 = load i64, i64* %10
%117 = call i32 @clReleaseContext(i64 %116)
store i32 -1, i32* %5
br label %222
118: ; preds = %103
%119 = load i64, i64* %13
%120 = call i64 @clCreateKernel(i64 %119, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* null)
store i64 %120, i64* %14
%121 = load i64, i64* %14
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %132
123: ; preds = %118
%124 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%125 = call i32 @delete_memobjs(i64* %124, i32 2)
%126 = load i64, i64* %13
%127 = call i32 @clReleaseProgram(i64 %126)
%128 = load i64, i64* %11
%129 = call i32 @clReleaseCommandQueue(i64 %128)
%130 = load i64, i64* %10
%131 = call i32 @clReleaseContext(i64 %130)
store i32 -1, i32* %5
br label %222
132: ; preds = %118
%133 = load i64, i64* %14
%134 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%135 = bitcast i64* %134 to i8*
%136 = call i32 @clSetKernelArg(i64 %133, i32 0, i32 8, i8* %135)
store i32 %136, i32* %19
%137 = load i64, i64* %14
%138 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%139 = bitcast i64* %138 to i8*
%140 = call i32 @clSetKernelArg(i64 %137, i32 1, i32 8, i8* %139)
%141 = load i32, i32* %19
%142 = or i32 %141, %140
store i32 %142, i32* %19
%143 = load i64, i64* %14
%144 = bitcast float* %20 to i8*
%145 = call i32 @clSetKernelArg(i64 %143, i32 2, i32 4, i8* %144)
%146 = load i32, i32* %19
%147 = or i32 %146, %145
store i32 %147, i32* %19
%148 = load i32, i32* %19
%149 = load i32, i32* @CL_SUCCESS
%150 = icmp ne i32 %148, %149
br i1 %150, label %151, label %162
151: ; preds = %132
%152 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%153 = call i32 @delete_memobjs(i64* %152, i32 2)
%154 = load i64, i64* %14
%155 = call i32 @clReleaseKernel(i64 %154)
%156 = load i64, i64* %13
%157 = call i32 @clReleaseProgram(i64 %156)
%158 = load i64, i64* %11
%159 = call i32 @clReleaseCommandQueue(i64 %158)
%160 = load i64, i64* %10
%161 = call i32 @clReleaseContext(i64 %160)
store i32 -1, i32* %5
br label %222
162: ; preds = %132
%163 = load i32, i32* %7
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [1 x i64], [1 x i64]* %16, i64 0, i64 0
store i64 %164, i64* %165
%166 = getelementptr inbounds [1 x i64], [1 x i64]* %17, i64 0, i64 0
store i64 2, i64* %166
%167 = load i64, i64* %11
%168 = load i64, i64* %14
%169 = getelementptr inbounds [1 x i64], [1 x i64]* %16, i64 0, i64 0
%170 = getelementptr inbounds [1 x i64], [1 x i64]* %17, i64 0, i64 0
%171 = call i32 @clEnqueueNDRangeKernel(i64 %167, i64 %168, i32 1, i32* null, i64* %169, i64* %170, i32 0, i32* null, i32* null)
store i32 %171, i32* %19
%172 = load i32, i32* %19
%173 = load i32, i32* @CL_SUCCESS
%174 = icmp ne i32 %172, %173
br i1 %174, label %175, label %186
175: ; preds = %162
%176 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%177 = call i32 @delete_memobjs(i64* %176, i32 2)
%178 = load i64, i64* %14
%179 = call i32 @clReleaseKernel(i64 %178)
%180 = load i64, i64* %13
%181 = call i32 @clReleaseProgram(i64 %180)
%182 = load i64, i64* %11
%183 = call i32 @clReleaseCommandQueue(i64 %182)
%184 = load i64, i64* %10
%185 = call i32 @clReleaseContext(i64 %184)
store i32 -1, i32* %5
br label %222
186: ; preds = %162
%187 = load i64, i64* %11
%188 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 1
%189 = load i64, i64* %188
%190 = load i32, i32* @CL_TRUE
%191 = load i32, i32* %7
%192 = sext i32 %191 to i64
%193 = mul i64 %192, 4
%194 = trunc i64 %193 to i32
%195 = load i8*, i8** %9
%196 = call i32 @clEnqueueReadBuffer(i64 %187, i64 %189, i32 %190, i32 0, i32 %194, i8* %195, i32 0, i32* null, i32* null)
store i32 %196, i32* %19
%197 = load i32, i32* %19
%198 = load i32, i32* @CL_SUCCESS
%199 = icmp ne i32 %197, %198
br i1 %199, label %200, label %211
200: ; preds = %186
%201 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%202 = call i32 @delete_memobjs(i64* %201, i32 2)
%203 = load i64, i64* %14
%204 = call i32 @clReleaseKernel(i64 %203)
%205 = load i64, i64* %13
%206 = call i32 @clReleaseProgram(i64 %205)
%207 = load i64, i64* %11
%208 = call i32 @clReleaseCommandQueue(i64 %207)
%209 = load i64, i64* %10
%210 = call i32 @clReleaseContext(i64 %209)
store i32 -1, i32* %5
br label %222
211: ; preds = %186
%212 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%213 = call i32 @delete_memobjs(i64* %212, i32 2)
%214 = load i64, i64* %14
%215 = call i32 @clReleaseKernel(i64 %214)
%216 = load i64, i64* %13
%217 = call i32 @clReleaseProgram(i64 %216)
%218 = load i64, i64* %11
%219 = call i32 @clReleaseCommandQueue(i64 %218)
%220 = load i64, i64* %10
%221 = call i32 @clReleaseContext(i64 %220)
store i32 0, i32* %5
br label %222
222: ; preds = %211, %200, %175, %151, %123, %109, %96, %84, %67, %45, %25
%223 = load i32, i32* %5
ret i32 %223
}

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