#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_cc;
  int c_cflag;
  int c_iflag;
  int c_oflag;
  int c_lflag;
  scalar_t__ c_line;
};

/* Variables and functions */
int CBAUD;
int CBAUDEX;
int CLOCAL;
int CREAD;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOCTL;
int ECHOE;
int ECHOK;
int ECHOKE;
int HUPCL;
int ICANON;
int ICRNL;
int IEXTEN;
int ISIG;
int IXOFF;
int IXON;
int ONLCR;
int OPOST;
int PARENB;
int PARODD;
int /*<<< orphan*/ TCSANOW;
size_t VEOF;
size_t VERASE;
size_t VINTR;
size_t VKILL;
size_t VQUIT;
size_t VSTART;
size_t VSTOP;
size_t VSUSP;
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void set_term(int fd) {
  struct termios tty;
  tcgetattr(fd, &tty);
  tty.c_cc[VINTR] = 3;
  tty.c_cc[VQUIT] = 28;
  tty.c_cc[VERASE] = 127;
  tty.c_cc[VKILL] = 21;
  tty.c_cc[VEOF] = 4;
  tty.c_cc[VSTART] = 17;
  tty.c_cc[VSTOP] = 19;
  tty.c_cc[VSUSP] = 26;
  tty.c_line = 0;
  tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD;
  tty.c_cflag |= CREAD | HUPCL | CLOCAL;
  tty.c_iflag = ICRNL | IXON | IXOFF;
  tty.c_oflag = OPOST | ONLCR;
  tty.c_lflag =
      ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN;
  tcsetattr(fd, TCSANOW, &tty);
}


x86 assembly (clang, -O0):
<set_term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1030 <tcgetattr@plt>
mov    -0x28(%rbp),%rax
mov    0x2dc6(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x3,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2de9(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1c,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x7f,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2e4f(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x15,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2d52(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x4,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2d4d(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x11,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2e08(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x13,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2d43(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1a,(%rax,%rcx,4)
movq   $0x0,-0x10(%rbp)
mov    0x2d22(%rip),%rax
mov    (%rax),%eax
mov    0x2d51(%rip),%rcx
or     (%rcx),%eax
mov    0x2d70(%rip),%rcx
or     (%rcx),%eax
mov    0x2cf7(%rip),%rcx
or     (%rcx),%eax
mov    0x2d9e(%rip),%rcx
or     (%rcx),%eax
mov    0x2d6d(%rip),%rcx
or     (%rcx),%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
mov    0x2cfd(%rip),%rcx
or     (%rcx),%eax
mov    0x2cb4(%rip),%rcx
or     (%rcx),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    0x2d64(%rip),%rcx
or     (%rcx),%eax
mov    0x2d83(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    0x2cc6(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    0x2ca1(%rip),%rcx
or     (%rcx),%eax
mov    0x2d08(%rip),%rcx
or     (%rcx),%eax
mov    0x2cf7(%rip),%rcx
or     (%rcx),%eax
mov    0x2cae(%rip),%rcx
or     (%rcx),%eax
mov    0x2d2d(%rip),%rcx
or     (%rcx),%eax
mov    0x2ca4(%rip),%rcx
or     (%rcx),%eax
mov    0x2cab(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2cd4(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_term>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1030 <tcgetattr@plt>
mov    0x8(%rsp),%rax
mov    0x2dc6(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x3,(%rax,%rcx,4)
mov    0x2ded(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1c,(%rax,%rcx,4)
mov    0x2e44(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x7f,(%rax,%rcx,4)
mov    0x2e5b(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x15,(%rax,%rcx,4)
mov    0x2d62(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x4,(%rax,%rcx,4)
mov    0x2d61(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x11,(%rax,%rcx,4)
mov    0x2e20(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x13,(%rax,%rcx,4)
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1a,(%rax,%rcx,4)
mov    0x2d46(%rip),%rcx
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2d94(%rip),%rcx
or     (%rcx),%eax
movq   $0x0,0x20(%rsp)
mov    0x2d12(%rip),%rcx
or     (%rcx),%eax
mov    0x2db9(%rip),%rcx
or     (%rcx),%eax
mov    0x2d88(%rip),%rcx
or     (%rcx),%eax
and    0x10(%rsp),%eax
mov    0x2d6b(%rip),%rcx
mov    0x2d1c(%rip),%rdx
mov    0x2cd5(%rip),%rsi
or     (%rcx),%eax
or     (%rdx),%eax
or     (%rsi),%eax
mov    0x2dc0(%rip),%rdx
mov    0x2d89(%rip),%rcx
mov    (%rcx),%ecx
or     (%rdx),%ecx
mov    0x2da6(%rip),%rdx
or     (%rdx),%ecx
mov    0x2d7d(%rip),%rdx
mov    0x2cee(%rip),%rsi
mov    (%rsi),%esi
or     (%rdx),%esi
mov    0x2d2b(%rip),%rdx
mov    0x2ccc(%rip),%rdi
mov    (%rdi),%edi
or     (%rdx),%edi
mov    0x2d31(%rip),%rdx
or     (%rdx),%edi
mov    0x2d20(%rip),%rdx
or     (%rdx),%edi
mov    0x2cd7(%rip),%rdx
or     (%rdx),%edi
mov    0x2d56(%rip),%rdx
or     (%rdx),%edi
mov    %eax,0x10(%rsp)
mov    0x2cc9(%rip),%rax
or     (%rax),%edi
mov    %ecx,0x14(%rsp)
mov    0x2ccc(%rip),%rax
or     (%rax),%edi
mov    %esi,0x18(%rsp)
mov    %edi,0x1c(%rsp)
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <tcsetattr@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32*, i32, i32, i32, i32, i64 }
@VINTR = global i64 0
@VQUIT = global i64 0
@VERASE = global i64 0
@VKILL = global i64 0
@VEOF = global i64 0
@VSTART = global i64 0
@VSTOP = global i64 0
@VSUSP = global i64 0
@CBAUD = global i32 0
@CBAUDEX = global i32 0
@CSIZE = global i32 0
@CSTOPB = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@CREAD = global i32 0
@HUPCL = global i32 0
@CLOCAL = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHOCTL = global i32 0
@ECHOKE = global i32 0
@IEXTEN = global i32 0
@TCSANOW = global i32 0
define void @set_term(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @tcgetattr(i32 %4, %struct.termios* %3)
%6 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%7 = load i32*, i32** %6
%8 = load i64, i64* @VINTR
%9 = getelementptr inbounds i32, i32* %7, i64 %8
store i32 3, i32* %9
%10 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%11 = load i32*, i32** %10
%12 = load i64, i64* @VQUIT
%13 = getelementptr inbounds i32, i32* %11, i64 %12
store i32 28, i32* %13
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%15 = load i32*, i32** %14
%16 = load i64, i64* @VERASE
%17 = getelementptr inbounds i32, i32* %15, i64 %16
store i32 127, i32* %17
%18 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%19 = load i32*, i32** %18
%20 = load i64, i64* @VKILL
%21 = getelementptr inbounds i32, i32* %19, i64 %20
store i32 21, i32* %21
%22 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%23 = load i32*, i32** %22
%24 = load i64, i64* @VEOF
%25 = getelementptr inbounds i32, i32* %23, i64 %24
store i32 4, i32* %25
%26 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%27 = load i32*, i32** %26
%28 = load i64, i64* @VSTART
%29 = getelementptr inbounds i32, i32* %27, i64 %28
store i32 17, i32* %29
%30 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%31 = load i32*, i32** %30
%32 = load i64, i64* @VSTOP
%33 = getelementptr inbounds i32, i32* %31, i64 %32
store i32 19, i32* %33
%34 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%35 = load i32*, i32** %34
%36 = load i64, i64* @VSUSP
%37 = getelementptr inbounds i32, i32* %35, i64 %36
store i32 26, i32* %37
%38 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 5
store i64 0, i64* %38
%39 = load i32, i32* @CBAUD
%40 = load i32, i32* @CBAUDEX
%41 = or i32 %39, %40
%42 = load i32, i32* @CSIZE
%43 = or i32 %41, %42
%44 = load i32, i32* @CSTOPB
%45 = or i32 %43, %44
%46 = load i32, i32* @PARENB
%47 = or i32 %45, %46
%48 = load i32, i32* @PARODD
%49 = or i32 %47, %48
%50 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 1
%51 = load i32, i32* %50
%52 = and i32 %51, %49
store i32 %52, i32* %50
%53 = load i32, i32* @CREAD
%54 = load i32, i32* @HUPCL
%55 = or i32 %53, %54
%56 = load i32, i32* @CLOCAL
%57 = or i32 %55, %56
%58 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 1
%59 = load i32, i32* %58
%60 = or i32 %59, %57
store i32 %60, i32* %58
%61 = load i32, i32* @ICRNL
%62 = load i32, i32* @IXON
%63 = or i32 %61, %62
%64 = load i32, i32* @IXOFF
%65 = or i32 %63, %64
%66 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 2
store i32 %65, i32* %66
%67 = load i32, i32* @OPOST
%68 = load i32, i32* @ONLCR
%69 = or i32 %67, %68
%70 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 3
store i32 %69, i32* %70
%71 = load i32, i32* @ISIG
%72 = load i32, i32* @ICANON
%73 = or i32 %71, %72
%74 = load i32, i32* @ECHO
%75 = or i32 %73, %74
%76 = load i32, i32* @ECHOE
%77 = or i32 %75, %76
%78 = load i32, i32* @ECHOK
%79 = or i32 %77, %78
%80 = load i32, i32* @ECHOCTL
%81 = or i32 %79, %80
%82 = load i32, i32* @ECHOKE
%83 = or i32 %81, %82
%84 = load i32, i32* @IEXTEN
%85 = or i32 %83, %84
%86 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 4
store i32 %85, i32* %86
%87 = load i32, i32* %2
%88 = load i32, i32* @TCSANOW
%89 = call i32 @tcsetattr(i32 %87, i32 %88, %struct.termios* %3)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32*, i32, i32, i32, i32, i64 }
@VINTR = global i64 0
@VQUIT = global i64 0
@VERASE = global i64 0
@VKILL = global i64 0
@VEOF = global i64 0
@VSTART = global i64 0
@VSTOP = global i64 0
@VSUSP = global i64 0
@CBAUD = global i32 0
@CBAUDEX = global i32 0
@CSIZE = global i32 0
@CSTOPB = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@CREAD = global i32 0
@HUPCL = global i32 0
@CLOCAL = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@OPOST = global i32 0
@ONLCR = global i32 0
@ISIG = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHOCTL = global i32 0
@ECHOKE = global i32 0
@IEXTEN = global i32 0
@TCSANOW = global i32 0
define void @set_term(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = call i32 @tcgetattr(i32 %0, %struct.termios* %2)
%5 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%6 = load i32*, i32** %5
%7 = load i64, i64* @VINTR
%8 = getelementptr inbounds i32, i32* %6, i64 %7
store i32 3, i32* %8
%9 = load i64, i64* @VQUIT
%10 = getelementptr inbounds i32, i32* %6, i64 %9
store i32 28, i32* %10
%11 = load i64, i64* @VERASE
%12 = getelementptr inbounds i32, i32* %6, i64 %11
store i32 127, i32* %12
%13 = load i64, i64* @VKILL
%14 = getelementptr inbounds i32, i32* %6, i64 %13
store i32 21, i32* %14
%15 = load i64, i64* @VEOF
%16 = getelementptr inbounds i32, i32* %6, i64 %15
store i32 4, i32* %16
%17 = load i64, i64* @VSTART
%18 = getelementptr inbounds i32, i32* %6, i64 %17
store i32 17, i32* %18
%19 = load i64, i64* @VSTOP
%20 = getelementptr inbounds i32, i32* %6, i64 %19
store i32 19, i32* %20
%21 = load i64, i64* @VSUSP
%22 = getelementptr inbounds i32, i32* %6, i64 %21
store i32 26, i32* %22
%23 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 5
store i64 0, i64* %23
%24 = load i32, i32* @CBAUD
%25 = load i32, i32* @CBAUDEX
%26 = or i32 %25, %24
%27 = load i32, i32* @CSIZE
%28 = or i32 %26, %27
%29 = load i32, i32* @CSTOPB
%30 = or i32 %28, %29
%31 = load i32, i32* @PARENB
%32 = or i32 %30, %31
%33 = load i32, i32* @PARODD
%34 = or i32 %32, %33
%35 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%36 = load i32, i32* %35
%37 = and i32 %36, %34
%38 = load i32, i32* @CREAD
%39 = load i32, i32* @HUPCL
%40 = load i32, i32* @CLOCAL
%41 = or i32 %38, %37
%42 = or i32 %41, %39
%43 = or i32 %42, %40
store i32 %43, i32* %35
%44 = load i32, i32* @ICRNL
%45 = load i32, i32* @IXON
%46 = or i32 %45, %44
%47 = load i32, i32* @IXOFF
%48 = or i32 %46, %47
%49 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 2
store i32 %48, i32* %49
%50 = load i32, i32* @OPOST
%51 = load i32, i32* @ONLCR
%52 = or i32 %51, %50
%53 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 3
store i32 %52, i32* %53
%54 = load i32, i32* @ISIG
%55 = load i32, i32* @ICANON
%56 = or i32 %55, %54
%57 = load i32, i32* @ECHO
%58 = or i32 %56, %57
%59 = load i32, i32* @ECHOE
%60 = or i32 %58, %59
%61 = load i32, i32* @ECHOK
%62 = or i32 %60, %61
%63 = load i32, i32* @ECHOCTL
%64 = or i32 %62, %63
%65 = load i32, i32* @ECHOKE
%66 = or i32 %64, %65
%67 = load i32, i32* @IEXTEN
%68 = or i32 %66, %67
%69 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 4
store i32 %68, i32* %69
%70 = load i32, i32* @TCSANOW
%71 = call i32 @tcsetattr(i32 %0, i32 %70, %struct.termios* %2)
ret void
}