#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 /*<<< orphan*/ tuple;
struct bpf_sock_tuple {
  int dummy;
};
struct bpf_sock {
  int dummy;
};
struct __sk_buff {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ BPF_F_CURRENT_NETNS;
struct bpf_sock *bpf_sk_lookup_tcp(struct __sk_buff *, struct bpf_sock_tuple *,
                                   int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ bpf_sk_release(struct bpf_sock *);
__attribute__((section("fail_release_unchecked"), used)) int
bpf_sk_lookup_test4(struct __sk_buff *skb) {
  struct bpf_sock_tuple tuple = {};
  struct bpf_sock *sk;
  sk = bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0);
  bpf_sk_release(sk);
  return 0;
}


x86 assembly (clang, -O0):
<bpf_sk_lookup_test4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%ecx
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
xor    %r8d,%r8d
call   1050 <bpf_sk_lookup_tcp@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <bpf_sk_release@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_sk_lookup_test4>:
push   %rax
movl   $0x0,(%rsp)
mov    0x2ec9(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rsi
mov    $0x4,%edx
xor    %r8d,%r8d
call   1040 <bpf_sk_lookup_tcp@plt>
mov    %rax,%rdi
call   1030 <bpf_sk_release@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.__sk_buff = type { i32 }
%struct.bpf_sock_tuple = type { i32 }
%struct.bpf_sock = type { i32 }
@BPF_F_CURRENT_NETNS = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.__sk_buff*)* @bpf_sk_lookup_test4 to i8*)], section "llvm.metadata"
define i32 @bpf_sk_lookup_test4(%struct.__sk_buff* %0) section "fail_release_unchecked" {
%2 = alloca %struct.__sk_buff*
%3 = alloca %struct.bpf_sock_tuple
%4 = alloca %struct.bpf_sock*
store %struct.__sk_buff* %0, %struct.__sk_buff** %2
%5 = bitcast %struct.bpf_sock_tuple* %3 to i8*
%6 = load %struct.__sk_buff*, %struct.__sk_buff** %2
%7 = load i32, i32* @BPF_F_CURRENT_NETNS
%8 = call %struct.bpf_sock* @bpf_sk_lookup_tcp(%struct.__sk_buff* %6, %struct.bpf_sock_tuple* %3, i32 4, i32 %7, i32 0)
store %struct.bpf_sock* %8, %struct.bpf_sock** %4
%9 = load %struct.bpf_sock*, %struct.bpf_sock** %4
%10 = call i32 @bpf_sk_release(%struct.bpf_sock* %9)
ret i32 0
}

LLVM IR (-O2):
%struct.__sk_buff = type { i32 }
%struct.bpf_sock_tuple = type { i32 }
%struct.bpf_sock = type { i32 }
@BPF_F_CURRENT_NETNS = global i32 0
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.__sk_buff*)* @bpf_sk_lookup_test4 to i8*)], section "llvm.metadata"
define i32 @bpf_sk_lookup_test4(%struct.__sk_buff* %0) section "fail_release_unchecked" {
%2 = alloca %struct.bpf_sock_tuple
%3 = bitcast %struct.bpf_sock_tuple* %2 to i8*
%4 = getelementptr inbounds %struct.bpf_sock_tuple, %struct.bpf_sock_tuple* %2, i64 0, i32 0
store i32 0, i32* %4
%5 = load i32, i32* @BPF_F_CURRENT_NETNS
%6 = call %struct.bpf_sock* @bpf_sk_lookup_tcp(%struct.__sk_buff* %0, %struct.bpf_sock_tuple* %2, i32 4, i32 %5, i32 0)
%7 = call i32 @bpf_sk_release(%struct.bpf_sock* %6)
ret i32 0
}