float msf_get_freq(int note) {
  int octave = note / 12;
  int base = note % 12;
  float base_freq = 16.351;
  switch (base) {
  case 0:
    base_freq = 16.351;
    break;
  case 1:
    base_freq = 17.324;
    break;
  case 2:
    base_freq = 18.354;
    break;
  case 3:
    base_freq = 19.445;
    break;
  case 4:
    base_freq = 20.601;
    break;
  case 5:
    base_freq = 21.827;
    break;
  case 6:
    base_freq = 23.124;
    break;
  case 7:
    base_freq = 24.499;
    break;
  case 8:
    base_freq = 25.956;
    break;
  case 9:
    base_freq = 27.5;
    break;
  case 10:
    base_freq = 29.135;
    break;
  case 11:
    base_freq = 30.868;
    break;
  }
  int mult = 1 << (octave + 1);
  return base_freq * mult;
}


x86 assembly (clang, -O0):
<msf_get_freq>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
movslq -0x4(%rbp),%rcx
mov    %ecx,%eax
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rdx
add    %ecx,%edx
shl    $0x2,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
movl   $0x4182ced9,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0xb,%rax
ja     1248 <msf_get_freq+0x148>
mov    -0x20(%rbp),%rax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe99(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe83(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe6d(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe57(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe41(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe2b(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xe15(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xdff(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xde9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xdd3(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1248 <msf_get_freq+0x148>
movss  0xdbd(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm1
mulss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<msf_get_freq>:
movslq %edi,%rax
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    0x0(,%rcx,4),%edx
lea    (%rdx,%rdx,2),%edx
not    %edx
add    %edx,%eax
cmp    $0xa,%eax
ja     113a <msf_get_freq+0x3a>
cltq
lea    0xed1(%rip),%rdx
movss  (%rdx,%rax,4),%xmm1
jmp    1142 <msf_get_freq+0x42>
movss  0xebe(%rip),%xmm1
add    $0x1,%cl
mov    $0x1,%eax
shl    %cl,%eax
cvtsi2ss %eax,%xmm0
mulss  %xmm1,%xmm0
ret

LLVM IR (-O0):
define float @msf_get_freq(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 12
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = srem i32 %9, 12
store i32 %10, i32* %4
store float 0x403059DB20000000, float* %5
%11 = load i32, i32* %4
switch i32 %11, label %24 [
i32 0, label %12
i32 1, label %13
i32 2, label %14
i32 3, label %15
i32 4, label %16
i32 5, label %17
i32 6, label %18
i32 7, label %19
i32 8, label %20
i32 9, label %21
i32 10, label %22
i32 11, label %23
]
12: ; preds = %1
store float 0x403059DB20000000, float* %5
br label %24
13: ; preds = %1
store float 0x403152F1A0000000, float* %5
br label %24
14: ; preds = %1
store float 0x40325A9FC0000000, float* %5
br label %24
15: ; preds = %1
store float 0x403371EB80000000, float* %5
br label %24
16: ; preds = %1
store float 0x403499DB20000000, float* %5
br label %24
17: ; preds = %1
store float 0x4035D3B640000000, float* %5
br label %24
18: ; preds = %1
store float 0x40371FBE80000000, float* %5
br label %24
19: ; preds = %1
store float 0x40387FBE80000000, float* %5
br label %24
20: ; preds = %1
store float 0x4039F4BC60000000, float* %5
br label %24
21: ; preds = %1
store float 2.750000e+01, float* %5
br label %24
22: ; preds = %1
store float 0x403D228F60000000, float* %5
br label %24
23: ; preds = %1
store float 0x403EDE3540000000, float* %5
br label %24
24: ; preds = %1, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
%27 = shl i32 1, %26
store i32 %27, i32* %6
%28 = load float, float* %5
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to float
%31 = fmul float %28, %30
ret float %31
}

LLVM IR (-O2):
@switch.table.msf_get_freq = [11 x float] [float 0x403152F1A0000000, float 0x40325A9FC0000000, float 0x403371EB80000000, float 0x403499DB20000000, float 0x4035D3B640000000, float 0x40371FBE80000000, float 0x40387FBE80000000, float 0x4039F4BC60000000, float 2.750000e+01, float 0x403D228F60000000, float 0x403EDE3540000000]
define float @msf_get_freq(i32 %0) {
%2 = srem i32 %0, 12
%3 = sdiv i32 %0, 12
%4 = add nsw i32 %2, -1
%5 = icmp ult i32 %4, 11
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds [11 x float], [11 x float]* @switch.table.msf_get_freq, i64 0, i64 %7
%9 = load float, float* %8
br label %10
10: ; preds = %6, %1
%11 = phi float [ 0x403059DB20000000, %1 ], [ %9, %6 ]
%12 = add nsw i32 %3, 1
%13 = shl nuw i32 1, %12
%14 = sitofp i32 %13 to float
%15 = fmul float %11, %14
ret float %15
}