#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 CS7;
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;
void makeraw(struct termios *termios_p, int bits) {
  termios_p->c_iflag &=
      ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  termios_p->c_oflag &= ~OPOST;
  termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
  termios_p->c_cflag &= ~(CSIZE | PARENB);
  if (bits == 7)
    termios_p->c_cflag |= CS7;
  if (bits == 8)
    termios_p->c_cflag |= CS8;
}


x86 assembly (clang, -O0):
<makeraw>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%ecx
mov    0x2e85(%rip),%rax
or     (%rax),%ecx
mov    0x2ecc(%rip),%rax
or     (%rax),%ecx
mov    0x2e4b(%rip),%rax
or     (%rax),%ecx
mov    0x2ea2(%rip),%rax
or     (%rax),%ecx
mov    0x2e91(%rip),%rax
or     (%rax),%ecx
mov    0x2e98(%rip),%rax
or     (%rax),%ecx
mov    0x2e6f(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2e63(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
mov    0x2e35(%rip),%rax
mov    (%rax),%ecx
mov    0x2dec(%rip),%rax
or     (%rax),%ecx
mov    0x2dd3(%rip),%rax
or     (%rax),%ecx
mov    0x2e12(%rip),%rax
or     (%rax),%ecx
mov    0x2de9(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    0x2ddb(%rip),%rax
mov    (%rax),%ecx
mov    0x2dfa(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
cmpl   $0x7,-0xc(%rbp)
jne    11ea <makeraw+0xea>
mov    0x2d72(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
cmpl   $0x8,-0xc(%rbp)
jne    1207 <makeraw+0x107>
mov    0x2d9d(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeraw>:
mov    0x2e61(%rip),%rax
mov    0x2e92(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ed7(%rip),%rax
or     (%rax),%ecx
mov    0x2e56(%rip),%rax
or     (%rax),%ecx
mov    0x2ead(%rip),%rax
or     (%rax),%ecx
mov    0x2e9c(%rip),%rax
or     (%rax),%ecx
mov    0x2ea3(%rip),%rax
or     (%rax),%ecx
mov    0x2e7a(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rdi)
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0xc(%rdi)
mov    0x2e4f(%rip),%rax
mov    0x2e08(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ded(%rip),%rax
or     (%rax),%ecx
mov    0x2e2c(%rip),%rax
or     (%rax),%ecx
mov    0x2e03(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rdi)
mov    0x2dfd(%rip),%rcx
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
not    %eax
and    0x8(%rdi),%eax
mov    %eax,0x8(%rdi)
cmp    $0x7,%esi
je     11b9 <makeraw+0xb9>
cmp    $0x8,%esi
jne    11c5 <makeraw+0xc5>
mov    0x2de1(%rip),%rcx
jmp    11c0 <makeraw+0xc0>
mov    0x2d90(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rdi)
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
@CS7 = global i32 0
@CS8 = global i32 0
define void @makeraw(%struct.termios* %0, i32 %1) {
%3 = alloca %struct.termios*
%4 = alloca i32
store %struct.termios* %0, %struct.termios** %3
store i32 %1, i32* %4
%5 = load i32, i32* @IGNBRK
%6 = load i32, i32* @BRKINT
%7 = or i32 %5, %6
%8 = load i32, i32* @PARMRK
%9 = or i32 %7, %8
%10 = load i32, i32* @ISTRIP
%11 = or i32 %9, %10
%12 = load i32, i32* @INLCR
%13 = or i32 %11, %12
%14 = load i32, i32* @IGNCR
%15 = or i32 %13, %14
%16 = load i32, i32* @ICRNL
%17 = or i32 %15, %16
%18 = load i32, i32* @IXON
%19 = or i32 %17, %18
%20 = xor i32 %19, -1
%21 = load %struct.termios*, %struct.termios** %3
%22 = getelementptr inbounds %struct.termios, %struct.termios* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = and i32 %23, %20
store i32 %24, i32* %22
%25 = load i32, i32* @OPOST
%26 = xor i32 %25, -1
%27 = load %struct.termios*, %struct.termios** %3
%28 = getelementptr inbounds %struct.termios, %struct.termios* %27, i32 0, i32 3
%29 = load i32, i32* %28
%30 = and i32 %29, %26
store i32 %30, i32* %28
%31 = load i32, i32* @ECHO
%32 = load i32, i32* @ECHONL
%33 = or i32 %31, %32
%34 = load i32, i32* @ICANON
%35 = or i32 %33, %34
%36 = load i32, i32* @ISIG
%37 = or i32 %35, %36
%38 = load i32, i32* @IEXTEN
%39 = or i32 %37, %38
%40 = xor i32 %39, -1
%41 = load %struct.termios*, %struct.termios** %3
%42 = getelementptr inbounds %struct.termios, %struct.termios* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = and i32 %43, %40
store i32 %44, i32* %42
%45 = load i32, i32* @CSIZE
%46 = load i32, i32* @PARENB
%47 = or i32 %45, %46
%48 = xor i32 %47, -1
%49 = load %struct.termios*, %struct.termios** %3
%50 = getelementptr inbounds %struct.termios, %struct.termios* %49, i32 0, i32 2
%51 = load i32, i32* %50
%52 = and i32 %51, %48
store i32 %52, i32* %50
%53 = load i32, i32* %4
%54 = icmp eq i32 %53, 7
br i1 %54, label %55, label %61
55: ; preds = %2
%56 = load i32, i32* @CS7
%57 = load %struct.termios*, %struct.termios** %3
%58 = getelementptr inbounds %struct.termios, %struct.termios* %57, i32 0, i32 2
%59 = load i32, i32* %58
%60 = or i32 %59, %56
store i32 %60, i32* %58
br label %61
61: ; preds = %55, %2
%62 = load i32, i32* %4
%63 = icmp eq i32 %62, 8
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i32, i32* @CS8
%66 = load %struct.termios*, %struct.termios** %3
%67 = getelementptr inbounds %struct.termios, %struct.termios* %66, i32 0, i32 2
%68 = load i32, i32* %67
%69 = or i32 %68, %65
store i32 %69, i32* %67
br label %70
70: ; preds = %64, %61
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
@CS7 = global i32 0
@CS8 = global i32 0
define void @makeraw(%struct.termios* nocapture %0, i32 %1) {
%3 = load i32, i32* @IGNBRK
%4 = load i32, i32* @BRKINT
%5 = or i32 %4, %3
%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* %0, i64 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* %0, i64 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 %28, %27
%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* %0, i64 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 %41, %40
%43 = xor i32 %42, -1
%44 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 2
%45 = load i32, i32* %44
%46 = and i32 %45, %43
store i32 %46, i32* %44
switch i32 %1, label %52 [
i32 7, label %48
i32 8, label %47
]
47: ; preds = %2
br label %48
48: ; preds = %2, %47
%49 = phi i32* [ @CS8, %47 ], [ @CS7, %2 ]
%50 = load i32, i32* %49
%51 = or i32 %50, %46
store i32 %51, i32* %44
br label %52
52: ; preds = %48, %2
ret void
}