#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 */

/* Variables and functions */
size_t ascii_tolower(int /*<<< orphan*/);
size_t fnv_1a_init();
size_t fnv_1a_prime();
size_t fnv_1a_hash_icase(const unsigned char *str, size_t n) {
  const size_t prime = fnv_1a_prime();
  size_t hash = fnv_1a_init();
  while (n--) {
    hash ^= ascii_tolower(*str++);
    hash *= prime;
  }
  return hash;
}


x86 assembly (clang, -O0):
<fnv_1a_hash_icase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <fnv_1a_prime@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <fnv_1a_init@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11a0 <fnv_1a_hash_icase+0x70>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%edi
call   1050 <ascii_tolower@plt>
xor    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1156 <fnv_1a_hash_icase+0x26>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnv_1a_hash_icase>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <fnv_1a_prime@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <fnv_1a_init@plt>
mov    %rax,%r13
test   %r15,%r15
je     117f <fnv_1a_hash_icase+0x4f>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%edi
call   1050 <ascii_tolower@plt>
xor    %r13,%rax
imul   %r12,%rax
add    $0x1,%rbx
mov    %rax,%r13
cmp    %rbx,%r15
jne    1160 <fnv_1a_hash_icase+0x30>
jmp    1182 <fnv_1a_hash_icase+0x52>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @fnv_1a_hash_icase(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = call i64 (...) @fnv_1a_prime()
store i64 %7, i64* %5
%8 = call i64 (...) @fnv_1a_init()
store i64 %8, i64* %6
br label %9
9: ; preds = %13, %2
%10 = load i64, i64* %4
%11 = add i64 %10, -1
store i64 %11, i64* %4
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
%16 = load i8, i8* %14
%17 = zext i8 %16 to i32
%18 = call i64 @ascii_tolower(i32 %17)
%19 = load i64, i64* %6
%20 = xor i64 %19, %18
store i64 %20, i64* %6
%21 = load i64, i64* %5
%22 = load i64, i64* %6
%23 = mul i64 %22, %21
store i64 %23, i64* %6
br label %9
24: ; preds = %9
%25 = load i64, i64* %6
ret i64 %25
}

LLVM IR (-O2):
define i64 @fnv_1a_hash_icase(i8* nocapture %0, i64 %1) {
%3 = tail call i64 (...) @fnv_1a_prime()
%4 = tail call i64 (...) @fnv_1a_init()
%5 = icmp eq i64 %1, 0
br i1 %5, label %18, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %16, %6 ], [ %4, %2 ]
%8 = phi i8* [ %11, %6 ], [ %0, %2 ]
%9 = phi i64 [ %10, %6 ], [ %1, %2 ]
%10 = add i64 %9, -1
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %8
%13 = zext i8 %12 to i32
%14 = tail call i64 @ascii_tolower(i32 %13)
%15 = xor i64 %14, %7
%16 = mul i64 %15, %3
%17 = icmp eq i64 %10, 0
br i1 %17, label %18, label %6
18: ; preds = %6, %2
%19 = phi i64 [ %4, %2 ], [ %16, %6 ]
ret i64 %19
}