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

/* Variables and functions */
int /*<<< orphan*/ syscall(int, int, unsigned int *);
cl_int clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
                      cl_uint num_entries, cl_device_id *devices,
                      cl_uint *num_devices) {
  unsigned int sys_args[5];
  sys_args[0] = (unsigned int)platform;
  sys_args[1] = (unsigned int)device_type;
  sys_args[2] = (unsigned int)num_entries;
  sys_args[3] = (unsigned int)devices;
  sys_args[4] = (unsigned int)num_devices;
  return (cl_int)syscall(325, 1002, sys_args);
}


x86 assembly (clang, -O0):
<clGetDeviceIDs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,-0x30(%rbp)
lea    -0x40(%rbp),%rdx
mov    $0x145,%edi
mov    $0x3ea,%esi
call   1030 <syscall@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clGetDeviceIDs>:
sub    $0x18,%rsp
mov    %edi,(%rsp)
mov    %esi,0x4(%rsp)
mov    %edx,0x8(%rsp)
mov    %ecx,0xc(%rsp)
mov    %r8d,0x10(%rsp)
mov    %rsp,%rdx
mov    $0x145,%edi
mov    $0x3ea,%esi
call   1030 <syscall@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @clGetDeviceIDs(i64 %0, i64 %1, i64 %2, i32* %3, i64* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i64*
%11 = alloca [5 x i32]
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i32* %3, i32** %9
store i64* %4, i64** %10
%12 = load i64, i64* %6
%13 = trunc i64 %12 to i32
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 0
store i32 %13, i32* %14
%15 = load i64, i64* %7
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 1
store i32 %16, i32* %17
%18 = load i64, i64* %8
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 2
store i32 %19, i32* %20
%21 = load i32*, i32** %9
%22 = ptrtoint i32* %21 to i32
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 3
store i32 %22, i32* %23
%24 = load i64*, i64** %10
%25 = ptrtoint i64* %24 to i32
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 4
store i32 %25, i32* %26
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 0
%28 = call i32 @syscall(i32 325, i32 1002, i32* %27)
ret i32 %28
}

LLVM IR (-O2):
define i32 @clGetDeviceIDs(i64 %0, i64 %1, i64 %2, i32* %3, i64* %4) {
%6 = alloca [5 x i32]
%7 = bitcast [5 x i32]* %6 to i8*
%8 = trunc i64 %0 to i32
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
store i32 %8, i32* %9
%10 = trunc i64 %1 to i32
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 1
store i32 %10, i32* %11
%12 = trunc i64 %2 to i32
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 2
store i32 %12, i32* %13
%14 = ptrtoint i32* %3 to i64
%15 = trunc i64 %14 to i32
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 3
store i32 %15, i32* %16
%17 = ptrtoint i64* %4 to i64
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 4
store i32 %18, i32* %19
%20 = call i32 @syscall(i32 325, i32 1002, i32* %9)
ret i32 %20
}