#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int speed_t;

/* Variables and functions */
#define B0 141
#define B110 140
#define B1200 139
#define B134 138
#define B150 137
#define B1800 136
#define B200 135
#define B2400 134
#define B300 133
#define B4800 132
#define B50 131
#define B600 130
#define B75 129
#define B9600 128
int speed_to_baud(speed_t speed) {
  switch (speed) {
  case B0:
    return 0;
  case B50:
    return 50;
  case B75:
    return 75;
  case B110:
    return 110;
  case B134:
    return 134;
  case B150:
    return 150;
  case B200:
    return 200;
  case B300:
    return 300;
  case B600:
    return 600;
  case B1200:
    return 1200;
  case B1800:
    return 1800;
  case B2400:
    return 2400;
  case B4800:
    return 4800;
  case B9600:
    return 9600;
  default:
    return 9600;
  }
}


x86 assembly (clang, -O0):
<speed_to_baud>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xd,%eax
ja     11d8 <speed_to_baud+0xd8>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x32,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x4b,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x6e,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x86,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x96,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0xc8,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x12c,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x258,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x4b0,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x708,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x960,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x12c0,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x2580,-0x4(%rbp)
jmp    11df <speed_to_baud+0xdf>
movl   $0x2580,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<speed_to_baud>:
add    $0xffffff80,%edi
mov    $0x2580,%eax
cmp    $0xd,%edi
ja     111a <speed_to_baud+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @speed_to_baud(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %19 [
i32 141, label %5
i32 131, label %6
i32 129, label %7
i32 140, label %8
i32 138, label %9
i32 137, label %10
i32 135, label %11
i32 133, label %12
i32 130, label %13
i32 139, label %14
i32 136, label %15
i32 134, label %16
i32 132, label %17
i32 128, label %18
]
5: ; preds = %1
store i32 0, i32* %2
br label %20
6: ; preds = %1
store i32 50, i32* %2
br label %20
7: ; preds = %1
store i32 75, i32* %2
br label %20
8: ; preds = %1
store i32 110, i32* %2
br label %20
9: ; preds = %1
store i32 134, i32* %2
br label %20
10: ; preds = %1
store i32 150, i32* %2
br label %20
11: ; preds = %1
store i32 200, i32* %2
br label %20
12: ; preds = %1
store i32 300, i32* %2
br label %20
13: ; preds = %1
store i32 600, i32* %2
br label %20
14: ; preds = %1
store i32 1200, i32* %2
br label %20
15: ; preds = %1
store i32 1800, i32* %2
br label %20
16: ; preds = %1
store i32 2400, i32* %2
br label %20
17: ; preds = %1
store i32 4800, i32* %2
br label %20
18: ; preds = %1
store i32 9600, i32* %2
br label %20
19: ; preds = %1
store i32 9600, i32* %2
br label %20
20: ; preds = %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@switch.table.speed_to_baud = [14 x i32] [i32 9600, i32 75, i32 600, i32 50, i32 4800, i32 300, i32 2400, i32 200, i32 1800, i32 150, i32 134, i32 1200, i32 110, i32 0]
define i32 @speed_to_baud(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 14
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [14 x i32], [14 x i32]* @switch.table.speed_to_baud, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %1, %4
%9 = phi i32 [ %7, %4 ], [ 9600, %1 ]
ret i32 %9
}