#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*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
int main(void) {
  struct termios canon, noncanon = {.c_lflag = 0};
  tcgetattr(STDIN_FILENO, &canon);
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &noncanon);
  sleep(10);
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &canon);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1050 <tcsetattr@plt>
mov    $0xa,%edi
call   1060 <sleep@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1050 <tcsetattr@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,(%rsp)
mov    0x2e91(%rip),%rbx
mov    (%rbx),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1030 <tcgetattr@plt>
mov    (%rbx),%edi
mov    0x2e89(%rip),%r15
mov    (%r15),%esi
mov    %rsp,%rdx
call   1040 <tcsetattr@plt>
mov    $0xa,%edi
call   1050 <sleep@plt>
mov    (%rbx),%edi
mov    (%r15),%esi
mov    %r14,%rdx
call   1040 <tcsetattr@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@TCSAFLUSH = global i32 0
define i32 @main() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %2 to i8*
%4 = load i32, i32* @STDIN_FILENO
%5 = call i32 @tcgetattr(i32 %4, %struct.termios* %1)
%6 = load i32, i32* @STDIN_FILENO
%7 = load i32, i32* @TCSAFLUSH
%8 = call i32 @tcsetattr(i32 %6, i32 %7, %struct.termios* %2)
%9 = call i32 @sleep(i32 10)
%10 = load i32, i32* @STDIN_FILENO
%11 = load i32, i32* @TCSAFLUSH
%12 = call i32 @tcsetattr(i32 %10, i32 %11, %struct.termios* %1)
ret i32 0
}

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