#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 */
int B115200;
int B1200;
int B1800;
int B19200;
int B2400;
int B38400;
int B4800;
int B57600;
int B9600;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int string2speed(char *speed) {
  int serialspeed = 0;
  switch (atoi(optarg)) {
  case 1200:
    serialspeed = B1200;
    break;
  case 1800:
    serialspeed = B1800;
    break;
  case 2400:
    serialspeed = B2400;
    break;
  case 4800:
    serialspeed = B4800;
    break;
  case 9600:
    serialspeed = B9600;
    break;
  case 19200:
    serialspeed = B19200;
    break;
  case 38400:
    serialspeed = B38400;
    break;
  case 57600:
    serialspeed = B57600;
    break;
  case 115200:
    serialspeed = B115200;
    break;
  default:
    serialspeed = -1;
  }
  return serialspeed;
}


x86 assembly (clang, -O0):
<string2speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2ece(%rip),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
sub    $0x4b0,%eax
je     11de <string2speed+0xce>
jmp    1146 <string2speed+0x36>
mov    -0x10(%rbp),%eax
sub    $0x708,%eax
je     11ef <string2speed+0xdf>
jmp    1159 <string2speed+0x49>
mov    -0x10(%rbp),%eax
sub    $0x960,%eax
je     1200 <string2speed+0xf0>
jmp    116c <string2speed+0x5c>
mov    -0x10(%rbp),%eax
sub    $0x12c0,%eax
je     1211 <string2speed+0x101>
jmp    117f <string2speed+0x6f>
mov    -0x10(%rbp),%eax
sub    $0x2580,%eax
je     1222 <string2speed+0x112>
jmp    1192 <string2speed+0x82>
mov    -0x10(%rbp),%eax
sub    $0x4b00,%eax
je     1233 <string2speed+0x123>
jmp    11a5 <string2speed+0x95>
mov    -0x10(%rbp),%eax
sub    $0x9600,%eax
je     1244 <string2speed+0x134>
jmp    11b8 <string2speed+0xa8>
mov    -0x10(%rbp),%eax
sub    $0xe100,%eax
je     1255 <string2speed+0x145>
jmp    11cb <string2speed+0xbb>
mov    -0x10(%rbp),%eax
sub    $0x1c200,%eax
je     1266 <string2speed+0x156>
jmp    1277 <string2speed+0x167>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    127e <string2speed+0x16e>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string2speed>:
push   %rax
mov    0x2ee0(%rip),%rax
mov    (%rax),%edi
call   1030 <atoi@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x257f,%ecx
jle    115b <string2speed+0x4b>
cmp    $0x95ff,%ecx
jle    117c <string2speed+0x6c>
cmp    $0x9600,%ecx
je     11ae <string2speed+0x9e>
cmp    $0xe100,%ecx
je     11b7 <string2speed+0xa7>
cmp    $0x1c200,%ecx
jne    11db <string2speed+0xcb>
mov    0x2e47(%rip),%rax
jmp    11d9 <string2speed+0xc9>
cmp    $0x95f,%ecx
jg     1195 <string2speed+0x85>
cmp    $0x4b0,%ecx
je     11c0 <string2speed+0xb0>
cmp    $0x708,%ecx
jne    11db <string2speed+0xcb>
mov    0x2e3e(%rip),%rax
jmp    11d9 <string2speed+0xc9>
cmp    $0x2580,%ecx
je     11c9 <string2speed+0xb9>
cmp    $0x4b00,%ecx
jne    11db <string2speed+0xcb>
mov    0x2e55(%rip),%rax
jmp    11d9 <string2speed+0xc9>
cmp    $0x960,%ecx
je     11d2 <string2speed+0xc2>
cmp    $0x12c0,%ecx
jne    11db <string2speed+0xcb>
mov    0x2e2c(%rip),%rax
jmp    11d9 <string2speed+0xc9>
mov    0x2ddb(%rip),%rax
jmp    11d9 <string2speed+0xc9>
mov    0x2e0a(%rip),%rax
jmp    11d9 <string2speed+0xc9>
mov    0x2de1(%rip),%rax
jmp    11d9 <string2speed+0xc9>
mov    0x2e00(%rip),%rax
jmp    11d9 <string2speed+0xc9>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@optarg = 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
@B115200 = global i32 0
define i32 @string2speed(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i32, i32* @optarg
%5 = call i32 @atoi(i32 %4)
switch i32 %5, label %24 [
i32 1200, label %6
i32 1800, label %8
i32 2400, label %10
i32 4800, label %12
i32 9600, label %14
i32 19200, label %16
i32 38400, label %18
i32 57600, label %20
i32 115200, label %22
]
6: ; preds = %1
%7 = load i32, i32* @B1200
store i32 %7, i32* %3
br label %25
8: ; preds = %1
%9 = load i32, i32* @B1800
store i32 %9, i32* %3
br label %25
10: ; preds = %1
%11 = load i32, i32* @B2400
store i32 %11, i32* %3
br label %25
12: ; preds = %1
%13 = load i32, i32* @B4800
store i32 %13, i32* %3
br label %25
14: ; preds = %1
%15 = load i32, i32* @B9600
store i32 %15, i32* %3
br label %25
16: ; preds = %1
%17 = load i32, i32* @B19200
store i32 %17, i32* %3
br label %25
18: ; preds = %1
%19 = load i32, i32* @B38400
store i32 %19, i32* %3
br label %25
20: ; preds = %1
%21 = load i32, i32* @B57600
store i32 %21, i32* %3
br label %25
22: ; preds = %1
%23 = load i32, i32* @B115200
store i32 %23, i32* %3
br label %25
24: ; preds = %1
store i32 -1, i32* %3
br label %25
25: ; preds = %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@optarg = 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
@B115200 = global i32 0
define i32 @string2speed(i8* nocapture readnone %0) {
%2 = load i32, i32* @optarg
%3 = tail call i32 @atoi(i32 %2)
switch i32 %3, label %22 [
i32 1200, label %4
i32 1800, label %6
i32 2400, label %8
i32 4800, label %10
i32 9600, label %12
i32 19200, label %14
i32 38400, label %16
i32 57600, label %18
i32 115200, label %20
]
4: ; preds = %1
%5 = load i32, i32* @B1200
br label %22
6: ; preds = %1
%7 = load i32, i32* @B1800
br label %22
8: ; preds = %1
%9 = load i32, i32* @B2400
br label %22
10: ; preds = %1
%11 = load i32, i32* @B4800
br label %22
12: ; preds = %1
%13 = load i32, i32* @B9600
br label %22
14: ; preds = %1
%15 = load i32, i32* @B19200
br label %22
16: ; preds = %1
%17 = load i32, i32* @B38400
br label %22
18: ; preds = %1
%19 = load i32, i32* @B57600
br label %22
20: ; preds = %1
%21 = load i32, i32* @B115200
br label %22
22: ; preds = %1, %20, %18, %16, %14, %12, %10, %8, %6, %4
%23 = phi i32 [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ -1, %1 ]
ret i32 %23
}