#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 _err_event();
int _read_event();
int _write_event();
int _convert_events(int events) {
  int epoll_events = 0;
  if (events & 4) {
    epoll_events |= _read_event();
  }
  if (events & 2) {
    epoll_events |= _write_event();
  }
  if (events & 1) {
    epoll_events |= _err_event();
  }
  return epoll_events;
}


x86 assembly (clang, -O0):
<_convert_events>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     115e <_convert_events+0x2e>
mov    $0x0,%al
call   1030 <_read_event@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     117a <_convert_events+0x4a>
mov    $0x0,%al
call   1050 <_write_event@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1196 <_convert_events+0x66>
mov    $0x0,%al
call   1040 <_err_event@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_convert_events>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %ebx,%ebx
test   $0x4,%bpl
jne    115b <_convert_events+0x2b>
test   $0x2,%bpl
jne    116a <_convert_events+0x3a>
test   $0x1,%bpl
je     1152 <_convert_events+0x22>
xor    %eax,%eax
call   1040 <_err_event@plt>
or     %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1030 <_read_event@plt>
mov    %eax,%ebx
test   $0x2,%bpl
je     1143 <_convert_events+0x13>
xor    %eax,%eax
call   1050 <_write_event@plt>
or     %eax,%ebx
test   $0x1,%bpl
jne    1149 <_convert_events+0x19>
jmp    1152 <_convert_events+0x22>

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

LLVM IR (-O2):
define i32 @_convert_events(i32 %0) {
%2 = and i32 %0, 4
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 (...) @_read_event()
br label %6
6: ; preds = %4, %1
%7 = phi i32 [ %5, %4 ], [ 0, %1 ]
%8 = and i32 %0, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 (...) @_write_event()
%12 = or i32 %11, %7
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ %12, %10 ], [ %7, %6 ]
%15 = and i32 %0, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = tail call i32 (...) @_err_event()
%19 = or i32 %18, %14
br label %20
20: ; preds = %17, %13
%21 = phi i32 [ %19, %17 ], [ %14, %13 ]
ret i32 %21
}