#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;
int atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int);
int /*<<< orphan*/ stderr;
speed_t parse_baudrate(const char *value) {
  int rate = atoi(value);
  switch (rate) {
  case 9600:
    return B9600;
  case 19200:
    return B19200;
  case 38400:
    return B38400;
  case 57600:
    return B57600;
  case 115200:
    return B115200;
  default:
    fprintf(stderr, "Invalid baudrate %s, using %d\n", value, B38400);
    return B38400;
  }
}


x86 assembly (clang, -O0):
<parse_baudrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2580,%eax
je     119a <parse_baudrate+0x7a>
jmp    114e <parse_baudrate+0x2e>
mov    -0x18(%rbp),%eax
sub    $0x4b00,%eax
je     11ab <parse_baudrate+0x8b>
jmp    1161 <parse_baudrate+0x41>
mov    -0x18(%rbp),%eax
sub    $0x9600,%eax
je     11bc <parse_baudrate+0x9c>
jmp    1174 <parse_baudrate+0x54>
mov    -0x18(%rbp),%eax
sub    $0xe100,%eax
je     11cd <parse_baudrate+0xad>
jmp    1187 <parse_baudrate+0x67>
mov    -0x18(%rbp),%eax
sub    $0x1c200,%eax
je     11de <parse_baudrate+0xbe>
jmp    11ef <parse_baudrate+0xcf>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <parse_baudrate+0xfd>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <parse_baudrate+0xfd>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <parse_baudrate+0xfd>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <parse_baudrate+0xfd>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121d <parse_baudrate+0xfd>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    0x2dad(%rip),%rax
mov    (%rax),%ecx
lea    0xdf4(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_baudrate>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <atoi@plt>
cmp    $0x95ff,%eax
jle    1151 <parse_baudrate+0x31>
cmp    $0x9600,%eax
je     1168 <parse_baudrate+0x48>
cmp    $0xe100,%eax
je     1171 <parse_baudrate+0x51>
cmp    $0x1c200,%eax
jne    1183 <parse_baudrate+0x63>
mov    0x2e71(%rip),%rbx
jmp    11a4 <parse_baudrate+0x84>
cmp    $0x2580,%eax
je     117a <parse_baudrate+0x5a>
cmp    $0x4b00,%eax
jne    1183 <parse_baudrate+0x63>
mov    0x2e8a(%rip),%rbx
jmp    11a4 <parse_baudrate+0x84>
mov    0x2e41(%rip),%rbx
jmp    11a4 <parse_baudrate+0x84>
mov    0x2e60(%rip),%rbx
jmp    11a4 <parse_baudrate+0x84>
mov    0x2e5f(%rip),%rbx
jmp    11a4 <parse_baudrate+0x84>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    0x2e1d(%rip),%rbx
mov    (%rbx),%ecx
lea    0xe64(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Invalid baudrate %s, using %d\0A\00"
define i32 @parse_baudrate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @atoi(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %18 [
i32 9600, label %8
i32 19200, label %10
i32 38400, label %12
i32 57600, label %14
i32 115200, label %16
]
8: ; preds = %1
%9 = load i32, i32* @B9600
store i32 %9, i32* %2
br label %24
10: ; preds = %1
%11 = load i32, i32* @B19200
store i32 %11, i32* %2
br label %24
12: ; preds = %1
%13 = load i32, i32* @B38400
store i32 %13, i32* %2
br label %24
14: ; preds = %1
%15 = load i32, i32* @B57600
store i32 %15, i32* %2
br label %24
16: ; preds = %1
%17 = load i32, i32* @B115200
store i32 %17, i32* %2
br label %24
18: ; preds = %1
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %3
%21 = load i32, i32* @B38400
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21)
%23 = load i32, i32* @B38400
store i32 %23, i32* %2
br label %24
24: ; preds = %18, %16, %14, %12, %10, %8
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Invalid baudrate %s, using %d\0A\00"
define i32 @parse_baudrate(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
switch i32 %2, label %7 [
i32 9600, label %11
i32 19200, label %3
i32 38400, label %4
i32 57600, label %5
i32 115200, label %6
]
3: ; preds = %1
br label %11
4: ; preds = %1
br label %11
5: ; preds = %1
br label %11
6: ; preds = %1
br label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i32, i32* @B38400
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %9)
br label %11
11: ; preds = %1, %7, %6, %5, %4, %3
%12 = phi i32* [ @B38400, %7 ], [ @B115200, %6 ], [ @B57600, %5 ], [ @B38400, %4 ], [ @B19200, %3 ], [ @B9600, %1 ]
%13 = load i32, i32* %12
ret i32 %13
}