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

/* Variables and functions */
int BRKINT;
int CS8;
int CSIZE;
int ECHO;
int ECHONL;
int ICANON;
int ICRNL;
int IEXTEN;
int IGNBRK;
int INLCR;
int INPCK;
int ISIG;
int ISTRIP;
int IXON;
int O_NDELAY;
int O_NOCTTY;
int O_RDWR;
int PARENB;
int PARMRK;
int /*<<< orphan*/ TCSAFLUSH;
size_t VMIN;
size_t VTIME;
scalar_t__ cfsetispeed(struct termios *, int /*<<< orphan*/);
scalar_t__ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ convertspeed(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ isatty(int);
int open(char const *, int);
int /*<<< orphan*/ stderr;
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int getttyfd(const char *device, int s) {
  struct termios config;
  int tty;
  speed_t speed;
  speed = convertspeed(s);
  tty = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
  if (tty == -1) {
    fprintf(stderr, "failed to open port %s\n", device);
    return -1;
  }
  if (!isatty(tty)) {
    fprintf(stderr, "%s is not a tty\n", device);
    return -1;
  }
  if (tcgetattr(tty, &config) < 0) {
    fprintf(stderr, "failed to get port config\n");
    return -1;
  }
  config.c_iflag &=
      ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
  config.c_oflag = 0;
  config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
  config.c_cflag &= ~(CSIZE | PARENB);
  config.c_cflag |= CS8;
  config.c_cc[VMIN] = 1;
  config.c_cc[VTIME] = 0;
  if (cfsetispeed(&config, speed) < 0 || cfsetospeed(&config, speed) < 0) {
    fprintf(stderr, "failed to set speed\n");
    return -1;
  }
  if (tcsetattr(tty, TCSAFLUSH, &config) < 0) {
    fprintf(stderr, "failed to apply config\n");
    return -1;
  }
  return tty;
}


x86 assembly (clang, -O0):
<getttyfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1090 <convertspeed@plt>
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
mov    0x2dc2(%rip),%rax
or     (%rax),%esi
mov    0x2da1(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11f2 <getttyfd+0x72>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dd <getttyfd+0x25d>
mov    -0x3c(%rbp),%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    122a <getttyfd+0xaa>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dd <getttyfd+0x25d>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0x0,%rax
jge    1263 <getttyfd+0xe3>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dd <getttyfd+0x25d>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
mov    0x2d2d(%rip),%rcx
or     (%rcx),%eax
mov    0x2d5c(%rip),%rcx
or     (%rcx),%eax
mov    0x2d4b(%rip),%rcx
or     (%rcx),%eax
mov    0x2d62(%rip),%rcx
or     (%rcx),%eax
mov    0x2cc9(%rip),%rcx
or     (%rcx),%eax
mov    0x2cb0(%rip),%rcx
or     (%rcx),%eax
mov    0x2d17(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2ced(%rip),%rax
mov    (%rax),%eax
mov    0x2c7c(%rip),%rcx
or     (%rcx),%eax
mov    0x2c5b(%rip),%rcx
or     (%rcx),%eax
mov    0x2ca2(%rip),%rcx
or     (%rcx),%eax
mov    0x2cc1(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
mov    0x2cb6(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2c69(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2bfc(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x40(%rbp),%esi
lea    -0x38(%rbp),%rdi
call   10a0 <cfsetispeed@plt>
cmp    $0x0,%rax
jl     1372 <getttyfd+0x1f2>
mov    -0x40(%rbp),%esi
lea    -0x38(%rbp),%rdi
call   1040 <cfsetospeed@plt>
cmp    $0x0,%rax
jge    1395 <getttyfd+0x215>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dd <getttyfd+0x25d>
mov    -0x3c(%rbp),%edi
mov    0x2c29(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1070 <tcsetattr@plt>
cmp    $0x0,%rax
jge    13d7 <getttyfd+0x257>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dd <getttyfd+0x25d>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getttyfd>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbp
mov    %esi,%edi
call   1090 <convertspeed@plt>
mov    0x2e47(%rip),%rcx
mov    0x2dd0(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %eax,%r14d
mov    0x2daa(%rip),%rax
or     (%rax),%esi
mov    %rbp,%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     1304 <getttyfd+0x184>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <isatty@plt>
test   %eax,%eax
je     1316 <getttyfd+0x196>
mov    %rsp,%rsi
mov    %ebx,%edi
call   1060 <tcgetattr@plt>
test   %rax,%rax
js     1344 <getttyfd+0x1c4>
mov    0x2d54(%rip),%rax
mov    0x2dad(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2dda(%rip),%rax
or     (%rax),%ecx
mov    0x2dc9(%rip),%rax
or     (%rax),%ecx
mov    0x2de0(%rip),%rax
or     (%rax),%ecx
mov    0x2d47(%rip),%rax
or     (%rax),%ecx
mov    0x2d2e(%rip),%rax
or     (%rax),%ecx
mov    0x2d95(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x2d77(%rip),%rax
mov    0x2d08(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ce5(%rip),%rax
or     (%rax),%ecx
movq   $0x0,0x18(%rsp)
mov    0x2d23(%rip),%rax
or     (%rax),%ecx
mov    0x2d42(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2d13(%rip),%rax
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    0x8(%rsp),%ecx
mov    0x2d0b(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    0x2cf1(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2c88(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    %rsp,%rdi
mov    %r14d,%esi
call   10a0 <cfsetispeed@plt>
test   %rax,%rax
js     1332 <getttyfd+0x1b2>
mov    %rsp,%rdi
mov    %r14d,%esi
call   1040 <cfsetospeed@plt>
test   %rax,%rax
js     1332 <getttyfd+0x1b2>
mov    0x2ce7(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1070 <tcsetattr@plt>
test   %rax,%rax
jns    1360 <getttyfd+0x1e0>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
lea    0xd57(%rip),%rsi
jmp    1354 <getttyfd+0x1d4>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcec(%rip),%rsi
jmp    1326 <getttyfd+0x1a6>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    135b <getttyfd+0x1db>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
lea    0xd02(%rip),%rsi
jmp    1354 <getttyfd+0x1d4>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
lea    0xcd5(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
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*, i64 }
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"failed to open port %s\0A\00"
@.str.1 = [17 x i8] c"%s is not a tty\0A\00"
@.str.2 = [27 x i8] c"failed to get port config\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@IXON = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@.str.3 = [21 x i8] c"failed to set speed\0A\00"
@TCSAFLUSH = global i32 0
@.str.4 = [24 x i8] c"failed to apply config\0A\00"
define i32 @getttyfd(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 i32, i32* %5
%10 = call i32 @convertspeed(i32 %9)
store i32 %10, i32* %8
%11 = load i8*, i8** %4
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_NOCTTY
%14 = or i32 %12, %13
%15 = load i32, i32* @O_NDELAY
%16 = or i32 %14, %15
%17 = call i32 @open(i8* %11, i32 %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %4
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 -1, i32* %3
br label %112
24: ; preds = %2
%25 = load i32, i32* %7
%26 = call i32 @isatty(i32 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %4
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 -1, i32* %3
br label %112
32: ; preds = %24
%33 = load i32, i32* %7
%34 = call i64 @tcgetattr(i32 %33, %struct.termios* %6)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %112
39: ; preds = %32
%40 = load i32, i32* @IGNBRK
%41 = load i32, i32* @BRKINT
%42 = or i32 %40, %41
%43 = load i32, i32* @ICRNL
%44 = or i32 %42, %43
%45 = load i32, i32* @INLCR
%46 = or i32 %44, %45
%47 = load i32, i32* @PARMRK
%48 = or i32 %46, %47
%49 = load i32, i32* @INPCK
%50 = or i32 %48, %49
%51 = load i32, i32* @ISTRIP
%52 = or i32 %50, %51
%53 = load i32, i32* @IXON
%54 = or i32 %52, %53
%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 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 4
store i64 0, i64* %59
%60 = load i32, i32* @ECHO
%61 = load i32, i32* @ECHONL
%62 = or i32 %60, %61
%63 = load i32, i32* @ICANON
%64 = or i32 %62, %63
%65 = load i32, i32* @IEXTEN
%66 = or i32 %64, %65
%67 = load i32, i32* @ISIG
%68 = or i32 %66, %67
%69 = xor i32 %68, -1
%70 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%71 = load i32, i32* %70
%72 = and i32 %71, %69
store i32 %72, i32* %70
%73 = load i32, i32* @CSIZE
%74 = load i32, i32* @PARENB
%75 = or i32 %73, %74
%76 = xor i32 %75, -1
%77 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%78 = load i32, i32* %77
%79 = and i32 %78, %76
store i32 %79, i32* %77
%80 = load i32, i32* @CS8
%81 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 2
%82 = load i32, i32* %81
%83 = or i32 %82, %80
store i32 %83, i32* %81
%84 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%85 = load i32*, i32** %84
%86 = load i64, i64* @VMIN
%87 = getelementptr inbounds i32, i32* %85, i64 %86
store i32 1, i32* %87
%88 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 3
%89 = load i32*, i32** %88
%90 = load i64, i64* @VTIME
%91 = getelementptr inbounds i32, i32* %89, i64 %90
store i32 0, i32* %91
%92 = load i32, i32* %8
%93 = call i64 @cfsetispeed(%struct.termios* %6, i32 %92)
%94 = icmp slt i64 %93, 0
br i1 %94, label %99, label %95
95: ; preds = %39
%96 = load i32, i32* %8
%97 = call i64 @cfsetospeed(%struct.termios* %6, i32 %96)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %95, %39
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %112
102: ; preds = %95
%103 = load i32, i32* %7
%104 = load i32, i32* @TCSAFLUSH
%105 = call i64 @tcsetattr(i32 %103, i32 %104, %struct.termios* %6)
%106 = icmp slt i64 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %102
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %112
110: ; preds = %102
%111 = load i32, i32* %7
store i32 %111, i32* %3
br label %112
112: ; preds = %110, %107, %99, %36, %28, %20
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32*, i64 }
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NDELAY = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"failed to open port %s\0A\00"
@.str.1 = [17 x i8] c"%s is not a tty\0A\00"
@.str.2 = [27 x i8] c"failed to get port config\0A\00"
@IGNBRK = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@IXON = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@.str.3 = [21 x i8] c"failed to set speed\0A\00"
@TCSAFLUSH = global i32 0
@.str.4 = [24 x i8] c"failed to apply config\0A\00"
define i32 @getttyfd(i8* %0, i32 %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = tail call i32 @convertspeed(i32 %1)
%6 = load i32, i32* @O_RDWR
%7 = load i32, i32* @O_NOCTTY
%8 = or i32 %7, %6
%9 = load i32, i32* @O_NDELAY
%10 = or i32 %8, %9
%11 = tail call i32 @open(i8* %0, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %92
16: ; preds = %2
%17 = tail call i32 @isatty(i32 %11)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %92
22: ; preds = %16
%23 = call i64 @tcgetattr(i32 %11, %struct.termios* %3)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %92
28: ; preds = %22
%29 = load i32, i32* @IGNBRK
%30 = load i32, i32* @BRKINT
%31 = or i32 %30, %29
%32 = load i32, i32* @ICRNL
%33 = or i32 %31, %32
%34 = load i32, i32* @INLCR
%35 = or i32 %33, %34
%36 = load i32, i32* @PARMRK
%37 = or i32 %35, %36
%38 = load i32, i32* @INPCK
%39 = or i32 %37, %38
%40 = load i32, i32* @ISTRIP
%41 = or i32 %39, %40
%42 = load i32, i32* @IXON
%43 = or i32 %41, %42
%44 = xor i32 %43, -1
%45 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%46 = load i32, i32* %45
%47 = and i32 %46, %44
store i32 %47, i32* %45
%48 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 4
store i64 0, i64* %48
%49 = load i32, i32* @ECHO
%50 = load i32, i32* @ECHONL
%51 = or i32 %50, %49
%52 = load i32, i32* @ICANON
%53 = or i32 %51, %52
%54 = load i32, i32* @IEXTEN
%55 = or i32 %53, %54
%56 = load i32, i32* @ISIG
%57 = or i32 %55, %56
%58 = xor i32 %57, -1
%59 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%60 = load i32, i32* %59
%61 = and i32 %60, %58
store i32 %61, i32* %59
%62 = load i32, i32* @CSIZE
%63 = load i32, i32* @PARENB
%64 = or i32 %63, %62
%65 = xor i32 %64, -1
%66 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%67 = load i32, i32* %66
%68 = and i32 %67, %65
%69 = load i32, i32* @CS8
%70 = or i32 %69, %68
store i32 %70, i32* %66
%71 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%72 = load i32*, i32** %71
%73 = load i64, i64* @VMIN
%74 = getelementptr inbounds i32, i32* %72, i64 %73
store i32 1, i32* %74
%75 = load i64, i64* @VTIME
%76 = getelementptr inbounds i32, i32* %72, i64 %75
store i32 0, i32* %76
%77 = call i64 @cfsetispeed(%struct.termios* %3, i32 %5)
%78 = icmp slt i64 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %28
%80 = call i64 @cfsetospeed(%struct.termios* %3, i32 %5)
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79, %28
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %92
85: ; preds = %79
%86 = load i32, i32* @TCSAFLUSH
%87 = call i64 @tcsetattr(i32 %11, i32 %86, %struct.termios* %3)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %85, %89, %82, %25, %19, %13
%93 = phi i32 [ -1, %13 ], [ -1, %25 ], [ -1, %82 ], [ -1, %89 ], [ -1, %19 ], [ %11, %85 ]
ret i32 %93
}