#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 ev) {
  cl_ulong ev_t_start, ev_t_finish;
  {
    cl_int err = clWaitForEvents(1, &ev);
    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",
              266, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  {
    cl_int err = clGetEventProfilingInfo(ev, 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",
              267, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  {
    cl_int err = clGetEventProfilingInfo(ev, 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",
              268, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  double time = (ev_t_finish - ev_t_start) / 1000000000.0;
  {
    cl_int err = clReleaseEvent(ev);
    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",
              270, loclGetErrCode(err));
      exit(EXIT_FAILURE);
    }
  };
  return time;
}


x86 assembly (clang, -O0):
<loclGetEventExecTimeAndRelease>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1,%edi
lea    -0x4(%rbp),%rsi
call   1060 <clWaitForEvents@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
je     11d2 <loclGetEventExecTimeAndRelease+0x72>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%r8
lea    0xe55(%rip),%rsi
lea    0xe7a(%rip),%rdx
mov    $0x10a,%ecx
call   1040 <fprintf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2df4(%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    0x2dc4(%rip),%rax
mov    (%rax),%rax
cmp    -0x28(%rbp),%rax
je     124a <loclGetEventExecTimeAndRelease+0xea>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%r8
lea    0xddd(%rip),%rsi
lea    0xe02(%rip),%rdx
mov    $0x10b,%ecx
call   1040 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2d94(%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    0x2d4c(%rip),%rax
mov    (%rax),%rax
cmp    -0x30(%rbp),%rax
je     12c2 <loclGetEventExecTimeAndRelease+0x162>
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x4c(%rbp),%edi
mov    %rax,%r8
lea    0xd65(%rip),%rsi
lea    0xd8a(%rip),%rdx
mov    $0x10c,%ecx
call   1040 <fprintf@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xd2c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <clReleaseEvent@plt>
mov    %rax,-0x40(%rbp)
mov    0x2cd0(%rip),%rax
mov    (%rax),%rax
cmp    -0x40(%rbp),%rax
je     133e <loclGetEventExecTimeAndRelease+0x1de>
mov    0x2cd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
call   1080 <loclGetErrCode@plt>
mov    -0x50(%rbp),%edi
mov    %rax,%r8
lea    0xce9(%rip),%rsi
lea    0xd0e(%rip),%rdx
mov    $0x10e,%ecx
call   1040 <fprintf@plt>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loclGetEventExecTimeAndRelease>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1060 <clWaitForEvents@plt>
mov    0x2e41(%rip),%rbx
cmp    %rax,(%rbx)
jne    121c <loclGetEventExecTimeAndRelease+0xbc>
mov    0xc(%rsp),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0x28(%rsp),%rcx
mov    $0x8,%edx
xor    %r8d,%r8d
call   1030 <clGetEventProfilingInfo@plt>
cmp    %rax,(%rbx)
jne    1244 <loclGetEventExecTimeAndRelease+0xe4>
mov    0xc(%rsp),%edi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rcx
mov    $0x8,%edx
xor    %r8d,%r8d
call   1030 <clGetEventProfilingInfo@plt>
cmp    %rax,(%rbx)
jne    126c <loclGetEventExecTimeAndRelease+0x10c>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%edi
call   1050 <clReleaseEvent@plt>
cmp    %rax,(%rbx)
jne    1294 <loclGetEventExecTimeAndRelease+0x134>
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
divsd  0xdea(%rip),%xmm0
add    $0x30,%rsp
pop    %rbx
ret
mov    0x2db5(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xdd4(%rip),%rsi
lea    0xdf9(%rip),%rdx
mov    %ebx,%edi
mov    $0x10a,%ecx
jmp    12ba <loclGetEventExecTimeAndRelease+0x15a>
mov    0x2d8d(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xdac(%rip),%rsi
lea    0xdd1(%rip),%rdx
mov    %ebx,%edi
mov    $0x10b,%ecx
jmp    12ba <loclGetEventExecTimeAndRelease+0x15a>
mov    0x2d65(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd84(%rip),%rsi
lea    0xda9(%rip),%rdx
mov    %ebx,%edi
mov    $0x10c,%ecx
jmp    12ba <loclGetEventExecTimeAndRelease+0x15a>
mov    0x2d3d(%rip),%rcx
mov    (%rcx),%ebx
mov    %rax,%rdi
call   1080 <loclGetErrCode@plt>
lea    0xd5c(%rip),%rsi
lea    0xd81(%rip),%rdx
mov    %ebx,%edi
mov    $0x10e,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    0x2cff(%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) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca i64
store i32 %0, i32* %2
%10 = call i64 @clWaitForEvents(i32 1, i32* %2)
store i64 %10, i64* %5
%11 = load i64, i64* @CL_SUCCESS
%12 = load i64, i64* %5
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = load i64, i64* %5
%17 = call i8* @loclGetErrCode(i64 %16)
%18 = call i32 @fprintf(i32 %15, 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 266, i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %1
%22 = load i32, i32* %2
%23 = load i32, i32* @CL_PROFILING_COMMAND_START
%24 = call i64 @clGetEventProfilingInfo(i32 %22, i32 %23, i32 8, double* %3, i32* null)
store i64 %24, i64* %6
%25 = load i64, i64* @CL_SUCCESS
%26 = load i64, i64* %6
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = load i64, i64* %6
%31 = call i8* @loclGetErrCode(i64 %30)
%32 = call i32 @fprintf(i32 %29, 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 267, i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %21
%36 = load i32, i32* %2
%37 = load i32, i32* @CL_PROFILING_COMMAND_END
%38 = call i64 @clGetEventProfilingInfo(i32 %36, i32 %37, i32 8, double* %4, i32* null)
store i64 %38, i64* %7
%39 = load i64, i64* @CL_SUCCESS
%40 = load i64, i64* %7
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %49
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i64, i64* %7
%45 = call i8* @loclGetErrCode(i64 %44)
%46 = call i32 @fprintf(i32 %43, 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 268, i8* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %35
%50 = load double, double* %4
%51 = load double, double* %3
%52 = fsub double %50, %51
%53 = fdiv double %52, 1.000000e+09
store double %53, double* %8
%54 = load i32, i32* %2
%55 = call i64 @clReleaseEvent(i32 %54)
store i64 %55, i64* %9
%56 = load i64, i64* @CL_SUCCESS
%57 = load i64, i64* %9
%58 = icmp ne i64 %56, %57
br i1 %58, label %59, label %66
59: ; preds = %49
%60 = load i32, i32* @stderr
%61 = load i64, i64* %9
%62 = call i8* @loclGetErrCode(i64 %61)
%63 = call i32 @fprintf(i32 %60, 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 270, i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %49
%67 = load double, double* %8
ret double %67
}

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) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 %0, i32* %2
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = call i64 @clWaitForEvents(i32 1, i32* %2)
%8 = load i64, i64* @CL_SUCCESS
%9 = icmp eq i64 %8, %7
br i1 %9, label %16, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i8* @loclGetErrCode(i64 %7)
%13 = call i32 @fprintf(i32 %11, 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 266, i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %1
%17 = load i32, i32* %2
%18 = load i32, i32* @CL_PROFILING_COMMAND_START
%19 = call i64 @clGetEventProfilingInfo(i32 %17, i32 %18, i32 8, double* %3, i32* null)
%20 = load i64, i64* @CL_SUCCESS
%21 = icmp eq i64 %20, %19
br i1 %21, label %28, label %22
22: ; preds = %16
%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 267, i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %16
%29 = load i32, i32* %2
%30 = load i32, i32* @CL_PROFILING_COMMAND_END
%31 = call i64 @clGetEventProfilingInfo(i32 %29, i32 %30, i32 8, double* %4, 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 268, i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %28
%41 = load double, double* %4
%42 = load double, double* %3
%43 = load i32, i32* %2
%44 = call i64 @clReleaseEvent(i32 %43)
%45 = load i64, i64* @CL_SUCCESS
%46 = icmp eq i64 %45, %44
br i1 %46, label %53, label %47
47: ; preds = %40
%48 = load i32, i32* @stderr
%49 = call i8* @loclGetErrCode(i64 %44)
%50 = call i32 @fprintf(i32 %48, 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 270, i8* %49)
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %40
%54 = fsub double %41, %42
%55 = fdiv double %54, 1.000000e+09
ret double %55
}