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

/* Variables and functions */
int /*<<< orphan*/ EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ memset(struct epoll_event *, int /*<<< orphan*/, int);
int add_to_epoll(int fd, int epollFd) {
  int result;
  struct epoll_event eventItem;
  memset(&eventItem, 0, sizeof(eventItem));
  eventItem.events = EPOLLIN;
  eventItem.data.fd = fd;
  result = epoll_ctl(epollFd, EPOLL_CTL_ADD, fd, &eventItem);
  return result;
}


x86 assembly (clang, -O0):
<add_to_epoll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
mov    -0x4(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_to_epoll>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %ebp,0x8(%rsp)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <epoll_ctl@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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
define i32 @add_to_epoll(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.epoll_event
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 @memset(%struct.epoll_event* %6, i32 0, i32 8)
%8 = load i32, i32* @EPOLLIN
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %6, i32 0, i32 1
store i32 %8, i32* %9
%10 = load i32, i32* %3
%11 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %6, 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* %3
%16 = call i32 @epoll_ctl(i32 %13, i32 %14, i32 %15, %struct.epoll_event* %6)
store i32 %16, i32* %5
%17 = load i32, i32* %5
ret i32 %17
}

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
define i32 @add_to_epoll(i32 %0, i32 %1) {
%3 = alloca %struct.epoll_event
%4 = bitcast %struct.epoll_event* %3 to i8*
%5 = call i32 @memset(%struct.epoll_event* %3, i32 0, i32 8)
%6 = load i32, i32* @EPOLLIN
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1
store i32 %6, i32* %7
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0, i32 0
store i32 %0, i32* %8
%9 = load i32, i32* @EPOLL_CTL_ADD
%10 = call i32 @epoll_ctl(i32 %1, i32 %9, i32 %0, %struct.epoll_event* %3)
ret i32 %10
}