#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 */
typedef int __u32;

/* Variables and functions */
unsigned char IFLA_XDP_DRV_PROG_ID;
unsigned char IFLA_XDP_HW_PROG_ID;
unsigned char IFLA_XDP_PROG_ID;
unsigned char IFLA_XDP_SKB_PROG_ID;
unsigned char IFLA_XDP_UNSPEC;
unsigned char XDP_ATTACHED_MULTI;
int XDP_FLAGS_DRV_MODE;
int XDP_FLAGS_HW_MODE;
int XDP_FLAGS_SKB_MODE;
unsigned char get_xdp_id_attr(unsigned char mode, __u32 flags) {
  if (mode != XDP_ATTACHED_MULTI)
    return IFLA_XDP_PROG_ID;
  if (flags & XDP_FLAGS_DRV_MODE)
    return IFLA_XDP_DRV_PROG_ID;
  if (flags & XDP_FLAGS_HW_MODE)
    return IFLA_XDP_HW_PROG_ID;
  if (flags & XDP_FLAGS_SKB_MODE)
    return IFLA_XDP_SKB_PROG_ID;
  return IFLA_XDP_UNSPEC;
}


x86 assembly (clang, -O0):
<get_xdp_id_attr>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %esi,-0x8(%rbp)
movzbl -0x2(%rbp),%eax
mov    0x2ec0(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
je     1134 <get_xdp_id_attr+0x34>
mov    0x2e96(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11b2 <get_xdp_id_attr+0xb2>
mov    -0x8(%rbp),%eax
mov    0x2ea2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     115a <get_xdp_id_attr+0x5a>
mov    0x2e50(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11b2 <get_xdp_id_attr+0xb2>
mov    -0x8(%rbp),%eax
mov    0x2e64(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1180 <get_xdp_id_attr+0x80>
mov    0x2e22(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11b2 <get_xdp_id_attr+0xb2>
mov    -0x8(%rbp),%eax
mov    0x2e26(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a6 <get_xdp_id_attr+0xa6>
mov    0x2e1c(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11b2 <get_xdp_id_attr+0xb2>
mov    0x2e43(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_xdp_id_attr>:
mov    0x2ed1(%rip),%rax
cmp    %dil,(%rax)
jne    1121 <get_xdp_id_attr+0x21>
mov    0x2ecd(%rip),%rax
test   %esi,(%rax)
je     112b <get_xdp_id_attr+0x2b>
mov    0x2e82(%rip),%rax
mov    (%rax),%al
ret
mov    0x2e98(%rip),%rax
mov    (%rax),%al
ret
mov    0x2e96(%rip),%rax
test   %esi,(%rax)
je     1140 <get_xdp_id_attr+0x40>
mov    0x2e5b(%rip),%rax
mov    (%rax),%al
ret
mov    0x2e69(%rip),%rax
test   %esi,(%rax)
jne    1155 <get_xdp_id_attr+0x55>
mov    0x2e9e(%rip),%rax
mov    (%rax),%al
ret
mov    0x2e5c(%rip),%rax
mov    (%rax),%al
ret

LLVM IR (-O0):
@XDP_ATTACHED_MULTI = global i8 0
@IFLA_XDP_PROG_ID = global i8 0
@XDP_FLAGS_DRV_MODE = global i32 0
@IFLA_XDP_DRV_PROG_ID = global i8 0
@XDP_FLAGS_HW_MODE = global i32 0
@IFLA_XDP_HW_PROG_ID = global i8 0
@XDP_FLAGS_SKB_MODE = global i32 0
@IFLA_XDP_SKB_PROG_ID = global i8 0
@IFLA_XDP_UNSPEC = global i8 0
define zeroext i8 @get_xdp_id_attr(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = load i8, i8* @XDP_ATTACHED_MULTI
%9 = zext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i8, i8* @IFLA_XDP_PROG_ID
store i8 %12, i8* %3
br label %36
13: ; preds = %2
%14 = load i32, i32* %5
%15 = load i32, i32* @XDP_FLAGS_DRV_MODE
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i8, i8* @IFLA_XDP_DRV_PROG_ID
store i8 %19, i8* %3
br label %36
20: ; preds = %13
%21 = load i32, i32* %5
%22 = load i32, i32* @XDP_FLAGS_HW_MODE
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i8, i8* @IFLA_XDP_HW_PROG_ID
store i8 %26, i8* %3
br label %36
27: ; preds = %20
%28 = load i32, i32* %5
%29 = load i32, i32* @XDP_FLAGS_SKB_MODE
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = load i8, i8* @IFLA_XDP_SKB_PROG_ID
store i8 %33, i8* %3
br label %36
34: ; preds = %27
%35 = load i8, i8* @IFLA_XDP_UNSPEC
store i8 %35, i8* %3
br label %36
36: ; preds = %34, %32, %25, %18, %11
%37 = load i8, i8* %3
ret i8 %37
}

LLVM IR (-O2):
@XDP_ATTACHED_MULTI = global i8 0
@IFLA_XDP_PROG_ID = global i8 0
@XDP_FLAGS_DRV_MODE = global i32 0
@IFLA_XDP_DRV_PROG_ID = global i8 0
@XDP_FLAGS_HW_MODE = global i32 0
@IFLA_XDP_HW_PROG_ID = global i8 0
@XDP_FLAGS_SKB_MODE = global i32 0
@IFLA_XDP_SKB_PROG_ID = global i8 0
@IFLA_XDP_UNSPEC = global i8 0
define zeroext i8 @get_xdp_id_attr(i8 zeroext %0, i32 %1) {
%3 = load i8, i8* @XDP_ATTACHED_MULTI
%4 = icmp eq i8 %3, %0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = load i32, i32* @XDP_FLAGS_DRV_MODE
%7 = and i32 %6, %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = load i32, i32* @XDP_FLAGS_HW_MODE
%11 = and i32 %10, %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* @XDP_FLAGS_SKB_MODE
%15 = and i32 %14, %1
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* @IFLA_XDP_UNSPEC, i8* @IFLA_XDP_SKB_PROG_ID
br label %18
18: ; preds = %13, %9, %5, %2
%19 = phi i8* [ @IFLA_XDP_PROG_ID, %2 ], [ @IFLA_XDP_DRV_PROG_ID, %5 ], [ @IFLA_XDP_HW_PROG_ID, %9 ], [ %17, %13 ]
%20 = load i8, i8* %19
ret i8 %20
}