#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*/ ICANON;
int /*<<< orphan*/ TCSANOW;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void DisableBuffering(void) {
  struct termios term;
  setvbuf(stdin, NULL, _IONBF, 0);
  setvbuf(stdout, NULL, _IONBF, 0);
  tcgetattr(0, &term);
  term.c_lflag &= ~ICANON;
  tcsetattr(0, TCSANOW, &term);
}


x86 assembly (clang, -O0):
<DisableBuffering>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x8(%rbp),%rdx
call   1050 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DisableBuffering>:
push   %rbx
sub    $0x10,%rsp
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    0x2e93(%rip),%rbx
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
lea    0x8(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <tcgetattr@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    %rbx,%rdx
call   1050 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@stdin = global i32 0
@_IONBF = global i32 0
@stdout = global i32 0
@ICANON = global i32 0
@TCSANOW = global i32 0
define void @DisableBuffering() {
%1 = alloca %struct.termios
%2 = load i32, i32* @stdin
%3 = load i32, i32* @_IONBF
%4 = call i32 @setvbuf(i32 %2, i32* null, i32 %3, i32 0)
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
%8 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%9 = load i32, i32* @ICANON
%10 = xor i32 %9, -1
%11 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 0
%12 = load i32, i32* %11
%13 = and i32 %12, %10
store i32 %13, i32* %11
%14 = load i32, i32* @TCSANOW
%15 = call i32 @tcsetattr(i32 0, i32 %14, %struct.termios* %1)
ret void
}

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