#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 __sk_buff {
  scalar_t__ protocol;
};

/* Variables and functions */
int /*<<< orphan*/ ETH_P_IPV6;
int /*<<< orphan*/ IPPROTO_UDP;
int TC_ACT_OK;
scalar_t__ ___constant_swab16(int /*<<< orphan*/);
int encap_ipv6(struct __sk_buff *, int /*<<< orphan*/, int /*<<< orphan*/);
__attribute__((section("encap_ip6udp_none"), used)) int
__encap_ip6udp_none(struct __sk_buff *skb) {
  if (skb->protocol == ___constant_swab16(ETH_P_IPV6))
    return encap_ipv6(skb, IPPROTO_UDP, ETH_P_IPV6);
  else
    return TC_ACT_OK;
}


x86 assembly (clang, -O0):
<__encap_ip6udp_none>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
call   1040 <___constant_swab16@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jne    1178 <__encap_ip6udp_none+0x58>
mov    -0x10(%rbp),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
call   1030 <encap_ipv6@plt>
mov    %eax,-0x4(%rbp)
jmp    1184 <__encap_ip6udp_none+0x64>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__encap_ip6udp_none>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%r15
mov    0x2ea6(%rip),%r14
mov    (%r14),%edi
call   1040 <___constant_swab16@plt>
cmp    %rax,%r15
jne    1158 <__encap_ip6udp_none+0x38>
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <encap_ipv6@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__sk_buff = type { i64 }
@ETH_P_IPV6 = global i32 0
@IPPROTO_UDP = global i32 0
@TC_ACT_OK = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.__sk_buff*)* @__encap_ip6udp_none to i8*)], section "llvm.metadata"
define i32 @__encap_ip6udp_none(%struct.__sk_buff* %0) section "encap_ip6udp_none" {
%2 = alloca i32
%3 = alloca %struct.__sk_buff*
store %struct.__sk_buff* %0, %struct.__sk_buff** %3
%4 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%5 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %4, i32 0, i32 0
%6 = load i64, i64* %5
%7 = load i32, i32* @ETH_P_IPV6
%8 = call i64 @___constant_swab16(i32 %7)
%9 = icmp eq i64 %6, %8
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%12 = load i32, i32* @IPPROTO_UDP
%13 = load i32, i32* @ETH_P_IPV6
%14 = call i32 @encap_ipv6(%struct.__sk_buff* %11, i32 %12, i32 %13)
store i32 %14, i32* %2
br label %17
15: ; preds = %1
%16 = load i32, i32* @TC_ACT_OK
store i32 %16, i32* %2
br label %17
17: ; preds = %15, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.__sk_buff = type { i64 }
@ETH_P_IPV6 = global i32 0
@IPPROTO_UDP = global i32 0
@TC_ACT_OK = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.__sk_buff*)* @__encap_ip6udp_none to i8*)], section "llvm.metadata"
define i32 @__encap_ip6udp_none(%struct.__sk_buff* %0) section "encap_ip6udp_none" {
%2 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = load i32, i32* @ETH_P_IPV6
%5 = tail call i64 @___constant_swab16(i32 %4)
%6 = icmp eq i64 %3, %5
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @IPPROTO_UDP
%9 = load i32, i32* @ETH_P_IPV6
%10 = tail call i32 @encap_ipv6(%struct.__sk_buff* %0, i32 %8, i32 %9)
br label %13
11: ; preds = %1
%12 = load i32, i32* @TC_ACT_OK
br label %13
13: ; preds = %11, %7
%14 = phi i32 [ %10, %7 ], [ %12, %11 ]
ret i32 %14
}