#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 */
typedef int /*<<< orphan*/ uint32_t;
struct termios {
  int c_cflag;
};

/* Variables and functions */
int CLOCAL;
int CREAD;
int /*<<< orphan*/ FNDELAY;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void local_config_port(int uart, uint32_t speed) {
  fcntl(uart, F_SETFL, FNDELAY);
  struct termios options;
  tcgetattr(uart, &options);
  cfsetispeed(&options, speed);
  cfsetospeed(&options, speed);
  options.c_cflag |= (CLOCAL | CREAD);
  tcsetattr(uart, TCSANOW, &options);
}


x86 assembly (clang, -O0):
<local_config_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <tcgetattr@plt>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1070 <cfsetispeed@plt>
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   1040 <cfsetospeed@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    0x2e34(%rip),%rcx
or     (%rcx),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1060 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local_config_port>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
call   1030 <fcntl@plt>
lea    0x8(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tcgetattr@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1070 <cfsetispeed@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <cfsetospeed@plt>
mov    0x2e1b(%rip),%rax
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,0x8(%rsp)
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1060 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@F_SETFL = global i32 0
@FNDELAY = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
define void @local_config_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 = load i32, i32* @F_SETFL
%8 = load i32, i32* @FNDELAY
%9 = call i32 @fcntl(i32 %6, i32 %7, i32 %8)
%10 = load i32, i32* %3
%11 = call i32 @tcgetattr(i32 %10, %struct.termios* %5)
%12 = load i32, i32* %4
%13 = call i32 @cfsetispeed(%struct.termios* %5, i32 %12)
%14 = load i32, i32* %4
%15 = call i32 @cfsetospeed(%struct.termios* %5, i32 %14)
%16 = load i32, i32* @CLOCAL
%17 = load i32, i32* @CREAD
%18 = or i32 %16, %17
%19 = getelementptr inbounds %struct.termios, %struct.termios* %5, i32 0, i32 0
%20 = load i32, i32* %19
%21 = or i32 %20, %18
store i32 %21, i32* %19
%22 = load i32, i32* %3
%23 = load i32, i32* @TCSANOW
%24 = call i32 @tcsetattr(i32 %22, i32 %23, %struct.termios* %5)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@F_SETFL = global i32 0
@FNDELAY = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
define void @local_config_port(i32 %0, i32 %1) {
%3 = alloca %struct.termios
%4 = load i32, i32* @F_SETFL
%5 = load i32, i32* @FNDELAY
%6 = tail call i32 @fcntl(i32 %0, i32 %4, i32 %5)
%7 = bitcast %struct.termios* %3 to i8*
%8 = call i32 @tcgetattr(i32 %0, %struct.termios* %3)
%9 = call i32 @cfsetispeed(%struct.termios* %3, i32 %1)
%10 = call i32 @cfsetospeed(%struct.termios* %3, i32 %1)
%11 = load i32, i32* @CLOCAL
%12 = load i32, i32* @CREAD
%13 = or i32 %12, %11
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = or i32 %13, %15
store i32 %16, i32* %14
%17 = load i32, i32* @TCSANOW
%18 = call i32 @tcsetattr(i32 %0, i32 %17, %struct.termios* %3)
ret void
}