#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*/ ICANON;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
int main(int argc, char *argv[]) {
  char b;
  struct termios tcattr;
  printf("Press any key to continue . . .\n");
  tcgetattr(0, &tcattr);
  tcattr.c_lflag &= ~ICANON;
  tcattr.c_cc[VTIME] = 0;
  tcattr.c_cc[VMIN] = 1;
  tcsetattr(0, TCSANOW, &tcattr);
  read(0, &b, 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
lea    -0x28(%rbp),%rsi
call   1050 <tcgetattr@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e46(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2e41(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x28(%rbp),%rdx
call   1060 <tcsetattr@plt>
xor    %edi,%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <tcgetattr@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2e54(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    %rbx,%rdx
call   1060 <tcsetattr@plt>
lea    0xf(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.termios = type { i32*, i32 }
@.str = [33 x i8] c"Press any key to continue . . .\0A\00"
@ICANON = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca %struct.termios
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @tcgetattr(i32 0, %struct.termios* %7)
%10 = load i32, i32* @ICANON
%11 = xor i32 %10, -1
%12 = getelementptr inbounds %struct.termios, %struct.termios* %7, i32 0, i32 1
%13 = load i32, i32* %12
%14 = and i32 %13, %11
store i32 %14, i32* %12
%15 = getelementptr inbounds %struct.termios, %struct.termios* %7, i32 0, i32 0
%16 = load i32*, i32** %15
%17 = load i64, i64* @VTIME
%18 = getelementptr inbounds i32, i32* %16, i64 %17
store i32 0, i32* %18
%19 = getelementptr inbounds %struct.termios, %struct.termios* %7, i32 0, i32 0
%20 = load i32*, i32** %19
%21 = load i64, i64* @VMIN
%22 = getelementptr inbounds i32, i32* %20, i64 %21
store i32 1, i32* %22
%23 = load i32, i32* @TCSANOW
%24 = call i32 @tcsetattr(i32 0, i32 %23, %struct.termios* %7)
%25 = call i32 @read(i32 0, i8* %6, i32 1)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32*, i32 }
@ICANON = global i32 0
@VTIME = global i64 0
@VMIN = global i64 0
@TCSANOW = global i32 0
@str = [32 x i8] c"Press any key to continue . . .\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = alloca %struct.termios
%5 = bitcast %struct.termios* %4 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%7 = call i32 @tcgetattr(i32 0, %struct.termios* %4)
%8 = load i32, i32* @ICANON
%9 = xor i32 %8, -1
%10 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%11 = load i32, i32* %10
%12 = and i32 %11, %9
store i32 %12, i32* %10
%13 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%14 = load i32*, i32** %13
%15 = load i64, i64* @VTIME
%16 = getelementptr inbounds i32, i32* %14, i64 %15
store i32 0, i32* %16
%17 = load i64, i64* @VMIN
%18 = getelementptr inbounds i32, i32* %14, i64 %17
store i32 1, i32* %18
%19 = load i32, i32* @TCSANOW
%20 = call i32 @tcsetattr(i32 0, i32 %19, %struct.termios* %4)
%21 = call i32 @read(i32 0, i8* %3, i32 1)
ret i32 0
}