#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 dummy;
};
typedef int /*<<< orphan*/ __u8;

/* Variables and functions */
int /*<<< orphan*/ load_byte(struct __sk_buff *, int);
void fill_payload_bucket(struct __sk_buff *skb, int offset, __u8 *bucket,
                         int bsize) {
#pragma unroll
  for (int i = 0; i != bsize; i++) {
    bucket[i] = load_byte(skb, offset + i);
  }
}


x86 assembly (clang, -O0):
<fill_payload_bucket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1163 <fill_payload_bucket+0x53>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x20(%rbp),%esi
call   1030 <load_byte@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <fill_payload_bucket+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_payload_bucket>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
je     1228 <fill_payload_bucket+0x118>
mov    %ecx,%r14d
mov    %rdx,%r13
mov    %rdi,%r12
lea    -0x1(%r14),%eax
cmp    $0x7,%eax
mov    %rsi,(%rsp)
jae    1140 <fill_payload_bucket+0x30>
xor    %ebx,%ebx
jmp    11f2 <fill_payload_bucket+0xe2>
mov    %esi,%ebp
mov    %r14d,%r15d
and    $0xfffffff8,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x0(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x1,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x4(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x2,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x8(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x3,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0xc(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x4,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x10(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x5,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x14(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x6,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x18(%r13,%rbx,4)
lea    (%rbx,%rbp,1),%esi
add    $0x7,%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,0x1c(%r13,%rbx,4)
add    $0x8,%rbx
cmp    %ebx,%r15d
jne    1150 <fill_payload_bucket+0x40>
test   $0x7,%r14b
mov    (%rsp),%r15
je     1228 <fill_payload_bucket+0x118>
add    %ebx,%r15d
lea    0x0(,%rbx,4),%rbx
add    %r13,%rbx
and    $0x7,%r14d
xor    %ebp,%ebp
lea    (%r15,%rbp,1),%esi
mov    %r12,%rdi
call   1030 <load_byte@plt>
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    1210 <fill_payload_bucket+0x100>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.__sk_buff = type { i32 }
define void @fill_payload_bucket(%struct.__sk_buff* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca %struct.__sk_buff*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store %struct.__sk_buff* %0, %struct.__sk_buff** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %24, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load %struct.__sk_buff*, %struct.__sk_buff** %5
%16 = load i32, i32* %6
%17 = load i32, i32* %9
%18 = add nsw i32 %16, %17
%19 = call i32 @load_byte(%struct.__sk_buff* %15, i32 %18)
%20 = load i32*, i32** %7
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 %19, i32* %23
br label %24
24: ; preds = %14
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %10
27: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.__sk_buff = type { i32 }
define void @fill_payload_bucket(%struct.__sk_buff* %0, i32 %1, i32* nocapture writeonly %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %25, label %6
6: ; preds = %4
%7 = add i32 %3, -1
%8 = and i32 %3, 7
%9 = icmp ult i32 %7, 7
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = and i32 %3, -8
br label %26
12: ; preds = %26, %6
%13 = phi i64 [ 0, %6 ], [ %68, %26 ]
%14 = icmp eq i32 %8, 0
br i1 %14, label %25, label %15
15: ; preds = %12, %15
%16 = phi i64 [ %22, %15 ], [ %13, %12 ]
%17 = phi i32 [ %23, %15 ], [ 0, %12 ]
%18 = trunc i64 %16 to i32
%19 = add i32 %18, %1
%20 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %19)
%21 = getelementptr inbounds i32, i32* %2, i64 %16
store i32 %20, i32* %21
%22 = add nuw nsw i64 %16, 1
%23 = add nuw nsw i32 %17, 1
%24 = icmp eq i32 %23, %8
br i1 %24, label %25, label %15
25: ; preds = %15, %12, %4
ret void
26: ; preds = %26, %10
%27 = phi i64 [ 0, %10 ], [ %68, %26 ]
%28 = phi i32 [ 0, %10 ], [ %69, %26 ]
%29 = trunc i64 %27 to i32
%30 = add i32 %29, %1
%31 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %30)
%32 = getelementptr inbounds i32, i32* %2, i64 %27
store i32 %31, i32* %32
%33 = or i64 %27, 1
%34 = trunc i64 %33 to i32
%35 = add i32 %34, %1
%36 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %35)
%37 = getelementptr inbounds i32, i32* %2, i64 %33
store i32 %36, i32* %37
%38 = or i64 %27, 2
%39 = trunc i64 %38 to i32
%40 = add i32 %39, %1
%41 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %40)
%42 = getelementptr inbounds i32, i32* %2, i64 %38
store i32 %41, i32* %42
%43 = or i64 %27, 3
%44 = trunc i64 %43 to i32
%45 = add i32 %44, %1
%46 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %45)
%47 = getelementptr inbounds i32, i32* %2, i64 %43
store i32 %46, i32* %47
%48 = or i64 %27, 4
%49 = trunc i64 %48 to i32
%50 = add i32 %49, %1
%51 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %50)
%52 = getelementptr inbounds i32, i32* %2, i64 %48
store i32 %51, i32* %52
%53 = or i64 %27, 5
%54 = trunc i64 %53 to i32
%55 = add i32 %54, %1
%56 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %55)
%57 = getelementptr inbounds i32, i32* %2, i64 %53
store i32 %56, i32* %57
%58 = or i64 %27, 6
%59 = trunc i64 %58 to i32
%60 = add i32 %59, %1
%61 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %60)
%62 = getelementptr inbounds i32, i32* %2, i64 %58
store i32 %61, i32* %62
%63 = or i64 %27, 7
%64 = trunc i64 %63 to i32
%65 = add i32 %64, %1
%66 = tail call i32 @load_byte(%struct.__sk_buff* %0, i32 %65)
%67 = getelementptr inbounds i32, i32* %2, i64 %63
store i32 %66, i32* %67
%68 = add nuw nsw i64 %27, 8
%69 = add i32 %28, 8
%70 = icmp eq i32 %69, %11
br i1 %70, label %12, label %26
}