#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 */
unsigned int toupper(unsigned char);
int ast_hashtab_hash_string_nocase(const void *obj, int modulus) {
  unsigned char *str = (unsigned char *)obj;
  unsigned int total;
  for (total = 0; *str; str++) {
    unsigned int tmp = total;
    unsigned int charval = toupper(*str);
    total <<= 1;
    total += tmp;
    total <<= 2;
    total += tmp;
    total += (charval);
  }
  return (total % modulus);
}


x86 assembly (clang, -O0):
<ast_hashtab_hash_string_nocase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118e <ast_hashtab_hash_string_nocase+0x7e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112e <ast_hashtab_hash_string_nocase+0x1e>
mov    -0x1c(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ast_hashtab_hash_string_nocase>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    (%rdi),%al
test   %al,%al
je     114f <ast_hashtab_hash_string_nocase+0x3f>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <toupper@plt>
lea    0x0(%rbp,%rbp,2),%ecx
lea    0x0(%rbp,%rcx,4),%ebp
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <ast_hashtab_hash_string_nocase+0x20>
jmp    1151 <ast_hashtab_hash_string_nocase+0x41>
xor    %ebp,%ebp
mov    %ebp,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ast_hashtab_hash_string_nocase(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
store i32 0, i32* %6
br label %10
10: ; preds = %32, %2
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load i32, i32* %6
store i32 %15, i32* %7
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = call i32 @toupper(i8 zeroext %17)
store i32 %18, i32* %8
%19 = load i32, i32* %6
%20 = shl i32 %19, 1
store i32 %20, i32* %6
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = add i32 %22, %21
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = shl i32 %24, 2
store i32 %25, i32* %6
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = add i32 %27, %26
store i32 %28, i32* %6
%29 = load i32, i32* %8
%30 = load i32, i32* %6
%31 = add i32 %30, %29
store i32 %31, i32* %6
br label %32
32: ; preds = %14
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
br label %10
35: ; preds = %10
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = urem i32 %36, %37
ret i32 %38
}

LLVM IR (-O2):
define i32 @ast_hashtab_hash_string_nocase(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %13, %5 ], [ %3, %2 ]
%7 = phi i8* [ %12, %5 ], [ %0, %2 ]
%8 = phi i32 [ %11, %5 ], [ 0, %2 ]
%9 = tail call i32 @toupper(i8 zeroext %6)
%10 = mul i32 %8, 13
%11 = add i32 %9, %10
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %5, %2
%16 = phi i32 [ 0, %2 ], [ %11, %5 ]
%17 = urem i32 %16, %1
ret i32 %17
}