#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_lflag;
  int *c_cc;
  int /*<<< orphan*/ c_oflag;
};
typedef int /*<<< orphan*/ speed_t;

/* Variables and functions */
int /*<<< orphan*/ B110;
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ B1200;
int /*<<< orphan*/ B134;
int /*<<< orphan*/ B150;
int /*<<< orphan*/ B1800;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B200;
int /*<<< orphan*/ B230400;
int /*<<< orphan*/ B2400;
int /*<<< orphan*/ B300;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B50;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B600;
int /*<<< orphan*/ B75;
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int /*<<< orphan*/ F_SETFL;
int ICANON;
int ISIG;
int /*<<< orphan*/ OPOST;
int O_NDELAY;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int PARENB;
int TCSAFLUSH;
int TCSANOW;
int /*<<< orphan*/ TIOCMGET;
int /*<<< orphan*/ TIOCMSET;
int TIOCM_DTR;
int TIOCM_RTS;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int open(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int, struct termios *);
int /*<<< orphan*/ usleep(int);
int SerialOpen(int baud) {
  struct termios options;
  speed_t myBaud;
  int status, fd;
  switch (baud) {
  case 50:
    myBaud = B50;
    break;
  case 75:
    myBaud = B75;
    break;
  case 110:
    myBaud = B110;
    break;
  case 134:
    myBaud = B134;
    break;
  case 150:
    myBaud = B150;
    break;
  case 200:
    myBaud = B200;
    break;
  case 300:
    myBaud = B300;
    break;
  case 600:
    myBaud = B600;
    break;
  case 1200:
    myBaud = B1200;
    break;
  case 1800:
    myBaud = B1800;
    break;
  case 2400:
    myBaud = B2400;
    break;
  case 9600:
    myBaud = B9600;
    break;
  case 19200:
    myBaud = B19200;
    break;
  case 38400:
    myBaud = B38400;
    break;
  case 57600:
    myBaud = B57600;
    break;
  case 115200:
    myBaud = B115200;
    break;
  case 230400:
    myBaud = B230400;
    break;
  default:
    return -2;
  }
  if ((fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) ==
      -1) {
    fprintf(stderr, "Cannot open port serial port.\n");
  }
  fcntl(fd, F_SETFL, O_RDWR);
  tcgetattr(fd, &options);
  cfmakeraw(&options);
  cfsetispeed(&options, myBaud);
  cfsetospeed(&options, myBaud);
  options.c_cflag |= (CLOCAL | CREAD);
  options.c_cflag &= ~PARENB;
  options.c_cflag &= ~CSTOPB;
  options.c_cflag &= ~CSIZE;
  options.c_cflag |= CS8;
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  options.c_oflag &= ~OPOST;
  options.c_cc[VMIN] = 0;
  options.c_cc[VTIME] = 100;
  tcsetattr(fd, TCSANOW | TCSAFLUSH, &options);
  ioctl(fd, TIOCMGET, &status);
  status |= TIOCM_DTR;
  status |= TIOCM_RTS;
  ioctl(fd, TIOCMSET, &status);
  usleep(10000);
  return fd;
}


x86 assembly (clang, -O0):
<SerialOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x32,%eax
je     22eb <SerialOpen+0x14b>
jmp    21bf <SerialOpen+0x1f>
mov    -0x30(%rbp),%eax
sub    $0x4b,%eax
je     22fc <SerialOpen+0x15c>
jmp    21d0 <SerialOpen+0x30>
mov    -0x30(%rbp),%eax
sub    $0x6e,%eax
je     230d <SerialOpen+0x16d>
jmp    21e1 <SerialOpen+0x41>
mov    -0x30(%rbp),%eax
sub    $0x86,%eax
je     231e <SerialOpen+0x17e>
jmp    21f4 <SerialOpen+0x54>
mov    -0x30(%rbp),%eax
sub    $0x96,%eax
je     232f <SerialOpen+0x18f>
jmp    2207 <SerialOpen+0x67>
mov    -0x30(%rbp),%eax
sub    $0xc8,%eax
je     2340 <SerialOpen+0x1a0>
jmp    221a <SerialOpen+0x7a>
mov    -0x30(%rbp),%eax
sub    $0x12c,%eax
je     2351 <SerialOpen+0x1b1>
jmp    222d <SerialOpen+0x8d>
mov    -0x30(%rbp),%eax
sub    $0x258,%eax
je     2362 <SerialOpen+0x1c2>
jmp    2240 <SerialOpen+0xa0>
mov    -0x30(%rbp),%eax
sub    $0x4b0,%eax
je     2373 <SerialOpen+0x1d3>
jmp    2253 <SerialOpen+0xb3>
mov    -0x30(%rbp),%eax
sub    $0x708,%eax
je     2384 <SerialOpen+0x1e4>
jmp    2266 <SerialOpen+0xc6>
mov    -0x30(%rbp),%eax
sub    $0x960,%eax
je     2395 <SerialOpen+0x1f5>
jmp    2279 <SerialOpen+0xd9>
mov    -0x30(%rbp),%eax
sub    $0x2580,%eax
je     23a6 <SerialOpen+0x206>
jmp    228c <SerialOpen+0xec>
mov    -0x30(%rbp),%eax
sub    $0x4b00,%eax
je     23b7 <SerialOpen+0x217>
jmp    229f <SerialOpen+0xff>
mov    -0x30(%rbp),%eax
sub    $0x9600,%eax
je     23c8 <SerialOpen+0x228>
jmp    22b2 <SerialOpen+0x112>
mov    -0x30(%rbp),%eax
sub    $0xe100,%eax
je     23d9 <SerialOpen+0x239>
jmp    22c5 <SerialOpen+0x125>
mov    -0x30(%rbp),%eax
sub    $0x1c200,%eax
je     23ea <SerialOpen+0x24a>
jmp    22d8 <SerialOpen+0x138>
mov    -0x30(%rbp),%eax
sub    $0x38400,%eax
je     23fb <SerialOpen+0x25b>
jmp    240c <SerialOpen+0x26c>
mov    0x2c5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2cc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2c4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2baa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2bf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2c27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2b56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2b7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2b54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2bb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2c32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2ac1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2b40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2ad7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
mov    0x2aa6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    2418 <SerialOpen+0x278>
movl   $0xfffffffe,-0x4(%rbp)
jmp    25ec <SerialOpen+0x44c>
mov    0x2bc1(%rip),%rax
mov    (%rax),%esi
mov    0x2ad8(%rip),%rax
or     (%rax),%esi
mov    0x2aa7(%rip),%rax
or     (%rax),%esi
mov    0x2b8e(%rip),%rax
or     (%rax),%esi
lea    0xbbd(%rip),%rdi
call   20a0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    2469 <SerialOpen+0x2c9>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
lea    0xba9(%rip),%rsi
call   2060 <fprintf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2a75(%rip),%rax
mov    (%rax),%esi
mov    0x2b64(%rip),%rax
mov    (%rax),%edx
call   2030 <fcntl@plt>
mov    -0x2c(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   2080 <tcgetattr@plt>
lea    -0x20(%rbp),%rdi
call   2070 <cfmakeraw@plt>
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   20b0 <cfsetispeed@plt>
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   2040 <cfsetospeed@plt>
mov    0x29e1(%rip),%rax
mov    (%rax),%eax
mov    0x2a88(%rip),%rcx
or     (%rcx),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2ad9(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x29bf(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2a35(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2a3b(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x29a4(%rip),%rax
mov    (%rax),%eax
mov    0x2a6b(%rip),%rcx
or     (%rcx),%eax
mov    0x2a5a(%rip),%rcx
or     (%rcx),%eax
mov    0x2a49(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2a6f(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x29d9(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2954(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x64,(%rax,%rcx,4)
mov    -0x2c(%rbp),%edi
mov    0x2a20(%rip),%rax
mov    (%rax),%esi
mov    0x2a47(%rip),%rax
or     (%rax),%esi
lea    -0x20(%rbp),%rdx
call   2090 <tcsetattr@plt>
mov    -0x2c(%rbp),%edi
mov    0x297a(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   2050 <ioctl@plt>
mov    0x29b8(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x29d9(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    0x29e7(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   2050 <ioctl@plt>
mov    $0x2710,%edi
call   20c0 <usleep@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SerialOpen>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0xfffffffe,%ebx
cmp    $0x4af,%edi
jle    21f9 <SerialOpen+0x59>
cmp    $0x4aff,%edi
jle    2228 <SerialOpen+0x88>
cmp    $0xe0ff,%edi
jle    2288 <SerialOpen+0xe8>
cmp    $0xe100,%edi
je     2307 <SerialOpen+0x167>
cmp    $0x1c200,%edi
je     2310 <SerialOpen+0x170>
cmp    $0x38400,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2cb4(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x95,%edi
jg     2258 <SerialOpen+0xb8>
cmp    $0x6d,%edi
jg     22ac <SerialOpen+0x10c>
cmp    $0x32,%edi
je     2319 <SerialOpen+0x179>
cmp    $0x4b,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2d9d(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x95f,%edi
jg     22cd <SerialOpen+0x12d>
cmp    $0x4b0,%edi
je     2322 <SerialOpen+0x182>
cmp    $0x708,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2cb5(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x12b,%edi
jg     22ea <SerialOpen+0x14a>
cmp    $0x96,%edi
je     232b <SerialOpen+0x18b>
cmp    $0xc8,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2cb5(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x4b00,%edi
je     2334 <SerialOpen+0x194>
cmp    $0x9600,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2be9(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x6e,%edi
je     233d <SerialOpen+0x19d>
cmp    $0x86,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2ca8(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x960,%edi
je     2346 <SerialOpen+0x1a6>
cmp    $0x2580,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2c78(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
cmp    $0x12c,%edi
je     234f <SerialOpen+0x1af>
cmp    $0x258,%edi
jne    24f0 <SerialOpen+0x350>
mov    0x2c8b(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2c12(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2bb1(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2c30(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2ba7(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2bae(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2cb5(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2c94(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2ba3(%rip),%rax
jmp    2356 <SerialOpen+0x1b6>
mov    0x2c02(%rip),%rax
mov    0x2c83(%rip),%r14
mov    0x2b9c(%rip),%rcx
mov    (%rcx),%esi
or     (%r14),%esi
mov    0x2b68(%rip),%rcx
or     (%rcx),%esi
mov    (%rax),%ebp
mov    0x2c4d(%rip),%rax
or     (%rax),%esi
lea    0xc7c(%rip),%rdi
call   20a0 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    23a5 <SerialOpen+0x205>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
lea    0xc6d(%rip),%rsi
call   2060 <fprintf@plt>
mov    0x2b3c(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    %ebx,%edi
call   2030 <fcntl@plt>
lea    0x8(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   2080 <tcgetattr@plt>
mov    %r14,%rdi
call   2070 <cfmakeraw@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   20b0 <cfsetispeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   2040 <cfsetospeed@plt>
mov    0x2aae(%rip),%rax
mov    0x2b57(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     0x8(%rsp),%ecx
mov    0x2ba8(%rip),%rax
mov    (%rax),%eax
mov    0x2a97(%rip),%rdx
or     (%rdx),%eax
mov    0x2b16(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %ecx,%eax
mov    0x2b21(%rip),%rcx
or     (%rcx),%eax
mov    0x2a90(%rip),%rcx
mov    0x2b59(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2b46(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x8(%rsp)
mov    0x2b31(%rip),%rax
or     (%rax),%edx
not    %edx
and    %edx,0xc(%rsp)
mov    0x2b5a(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2ac6(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2a45(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x64,(%rax,%rcx,4)
mov    0x2b14(%rip),%rax
mov    0x2b3d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   2090 <tcsetattr@plt>
mov    0x2a70(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rdx
call   2050 <ioctl@plt>
mov    0x2aa8(%rip),%rax
mov    0x4(%rsp),%ecx
or     (%rax),%ecx
mov    0x2acb(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x4(%rsp)
mov    0x2ade(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
call   2050 <ioctl@plt>
mov    $0x2710,%edi
call   20c0 <usleep@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32*, 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
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@.str = [13 x i8] c"/dev/ttyAMA0\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@O_NONBLOCK = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Cannot open port serial port.\0A\00"
@F_SETFL = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@TCSAFLUSH = global i32 0
@TIOCMGET = global i32 0
@TIOCM_DTR = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
define i32 @SerialOpen(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.termios
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = load i32, i32* %3
switch i32 %8, label %43 [
i32 50, label %9
i32 75, label %11
i32 110, label %13
i32 134, label %15
i32 150, label %17
i32 200, label %19
i32 300, label %21
i32 600, label %23
i32 1200, label %25
i32 1800, label %27
i32 2400, label %29
i32 9600, label %31
i32 19200, label %33
i32 38400, label %35
i32 57600, label %37
i32 115200, label %39
i32 230400, label %41
]
9: ; preds = %1
%10 = load i32, i32* @B50
store i32 %10, i32* %5
br label %44
11: ; preds = %1
%12 = load i32, i32* @B75
store i32 %12, i32* %5
br label %44
13: ; preds = %1
%14 = load i32, i32* @B110
store i32 %14, i32* %5
br label %44
15: ; preds = %1
%16 = load i32, i32* @B134
store i32 %16, i32* %5
br label %44
17: ; preds = %1
%18 = load i32, i32* @B150
store i32 %18, i32* %5
br label %44
19: ; preds = %1
%20 = load i32, i32* @B200
store i32 %20, i32* %5
br label %44
21: ; preds = %1
%22 = load i32, i32* @B300
store i32 %22, i32* %5
br label %44
23: ; preds = %1
%24 = load i32, i32* @B600
store i32 %24, i32* %5
br label %44
25: ; preds = %1
%26 = load i32, i32* @B1200
store i32 %26, i32* %5
br label %44
27: ; preds = %1
%28 = load i32, i32* @B1800
store i32 %28, i32* %5
br label %44
29: ; preds = %1
%30 = load i32, i32* @B2400
store i32 %30, i32* %5
br label %44
31: ; preds = %1
%32 = load i32, i32* @B9600
store i32 %32, i32* %5
br label %44
33: ; preds = %1
%34 = load i32, i32* @B19200
store i32 %34, i32* %5
br label %44
35: ; preds = %1
%36 = load i32, i32* @B38400
store i32 %36, i32* %5
br label %44
37: ; preds = %1
%38 = load i32, i32* @B57600
store i32 %38, i32* %5
br label %44
39: ; preds = %1
%40 = load i32, i32* @B115200
store i32 %40, i32* %5
br label %44
41: ; preds = %1
%42 = load i32, i32* @B230400
store i32 %42, i32* %5
br label %44
43: ; preds = %1
store i32 -2, i32* %2
br label %137
44: ; preds = %41, %39, %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9
%45 = load i32, i32* @O_RDWR
%46 = load i32, i32* @O_NOCTTY
%47 = or i32 %45, %46
%48 = load i32, i32* @O_NDELAY
%49 = or i32 %47, %48
%50 = load i32, i32* @O_NONBLOCK
%51 = or i32 %49, %50
%52 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %51)
store i32 %52, i32* %7
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %57
54: ; preds = %44
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %54, %44
%58 = load i32, i32* %7
%59 = load i32, i32* @F_SETFL
%60 = load i32, i32* @O_RDWR
%61 = call i32 @fcntl(i32 %58, i32 %59, i32 %60)
%62 = load i32, i32* %7
%63 = call i32 @tcgetattr(i32 %62, %struct.termios* %4)
%64 = call i32 @cfmakeraw(%struct.termios* %4)
%65 = load i32, i32* %5
%66 = call i32 @cfsetispeed(%struct.termios* %4, i32 %65)
%67 = load i32, i32* %5
%68 = call i32 @cfsetospeed(%struct.termios* %4, i32 %67)
%69 = load i32, i32* @CLOCAL
%70 = load i32, i32* @CREAD
%71 = or i32 %69, %70
%72 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%73 = load i32, i32* %72
%74 = or i32 %73, %71
store i32 %74, i32* %72
%75 = load i32, i32* @PARENB
%76 = xor i32 %75, -1
%77 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%78 = load i32, i32* %77
%79 = and i32 %78, %76
store i32 %79, i32* %77
%80 = load i32, i32* @CSTOPB
%81 = xor i32 %80, -1
%82 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%83 = load i32, i32* %82
%84 = and i32 %83, %81
store i32 %84, i32* %82
%85 = load i32, i32* @CSIZE
%86 = xor i32 %85, -1
%87 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%88 = load i32, i32* %87
%89 = and i32 %88, %86
store i32 %89, i32* %87
%90 = load i32, i32* @CS8
%91 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%92 = load i32, i32* %91
%93 = or i32 %92, %90
store i32 %93, i32* %91
%94 = load i32, i32* @ICANON
%95 = load i32, i32* @ECHO
%96 = or i32 %94, %95
%97 = load i32, i32* @ECHOE
%98 = or i32 %96, %97
%99 = load i32, i32* @ISIG
%100 = or i32 %98, %99
%101 = xor i32 %100, -1
%102 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 1
%103 = load i32, i32* %102
%104 = and i32 %103, %101
store i32 %104, i32* %102
%105 = load i32, i32* @OPOST
%106 = xor i32 %105, -1
%107 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 3
%108 = load i32, i32* %107
%109 = and i32 %108, %106
store i32 %109, i32* %107
%110 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 2
%111 = load i32*, i32** %110
%112 = load i64, i64* @VMIN
%113 = getelementptr inbounds i32, i32* %111, i64 %112
store i32 0, i32* %113
%114 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 2
%115 = load i32*, i32** %114
%116 = load i64, i64* @VTIME
%117 = getelementptr inbounds i32, i32* %115, i64 %116
store i32 100, i32* %117
%118 = load i32, i32* %7
%119 = load i32, i32* @TCSANOW
%120 = load i32, i32* @TCSAFLUSH
%121 = or i32 %119, %120
%122 = call i32 @tcsetattr(i32 %118, i32 %121, %struct.termios* %4)
%123 = load i32, i32* %7
%124 = load i32, i32* @TIOCMGET
%125 = call i32 @ioctl(i32 %123, i32 %124, i32* %6)
%126 = load i32, i32* @TIOCM_DTR
%127 = load i32, i32* %6
%128 = or i32 %127, %126
store i32 %128, i32* %6
%129 = load i32, i32* @TIOCM_RTS
%130 = load i32, i32* %6
%131 = or i32 %130, %129
store i32 %131, i32* %6
%132 = load i32, i32* %7
%133 = load i32, i32* @TIOCMSET
%134 = call i32 @ioctl(i32 %132, i32 %133, i32* %6)
%135 = call i32 @usleep(i32 10000)
%136 = load i32, i32* %7
store i32 %136, i32* %2
br label %137
137: ; preds = %57, %43
%138 = load i32, i32* %2
ret i32 %138
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32*, 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
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@.str = [13 x i8] c"/dev/ttyAMA0\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@O_NONBLOCK = global i32 0
@stderr = global i32 0
@.str.1 = [31 x i8] c"Cannot open port serial port.\0A\00"
@F_SETFL = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@TCSAFLUSH = global i32 0
@TIOCMGET = global i32 0
@TIOCM_DTR = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
define i32 @SerialOpen(i32 %0) {
%2 = alloca %struct.termios
%3 = alloca i32
%4 = bitcast %struct.termios* %2 to i8*
%5 = bitcast i32* %3 to i8*
switch i32 %0, label %96 [
i32 50, label %22
i32 75, label %6
i32 110, label %7
i32 134, label %8
i32 150, label %9
i32 200, label %10
i32 300, label %11
i32 600, label %12
i32 1200, label %13
i32 1800, label %14
i32 2400, label %15
i32 9600, label %16
i32 19200, label %17
i32 38400, label %18
i32 57600, label %19
i32 115200, label %20
i32 230400, label %21
]
6: ; preds = %1
br label %22
7: ; preds = %1
br label %22
8: ; preds = %1
br label %22
9: ; preds = %1
br label %22
10: ; preds = %1
br label %22
11: ; preds = %1
br label %22
12: ; preds = %1
br label %22
13: ; preds = %1
br label %22
14: ; preds = %1
br label %22
15: ; preds = %1
br label %22
16: ; preds = %1
br label %22
17: ; preds = %1
br label %22
18: ; preds = %1
br label %22
19: ; preds = %1
br label %22
20: ; preds = %1
br label %22
21: ; preds = %1
br label %22
22: ; preds = %1, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%23 = phi i32* [ @B230400, %21 ], [ @B115200, %20 ], [ @B57600, %19 ], [ @B38400, %18 ], [ @B19200, %17 ], [ @B9600, %16 ], [ @B2400, %15 ], [ @B1800, %14 ], [ @B1200, %13 ], [ @B600, %12 ], [ @B300, %11 ], [ @B200, %10 ], [ @B150, %9 ], [ @B134, %8 ], [ @B110, %7 ], [ @B75, %6 ], [ @B50, %1 ]
%24 = load i32, i32* %23
%25 = load i32, i32* @O_RDWR
%26 = load i32, i32* @O_NOCTTY
%27 = or i32 %26, %25
%28 = load i32, i32* @O_NDELAY
%29 = or i32 %27, %28
%30 = load i32, i32* @O_NONBLOCK
%31 = or i32 %29, %30
%32 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %22
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %34, %22
%38 = load i32, i32* @F_SETFL
%39 = load i32, i32* @O_RDWR
%40 = tail call i32 @fcntl(i32 %32, i32 %38, i32 %39)
%41 = call i32 @tcgetattr(i32 %32, %struct.termios* %2)
%42 = call i32 @cfmakeraw(%struct.termios* %2)
%43 = call i32 @cfsetispeed(%struct.termios* %2, i32 %24)
%44 = call i32 @cfsetospeed(%struct.termios* %2, i32 %24)
%45 = load i32, i32* @CLOCAL
%46 = load i32, i32* @CREAD
%47 = or i32 %46, %45
%48 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%49 = load i32, i32* %48
%50 = or i32 %47, %49
%51 = load i32, i32* @PARENB
%52 = load i32, i32* @CSTOPB
%53 = or i32 %51, %52
%54 = load i32, i32* @CSIZE
%55 = or i32 %53, %54
%56 = xor i32 %55, -1
%57 = and i32 %50, %56
%58 = load i32, i32* @CS8
%59 = or i32 %58, %57
store i32 %59, i32* %48
%60 = load i32, i32* @ICANON
%61 = load i32, i32* @ECHO
%62 = or i32 %61, %60
%63 = load i32, i32* @ECHOE
%64 = or i32 %62, %63
%65 = load i32, i32* @ISIG
%66 = or i32 %64, %65
%67 = xor i32 %66, -1
%68 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%69 = load i32, i32* %68
%70 = and i32 %69, %67
store i32 %70, i32* %68
%71 = load i32, i32* @OPOST
%72 = xor i32 %71, -1
%73 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 3
%74 = load i32, i32* %73
%75 = and i32 %74, %72
store i32 %75, i32* %73
%76 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 2
%77 = load i32*, i32** %76
%78 = load i64, i64* @VMIN
%79 = getelementptr inbounds i32, i32* %77, i64 %78
store i32 0, i32* %79
%80 = load i64, i64* @VTIME
%81 = getelementptr inbounds i32, i32* %77, i64 %80
store i32 100, i32* %81
%82 = load i32, i32* @TCSANOW
%83 = load i32, i32* @TCSAFLUSH
%84 = or i32 %83, %82
%85 = call i32 @tcsetattr(i32 %32, i32 %84, %struct.termios* %2)
%86 = load i32, i32* @TIOCMGET
%87 = call i32 @ioctl(i32 %32, i32 %86, i32* %3)
%88 = load i32, i32* @TIOCM_DTR
%89 = load i32, i32* %3
%90 = or i32 %89, %88
%91 = load i32, i32* @TIOCM_RTS
%92 = or i32 %91, %90
store i32 %92, i32* %3
%93 = load i32, i32* @TIOCMSET
%94 = call i32 @ioctl(i32 %32, i32 %93, i32* %3)
%95 = call i32 @usleep(i32 10000)
br label %96
96: ; preds = %1, %37
%97 = phi i32 [ %32, %37 ], [ -2, %1 ]
ret i32 %97
}