int xbee_baud_rate_mapper(int baud) {
  int value;
  switch (baud) {
  case 1200:
    value = 0;
    break;
  case 2300:
    value = 1;
    break;
  case 4800:
    value = 2;
    break;
  case 9600:
    value = 3;
    break;
  case 19200:
    value = 4;
    break;
  case 38400:
    value = 5;
    break;
  case 57600:
    value = 6;
    break;
  case 115200:
    value = 7;
    break;
  }
  return value;
}


x86 assembly (clang, -O0):
<xbee_baud_rate_mapper>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x4b0,%eax
je     11a2 <xbee_baud_rate_mapper+0xa2>
jmp    111d <xbee_baud_rate_mapper+0x1d>
mov    -0xc(%rbp),%eax
sub    $0x8fc,%eax
je     11ae <xbee_baud_rate_mapper+0xae>
jmp    1130 <xbee_baud_rate_mapper+0x30>
mov    -0xc(%rbp),%eax
sub    $0x12c0,%eax
je     11ba <xbee_baud_rate_mapper+0xba>
jmp    1143 <xbee_baud_rate_mapper+0x43>
mov    -0xc(%rbp),%eax
sub    $0x2580,%eax
je     11c6 <xbee_baud_rate_mapper+0xc6>
jmp    1156 <xbee_baud_rate_mapper+0x56>
mov    -0xc(%rbp),%eax
sub    $0x4b00,%eax
je     11d2 <xbee_baud_rate_mapper+0xd2>
jmp    1169 <xbee_baud_rate_mapper+0x69>
mov    -0xc(%rbp),%eax
sub    $0x9600,%eax
je     11de <xbee_baud_rate_mapper+0xde>
jmp    117c <xbee_baud_rate_mapper+0x7c>
mov    -0xc(%rbp),%eax
sub    $0xe100,%eax
je     11ea <xbee_baud_rate_mapper+0xea>
jmp    118f <xbee_baud_rate_mapper+0x8f>
mov    -0xc(%rbp),%eax
sub    $0x1c200,%eax
je     11f6 <xbee_baud_rate_mapper+0xf6>
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x0,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x1,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x2,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x3,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x4,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x5,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x6,-0x8(%rbp)
jmp    11fd <xbee_baud_rate_mapper+0xfd>
movl   $0x7,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xbee_baud_rate_mapper>:
xor    %eax,%eax
cmp    $0x4aff,%edi
jle    1128 <xbee_baud_rate_mapper+0x28>
cmp    $0xe0ff,%edi
jg     1146 <xbee_baud_rate_mapper+0x46>
cmp    $0x4b00,%edi
je     115c <xbee_baud_rate_mapper+0x5c>
cmp    $0x9600,%edi
jne    116d <xbee_baud_rate_mapper+0x6d>
mov    $0x5,%eax
ret
cmp    $0x8fc,%edi
je     1162 <xbee_baud_rate_mapper+0x62>
cmp    $0x12c0,%edi
je     116e <xbee_baud_rate_mapper+0x6e>
cmp    $0x2580,%edi
jne    116d <xbee_baud_rate_mapper+0x6d>
mov    $0x3,%eax
ret
cmp    $0xe100,%edi
je     1168 <xbee_baud_rate_mapper+0x68>
cmp    $0x1c200,%edi
jne    116d <xbee_baud_rate_mapper+0x6d>
mov    $0x7,%eax
ret
mov    $0x4,%eax
ret
mov    $0x1,%eax
ret
mov    $0x6,%eax
ret
mov    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @xbee_baud_rate_mapper(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %13 [
i32 1200, label %5
i32 2300, label %6
i32 4800, label %7
i32 9600, label %8
i32 19200, label %9
i32 38400, label %10
i32 57600, label %11
i32 115200, label %12
]
5: ; preds = %1
store i32 0, i32* %3
br label %13
6: ; preds = %1
store i32 1, i32* %3
br label %13
7: ; preds = %1
store i32 2, i32* %3
br label %13
8: ; preds = %1
store i32 3, i32* %3
br label %13
9: ; preds = %1
store i32 4, i32* %3
br label %13
10: ; preds = %1
store i32 5, i32* %3
br label %13
11: ; preds = %1
store i32 6, i32* %3
br label %13
12: ; preds = %1
store i32 7, i32* %3
br label %13
13: ; preds = %1, %12, %11, %10, %9, %8, %7, %6, %5
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
define i32 @xbee_baud_rate_mapper(i32 %0) {
switch i32 %0, label %9 [
i32 115200, label %8
i32 2300, label %2
i32 4800, label %3
i32 9600, label %4
i32 19200, label %5
i32 38400, label %6
i32 57600, label %7
]
2: ; preds = %1
br label %9
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i32 [ 7, %8 ], [ 6, %7 ], [ 5, %6 ], [ 4, %5 ], [ 3, %4 ], [ 2, %3 ], [ 1, %2 ], [ 0, %1 ]
ret i32 %10
}