#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 */
typedef int u_int8_t;
struct termios {
  int /*<<< orphan*/ c_iflag;
  int /*<<< orphan*/ c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ ECHO;
int /*<<< orphan*/ IXON;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
int tcgetattr(int /*<<< orphan*/, struct termios *);
int tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/, struct termios *);
u_int8_t __silent_control() {
  struct termios tp;
  if (tcgetattr(STDIN_FILENO, &tp) == -1) {
    return 1;
  }
  tp.c_lflag &= ~ECHO;
  tp.c_iflag &= ~IXON;
  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &tp) == -1) {
    return 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<__silent_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    114f <__silent_control+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    11aa <__silent_control+0x8a>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <tcsetattr@plt>
cmp    $0xffffffff,%eax
jne    11a3 <__silent_control+0x83>
movl   $0x2,-0x4(%rbp)
jmp    11aa <__silent_control+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__silent_control>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     117e <__silent_control+0x5e>
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0xc(%rsp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    (%rbx),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1040 <tcsetattr@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
sete   %al
add    %eax,%eax
jmp    1183 <__silent_control+0x63>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@IXON = global i32 0
@TCSAFLUSH = global i32 0
define i32 @__silent_control() {
%1 = alloca i32
%2 = alloca %struct.termios
%3 = load i32, i32* @STDIN_FILENO
%4 = call i32 @tcgetattr(i32 %3, %struct.termios* %2)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 1, i32* %1
br label %24
7: ; preds = %0
%8 = load i32, i32* @ECHO
%9 = xor i32 %8, -1
%10 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 1
%11 = load i32, i32* %10
%12 = and i32 %11, %9
store i32 %12, i32* %10
%13 = load i32, i32* @IXON
%14 = xor i32 %13, -1
%15 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%16 = load i32, i32* %15
%17 = and i32 %16, %14
store i32 %17, i32* %15
%18 = load i32, i32* @STDIN_FILENO
%19 = load i32, i32* @TCSAFLUSH
%20 = call i32 @tcsetattr(i32 %18, i32 %19, %struct.termios* %2)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %7
store i32 2, i32* %1
br label %24
23: ; preds = %7
store i32 0, i32* %1
br label %24
24: ; preds = %23, %22, %6
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
%struct.termios = type { i32, i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@IXON = global i32 0
@TCSAFLUSH = global i32 0
define i32 @__silent_control() {
%1 = alloca %struct.termios
%2 = bitcast %struct.termios* %1 to i8*
%3 = load i32, i32* @STDIN_FILENO
%4 = call i32 @tcgetattr(i32 %3, %struct.termios* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %22, label %6
6: ; preds = %0
%7 = load i32, i32* @ECHO
%8 = xor i32 %7, -1
%9 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = and i32 %10, %8
store i32 %11, i32* %9
%12 = load i32, i32* @IXON
%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* @STDIN_FILENO
%18 = load i32, i32* @TCSAFLUSH
%19 = call i32 @tcsetattr(i32 %17, i32 %18, %struct.termios* %1)
%20 = icmp eq i32 %19, -1
%21 = select i1 %20, i32 2, i32 0
br label %22
22: ; preds = %6, %0
%23 = phi i32 [ 1, %0 ], [ %21, %6 ]
ret i32 %23
}