#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 serial_open(const char *serialport, int baud) {
  struct termios toptions;
  int fd;
  fd = open(serialport, O_RDWR | O_NONBLOCK);
  if (fd == -1) {
    perror("serial_init: Unable to open port ");
    return -1;
  }
  if (tcgetattr(fd, &toptions) < 0) {
    perror("serial_init: Couldn't get term attributes");
    return -1;
  }
  speed_t brate = baud;
  switch (baud) {
  case 4800:
    brate = B4800;
    break;
  case 19200:
    brate = B19200;
    break;
  case 38400:
    brate = B38400;
    break;
  case 57600:
    brate = B57600;
    break;
  case 115200:
    brate = B115200;
    break;
  default:
    brate = B9600;
    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");
    return -1;
  }
  return fd;
}


x86 assembly (clang, -O0):
<serial_open>:
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 <serial_open+0x4f>
lea    0xe62(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140e <serial_open+0x2ae>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1040 <tcgetattr@plt>
cmp    $0x0,%rax
jge    11dd <serial_open+0x7d>
lea    0xe56(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140e <serial_open+0x2ae>
mov    -0x14(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x12c0,%eax
je     1245 <serial_open+0xe5>
jmp    11f9 <serial_open+0x99>
mov    -0x44(%rbp),%eax
sub    $0x4b00,%eax
je     1256 <serial_open+0xf6>
jmp    120c <serial_open+0xac>
mov    -0x44(%rbp),%eax
sub    $0x9600,%eax
je     1267 <serial_open+0x107>
jmp    121f <serial_open+0xbf>
mov    -0x44(%rbp),%eax
sub    $0xe100,%eax
je     1278 <serial_open+0x118>
jmp    1232 <serial_open+0xd2>
mov    -0x44(%rbp),%eax
sub    $0x1c200,%eax
je     1289 <serial_open+0x129>
jmp    129a <serial_open+0x13a>
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12a6 <serial_open+0x146>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12a6 <serial_open+0x146>
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12a6 <serial_open+0x146>
mov    0x2cd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12a6 <serial_open+0x146>
mov    0x2cb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    12a6 <serial_open+0x146>
mov    0x2cdf(%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    0x2ceb(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c41(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c77(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c75(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c16(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%eax
mov    0x2beb(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    0x2c93(%rip),%rcx
or     (%rcx),%eax
mov    0x2c02(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2bd8(%rip),%rax
mov    (%rax),%eax
mov    0x2c3f(%rip),%rcx
or     (%rcx),%eax
mov    0x2c2e(%rip),%rcx
or     (%rcx),%eax
mov    0x2c1d(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c3b(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2bcd(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    0x2b87(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%edi
mov    0x2be2(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <tcsetattr@plt>
mov    -0x3c(%rbp),%edi
mov    0x2bfd(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <tcsetattr@plt>
cmp    $0x0,%rax
jge    1408 <serial_open+0x2a8>
lea    0xc55(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140e <serial_open+0x2ae>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_open>:
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     1320 <serial_open+0x1c0>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   1040 <tcgetattr@plt>
test   %rax,%rax
js     1329 <serial_open+0x1c9>
cmp    $0x95ff,%ebp
jle    11c8 <serial_open+0x68>
cmp    $0x9600,%ebp
je     11e1 <serial_open+0x81>
cmp    $0xe100,%ebp
je     11ea <serial_open+0x8a>
cmp    $0x1c200,%ebp
jne    11fc <serial_open+0x9c>
mov    0x2d7a(%rip),%rax
jmp    1203 <serial_open+0xa3>
cmp    $0x12c0,%ebp
je     11f3 <serial_open+0x93>
cmp    $0x4b00,%ebp
jne    11fc <serial_open+0x9c>
mov    0x2e11(%rip),%rax
jmp    1203 <serial_open+0xa3>
mov    0x2d20(%rip),%rax
jmp    1203 <serial_open+0xa3>
mov    0x2d67(%rip),%rax
jmp    1203 <serial_open+0xa3>
mov    0x2d8e(%rip),%rax
jmp    1203 <serial_open+0xa3>
mov    0x2d7d(%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    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    0x2cec(%rip),%rcx
or     (%rcx),%eax
mov    0x2d2b(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    (%rsp),%eax
mov    0x2d2d(%rip),%rcx
or     (%rcx),%eax
mov    0x2cd4(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x2d1f(%rip),%rax
mov    0x2cb0(%rip),%rdx
or     (%rax),%ecx
or     (%rdx),%ecx
mov    %ecx,(%rsp)
mov    0x2d4a(%rip),%rax
mov    0x2d5b(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cc8(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2ca1(%rip),%rax
mov    0x2d0a(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cf7(%rip),%rax
or     (%rax),%ecx
mov    0x2ce6(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2c9b(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c59(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
test   %rax,%rax
js     1332 <serial_open+0x1d2>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcd9(%rip),%rdi
jmp    1339 <serial_open+0x1d9>
lea    0xcf2(%rip),%rdi
jmp    1339 <serial_open+0x1d9>
lea    0xd13(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
jmp    1315 <serial_open+0x1b5>

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