#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 numa_node;
  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_F_NUMA_NODE;
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_node(enum bpf_map_type map_type, int key_size,
                        int value_size, int max_entries, __u32 map_flags,
                        int node) {
  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;
  if (node >= 0) {
    attr.map_flags |= BPF_F_NUMA_NODE;
    attr.numa_node = node;
  }
  return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}


x86 assembly (clang, -O0):
<bpf_create_map_node>:
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)
mov    %r9d,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1189 <bpf_create_map_node+0x69>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_create_map_node>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r9d,%ebx
mov    %r8d,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
test   %ebx,%ebx
cmovns %ebx,%ebp
mov    %ebp,0x8(%rsp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.bpf_attr = type { i32 }
@BPF_F_NUMA_NODE = global i32 0
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_node(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %union.bpf_attr
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = call i32 @memset(%union.bpf_attr* %13, i8 signext 0, i32 4)
%15 = load i32, i32* %7
%16 = bitcast %union.bpf_attr* %13 to i32*
store i32 %15, i32* %16
%17 = load i32, i32* %8
%18 = bitcast %union.bpf_attr* %13 to i32*
store i32 %17, i32* %18
%19 = load i32, i32* %9
%20 = bitcast %union.bpf_attr* %13 to i32*
store i32 %19, i32* %20
%21 = load i32, i32* %10
%22 = bitcast %union.bpf_attr* %13 to i32*
store i32 %21, i32* %22
%23 = load i32, i32* %11
%24 = bitcast %union.bpf_attr* %13 to i32*
store i32 %23, i32* %24
%25 = load i32, i32* %12
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %6
%28 = load i32, i32* @BPF_F_NUMA_NODE
%29 = bitcast %union.bpf_attr* %13 to i32*
%30 = load i32, i32* %29
%31 = or i32 %30, %28
store i32 %31, i32* %29
%32 = load i32, i32* %12
%33 = bitcast %union.bpf_attr* %13 to i32*
store i32 %32, i32* %33
br label %34
34: ; preds = %27, %6
%35 = load i32, i32* @BPF_MAP_CREATE
%36 = call i32 @sys_bpf(i32 %35, %union.bpf_attr* %13, i32 4)
ret i32 %36
}

LLVM IR (-O2):
%union.bpf_attr = type { i32 }
@BPF_F_NUMA_NODE = global i32 0
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_node(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %union.bpf_attr
%8 = bitcast %union.bpf_attr* %7 to i8*
%9 = call i32 @memset(%union.bpf_attr* %7, i8 signext 0, i32 4)
%10 = icmp sgt i32 %5, -1
%11 = select i1 %10, i32 %5, i32 %4
%12 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %7, i64 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* @BPF_MAP_CREATE
%14 = call i32 @sys_bpf(i32 %13, %union.bpf_attr* %7, i32 4)
ret i32 %14
}