#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;
  void *ptr;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};

/* Variables and functions */
int EPOLLET;
int EPOLLONESHOT;
int EPOLLOUT;
int /*<<< orphan*/ EPOLL_CTL_MOD;
scalar_t__ epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ perror(char *);
void set_epollout(int efd, int fd, void *data) {
  struct epoll_event ev;
  ev.data.fd = fd;
  if (data)
    ev.data.ptr = data;
  ev.events = EPOLLOUT | EPOLLET | EPOLLONESHOT;
  if (epoll_ctl(efd, EPOLL_CTL_MOD, fd, &ev) < 0) {
    perror("epoll_ctl(2): set epollout");
  }
}


x86 assembly (clang, -O0):
<set_epollout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114b <set_epollout+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    0x2e6d(%rip),%rcx
or     (%rcx),%eax
mov    0x2e84(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x28(%rbp),%rcx
call   1030 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    1197 <set_epollout+0x77>
lea    0xe6e(%rip),%rdi
call   1040 <perror@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_epollout>:
sub    $0x18,%rsp
mov    %rdx,%rax
mov    %esi,%edx
mov    %esi,0x8(%rsp)
test   %rax,%rax
je     1137 <set_epollout+0x17>
mov    %rax,0x10(%rsp)
mov    0x2e92(%rip),%rax
mov    0x2e83(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e98(%rip),%rax
or     (%rax),%ecx
mov    %ecx,(%rsp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
call   1030 <epoll_ctl@plt>
test   %rax,%rax
js     1170 <set_epollout+0x50>
add    $0x18,%rsp
ret
lea    0xe89(%rip),%rdi
call   1040 <perror@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i8* }
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLLONESHOT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str = [27 x i8] c"epoll_ctl(2): set epollout\00"
define void @set_epollout(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.epoll_event
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %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 i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 1
store i8* %14, i8** %16
br label %17
17: ; preds = %13, %3
%18 = load i32, i32* @EPOLLOUT
%19 = load i32, i32* @EPOLLET
%20 = or i32 %18, %19
%21 = load i32, i32* @EPOLLONESHOT
%22 = or i32 %20, %21
%23 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
store i32 %22, i32* %23
%24 = load i32, i32* %4
%25 = load i32, i32* @EPOLL_CTL_MOD
%26 = load i32, i32* %5
%27 = call i64 @epoll_ctl(i32 %24, i32 %25, i32 %26, %struct.epoll_event* %7)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %17
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i8* }
@EPOLLOUT = global i32 0
@EPOLLET = global i32 0
@EPOLLONESHOT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str = [27 x i8] c"epoll_ctl(2): set epollout\00"
define void @set_epollout(i32 %0, i32 %1, i8* %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 = icmp eq i8* %2, null
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 1
store i8* %2, i8** %9
br label %10
10: ; preds = %8, %3
%11 = load i32, i32* @EPOLLOUT
%12 = load i32, i32* @EPOLLET
%13 = or i32 %12, %11
%14 = load i32, i32* @EPOLLONESHOT
%15 = or i32 %13, %14
%16 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %15, i32* %16
%17 = load i32, i32* @EPOLL_CTL_MOD
%18 = call i64 @epoll_ctl(i32 %0, i32 %17, i32 %1, %struct.epoll_event* %4)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %10
%21 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %10
ret void
}