#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 */
typedef int /*<<< orphan*/ tty;
struct termios {
  int c_iflag;
  int c_lflag;
  int c_cflag;
  int /*<<< orphan*/ c_oflag;
};

/* Variables and functions */
int /*<<< orphan*/ B115200;
int BRKINT;
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSTOPB;
int ECHO;
int ICANON;
int ICRNL;
int IEXTEN;
int IGNBRK;
int IGNCR;
int IGNPAR;
int INLCR;
int INPCK;
int ISIG;
int ISTRIP;
int /*<<< orphan*/ OPOST;
int PARENB;
int PARMRK;
int PARODD;
int /*<<< orphan*/ TCSANOW;
scalar_t__ cfsetispeed(struct termios *, int /*<<< orphan*/);
scalar_t__ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int openpty(int *, int *, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int pty_setup() {
  int mfd, sfd;
  char pts_name[256];
  if ((openpty(&mfd, &sfd, pts_name, 0, 0)) == -1) {
    printf("%s: Unable to open PTY\n", strerror(errno));
    return -1;
  }
  printf("Simulator running on device %s\n", pts_name);
  struct termios tty;
  memset(&tty, 0, sizeof(tty));
  if (tcgetattr(mfd, &tty) != 0) {
    printf("Unable to get attributes, %s\n", strerror(errno));
    close(mfd);
    return -1;
  }
  tty.c_iflag &= ~(IGNBRK | BRKINT | ISTRIP | INLCR | IGNCR | ICRNL);
  tty.c_oflag &= ~(OPOST);
  tty.c_lflag &= ~(ICANON | ECHO | ISIG | IEXTEN);
  tty.c_cflag |= (CLOCAL | CREAD);
  if (cfsetispeed(&tty, B115200) != 0 || cfsetospeed(&tty, B115200) != 0) {
    printf("Unable to set baud, %s\n", strerror(errno));
    close(mfd);
    return -1;
  }
  tty.c_cflag |= CS8;
  tty.c_cflag &= ~(PARENB | PARODD);
  tty.c_iflag &= ~(IGNPAR | PARMRK | INPCK);
  tty.c_iflag |= IGNPAR;
  tty.c_cflag &= ~CSTOPB;
  tty.c_cflag &= ~CRTSCTS;
  if (tcsetattr(mfd, TCSANOW, &tty) != 0) {
    printf("Unable to set parameters, %s\n", strerror(errno));
    close(mfd);
    return -1;
  }
  return mfd;
}


x86 assembly (clang, -O0):
<pty_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x110(%rbp),%rdx
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1070 <openpty@plt>
cmp    $0xffffffff,%eax
jne    11e7 <pty_setup+0x57>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %rax,%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1472 <pty_setup+0x2e2>
lea    -0x110(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
call   1080 <tcgetattr@plt>
cmp    $0x0,%rax
je     1257 <pty_setup+0xc7>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %rax,%rsi
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1472 <pty_setup+0x2e2>
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    0x2d31(%rip),%rcx
or     (%rcx),%eax
mov    0x2cf0(%rip),%rcx
or     (%rcx),%eax
mov    0x2d5f(%rip),%rcx
or     (%rcx),%eax
mov    0x2d4e(%rip),%rcx
or     (%rcx),%eax
mov    0x2d55(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x120(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x114(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    0x2c85(%rip),%rax
mov    (%rax),%eax
mov    0x2cec(%rip),%rcx
or     (%rcx),%eax
mov    0x2cd3(%rip),%rcx
or     (%rcx),%eax
mov    0x2caa(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x11c(%rbp),%eax
mov    %eax,-0x11c(%rbp)
mov    0x2c32(%rip),%rax
mov    (%rax),%eax
mov    0x2c99(%rip),%rcx
or     (%rcx),%eax
or     -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    0x2c44(%rip),%rax
mov    (%rax),%esi
lea    -0x120(%rbp),%rdi
call   10a0 <cfsetispeed@plt>
cmp    $0x0,%rax
jne    1343 <pty_setup+0x1b3>
mov    0x2c25(%rip),%rax
mov    (%rax),%esi
lea    -0x120(%rbp),%rdi
call   1030 <cfsetospeed@plt>
cmp    $0x0,%rax
je     1374 <pty_setup+0x1e4>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %rax,%rsi
lea    0xcfb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1472 <pty_setup+0x2e2>
mov    0x2c0d(%rip),%rax
mov    (%rax),%eax
or     -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    0x2c30(%rip),%rax
mov    (%rax),%eax
mov    0x2c0f(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    0x2b97(%rip),%rax
mov    (%rax),%eax
mov    0x2c36(%rip),%rcx
or     (%rcx),%eax
mov    0x2bad(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x120(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
or     -0x120(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    0x2b38(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    0x2b28(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2b95(%rip),%rax
mov    (%rax),%esi
lea    -0x120(%rbp),%rdx
call   1090 <tcsetattr@plt>
cmp    $0x0,%rax
je     146c <pty_setup+0x2dc>
mov    0x2b26(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    %rax,%rsi
lea    0xc1b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1472 <pty_setup+0x2e2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pty_setup>:
push   %rbx
sub    $0x120,%rsp
lea    0x4(%rsp),%rdi
lea    0x1c(%rsp),%rsi
lea    0x20(%rsp),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <openpty@plt>
cmp    $0xffffffff,%eax
je     1206 <pty_setup+0x76>
lea    0xe5b(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1040 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
call   1080 <tcgetattr@plt>
test   %rax,%rax
je     1228 <pty_setup+0x98>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xe37(%rip),%rdi
jmp    12f1 <pty_setup+0x161>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xde5(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
jmp    1302 <pty_setup+0x172>
mov    0x2d29(%rip),%rax
mov    0x2d62(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d1f(%rip),%rax
or     (%rax),%ecx
mov    0x2d8e(%rip),%rax
or     (%rax),%ecx
mov    0x2d7d(%rip),%rax
or     (%rax),%ecx
mov    0x2d84(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x14(%rsp)
mov    0x2cc6(%rip),%rax
mov    0x2d2f(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d14(%rip),%rax
or     (%rax),%ecx
mov    0x2ceb(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0xc(%rsp)
mov    0x2c7c(%rip),%rax
mov    0x2ce5(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,0x10(%rsp)
mov    0x2c96(%rip),%rbx
mov    (%rbx),%esi
lea    0x8(%rsp),%rdi
call   10a0 <cfsetispeed@plt>
test   %rax,%rax
jne    12dc <pty_setup+0x14c>
mov    (%rbx),%esi
lea    0x8(%rsp),%rdi
call   1030 <cfsetospeed@plt>
test   %rax,%rax
je     1310 <pty_setup+0x180>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xd65(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    $0xffffffff,%eax
add    $0x120,%rsp
pop    %rbx
ret
mov    0x2c71(%rip),%rcx
mov    0x10(%rsp),%eax
or     (%rcx),%eax
mov    0x2c9c(%rip),%rcx
mov    0x2c7d(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2c12(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2cb1(%rip),%rsi
mov    (%rsi),%esi
or     %ecx,%esi
mov    0x2c26(%rip),%rdi
or     (%rdi),%esi
not    %esi
and    0x8(%rsp),%esi
or     %ecx,%esi
mov    %esi,0x8(%rsp)
mov    0x2bc9(%rip),%rcx
or     (%rcx),%edx
mov    0x2bc8(%rip),%rcx
or     (%rcx),%edx
not    %edx
and    %eax,%edx
mov    %edx,0x10(%rsp)
mov    0x4(%rsp),%edi
mov    0x2c3b(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1090 <tcsetattr@plt>
test   %rax,%rax
je     13a8 <pty_setup+0x218>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xccb(%rip),%rdi
jmp    12f1 <pty_setup+0x161>
mov    0x4(%rsp),%eax
jmp    1307 <pty_setup+0x177>

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32 }
@.str = [24 x i8] c"%s: Unable to open PTY\0A\00"
@errno = global i32 0
@.str.1 = [32 x i8] c"Simulator running on device %s\0A\00"
@.str.2 = [30 x i8] c"Unable to get attributes, %s\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@OPOST = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@B115200 = global i32 0
@.str.3 = [24 x i8] c"Unable to set baud, %s\0A\00"
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@IGNPAR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@CSTOPB = global i32 0
@CRTSCTS = global i32 0
@TCSANOW = global i32 0
@.str.4 = [30 x i8] c"Unable to set parameters, %s\0A\00"
define i32 @pty_setup() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca %struct.termios
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = call i32 @openpty(i32* %2, i32* %3, i8* %6, i32 0, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 -1, i32* %1
br label %124
13: ; preds = %0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @memset(%struct.termios* %5, i32 0, i32 16)
%17 = load i32, i32* %2
%18 = call i64 @tcgetattr(i32 %17, %struct.termios* %5)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %13
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %2
%25 = call i32 @close(i32 %24)
store i32 -1, i32* %1
br label %124
26: ; preds = %13
%27 = load i32, i32* @IGNBRK
%28 = load i32, i32* @BRKINT
%29 = or i32 %27, %28
%30 = load i32, i32* @ISTRIP
%31 = or i32 %29, %30
%32 = load i32, i32* @INLCR
%33 = or i32 %31, %32
%34 = load i32, i32* @IGNCR
%35 = or i32 %33, %34
%36 = load i32, i32* @ICRNL
%37 = or i32 %35, %36
%38 = xor i32 %37, -1
%39 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%40 = load i32, i32* %39
%41 = and i32 %40, %38
store i32 %41, i32* %39
%42 = load i32, i32* @OPOST
%43 = xor i32 %42, -1
%44 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 3
%45 = load i32, i32* %44
%46 = and i32 %45, %43
store i32 %46, i32* %44
%47 = load i32, i32* @ICANON
%48 = load i32, i32* @ECHO
%49 = or i32 %47, %48
%50 = load i32, i32* @ISIG
%51 = or i32 %49, %50
%52 = load i32, i32* @IEXTEN
%53 = or i32 %51, %52
%54 = xor i32 %53, -1
%55 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 1
%56 = load i32, i32* %55
%57 = and i32 %56, %54
store i32 %57, i32* %55
%58 = load i32, i32* @CLOCAL
%59 = load i32, i32* @CREAD
%60 = or i32 %58, %59
%61 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%62 = load i32, i32* %61
%63 = or i32 %62, %60
store i32 %63, i32* %61
%64 = load i32, i32* @B115200
%65 = call i64 @cfsetispeed(%struct.termios* %5, i32 %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %71, label %67
67: ; preds = %26
%68 = load i32, i32* @B115200
%69 = call i64 @cfsetospeed(%struct.termios* %5, i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %67, %26
%72 = load i32, i32* @errno
%73 = call i8* @strerror(i32 %72)
%74 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %73)
%75 = load i32, i32* %2
%76 = call i32 @close(i32 %75)
store i32 -1, i32* %1
br label %124
77: ; preds = %67
%78 = load i32, i32* @CS8
%79 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%80 = load i32, i32* %79
%81 = or i32 %80, %78
store i32 %81, i32* %79
%82 = load i32, i32* @PARENB
%83 = load i32, i32* @PARODD
%84 = or i32 %82, %83
%85 = xor i32 %84, -1
%86 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%87 = load i32, i32* %86
%88 = and i32 %87, %85
store i32 %88, i32* %86
%89 = load i32, i32* @IGNPAR
%90 = load i32, i32* @PARMRK
%91 = or i32 %89, %90
%92 = load i32, i32* @INPCK
%93 = or i32 %91, %92
%94 = xor i32 %93, -1
%95 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%96 = load i32, i32* %95
%97 = and i32 %96, %94
store i32 %97, i32* %95
%98 = load i32, i32* @IGNPAR
%99 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%100 = load i32, i32* %99
%101 = or i32 %100, %98
store i32 %101, i32* %99
%102 = load i32, i32* @CSTOPB
%103 = xor i32 %102, -1
%104 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%105 = load i32, i32* %104
%106 = and i32 %105, %103
store i32 %106, i32* %104
%107 = load i32, i32* @CRTSCTS
%108 = xor i32 %107, -1
%109 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%110 = load i32, i32* %109
%111 = and i32 %110, %108
store i32 %111, i32* %109
%112 = load i32, i32* %2
%113 = load i32, i32* @TCSANOW
%114 = call i64 @tcsetattr(i32 %112, i32 %113, %struct.termios* %5)
%115 = icmp ne i64 %114, 0
br i1 %115, label %116, label %122
116: ; preds = %77
%117 = load i32, i32* @errno
%118 = call i8* @strerror(i32 %117)
%119 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %118)
%120 = load i32, i32* %2
%121 = call i32 @close(i32 %120)
store i32 -1, i32* %1
br label %124
122: ; preds = %77
%123 = load i32, i32* %2
store i32 %123, i32* %1
br label %124
124: ; preds = %122, %116, %71, %20, %9
%125 = load i32, i32* %1
ret i32 %125
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32 }
@.str = [24 x i8] c"%s: Unable to open PTY\0A\00"
@errno = global i32 0
@.str.1 = [32 x i8] c"Simulator running on device %s\0A\00"
@.str.2 = [30 x i8] c"Unable to get attributes, %s\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@OPOST = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@B115200 = global i32 0
@.str.3 = [24 x i8] c"Unable to set baud, %s\0A\00"
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@IGNPAR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@CSTOPB = global i32 0
@CRTSCTS = global i32 0
@TCSANOW = global i32 0
@.str.4 = [30 x i8] c"Unable to set parameters, %s\0A\00"
define i32 @pty_setup() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = alloca %struct.termios
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i32 @openpty(i32* %1, i32* %2, i8* %7, i32 0, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %114
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%16 = bitcast %struct.termios* %4 to i8*
%17 = call i32 @memset(%struct.termios* %4, i32 0, i32 16)
%18 = load i32, i32* %1
%19 = call i64 @tcgetattr(i32 %18, %struct.termios* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %14
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %1
%26 = call i32 @close(i32 %25)
br label %112
27: ; preds = %14
%28 = load i32, i32* @IGNBRK
%29 = load i32, i32* @BRKINT
%30 = or i32 %29, %28
%31 = load i32, i32* @ISTRIP
%32 = or i32 %30, %31
%33 = load i32, i32* @INLCR
%34 = or i32 %32, %33
%35 = load i32, i32* @IGNCR
%36 = or i32 %34, %35
%37 = load i32, i32* @ICRNL
%38 = or i32 %36, %37
%39 = xor i32 %38, -1
%40 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%41 = load i32, i32* %40
%42 = and i32 %41, %39
store i32 %42, i32* %40
%43 = load i32, i32* @OPOST
%44 = xor i32 %43, -1
%45 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 3
%46 = load i32, i32* %45
%47 = and i32 %46, %44
store i32 %47, i32* %45
%48 = load i32, i32* @ICANON
%49 = load i32, i32* @ECHO
%50 = or i32 %49, %48
%51 = load i32, i32* @ISIG
%52 = or i32 %50, %51
%53 = load i32, i32* @IEXTEN
%54 = or i32 %52, %53
%55 = xor i32 %54, -1
%56 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%57 = load i32, i32* %56
%58 = and i32 %57, %55
store i32 %58, i32* %56
%59 = load i32, i32* @CLOCAL
%60 = load i32, i32* @CREAD
%61 = or i32 %60, %59
%62 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 2
%63 = load i32, i32* %62
%64 = or i32 %61, %63
store i32 %64, i32* %62
%65 = load i32, i32* @B115200
%66 = call i64 @cfsetispeed(%struct.termios* %4, i32 %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %27
%69 = load i32, i32* @B115200
%70 = call i64 @cfsetospeed(%struct.termios* %4, i32 %69)
%71 = icmp eq i64 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %68, %27
%73 = load i32, i32* @errno
%74 = call i8* @strerror(i32 %73)
%75 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %74)
%76 = load i32, i32* %1
%77 = call i32 @close(i32 %76)
br label %112
78: ; preds = %68
%79 = load i32, i32* @CS8
%80 = load i32, i32* %62
%81 = or i32 %80, %79
%82 = load i32, i32* @PARENB
%83 = load i32, i32* @PARODD
%84 = or i32 %83, %82
%85 = load i32, i32* @IGNPAR
%86 = load i32, i32* @PARMRK
%87 = or i32 %86, %85
%88 = load i32, i32* @INPCK
%89 = or i32 %87, %88
%90 = xor i32 %89, -1
%91 = load i32, i32* %40
%92 = and i32 %91, %90
%93 = or i32 %92, %85
store i32 %93, i32* %40
%94 = load i32, i32* @CSTOPB
%95 = or i32 %84, %94
%96 = load i32, i32* @CRTSCTS
%97 = or i32 %95, %96
%98 = xor i32 %97, -1
%99 = and i32 %81, %98
store i32 %99, i32* %62
%100 = load i32, i32* %1
%101 = load i32, i32* @TCSANOW
%102 = call i64 @tcsetattr(i32 %100, i32 %101, %struct.termios* %4)
%103 = icmp eq i64 %102, 0
br i1 %103, label %110, label %104
104: ; preds = %78
%105 = load i32, i32* @errno
%106 = call i8* @strerror(i32 %105)
%107 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %106)
%108 = load i32, i32* %1
%109 = call i32 @close(i32 %108)
br label %112
110: ; preds = %78
%111 = load i32, i32* %1
br label %112
112: ; preds = %110, %104, %72, %21
%113 = phi i32 [ -1, %21 ], [ -1, %72 ], [ -1, %104 ], [ %111, %110 ]
br label %114
114: ; preds = %112, %10
%115 = phi i32 [ -1, %10 ], [ %113, %112 ]
ret i32 %115
}