#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 timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ FD_SET(scalar_t__, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
scalar_t__ fileno(int /*<<< orphan*/);
int select(scalar_t__, int /*<<< orphan*/ *, int, int, struct timeval *);
int /*<<< orphan*/ stdin;
char InputIsReady() {
  fd_set rfds;
  FD_ZERO(&rfds);
  FD_SET(fileno(stdin), &rfds);
  struct timeval tv;
  tv.tv_sec = 0;
  tv.tv_usec = 0;
  int ready = select(fileno(stdin) + 1, &rfds, 0x0, 0x0, &tv);
  return ready;
}


x86 assembly (clang, -O0):
<InputIsReady>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x4(%rbp),%rdi
call   1040 <FD_ZERO@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1030 <fileno@plt>
mov    %rax,%rdi
lea    -0x4(%rbp),%rsi
call   1060 <FD_SET@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1030 <fileno@plt>
mov    %rax,%rdi
add    $0x1,%rdi
lea    -0x4(%rbp),%rsi
xor    %ecx,%ecx
lea    -0x18(%rbp),%r8
mov    %ecx,%edx
call   1050 <select@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movsbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InputIsReady>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1040 <FD_ZERO@plt>
mov    0x2e8d(%rip),%rbx
mov    (%rbx),%edi
call   1030 <fileno@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <FD_SET@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    (%rbx),%edi
call   1030 <fileno@plt>
lea    0x1(%rax),%rdi
lea    0x10(%rsp),%r8
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <select@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@stdin = global i32 0
define signext i8 @InputIsReady() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca i32
%4 = call i32 @FD_ZERO(i32* %1)
%5 = load i32, i32* @stdin
%6 = call i64 @fileno(i32 %5)
%7 = call i32 @FD_SET(i64 %6, i32* %1)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
store i64 0, i64* %9
%10 = load i32, i32* @stdin
%11 = call i64 @fileno(i32 %10)
%12 = add nsw i64 %11, 1
%13 = call i32 @select(i64 %12, i32* %1, i32 0, i32 0, %struct.timeval* %2)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = trunc i32 %14 to i8
ret i8 %15
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@stdin = global i32 0
define signext i8 @InputIsReady() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = bitcast i32* %1 to i8*
%4 = call i32 @FD_ZERO(i32* %1)
%5 = load i32, i32* @stdin
%6 = call i64 @fileno(i32 %5)
%7 = call i32 @FD_SET(i64 %6, i32* %1)
%8 = bitcast %struct.timeval* %2 to i8*
%9 = bitcast %struct.timeval* %2 to i8*
%10 = load i32, i32* @stdin
%11 = call i64 @fileno(i32 %10)
%12 = add nsw i64 %11, 1
%13 = call i32 @select(i64 %12, i32* %1, i32 0, i32 0, %struct.timeval* %2)
%14 = trunc i32 %13 to i8
ret i8 %14
}