#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 /*<<< orphan*/ c_cflag;
};

/* Variables and functions */
int /*<<< orphan*/ B9600;
int /*<<< orphan*/ CS8;
int /*<<< orphan*/ CSIZE;
int /*<<< orphan*/ CSTOPB;
int /*<<< orphan*/ PARENB;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int configure_port(int fd) {
  struct termios port_settings;
  cfsetispeed(&port_settings, B9600);
  cfsetospeed(&port_settings, B9600);
  port_settings.c_cflag &= ~PARENB;
  port_settings.c_cflag &= ~CSTOPB;
  port_settings.c_cflag &= ~CSIZE;
  port_settings.c_cflag |= CS8;
  tcsetattr(fd, TCSANOW, &port_settings);
  return (fd);
}


x86 assembly (clang, -O0):
<configure_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1050 <cfsetispeed@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1040 <tcsetattr@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configure_port>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2e96(%rip),%r15
mov    (%r15),%esi
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1050 <cfsetispeed@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1030 <cfsetospeed@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    0x2e43(%rip),%rcx
or     (%rcx),%eax
mov    0x2e52(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    0x8(%rsp),%eax
mov    0x2e4b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1040 <tcsetattr@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@B9600 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
define i32 @configure_port(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = load i32, i32* @B9600
%5 = call i32 @cfsetispeed(%struct.termios* %3, i32 %4)
%6 = load i32, i32* @B9600
%7 = call i32 @cfsetospeed(%struct.termios* %3, i32 %6)
%8 = load i32, i32* @PARENB
%9 = xor i32 %8, -1
%10 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, %9
store i32 %12, i32* %10
%13 = load i32, i32* @CSTOPB
%14 = xor i32 %13, -1
%15 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%16 = load i32, i32* %15
%17 = and i32 %16, %14
store i32 %17, i32* %15
%18 = load i32, i32* @CSIZE
%19 = xor i32 %18, -1
%20 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%21 = load i32, i32* %20
%22 = and i32 %21, %19
store i32 %22, i32* %20
%23 = load i32, i32* @CS8
%24 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%25 = load i32, i32* %24
%26 = or i32 %25, %23
store i32 %26, i32* %24
%27 = load i32, i32* %2
%28 = load i32, i32* @TCSANOW
%29 = call i32 @tcsetattr(i32 %27, i32 %28, %struct.termios* %3)
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@B9600 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
define i32 @configure_port(i32 returned %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @B9600
%5 = call i32 @cfsetispeed(%struct.termios* %2, i32 %4)
%6 = load i32, i32* @B9600
%7 = call i32 @cfsetospeed(%struct.termios* %2, i32 %6)
%8 = load i32, i32* @PARENB
%9 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = load i32, i32* @CSTOPB
%12 = or i32 %8, %11
%13 = load i32, i32* @CSIZE
%14 = or i32 %12, %13
%15 = xor i32 %14, -1
%16 = and i32 %10, %15
%17 = load i32, i32* @CS8
%18 = or i32 %17, %16
store i32 %18, i32* %9
%19 = load i32, i32* @TCSANOW
%20 = call i32 @tcsetattr(i32 %0, i32 %19, %struct.termios* %2)
ret i32 %0
}