#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_cc;
  int /*<<< orphan*/ c_iflag;
};

/* Variables and functions */
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int /*<<< orphan*/ INPCK;
int ISIG;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ logcat(char *, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int uart_set_parity(int fd, int databits, int stopbits, int parity) {
  struct termios options;
  if (tcgetattr(fd, &options) != 0) {
    logcat("SetupSerial 1: %s\n", strerror(errno));
    return -1;
  }
  options.c_cflag &= ~CSIZE;
  switch (databits) {
  case 7:
    options.c_cflag |= CS7;
    break;
  case 8:
    options.c_cflag |= CS8;
    break;
  default:
    logcat("Unsupported data size\n");
    return -1;
  }
  switch (parity) {
  case 'n':
  case 'N':
    options.c_cflag &= ~PARENB;
    options.c_iflag &= ~INPCK;
    break;
  case 'o':
  case 'O':
    options.c_cflag |= (PARODD | PARENB);
    options.c_iflag |= INPCK;
    break;
  case 'e':
  case 'E':
    options.c_cflag |= PARENB;
    options.c_cflag &= ~PARODD;
    options.c_iflag |= INPCK;
    break;
  case 'S':
  case 's':
    options.c_cflag &= ~PARENB;
    options.c_cflag &= ~CSTOPB;
    break;
  default:
    logcat("Unsupported parity\n");
    return -1;
  }
  switch (stopbits) {
  case 1:
    options.c_cflag &= ~CSTOPB;
    break;
  case 2:
    options.c_cflag |= CSTOPB;
    break;
  default:
    logcat("Unsupported stop bits\n");
    return -1;
  }
  if (parity != 'n')
    options.c_iflag |= INPCK;
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  tcflush(fd, TCIFLUSH);
  options.c_cc[VTIME] = 150;
  options.c_cc[VMIN] = 0;
  if (tcsetattr(fd, TCSANOW, &options) != 0) {
    logcat("SetupSerial 3: %s\n", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<uart_set_parity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <tcgetattr@plt>
cmp    $0x0,%rax
je     11a4 <uart_set_parity+0x54>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%esi
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144f <uart_set_parity+0x2ff>
mov    0x2dfd(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x30(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x7,%eax
je     11dc <uart_set_parity+0x8c>
jmp    11cb <uart_set_parity+0x7b>
mov    -0x34(%rbp),%eax
sub    $0x8,%eax
je     11f0 <uart_set_parity+0xa0>
jmp    1204 <uart_set_parity+0xb4>
mov    0x2d7d(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    121e <uart_set_parity+0xce>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    121e <uart_set_parity+0xce>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144f <uart_set_parity+0x2ff>
mov    -0x14(%rbp),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x2e,%eax
ja     12fa <uart_set_parity+0x1aa>
mov    -0x40(%rbp),%rax
lea    0xdc2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1314 <uart_set_parity+0x1c4>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    0x2d68(%rip),%rcx
or     (%rcx),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1314 <uart_set_parity+0x1c4>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1314 <uart_set_parity+0x1c4>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c7e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1314 <uart_set_parity+0x1c4>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144f <uart_set_parity+0x2ff>
mov    -0x10(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x1,%eax
je     1339 <uart_set_parity+0x1e9>
jmp    1328 <uart_set_parity+0x1d8>
mov    -0x44(%rbp),%eax
sub    $0x2,%eax
je     1350 <uart_set_parity+0x200>
jmp    1364 <uart_set_parity+0x214>
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    137e <uart_set_parity+0x22e>
mov    0x2c11(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    137e <uart_set_parity+0x22e>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144f <uart_set_parity+0x2ff>
cmpl   $0x6e,-0x14(%rbp)
je     1397 <uart_set_parity+0x247>
mov    0x2c01(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    0x2c31(%rip),%rcx
or     (%rcx),%eax
mov    0x2c20(%rip),%rcx
or     (%rcx),%eax
mov    0x2c07(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bca(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
mov    -0x28(%rbp),%rax
mov    0x2ba0(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x96,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2bbb(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%edi
mov    0x2bd7(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1060 <tcsetattr@plt>
cmp    $0x0,%rax
je     1448 <uart_set_parity+0x2f8>
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %eax,%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1040 <logcat@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144f <uart_set_parity+0x2ff>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_set_parity>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%rsi
call   1050 <tcgetattr@plt>
test   %rax,%rax
je     1194 <uart_set_parity+0x44>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xf36(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <logcat@plt>
jmp    1358 <uart_set_parity+0x208>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
not    %eax
and    (%rsp),%eax
mov    %eax,(%rsp)
cmp    $0x7,%ebp
je     11b8 <uart_set_parity+0x68>
cmp    $0x8,%ebp
jne    11f9 <uart_set_parity+0xa9>
mov    0x2e02(%rip),%rcx
jmp    11bf <uart_set_parity+0x6f>
mov    0x2da1(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
lea    -0x45(%r14),%ecx
cmp    $0x2e,%ecx
ja     134a <uart_set_parity+0x1fa>
lea    0xe28(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    0x2e00(%rip),%rcx
or     (%rcx),%eax
mov    0x2dd7(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
jmp    123e <uart_set_parity+0xee>
lea    0xecf(%rip),%rdi
jmp    1351 <uart_set_parity+0x201>
mov    0x2ddc(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,(%rsp)
mov    0x2d74(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,0x10(%rsp)
cmp    $0x2,%r15d
jne    1254 <uart_set_parity+0x104>
jmp    1294 <uart_set_parity+0x144>
mov    0x2d95(%rip),%rcx
mov    0x2dae(%rip),%rdx
or     (%rcx),%eax
or     (%rdx),%eax
mov    %eax,(%rsp)
mov    0x2d48(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,0x10(%rsp)
cmp    $0x2,%r15d
je     1294 <uart_set_parity+0x144>
cmp    $0x1,%r15d
jne    1269 <uart_set_parity+0x119>
mov    0x2d07(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
jmp    129d <uart_set_parity+0x14d>
lea    0xe8a(%rip),%rdi
jmp    1351 <uart_set_parity+0x201>
mov    0x2d6c(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2ce3(%rip),%rdx
or     (%rdx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,(%rsp)
cmp    $0x2,%r15d
jne    1254 <uart_set_parity+0x104>
mov    0x2ccd(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
cmp    $0x6e,%r14d
je     12b3 <uart_set_parity+0x163>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
or     %eax,0x10(%rsp)
mov    0x2cbe(%rip),%rax
mov    0x2d17(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d04(%rip),%rax
or     (%rax),%ecx
mov    0x2ceb(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1030 <tcflush@plt>
mov    0x8(%rsp),%rax
mov    0x2c87(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x96,(%rax,%rcx,4)
mov    0x2ca6(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2cc5(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1060 <tcsetattr@plt>
test   %rax,%rax
je     1346 <uart_set_parity+0x1f6>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xdd0(%rip),%rdi
jmp    1186 <uart_set_parity+0x36>
xor    %eax,%eax
jmp    135d <uart_set_parity+0x20d>
lea    0xd95(%rip),%rdi
xor    %eax,%eax
call   1040 <logcat@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32*, i32 }
@.str = [19 x i8] c"SetupSerial 1: %s\0A\00"
@errno = global i32 0
@CSIZE = 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
@PARODD = global i32 0
@CSTOPB = global i32 0
@.str.2 = [20 x i8] c"Unsupported parity\0A\00"
@.str.3 = [23 x i8] c"Unsupported stop bits\0A\00"
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@TCIFLUSH = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@.str.4 = [19 x i8] c"SetupSerial 3: %s\0A\00"
define i32 @uart_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 %13, label %9
9: ; preds = %4
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %108
13: ; preds = %4
%14 = load i32, i32* @CSIZE
%15 = xor i32 %14, -1
%16 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
%17 = load i32, i32* %16
%18 = and i32 %17, %15
store i32 %18, i32* %16
switch i32 %1, label %20 [
i32 7, label %22
i32 8, label %19
]
19: ; preds = %13
br label %22
20: ; preds = %13
%21 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %108
22: ; preds = %13, %19
%23 = phi i32* [ @CS8, %19 ], [ @CS7, %13 ]
%24 = load i32, i32* %23
%25 = or i32 %24, %18
store i32 %25, i32* %16
switch i32 %3, label %60 [
i32 110, label %26
i32 78, label %26
i32 111, label %35
i32 79, label %35
i32 101, label %44
i32 69, label %44
i32 83, label %54
i32 115, label %54
]
26: ; preds = %22, %22
%27 = load i32, i32* @PARENB
%28 = xor i32 %27, -1
%29 = and i32 %25, %28
store i32 %29, i32* %16
%30 = load i32, i32* @INPCK
%31 = xor i32 %30, -1
%32 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 3
%33 = load i32, i32* %32
%34 = and i32 %33, %31
store i32 %34, i32* %32
br label %62
35: ; preds = %22, %22
%36 = load i32, i32* @PARODD
%37 = load i32, i32* @PARENB
%38 = or i32 %36, %25
%39 = or i32 %38, %37
store i32 %39, i32* %16
%40 = load i32, i32* @INPCK
%41 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 3
%42 = load i32, i32* %41
%43 = or i32 %42, %40
store i32 %43, i32* %41
br label %62
44: ; preds = %22, %22
%45 = load i32, i32* @PARENB
%46 = or i32 %45, %25
%47 = load i32, i32* @PARODD
%48 = xor i32 %47, -1
%49 = and i32 %46, %48
store i32 %49, i32* %16
%50 = load i32, i32* @INPCK
%51 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 3
%52 = load i32, i32* %51
%53 = or i32 %52, %50
store i32 %53, i32* %51
br label %62
54: ; preds = %22, %22
%55 = load i32, i32* @PARENB
%56 = load i32, i32* @CSTOPB
%57 = or i32 %55, %56
%58 = xor i32 %57, -1
%59 = and i32 %25, %58
store i32 %59, i32* %16
br label %62
60: ; preds = %22
%61 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %108
62: ; preds = %54, %44, %35, %26
%63 = phi i32 [ %59, %54 ], [ %49, %44 ], [ %39, %35 ], [ %29, %26 ]
switch i32 %2, label %71 [
i32 1, label %64
i32 2, label %68
]
64: ; preds = %62
%65 = load i32, i32* @CSTOPB
%66 = xor i32 %65, -1
%67 = and i32 %63, %66
br label %73
68: ; preds = %62
%69 = load i32, i32* @CSTOPB
%70 = or i32 %63, %69
br label %73
71: ; preds = %62
%72 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %108
73: ; preds = %68, %64
%74 = phi i32 [ %70, %68 ], [ %67, %64 ]
store i32 %74, i32* %16
%75 = icmp eq i32 %3, 110
br i1 %75, label %81, label %76
76: ; preds = %73
%77 = load i32, i32* @INPCK
%78 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 3
%79 = load i32, i32* %78
%80 = or i32 %79, %77
store i32 %80, i32* %78
br label %81
81: ; preds = %76, %73
%82 = load i32, i32* @ICANON
%83 = load i32, i32* @ECHO
%84 = or i32 %83, %82
%85 = load i32, i32* @ECHOE
%86 = or i32 %84, %85
%87 = load i32, i32* @ISIG
%88 = or i32 %86, %87
%89 = xor i32 %88, -1
%90 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 1
%91 = load i32, i32* %90
%92 = and i32 %91, %89
store i32 %92, i32* %90
%93 = load i32, i32* @TCIFLUSH
%94 = call i32 @tcflush(i32 %0, i32 %93)
%95 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 2
%96 = load i32*, i32** %95
%97 = load i64, i64* @VTIME
%98 = getelementptr inbounds i32, i32* %96, i64 %97
store i32 150, i32* %98
%99 = load i64, i64* @VMIN
%100 = getelementptr inbounds i32, i32* %96, i64 %99
store i32 0, i32* %100
%101 = load i32, i32* @TCSANOW
%102 = call i64 @tcsetattr(i32 %0, i32 %101, %struct.termios* %5)
%103 = icmp eq i64 %102, 0
br i1 %103, label %108, label %104
104: ; preds = %81
%105 = load i32, i32* @errno
%106 = call i32 @strerror(i32 %105)
%107 = call i32 (i8*, ...) @logcat(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %106)
br label %108
108: ; preds = %81, %104, %71, %60, %20, %9
%109 = phi i32 [ -1, %9 ], [ -1, %20 ], [ -1, %60 ], [ -1, %71 ], [ -1, %104 ], [ 0, %81 ]
ret i32 %109
}