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

/* Variables and functions */
int B115200;
int B19200;
int B38400;
int B4800;
int B57600;
int B9600;
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ISIG;
int IXANY;
int IXOFF;
int IXON;
int /*<<< orphan*/ OPOST;
int O_NONBLOCK;
int O_RDWR;
int PARENB;
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int);
int /*<<< orphan*/ cfsetospeed(struct termios *, int);
int open(char const *, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int serialport_init(const char *serialport, int baud) {
  struct termios toptions;
  int fd;
  fd = open(serialport, O_RDWR | O_NONBLOCK);
  if (fd == -1) {
    perror("serialport_init: Unable to open port\n\t");
    return -1;
  }
  if (tcgetattr(fd, &toptions) < 0) {
    perror("serialport_init: Couldn't get term attributes\n\t");
    return -1;
  }
  speed_t brate = baud;
  switch (baud) {
  case 4800:
    brate = B4800;
    break;
  case 9600:
    brate = B9600;
    break;
  case 19200:
    brate = B19200;
    break;
  case 38400:
    brate = B38400;
    break;
  case 57600:
    brate = B57600;
    break;
  case 115200:
    brate = B115200;
    break;
  }
  cfsetispeed(&toptions, brate);
  cfsetospeed(&toptions, brate);
  toptions.c_cflag &= ~PARENB;
  toptions.c_cflag &= ~CSTOPB;
  toptions.c_cflag &= ~CSIZE;
  toptions.c_cflag |= CS8;
  toptions.c_cflag &= ~CRTSCTS;
  toptions.c_cflag |= CREAD | CLOCAL;
  toptions.c_iflag &= ~(IXON | IXOFF | IXANY);
  toptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  toptions.c_oflag &= ~OPOST;
  toptions.c_cc[VMIN] = 0;
  toptions.c_cc[VTIME] = 0;
  tcsetattr(fd, TCSANOW, &toptions);
  if (tcsetattr(fd, TCSAFLUSH, &toptions) < 0) {
    perror("init_serialport: Couldn't set term attributes\n\t");
    return -1;
  }
  return fd;
}


x86 assembly (clang, -O0):
<serialport_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
mov    0x2e45(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11af <serialport_init+0x4f>
lea    0xe62(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1421 <serialport_init+0x2c1>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1040 <tcgetattr@plt>
cmp    $0x0,%rax
jge    11dd <serialport_init+0x7d>
lea    0xe5b(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1421 <serialport_init+0x2c1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x12c0,%eax
je     1258 <serialport_init+0xf8>
jmp    11f9 <serialport_init+0x99>
mov    -0x44(%rbp),%eax
sub    $0x2580,%eax
je     1269 <serialport_init+0x109>
jmp    120c <serialport_init+0xac>
mov    -0x44(%rbp),%eax
sub    $0x4b00,%eax
je     127a <serialport_init+0x11a>
jmp    121f <serialport_init+0xbf>
mov    -0x44(%rbp),%eax
sub    $0x9600,%eax
je     128b <serialport_init+0x12b>
jmp    1232 <serialport_init+0xd2>
mov    -0x44(%rbp),%eax
sub    $0xe100,%eax
je     129c <serialport_init+0x13c>
jmp    1245 <serialport_init+0xe5>
mov    -0x44(%rbp),%eax
sub    $0x1c200,%eax
je     12ad <serialport_init+0x14d>
jmp    12b9 <serialport_init+0x159>
mov    0x2d29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12b9 <serialport_init+0x159>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12b9 <serialport_init+0x159>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12b9 <serialport_init+0x159>
mov    0x2c76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12b9 <serialport_init+0x159>
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12b9 <serialport_init+0x159>
mov    0x2c8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%esi
lea    -0x38(%rbp),%rdi
call   1070 <cfsetispeed@plt>
mov    -0x40(%rbp),%esi
lea    -0x38(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c2e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c64(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c49(%rip),%rax
mov    (%rax),%eax
mov    0x2bd8(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c71(%rip),%rax
mov    (%rax),%eax
mov    0x2c80(%rip),%rcx
or     (%rcx),%eax
mov    0x2bef(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2bc5(%rip),%rax
mov    (%rax),%eax
mov    0x2c2c(%rip),%rcx
or     (%rcx),%eax
mov    0x2c1b(%rip),%rcx
or     (%rcx),%eax
mov    0x2c0a(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bba(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    0x2b74(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%edi
mov    0x2bcf(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <tcsetattr@plt>
mov    -0x3c(%rbp),%edi
mov    0x2bea(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <tcsetattr@plt>
cmp    $0x0,%rax
jge    141b <serialport_init+0x2bb>
lea    0xc4d(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1421 <serialport_init+0x2c1>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serialport_init>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    0x2e6f(%rip),%rax
mov    0x2e50(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     1328 <serialport_init+0x1c8>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   1040 <tcgetattr@plt>
test   %rax,%rax
js     1331 <serialport_init+0x1d1>
cmp    $0x95ff,%ebp
jg     11c8 <serialport_init+0x68>
cmp    $0x12c0,%ebp
je     11e9 <serialport_init+0x89>
cmp    $0x2580,%ebp
je     11f2 <serialport_init+0x92>
cmp    $0x4b00,%ebp
jne    120d <serialport_init+0xad>
mov    0x2e2a(%rip),%rax
jmp    120b <serialport_init+0xab>
cmp    $0x9600,%ebp
je     11fb <serialport_init+0x9b>
cmp    $0xe100,%ebp
je     1204 <serialport_init+0xa4>
cmp    $0x1c200,%ebp
jne    120d <serialport_init+0xad>
mov    0x2d59(%rip),%rax
jmp    120b <serialport_init+0xab>
mov    0x2d98(%rip),%rax
jmp    120b <serialport_init+0xab>
mov    0x2d87(%rip),%rax
jmp    120b <serialport_init+0xab>
mov    0x2d06(%rip),%rax
jmp    120b <serialport_init+0xab>
mov    0x2d4d(%rip),%rax
mov    (%rax),%ebp
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebp,%esi
call   1070 <cfsetispeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <cfsetospeed@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    0x2ce4(%rip),%rcx
or     (%rcx),%eax
mov    0x2d23(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    (%rsp),%eax
mov    0x2d25(%rip),%rcx
or     (%rcx),%eax
mov    0x2ccc(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x2d17(%rip),%rax
mov    0x2ca8(%rip),%rdx
or     (%rax),%ecx
or     (%rdx),%ecx
mov    %ecx,(%rsp)
mov    0x2d42(%rip),%rax
mov    0x2d53(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cc0(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2c99(%rip),%rax
mov    0x2d02(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cef(%rip),%rax
or     (%rax),%ecx
mov    0x2cde(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2c93(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c51(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
test   %rax,%rax
js     133a <serialport_init+0x1da>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcd1(%rip),%rdi
jmp    1341 <serialport_init+0x1e1>
lea    0xcef(%rip),%rdi
jmp    1341 <serialport_init+0x1e1>
lea    0xd16(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
jmp    131d <serialport_init+0x1bd>

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str = [39 x i8] c"serialport_init: Unable to open port\0A\09\00"
@.str.1 = [48 x i8] c"serialport_init: Couldn't get term attributes\0A\09\00"
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = 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
@.str.2 = [48 x i8] c"init_serialport: Couldn't set term attributes\0A\09\00"
define i32 @serialport_init(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.termios
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = load i8*, i8** %4
%10 = load i32, i32* @O_RDWR
%11 = load i32, i32* @O_NONBLOCK
%12 = or i32 %10, %11
%13 = call i32 @open(i8* %9, i32 %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %118
18: ; preds = %2
%19 = load i32, i32* %7
%20 = call i64 @tcgetattr(i32 %19, %struct.termios* %6)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %118
24: ; preds = %18
%25 = load i32, i32* %5
store i32 %25, i32* %8
%26 = load i32, i32* %5
switch i32 %26, label %39 [
i32 4800, label %27
i32 9600, label %29
i32 19200, label %31
i32 38400, label %33
i32 57600, label %35
i32 115200, label %37
]
27: ; preds = %24
%28 = load i32, i32* @B4800
store i32 %28, i32* %8
br label %39
29: ; preds = %24
%30 = load i32, i32* @B9600
store i32 %30, i32* %8
br label %39
31: ; preds = %24
%32 = load i32, i32* @B19200
store i32 %32, i32* %8
br label %39
33: ; preds = %24
%34 = load i32, i32* @B38400
store i32 %34, i32* %8
br label %39
35: ; preds = %24
%36 = load i32, i32* @B57600
store i32 %36, i32* %8
br label %39
37: ; preds = %24
%38 = load i32, i32* @B115200
store i32 %38, i32* %8
br label %39
39: ; preds = %24, %37, %35, %33, %31, %29, %27
%40 = load i32, i32* %8
%41 = call i32 @cfsetispeed(%struct.termios* %6, i32 %40)
%42 = load i32, i32* %8
%43 = call i32 @cfsetospeed(%struct.termios* %6, i32 %42)
%44 = load i32, i32* @PARENB
%45 = xor i32 %44, -1
%46 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%47 = load i32, i32* %46
%48 = and i32 %47, %45
store i32 %48, i32* %46
%49 = load i32, i32* @CSTOPB
%50 = xor i32 %49, -1
%51 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%52 = load i32, i32* %51
%53 = and i32 %52, %50
store i32 %53, i32* %51
%54 = load i32, i32* @CSIZE
%55 = xor i32 %54, -1
%56 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%57 = load i32, i32* %56
%58 = and i32 %57, %55
store i32 %58, i32* %56
%59 = load i32, i32* @CS8
%60 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%61 = load i32, i32* %60
%62 = or i32 %61, %59
store i32 %62, i32* %60
%63 = load i32, i32* @CRTSCTS
%64 = xor i32 %63, -1
%65 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%66 = load i32, i32* %65
%67 = and i32 %66, %64
store i32 %67, i32* %65
%68 = load i32, i32* @CREAD
%69 = load i32, i32* @CLOCAL
%70 = or i32 %68, %69
%71 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%72 = load i32, i32* %71
%73 = or i32 %72, %70
store i32 %73, i32* %71
%74 = load i32, i32* @IXON
%75 = load i32, i32* @IXOFF
%76 = or i32 %74, %75
%77 = load i32, i32* @IXANY
%78 = or i32 %76, %77
%79 = xor i32 %78, -1
%80 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%81 = load i32, i32* %80
%82 = and i32 %81, %79
store i32 %82, i32* %80
%83 = load i32, i32* @ICANON
%84 = load i32, i32* @ECHO
%85 = or i32 %83, %84
%86 = load i32, i32* @ECHOE
%87 = or i32 %85, %86
%88 = load i32, i32* @ISIG
%89 = or i32 %87, %88
%90 = xor i32 %89, -1
%91 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%92 = load i32, i32* %91
%93 = and i32 %92, %90
store i32 %93, i32* %91
%94 = load i32, i32* @OPOST
%95 = xor i32 %94, -1
%96 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 4
%97 = load i32, i32* %96
%98 = and i32 %97, %95
store i32 %98, i32* %96
%99 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%100 = load i64*, i64** %99
%101 = load i64, i64* @VMIN
%102 = getelementptr inbounds i64, i64* %100, i64 %101
store i64 0, i64* %102
%103 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%104 = load i64*, i64** %103
%105 = load i64, i64* @VTIME
%106 = getelementptr inbounds i64, i64* %104, i64 %105
store i64 0, i64* %106
%107 = load i32, i32* %7
%108 = load i32, i32* @TCSANOW
%109 = call i64 @tcsetattr(i32 %107, i32 %108, %struct.termios* %6)
%110 = load i32, i32* %7
%111 = load i32, i32* @TCSAFLUSH
%112 = call i64 @tcsetattr(i32 %110, i32 %111, %struct.termios* %6)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %39
%115 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %118
116: ; preds = %39
%117 = load i32, i32* %7
store i32 %117, i32* %3
br label %118
118: ; preds = %116, %114, %22, %16
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str = [39 x i8] c"serialport_init: Unable to open port\0A\09\00"
@.str.1 = [48 x i8] c"serialport_init: Couldn't get term attributes\0A\09\00"
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = 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
@.str.2 = [48 x i8] c"init_serialport: Couldn't set term attributes\0A\09\00"
define i32 @serialport_init(i8* nocapture %0, i32 %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* %0, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %90
12: ; preds = %2
%13 = call i64 @tcgetattr(i32 %8, %struct.termios* %3)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %90
17: ; preds = %12
switch i32 %1, label %30 [
i32 4800, label %18
i32 9600, label %20
i32 19200, label %22
i32 38400, label %24
i32 57600, label %26
i32 115200, label %28
]
18: ; preds = %17
%19 = load i32, i32* @B4800
br label %30
20: ; preds = %17
%21 = load i32, i32* @B9600
br label %30
22: ; preds = %17
%23 = load i32, i32* @B19200
br label %30
24: ; preds = %17
%25 = load i32, i32* @B38400
br label %30
26: ; preds = %17
%27 = load i32, i32* @B57600
br label %30
28: ; preds = %17
%29 = load i32, i32* @B115200
br label %30
30: ; preds = %17, %28, %26, %24, %22, %20, %18
%31 = phi i32 [ %1, %17 ], [ %29, %28 ], [ %27, %26 ], [ %25, %24 ], [ %23, %22 ], [ %21, %20 ], [ %19, %18 ]
%32 = call i32 @cfsetispeed(%struct.termios* %3, i32 %31)
%33 = call i32 @cfsetospeed(%struct.termios* %3, i32 %31)
%34 = load i32, i32* @PARENB
%35 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%36 = load i32, i32* %35
%37 = load i32, i32* @CSTOPB
%38 = or i32 %34, %37
%39 = load i32, i32* @CSIZE
%40 = or i32 %38, %39
%41 = xor i32 %40, -1
%42 = and i32 %36, %41
%43 = load i32, i32* @CS8
%44 = or i32 %43, %42
%45 = load i32, i32* @CRTSCTS
%46 = xor i32 %45, -1
%47 = and i32 %44, %46
%48 = load i32, i32* @CREAD
%49 = load i32, i32* @CLOCAL
%50 = or i32 %48, %47
%51 = or i32 %50, %49
store i32 %51, i32* %35
%52 = load i32, i32* @IXON
%53 = load i32, i32* @IXOFF
%54 = or i32 %53, %52
%55 = load i32, i32* @IXANY
%56 = or i32 %54, %55
%57 = xor i32 %56, -1
%58 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%59 = load i32, i32* %58
%60 = and i32 %59, %57
store i32 %60, i32* %58
%61 = load i32, i32* @ICANON
%62 = load i32, i32* @ECHO
%63 = or i32 %62, %61
%64 = load i32, i32* @ECHOE
%65 = or i32 %63, %64
%66 = load i32, i32* @ISIG
%67 = or i32 %65, %66
%68 = xor i32 %67, -1
%69 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%70 = load i32, i32* %69
%71 = and i32 %70, %68
store i32 %71, i32* %69
%72 = load i32, i32* @OPOST
%73 = xor i32 %72, -1
%74 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 4
%75 = load i32, i32* %74
%76 = and i32 %75, %73
store i32 %76, i32* %74
%77 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%78 = load i64*, i64** %77
%79 = load i64, i64* @VMIN
%80 = getelementptr inbounds i64, i64* %78, i64 %79
store i64 0, i64* %80
%81 = load i64, i64* @VTIME
%82 = getelementptr inbounds i64, i64* %78, i64 %81
store i64 0, i64* %82
%83 = load i32, i32* @TCSANOW
%84 = call i64 @tcsetattr(i32 %8, i32 %83, %struct.termios* %3)
%85 = load i32, i32* @TCSAFLUSH
%86 = call i64 @tcsetattr(i32 %8, i32 %85, %struct.termios* %3)
%87 = icmp slt i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %30
%89 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %90
90: ; preds = %88, %30, %15, %10
%91 = phi i32 [ -1, %10 ], [ -1, %15 ], [ -1, %88 ], [ %8, %30 ]
ret i32 %91
}