#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 Platform_Halt(int);
int SYSTEM_MOD(long long, long long);
int OPC_PerfectHash(unsigned char *s, long long s__len) {
  int _o_result;
  int i, h;
  i = 0;
  h = 0;
  while ((s[(((unsigned long long)(i) < (unsigned long long)(s__len))
                 ? i
                 : (Platform_Halt(-2), 0))] != 0x00 &&
          i < 5)) {
    h = 3 * h + (int)s[(((unsigned long long)(i) < (unsigned long long)(s__len))
                            ? i
                            : (Platform_Halt(-2), 0))];
    i += 1;
  }
  _o_result = (int)((h) >= 0 ? (h) % (105)
                             : SYSTEM_MOD((long long)(h), (long long)(105)));
  return _o_result;
}


x86 assembly (clang, -O0):
<OPC_PerfectHash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    115f <OPC_PerfectHash+0x3f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    116e <OPC_PerfectHash+0x4e>
mov    $0xfffffffe,%edi
call   1040 <Platform_Halt@plt>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     1194 <OPC_PerfectHash+0x74>
cmpl   $0x5,-0x18(%rbp)
setl   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11a4 <OPC_PerfectHash+0x84>
jmp    11ff <OPC_PerfectHash+0xdf>
imul   $0x3,-0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11cc <OPC_PerfectHash+0xac>
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11db <OPC_PerfectHash+0xbb>
mov    $0xfffffffe,%edi
call   1040 <Platform_Halt@plt>
xor    %eax,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <OPC_PerfectHash+0x1e>
cmpl   $0x0,-0x1c(%rbp)
jl     121e <OPC_PerfectHash+0xfe>
mov    -0x1c(%rbp),%eax
mov    $0x69,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,-0x44(%rbp)
jmp    122f <OPC_PerfectHash+0x10f>
movslq -0x1c(%rbp),%rdi
mov    $0x69,%esi
call   1030 <SYSTEM_MOD@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OPC_PerfectHash>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    1150 <OPC_PerfectHash+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%r12,2),%ecx
movzbl (%r15,%rax,1),%r12d
add    %ecx,%r12d
add    $0x1,%rbx
cmp    %r14,%rbx
jae    1170 <OPC_PerfectHash+0x50>
cmpb   $0x0,(%r15,%rbx,1)
je     1194 <OPC_PerfectHash+0x74>
mov    %rbx,%rax
cmp    $0x5,%rbx
jb     1140 <OPC_PerfectHash+0x20>
jmp    1194 <OPC_PerfectHash+0x74>
nopw   0x0(%rax,%rax,1)
mov    $0xfffffffe,%edi
call   1040 <Platform_Halt@plt>
cmpb   $0x0,(%r15)
je     1194 <OPC_PerfectHash+0x74>
cmp    $0x4,%rbx
ja     1194 <OPC_PerfectHash+0x74>
mov    $0xfffffffe,%edi
call   1040 <Platform_Halt@plt>
xor    %eax,%eax
jmp    1140 <OPC_PerfectHash+0x20>
test   %r12d,%r12d
js     11c8 <OPC_PerfectHash+0xa8>
mov    %r12d,%eax
imul   $0x38138139,%rax,%rax
shr    $0x20,%rax
mov    %r12d,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x6,%ecx
imul   $0x69,%ecx,%eax
sub    %eax,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
movslq %r12d,%rdi
mov    $0x69,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <SYSTEM_MOD@plt>

LLVM IR (-O0):
define i32 @OPC_PerfectHash(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %42, %2
%9 = load i8*, i8** %3
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = load i64, i64* %4
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = load i32, i32* %6
br label %18
16: ; preds = %8
%17 = call i32 @Platform_Halt(i32 -2)
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ 0, %16 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %9, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 5
br label %28
28: ; preds = %25, %18
%29 = phi i1 [ false, %18 ], [ %27, %25 ]
br i1 %29, label %30, label %51
30: ; preds = %28
%31 = load i32, i32* %7
%32 = mul nsw i32 3, %31
%33 = load i8*, i8** %3
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = load i64, i64* %4
%37 = icmp ult i64 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %30
%39 = load i32, i32* %6
br label %42
40: ; preds = %30
%41 = call i32 @Platform_Halt(i32 -2)
br label %42
42: ; preds = %40, %38
%43 = phi i32 [ %39, %38 ], [ 0, %40 ]
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %33, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = add nsw i32 %32, %47
store i32 %48, i32* %7
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %8
51: ; preds = %28
%52 = load i32, i32* %7
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %7
%56 = srem i32 %55, 105
br label %61
57: ; preds = %51
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = call i32 @SYSTEM_MOD(i64 %59, i64 105)
br label %61
61: ; preds = %57, %54
%62 = phi i32 [ %56, %54 ], [ %60, %57 ]
store i32 %62, i32* %5
%63 = load i32, i32* %5
ret i32 %63
}

LLVM IR (-O2):
define i32 @OPC_PerfectHash(i8* nocapture %0, i64 %1) {
br label %3
3: ; preds = %21, %2
%4 = phi i64 [ %28, %21 ], [ 0, %2 ]
%5 = phi i32 [ %27, %21 ], [ 0, %2 ]
%6 = icmp ult i64 %4, %1
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
%11 = icmp ult i64 %4, 5
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %21, label %29
13: ; preds = %3
%14 = tail call i32 @Platform_Halt(i32 -2)
%15 = load i8, i8* %0
%16 = icmp ne i8 %15, 0
%17 = icmp ult i64 %4, 5
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = tail call i32 @Platform_Halt(i32 -2)
br label %21
21: ; preds = %7, %19
%22 = phi i64 [ 0, %19 ], [ %4, %7 ]
%23 = mul nsw i32 %5, 3
%24 = getelementptr inbounds i8, i8* %0, i64 %22
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = add nsw i32 %23, %26
%28 = add nuw nsw i64 %4, 1
br label %3
29: ; preds = %13, %7
%30 = icmp sgt i32 %5, -1
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = urem i32 %5, 105
br label %36
33: ; preds = %29
%34 = sext i32 %5 to i64
%35 = tail call i32 @SYSTEM_MOD(i64 %34, i64 105)
br label %36
36: ; preds = %33, %31
%37 = phi i32 [ %32, %31 ], [ %35, %33 ]
ret i32 %37
}