#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 inner_map_fd;
  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_in_map_node(enum bpf_map_type map_type, int key_size,
                               int inner_map_fd, 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 = 4;
  attr.inner_map_fd = inner_map_fd;
  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_in_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)
movl   $0x4,-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     1190 <bpf_create_map_in_map_node+0x70>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e49(%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_in_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_in_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 = bitcast %union.bpf_attr* %13 to i32*
store i32 4, i32* %19
%20 = load i32, i32* %9
%21 = bitcast %union.bpf_attr* %13 to i32*
store i32 %20, i32* %21
%22 = load i32, i32* %10
%23 = bitcast %union.bpf_attr* %13 to i32*
store i32 %22, i32* %23
%24 = load i32, i32* %11
%25 = bitcast %union.bpf_attr* %13 to i32*
store i32 %24, i32* %25
%26 = load i32, i32* %12
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %6
%29 = load i32, i32* @BPF_F_NUMA_NODE
%30 = bitcast %union.bpf_attr* %13 to i32*
%31 = load i32, i32* %30
%32 = or i32 %31, %29
store i32 %32, i32* %30
%33 = load i32, i32* %12
%34 = bitcast %union.bpf_attr* %13 to i32*
store i32 %33, i32* %34
br label %35
35: ; preds = %28, %6
%36 = load i32, i32* @BPF_MAP_CREATE
%37 = call i32 @sys_bpf(i32 %36, %union.bpf_attr* %13, i32 4)
ret i32 %37
}

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_in_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
}