#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int prog_fd;
  int /*<<< orphan*/ name;
};
union bpf_attr {
  TYPE_1__ raw_tracepoint;
};
typedef int /*<<< orphan*/ attr;

/* Variables and functions */
int /*<<< orphan*/ BPF_RAW_TRACEPOINT_OPEN;
int /*<<< orphan*/ memset(union bpf_attr *, int /*<<< orphan*/, int);
int /*<<< orphan*/ ptr_to_u64(char const *);
int sys_bpf(int /*<<< orphan*/, union bpf_attr *, int);
int bpf_raw_tracepoint_open(const char *name, int prog_fd) {
  union bpf_attr attr;
  memset(&attr, 0, sizeof(attr));
  attr.raw_tracepoint.name = ptr_to_u64(name);
  attr.raw_tracepoint.prog_fd = prog_fd;
  return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, &attr, sizeof(attr));
}


x86 assembly (clang, -O0):
<bpf_raw_tracepoint_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ptr_to_u64@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1030 <sys_bpf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_raw_tracepoint_open>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1040 <ptr_to_u64@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,0x8(%rsp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <sys_bpf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%union.bpf_attr = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32 }
@BPF_RAW_TRACEPOINT_OPEN = global i32 0
define i32 @bpf_raw_tracepoint_open(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %union.bpf_attr
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 @memset(%union.bpf_attr* %5, i32 0, i32 8)
%7 = load i8*, i8** %3
%8 = call i32 @ptr_to_u64(i8* %7)
%9 = bitcast %union.bpf_attr* %5 to %struct.TYPE_2__*
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 1
store i32 %8, i32* %10
%11 = load i32, i32* %4
%12 = bitcast %union.bpf_attr* %5 to %struct.TYPE_2__*
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 0
store i32 %11, i32* %13
%14 = load i32, i32* @BPF_RAW_TRACEPOINT_OPEN
%15 = call i32 @sys_bpf(i32 %14, %union.bpf_attr* %5, i32 8)
ret i32 %15
}

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