#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;
scalar_t__ EINTR;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
scalar_t__ errno;
int tcgetattr(int /*<<< orphan*/, struct termios *);
int tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/, struct termios *);
void setBlindInput(int on) {
  int error;
  struct termios term;
  if (tcgetattr(STDIN_FILENO, &term) == -1)
    return;
  if (on == 0)
    term.c_lflag |= (ECHO | ECHOE | ECHOK | ECHONL);
  else
    term.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
  while (((error = tcsetattr(STDIN_FILENO, TCSAFLUSH, &term)) == -1) &&
         (errno == EINTR))
    ;
  return;
}


x86 assembly (clang, -O0):
<setBlindInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    114b <setBlindInput+0x2b>
jmp    1218 <setBlindInput+0xf8>
cmpl   $0x0,-0x4(%rbp)
jne    1184 <setBlindInput+0x64>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    0x2e73(%rip),%rcx
or     (%rcx),%eax
mov    0x2e5a(%rip),%rcx
or     (%rcx),%eax
mov    0x2e41(%rip),%rcx
or     (%rcx),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b1 <setBlindInput+0x91>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    0x2e44(%rip),%rcx
or     (%rcx),%eax
mov    0x2e2b(%rip),%rcx
or     (%rcx),%eax
mov    0x2e12(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b6 <setBlindInput+0x96>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <tcsetattr@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x11(%rbp)
jne    11fe <setBlindInput+0xde>
mov    0x2dd5(%rip),%rax
mov    (%rax),%rax
mov    0x2dbb(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    120e <setBlindInput+0xee>
jmp    1213 <setBlindInput+0xf3>
jmp    11b6 <setBlindInput+0x96>
jmp    1218 <setBlindInput+0xf8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBlindInput>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2e72(%rip),%r14
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     11bc <setBlindInput+0x9c>
mov    0x2e91(%rip),%rcx
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2e67(%rip),%rcx
or     (%rcx),%eax
mov    0x2e4e(%rip),%rcx
or     (%rcx),%eax
test   %ebx,%ebx
je     1178 <setBlindInput+0x58>
not    %eax
and    %eax,0x8(%rsp)
jmp    117c <setBlindInput+0x5c>
or     %eax,0x8(%rsp)
mov    0x2e65(%rip),%r15
lea    0x8(%rsp),%r13
mov    0x2e31(%rip),%r12
mov    0x2e1a(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    (%r15),%esi
mov    %r13,%rdx
call   1040 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    11bc <setBlindInput+0x9c>
mov    (%rbx),%rax
cmp    %rax,(%r12)
je     11a0 <setBlindInput+0x80>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@TCSAFLUSH = global i32 0
@errno = global i64 0
@EINTR = global i64 0
define void @setBlindInput(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.termios
store i32 %0, i32* %2
%5 = load i32, i32* @STDIN_FILENO
%6 = call i32 @tcgetattr(i32 %5, %struct.termios* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %1
br label %49
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load i32, i32* @ECHO
%14 = load i32, i32* @ECHOE
%15 = or i32 %13, %14
%16 = load i32, i32* @ECHOK
%17 = or i32 %15, %16
%18 = load i32, i32* @ECHONL
%19 = or i32 %17, %18
%20 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%21 = load i32, i32* %20
%22 = or i32 %21, %19
store i32 %22, i32* %20
br label %35
23: ; preds = %9
%24 = load i32, i32* @ECHO
%25 = load i32, i32* @ECHOE
%26 = or i32 %24, %25
%27 = load i32, i32* @ECHOK
%28 = or i32 %26, %27
%29 = load i32, i32* @ECHONL
%30 = or i32 %28, %29
%31 = xor i32 %30, -1
%32 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%33 = load i32, i32* %32
%34 = and i32 %33, %31
store i32 %34, i32* %32
br label %35
35: ; preds = %23, %12
br label %36
36: ; preds = %47, %35
%37 = load i32, i32* @STDIN_FILENO
%38 = load i32, i32* @TCSAFLUSH
%39 = call i32 @tcsetattr(i32 %37, i32 %38, %struct.termios* %4)
store i32 %39, i32* %3
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i64, i64* @errno
%43 = load i64, i64* @EINTR
%44 = icmp eq i64 %42, %43
br label %45
45: ; preds = %41, %36
%46 = phi i1 [ false, %36 ], [ %44, %41 ]
br i1 %46, label %47, label %48
47: ; preds = %45
br label %36
48: ; preds = %45
br label %49
49: ; preds = %48, %8
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ECHOK = global i32 0
@ECHONL = global i32 0
@TCSAFLUSH = global i32 0
@errno = global i64 0
@EINTR = global i64 0
define void @setBlindInput(i32 %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @STDIN_FILENO
%5 = call i32 @tcgetattr(i32 %4, %struct.termios* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %35, label %7
7: ; preds = %1
%8 = icmp eq i32 %0, 0
%9 = load i32, i32* @ECHO
%10 = load i32, i32* @ECHOE
%11 = or i32 %10, %9
%12 = load i32, i32* @ECHOK
%13 = or i32 %11, %12
%14 = load i32, i32* @ECHONL
%15 = or i32 %13, %14
br i1 %8, label %16, label %20
16: ; preds = %7
%17 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%18 = load i32, i32* %17
%19 = or i32 %15, %18
store i32 %19, i32* %17
br label %25
20: ; preds = %7
%21 = xor i32 %15, -1
%22 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%23 = load i32, i32* %22
%24 = and i32 %23, %21
store i32 %24, i32* %22
br label %25
25: ; preds = %20, %16
br label %26
26: ; preds = %25, %26
%27 = load i32, i32* @STDIN_FILENO
%28 = load i32, i32* @TCSAFLUSH
%29 = call i32 @tcsetattr(i32 %27, i32 %28, %struct.termios* %2)
%30 = icmp eq i32 %29, -1
%31 = load i64, i64* @errno
%32 = load i64, i64* @EINTR
%33 = icmp eq i64 %31, %32
%34 = select i1 %30, i1 %33, i1 false
br i1 %34, label %26, label %35
35: ; preds = %26, %1
ret void
}