#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 */

/* Variables and functions */
#define B115200 133
#define B19200 132
#define B230400 131
#define B38400 130
#define B57600 129
#define B9600 128
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int BaudrateToBitPerSec(int baudrate) {
  switch (baudrate) {
  case B9600:
    return 9600;
    break;
  case B19200:
    return 19200;
    break;
  case B38400:
    return 38400;
    break;
  case B57600:
    return 57600;
    break;
  case B115200:
    return 115200;
    break;
  case B230400:
    return 230400;
    break;
  default: {
    fprintf(stderr, "Internal error!\n");
    exit(EXIT_FAILURE);
  }
  }
}


x86 assembly (clang, -O0):
<BaudrateToBitPerSec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     119c <BaudrateToBitPerSec+0x7c>
mov    -0x10(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x2580,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
movl   $0x4b00,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
movl   $0x9600,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
movl   $0xe100,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
movl   $0x1c200,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
movl   $0x38400,-0x4(%rbp)
jmp    11bf <BaudrateToBitPerSec+0x9f>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BaudrateToBitPerSec>:
push   %rax
add    $0xffffff80,%edi
cmp    $0x6,%edi
jae    1138 <BaudrateToBitPerSec+0x18>
movslq %edi,%rax
lea    0xee1(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Internal error!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @BaudrateToBitPerSec(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 128, label %5
i32 132, label %6
i32 130, label %7
i32 129, label %8
i32 133, label %9
i32 131, label %10
]
5: ; preds = %1
store i32 9600, i32* %2
br label %16
6: ; preds = %1
store i32 19200, i32* %2
br label %16
7: ; preds = %1
store i32 38400, i32* %2
br label %16
8: ; preds = %1
store i32 57600, i32* %2
br label %16
9: ; preds = %1
store i32 115200, i32* %2
br label %16
10: ; preds = %1
store i32 230400, i32* %2
br label %16
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %10, %9, %8, %7, %6, %5
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Internal error!\0A\00"
@EXIT_FAILURE = global i32 0
@switch.table.BaudrateToBitPerSec = [6 x i32] [i32 9600, i32 57600, i32 38400, i32 230400, i32 19200, i32 115200]
define i32 @BaudrateToBitPerSec(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 6
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.BaudrateToBitPerSec, i64 0, i64 %10
%12 = load i32, i32* %11
ret i32 %12
}