#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;
  int /*<<< orphan*/ map_name;
};
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 BPF_OBJ_NAME_LEN;
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, char const *, int);
int /*<<< orphan*/ memset(union bpf_attr *, char, int);
int strlen(char const *);
int sys_bpf(int /*<<< orphan*/, union bpf_attr *, int);
int bpf_create_map_in_map_node(enum bpf_map_type map_type, const char *name,
                               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 (name)
    memcpy(attr.map_name, name,
           ((strlen(name)) < (BPF_OBJ_NAME_LEN - 1) ? (strlen(name))
                                                    : (BPF_OBJ_NAME_LEN - 1)));
  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    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x4,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11fa <bpf_create_map_in_map_node+0xba>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    0x2e1a(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11dc <bpf_create_map_in_map_node+0x9c>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x38(%rbp)
jmp    11eb <bpf_create_map_in_map_node+0xab>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%edx
call   1060 <memcpy@plt>
cmpl   $0x0,0x10(%rbp)
jl     1219 <bpf_create_map_in_map_node+0xd9>
mov    0x2ddd(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x40,%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,%ebp
mov    %rsi,%rbx
mov    0x30(%rsp),%r14d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %ebp,0x8(%rsp)
test   %rbx,%rbx
je     1199 <bpf_create_map_in_map_node+0x59>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2e64(%rip),%rcx
mov    (%rcx),%edx
add    $0xffffffff,%edx
cmp    %edx,%eax
jge    118f <bpf_create_map_in_map_node+0x4f>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
test   %r14d,%r14d
js     11a3 <bpf_create_map_in_map_node+0x63>
mov    %r14d,0x8(%rsp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%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_OBJ_NAME_LEN = global i32 0
@BPF_F_NUMA_NODE = global i32 0
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_in_map_node(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %union.bpf_attr
store i32 %0, i32* %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%16 = call i32 @memset(%union.bpf_attr* %15, i8 signext 0, i32 4)
%17 = load i32, i32* %8
%18 = bitcast %union.bpf_attr* %15 to i32*
store i32 %17, i32* %18
%19 = load i32, i32* %10
%20 = bitcast %union.bpf_attr* %15 to i32*
store i32 %19, i32* %20
%21 = bitcast %union.bpf_attr* %15 to i32*
store i32 4, i32* %21
%22 = load i32, i32* %11
%23 = bitcast %union.bpf_attr* %15 to i32*
store i32 %22, i32* %23
%24 = load i32, i32* %12
%25 = bitcast %union.bpf_attr* %15 to i32*
store i32 %24, i32* %25
%26 = load i32, i32* %13
%27 = bitcast %union.bpf_attr* %15 to i32*
store i32 %26, i32* %27
%28 = load i8*, i8** %9
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %48
30: ; preds = %7
%31 = bitcast %union.bpf_attr* %15 to i32*
%32 = load i32, i32* %31
%33 = load i8*, i8** %9
%34 = load i8*, i8** %9
%35 = call i32 @strlen(i8* %34)
%36 = load i32, i32* @BPF_OBJ_NAME_LEN
%37 = sub nsw i32 %36, 1
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %42
39: ; preds = %30
%40 = load i8*, i8** %9
%41 = call i32 @strlen(i8* %40)
br label %45
42: ; preds = %30
%43 = load i32, i32* @BPF_OBJ_NAME_LEN
%44 = sub nsw i32 %43, 1
br label %45
45: ; preds = %42, %39
%46 = phi i32 [ %41, %39 ], [ %44, %42 ]
%47 = call i32 @memcpy(i32 %32, i8* %33, i32 %46)
br label %48
48: ; preds = %45, %7
%49 = load i32, i32* %14
%50 = icmp sge i32 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i32, i32* @BPF_F_NUMA_NODE
%53 = bitcast %union.bpf_attr* %15 to i32*
%54 = load i32, i32* %53
%55 = or i32 %54, %52
store i32 %55, i32* %53
%56 = load i32, i32* %14
%57 = bitcast %union.bpf_attr* %15 to i32*
store i32 %56, i32* %57
br label %58
58: ; preds = %51, %48
%59 = load i32, i32* @BPF_MAP_CREATE
%60 = call i32 @sys_bpf(i32 %59, %union.bpf_attr* %15, i32 4)
ret i32 %60
}

LLVM IR (-O2):
%union.bpf_attr = type { i32 }
@BPF_OBJ_NAME_LEN = global i32 0
@BPF_F_NUMA_NODE = global i32 0
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_in_map_node(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca %union.bpf_attr
%9 = bitcast %union.bpf_attr* %8 to i8*
%10 = call i32 @memset(%union.bpf_attr* %8, i8 signext 0, i32 4)
%11 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %8, i64 0, i32 0
store i32 %5, i32* %11
%12 = icmp eq i8* %1, null
br i1 %12, label %23, label %13
13: ; preds = %7
%14 = call i32 @strlen(i8* %1)
%15 = load i32, i32* @BPF_OBJ_NAME_LEN
%16 = add nsw i32 %15, -1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @strlen(i8* %1)
br label %20
20: ; preds = %13, %18
%21 = phi i32 [ %19, %18 ], [ %16, %13 ]
%22 = call i32 @memcpy(i32 %5, i8* %1, i32 %21)
br label %23
23: ; preds = %20, %7
%24 = icmp sgt i32 %6, -1
br i1 %24, label %25, label %26
25: ; preds = %23
store i32 %6, i32* %11
br label %26
26: ; preds = %25, %23
%27 = load i32, i32* @BPF_MAP_CREATE
%28 = call i32 @sys_bpf(i32 %27, %union.bpf_attr* %8, i32 4)
ret i32 %28
}