#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 {
  int *cb;
  int /*<<< orphan*/ priority;
};

/* Variables and functions */
__attribute__((section("skb_ctx"), used)) int process(struct __sk_buff *skb) {
#pragma clang loop unroll(full)
  for (int i = 0; i < 5; i++) {
    if (skb->cb[i] != i + 1)
      return 1;
    skb->cb[i]++;
  }
  skb->priority++;
  return 0;
}


x86 assembly (clang, -O0):
<process>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1163 <process+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     1141 <process+0x41>
movl   $0x1,-0x4(%rbp)
jmp    1177 <process+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <process+0xf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<process>:
mov    (%rdi),%rcx
mov    (%rcx),%edx
mov    $0x1,%eax
cmp    $0x1,%edx
jne    1152 <process+0x52>
add    $0x1,%edx
mov    %edx,(%rcx)
mov    0x4(%rcx),%edx
cmp    $0x2,%edx
jne    1152 <process+0x52>
add    $0x1,%edx
mov    %edx,0x4(%rcx)
mov    0x8(%rcx),%edx
cmp    $0x3,%edx
jne    1152 <process+0x52>
add    $0x1,%edx
mov    %edx,0x8(%rcx)
mov    0xc(%rcx),%edx
cmp    $0x4,%edx
jne    1152 <process+0x52>
add    $0x1,%edx
mov    %edx,0xc(%rcx)
mov    0x10(%rcx),%edx
cmp    $0x5,%edx
jne    1152 <process+0x52>
add    $0x1,%edx
mov    %edx,0x10(%rcx)
addl   $0x1,0x8(%rdi)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
%struct.__sk_buff = type { i32*, i32 }
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.__sk_buff*)* @process to i8*)], section "llvm.metadata"
define i32 @process(%struct.__sk_buff* nocapture %0) section "skb_ctx" {
%2 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %0, i64 0, i32 0
%3 = load i32*, i32** %2
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %31
6: ; preds = %1
%7 = add nuw nsw i32 %4, 1
store i32 %7, i32* %3
%8 = getelementptr inbounds i32, i32* %3, i64 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %31
11: ; preds = %6
%12 = add nuw nsw i32 %9, 1
store i32 %12, i32* %8
%13 = getelementptr inbounds i32, i32* %3, i64 2
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %31
16: ; preds = %11
%17 = add nuw nsw i32 %14, 1
store i32 %17, i32* %13
%18 = getelementptr inbounds i32, i32* %3, i64 3
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 4
br i1 %20, label %21, label %31
21: ; preds = %16
%22 = add nuw nsw i32 %19, 1
store i32 %22, i32* %18
%23 = getelementptr inbounds i32, i32* %3, i64 4
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 5
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = add nuw nsw i32 %24, 1
store i32 %27, i32* %23
%28 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %0, i64 0, i32 1
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %1, %6, %11, %16, %21, %26
%32 = phi i32 [ 0, %26 ], [ 1, %21 ], [ 1, %16 ], [ 1, %11 ], [ 1, %6 ], [ 1, %1 ]
ret i32 %32
}