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

/* Variables and functions */
int epoll_ctl(int, int, int, struct epoll_event *);
int /*<<< orphan*/ memset(struct epoll_event *, int /*<<< orphan*/, int);
int set_epoll_descriptor2(int fd_epoll, int action, int fd_toadd, int events) {
  struct epoll_event ev;
  memset(&ev, 0, sizeof(ev));
  ev.events = events;
  ev.data.fd = fd_toadd;
  return epoll_ctl(fd_epoll, action, fd_toadd, &ev);
}


x86 assembly (clang, -O0):
<set_epoll_descriptor2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1040 <epoll_ctl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_epoll_descriptor2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x8(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    %ebx,0x8(%rsp)
mov    %ebp,0xc(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12,%rcx
call   1040 <epoll_ctl@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @set_epoll_descriptor2(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.epoll_event
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = call i32 @memset(%struct.epoll_event* %9, i32 0, i32 8)
%11 = load i32, i32* %8
%12 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %7
%14 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %9, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
store i32 %13, i32* %15
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = call i32 @epoll_ctl(i32 %16, i32 %17, i32 %18, %struct.epoll_event* %9)
ret i32 %19
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define i32 @set_epoll_descriptor2(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.epoll_event
%6 = bitcast %struct.epoll_event* %5 to i8*
%7 = call i32 @memset(%struct.epoll_event* %5, i32 0, i32 8)
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i64 0, i32 0
store i32 %3, i32* %8
%9 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i64 0, i32 1, i32 0
store i32 %2, i32* %9
%10 = call i32 @epoll_ctl(i32 %0, i32 %1, i32 %2, %struct.epoll_event* %5)
ret i32 %10
}