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

/* Variables and functions */
int syscall_cp(int, int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
               int /*<<< orphan*/ *, struct timespec *, long *);
int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds,
            const struct timespec *ts, const sigset_t *mask) {
  long data[2] = {(long)mask, 8};
  struct timespec ts_tmp;
  if (ts)
    ts_tmp = *ts;
  return syscall_cp(335, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data);
}


x86 assembly (clang, -O0):
<pselect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x8,-0x38(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1156 <pselect+0x46>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     118c <pselect+0x7c>
lea    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    1197 <pselect+0x87>
xor    %eax,%eax
mov    %rax,-0x70(%rbp)
jmp    1197 <pselect+0x87>
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%rcx
mov    -0x60(%rbp),%rdx
mov    -0x64(%rbp),%esi
mov    -0x70(%rbp),%r9
lea    -0x40(%rbp),%rax
mov    $0x14f,%edi
mov    %rax,(%rsp)
call   1030 <syscall_cp@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pselect>:
sub    $0x28,%rsp
mov    %rcx,%rax
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %edi,%esi
mov    %r9,0x10(%rsp)
movq   $0x8,0x18(%rsp)
test   %r8,%r8
je     1140 <pselect+0x30>
mov    (%r8),%edi
mov    %edi,0x8(%rsp)
lea    0x8(%rsp),%r9
jmp    1143 <pselect+0x33>
xor    %r9d,%r9d
lea    0x10(%rsp),%rdi
mov    %rdi,(%rsp)
mov    $0x14f,%edi
mov    %rax,%r8
call   1030 <syscall_cp@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
define i32 @pselect(i32 %0, i32* %1, i32* %2, i32* %3, %struct.timespec* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.timespec*
%12 = alloca i32*
%13 = alloca [2 x i64]
%14 = alloca %struct.timespec
store i32 %0, i32* %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store %struct.timespec* %4, %struct.timespec** %11
store i32* %5, i32** %12
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %13, i64 0, i64 0
%16 = load i32*, i32** %12
%17 = ptrtoint i32* %16 to i64
store i64 %17, i64* %15
%18 = getelementptr inbounds i64, i64* %15, i64 1
store i64 8, i64* %18
%19 = load %struct.timespec*, %struct.timespec** %11
%20 = icmp ne %struct.timespec* %19, null
br i1 %20, label %21, label %25
21: ; preds = %6
%22 = load %struct.timespec*, %struct.timespec** %11
%23 = bitcast %struct.timespec* %14 to i8*
%24 = bitcast %struct.timespec* %22 to i8*
br label %25
25: ; preds = %21, %6
%26 = load i32, i32* %7
%27 = load i32*, i32** %8
%28 = load i32*, i32** %9
%29 = load i32*, i32** %10
%30 = load %struct.timespec*, %struct.timespec** %11
%31 = icmp ne %struct.timespec* %30, null
br i1 %31, label %32, label %33
32: ; preds = %25
br label %34
33: ; preds = %25
br label %34
34: ; preds = %33, %32
%35 = phi %struct.timespec* [ %14, %32 ], [ null, %33 ]
%36 = getelementptr inbounds [2 x i64], [2 x i64]* %13, i64 0, i64 0
%37 = call i32 @syscall_cp(i32 335, i32 %26, i32* %27, i32* %28, i32* %29, %struct.timespec* %35, i64* %36)
ret i32 %37
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
define i32 @pselect(i32 %0, i32* %1, i32* %2, i32* %3, %struct.timespec* %4, i32* %5) {
%7 = alloca [2 x i64]
%8 = alloca %struct.timespec
%9 = bitcast [2 x i64]* %7 to i8*
%10 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%11 = ptrtoint i32* %5 to i64
store i64 %11, i64* %10
%12 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 8, i64* %12
%13 = bitcast %struct.timespec* %8 to i8*
%14 = icmp eq %struct.timespec* %4, null
br i1 %14, label %19, label %15
15: ; preds = %6
%16 = getelementptr %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 0
%18 = load i32, i32* %16
store i32 %18, i32* %17
br label %19
19: ; preds = %15, %6
%20 = phi %struct.timespec* [ %8, %15 ], [ null, %6 ]
%21 = call i32 @syscall_cp(i32 335, i32 %0, i32* %1, i32* %2, i32* %3, %struct.timespec* %20, i64* %10)
ret i32 %21
}