#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 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_node(enum bpf_map_type map_type, const char *name,
                        int key_size, int value_size, 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 = value_size;
  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_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_node+0x3c>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
jmp    1186 <bpf_create_map_node+0x46>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <bpf_create_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)
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    0x2e06(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ea <bpf_create_map_node+0xaa>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11f9 <bpf_create_map_node+0xb9>
mov    0x2de7(%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     1227 <bpf_create_map_node+0xe7>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2db2(%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_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_node+0x23>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
jmp    1165 <bpf_create_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_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_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 = load i32, i32* %11
%31 = bitcast %union.bpf_attr* %16 to i32*
store i32 %30, i32* %31
%32 = load i32, i32* %12
%33 = bitcast %union.bpf_attr* %16 to i32*
store i32 %32, i32* %33
%34 = load i32, i32* %13
%35 = bitcast %union.bpf_attr* %16 to i32*
store i32 %34, i32* %35
%36 = bitcast %union.bpf_attr* %16 to i32*
%37 = load i32, i32* %36
%38 = load i8*, i8** %9
%39 = load i32, i32* %15
%40 = load i32, i32* @BPF_OBJ_NAME_LEN
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %45
43: ; preds = %23
%44 = load i32, i32* %15
br label %48
45: ; preds = %23
%46 = load i32, i32* @BPF_OBJ_NAME_LEN
%47 = sub nsw i32 %46, 1
br label %48
48: ; preds = %45, %43
%49 = phi i32 [ %44, %43 ], [ %47, %45 ]
%50 = call i32 @memcpy(i32 %37, i8* %38, i32 %49)
%51 = load i32, i32* %14
%52 = icmp sge i32 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %48
%54 = load i32, i32* @BPF_F_NUMA_NODE
%55 = bitcast %union.bpf_attr* %16 to i32*
%56 = load i32, i32* %55
%57 = or i32 %56, %54
store i32 %57, i32* %55
%58 = load i32, i32* %14
%59 = bitcast %union.bpf_attr* %16 to i32*
store i32 %58, i32* %59
br label %60
60: ; preds = %53, %48
%61 = load i32, i32* @BPF_MAP_CREATE
%62 = call i32 @sys_bpf(i32 %61, %union.bpf_attr* %16, i32 4)
ret i32 %62
}

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