#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 /*<<< orphan*/ speed_t;

/* Variables and functions */
int /*<<< orphan*/ B1200;
int /*<<< orphan*/ B1800;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B2400;
int /*<<< orphan*/ B300;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B4800;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B600;
int /*<<< orphan*/ B9600;
int atoi(char const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
speed_t ConvertBaud(const char *baudratestr) {
  switch (atoi(baudratestr)) {
  case 300:
    return B300;
  case 600:
    return B600;
  case 1200:
    return B1200;
  case 1800:
    return B1800;
  case 2400:
    return B2400;
  case 4800:
    return B4800;
  case 9600:
    return B9600;
  case 19200:
    return B19200;
  case 38400:
    return B38400;
  case 57600:
    return B57600;
  default:
    printf("Invalid baud rate: %s\n", baudratestr);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<ConvertBaud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0x12c,%eax
je     1205 <ConvertBaud+0xd5>
jmp    115a <ConvertBaud+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x258,%eax
je     1216 <ConvertBaud+0xe6>
jmp    116d <ConvertBaud+0x3d>
mov    -0x14(%rbp),%eax
sub    $0x4b0,%eax
je     1227 <ConvertBaud+0xf7>
jmp    1180 <ConvertBaud+0x50>
mov    -0x14(%rbp),%eax
sub    $0x708,%eax
je     1238 <ConvertBaud+0x108>
jmp    1193 <ConvertBaud+0x63>
mov    -0x14(%rbp),%eax
sub    $0x960,%eax
je     1249 <ConvertBaud+0x119>
jmp    11a6 <ConvertBaud+0x76>
mov    -0x14(%rbp),%eax
sub    $0x12c0,%eax
je     125a <ConvertBaud+0x12a>
jmp    11b9 <ConvertBaud+0x89>
mov    -0x14(%rbp),%eax
sub    $0x2580,%eax
je     126b <ConvertBaud+0x13b>
jmp    11cc <ConvertBaud+0x9c>
mov    -0x14(%rbp),%eax
sub    $0x4b00,%eax
je     127c <ConvertBaud+0x14c>
jmp    11df <ConvertBaud+0xaf>
mov    -0x14(%rbp),%eax
sub    $0x9600,%eax
je     128d <ConvertBaud+0x15d>
jmp    11f2 <ConvertBaud+0xc2>
mov    -0x14(%rbp),%eax
sub    $0xe100,%eax
je     129e <ConvertBaud+0x16e>
jmp    12af <ConvertBaud+0x17f>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    0x2d1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c6 <ConvertBaud+0x196>
mov    -0x10(%rbp),%rsi
lea    0xd46(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertBaud>:
push   %rbx
mov    %rdi,%rbx
call   1040 <atoi@plt>
cmp    $0x12bf,%eax
jg     116c <ConvertBaud+0x3c>
cmp    $0x4af,%eax
jle    1191 <ConvertBaud+0x61>
cmp    $0x4b0,%eax
je     11bf <ConvertBaud+0x8f>
cmp    $0x708,%eax
je     11c8 <ConvertBaud+0x98>
cmp    $0x960,%eax
jne    11f7 <ConvertBaud+0xc7>
mov    0x2e41(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
cmp    $0x4aff,%eax
jle    11a8 <ConvertBaud+0x78>
cmp    $0x4b00,%eax
je     11d1 <ConvertBaud+0xa1>
cmp    $0x9600,%eax
je     11da <ConvertBaud+0xaa>
cmp    $0xe100,%eax
jne    11f7 <ConvertBaud+0xc7>
mov    0x2e31(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
cmp    $0x12c,%eax
je     11e3 <ConvertBaud+0xb3>
cmp    $0x258,%eax
jne    11f7 <ConvertBaud+0xc7>
mov    0x2e3a(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
cmp    $0x12c0,%eax
je     11ec <ConvertBaud+0xbc>
cmp    $0x2580,%eax
jne    11f7 <ConvertBaud+0xc7>
mov    0x2e13(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2dda(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2de1(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2e18(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2daf(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2dde(%rip),%rax
jmp    11f3 <ConvertBaud+0xc3>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xe02(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@.str = [23 x i8] c"Invalid baud rate: %s\0A\00"
define i32 @ConvertBaud(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @atoi(i8* %4)
switch i32 %5, label %26 [
i32 300, label %6
i32 600, label %8
i32 1200, label %10
i32 1800, label %12
i32 2400, label %14
i32 4800, label %16
i32 9600, label %18
i32 19200, label %20
i32 38400, label %22
i32 57600, label %24
]
6: ; preds = %1
%7 = load i32, i32* @B300
store i32 %7, i32* %2
br label %30
8: ; preds = %1
%9 = load i32, i32* @B600
store i32 %9, i32* %2
br label %30
10: ; preds = %1
%11 = load i32, i32* @B1200
store i32 %11, i32* %2
br label %30
12: ; preds = %1
%13 = load i32, i32* @B1800
store i32 %13, i32* %2
br label %30
14: ; preds = %1
%15 = load i32, i32* @B2400
store i32 %15, i32* %2
br label %30
16: ; preds = %1
%17 = load i32, i32* @B4800
store i32 %17, i32* %2
br label %30
18: ; preds = %1
%19 = load i32, i32* @B9600
store i32 %19, i32* %2
br label %30
20: ; preds = %1
%21 = load i32, i32* @B19200
store i32 %21, i32* %2
br label %30
22: ; preds = %1
%23 = load i32, i32* @B38400
store i32 %23, i32* %2
br label %30
24: ; preds = %1
%25 = load i32, i32* @B57600
store i32 %25, i32* %2
br label %30
26: ; preds = %1
%27 = load i8*, i8** %3
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@B300 = global i32 0
@B600 = global i32 0
@B1200 = global i32 0
@B1800 = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@.str = [23 x i8] c"Invalid baud rate: %s\0A\00"
define i32 @ConvertBaud(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
switch i32 %2, label %12 [
i32 300, label %15
i32 600, label %3
i32 1200, label %4
i32 1800, label %5
i32 2400, label %6
i32 4800, label %7
i32 9600, label %8
i32 19200, label %9
i32 38400, label %10
i32 57600, label %11
]
3: ; preds = %1
br label %15
4: ; preds = %1
br label %15
5: ; preds = %1
br label %15
6: ; preds = %1
br label %15
7: ; preds = %1
br label %15
8: ; preds = %1
br label %15
9: ; preds = %1
br label %15
10: ; preds = %1
br label %15
11: ; preds = %1
br label %15
12: ; preds = %1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %1, %11, %10, %9, %8, %7, %6, %5, %4, %3
%16 = phi i32* [ @B57600, %11 ], [ @B38400, %10 ], [ @B19200, %9 ], [ @B9600, %8 ], [ @B4800, %7 ], [ @B2400, %6 ], [ @B1800, %5 ], [ @B1200, %4 ], [ @B600, %3 ], [ @B300, %1 ]
%17 = load i32, i32* %16
ret i32 %17
}