#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_cflag;
  int *c_cc;
  scalar_t__ c_oflag;
  scalar_t__ c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ B9600;
int CMSPAR;
int CS5;
int CS6;
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetspeed(struct termios *, int /*<<< orphan*/);
int errno;
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, char *);
char *strerror(int);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int set_interface_attribs(int fd, int speed, int data_bits, int parity,
                          int stop_bits) {
  struct termios tty;
  memset(&tty, 0, sizeof(tty));
  if (tcgetattr(fd, &tty) != 0) {
    printf("error %d from tcgetattr: %s\n", errno, strerror(errno));
    return -1;
  }
  tty.c_cflag &= ~CSIZE;
  switch (data_bits) {
  case 5:
    tty.c_cflag |= CS5;
    break;
  case 6:
    tty.c_cflag |= CS6;
    break;
  case 7:
    tty.c_cflag |= CS7;
    break;
  case 8:
  default:
    tty.c_cflag |= CS8;
    break;
  }
  switch (parity) {
  case 'N':
  case 'n':
  default:
    tty.c_cflag &= ~(PARENB | PARODD | CMSPAR);
    break;
  case 'E':
  case 'e':
    tty.c_cflag |= PARENB;
    tty.c_cflag &= ~(PARODD | CMSPAR);
    break;
  case 'O':
  case 'o':
    tty.c_cflag |= PARENB | PARODD;
    tty.c_cflag &= ~CMSPAR;
    break;
  case 'M':
  case 'm':
    tty.c_cflag |= PARENB | PARODD | CMSPAR;
    break;
  case 'S':
  case 's':
    tty.c_cflag |= PARENB | CMSPAR;
    tty.c_cflag &= ~PARODD;
    break;
  }
  if (stop_bits == 2)
    tty.c_cflag |= CSTOPB;
  else
    tty.c_cflag &= ~CSTOPB;
  cfmakeraw(&tty);
  cfsetspeed(&tty, B9600);
  tty.c_lflag = 0;
  tty.c_oflag = 0;
  tty.c_cc[VMIN] = 0;
  tty.c_cc[VTIME] = 5;
  tcflush(fd, TCIFLUSH);
  if (tcsetattr(fd, TCSANOW, &tty) != 0) {
    printf("error %d from tcsetattr: %s\n", errno, strerror(errno));
    return -1;
  }
}


x86 assembly (clang, -O0):
<set_interface_attribs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x38(%rbp),%rsi
call   1080 <tcgetattr@plt>
cmp    $0x0,%rax
je     11f6 <set_interface_attribs+0x76>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x3c(%rbp),%esi
mov    %rax,%rdx
lea    0xee7(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    146f <set_interface_attribs+0x2ef>
mov    0x2db3(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x38(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%eax
add    $0xfffffffb,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x3,%eax
ja     1273 <set_interface_attribs+0xf3>
mov    -0x48(%rbp),%rax
lea    0xdd7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1282 <set_interface_attribs+0x102>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1282 <set_interface_attribs+0x102>
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1282 <set_interface_attribs+0x102>
jmp    1273 <set_interface_attribs+0xf3>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x2e,%eax
ja     12b0 <set_interface_attribs+0x130>
mov    -0x50(%rbp),%rax
lea    0xd6e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    12b0 <set_interface_attribs+0x130>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    0x2d18(%rip),%rcx
or     (%rcx),%eax
mov    0x2cbf(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1387 <set_interface_attribs+0x207>
mov    0x2d08(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2ce9(%rip),%rax
mov    (%rax),%eax
mov    0x2c90(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1387 <set_interface_attribs+0x207>
mov    0x2cd9(%rip),%rax
mov    (%rax),%eax
mov    0x2cc0(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c61(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1387 <set_interface_attribs+0x207>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    0x2c91(%rip),%rcx
or     (%rcx),%eax
mov    0x2c38(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1387 <set_interface_attribs+0x207>
mov    0x2c84(%rip),%rax
mov    (%rax),%eax
mov    0x2c1b(%rip),%rcx
or     (%rcx),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    13a5 <set_interface_attribs+0x225>
mov    0x2be0(%rip),%rax
mov    (%rax),%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    13b7 <set_interface_attribs+0x237>
mov    0x2bcc(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x38(%rbp),%rdi
call   1070 <cfmakeraw@plt>
mov    0x2c09(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdi
call   1060 <cfsetspeed@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2bcb(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    0x2b8e(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    -0x8(%rbp),%edi
mov    0x2b8a(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
mov    -0x8(%rbp),%edi
mov    0x2bb9(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1090 <tcsetattr@plt>
cmp    $0x0,%rax
je     146f <set_interface_attribs+0x2ef>
mov    0x2b55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x54(%rbp),%esi
mov    %rax,%rdx
lea    0xc86(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_interface_attribs>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %edi,%r15d
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
call   1080 <tcgetattr@plt>
test   %rax,%rax
je     11d5 <set_interface_attribs+0x55>
mov    0x2de0(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10a0 <strerror@plt>
lea    0xeec(%rip),%rdi
jmp    1360 <set_interface_attribs+0x1e0>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
not    %eax
and    (%rsp),%eax
add    $0xfffffffb,%ebx
cmp    $0x2,%ebx
ja     11fb <set_interface_attribs+0x7b>
movslq %ebx,%rcx
lea    0x2bb3(%rip),%rdx
mov    (%rdx,%rcx,8),%rcx
jmp    1202 <set_interface_attribs+0x82>
mov    0x2dc6(%rip),%rcx
or     (%rcx),%eax
add    $0xffffffbb,%r12d
cmp    $0x2e,%r12d
ja     129a <set_interface_attribs+0x11a>
lea    0xde7(%rip),%rcx
movslq (%rcx,%r12,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    0x2dbf(%rip),%rcx
or     (%rcx),%eax
mov    0x2da6(%rip),%rcx
mov    0x2d57(%rip),%rdx
mov    (%rdx),%edx
jmp    12b3 <set_interface_attribs+0x133>
mov    0x2da4(%rip),%rcx
mov    0x2d8d(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d3a(%rip),%rcx
or     (%rcx),%edx
or     %edx,%eax
jmp    12b9 <set_interface_attribs+0x139>
mov    0x2d85(%rip),%rcx
mov    0x2d6e(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
or     %eax,%edx
mov    0x2d19(%rip),%rax
jmp    1294 <set_interface_attribs+0x114>
mov    0x2d68(%rip),%rcx
mov    0x2d09(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
or     %eax,%edx
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
not    %eax
jmp    12b7 <set_interface_attribs+0x137>
mov    0x2d47(%rip),%rcx
mov    0x2d30(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2cdd(%rip),%rcx
or     (%rcx),%edx
not    %edx
and    %edx,%eax
mov    0x2cc0(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%edx
not    %edx
and    %eax,%edx
or     %ecx,%eax
cmp    $0x2,%r14d
cmovne %edx,%eax
mov    %eax,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <cfmakeraw@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <cfsetspeed@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rax
mov    0x2cbc(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2c83(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1030 <tcflush@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %rbx,%rdx
call   1090 <tcsetattr@plt>
test   %rax,%rax
je     136a <set_interface_attribs+0x1ea>
mov    0x2c50(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10a0 <strerror@plt>
lea    0xd79(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32*, i64, i64 }
@.str = [29 x i8] c"error %d from tcgetattr: %s\0A\00"
@errno = global i32 0
@CSIZE = global i32 0
@CS5 = global i32 0
@CS6 = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@CMSPAR = global i32 0
@CSTOPB = global i32 0
@B9600 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.1 = [29 x i8] c"error %d from tcsetattr: %s\0A\00"
define i32 @set_interface_attribs(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.termios
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = call i32 @memset(%struct.termios* %12, i32 0, i32 32)
%14 = load i32, i32* %7
%15 = call i64 @tcgetattr(i32 %14, %struct.termios* %12)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %5
%18 = load i32, i32* @errno
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %20)
store i32 -1, i32* %6
br label %148
22: ; preds = %5
%23 = load i32, i32* @CSIZE
%24 = xor i32 %23, -1
%25 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%26 = load i32, i32* %25
%27 = and i32 %26, %24
store i32 %27, i32* %25
%28 = load i32, i32* %9
switch i32 %28, label %45 [
i32 5, label %29
i32 6, label %34
i32 7, label %39
i32 8, label %44
]
29: ; preds = %22
%30 = load i32, i32* @CS5
%31 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%32 = load i32, i32* %31
%33 = or i32 %32, %30
store i32 %33, i32* %31
br label %50
34: ; preds = %22
%35 = load i32, i32* @CS6
%36 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%37 = load i32, i32* %36
%38 = or i32 %37, %35
store i32 %38, i32* %36
br label %50
39: ; preds = %22
%40 = load i32, i32* @CS7
%41 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%42 = load i32, i32* %41
%43 = or i32 %42, %40
store i32 %43, i32* %41
br label %50
44: ; preds = %22
br label %45
45: ; preds = %22, %44
%46 = load i32, i32* @CS8
%47 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%48 = load i32, i32* %47
%49 = or i32 %48, %46
store i32 %49, i32* %47
br label %50
50: ; preds = %45, %39, %34, %29
%51 = load i32, i32* %10
switch i32 %51, label %53 [
i32 78, label %52
i32 110, label %52
i32 69, label %63
i32 101, label %63
i32 79, label %75
i32 111, label %75
i32 77, label %87
i32 109, label %87
i32 83, label %96
i32 115, label %96
]
52: ; preds = %50, %50
br label %53
53: ; preds = %50, %52
%54 = load i32, i32* @PARENB
%55 = load i32, i32* @PARODD
%56 = or i32 %54, %55
%57 = load i32, i32* @CMSPAR
%58 = or i32 %56, %57
%59 = xor i32 %58, -1
%60 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%61 = load i32, i32* %60
%62 = and i32 %61, %59
store i32 %62, i32* %60
br label %108
63: ; preds = %50, %50
%64 = load i32, i32* @PARENB
%65 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%66 = load i32, i32* %65
%67 = or i32 %66, %64
store i32 %67, i32* %65
%68 = load i32, i32* @PARODD
%69 = load i32, i32* @CMSPAR
%70 = or i32 %68, %69
%71 = xor i32 %70, -1
%72 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%73 = load i32, i32* %72
%74 = and i32 %73, %71
store i32 %74, i32* %72
br label %108
75: ; preds = %50, %50
%76 = load i32, i32* @PARENB
%77 = load i32, i32* @PARODD
%78 = or i32 %76, %77
%79 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%80 = load i32, i32* %79
%81 = or i32 %80, %78
store i32 %81, i32* %79
%82 = load i32, i32* @CMSPAR
%83 = xor i32 %82, -1
%84 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%85 = load i32, i32* %84
%86 = and i32 %85, %83
store i32 %86, i32* %84
br label %108
87: ; preds = %50, %50
%88 = load i32, i32* @PARENB
%89 = load i32, i32* @PARODD
%90 = or i32 %88, %89
%91 = load i32, i32* @CMSPAR
%92 = or i32 %90, %91
%93 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%94 = load i32, i32* %93
%95 = or i32 %94, %92
store i32 %95, i32* %93
br label %108
96: ; preds = %50, %50
%97 = load i32, i32* @PARENB
%98 = load i32, i32* @CMSPAR
%99 = or i32 %97, %98
%100 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%101 = load i32, i32* %100
%102 = or i32 %101, %99
store i32 %102, i32* %100
%103 = load i32, i32* @PARODD
%104 = xor i32 %103, -1
%105 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%106 = load i32, i32* %105
%107 = and i32 %106, %104
store i32 %107, i32* %105
br label %108
108: ; preds = %96, %87, %75, %63, %53
%109 = load i32, i32* %11
%110 = icmp eq i32 %109, 2
br i1 %110, label %111, label %116
111: ; preds = %108
%112 = load i32, i32* @CSTOPB
%113 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%114 = load i32, i32* %113
%115 = or i32 %114, %112
store i32 %115, i32* %113
br label %122
116: ; preds = %108
%117 = load i32, i32* @CSTOPB
%118 = xor i32 %117, -1
%119 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%120 = load i32, i32* %119
%121 = and i32 %120, %118
store i32 %121, i32* %119
br label %122
122: ; preds = %116, %111
%123 = call i32 @cfmakeraw(%struct.termios* %12)
%124 = load i32, i32* @B9600
%125 = call i32 @cfsetspeed(%struct.termios* %12, i32 %124)
%126 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 3
store i64 0, i64* %126
%127 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 2
store i64 0, i64* %127
%128 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%129 = load i32*, i32** %128
%130 = load i64, i64* @VMIN
%131 = getelementptr inbounds i32, i32* %129, i64 %130
store i32 0, i32* %131
%132 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%133 = load i32*, i32** %132
%134 = load i64, i64* @VTIME
%135 = getelementptr inbounds i32, i32* %133, i64 %134
store i32 5, i32* %135
%136 = load i32, i32* %7
%137 = load i32, i32* @TCIFLUSH
%138 = call i32 @tcflush(i32 %136, i32 %137)
%139 = load i32, i32* %7
%140 = load i32, i32* @TCSANOW
%141 = call i64 @tcsetattr(i32 %139, i32 %140, %struct.termios* %12)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %148
143: ; preds = %122
%144 = load i32, i32* @errno
%145 = load i32, i32* @errno
%146 = call i8* @strerror(i32 %145)
%147 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %144, i8* %146)
store i32 -1, i32* %6
br label %148
148: ; preds = %17, %143, %122
%149 = load i32, i32* %6
ret i32 %149
}

LLVM IR (-O2):
%struct.termios = type { i32, i32*, i64, i64 }
@.str = [29 x i8] c"error %d from tcgetattr: %s\0A\00"
@errno = global i32 0
@CSIZE = global i32 0
@CS5 = global i32 0
@CS6 = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@CMSPAR = global i32 0
@CSTOPB = global i32 0
@B9600 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.1 = [29 x i8] c"error %d from tcsetattr: %s\0A\00"
@switch.table.set_interface_attribs = [3 x i32*] [i32* @CS5, i32* @CS6, i32* @CS7]
define i32 @set_interface_attribs(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.termios
%7 = bitcast %struct.termios* %6 to i8*
%8 = call i32 @memset(%struct.termios* %6, i32 0, i32 32)
%9 = call i64 @tcgetattr(i32 %0, %struct.termios* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
br label %98
15: ; preds = %5
%16 = load i32, i32* @CSIZE
%17 = xor i32 %16, -1
%18 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, %17
%21 = add i32 %2, -5
%22 = icmp ult i32 %21, 3
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = sext i32 %21 to i64
%25 = getelementptr inbounds [3 x i32*], [3 x i32*]* @switch.table.set_interface_attribs, i64 0, i64 %24
%26 = load i32*, i32** %25
br label %27
27: ; preds = %15, %23
%28 = phi i32* [ %26, %23 ], [ @CS8, %15 ]
%29 = load i32, i32* %28
%30 = or i32 %29, %20
switch i32 %3, label %31 [
i32 115, label %62
i32 83, label %62
i32 69, label %39
i32 101, label %39
i32 79, label %47
i32 111, label %47
i32 77, label %55
i32 109, label %55
]
31: ; preds = %27
%32 = load i32, i32* @PARENB
%33 = load i32, i32* @PARODD
%34 = or i32 %33, %32
%35 = load i32, i32* @CMSPAR
%36 = or i32 %34, %35
%37 = xor i32 %36, -1
%38 = and i32 %30, %37
br label %70
39: ; preds = %27, %27
%40 = load i32, i32* @PARENB
%41 = or i32 %30, %40
%42 = load i32, i32* @PARODD
%43 = load i32, i32* @CMSPAR
%44 = or i32 %43, %42
%45 = xor i32 %44, -1
%46 = and i32 %41, %45
br label %70
47: ; preds = %27, %27
%48 = load i32, i32* @PARENB
%49 = load i32, i32* @PARODD
%50 = or i32 %49, %48
%51 = or i32 %50, %30
%52 = load i32, i32* @CMSPAR
%53 = xor i32 %52, -1
%54 = and i32 %51, %53
br label %70
55: ; preds = %27, %27
%56 = load i32, i32* @PARENB
%57 = load i32, i32* @PARODD
%58 = or i32 %57, %56
%59 = load i32, i32* @CMSPAR
%60 = or i32 %58, %59
%61 = or i32 %60, %30
br label %70
62: ; preds = %27, %27
%63 = load i32, i32* @PARENB
%64 = load i32, i32* @CMSPAR
%65 = or i32 %64, %63
%66 = or i32 %65, %30
%67 = load i32, i32* @PARODD
%68 = xor i32 %67, -1
%69 = and i32 %66, %68
br label %70
70: ; preds = %62, %55, %47, %39, %31
%71 = phi i32 [ %69, %62 ], [ %61, %55 ], [ %54, %47 ], [ %46, %39 ], [ %38, %31 ]
%72 = icmp eq i32 %4, 2
%73 = load i32, i32* @CSTOPB
%74 = xor i32 %73, -1
%75 = and i32 %71, %74
%76 = or i32 %71, %73
%77 = select i1 %72, i32 %76, i32 %75
store i32 %77, i32* %18
%78 = call i32 @cfmakeraw(%struct.termios* %6)
%79 = load i32, i32* @B9600
%80 = call i32 @cfsetspeed(%struct.termios* %6, i32 %79)
%81 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 2
%82 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 1
%83 = bitcast i64* %81 to i8*
%84 = load i32*, i32** %82
%85 = load i64, i64* @VMIN
%86 = getelementptr inbounds i32, i32* %84, i64 %85
store i32 0, i32* %86
%87 = load i64, i64* @VTIME
%88 = getelementptr inbounds i32, i32* %84, i64 %87
store i32 5, i32* %88
%89 = load i32, i32* @TCIFLUSH
%90 = call i32 @tcflush(i32 %0, i32 %89)
%91 = load i32, i32* @TCSANOW
%92 = call i64 @tcsetattr(i32 %0, i32 %91, %struct.termios* %6)
%93 = icmp eq i64 %92, 0
br i1 %93, label %98, label %94
94: ; preds = %70
%95 = load i32, i32* @errno
%96 = call i8* @strerror(i32 %95)
%97 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %95, i8* %96)
br label %98
98: ; preds = %70, %94, %11
ret i32 -1
}