#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_mem_flags;
typedef int /*<<< orphan*/ cl_mem;
typedef int /*<<< orphan*/ cl_int;
typedef scalar_t__ cl_context;

/* Variables and functions */
int /*<<< orphan*/ syscall(int, int, unsigned int *);
cl_mem clCreateBuffer(cl_context context, cl_mem_flags flags, size_t size,
                      void *host_ptr, cl_int *errcode_ret) {
  unsigned int sys_args[5];
  sys_args[0] = (unsigned int)context;
  sys_args[1] = (unsigned int)flags;
  sys_args[2] = (unsigned int)size;
  sys_args[3] = (unsigned int)host_ptr;
  sys_args[4] = (unsigned int)errcode_ret;
  return (cl_mem)syscall(325, 1014, sys_args);
}


x86 assembly (clang, -O0):
<clCreateBuffer>:
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    $0x3f6,%esi
call   1030 <syscall@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clCreateBuffer>:
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    $0x3f6,%esi
call   1030 <syscall@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @clCreateBuffer(i64 %0, i64 %1, i64 %2, i8* %3, i32* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca [5 x i32]
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32* %4, i32** %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 i8*, i8** %9
%22 = ptrtoint i8* %21 to i32
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0, i64 3
store i32 %22, i32* %23
%24 = load i32*, i32** %10
%25 = ptrtoint i32* %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 1014, i32* %27)
ret i32 %28
}

LLVM IR (-O2):
define i32 @clCreateBuffer(i64 %0, i64 %1, i64 %2, i8* %3, i32* %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 i8* %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 i32* %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 1014, i32* %9)
ret i32 %20
}