#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_lflag;
  int c_iflag;
  int c_cflag;
  int /*<<< orphan*/ c_oflag;
};
typedef int /*<<< orphan*/ speed_t;

/* Variables and functions */
int BRKINT;
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ECHOK;
int ECHONL;
int HUPCL;
int ICANON;
int ICRNL;
int IEXTEN;
int IGNBRK;
int IGNCR;
int INLCR;
int ISIG;
int ISTRIP;
int IXANY;
int IXOFF;
int IXON;
int /*<<< orphan*/ OPOST;
int PARENB;
int PARMRK;
int /*<<< orphan*/ cfmakeraw(struct termios *);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
struct termios *serial_termios(struct termios *termctl, speed_t baudrate) {
  cfmakeraw(termctl);
  termctl->c_lflag &= ~(ECHO | ECHONL | ECHOE | ECHOK | ICANON | ISIG | IEXTEN);
  termctl->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR |
                        ICRNL | IXON | IXOFF | IXANY);
  termctl->c_cflag &= ~(CSTOPB | CSIZE | PARENB | HUPCL | CRTSCTS);
  termctl->c_cflag |= CS8 | CREAD | CLOCAL;
  termctl->c_iflag |= IGNBRK;
  termctl->c_oflag &= ~OPOST;
  cfsetospeed(termctl, baudrate);
  cfsetispeed(termctl, baudrate);
  return termctl;
}


x86 assembly (clang, -O0):
<serial_termios>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <cfmakeraw@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%ecx
mov    0x2df0(%rip),%rax
or     (%rax),%ecx
mov    0x2e3f(%rip),%rax
or     (%rax),%ecx
mov    0x2dee(%rip),%rax
or     (%rax),%ecx
mov    0x2dbd(%rip),%rax
or     (%rax),%ecx
mov    0x2e1c(%rip),%rax
or     (%rax),%ecx
mov    0x2deb(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2da7(%rip),%rax
mov    (%rax),%ecx
mov    0x2dee(%rip),%rax
or     (%rax),%ecx
mov    0x2e45(%rip),%rax
or     (%rax),%ecx
mov    0x2d9c(%rip),%rax
or     (%rax),%ecx
mov    0x2e1b(%rip),%rax
or     (%rax),%ecx
mov    0x2e02(%rip),%rax
or     (%rax),%ecx
mov    0x2e11(%rip),%rax
or     (%rax),%ecx
mov    0x2de0(%rip),%rax
or     (%rax),%ecx
mov    0x2def(%rip),%rax
or     (%rax),%ecx
mov    0x2d76(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    0x2d18(%rip),%rax
mov    (%rax),%ecx
mov    0x2d6f(%rip),%rax
or     (%rax),%ecx
mov    0x2d9e(%rip),%rax
or     (%rax),%ecx
mov    0x2d1d(%rip),%rax
or     (%rax),%ecx
mov    0x2cfc(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    0x2d46(%rip),%rax
mov    (%rax),%ecx
mov    0x2d45(%rip),%rax
or     (%rax),%ecx
mov    0x2cc4(%rip),%rax
or     (%rax),%ecx
mov    -0x8(%rbp),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    0x2ce1(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
or     0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    0x2d4e(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <cfsetospeed@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <cfsetispeed@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_termios>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <cfmakeraw@plt>
mov    0x2e64(%rip),%rax
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e4a(%rip),%rax
or     (%rax),%ecx
mov    0x2df9(%rip),%rax
or     (%rax),%ecx
mov    0x2dc8(%rip),%rax
or     (%rax),%ecx
mov    0x2e27(%rip),%rax
or     (%rax),%ecx
mov    0x2df6(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rbx)
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    0x2e00(%rip),%rcx
mov    (%rcx),%ecx
or     %eax,%ecx
mov    0x2e55(%rip),%rdx
or     (%rdx),%ecx
mov    0x2dac(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e2b(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e12(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e21(%rip),%rdx
or     (%rdx),%ecx
mov    0x2df0(%rip),%rdx
or     (%rdx),%ecx
mov    0x2dff(%rip),%rdx
or     (%rdx),%ecx
mov    0x2d86(%rip),%rdx
or     (%rdx),%ecx
not    %ecx
and    0x4(%rbx),%ecx
mov    0x2d30(%rip),%rdx
mov    0x2d89(%rip),%rsi
mov    (%rsi),%esi
or     (%rdx),%esi
mov    0x2db6(%rip),%rdx
or     (%rdx),%esi
mov    0x2d35(%rip),%rdx
or     (%rdx),%esi
mov    0x2d14(%rip),%rdx
or     (%rdx),%esi
not    %esi
and    0x8(%rbx),%esi
mov    0x2d66(%rip),%rdx
mov    0x2d67(%rip),%rdi
or     (%rdx),%esi
or     (%rdi),%esi
mov    0x2ce4(%rip),%rdx
or     (%rdx),%esi
mov    %esi,0x8(%rbx)
or     %eax,%ecx
mov    %ecx,0x4(%rbx)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0xc(%rbx)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <cfsetospeed@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <cfsetispeed@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i32 }
@ECHO = global i32 0
@ECHONL = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ICANON = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@IGNBRK = global i32 0
@BRKINT = global i32 0
@PARMRK = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@HUPCL = global i32 0
@CRTSCTS = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@OPOST = global i32 0
define %struct.termios* @serial_termios(%struct.termios* %0, i32 %1) {
%3 = alloca %struct.termios*
%4 = alloca i32
store %struct.termios* %0, %struct.termios** %3
store i32 %1, i32* %4
%5 = load %struct.termios*, %struct.termios** %3
%6 = call i32 @cfmakeraw(%struct.termios* %5)
%7 = load i32, i32* @ECHO
%8 = load i32, i32* @ECHONL
%9 = or i32 %7, %8
%10 = load i32, i32* @ECHOE
%11 = or i32 %9, %10
%12 = load i32, i32* @ECHOK
%13 = or i32 %11, %12
%14 = load i32, i32* @ICANON
%15 = or i32 %13, %14
%16 = load i32, i32* @ISIG
%17 = or i32 %15, %16
%18 = load i32, i32* @IEXTEN
%19 = or i32 %17, %18
%20 = xor i32 %19, -1
%21 = load %struct.termios*, %struct.termios** %3
%22 = getelementptr inbounds %struct.termios, %struct.termios* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = and i32 %23, %20
store i32 %24, i32* %22
%25 = load i32, i32* @IGNBRK
%26 = load i32, i32* @BRKINT
%27 = or i32 %25, %26
%28 = load i32, i32* @PARMRK
%29 = or i32 %27, %28
%30 = load i32, i32* @ISTRIP
%31 = or i32 %29, %30
%32 = load i32, i32* @INLCR
%33 = or i32 %31, %32
%34 = load i32, i32* @IGNCR
%35 = or i32 %33, %34
%36 = load i32, i32* @ICRNL
%37 = or i32 %35, %36
%38 = load i32, i32* @IXON
%39 = or i32 %37, %38
%40 = load i32, i32* @IXOFF
%41 = or i32 %39, %40
%42 = load i32, i32* @IXANY
%43 = or i32 %41, %42
%44 = xor i32 %43, -1
%45 = load %struct.termios*, %struct.termios** %3
%46 = getelementptr inbounds %struct.termios, %struct.termios* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = and i32 %47, %44
store i32 %48, i32* %46
%49 = load i32, i32* @CSTOPB
%50 = load i32, i32* @CSIZE
%51 = or i32 %49, %50
%52 = load i32, i32* @PARENB
%53 = or i32 %51, %52
%54 = load i32, i32* @HUPCL
%55 = or i32 %53, %54
%56 = load i32, i32* @CRTSCTS
%57 = or i32 %55, %56
%58 = xor i32 %57, -1
%59 = load %struct.termios*, %struct.termios** %3
%60 = getelementptr inbounds %struct.termios, %struct.termios* %59, i32 0, i32 2
%61 = load i32, i32* %60
%62 = and i32 %61, %58
store i32 %62, i32* %60
%63 = load i32, i32* @CS8
%64 = load i32, i32* @CREAD
%65 = or i32 %63, %64
%66 = load i32, i32* @CLOCAL
%67 = or i32 %65, %66
%68 = load %struct.termios*, %struct.termios** %3
%69 = getelementptr inbounds %struct.termios, %struct.termios* %68, i32 0, i32 2
%70 = load i32, i32* %69
%71 = or i32 %70, %67
store i32 %71, i32* %69
%72 = load i32, i32* @IGNBRK
%73 = load %struct.termios*, %struct.termios** %3
%74 = getelementptr inbounds %struct.termios, %struct.termios* %73, i32 0, i32 1
%75 = load i32, i32* %74
%76 = or i32 %75, %72
store i32 %76, i32* %74
%77 = load i32, i32* @OPOST
%78 = xor i32 %77, -1
%79 = load %struct.termios*, %struct.termios** %3
%80 = getelementptr inbounds %struct.termios, %struct.termios* %79, i32 0, i32 3
%81 = load i32, i32* %80
%82 = and i32 %81, %78
store i32 %82, i32* %80
%83 = load %struct.termios*, %struct.termios** %3
%84 = load i32, i32* %4
%85 = call i32 @cfsetospeed(%struct.termios* %83, i32 %84)
%86 = load %struct.termios*, %struct.termios** %3
%87 = load i32, i32* %4
%88 = call i32 @cfsetispeed(%struct.termios* %86, i32 %87)
%89 = load %struct.termios*, %struct.termios** %3
ret %struct.termios* %89
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i32 }
@ECHO = global i32 0
@ECHONL = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ICANON = global i32 0
@ISIG = global i32 0
@IEXTEN = global i32 0
@IGNBRK = global i32 0
@BRKINT = global i32 0
@PARMRK = global i32 0
@ISTRIP = global i32 0
@INLCR = global i32 0
@IGNCR = global i32 0
@ICRNL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@PARENB = global i32 0
@HUPCL = global i32 0
@CRTSCTS = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@OPOST = global i32 0
define %struct.termios* @serial_termios(%struct.termios* returned %0, i32 %1) {
%3 = tail call i32 @cfmakeraw(%struct.termios* %0)
%4 = load i32, i32* @ECHO
%5 = load i32, i32* @ECHONL
%6 = or i32 %5, %4
%7 = load i32, i32* @ECHOE
%8 = or i32 %6, %7
%9 = load i32, i32* @ECHOK
%10 = or i32 %8, %9
%11 = load i32, i32* @ICANON
%12 = or i32 %10, %11
%13 = load i32, i32* @ISIG
%14 = or i32 %12, %13
%15 = load i32, i32* @IEXTEN
%16 = or i32 %14, %15
%17 = xor i32 %16, -1
%18 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, %17
store i32 %20, i32* %18
%21 = load i32, i32* @IGNBRK
%22 = load i32, i32* @BRKINT
%23 = or i32 %22, %21
%24 = load i32, i32* @PARMRK
%25 = or i32 %23, %24
%26 = load i32, i32* @ISTRIP
%27 = or i32 %25, %26
%28 = load i32, i32* @INLCR
%29 = or i32 %27, %28
%30 = load i32, i32* @IGNCR
%31 = or i32 %29, %30
%32 = load i32, i32* @ICRNL
%33 = or i32 %31, %32
%34 = load i32, i32* @IXON
%35 = or i32 %33, %34
%36 = load i32, i32* @IXOFF
%37 = or i32 %35, %36
%38 = load i32, i32* @IXANY
%39 = or i32 %37, %38
%40 = xor i32 %39, -1
%41 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 1
%42 = load i32, i32* %41
%43 = and i32 %42, %40
%44 = load i32, i32* @CSTOPB
%45 = load i32, i32* @CSIZE
%46 = or i32 %45, %44
%47 = load i32, i32* @PARENB
%48 = or i32 %46, %47
%49 = load i32, i32* @HUPCL
%50 = or i32 %48, %49
%51 = load i32, i32* @CRTSCTS
%52 = or i32 %50, %51
%53 = xor i32 %52, -1
%54 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 2
%55 = load i32, i32* %54
%56 = and i32 %55, %53
%57 = load i32, i32* @CS8
%58 = load i32, i32* @CREAD
%59 = load i32, i32* @CLOCAL
%60 = or i32 %57, %56
%61 = or i32 %60, %58
%62 = or i32 %61, %59
store i32 %62, i32* %54
%63 = or i32 %43, %21
store i32 %63, i32* %41
%64 = load i32, i32* @OPOST
%65 = xor i32 %64, -1
%66 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 3
%67 = load i32, i32* %66
%68 = and i32 %67, %65
store i32 %68, i32* %66
%69 = tail call i32 @cfsetospeed(%struct.termios* %0, i32 %1)
%70 = tail call i32 @cfsetispeed(%struct.termios* %0, i32 %1)
ret %struct.termios* %0
}