#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 /*<<< orphan*/ c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ ECHO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
scalar_t__ tcgetattr(int /*<<< orphan*/, struct termios *);
scalar_t__ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/, struct termios *);
int setsilent(struct termios *initial_term) {
  struct termios term;
  if (tcgetattr(STDIN_FILENO, initial_term) != 0) {
    return -1;
  }
  term = *initial_term;
  term.c_lflag &= ~ECHO;
  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &term) != 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setsilent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1030 <tcgetattr@plt>
cmp    $0x0,%rax
je     1154 <setsilent+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a7 <setsilent+0x87>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <tcsetattr@plt>
cmp    $0x0,%rax
je     11a0 <setsilent+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a7 <setsilent+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setsilent>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
mov    (%r14),%edi
mov    %rbx,%rsi
call   1030 <tcgetattr@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    116f <setsilent+0x4f>
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
not    %eax
and    (%rbx),%eax
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1040 <tcsetattr@plt>
neg    %rax
sbb    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@TCSAFLUSH = global i32 0
define i32 @setsilent(%struct.termios* %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @STDIN_FILENO
%5 = tail call i64 @tcgetattr(i32 %4, %struct.termios* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = getelementptr %struct.termios, %struct.termios* %0, i64 0, i32 0
%9 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%10 = load i32, i32* %8
%11 = load i32, i32* @ECHO
%12 = xor i32 %11, -1
%13 = and i32 %10, %12
store i32 %13, i32* %9
%14 = load i32, i32* @STDIN_FILENO
%15 = load i32, i32* @TCSAFLUSH
%16 = call i64 @tcsetattr(i32 %14, i32 %15, %struct.termios* %2)
%17 = icmp ne i64 %16, 0
%18 = sext i1 %17 to i32
br label %19
19: ; preds = %7, %1
%20 = phi i32 [ -1, %1 ], [ %18, %7 ]
ret i32 %20
}