#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 */
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ EPOLL_CLOEXEC;
int /*<<< orphan*/ IN_CLOEXEC;
int O_NOCTTY;
int O_RDWR;
int /*<<< orphan*/ SIGCONT;
int /*<<< orphan*/ assert_fd(char *, int);
int /*<<< orphan*/ close(int);
int epoll_create(int);
int epoll_create1(int /*<<< orphan*/);
int eventfd(int /*<<< orphan*/, int /*<<< orphan*/);
int getpt();
int inotify_init();
int inotify_init1(int /*<<< orphan*/);
int posix_openpt(int);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int signalfd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int timerfd_create(int /*<<< orphan*/, int /*<<< orphan*/);
void test_fd_special(void) {
  sigset_t mask;
  int fd1, fd2, fd3;
  fd1 = inotify_init();
  assert_fd("inotify_init", fd1);
  fd2 = inotify_init1(IN_CLOEXEC);
  assert_fd("inotify_init1", fd2);
  close(fd2);
  close(fd1);
  fd1 = epoll_create(8);
  assert_fd("epoll_create", fd1);
  fd2 = epoll_create1(EPOLL_CLOEXEC);
  assert_fd("epoll_create1", fd2);
  close(fd1);
  close(fd2);
  sigemptyset(&mask);
  sigaddset(&mask, SIGCONT);
  fd1 = signalfd(-1, &mask, 0);
  assert_fd("signalfd", fd1);
  fd2 = timerfd_create(CLOCK_MONOTONIC, 0);
  assert_fd("timerfd_create", fd2);
  fd3 = eventfd(0, 0);
  assert_fd("eventfd", fd3);
  close(fd1);
  close(fd2);
  close(fd3);
  fd1 = getpt();
  assert_fd("getpt", fd1);
  fd2 = posix_openpt(O_RDWR | O_NOCTTY);
  assert_fd("posix_openpt", fd2);
  close(fd1);
  close(fd2);
}


x86 assembly (clang, -O0):
<test_fd_special>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1090 <inotify_init@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1030 <assert_fd@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
call   10f0 <inotify_init1@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe01(%rip),%rdi
call   1030 <assert_fd@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    $0x8,%edi
call   10a0 <epoll_create@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xde3(%rip),%rdi
call   1030 <assert_fd@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   10d0 <epoll_create1@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdd0(%rip),%rdi
call   1030 <assert_fd@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
lea    -0x4(%rbp),%rdi
call   1070 <sigemptyset@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   10e0 <sigaddset@plt>
mov    $0xffffffff,%edi
lea    -0x4(%rbp),%rsi
xor    %edx,%edx
call   1040 <signalfd@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd91(%rip),%rdi
call   1030 <assert_fd@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1080 <timerfd_create@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xd78(%rip),%rdi
call   1030 <assert_fd@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10b0 <eventfd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xd6c(%rip),%rdi
call   1030 <assert_fd@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
mov    $0x0,%al
call   1060 <getpt@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd43(%rip),%rdi
call   1030 <assert_fd@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
mov    0x2c98(%rip),%rax
or     (%rax),%edi
call   10c0 <posix_openpt@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xd20(%rip),%rdi
call   1030 <assert_fd@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fd_special>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1090 <inotify_init@plt>
mov    %eax,%ebx
lea    0xe18(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   10f0 <inotify_init1@plt>
mov    %eax,%ebp
lea    0xe07(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    $0x8,%edi
call   10a0 <epoll_create@plt>
mov    %eax,%ebx
lea    0xded(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   10d0 <epoll_create1@plt>
mov    %eax,%ebp
lea    0xddc(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sigemptyset@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10e0 <sigaddset@plt>
mov    $0xffffffff,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <signalfd@plt>
mov    %eax,%r14d
lea    0xd9e(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1080 <timerfd_create@plt>
mov    %eax,%ebp
lea    0xd87(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10b0 <eventfd@plt>
mov    %eax,%ebx
lea    0xd7d(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
call   1060 <getpt@plt>
mov    %eax,%ebx
lea    0xd58(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    0x2cdc(%rip),%rax
mov    0x2cad(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
call   10c0 <posix_openpt@plt>
mov    %eax,%ebp
lea    0xd37(%rip),%rdi
mov    %eax,%esi
call   1030 <assert_fd@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"inotify_init\00"
@IN_CLOEXEC = global i32 0
@.str.1 = [14 x i8] c"inotify_init1\00"
@.str.2 = [13 x i8] c"epoll_create\00"
@EPOLL_CLOEXEC = global i32 0
@.str.3 = [14 x i8] c"epoll_create1\00"
@SIGCONT = global i32 0
@.str.4 = [9 x i8] c"signalfd\00"
@CLOCK_MONOTONIC = global i32 0
@.str.5 = [15 x i8] c"timerfd_create\00"
@.str.6 = [8 x i8] c"eventfd\00"
@.str.7 = [6 x i8] c"getpt\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@.str.8 = [13 x i8] c"posix_openpt\00"
define void @test_fd_special() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @inotify_init()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @IN_CLOEXEC
%9 = call i32 @inotify_init1(i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @assert_fd(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @close(i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
%16 = call i32 @epoll_create(i32 8)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @EPOLL_CLOEXEC
%20 = call i32 @epoll_create1(i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 @assert_fd(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @close(i32 %23)
%25 = load i32, i32* %3
%26 = call i32 @close(i32 %25)
%27 = call i32 @sigemptyset(i32* %1)
%28 = load i32, i32* @SIGCONT
%29 = call i32 @sigaddset(i32* %1, i32 %28)
%30 = call i32 @signalfd(i32 -1, i32* %1, i32 0)
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = call i32 @assert_fd(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @CLOCK_MONOTONIC
%34 = call i32 @timerfd_create(i32 %33, i32 0)
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = call i32 @assert_fd(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = call i32 @eventfd(i32 0, i32 0)
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = call i32 @assert_fd(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %2
%41 = call i32 @close(i32 %40)
%42 = load i32, i32* %3
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* %4
%45 = call i32 @close(i32 %44)
%46 = call i32 (...) @getpt()
store i32 %46, i32* %2
%47 = load i32, i32* %2
%48 = call i32 @assert_fd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @O_RDWR
%50 = load i32, i32* @O_NOCTTY
%51 = or i32 %49, %50
%52 = call i32 @posix_openpt(i32 %51)
store i32 %52, i32* %3
%53 = load i32, i32* %3
%54 = call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %2
%56 = call i32 @close(i32 %55)
%57 = load i32, i32* %3
%58 = call i32 @close(i32 %57)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"inotify_init\00"
@IN_CLOEXEC = global i32 0
@.str.1 = [14 x i8] c"inotify_init1\00"
@.str.2 = [13 x i8] c"epoll_create\00"
@EPOLL_CLOEXEC = global i32 0
@.str.3 = [14 x i8] c"epoll_create1\00"
@SIGCONT = global i32 0
@.str.4 = [9 x i8] c"signalfd\00"
@CLOCK_MONOTONIC = global i32 0
@.str.5 = [15 x i8] c"timerfd_create\00"
@.str.6 = [8 x i8] c"eventfd\00"
@.str.7 = [6 x i8] c"getpt\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@.str.8 = [13 x i8] c"posix_openpt\00"
define void @test_fd_special() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @inotify_init()
%4 = tail call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @IN_CLOEXEC
%6 = tail call i32 @inotify_init1(i32 %5)
%7 = tail call i32 @assert_fd(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @close(i32 %6)
%9 = tail call i32 @close(i32 %3)
%10 = tail call i32 @epoll_create(i32 8)
%11 = tail call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @EPOLL_CLOEXEC
%13 = tail call i32 @epoll_create1(i32 %12)
%14 = tail call i32 @assert_fd(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = tail call i32 @close(i32 %10)
%16 = tail call i32 @close(i32 %13)
%17 = call i32 @sigemptyset(i32* %1)
%18 = load i32, i32* @SIGCONT
%19 = call i32 @sigaddset(i32* %1, i32 %18)
%20 = call i32 @signalfd(i32 -1, i32* %1, i32 0)
%21 = call i32 @assert_fd(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @CLOCK_MONOTONIC
%23 = call i32 @timerfd_create(i32 %22, i32 0)
%24 = call i32 @assert_fd(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = call i32 @eventfd(i32 0, i32 0)
%26 = call i32 @assert_fd(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = call i32 @close(i32 %20)
%28 = call i32 @close(i32 %23)
%29 = call i32 @close(i32 %25)
%30 = call i32 (...) @getpt()
%31 = call i32 @assert_fd(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @O_RDWR
%33 = load i32, i32* @O_NOCTTY
%34 = or i32 %33, %32
%35 = call i32 @posix_openpt(i32 %34)
%36 = call i32 @assert_fd(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %35)
%37 = call i32 @close(i32 %30)
%38 = call i32 @close(i32 %35)
ret void
}