int smallhash_function(char *lmer) {
  int x, ans;
  for (x = 0; x < 6; x++) {
    if (lmer[x] == 99)
      return -1;
  }
  ans = lmer[0];
  for (x = 1; x < 6; x++)
    ans = (4 * ans + (lmer[x] % 4)) % 5003;
  return ans;
}


x86 assembly (clang, -O0):
<smallhash_function>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    114d <smallhash_function+0x4d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    113a <smallhash_function+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <smallhash_function+0xa9>
jmp    113f <smallhash_function+0x3f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <smallhash_function+0xf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11a3 <smallhash_function+0xa3>
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%eax
add    %edx,%eax
mov    $0x138b,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <smallhash_function+0x5e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<smallhash_function>:
movsbl (%rdi),%esi
mov    $0xffffffff,%eax
cmp    $0x63,%esi
je     125c <smallhash_function+0x15c>
mov    0x1(%rdi),%cl
cmp    $0x63,%cl
je     125c <smallhash_function+0x15c>
mov    0x2(%rdi),%dl
cmp    $0x63,%dl
je     125c <smallhash_function+0x15c>
mov    0x3(%rdi),%r9b
cmp    $0x63,%r9b
je     125c <smallhash_function+0x15c>
mov    0x4(%rdi),%r8b
cmp    $0x63,%r8b
je     125c <smallhash_function+0x15c>
mov    0x5(%rdi),%dil
cmp    $0x63,%dil
je     125c <smallhash_function+0x15c>
mov    %ecx,%eax
sar    $0x7,%al
shr    $0x6,%al
add    %cl,%al
and    $0xfc,%al
sub    %al,%cl
movsbl %cl,%eax
lea    (%rax,%rsi,4),%eax
cltq
imul   $0x68cb72fb,%rax,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x2b,%rcx
add    %esi,%ecx
imul   $0x138b,%ecx,%ecx
sub    %ecx,%eax
mov    %edx,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %dl,%cl
and    $0xfc,%cl
sub    %cl,%dl
movsbl %dl,%ecx
lea    (%rcx,%rax,4),%eax
cltq
imul   $0x68cb72fb,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x138b,%ecx,%ecx
sub    %ecx,%eax
mov    %r9d,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %r9b,%cl
and    $0xfc,%cl
sub    %cl,%r9b
movsbl %r9b,%ecx
lea    (%rcx,%rax,4),%eax
cltq
imul   $0x68cb72fb,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x138b,%ecx,%ecx
sub    %ecx,%eax
mov    %r8d,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %r8b,%cl
and    $0xfc,%cl
sub    %cl,%r8b
movsbl %r8b,%ecx
lea    (%rcx,%rax,4),%eax
cltq
imul   $0x68cb72fb,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x138b,%ecx,%ecx
sub    %ecx,%eax
mov    %edi,%ecx
sar    $0x7,%cl
shr    $0x6,%cl
add    %dil,%cl
and    $0xfc,%cl
sub    %cl,%dil
movsbl %dil,%ecx
lea    (%rcx,%rax,4),%eax
cltq
imul   $0x68cb72fb,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2b,%rcx
add    %edx,%ecx
imul   $0x138b,%ecx,%ecx
sub    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @smallhash_function(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 99
br i1 %16, label %17, label %18
17: ; preds = %9
store i32 -1, i32* %2
br label %47
18: ; preds = %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %6
22: ; preds = %6
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
store i32 %26, i32* %5
store i32 1, i32* %4
br label %27
27: ; preds = %42, %22
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 6
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i32, i32* %5
%32 = mul nsw i32 4, %31
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = srem i32 %38, 4
%40 = add nsw i32 %32, %39
%41 = srem i32 %40, 5003
store i32 %41, i32* %5
br label %42
42: ; preds = %30
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %27
45: ; preds = %27
%46 = load i32, i32* %5
store i32 %46, i32* %2
br label %47
47: ; preds = %45, %17
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
define i32 @smallhash_function(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 99
br i1 %3, label %51, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 99
br i1 %7, label %51, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 99
br i1 %11, label %51, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 3
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 99
br i1 %15, label %51, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 99
br i1 %19, label %51, label %20
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %0, i64 5
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 99
br i1 %23, label %51, label %24
24: ; preds = %20
%25 = sext i8 %2 to i32
%26 = shl nsw i32 %25, 2
%27 = srem i8 %6, 4
%28 = sext i8 %27 to i32
%29 = add nsw i32 %26, %28
%30 = srem i32 %29, 5003
%31 = shl nsw i32 %30, 2
%32 = srem i8 %10, 4
%33 = sext i8 %32 to i32
%34 = add nsw i32 %31, %33
%35 = srem i32 %34, 5003
%36 = shl nsw i32 %35, 2
%37 = srem i8 %14, 4
%38 = sext i8 %37 to i32
%39 = add nsw i32 %36, %38
%40 = srem i32 %39, 5003
%41 = shl nsw i32 %40, 2
%42 = srem i8 %18, 4
%43 = sext i8 %42 to i32
%44 = add nsw i32 %41, %43
%45 = srem i32 %44, 5003
%46 = shl nsw i32 %45, 2
%47 = srem i8 %22, 4
%48 = sext i8 %47 to i32
%49 = add nsw i32 %46, %48
%50 = srem i32 %49, 5003
br label %51
51: ; preds = %1, %4, %8, %12, %16, %20, %24
%52 = phi i32 [ %50, %24 ], [ -1, %20 ], [ -1, %16 ], [ -1, %12 ], [ -1, %8 ], [ -1, %4 ], [ -1, %1 ]
ret i32 %52
}