#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 ECHOK;
int ECHONL;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void echo_off() {
  struct termios foo;
  if (!tcgetattr(0, &foo)) {
    foo.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
    tcsetattr(0, TCSANOW, &foo);
  }
}


x86 assembly (clang, -O0):
<echo_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0x0,%eax
jne    117d <echo_off+0x5d>
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    0x2e8c(%rip),%rcx
or     (%rcx),%eax
mov    0x2e73(%rip),%rcx
or     (%rcx),%eax
mov    0x2e62(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<echo_off>:
push   %rax
mov    %rsp,%rsi
xor    %edi,%edi
call   1030 <tcgetattr@plt>
test   %eax,%eax
je     1131 <echo_off+0x11>
pop    %rax
ret
mov    0x2ea8(%rip),%rax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e7e(%rip),%rax
or     (%rax),%ecx
mov    0x2e6d(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,(%rsp)
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1040 <tcsetattr@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@TCSANOW = global i32 0
define void @echo_off() {
%1 = alloca %struct.termios
%2 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%3 = icmp ne i32 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %0
%5 = load i32, i32* @ECHO
%6 = load i32, i32* @ECHOE
%7 = or i32 %5, %6
%8 = load i32, i32* @ECHOK
%9 = or i32 %7, %8
%10 = load i32, i32* @ECHONL
%11 = or i32 %9, %10
%12 = xor i32 %11, -1
%13 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 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* %1)
br label %18
18: ; preds = %4, %0
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@TCSANOW = global i32 0
define void @echo_off() {
%1 = alloca %struct.termios
%2 = bitcast %struct.termios* %1 to i8*
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %0
%6 = load i32, i32* @ECHO
%7 = load i32, i32* @ECHOE
%8 = or i32 %7, %6
%9 = load i32, i32* @ECHOK
%10 = or i32 %8, %9
%11 = load i32, i32* @ECHONL
%12 = or i32 %10, %11
%13 = xor i32 %12, -1
%14 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%15 = load i32, i32* %14
%16 = and i32 %15, %13
store i32 %16, i32* %14
%17 = load i32, i32* @TCSANOW
%18 = call i32 @tcsetattr(i32 0, i32 %17, %struct.termios* %1)
br label %19
19: ; preds = %5, %0
ret void
}