#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 /*<<< orphan*/ isdigit(char);
int Analyser__hash_code_from_word(char *text) {
  unsigned int hash_code = 0;
  char *p = text;
  switch (*p) {
  case '-':
    if (p[1] == 0)
      break;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
    for (p++; *p; p++)
      if (isdigit(*p) == 0)
        break;
    return 0;
  }
  for (p = text; *p; p++)
    hash_code = (unsigned int)((int)(hash_code * 30011) + (*p));
  return (int)(1 + (hash_code % (1000 - 1)));
}


x86 assembly (clang, -O0):
<Analyser__hash_code_from_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2d,%eax
je     1157 <Analyser__hash_code_from_word+0x47>
jmp    1143 <Analyser__hash_code_from_word+0x33>
mov    -0x24(%rbp),%eax
add    $0xffffffd0,%eax
sub    $0xa,%eax
jb     1172 <Analyser__hash_code_from_word+0x62>
jmp    11c7 <Analyser__hash_code_from_word+0xb7>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    116d <Analyser__hash_code_from_word+0x5d>
jmp    11c7 <Analyser__hash_code_from_word+0xb7>
jmp    1172 <Analyser__hash_code_from_word+0x62>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bb <Analyser__hash_code_from_word+0xab>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a5 <Analyser__hash_code_from_word+0x95>
jmp    11bb <Analyser__hash_code_from_word+0xab>
jmp    11aa <Analyser__hash_code_from_word+0x9a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117e <Analyser__hash_code_from_word+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    1212 <Analyser__hash_code_from_word+0x102>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1200 <Analyser__hash_code_from_word+0xf0>
imul   $0x753b,-0x14(%rbp),%eax
mov    -0x20(%rbp),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11cf <Analyser__hash_code_from_word+0xbf>
mov    -0x14(%rbp),%eax
mov    $0x3e7,%ecx
xor    %edx,%edx
div    %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Analyser__hash_code_from_word>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%cl
movsbl %cl,%eax
lea    -0x30(%rax),%edx
cmp    $0xa,%edx
jae    1150 <Analyser__hash_code_from_word+0x40>
add    $0x1,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
movzbl (%rbx),%eax
test   %al,%al
je     1147 <Analyser__hash_code_from_word+0x37>
movsbl %al,%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1130 <Analyser__hash_code_from_word+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0x2d,%eax
jne    115b <Analyser__hash_code_from_word+0x4b>
cmpb   $0x0,0x1(%rbx)
jne    1123 <Analyser__hash_code_from_word+0x13>
test   %cl,%cl
je     11ae <Analyser__hash_code_from_word+0x9e>
add    $0x1,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
imul   $0x753b,%eax,%edx
movsbl %cl,%eax
add    %edx,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1170 <Analyser__hash_code_from_word+0x60>
mov    %eax,%ecx
imul   $0x6680a41,%rcx,%rcx
shr    $0x20,%rcx
mov    %eax,%edx
sub    %ecx,%edx
shr    %edx
add    %ecx,%edx
shr    $0x9,%edx
imul   $0x3e7,%edx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
jmp    1147 <Analyser__hash_code_from_word+0x37>
mov    $0x1,%ebp
jmp    1147 <Analyser__hash_code_from_word+0x37>

LLVM IR (-O0):
define i32 @Analyser__hash_code_from_word(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %36 [
i32 45, label %10
i32 48, label %18
i32 49, label %18
i32 50, label %18
i32 51, label %18
i32 52, label %18
i32 53, label %18
i32 54, label %18
i32 55, label %18
i32 56, label %18
i32 57, label %18
]
10: ; preds = %1
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %36
17: ; preds = %10
br label %18
18: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %17
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
br label %21
21: ; preds = %32, %18
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = call i32 @isdigit(i8 signext %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
br label %35
31: ; preds = %25
br label %32
32: ; preds = %31
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
br label %21
35: ; preds = %30, %21
store i32 0, i32* %2
br label %56
36: ; preds = %1, %16
%37 = load i8*, i8** %3
store i8* %37, i8** %5
br label %38
38: ; preds = %49, %36
%39 = load i8*, i8** %5
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %52
42: ; preds = %38
%43 = load i32, i32* %4
%44 = mul i32 %43, 30011
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = add nsw i32 %44, %47
store i32 %48, i32* %4
br label %49
49: ; preds = %42
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
br label %38
52: ; preds = %38
%53 = load i32, i32* %4
%54 = urem i32 %53, 999
%55 = add i32 1, %54
store i32 %55, i32* %2
br label %56
56: ; preds = %52, %35
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
define i32 @Analyser__hash_code_from_word(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %17 [
i32 45, label %4
i32 48, label %8
i32 49, label %8
i32 50, label %8
i32 51, label %8
i32 52, label %8
i32 53, label %8
i32 54, label %8
i32 55, label %8
i32 56, label %8
i32 57, label %8
]
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %4, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
br label %9
9: ; preds = %8, %14
%10 = phi i8* [ %11, %14 ], [ %0, %8 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %32, label %14
14: ; preds = %9
%15 = tail call i32 @isdigit(i8 signext %12)
%16 = icmp eq i32 %15, 0
br i1 %16, label %32, label %9
17: ; preds = %4, %1
%18 = icmp eq i8 %2, 0
br i1 %18, label %32, label %19
19: ; preds = %17, %19
%20 = phi i8 [ %27, %19 ], [ %2, %17 ]
%21 = phi i8* [ %26, %19 ], [ %0, %17 ]
%22 = phi i32 [ %25, %19 ], [ 0, %17 ]
%23 = mul i32 %22, 30011
%24 = sext i8 %20 to i32
%25 = add nsw i32 %23, %24
%26 = getelementptr inbounds i8, i8* %21, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %19
29: ; preds = %19
%30 = urem i32 %25, 999
%31 = add nuw nsw i32 %30, 1
br label %32
32: ; preds = %9, %14, %17, %29
%33 = phi i32 [ 1, %17 ], [ %31, %29 ], [ 0, %14 ], [ 0, %9 ]
ret i32 %33
}