#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 epoll_event {
  int dummy;
};

/* Variables and functions */
int epoll_wait(int, struct epoll_event *, int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errx(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int xepoll_wait(int epfd, struct epoll_event *events, int maxevents,
                int timeout) {
  int rv;
  rv = epoll_wait(epfd, events, maxevents, timeout);
  if (rv < 0)
    errx(1, "epoll_wait: %s", strerror(errno));
  return rv;
}


x86 assembly (clang, -O0):
<xepoll_wait>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <epoll_wait@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1185 <xepoll_wait+0x55>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xe80(%rip),%rsi
call   1030 <errx@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xepoll_wait>:
push   %rbx
call   1040 <epoll_wait@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    115d <xepoll_wait+0x2d>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xeaf(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1030 <errx@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32 }
@.str = [15 x i8] c"epoll_wait: %s\00"
@errno = global i32 0
define i32 @xepoll_wait(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.epoll_event*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store %struct.epoll_event* %1, %struct.epoll_event** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load %struct.epoll_event*, %struct.epoll_event** %6
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @epoll_wait(i32 %10, %struct.epoll_event* %11, i32 %12, i32 %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @errx(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17, %4
%22 = load i32, i32* %9
ret i32 %22
}

LLVM IR (-O2):
%struct.epoll_event = type { i32 }
@.str = [15 x i8] c"epoll_wait: %s\00"
@errno = global i32 0
define i32 @xepoll_wait(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3) {
%5 = tail call i32 @epoll_wait(i32 %0, %struct.epoll_event* %1, i32 %2, i32 %3)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %7, %4
ret i32 %5
}