#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 hf1Int(int *);
int /*<<< orphan*/ printf(char *, ...);
void testHf1() {
  int xs[] = {4, 14, 28, 42, 128, 28};
  printf("hash fn 1:\n");
  for (int i = 0; i < 6; i++) {
    int h = hf1Int(xs + i);
    printf("%d: %d\n", xs[i], h);
  }
}


x86 assembly (clang, -O0):
<testHf1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    11a6 <testHf1+0x86>
lea    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1040 <hf1Int@plt>
mov    %eax,-0x28(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
mov    -0x28(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <testHf1+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testHf1>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xed2(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r14
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1050 <hf1Int@plt>
mov    (%rsp),%esi
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
call   1050 <hf1Int@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
call   1050 <hf1Int@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rdi
call   1050 <hf1Int@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <hf1Int@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rdi
call   1050 <hf1Int@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.testHf1.xs = [6 x i32] [i32 4, i32 14, i32 28, i32 42, i32 128, i32 28]
@.str = [12 x i8] c"hash fn 1:\0A\00"
@.str.1 = [8 x i8] c"%d: %d\0A\00"
define void @testHf1() {
%1 = alloca [6 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [6 x i32]* %1 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = call i32 @hf1Int(i32* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %9
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %6
24: ; preds = %6
ret void
}

LLVM IR (-O2):
@__const.testHf1.xs = [6 x i32] [i32 4, i32 14, i32 28, i32 42, i32 128, i32 28]
@.str.1 = [8 x i8] c"%d: %d\0A\00"
@str = [11 x i8] c"hash fn 1:\00"
define void @testHf1() {
%1 = alloca [6 x i32]
%2 = bitcast [6 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%5 = call i32 @hf1Int(i32* %4)
%6 = load i32, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %5)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 1
%9 = call i32 @hf1Int(i32* %8)
%10 = load i32, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %9)
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 2
%13 = call i32 @hf1Int(i32* %12)
%14 = load i32, i32* %12
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %13)
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 3
%17 = call i32 @hf1Int(i32* %16)
%18 = load i32, i32* %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %17)
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 4
%21 = call i32 @hf1Int(i32* %20)
%22 = load i32, i32* %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %21)
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 5
%25 = call i32 @hf1Int(i32* %24)
%26 = load i32, i32* %24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %25)
ret void
}