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

/* Variables and functions */
int 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) {
  __u32 name_len = name ? strlen(name) : 0;
  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;
  memcpy(attr.map_name, name,
         ((name_len) < (BPF_OBJ_NAME_LEN - 1) ? (name_len)
                                              : (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)
cmpq   $0x0,-0x10(%rbp)
je     117c <bpf_create_map_in_map_node+0x3c>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    1186 <bpf_create_map_in_map_node+0x46>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <bpf_create_map_in_map_node+0x46>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x24(%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)
mov    -0x28(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2dff(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f1 <bpf_create_map_in_map_node+0xb1>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    1200 <bpf_create_map_in_map_node+0xc0>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%edx
call   1060 <memcpy@plt>
cmpl   $0x0,0x10(%rbp)
jl     122e <bpf_create_map_in_map_node+0xee>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2dab(%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   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %rsi,%rbx
mov    0x30(%rsp),%r15d
test   %rsi,%rsi
je     1163 <bpf_create_map_in_map_node+0x23>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
jmp    1165 <bpf_create_map_in_map_node+0x25>
xor    %ebp,%ebp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %r14d,(%rsp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
add    $0xffffffff,%edx
cmp    %edx,%ebp
cmovl  %ebp,%edx
mov    %r14d,%edi
mov    %rbx,%rsi
call   1060 <memcpy@plt>
test   %r15d,%r15d
js     119d <bpf_create_map_in_map_node+0x5d>
mov    %r15d,(%rsp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 i32
%16 = 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
%17 = load i8*, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %7
%20 = load i8*, i8** %9
%21 = call i32 @strlen(i8* %20)
br label %23
22: ; preds = %7
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 0, %22 ]
store i32 %24, i32* %15
%25 = call i32 @memset(%union.bpf_attr* %16, i8 signext 0, i32 4)
%26 = load i32, i32* %8
%27 = bitcast %union.bpf_attr* %16 to i32*
store i32 %26, i32* %27
%28 = load i32, i32* %10
%29 = bitcast %union.bpf_attr* %16 to i32*
store i32 %28, i32* %29
%30 = bitcast %union.bpf_attr* %16 to i32*
store i32 4, i32* %30
%31 = load i32, i32* %11
%32 = bitcast %union.bpf_attr* %16 to i32*
store i32 %31, i32* %32
%33 = load i32, i32* %12
%34 = bitcast %union.bpf_attr* %16 to i32*
store i32 %33, i32* %34
%35 = load i32, i32* %13
%36 = bitcast %union.bpf_attr* %16 to i32*
store i32 %35, i32* %36
%37 = bitcast %union.bpf_attr* %16 to i32*
%38 = load i32, i32* %37
%39 = load i8*, i8** %9
%40 = load i32, i32* %15
%41 = load i32, i32* @BPF_OBJ_NAME_LEN
%42 = sub nsw i32 %41, 1
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %46
44: ; preds = %23
%45 = load i32, i32* %15
br label %49
46: ; preds = %23
%47 = load i32, i32* @BPF_OBJ_NAME_LEN
%48 = sub nsw i32 %47, 1
br label %49
49: ; preds = %46, %44
%50 = phi i32 [ %45, %44 ], [ %48, %46 ]
%51 = call i32 @memcpy(i32 %38, i8* %39, i32 %50)
%52 = load i32, i32* %14
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %49
%55 = load i32, i32* @BPF_F_NUMA_NODE
%56 = bitcast %union.bpf_attr* %16 to i32*
%57 = load i32, i32* %56
%58 = or i32 %57, %55
store i32 %58, i32* %56
%59 = load i32, i32* %14
%60 = bitcast %union.bpf_attr* %16 to i32*
store i32 %59, i32* %60
br label %61
61: ; preds = %54, %49
%62 = load i32, i32* @BPF_MAP_CREATE
%63 = call i32 @sys_bpf(i32 %62, %union.bpf_attr* %16, i32 4)
ret i32 %63
}

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 = icmp eq i8* %1, null
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %1)
br label %12
12: ; preds = %7, %10
%13 = phi i32 [ %11, %10 ], [ 0, %7 ]
%14 = bitcast %union.bpf_attr* %8 to i8*
%15 = call i32 @memset(%union.bpf_attr* %8, i8 signext 0, i32 4)
%16 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %8, i64 0, i32 0
store i32 %5, i32* %16
%17 = load i32, i32* @BPF_OBJ_NAME_LEN
%18 = add nsw i32 %17, -1
%19 = icmp slt i32 %13, %18
%20 = select i1 %19, i32 %13, i32 %18
%21 = call i32 @memcpy(i32 %5, i8* %1, i32 %20)
%22 = icmp sgt i32 %6, -1
br i1 %22, label %23, label %24
23: ; preds = %12
store i32 %6, i32* %16
br label %24
24: ; preds = %23, %12
%25 = load i32, i32* @BPF_MAP_CREATE
%26 = call i32 @sys_bpf(i32 %25, %union.bpf_attr* %8, i32 4)
ret i32 %26
}