#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 */
int EPOLLERR;
int EPOLLHUP;
int EPOLLIN;
int EPOLLOUT;
int EPOLLPRI;
int EPOLLRDHUP;
int etol_mask(int mask) {
  int result = 0;
  if (mask & (EPOLLIN | EPOLLRDHUP | EPOLLPRI | EPOLLHUP | EPOLLERR))
    result |= 1;
  if (mask & EPOLLOUT)
    result |= 2;
  return result;
}


x86 assembly (clang, -O0):
<etol_mask>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ec8(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e9f(%rip),%rdx
or     (%rdx),%ecx
mov    0x2ec6(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e85(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e94(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1152 <etol_mask+0x52>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e6c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1170 <etol_mask+0x70>
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<etol_mask>:
mov    0x2ed9(%rip),%rax
mov    0x2eb2(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ed7(%rip),%rax
or     (%rax),%ecx
mov    0x2e96(%rip),%rax
or     (%rax),%ecx
mov    0x2ea5(%rip),%rax
or     (%rax),%ecx
xor    %edx,%edx
test   %edi,%ecx
setne  %dl
mov    0x2e8d(%rip),%rcx
lea    0x2(%rdx),%eax
test   %edi,(%rcx)
cmove  %edx,%eax
ret

LLVM IR (-O0):
@EPOLLIN = global i32 0
@EPOLLRDHUP = global i32 0
@EPOLLPRI = global i32 0
@EPOLLHUP = global i32 0
@EPOLLERR = global i32 0
@EPOLLOUT = global i32 0
define i32 @etol_mask(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @EPOLLIN
%6 = load i32, i32* @EPOLLRDHUP
%7 = or i32 %5, %6
%8 = load i32, i32* @EPOLLPRI
%9 = or i32 %7, %8
%10 = load i32, i32* @EPOLLHUP
%11 = or i32 %9, %10
%12 = load i32, i32* @EPOLLERR
%13 = or i32 %11, %12
%14 = and i32 %4, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* %3
%18 = or i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %1
%20 = load i32, i32* %2
%21 = load i32, i32* @EPOLLOUT
%22 = and i32 %20, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %3
%26 = or i32 %25, 2
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %19
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@EPOLLIN = global i32 0
@EPOLLRDHUP = global i32 0
@EPOLLPRI = global i32 0
@EPOLLHUP = global i32 0
@EPOLLERR = global i32 0
@EPOLLOUT = global i32 0
define i32 @etol_mask(i32 %0) {
%2 = load i32, i32* @EPOLLIN
%3 = load i32, i32* @EPOLLRDHUP
%4 = or i32 %3, %2
%5 = load i32, i32* @EPOLLPRI
%6 = or i32 %4, %5
%7 = load i32, i32* @EPOLLHUP
%8 = or i32 %6, %7
%9 = load i32, i32* @EPOLLERR
%10 = or i32 %8, %9
%11 = and i32 %10, %0
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
%14 = load i32, i32* @EPOLLOUT
%15 = and i32 %14, %0
%16 = icmp eq i32 %15, 0
%17 = or i32 %13, 2
%18 = select i1 %16, i32 %13, i32 %17
ret i32 %18
}