#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 char *cl_platform_id;
typedef int /*<<< orphan*/ cl_int;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ CL_PLATFORM_NAME;
int /*<<< orphan*/ CL_PLATFORM_VENDOR;
int /*<<< orphan*/ clGetPlatformInfo(char *, int /*<<< orphan*/, int, char *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ oclCheckStatus(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
void oclDisplayPlatformInfo(cl_platform_id platform_id) {
  cl_int status;
  char buffer[128];
  printf("OpenCL Platform, id %p\n", platform_id);
  status = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, sizeof(buffer),
                             buffer, NULL);
  oclCheckStatus(status, "clGetPlatformInfo(CL_PLATFORM_NAME) failed.");
  printf("  name  : %s\n", buffer);
  status = clGetPlatformInfo(platform_id, CL_PLATFORM_VENDOR, sizeof(buffer),
                             buffer, NULL);
  oclCheckStatus(status, "clGetPlatformInfo(CL_PLATFORM_VENDOR) failed.");
  printf("  vendor: %s\n", buffer);
}


x86 assembly (clang, -O0):
<oclDisplayPlatformInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
lea    -0x90(%rbp),%rcx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetPlatformInfo@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xe99(%rip),%rsi
call   1050 <oclCheckStatus@plt>
lea    -0x90(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
lea    -0x90(%rbp),%rcx
mov    $0x80,%edx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetPlatformInfo@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    0xe8b(%rip),%rsi
call   1050 <oclCheckStatus@plt>
lea    -0x90(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oclDisplayPlatformInfo>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r14
mov    %rbx,%rdi
mov    $0x80,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <clGetPlatformInfo@plt>
lea    0xea6(%rip),%rsi
mov    %eax,%edi
call   1050 <oclCheckStatus@plt>
lea    0xec4(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    $0x80,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <clGetPlatformInfo@plt>
lea    0xea7(%rip),%rsi
mov    %eax,%edi
call   1050 <oclCheckStatus@plt>
lea    0xec7(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"OpenCL Platform, id %p\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.1 = [44 x i8] c"clGetPlatformInfo(CL_PLATFORM_NAME) failed.\00"
@.str.2 = [14 x i8] c" name : %s\0A\00"
@CL_PLATFORM_VENDOR = global i32 0
@.str.3 = [46 x i8] c"clGetPlatformInfo(CL_PLATFORM_VENDOR) failed.\00"
@.str.4 = [14 x i8] c" vendor: %s\0A\00"
define void @oclDisplayPlatformInfo(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [128 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = load i32, i32* @CL_PLATFORM_NAME
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = call i32 @clGetPlatformInfo(i8* %7, i32 %8, i32 128, i8* %9, i32* null)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @oclCheckStatus(i32 %11, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %2
%16 = load i32, i32* @CL_PLATFORM_VENDOR
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%18 = call i32 @clGetPlatformInfo(i8* %15, i32 %16, i32 128, i8* %17, i32* null)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 @oclCheckStatus(i32 %19, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"OpenCL Platform, id %p\0A\00"
@CL_PLATFORM_NAME = global i32 0
@.str.1 = [44 x i8] c"clGetPlatformInfo(CL_PLATFORM_NAME) failed.\00"
@.str.2 = [14 x i8] c" name : %s\0A\00"
@CL_PLATFORM_VENDOR = global i32 0
@.str.3 = [46 x i8] c"clGetPlatformInfo(CL_PLATFORM_VENDOR) failed.\00"
@.str.4 = [14 x i8] c" vendor: %s\0A\00"
define void @oclDisplayPlatformInfo(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @CL_PLATFORM_NAME
%6 = call i32 @clGetPlatformInfo(i8* %0, i32 %5, i32 128, i8* %3, i32* null)
%7 = call i32 @oclCheckStatus(i32 %6, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%9 = load i32, i32* @CL_PLATFORM_VENDOR
%10 = call i32 @clGetPlatformInfo(i8* %0, i32 %9, i32 128, i8* %3, i32* null)
%11 = call i32 @oclCheckStatus(i32 %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %3)
ret void
}