#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;
};

/* Variables and functions */
int B9600;
int CLOCAL;
int CREAD;
int CS8;
int EXIT_SUCCESS;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int cfsetispeed(struct termios *, int);
int cfsetospeed(struct termios *, int);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int tcgetattr(int, struct termios *);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int conf_ser(int serialDev) {
  int rc;
  struct termios params;
  rc = tcgetattr(serialDev, &params);
  cfmakeraw(&params);
  rc = cfsetispeed(&params, B9600);
  rc = cfsetospeed(&params, B9600);
  params.c_cflag |= (B9600 | CS8 | CLOCAL | CREAD);
  rc = tcsetattr(serialDev, TCSANOW, &params);
  tcflush(serialDev, TCIOFLUSH);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<conf_ser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1060 <tcgetattr@plt>
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <cfmakeraw@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    0x2e13(%rip),%rcx
or     (%rcx),%eax
mov    0x2de2(%rip),%rcx
or     (%rcx),%eax
mov    0x2e09(%rip),%rcx
or     (%rcx),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1070 <tcsetattr@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_ser>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1060 <tcgetattr@plt>
mov    %r14,%rdi
call   1050 <cfmakeraw@plt>
mov    0x2e59(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1080 <cfsetispeed@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1030 <cfsetospeed@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
or     (%r15),%eax
mov    0x2df8(%rip),%rcx
or     (%rcx),%eax
mov    0x2e1f(%rip),%rcx
or     (%rcx),%eax
or     %eax,0x8(%rsp)
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1070 <tcsetattr@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <tcflush@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@B9600 = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@TCIOFLUSH = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @conf_ser(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.termios
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @tcgetattr(i32 %5, %struct.termios* %4)
store i32 %6, i32* %3
%7 = call i32 @cfmakeraw(%struct.termios* %4)
%8 = load i32, i32* @B9600
%9 = call i32 @cfsetispeed(%struct.termios* %4, i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* @B9600
%11 = call i32 @cfsetospeed(%struct.termios* %4, i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* @B9600
%13 = load i32, i32* @CS8
%14 = or i32 %12, %13
%15 = load i32, i32* @CLOCAL
%16 = or i32 %14, %15
%17 = load i32, i32* @CREAD
%18 = or i32 %16, %17
%19 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = or i32 %20, %18
store i32 %21, i32* %19
%22 = load i32, i32* %2
%23 = load i32, i32* @TCSANOW
%24 = call i32 @tcsetattr(i32 %22, i32 %23, %struct.termios* %4)
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* @TCIOFLUSH
%27 = call i32 @tcflush(i32 %25, i32 %26)
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@B9600 = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@TCIOFLUSH = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @conf_ser(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = call i32 @tcgetattr(i32 %0, %struct.termios* %2)
%5 = call i32 @cfmakeraw(%struct.termios* %2)
%6 = load i32, i32* @B9600
%7 = call i32 @cfsetispeed(%struct.termios* %2, i32 %6)
%8 = load i32, i32* @B9600
%9 = call i32 @cfsetospeed(%struct.termios* %2, i32 %8)
%10 = load i32, i32* @B9600
%11 = load i32, i32* @CS8
%12 = or i32 %11, %10
%13 = load i32, i32* @CLOCAL
%14 = or i32 %12, %13
%15 = load i32, i32* @CREAD
%16 = or i32 %14, %15
%17 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%18 = load i32, i32* %17
%19 = or i32 %16, %18
store i32 %19, i32* %17
%20 = load i32, i32* @TCSANOW
%21 = call i32 @tcsetattr(i32 %0, i32 %20, %struct.termios* %2)
%22 = load i32, i32* @TCIOFLUSH
%23 = call i32 @tcflush(i32 %0, i32 %22)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}