#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 int cl_int;

/* Variables and functions */
int CL_SUCCESS;
int /*<<< orphan*/ EXIT_FAILURE;
char *err_code(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
void check_error(cl_int err, const char *operation, char *filename, int line) {
  if (err != CL_SUCCESS) {
    fprintf(stderr, "Error during operation '%s', ", operation);
    fprintf(stderr, "in '%s' on line %d\n", filename, line);
    fprintf(stderr, "Error code was \"%s\" (%d)\n", err_code(err), err);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<check_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
je     11ca <check_error+0x9a>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <err_code@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
mov    -0x4(%rbp),%ecx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_error>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e92(%rip),%rax
cmp    %edi,(%rax)
jne    114d <check_error+0x1d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%rdx
mov    %edi,%ebx
mov    0x2e81(%rip),%r15
mov    (%r15),%edi
lea    0xe97(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xea4(%rip),%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%ebp
mov    %ebx,%edi
call   1030 <err_code@plt>
lea    0xe9a(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"Error during operation '%s', \00"
@.str.1 = [20 x i8] c"in '%s' on line %d\0A\00"
@.str.2 = [26 x i8] c"Error code was \22%s\22 (%d)\0A\00"
@EXIT_FAILURE = global i32 0
define void @check_error(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %5
%10 = load i32, i32* @CL_SUCCESS
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %4
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %6
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %7
%18 = load i32, i32* %8
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32, i32* @stderr
%21 = load i32, i32* %5
%22 = call i8* @err_code(i32 %21)
%23 = load i32, i32* %5
%24 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %4
ret void
}

LLVM IR (-O2):
@CL_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [30 x i8] c"Error during operation '%s', \00"
@.str.1 = [20 x i8] c"in '%s' on line %d\0A\00"
@.str.2 = [26 x i8] c"Error code was \22%s\22 (%d)\0A\00"
@EXIT_FAILURE = global i32 0
define void @check_error(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = load i32, i32* @CL_SUCCESS
%6 = icmp eq i32 %5, %0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %2, i32 %3)
%12 = load i32, i32* @stderr
%13 = tail call i8* @err_code(i32 %0)
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 %0)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %4
ret void
}