#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 B1000000 157
#define B110 156
#define B115200 155
#define B1152000 154
#define B1200 153
#define B134 152
#define B150 151
#define B1500000 150
#define B1800 149
#define B19200 148
#define B200 147
#define B2000000 146
#define B230400 145
#define B2400 144
#define B2500000 143
#define B300 142
#define B3000000 141
#define B3500000 140
#define B38400 139
#define B4000000 138
#define B460800 137
#define B4800 136
#define B50 135
#define B500000 134
#define B57600 133
#define B576000 132
#define B600 131
#define B75 130
#define B921600 129
#define B9600 128
int /*<<< orphan*/ printf(char *);
int speedtobaudrate(speed_t speed) {
  printf("enum baud rate reverse matching\n");
  switch (speed) {
  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;
  case B19200:
    return 19200;
  case B38400:
    return 38400;
  case B57600:
    return 57600;
  case B115200:
    return 115200;
  case B230400:
    return 230400;
  case B460800:
    return 460800;
  case B500000:
    return 500000;
  case B576000:
    return 576000;
  case B921600:
    return 921600;
  case B1000000:
    return 1000000;
  case B1152000:
    return 1152000;
  case B1500000:
    return 1500000;
  case B2000000:
    return 2000000;
  case B2500000:
    return 2500000;
  case B3000000:
    return 3000000;
  case B3500000:
    return 3500000;
  case B4000000:
    return 4000000;
  }
  return 0;
}


x86 assembly (clang, -O0):
<speedtobaudrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xf56(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1d,%eax
ja     12b8 <speedtobaudrate+0x1a8>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x32,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x4b,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x6e,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x86,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x96,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0xc8,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x12c,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x258,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x4b0,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x708,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x960,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x12c0,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x2580,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x4b00,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x9600,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0xe100,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x1c200,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x38400,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x70800,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x7a120,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x8ca00,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0xe1000,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0xf4240,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x119400,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x16e360,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x1e8480,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x2625a0,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x2dc6c0,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x3567e0,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x3d0900,-0x4(%rbp)
jmp    12bf <speedtobaudrate+0x1af>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speedtobaudrate>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
add    $0xffffff80,%ebx
xor    %eax,%eax
cmp    $0x1d,%ebx
ja     1136 <speedtobaudrate+0x26>
movslq %ebx,%rax
lea    0xeed(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"enum baud rate reverse matching\0A\00"
define i32 @speedtobaudrate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %3
switch i32 %5, label %36 [
i32 135, label %6
i32 130, label %7
i32 156, label %8
i32 152, label %9
i32 151, label %10
i32 147, label %11
i32 142, label %12
i32 131, label %13
i32 153, label %14
i32 149, label %15
i32 144, label %16
i32 136, label %17
i32 128, label %18
i32 148, label %19
i32 139, label %20
i32 133, label %21
i32 155, label %22
i32 145, label %23
i32 137, label %24
i32 134, label %25
i32 132, label %26
i32 129, label %27
i32 157, label %28
i32 154, label %29
i32 150, label %30
i32 146, label %31
i32 143, label %32
i32 141, label %33
i32 140, label %34
i32 138, label %35
]
6: ; preds = %1
store i32 50, i32* %2
br label %37
7: ; preds = %1
store i32 75, i32* %2
br label %37
8: ; preds = %1
store i32 110, i32* %2
br label %37
9: ; preds = %1
store i32 134, i32* %2
br label %37
10: ; preds = %1
store i32 150, i32* %2
br label %37
11: ; preds = %1
store i32 200, i32* %2
br label %37
12: ; preds = %1
store i32 300, i32* %2
br label %37
13: ; preds = %1
store i32 600, i32* %2
br label %37
14: ; preds = %1
store i32 1200, i32* %2
br label %37
15: ; preds = %1
store i32 1800, i32* %2
br label %37
16: ; preds = %1
store i32 2400, i32* %2
br label %37
17: ; preds = %1
store i32 4800, i32* %2
br label %37
18: ; preds = %1
store i32 9600, i32* %2
br label %37
19: ; preds = %1
store i32 19200, i32* %2
br label %37
20: ; preds = %1
store i32 38400, i32* %2
br label %37
21: ; preds = %1
store i32 57600, i32* %2
br label %37
22: ; preds = %1
store i32 115200, i32* %2
br label %37
23: ; preds = %1
store i32 230400, i32* %2
br label %37
24: ; preds = %1
store i32 460800, i32* %2
br label %37
25: ; preds = %1
store i32 500000, i32* %2
br label %37
26: ; preds = %1
store i32 576000, i32* %2
br label %37
27: ; preds = %1
store i32 921600, i32* %2
br label %37
28: ; preds = %1
store i32 1000000, i32* %2
br label %37
29: ; preds = %1
store i32 1152000, i32* %2
br label %37
30: ; preds = %1
store i32 1500000, i32* %2
br label %37
31: ; preds = %1
store i32 2000000, i32* %2
br label %37
32: ; preds = %1
store i32 2500000, i32* %2
br label %37
33: ; preds = %1
store i32 3000000, i32* %2
br label %37
34: ; preds = %1
store i32 3500000, i32* %2
br label %37
35: ; preds = %1
store i32 4000000, i32* %2
br label %37
36: ; preds = %1
store i32 0, i32* %2
br label %37
37: ; preds = %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@str = [32 x i8] c"enum baud rate reverse matching\00"
@switch.table.speedtobaudrate = [30 x i32] [i32 9600, i32 921600, i32 75, i32 600, i32 576000, i32 57600, i32 500000, i32 50, i32 4800, i32 460800, i32 4000000, i32 38400, i32 3500000, i32 3000000, i32 300, i32 2500000, i32 2400, i32 230400, i32 2000000, i32 200, i32 19200, i32 1800, i32 1500000, i32 150, i32 134, i32 1200, i32 1152000, i32 115200, i32 110, i32 1000000]
define i32 @speedtobaudrate(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%3 = add i32 %0, -128
%4 = icmp ult i32 %3, 30
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [30 x i32], [30 x i32]* @switch.table.speedtobaudrate, i64 0, i64 %6
%8 = load i32, i32* %7
br label %9
9: ; preds = %1, %5
%10 = phi i32 [ %8, %5 ], [ 0, %1 ]
ret i32 %10
}