#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 */
scalar_t__ strcmp(char *, char *);
unsigned hash(char *string) {
  char *p;
  unsigned int i, sum;
  if (strcmp(string, "ANY") == 0)
    return 128;
  for (sum = i = 0, p = string; *p; i += 3)
    sum += (*p++) << (i & 03);
  return sum % 128;
}


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1142 <hash+0x32>
movl   $0x80,-0x4(%rbp)
jmp    119c <hash+0x8c>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1193 <hash+0x83>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
mov    -0x1c(%rbp),%ecx
and    $0x3,%ecx
shl    %cl,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <hash+0x48>
mov    -0x20(%rbp),%eax
and    $0x7f,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115f <hash+0x4f>
mov    (%rbx),%cl
test   %cl,%cl
je     1166 <hash+0x56>
add    $0x1,%rbx
xor    %eax,%eax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %cl,%esi
mov    %edx,%ecx
and    $0x3,%cl
shl    %cl,%esi
add    %esi,%eax
add    $0x3,%edx
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1140 <hash+0x30>
and    $0x7f,%eax
pop    %rbx
ret
mov    $0x80,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ANY\00"
define i32 @hash(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 128, i32* %2
br label %33
11: ; preds = %1
store i32 0, i32* %5
store i32 0, i32* %6
%12 = load i8*, i8** %3
store i8* %12, i8** %4
br label %13
13: ; preds = %27, %11
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
%20 = load i8, i8* %18
%21 = sext i8 %20 to i32
%22 = load i32, i32* %5
%23 = and i32 %22, 3
%24 = shl i32 %21, %23
%25 = load i32, i32* %6
%26 = add i32 %25, %24
store i32 %26, i32* %6
br label %27
27: ; preds = %17
%28 = load i32, i32* %5
%29 = add i32 %28, 3
store i32 %29, i32* %5
br label %13
30: ; preds = %13
%31 = load i32, i32* %6
%32 = urem i32 %31, 128
store i32 %32, i32* %2
br label %33
33: ; preds = %30, %10
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@.str = [4 x i8] c"ANY\00"
define i32 @hash(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %4, %7
%8 = phi i8 [ %18, %7 ], [ %5, %4 ]
%9 = phi i32 [ %16, %7 ], [ 0, %4 ]
%10 = phi i32 [ %17, %7 ], [ 0, %4 ]
%11 = phi i8* [ %12, %7 ], [ %0, %4 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = sext i8 %8 to i32
%14 = and i32 %10, 3
%15 = shl nsw i32 %13, %14
%16 = add i32 %15, %9
%17 = add i32 %10, 3
%18 = load i8, i8* %12
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = and i32 %16, 127
br label %22
22: ; preds = %4, %20, %1
%23 = phi i32 [ 128, %1 ], [ 0, %4 ], [ %21, %20 ]
ret i32 %23
}