#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;
  int c_lflag;
  int /*<<< orphan*/ c_cc;
};
typedef int /*<<< orphan*/ com_options;

/* Variables and functions */
int /*<<< orphan*/ B115200;
int BRKINT;
int BS0;
int CLOCAL;
int CR0;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ECHOK;
int ECHONL;
int FF0;
int ICANON;
int ICRNL;
int IGNBRK;
int IGNCR;
int IGNPAR;
int INLCR;
int INPCK;
int ISIG;
int ISTRIP;
int IUCLC;
int IXANY;
int IXOFF;
int IXON;
int NL0;
int NOFLSH;
int OCRNL;
int OFDEL;
int OFILL;
int OLCUC;
int ONLCR;
int ONLRET;
int ONOCR;
int OPOST;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int O_SYNC;
int PARENB;
int PARMRK;
int TAB0;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
int VT0;
int XCASE;
int /*<<< orphan*/ bzero(struct termios *, int);
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int open_uart(char *pcDriverName) {
  int fd = -1;
  struct termios com_options;
  fd = open(pcDriverName, O_RDWR | O_NONBLOCK | O_NOCTTY | O_SYNC);
  if (fd < 0) {
    perror("open uart");
    exit(1);
  }
  bzero(&com_options, sizeof(com_options));
  tcgetattr(fd, &com_options);
  cfmakeraw(&com_options);
  cfsetispeed(&com_options, B115200);
  cfsetospeed(&com_options, B115200);
  com_options.c_cflag |= (CLOCAL | CREAD);
  com_options.c_cflag |= PARENB;
  com_options.c_cflag &= ~CSTOPB;
  com_options.c_cflag &= ~CSIZE;
  com_options.c_cflag |= CS8;
  com_options.c_cflag &= ~CRTSCTS;
  com_options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK);
  com_options.c_iflag &= ~(IXON | IXOFF | IXANY);
  com_options.c_iflag &= ~(IGNPAR | INPCK | ISTRIP);
  com_options.c_iflag &= ~(INLCR | IGNCR | ICRNL);
  com_options.c_iflag &= ~(IUCLC);
  com_options.c_iflag &= ~(OPOST | OLCUC | ONLCR);
  com_options.c_iflag &= ~(OCRNL | ONOCR | ONLRET);
  com_options.c_iflag &= ~(OFILL | OFDEL);
  com_options.c_iflag &= ~(NL0 | CR0 | TAB0 | BS0);
  com_options.c_iflag &= ~(VT0 | FF0);
  com_options.c_lflag &= ~(ISIG | ICANON | XCASE);
  com_options.c_lflag &= ~(NOFLSH | ECHO | ECHOE);
  com_options.c_lflag &= ~(ECHOK | ECHONL);
  memset(&com_options.c_cc, 0, sizeof(com_options.c_cc));
  tcflush(fd, TCIOFLUSH);
  tcsetattr(fd, TCSANOW, &com_options);
  return fd;
}


x86 assembly (clang, -O0):
<open_uart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
mov    0x2dd1(%rip),%rax
or     (%rax),%esi
mov    0x2d20(%rip),%rax
or     (%rax),%esi
mov    0x2dd7(%rip),%rax
or     (%rax),%esi
call   2090 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    2213 <open_uart+0x63>
lea    0xdfc(%rip),%rdi
call   20b0 <perror@plt>
mov    $0x1,%edi
call   20d0 <exit@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   20c0 <bzero@plt>
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   2070 <tcgetattr@plt>
lea    -0x20(%rbp),%rdi
call   2060 <cfmakeraw@plt>
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdi
call   20a0 <cfsetispeed@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdi
call   2030 <cfsetospeed@plt>
mov    0x2bf7(%rip),%rax
mov    (%rax),%eax
mov    0x2cc6(%rip),%rcx
or     (%rcx),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2bd8(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c86(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2bad(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2bfb(%rip),%rax
mov    (%rax),%eax
mov    0x2c72(%rip),%rcx
or     (%rcx),%eax
mov    0x2d09(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
mov    0x2cbe(%rip),%rcx
or     (%rcx),%eax
mov    0x2c05(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b8b(%rip),%rax
mov    (%rax),%eax
mov    0x2bda(%rip),%rcx
or     (%rcx),%eax
mov    0x2bb1(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%eax
mov    0x2c56(%rip),%rcx
or     (%rcx),%eax
mov    0x2c85(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b33(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c19(%rip),%rax
mov    (%rax),%eax
mov    0x2bc0(%rip),%rcx
or     (%rcx),%eax
mov    0x2b2f(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c5d(%rip),%rax
mov    (%rax),%eax
mov    0x2c14(%rip),%rcx
or     (%rcx),%eax
mov    0x2ae3(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b31(%rip),%rax
mov    (%rax),%eax
mov    0x2ab8(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2ad6(%rip),%rax
mov    (%rax),%eax
mov    0x2abd(%rip),%rcx
or     (%rcx),%eax
mov    0x2adc(%rip),%rcx
or     (%rcx),%eax
mov    0x2ba3(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b41(%rip),%rax
mov    (%rax),%eax
mov    0x2b98(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b36(%rip),%rax
mov    (%rax),%eax
mov    0x2a5d(%rip),%rcx
or     (%rcx),%eax
mov    0x2b3c(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2ada(%rip),%rax
mov    (%rax),%eax
mov    0x2b19(%rip),%rcx
or     (%rcx),%eax
mov    0x2b08(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2a8e(%rip),%rax
mov    (%rax),%eax
mov    0x2a65(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
add    $0xc,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   2050 <memset@plt>
mov    -0xc(%rbp),%edi
mov    0x2a4c(%rip),%rax
mov    (%rax),%esi
call   2040 <tcflush@plt>
mov    -0xc(%rbp),%edi
mov    0x2acb(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   2080 <tcsetattr@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_uart>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e19(%rip),%rax
mov    0x2de2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d2f(%rip),%rax
or     (%rax),%esi
mov    0x2de6(%rip),%rax
or     (%rax),%esi
call   2090 <open@plt>
test   %eax,%eax
js     240f <open_uart+0x25f>
mov    %eax,%ebp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x10,%esi
call   20c0 <bzero@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   2070 <tcgetattr@plt>
mov    %r14,%rdi
call   2060 <cfmakeraw@plt>
mov    0x2ca4(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
call   20a0 <cfsetispeed@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   2030 <cfsetospeed@plt>
mov    0x2c29(%rip),%rax
mov    0x2cfa(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     (%rsp),%ecx
mov    0x2d34(%rip),%rax
or     (%rax),%ecx
mov    0x2c13(%rip),%rax
mov    (%rax),%eax
mov    0x2cca(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %ecx,%eax
mov    0x2cc5(%rip),%rcx
or     (%rcx),%eax
mov    0x2c5c(%rip),%rcx
mov    0x2cd5(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d6a(%rip),%rcx
or     (%rcx),%edx
mov    0x2cf9(%rip),%rcx
mov    0x2d2a(%rip),%rsi
mov    (%rsi),%esi
or     (%rcx),%esi
mov    0x2c6f(%rip),%rcx
or     (%rcx),%esi
or     %edx,%esi
mov    0x2bfc(%rip),%rcx
mov    0x2c4d(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2c22(%rip),%rcx
or     (%rcx),%edx
mov    0x2d09(%rip),%rdi
mov    0x2cd2(%rip),%rcx
mov    (%rcx),%ecx
or     (%rdi),%ecx
mov    0x2cff(%rip),%rdi
or     (%rdi),%ecx
or     %edx,%ecx
or     %esi,%ecx
mov    0x2bb2(%rip),%rdx
or     (%rdx),%ecx
mov    0x2ca1(%rip),%rdx
mov    0x2c4a(%rip),%rsi
mov    (%rsi),%esi
or     (%rdx),%esi
mov    0x2bb7(%rip),%rdx
or     (%rdx),%esi
mov    0x2cee(%rip),%rdx
mov    0x2ca7(%rip),%rdi
mov    (%rdi),%edi
or     (%rdx),%edi
mov    0x2b54(%rip),%rdx
mov    (%rdx),%edx
not    %edx
and    %eax,%edx
mov    0x2b67(%rip),%rax
or     (%rax),%edi
mov    %edx,(%rsp)
or     %esi,%edi
mov    0x2bb9(%rip),%rax
mov    0x2b42(%rip),%rdx
mov    (%rdx),%edx
or     (%rax),%edx
mov    0x2b67(%rip),%rax
mov    0x2b50(%rip),%rsi
mov    (%rsi),%esi
or     (%rax),%esi
or     %edi,%edx
mov    0x2b6b(%rip),%rax
or     (%rax),%esi
mov    0x2c32(%rip),%rax
or     (%rax),%esi
mov    0x2bd9(%rip),%rax
mov    0x2c32(%rip),%rdi
mov    (%rdi),%edi
or     (%rax),%edi
or     %edx,%esi
or     %esi,%edi
or     %ecx,%edi
not    %edi
and    %edi,0x4(%rsp)
mov    0x2bcb(%rip),%rax
mov    0x2af4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2bd1(%rip),%rax
or     (%rax),%ecx
mov    0x2b78(%rip),%rax
mov    0x2bb9(%rip),%rdx
mov    (%rdx),%edx
or     (%rax),%edx
mov    0x2ba6(%rip),%rax
or     (%rax),%edx
or     %ecx,%edx
mov    0x2b33(%rip),%rax
mov    0x2b0c(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %edx,%ecx
not    %ecx
and    %ecx,0x8(%rsp)
lea    0xc(%rsp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   2050 <memset@plt>
mov    0x2af8(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   2040 <tcflush@plt>
mov    0x2b78(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   2080 <tcsetattr@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xbea(%rip),%rdi
call   20b0 <perror@plt>
mov    $0x1,%edi
call   20d0 <exit@plt>

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

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32 }
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@O_NOCTTY = global i32 0
@O_SYNC = global i32 0
@.str = [10 x i8] c"open uart\00"
@B115200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@IGNBRK = global i32 0
@BRKINT = global i32 0
@PARMRK = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@IGNPAR = global i32 0
@INPCK = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@IUCLC = global i32 0
@OPOST = global i32 0
@OLCUC = global i32 0
@ONLCR = global i32 0
@OCRNL = global i32 0
@ONOCR = global i32 0
@ONLRET = global i32 0
@OFILL = global i32 0
@OFDEL = global i32 0
@NL0 = global i32 0
@CR0 = global i32 0
@TAB0 = global i32 0
@BS0 = global i32 0
@VT0 = global i32 0
@FF0 = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@XCASE = global i32 0
@NOFLSH = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@TCIOFLUSH = global i32 0
@TCSANOW = global i32 0
define i32 @open_uart(i8* nocapture %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @O_RDWR
%5 = load i32, i32* @O_NONBLOCK
%6 = or i32 %5, %4
%7 = load i32, i32* @O_NOCTTY
%8 = or i32 %6, %7
%9 = load i32, i32* @O_SYNC
%10 = or i32 %8, %9
%11 = tail call i32 @open(i8* %0, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %1
%17 = call i32 @bzero(%struct.termios* %2, i32 16)
%18 = call i32 @tcgetattr(i32 %11, %struct.termios* %2)
%19 = call i32 @cfmakeraw(%struct.termios* %2)
%20 = load i32, i32* @B115200
%21 = call i32 @cfsetispeed(%struct.termios* %2, i32 %20)
%22 = load i32, i32* @B115200
%23 = call i32 @cfsetospeed(%struct.termios* %2, i32 %22)
%24 = load i32, i32* @CLOCAL
%25 = load i32, i32* @CREAD
%26 = or i32 %25, %24
%27 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%28 = load i32, i32* %27
%29 = or i32 %26, %28
%30 = load i32, i32* @PARENB
%31 = or i32 %30, %29
%32 = load i32, i32* @CSTOPB
%33 = load i32, i32* @CSIZE
%34 = or i32 %32, %33
%35 = xor i32 %34, -1
%36 = and i32 %31, %35
%37 = load i32, i32* @CS8
%38 = or i32 %37, %36
%39 = load i32, i32* @CRTSCTS
%40 = xor i32 %39, -1
%41 = and i32 %38, %40
store i32 %41, i32* %27
%42 = load i32, i32* @IGNBRK
%43 = load i32, i32* @BRKINT
%44 = or i32 %43, %42
%45 = load i32, i32* @PARMRK
%46 = or i32 %44, %45
%47 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%48 = load i32, i32* %47
%49 = load i32, i32* @IXON
%50 = load i32, i32* @IXOFF
%51 = or i32 %50, %49
%52 = load i32, i32* @IXANY
%53 = or i32 %51, %52
%54 = or i32 %46, %53
%55 = load i32, i32* @IGNPAR
%56 = load i32, i32* @INPCK
%57 = or i32 %56, %55
%58 = load i32, i32* @ISTRIP
%59 = or i32 %57, %58
%60 = or i32 %54, %59
%61 = load i32, i32* @INLCR
%62 = load i32, i32* @IGNCR
%63 = or i32 %62, %61
%64 = load i32, i32* @ICRNL
%65 = or i32 %63, %64
%66 = or i32 %60, %65
%67 = load i32, i32* @IUCLC
%68 = or i32 %66, %67
%69 = load i32, i32* @OPOST
%70 = load i32, i32* @OLCUC
%71 = or i32 %70, %69
%72 = load i32, i32* @ONLCR
%73 = or i32 %71, %72
%74 = or i32 %68, %73
%75 = load i32, i32* @OCRNL
%76 = load i32, i32* @ONOCR
%77 = or i32 %76, %75
%78 = load i32, i32* @ONLRET
%79 = or i32 %77, %78
%80 = or i32 %74, %79
%81 = load i32, i32* @OFILL
%82 = load i32, i32* @OFDEL
%83 = or i32 %82, %81
%84 = or i32 %80, %83
%85 = load i32, i32* @NL0
%86 = load i32, i32* @CR0
%87 = or i32 %86, %85
%88 = load i32, i32* @TAB0
%89 = or i32 %87, %88
%90 = load i32, i32* @BS0
%91 = or i32 %89, %90
%92 = or i32 %84, %91
%93 = load i32, i32* @VT0
%94 = load i32, i32* @FF0
%95 = or i32 %94, %93
%96 = or i32 %92, %95
%97 = xor i32 %96, -1
%98 = and i32 %48, %97
store i32 %98, i32* %47
%99 = load i32, i32* @ISIG
%100 = load i32, i32* @ICANON
%101 = or i32 %100, %99
%102 = load i32, i32* @XCASE
%103 = or i32 %101, %102
%104 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 2
%105 = load i32, i32* %104
%106 = load i32, i32* @NOFLSH
%107 = load i32, i32* @ECHO
%108 = or i32 %107, %106
%109 = load i32, i32* @ECHOE
%110 = or i32 %108, %109
%111 = or i32 %103, %110
%112 = load i32, i32* @ECHOK
%113 = load i32, i32* @ECHONL
%114 = or i32 %113, %112
%115 = or i32 %111, %114
%116 = xor i32 %115, -1
%117 = and i32 %105, %116
store i32 %117, i32* %104
%118 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 3
%119 = call i32 @memset(i32* %118, i32 0, i32 4)
%120 = load i32, i32* @TCIOFLUSH
%121 = call i32 @tcflush(i32 %11, i32 %120)
%122 = load i32, i32* @TCSANOW
%123 = call i32 @tcsetattr(i32 %11, i32 %122, %struct.termios* %2)
ret i32 %11
}