#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 FD_ISSET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(scalar_t__, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
scalar_t__ STDIN_FILENO;
int /*<<< orphan*/ select(scalar_t__, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          struct timeval *);
int input_available() {
  struct timeval tv;
  fd_set fds;
  tv.tv_sec = 0;
  tv.tv_usec = 0;
  FD_ZERO(&fds);
  FD_SET(STDIN_FILENO, &fds);
  select(STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
  return FD_ISSET(0, &fds);
}


x86 assembly (clang, -O0):
<input_available>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <FD_ZERO@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <FD_SET@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%r8
mov    %rcx,%rdx
call   1050 <select@plt>
xor    %edi,%edi
lea    -0x14(%rbp),%rsi
call   1030 <FD_ISSET@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@STDIN_FILENO = global i64 0
define i32 @input_available() {
%1 = alloca %struct.timeval
%2 = alloca i32
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
store i64 0, i64* %3
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
store i64 0, i64* %4
%5 = call i32 @FD_ZERO(i32* %2)
%6 = load i64, i64* @STDIN_FILENO
%7 = call i32 @FD_SET(i64 %6, i32* %2)
%8 = load i64, i64* @STDIN_FILENO
%9 = add nsw i64 %8, 1
%10 = call i32 @select(i64 %9, i32* %2, i32* null, i32* null, %struct.timeval* %1)
%11 = call i32 @FD_ISSET(i32 0, i32* %2)
ret i32 %11
}

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