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

/* Variables and functions */
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B230400;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B57600;
int /*<<< orphan*/ B9600;
int /*<<< orphan*/ CLOCAL;
int /*<<< orphan*/ CRTSCTS;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ HUPCL;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ TIOCMBIS;
int TIOCM_DTR;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ stderr;
int tcflush(int, int /*<<< orphan*/);
int tcgetattr(int, struct termios *);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ usleep(int);
int stty_telos(int fd, int baudrate) {
  struct termios tty;
  speed_t speed;
  int i;
  switch (baudrate) {
  case 9600:
    speed = B9600;
    break;
  case 19200:
    speed = B19200;
    break;
  case 38400:
    speed = B38400;
    break;
  case 57600:
    speed = B57600;
    break;
  case 115200:
    speed = B115200;
    break;
  case 230400:
    speed = B230400;
    break;
  default:
    fprintf(stderr, "unknown baudrate %d", baudrate);
    return -1;
  }
  if (tcflush(fd, TCIOFLUSH) == -1)
    fprintf(stderr, "Error: tcflush()\n");
  if (tcgetattr(fd, &tty) == -1)
    fprintf(stderr, "Error: tcgetattr()\n");
  cfmakeraw(&tty);
  tty.c_cc[VTIME] = 0;
  tty.c_cc[VMIN] = 0;
  tty.c_cflag &= ~CRTSCTS;
  tty.c_cflag &= ~HUPCL;
  tty.c_cflag &= ~CLOCAL;
  cfsetispeed(&tty, speed);
  cfsetospeed(&tty, speed);
  if (tcsetattr(fd, TCSAFLUSH, &tty) == -1)
    fprintf(stderr, "Error: tcsetattr()\n");
  if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1)
    fprintf(stderr, "Error:fcntl()\n");
  tty.c_cflag |= CLOCAL;
  if (tcsetattr(fd, TCSAFLUSH, &tty) == -1)
    fprintf(stderr, "Error: tcsetattr()\n");
  i = TIOCM_DTR;
  if (ioctl(fd, TIOCMBIS, &i) == -1)
    fprintf(stderr, "Error: ioctl()\n");
  usleep(10 * 1000);
  if (tcflush(fd, TCIOFLUSH) == -1)
    fprintf(stderr, "Error: tcflush()\n");
  return 0;
}


x86 assembly (clang, -O0):
<stty_telos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x2580,%eax
je     1223 <stty_telos+0x83>
jmp    11c4 <stty_telos+0x24>
mov    -0x2c(%rbp),%eax
sub    $0x4b00,%eax
je     1234 <stty_telos+0x94>
jmp    11d7 <stty_telos+0x37>
mov    -0x2c(%rbp),%eax
sub    $0x9600,%eax
je     1245 <stty_telos+0xa5>
jmp    11ea <stty_telos+0x4a>
mov    -0x2c(%rbp),%eax
sub    $0xe100,%eax
je     1256 <stty_telos+0xb6>
jmp    11fd <stty_telos+0x5d>
mov    -0x2c(%rbp),%eax
sub    $0x1c200,%eax
je     1267 <stty_telos+0xc7>
jmp    1210 <stty_telos+0x70>
mov    -0x2c(%rbp),%eax
sub    $0x38400,%eax
je     1278 <stty_telos+0xd8>
jmp    1289 <stty_telos+0xe9>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2ce1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    12af <stty_telos+0x10f>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c5 <stty_telos+0x325>
mov    -0x8(%rbp),%edi
mov    0x2cd7(%rip),%rax
mov    (%rax),%esi
call   1050 <tcflush@plt>
cmp    $0xffffffff,%eax
jne    12e0 <stty_telos+0x140>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1090 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    130c <stty_telos+0x16c>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x20(%rbp),%rdi
call   1080 <cfmakeraw@plt>
mov    -0x18(%rbp),%rax
mov    0x2c60(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    0x2c8a(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c20(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c1e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2bec(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   10b0 <cfsetispeed@plt>
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   1040 <cfsetospeed@plt>
mov    -0x8(%rbp),%edi
mov    0x2c47(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   10a0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    13c4 <stty_telos+0x224>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
lea    0xc7d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    0x2bca(%rip),%rax
mov    (%rax),%esi
mov    0x2c01(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    13fe <stty_telos+0x25e>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
lea    0xc57(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b53(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bc9(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   10a0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    1442 <stty_telos+0x2a2>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xbff(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2b50(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1483 <stty_telos+0x2e3>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x2710,%edi
call   10c0 <usleep@plt>
mov    -0x8(%rbp),%edi
mov    0x2af9(%rip),%rax
mov    (%rax),%esi
call   1050 <tcflush@plt>
cmp    $0xffffffff,%eax
jne    14be <stty_telos+0x31e>
mov    0x2af2(%rip),%rax
mov    (%rax),%edi
lea    0xb5d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stty_telos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%edx
mov    %edi,%ebx
cmp    $0xe0ff,%esi
jg     11dd <stty_telos+0x3d>
cmp    $0x2580,%edx
je     1202 <stty_telos+0x62>
cmp    $0x4b00,%edx
je     120b <stty_telos+0x6b>
cmp    $0x9600,%edx
jne    13f7 <stty_telos+0x257>
mov    0x2d75(%rip),%rax
jmp    1224 <stty_telos+0x84>
cmp    $0xe100,%edx
je     1214 <stty_telos+0x74>
cmp    $0x1c200,%edx
je     121d <stty_telos+0x7d>
cmp    $0x38400,%edx
jne    13f7 <stty_telos+0x257>
mov    0x2d60(%rip),%rax
jmp    1224 <stty_telos+0x84>
mov    0x2dbf(%rip),%rax
jmp    1224 <stty_telos+0x84>
mov    0x2dde(%rip),%rax
jmp    1224 <stty_telos+0x84>
mov    0x2d9d(%rip),%rax
jmp    1224 <stty_telos+0x84>
mov    0x2d64(%rip),%rax
mov    (%rax),%r14d
mov    0x2d62(%rip),%r15
mov    (%r15),%esi
mov    %ebx,%edi
call   1050 <tcflush@plt>
cmp    $0xffffffff,%eax
jne    1254 <stty_telos+0xb4>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
call   1090 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    127c <stty_telos+0xdc>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <cfmakeraw@plt>
mov    0x18(%rsp),%rax
mov    0x2ceb(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d19(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
mov    0x2cb6(%rip),%rcx
or     (%rcx),%eax
mov    0x2c8d(%rip),%r12
or     (%r12),%eax
not    %eax
and    %eax,0x10(%rsp)
mov    %rbp,%rdi
mov    %r14d,%esi
call   10b0 <cfsetispeed@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <cfsetospeed@plt>
mov    0x2cee(%rip),%r14
mov    (%r14),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
call   10a0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    131b <stty_telos+0x17b>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
lea    0xd26(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%esi
mov    0x2cad(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    1350 <stty_telos+0x1b0>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
lea    0xd05(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r12),%eax
or     %eax,0x10(%rsp)
mov    (%r14),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   10a0 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    1383 <stty_telos+0x1e3>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
lea    0xcbe(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c46(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2c11(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    13c1 <stty_telos+0x221>
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x2710,%edi
call   10c0 <usleep@plt>
mov    (%r15),%esi
mov    %ebx,%edi
call   1050 <tcflush@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
jne    1413 <stty_telos+0x273>
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
lea    0xc28(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1413 <stty_telos+0x273>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
lea    0xbf9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i64* }
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"unknown baudrate %d\00"
@TCIOFLUSH = global i32 0
@.str.1 = [18 x i8] c"Error: tcflush()\0A\00"
@.str.2 = [20 x i8] c"Error: tcgetattr()\0A\00"
@VTIME = global i64 0
@VMIN = global i64 0
@CRTSCTS = global i32 0
@HUPCL = global i32 0
@CLOCAL = global i32 0
@TCSAFLUSH = global i32 0
@.str.3 = [20 x i8] c"Error: tcsetattr()\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [15 x i8] c"Error:fcntl()\0A\00"
@TIOCM_DTR = global i32 0
@TIOCMBIS = global i32 0
@.str.5 = [16 x i8] c"Error: ioctl()\0A\00"
define i32 @stty_telos(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.termios
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = load i32, i32* %5
switch i32 %9, label %22 [
i32 9600, label %10
i32 19200, label %12
i32 38400, label %14
i32 57600, label %16
i32 115200, label %18
i32 230400, label %20
]
10: ; preds = %2
%11 = load i32, i32* @B9600
store i32 %11, i32* %7
br label %26
12: ; preds = %2
%13 = load i32, i32* @B19200
store i32 %13, i32* %7
br label %26
14: ; preds = %2
%15 = load i32, i32* @B38400
store i32 %15, i32* %7
br label %26
16: ; preds = %2
%17 = load i32, i32* @B57600
store i32 %17, i32* %7
br label %26
18: ; preds = %2
%19 = load i32, i32* @B115200
store i32 %19, i32* %7
br label %26
20: ; preds = %2
%21 = load i32, i32* @B230400
store i32 %21, i32* %7
br label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i32, i32* %5
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %24)
store i32 -1, i32* %3
br label %117
26: ; preds = %20, %18, %16, %14, %12, %10
%27 = load i32, i32* %4
%28 = load i32, i32* @TCIOFLUSH
%29 = call i32 @tcflush(i32 %27, i32 %28)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* %4
%36 = call i32 @tcgetattr(i32 %35, %struct.termios* %6)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %38, %34
%42 = call i32 @cfmakeraw(%struct.termios* %6)
%43 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%44 = load i64*, i64** %43
%45 = load i64, i64* @VTIME
%46 = getelementptr inbounds i64, i64* %44, i64 %45
store i64 0, i64* %46
%47 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 1
%48 = load i64*, i64** %47
%49 = load i64, i64* @VMIN
%50 = getelementptr inbounds i64, i64* %48, i64 %49
store i64 0, i64* %50
%51 = load i32, i32* @CRTSCTS
%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* @HUPCL
%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* @CLOCAL
%62 = xor i32 %61, -1
%63 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%64 = load i32, i32* %63
%65 = and i32 %64, %62
store i32 %65, i32* %63
%66 = load i32, i32* %7
%67 = call i32 @cfsetispeed(%struct.termios* %6, i32 %66)
%68 = load i32, i32* %7
%69 = call i32 @cfsetospeed(%struct.termios* %6, i32 %68)
%70 = load i32, i32* %4
%71 = load i32, i32* @TCSAFLUSH
%72 = call i32 @tcsetattr(i32 %70, i32 %71, %struct.termios* %6)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %41
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %74, %41
%78 = load i32, i32* %4
%79 = load i32, i32* @F_SETFL
%80 = load i32, i32* @O_NONBLOCK
%81 = call i32 @fcntl(i32 %78, i32 %79, i32 %80)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %86
83: ; preds = %77
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %86
86: ; preds = %83, %77
%87 = load i32, i32* @CLOCAL
%88 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%89 = load i32, i32* %88
%90 = or i32 %89, %87
store i32 %90, i32* %88
%91 = load i32, i32* %4
%92 = load i32, i32* @TCSAFLUSH
%93 = call i32 @tcsetattr(i32 %91, i32 %92, %struct.termios* %6)
%94 = icmp eq i32 %93, -1
br i1 %94, label %95, label %98
95: ; preds = %86
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %98
98: ; preds = %95, %86
%99 = load i32, i32* @TIOCM_DTR
store i32 %99, i32* %8
%100 = load i32, i32* %4
%101 = load i32, i32* @TIOCMBIS
%102 = call i32 @ioctl(i32 %100, i32 %101, i32* %8)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %107
104: ; preds = %98
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %107
107: ; preds = %104, %98
%108 = call i32 @usleep(i32 10000)
%109 = load i32, i32* %4
%110 = load i32, i32* @TCIOFLUSH
%111 = call i32 @tcflush(i32 %109, i32 %110)
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %116
113: ; preds = %107
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %116
116: ; preds = %113, %107
store i32 0, i32* %3
br label %117
117: ; preds = %116, %22
%118 = load i32, i32* %3
ret i32 %118
}

LLVM IR (-O2):
%struct.termios = type { i32, i64* }
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B57600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"unknown baudrate %d\00"
@TCIOFLUSH = global i32 0
@.str.1 = [18 x i8] c"Error: tcflush()\0A\00"
@.str.2 = [20 x i8] c"Error: tcgetattr()\0A\00"
@VTIME = global i64 0
@VMIN = global i64 0
@CRTSCTS = global i32 0
@HUPCL = global i32 0
@CLOCAL = global i32 0
@TCSAFLUSH = global i32 0
@.str.3 = [20 x i8] c"Error: tcsetattr()\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [15 x i8] c"Error:fcntl()\0A\00"
@TIOCM_DTR = global i32 0
@TIOCMBIS = global i32 0
@.str.5 = [16 x i8] c"Error: ioctl()\0A\00"
define i32 @stty_telos(i32 %0, i32 %1) {
%3 = alloca %struct.termios
%4 = alloca i32
%5 = bitcast %struct.termios* %3 to i8*
%6 = bitcast i32* %4 to i8*
switch i32 %1, label %12 [
i32 9600, label %15
i32 19200, label %7
i32 38400, label %8
i32 57600, label %9
i32 115200, label %10
i32 230400, label %11
]
7: ; preds = %2
br label %15
8: ; preds = %2
br label %15
9: ; preds = %2
br label %15
10: ; preds = %2
br label %15
11: ; preds = %2
br label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %89
15: ; preds = %2, %11, %10, %9, %8, %7
%16 = phi i32* [ @B230400, %11 ], [ @B115200, %10 ], [ @B57600, %9 ], [ @B38400, %8 ], [ @B19200, %7 ], [ @B9600, %2 ]
%17 = load i32, i32* %16
%18 = load i32, i32* @TCIOFLUSH
%19 = tail call i32 @tcflush(i32 %0, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %15
%25 = call i32 @tcgetattr(i32 %0, %struct.termios* %3)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %27, %24
%31 = call i32 @cfmakeraw(%struct.termios* %3)
%32 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%33 = load i64*, i64** %32
%34 = load i64, i64* @VTIME
%35 = getelementptr inbounds i64, i64* %33, i64 %34
store i64 0, i64* %35
%36 = load i64, i64* @VMIN
%37 = getelementptr inbounds i64, i64* %33, i64 %36
store i64 0, i64* %37
%38 = load i32, i32* @CRTSCTS
%39 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%40 = load i32, i32* %39
%41 = load i32, i32* @HUPCL
%42 = or i32 %38, %41
%43 = load i32, i32* @CLOCAL
%44 = or i32 %42, %43
%45 = xor i32 %44, -1
%46 = and i32 %40, %45
store i32 %46, i32* %39
%47 = call i32 @cfsetispeed(%struct.termios* %3, i32 %17)
%48 = call i32 @cfsetospeed(%struct.termios* %3, i32 %17)
%49 = load i32, i32* @TCSAFLUSH
%50 = call i32 @tcsetattr(i32 %0, i32 %49, %struct.termios* %3)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %55
52: ; preds = %30
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %52, %30
%56 = load i32, i32* @F_SETFL
%57 = load i32, i32* @O_NONBLOCK
%58 = call i32 @fcntl(i32 %0, i32 %56, i32 %57)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %60, %55
%64 = load i32, i32* @CLOCAL
%65 = load i32, i32* %39
%66 = or i32 %65, %64
store i32 %66, i32* %39
%67 = load i32, i32* @TCSAFLUSH
%68 = call i32 @tcsetattr(i32 %0, i32 %67, %struct.termios* %3)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %73
70: ; preds = %63
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %70, %63
%74 = load i32, i32* @TIOCM_DTR
store i32 %74, i32* %4
%75 = load i32, i32* @TIOCMBIS
%76 = call i32 @ioctl(i32 %0, i32 %75, i32* %4)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %81
78: ; preds = %73
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %78, %73
%82 = call i32 @usleep(i32 10000)
%83 = load i32, i32* @TCIOFLUSH
%84 = call i32 @tcflush(i32 %0, i32 %83)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %89
86: ; preds = %81
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %89
89: ; preds = %81, %86, %12
%90 = phi i32 [ -1, %12 ], [ 0, %86 ], [ 0, %81 ]
ret i32 %90
}