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

/* Variables and functions */
int /*<<< orphan*/ gen_spi(struct in_addr);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ ksft_print_msg(char *, int /*<<< orphan*/, int);
scalar_t__ xfrm_state_del(int, int /*<<< orphan*/, int /*<<< orphan*/,
                          struct in_addr, struct in_addr, int /*<<< orphan*/);
int xfrm_delete(int xfrm_sock, uint32_t *seq, struct in_addr src,
                struct in_addr dst, struct in_addr tunsrc,
                struct in_addr tundst, uint8_t proto) {
  if (xfrm_state_del(xfrm_sock, (*seq)++, gen_spi(src), src, dst, proto)) {
    ksft_print_msg("%d[%u] "
                   "Failed to remove xfrm state"
                   "\n",
                   getpid(), 1273);
    return -1;
  }
  if (xfrm_state_del(xfrm_sock, (*seq)++, gen_spi(src), dst, src, proto)) {
    ksft_print_msg("%d[%u] "
                   "Failed to remove xfrm state"
                   "\n",
                   getpid(), 1278);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<xfrm_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
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),%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    %ecx,-0x34(%rbp)
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edi
call   1050 <gen_spi@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    %eax,%edx
mov    0x10(%rbp),%r9d
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1030 <xfrm_state_del@plt>
cmp    $0x0,%rax
je     11c4 <xfrm_delete+0x84>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x4f9,%edx
call   1060 <ksft_print_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <xfrm_delete+0xef>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    %ecx,-0x3c(%rbp)
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edi
call   1050 <gen_spi@plt>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    %eax,%edx
mov    0x10(%rbp),%r9d
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%r8d
call   1030 <xfrm_state_del@plt>
cmp    $0x0,%rax
je     1228 <xfrm_delete+0xe8>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
mov    $0x4fe,%edx
call   1060 <ksft_print_msg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <xfrm_delete+0xef>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfrm_delete>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %edi,%r12d
mov    0x40(%rsp),%r13d
mov    (%rsi),%ebx
lea    0x1(%rbx),%eax
mov    %eax,(%rsi)
mov    %edx,%edi
call   1050 <gen_spi@plt>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %eax,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    %r13d,%r9d
call   1030 <xfrm_state_del@plt>
mov    $0x4f9,%r13d
test   %rax,%rax
jne    11bd <xfrm_delete+0x7d>
mov    0x0(%rbp),%ebx
lea    0x1(%rbx),%eax
mov    %eax,0x0(%rbp)
mov    %r14d,%edi
call   1050 <gen_spi@plt>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %eax,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
mov    0x40(%rsp),%r9d
call   1030 <xfrm_state_del@plt>
mov    $0x4fe,%r13d
test   %rax,%rax
je     11e9 <xfrm_delete+0xa9>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe35(%rip),%rdi
mov    %eax,%esi
mov    %r13d,%edx
call   1060 <ksft_print_msg@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    11da <xfrm_delete+0x9a>

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

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