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

/* Variables and functions */
int /*<<< orphan*/ SIGUSR2;
int /*<<< orphan*/ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int main() {
  int fd;
  struct timespec tim = {0, 200000000};
  sigset_t sigs;
  fd_set rfds;
  struct timeval tv = {0, 117};
  sigemptyset(&sigs);
  sigaddset(&sigs, SIGUSR2);
  select(1, &rfds, NULL, NULL, &tv);
  tv.tv_sec = 0;
  tv.tv_usec = 113;
  select(1, NULL, NULL, NULL, &tv);
  tv.tv_sec = 0;
  tv.tv_usec = 120;
  select(-1, &rfds, NULL, NULL, &tv);
  tv.tv_sec = 0;
  tv.tv_usec = 121;
  select(1, (fd_set *)-1, NULL, NULL, &tv);
  tv.tv_sec = 0;
  tv.tv_usec = 122;
  select(1, &rfds, (fd_set *)-1, NULL, &tv);
  tv.tv_sec = 0;
  tv.tv_usec = 123;
  select(1, &rfds, NULL, (fd_set *)-1, &tv);
  select(1, &rfds, NULL, NULL, (struct timeval *)-1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <sigemptyset@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdi
call   1050 <sigaddset@plt>
mov    $0x1,%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x71,-0x2c(%rbp)
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <select@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x78,-0x2c(%rbp)
mov    $0xffffffff,%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x79,-0x2c(%rbp)
mov    $0x1,%edi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x7a,-0x2c(%rbp)
mov    $0x1,%edi
lea    -0x18(%rbp),%rsi
mov    $0xffffffffffffffff,%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x30(%rbp),%r8
call   1040 <select@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x7b,-0x2c(%rbp)
mov    $0x1,%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0xffffffffffffffff,%rcx
lea    -0x30(%rbp),%r8
call   1040 <select@plt>
mov    $0x1,%edi
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    $0xffffffffffffffff,%r8
mov    %rcx,%rdx
call   1040 <select@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xed2(%rip),%rax
mov    %rax,0x10(%rsp)
movups 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x24(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <sigemptyset@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
lea    0x20(%rsp),%r14
mov    %rsp,%rbx
mov    $0x1,%edi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x8(%rsp)
movl   $0x71,0x4(%rsp)
mov    $0x1,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x8(%rsp)
movl   $0x78,0x4(%rsp)
mov    $0xffffffff,%edi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x8(%rsp)
movl   $0x79,0x4(%rsp)
mov    $0x1,%edi
mov    $0xffffffffffffffff,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x8(%rsp)
movl   $0x7a,0x4(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0xffffffffffffffff,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x8(%rsp)
movl   $0x7b,0x4(%rsp)
mov    $0x1,%edi
mov    %r14,%rsi
xor    %edx,%edx
mov    $0xffffffffffffffff,%rcx
mov    %rbx,%r8
call   1040 <select@plt>
mov    $0x1,%edi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0xffffffffffffffff,%r8
call   1040 <select@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32, i64, i32 }
@__const.main.tim = %struct.timespec { i32 0, i32 200000000 }
@__const.main.tv = %struct.timeval { i32 0, i32 117, i64 0, i32 0 }
@SIGUSR2 = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.timeval
store i32 0, i32* %1
%7 = bitcast %struct.timespec* %3 to i8*
%8 = bitcast %struct.timeval* %6 to i8*
%9 = call i32 @sigemptyset(i32* %4)
%10 = load i32, i32* @SIGUSR2
%11 = call i32 @sigaddset(i32* %4, i32 %10)
%12 = call i32 @select(i32 1, i32* %5, i32* null, i32* null, %struct.timeval* %6)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 2
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i32 113, i32* %14
%15 = call i32 @select(i32 1, i32* null, i32* null, i32* null, %struct.timeval* %6)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 2
store i64 0, i64* %16
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i32 120, i32* %17
%18 = call i32 @select(i32 -1, i32* %5, i32* null, i32* null, %struct.timeval* %6)
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 2
store i64 0, i64* %19
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i32 121, i32* %20
%21 = call i32 @select(i32 1, i32* inttoptr (i64 -1 to i32*), i32* null, i32* null, %struct.timeval* %6)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 2
store i64 0, i64* %22
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i32 122, i32* %23
%24 = call i32 @select(i32 1, i32* %5, i32* inttoptr (i64 -1 to i32*), i32* null, %struct.timeval* %6)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 2
store i64 0, i64* %25
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i32 123, i32* %26
%27 = call i32 @select(i32 1, i32* %5, i32* null, i32* inttoptr (i64 -1 to i32*), %struct.timeval* %6)
%28 = call i32 @select(i32 1, i32* %5, i32* null, i32* null, %struct.timeval* inttoptr (i64 -1 to %struct.timeval*))
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32, i64, i32 }
@__const.main.tv = %struct.timeval { i32 0, i32 117, i64 0, i32 0 }
@SIGUSR2 = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timeval
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = call i32 @sigemptyset(i32* %1)
%8 = load i32, i32* @SIGUSR2
%9 = call i32 @sigaddset(i32* %1, i32 %8)
%10 = call i32 @select(i32 1, i32* %2, i32* null, i32* null, %struct.timeval* %3)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 2
store i64 0, i64* %11
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
store i32 113, i32* %12
%13 = call i32 @select(i32 1, i32* null, i32* null, i32* null, %struct.timeval* %3)
store i64 0, i64* %11
store i32 120, i32* %12
%14 = call i32 @select(i32 -1, i32* %2, i32* null, i32* null, %struct.timeval* %3)
store i64 0, i64* %11
store i32 121, i32* %12
%15 = call i32 @select(i32 1, i32* inttoptr (i64 -1 to i32*), i32* null, i32* null, %struct.timeval* %3)
store i64 0, i64* %11
store i32 122, i32* %12
%16 = call i32 @select(i32 1, i32* %2, i32* inttoptr (i64 -1 to i32*), i32* null, %struct.timeval* %3)
store i64 0, i64* %11
store i32 123, i32* %12
%17 = call i32 @select(i32 1, i32* %2, i32* null, i32* inttoptr (i64 -1 to i32*), %struct.timeval* %3)
%18 = call i32 @select(i32 1, i32* %2, i32* null, i32* null, %struct.timeval* inttoptr (i64 -1 to %struct.timeval*))
ret i32 0
}