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

/* Variables and functions */
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SETSIZE;
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int select(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int input_timeout(int filedes, unsigned int milli_seconds) {
  char buf;
  fd_set set;
  struct timeval timeout;
  int res, r;
  FD_ZERO(&set);
  FD_SET(filedes, &set);
  timeout.tv_sec = 0;
  timeout.tv_usec = 1000 * milli_seconds;
  return select(FD_SETSIZE, &set, NULL, NULL, &timeout);
}


x86 assembly (clang, -O0):
<input_timeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <FD_ZERO@plt>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <FD_SET@plt>
movq   $0x0,-0x18(%rbp)
imul   $0x3e8,-0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_timeout>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1030 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <FD_SET@plt>
movq   $0x0,0x18(%rsp)
imul   $0x3e8,%ebx,%eax
mov    %eax,0x10(%rsp)
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%r8
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <select@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@FD_SETSIZE = global i32 0
define i32 @input_timeout(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = call i32 @FD_ZERO(i32* %6)
%11 = load i32, i32* %3
%12 = call i32 @FD_SET(i32 %11, i32* %6)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i64 0, i64* %13
%14 = load i32, i32* %4
%15 = mul i32 1000, %14
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i32 %15, i32* %16
%17 = load i32, i32* @FD_SETSIZE
%18 = call i32 @select(i32 %17, i32* %6, i32* null, i32* null, %struct.timeval* %7)
ret i32 %18
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@FD_SETSIZE = global i32 0
define i32 @input_timeout(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = call i32 @FD_ZERO(i32* %3)
%8 = call i32 @FD_SET(i32 %0, i32* %3)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i64 0, i64* %9
%10 = mul i32 %1, 1000
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* @FD_SETSIZE
%13 = call i32 @select(i32 %12, i32* %3, i32* null, i32* null, %struct.timeval* %4)
ret i32 %13
}