#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;
};
typedef enum bpf_map_type { ____Placeholder_bpf_map_type } bpf_map_type;
typedef int /*<<< orphan*/ attr;

/* Variables and functions */
int /*<<< orphan*/ BPF_MAP_CREATE;
int /*<<< orphan*/ memset(union bpf_attr *, int /*<<< orphan*/, int);
int syscall(int, 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) {
  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;
  return syscall(321, 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)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <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    0x2e85(%rip),%rax
mov    (%rax),%esi
mov    $0x141,%edi
lea    -0x18(%rbp),%rdx
mov    $0x4,%ecx
call   1040 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_create_map>:
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %ebx,(%rsp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
mov    $0x141,%edi
mov    %r14,%rdx
mov    $0x4,%ecx
call   1040 <syscall@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) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %union.bpf_attr
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32 @memset(%union.bpf_attr* %9, i32 0, i32 4)
%11 = load i32, i32* %5
%12 = bitcast %union.bpf_attr* %9 to i32*
store i32 %11, i32* %12
%13 = load i32, i32* %6
%14 = bitcast %union.bpf_attr* %9 to i32*
store i32 %13, i32* %14
%15 = load i32, i32* %7
%16 = bitcast %union.bpf_attr* %9 to i32*
store i32 %15, i32* %16
%17 = load i32, i32* %8
%18 = bitcast %union.bpf_attr* %9 to i32*
store i32 %17, i32* %18
%19 = load i32, i32* @BPF_MAP_CREATE
%20 = call i32 @syscall(i32 321, i32 %19, %union.bpf_attr* %9, i32 4)
ret i32 %20
}

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) {
%5 = alloca %union.bpf_attr
%6 = bitcast %union.bpf_attr* %5 to i8*
%7 = call i32 @memset(%union.bpf_attr* %5, i32 0, i32 4)
%8 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %5, i64 0, i32 0
store i32 %3, i32* %8
%9 = load i32, i32* @BPF_MAP_CREATE
%10 = call i32 @syscall(i32 321, i32 %9, %union.bpf_attr* %5, i32 4)
ret i32 %10
}