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

/* Variables and functions */
int EPOLLERR;
int EPOLLIN;
int EPOLLRDHUP;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ jlog(int, char *, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int ion_add(int queue, int fd, void *udata) {
  struct epoll_event nevent;
  int ret;
  nevent.events = EPOLLIN | EPOLLRDHUP | EPOLLERR;
  nevent.data.ptr = udata;
  ret = epoll_ctl(queue, EPOLL_CTL_ADD, fd, &nevent);
  if (ret < 0)
    jlog(0x01, "ion]> epoll_ctl() %s :: %s:%i", strerror(errno),
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/"
         "libdnds/src/ion_epoll.c",
         58);
  return ret;
}


x86 assembly (clang, -O0):
<ion_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    0x2e6e(%rip),%rcx
or     (%rcx),%eax
mov    0x2e75(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x20(%rbp),%rcx
call   1040 <epoll_ctl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11bb <ion_add+0x8b>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xe57(%rip),%rsi
lea    0xe6e(%rip),%rcx
mov    $0x3a,%r8d
call   1030 <jlog@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ion_add>:
push   %rbx
sub    $0x10,%rsp
mov    0x2eac(%rip),%rax
mov    0x2e7d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    %esi,%eax
mov    0x2e80(%rip),%rsi
or     (%rsi),%ecx
mov    %ecx,(%rsp)
mov    %rdx,0x8(%rsp)
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rcx
mov    %eax,%edx
call   1040 <epoll_ctl@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11a1 <ion_add+0x71>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe78(%rip),%rsi
lea    0xe8f(%rip),%rcx
mov    $0x1,%edi
mov    %eax,%edx
mov    $0x3a,%r8d
call   1030 <jlog@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i8* }
@EPOLLIN = global i32 0
@EPOLLRDHUP = global i32 0
@EPOLLERR = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str = [30 x i8] c"ion]> epoll_ctl() %s :: %s:%i\00"
@errno = global i32 0
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/libdnds/src/ion_epoll.c\00"
define i32 @ion_add(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.epoll_event
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* @EPOLLIN
%10 = load i32, i32* @EPOLLRDHUP
%11 = or i32 %9, %10
%12 = load i32, i32* @EPOLLERR
%13 = or i32 %11, %12
%14 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i8*, i8** %6
%16 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %7, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
store i8* %15, i8** %17
%18 = load i32, i32* %4
%19 = load i32, i32* @EPOLL_CTL_ADD
%20 = load i32, i32* %5
%21 = call i32 @epoll_ctl(i32 %18, i32 %19, i32 %20, %struct.epoll_event* %7)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %3
%25 = load i32, i32* @errno
%26 = call i32 @strerror(i32 %25)
%27 = call i32 @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %26, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 58)
br label %28
28: ; preds = %24, %3
%29 = load i32, i32* %8
ret i32 %29
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i8* }
@EPOLLIN = global i32 0
@EPOLLRDHUP = global i32 0
@EPOLLERR = global i32 0
@EPOLL_CTL_ADD = global i32 0
@.str = [30 x i8] c"ion]> epoll_ctl() %s :: %s:%i\00"
@errno = global i32 0
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aboudreault/dnds-debian/refs/heads/master/libdnds/src/ion_epoll.c\00"
define i32 @ion_add(i32 %0, i32 %1, i8* %2) {
%4 = alloca %struct.epoll_event
%5 = bitcast %struct.epoll_event* %4 to i8*
%6 = load i32, i32* @EPOLLIN
%7 = load i32, i32* @EPOLLRDHUP
%8 = or i32 %7, %6
%9 = load i32, i32* @EPOLLERR
%10 = or i32 %8, %9
%11 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 0
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %4, i64 0, i32 1, i32 0
store i8* %2, i8** %12
%13 = load i32, i32* @EPOLL_CTL_ADD
%14 = call i32 @epoll_ctl(i32 %0, i32 %13, i32 %1, %struct.epoll_event* %4)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 @jlog(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %18, i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 58)
br label %20
20: ; preds = %16, %3
ret i32 %14
}