#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;
typedef int /*<<< orphan*/ cl_event;

/* Variables and functions */
scalar_t__ CL_COMPLETE;
scalar_t__ CL_RUNNING;
scalar_t__ CL_SUBMITTED;
int /*<<< orphan*/ printf(char *, ...);
void callback_function(cl_event event, cl_int event_command_exec_status,
                       void *user_data) {
  printf("%s ", (const char *)user_data);
  if (event_command_exec_status == CL_SUBMITTED)
    printf("CL_SUBMITTED\n");
  if (event_command_exec_status == CL_RUNNING)
    printf("CL_RUNNING\n");
  if (event_command_exec_status == CL_COMPLETE)
    printf("CL_COMPLETE\n");
  return;
}


x86 assembly (clang, -O0):
<callback_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%rax
jne    1157 <callback_function+0x47>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <callback_function+0x69>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
jne    119b <callback_function+0x8b>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callback_function>:
push   %rbx
mov    %rsi,%rbx
lea    0xed5(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e9c(%rip),%rax
cmp    %rbx,(%rax)
jne    114d <callback_function+0x2d>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e94(%rip),%rax
cmp    %rbx,(%rax)
jne    1165 <callback_function+0x45>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e64(%rip),%rax
cmp    %rbx,(%rax)
jne    117e <callback_function+0x5e>
lea    0xe8c(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@CL_SUBMITTED = global i64 0
@.str.1 = [14 x i8] c"CL_SUBMITTED\0A\00"
@CL_RUNNING = global i64 0
@.str.2 = [12 x i8] c"CL_RUNNING\0A\00"
@CL_COMPLETE = global i64 0
@.str.3 = [13 x i8] c"CL_COMPLETE\0A\00"
define void @callback_function(i32 %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
store i32 %0, i32* %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i64, i64* %5
%10 = load i64, i64* @CL_SUBMITTED
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %3
%15 = load i64, i64* %5
%16 = load i64, i64* @CL_RUNNING
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load i64, i64* %5
%22 = load i64, i64* @CL_COMPLETE
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@CL_SUBMITTED = global i64 0
@CL_RUNNING = global i64 0
@CL_COMPLETE = global i64 0
@str = [12 x i8] c"CL_COMPLETE\00"
@str.4 = [11 x i8] c"CL_RUNNING\00"
@str.5 = [13 x i8] c"CL_SUBMITTED\00"
define void @callback_function(i32 %0, i64 %1, i8* %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = load i64, i64* @CL_SUBMITTED
%6 = icmp eq i64 %5, %1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %7, %3
%10 = load i64, i64* @CL_RUNNING
%11 = icmp eq i64 %10, %1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i64, i64* @CL_COMPLETE
%16 = icmp eq i64 %15, %1
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
ret void
}