#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_lflag;
};

/* Variables and functions */
int ECHO;
int ICANON;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSANOW;
int getchar();
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
int getEnter(void) {
  struct termios newt, oldt;
  tcgetattr(STDIN_FILENO, &oldt);
  newt = oldt;
  newt.c_lflag &= ~(ICANON | ECHO);
  tcsetattr(STDIN_FILENO, TCSANOW, &newt);
  int input = getchar();
  tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
  if (input == 10)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<getEnter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    0x2e80(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1050 <tcsetattr@plt>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1050 <tcsetattr@plt>
cmpl   $0xa,-0x14(%rbp)
jne    11c1 <getEnter+0x91>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <getEnter+0x98>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEnter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e8f(%rip),%r15
mov    (%r15),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1040 <tcgetattr@plt>
mov    0x2e70(%rip),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    0x8(%rsp),%ecx
mov    %ecx,0x10(%rsp)
mov    (%r15),%edi
mov    0x2e71(%rip),%rbx
mov    (%rbx),%esi
lea    0x10(%rsp),%rdx
call   1050 <tcsetattr@plt>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ebp
mov    (%r15),%edi
mov    (%rbx),%esi
mov    %r14,%rdx
call   1050 <tcsetattr@plt>
xor    %eax,%eax
cmp    $0xa,%ebp
sete   %al
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@TCSANOW = global i32 0
define i32 @getEnter() {
%1 = alloca i32
%2 = alloca %struct.termios
%3 = alloca %struct.termios
%4 = alloca i32
%5 = load i32, i32* @STDIN_FILENO
%6 = call i32 @tcgetattr(i32 %5, %struct.termios* %3)
%7 = bitcast %struct.termios* %2 to i8*
%8 = bitcast %struct.termios* %3 to i8*
%9 = load i32, i32* @ICANON
%10 = load i32, i32* @ECHO
%11 = or i32 %9, %10
%12 = xor i32 %11, -1
%13 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%14 = load i32, i32* %13
%15 = and i32 %14, %12
store i32 %15, i32* %13
%16 = load i32, i32* @STDIN_FILENO
%17 = load i32, i32* @TCSANOW
%18 = call i32 @tcsetattr(i32 %16, i32 %17, %struct.termios* %2)
%19 = call i32 (...) @getchar()
store i32 %19, i32* %4
%20 = load i32, i32* @STDIN_FILENO
%21 = load i32, i32* @TCSANOW
%22 = call i32 @tcsetattr(i32 %20, i32 %21, %struct.termios* %3)
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %26
25: ; preds = %0
store i32 1, i32* %1
br label %27
26: ; preds = %0
store i32 0, i32* %1
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@TCSANOW = global i32 0
define i32 @getEnter() {
%1 = alloca %struct.termios
%2 = alloca %struct.termios
%3 = bitcast %struct.termios* %1 to i8*
%4 = bitcast %struct.termios* %2 to i8*
%5 = load i32, i32* @STDIN_FILENO
%6 = call i32 @tcgetattr(i32 %5, %struct.termios* %2)
%7 = getelementptr inbounds %struct.termios, %struct.termios* %2, i64 0, i32 0
%8 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%9 = load i32, i32* %7
%10 = load i32, i32* @ICANON
%11 = load i32, i32* @ECHO
%12 = or i32 %11, %10
%13 = xor i32 %12, -1
%14 = and i32 %9, %13
store i32 %14, i32* %8
%15 = load i32, i32* @STDIN_FILENO
%16 = load i32, i32* @TCSANOW
%17 = call i32 @tcsetattr(i32 %15, i32 %16, %struct.termios* %1)
%18 = call i32 (...) @getchar()
%19 = load i32, i32* @STDIN_FILENO
%20 = load i32, i32* @TCSANOW
%21 = call i32 @tcsetattr(i32 %19, i32 %20, %struct.termios* %2)
%22 = icmp eq i32 %18, 10
%23 = zext i1 %22 to i32
ret i32 %23
}