#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 */
unsigned int shift_rotate(char, int);
int strlen(char *);
unsigned int hash(char chaine[100], int m) {
  int i;
  unsigned int h = 0;
  for (i = 0; i < strlen(chaine); i++) {
    h = h + shift_rotate(chaine[i], i * 7);
  }
  return h % m;
}


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    118e <hash+0x6e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
imul   $0x7,-0x10(%rbp),%esi
movsbl %al,%edi
call   1040 <shift_rotate@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <hash+0x1d>
mov    -0x14(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    1167 <hash+0x47>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
xchg   %ax,%ax
movsbl (%r15,%rbp,1),%edi
mov    %ebx,%esi
call   1040 <shift_rotate@plt>
add    %eax,%r12d
add    $0x1,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
add    $0x7,%ebx
cmp    %rax,%rbp
jl     1140 <hash+0x20>
jmp    116a <hash+0x4a>
xor    %r12d,%r12d
mov    %r12d,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hash(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %23, %2
%8 = load i32, i32* %5
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %26
12: ; preds = %7
%13 = load i32, i32* %6
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = load i32, i32* %5
%20 = mul nsw i32 %19, 7
%21 = call i32 @shift_rotate(i8 signext %18, i32 %20)
%22 = add i32 %13, %21
store i32 %22, i32* %6
br label %23
23: ; preds = %12
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %7
26: ; preds = %7
%27 = load i32, i32* %6
%28 = load i32, i32* %4
%29 = urem i32 %27, %28
ret i32 %29
}

LLVM IR (-O2):
define i32 @hash(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2, %5
%6 = phi i64 [ %14, %5 ], [ 0, %2 ]
%7 = phi i32 [ %13, %5 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %6
%9 = load i8, i8* %8
%10 = trunc i64 %6 to i32
%11 = mul i32 %10, 7
%12 = tail call i32 @shift_rotate(i8 signext %9, i32 %11)
%13 = add i32 %12, %7
%14 = add nuw nsw i64 %6, 1
%15 = tail call i32 @strlen(i8* %0)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %5, label %18
18: ; preds = %5, %2
%19 = phi i32 [ 0, %2 ], [ %13, %5 ]
%20 = urem i32 %19, %1
ret i32 %20
}