#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 *);
int hash(char *str) {
  if (strcmp(str, "iif") == 0) {
    return hash("iff");
  }
  int hash = 0;
  char c;
  while ((c = *str++)) {
    hash = hash * 100 + c - 'a' + 1;
  }
  return hash;
}


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    115a <hash+0x3a>
lea    0xeb7(%rip),%rdi
call   1030 <hash@plt>
mov    %eax,-0x4(%rbp)
jmp    119b <hash+0x7b>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x15(%rbp)
cmp    $0x0,%al
je     1195 <hash+0x75>
imul   $0x64,-0x14(%rbp),%eax
movsbl -0x15(%rbp),%ecx
add    %ecx,%eax
sub    $0x61,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <hash+0x41>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee2(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1150 <hash+0x40>
lea    0xed5(%rip),%rbx
lea    0xeca(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1140 <hash+0x30>
mov    (%rbx),%cl
test   %cl,%cl
je     1178 <hash+0x68>
add    $0x1,%rbx
xor    %eax,%eax
nopl   0x0(%rax)
imul   $0x64,%eax,%eax
movsbl %cl,%ecx
add    %ecx,%eax
add    $0xffffffa0,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1160 <hash+0x50>
jmp    117a <hash+0x6a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"iif\00"
@.str.1 = [4 x i8] c"iff\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 %4, label %7
4: ; preds = %1, %4
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %4, label %7
7: ; preds = %4, %1
%8 = phi i8* [ %0, %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %4 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %7, %11
%12 = phi i8 [ %20, %11 ], [ %9, %7 ]
%13 = phi i32 [ %19, %11 ], [ 0, %7 ]
%14 = phi i8* [ %15, %11 ], [ %8, %7 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = mul nsw i32 %13, 100
%17 = sext i8 %12 to i32
%18 = add i32 %16, -96
%19 = add i32 %18, %17
%20 = load i8, i8* %15
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %11, %7
%23 = phi i32 [ 0, %7 ], [ %19, %11 ]
ret i32 %23
}