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

/* Variables and functions */
int BRKINT;
int CS8;
int CSIZE;
int ECHONL;
int /*<<< orphan*/ EINVAL;
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;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ errno;
void cfmakeraw(struct termios *termiosp) {
  if (termiosp == NULL) {
    errno = EINVAL;
    return;
  }
  termiosp->c_iflag &=
      ~(BRKINT | ICRNL | IGNBRK | IGNCR | INLCR | ISTRIP | PARMRK | IXON);
  termiosp->c_oflag &= ~OPOST;
  termiosp->c_lflag &= ~(ECHONL | ICANON | IEXTEN | ISIG);
  termiosp->c_cflag &= ~(CSIZE | PARENB);
  termiosp->c_cflag |= CS8;
  termiosp->c_cc[VMIN] = 1;
  termiosp->c_cc[VTIME] = 0;
}


x86 assembly (clang, -O0):
<cfmakeraw>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112a <cfmakeraw+0x2a>
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    0x2e55(%rip),%rax
mov    %ecx,(%rax)
jmp    1228 <cfmakeraw+0x128>
mov    0x2e77(%rip),%rax
mov    (%rax),%ecx
mov    0x2ea6(%rip),%rax
or     (%rax),%ecx
mov    0x2e15(%rip),%rax
or     (%rax),%ecx
mov    0x2e84(%rip),%rax
or     (%rax),%ecx
mov    0x2e83(%rip),%rax
or     (%rax),%ecx
mov    0x2e12(%rip),%rax
or     (%rax),%ecx
mov    0x2e89(%rip),%rax
or     (%rax),%ecx
mov    0x2e50(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x18(%rax),%ecx
mov    %ecx,0x18(%rax)
mov    0x2dce(%rip),%rax
mov    (%rax),%ecx
mov    0x2da5(%rip),%rax
or     (%rax),%ecx
mov    0x2ddc(%rip),%rax
or     (%rax),%ecx
mov    0x2dfb(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    0x2dc5(%rip),%rax
mov    (%rax),%ecx
mov    0x2de4(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    0x2db6(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2d93(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2d32(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfmakeraw>:
test   %rdi,%rdi
je     11d6 <cfmakeraw+0xd6>
mov    0x2e98(%rip),%rax
mov    0x2ec9(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e36(%rip),%rax
or     (%rax),%ecx
mov    0x2ea5(%rip),%rax
or     (%rax),%ecx
mov    0x2ea4(%rip),%rax
or     (%rax),%ecx
mov    0x2e33(%rip),%rax
or     (%rax),%ecx
mov    0x2eaa(%rip),%rax
or     (%rax),%ecx
mov    0x2e71(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rdi)
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rdi)
mov    0x2dfe(%rip),%rax
mov    0x2dd7(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e0c(%rip),%rax
or     (%rax),%ecx
mov    0x2e2b(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rdi)
mov    0x2dfd(%rip),%rax
mov    0x2e1e(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    0x8(%rdi),%ecx
mov    0x2df6(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x8(%rdi)
mov    0x10(%rdi),%rax
mov    0x2dde(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d85(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
ret
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    0x2d92(%rip),%rcx
mov    %eax,(%rcx)
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32*, i32 }
@EINVAL = global i32 0
@errno = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@IGNBRK = global i32 0
@IGNCR = global i32 0
@INLCR = global i32 0
@ISTRIP = global i32 0
@PARMRK = global i32 0
@IXON = global i32 0
@OPOST = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
define void @cfmakeraw(%struct.termios* %0) {
%2 = alloca %struct.termios*
store %struct.termios* %0, %struct.termios** %2
%3 = load %struct.termios*, %struct.termios** %2
%4 = icmp eq %struct.termios* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = load i32, i32* @EINVAL
store i32 %6, i32* @errno
br label %69
7: ; preds = %1
%8 = load i32, i32* @BRKINT
%9 = load i32, i32* @ICRNL
%10 = or i32 %8, %9
%11 = load i32, i32* @IGNBRK
%12 = or i32 %10, %11
%13 = load i32, i32* @IGNCR
%14 = or i32 %12, %13
%15 = load i32, i32* @INLCR
%16 = or i32 %14, %15
%17 = load i32, i32* @ISTRIP
%18 = or i32 %16, %17
%19 = load i32, i32* @PARMRK
%20 = or i32 %18, %19
%21 = load i32, i32* @IXON
%22 = or i32 %20, %21
%23 = xor i32 %22, -1
%24 = load %struct.termios*, %struct.termios** %2
%25 = getelementptr inbounds %struct.termios, %struct.termios* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = and i32 %26, %23
store i32 %27, i32* %25
%28 = load i32, i32* @OPOST
%29 = xor i32 %28, -1
%30 = load %struct.termios*, %struct.termios** %2
%31 = getelementptr inbounds %struct.termios, %struct.termios* %30, i32 0, i32 4
%32 = load i32, i32* %31
%33 = and i32 %32, %29
store i32 %33, i32* %31
%34 = load i32, i32* @ECHONL
%35 = load i32, i32* @ICANON
%36 = or i32 %34, %35
%37 = load i32, i32* @IEXTEN
%38 = or i32 %36, %37
%39 = load i32, i32* @ISIG
%40 = or i32 %38, %39
%41 = xor i32 %40, -1
%42 = load %struct.termios*, %struct.termios** %2
%43 = getelementptr inbounds %struct.termios, %struct.termios* %42, i32 0, i32 1
%44 = load i32, i32* %43
%45 = and i32 %44, %41
store i32 %45, i32* %43
%46 = load i32, i32* @CSIZE
%47 = load i32, i32* @PARENB
%48 = or i32 %46, %47
%49 = xor i32 %48, -1
%50 = load %struct.termios*, %struct.termios** %2
%51 = getelementptr inbounds %struct.termios, %struct.termios* %50, i32 0, i32 2
%52 = load i32, i32* %51
%53 = and i32 %52, %49
store i32 %53, i32* %51
%54 = load i32, i32* @CS8
%55 = load %struct.termios*, %struct.termios** %2
%56 = getelementptr inbounds %struct.termios, %struct.termios* %55, i32 0, i32 2
%57 = load i32, i32* %56
%58 = or i32 %57, %54
store i32 %58, i32* %56
%59 = load %struct.termios*, %struct.termios** %2
%60 = getelementptr inbounds %struct.termios, %struct.termios* %59, i32 0, i32 3
%61 = load i32*, i32** %60
%62 = load i64, i64* @VMIN
%63 = getelementptr inbounds i32, i32* %61, i64 %62
store i32 1, i32* %63
%64 = load %struct.termios*, %struct.termios** %2
%65 = getelementptr inbounds %struct.termios, %struct.termios* %64, i32 0, i32 3
%66 = load i32*, i32** %65
%67 = load i64, i64* @VTIME
%68 = getelementptr inbounds i32, i32* %66, i64 %67
store i32 0, i32* %68
br label %69
69: ; preds = %7, %5
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32*, i32 }
@EINVAL = global i32 0
@errno = global i32 0
@BRKINT = global i32 0
@ICRNL = global i32 0
@IGNBRK = global i32 0
@IGNCR = global i32 0
@INLCR = global i32 0
@ISTRIP = global i32 0
@PARMRK = global i32 0
@IXON = global i32 0
@OPOST = global i32 0
@ECHONL = global i32 0
@ICANON = global i32 0
@IEXTEN = global i32 0
@ISIG = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@CS8 = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
define void @cfmakeraw(%struct.termios* %0) {
%2 = icmp eq %struct.termios* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @EINVAL
store i32 %4, i32* @errno
br label %56
5: ; preds = %1
%6 = load i32, i32* @BRKINT
%7 = load i32, i32* @ICRNL
%8 = or i32 %7, %6
%9 = load i32, i32* @IGNBRK
%10 = or i32 %8, %9
%11 = load i32, i32* @IGNCR
%12 = or i32 %10, %11
%13 = load i32, i32* @INLCR
%14 = or i32 %12, %13
%15 = load i32, i32* @ISTRIP
%16 = or i32 %14, %15
%17 = load i32, i32* @PARMRK
%18 = or i32 %16, %17
%19 = load i32, i32* @IXON
%20 = or i32 %18, %19
%21 = xor i32 %20, -1
%22 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%23 = load i32, i32* %22
%24 = and i32 %23, %21
store i32 %24, i32* %22
%25 = load i32, i32* @OPOST
%26 = xor i32 %25, -1
%27 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 4
%28 = load i32, i32* %27
%29 = and i32 %28, %26
store i32 %29, i32* %27
%30 = load i32, i32* @ECHONL
%31 = load i32, i32* @ICANON
%32 = or i32 %31, %30
%33 = load i32, i32* @IEXTEN
%34 = or i32 %32, %33
%35 = load i32, i32* @ISIG
%36 = or i32 %34, %35
%37 = xor i32 %36, -1
%38 = getelementptr inbounds %struct.termios, %struct.termios* %0, 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* %0, 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 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 3
%51 = load i32*, i32** %50
%52 = load i64, i64* @VMIN
%53 = getelementptr inbounds i32, i32* %51, i64 %52
store i32 1, i32* %53
%54 = load i64, i64* @VTIME
%55 = getelementptr inbounds i32, i32* %51, i64 %54
store i32 0, i32* %55
br label %56
56: ; preds = %5, %3
ret void
}