#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_fd;
  void *value;
  void *key;
};
typedef int /*<<< orphan*/ attr;

/* Variables and functions */
int /*<<< orphan*/ BPF_MAP_LOOKUP_AND_DELETE_ELEM;
int /*<<< orphan*/ bzero(union bpf_attr *, int);
void *ptr_to_u64(void *);
int sys_bpf(int /*<<< orphan*/, union bpf_attr *, int);
int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) {
  union bpf_attr attr;
  bzero(&attr, sizeof(attr));
  attr.map_fd = fd;
  attr.key = ptr_to_u64(key);
  attr.value = ptr_to_u64(value);
  return sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr));
}


x86 assembly (clang, -O0):
<bpf_map_lookup_and_delete_elem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x8,%esi
call   1050 <bzero@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ptr_to_u64@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ptr_to_u64@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1030 <sys_bpf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_map_lookup_and_delete_elem>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%rdi
call   1040 <ptr_to_u64@plt>
mov    %rbx,%rdi
call   1040 <ptr_to_u64@plt>
mov    %rax,0x8(%rsp)
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1030 <sys_bpf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%union.bpf_attr = type { i8* }
@BPF_MAP_LOOKUP_AND_DELETE_ELEM = global i32 0
define i32 @bpf_map_lookup_and_delete_elem(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %union.bpf_attr
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = call i32 @bzero(%union.bpf_attr* %7, i32 8)
%9 = load i32, i32* %4
%10 = bitcast %union.bpf_attr* %7 to i32*
store i32 %9, i32* %10
%11 = load i8*, i8** %5
%12 = call i8* @ptr_to_u64(i8* %11)
%13 = bitcast %union.bpf_attr* %7 to i8**
store i8* %12, i8** %13
%14 = load i8*, i8** %6
%15 = call i8* @ptr_to_u64(i8* %14)
%16 = bitcast %union.bpf_attr* %7 to i8**
store i8* %15, i8** %16
%17 = load i32, i32* @BPF_MAP_LOOKUP_AND_DELETE_ELEM
%18 = call i32 @sys_bpf(i32 %17, %union.bpf_attr* %7, i32 8)
ret i32 %18
}

LLVM IR (-O2):
%union.bpf_attr = type { i8* }
@BPF_MAP_LOOKUP_AND_DELETE_ELEM = global i32 0
define i32 @bpf_map_lookup_and_delete_elem(i32 %0, i8* %1, i8* %2) {
%4 = alloca %union.bpf_attr
%5 = bitcast %union.bpf_attr* %4 to i8*
%6 = tail call i8* @ptr_to_u64(i8* %1)
%7 = getelementptr inbounds %union.bpf_attr, %union.bpf_attr* %4, i64 0, i32 0
%8 = tail call i8* @ptr_to_u64(i8* %2)
store i8* %8, i8** %7
%9 = load i32, i32* @BPF_MAP_LOOKUP_AND_DELETE_ELEM
%10 = call i32 @sys_bpf(i32 %9, %union.bpf_attr* %4, i32 8)
ret i32 %10
}