#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_iflag;
  int c_lflag;
  int c_cflag;
  int /*<<< orphan*/ c_oflag;
};

/* Variables and functions */
int BRKINT;
int CS8;
int CSIZE;
int ECHO;
int ECHONL;
int ICANON;
int ICRNL;
int IEXTEN;
int IGNBRK;
int IGNCR;
int INLCR;
int ISIG;
int ISTRIP;
int IXON;
int /*<<< orphan*/ OPOST;
int PARENB;
int PARMRK;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void setrawmode(void) {
  struct termios term;
  (void)tcgetattr(0, &term);
  term.c_iflag &=
      ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  term.c_oflag &= ~OPOST;
  term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
  term.c_cflag &= ~(CSIZE | PARENB);
  term.c_cflag |= CS8;
  (void)tcsetattr(0, TCSANOW, &term);
}


x86 assembly (clang, -O0):
<setrawmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   1030 <tcgetattr@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    0x2e55(%rip),%rcx
or     (%rcx),%eax
mov    0x2ea4(%rip),%rcx
or     (%rcx),%eax
mov    0x2e1b(%rip),%rcx
or     (%rcx),%eax
mov    0x2e7a(%rip),%rcx
or     (%rcx),%eax
mov    0x2e69(%rip),%rcx
or     (%rcx),%eax
mov    0x2e70(%rip),%rcx
or     (%rcx),%eax
mov    0x2e47(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    0x2dc2(%rip),%rcx
or     (%rcx),%eax
mov    0x2da9(%rip),%rcx
or     (%rcx),%eax
mov    0x2de8(%rip),%rcx
or     (%rcx),%eax
mov    0x2dbf(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    0x2ddc(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x10(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setrawmode>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <tcgetattr@plt>
mov    0x2e27(%rip),%rax
mov    0x2e58(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ea5(%rip),%rax
or     (%rax),%ecx
mov    0x2e1c(%rip),%rax
or     (%rax),%ecx
mov    0x2e7b(%rip),%rax
or     (%rax),%ecx
mov    0x2e6a(%rip),%rax
or     (%rax),%ecx
mov    0x2e71(%rip),%rax
or     (%rax),%ecx
mov    0x2e48(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0xc(%rsp)
mov    0x2e13(%rip),%rax
mov    0x2dcc(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2db1(%rip),%rax
or     (%rax),%ecx
mov    0x2df0(%rip),%rax
or     (%rax),%ecx
mov    0x2dc7(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2dc0(%rip),%rax
mov    0x2de9(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    0x8(%rsp),%ecx
mov    0x2db0(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    %rbx,%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32 }
@IGNBRK = global i32 0
@BRKINT = global i32 0
@PARMRK = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@OPOST = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
define void @setrawmode() {
%1 = alloca %struct.termios
%2 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%3 = load i32, i32* @IGNBRK
%4 = load i32, i32* @BRKINT
%5 = or i32 %3, %4
%6 = load i32, i32* @PARMRK
%7 = or i32 %5, %6
%8 = load i32, i32* @ISTRIP
%9 = or i32 %7, %8
%10 = load i32, i32* @INLCR
%11 = or i32 %9, %10
%12 = load i32, i32* @IGNCR
%13 = or i32 %11, %12
%14 = load i32, i32* @ICRNL
%15 = or i32 %13, %14
%16 = load i32, i32* @IXON
%17 = or i32 %15, %16
%18 = xor i32 %17, -1
%19 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 0
%20 = load i32, i32* %19
%21 = and i32 %20, %18
store i32 %21, i32* %19
%22 = load i32, i32* @OPOST
%23 = xor i32 %22, -1
%24 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 3
%25 = load i32, i32* %24
%26 = and i32 %25, %23
store i32 %26, i32* %24
%27 = load i32, i32* @ECHO
%28 = load i32, i32* @ECHONL
%29 = or i32 %27, %28
%30 = load i32, i32* @ICANON
%31 = or i32 %29, %30
%32 = load i32, i32* @ISIG
%33 = or i32 %31, %32
%34 = load i32, i32* @IEXTEN
%35 = or i32 %33, %34
%36 = xor i32 %35, -1
%37 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 1
%38 = load i32, i32* %37
%39 = and i32 %38, %36
store i32 %39, i32* %37
%40 = load i32, i32* @CSIZE
%41 = load i32, i32* @PARENB
%42 = or i32 %40, %41
%43 = xor i32 %42, -1
%44 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 2
%45 = load i32, i32* %44
%46 = and i32 %45, %43
store i32 %46, i32* %44
%47 = load i32, i32* @CS8
%48 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 2
%49 = load i32, i32* %48
%50 = or i32 %49, %47
store i32 %50, i32* %48
%51 = load i32, i32* @TCSANOW
%52 = call i32 @tcsetattr(i32 0, i32 %51, %struct.termios* %1)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32 }
@IGNBRK = global i32 0
@BRKINT = global i32 0
@PARMRK = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@OPOST = global i32 0
@ECHO = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
define void @setrawmode() {
%1 = alloca %struct.termios
%2 = bitcast %struct.termios* %1 to i8*
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%4 = load i32, i32* @IGNBRK
%5 = load i32, i32* @BRKINT
%6 = or i32 %5, %4
%7 = load i32, i32* @PARMRK
%8 = or i32 %6, %7
%9 = load i32, i32* @ISTRIP
%10 = or i32 %8, %9
%11 = load i32, i32* @INLCR
%12 = or i32 %10, %11
%13 = load i32, i32* @IGNCR
%14 = or i32 %12, %13
%15 = load i32, i32* @ICRNL
%16 = or i32 %14, %15
%17 = load i32, i32* @IXON
%18 = or i32 %16, %17
%19 = xor i32 %18, -1
%20 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%21 = load i32, i32* %20
%22 = and i32 %21, %19
store i32 %22, i32* %20
%23 = load i32, i32* @OPOST
%24 = xor i32 %23, -1
%25 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 3
%26 = load i32, i32* %25
%27 = and i32 %26, %24
store i32 %27, i32* %25
%28 = load i32, i32* @ECHO
%29 = load i32, i32* @ECHONL
%30 = or i32 %29, %28
%31 = load i32, i32* @ICANON
%32 = or i32 %30, %31
%33 = load i32, i32* @ISIG
%34 = or i32 %32, %33
%35 = load i32, i32* @IEXTEN
%36 = or i32 %34, %35
%37 = xor i32 %36, -1
%38 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 1
%39 = load i32, i32* %38
%40 = and i32 %39, %37
store i32 %40, i32* %38
%41 = load i32, i32* @CSIZE
%42 = load i32, i32* @PARENB
%43 = or i32 %42, %41
%44 = xor i32 %43, -1
%45 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 2
%46 = load i32, i32* %45
%47 = and i32 %46, %44
%48 = load i32, i32* @CS8
%49 = or i32 %48, %47
store i32 %49, i32* %45
%50 = load i32, i32* @TCSANOW
%51 = call i32 @tcsetattr(i32 0, i32 %50, %struct.termios* %1)
ret void
}