int rn42_baud_rate_mapper(int baud) {
  int value;
  switch (baud) {
  case 1200:
    value = 12;
    break;
  case 2300:
    value = 23;
    break;
  case 4800:
    value = 48;
    break;
  case 9600:
    value = 96;
    break;
  case 19200:
    value = 19;
    break;
  case 38400:
    value = 28;
    break;
  case 57600:
    value = 57;
    break;
  case 115200:
    value = 11;
    break;
  case 230400:
    value = 23;
    break;
  case 460800:
    value = 46;
    break;
  case 921600:
    value = 92;
    break;
  }
  return value;
}


x86 assembly (clang, -O0):
<rn42_baud_rate_mapper>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x4b0,%eax
je     11db <rn42_baud_rate_mapper+0xdb>
jmp    111d <rn42_baud_rate_mapper+0x1d>
mov    -0xc(%rbp),%eax
sub    $0x8fc,%eax
je     11e7 <rn42_baud_rate_mapper+0xe7>
jmp    1130 <rn42_baud_rate_mapper+0x30>
mov    -0xc(%rbp),%eax
sub    $0x12c0,%eax
je     11f3 <rn42_baud_rate_mapper+0xf3>
jmp    1143 <rn42_baud_rate_mapper+0x43>
mov    -0xc(%rbp),%eax
sub    $0x2580,%eax
je     11ff <rn42_baud_rate_mapper+0xff>
jmp    1156 <rn42_baud_rate_mapper+0x56>
mov    -0xc(%rbp),%eax
sub    $0x4b00,%eax
je     120b <rn42_baud_rate_mapper+0x10b>
jmp    1169 <rn42_baud_rate_mapper+0x69>
mov    -0xc(%rbp),%eax
sub    $0x9600,%eax
je     1217 <rn42_baud_rate_mapper+0x117>
jmp    117c <rn42_baud_rate_mapper+0x7c>
mov    -0xc(%rbp),%eax
sub    $0xe100,%eax
je     1223 <rn42_baud_rate_mapper+0x123>
jmp    118f <rn42_baud_rate_mapper+0x8f>
mov    -0xc(%rbp),%eax
sub    $0x1c200,%eax
je     122f <rn42_baud_rate_mapper+0x12f>
jmp    11a2 <rn42_baud_rate_mapper+0xa2>
mov    -0xc(%rbp),%eax
sub    $0x38400,%eax
je     123b <rn42_baud_rate_mapper+0x13b>
jmp    11b5 <rn42_baud_rate_mapper+0xb5>
mov    -0xc(%rbp),%eax
sub    $0x70800,%eax
je     1247 <rn42_baud_rate_mapper+0x147>
jmp    11c8 <rn42_baud_rate_mapper+0xc8>
mov    -0xc(%rbp),%eax
sub    $0xe1000,%eax
je     1253 <rn42_baud_rate_mapper+0x153>
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0xc,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x17,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x30,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x60,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x13,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x1c,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x39,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0xb,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x17,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x2e,-0x8(%rbp)
jmp    125a <rn42_baud_rate_mapper+0x15a>
movl   $0x5c,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rn42_baud_rate_mapper>:
mov    $0xc,%eax
cmp    $0xe0ff,%edi
jg     1133 <rn42_baud_rate_mapper+0x33>
cmp    $0x257f,%edi
jle    1159 <rn42_baud_rate_mapper+0x59>
cmp    $0x2580,%edi
je     118b <rn42_baud_rate_mapper+0x8b>
cmp    $0x4b00,%edi
je     1191 <rn42_baud_rate_mapper+0x91>
cmp    $0x9600,%edi
jne    119c <rn42_baud_rate_mapper+0x9c>
mov    $0x1c,%eax
ret
cmp    $0x383ff,%edi
jle    116f <rn42_baud_rate_mapper+0x6f>
cmp    $0x38400,%edi
je     1185 <rn42_baud_rate_mapper+0x85>
cmp    $0x70800,%edi
je     1197 <rn42_baud_rate_mapper+0x97>
cmp    $0xe1000,%edi
jne    119c <rn42_baud_rate_mapper+0x9c>
mov    $0x5c,%eax
ret
cmp    $0x8fc,%edi
je     1185 <rn42_baud_rate_mapper+0x85>
cmp    $0x12c0,%edi
jne    119c <rn42_baud_rate_mapper+0x9c>
mov    $0x30,%eax
ret
cmp    $0xe100,%edi
je     119d <rn42_baud_rate_mapper+0x9d>
cmp    $0x1c200,%edi
jne    119c <rn42_baud_rate_mapper+0x9c>
mov    $0xb,%eax
ret
mov    $0x17,%eax
ret
mov    $0x60,%eax
ret
mov    $0x13,%eax
ret
mov    $0x2e,%eax
ret
mov    $0x39,%eax
ret

LLVM IR (-O0):
define i32 @rn42_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 %16 [
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
i32 230400, label %13
i32 460800, label %14
i32 921600, label %15
]
5: ; preds = %1
store i32 12, i32* %3
br label %16
6: ; preds = %1
store i32 23, i32* %3
br label %16
7: ; preds = %1
store i32 48, i32* %3
br label %16
8: ; preds = %1
store i32 96, i32* %3
br label %16
9: ; preds = %1
store i32 19, i32* %3
br label %16
10: ; preds = %1
store i32 28, i32* %3
br label %16
11: ; preds = %1
store i32 57, i32* %3
br label %16
12: ; preds = %1
store i32 11, i32* %3
br label %16
13: ; preds = %1
store i32 23, i32* %3
br label %16
14: ; preds = %1
store i32 46, i32* %3
br label %16
15: ; preds = %1
store i32 92, i32* %3
br label %16
16: ; preds = %1, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
define i32 @rn42_baud_rate_mapper(i32 %0) {
switch i32 %0, label %12 [
i32 921600, label %11
i32 2300, label %2
i32 4800, label %3
i32 9600, label %4
i32 19200, label %5
i32 38400, label %6
i32 57600, label %7
i32 115200, label %8
i32 230400, label %9
i32 460800, label %10
]
2: ; preds = %1
br label %12
3: ; preds = %1
br label %12
4: ; preds = %1
br label %12
5: ; preds = %1
br label %12
6: ; preds = %1
br label %12
7: ; preds = %1
br label %12
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
br label %12
11: ; preds = %1
br label %12
12: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%13 = phi i32 [ 92, %11 ], [ 46, %10 ], [ 23, %9 ], [ 11, %8 ], [ 57, %7 ], [ 28, %6 ], [ 19, %5 ], [ 96, %4 ], [ 48, %3 ], [ 23, %2 ], [ 12, %1 ]
ret i32 %13
}