#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 xdp_md {
  scalar_t__ data;
  scalar_t__ data_end;
};

/* Variables and functions */
int XDP_DROP;
int XDP_TX;
scalar_t__ bpf_xdp_adjust_tail(struct xdp_md *, scalar_t__);
__attribute__((section("xdp_adjust_tail"), used)) int
_xdp_adjust_tail(struct xdp_md *xdp) {
  void *data_end = (void *)(long)xdp->data_end;
  void *data = (void *)(long)xdp->data;
  int offset = 0;
  if (data_end - data == 54)
    offset = 256;
  else
    offset = 20;
  if (bpf_xdp_adjust_tail(xdp, 0 - offset))
    return XDP_DROP;
  return XDP_TX;
}


x86 assembly (clang, -O0):
<_xdp_adjust_tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x36,%rax
jne    115b <_xdp_adjust_tail+0x4b>
movl   $0x100,-0x24(%rbp)
jmp    1162 <_xdp_adjust_tail+0x52>
movl   $0x14,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
sub    -0x24(%rbp),%eax
movslq %eax,%rsi
call   1030 <bpf_xdp_adjust_tail@plt>
cmp    $0x0,%rax
je     118e <_xdp_adjust_tail+0x7e>
mov    0x2e5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119a <_xdp_adjust_tail+0x8a>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xdp_adjust_tail>:
push   %rax
mov    0x8(%rdi),%rax
sub    (%rdi),%rax
cmp    $0x36,%rax
mov    $0xffffffffffffff00,%rax
mov    $0xffffffffffffffec,%rsi
cmove  %rax,%rsi
call   1030 <bpf_xdp_adjust_tail@plt>
test   %rax,%rax
jne    1141 <_xdp_adjust_tail+0x31>
mov    0x2eb1(%rip),%rax
jmp    1148 <_xdp_adjust_tail+0x38>
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.xdp_md = type { i64, i64 }
@XDP_DROP = global i32 0
@XDP_TX = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.xdp_md*)* @_xdp_adjust_tail to i8*)], section "llvm.metadata"
define i32 @_xdp_adjust_tail(%struct.xdp_md* %0) section "xdp_adjust_tail" {
%2 = alloca i32
%3 = alloca %struct.xdp_md*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store %struct.xdp_md* %0, %struct.xdp_md** %3
%7 = load %struct.xdp_md*, %struct.xdp_md** %3
%8 = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %7, i32 0, i32 1
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %4
%11 = load %struct.xdp_md*, %struct.xdp_md** %3
%12 = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %5
store i32 0, i32* %6
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = icmp eq i64 %19, 54
br i1 %20, label %21, label %22
21: ; preds = %1
store i32 256, i32* %6
br label %23
22: ; preds = %1
store i32 20, i32* %6
br label %23
23: ; preds = %22, %21
%24 = load %struct.xdp_md*, %struct.xdp_md** %3
%25 = load i32, i32* %6
%26 = sub nsw i32 0, %25
%27 = sext i32 %26 to i64
%28 = call i64 @bpf_xdp_adjust_tail(%struct.xdp_md* %24, i64 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = load i32, i32* @XDP_DROP
store i32 %31, i32* %2
br label %34
32: ; preds = %23
%33 = load i32, i32* @XDP_TX
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.xdp_md = type { i64, i64 }
@XDP_DROP = global i32 0
@XDP_TX = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.xdp_md*)* @_xdp_adjust_tail to i8*)], section "llvm.metadata"
define i32 @_xdp_adjust_tail(%struct.xdp_md* %0) section "xdp_adjust_tail" {
%2 = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %0, i64 0, i32 1
%3 = load i64, i64* %2
%4 = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = sub i64 %3, %5
%7 = icmp eq i64 %6, 54
%8 = select i1 %7, i64 -256, i64 -20
%9 = tail call i64 @bpf_xdp_adjust_tail(%struct.xdp_md* %0, i64 %8)
%10 = icmp eq i64 %9, 0
%11 = load i32, i32* @XDP_TX
%12 = load i32, i32* @XDP_DROP
%13 = select i1 %10, i32 %11, i32 %12
ret i32 %13
}