#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*/ TCSANOW;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void stdin_setup(struct termios *old) {
  struct termios new;
  tcgetattr(STDIN_FILENO, old);
  new = *old;
  new.c_lflag &= ~ECHO;
  tcsetattr(STDIN_FILENO, TCSANOW, &new);
}


x86 assembly (clang, -O0):
<stdin_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1030 <tcgetattr@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdin_setup>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
mov    (%r14),%edi
mov    %rbx,%rsi
call   1030 <tcgetattr@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
not    %eax
and    (%rbx),%eax
mov    %eax,(%rsp)
mov    (%r14),%edi
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1040 <tcsetattr@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@TCSANOW = global i32 0
define void @stdin_setup(%struct.termios* %0) {
%2 = alloca %struct.termios*
%3 = alloca %struct.termios
store %struct.termios* %0, %struct.termios** %2
%4 = load i32, i32* @STDIN_FILENO
%5 = load %struct.termios*, %struct.termios** %2
%6 = call i32 @tcgetattr(i32 %4, %struct.termios* %5)
%7 = load %struct.termios*, %struct.termios** %2
%8 = bitcast %struct.termios* %3 to i8*
%9 = bitcast %struct.termios* %7 to i8*
%10 = load i32, i32* @ECHO
%11 = xor i32 %10, -1
%12 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, %11
store i32 %14, i32* %12
%15 = load i32, i32* @STDIN_FILENO
%16 = load i32, i32* @TCSANOW
%17 = call i32 @tcsetattr(i32 %15, i32 %16, %struct.termios* %3)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ECHO = global i32 0
@TCSANOW = global i32 0
define void @stdin_setup(%struct.termios* %0) {
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @STDIN_FILENO
%5 = tail call i32 @tcgetattr(i32 %4, %struct.termios* %0)
%6 = getelementptr %struct.termios, %struct.termios* %0, i64 0, i32 0
%7 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%8 = load i32, i32* %6
%9 = load i32, i32* @ECHO
%10 = xor i32 %9, -1
%11 = and i32 %8, %10
store i32 %11, i32* %7
%12 = load i32, i32* @STDIN_FILENO
%13 = load i32, i32* @TCSANOW
%14 = call i32 @tcsetattr(i32 %12, i32 %13, %struct.termios* %2)
ret void
}