#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;
};
typedef int /*<<< orphan*/ speed_t;

/* Variables and functions */
int BRKINT;
int CLOCAL;
int CREAD;
int CRTSCTS;
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;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void Setup_Port(int fd, speed_t speed) {
  struct termios portset;
  tcgetattr(fd, &portset);
  portset.c_iflag &=
      ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
  portset.c_oflag &= ~OPOST;
  portset.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
  portset.c_cflag &= ~(CSIZE | PARENB | CRTSCTS);
  portset.c_cflag |= CS8 | CREAD | CLOCAL;
  portset.c_cc[VMIN] = 1;
  portset.c_cc[VTIME] = 5;
  cfsetospeed(&portset, speed);
  cfsetispeed(&portset, speed);
  tcsetattr(fd, TCSANOW, &portset);
}


x86 assembly (clang, -O0):
<Setup_Port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%eax
mov    0x2e2e(%rip),%rcx
or     (%rcx),%eax
mov    0x2e7d(%rip),%rcx
or     (%rcx),%eax
mov    0x2de4(%rip),%rcx
or     (%rcx),%eax
mov    0x2e53(%rip),%rcx
or     (%rcx),%eax
mov    0x2e42(%rip),%rcx
or     (%rcx),%eax
mov    0x2e49(%rip),%rcx
or     (%rcx),%eax
mov    0x2e20(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    0x2d8b(%rip),%rcx
or     (%rcx),%eax
mov    0x2d6a(%rip),%rcx
or     (%rcx),%eax
mov    0x2dc1(%rip),%rcx
or     (%rcx),%eax
mov    0x2d88(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    0x2db5(%rip),%rcx
or     (%rcx),%eax
mov    0x2d24(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    0x2d69(%rip),%rcx
or     (%rcx),%eax
mov    0x2cf8(%rip),%rcx
or     (%rcx),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2d3d(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x2cf0(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    -0x8(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    -0x8(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   1060 <cfsetispeed@plt>
mov    -0x4(%rbp),%edi
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1050 <tcsetattr@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Setup_Port>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <tcgetattr@plt>
mov    0x2df2(%rip),%rax
mov    0x2e33(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e80(%rip),%rax
or     (%rax),%ecx
mov    0x2de7(%rip),%rax
or     (%rax),%ecx
mov    0x2e56(%rip),%rax
or     (%rax),%ecx
mov    0x2e45(%rip),%rax
or     (%rax),%ecx
mov    0x2e4c(%rip),%rax
or     (%rax),%ecx
mov    0x2e23(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x2dee(%rip),%rax
mov    0x2d97(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d74(%rip),%rax
or     (%rax),%ecx
mov    0x2dcb(%rip),%rax
or     (%rax),%ecx
mov    0x2d92(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x4(%rsp)
mov    0x2d8b(%rip),%rax
mov    0x2dc4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d31(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    0x8(%rsp),%ecx
mov    0x2d7a(%rip),%rax
mov    0x2d7b(%rip),%rdx
mov    0x2d0c(%rip),%rsi
or     (%rax),%ecx
or     (%rdx),%ecx
or     (%rsi),%ecx
mov    %ecx,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    0x2d4e(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d05(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x5,(%rax,%rcx,4)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <cfsetospeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <cfsetispeed@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, 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
@CRTSCTS = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define void @Setup_Port(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.termios
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = call i32 @tcgetattr(i32 %6, %struct.termios* %5)
%8 = load i32, i32* @IGNBRK
%9 = load i32, i32* @BRKINT
%10 = or i32 %8, %9
%11 = load i32, i32* @PARMRK
%12 = or i32 %10, %11
%13 = load i32, i32* @ISTRIP
%14 = or i32 %12, %13
%15 = load i32, i32* @INLCR
%16 = or i32 %14, %15
%17 = load i32, i32* @IGNCR
%18 = or i32 %16, %17
%19 = load i32, i32* @ICRNL
%20 = or i32 %18, %19
%21 = load i32, i32* @IXON
%22 = or i32 %20, %21
%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* @OPOST
%28 = xor i32 %27, -1
%29 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 4
%30 = load i32, i32* %29
%31 = and i32 %30, %28
store i32 %31, i32* %29
%32 = load i32, i32* @ECHO
%33 = load i32, i32* @ECHONL
%34 = or i32 %32, %33
%35 = load i32, i32* @ICANON
%36 = or i32 %34, %35
%37 = load i32, i32* @ISIG
%38 = or i32 %36, %37
%39 = load i32, i32* @IEXTEN
%40 = or i32 %38, %39
%41 = xor i32 %40, -1
%42 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 1
%43 = load i32, i32* %42
%44 = and i32 %43, %41
store i32 %44, i32* %42
%45 = load i32, i32* @CSIZE
%46 = load i32, i32* @PARENB
%47 = or i32 %45, %46
%48 = load i32, i32* @CRTSCTS
%49 = or i32 %47, %48
%50 = xor i32 %49, -1
%51 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%52 = load i32, i32* %51
%53 = and i32 %52, %50
store i32 %53, i32* %51
%54 = load i32, i32* @CS8
%55 = load i32, i32* @CREAD
%56 = or i32 %54, %55
%57 = load i32, i32* @CLOCAL
%58 = or i32 %56, %57
%59 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 2
%60 = load i32, i32* %59
%61 = or i32 %60, %58
store i32 %61, i32* %59
%62 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 3
%63 = load i32*, i32** %62
%64 = load i64, i64* @VMIN
%65 = getelementptr inbounds i32, i32* %63, i64 %64
store i32 1, i32* %65
%66 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 3
%67 = load i32*, i32** %66
%68 = load i64, i64* @VTIME
%69 = getelementptr inbounds i32, i32* %67, i64 %68
store i32 5, i32* %69
%70 = load i32, i32* %4
%71 = call i32 @cfsetospeed(%struct.termios* %5, i32 %70)
%72 = load i32, i32* %4
%73 = call i32 @cfsetispeed(%struct.termios* %5, i32 %72)
%74 = load i32, i32* %3
%75 = load i32, i32* @TCSANOW
%76 = call i32 @tcsetattr(i32 %74, i32 %75, %struct.termios* %5)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, 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
@CRTSCTS = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define void @Setup_Port(i32 %0, i32 %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = call i32 @tcgetattr(i32 %0, %struct.termios* %3)
%6 = load i32, i32* @IGNBRK
%7 = load i32, i32* @BRKINT
%8 = or i32 %7, %6
%9 = load i32, i32* @PARMRK
%10 = or i32 %8, %9
%11 = load i32, i32* @ISTRIP
%12 = or i32 %10, %11
%13 = load i32, i32* @INLCR
%14 = or i32 %12, %13
%15 = load i32, i32* @IGNCR
%16 = or i32 %14, %15
%17 = load i32, i32* @ICRNL
%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* %3, 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* %3, i64 0, i32 4
%28 = load i32, i32* %27
%29 = and i32 %28, %26
store i32 %29, i32* %27
%30 = load i32, i32* @ECHO
%31 = load i32, i32* @ECHONL
%32 = or i32 %31, %30
%33 = load i32, i32* @ICANON
%34 = or i32 %32, %33
%35 = load i32, i32* @ISIG
%36 = or i32 %34, %35
%37 = load i32, i32* @IEXTEN
%38 = or i32 %36, %37
%39 = xor i32 %38, -1
%40 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%41 = load i32, i32* %40
%42 = and i32 %41, %39
store i32 %42, i32* %40
%43 = load i32, i32* @CSIZE
%44 = load i32, i32* @PARENB
%45 = or i32 %44, %43
%46 = load i32, i32* @CRTSCTS
%47 = or i32 %45, %46
%48 = xor i32 %47, -1
%49 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%50 = load i32, i32* %49
%51 = and i32 %50, %48
%52 = load i32, i32* @CS8
%53 = load i32, i32* @CREAD
%54 = load i32, i32* @CLOCAL
%55 = or i32 %52, %51
%56 = or i32 %55, %53
%57 = or i32 %56, %54
store i32 %57, i32* %49
%58 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%59 = load i32*, i32** %58
%60 = load i64, i64* @VMIN
%61 = getelementptr inbounds i32, i32* %59, i64 %60
store i32 1, i32* %61
%62 = load i64, i64* @VTIME
%63 = getelementptr inbounds i32, i32* %59, i64 %62
store i32 5, i32* %63
%64 = call i32 @cfsetospeed(%struct.termios* %3, i32 %1)
%65 = call i32 @cfsetispeed(%struct.termios* %3, i32 %1)
%66 = load i32, i32* @TCSANOW
%67 = call i32 @tcsetattr(i32 %0, i32 %66, %struct.termios* %3)
ret void
}