#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 EPOLLET;
int EPOLLIN;
int EPOLLONESHOT;
int /*<<< orphan*/ EPOLL_CTL_MOD;
scalar_t__ epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ perror(char *);
void set_epollin(int efd, int fd) {
  struct epoll_event ev;
  ev.data.fd = fd;
  ev.events = EPOLLIN | EPOLLET | EPOLLONESHOT;
  if (epoll_ctl(efd, EPOLL_CTL_MOD, fd, &ev) < 0) {
    perror("epoll_ctl(2): set epollin");
  }
}


x86 assembly (clang, -O0):
<set_epollin>:
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    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    0x2e84(%rip),%rcx
or     (%rcx),%eax
mov    0x2e93(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x10(%rbp),%rcx
call   1030 <epoll_ctl@plt>
cmp    $0x0,%rax
jge    1180 <set_epollin+0x60>
lea    0xe85(%rip),%rdi
call   1040 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_epollin>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %esi,%edx
mov    0x2ea4(%rip),%rax
or     (%rax),%ecx
mov    %esi,0x4(%rsp)
mov    %ecx,(%rsp)
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
call   1030 <epoll_ctl@plt>
test   %rax,%rax
js     115d <set_epollin+0x3d>
pop    %rax
ret
lea    0xe9c(%rip),%rdi
call   1040 <perror@plt>
pop    %rax
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
@EPOLLONESHOT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str = [26 x i8] c"epoll_ctl(2): set epollin\00"
define void @set_epollin(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* @EPOLLIN
%10 = load i32, i32* @EPOLLET
%11 = or i32 %9, %10
%12 = load i32, i32* @EPOLLONESHOT
%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_MOD
%17 = load i32, i32* %4
%18 = call i64 @epoll_ctl(i32 %15, i32 %16, i32 %17, %struct.epoll_event* %5)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
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
@EPOLLONESHOT = global i32 0
@EPOLL_CTL_MOD = global i32 0
@.str = [26 x i8] c"epoll_ctl(2): set epollin\00"
define void @set_epollin(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* @EPOLLIN
%7 = load i32, i32* @EPOLLET
%8 = or i32 %7, %6
%9 = load i32, i32* @EPOLLONESHOT
%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_MOD
%13 = call i64 @epoll_ctl(i32 %0, i32 %12, i32 %1, %struct.epoll_event* %3)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
ret void
}