#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 POLLIN;
short POLLOUT;
short POLLPRI;
unsigned int polltoepoll(short events) {
  unsigned int epe = EPOLLERR | EPOLLHUP;
  if (events & POLLIN)
    epe |= EPOLLIN;
  if (events & POLLOUT)
    epe |= EPOLLOUT;
  if (events & POLLPRI)
    epe |= EPOLLPRI;
  return epe;
}


x86 assembly (clang, -O0):
<polltoepoll>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    0x2e8d(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x8(%rbp)
movswl -0x2(%rbp),%eax
mov    0x2e9d(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1148 <polltoepoll+0x48>
mov    0x2e90(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movswl -0x2(%rbp),%eax
mov    0x2ea5(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1170 <polltoepoll+0x70>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movswl -0x2(%rbp),%eax
mov    0x2e65(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1198 <polltoepoll+0x98>
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<polltoepoll>:
mov    0x2eb1(%rip),%r8
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
mov    0x2eb1(%rip),%rdx
xor    %ecx,%ecx
mov    $0x0,%esi
test   %di,(%rdx)
je     112c <polltoepoll+0x2c>
mov    0x2ea6(%rip),%rdx
mov    (%rdx),%esi
or     (%r8),%eax
mov    0x2ec2(%rip),%r8
mov    $0x0,%edx
test   %di,(%r8)
je     114a <polltoepoll+0x4a>
mov    0x2e68(%rip),%rdx
mov    (%rdx),%edx
or     %esi,%eax
mov    0x2e8d(%rip),%rsi
test   %di,(%rsi)
je     1161 <polltoepoll+0x61>
mov    0x2e89(%rip),%rcx
mov    (%rcx),%ecx
or     %ecx,%edx
or     %edx,%eax
ret

LLVM IR (-O0):
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@POLLIN = global i16 0
@EPOLLIN = global i32 0
@POLLOUT = global i16 0
@EPOLLOUT = global i32 0
@POLLPRI = global i16 0
@EPOLLPRI = global i32 0
define i32 @polltoepoll(i16 signext %0) {
%2 = alloca i16
%3 = alloca i32
store i16 %0, i16* %2
%4 = load i32, i32* @EPOLLERR
%5 = load i32, i32* @EPOLLHUP
%6 = or i32 %4, %5
store i32 %6, i32* %3
%7 = load i16, i16* %2
%8 = sext i16 %7 to i32
%9 = load i16, i16* @POLLIN
%10 = sext i16 %9 to i32
%11 = and i32 %8, %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i32, i32* @EPOLLIN
%15 = load i32, i32* %3
%16 = or i32 %15, %14
store i32 %16, i32* %3
br label %17
17: ; preds = %13, %1
%18 = load i16, i16* %2
%19 = sext i16 %18 to i32
%20 = load i16, i16* @POLLOUT
%21 = sext i16 %20 to i32
%22 = and i32 %19, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = load i32, i32* @EPOLLOUT
%26 = load i32, i32* %3
%27 = or i32 %26, %25
store i32 %27, i32* %3
br label %28
28: ; preds = %24, %17
%29 = load i16, i16* %2
%30 = sext i16 %29 to i32
%31 = load i16, i16* @POLLPRI
%32 = sext i16 %31 to i32
%33 = and i32 %30, %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32, i32* @EPOLLPRI
%37 = load i32, i32* %3
%38 = or i32 %37, %36
store i32 %38, i32* %3
br label %39
39: ; preds = %35, %28
%40 = load i32, i32* %3
ret i32 %40
}

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