#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 */
union bpf_attr {
  int map_type;
  int key_size;
  int value_size;
  int max_entries;
  int /*<<< orphan*/ map_flags;
};
typedef enum bpf_map_type { ____Placeholder_bpf_map_type } bpf_map_type;
typedef int /*<<< orphan*/ attr;
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
int /*<<< orphan*/ BPF_MAP_CREATE;
int /*<<< orphan*/ memset(union bpf_attr *, char, int);
int sys_bpf(int /*<<< orphan*/, union bpf_attr *, int);
int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
                   int max_entries, __u32 map_flags) {
  union bpf_attr attr;
  memset(&attr, '\0', sizeof(attr));
  attr.map_type = map_type;
  attr.key_size = key_size;
  attr.value_size = value_size;
  attr.max_entries = max_entries;
  attr.map_flags = map_flags;
  return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}


x86 assembly (clang, -O0):
<bpf_create_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_create_map>:
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,(%rsp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%union.bpf_attr = type { i32 }
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %union.bpf_attr
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = call i32 @memset(%union.bpf_attr* %11, i8 signext 0, i32 4)
%13 = load i32, i32* %6
%14 = bitcast %union.bpf_attr* %11 to i32*
store i32 %13, i32* %14
%15 = load i32, i32* %7
%16 = bitcast %union.bpf_attr* %11 to i32*
store i32 %15, i32* %16
%17 = load i32, i32* %8
%18 = bitcast %union.bpf_attr* %11 to i32*
store i32 %17, i32* %18
%19 = load i32, i32* %9
%20 = bitcast %union.bpf_attr* %11 to i32*
store i32 %19, i32* %20
%21 = load i32, i32* %10
%22 = bitcast %union.bpf_attr* %11 to i32*
store i32 %21, i32* %22
%23 = load i32, i32* @BPF_MAP_CREATE
%24 = call i32 @sys_bpf(i32 %23, %union.bpf_attr* %11, i32 4)
ret i32 %24
}

LLVM IR (-O2):
%union.bpf_attr = type { i32 }
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %union.bpf_attr
%7 = bitcast %union.bpf_attr* %6 to i8*
%8 = call i32 @memset(%union.bpf_attr* %6, i8 signext 0, i32 4)
%9 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %6, i64 0, i32 0
store i32 %4, i32* %9
%10 = load i32, i32* @BPF_MAP_CREATE
%11 = call i32 @sys_bpf(i32 %10, %union.bpf_attr* %6, i32 4)
ret i32 %11
}