int snd_seq_oss_note_to_freq(int note_num) {
  int note, octave, note_freq;
  static int notes[] = {261632, 277189, 293671, 311132, 329632, 349232,
                        369998, 391998, 415306, 440000, 466162, 493880};
  octave = note_num / 12;
  note = note_num % 12;
  note_freq = notes[note];
  if (octave < 5)
    note_freq >>= (5 - octave);
  else if (octave > 5)
    note_freq <<= (octave - 5);
  return note_freq;
}


x86 assembly (clang, -O0):
<snd_seq_oss_note_to_freq>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
movslq -0x8(%rbp),%rcx
lea    0x2f02(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    1153 <snd_seq_oss_note_to_freq+0x53>
mov    $0x5,%ecx
sub    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%eax
sar    %cl,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <snd_seq_oss_note_to_freq+0x70>
cmpl   $0x5,-0xc(%rbp)
jle    116b <snd_seq_oss_note_to_freq+0x6b>
mov    -0xc(%rbp),%ecx
sub    $0x5,%ecx
mov    -0x10(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <snd_seq_oss_note_to_freq+0x70>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<snd_seq_oss_note_to_freq>:
movslq %edi,%rdx
imul   $0x2aaaaaab,%rdx,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x21,%rcx
add    %eax,%ecx
lea    0x0(,%rcx,4),%eax
lea    (%rax,%rax,2),%eax
mov    %edx,%esi
sub    %eax,%esi
movslq %esi,%rax
lea    0xed1(%rip),%rsi
mov    (%rsi,%rax,4),%eax
cmp    $0x3b,%edx
jg     1140 <snd_seq_oss_note_to_freq+0x40>
mov    $0x5,%dl
sub    %cl,%dl
mov    %edx,%ecx
sar    %cl,%eax
ret
cmp    $0x48,%edi
jb     114a <snd_seq_oss_note_to_freq+0x4a>
add    $0xfb,%cl
shl    %cl,%eax
ret

LLVM IR (-O0):
@snd_seq_oss_note_to_freq.notes = internal global [12 x i32] [i32 261632, i32 277189, i32 293671, i32 311132, i32 329632, i32 349232, i32 369998, i32 391998, i32 415306, i32 440000, i32 466162, i32 493880]
define i32 @snd_seq_oss_note_to_freq(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 12
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 12
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [12 x i32], [12 x i32]* @snd_seq_oss_note_to_freq.notes, i64 0, i64 %11
%13 = load i32, i32* %12
store i32 %13, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 5
br i1 %15, label %16, label %21
16: ; preds = %1
%17 = load i32, i32* %4
%18 = sub nsw i32 5, %17
%19 = load i32, i32* %5
%20 = ashr i32 %19, %18
store i32 %20, i32* %5
br label %30
21: ; preds = %1
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 5
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 5
%27 = load i32, i32* %5
%28 = shl i32 %27, %26
store i32 %28, i32* %5
br label %29
29: ; preds = %24, %21
br label %30
30: ; preds = %29, %16
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@snd_seq_oss_note_to_freq.notes = internal unnamed_addr constant [12 x i32] [i32 261632, i32 277189, i32 293671, i32 311132, i32 329632, i32 349232, i32 369998, i32 391998, i32 415306, i32 440000, i32 466162, i32 493880]
define i32 @snd_seq_oss_note_to_freq(i32 %0) {
%2 = sdiv i32 %0, 12
%3 = srem i32 %0, 12
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [12 x i32], [12 x i32]* @snd_seq_oss_note_to_freq.notes, i64 0, i64 %4
%6 = load i32, i32* %5
%7 = icmp slt i32 %0, 60
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = sub nsw i32 5, %2
%10 = ashr i32 %6, %9
br label %16
11: ; preds = %1
%12 = icmp ugt i32 %0, 71
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = add nsw i32 %2, -5
%15 = shl i32 %6, %14
br label %16
16: ; preds = %11, %13, %8
%17 = phi i32 [ %10, %8 ], [ %15, %13 ], [ %6, %11 ]
ret i32 %17
}