#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 events;
  TYPE_1__ data;
};

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


x86 assembly (clang, -O0):
<addfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    0x2e84(%rip),%rcx
or     (%rcx),%eax
mov    0x2e8b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x10(%rbp),%rcx
call   1030 <epoll_ctl@plt>
mov    -0x8(%rbp),%edi
call   1040 <setnonblocking@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addfd>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ea4(%rip),%rax
mov    0x2e95(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %esi,%ebx
mov    0x2e98(%rip),%rax
or     (%rax),%ecx
mov    %esi,0xc(%rsp)
mov    %ecx,0x8(%rsp)
mov    0x2e97(%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 }
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLLERR = global i32 0
@EPOLL_CTL_ADD = global i32 0
define void @addfd(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 = load i32, i32* %4
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
store i32 %6, i32* %8
%9 = load i32, i32* @EPOLLOUT
%10 = load i32, i32* @EPOLLET
%11 = or i32 %9, %10
%12 = load i32, i32* @EPOLLERR
%13 = or i32 %11, %12
%14 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* %3
%16 = load i32, i32* @EPOLL_CTL_ADD
%17 = load i32, i32* %4
%18 = call i32 @epoll_ctl(i32 %15, i32 %16, i32 %17, %struct.epoll_event* %5)
%19 = load i32, i32* %4
%20 = call i32 @setnonblocking(i32 %19)
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLLERR = global i32 0
@EPOLL_CTL_ADD = global i32 0
define void @addfd(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 1, i32 0
store i32 %1, i32* %5
%6 = load i32, i32* @EPOLLOUT
%7 = load i32, i32* @EPOLLET
%8 = or i32 %7, %6
%9 = load i32, i32* @EPOLLERR
%10 = or i32 %8, %9
%11 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* @EPOLL_CTL_ADD
%13 = call i32 @epoll_ctl(i32 %0, i32 %12, i32 %1, %struct.epoll_event* %3)
%14 = call i32 @setnonblocking(i32 %1)
ret void
}