#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 */

/* Type definitions */

/* Variables and functions */
unsigned int EPOLLERR;
unsigned int EPOLLHUP;
unsigned int EPOLLIN;
unsigned int EPOLLOUT;
unsigned int EPOLLPRI;
short POLLERR;
short POLLHUP;
short POLLIN;
short POLLOUT;
short POLLPRI;
short epolltopoll(unsigned int events) {
  short e = 0;
  if (events & EPOLLIN)
    e |= POLLIN;
  if (events & EPOLLOUT)
    e |= POLLOUT;
  if (events & EPOLLERR)
    e |= POLLERR;
  if (events & EPOLLPRI)
    e |= POLLPRI;
  if (events & EPOLLHUP)
    e |= POLLHUP;
  return e;
}


x86 assembly (clang, -O0):
<epolltopoll>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movw   $0x0,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ea9(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1136 <epolltopoll+0x36>
mov    0x2e8f(%rip),%rax
movswl (%rax),%ecx
movswl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e60(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     115f <epolltopoll+0x5f>
mov    0x2ea6(%rip),%rax
movswl (%rax),%ecx
movswl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e3f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1188 <epolltopoll+0x88>
mov    0x2e4d(%rip),%rax
movswl (%rax),%ecx
movswl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e56(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11b1 <epolltopoll+0xb1>
mov    0x2e3c(%rip),%rax
movswl (%rax),%ecx
movswl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ddd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11da <epolltopoll+0xda>
mov    0x2e03(%rip),%rax
movswl (%rax),%ecx
movswl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
movswl -0x6(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<epolltopoll>:
mov    0x2eb9(%rip),%rax
xor    %r8d,%r8d
mov    $0x0,%edx
test   %edi,(%rax)
je     111d <epolltopoll+0x1d>
mov    0x2e9e(%rip),%rax
movzwl (%rax),%edx
mov    0x2e7c(%rip),%rsi
mov    $0x0,%eax
test   %edi,(%rsi)
je     1137 <epolltopoll+0x37>
mov    0x2ec4(%rip),%rax
movzwl (%rax),%eax
mov    0x2e6a(%rip),%rcx
mov    $0x0,%esi
test   %edi,(%rcx)
je     1151 <epolltopoll+0x51>
mov    0x2e7a(%rip),%rcx
movzwl (%rcx),%esi
or     %edx,%eax
mov    0x2e8e(%rip),%rcx
mov    $0x0,%edx
test   %edi,(%rcx)
je     116d <epolltopoll+0x6d>
mov    0x2e76(%rip),%rcx
movzwl (%rcx),%edx
or     %edx,%esi
or     %esi,%eax
mov    0x2e20(%rip),%rcx
test   %edi,(%rcx)
je     1187 <epolltopoll+0x87>
mov    0x2e4d(%rip),%rcx
movzwl (%rcx),%r8d
or     %r8d,%eax
ret

LLVM IR (-O0):
@EPOLLIN = global i32 0
@POLLIN = global i16 0
@EPOLLOUT = global i32 0
@POLLOUT = global i16 0
@EPOLLERR = global i32 0
@POLLERR = global i16 0
@EPOLLPRI = global i32 0
@POLLPRI = global i16 0
@EPOLLHUP = global i32 0
@POLLHUP = global i16 0
define signext i16 @epolltopoll(i32 %0) {
%2 = alloca i32
%3 = alloca i16
store i32 %0, i32* %2
store i16 0, i16* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @EPOLLIN
%6 = and i32 %4, %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %1
%9 = load i16, i16* @POLLIN
%10 = sext i16 %9 to i32
%11 = load i16, i16* %3
%12 = sext i16 %11 to i32
%13 = or i32 %12, %10
%14 = trunc i32 %13 to i16
store i16 %14, i16* %3
br label %15
15: ; preds = %8, %1
%16 = load i32, i32* %2
%17 = load i32, i32* @EPOLLOUT
%18 = and i32 %16, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = load i16, i16* @POLLOUT
%22 = sext i16 %21 to i32
%23 = load i16, i16* %3
%24 = sext i16 %23 to i32
%25 = or i32 %24, %22
%26 = trunc i32 %25 to i16
store i16 %26, i16* %3
br label %27
27: ; preds = %20, %15
%28 = load i32, i32* %2
%29 = load i32, i32* @EPOLLERR
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %27
%33 = load i16, i16* @POLLERR
%34 = sext i16 %33 to i32
%35 = load i16, i16* %3
%36 = sext i16 %35 to i32
%37 = or i32 %36, %34
%38 = trunc i32 %37 to i16
store i16 %38, i16* %3
br label %39
39: ; preds = %32, %27
%40 = load i32, i32* %2
%41 = load i32, i32* @EPOLLPRI
%42 = and i32 %40, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = load i16, i16* @POLLPRI
%46 = sext i16 %45 to i32
%47 = load i16, i16* %3
%48 = sext i16 %47 to i32
%49 = or i32 %48, %46
%50 = trunc i32 %49 to i16
store i16 %50, i16* %3
br label %51
51: ; preds = %44, %39
%52 = load i32, i32* %2
%53 = load i32, i32* @EPOLLHUP
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %51
%57 = load i16, i16* @POLLHUP
%58 = sext i16 %57 to i32
%59 = load i16, i16* %3
%60 = sext i16 %59 to i32
%61 = or i32 %60, %58
%62 = trunc i32 %61 to i16
store i16 %62, i16* %3
br label %63
63: ; preds = %56, %51
%64 = load i16, i16* %3
ret i16 %64
}

LLVM IR (-O2):
@EPOLLIN = global i32 0
@POLLIN = global i16 0
@EPOLLOUT = global i32 0
@POLLOUT = global i16 0
@EPOLLERR = global i32 0
@POLLERR = global i16 0
@EPOLLPRI = global i32 0
@POLLPRI = global i16 0
@EPOLLHUP = global i32 0
@POLLHUP = global i16 0
define signext i16 @epolltopoll(i32 %0) {
%2 = load i32, i32* @EPOLLIN
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
%5 = load i16, i16* @POLLIN
%6 = select i1 %4, i16 0, i16 %5
%7 = load i32, i32* @EPOLLOUT
%8 = and i32 %7, %0
%9 = icmp eq i32 %8, 0
%10 = load i16, i16* @POLLOUT
%11 = select i1 %9, i16 0, i16 %10
%12 = or i16 %11, %6
%13 = load i32, i32* @EPOLLERR
%14 = and i32 %13, %0
%15 = icmp eq i32 %14, 0
%16 = load i16, i16* @POLLERR
%17 = select i1 %15, i16 0, i16 %16
%18 = or i16 %12, %17
%19 = load i32, i32* @EPOLLPRI
%20 = and i32 %19, %0
%21 = icmp eq i32 %20, 0
%22 = load i16, i16* @POLLPRI
%23 = select i1 %21, i16 0, i16 %22
%24 = or i16 %18, %23
%25 = load i32, i32* @EPOLLHUP
%26 = and i32 %25, %0
%27 = icmp eq i32 %26, 0
%28 = load i16, i16* @POLLHUP
%29 = select i1 %27, i16 0, i16 %28
%30 = or i16 %24, %29
ret i16 %30
}