#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ s_addr;
};
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct ip {
  int /*<<< orphan*/ ip_id;
  int /*<<< orphan*/ ip_p;
  TYPE_2__ ip_dst;
  TYPE_1__ ip_src;
};

/* Variables and functions */
unsigned long hash_32(int /*<<< orphan*/, int);
unsigned long pna_frag_hash(struct ip *iphdr) {
  unsigned long hash = 0;
  hash ^= hash_32(iphdr->ip_src.s_addr, 32);
  hash ^= hash_32(iphdr->ip_dst.s_addr, 32);
  hash ^= (hash_32(iphdr->ip_p, 16) << 16);
  hash ^= hash_32(iphdr->ip_id, 16);
  return hash;
}


x86 assembly (clang, -O0):
<pna_frag_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
mov    $0x20,%esi
call   1030 <hash_32@plt>
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x20,%esi
call   1030 <hash_32@plt>
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    $0x10,%esi
call   1030 <hash_32@plt>
shl    $0x10,%rax
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    $0x10,%esi
call   1030 <hash_32@plt>
xor    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pna_frag_hash>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0xc(%rdi),%edi
mov    $0x20,%esi
call   1030 <hash_32@plt>
mov    %rax,%r14
mov    0x8(%r15),%edi
mov    $0x20,%esi
call   1030 <hash_32@plt>
mov    %rax,%r12
xor    %r14,%r12
mov    0x4(%r15),%edi
mov    $0x10,%esi
call   1030 <hash_32@plt>
mov    %rax,%rbx
shl    $0x10,%rbx
xor    %r12,%rbx
mov    (%r15),%edi
mov    $0x10,%esi
call   1030 <hash_32@plt>
xor    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ip = type { i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
define i64 @pna_frag_hash(%struct.ip* %0) {
%2 = alloca %struct.ip*
%3 = alloca i64
store %struct.ip* %0, %struct.ip** %2
store i64 0, i64* %3
%4 = load %struct.ip*, %struct.ip** %2
%5 = getelementptr inbounds %struct.ip, %struct.ip* %4, i32 0, i32 3
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = call i64 @hash_32(i32 %7, i32 32)
%9 = load i64, i64* %3
%10 = xor i64 %9, %8
store i64 %10, i64* %3
%11 = load %struct.ip*, %struct.ip** %2
%12 = getelementptr inbounds %struct.ip, %struct.ip* %11, i32 0, i32 2
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i64 @hash_32(i32 %14, i32 32)
%16 = load i64, i64* %3
%17 = xor i64 %16, %15
store i64 %17, i64* %3
%18 = load %struct.ip*, %struct.ip** %2
%19 = getelementptr inbounds %struct.ip, %struct.ip* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = call i64 @hash_32(i32 %20, i32 16)
%22 = shl i64 %21, 16
%23 = load i64, i64* %3
%24 = xor i64 %23, %22
store i64 %24, i64* %3
%25 = load %struct.ip*, %struct.ip** %2
%26 = getelementptr inbounds %struct.ip, %struct.ip* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i64 @hash_32(i32 %27, i32 16)
%29 = load i64, i64* %3
%30 = xor i64 %29, %28
store i64 %30, i64* %3
%31 = load i64, i64* %3
ret i64 %31
}

LLVM IR (-O2):
%struct.ip = type { i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
define i64 @pna_frag_hash(%struct.ip* nocapture %0) {
%2 = getelementptr inbounds %struct.ip, %struct.ip* %0, i64 0, i32 3, i32 0
%3 = load i32, i32* %2
%4 = tail call i64 @hash_32(i32 %3, i32 32)
%5 = getelementptr inbounds %struct.ip, %struct.ip* %0, i64 0, i32 2, i32 0
%6 = load i32, i32* %5
%7 = tail call i64 @hash_32(i32 %6, i32 32)
%8 = xor i64 %7, %4
%9 = getelementptr inbounds %struct.ip, %struct.ip* %0, i64 0, i32 1
%10 = load i32, i32* %9
%11 = tail call i64 @hash_32(i32 %10, i32 16)
%12 = shl i64 %11, 16
%13 = xor i64 %8, %12
%14 = getelementptr inbounds %struct.ip, %struct.ip* %0, i64 0, i32 0
%15 = load i32, i32* %14
%16 = tail call i64 @hash_32(i32 %15, i32 16)
%17 = xor i64 %13, %16
ret i64 %17
}