#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 */
struct TYPE_2__ {
  int fd;
};
struct epoll_event {
  TYPE_1__ data;
  int /*<<< orphan*/ events;
};

/* Variables and functions */
int /*<<< orphan*/ EPOLLIN;
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_add(int epollfd, int fd) {
  struct epoll_event event = {.events = EPOLLIN, .data.fd = fd};
  if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event) == -1) {
    do {
      perror("epoll_ctl");
      exit(1);
    } while (0);
  }
}


x86 assembly (clang, -O0):
<epoll_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x10(%rbp),%rcx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    118c <epoll_add+0x5c>
jmp    1176 <epoll_add+0x46>
lea    0xe83(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epoll_add>:
push   %rax
mov    %esi,%edx
mov    %esi,(%rsp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     115b <epoll_add+0x2b>
pop    %rax
ret
lea    0xe9e(%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 }
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str = [10 x i8] c"epoll_ctl\00"
define void @epoll_add(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.epoll_event
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 0
%7 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %6, i32 0, i32 0
%8 = load i32, i32* %4
store i32 %8, i32* %7
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 1
%10 = load i32, i32* @EPOLLIN
store i32 %10, i32* %9
%11 = load i32, i32* %3
%12 = load i32, i32* @EPOLL_CTL_ADD
%13 = load i32, i32* %4
%14 = call i32 @epoll_ctl(i32 %11, i32 %12, i32 %13, %struct.epoll_event* %5)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %2
br label %17
17: ; preds = %16
%18 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; No predecessors!
br label %21
21: ; preds = %20, %2
ret void
}

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