#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 */
struct termios {
  int c_cflag;
  int *c_cc;
  scalar_t__ c_lflag;
  scalar_t__ c_oflag;
  int /*<<< orphan*/ c_iflag;
};
typedef int /*<<< orphan*/ options;

/* Variables and functions */
int B1000000;
int B110;
int B115200;
int B1200;
int B134;
int B150;
int B1800;
int B19200;
int B200;
int B230400;
int B2400;
int B300;
int B38400;
int B460800;
int B4800;
int B50;
int B500000;
int B57600;
int B576000;
int B600;
int B75;
int B921600;
int B9600;
int CLOCAL;
int CREAD;
int CS8;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ IGNPAR;
int O_NOCTTY;
int O_RDWR;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int open(char *, int);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int Serial_Openport(char *port, int baudrate, int rec_chars, int block_time) {
  struct termios options;
  int baudr;
  int port_id;
  switch (baudrate) {
  case 50:
    baudr = B50;
    break;
  case 75:
    baudr = B75;
    break;
  case 110:
    baudr = B110;
    break;
  case 134:
    baudr = B134;
    break;
  case 150:
    baudr = B150;
    break;
  case 200:
    baudr = B200;
    break;
  case 300:
    baudr = B300;
    break;
  case 600:
    baudr = B600;
    break;
  case 1200:
    baudr = B1200;
    break;
  case 1800:
    baudr = B1800;
    break;
  case 2400:
    baudr = B2400;
    break;
  case 4800:
    baudr = B4800;
    break;
  case 9600:
    baudr = B9600;
    break;
  case 19200:
    baudr = B19200;
    break;
  case 38400:
    baudr = B38400;
    break;
  case 57600:
    baudr = B57600;
    break;
  case 115200:
    baudr = B115200;
    break;
  case 230400:
    baudr = B230400;
    break;
  case 460800:
    baudr = B460800;
    break;
  case 500000:
    baudr = B500000;
    break;
  case 576000:
    baudr = B576000;
    break;
  case 921600:
    baudr = B921600;
    break;
  case 1000000:
    baudr = B1000000;
    break;
  default:
    baudr = B115200;
    break;
  }
  port_id = open(port, O_RDWR | O_NOCTTY);
  if (port_id < 0)
    return (-1);
  fcntl(port_id, F_SETFL, 0);
  memset(&options, 0, sizeof(options));
  options.c_cflag = baudr | CS8 | CLOCAL | CREAD;
  options.c_iflag = IGNPAR;
  options.c_oflag = 0;
  options.c_lflag = 0;
  options.c_cc[VMIN] = rec_chars;
  options.c_cc[VTIME] = block_time;
  if (tcsetattr(port_id, TCSANOW, &options) == -1) {
    close(port_id);
    return (-1);
  }
  return port_id;
}


x86 assembly (clang, -O0):
<Serial_Openport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x32,%eax
je     1317 <Serial_Openport+0x1c7>
jmp    1179 <Serial_Openport+0x29>
mov    -0x54(%rbp),%eax
sub    $0x4b,%eax
je     1328 <Serial_Openport+0x1d8>
jmp    118a <Serial_Openport+0x3a>
mov    -0x54(%rbp),%eax
sub    $0x6e,%eax
je     1339 <Serial_Openport+0x1e9>
jmp    119b <Serial_Openport+0x4b>
mov    -0x54(%rbp),%eax
sub    $0x86,%eax
je     134a <Serial_Openport+0x1fa>
jmp    11ae <Serial_Openport+0x5e>
mov    -0x54(%rbp),%eax
sub    $0x96,%eax
je     135b <Serial_Openport+0x20b>
jmp    11c1 <Serial_Openport+0x71>
mov    -0x54(%rbp),%eax
sub    $0xc8,%eax
je     136c <Serial_Openport+0x21c>
jmp    11d4 <Serial_Openport+0x84>
mov    -0x54(%rbp),%eax
sub    $0x12c,%eax
je     137d <Serial_Openport+0x22d>
jmp    11e7 <Serial_Openport+0x97>
mov    -0x54(%rbp),%eax
sub    $0x258,%eax
je     138e <Serial_Openport+0x23e>
jmp    11fa <Serial_Openport+0xaa>
mov    -0x54(%rbp),%eax
sub    $0x4b0,%eax
je     139f <Serial_Openport+0x24f>
jmp    120d <Serial_Openport+0xbd>
mov    -0x54(%rbp),%eax
sub    $0x708,%eax
je     13b0 <Serial_Openport+0x260>
jmp    1220 <Serial_Openport+0xd0>
mov    -0x54(%rbp),%eax
sub    $0x960,%eax
je     13c1 <Serial_Openport+0x271>
jmp    1233 <Serial_Openport+0xe3>
mov    -0x54(%rbp),%eax
sub    $0x12c0,%eax
je     13d2 <Serial_Openport+0x282>
jmp    1246 <Serial_Openport+0xf6>
mov    -0x54(%rbp),%eax
sub    $0x2580,%eax
je     13e3 <Serial_Openport+0x293>
jmp    1259 <Serial_Openport+0x109>
mov    -0x54(%rbp),%eax
sub    $0x4b00,%eax
je     13f4 <Serial_Openport+0x2a4>
jmp    126c <Serial_Openport+0x11c>
mov    -0x54(%rbp),%eax
sub    $0x9600,%eax
je     1405 <Serial_Openport+0x2b5>
jmp    127f <Serial_Openport+0x12f>
mov    -0x54(%rbp),%eax
sub    $0xe100,%eax
je     1416 <Serial_Openport+0x2c6>
jmp    1292 <Serial_Openport+0x142>
mov    -0x54(%rbp),%eax
sub    $0x1c200,%eax
je     1427 <Serial_Openport+0x2d7>
jmp    12a5 <Serial_Openport+0x155>
mov    -0x54(%rbp),%eax
sub    $0x38400,%eax
je     1438 <Serial_Openport+0x2e8>
jmp    12b8 <Serial_Openport+0x168>
mov    -0x54(%rbp),%eax
sub    $0x70800,%eax
je     1449 <Serial_Openport+0x2f9>
jmp    12cb <Serial_Openport+0x17b>
mov    -0x54(%rbp),%eax
sub    $0x7a120,%eax
je     145a <Serial_Openport+0x30a>
jmp    12de <Serial_Openport+0x18e>
mov    -0x54(%rbp),%eax
sub    $0x8ca00,%eax
je     146b <Serial_Openport+0x31b>
jmp    12f1 <Serial_Openport+0x1a1>
mov    -0x54(%rbp),%eax
sub    $0xe1000,%eax
je     147c <Serial_Openport+0x32c>
jmp    1304 <Serial_Openport+0x1b4>
mov    -0x54(%rbp),%eax
sub    $0xf4240,%eax
je     148d <Serial_Openport+0x33d>
jmp    149e <Serial_Openport+0x34e>
mov    0x2c6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2ca1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2c98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2c5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2bc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2bfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2c2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2bae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2acc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2ae2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2aa9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2ad0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2a9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2b35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2acc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
jmp    14aa <Serial_Openport+0x35a>
mov    0x2a6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2b2b(%rip),%rax
mov    (%rax),%esi
mov    0x2a82(%rip),%rax
or     (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    14de <Serial_Openport+0x38e>
movl   $0xffffffff,-0x4(%rbp)
jmp    159e <Serial_Openport+0x44e>
mov    -0x50(%rbp),%edi
mov    0x2a48(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    -0x4c(%rbp),%eax
mov    0x2a6d(%rip),%rcx
or     (%rcx),%eax
mov    0x29cc(%rip),%rcx
or     (%rcx),%eax
mov    0x2a63(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x48(%rbp)
mov    0x29cf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x40(%rbp),%rax
mov    0x2a1c(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x40(%rbp),%rax
mov    0x29a8(%rip),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x50(%rbp),%edi
mov    0x2a58(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1060 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    1598 <Serial_Openport+0x448>
mov    -0x50(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    159e <Serial_Openport+0x44e>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Serial_Openport>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
cmp    $0x12bf,%esi
jle    11b4 <Serial_Openport+0x64>
cmp    $0x383ff,%esi
jg     11f8 <Serial_Openport+0xa8>
cmp    $0x95ff,%esi
jg     1262 <Serial_Openport+0x112>
cmp    $0x12c0,%esi
je     12fe <Serial_Openport+0x1ae>
cmp    $0x2580,%esi
je     1307 <Serial_Openport+0x1b7>
cmp    $0x4b00,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2e41(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0xc7,%esi
jle    1230 <Serial_Openport+0xe0>
cmp    $0x4af,%esi
jg     128c <Serial_Openport+0x13c>
cmp    $0xc8,%esi
je     1310 <Serial_Openport+0x1c0>
cmp    $0x12c,%esi
je     1319 <Serial_Openport+0x1c9>
cmp    $0x258,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2dcd(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x8c9ff,%esi
jg     12b8 <Serial_Openport+0x168>
cmp    $0x38400,%esi
je     1322 <Serial_Openport+0x1d2>
cmp    $0x70800,%esi
je     132b <Serial_Openport+0x1db>
cmp    $0x7a120,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2cd5(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x6d,%esi
jle    12e4 <Serial_Openport+0x194>
cmp    $0x6e,%esi
je     1334 <Serial_Openport+0x1e4>
cmp    $0x86,%esi
je     133d <Serial_Openport+0x1ed>
cmp    $0x96,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2ccb(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x9600,%esi
je     1346 <Serial_Openport+0x1f6>
cmp    $0xe100,%esi
je     134f <Serial_Openport+0x1ff>
cmp    $0x1c200,%esi
mov    0x2c89(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x4b0,%esi
je     1358 <Serial_Openport+0x208>
cmp    $0x708,%esi
je     1361 <Serial_Openport+0x211>
cmp    $0x960,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2c85(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x8ca00,%esi
je     136a <Serial_Openport+0x21a>
cmp    $0xe1000,%esi
je     1373 <Serial_Openport+0x223>
cmp    $0xf4240,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2c81(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
cmp    $0x32,%esi
je     137c <Serial_Openport+0x22c>
cmp    $0x4b,%esi
jne    1280 <Serial_Openport+0x130>
mov    0x2cd7(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c9b(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c8a(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c59(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c70(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2bbf(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2bee(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c9d(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c6c(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2b8b(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c02(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2bb9(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2be0(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c37(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c3e(%rip),%rax
jmp    1383 <Serial_Openport+0x233>
mov    0x2c05(%rip),%rax
mov    (%rax),%ebp
mov    0x2c54(%rip),%rax
mov    0x2bad(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   1070 <open@plt>
mov    $0xffffffff,%r13d
test   %eax,%eax
js     1448 <Serial_Openport+0x2f8>
mov    %eax,%ebx
mov    0x2b7d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
mov    0x2ba1(%rip),%rax
or     (%rax),%ebp
mov    0x2b00(%rip),%rax
or     (%rax),%ebp
mov    0x2b97(%rip),%rax
or     (%rax),%ebp
mov    %ebp,(%rsp)
mov    0x2b03(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rax
mov    0x2b59(%rip),%rcx
mov    (%rcx),%rcx
mov    %r15d,(%rax,%rcx,4)
mov    0x2aeb(%rip),%rcx
mov    (%rcx),%rcx
mov    %r14d,(%rax,%rcx,4)
mov    0x2b9d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r12,%rdx
call   1060 <tcsetattr@plt>
cmp    $0xffffffff,%eax
je     1441 <Serial_Openport+0x2f1>
mov    %ebx,%r13d
jmp    1448 <Serial_Openport+0x2f8>
mov    %ebx,%edi
call   1050 <close@plt>
mov    %r13d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32*, i64, i64, i32 }
@B50 = global i32 0
@B75 = global i32 0
@B110 = global i32 0
@B134 = global i32 0
@B150 = global i32 0
@B200 = global i32 0
@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
@B115200 = global i32 0
@B230400 = global i32 0
@B460800 = global i32 0
@B500000 = global i32 0
@B576000 = global i32 0
@B921600 = global i32 0
@B1000000 = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@F_SETFL = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@IGNPAR = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define i32 @Serial_Openport(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.termios
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %7
switch i32 %13, label %60 [
i32 50, label %14
i32 75, label %16
i32 110, label %18
i32 134, label %20
i32 150, label %22
i32 200, label %24
i32 300, label %26
i32 600, label %28
i32 1200, label %30
i32 1800, label %32
i32 2400, label %34
i32 4800, label %36
i32 9600, label %38
i32 19200, label %40
i32 38400, label %42
i32 57600, label %44
i32 115200, label %46
i32 230400, label %48
i32 460800, label %50
i32 500000, label %52
i32 576000, label %54
i32 921600, label %56
i32 1000000, label %58
]
14: ; preds = %4
%15 = load i32, i32* @B50
store i32 %15, i32* %11
br label %62
16: ; preds = %4
%17 = load i32, i32* @B75
store i32 %17, i32* %11
br label %62
18: ; preds = %4
%19 = load i32, i32* @B110
store i32 %19, i32* %11
br label %62
20: ; preds = %4
%21 = load i32, i32* @B134
store i32 %21, i32* %11
br label %62
22: ; preds = %4
%23 = load i32, i32* @B150
store i32 %23, i32* %11
br label %62
24: ; preds = %4
%25 = load i32, i32* @B200
store i32 %25, i32* %11
br label %62
26: ; preds = %4
%27 = load i32, i32* @B300
store i32 %27, i32* %11
br label %62
28: ; preds = %4
%29 = load i32, i32* @B600
store i32 %29, i32* %11
br label %62
30: ; preds = %4
%31 = load i32, i32* @B1200
store i32 %31, i32* %11
br label %62
32: ; preds = %4
%33 = load i32, i32* @B1800
store i32 %33, i32* %11
br label %62
34: ; preds = %4
%35 = load i32, i32* @B2400
store i32 %35, i32* %11
br label %62
36: ; preds = %4
%37 = load i32, i32* @B4800
store i32 %37, i32* %11
br label %62
38: ; preds = %4
%39 = load i32, i32* @B9600
store i32 %39, i32* %11
br label %62
40: ; preds = %4
%41 = load i32, i32* @B19200
store i32 %41, i32* %11
br label %62
42: ; preds = %4
%43 = load i32, i32* @B38400
store i32 %43, i32* %11
br label %62
44: ; preds = %4
%45 = load i32, i32* @B57600
store i32 %45, i32* %11
br label %62
46: ; preds = %4
%47 = load i32, i32* @B115200
store i32 %47, i32* %11
br label %62
48: ; preds = %4
%49 = load i32, i32* @B230400
store i32 %49, i32* %11
br label %62
50: ; preds = %4
%51 = load i32, i32* @B460800
store i32 %51, i32* %11
br label %62
52: ; preds = %4
%53 = load i32, i32* @B500000
store i32 %53, i32* %11
br label %62
54: ; preds = %4
%55 = load i32, i32* @B576000
store i32 %55, i32* %11
br label %62
56: ; preds = %4
%57 = load i32, i32* @B921600
store i32 %57, i32* %11
br label %62
58: ; preds = %4
%59 = load i32, i32* @B1000000
store i32 %59, i32* %11
br label %62
60: ; preds = %4
%61 = load i32, i32* @B115200
store i32 %61, i32* %11
br label %62
62: ; preds = %60, %58, %56, %54, %52, %50, %48, %46, %44, %42, %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14
%63 = load i8*, i8** %6
%64 = load i32, i32* @O_RDWR
%65 = load i32, i32* @O_NOCTTY
%66 = or i32 %64, %65
%67 = call i32 @open(i8* %63, i32 %66)
store i32 %67, i32* %12
%68 = load i32, i32* %12
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %62
store i32 -1, i32* %5
br label %107
71: ; preds = %62
%72 = load i32, i32* %12
%73 = load i32, i32* @F_SETFL
%74 = call i32 @fcntl(i32 %72, i32 %73, i32 0)
%75 = call i32 @memset(%struct.termios* %10, i32 0, i32 40)
%76 = load i32, i32* %11
%77 = load i32, i32* @CS8
%78 = or i32 %76, %77
%79 = load i32, i32* @CLOCAL
%80 = or i32 %78, %79
%81 = load i32, i32* @CREAD
%82 = or i32 %80, %81
%83 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 0
store i32 %82, i32* %83
%84 = load i32, i32* @IGNPAR
%85 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 4
store i32 %84, i32* %85
%86 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 3
store i64 0, i64* %86
%87 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 2
store i64 0, i64* %87
%88 = load i32, i32* %8
%89 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 1
%90 = load i32*, i32** %89
%91 = load i64, i64* @VMIN
%92 = getelementptr inbounds i32, i32* %90, i64 %91
store i32 %88, i32* %92
%93 = load i32, i32* %9
%94 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 1
%95 = load i32*, i32** %94
%96 = load i64, i64* @VTIME
%97 = getelementptr inbounds i32, i32* %95, i64 %96
store i32 %93, i32* %97
%98 = load i32, i32* %12
%99 = load i32, i32* @TCSANOW
%100 = call i32 @tcsetattr(i32 %98, i32 %99, %struct.termios* %10)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %71
%103 = load i32, i32* %12
%104 = call i32 @close(i32 %103)
store i32 -1, i32* %5
br label %107
105: ; preds = %71
%106 = load i32, i32* %12
store i32 %106, i32* %5
br label %107
107: ; preds = %105, %102, %70
%108 = load i32, i32* %5
ret i32 %108
}

LLVM IR (-O2):
%struct.termios = type { i32, i32*, i64, i64, i32 }
@B50 = global i32 0
@B75 = global i32 0
@B110 = global i32 0
@B134 = global i32 0
@B150 = global i32 0
@B200 = global i32 0
@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
@B115200 = global i32 0
@B230400 = global i32 0
@B460800 = global i32 0
@B500000 = global i32 0
@B576000 = global i32 0
@B921600 = global i32 0
@B1000000 = global i32 0
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@F_SETFL = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@IGNPAR = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define i32 @Serial_Openport(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.termios
%6 = bitcast %struct.termios* %5 to i8*
switch i32 %1, label %29 [
i32 50, label %30
i32 75, label %7
i32 110, label %8
i32 134, label %9
i32 150, label %10
i32 200, label %11
i32 300, label %12
i32 600, label %13
i32 1200, label %14
i32 1800, label %15
i32 2400, label %16
i32 4800, label %17
i32 9600, label %18
i32 19200, label %19
i32 38400, label %20
i32 57600, label %21
i32 115200, label %22
i32 230400, label %23
i32 460800, label %24
i32 500000, label %25
i32 576000, label %26
i32 921600, label %27
i32 1000000, label %28
]
7: ; preds = %4
br label %30
8: ; preds = %4
br label %30
9: ; preds = %4
br label %30
10: ; preds = %4
br label %30
11: ; preds = %4
br label %30
12: ; preds = %4
br label %30
13: ; preds = %4
br label %30
14: ; preds = %4
br label %30
15: ; preds = %4
br label %30
16: ; preds = %4
br label %30
17: ; preds = %4
br label %30
18: ; preds = %4
br label %30
19: ; preds = %4
br label %30
20: ; preds = %4
br label %30
21: ; preds = %4
br label %30
22: ; preds = %4
br label %30
23: ; preds = %4
br label %30
24: ; preds = %4
br label %30
25: ; preds = %4
br label %30
26: ; preds = %4
br label %30
27: ; preds = %4
br label %30
28: ; preds = %4
br label %30
29: ; preds = %4
br label %30
30: ; preds = %4, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7
%31 = phi i32* [ @B115200, %29 ], [ @B1000000, %28 ], [ @B921600, %27 ], [ @B576000, %26 ], [ @B500000, %25 ], [ @B460800, %24 ], [ @B230400, %23 ], [ @B115200, %22 ], [ @B57600, %21 ], [ @B38400, %20 ], [ @B19200, %19 ], [ @B9600, %18 ], [ @B4800, %17 ], [ @B2400, %16 ], [ @B1800, %15 ], [ @B1200, %14 ], [ @B600, %13 ], [ @B300, %12 ], [ @B200, %11 ], [ @B150, %10 ], [ @B134, %9 ], [ @B110, %8 ], [ @B75, %7 ], [ @B50, %4 ]
%32 = load i32, i32* %31
%33 = load i32, i32* @O_RDWR
%34 = load i32, i32* @O_NOCTTY
%35 = or i32 %34, %33
%36 = tail call i32 @open(i8* %0, i32 %35)
%37 = icmp slt i32 %36, 0
br i1 %37, label %64, label %38
38: ; preds = %30
%39 = load i32, i32* @F_SETFL
%40 = tail call i32 @fcntl(i32 %36, i32 %39, i32 0)
%41 = call i32 @memset(%struct.termios* %5, i32 0, i32 40)
%42 = load i32, i32* @CS8
%43 = or i32 %42, %32
%44 = load i32, i32* @CLOCAL
%45 = or i32 %43, %44
%46 = load i32, i32* @CREAD
%47 = or i32 %45, %46
%48 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
store i32 %47, i32* %48
%49 = load i32, i32* @IGNPAR
%50 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 4
store i32 %49, i32* %50
%51 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 2
%52 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 1
%53 = bitcast i64* %51 to i8*
%54 = load i32*, i32** %52
%55 = load i64, i64* @VMIN
%56 = getelementptr inbounds i32, i32* %54, i64 %55
store i32 %2, i32* %56
%57 = load i64, i64* @VTIME
%58 = getelementptr inbounds i32, i32* %54, i64 %57
store i32 %3, i32* %58
%59 = load i32, i32* @TCSANOW
%60 = call i32 @tcsetattr(i32 %36, i32 %59, %struct.termios* %5)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %38
%63 = call i32 @close(i32 %36)
br label %64
64: ; preds = %38, %30, %62
%65 = phi i32 [ -1, %62 ], [ -1, %30 ], [ %36, %38 ]
ret i32 %65
}