#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 */
double floor(int const);
unsigned int to_int(char const *);
unsigned int hasher(const char *key, const int taille) {
  static double nb_or = 0.618;
  unsigned int k = to_int(key);
  return ((unsigned int)floor(taille * (nb_or * k - floor(nb_or * k)))) %
         (taille);
}


x86 assembly (clang, -O0):
<hasher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <to_int@plt>
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0x2ee3(%rip),%xmm0
mov    -0x10(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
movsd  -0x20(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
cvttsd2si %xmm0,%rax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasher>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
call   1030 <to_int@plt>
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xeb8(%rip),%xmm0
movsd  %xmm0,(%rsp)
cvttsd2si %xmm0,%edi
call   1040 <floor@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1040 <floor@plt>
cvttsd2si %xmm0,%rax
xor    %edx,%edx
div    %ebx
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@hasher.nb_or = internal global double 6.180000e-01
define i32 @hasher(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @to_int(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = load double, double* @hasher.nb_or
%11 = load i32, i32* %5
%12 = uitofp i32 %11 to double
%13 = load double, double* @hasher.nb_or
%14 = load i32, i32* %5
%15 = uitofp i32 %14 to double
%16 = fmul double %13, %15
%17 = fptosi double %16 to i32
%18 = call double @floor(i32 %17)
%19 = fneg double %18
%20 = call double @llvm.fmuladd.f64(double %10, double %12, double %19)
%21 = fmul double %9, %20
%22 = fptosi double %21 to i32
%23 = call double @floor(i32 %22)
%24 = fptoui double %23 to i32
%25 = load i32, i32* %4
%26 = urem i32 %24, %25
ret i32 %26
}

LLVM IR (-O2):
define i32 @hasher(i8* %0, i32 %1) {
%3 = tail call i32 @to_int(i8* %0)
%4 = sitofp i32 %1 to double
%5 = uitofp i32 %3 to double
%6 = fmul double %5, 6.180000e-01
%7 = fptosi double %6 to i32
%8 = tail call double @floor(i32 %7)
%9 = fneg double %8
%10 = tail call double @llvm.fmuladd.f64(double %5, double 6.180000e-01, double %9)
%11 = fmul double %10, %4
%12 = fptosi double %11 to i32
%13 = tail call double @floor(i32 %12)
%14 = fptoui double %13 to i32
%15 = urem i32 %14, %1
ret i32 %15
}