#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*/ uint32_t;
struct in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ XFRM_POLICY_IN;
int /*<<< orphan*/ XFRM_POLICY_OUT;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ ksft_print_msg(char *, int /*<<< orphan*/, int);
scalar_t__ xfrm_policy_del(int, int /*<<< orphan*/, struct in_addr,
                           struct in_addr, int /*<<< orphan*/, struct in_addr,
                           struct in_addr);
int xfrm_cleanup(int xfrm_sock, uint32_t *seq, struct in_addr src,
                 struct in_addr dst, struct in_addr tunsrc,
                 struct in_addr tundst) {
  if (xfrm_policy_del(xfrm_sock, (*seq)++, src, dst, XFRM_POLICY_OUT, tunsrc,
                      tundst)) {
    ksft_print_msg("%d[%u] "
                   "Failed to add xfrm policy"
                   "\n",
                   getpid(), 1221);
    return -1;
  }
  if (xfrm_policy_del(xfrm_sock, (*seq)++, dst, src, XFRM_POLICY_IN, tunsrc,
                      tundst)) {
    ksft_print_msg("%d[%u] "
                   "Failed to add xfrm policy"
                   "\n",
                   getpid(), 1227);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<xfrm_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edx,-0x8(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %rsi,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    %esi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    0x2e7c(%rip),%rax
mov    (%rax),%r8d
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r9d
mov    -0x20(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <xfrm_policy_del@plt>
cmp    $0x0,%rax
je     11ac <xfrm_cleanup+0x7c>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
mov    $0x4c5,%edx
call   1050 <ksft_print_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <xfrm_cleanup+0xe2>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    %esi,%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    0x2e15(%rip),%rax
mov    (%rax),%r8d
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r9d
mov    -0x20(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <xfrm_policy_del@plt>
cmp    $0x0,%rax
je     120b <xfrm_cleanup+0xdb>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe0b(%rip),%rdi
mov    $0x4cb,%edx
call   1050 <ksft_print_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <xfrm_cleanup+0xe2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfrm_cleanup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r13d
mov    %r8d,%r9d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%esi
lea    0x1(%rsi),%eax
mov    %eax,(%rbx)
mov    0x2e83(%rip),%rax
mov    (%rax),%r8d
mov    %r13d,(%rsp)
mov    %r9d,0x14(%rsp)
call   1040 <xfrm_policy_del@plt>
mov    $0x4c5,%r14d
test   %rax,%rax
jne    11ab <xfrm_cleanup+0x7b>
mov    (%rbx),%esi
lea    0x1(%rsi),%eax
mov    %eax,(%rbx)
mov    0x2e51(%rip),%rax
mov    (%rax),%r8d
mov    %r13d,(%rsp)
mov    %ebp,%edi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    0x14(%rsp),%r9d
call   1040 <xfrm_policy_del@plt>
mov    $0x4cb,%r14d
test   %rax,%rax
je     11d7 <xfrm_cleanup+0xa7>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe47(%rip),%rdi
mov    %eax,%esi
mov    %r14d,%edx
call   1050 <ksft_print_msg@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    11c8 <xfrm_cleanup+0x98>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@XFRM_POLICY_OUT = global i32 0
@.str = [34 x i8] c"%d[%u] Failed to add xfrm policy\0A\00"
@XFRM_POLICY_IN = global i32 0
define i32 @xfrm_cleanup(i32 %0, i32* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.in_addr
%9 = alloca %struct.in_addr
%10 = alloca %struct.in_addr
%11 = alloca %struct.in_addr
%12 = alloca i32
%13 = alloca i32*
%14 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
store i32 %2, i32* %14
%15 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i32 %3, i32* %15
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %10, i32 0, i32 0
store i32 %4, i32* %16
%17 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %11, i32 0, i32 0
store i32 %5, i32* %17
store i32 %0, i32* %12
store i32* %1, i32** %13
%18 = load i32, i32* %12
%19 = load i32*, i32** %13
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
%22 = load i32, i32* @XFRM_POLICY_OUT
%23 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %10, i32 0, i32 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %11, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i64 @xfrm_policy_del(i32 %18, i32 %20, i32 %24, i32 %26, i32 %22, i32 %28, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %6
%34 = call i32 (...) @getpid()
%35 = call i32 @ksft_print_msg(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %34, i32 1221)
store i32 -1, i32* %7
br label %56
36: ; preds = %6
%37 = load i32, i32* %12
%38 = load i32*, i32** %13
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
%41 = load i32, i32* @XFRM_POLICY_IN
%42 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %10, i32 0, i32 0
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %11, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i64 @xfrm_policy_del(i32 %37, i32 %39, i32 %43, i32 %45, i32 %41, i32 %47, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %36
%53 = call i32 (...) @getpid()
%54 = call i32 @ksft_print_msg(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %53, i32 1227)
store i32 -1, i32* %7
br label %56
55: ; preds = %36
store i32 0, i32* %7
br label %56
56: ; preds = %55, %52, %33
%57 = load i32, i32* %7
ret i32 %57
}

LLVM IR (-O2):
@XFRM_POLICY_OUT = global i32 0
@.str = [34 x i8] c"%d[%u] Failed to add xfrm policy\0A\00"
@XFRM_POLICY_IN = global i32 0
define i32 @xfrm_cleanup(i32 %0, i32* nocapture %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 1
store i32 %8, i32* %1
%9 = load i32, i32* @XFRM_POLICY_OUT
%10 = tail call i64 @xfrm_policy_del(i32 %0, i32 %7, i32 %2, i32 %3, i32 %9, i32 %4, i32 %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
%15 = load i32, i32* @XFRM_POLICY_IN
%16 = tail call i64 @xfrm_policy_del(i32 %0, i32 %13, i32 %3, i32 %2, i32 %15, i32 %4, i32 %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %12, %6
%19 = phi i32 [ 1221, %6 ], [ 1227, %12 ]
%20 = tail call i32 (...) @getpid()
%21 = tail call i32 @ksft_print_msg(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %19)
br label %22
22: ; preds = %18, %12
%23 = phi i32 [ 0, %12 ], [ -1, %18 ]
ret i32 %23
}