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

/* Variables and functions */
int fnv1a_string(int /*<<< orphan*/ const *, int, int);
uint32_t fnv1a(const char *p, uint32_t len) {
  const uint8_t *str = (const uint8_t *)p;
  uint32_t hash = 0x811c9dc5;
  while (len >= 4) {
    hash = fnv1a_string(str, 4, hash);
    str += 4;
    len -= 4;
  }
  return fnv1a_string(str, len, hash);
}


x86 assembly (clang, -O0):
<fnv1a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x811c9dc5,-0x1c(%rbp)
cmpl   $0x4,-0xc(%rbp)
jl     1166 <fnv1a+0x56>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    $0x4,%esi
call   1030 <fnv1a_string@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    112e <fnv1a+0x1e>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <fnv1a_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnv1a>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x811c9dc5,%eax
cmp    $0x4,%esi
jl     114d <fnv1a+0x3d>
mov    %esi,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    $0x4,%esi
mov    %eax,%edx
call   1030 <fnv1a_string@plt>
add    $0x10,%r14
lea    -0x4(%rbx),%esi
cmp    $0x7,%ebx
mov    %esi,%ebx
ja     1130 <fnv1a+0x20>
mov    %r14,%rdi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fnv1a_string@plt>

LLVM IR (-O0):
define i32 @fnv1a(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %5
store i32 -2128831035, i32* %6
br label %9
9: ; preds = %12, %2
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 4
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i32*, i32** %5
%14 = load i32, i32* %6
%15 = call i32 @fnv1a_string(i32* %13, i32 4, i32 %14)
store i32 %15, i32* %6
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 4
store i32* %17, i32** %5
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 4
store i32 %19, i32* %4
br label %9
20: ; preds = %9
%21 = load i32*, i32** %5
%22 = load i32, i32* %4
%23 = load i32, i32* %6
%24 = call i32 @fnv1a_string(i32* %21, i32 %22, i32 %23)
ret i32 %24
}

LLVM IR (-O2):
define i32 @fnv1a(i8* %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = icmp sgt i32 %1, 3
br i1 %4, label %5, label %13
5: ; preds = %2, %5
%6 = phi i32 [ %9, %5 ], [ -2128831035, %2 ]
%7 = phi i32* [ %10, %5 ], [ %3, %2 ]
%8 = phi i32 [ %11, %5 ], [ %1, %2 ]
%9 = tail call i32 @fnv1a_string(i32* %7, i32 4, i32 %6)
%10 = getelementptr inbounds i32, i32* %7, i64 4
%11 = add nsw i32 %8, -4
%12 = icmp ugt i32 %8, 7
br i1 %12, label %5, label %13
13: ; preds = %5, %2
%14 = phi i32 [ %1, %2 ], [ %11, %5 ]
%15 = phi i32* [ %3, %2 ], [ %10, %5 ]
%16 = phi i32 [ -2128831035, %2 ], [ %9, %5 ]
%17 = tail call i32 @fnv1a_string(i32* %15, i32 %14, i32 %16)
ret i32 %17
}