#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*/ B115200;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B2400;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B4800;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B9600;
int error_return(char const *, char *);
int speed_to_baud(const char *caller, int speed, speed_t *baud) {
  switch (speed) {
  case 2400:
    *baud = B2400;
    return 0;
  case 4800:
    *baud = B4800;
    return 0;
  case 9600:
    *baud = B9600;
    return 0;
  case 19200:
    *baud = B19200;
    return 0;
  case 38400:
    *baud = B38400;
    return 0;
  case 57600:
    *baud = B57600;
    return 0;
  case 115200:
    *baud = B115200;
    return 0;
  default:
    return error_return(caller, "speed_to_baud: unknown baud rate");
  }
}


x86 assembly (clang, -O0):
<speed_to_baud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x960,%eax
je     11ab <speed_to_baud+0x9b>
jmp    1139 <speed_to_baud+0x29>
mov    -0x24(%rbp),%eax
sub    $0x12c0,%eax
je     11c6 <speed_to_baud+0xb6>
jmp    114c <speed_to_baud+0x3c>
mov    -0x24(%rbp),%eax
sub    $0x2580,%eax
je     11e1 <speed_to_baud+0xd1>
jmp    115f <speed_to_baud+0x4f>
mov    -0x24(%rbp),%eax
sub    $0x4b00,%eax
je     11fc <speed_to_baud+0xec>
jmp    1172 <speed_to_baud+0x62>
mov    -0x24(%rbp),%eax
sub    $0x9600,%eax
je     1217 <speed_to_baud+0x107>
jmp    1185 <speed_to_baud+0x75>
mov    -0x24(%rbp),%eax
sub    $0xe100,%eax
je     1232 <speed_to_baud+0x122>
jmp    1198 <speed_to_baud+0x88>
mov    -0x24(%rbp),%eax
sub    $0x1c200,%eax
je     124d <speed_to_baud+0x13d>
jmp    1268 <speed_to_baud+0x158>
mov    0x2e0e(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2e13(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2df0(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2ded(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2d8a(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2d97(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    0x2d64(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    127b <speed_to_baud+0x16b>
mov    -0x10(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1030 <error_return@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speed_to_baud>:
cmp    $0x4aff,%esi
jle    1139 <speed_to_baud+0x29>
cmp    $0xe0ff,%esi
jg     115a <speed_to_baud+0x4a>
cmp    $0x4b00,%esi
je     1173 <speed_to_baud+0x63>
cmp    $0x9600,%esi
jne    118e <speed_to_baud+0x7e>
mov    0x2e71(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
cmp    $0x960,%esi
je     117c <speed_to_baud+0x6c>
cmp    $0x12c0,%esi
je     119a <speed_to_baud+0x8a>
cmp    $0x2580,%esi
jne    118e <speed_to_baud+0x7e>
mov    0x2e80(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
cmp    $0xe100,%esi
je     1185 <speed_to_baud+0x75>
cmp    $0x1c200,%esi
jne    118e <speed_to_baud+0x7e>
mov    0x2e47(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
mov    0x2e76(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
mov    0x2e3d(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
mov    0x2e44(%rip),%rax
jmp    11a1 <speed_to_baud+0x91>
lea    0xe6b(%rip),%rsi
jmp    1030 <error_return@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rdx)
xor    %eax,%eax
ret

LLVM IR (-O0):
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@.str = [33 x i8] c"speed_to_baud: unknown baud rate\00"
define i32 @speed_to_baud(i8* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %6
switch i32 %8, label %30 [
i32 2400, label %9
i32 4800, label %12
i32 9600, label %15
i32 19200, label %18
i32 38400, label %21
i32 57600, label %24
i32 115200, label %27
]
9: ; preds = %3
%10 = load i32, i32* @B2400
%11 = load i32*, i32** %7
store i32 %10, i32* %11
store i32 0, i32* %4
br label %33
12: ; preds = %3
%13 = load i32, i32* @B4800
%14 = load i32*, i32** %7
store i32 %13, i32* %14
store i32 0, i32* %4
br label %33
15: ; preds = %3
%16 = load i32, i32* @B9600
%17 = load i32*, i32** %7
store i32 %16, i32* %17
store i32 0, i32* %4
br label %33
18: ; preds = %3
%19 = load i32, i32* @B19200
%20 = load i32*, i32** %7
store i32 %19, i32* %20
store i32 0, i32* %4
br label %33
21: ; preds = %3
%22 = load i32, i32* @B38400
%23 = load i32*, i32** %7
store i32 %22, i32* %23
store i32 0, i32* %4
br label %33
24: ; preds = %3
%25 = load i32, i32* @B57600
%26 = load i32*, i32** %7
store i32 %25, i32* %26
store i32 0, i32* %4
br label %33
27: ; preds = %3
%28 = load i32, i32* @B115200
%29 = load i32*, i32** %7
store i32 %28, i32* %29
store i32 0, i32* %4
br label %33
30: ; preds = %3
%31 = load i8*, i8** %5
%32 = call i32 @error_return(i8* %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 %32, i32* %4
br label %33
33: ; preds = %30, %27, %24, %21, %18, %15, %12, %9
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@.str = [33 x i8] c"speed_to_baud: unknown baud rate\00"
define i32 @speed_to_baud(i8* %0, i32 %1, i32* nocapture writeonly %2) {
switch i32 %1, label %18 [
i32 2400, label %4
i32 4800, label %6
i32 9600, label %8
i32 19200, label %10
i32 38400, label %12
i32 57600, label %14
i32 115200, label %16
]
4: ; preds = %3
%5 = load i32, i32* @B2400
store i32 %5, i32* %2
br label %20
6: ; preds = %3
%7 = load i32, i32* @B4800
store i32 %7, i32* %2
br label %20
8: ; preds = %3
%9 = load i32, i32* @B9600
store i32 %9, i32* %2
br label %20
10: ; preds = %3
%11 = load i32, i32* @B19200
store i32 %11, i32* %2
br label %20
12: ; preds = %3
%13 = load i32, i32* @B38400
store i32 %13, i32* %2
br label %20
14: ; preds = %3
%15 = load i32, i32* @B57600
store i32 %15, i32* %2
br label %20
16: ; preds = %3
%17 = load i32, i32* @B115200
store i32 %17, i32* %2
br label %20
18: ; preds = %3
%19 = tail call i32 @error_return(i8* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12, %10, %8, %6, %4
%21 = phi i32 [ %19, %18 ], [ 0, %16 ], [ 0, %14 ], [ 0, %12 ], [ 0, %10 ], [ 0, %8 ], [ 0, %6 ], [ 0, %4 ]
ret i32 %21
}