#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 cio_events_from_epoll(int epoll) {
  int cio = 0;
  if (epoll & EPOLLIN)
    cio |= 1;
  if (epoll & EPOLLOUT)
    cio |= 2;
  if (epoll & EPOLLERR)
    cio |= 4;
  if (epoll & EPOLLHUP)
    cio |= 8;
  return cio;
}


x86 assembly (clang, -O0):
<cio_events_from_epoll>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ed0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     112c <cio_events_from_epoll+0x2c>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e9a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     114a <cio_events_from_epoll+0x4a>
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e84(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1168 <cio_events_from_epoll+0x68>
mov    -0x8(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e56(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1186 <cio_events_from_epoll+0x86>
mov    -0x8(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<cio_events_from_epoll>:
mov    0x2ee1(%rip),%rax
xor    %ecx,%ecx
test   %edi,(%rax)
setne  %cl
mov    0x2ebb(%rip),%rax
lea    0x2(%rcx),%edx
test   %edi,(%rax)
cmove  %ecx,%edx
mov    0x2eb4(%rip),%rax
lea    0x4(%rdx),%ecx
test   %edi,(%rax)
cmove  %edx,%ecx
mov    0x2e95(%rip),%rdx
lea    0x8(%rcx),%eax
test   %edi,(%rdx)
cmove  %ecx,%eax
ret

LLVM IR (-O0):
@EPOLLIN = global i32 0
@EPOLLOUT = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
define i32 @cio_events_from_epoll(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 = and i32 %4, %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = or i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %1
%12 = load i32, i32* %2
%13 = load i32, i32* @EPOLLOUT
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %3
%18 = or i32 %17, 2
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* %2
%21 = load i32, i32* @EPOLLERR
%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, 4
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %19
%28 = load i32, i32* %2
%29 = load i32, i32* @EPOLLHUP
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %3
%34 = or i32 %33, 8
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %27
%36 = load i32, i32* %3
ret i32 %36
}

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