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

/* Variables and functions */
int /*<<< orphan*/ B115200;
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ICRNL;
int IGNCR;
int INLCR;
int ISIG;
int IXANY;
int IXOFF;
int IXON;
int NOFLSH;
int OCRNL;
int ONLCR;
int ONLRET;
int OPOST;
int PARENB;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCSANOW;
int TOSTOP;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void termConfigRaw(int fd, struct termios *saved) {
  struct termios newtio;
  tcgetattr(fd, saved);
  newtio = *saved;
  cfsetispeed(&newtio, B115200);
  cfsetospeed(&newtio, B115200);
  newtio.c_cflag |= (CLOCAL | CREAD);
  newtio.c_cflag &= ~PARENB;
  newtio.c_cflag &= ~CSTOPB;
  newtio.c_cflag &= ~CSIZE;
  newtio.c_cflag |= CS8;
  newtio.c_cflag &= ~CRTSCTS;
  newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | NOFLSH | TOSTOP);
  newtio.c_lflag = 0;
  newtio.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL | INLCR | IGNCR);
  newtio.c_oflag &= ~(OPOST | ONLCR | OCRNL | ONLRET);
  newtio.c_cc[VTIME] = 0;
  newtio.c_cc[VMIN] = 0;
  tcflush(fd, TCIFLUSH);
  tcsetattr(fd, TCSANOW, &newtio);
}


x86 assembly (clang, -O0):
<termConfigRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <tcgetattr@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,-0x28(%rbp)
mov    0x8(%rax),%rcx
mov    %rcx,-0x20(%rbp)
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1070 <cfsetispeed@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
mov    0x2dc6(%rip),%rcx
or     (%rcx),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
mov    0x2d6f(%rip),%rcx
or     (%rcx),%eax
mov    0x2d5e(%rip),%rcx
or     (%rcx),%eax
mov    0x2d4d(%rip),%rcx
or     (%rcx),%eax
mov    0x2d1c(%rip),%rcx
or     (%rcx),%eax
mov    0x2d93(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    0x2d59(%rip),%rcx
or     (%rcx),%eax
mov    0x2cd8(%rip),%rcx
or     (%rcx),%eax
mov    0x2d57(%rip),%rcx
or     (%rcx),%eax
mov    0x2d46(%rip),%rcx
or     (%rcx),%eax
mov    0x2d2d(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
mov    0x2c8a(%rip),%rcx
or     (%rcx),%eax
mov    0x2d39(%rip),%rcx
or     (%rcx),%eax
mov    0x2c68(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c5a(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    0x2c84(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
mov    0x2c47(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    -0x4(%rbp),%edi
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <tcsetattr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<termConfigRaw>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
call   1050 <tcgetattr@plt>
movups (%rbx),%xmm0
movaps %xmm0,(%rsp)
mov    0x10(%rbx),%rax
mov    %rax,0x10(%rsp)
mov    0x2def(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <cfsetispeed@plt>
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <cfsetospeed@plt>
mov    0x2d99(%rip),%rax
mov    0x2e02(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     (%rsp),%ecx
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    0x2d83(%rip),%rdx
or     (%rdx),%eax
mov    0x2dca(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %ecx,%eax
mov    0x2dcd(%rip),%rcx
or     (%rcx),%eax
mov    0x2de4(%rip),%rcx
mov    0x2df5(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d5a(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x2d85(%rip),%rax
or     (%rax),%edx
mov    %ecx,(%rsp)
mov    0x2de1(%rip),%rax
or     (%rax),%edx
movl   $0x0,0x4(%rsp)
mov    0x2dc8(%rip),%rax
or     (%rax),%edx
mov    0x2daf(%rip),%rax
or     (%rax),%edx
not    %edx
and    %edx,0x8(%rsp)
mov    0x2d98(%rip),%rax
mov    0x2d31(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2db6(%rip),%rax
or     (%rax),%ecx
mov    0x2d0d(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0xc(%rsp)
mov    0x10(%rsp),%rax
mov    0x2d01(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d27(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1040 <tcflush@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1060 <tcsetattr@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32, i64* }
@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
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@NOFLSH = global i32 0
@TOSTOP = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@OCRNL = global i32 0
@ONLRET = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
define void @termConfigRaw(i32 %0, %struct.termios* %1) {
%3 = alloca i32
%4 = alloca %struct.termios*
%5 = alloca %struct.termios
store i32 %0, i32* %3
store %struct.termios* %1, %struct.termios** %4
%6 = load i32, i32* %3
%7 = load %struct.termios*, %struct.termios** %4
%8 = call i32 @tcgetattr(i32 %6, %struct.termios* %7)
%9 = load %struct.termios*, %struct.termios** %4
%10 = bitcast %struct.termios* %5 to i8*
%11 = bitcast %struct.termios* %9 to i8*
%12 = load i32, i32* @B115200
%13 = call i32 @cfsetispeed(%struct.termios* %5, i32 %12)
%14 = load i32, i32* @B115200
%15 = call i32 @cfsetospeed(%struct.termios* %5, i32 %14)
%16 = load i32, i32* @CLOCAL
%17 = load i32, i32* @CREAD
%18 = or i32 %16, %17
%19 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%20 = load i32, i32* %19
%21 = or i32 %20, %18
store i32 %21, i32* %19
%22 = load i32, i32* @PARENB
%23 = xor i32 %22, -1
%24 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%25 = load i32, i32* %24
%26 = and i32 %25, %23
store i32 %26, i32* %24
%27 = load i32, i32* @CSTOPB
%28 = xor i32 %27, -1
%29 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%30 = load i32, i32* %29
%31 = and i32 %30, %28
store i32 %31, i32* %29
%32 = load i32, i32* @CSIZE
%33 = xor i32 %32, -1
%34 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%35 = load i32, i32* %34
%36 = and i32 %35, %33
store i32 %36, i32* %34
%37 = load i32, i32* @CS8
%38 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%39 = load i32, i32* %38
%40 = or i32 %39, %37
store i32 %40, i32* %38
%41 = load i32, i32* @CRTSCTS
%42 = xor i32 %41, -1
%43 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%44 = load i32, i32* %43
%45 = and i32 %44, %42
store i32 %45, i32* %43
%46 = load i32, i32* @ICANON
%47 = load i32, i32* @ECHO
%48 = or i32 %46, %47
%49 = load i32, i32* @ECHOE
%50 = or i32 %48, %49
%51 = load i32, i32* @ISIG
%52 = or i32 %50, %51
%53 = load i32, i32* @NOFLSH
%54 = or i32 %52, %53
%55 = load i32, i32* @TOSTOP
%56 = or i32 %54, %55
%57 = xor i32 %56, -1
%58 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 1
%59 = load i32, i32* %58
%60 = and i32 %59, %57
store i32 %60, i32* %58
%61 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 1
store i32 0, i32* %61
%62 = load i32, i32* @IXON
%63 = load i32, i32* @IXOFF
%64 = or i32 %62, %63
%65 = load i32, i32* @IXANY
%66 = or i32 %64, %65
%67 = load i32, i32* @ICRNL
%68 = or i32 %66, %67
%69 = load i32, i32* @INLCR
%70 = or i32 %68, %69
%71 = load i32, i32* @IGNCR
%72 = or i32 %70, %71
%73 = xor i32 %72, -1
%74 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%75 = load i32, i32* %74
%76 = and i32 %75, %73
store i32 %76, i32* %74
%77 = load i32, i32* @OPOST
%78 = load i32, i32* @ONLCR
%79 = or i32 %77, %78
%80 = load i32, i32* @OCRNL
%81 = or i32 %79, %80
%82 = load i32, i32* @ONLRET
%83 = or i32 %81, %82
%84 = xor i32 %83, -1
%85 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 3
%86 = load i32, i32* %85
%87 = and i32 %86, %84
store i32 %87, i32* %85
%88 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 4
%89 = load i64*, i64** %88
%90 = load i64, i64* @VTIME
%91 = getelementptr inbounds i64, i64* %89, i64 %90
store i64 0, i64* %91
%92 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 4
%93 = load i64*, i64** %92
%94 = load i64, i64* @VMIN
%95 = getelementptr inbounds i64, i64* %93, i64 %94
store i64 0, i64* %95
%96 = load i32, i32* %3
%97 = load i32, i32* @TCIFLUSH
%98 = call i32 @tcflush(i32 %96, i32 %97)
%99 = load i32, i32* %3
%100 = load i32, i32* @TCSANOW
%101 = call i32 @tcsetattr(i32 %99, i32 %100, %struct.termios* %5)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32, i64* }
@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
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@NOFLSH = global i32 0
@TOSTOP = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICRNL = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@OCRNL = global i32 0
@ONLRET = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
define void @termConfigRaw(i32 %0, %struct.termios* %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = tail call i32 @tcgetattr(i32 %0, %struct.termios* %1)
%6 = bitcast %struct.termios* %1 to i8*
%7 = load i32, i32* @B115200
%8 = call i32 @cfsetispeed(%struct.termios* %3, i32 %7)
%9 = load i32, i32* @B115200
%10 = call i32 @cfsetospeed(%struct.termios* %3, i32 %9)
%11 = load i32, i32* @CLOCAL
%12 = load i32, i32* @CREAD
%13 = or i32 %12, %11
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = or i32 %13, %15
%17 = load i32, i32* @PARENB
%18 = load i32, i32* @CSTOPB
%19 = or i32 %17, %18
%20 = load i32, i32* @CSIZE
%21 = or i32 %19, %20
%22 = xor i32 %21, -1
%23 = and i32 %16, %22
%24 = load i32, i32* @CS8
%25 = or i32 %24, %23
%26 = load i32, i32* @CRTSCTS
%27 = xor i32 %26, -1
%28 = and i32 %25, %27
store i32 %28, i32* %14
%29 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
store i32 0, i32* %29
%30 = load i32, i32* @IXON
%31 = load i32, i32* @IXOFF
%32 = or i32 %31, %30
%33 = load i32, i32* @IXANY
%34 = or i32 %32, %33
%35 = load i32, i32* @ICRNL
%36 = or i32 %34, %35
%37 = load i32, i32* @INLCR
%38 = or i32 %36, %37
%39 = load i32, i32* @IGNCR
%40 = or i32 %38, %39
%41 = xor i32 %40, -1
%42 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%43 = load i32, i32* %42
%44 = and i32 %43, %41
store i32 %44, i32* %42
%45 = load i32, i32* @OPOST
%46 = load i32, i32* @ONLCR
%47 = or i32 %46, %45
%48 = load i32, i32* @OCRNL
%49 = or i32 %47, %48
%50 = load i32, i32* @ONLRET
%51 = or i32 %49, %50
%52 = xor i32 %51, -1
%53 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%54 = load i32, i32* %53
%55 = and i32 %54, %52
store i32 %55, i32* %53
%56 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 4
%57 = load i64*, i64** %56
%58 = load i64, i64* @VTIME
%59 = getelementptr inbounds i64, i64* %57, i64 %58
store i64 0, i64* %59
%60 = load i64, i64* @VMIN
%61 = getelementptr inbounds i64, i64* %57, i64 %60
store i64 0, i64* %61
%62 = load i32, i32* @TCIFLUSH
%63 = call i32 @tcflush(i32 %0, i32 %62)
%64 = load i32, i32* @TCSANOW
%65 = call i32 @tcsetattr(i32 %0, i32 %64, %struct.termios* %3)
ret void
}