#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__ pow(char const, char const);
int strlen(char const *);
unsigned long hash_ds(const char *chave, int tamanho) {
  int i;
  unsigned long r = 0L;
  for (i = 0; i < strlen(chave); i++) {
    r += pow(chave[i], chave[i] % 5);
  }
  return r % tamanho;
}


x86 assembly (clang, -O0):
<hash_ds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    119c <hash_ds+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
movsbl (%rax,%rdx,1),%eax
mov    $0x5,%esi
cltd
idiv   %esi
mov    %dl,%al
movsbl %cl,%edi
movsbl %al,%esi
call   1040 <pow@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <hash_ds+0x1e>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_ds>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    117d <hash_ds+0x5d>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbp,1),%edi
imul   $0x67,%edi,%eax
movzwl %ax,%ecx
shr    $0x9,%eax
shr    $0xf,%ecx
add    %al,%cl
movzbl %cl,%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ecx
sub    %al,%cl
movsbl %cl,%esi
call   1040 <pow@plt>
add    %rax,%rbx
add    $0x1,%rbp
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1140 <hash_ds+0x20>
jmp    117f <hash_ds+0x5f>
xor    %ebx,%ebx
movslq %r14d,%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     119b <hash_ds+0x7b>
mov    %rbx,%rax
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
jmp    11a4 <hash_ds+0x84>
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @hash_ds(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
store i64 0, i64* %6
store i32 0, i32* %5
br label %7
7: ; preds = %29, %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 %32
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = srem i32 %23, 5
%25 = trunc i32 %24 to i8
%26 = call i64 @pow(i8 signext %17, i8 signext %25)
%27 = load i64, i64* %6
%28 = add i64 %27, %26
store i64 %28, i64* %6
br label %29
29: ; preds = %12
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %7
32: ; preds = %7
%33 = load i64, i64* %6
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = urem i64 %33, %35
ret i64 %36
}

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