int wlan_rate_to_index(int rate) {
  switch (rate) {
  case 540:
    return 12;
  case 480:
    return 11;
  case 360:
    return 10;
  case 240:
    return 9;
  case 180:
    return 8;
  case 120:
    return 7;
  case 110:
    return 6;
  case 90:
    return 5;
  case 60:
    return 4;
  case 55:
    return 3;
  case 20:
    return 2;
  case 10:
    return 1;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<wlan_rate_to_index>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0xa,%eax
je     1264 <wlan_rate_to_index+0x164>
jmp    111b <wlan_rate_to_index+0x1b>
mov    -0xc(%rbp),%eax
sub    $0x14,%eax
je     1258 <wlan_rate_to_index+0x158>
jmp    112c <wlan_rate_to_index+0x2c>
mov    -0xc(%rbp),%eax
sub    $0x37,%eax
je     124c <wlan_rate_to_index+0x14c>
jmp    113d <wlan_rate_to_index+0x3d>
mov    -0xc(%rbp),%eax
sub    $0x3c,%eax
je     1240 <wlan_rate_to_index+0x140>
jmp    114e <wlan_rate_to_index+0x4e>
mov    -0xc(%rbp),%eax
sub    $0x5a,%eax
je     1234 <wlan_rate_to_index+0x134>
jmp    115f <wlan_rate_to_index+0x5f>
mov    -0xc(%rbp),%eax
sub    $0x6e,%eax
je     1228 <wlan_rate_to_index+0x128>
jmp    1170 <wlan_rate_to_index+0x70>
mov    -0xc(%rbp),%eax
sub    $0x78,%eax
je     121c <wlan_rate_to_index+0x11c>
jmp    1181 <wlan_rate_to_index+0x81>
mov    -0xc(%rbp),%eax
sub    $0xb4,%eax
je     1210 <wlan_rate_to_index+0x110>
jmp    1194 <wlan_rate_to_index+0x94>
mov    -0xc(%rbp),%eax
sub    $0xf0,%eax
je     1204 <wlan_rate_to_index+0x104>
jmp    11a7 <wlan_rate_to_index+0xa7>
mov    -0xc(%rbp),%eax
sub    $0x168,%eax
je     11f8 <wlan_rate_to_index+0xf8>
jmp    11ba <wlan_rate_to_index+0xba>
mov    -0xc(%rbp),%eax
sub    $0x1e0,%eax
je     11ec <wlan_rate_to_index+0xec>
jmp    11cd <wlan_rate_to_index+0xcd>
mov    -0xc(%rbp),%eax
sub    $0x21c,%eax
jne    1270 <wlan_rate_to_index+0x170>
jmp    11e0 <wlan_rate_to_index+0xe0>
movl   $0xc,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0xb,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0xa,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x9,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x8,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x7,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x6,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x5,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x4,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x3,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x2,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x1,-0x4(%rbp)
jmp    1277 <wlan_rate_to_index+0x177>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wlan_rate_to_index>:
cmp    $0x77,%edi
jg     1123 <wlan_rate_to_index+0x23>
cmp    $0x3b,%edi
jg     1146 <wlan_rate_to_index+0x46>
cmp    $0xa,%edi
je     117e <wlan_rate_to_index+0x7e>
cmp    $0x14,%edi
je     1184 <wlan_rate_to_index+0x84>
cmp    $0x37,%edi
jne    11a8 <wlan_rate_to_index+0xa8>
mov    $0x3,%eax
ret
cmp    $0x167,%edi
jg     115b <wlan_rate_to_index+0x5b>
cmp    $0x78,%edi
je     118a <wlan_rate_to_index+0x8a>
cmp    $0xb4,%edi
je     1190 <wlan_rate_to_index+0x90>
cmp    $0xf0,%edi
jne    11a8 <wlan_rate_to_index+0xa8>
mov    $0x9,%eax
ret
cmp    $0x3c,%edi
je     1196 <wlan_rate_to_index+0x96>
cmp    $0x5a,%edi
je     119c <wlan_rate_to_index+0x9c>
cmp    $0x6e,%edi
jne    11a8 <wlan_rate_to_index+0xa8>
mov    $0x6,%eax
ret
cmp    $0x168,%edi
je     11a2 <wlan_rate_to_index+0xa2>
mov    $0xc,%eax
cmp    $0x21c,%edi
je     11aa <wlan_rate_to_index+0xaa>
cmp    $0x1e0,%edi
jne    11a8 <wlan_rate_to_index+0xa8>
mov    $0xb,%eax
ret
mov    $0x1,%eax
ret
mov    $0x2,%eax
ret
mov    $0x7,%eax
ret
mov    $0x8,%eax
ret
mov    $0x4,%eax
ret
mov    $0x5,%eax
ret
mov    $0xa,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @wlan_rate_to_index(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 540, label %5
i32 480, label %6
i32 360, label %7
i32 240, label %8
i32 180, label %9
i32 120, label %10
i32 110, label %11
i32 90, label %12
i32 60, label %13
i32 55, label %14
i32 20, label %15
i32 10, label %16
]
5: ; preds = %1
store i32 12, i32* %2
br label %18
6: ; preds = %1
store i32 11, i32* %2
br label %18
7: ; preds = %1
store i32 10, i32* %2
br label %18
8: ; preds = %1
store i32 9, i32* %2
br label %18
9: ; preds = %1
store i32 8, i32* %2
br label %18
10: ; preds = %1
store i32 7, i32* %2
br label %18
11: ; preds = %1
store i32 6, i32* %2
br label %18
12: ; preds = %1
store i32 5, i32* %2
br label %18
13: ; preds = %1
store i32 4, i32* %2
br label %18
14: ; preds = %1
store i32 3, i32* %2
br label %18
15: ; preds = %1
store i32 2, i32* %2
br label %18
16: ; preds = %1
store i32 1, i32* %2
br label %18
17: ; preds = %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @wlan_rate_to_index(i32 %0) {
switch i32 %0, label %13 [
i32 540, label %14
i32 480, label %2
i32 360, label %3
i32 240, label %4
i32 180, label %5
i32 120, label %6
i32 110, label %7
i32 90, label %8
i32 60, label %9
i32 55, label %10
i32 20, label %11
i32 10, label %12
]
2: ; preds = %1
br label %14
3: ; preds = %1
br label %14
4: ; preds = %1
br label %14
5: ; preds = %1
br label %14
6: ; preds = %1
br label %14
7: ; preds = %1
br label %14
8: ; preds = %1
br label %14
9: ; preds = %1
br label %14
10: ; preds = %1
br label %14
11: ; preds = %1
br label %14
12: ; preds = %1
br label %14
13: ; preds = %1
br label %14
14: ; preds = %1, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%15 = phi i32 [ 0, %13 ], [ 1, %12 ], [ 2, %11 ], [ 3, %10 ], [ 4, %9 ], [ 5, %8 ], [ 6, %7 ], [ 7, %6 ], [ 8, %5 ], [ 9, %4 ], [ 10, %3 ], [ 11, %2 ], [ 12, %1 ]
ret i32 %15
}