#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 double cl_ulong;
typedef scalar_t__ cl_int;
typedef int /*<<< orphan*/ cl_event;

/* Variables and functions */
int /*<<< orphan*/ CL_PROFILING_COMMAND_END;
int /*<<< orphan*/ CL_PROFILING_COMMAND_START;
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ clGetEventProfilingInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   double *, int /*<<< orphan*/ *);
scalar_t__ clReleaseEvent(int /*<<< orphan*/);
scalar_t__ clWaitForEvents(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
char *loclGetErrCode(scalar_t__);
int /*<<< orphan*/ stderr;
double loclGetEventExecTimeAndRelease(cl_event evfirst, cl_event evlast) {
  cl_ulong ev_t_start, ev_t_finish;
  {
    cl_int err = clWaitForEvents(1, &evlast);
    if (CL_SUCCESS != err) {
      fprintf(stderr, "OpenCL error in file '%s' in line %i : %s.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/"
              "common/loclutil.h",
              277, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  {
    cl_int err = clGetEventProfilingInfo(evfirst, CL_PROFILING_COMMAND_START,
                                         sizeof(cl_ulong), &ev_t_start, NULL);
    if (CL_SUCCESS != err) {
      fprintf(stderr, "OpenCL error in file '%s' in line %i : %s.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/"
              "common/loclutil.h",
              278, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  {
    cl_int err = clGetEventProfilingInfo(evlast, CL_PROFILING_COMMAND_END,
                                         sizeof(cl_ulong), &ev_t_finish, NULL);
    if (CL_SUCCESS != err) {
      fprintf(stderr, "OpenCL error in file '%s' in line %i : %s.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/"
              "common/loclutil.h",
              279, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  double time = (ev_t_finish - ev_t_start) / 1000000000.0;
  {
    cl_int err = clReleaseEvent(evfirst);
    if (CL_SUCCESS != err) {
      fprintf(stderr, "OpenCL error in file '%s' in line %i : %s.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/"
              "common/loclutil.h",
              281, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  {
    cl_int err = clReleaseEvent(evlast);
    if (CL_SUCCESS != err) {
      fprintf(stderr, "OpenCL error in file '%s' in line %i : %s.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/"
              "common/loclutil.h",
              282, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  return time;
}


x86 assembly (clang, -O0):
<loclGetEventExecTimeAndRelease>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
call   1060 <clWaitForEvents@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
je     11d5 <loclGetEventExecTimeAndRelease+0x75>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%r8
lea    0xe52(%rip),%rsi
lea    0xe77(%rip),%rdx
mov    $0x115,%ecx
call   1040 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%edx
lea    -0x10(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <clGetEventProfilingInfo@plt>
mov    %rax,-0x28(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
cmp    -0x28(%rbp),%rax
je     124d <loclGetEventExecTimeAndRelease+0xed>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%r8
lea    0xdda(%rip),%rsi
lea    0xdff(%rip),%rdx
mov    $0x116,%ecx
call   1040 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
mov    $0x8,%edx
lea    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <clGetEventProfilingInfo@plt>
mov    %rax,-0x30(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%rax
cmp    -0x30(%rbp),%rax
je     12c5 <loclGetEventExecTimeAndRelease+0x165>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%r8
lea    0xd62(%rip),%rsi
lea    0xd87(%rip),%rdx
mov    $0x117,%ecx
call   1040 <fprintf@plt>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xd29(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <clReleaseEvent@plt>
mov    %rax,-0x40(%rbp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%rax
cmp    -0x40(%rbp),%rax
je     1341 <loclGetEventExecTimeAndRelease+0x1e1>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x40(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%r8
lea    0xce6(%rip),%rsi
lea    0xd0b(%rip),%rdx
mov    $0x119,%ecx
call   1040 <fprintf@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
call   1050 <clReleaseEvent@plt>
mov    %rax,-0x48(%rbp)
mov    0x2c6c(%rip),%rax
mov    (%rax),%rax
cmp    -0x48(%rbp),%rax
je     13a2 <loclGetEventExecTimeAndRelease+0x242>
mov    0x2c70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x48(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%r8
lea    0xc85(%rip),%rsi
lea    0xcaa(%rip),%rdx
mov    $0x11a,%ecx
call   1040 <fprintf@plt>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movsd  -0x38(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loclGetEventExecTimeAndRelease>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
mov    %esi,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
call   1060 <clWaitForEvents@plt>
mov    0x2e3d(%rip),%r14
cmp    %rax,(%r14)
jne    1230 <loclGetEventExecTimeAndRelease+0xd0>
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rcx
mov    %ebx,%edi
mov    $0x8,%edx
xor    %r8d,%r8d
call   1030 <clGetEventProfilingInfo@plt>
cmp    %rax,(%r14)
jne    125b <loclGetEventExecTimeAndRelease+0xfb>
mov    0x4(%rsp),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rcx
mov    $0x8,%edx
xor    %r8d,%r8d
call   1030 <clGetEventProfilingInfo@plt>
cmp    %rax,(%r14)
jne    1283 <loclGetEventExecTimeAndRelease+0x123>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1050 <clReleaseEvent@plt>
cmp    %rax,(%r14)
jne    12ab <loclGetEventExecTimeAndRelease+0x14b>
mov    0x4(%rsp),%edi
call   1050 <clReleaseEvent@plt>
cmp    %rax,(%r14)
jne    12d3 <loclGetEventExecTimeAndRelease+0x173>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
divsd  0xdd8(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2da1(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xdc0(%rip),%rsi
lea    0xde5(%rip),%rdx
mov    %ebx,%edi
mov    $0x115,%ecx
jmp    12f9 <loclGetEventExecTimeAndRelease+0x199>
mov    0x2d76(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd95(%rip),%rsi
lea    0xdba(%rip),%rdx
mov    %ebx,%edi
mov    $0x116,%ecx
jmp    12f9 <loclGetEventExecTimeAndRelease+0x199>
mov    0x2d4e(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd6d(%rip),%rsi
lea    0xd92(%rip),%rdx
mov    %ebx,%edi
mov    $0x117,%ecx
jmp    12f9 <loclGetEventExecTimeAndRelease+0x199>
mov    0x2d26(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd45(%rip),%rsi
lea    0xd6a(%rip),%rdx
mov    %ebx,%edi
mov    $0x119,%ecx
jmp    12f9 <loclGetEventExecTimeAndRelease+0x199>
mov    0x2cfe(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd1d(%rip),%rsi
lea    0xd42(%rip),%rdx
mov    %ebx,%edi
mov    $0x11a,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i64 0
@stderr = global i32 0
@.str = [44 x i8] c"OpenCL error in file '%s' in line %i : %s.\0A\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/common/loclutil.h\00"
@EXIT_FAILURE = global i32 0
@CL_PROFILING_COMMAND_START = global i32 0
@CL_PROFILING_COMMAND_END = global i32 0
define double @loclGetEventExecTimeAndRelease(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
%11 = alloca i64
%12 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
%13 = call i64 @clWaitForEvents(i32 1, i32* %4)
store i64 %13, i64* %7
%14 = load i64, i64* @CL_SUCCESS
%15 = load i64, i64* %7
%16 = icmp ne i64 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i64, i64* %7
%20 = call i8* @loclGetErrCode(i64 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 277, i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = load i32, i32* %3
%26 = load i32, i32* @CL_PROFILING_COMMAND_START
%27 = call i64 @clGetEventProfilingInfo(i32 %25, i32 %26, i32 8, double* %5, i32* null)
store i64 %27, i64* %8
%28 = load i64, i64* @CL_SUCCESS
%29 = load i64, i64* %8
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %38
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i64, i64* %8
%34 = call i8* @loclGetErrCode(i64 %33)
%35 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 278, i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %24
%39 = load i32, i32* %4
%40 = load i32, i32* @CL_PROFILING_COMMAND_END
%41 = call i64 @clGetEventProfilingInfo(i32 %39, i32 %40, i32 8, double* %6, i32* null)
store i64 %41, i64* %9
%42 = load i64, i64* @CL_SUCCESS
%43 = load i64, i64* %9
%44 = icmp ne i64 %42, %43
br i1 %44, label %45, label %52
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i64, i64* %9
%48 = call i8* @loclGetErrCode(i64 %47)
%49 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 279, i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %38
%53 = load double, double* %6
%54 = load double, double* %5
%55 = fsub double %53, %54
%56 = fdiv double %55, 1.000000e+09
store double %56, double* %10
%57 = load i32, i32* %3
%58 = call i64 @clReleaseEvent(i32 %57)
store i64 %58, i64* %11
%59 = load i64, i64* @CL_SUCCESS
%60 = load i64, i64* %11
%61 = icmp ne i64 %59, %60
br i1 %61, label %62, label %69
62: ; preds = %52
%63 = load i32, i32* @stderr
%64 = load i64, i64* %11
%65 = call i8* @loclGetErrCode(i64 %64)
%66 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 281, i8* %65)
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %52
%70 = load i32, i32* %4
%71 = call i64 @clReleaseEvent(i32 %70)
store i64 %71, i64* %12
%72 = load i64, i64* @CL_SUCCESS
%73 = load i64, i64* %12
%74 = icmp ne i64 %72, %73
br i1 %74, label %75, label %82
75: ; preds = %69
%76 = load i32, i32* @stderr
%77 = load i64, i64* %12
%78 = call i8* @loclGetErrCode(i64 %77)
%79 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 282, i8* %78)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %69
%83 = load double, double* %10
ret double %83
}

LLVM IR (-O2):
@CL_SUCCESS = global i64 0
@stderr = global i32 0
@.str = [44 x i8] c"OpenCL error in file '%s' in line %i : %s.\0A\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ekondis/gpumembench/refs/heads/master/common/loclutil.h\00"
@EXIT_FAILURE = global i32 0
@CL_PROFILING_COMMAND_START = global i32 0
@CL_PROFILING_COMMAND_END = global i32 0
define double @loclGetEventExecTimeAndRelease(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 %1, i32* %3
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = call i64 @clWaitForEvents(i32 1, i32* %3)
%9 = load i64, i64* @CL_SUCCESS
%10 = icmp eq i64 %9, %8
br i1 %10, label %17, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i8* @loclGetErrCode(i64 %8)
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 277, i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = load i32, i32* @CL_PROFILING_COMMAND_START
%19 = call i64 @clGetEventProfilingInfo(i32 %0, i32 %18, i32 8, double* %4, i32* null)
%20 = load i64, i64* @CL_SUCCESS
%21 = icmp eq i64 %20, %19
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = call i8* @loclGetErrCode(i64 %19)
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 278, i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %17
%29 = load i32, i32* %3
%30 = load i32, i32* @CL_PROFILING_COMMAND_END
%31 = call i64 @clGetEventProfilingInfo(i32 %29, i32 %30, i32 8, double* %5, i32* null)
%32 = load i64, i64* @CL_SUCCESS
%33 = icmp eq i64 %32, %31
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = call i8* @loclGetErrCode(i64 %31)
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 279, i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %28
%41 = load double, double* %5
%42 = load double, double* %4
%43 = call i64 @clReleaseEvent(i32 %0)
%44 = load i64, i64* @CL_SUCCESS
%45 = icmp eq i64 %44, %43
br i1 %45, label %52, label %46
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i8* @loclGetErrCode(i64 %43)
%49 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 281, i8* %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %40
%53 = load i32, i32* %3
%54 = call i64 @clReleaseEvent(i32 %53)
%55 = load i64, i64* @CL_SUCCESS
%56 = icmp eq i64 %55, %54
br i1 %56, label %63, label %57
57: ; preds = %52
%58 = load i32, i32* @stderr
%59 = call i8* @loclGetErrCode(i64 %54)
%60 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 282, i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %52
%64 = fsub double %41, %42
%65 = fdiv double %64, 1.000000e+09
ret double %65
}