#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 __u64;
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
int load_word(struct __sk_buff *, int);
__u32 ipv6_addr_hash(struct __sk_buff *ctx, __u64 off) {
  __u64 w0 = load_word(ctx, off);
  __u64 w1 = load_word(ctx, off + 4);
  __u64 w2 = load_word(ctx, off + 8);
  __u64 w3 = load_word(ctx, off + 12);
  return (__u32)(w0 ^ w1 ^ w2 ^ w3);
}


x86 assembly (clang, -O0):
<ipv6_addr_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <load_word@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x4,%esi
call   1030 <load_word@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x8,%esi
call   1030 <load_word@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0xc,%esi
call   1030 <load_word@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
xor    -0x14(%rbp),%eax
xor    -0x18(%rbp),%eax
xor    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipv6_addr_hash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <load_word@plt>
mov    %eax,%r15d
lea    0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <load_word@plt>
mov    %eax,%ebp
lea    0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <load_word@plt>
mov    %eax,%r12d
add    $0xc,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <load_word@plt>
xor    %r15d,%ebp
xor    %r12d,%eax
xor    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.__sk_buff = type { i32 }
define i32 @ipv6_addr_hash(%struct.__sk_buff* %0, i32 %1) {
%3 = alloca %struct.__sk_buff*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.__sk_buff* %0, %struct.__sk_buff** %3
store i32 %1, i32* %4
%9 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%10 = load i32, i32* %4
%11 = call i32 @load_word(%struct.__sk_buff* %9, i32 %10)
store i32 %11, i32* %5
%12 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 4
%15 = call i32 @load_word(%struct.__sk_buff* %12, i32 %14)
store i32 %15, i32* %6
%16 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 8
%19 = call i32 @load_word(%struct.__sk_buff* %16, i32 %18)
store i32 %19, i32* %7
%20 = load %struct.__sk_buff*, %struct.__sk_buff** %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 12
%23 = call i32 @load_word(%struct.__sk_buff* %20, i32 %22)
store i32 %23, i32* %8
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = xor i32 %24, %25
%27 = load i32, i32* %7
%28 = xor i32 %26, %27
%29 = load i32, i32* %8
%30 = xor i32 %28, %29
ret i32 %30
}

LLVM IR (-O2):
%struct.__sk_buff = type { i32 }
define i32 @ipv6_addr_hash(%struct.__sk_buff* %0, i32 %1) {
%3 = tail call i32 @load_word(%struct.__sk_buff* %0, i32 %1)
%4 = add nsw i32 %1, 4
%5 = tail call i32 @load_word(%struct.__sk_buff* %0, i32 %4)
%6 = add nsw i32 %1, 8
%7 = tail call i32 @load_word(%struct.__sk_buff* %0, i32 %6)
%8 = add nsw i32 %1, 12
%9 = tail call i32 @load_word(%struct.__sk_buff* %0, i32 %8)
%10 = xor i32 %5, %3
%11 = xor i32 %10, %7
%12 = xor i32 %11, %9
ret i32 %12
}