#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*/ ioctl(int, int /*<<< orphan*/, int *);
int open(char *, int);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int, struct termios *);
int /*<<< orphan*/ usleep(int);
int genieOpen(char *device, 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(device, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) == -1)
    return -1;
  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):
<genieOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x32,%eax
je     22df <genieOpen+0x14f>
jmp    21b3 <genieOpen+0x23>
mov    -0x40(%rbp),%eax
sub    $0x4b,%eax
je     22f0 <genieOpen+0x160>
jmp    21c4 <genieOpen+0x34>
mov    -0x40(%rbp),%eax
sub    $0x6e,%eax
je     2301 <genieOpen+0x171>
jmp    21d5 <genieOpen+0x45>
mov    -0x40(%rbp),%eax
sub    $0x86,%eax
je     2312 <genieOpen+0x182>
jmp    21e8 <genieOpen+0x58>
mov    -0x40(%rbp),%eax
sub    $0x96,%eax
je     2323 <genieOpen+0x193>
jmp    21fb <genieOpen+0x6b>
mov    -0x40(%rbp),%eax
sub    $0xc8,%eax
je     2334 <genieOpen+0x1a4>
jmp    220e <genieOpen+0x7e>
mov    -0x40(%rbp),%eax
sub    $0x12c,%eax
je     2345 <genieOpen+0x1b5>
jmp    2221 <genieOpen+0x91>
mov    -0x40(%rbp),%eax
sub    $0x258,%eax
je     2356 <genieOpen+0x1c6>
jmp    2234 <genieOpen+0xa4>
mov    -0x40(%rbp),%eax
sub    $0x4b0,%eax
je     2367 <genieOpen+0x1d7>
jmp    2247 <genieOpen+0xb7>
mov    -0x40(%rbp),%eax
sub    $0x708,%eax
je     2378 <genieOpen+0x1e8>
jmp    225a <genieOpen+0xca>
mov    -0x40(%rbp),%eax
sub    $0x960,%eax
je     2389 <genieOpen+0x1f9>
jmp    226d <genieOpen+0xdd>
mov    -0x40(%rbp),%eax
sub    $0x2580,%eax
je     239a <genieOpen+0x20a>
jmp    2280 <genieOpen+0xf0>
mov    -0x40(%rbp),%eax
sub    $0x4b00,%eax
je     23ab <genieOpen+0x21b>
jmp    2293 <genieOpen+0x103>
mov    -0x40(%rbp),%eax
sub    $0x9600,%eax
je     23bc <genieOpen+0x22c>
jmp    22a6 <genieOpen+0x116>
mov    -0x40(%rbp),%eax
sub    $0xe100,%eax
je     23cd <genieOpen+0x23d>
jmp    22b9 <genieOpen+0x129>
mov    -0x40(%rbp),%eax
sub    $0x1c200,%eax
je     23de <genieOpen+0x24e>
jmp    22cc <genieOpen+0x13c>
mov    -0x40(%rbp),%eax
sub    $0x38400,%eax
je     23ef <genieOpen+0x25f>
jmp    2400 <genieOpen+0x270>
mov    0x2c6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2c57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2bbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2bfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2c0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2c33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2b6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2b89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2b68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2bbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2c3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2ad5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2b4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2aeb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
mov    0x2aba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
jmp    240c <genieOpen+0x27c>
movl   $0xfffffffe,-0x4(%rbp)
jmp    25d4 <genieOpen+0x444>
mov    -0x10(%rbp),%rdi
mov    0x2bc9(%rip),%rax
mov    (%rax),%esi
mov    0x2ae0(%rip),%rax
or     (%rax),%esi
mov    0x2ab7(%rip),%rax
or     (%rax),%esi
mov    0x2b96(%rip),%rax
or     (%rax),%esi
call   2090 <open@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
jne    2451 <genieOpen+0x2c1>
movl   $0xffffffff,-0x4(%rbp)
jmp    25d4 <genieOpen+0x444>
mov    -0x3c(%rbp),%edi
mov    0x2a95(%rip),%rax
mov    (%rax),%esi
mov    0x2b7c(%rip),%rax
mov    (%rax),%edx
call   2030 <fcntl@plt>
mov    -0x3c(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   2070 <tcgetattr@plt>
lea    -0x30(%rbp),%rdi
call   2060 <cfmakeraw@plt>
mov    -0x34(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   20a0 <cfsetispeed@plt>
mov    -0x34(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   2040 <cfsetospeed@plt>
mov    0x2a01(%rip),%rax
mov    (%rax),%eax
mov    0x2aa0(%rip),%rcx
or     (%rcx),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2af1(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x29df(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2a4d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2a53(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x29c4(%rip),%rax
mov    (%rax),%eax
mov    0x2a83(%rip),%rcx
or     (%rcx),%eax
mov    0x2a72(%rip),%rcx
or     (%rcx),%eax
mov    0x2a61(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2a87(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x29f1(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2974(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x64,(%rax,%rcx,4)
mov    -0x3c(%rbp),%edi
mov    0x2a38(%rip),%rax
mov    (%rax),%esi
mov    0x2a5f(%rip),%rax
or     (%rax),%esi
lea    -0x30(%rbp),%rdx
call   2080 <tcsetattr@plt>
mov    -0x3c(%rbp),%edi
mov    0x2992(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   2050 <ioctl@plt>
mov    0x29d0(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x29f1(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x29ff(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   2050 <ioctl@plt>
mov    $0x2710,%edi
call   20b0 <usleep@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genieOpen>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0xfffffffe,%ebx
cmp    $0x4af,%esi
jle    21e9 <genieOpen+0x59>
cmp    $0x4aff,%esi
jle    2218 <genieOpen+0x88>
cmp    $0xe0ff,%esi
jle    2278 <genieOpen+0xe8>
cmp    $0xe100,%esi
je     22f7 <genieOpen+0x167>
cmp    $0x1c200,%esi
je     2300 <genieOpen+0x170>
cmp    $0x38400,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2ccc(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x95,%esi
jg     2248 <genieOpen+0xb8>
cmp    $0x6d,%esi
jg     229c <genieOpen+0x10c>
cmp    $0x32,%esi
je     2309 <genieOpen+0x179>
cmp    $0x4b,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2dad(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x95f,%esi
jg     22bd <genieOpen+0x12d>
cmp    $0x4b0,%esi
je     2312 <genieOpen+0x182>
cmp    $0x708,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2cc5(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x12b,%esi
jg     22da <genieOpen+0x14a>
cmp    $0x96,%esi
je     231b <genieOpen+0x18b>
cmp    $0xc8,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2cc5(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x4b00,%esi
je     2324 <genieOpen+0x194>
cmp    $0x9600,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2c01(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x6e,%esi
je     232d <genieOpen+0x19d>
cmp    $0x86,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2cb8(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x960,%esi
je     2336 <genieOpen+0x1a6>
cmp    $0x2580,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2c88(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
cmp    $0x12c,%esi
je     233f <genieOpen+0x1af>
cmp    $0x258,%esi
jne    24cf <genieOpen+0x33f>
mov    0x2c9b(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2c22(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2bc9(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2c40(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2bbf(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2bc6(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2cc5(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2ca4(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2bbb(%rip),%rax
jmp    2346 <genieOpen+0x1b6>
mov    0x2c12(%rip),%rax
mov    0x2c93(%rip),%r14
mov    0x2bac(%rip),%rcx
mov    (%rcx),%esi
or     (%r14),%esi
mov    0x2b80(%rip),%rcx
or     (%rcx),%esi
mov    (%rax),%ebp
mov    0x2c5d(%rip),%rax
or     (%rax),%esi
call   2090 <open@plt>
cmp    $0xffffffff,%eax
je     24ca <genieOpen+0x33a>
mov    %eax,%ebx
mov    0x2b6c(%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   2070 <tcgetattr@plt>
mov    %r14,%rdi
call   2060 <cfmakeraw@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   20a0 <cfsetispeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   2040 <cfsetospeed@plt>
mov    0x2ade(%rip),%rax
mov    0x2b7f(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     0x8(%rsp),%ecx
mov    0x2bd0(%rip),%rax
mov    (%rax),%eax
mov    0x2ac7(%rip),%rdx
or     (%rdx),%eax
mov    0x2b3e(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %ecx,%eax
mov    0x2b49(%rip),%rcx
or     (%rcx),%eax
mov    0x2ac0(%rip),%rcx
mov    0x2b81(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2b6e(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x8(%rsp)
mov    0x2b59(%rip),%rax
or     (%rax),%edx
not    %edx
and    %edx,0xc(%rsp)
mov    0x2b82(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2aee(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2a75(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x64,(%rax,%rcx,4)
mov    0x2b3c(%rip),%rax
mov    0x2b65(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   2080 <tcsetattr@plt>
mov    0x2a98(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rdx
call   2050 <ioctl@plt>
mov    0x2ad0(%rip),%rax
mov    0x4(%rsp),%ecx
or     (%rax),%ecx
mov    0x2af3(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x4(%rsp)
mov    0x2b06(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
call   2050 <ioctl@plt>
mov    $0x2710,%edi
call   20b0 <usleep@plt>
jmp    24cf <genieOpen+0x33f>
mov    $0xffffffff,%ebx
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
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@O_NONBLOCK = global i32 0
@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 @genieOpen(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.termios
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = load i32, i32* %5
switch i32 %10, label %45 [
i32 50, label %11
i32 75, label %13
i32 110, label %15
i32 134, label %17
i32 150, label %19
i32 200, label %21
i32 300, label %23
i32 600, label %25
i32 1200, label %27
i32 1800, label %29
i32 2400, label %31
i32 9600, label %33
i32 19200, label %35
i32 38400, label %37
i32 57600, label %39
i32 115200, label %41
i32 230400, label %43
]
11: ; preds = %2
%12 = load i32, i32* @B50
store i32 %12, i32* %7
br label %46
13: ; preds = %2
%14 = load i32, i32* @B75
store i32 %14, i32* %7
br label %46
15: ; preds = %2
%16 = load i32, i32* @B110
store i32 %16, i32* %7
br label %46
17: ; preds = %2
%18 = load i32, i32* @B134
store i32 %18, i32* %7
br label %46
19: ; preds = %2
%20 = load i32, i32* @B150
store i32 %20, i32* %7
br label %46
21: ; preds = %2
%22 = load i32, i32* @B200
store i32 %22, i32* %7
br label %46
23: ; preds = %2
%24 = load i32, i32* @B300
store i32 %24, i32* %7
br label %46
25: ; preds = %2
%26 = load i32, i32* @B600
store i32 %26, i32* %7
br label %46
27: ; preds = %2
%28 = load i32, i32* @B1200
store i32 %28, i32* %7
br label %46
29: ; preds = %2
%30 = load i32, i32* @B1800
store i32 %30, i32* %7
br label %46
31: ; preds = %2
%32 = load i32, i32* @B2400
store i32 %32, i32* %7
br label %46
33: ; preds = %2
%34 = load i32, i32* @B9600
store i32 %34, i32* %7
br label %46
35: ; preds = %2
%36 = load i32, i32* @B19200
store i32 %36, i32* %7
br label %46
37: ; preds = %2
%38 = load i32, i32* @B38400
store i32 %38, i32* %7
br label %46
39: ; preds = %2
%40 = load i32, i32* @B57600
store i32 %40, i32* %7
br label %46
41: ; preds = %2
%42 = load i32, i32* @B115200
store i32 %42, i32* %7
br label %46
43: ; preds = %2
%44 = load i32, i32* @B230400
store i32 %44, i32* %7
br label %46
45: ; preds = %2
store i32 -2, i32* %3
br label %138
46: ; preds = %43, %41, %39, %37, %35, %33, %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11
%47 = load i8*, i8** %4
%48 = load i32, i32* @O_RDWR
%49 = load i32, i32* @O_NOCTTY
%50 = or i32 %48, %49
%51 = load i32, i32* @O_NDELAY
%52 = or i32 %50, %51
%53 = load i32, i32* @O_NONBLOCK
%54 = or i32 %52, %53
%55 = call i32 @open(i8* %47, i32 %54)
store i32 %55, i32* %9
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %58
57: ; preds = %46
store i32 -1, i32* %3
br label %138
58: ; preds = %46
%59 = load i32, i32* %9
%60 = load i32, i32* @F_SETFL
%61 = load i32, i32* @O_RDWR
%62 = call i32 @fcntl(i32 %59, i32 %60, i32 %61)
%63 = load i32, i32* %9
%64 = call i32 @tcgetattr(i32 %63, %struct.termios* %6)
%65 = call i32 @cfmakeraw(%struct.termios* %6)
%66 = load i32, i32* %7
%67 = call i32 @cfsetispeed(%struct.termios* %6, i32 %66)
%68 = load i32, i32* %7
%69 = call i32 @cfsetospeed(%struct.termios* %6, i32 %68)
%70 = load i32, i32* @CLOCAL
%71 = load i32, i32* @CREAD
%72 = or i32 %70, %71
%73 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%74 = load i32, i32* %73
%75 = or i32 %74, %72
store i32 %75, i32* %73
%76 = load i32, i32* @PARENB
%77 = xor i32 %76, -1
%78 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%79 = load i32, i32* %78
%80 = and i32 %79, %77
store i32 %80, i32* %78
%81 = load i32, i32* @CSTOPB
%82 = xor i32 %81, -1
%83 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%84 = load i32, i32* %83
%85 = and i32 %84, %82
store i32 %85, i32* %83
%86 = load i32, i32* @CSIZE
%87 = xor i32 %86, -1
%88 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%89 = load i32, i32* %88
%90 = and i32 %89, %87
store i32 %90, i32* %88
%91 = load i32, i32* @CS8
%92 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%93 = load i32, i32* %92
%94 = or i32 %93, %91
store i32 %94, i32* %92
%95 = load i32, i32* @ICANON
%96 = load i32, i32* @ECHO
%97 = or i32 %95, %96
%98 = load i32, i32* @ECHOE
%99 = or i32 %97, %98
%100 = load i32, i32* @ISIG
%101 = or i32 %99, %100
%102 = xor i32 %101, -1
%103 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%104 = load i32, i32* %103
%105 = and i32 %104, %102
store i32 %105, i32* %103
%106 = load i32, i32* @OPOST
%107 = xor i32 %106, -1
%108 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%109 = load i32, i32* %108
%110 = and i32 %109, %107
store i32 %110, i32* %108
%111 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%112 = load i32*, i32** %111
%113 = load i64, i64* @VMIN
%114 = getelementptr inbounds i32, i32* %112, i64 %113
store i32 0, i32* %114
%115 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%116 = load i32*, i32** %115
%117 = load i64, i64* @VTIME
%118 = getelementptr inbounds i32, i32* %116, i64 %117
store i32 100, i32* %118
%119 = load i32, i32* %9
%120 = load i32, i32* @TCSANOW
%121 = load i32, i32* @TCSAFLUSH
%122 = or i32 %120, %121
%123 = call i32 @tcsetattr(i32 %119, i32 %122, %struct.termios* %6)
%124 = load i32, i32* %9
%125 = load i32, i32* @TIOCMGET
%126 = call i32 @ioctl(i32 %124, i32 %125, i32* %8)
%127 = load i32, i32* @TIOCM_DTR
%128 = load i32, i32* %8
%129 = or i32 %128, %127
store i32 %129, i32* %8
%130 = load i32, i32* @TIOCM_RTS
%131 = load i32, i32* %8
%132 = or i32 %131, %130
store i32 %132, i32* %8
%133 = load i32, i32* %9
%134 = load i32, i32* @TIOCMSET
%135 = call i32 @ioctl(i32 %133, i32 %134, i32* %8)
%136 = call i32 @usleep(i32 10000)
%137 = load i32, i32* %9
store i32 %137, i32* %3
br label %138
138: ; preds = %58, %57, %45
%139 = load i32, i32* %3
ret i32 %139
}

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