#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 dummy;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ err_msg(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int Select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
           struct timeval *timeout) {
  int ret;
  ret = select(maxfdp1, readset, writeset, exceptset, timeout);
  if (ret == -1) {
    err_msg("error while selecting: %s", strerror(errno));
    exit(EXIT_FAILURE);
  } else
    return ret;
}


x86 assembly (clang, -O0):
<Select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <select@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11aa <Select+0x6a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %eax,%esi
lea    0xe69(%rip),%rdi
call   1040 <err_msg@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Select>:
push   %rax
call   1030 <select@plt>
cmp    $0xffffffff,%eax
je     114d <Select+0xd>
pop    %rcx
ret
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe9e(%rip),%rdi
mov    %eax,%esi
call   1040 <err_msg@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [26 x i8] c"error while selecting: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @Select(i32 %0, i32* %1, i32* %2, i32* %3, %struct.timeval* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca %struct.timeval*
%11 = alloca i32
store i32 %0, i32* %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store %struct.timeval* %4, %struct.timeval** %10
%12 = load i32, i32* %6
%13 = load i32*, i32** %7
%14 = load i32*, i32** %8
%15 = load i32*, i32** %9
%16 = load %struct.timeval*, %struct.timeval** %10
%17 = call i32 @select(i32 %12, i32* %13, i32* %14, i32* %15, %struct.timeval* %16)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %5
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @err_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %5
%27 = load i32, i32* %11
ret i32 %27
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [26 x i8] c"error while selecting: %s\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @Select(i32 %0, i32* %1, i32* %2, i32* %3, %struct.timeval* %4) {
%6 = tail call i32 @select(i32 %0, i32* %1, i32* %2, i32* %3, %struct.timeval* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 @err_msg(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %5
ret i32 %6
}