#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 */

/* Variables and functions */
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdscr;
void flushbuffer() {
  int c;
  nodelay(stdscr, TRUE);
  do {
    c = getch();
  } while (c == '\n' && !feof(stdin));
  nodelay(stdscr, FALSE);
}


x86 assembly (clang, -O0):
<flushbuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
call   1040 <nodelay@plt>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jne    1181 <flushbuffer+0x51>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1030 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    114f <flushbuffer+0x1f>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
call   1040 <nodelay@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flushbuffer>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%r14
mov    (%r14),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
call   1040 <nodelay@plt>
mov    0x2e95(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0xa,%eax
jne    1177 <flushbuffer+0x47>
mov    (%rbx),%edi
call   1030 <feof@plt>
test   %eax,%eax
je     1160 <flushbuffer+0x30>
mov    (%r14),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <nodelay@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@stdin = global i32 0
@FALSE = global i32 0
define void @flushbuffer() {
%1 = alloca i32
%2 = load i32, i32* @stdscr
%3 = load i32, i32* @TRUE
%4 = call i32 @nodelay(i32 %2, i32 %3)
br label %5
5: ; preds = %15, %0
%6 = call i32 (...) @getch()
store i32 %6, i32* %1
br label %7
7: ; preds = %5
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i32, i32* @stdin
%12 = call i32 @feof(i32 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br label %15
15: ; preds = %10, %7
%16 = phi i1 [ false, %7 ], [ %14, %10 ]
br i1 %16, label %5, label %17
17: ; preds = %15
%18 = load i32, i32* @stdscr
%19 = load i32, i32* @FALSE
%20 = call i32 @nodelay(i32 %18, i32 %19)
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@stdin = global i32 0
@FALSE = global i32 0
define void @flushbuffer() {
%1 = load i32, i32* @stdscr
%2 = load i32, i32* @TRUE
%3 = tail call i32 @nodelay(i32 %1, i32 %2)
br label %4
4: ; preds = %7, %0
%5 = tail call i32 (...) @getch()
%6 = icmp eq i32 %5, 10
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i32, i32* @stdin
%9 = tail call i32 @feof(i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %4, %7
%12 = load i32, i32* @stdscr
%13 = load i32, i32* @FALSE
%14 = tail call i32 @nodelay(i32 %12, i32 %13)
ret void
}