#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);
  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>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x20(%rsp)
movups 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <sigemptyset@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <sigaddset@plt>
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    $0x1,%edi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
movq   $0x0,0x18(%rsp)
movl   $0x71,0x14(%rsp)
mov    $0x1,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <select@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
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)
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)
ret i32 0
}