#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__ {
  scalar_t__ fd;
};
struct epoll_event {
  TYPE_1__ data;
  scalar_t__ events;
};

/* Variables and functions */
int /*<<< orphan*/ EPOLL_CTL_DEL;
int epoll_ctl(int, int /*<<< orphan*/, int, struct epoll_event *);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int, int);
void epoll_unwatch_fd(int epfd, int fd) {
  struct epoll_event ev;
  ev.events = 0;
  ev.data.fd = 0;
  if (epoll_ctl(epfd, EPOLL_CTL_DEL, fd, &ev) == -1) {
    printf("epoll_ctl(EPOLL_CTL_DEL, %d) failed: error = %d\n", fd, errno);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<epoll_unwatch_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    -0x18(%rbp),%rcx
call   1040 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
jne    1191 <epoll_unwatch_fd+0x61>
mov    -0x8(%rbp),%esi
mov    0x2e5f(%rip),%rax
mov    (%rax),%edx
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epoll_unwatch_fd>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    0x2eb3(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
mov    %ebx,%edx
call   1040 <epoll_ctl@plt>
cmp    $0xffffffff,%eax
je     115c <epoll_unwatch_fd+0x2c>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
lea    0xe94(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.epoll_event = type { %struct.TYPE_2__, i64 }
%struct.TYPE_2__ = type { i64 }
@EPOLL_CTL_DEL = global i32 0
@.str = [49 x i8] c"epoll_ctl(EPOLL_CTL_DEL, %d) failed: error = %d\0A\00"
@errno = global i32 0
define void @epoll_unwatch_fd(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 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 1
store i64 0, i64* %6
%7 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %5, i32 0, i32 0
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
store i64 0, i64* %8
%9 = load i32, i32* %3
%10 = load i32, i32* @EPOLL_CTL_DEL
%11 = load i32, i32* %4
%12 = call i32 @epoll_ctl(i32 %9, i32 %10, i32 %11, %struct.epoll_event* %5)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i32, i32* @errno
%17 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { %struct.TYPE_2__, i64 }
%struct.TYPE_2__ = type { i64 }
@EPOLL_CTL_DEL = global i32 0
@.str = [49 x i8] c"epoll_ctl(EPOLL_CTL_DEL, %d) failed: error = %d\0A\00"
@errno = global i32 0
define void @epoll_unwatch_fd(i32 %0, i32 %1) {
%3 = alloca %struct.epoll_event
%4 = bitcast %struct.epoll_event* %3 to i8*
%5 = bitcast %struct.epoll_event* %3 to i8*
%6 = load i32, i32* @EPOLL_CTL_DEL
%7 = call i32 @epoll_ctl(i32 %0, i32 %6, i32 %1, %struct.epoll_event* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @errno
%11 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %10)
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
ret void
}