#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 */
int B115200;
int B19200;
int B38400;
int B57600;
int B9600;
speed_t kwboot_tty_speed(int baudrate) {
  switch (baudrate) {
  case 115200:
    return B115200;
  case 57600:
    return B57600;
  case 38400:
    return B38400;
  case 19200:
    return B19200;
  case 9600:
    return B9600;
  }
  return -1;
}


x86 assembly (clang, -O0):
<kwboot_tty_speed>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x2580,%eax
je     11ad <kwboot_tty_speed+0xad>
jmp    111d <kwboot_tty_speed+0x1d>
mov    -0xc(%rbp),%eax
sub    $0x4b00,%eax
je     119c <kwboot_tty_speed+0x9c>
jmp    1130 <kwboot_tty_speed+0x30>
mov    -0xc(%rbp),%eax
sub    $0x9600,%eax
je     118b <kwboot_tty_speed+0x8b>
jmp    1143 <kwboot_tty_speed+0x43>
mov    -0xc(%rbp),%eax
sub    $0xe100,%eax
je     117a <kwboot_tty_speed+0x7a>
jmp    1156 <kwboot_tty_speed+0x56>
mov    -0xc(%rbp),%eax
sub    $0x1c200,%eax
jne    11be <kwboot_tty_speed+0xbe>
jmp    1169 <kwboot_tty_speed+0x69>
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <kwboot_tty_speed+0xc5>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <kwboot_tty_speed+0xc5>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <kwboot_tty_speed+0xc5>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <kwboot_tty_speed+0xc5>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <kwboot_tty_speed+0xc5>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<kwboot_tty_speed>:
mov    $0xffffffff,%eax
cmp    $0x95ff,%edi
jle    112e <kwboot_tty_speed+0x2e>
cmp    $0x9600,%edi
je     1147 <kwboot_tty_speed+0x47>
cmp    $0xe100,%edi
je     1150 <kwboot_tty_speed+0x50>
cmp    $0x1c200,%edi
jne    1162 <kwboot_tty_speed+0x62>
mov    0x2e9c(%rip),%rax
jmp    1160 <kwboot_tty_speed+0x60>
cmp    $0x2580,%edi
je     1159 <kwboot_tty_speed+0x59>
cmp    $0x4b00,%edi
jne    1162 <kwboot_tty_speed+0x62>
mov    0x2eab(%rip),%rax
jmp    1160 <kwboot_tty_speed+0x60>
mov    0x2e6a(%rip),%rax
jmp    1160 <kwboot_tty_speed+0x60>
mov    0x2e81(%rip),%rax
jmp    1160 <kwboot_tty_speed+0x60>
mov    0x2e80(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@B115200 = global i32 0
@B57600 = global i32 0
@B38400 = global i32 0
@B19200 = global i32 0
@B9600 = global i32 0
define i32 @kwboot_tty_speed(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 115200, label %5
i32 57600, label %7
i32 38400, label %9
i32 19200, label %11
i32 9600, label %13
]
5: ; preds = %1
%6 = load i32, i32* @B115200
store i32 %6, i32* %2
br label %16
7: ; preds = %1
%8 = load i32, i32* @B57600
store i32 %8, i32* %2
br label %16
9: ; preds = %1
%10 = load i32, i32* @B38400
store i32 %10, i32* %2
br label %16
11: ; preds = %1
%12 = load i32, i32* @B19200
store i32 %12, i32* %2
br label %16
13: ; preds = %1
%14 = load i32, i32* @B9600
store i32 %14, i32* %2
br label %16
15: ; preds = %1
store i32 -1, i32* %2
br label %16
16: ; preds = %15, %13, %11, %9, %7, %5
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@B115200 = global i32 0
@B57600 = global i32 0
@B38400 = global i32 0
@B19200 = global i32 0
@B9600 = global i32 0
define i32 @kwboot_tty_speed(i32 %0) {
switch i32 %0, label %12 [
i32 115200, label %2
i32 57600, label %4
i32 38400, label %6
i32 19200, label %8
i32 9600, label %10
]
2: ; preds = %1
%3 = load i32, i32* @B115200
br label %12
4: ; preds = %1
%5 = load i32, i32* @B57600
br label %12
6: ; preds = %1
%7 = load i32, i32* @B38400
br label %12
8: ; preds = %1
%9 = load i32, i32* @B19200
br label %12
10: ; preds = %1
%11 = load i32, i32* @B9600
br label %12
12: ; preds = %1, %10, %8, %6, %4, %2
%13 = phi i32 [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ], [ -1, %1 ]
ret i32 %13
}