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

/* Variables and functions */
int /*<<< orphan*/ CL_PROGRAM_BUILD_LOG;
int /*<<< orphan*/ clGetProgramBuildInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/, size_t, char *,
                                         size_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ stderr;
void clu_PrintBuildLog(cl_program program, cl_device_id device) {
  size_t log_size;
  clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL,
                        &log_size);
  char *log = (char *)malloc(log_size + 1);
  clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size, log,
                        NULL);
  fprintf(stderr, "\n======== BUILD LOG ========\n%s\n", log);
  fprintf(stderr,
          "=======================================================\n\n");
  free(log);
}


x86 assembly (clang, -O0):
<clu_PrintBuildLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x10(%rbp),%r9
mov    %r8,%rcx
call   1050 <clGetProgramBuildInfo@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   1050 <clGetProgramBuildInfo@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clu_PrintBuildLog>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebp
mov    0x2e95(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%r9
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <clGetProgramBuildInfo@plt>
mov    (%rsp),%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    (%r15),%edx
mov    (%rsp),%rcx
mov    %ebp,%edi
mov    %r14d,%esi
mov    %rax,%r8
xor    %r9d,%r9d
call   1050 <clGetProgramBuildInfo@plt>
mov    0x2e47(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe65(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe72(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CL_PROGRAM_BUILD_LOG = global i32 0
@stderr = global i32 0
@.str = [33 x i8] c"\0A======== BUILD LOG ========\0A%s\0A\00"
@.str.1 = [58 x i8] c"=======================================================\0A\0A\00"
define void @clu_PrintBuildLog(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%10 = call i32 @clGetProgramBuildInfo(i32 %7, i32 %8, i32 %9, i64 0, i8* null, i64* %5)
%11 = load i64, i64* %5
%12 = add i64 %11, 1
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %6
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%18 = load i64, i64* %5
%19 = load i8*, i8** %6
%20 = call i32 @clGetProgramBuildInfo(i32 %15, i32 %16, i32 %17, i64 %18, i8* %19, i64* null)
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %6
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
ret void
}

LLVM IR (-O2):
@CL_PROGRAM_BUILD_LOG = global i32 0
@stderr = global i32 0
@.str = [33 x i8] c"\0A======== BUILD LOG ========\0A%s\0A\00"
@.str.1 = [58 x i8] c"=======================================================\0A\0A\00"
define void @clu_PrintBuildLog(i32 %0, i32 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%6 = call i32 @clGetProgramBuildInfo(i32 %0, i32 %1, i32 %5, i64 0, i8* null, i64* %3)
%7 = load i64, i64* %3
%8 = add i64 %7, 1
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = load i32, i32* @CL_PROGRAM_BUILD_LOG
%12 = load i64, i64* %3
%13 = call i32 @clGetProgramBuildInfo(i32 %0, i32 %1, i32 %11, i64 %12, i8* %10, i64* null)
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %10)
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @free(i8* %10)
ret void
}