#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 {
  scalar_t__ kern_version;
  void *log_buf;
  scalar_t__ log_size;
  scalar_t__ log_level;
  void *license;
  void *insns;
  scalar_t__ insn_cnt;
  scalar_t__ prog_type;
};
typedef void *__u64;
typedef scalar_t__ __u32;

/* Variables and functions */
void bpf_attr_setup_load_prog(union bpf_attr *attr, __u32 prog_type,
                              __u32 insn_count, void *insns, char *license,
                              __u32 log_level, __u32 log_size, void *log_buf) {
  attr->prog_type = prog_type;
  attr->insn_cnt = insn_count;
  attr->insns = (__u64)(unsigned long)insns;
  attr->license = (__u64)(unsigned long)license;
  attr->log_level = log_level;
  attr->log_size = log_size;
  attr->log_buf = (__u64)(unsigned long)log_buf;
  attr->kern_version = 0;
  if (log_size > 0)
    ((char *)log_buf)[0] = 0;
}


x86 assembly (clang, -O0):
<bpf_attr_setup_load_prog>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,0x10(%rbp)
jle    118e <bpf_attr_setup_load_prog+0x8e>
mov    0x18(%rbp),%rax
movb   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_attr_setup_load_prog>:
movq   $0x0,(%rdi)
cmpq   $0x0,0x8(%rsp)
jle    1117 <bpf_attr_setup_load_prog+0x17>
mov    0x10(%rsp),%rax
movb   $0x0,(%rax)
ret

LLVM IR (-O0):
%union.bpf_attr = type { i64 }
define void @bpf_attr_setup_load_prog(%union.bpf_attr* %0, i64 %1, i64 %2, i8* %3, i8* %4, i64 %5, i64 %6, i8* %7) {
%9 = alloca %union.bpf_attr*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8*
store %union.bpf_attr* %0, %union.bpf_attr** %9
store i64 %1, i64* %10
store i64 %2, i64* %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i64 %5, i64* %14
store i64 %6, i64* %15
store i8* %7, i8** %16
%17 = load i64, i64* %10
%18 = load %union.bpf_attr*, %union.bpf_attr** %9
%19 = bitcast %union.bpf_attr* %18 to i64*
store i64 %17, i64* %19
%20 = load i64, i64* %11
%21 = load %union.bpf_attr*, %union.bpf_attr** %9
%22 = bitcast %union.bpf_attr* %21 to i64*
store i64 %20, i64* %22
%23 = load i8*, i8** %12
%24 = ptrtoint i8* %23 to i64
%25 = inttoptr i64 %24 to i8*
%26 = load %union.bpf_attr*, %union.bpf_attr** %9
%27 = bitcast %union.bpf_attr* %26 to i8**
store i8* %25, i8** %27
%28 = load i8*, i8** %13
%29 = ptrtoint i8* %28 to i64
%30 = inttoptr i64 %29 to i8*
%31 = load %union.bpf_attr*, %union.bpf_attr** %9
%32 = bitcast %union.bpf_attr* %31 to i8**
store i8* %30, i8** %32
%33 = load i64, i64* %14
%34 = load %union.bpf_attr*, %union.bpf_attr** %9
%35 = bitcast %union.bpf_attr* %34 to i64*
store i64 %33, i64* %35
%36 = load i64, i64* %15
%37 = load %union.bpf_attr*, %union.bpf_attr** %9
%38 = bitcast %union.bpf_attr* %37 to i64*
store i64 %36, i64* %38
%39 = load i8*, i8** %16
%40 = ptrtoint i8* %39 to i64
%41 = inttoptr i64 %40 to i8*
%42 = load %union.bpf_attr*, %union.bpf_attr** %9
%43 = bitcast %union.bpf_attr* %42 to i8**
store i8* %41, i8** %43
%44 = load %union.bpf_attr*, %union.bpf_attr** %9
%45 = bitcast %union.bpf_attr* %44 to i64*
store i64 0, i64* %45
%46 = load i64, i64* %15
%47 = icmp sgt i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %8
%49 = load i8*, i8** %16
%50 = getelementptr inbounds i8, i8* %49, i64 0
store i8 0, i8* %50
br label %51
51: ; preds = %48, %8
ret void
}

LLVM IR (-O2):
%union.bpf_attr = type { i64 }
define void @bpf_attr_setup_load_prog(%union.bpf_attr* nocapture writeonly %0, i64 %1, i64 %2, i8* nocapture readnone %3, i8* %4, i64 %5, i64 %6, i8* %7) {
%9 = getelementptr %union.bpf_attr, %union.bpf_attr* %0, i64 0, i32 0
store i64 0, i64* %9
%10 = icmp sgt i64 %6, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i8 0, i8* %7
br label %12
12: ; preds = %11, %8
ret void
}