#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;
  int *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_NDELAY;
int O_NOCTTY;
int O_RDWR;
int PARENB;
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_NOCTTY | O_NDELAY);
  if (fd == -1) {
    perror("init_serialport: Unable to open port ");
    return -1;
  }
  if (tcgetattr(fd, &toptions) < 0) {
    perror("init_serialport: Couldn't get term attributes");
    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] = 5;
  toptions.c_cc[VTIME] = 0;
  if (tcsetattr(fd, TCSANOW, &toptions) < 0) {
    perror("init_serialport: Couldn't set term attributes");
    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    0x2dcd(%rip),%rax
or     (%rax),%esi
mov    0x2dbc(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11b8 <serialport_init+0x58>
lea    0xe59(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <serialport_init+0x2b3>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1040 <tcgetattr@plt>
cmp    $0x0,%rax
jge    11e6 <serialport_init+0x86>
lea    0xe51(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <serialport_init+0x2b3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x12c0,%eax
je     1261 <serialport_init+0x101>
jmp    1202 <serialport_init+0xa2>
mov    -0x44(%rbp),%eax
sub    $0x2580,%eax
je     1272 <serialport_init+0x112>
jmp    1215 <serialport_init+0xb5>
mov    -0x44(%rbp),%eax
sub    $0x4b00,%eax
je     1283 <serialport_init+0x123>
jmp    1228 <serialport_init+0xc8>
mov    -0x44(%rbp),%eax
sub    $0x9600,%eax
je     1294 <serialport_init+0x134>
jmp    123b <serialport_init+0xdb>
mov    -0x44(%rbp),%eax
sub    $0xe100,%eax
je     12a5 <serialport_init+0x145>
jmp    124e <serialport_init+0xee>
mov    -0x44(%rbp),%eax
sub    $0x1c200,%eax
je     12b6 <serialport_init+0x156>
jmp    12c2 <serialport_init+0x162>
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12c2 <serialport_init+0x162>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12c2 <serialport_init+0x162>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12c2 <serialport_init+0x162>
mov    0x2c6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12c2 <serialport_init+0x162>
mov    0x2cbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12c2 <serialport_init+0x162>
mov    0x2c83(%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    0x2cdf(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c6b(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c69(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2bfa(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c50(%rip),%rax
mov    (%rax),%eax
mov    0x2bcf(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
mov    0x2c7f(%rip),%rcx
or     (%rcx),%eax
mov    0x2bf6(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2bbc(%rip),%rax
mov    (%rax),%eax
mov    0x2c33(%rip),%rcx
or     (%rcx),%eax
mov    0x2c22(%rip),%rcx
or     (%rcx),%eax
mov    0x2c11(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c2f(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bc1(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2b6c(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%edi
mov    0x2bd8(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <tcsetattr@plt>
cmp    $0x0,%rax
jge    140d <serialport_init+0x2ad>
lea    0xc58(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1413 <serialport_init+0x2b3>
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    0x2e71(%rip),%rcx
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    %esi,%ebp
mov    0x2dc5(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%esi
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     131e <serialport_init+0x1be>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   1040 <tcgetattr@plt>
test   %rax,%rax
js     1327 <serialport_init+0x1c7>
cmp    $0x95ff,%ebp
jg     11d3 <serialport_init+0x73>
cmp    $0x12c0,%ebp
je     11f4 <serialport_init+0x94>
cmp    $0x2580,%ebp
je     11fd <serialport_init+0x9d>
cmp    $0x4b00,%ebp
jne    1218 <serialport_init+0xb8>
mov    0x2e1f(%rip),%rax
jmp    1216 <serialport_init+0xb6>
cmp    $0x9600,%ebp
je     1206 <serialport_init+0xa6>
cmp    $0xe100,%ebp
je     120f <serialport_init+0xaf>
cmp    $0x1c200,%ebp
jne    1218 <serialport_init+0xb8>
mov    0x2d4e(%rip),%rax
jmp    1216 <serialport_init+0xb6>
mov    0x2d9d(%rip),%rax
jmp    1216 <serialport_init+0xb6>
mov    0x2d8c(%rip),%rax
jmp    1216 <serialport_init+0xb6>
mov    0x2cfb(%rip),%rax
jmp    1216 <serialport_init+0xb6>
mov    0x2d52(%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    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    0x2cd9(%rip),%rcx
or     (%rcx),%eax
mov    0x2d28(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    (%rsp),%eax
mov    0x2d2a(%rip),%rcx
or     (%rcx),%eax
mov    0x2cc1(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x2d1c(%rip),%rax
mov    0x2c9d(%rip),%rdx
or     (%rax),%ecx
or     (%rdx),%ecx
mov    %ecx,(%rsp)
mov    0x2d47(%rip),%rax
mov    0x2d50(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cc5(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2c8e(%rip),%rax
mov    0x2d07(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cf4(%rip),%rax
or     (%rax),%ecx
mov    0x2ce3(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2c98(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    0x2c47(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2cb6(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
test   %rax,%rax
js     1330 <serialport_init+0x1d0>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcdb(%rip),%rdi
jmp    1337 <serialport_init+0x1d7>
lea    0xcf8(%rip),%rdi
jmp    1337 <serialport_init+0x1d7>
lea    0xd1d(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
jmp    1313 <serialport_init+0x1b3>

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

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