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

/* Variables and functions */
int /*<<< orphan*/ EPOLLET;
int /*<<< orphan*/ EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int /*<<< orphan*/ epoll_ctl(int, int /*<<< orphan*/, int,
                             struct epoll_event *);
int /*<<< orphan*/ setnonblocking(int);
void addfd(int epollfd, int fd, int enable_et) {
  struct epoll_event event;
  event.data.fd = fd;
  event.events = EPOLLIN;
  if (enable_et)
    event.events |= EPOLLET;
  epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event);
  setnonblocking(fd);
}


x86 assembly (clang, -O0):
<addfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     115c <addfd+0x3c>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1030 <epoll_ctl@plt>
mov    -0x8(%rbp),%edi
call   1040 <setnonblocking@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addfd>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %esi,0xc(%rsp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
test   %edx,%edx
je     1149 <addfd+0x29>
mov    0x2e8d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,0x8(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rcx
mov    %ebx,%edx
call   1030 <epoll_ctl@plt>
mov    %ebx,%edi
call   1040 <setnonblocking@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
define void @addfd(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* %5
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 0
store i32 %8, i32* %10
%11 = load i32, i32* @EPOLLIN
%12 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32, i32* @EPOLLET
%17 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
%18 = load i32, i32* %17
%19 = or i32 %18, %16
store i32 %19, i32* %17
br label %20
20: ; preds = %15, %3
%21 = load i32, i32* %4
%22 = load i32, i32* @EPOLL_CTL_ADD
%23 = load i32, i32* %5
%24 = call i32 @epoll_ctl(i32 %21, i32 %22, i32 %23, %struct.epoll_event* %7)
%25 = load i32, i32* %5
%26 = call i32 @setnonblocking(i32 %25)
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLLET = global i32 0
@EPOLL_CTL_ADD = global i32 0
define void @addfd(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, i32 0
store i32 %1, i32* %6
%7 = load i32, i32* @EPOLLIN
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %7, i32* %8
%9 = icmp eq i32 %2, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* @EPOLLET
%12 = or i32 %11, %7
store i32 %12, i32* %8
br label %13
13: ; preds = %10, %3
%14 = load i32, i32* @EPOLL_CTL_ADD
%15 = call i32 @epoll_ctl(i32 %0, i32 %14, i32 %1, %struct.epoll_event* %4)
%16 = call i32 @setnonblocking(i32 %1)
ret void
}