#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*/ tio;
struct termios {
  scalar_t__ *c_cc;
};

/* Variables and functions */
int /*<<< orphan*/ B115200;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void serial_init(int fd) {
  struct termios tio;
  memset(&tio, 0, sizeof(tio));
  cfmakeraw(&tio);
  tio.c_cc[VTIME] = 0;
  tio.c_cc[VMIN] = 0;
  cfsetispeed(&tio, B115200);
  cfsetospeed(&tio, B115200);
  tcsetattr(fd, TCSANOW, &tio);
}


x86 assembly (clang, -O0):
<serial_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x10(%rbp),%rdi
call   1050 <cfmakeraw@plt>
mov    -0x10(%rbp),%rax
mov    0x2e49(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x2e4b(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
call   1070 <cfsetispeed@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
call   1030 <cfsetospeed@plt>
mov    -0x4(%rbp),%edi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1060 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_init>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1050 <cfmakeraw@plt>
mov    0x8(%rsp),%rax
mov    0x2e45(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2e4b(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2e29(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1070 <cfsetispeed@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1030 <cfsetospeed@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %rbx,%rdx
call   1060 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i64* }
@VTIME = global i64 0
@VMIN = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
define void @serial_init(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = call i32 @memset(%struct.termios* %3, i32 0, i32 8)
%5 = call i32 @cfmakeraw(%struct.termios* %3)
%6 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%7 = load i64*, i64** %6
%8 = load i64, i64* @VTIME
%9 = getelementptr inbounds i64, i64* %7, i64 %8
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%11 = load i64*, i64** %10
%12 = load i64, i64* @VMIN
%13 = getelementptr inbounds i64, i64* %11, i64 %12
store i64 0, i64* %13
%14 = load i32, i32* @B115200
%15 = call i32 @cfsetispeed(%struct.termios* %3, i32 %14)
%16 = load i32, i32* @B115200
%17 = call i32 @cfsetospeed(%struct.termios* %3, i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* @TCSANOW
%20 = call i32 @tcsetattr(i32 %18, i32 %19, %struct.termios* %3)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i64* }
@VTIME = global i64 0
@VMIN = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
define void @serial_init(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = call i32 @memset(%struct.termios* %2, i32 0, i32 8)
%5 = call i32 @cfmakeraw(%struct.termios* %2)
%6 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%7 = load i64*, i64** %6
%8 = load i64, i64* @VTIME
%9 = getelementptr inbounds i64, i64* %7, i64 %8
store i64 0, i64* %9
%10 = load i64, i64* @VMIN
%11 = getelementptr inbounds i64, i64* %7, i64 %10
store i64 0, i64* %11
%12 = load i32, i32* @B115200
%13 = call i32 @cfsetispeed(%struct.termios* %2, i32 %12)
%14 = load i32, i32* @B115200
%15 = call i32 @cfsetospeed(%struct.termios* %2, i32 %14)
%16 = load i32, i32* @TCSANOW
%17 = call i32 @tcsetattr(i32 %0, i32 %16, %struct.termios* %2)
ret void
}