#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;
};

/* Variables and functions */
int ECHO;
int ECHOE;
int ICANON;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
void __init_fd_tc(int fd) {
  struct termios options;
  tcgetattr(fd, &options);
  tcflush(fd, TCIOFLUSH);
  options.c_lflag &= ~(ICANON | ECHO | ECHOE);
  tcsetattr(fd, TCSANOW, &options);
}


x86 assembly (clang, -O0):
<__init_fd_tc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    -0x4(%rbp),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    0x2e78(%rip),%rcx
or     (%rcx),%eax
mov    0x2e67(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1050 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__init_fd_tc>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <tcgetattr@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1030 <tcflush@plt>
mov    0x2e68(%rip),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e6e(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@TCIOFLUSH = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@TCSANOW = global i32 0
define void @__init_fd_tc(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @tcgetattr(i32 %4, %struct.termios* %3)
%6 = load i32, i32* %2
%7 = load i32, i32* @TCIOFLUSH
%8 = call i32 @tcflush(i32 %6, i32 %7)
%9 = load i32, i32* @ICANON
%10 = load i32, i32* @ECHO
%11 = or i32 %9, %10
%12 = load i32, i32* @ECHOE
%13 = or i32 %11, %12
%14 = xor i32 %13, -1
%15 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%16 = load i32, i32* %15
%17 = and i32 %16, %14
store i32 %17, i32* %15
%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 { i32 }
@TCIOFLUSH = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@TCSANOW = global i32 0
define void @__init_fd_tc(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = call i32 @tcgetattr(i32 %0, %struct.termios* %2)
%5 = load i32, i32* @TCIOFLUSH
%6 = call i32 @tcflush(i32 %0, i32 %5)
%7 = load i32, i32* @ICANON
%8 = load i32, i32* @ECHO
%9 = or i32 %8, %7
%10 = load i32, i32* @ECHOE
%11 = or i32 %9, %10
%12 = xor i32 %11, -1
%13 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%14 = load i32, i32* %13
%15 = and i32 %14, %12
store i32 %15, i32* %13
%16 = load i32, i32* @TCSANOW
%17 = call i32 @tcsetattr(i32 %0, i32 %16, %struct.termios* %2)
ret void
}