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

/* Variables and functions */
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int medusaDataReadyTimed(int socket, time_t sec, time_t usec) {
  fd_set fds;
  struct timeval tv;
  FD_ZERO(&fds);
  FD_SET(socket, &fds);
  tv.tv_sec = sec;
  tv.tv_usec = usec;
  return (select(socket + 1, &fds, NULL, NULL, &tv));
}


x86 assembly (clang, -O0):
<medusaDataReadyTimed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <FD_ZERO@plt>
mov    -0x4(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1050 <FD_SET@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
lea    -0x1c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<medusaDataReadyTimed>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1030 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %r15,%rsi
call   1050 <FD_SET@plt>
mov    %rbx,0x10(%rsp)
mov    %r14,0x8(%rsp)
add    $0x1,%ebp
lea    0x8(%rsp),%r8
mov    %ebp,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <select@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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