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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int syscall(int, int, unsigned int *);
cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
                        cl_uint *num_platforms) {
  unsigned int sys_args[3];
  int ret;
  sys_args[0] = (unsigned int)num_entries;
  sys_args[1] = (unsigned int)platforms;
  sys_args[2] = (unsigned int)num_platforms;
  sys_args[3] = ((1 << 16) | (0 << 8) | 0);
  ret = syscall(325, 1000, sys_args);
  if (ret == -1) {
    fprintf(
        stderr,
        "error: OpenCL program cannot be run natively.\n"
        "\tThis is an error message provided by the Multi2Sim OpenCL library\n"
        "\t(libm2s-opencl). Apparently, you are attempting to run natively a\n"
        "\tprogram that was linked with this library. You should either run\n"
        "\tit on top of Multi2Sim, or link it with the OpenCL library "
        "provided\n"
        "\tin the ATI Stream SDK if you want to use your physical GPU "
        "device.\n");
    abort();
  }
  return (cl_int)ret;
}


x86 assembly (clang, -O0):
<clGetPlatformIDs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x1c(%rbp)
movl   $0x10000,-0x18(%rbp)
lea    -0x24(%rbp),%rdx
mov    $0x145,%edi
mov    $0x3e8,%esi
call   1050 <syscall@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    119c <clGetPlatformIDs+0x6c>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clGetPlatformIDs>:
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
mov    %esi,0x10(%rsp)
mov    %edx,0x14(%rsp)
movl   $0x10000,0x18(%rsp)
lea    0xc(%rsp),%rdx
mov    $0x145,%edi
mov    $0x3e8,%esi
call   1050 <syscall@plt>
cmp    $0xffffffff,%eax
je     1166 <clGetPlatformIDs+0x36>
add    $0x18,%rsp
ret
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [384 x i8] c"error: OpenCL program cannot be run natively.\0A\09This is an error message provided by the Multi2Sim OpenCL library\0A\09(libm2s-opencl). Apparently, you are attempting to run natively a\0A\09program that was linked with this library. You should either run\0A\09it on top of Multi2Sim, or link it with the OpenCL library provided\0A\09in the ATI Stream SDK if you want to use your physical GPU device.\0A\00"
define i32 @clGetPlatformIDs(i64 %0, i32* %1, i64* %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca [3 x i32]
%8 = alloca i32
store i64 %0, i64* %4
store i32* %1, i32** %5
store i64* %2, i64** %6
%9 = load i64, i64* %4
%10 = trunc i64 %9 to i32
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
store i32 %10, i32* %11
%12 = load i32*, i32** %5
%13 = ptrtoint i32* %12 to i32
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
store i32 %13, i32* %14
%15 = load i64*, i64** %6
%16 = ptrtoint i64* %15 to i32
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
store i32 %16, i32* %17
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 3
store i32 65536, i32* %18
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%20 = call i32 @syscall(i32 325, i32 1000, i32* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %27
23: ; preds = %3
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([384 x i8], [384 x i8]* @.str, i64 0, i64 0))
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %3
%28 = load i32, i32* %8
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [384 x i8] c"error: OpenCL program cannot be run natively.\0A\09This is an error message provided by the Multi2Sim OpenCL library\0A\09(libm2s-opencl). Apparently, you are attempting to run natively a\0A\09program that was linked with this library. You should either run\0A\09it on top of Multi2Sim, or link it with the OpenCL library provided\0A\09in the ATI Stream SDK if you want to use your physical GPU device.\0A\00"
define i32 @clGetPlatformIDs(i64 %0, i32* %1, i64* %2) {
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = trunc i64 %0 to i32
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 %6, i32* %7
%8 = ptrtoint i32* %1 to i64
%9 = trunc i64 %8 to i32
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 1
store i32 %9, i32* %10
%11 = ptrtoint i64* %2 to i64
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 2
store i32 %12, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 3
store i32 65536, i32* %14
%15 = call i32 @syscall(i32 325, i32 1000, i32* %7)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([384 x i8], [384 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %3
ret i32 %15
}