#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  TYPE_1__ data;
  int /*<<< orphan*/ events;
};

/* Variables and functions */
int /*<<< orphan*/ EPOLL_CTL_ADD;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
void epoll_ctl_add(int epfd, int fd, uint32_t events) {
  struct epoll_event ev;
  ev.events = events;
  ev.data.fd = fd;
  if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
    perror("epoll_ctl()\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<epoll_ctl_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    1184 <epoll_ctl_add+0x54>
lea    0xe8b(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epoll_ctl_add>:
push   %rax
mov    %esi,%eax
mov    %edx,0x4(%rsp)
mov    %esi,(%rsp)
mov    0x2ea7(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rcx
mov    %eax,%edx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     1154 <epoll_ctl_add+0x24>
pop    %rax
ret
lea    0xea5(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.epoll_event = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLL_CTL_ADD = global i32 0
@.str = [13 x i8] c"epoll_ctl()\0A\00"
define void @epoll_ctl_add(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.epoll_event
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
store i32 %8, i32* %9
%10 = load i32, i32* %5
%11 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i32 %10, i32* %12
%13 = load i32, i32* %4
%14 = load i32, i32* @EPOLL_CTL_ADD
%15 = load i32, i32* %5
%16 = call i32 @epoll_ctl(i32 %13, i32 %14, i32 %15, %struct.epoll_event* %7)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %3
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLL_CTL_ADD = global i32 0
@.str = [13 x i8] c"epoll_ctl()\0A\00"
define void @epoll_ctl_add(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.epoll_event
%5 = bitcast %struct.epoll_event* %4 to i8*
%6 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1
store i32 %2, i32* %6
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0, i32 0
store i32 %1, i32* %7
%8 = load i32, i32* @EPOLL_CTL_ADD
%9 = call i32 @epoll_ctl(i32 %0, i32 %8, i32 %1, %struct.epoll_event* %4)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %3
ret void
}