#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 */
int strlen(char *);
int hashAddress(char *text) {
  int address = 1;
  int i;
  for (i = 0; i < strlen(text); i++) {
    address = (address * text[i]) % 997 + 1;
  }
  return address - 1;
}


x86 assembly (clang, -O0):
<hashAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1174 <hashAddress+0x64>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
imul   %ecx,%eax
mov    $0x3e5,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <hashAddress+0x1a>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashAddress>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    117c <hashAddress+0x6c>
mov    $0x1,%r12d
xor    %r15d,%r15d
nopl   (%rax)
movsbl (%r14,%r15,1),%ebx
imul   %r12d,%ebx
movslq %ebx,%rax
imul   $0xffffffff837765f1,%rax,%rax
shr    $0x20,%rax
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x9,%eax
add    %ecx,%eax
imul   $0x3e5,%eax,%ebp
mov    %ebp,%eax
neg    %eax
lea    (%rbx,%rax,1),%r12d
add    $0x1,%r12d
add    $0x1,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r15
jl     1130 <hashAddress+0x20>
sub    %ebp,%ebx
jmp    117e <hashAddress+0x6e>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hashAddress(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %21, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %24
10: ; preds = %5
%11 = load i32, i32* %3
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = mul nsw i32 %11, %17
%19 = srem i32 %18, 997
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %10
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %5
24: ; preds = %5
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
ret i32 %26
}

LLVM IR (-O2):
define i32 @hashAddress(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1, %4
%5 = phi i64 [ %13, %4 ], [ 0, %1 ]
%6 = phi i32 [ %12, %4 ], [ 1, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = mul nsw i32 %6, %9
%11 = srem i32 %10, 997
%12 = add nsw i32 %11, 1
%13 = add nuw nsw i64 %5, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %4, label %17
17: ; preds = %4, %1
%18 = phi i32 [ 0, %1 ], [ %11, %4 ]
ret i32 %18
}