#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 /*<<< 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_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(enum bpf_map_type map_type, int key_size,
                          int inner_map_fd, int max_entries, __u32 map_flags) {
  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;
  return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}


x86 assembly (clang, -O0):
<bpf_create_map_in_map>:
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)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x4,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%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>:
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,(%rsp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <sys_bpf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%union.bpf_attr = type { i32 }
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_in_map(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %union.bpf_attr
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = call i32 @memset(%union.bpf_attr* %11, i8 signext 0, i32 4)
%13 = load i32, i32* %6
%14 = bitcast %union.bpf_attr* %11 to i32*
store i32 %13, i32* %14
%15 = load i32, i32* %7
%16 = bitcast %union.bpf_attr* %11 to i32*
store i32 %15, i32* %16
%17 = bitcast %union.bpf_attr* %11 to i32*
store i32 4, i32* %17
%18 = load i32, i32* %8
%19 = bitcast %union.bpf_attr* %11 to i32*
store i32 %18, i32* %19
%20 = load i32, i32* %9
%21 = bitcast %union.bpf_attr* %11 to i32*
store i32 %20, i32* %21
%22 = load i32, i32* %10
%23 = bitcast %union.bpf_attr* %11 to i32*
store i32 %22, i32* %23
%24 = load i32, i32* @BPF_MAP_CREATE
%25 = call i32 @sys_bpf(i32 %24, %union.bpf_attr* %11, i32 4)
ret i32 %25
}

LLVM IR (-O2):
%union.bpf_attr = type { i32 }
@BPF_MAP_CREATE = global i32 0
define i32 @bpf_create_map_in_map(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %union.bpf_attr
%7 = bitcast %union.bpf_attr* %6 to i8*
%8 = call i32 @memset(%union.bpf_attr* %6, i8 signext 0, i32 4)
%9 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %6, i64 0, i32 0
store i32 %4, i32* %9
%10 = load i32, i32* @BPF_MAP_CREATE
%11 = call i32 @sys_bpf(i32 %10, %union.bpf_attr* %6, i32 4)
ret i32 %11
}