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

/* Variables and functions */
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ISIG;
int PARENB;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ cfmakeraw(struct termios *);
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 portSettings(int portFD, speed_t speed) {
  struct termios options;
  tcgetattr(portFD, &options);
  cfmakeraw(&options);
  cfsetispeed(&options, speed);
  cfsetospeed(&options, speed);
  options.c_cflag |= (CLOCAL | CREAD);
  options.c_cflag &= ~PARENB;
  options.c_cflag &= ~CSTOPB;
  options.c_cflag &= ~CSIZE;
  options.c_cflag |= CS8;
  options.c_cflag |= CRTSCTS;
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  tcsetattr(portFD, TCSANOW, &options);
  tcgetattr(portFD, &options);
}


x86 assembly (clang, -O0):
<portSettings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <tcgetattr@plt>
lea    -0x10(%rbp),%rdi
call   1040 <cfmakeraw@plt>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1070 <cfsetispeed@plt>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    0x2e25(%rip),%rcx
or     (%rcx),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2da2(%rip),%rax
mov    (%rax),%eax
mov    0x2dd1(%rip),%rcx
or     (%rcx),%eax
mov    0x2dc0(%rip),%rcx
or     (%rcx),%eax
mov    0x2daf(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1060 <tcsetattr@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <tcgetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<portSettings>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1050 <tcgetattr@plt>
mov    %r14,%rdi
call   1040 <cfmakeraw@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1070 <cfsetispeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <cfsetospeed@plt>
mov    0x2df4(%rip),%rax
mov    0x2e2d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     0x8(%rsp),%ecx
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    0x2ddd(%rip),%rdx
or     (%rdx),%eax
mov    0x2dfc(%rip),%rdx
or     (%rdx),%eax
not    %eax
and    %ecx,%eax
mov    0x2df7(%rip),%rcx
or     (%rcx),%eax
mov    0x2dc6(%rip),%rcx
or     (%rcx),%eax
mov    0x2dcd(%rip),%rcx
mov    0x2dfe(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2deb(%rip),%rcx
or     (%rcx),%edx
mov    %eax,0x8(%rsp)
mov    0x2dd6(%rip),%rax
or     (%rax),%edx
not    %edx
and    %edx,0xc(%rsp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1060 <tcsetattr@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tcgetattr@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32 }
@CLOCAL = global i32 0
@CREAD = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@TCSANOW = global i32 0
define void @portSettings(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 = call i32 @cfmakeraw(%struct.termios* %5)
%9 = load i32, i32* %4
%10 = call i32 @cfsetispeed(%struct.termios* %5, i32 %9)
%11 = load i32, i32* %4
%12 = call i32 @cfsetospeed(%struct.termios* %5, i32 %11)
%13 = load i32, i32* @CLOCAL
%14 = load i32, i32* @CREAD
%15 = or i32 %13, %14
%16 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = or i32 %17, %15
store i32 %18, i32* %16
%19 = load i32, i32* @PARENB
%20 = xor i32 %19, -1
%21 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%22 = load i32, i32* %21
%23 = and i32 %22, %20
store i32 %23, i32* %21
%24 = load i32, i32* @CSTOPB
%25 = xor i32 %24, -1
%26 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%27 = load i32, i32* %26
%28 = and i32 %27, %25
store i32 %28, i32* %26
%29 = load i32, i32* @CSIZE
%30 = xor i32 %29, -1
%31 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%32 = load i32, i32* %31
%33 = and i32 %32, %30
store i32 %33, i32* %31
%34 = load i32, i32* @CS8
%35 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%36 = load i32, i32* %35
%37 = or i32 %36, %34
store i32 %37, i32* %35
%38 = load i32, i32* @CRTSCTS
%39 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%40 = load i32, i32* %39
%41 = or i32 %40, %38
store i32 %41, i32* %39
%42 = load i32, i32* @ICANON
%43 = load i32, i32* @ECHO
%44 = or i32 %42, %43
%45 = load i32, i32* @ECHOE
%46 = or i32 %44, %45
%47 = load i32, i32* @ISIG
%48 = or i32 %46, %47
%49 = xor i32 %48, -1
%50 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 1
%51 = load i32, i32* %50
%52 = and i32 %51, %49
store i32 %52, i32* %50
%53 = load i32, i32* %3
%54 = load i32, i32* @TCSANOW
%55 = call i32 @tcsetattr(i32 %53, i32 %54, %struct.termios* %5)
%56 = load i32, i32* %3
%57 = call i32 @tcgetattr(i32 %56, %struct.termios* %5)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32, i32 }
@CLOCAL = global i32 0
@CREAD = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@TCSANOW = global i32 0
define void @portSettings(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 = call i32 @cfmakeraw(%struct.termios* %3)
%7 = call i32 @cfsetispeed(%struct.termios* %3, i32 %1)
%8 = call i32 @cfsetospeed(%struct.termios* %3, i32 %1)
%9 = load i32, i32* @CLOCAL
%10 = load i32, i32* @CREAD
%11 = or i32 %10, %9
%12 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = or i32 %11, %13
%15 = load i32, i32* @PARENB
%16 = load i32, i32* @CSTOPB
%17 = or i32 %15, %16
%18 = load i32, i32* @CSIZE
%19 = or i32 %17, %18
%20 = xor i32 %19, -1
%21 = and i32 %14, %20
%22 = load i32, i32* @CS8
%23 = or i32 %22, %21
%24 = load i32, i32* @CRTSCTS
%25 = or i32 %24, %23
store i32 %25, i32* %12
%26 = load i32, i32* @ICANON
%27 = load i32, i32* @ECHO
%28 = or i32 %27, %26
%29 = load i32, i32* @ECHOE
%30 = or i32 %28, %29
%31 = load i32, i32* @ISIG
%32 = or i32 %30, %31
%33 = xor i32 %32, -1
%34 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%35 = load i32, i32* %34
%36 = and i32 %35, %33
store i32 %36, i32* %34
%37 = load i32, i32* @TCSANOW
%38 = call i32 @tcsetattr(i32 %0, i32 %37, %struct.termios* %3)
%39 = call i32 @tcgetattr(i32 %0, %struct.termios* %3)
ret void
}