#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 /*<<< orphan*/ B115200;
int CLOCAL;
int CREAD;
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*/ printf(char *);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void s_configure(int fd) {
  struct termios options;
  printf("configuring port...");
  tcgetattr(fd, &options);
  cfsetispeed(&options, B115200);
  cfsetospeed(&options, B115200);
  options.c_cflag |= (CLOCAL | CREAD);
  tcsetattr(fd, TCSANOW, &options);
  fcntl(fd, F_SETFL, 0);
  printf("done!\n");
}


x86 assembly (clang, -O0):
<s_configure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe8e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1060 <tcgetattr@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1080 <cfsetispeed@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1040 <cfsetospeed@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
mov    0x2e29(%rip),%rcx
or     (%rcx),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1070 <tcsetattr@plt>
mov    -0x4(%rbp),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_configure>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xe7e(%rip),%rdi
call   1060 <printf@plt>
lea    0x8(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1070 <tcgetattr@plt>
mov    0x2e2b(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1090 <cfsetispeed@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1050 <cfsetospeed@plt>
mov    0x2dfe(%rip),%rax
mov    0x2e1f(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
or     %ecx,0x8(%rsp)
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1080 <tcsetattr@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <fcntl@plt>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@.str = [20 x i8] c"configuring port...\00"
@B115200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@F_SETFL = global i32 0
@.str.1 = [7 x i8] c"done!\0A\00"
define void @s_configure(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @tcgetattr(i32 %5, %struct.termios* %3)
%7 = load i32, i32* @B115200
%8 = call i32 @cfsetispeed(%struct.termios* %3, i32 %7)
%9 = load i32, i32* @B115200
%10 = call i32 @cfsetospeed(%struct.termios* %3, i32 %9)
%11 = load i32, i32* @CLOCAL
%12 = load i32, i32* @CREAD
%13 = or i32 %11, %12
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = or i32 %15, %13
store i32 %16, i32* %14
%17 = load i32, i32* %2
%18 = load i32, i32* @TCSANOW
%19 = call i32 @tcsetattr(i32 %17, i32 %18, %struct.termios* %3)
%20 = load i32, i32* %2
%21 = load i32, i32* @F_SETFL
%22 = call i32 @fcntl(i32 %20, i32 %21, i32 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@.str = [20 x i8] c"configuring port...\00"
@B115200 = global i32 0
@CLOCAL = global i32 0
@CREAD = global i32 0
@TCSANOW = global i32 0
@F_SETFL = global i32 0
@str = [6 x i8] c"done!\00"
define void @s_configure(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @tcgetattr(i32 %0, %struct.termios* %2)
%6 = load i32, i32* @B115200
%7 = call i32 @cfsetispeed(%struct.termios* %2, i32 %6)
%8 = load i32, i32* @B115200
%9 = call i32 @cfsetospeed(%struct.termios* %2, i32 %8)
%10 = load i32, i32* @CLOCAL
%11 = load i32, i32* @CREAD
%12 = or i32 %11, %10
%13 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%14 = load i32, i32* %13
%15 = or i32 %12, %14
store i32 %15, i32* %13
%16 = load i32, i32* @TCSANOW
%17 = call i32 @tcsetattr(i32 %0, i32 %16, %struct.termios* %2)
%18 = load i32, i32* @F_SETFL
%19 = call i32 @fcntl(i32 %0, i32 %18, i32 0)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret void
}