#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 {
  TYPE_1__ data;
  int /*<<< orphan*/ events;
};

/* Variables and functions */
int /*<<< orphan*/ EPOLLIN;
int /*<<< orphan*/ EPOLL_CTL_ADD;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int poll_add(int poll_fd, int fd) {
  struct epoll_event ee;
  ee.events = EPOLLIN;
  ee.data.fd = fd;
  if (epoll_ctl(poll_fd, EPOLL_CTL_ADD, fd, &ee) == -1) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<poll_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ec3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1030 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    115d <poll_add+0x4d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1164 <poll_add+0x54>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poll_add>:
push   %rax
mov    %esi,%edx
mov    0x2ece(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %esi,(%rsp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
call   1030 <epoll_ctl@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.epoll_event = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @poll_add(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.epoll_event
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* @EPOLLIN
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %6, i32 0, i32 1
store i32 %7, i32* %8
%9 = load i32, i32* %5
%10 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %6, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
store i32 %9, i32* %11
%12 = load i32, i32* %4
%13 = load i32, i32* @EPOLL_CTL_ADD
%14 = load i32, i32* %5
%15 = call i32 @epoll_ctl(i32 %12, i32 %13, i32 %14, %struct.epoll_event* %6)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 -1, i32* %3
br label %19
18: ; preds = %2
store i32 0, i32* %3
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.epoll_event = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@EPOLLIN = global i32 0
@EPOLL_CTL_ADD = global i32 0
define i32 @poll_add(i32 %0, i32 %1) {
%3 = alloca %struct.epoll_event
%4 = bitcast %struct.epoll_event* %3 to i8*
%5 = load i32, i32* @EPOLLIN
%6 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 1
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %3, i64 0, i32 0, i32 0
store i32 %1, i32* %7
%8 = load i32, i32* @EPOLL_CTL_ADD
%9 = call i32 @epoll_ctl(i32 %0, i32 %8, i32 %1, %struct.epoll_event* %3)
%10 = icmp eq i32 %9, -1
%11 = sext i1 %10 to i32
ret i32 %11
}