#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 */
struct btf_type {
  int dummy;
};
struct btf_member {
  int /*<<< orphan*/ offset;
};
typedef int __u32;

/* Variables and functions */
int BTF_MEMBER_BITFIELD_SIZE(int /*<<< orphan*/);
int btf_kflag(struct btf_type const *);
struct btf_member *btf_members(struct btf_type const *);
__u32 btf_member_bitfield_size(const struct btf_type *t, __u32 member_idx) {
  const struct btf_member *m = btf_members(t) + member_idx;
  bool kflag = btf_kflag(t);
  return kflag ? BTF_MEMBER_BITFIELD_SIZE(m->offset) : 0;
}


x86 assembly (clang, -O0):
<btf_member_bitfield_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <btf_members@plt>
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <btf_kflag@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1180 <btf_member_bitfield_size+0x50>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <BTF_MEMBER_BITFIELD_SIZE@plt>
mov    %eax,-0x20(%rbp)
jmp    118a <btf_member_bitfield_size+0x5a>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    118a <btf_member_bitfield_size+0x5a>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btf_member_bitfield_size>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
call   1050 <btf_members@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1030 <btf_kflag@plt>
test   %eax,%eax
je     115d <btf_member_bitfield_size+0x2d>
movslq %r14d,%rax
mov    (%rbx,%rax,4),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <BTF_MEMBER_BITFIELD_SIZE@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.btf_type = type { i32 }
%struct.btf_member = type { i32 }
define i32 @btf_member_bitfield_size(%struct.btf_type* %0, i32 %1) {
%3 = alloca %struct.btf_type*
%4 = alloca i32
%5 = alloca %struct.btf_member*
%6 = alloca i32
store %struct.btf_type* %0, %struct.btf_type** %3
store i32 %1, i32* %4
%7 = load %struct.btf_type*, %struct.btf_type** %3
%8 = call %struct.btf_member* @btf_members(%struct.btf_type* %7)
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds %struct.btf_member, %struct.btf_member* %8, i64 %10
store %struct.btf_member* %11, %struct.btf_member** %5
%12 = load %struct.btf_type*, %struct.btf_type** %3
%13 = call i32 @btf_kflag(%struct.btf_type* %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load %struct.btf_member*, %struct.btf_member** %5
%18 = getelementptr inbounds %struct.btf_member, %struct.btf_member* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @BTF_MEMBER_BITFIELD_SIZE(i32 %19)
br label %22
21: ; preds = %2
br label %22
22: ; preds = %21, %16
%23 = phi i32 [ %20, %16 ], [ 0, %21 ]
ret i32 %23
}

LLVM IR (-O2):
%struct.btf_type = type { i32 }
%struct.btf_member = type { i32 }
define i32 @btf_member_bitfield_size(%struct.btf_type* %0, i32 %1) {
%3 = tail call %struct.btf_member* @btf_members(%struct.btf_type* %0)
%4 = tail call i32 @btf_kflag(%struct.btf_type* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds %struct.btf_member, %struct.btf_member* %3, i64 %7, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @BTF_MEMBER_BITFIELD_SIZE(i32 %9)
br label %11
11: ; preds = %2, %6
%12 = phi i32 [ %10, %6 ], [ 0, %2 ]
ret i32 %12
}