#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 sqrt(int);
int hachage(float k, int taille) {
  return (int)(taille *
               (k * ((sqrt(5) - 1) / 2) - (int)(k * ((sqrt(5) - 1) / 2))));
}


x86 assembly (clang, -O0):
<hachage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x5,%edi
call   1030 <sqrt@plt>
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    $0x5,%edi
call   1030 <sqrt@plt>
movss  -0x18(%rbp),%xmm2
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm3
movss  -0xc(%rbp),%xmm0
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm4
mulss  %xmm4,%xmm2
cvttss2si %xmm2,%eax
cvtsi2ss %eax,%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hachage>:
sub    $0x18,%rsp
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
movss  %xmm0,0x14(%rsp)
mov    $0x5,%edi
call   1030 <sqrt@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x5,%edi
call   1030 <sqrt@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x10(%rsp),%xmm1
mulss  %xmm1,%xmm0
cvttps2dq %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm0
movss  0xc(%rsp),%xmm2
mulss  %xmm1,%xmm2
subss  %xmm0,%xmm2
mulss  0x14(%rsp),%xmm2
cvttss2si %xmm2,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @hachage(float %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
store float %0, float* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = sitofp i32 %5 to float
%7 = load float, float* %3
%8 = call i32 @sqrt(i32 5)
%9 = sub nsw i32 %8, 1
%10 = sdiv i32 %9, 2
%11 = sitofp i32 %10 to float
%12 = load float, float* %3
%13 = call i32 @sqrt(i32 5)
%14 = sub nsw i32 %13, 1
%15 = sdiv i32 %14, 2
%16 = sitofp i32 %15 to float
%17 = fmul float %12, %16
%18 = fptosi float %17 to i32
%19 = sitofp i32 %18 to float
%20 = fneg float %19
%21 = call float @llvm.fmuladd.f32(float %7, float %11, float %20)
%22 = fmul float %6, %21
%23 = fptosi float %22 to i32
ret i32 %23
}

LLVM IR (-O2):
define i32 @hachage(float %0, i32 %1) {
%3 = sitofp i32 %1 to float
%4 = tail call i32 @sqrt(i32 5)
%5 = add nsw i32 %4, -1
%6 = sdiv i32 %5, 2
%7 = sitofp i32 %6 to float
%8 = tail call i32 @sqrt(i32 5)
%9 = add nsw i32 %8, -1
%10 = sdiv i32 %9, 2
%11 = sitofp i32 %10 to float
%12 = fmul float %11, %0
%13 = fptosi float %12 to i32
%14 = sitofp i32 %13 to float
%15 = fneg float %14
%16 = tail call float @llvm.fmuladd.f32(float %0, float %7, float %15)
%17 = fmul float %16, %3
%18 = fptosi float %17 to i32
ret i32 %18
}