#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_iflag;
  scalar_t__ *c_cc;
};

/* Variables and functions */
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS5;
int CS6;
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int INPCK;
int ISTRIP;
int IXANY;
int IXOFF;
int IXON;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int set_parity(int fd, int databits, int stopbits, int parity) {
  struct termios options;
  if (tcgetattr(fd, &options) != 0) {
    fprintf(stderr, "set_parity: fail to tcgetattr!\n");
    return ((-1));
  }
  tcflush(fd, TCIOFLUSH);
  options.c_cflag |= (CLOCAL | CREAD);
  cfmakeraw(&options);
  options.c_cflag &= ~CRTSCTS;
  options.c_iflag &= ~(IXON | IXOFF | IXANY);
  options.c_cflag &= ~CSIZE;
  switch (databits) {
  case 5:
    options.c_cflag |= CS5;
    break;
  case 6:
    options.c_cflag |= CS6;
    break;
  case 7:
    options.c_cflag |= CS7;
    break;
  case 8:
    options.c_cflag |= CS8;
    break;
  default:
    fprintf(stderr, "Unsupported data size\n");
    return ((-1));
  }
  switch (parity) {
  case 'n':
  case 'N':
    options.c_cflag &= ~PARENB;
    options.c_iflag &= ~INPCK;
    options.c_iflag &= ~ISTRIP;
    break;
  case 'o':
  case 'O':
    options.c_cflag |= PARENB;
    options.c_cflag |= PARODD;
    options.c_iflag |= INPCK;
    options.c_iflag |= ISTRIP;
    break;
  case 'e':
  case 'E':
    options.c_cflag |= PARENB;
    options.c_cflag &= ~PARODD;
    options.c_iflag |= INPCK;
    options.c_iflag |= ISTRIP;
    break;
  default:
    fprintf(stderr, "Unsupported parity\n");
    return ((-1));
  }
  switch (stopbits) {
  case 1:
    options.c_cflag &= ~CSTOPB;
    break;
  case 2:
    options.c_cflag |= CSTOPB;
    break;
  default:
    fprintf(stderr, "Unsupported stop bits\n");
    return ((-1));
  }
  options.c_cc[VMIN] = 0;
  tcflush(fd, TCIFLUSH);
  if (tcsetattr(fd, TCSANOW, &options) != 0) {
    fprintf(stderr, "set_parity: fail to tcsetattr!\n");
    return ((-1));
  }
  return (0);
}


x86 assembly (clang, -O0):
<set_parity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0x0,%rax
je     119b <set_parity+0x4b>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e3 <set_parity+0x393>
mov    -0x8(%rbp),%edi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%ecx
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    -0x28(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <cfmakeraw@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x28(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%ecx
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
not    %ecx
mov    -0x24(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    0x2d8c(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x28(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffb,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1299 <set_parity+0x149>
mov    -0x30(%rbp),%rax
lea    0xdc0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12ba <set_parity+0x16a>
mov    0x2d5c(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12ba <set_parity+0x16a>
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12ba <set_parity+0x16a>
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12ba <set_parity+0x16a>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e3 <set_parity+0x393>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x45,%eax
je     139f <set_parity+0x24f>
jmp    12ce <set_parity+0x17e>
mov    -0x34(%rbp),%eax
sub    $0x4e,%eax
je     1323 <set_parity+0x1d3>
jmp    12df <set_parity+0x18f>
mov    -0x34(%rbp),%eax
sub    $0x4f,%eax
je     135e <set_parity+0x20e>
jmp    12f0 <set_parity+0x1a0>
mov    -0x34(%rbp),%eax
sub    $0x65,%eax
je     139f <set_parity+0x24f>
jmp    1301 <set_parity+0x1b1>
mov    -0x34(%rbp),%eax
sub    $0x6e,%eax
je     1323 <set_parity+0x1d3>
jmp    1312 <set_parity+0x1c2>
mov    -0x34(%rbp),%eax
sub    $0x6f,%eax
je     135e <set_parity+0x20e>
jmp    13e3 <set_parity+0x293>
mov    0x2cae(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2c1a(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1404 <set_parity+0x2b4>
mov    0x2c73(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c54(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2bd6(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1404 <set_parity+0x2b4>
mov    0x2c32(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c13(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2bb1(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2b92(%rip),%rax
mov    (%rax),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1404 <set_parity+0x2b4>
mov    0x2b96(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e3 <set_parity+0x393>
mov    -0x10(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x1,%eax
je     1429 <set_parity+0x2d9>
jmp    1418 <set_parity+0x2c8>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     1440 <set_parity+0x2f0>
jmp    1454 <set_parity+0x304>
mov    0x2b20(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1475 <set_parity+0x325>
mov    0x2b09(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1475 <set_parity+0x325>
mov    0x2b25(%rip),%rax
mov    (%rax),%edi
lea    0xbf7(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e3 <set_parity+0x393>
mov    -0x20(%rbp),%rax
mov    0x2b28(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x8(%rbp),%edi
mov    0x2af3(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
mov    -0x8(%rbp),%edi
mov    0x2b2a(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1070 <tcsetattr@plt>
cmp    $0x0,%rax
je     14dc <set_parity+0x38c>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
lea    0xba7(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e3 <set_parity+0x393>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_parity>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%r15d
lea    0x8(%rsp),%rsi
call   1060 <tcgetattr@plt>
test   %rax,%rax
je     1198 <set_parity+0x48>
lea    0xe96(%rip),%rsi
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1030 <tcflush@plt>
mov    0x2d88(%rip),%rax
mov    0x2e01(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <cfmakeraw@plt>
mov    0x2e10(%rip),%rax
mov    0x2e11(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2dae(%rip),%rax
or     (%rax),%ecx
mov    0x2d6d(%rip),%rax
not    %ecx
and    0xc(%rsp),%ecx
mov    (%rax),%eax
mov    0x2da6(%rip),%rdx
or     (%rdx),%eax
mov    %ecx,0xc(%rsp)
not    %eax
and    0x8(%rsp),%eax
mov    %eax,0x8(%rsp)
add    $0xfffffffb,%ebx
cmp    $0x3,%ebx
ja     122b <set_parity+0xdb>
lea    0xde7(%rip),%rdx
movslq (%rdx,%rbx,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
mov    0x2d1f(%rip),%rdx
jmp    1250 <set_parity+0x100>
lea    0xdfe(%rip),%rsi
jmp    117a <set_parity+0x2a>
mov    0x2d82(%rip),%rdx
jmp    1250 <set_parity+0x100>
mov    0x2cf9(%rip),%rdx
jmp    1250 <set_parity+0x100>
mov    0x2d60(%rip),%rdx
or     (%rdx),%eax
mov    %eax,0x8(%rsp)
lea    0xdea(%rip),%rsi
add    $0xffffffbb,%ebp
cmp    $0x2a,%ebp
ja     117a <set_parity+0x2a>
movabs $0x100000001,%rdx
bt     %rbp,%rdx
jb     12b1 <set_parity+0x161>
movabs $0x20000000200,%rdx
bt     %rbp,%rdx
jb     12df <set_parity+0x18f>
movabs $0x40000000400,%rdx
bt     %rbp,%rdx
jae    117a <set_parity+0x2a>
mov    0x2d34(%rip),%rdx
or     (%rdx),%eax
mov    0x2d1b(%rip),%rdx
or     (%rdx),%eax
jmp    12c7 <set_parity+0x177>
mov    0x2d20(%rip),%rdx
or     (%rdx),%eax
mov    0x2d07(%rip),%rdx
mov    (%rdx),%edx
not    %edx
and    %edx,%eax
mov    0x2caa(%rip),%rdx
or     (%rdx),%ecx
mov    %eax,0x8(%rsp)
mov    0x2c8d(%rip),%rdx
or     (%rdx),%ecx
jmp    1306 <set_parity+0x1b6>
mov    0x2cf2(%rip),%rdx
mov    (%rdx),%edx
not    %edx
and    %edx,%eax
mov    %eax,0x8(%rsp)
mov    0x2c81(%rip),%rdx
mov    (%rdx),%edx
mov    0x2c68(%rip),%rsi
or     (%rsi),%edx
not    %edx
and    %edx,%ecx
mov    %ecx,0xc(%rsp)
cmp    $0x2,%r14d
je     1325 <set_parity+0x1d5>
cmp    $0x1,%r14d
jne    1381 <set_parity+0x231>
mov    0x2c33(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
jmp    132e <set_parity+0x1de>
mov    0x2c24(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    0x2c6a(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c38(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1030 <tcflush@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r15d,%edi
call   1070 <tcsetattr@plt>
test   %rax,%rax
je     138d <set_parity+0x23d>
lea    0xcf6(%rip),%rsi
jmp    117a <set_parity+0x2a>
lea    0xcd3(%rip),%rsi
jmp    117a <set_parity+0x2a>
xor    %eax,%eax
jmp    118d <set_parity+0x3d>

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

LLVM IR (-O2):
%struct.termios = type { i32, i32, i64* }
@stderr = global i32 0
@.str = [32 x i8] c"set_parity: fail to tcgetattr!\0A\00"
@TCIOFLUSH = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@CRTSCTS = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@CSIZE = global i32 0
@CS5 = global i32 0
@CS6 = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@.str.1 = [23 x i8] c"Unsupported data size\0A\00"
@PARENB = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@PARODD = global i32 0
@.str.2 = [20 x i8] c"Unsupported parity\0A\00"
@CSTOPB = global i32 0
@.str.3 = [23 x i8] c"Unsupported stop bits\0A\00"
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.4 = [32 x i8] c"set_parity: fail to tcsetattr!\0A\00"
define i32 @set_parity(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.termios
%6 = bitcast %struct.termios* %5 to i8*
%7 = call i64 @tcgetattr(i32 %0, %struct.termios* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %97
9: ; preds = %4
%10 = load i32, i32* @TCIOFLUSH
%11 = call i32 @tcflush(i32 %0, i32 %10)
%12 = load i32, i32* @CLOCAL
%13 = load i32, i32* @CREAD
%14 = or i32 %13, %12
%15 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
%16 = load i32, i32* %15
%17 = or i32 %14, %16
store i32 %17, i32* %15
%18 = call i32 @cfmakeraw(%struct.termios* %5)
%19 = load i32, i32* @CRTSCTS
%20 = load i32, i32* %15
%21 = load i32, i32* @IXON
%22 = load i32, i32* @IXOFF
%23 = or i32 %22, %21
%24 = load i32, i32* @IXANY
%25 = or i32 %23, %24
%26 = xor i32 %25, -1
%27 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 1
%28 = load i32, i32* %27
%29 = and i32 %28, %26
store i32 %29, i32* %27
%30 = load i32, i32* @CSIZE
%31 = or i32 %19, %30
%32 = xor i32 %31, -1
%33 = and i32 %20, %32
store i32 %33, i32* %15
switch i32 %1, label %97 [
i32 5, label %34
i32 6, label %37
i32 7, label %40
i32 8, label %43
]
34: ; preds = %9
%35 = load i32, i32* @CS5
%36 = or i32 %35, %33
store i32 %36, i32* %15
br label %46
37: ; preds = %9
%38 = load i32, i32* @CS6
%39 = or i32 %38, %33
store i32 %39, i32* %15
br label %46
40: ; preds = %9
%41 = load i32, i32* @CS7
%42 = or i32 %41, %33
store i32 %42, i32* %15
br label %46
43: ; preds = %9
%44 = load i32, i32* @CS8
%45 = or i32 %44, %33
store i32 %45, i32* %15
br label %46
46: ; preds = %43, %40, %37, %34
%47 = phi i32 [ %45, %43 ], [ %42, %40 ], [ %39, %37 ], [ %36, %34 ]
switch i32 %3, label %97 [
i32 110, label %48
i32 78, label %48
i32 111, label %57
i32 79, label %57
i32 101, label %66
i32 69, label %66
]
48: ; preds = %46, %46
%49 = load i32, i32* @PARENB
%50 = xor i32 %49, -1
%51 = and i32 %47, %50
store i32 %51, i32* %15
%52 = load i32, i32* @INPCK
%53 = load i32, i32* @ISTRIP
%54 = or i32 %52, %53
%55 = xor i32 %54, -1
%56 = and i32 %29, %55
br label %76
57: ; preds = %46, %46
%58 = load i32, i32* @PARENB
%59 = or i32 %47, %58
%60 = load i32, i32* @PARODD
%61 = or i32 %60, %59
store i32 %61, i32* %15
%62 = load i32, i32* @INPCK
%63 = or i32 %62, %29
%64 = load i32, i32* @ISTRIP
%65 = or i32 %64, %63
br label %76
66: ; preds = %46, %46
%67 = load i32, i32* @PARENB
%68 = or i32 %47, %67
%69 = load i32, i32* @PARODD
%70 = xor i32 %69, -1
%71 = and i32 %68, %70
store i32 %71, i32* %15
%72 = load i32, i32* @INPCK
%73 = or i32 %72, %29
%74 = load i32, i32* @ISTRIP
%75 = or i32 %74, %73
br label %76
76: ; preds = %66, %57, %48
%77 = phi i32 [ %75, %66 ], [ %65, %57 ], [ %56, %48 ]
%78 = phi i32 [ %71, %66 ], [ %61, %57 ], [ %51, %48 ]
store i32 %77, i32* %27
switch i32 %2, label %97 [
i32 1, label %79
i32 2, label %83
]
79: ; preds = %76
%80 = load i32, i32* @CSTOPB
%81 = xor i32 %80, -1
%82 = and i32 %78, %81
br label %86
83: ; preds = %76
%84 = load i32, i32* @CSTOPB
%85 = or i32 %78, %84
br label %86
86: ; preds = %83, %79
%87 = phi i32 [ %85, %83 ], [ %82, %79 ]
store i32 %87, i32* %15
%88 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 2
%89 = load i64*, i64** %88
%90 = load i64, i64* @VMIN
%91 = getelementptr inbounds i64, i64* %89, i64 %90
store i64 0, i64* %91
%92 = load i32, i32* @TCIFLUSH
%93 = call i32 @tcflush(i32 %0, i32 %92)
%94 = load i32, i32* @TCSANOW
%95 = call i64 @tcsetattr(i32 %0, i32 %94, %struct.termios* %5)
%96 = icmp eq i64 %95, 0
br i1 %96, label %101, label %97
97: ; preds = %86, %76, %46, %9, %4
%98 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %46 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %76 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), %86 ]
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* %98)
br label %101
101: ; preds = %97, %86
%102 = phi i32 [ 0, %86 ], [ -1, %97 ]
ret i32 %102
}