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

/* Variables and functions */
int /*<<< orphan*/ EPOLL_CTL_MOD;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
void mod_event(int epfd, int fd, int event_flag) {
  struct epoll_event event = {0};
  event.data.fd = fd;
  event.events |= event_flag;
  if (-1 == epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &event)) {
    perror("epoll_ctl MOD: ");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<mod_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11ad <mod_event+0x6d>
lea    0xe62(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_event>:
sub    $0x18,%rsp
mov    %esi,%eax
movl   $0x0,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    0x2e93(%rip),%rcx
mov    (%rcx),%esi
lea    0x8(%rsp),%rcx
mov    %eax,%edx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     1165 <mod_event+0x35>
add    $0x18,%rsp
ret
lea    0xe94(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLL_CTL_MOD = global i32 0
@.str = [16 x i8] c"epoll_ctl MOD: \00"
define void @mod_event(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 = bitcast %struct.epoll_event* %7 to i8*
%9 = load i32, i32* %5
%10 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
store i32 %9, i32* %11
%12 = load i32, i32* %6
%13 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
%14 = load i32, i32* %13
%15 = or i32 %14, %12
store i32 %15, i32* %13
%16 = load i32, i32* %4
%17 = load i32, i32* @EPOLL_CTL_MOD
%18 = load i32, i32* %5
%19 = call i32 @epoll_ctl(i32 %16, i32 %17, i32 %18, %struct.epoll_event* %7)
%20 = icmp eq i32 -1, %19
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %3
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLL_CTL_MOD = global i32 0
@.str = [16 x i8] c"epoll_ctl MOD: \00"
define void @mod_event(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 2
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 0
store i32 %1, i32* %7
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %2, i32* %8
%9 = load i32, i32* @EPOLL_CTL_MOD
%10 = call i32 @epoll_ctl(i32 %0, i32 %9, i32 %1, %struct.epoll_event* %4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %3
ret void
}