#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ _wymix32(unsigned int *, unsigned int *);
unsigned int _wyr24(int /*<<< orphan*/ const *, unsigned int);
unsigned int _wyr32(int /*<<< orphan*/ const *);
unsigned wyhash32(const void *key, uint64_t len, unsigned seed) {
  const uint8_t *p = (const uint8_t *)key;
  uint64_t i = len;
  unsigned see1 = (unsigned)len;
  seed ^= (unsigned)(len >> 32);
  _wymix32(&seed, &see1);
  for (; i > 8; i -= 8, p += 8) {
    seed ^= _wyr32(p);
    see1 ^= _wyr32(p + 4);
    _wymix32(&seed, &see1);
  }
  if (i >= 4) {
    seed ^= _wyr32(p);
    see1 ^= _wyr32(p + i - 4);
  } else if (i)
    seed ^= _wyr24(p, (unsigned)i);
  _wymix32(&seed, &see1);
  _wymix32(&seed, &see1);
  return seed ^ see1;
}


x86 assembly (clang, -O0):
<wyhash32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
xor    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <_wymix32@plt>
cmpl   $0x8,-0x1c(%rbp)
jle    11c6 <wyhash32+0x96>
mov    -0x18(%rbp),%rdi
call   1030 <_wyr32@plt>
xor    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x10,%rdi
call   1030 <_wyr32@plt>
xor    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <_wymix32@plt>
mov    -0x1c(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
jmp    1173 <wyhash32+0x43>
cmpl   $0x4,-0x1c(%rbp)
jl     1202 <wyhash32+0xd2>
mov    -0x18(%rbp),%rdi
call   1030 <_wyr32@plt>
xor    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
add    $0xfffffffffffffff0,%rdi
call   1030 <_wyr32@plt>
xor    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1223 <wyhash32+0xf3>
cmpl   $0x0,-0x1c(%rbp)
je     121e <wyhash32+0xee>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <_wyr24@plt>
xor    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1223 <wyhash32+0xf3>
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <_wymix32@plt>
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <_wymix32@plt>
mov    -0x10(%rbp),%eax
xor    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wyhash32>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r12d
mov    %rdi,%rbx
mov    %edx,0x8(%rsp)
mov    %esi,0xc(%rsp)
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1040 <_wymix32@plt>
cmp    $0x9,%r12d
jl     11a4 <wyhash32+0x74>
lea    0x8(%rsp),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
mov    %r12d,%ebp
mov    %rbx,%rdi
call   1030 <_wyr32@plt>
xor    %eax,0x8(%rsp)
lea    0x10(%rbx),%rdi
call   1030 <_wyr32@plt>
xor    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <_wymix32@plt>
lea    -0x8(%rbp),%r12d
add    $0x20,%rbx
cmp    $0x10,%ebp
ja     1170 <wyhash32+0x40>
cmp    $0x4,%r12d
jl     11cc <wyhash32+0x9c>
mov    %rbx,%rdi
call   1030 <_wyr32@plt>
xor    %eax,0x8(%rsp)
mov    %r12d,%eax
lea    (%rbx,%rax,4),%rdi
add    $0xfffffffffffffff0,%rdi
call   1030 <_wyr32@plt>
xor    %eax,0xc(%rsp)
jmp    11e0 <wyhash32+0xb0>
test   %r12d,%r12d
je     11e0 <wyhash32+0xb0>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1050 <_wyr24@plt>
xor    %eax,0x8(%rsp)
lea    0x8(%rsp),%rbx
lea    0xc(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <_wymix32@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <_wymix32@plt>
mov    0xc(%rsp),%eax
xor    0x8(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @wyhash32(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %7
%12 = load i32, i32* %5
store i32 %12, i32* %8
%13 = load i32, i32* %5
store i32 %13, i32* %9
%14 = load i32, i32* %5
%15 = ashr i32 %14, 32
%16 = load i32, i32* %6
%17 = xor i32 %16, %15
store i32 %17, i32* %6
%18 = call i32 @_wymix32(i32* %6, i32* %9)
br label %19
19: ; preds = %33, %3
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 8
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load i32*, i32** %7
%24 = call i32 @_wyr32(i32* %23)
%25 = load i32, i32* %6
%26 = xor i32 %25, %24
store i32 %26, i32* %6
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i64 4
%29 = call i32 @_wyr32(i32* %28)
%30 = load i32, i32* %9
%31 = xor i32 %30, %29
store i32 %31, i32* %9
%32 = call i32 @_wymix32(i32* %6, i32* %9)
br label %33
33: ; preds = %22
%34 = load i32, i32* %8
%35 = sub nsw i32 %34, 8
store i32 %35, i32* %8
%36 = load i32*, i32** %7
%37 = getelementptr inbounds i32, i32* %36, i64 8
store i32* %37, i32** %7
br label %19
38: ; preds = %19
%39 = load i32, i32* %8
%40 = icmp sge i32 %39, 4
br i1 %40, label %41, label %54
41: ; preds = %38
%42 = load i32*, i32** %7
%43 = call i32 @_wyr32(i32* %42)
%44 = load i32, i32* %6
%45 = xor i32 %44, %43
store i32 %45, i32* %6
%46 = load i32*, i32** %7
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = getelementptr inbounds i32, i32* %49, i64 -4
%51 = call i32 @_wyr32(i32* %50)
%52 = load i32, i32* %9
%53 = xor i32 %52, %51
store i32 %53, i32* %9
br label %64
54: ; preds = %38
%55 = load i32, i32* %8
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %63
57: ; preds = %54
%58 = load i32*, i32** %7
%59 = load i32, i32* %8
%60 = call i32 @_wyr24(i32* %58, i32 %59)
%61 = load i32, i32* %6
%62 = xor i32 %61, %60
store i32 %62, i32* %6
br label %63
63: ; preds = %57, %54
br label %64
64: ; preds = %63, %41
%65 = call i32 @_wymix32(i32* %6, i32* %9)
%66 = call i32 @_wymix32(i32* %6, i32* %9)
%67 = load i32, i32* %6
%68 = load i32, i32* %9
%69 = xor i32 %67, %68
ret i32 %69
}

LLVM IR (-O2):
define i32 @wyhash32(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
store i32 %2, i32* %4
%6 = bitcast i8* %0 to i32*
%7 = bitcast i32* %5 to i8*
store i32 %1, i32* %5
%8 = call i32 @_wymix32(i32* %4, i32* %5)
%9 = icmp sgt i32 %1, 8
br i1 %9, label %10, label %24
10: ; preds = %3, %10
%11 = phi i32 [ %21, %10 ], [ %1, %3 ]
%12 = phi i32* [ %22, %10 ], [ %6, %3 ]
%13 = call i32 @_wyr32(i32* %12)
%14 = load i32, i32* %4
%15 = xor i32 %14, %13
store i32 %15, i32* %4
%16 = getelementptr inbounds i32, i32* %12, i64 4
%17 = call i32 @_wyr32(i32* %16)
%18 = load i32, i32* %5
%19 = xor i32 %18, %17
store i32 %19, i32* %5
%20 = call i32 @_wymix32(i32* %4, i32* %5)
%21 = add nsw i32 %11, -8
%22 = getelementptr inbounds i32, i32* %12, i64 8
%23 = icmp ugt i32 %11, 16
br i1 %23, label %10, label %24
24: ; preds = %10, %3
%25 = phi i32* [ %6, %3 ], [ %22, %10 ]
%26 = phi i32 [ %1, %3 ], [ %21, %10 ]
%27 = icmp sgt i32 %26, 3
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = call i32 @_wyr32(i32* %25)
%30 = load i32, i32* %4
%31 = xor i32 %30, %29
store i32 %31, i32* %4
%32 = zext i32 %26 to i64
%33 = getelementptr inbounds i32, i32* %25, i64 %32
%34 = getelementptr inbounds i32, i32* %33, i64 -4
%35 = call i32 @_wyr32(i32* %34)
%36 = load i32, i32* %5
%37 = xor i32 %36, %35
store i32 %37, i32* %5
br label %44
38: ; preds = %24
%39 = icmp eq i32 %26, 0
br i1 %39, label %44, label %40
40: ; preds = %38
%41 = call i32 @_wyr24(i32* %25, i32 %26)
%42 = load i32, i32* %4
%43 = xor i32 %42, %41
store i32 %43, i32* %4
br label %44
44: ; preds = %38, %40, %28
%45 = call i32 @_wymix32(i32* %4, i32* %5)
%46 = call i32 @_wymix32(i32* %4, i32* %5)
%47 = load i32, i32* %4
%48 = load i32, i32* %5
%49 = xor i32 %48, %47
ret i32 %49
}