#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 /*<<< orphan*/ strcpy(char *, void const *);
unsigned long pointerHashFunction(const void *pointer) {
  char randStr[1000];
  int pos = 0;
  unsigned long randAscii = 0;
  unsigned long randHash = 0;
  strcpy(randStr, pointer);
  for (pos = 0; randStr[pos] != '\0'; pos++) {
    randAscii = randAscii + randStr[pos];
  }
  randHash = randAscii >> 4;
  return (randHash);
}


x86 assembly (clang, -O0):
<pointerHashFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x3f4(%rbp)
movq   $0x0,-0x400(%rbp)
movq   $0x0,-0x408(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11a6 <pointerHashFunction+0x96>
mov    -0x400(%rbp),%rax
movslq -0x3f4(%rbp),%rcx
movsbq -0x3f0(%rbp,%rcx,1),%rcx
ff ff
add    %rcx,%rax
mov    %rax,-0x400(%rbp)
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    1159 <pointerHashFunction+0x49>
mov    -0x400(%rbp),%rax
shr    $0x4,%rax
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointerHashFunction>:
sub    $0x3e8,%rsp
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    (%rsp),%cl
test   %cl,%cl
je     114e <pointerHashFunction+0x3e>
lea    0x1(%rsp),%rdx
xor    %eax,%eax
movsbq %cl,%rcx
add    %rcx,%rax
movzbl (%rdx),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1130 <pointerHashFunction+0x20>
shr    $0x4,%rax
add    $0x3e8,%rsp
ret
xor    %eax,%eax
add    $0x3e8,%rsp
ret

LLVM IR (-O0):
define i64 @pointerHashFunction(i8* %0) {
%2 = alloca i8*
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
store i32 0, i32* %4
store i64 0, i64* %5
store i64 0, i64* %6
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
store i32 0, i32* %4
br label %10
10: ; preds = %25, %1
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %10
%18 = load i64, i64* %5
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i64
%24 = add i64 %18, %23
store i64 %24, i64* %5
br label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i64, i64* %5
%30 = lshr i64 %29, 4
store i64 %30, i64* %6
%31 = load i64, i64* %6
ret i64 %31
}

LLVM IR (-O2):
define i64 @pointerHashFunction(i8* %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %1, %7
%8 = phi i64 [ %13, %7 ], [ 0, %1 ]
%9 = phi i8 [ %15, %7 ], [ %5, %1 ]
%10 = phi i64 [ %12, %7 ], [ 0, %1 ]
%11 = sext i8 %9 to i64
%12 = add i64 %10, %11
%13 = add nuw nsw i64 %8, 1
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7
%18 = lshr i64 %12, 4
br label %19
19: ; preds = %17, %1
%20 = phi i64 [ 0, %1 ], [ %18, %17 ]
ret i64 %20
}