#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 */
scalar_t__ CL_SUCCESS;
int /*<<< orphan*/ clu_ErrorString(scalar_t__);
int /*<<< orphan*/ clu_Exit(char *, char const *, int, char const *, scalar_t__,
                            int /*<<< orphan*/);
void clu_CheckErrorInternal(cl_int err_code, const char *msg, const char *file,
                            int line) {
  if (err_code != CL_SUCCESS) {
    clu_Exit("ERROR[%s:%d] %s (%d:%s)\n", file, line, msg, err_code,
             clu_ErrorString(err_code));
  }
}


x86 assembly (clang, -O0):
<clu_CheckErrorInternal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     1190 <clu_CheckErrorInternal+0x70>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <clu_ErrorString@plt>
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    %eax,%r9d
lea    0xe75(%rip),%rdi
call   1030 <clu_Exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clu_CheckErrorInternal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2eb2(%rip),%rax
cmp    %rdi,(%rax)
jne    113e <clu_CheckErrorInternal+0x1e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <clu_ErrorString@plt>
lea    0xeaa(%rip),%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    %r15,%rcx
mov    %rbx,%r8
mov    %eax,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <clu_Exit@plt>

LLVM IR (-O0):
@CL_SUCCESS = global i64 0
@.str = [25 x i8] c"ERROR[%s:%d] %s (%d:%s)\0A\00"
define void @clu_CheckErrorInternal(i64 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i64 %0, i64* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i64, i64* %5
%10 = load i64, i64* @CL_SUCCESS
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %4
%13 = load i8*, i8** %7
%14 = load i32, i32* %8
%15 = load i8*, i8** %6
%16 = load i64, i64* %5
%17 = load i64, i64* %5
%18 = call i32 @clu_ErrorString(i64 %17)
%19 = call i32 @clu_Exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14, i8* %15, i64 %16, i32 %18)
br label %20
20: ; preds = %12, %4
ret void
}

LLVM IR (-O2):
@CL_SUCCESS = global i64 0
@.str = [25 x i8] c"ERROR[%s:%d] %s (%d:%s)\0A\00"
define void @clu_CheckErrorInternal(i64 %0, i8* %1, i8* %2, i32 %3) {
%5 = load i64, i64* @CL_SUCCESS
%6 = icmp eq i64 %5, %0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @clu_ErrorString(i64 %0)
%9 = tail call i32 @clu_Exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3, i8* %1, i64 %0, i32 %8)
br label %10
10: ; preds = %7, %4
ret void
}