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

/* Variables and functions */
int /*<<< orphan*/ ECHO;
int /*<<< orphan*/ ICANON;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
int setsilent(struct termios *initial_term) {
  int r;
  struct termios term;
  term = *initial_term;
  term.c_lflag &= ~ECHO;
  term.c_lflag &= ~ICANON;
  term.c_cc[VMIN] = 1;
  term.c_cc[VTIME] = 0;
  tcsetattr(0, TCSANOW, &term);
  return 0;
}


x86 assembly (clang, -O0):
<setsilent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    %rcx,-0x20(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e7a(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x20(%rbp),%rdx
call   1030 <tcsetattr@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setsilent>:
sub    $0x18,%rsp
movups (%rdi),%xmm0
movaps %xmm0,(%rsp)
mov    0x2ebe(%rip),%rax
mov    (%rax),%eax
mov    0x2e95(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    (%rsp),%rax
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2e79(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
xor    %edi,%edi
call   1030 <tcsetattr@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.termios = type { i32*, i32 }
@ECHO = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
define i32 @setsilent(%struct.termios* nocapture %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = bitcast %struct.termios* %0 to i8*
%5 = load i32, i32* @ECHO
%6 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 1
%7 = load i32, i32* %6
%8 = load i32, i32* @ICANON
%9 = or i32 %5, %8
%10 = xor i32 %9, -1
%11 = and i32 %7, %10
store i32 %11, i32* %6
%12 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%13 = load i32*, i32** %12
%14 = load i64, i64* @VMIN
%15 = getelementptr inbounds i32, i32* %13, i64 %14
store i32 1, i32* %15
%16 = load i64, i64* @VTIME
%17 = getelementptr inbounds i32, i32* %13, i64 %16
store i32 0, i32* %17
%18 = load i32, i32* @TCSANOW
%19 = call i32 @tcsetattr(i32 0, i32 %18, %struct.termios* %2)
ret i32 0
}