#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_lflag;
  int c_oflag;
  int c_iflag;
  int *c_cc;
};

/* Variables and functions */
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ICRNL;
int INLCR;
int INPCK;
int ISIG;
int IXANY;
int IXOFF;
int IXON;
int OCRNL;
int ONLCR;
int OPOST;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ errExit(char *);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void set_attr(int fd, int databits, int stopbits, int parity) {
  struct termios tp;
  if (tcgetattr(fd, &tp) == -1)
    errExit("tcgetattr");
  tp.c_cflag &= ~CSIZE;
  if (cfsetispeed(&tp, B9600) == -1)
    errExit("cfsetispeed");
  tp.c_cflag |= (CLOCAL | CREAD);
  tp.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  tp.c_oflag &= ~OPOST;
  tp.c_oflag &= ~(ONLCR | OCRNL);
  tp.c_iflag &= ~(ICRNL | INLCR);
  tp.c_iflag &= ~(IXON | IXOFF | IXANY);
  switch (databits) {
  case 7:
    tp.c_cflag |= CS7;
    break;
  case 8:
    tp.c_cflag |= CS8;
    break;
  default:
    errExit("switch databits");
  }
  switch (parity) {
  case 'n':
  case 'N':
    tp.c_cflag &= ~PARENB;
    tp.c_iflag &= ~INPCK;
    break;
  case 'o':
  case 'O':
    tp.c_cflag |= (PARODD | PARENB);
    tp.c_iflag |= INPCK;
    break;
  case 'e':
  case 'E':
    tp.c_cflag |= PARENB;
    tp.c_cflag &= ~PARODD;
    tp.c_iflag |= INPCK;
    break;
  case 's':
  case 'S':
    tp.c_cflag &= ~PARENB;
    tp.c_cflag &= ~CSTOPB;
    break;
  default:
    errExit("switch parity");
  }
  switch (stopbits) {
  case 1:
    tp.c_cflag &= ~CSTOPB;
    break;
  case 2:
    tp.c_cflag |= CSTOPB;
    break;
  default:
    errExit("switch stopbits");
  }
  tcflush(fd, TCIOFLUSH);
  tp.c_cc[VTIME] = 15;
  tp.c_cc[VMIN] = 0;
  if (tcsetattr(fd, TCSANOW, &tp) != 0)
    errExit("tcsetattr");
}


x86 assembly (clang, -O0):
<set_attr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    1185 <set_attr+0x35>
lea    0xf3c(%rip),%rdi
call   1030 <errExit@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1070 <cfsetispeed@plt>
cmp    $0xffffffff,%eax
jne    11be <set_attr+0x6e>
lea    0xf0d(%rip),%rdi
call   1030 <errExit@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%ecx
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    -0x28(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%ecx
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x24(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    0x2d18(%rip),%rax
mov    (%rax),%ecx
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x20(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%ecx
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x1c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d5c(%rip),%rax
mov    (%rax),%ecx
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x1c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x7,%eax
je     12ab <set_attr+0x15b>
jmp    129a <set_attr+0x14a>
mov    -0x2c(%rbp),%eax
sub    $0x8,%eax
je     12bf <set_attr+0x16f>
jmp    12d3 <set_attr+0x183>
mov    0x2c66(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12df <set_attr+0x18f>
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12df <set_attr+0x18f>
lea    0xdf8(%rip),%rdi
call   1030 <errExit@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x2e,%eax
ja     13bb <set_attr+0x26b>
mov    -0x38(%rbp),%rax
lea    0xd01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c2f(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    13c7 <set_attr+0x277>
mov    0x2c60(%rip),%rax
mov    (%rax),%eax
mov    0x2c77(%rip),%rcx
or     (%rcx),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c00(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    13c7 <set_attr+0x277>
mov    0x2c54(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2bcb(%rip),%rax
mov    (%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    13c7 <set_attr+0x277>
mov    0x2c1f(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2b75(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    13c7 <set_attr+0x277>
lea    0xd20(%rip),%rdi
call   1030 <errExit@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     13ec <set_attr+0x29c>
jmp    13db <set_attr+0x28b>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     1403 <set_attr+0x2b3>
jmp    1417 <set_attr+0x2c7>
mov    0x2b2d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1423 <set_attr+0x2d3>
mov    0x2b16(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1423 <set_attr+0x2d3>
lea    0xcd2(%rip),%rdi
call   1030 <errExit@plt>
mov    -0x4(%rbp),%edi
mov    0x2b1b(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    -0x18(%rbp),%rax
mov    0x2af9(%rip),%rcx
mov    (%rcx),%rcx
movl   $0xf,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2b1c(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    0x2b48(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <tcsetattr@plt>
cmp    $0x0,%rax
je     1489 <set_attr+0x339>
lea    0xc7c(%rip),%rdi
call   1030 <errExit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_attr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%r15d
mov    %rsp,%rsi
call   1050 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    117d <set_attr+0x2d>
lea    0xf44(%rip),%rdi
call   1030 <errExit@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1070 <cfsetispeed@plt>
cmp    $0xffffffff,%eax
jne    11ad <set_attr+0x5d>
lea    0xf1e(%rip),%rdi
call   1030 <errExit@plt>
mov    0x2d5c(%rip),%rcx
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
or     (%rsp),%eax
mov    0x2d67(%rip),%rcx
mov    0x2dd8(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2dc5(%rip),%rcx
or     (%rcx),%edx
mov    %eax,(%rsp)
mov    0x2da9(%rip),%rcx
or     (%rcx),%edx
not    %edx
and    %edx,0x4(%rsp)
mov    0x2dd2(%rip),%rcx
mov    0x2d43(%rip),%rdx
mov    0x2dec(%rip),%rsi
mov    (%rsi),%esi
or     (%rdx),%esi
or     (%rcx),%esi
not    %esi
and    %esi,0x8(%rsp)
mov    0x2dc9(%rip),%rcx
mov    0x2dba(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d97(%rip),%rcx
mov    0x2da0(%rip),%rsi
mov    (%rsi),%esi
or     (%rcx),%esi
mov    0x2d1d(%rip),%rcx
or     (%rcx),%esi
or     %edx,%esi
not    %esi
and    %esi,0xc(%rsp)
cmp    $0x8,%ebx
je     1258 <set_attr+0x108>
cmp    $0x7,%ebx
jne    1266 <set_attr+0x116>
mov    0x2cc2(%rip),%rcx
jmp    125f <set_attr+0x10f>
mov    0x2d19(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
jmp    1272 <set_attr+0x122>
lea    0xe65(%rip),%rdi
call   1030 <errExit@plt>
add    $0xffffffbb,%ebp
cmp    $0x2e,%ebp
ja     133c <set_attr+0x1ec>
lea    0xd7b(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x2d23(%rip),%rax
mov    (%rsp),%ecx
or     (%rax),%ecx
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %ecx,%eax
mov    %eax,(%rsp)
jmp    12e6 <set_attr+0x196>
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0xc(%rsp)
cmp    $0x2,%r14d
jne    1318 <set_attr+0x1c8>
jmp    134e <set_attr+0x1fe>
mov    0x2cc0(%rip),%rax
mov    0x2cd9(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,(%rsp)
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
or     %eax,0xc(%rsp)
cmp    $0x2,%r14d
jne    1318 <set_attr+0x1c8>
jmp    134e <set_attr+0x1fe>
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
mov    0x2c15(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    %eax,(%rsp)
cmp    $0x2,%r14d
je     134e <set_attr+0x1fe>
cmp    $0x1,%r14d
jne    132e <set_attr+0x1de>
mov    0x2bfb(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
jmp    135a <set_attr+0x20a>
lea    0xdbb(%rip),%rdi
call   1030 <errExit@plt>
jmp    135a <set_attr+0x20a>
lea    0xd9f(%rip),%rdi
call   1030 <errExit@plt>
cmp    $0x2,%r14d
jne    1318 <set_attr+0x1c8>
mov    0x2bcb(%rip),%rax
mov    (%rax),%eax
or     %eax,(%rsp)
mov    0x2be7(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1040 <tcflush@plt>
mov    0x10(%rsp),%rax
mov    0x2bc1(%rip),%rcx
mov    (%rcx),%rcx
movl   $0xf,(%rax,%rcx,4)
mov    0x2be8(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2c17(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %r15d,%edi
call   1060 <tcsetattr@plt>
test   %rax,%rax
je     13b7 <set_attr+0x267>
lea    0xd4e(%rip),%rdi
call   1030 <errExit@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32, i32* }
@.str = [10 x i8] c"tcgetattr\00"
@CSIZE = global i32 0
@B9600 = global i32 0
@.str.1 = [12 x i8] c"cfsetispeed\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@OCRNL = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@.str.2 = [16 x i8] c"switch databits\00"
@PARENB = global i32 0
@INPCK = global i32 0
@PARODD = global i32 0
@CSTOPB = global i32 0
@.str.3 = [14 x i8] c"switch parity\00"
@.str.4 = [16 x i8] c"switch stopbits\00"
@TCIOFLUSH = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@.str.5 = [10 x i8] c"tcsetattr\00"
define void @set_attr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.termios
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = call i32 @tcgetattr(i32 %10, %struct.termios* %9)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = call i32 @errExit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = load i32, i32* @CSIZE
%17 = xor i32 %16, -1
%18 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, %17
store i32 %20, i32* %18
%21 = load i32, i32* @B9600
%22 = call i32 @cfsetispeed(%struct.termios* %9, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 @errExit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %15
%27 = load i32, i32* @CLOCAL
%28 = load i32, i32* @CREAD
%29 = or i32 %27, %28
%30 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%31 = load i32, i32* %30
%32 = or i32 %31, %29
store i32 %32, i32* %30
%33 = load i32, i32* @ICANON
%34 = load i32, i32* @ECHO
%35 = or i32 %33, %34
%36 = load i32, i32* @ECHOE
%37 = or i32 %35, %36
%38 = load i32, i32* @ISIG
%39 = or i32 %37, %38
%40 = xor i32 %39, -1
%41 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 1
%42 = load i32, i32* %41
%43 = and i32 %42, %40
store i32 %43, i32* %41
%44 = load i32, i32* @OPOST
%45 = xor i32 %44, -1
%46 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 2
%47 = load i32, i32* %46
%48 = and i32 %47, %45
store i32 %48, i32* %46
%49 = load i32, i32* @ONLCR
%50 = load i32, i32* @OCRNL
%51 = or i32 %49, %50
%52 = xor i32 %51, -1
%53 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 2
%54 = load i32, i32* %53
%55 = and i32 %54, %52
store i32 %55, i32* %53
%56 = load i32, i32* @ICRNL
%57 = load i32, i32* @INLCR
%58 = or i32 %56, %57
%59 = xor i32 %58, -1
%60 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 3
%61 = load i32, i32* %60
%62 = and i32 %61, %59
store i32 %62, i32* %60
%63 = load i32, i32* @IXON
%64 = load i32, i32* @IXOFF
%65 = or i32 %63, %64
%66 = load i32, i32* @IXANY
%67 = or i32 %65, %66
%68 = xor i32 %67, -1
%69 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 3
%70 = load i32, i32* %69
%71 = and i32 %70, %68
store i32 %71, i32* %69
%72 = load i32, i32* %6
switch i32 %72, label %83 [
i32 7, label %73
i32 8, label %78
]
73: ; preds = %26
%74 = load i32, i32* @CS7
%75 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%76 = load i32, i32* %75
%77 = or i32 %76, %74
store i32 %77, i32* %75
br label %85
78: ; preds = %26
%79 = load i32, i32* @CS8
%80 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%81 = load i32, i32* %80
%82 = or i32 %81, %79
store i32 %82, i32* %80
br label %85
83: ; preds = %26
%84 = call i32 @errExit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %83, %78, %73
%86 = load i32, i32* %8
switch i32 %86, label %134 [
i32 110, label %87
i32 78, label %87
i32 111, label %98
i32 79, label %98
i32 101, label %109
i32 69, label %109
i32 115, label %123
i32 83, label %123
]
87: ; preds = %85, %85
%88 = load i32, i32* @PARENB
%89 = xor i32 %88, -1
%90 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%91 = load i32, i32* %90
%92 = and i32 %91, %89
store i32 %92, i32* %90
%93 = load i32, i32* @INPCK
%94 = xor i32 %93, -1
%95 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 3
%96 = load i32, i32* %95
%97 = and i32 %96, %94
store i32 %97, i32* %95
br label %136
98: ; preds = %85, %85
%99 = load i32, i32* @PARODD
%100 = load i32, i32* @PARENB
%101 = or i32 %99, %100
%102 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%103 = load i32, i32* %102
%104 = or i32 %103, %101
store i32 %104, i32* %102
%105 = load i32, i32* @INPCK
%106 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 3
%107 = load i32, i32* %106
%108 = or i32 %107, %105
store i32 %108, i32* %106
br label %136
109: ; preds = %85, %85
%110 = load i32, i32* @PARENB
%111 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%112 = load i32, i32* %111
%113 = or i32 %112, %110
store i32 %113, i32* %111
%114 = load i32, i32* @PARODD
%115 = xor i32 %114, -1
%116 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%117 = load i32, i32* %116
%118 = and i32 %117, %115
store i32 %118, i32* %116
%119 = load i32, i32* @INPCK
%120 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 3
%121 = load i32, i32* %120
%122 = or i32 %121, %119
store i32 %122, i32* %120
br label %136
123: ; preds = %85, %85
%124 = load i32, i32* @PARENB
%125 = xor i32 %124, -1
%126 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%127 = load i32, i32* %126
%128 = and i32 %127, %125
store i32 %128, i32* %126
%129 = load i32, i32* @CSTOPB
%130 = xor i32 %129, -1
%131 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%132 = load i32, i32* %131
%133 = and i32 %132, %130
store i32 %133, i32* %131
br label %136
134: ; preds = %85
%135 = call i32 @errExit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %136
136: ; preds = %134, %123, %109, %98, %87
%137 = load i32, i32* %7
switch i32 %137, label %149 [
i32 1, label %138
i32 2, label %144
]
138: ; preds = %136
%139 = load i32, i32* @CSTOPB
%140 = xor i32 %139, -1
%141 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%142 = load i32, i32* %141
%143 = and i32 %142, %140
store i32 %143, i32* %141
br label %151
144: ; preds = %136
%145 = load i32, i32* @CSTOPB
%146 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 0
%147 = load i32, i32* %146
%148 = or i32 %147, %145
store i32 %148, i32* %146
br label %151
149: ; preds = %136
%150 = call i32 @errExit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %151
151: ; preds = %149, %144, %138
%152 = load i32, i32* %5
%153 = load i32, i32* @TCIOFLUSH
%154 = call i32 @tcflush(i32 %152, i32 %153)
%155 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 4
%156 = load i32*, i32** %155
%157 = load i64, i64* @VTIME
%158 = getelementptr inbounds i32, i32* %156, i64 %157
store i32 15, i32* %158
%159 = getelementptr inbounds %struct.termios, %struct.termios* %9, i32 0, i32 4
%160 = load i32*, i32** %159
%161 = load i64, i64* @VMIN
%162 = getelementptr inbounds i32, i32* %160, i64 %161
store i32 0, i32* %162
%163 = load i32, i32* %5
%164 = load i32, i32* @TCSANOW
%165 = call i64 @tcsetattr(i32 %163, i32 %164, %struct.termios* %9)
%166 = icmp ne i64 %165, 0
br i1 %166, label %167, label %169
167: ; preds = %151
%168 = call i32 @errExit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %169
169: ; preds = %167, %151
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32, i32* }
@.str = [10 x i8] c"tcgetattr\00"
@CSIZE = global i32 0
@B9600 = global i32 0
@.str.1 = [12 x i8] c"cfsetispeed\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@OCRNL = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@.str.2 = [16 x i8] c"switch databits\00"
@PARENB = global i32 0
@INPCK = global i32 0
@PARODD = global i32 0
@CSTOPB = global i32 0
@.str.3 = [14 x i8] c"switch parity\00"
@.str.4 = [16 x i8] c"switch stopbits\00"
@TCIOFLUSH = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@.str.5 = [10 x i8] c"tcsetattr\00"
define void @set_attr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.termios
%6 = bitcast %struct.termios* %5 to i8*
%7 = call i32 @tcgetattr(i32 %0, %struct.termios* %5)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 @errExit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = load i32, i32* @CSIZE
%13 = xor i32 %12, -1
%14 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
%15 = load i32, i32* %14
%16 = and i32 %15, %13
store i32 %16, i32* %14
%17 = load i32, i32* @B9600
%18 = call i32 @cfsetispeed(%struct.termios* %5, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @errExit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %11
%23 = load i32, i32* @CLOCAL
%24 = load i32, i32* @CREAD
%25 = or i32 %24, %23
%26 = load i32, i32* %14
%27 = or i32 %25, %26
store i32 %27, i32* %14
%28 = load i32, i32* @ICANON
%29 = load i32, i32* @ECHO
%30 = or i32 %29, %28
%31 = load i32, i32* @ECHOE
%32 = or i32 %30, %31
%33 = load i32, i32* @ISIG
%34 = or i32 %32, %33
%35 = xor i32 %34, -1
%36 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 1
%37 = load i32, i32* %36
%38 = and i32 %37, %35
store i32 %38, i32* %36
%39 = load i32, i32* @OPOST
%40 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 2
%41 = load i32, i32* %40
%42 = load i32, i32* @ONLCR
%43 = load i32, i32* @OCRNL
%44 = or i32 %43, %42
%45 = or i32 %39, %44
%46 = xor i32 %45, -1
%47 = and i32 %41, %46
store i32 %47, i32* %40
%48 = load i32, i32* @ICRNL
%49 = load i32, i32* @INLCR
%50 = or i32 %49, %48
%51 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 3
%52 = load i32, i32* %51
%53 = load i32, i32* @IXON
%54 = load i32, i32* @IXOFF
%55 = or i32 %54, %53
%56 = load i32, i32* @IXANY
%57 = or i32 %55, %56
%58 = or i32 %50, %57
%59 = xor i32 %58, -1
%60 = and i32 %52, %59
store i32 %60, i32* %51
switch i32 %1, label %67 [
i32 7, label %61
i32 8, label %64
]
61: ; preds = %22
%62 = load i32, i32* @CS7
%63 = or i32 %62, %27
store i32 %63, i32* %14
br label %69
64: ; preds = %22
%65 = load i32, i32* @CS8
%66 = or i32 %65, %27
store i32 %66, i32* %14
br label %69
67: ; preds = %22
%68 = call i32 @errExit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %69
69: ; preds = %67, %64, %61
switch i32 %3, label %105 [
i32 110, label %70
i32 78, label %70
i32 111, label %79
i32 79, label %79
i32 101, label %88
i32 69, label %88
i32 115, label %98
i32 83, label %98
]
70: ; preds = %69, %69
%71 = load i32, i32* @PARENB
%72 = xor i32 %71, -1
%73 = load i32, i32* %14
%74 = and i32 %73, %72
store i32 %74, i32* %14
%75 = load i32, i32* @INPCK
%76 = xor i32 %75, -1
%77 = load i32, i32* %51
%78 = and i32 %77, %76
store i32 %78, i32* %51
br label %107
79: ; preds = %69, %69
%80 = load i32, i32* @PARODD
%81 = load i32, i32* @PARENB
%82 = or i32 %81, %80
%83 = load i32, i32* %14
%84 = or i32 %82, %83
store i32 %84, i32* %14
%85 = load i32, i32* @INPCK
%86 = load i32, i32* %51
%87 = or i32 %86, %85
store i32 %87, i32* %51
br label %107
88: ; preds = %69, %69
%89 = load i32, i32* @PARENB
%90 = load i32, i32* %14
%91 = or i32 %90, %89
%92 = load i32, i32* @PARODD
%93 = xor i32 %92, -1
%94 = and i32 %91, %93
store i32 %94, i32* %14
%95 = load i32, i32* @INPCK
%96 = load i32, i32* %51
%97 = or i32 %96, %95
store i32 %97, i32* %51
br label %107
98: ; preds = %69, %69
%99 = load i32, i32* @PARENB
%100 = load i32, i32* %14
%101 = load i32, i32* @CSTOPB
%102 = or i32 %99, %101
%103 = xor i32 %102, -1
%104 = and i32 %100, %103
store i32 %104, i32* %14
br label %107
105: ; preds = %69
%106 = call i32 @errExit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %107
107: ; preds = %105, %98, %88, %79, %70
switch i32 %2, label %117 [
i32 1, label %108
i32 2, label %113
]
108: ; preds = %107
%109 = load i32, i32* @CSTOPB
%110 = xor i32 %109, -1
%111 = load i32, i32* %14
%112 = and i32 %111, %110
store i32 %112, i32* %14
br label %119
113: ; preds = %107
%114 = load i32, i32* @CSTOPB
%115 = load i32, i32* %14
%116 = or i32 %115, %114
store i32 %116, i32* %14
br label %119
117: ; preds = %107
%118 = call i32 @errExit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %119
119: ; preds = %117, %113, %108
%120 = load i32, i32* @TCIOFLUSH
%121 = call i32 @tcflush(i32 %0, i32 %120)
%122 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 4
%123 = load i32*, i32** %122
%124 = load i64, i64* @VTIME
%125 = getelementptr inbounds i32, i32* %123, i64 %124
store i32 15, i32* %125
%126 = load i64, i64* @VMIN
%127 = getelementptr inbounds i32, i32* %123, i64 %126
store i32 0, i32* %127
%128 = load i32, i32* @TCSANOW
%129 = call i64 @tcsetattr(i32 %0, i32 %128, %struct.termios* %5)
%130 = icmp eq i64 %129, 0
br i1 %130, label %133, label %131
131: ; preds = %119
%132 = call i32 @errExit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %133
133: ; preds = %131, %119
ret void
}