#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_iflag;
  int c_lflag;
  int c_cflag;
  scalar_t__ *c_cc;
  int /*<<< orphan*/ c_oflag;
};

/* Variables and functions */
int BRKINT;
int CBAUD;
int CS8;
int ECHO;
int ECHOE;
int ECHOK;
int ECHONL;
int ICANON;
int IGNBRK;
int IGNCR;
int IGNPAR;
int INPCK;
int ISIG;
int IUCLC;
int IXOFF;
int IXON;
int NOFLSH;
int /*<<< orphan*/ ONOCR;
int PARMRK;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VSUSP;
size_t VTIME;
char *get_current_time();
int /*<<< orphan*/ printf(char *, char *, int);
int tcgetattr(int, struct termios *);
int tcsetattr(int, int /*<<< orphan*/, struct termios *);
int init_serial_fd(int fd, struct termios *t, int baud_to_use) {
  int i;
  i = tcgetattr(fd, t);
  printf("%s : serial tcgetattr returns %d\n", get_current_time(), i);
  t->c_iflag &= ~(BRKINT | PARMRK | INPCK | IUCLC | IXON | IXOFF);
  t->c_iflag |= (IGNBRK | IGNPAR | IGNCR);
  t->c_oflag &= ~(ONOCR);
  t->c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | NOFLSH);
  t->c_lflag |= (ISIG);
  t->c_cc[VMIN] = 0;
  t->c_cc[VTIME] = 0;
  t->c_cc[VSUSP] = 0;
  t->c_cflag &= ~(CBAUD);
  t->c_cflag |= (CS8 | baud_to_use);
  i = tcsetattr(fd, TCSANOW, t);
  printf("%s : result of new serial settings = %d\n", get_current_time(), i);
  return (i);
}


x86 assembly (clang, -O0):
<init_serial_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <tcgetattr@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <get_current_time@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e66(%rip),%rax
or     (%rax),%ecx
mov    0x2de5(%rip),%rax
or     (%rax),%ecx
mov    0x2dac(%rip),%rax
or     (%rax),%ecx
mov    0x2e23(%rip),%rax
or     (%rax),%ecx
mov    0x2e32(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x10(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2d9e(%rip),%rax
mov    (%rax),%ecx
mov    0x2d85(%rip),%rax
or     (%rax),%ecx
mov    0x2dfc(%rip),%rax
or     (%rax),%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2df3(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x10(%rbp),%rax
and    0x18(%rax),%ecx
mov    %ecx,0x18(%rax)
mov    0x2d45(%rip),%rax
mov    (%rax),%ecx
mov    0x2db4(%rip),%rax
or     (%rax),%ecx
mov    0x2da3(%rip),%rax
or     (%rax),%ecx
mov    0x2d5a(%rip),%rax
or     (%rax),%ecx
mov    0x2d49(%rip),%rax
or     (%rax),%ecx
mov    0x2d60(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x10(%rbp),%rax
and    0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    0x2d6a(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
or     0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2d37(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2ce5(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x2ca3(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c89(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x10(%rbp),%rax
and    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    0x2ce3(%rip),%rax
mov    (%rax),%ecx
or     -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    -0x4(%rbp),%edi
mov    0x2cf2(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1060 <tcsetattr@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <get_current_time@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xd32(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_serial_fd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%r15d
call   1050 <tcgetattr@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <get_current_time@plt>
lea    0xe9b(%rip),%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    0x2e2a(%rip),%rax
mov    0x2e73(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2df0(%rip),%rax
or     (%rax),%ecx
mov    0x2db7(%rip),%rax
or     (%rax),%ecx
mov    0x2e2e(%rip),%rax
or     (%rax),%ecx
mov    0x2e3d(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    (%rbx),%ecx
mov    %ecx,(%rbx)
mov    0x2dae(%rip),%rax
mov    0x2d97(%rip),%rdx
mov    0x2e10(%rip),%rsi
or     (%rax),%ecx
or     (%rdx),%ecx
or     (%rsi),%ecx
mov    %ecx,(%rbx)
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rbx)
mov    0x2d63(%rip),%rax
mov    0x2dd4(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2dc1(%rip),%rax
or     (%rax),%ecx
mov    0x2d78(%rip),%rax
or     (%rax),%ecx
mov    0x2d67(%rip),%rax
or     (%rax),%ecx
mov    0x2d7e(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    0x4(%rbx),%ecx
mov    0x2d90(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x4(%rbx)
mov    0x10(%rbx),%rax
mov    0x2d68(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d1e(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
not    %eax
and    0x8(%rbx),%eax
mov    0x2d2c(%rip),%rcx
or     %r14d,%eax
or     (%rcx),%eax
mov    %eax,0x8(%rbx)
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %rbx,%rdx
call   1060 <tcsetattr@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <get_current_time@plt>
lea    0xd8a(%rip),%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@.str = [34 x i8] c"%s : serial tcgetattr returns %d\0A\00"
@BRKINT = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@IUCLC = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IGNBRK = global i32 0
@IGNPAR = global i32 0
@IGNCR = global i32 0
@ONOCR = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@NOFLSH = global i32 0
@ISIG = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@VSUSP = global i64 0
@CBAUD = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
@.str.1 = [41 x i8] c"%s : result of new serial settings = %d\0A\00"
define i32 @init_serial_fd(i32 %0, %struct.termios* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.termios*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store %struct.termios* %1, %struct.termios** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load %struct.termios*, %struct.termios** %5
%10 = call i32 @tcgetattr(i32 %8, %struct.termios* %9)
store i32 %10, i32* %7
%11 = call i8* (...) @get_current_time()
%12 = load i32, i32* %7
%13 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12)
%14 = load i32, i32* @BRKINT
%15 = load i32, i32* @PARMRK
%16 = or i32 %14, %15
%17 = load i32, i32* @INPCK
%18 = or i32 %16, %17
%19 = load i32, i32* @IUCLC
%20 = or i32 %18, %19
%21 = load i32, i32* @IXON
%22 = or i32 %20, %21
%23 = load i32, i32* @IXOFF
%24 = or i32 %22, %23
%25 = xor i32 %24, -1
%26 = load %struct.termios*, %struct.termios** %5
%27 = getelementptr inbounds %struct.termios, %struct.termios* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = and i32 %28, %25
store i32 %29, i32* %27
%30 = load i32, i32* @IGNBRK
%31 = load i32, i32* @IGNPAR
%32 = or i32 %30, %31
%33 = load i32, i32* @IGNCR
%34 = or i32 %32, %33
%35 = load %struct.termios*, %struct.termios** %5
%36 = getelementptr inbounds %struct.termios, %struct.termios* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = or i32 %37, %34
store i32 %38, i32* %36
%39 = load i32, i32* @ONOCR
%40 = xor i32 %39, -1
%41 = load %struct.termios*, %struct.termios** %5
%42 = getelementptr inbounds %struct.termios, %struct.termios* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = and i32 %43, %40
store i32 %44, i32* %42
%45 = load i32, i32* @ICANON
%46 = load i32, i32* @ECHO
%47 = or i32 %45, %46
%48 = load i32, i32* @ECHOE
%49 = or i32 %47, %48
%50 = load i32, i32* @ECHOK
%51 = or i32 %49, %50
%52 = load i32, i32* @ECHONL
%53 = or i32 %51, %52
%54 = load i32, i32* @NOFLSH
%55 = or i32 %53, %54
%56 = xor i32 %55, -1
%57 = load %struct.termios*, %struct.termios** %5
%58 = getelementptr inbounds %struct.termios, %struct.termios* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = and i32 %59, %56
store i32 %60, i32* %58
%61 = load i32, i32* @ISIG
%62 = load %struct.termios*, %struct.termios** %5
%63 = getelementptr inbounds %struct.termios, %struct.termios* %62, i32 0, i32 1
%64 = load i32, i32* %63
%65 = or i32 %64, %61
store i32 %65, i32* %63
%66 = load %struct.termios*, %struct.termios** %5
%67 = getelementptr inbounds %struct.termios, %struct.termios* %66, i32 0, i32 3
%68 = load i64*, i64** %67
%69 = load i64, i64* @VMIN
%70 = getelementptr inbounds i64, i64* %68, i64 %69
store i64 0, i64* %70
%71 = load %struct.termios*, %struct.termios** %5
%72 = getelementptr inbounds %struct.termios, %struct.termios* %71, i32 0, i32 3
%73 = load i64*, i64** %72
%74 = load i64, i64* @VTIME
%75 = getelementptr inbounds i64, i64* %73, i64 %74
store i64 0, i64* %75
%76 = load %struct.termios*, %struct.termios** %5
%77 = getelementptr inbounds %struct.termios, %struct.termios* %76, i32 0, i32 3
%78 = load i64*, i64** %77
%79 = load i64, i64* @VSUSP
%80 = getelementptr inbounds i64, i64* %78, i64 %79
store i64 0, i64* %80
%81 = load i32, i32* @CBAUD
%82 = xor i32 %81, -1
%83 = load %struct.termios*, %struct.termios** %5
%84 = getelementptr inbounds %struct.termios, %struct.termios* %83, i32 0, i32 2
%85 = load i32, i32* %84
%86 = and i32 %85, %82
store i32 %86, i32* %84
%87 = load i32, i32* @CS8
%88 = load i32, i32* %6
%89 = or i32 %87, %88
%90 = load %struct.termios*, %struct.termios** %5
%91 = getelementptr inbounds %struct.termios, %struct.termios* %90, i32 0, i32 2
%92 = load i32, i32* %91
%93 = or i32 %92, %89
store i32 %93, i32* %91
%94 = load i32, i32* %4
%95 = load i32, i32* @TCSANOW
%96 = load %struct.termios*, %struct.termios** %5
%97 = call i32 @tcsetattr(i32 %94, i32 %95, %struct.termios* %96)
store i32 %97, i32* %7
%98 = call i8* (...) @get_current_time()
%99 = load i32, i32* %7
%100 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %98, i32 %99)
%101 = load i32, i32* %7
ret i32 %101
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@.str = [34 x i8] c"%s : serial tcgetattr returns %d\0A\00"
@BRKINT = global i32 0
@PARMRK = global i32 0
@INPCK = global i32 0
@IUCLC = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IGNBRK = global i32 0
@IGNPAR = global i32 0
@IGNCR = global i32 0
@ONOCR = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@NOFLSH = global i32 0
@ISIG = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@VSUSP = global i64 0
@CBAUD = global i32 0
@CS8 = global i32 0
@TCSANOW = global i32 0
@.str.1 = [41 x i8] c"%s : result of new serial settings = %d\0A\00"
define i32 @init_serial_fd(i32 %0, %struct.termios* %1, i32 %2) {
%4 = tail call i32 @tcgetattr(i32 %0, %struct.termios* %1)
%5 = tail call i8* (...) @get_current_time()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %4)
%7 = load i32, i32* @BRKINT
%8 = load i32, i32* @PARMRK
%9 = or i32 %8, %7
%10 = load i32, i32* @INPCK
%11 = or i32 %9, %10
%12 = load i32, i32* @IUCLC
%13 = or i32 %11, %12
%14 = load i32, i32* @IXON
%15 = or i32 %13, %14
%16 = load i32, i32* @IXOFF
%17 = or i32 %15, %16
%18 = xor i32 %17, -1
%19 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%20 = load i32, i32* %19
%21 = and i32 %20, %18
store i32 %21, i32* %19
%22 = load i32, i32* @IGNBRK
%23 = load i32, i32* @IGNPAR
%24 = load i32, i32* @IGNCR
%25 = or i32 %22, %21
%26 = or i32 %25, %23
%27 = or i32 %26, %24
store i32 %27, i32* %19
%28 = load i32, i32* @ONOCR
%29 = xor i32 %28, -1
%30 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 4
%31 = load i32, i32* %30
%32 = and i32 %31, %29
store i32 %32, i32* %30
%33 = load i32, i32* @ICANON
%34 = load i32, i32* @ECHO
%35 = or i32 %34, %33
%36 = load i32, i32* @ECHOE
%37 = or i32 %35, %36
%38 = load i32, i32* @ECHOK
%39 = or i32 %37, %38
%40 = load i32, i32* @ECHONL
%41 = or i32 %39, %40
%42 = load i32, i32* @NOFLSH
%43 = or i32 %41, %42
%44 = xor i32 %43, -1
%45 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 1
%46 = load i32, i32* %45
%47 = and i32 %46, %44
%48 = load i32, i32* @ISIG
%49 = or i32 %48, %47
store i32 %49, i32* %45
%50 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 3
%51 = load i64*, i64** %50
%52 = load i64, i64* @VMIN
%53 = getelementptr inbounds i64, i64* %51, i64 %52
store i64 0, i64* %53
%54 = load i64, i64* @VTIME
%55 = getelementptr inbounds i64, i64* %51, i64 %54
store i64 0, i64* %55
%56 = load i64, i64* @VSUSP
%57 = getelementptr inbounds i64, i64* %51, i64 %56
store i64 0, i64* %57
%58 = load i32, i32* @CBAUD
%59 = xor i32 %58, -1
%60 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 2
%61 = load i32, i32* %60
%62 = and i32 %61, %59
%63 = load i32, i32* @CS8
%64 = or i32 %62, %2
%65 = or i32 %64, %63
store i32 %65, i32* %60
%66 = load i32, i32* @TCSANOW
%67 = tail call i32 @tcsetattr(i32 %0, i32 %66, %struct.termios* %1)
%68 = tail call i8* (...) @get_current_time()
%69 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %68, i32 %67)
ret i32 %67
}