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


x86 assembly (clang, -O0):
<set_noecho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0x0,%rax
jge    1146 <set_noecho+0x26>
jmp    1188 <set_noecho+0x68>
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    0x2e82(%rip),%rcx
or     (%rcx),%eax
mov    0x2e69(%rip),%rcx
or     (%rcx),%eax
mov    0x2e58(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_noecho>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%rsi
call   1030 <tcgetattr@plt>
test   %rax,%rax
js     1175 <set_noecho+0x55>
mov    0x2ea3(%rip),%rax
mov    0x2e94(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e79(%rip),%rax
or     (%rax),%ecx
mov    0x2e68(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,0x8(%rsp)
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
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 @set_noecho(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.termios
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i64 @tcgetattr(i32 %4, %struct.termios* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %23
8: ; preds = %1
%9 = load i32, i32* @ECHO
%10 = load i32, i32* @ECHOE
%11 = or i32 %9, %10
%12 = load i32, i32* @ECHOK
%13 = or i32 %11, %12
%14 = load i32, i32* @ECHONL
%15 = or i32 %13, %14
%16 = xor i32 %15, -1
%17 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%18 = load i32, i32* %17
%19 = and i32 %18, %16
store i32 %19, i32* %17
%20 = load i32, i32* %2
%21 = load i32, i32* @TCSANOW
%22 = call i32 @tcsetattr(i32 %20, i32 %21, %struct.termios* %3)
br label %23
23: ; preds = %8, %7
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 @set_noecho(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = call i64 @tcgetattr(i32 %0, %struct.termios* %2)
%5 = icmp slt i64 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = load i32, i32* @ECHO
%8 = load i32, i32* @ECHOE
%9 = or i32 %8, %7
%10 = load i32, i32* @ECHOK
%11 = or i32 %9, %10
%12 = load i32, i32* @ECHONL
%13 = or i32 %11, %12
%14 = xor i32 %13, -1
%15 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = and i32 %16, %14
store i32 %17, i32* %15
%18 = load i32, i32* @TCSANOW
%19 = call i32 @tcsetattr(i32 %0, i32 %18, %struct.termios* %2)
br label %20
20: ; preds = %1, %6
ret void
}