int calcolaIndice(float i) {
  int inx;
  inx = i + 12;
  switch (inx) {
  case 0:
    inx = 0;
    break;
  case 3:
    inx = 1;
    break;
  case 6:
    inx = 2;
    break;
  case 9:
    inx = 3;
    break;
  case 12:
    inx = 4;
    break;
  case 15:
    inx = 5;
    break;
  case 18:
    inx = 6;
    break;
  case 21:
    inx = 7;
    break;
  case 24:
    inx = 8;
    break;
  }
  return (inx);
}


x86 assembly (clang, -O0):
<calcolaIndice>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xeea(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x18,%rax
ja     11ad <calcolaIndice+0xad>
mov    -0x10(%rbp),%rax
lea    0xec7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x1,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x2,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x3,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x4,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x5,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x6,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x7,-0x8(%rbp)
jmp    11ad <calcolaIndice+0xad>
movl   $0x8,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcolaIndice>:
addss  0xef8(%rip),%xmm0
cvttss2si %xmm0,%eax
cmp    $0x18,%eax
ja     1153 <calcolaIndice+0x53>
lea    0xeec(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
xor    %eax,%eax
ret
mov    $0x1,%eax
ret
mov    $0x2,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
mov    $0x5,%eax
ret
mov    $0x6,%eax
ret
mov    $0x7,%eax
ret
mov    $0x8,%eax
ret

LLVM IR (-O0):
define i32 @calcolaIndice(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = load float, float* %2
%5 = fadd float %4, 1.200000e+01
%6 = fptosi float %5 to i32
store i32 %6, i32* %3
%7 = load i32, i32* %3
switch i32 %7, label %17 [
i32 0, label %8
i32 3, label %9
i32 6, label %10
i32 9, label %11
i32 12, label %12
i32 15, label %13
i32 18, label %14
i32 21, label %15
i32 24, label %16
]
8: ; preds = %1
store i32 0, i32* %3
br label %17
9: ; preds = %1
store i32 1, i32* %3
br label %17
10: ; preds = %1
store i32 2, i32* %3
br label %17
11: ; preds = %1
store i32 3, i32* %3
br label %17
12: ; preds = %1
store i32 4, i32* %3
br label %17
13: ; preds = %1
store i32 5, i32* %3
br label %17
14: ; preds = %1
store i32 6, i32* %3
br label %17
15: ; preds = %1
store i32 7, i32* %3
br label %17
16: ; preds = %1
store i32 8, i32* %3
br label %17
17: ; preds = %1, %16, %15, %14, %13, %12, %11, %10, %9, %8
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
define i32 @calcolaIndice(float %0) {
%2 = fadd float %0, 1.200000e+01
%3 = fptosi float %2 to i32
switch i32 %3, label %13 [
i32 0, label %4
i32 3, label %5
i32 6, label %6
i32 9, label %7
i32 12, label %8
i32 15, label %9
i32 18, label %10
i32 21, label %11
i32 24, label %12
]
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
br label %13
7: ; preds = %1
br label %13
8: ; preds = %1
br label %13
9: ; preds = %1
br label %13
10: ; preds = %1
br label %13
11: ; preds = %1
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5, %4
%14 = phi i32 [ %3, %1 ], [ 8, %12 ], [ 7, %11 ], [ 6, %10 ], [ 5, %9 ], [ 4, %8 ], [ 3, %7 ], [ 2, %6 ], [ 1, %5 ], [ 0, %4 ]
ret i32 %14
}