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

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_GLOBAL_MEM_SIZE;
int /*<<< orphan*/ CL_DEVICE_MAX_CLOCK_FREQUENCY;
int /*<<< orphan*/ CL_DEVICE_MAX_COMPUTE_UNITS;
int /*<<< orphan*/ CL_DEVICE_MAX_MEM_ALLOC_SIZE;
int /*<<< orphan*/ CL_DEVICE_MEM_BASE_ADDR_ALIGN;
int /*<<< orphan*/ CL_DEVICE_NAME;
int /*<<< orphan*/ clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   ...);
int /*<<< orphan*/ printf(char *, ...);
void printDeviceInfo(cl_device_id device) {
  cl_int err;
  char paramValueString[100];
  cl_ulong paramValueUlong;
  cl_uint paramValueUint;
  size_t returnSize;
  printf("==== Device info ====\n");
  err = clGetDeviceInfo(device, CL_DEVICE_NAME, 100, paramValueString,
                        &returnSize);
  printf("Device name:\t\t%s\n", paramValueString);
  err = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong),
                        &paramValueUlong, &returnSize);
  printf("Device global memory:\t%lu\n", paramValueUlong);
  err = clGetDeviceInfo(device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(cl_uint),
                        &paramValueUint, &returnSize);
  printf("Device max frequency:\t%u\n", paramValueUint);
  err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint),
                        &paramValueUint, &returnSize);
  printf("Device compute units:\t%u\n", paramValueUint);
  err = clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong),
                        &paramValueUlong, &returnSize);
  printf("Max size of memory allocation:\t%lu\n", paramValueUlong);
  err = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint),
                        &paramValueUint, &returnSize);
  printf("Device memory alignment:\t%u\n", paramValueUint);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<printDeviceInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
lea    -0x70(%rbp),%rcx
mov    $0x64,%edx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x74(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x74(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x78(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x78(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x78(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x78(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x74(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x74(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x78(%rbp),%rcx
lea    -0x80(%rbp),%r8
mov    $0x0,%al
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x78(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDeviceInfo>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %edi,%ebx
lea    0xf5e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r14
mov    %ebx,%edi
mov    $0x64,%edx
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
lea    0xe89(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%r15
mov    %ebx,%edi
mov    $0x4,%edx
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
mov    0x4(%rsp),%esi
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%r12
mov    %ebx,%edi
mov    $0x4,%edx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
mov    (%rsp),%esi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x4,%edx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
mov    (%rsp),%esi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x4,%edx
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
mov    0x4(%rsp),%esi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x4,%edx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <clGetDeviceInfo@plt>
mov    (%rsp),%esi
lea    0xe1b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd98(%rip),%rdi
call   1030 <puts@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"==== Device info ====\0A\00"
@CL_DEVICE_NAME = global i32 0
@.str.1 = [18 x i8] c"Device name:\09\09%s\0A\00"
@CL_DEVICE_GLOBAL_MEM_SIZE = global i32 0
@.str.2 = [27 x i8] c"Device global memory:\09%lu\0A\00"
@CL_DEVICE_MAX_CLOCK_FREQUENCY = global i32 0
@.str.3 = [26 x i8] c"Device max frequency:\09%u\0A\00"
@CL_DEVICE_MAX_COMPUTE_UNITS = global i32 0
@.str.4 = [26 x i8] c"Device compute units:\09%u\0A\00"
@CL_DEVICE_MAX_MEM_ALLOC_SIZE = global i32 0
@.str.5 = [36 x i8] c"Max size of memory allocation:\09%lu\0A\00"
@CL_DEVICE_MEM_BASE_ADDR_ALIGN = global i32 0
@.str.6 = [29 x i8] c"Device memory alignment:\09%u\0A\00"
@.str.7 = [3 x i8] c"\0A\0A\00"
define void @printDeviceInfo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 %0, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = load i32, i32* @CL_DEVICE_NAME
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %9, i32 %10, i32 100, i8* %11, i64* %7)
store i32 %12, i32* %3
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %2
%16 = load i32, i32* @CL_DEVICE_GLOBAL_MEM_SIZE
%17 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %15, i32 %16, i32 4, i32* %5, i64* %7)
store i32 %17, i32* %3
%18 = load i32, i32* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = load i32, i32* @CL_DEVICE_MAX_CLOCK_FREQUENCY
%22 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %20, i32 %21, i32 4, i32* %6, i64* %7)
store i32 %22, i32* %3
%23 = load i32, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %2
%26 = load i32, i32* @CL_DEVICE_MAX_COMPUTE_UNITS
%27 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %25, i32 %26, i32 4, i32* %6, i64* %7)
store i32 %27, i32* %3
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = load i32, i32* @CL_DEVICE_MAX_MEM_ALLOC_SIZE
%32 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %30, i32 %31, i32 4, i32* %5, i64* %7)
store i32 %32, i32* %3
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* @CL_DEVICE_MEM_BASE_ADDR_ALIGN
%37 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %35, i32 %36, i32 4, i32* %6, i64* %7)
store i32 %37, i32* %3
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@CL_DEVICE_NAME = global i32 0
@.str.1 = [18 x i8] c"Device name:\09\09%s\0A\00"
@CL_DEVICE_GLOBAL_MEM_SIZE = global i32 0
@.str.2 = [27 x i8] c"Device global memory:\09%lu\0A\00"
@CL_DEVICE_MAX_CLOCK_FREQUENCY = global i32 0
@.str.3 = [26 x i8] c"Device max frequency:\09%u\0A\00"
@CL_DEVICE_MAX_COMPUTE_UNITS = global i32 0
@.str.4 = [26 x i8] c"Device compute units:\09%u\0A\00"
@CL_DEVICE_MAX_MEM_ALLOC_SIZE = global i32 0
@.str.5 = [36 x i8] c"Max size of memory allocation:\09%lu\0A\00"
@CL_DEVICE_MEM_BASE_ADDR_ALIGN = global i32 0
@.str.6 = [29 x i8] c"Device memory alignment:\09%u\0A\00"
@str = [22 x i8] c"==== Device info ====\00"
@str.8 = [2 x i8] c"\0A\00"
define void @printDeviceInfo(i32 %0) {
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i64* %5 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* @CL_DEVICE_NAME
%12 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %11, i32 100, i8* %6, i64* %5)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = load i32, i32* @CL_DEVICE_GLOBAL_MEM_SIZE
%15 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %14, i32 4, i32* %3, i64* %5)
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @CL_DEVICE_MAX_CLOCK_FREQUENCY
%19 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %18, i32 4, i32* %4, i64* %5)
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @CL_DEVICE_MAX_COMPUTE_UNITS
%23 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %22, i32 4, i32* %4, i64* %5)
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @CL_DEVICE_MAX_MEM_ALLOC_SIZE
%27 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %26, i32 4, i32* %3, i64* %5)
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @CL_DEVICE_MEM_BASE_ADDR_ALIGN
%31 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %0, i32 %30, i32 4, i32* %4, i64* %5)
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
ret void
}