#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 tv_sec;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ perror(char *);
int pselect(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
            int /*<<< orphan*/, struct timespec *, int /*<<< orphan*/);
int main(void) {
  struct timespec timeout;
  timeout.tv_sec = 1;
  timeout.tv_nsec = 0;
  switch (pselect(0, 0, 0, 0, &timeout, 0)) {
  default:
    abort();
  case -1:
    perror("pselect");
    return 1;
  case 0:
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x18(%rbp),%r8
xor    %r9d,%r9d
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
call   1040 <pselect@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
sub    $0xffffffff,%eax
je     1190 <main+0x60>
jmp    1179 <main+0x49>
mov    -0x1c(%rbp),%eax
test   %eax,%eax
je     11a8 <main+0x78>
jmp    1189 <main+0x59>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe69(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11af <main+0x7f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x1,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%r8
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r9d,%r9d
call   1040 <pselect@plt>
test   %eax,%eax
jne    1163 <main+0x33>
add    $0x18,%rsp
ret
cmp    $0xffffffff,%eax
jne    117e <main+0x4e>
lea    0xe91(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@.str = [8 x i8] c"pselect\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timespec
store i32 0, i32* %1
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 1, i32* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i64 0, i64* %4
%5 = call i32 @pselect(i32 0, i32 0, i32 0, i32 0, %struct.timespec* %2, i32 0)
switch i32 %5, label %6 [
i32 -1, label %8
i32 0, label %10
]
6: ; preds = %0
%7 = call i32 (...) @abort()
unreachable
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %11
10: ; preds = %0
store i32 0, i32* %1
br label %11
11: ; preds = %10, %8
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@.str = [8 x i8] c"pselect\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i32 1, i32* %3
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
store i64 0, i64* %4
%5 = call i32 @pselect(i32 0, i32 0, i32 0, i32 0, %struct.timespec* %1, i32 0)
switch i32 %5, label %6 [
i32 -1, label %8
i32 0, label %10
]
6: ; preds = %0
%7 = call i32 (...) @abort()
unreachable
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %8
%11 = phi i32 [ 1, %8 ], [ %5, %0 ]
ret i32 %11
}