#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 /*<<< orphan*/ cl_int;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *get_error_string(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, ...);
void process_error(cl_int err, const char *function_name) {
  if (function_name != NULL)
    printf("Error calling %s: %s\n", function_name, get_error_string(err));
  else
    printf("Error: %s\n", get_error_string(err));
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<process_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <process_error+0x44>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <get_error_string@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118d <process_error+0x5d>
mov    -0x4(%rbp),%edi
call   1040 <get_error_string@plt>
mov    %rax,%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<process_error>:
push   %rbx
mov    %rsi,%rbx
call   1040 <get_error_string@plt>
test   %rbx,%rbx
jne    1151 <process_error+0x21>
lea    0xed1(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1165 <process_error+0x35>
lea    0xea8(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Error calling %s: %s\0A\00"
@.str.1 = [11 x i8] c"Error: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @process_error(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i32, i32* %3
%10 = call i8* @get_error_string(i32 %9)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %10)
br label %16
12: ; preds = %2
%13 = load i32, i32* %3
%14 = call i8* @get_error_string(i32 %13)
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %7
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"Error calling %s: %s\0A\00"
@.str.1 = [11 x i8] c"Error: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @process_error(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = tail call i8* @get_error_string(i32 %0)
br i1 %3, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %4)
br label %9
7: ; preds = %2
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %9
9: ; preds = %7, %5
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
}