#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_int;

/* Variables and functions */
#define CL_BUILD_PROGRAM_FAILURE 141
#define CL_COMPILER_NOT_AVAILABLE 140
#define CL_DEVICE_NOT_AVAILABLE 139
#define CL_DEVICE_NOT_FOUND 138
#define CL_INVALID_BINARY 137
#define CL_INVALID_BUILD_OPTIONS 136
#define CL_INVALID_CONTEXT 135
#define CL_INVALID_DEVICE 134
#define CL_INVALID_DEVICE_TYPE 133
#define CL_INVALID_OPERATION 132
#define CL_INVALID_PLATFORM 131
#define CL_INVALID_PROGRAM 130
#define CL_INVALID_VALUE 129
#define CL_OUT_OF_HOST_MEMORY 128
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ exit(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void checkErr(char *func, cl_int err) {
  if (err != CL_SUCCESS) {
    fprintf(stderr, "%s(): ", func);
    switch (err) {
    case CL_BUILD_PROGRAM_FAILURE:
      fprintf(stderr, "CL_BUILD_PROGRAM_FAILURE");
      break;
    case CL_COMPILER_NOT_AVAILABLE:
      fprintf(stderr, "CL_COMPILER_NOT_AVAILABLE");
      break;
    case CL_DEVICE_NOT_AVAILABLE:
      fprintf(stderr, "CL_DEVICE_NOT_AVAILABLE");
      break;
    case CL_DEVICE_NOT_FOUND:
      fprintf(stderr, "CL_DEVICE_NOT_FOUND");
      break;
    case CL_INVALID_BINARY:
      fprintf(stderr, "CL_INVALID_BINARY");
      break;
    case CL_INVALID_BUILD_OPTIONS:
      fprintf(stderr, "CL_INVALID_BUILD_OPTIONS");
      break;
    case CL_INVALID_CONTEXT:
      fprintf(stderr, "CL_INVALID_CONTEXT");
      break;
    case CL_INVALID_DEVICE:
      fprintf(stderr, "CL_INVALID_DEVICE");
      break;
    case CL_INVALID_DEVICE_TYPE:
      fprintf(stderr, "CL_INVALID_DEVICE_TYPE");
      break;
    case CL_INVALID_OPERATION:
      fprintf(stderr, "CL_INVALID_OPERATION");
      break;
    case CL_INVALID_PLATFORM:
      fprintf(stderr, "CL_INVALID_PLATFORM");
      break;
    case CL_INVALID_PROGRAM:
      fprintf(stderr, "CL_INVALID_PROGRAM");
      break;
    case CL_INVALID_VALUE:
      fprintf(stderr, "CL_INVALID_VALUE");
      break;
    case CL_OUT_OF_HOST_MEMORY:
      fprintf(stderr, "CL_OUT_OF_HOST_MEMORY");
      break;
    default:
      fprintf(stderr, "Unknown error code: %d", (int)err);
      break;
    }
    fprintf(stderr, "\n");
    exit(err);
  }
}


x86 assembly (clang, -O0):
<checkErr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%rax
je     134e <checkErr+0x22e>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xee0(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffff80,%rax
mov    %rax,-0x18(%rbp)
sub    $0xd,%rax
ja     1311 <checkErr+0x1f1>
mov    -0x18(%rbp),%rax
lea    0xe80(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132e <checkErr+0x20e>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkErr>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rax
cmp    %rsi,(%rax)
jne    1138 <checkErr+0x18>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    0x2e9b(%rip),%r14
mov    (%r14),%edi
lea    0xee9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x80(%rbx),%rax
cmp    $0xd,%rax
ja     117f <checkErr+0x5f>
lea    0xe99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    (%r14),%edi
lea    0xfd8(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xfdf(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    123e <checkErr+0x11e>
mov    (%r14),%edi
lea    0xfa0(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xf7e(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xf5b(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xf3a(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xf17(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xef9(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xeda(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xeb5(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xe97(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xe77(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xe53(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xe2d(%rip),%rsi
jmp    1237 <checkErr+0x117>
mov    (%r14),%edi
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0xf37(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i64 0
@stderr = global i32 0
@.str = [7 x i8] c"%s(): \00"
@.str.1 = [25 x i8] c"CL_BUILD_PROGRAM_FAILURE\00"
@.str.2 = [26 x i8] c"CL_COMPILER_NOT_AVAILABLE\00"
@.str.3 = [24 x i8] c"CL_DEVICE_NOT_AVAILABLE\00"
@.str.4 = [20 x i8] c"CL_DEVICE_NOT_FOUND\00"
@.str.5 = [18 x i8] c"CL_INVALID_BINARY\00"
@.str.6 = [25 x i8] c"CL_INVALID_BUILD_OPTIONS\00"
@.str.7 = [19 x i8] c"CL_INVALID_CONTEXT\00"
@.str.8 = [18 x i8] c"CL_INVALID_DEVICE\00"
@.str.9 = [23 x i8] c"CL_INVALID_DEVICE_TYPE\00"
@.str.10 = [21 x i8] c"CL_INVALID_OPERATION\00"
@.str.11 = [20 x i8] c"CL_INVALID_PLATFORM\00"
@.str.12 = [19 x i8] c"CL_INVALID_PROGRAM\00"
@.str.13 = [17 x i8] c"CL_INVALID_VALUE\00"
@.str.14 = [22 x i8] c"CL_OUT_OF_HOST_MEMORY\00"
@.str.15 = [23 x i8] c"Unknown error code: %d\00"
@.str.16 = [2 x i8] c"\0A\00"
define void @checkErr(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = load i64, i64* @CL_SUCCESS
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %65
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %3
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i64, i64* %4
switch i64 %12, label %55 [
i64 141, label %13
i64 140, label %16
i64 139, label %19
i64 138, label %22
i64 137, label %25
i64 136, label %28
i64 135, label %31
i64 134, label %34
i64 133, label %37
i64 132, label %40
i64 131, label %43
i64 130, label %46
i64 129, label %49
i64 128, label %52
]
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %60
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %60
19: ; preds = %8
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %60
22: ; preds = %8
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %60
25: ; preds = %8
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %60
28: ; preds = %8
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %60
31: ; preds = %8
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %60
34: ; preds = %8
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %60
37: ; preds = %8
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %60
40: ; preds = %8
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %60
43: ; preds = %8
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
br label %60
46: ; preds = %8
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %60
49: ; preds = %8
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
br label %60
52: ; preds = %8
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
br label %60
55: ; preds = %8
%56 = load i32, i32* @stderr
%57 = load i64, i64* %4
%58 = trunc i64 %57 to i32
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %55, %52, %49, %46, %43, %40, %37, %34, %31, %28, %25, %22, %19, %16, %13
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%63 = load i64, i64* %4
%64 = call i32 @exit(i64 %63)
unreachable
65: ; preds = %2
ret void
}

LLVM IR (-O2):
@CL_SUCCESS = global i64 0
@stderr = global i32 0
@.str = [7 x i8] c"%s(): \00"
@.str.1 = [25 x i8] c"CL_BUILD_PROGRAM_FAILURE\00"
@.str.2 = [26 x i8] c"CL_COMPILER_NOT_AVAILABLE\00"
@.str.3 = [24 x i8] c"CL_DEVICE_NOT_AVAILABLE\00"
@.str.4 = [20 x i8] c"CL_DEVICE_NOT_FOUND\00"
@.str.5 = [18 x i8] c"CL_INVALID_BINARY\00"
@.str.6 = [25 x i8] c"CL_INVALID_BUILD_OPTIONS\00"
@.str.7 = [19 x i8] c"CL_INVALID_CONTEXT\00"
@.str.8 = [18 x i8] c"CL_INVALID_DEVICE\00"
@.str.9 = [23 x i8] c"CL_INVALID_DEVICE_TYPE\00"
@.str.10 = [21 x i8] c"CL_INVALID_OPERATION\00"
@.str.11 = [20 x i8] c"CL_INVALID_PLATFORM\00"
@.str.12 = [19 x i8] c"CL_INVALID_PROGRAM\00"
@.str.13 = [17 x i8] c"CL_INVALID_VALUE\00"
@.str.14 = [22 x i8] c"CL_OUT_OF_HOST_MEMORY\00"
@.str.15 = [23 x i8] c"Unknown error code: %d\00"
@.str.16 = [2 x i8] c"\0A\00"
define void @checkErr(i8* %0, i64 %1) {
%3 = load i64, i64* @CL_SUCCESS
%4 = icmp eq i64 %3, %1
br i1 %4, label %58, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
switch i64 %1, label %50 [
i64 141, label %8
i64 140, label %11
i64 139, label %14
i64 138, label %17
i64 137, label %20
i64 136, label %23
i64 135, label %26
i64 134, label %29
i64 133, label %32
i64 132, label %35
i64 131, label %38
i64 130, label %41
i64 129, label %44
i64 128, label %47
]
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %54
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %54
14: ; preds = %5
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %54
17: ; preds = %5
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %54
20: ; preds = %5
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %54
23: ; preds = %5
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %54
26: ; preds = %5
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %54
29: ; preds = %5
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %54
32: ; preds = %5
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %54
35: ; preds = %5
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %54
38: ; preds = %5
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
br label %54
41: ; preds = %5
%42 = load i32, i32* @stderr
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %54
44: ; preds = %5
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
br label %54
47: ; preds = %5
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
br label %54
50: ; preds = %5
%51 = load i32, i32* @stderr
%52 = trunc i64 %1 to i32
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%57 = tail call i32 @exit(i64 %1)
unreachable
58: ; preds = %2
ret void
}