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

/* Variables and functions */
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ B19200;
int /*<<< orphan*/ B230400;
int /*<<< orphan*/ B2400;
int /*<<< orphan*/ B38400;
int /*<<< orphan*/ B4800;
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int /*<<< orphan*/ INPCK;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ bzero(struct termios *, int);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
scalar_t__ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int config_uart(int fd, unsigned int nSpeed, int nBits, char nEvent,
                int nStop) {
  struct termios newtio, oldtio;
  if (tcgetattr(fd, &oldtio) != 0) {
    printf("tcgetattr error \n");
    return -1;
  }
  bzero(&newtio, sizeof(newtio));
  newtio.c_cflag |= CLOCAL | CREAD;
  newtio.c_cflag &= ~CSIZE;
  switch (nBits) {
  case 7:
    newtio.c_cflag |= CS7;
    break;
  case 8:
    newtio.c_cflag |= CS8;
    break;
  }
  switch (nEvent) {
  case 'O':
    newtio.c_cflag |= PARENB;
    newtio.c_cflag |= PARODD;
    newtio.c_iflag |= (INPCK);
    break;
  case 'E':
    newtio.c_iflag |= (INPCK);
    newtio.c_cflag |= PARENB;
    newtio.c_cflag &= ~PARODD;
    break;
  case 'N':
    newtio.c_cflag &= ~PARENB;
    break;
  }
  if (nStop == 1)
    newtio.c_cflag &= ~CSTOPB;
  else if (nStop == 2)
    newtio.c_cflag |= CSTOPB;
  switch (nSpeed) {
  case 2400:
    cfsetispeed(&newtio, B2400);
    cfsetospeed(&newtio, B2400);
    break;
  case 4800:
    cfsetispeed(&newtio, B4800);
    cfsetospeed(&newtio, B4800);
    break;
  case 9600:
    cfsetispeed(&newtio, B9600);
    cfsetospeed(&newtio, B9600);
    break;
  case 19200:
    cfsetispeed(&newtio, B19200);
    cfsetospeed(&newtio, B19200);
    break;
  case 38400:
    cfsetispeed(&newtio, B38400);
    cfsetospeed(&newtio, B38400);
    break;
  case 115200:
    cfsetispeed(&newtio, B115200);
    cfsetospeed(&newtio, B115200);
    break;
  case 230400:
    cfsetispeed(&newtio, B230400);
    cfsetospeed(&newtio, B230400);
    break;
  default:
    cfsetispeed(&newtio, B9600);
    cfsetospeed(&newtio, B9600);
    break;
  }
  newtio.c_cc[VTIME] = 0;
  newtio.c_cc[VMIN] = 1;
  tcflush(fd, TCIFLUSH);
  if ((tcsetattr(fd, TCSANOW, &newtio)) != 0) {
    printf("com set error.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<config_uart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %cl,%al
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x48(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0x0,%rax
je     11b8 <config_uart+0x48>
lea    0xe59(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1570 <config_uart+0x400>
lea    -0x30(%rbp),%rdi
mov    $0x18,%esi
call   1090 <bzero@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%ecx
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
or     %eax,%ecx
mov    -0x30(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%ecx
not    %ecx
mov    -0x30(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x7,%eax
je     121a <config_uart+0xaa>
jmp    1209 <config_uart+0x99>
mov    -0x4c(%rbp),%eax
sub    $0x8,%eax
je     122e <config_uart+0xbe>
jmp    123d <config_uart+0xcd>
mov    0x2d2f(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    123d <config_uart+0xcd>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x50(%rbp)
sub    $0x45,%eax
je     12a6 <config_uart+0x136>
jmp    1252 <config_uart+0xe2>
mov    -0x50(%rbp),%eax
sub    $0x4e,%eax
je     12db <config_uart+0x16b>
jmp    1263 <config_uart+0xf3>
mov    -0x50(%rbp),%eax
sub    $0x4f,%eax
jne    12ed <config_uart+0x17d>
jmp    1274 <config_uart+0x104>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    12ed <config_uart+0x17d>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    12ed <config_uart+0x17d>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    130e <config_uart+0x19e>
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    132c <config_uart+0x1bc>
cmpl   $0x2,-0x18(%rbp)
jne    1327 <config_uart+0x1b7>
mov    0x2c39(%rip),%rax
mov    (%rax),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    132c <config_uart+0x1bc>
mov    -0xc(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x960,%eax
je     13b4 <config_uart+0x244>
jmp    1342 <config_uart+0x1d2>
mov    -0x54(%rbp),%eax
sub    $0x12c0,%eax
je     13dd <config_uart+0x26d>
jmp    1355 <config_uart+0x1e5>
mov    -0x54(%rbp),%eax
sub    $0x2580,%eax
je     1406 <config_uart+0x296>
jmp    1368 <config_uart+0x1f8>
mov    -0x54(%rbp),%eax
sub    $0x4b00,%eax
je     142f <config_uart+0x2bf>
jmp    137b <config_uart+0x20b>
mov    -0x54(%rbp),%eax
sub    $0x9600,%eax
je     1458 <config_uart+0x2e8>
jmp    138e <config_uart+0x21e>
mov    -0x54(%rbp),%eax
sub    $0x1c200,%eax
je     1481 <config_uart+0x311>
jmp    13a1 <config_uart+0x231>
mov    -0x54(%rbp),%eax
sub    $0x38400,%eax
je     14aa <config_uart+0x33a>
jmp    14d3 <config_uart+0x363>
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2be4(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2bd2(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2bb3(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2ba1(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2bba(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2ba8(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2ae1(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2acf(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2af0(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2ade(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2aaf(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2a9d(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
jmp    14f7 <config_uart+0x387>
mov    0x2ae6(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    -0x28(%rbp),%rax
mov    0x2a6e(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2a91(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%edi
mov    0x2a65(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    -0x8(%rbp),%edi
mov    0x2a9c(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1070 <tcsetattr@plt>
cmp    $0x0,%rax
je     1569 <config_uart+0x3f9>
lea    0xaba(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1570 <config_uart+0x400>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_uart>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r14d
lea    0x18(%rsp),%rsi
call   1060 <tcgetattr@plt>
test   %rax,%rax
je     11a4 <config_uart+0x34>
lea    0xe70(%rip),%rdi
jmp    1382 <config_uart+0x212>
mov    %rsp,%rdi
mov    $0x18,%esi
call   1090 <bzero@plt>
mov    0x2d90(%rip),%rax
mov    0x2df9(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     (%rsp),%ecx
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %ecx,%eax
mov    %eax,(%rsp)
cmp    $0x8,%ebp
je     11e9 <config_uart+0x79>
cmp    $0x7,%ebp
jne    11f5 <config_uart+0x85>
mov    0x2d69(%rip),%rcx
jmp    11f0 <config_uart+0x80>
mov    0x2dc0(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
movsbl %bl,%ecx
cmp    $0x45,%ecx
je     1244 <config_uart+0xd4>
cmp    $0x4e,%ecx
je     1263 <config_uart+0xf3>
cmp    $0x4f,%ecx
jne    1229 <config_uart+0xb9>
mov    0x2dd2(%rip),%rcx
or     (%rcx),%eax
mov    0x2db9(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
mov    0x2d5d(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,0x10(%rsp)
cmp    $0x2,%r15d
je     1279 <config_uart+0x109>
cmp    $0x1,%r15d
jne    1285 <config_uart+0x115>
mov    0x2d1c(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
jmp    1282 <config_uart+0x112>
mov    0x2d35(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,0x10(%rsp)
mov    0x2d88(%rip),%rcx
or     (%rcx),%eax
mov    0x2d6f(%rip),%rcx
jmp    126a <config_uart+0xfa>
mov    0x2d76(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,(%rsp)
cmp    $0x2,%r15d
jne    122f <config_uart+0xbf>
mov    0x2cd8(%rip),%rcx
or     (%rcx),%eax
mov    %eax,(%rsp)
cmp    $0x4aff,%r12d
jle    12b2 <config_uart+0x142>
cmp    $0x1c1ff,%r12d
jg     12d4 <config_uart+0x164>
cmp    $0x4b00,%r12d
je     12ef <config_uart+0x17f>
cmp    $0x9600,%r12d
jne    12cb <config_uart+0x15b>
mov    0x2c90(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
cmp    $0x960,%r12d
je     12f8 <config_uart+0x188>
cmp    $0x12c0,%r12d
je     130a <config_uart+0x19a>
cmp    $0x2580,%r12d
mov    0x2cee(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
cmp    $0x1c200,%r12d
je     1301 <config_uart+0x191>
cmp    $0x38400,%r12d
jne    12cb <config_uart+0x15b>
mov    0x2c73(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
mov    0x2cfa(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
mov    0x2c89(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
mov    0x2c70(%rip),%rbp
jmp    1311 <config_uart+0x1a1>
mov    0x2cb7(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <cfsetispeed@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1040 <cfsetospeed@plt>
mov    0x8(%rsp),%rax
mov    0x2c3a(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2c61(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2c38(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1050 <tcflush@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %rbx,%rdx
call   1070 <tcsetattr@plt>
test   %rax,%rax
je     1399 <config_uart+0x229>
lea    0xc7e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    138c <config_uart+0x21c>

LLVM IR (-O0):
%struct.termios = type { i32, i32*, i32 }
@.str = [18 x i8] c"tcgetattr error \0A\00"
@CLOCAL = global i32 0
@CREAD = global i32 0
@CSIZE = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@INPCK = global i32 0
@CSTOPB = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.1 = [16 x i8] c"com set error.\0A\00"
define i32 @config_uart(i32 %0, i32 %1, i32 %2, i8 signext %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
%12 = alloca %struct.termios
%13 = alloca %struct.termios
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8 %3, i8* %10
store i32 %4, i32* %11
%14 = load i32, i32* %7
%15 = call i64 @tcgetattr(i32 %14, %struct.termios* %13)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %6
br label %158
19: ; preds = %5
%20 = call i32 @bzero(%struct.termios* %12, i32 24)
%21 = load i32, i32* @CLOCAL
%22 = load i32, i32* @CREAD
%23 = or i32 %21, %22
%24 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%25 = load i32, i32* %24
%26 = or i32 %25, %23
store i32 %26, i32* %24
%27 = load i32, i32* @CSIZE
%28 = xor i32 %27, -1
%29 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%30 = load i32, i32* %29
%31 = and i32 %30, %28
store i32 %31, i32* %29
%32 = load i32, i32* %9
switch i32 %32, label %43 [
i32 7, label %33
i32 8, label %38
]
33: ; preds = %19
%34 = load i32, i32* @CS7
%35 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%36 = load i32, i32* %35
%37 = or i32 %36, %34
store i32 %37, i32* %35
br label %43
38: ; preds = %19
%39 = load i32, i32* @CS8
%40 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%41 = load i32, i32* %40
%42 = or i32 %41, %39
store i32 %42, i32* %40
br label %43
43: ; preds = %19, %38, %33
%44 = load i8, i8* %10
%45 = sext i8 %44 to i32
switch i32 %45, label %79 [
i32 79, label %46
i32 69, label %59
i32 78, label %73
]
46: ; preds = %43
%47 = load i32, i32* @PARENB
%48 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%49 = load i32, i32* %48
%50 = or i32 %49, %47
store i32 %50, i32* %48
%51 = load i32, i32* @PARODD
%52 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%53 = load i32, i32* %52
%54 = or i32 %53, %51
store i32 %54, i32* %52
%55 = load i32, i32* @INPCK
%56 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 2
%57 = load i32, i32* %56
%58 = or i32 %57, %55
store i32 %58, i32* %56
br label %79
59: ; preds = %43
%60 = load i32, i32* @INPCK
%61 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 2
%62 = load i32, i32* %61
%63 = or i32 %62, %60
store i32 %63, i32* %61
%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 = xor i32 %68, -1
%70 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%71 = load i32, i32* %70
%72 = and i32 %71, %69
store i32 %72, i32* %70
br label %79
73: ; preds = %43
%74 = load i32, i32* @PARENB
%75 = xor i32 %74, -1
%76 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%77 = load i32, i32* %76
%78 = and i32 %77, %75
store i32 %78, i32* %76
br label %79
79: ; preds = %43, %73, %59, %46
%80 = load i32, i32* %11
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = load i32, i32* @CSTOPB
%84 = xor i32 %83, -1
%85 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%86 = load i32, i32* %85
%87 = and i32 %86, %84
store i32 %87, i32* %85
br label %97
88: ; preds = %79
%89 = load i32, i32* %11
%90 = icmp eq i32 %89, 2
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = load i32, i32* @CSTOPB
%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 %96
96: ; preds = %91, %88
br label %97
97: ; preds = %96, %82
%98 = load i32, i32* %8
switch i32 %98, label %134 [
i32 2400, label %99
i32 4800, label %104
i32 9600, label %109
i32 19200, label %114
i32 38400, label %119
i32 115200, label %124
i32 230400, label %129
]
99: ; preds = %97
%100 = load i32, i32* @B2400
%101 = call i32 @cfsetispeed(%struct.termios* %12, i32 %100)
%102 = load i32, i32* @B2400
%103 = call i32 @cfsetospeed(%struct.termios* %12, i32 %102)
br label %139
104: ; preds = %97
%105 = load i32, i32* @B4800
%106 = call i32 @cfsetispeed(%struct.termios* %12, i32 %105)
%107 = load i32, i32* @B4800
%108 = call i32 @cfsetospeed(%struct.termios* %12, i32 %107)
br label %139
109: ; preds = %97
%110 = load i32, i32* @B9600
%111 = call i32 @cfsetispeed(%struct.termios* %12, i32 %110)
%112 = load i32, i32* @B9600
%113 = call i32 @cfsetospeed(%struct.termios* %12, i32 %112)
br label %139
114: ; preds = %97
%115 = load i32, i32* @B19200
%116 = call i32 @cfsetispeed(%struct.termios* %12, i32 %115)
%117 = load i32, i32* @B19200
%118 = call i32 @cfsetospeed(%struct.termios* %12, i32 %117)
br label %139
119: ; preds = %97
%120 = load i32, i32* @B38400
%121 = call i32 @cfsetispeed(%struct.termios* %12, i32 %120)
%122 = load i32, i32* @B38400
%123 = call i32 @cfsetospeed(%struct.termios* %12, i32 %122)
br label %139
124: ; preds = %97
%125 = load i32, i32* @B115200
%126 = call i32 @cfsetispeed(%struct.termios* %12, i32 %125)
%127 = load i32, i32* @B115200
%128 = call i32 @cfsetospeed(%struct.termios* %12, i32 %127)
br label %139
129: ; preds = %97
%130 = load i32, i32* @B230400
%131 = call i32 @cfsetispeed(%struct.termios* %12, i32 %130)
%132 = load i32, i32* @B230400
%133 = call i32 @cfsetospeed(%struct.termios* %12, i32 %132)
br label %139
134: ; preds = %97
%135 = load i32, i32* @B9600
%136 = call i32 @cfsetispeed(%struct.termios* %12, i32 %135)
%137 = load i32, i32* @B9600
%138 = call i32 @cfsetospeed(%struct.termios* %12, i32 %137)
br label %139
139: ; preds = %134, %129, %124, %119, %114, %109, %104, %99
%140 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%141 = load i32*, i32** %140
%142 = load i64, i64* @VTIME
%143 = getelementptr inbounds i32, i32* %141, i64 %142
store i32 0, i32* %143
%144 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 1
%145 = load i32*, i32** %144
%146 = load i64, i64* @VMIN
%147 = getelementptr inbounds i32, i32* %145, i64 %146
store i32 1, i32* %147
%148 = load i32, i32* %7
%149 = load i32, i32* @TCIFLUSH
%150 = call i32 @tcflush(i32 %148, i32 %149)
%151 = load i32, i32* %7
%152 = load i32, i32* @TCSANOW
%153 = call i64 @tcsetattr(i32 %151, i32 %152, %struct.termios* %12)
%154 = icmp ne i64 %153, 0
br i1 %154, label %155, label %157
155: ; preds = %139
%156 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %6
br label %158
157: ; preds = %139
store i32 0, i32* %6
br label %158
158: ; preds = %157, %155, %17
%159 = load i32, i32* %6
ret i32 %159
}

LLVM IR (-O2):
%struct.termios = type { i32, i32*, i32 }
@CLOCAL = global i32 0
@CREAD = global i32 0
@CSIZE = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@INPCK = global i32 0
@CSTOPB = global i32 0
@B2400 = global i32 0
@B4800 = global i32 0
@B9600 = global i32 0
@B19200 = global i32 0
@B38400 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@str = [15 x i8] c"com set error.\00"
@str.2 = [17 x i8] c"tcgetattr error \00"
define i32 @config_uart(i32 %0, i32 %1, i32 %2, i8 signext %3, i32 %4) {
%6 = alloca %struct.termios
%7 = alloca %struct.termios
%8 = bitcast %struct.termios* %6 to i8*
%9 = bitcast %struct.termios* %7 to i8*
%10 = call i64 @tcgetattr(i32 %0, %struct.termios* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %89
12: ; preds = %5
%13 = call i32 @bzero(%struct.termios* %6, i32 24)
%14 = load i32, i32* @CLOCAL
%15 = load i32, i32* @CREAD
%16 = or i32 %15, %14
%17 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 0
%18 = load i32, i32* %17
%19 = or i32 %16, %18
%20 = load i32, i32* @CSIZE
%21 = xor i32 %20, -1
%22 = and i32 %19, %21
store i32 %22, i32* %17
switch i32 %2, label %29 [
i32 7, label %23
i32 8, label %26
]
23: ; preds = %12
%24 = load i32, i32* @CS7
%25 = or i32 %24, %22
store i32 %25, i32* %17
br label %29
26: ; preds = %12
%27 = load i32, i32* @CS8
%28 = or i32 %27, %22
store i32 %28, i32* %17
br label %29
29: ; preds = %12, %26, %23
%30 = phi i32 [ %22, %12 ], [ %28, %26 ], [ %25, %23 ]
%31 = sext i8 %3 to i32
switch i32 %31, label %55 [
i32 79, label %32
i32 69, label %41
i32 78, label %51
]
32: ; preds = %29
%33 = load i32, i32* @PARENB
%34 = or i32 %30, %33
%35 = load i32, i32* @PARODD
%36 = or i32 %35, %34
store i32 %36, i32* %17
%37 = load i32, i32* @INPCK
%38 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 2
%39 = load i32, i32* %38
%40 = or i32 %39, %37
store i32 %40, i32* %38
br label %55
41: ; preds = %29
%42 = load i32, i32* @INPCK
%43 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 2
%44 = load i32, i32* %43
%45 = or i32 %44, %42
store i32 %45, i32* %43
%46 = load i32, i32* @PARENB
%47 = or i32 %30, %46
%48 = load i32, i32* @PARODD
%49 = xor i32 %48, -1
%50 = and i32 %47, %49
store i32 %50, i32* %17
br label %55
51: ; preds = %29
%52 = load i32, i32* @PARENB
%53 = xor i32 %52, -1
%54 = and i32 %30, %53
store i32 %54, i32* %17
br label %55
55: ; preds = %29, %51, %41, %32
%56 = phi i32 [ %30, %29 ], [ %54, %51 ], [ %50, %41 ], [ %36, %32 ]
switch i32 %4, label %64 [
i32 1, label %57
i32 2, label %61
]
57: ; preds = %55
%58 = load i32, i32* @CSTOPB
%59 = xor i32 %58, -1
%60 = and i32 %56, %59
store i32 %60, i32* %17
br label %64
61: ; preds = %55
%62 = load i32, i32* @CSTOPB
%63 = or i32 %56, %62
store i32 %63, i32* %17
br label %64
64: ; preds = %55, %61, %57
switch i32 %1, label %71 [
i32 2400, label %72
i32 4800, label %65
i32 9600, label %66
i32 19200, label %67
i32 38400, label %68
i32 115200, label %69
i32 230400, label %70
]
65: ; preds = %64
br label %72
66: ; preds = %64
br label %72
67: ; preds = %64
br label %72
68: ; preds = %64
br label %72
69: ; preds = %64
br label %72
70: ; preds = %64
br label %72
71: ; preds = %64
br label %72
72: ; preds = %64, %71, %70, %69, %68, %67, %66, %65
%73 = phi i32* [ @B9600, %71 ], [ @B230400, %70 ], [ @B115200, %69 ], [ @B38400, %68 ], [ @B19200, %67 ], [ @B9600, %66 ], [ @B4800, %65 ], [ @B2400, %64 ]
%74 = load i32, i32* %73
%75 = call i32 @cfsetispeed(%struct.termios* %6, i32 %74)
%76 = load i32, i32* %73
%77 = call i32 @cfsetospeed(%struct.termios* %6, i32 %76)
%78 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 1
%79 = load i32*, i32** %78
%80 = load i64, i64* @VTIME
%81 = getelementptr inbounds i32, i32* %79, i64 %80
store i32 0, i32* %81
%82 = load i64, i64* @VMIN
%83 = getelementptr inbounds i32, i32* %79, i64 %82
store i32 1, i32* %83
%84 = load i32, i32* @TCIFLUSH
%85 = call i32 @tcflush(i32 %0, i32 %84)
%86 = load i32, i32* @TCSANOW
%87 = call i64 @tcsetattr(i32 %0, i32 %86, %struct.termios* %6)
%88 = icmp eq i64 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %72, %5
%90 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0), %72 ]
%91 = call i32 @puts(i8* dereferenceable(1) %90)
br label %92
92: ; preds = %89, %72
%93 = phi i32 [ 0, %72 ], [ -1, %89 ]
ret i32 %93
}