#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 */
typedef int uint32_t;
struct epoll_event_handler {
  int dummy;
};

/* Variables and functions */
int EPOLLERR;
int EPOLLHUP;
int EPOLLIN;
int EPOLLOUT;
int EPOLLRDHUP;
int /*<<< orphan*/ connection_on_close_event(struct epoll_event_handler *);
int /*<<< orphan*/ connection_on_in_event(struct epoll_event_handler *);
int /*<<< orphan*/ connection_on_out_event(struct epoll_event_handler *);
void connection_handle_event(struct epoll_event_handler *self,
                             uint32_t events) {
  if (events & EPOLLOUT) {
    connection_on_out_event(self);
  }
  if (events & EPOLLIN) {
    connection_on_in_event(self);
  }
  if ((events & EPOLLERR) | (events & EPOLLHUP) | (events & EPOLLRDHUP)) {
    connection_on_close_event(self);
  }
}


x86 assembly (clang, -O0):
<connection_handle_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e87(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     115d <connection_handle_event+0x2d>
mov    -0x8(%rbp),%rdi
call   1040 <connection_on_out_event@plt>
mov    -0xc(%rbp),%eax
mov    0x2e81(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     117b <connection_handle_event+0x4b>
mov    -0x8(%rbp),%rdi
call   1050 <connection_on_in_event@plt>
mov    -0xc(%rbp),%eax
mov    0x2e53(%rip),%rcx
and    (%rcx),%eax
mov    -0xc(%rbp),%ecx
mov    0x2e2f(%rip),%rdx
and    (%rdx),%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
mov    0x2e29(%rip),%rdx
and    (%rdx),%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     11b5 <connection_handle_event+0x85>
mov    -0x8(%rbp),%rdi
call   1030 <connection_on_close_event@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connection_handle_event>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e91(%rip),%rax
test   %esi,(%rax)
je     114b <connection_handle_event+0x1b>
mov    %rbx,%rdi
call   1040 <connection_on_out_event@plt>
mov    0x2e96(%rip),%rax
test   %ebp,(%rax)
je     115e <connection_handle_event+0x2e>
mov    %rbx,%rdi
call   1050 <connection_on_in_event@plt>
mov    0x2e73(%rip),%rax
mov    0x2e54(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e51(%rip),%rax
or     (%rax),%ecx
test   %ebp,%ecx
je     118b <connection_handle_event+0x5b>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <connection_on_close_event@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.epoll_event_handler = type { i32 }
@EPOLLOUT = global i32 0
@EPOLLIN = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@EPOLLRDHUP = global i32 0
define void @connection_handle_event(%struct.epoll_event_handler* %0, i32 %1) {
%3 = alloca %struct.epoll_event_handler*
%4 = alloca i32
store %struct.epoll_event_handler* %0, %struct.epoll_event_handler** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load i32, i32* @EPOLLOUT
%7 = and i32 %5, %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load %struct.epoll_event_handler*, %struct.epoll_event_handler** %3
%11 = call i32 @connection_on_out_event(%struct.epoll_event_handler* %10)
br label %12
12: ; preds = %9, %2
%13 = load i32, i32* %4
%14 = load i32, i32* @EPOLLIN
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load %struct.epoll_event_handler*, %struct.epoll_event_handler** %3
%19 = call i32 @connection_on_in_event(%struct.epoll_event_handler* %18)
br label %20
20: ; preds = %17, %12
%21 = load i32, i32* %4
%22 = load i32, i32* @EPOLLERR
%23 = and i32 %21, %22
%24 = load i32, i32* %4
%25 = load i32, i32* @EPOLLHUP
%26 = and i32 %24, %25
%27 = or i32 %23, %26
%28 = load i32, i32* %4
%29 = load i32, i32* @EPOLLRDHUP
%30 = and i32 %28, %29
%31 = or i32 %27, %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %20
%34 = load %struct.epoll_event_handler*, %struct.epoll_event_handler** %3
%35 = call i32 @connection_on_close_event(%struct.epoll_event_handler* %34)
br label %36
36: ; preds = %33, %20
ret void
}

LLVM IR (-O2):
%struct.epoll_event_handler = type { i32 }
@EPOLLOUT = global i32 0
@EPOLLIN = global i32 0
@EPOLLERR = global i32 0
@EPOLLHUP = global i32 0
@EPOLLRDHUP = global i32 0
define void @connection_handle_event(%struct.epoll_event_handler* %0, i32 %1) {
%3 = load i32, i32* @EPOLLOUT
%4 = and i32 %3, %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @connection_on_out_event(%struct.epoll_event_handler* %0)
br label %8
8: ; preds = %6, %2
%9 = load i32, i32* @EPOLLIN
%10 = and i32 %9, %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @connection_on_in_event(%struct.epoll_event_handler* %0)
br label %14
14: ; preds = %12, %8
%15 = load i32, i32* @EPOLLERR
%16 = load i32, i32* @EPOLLHUP
%17 = or i32 %16, %15
%18 = load i32, i32* @EPOLLRDHUP
%19 = or i32 %17, %18
%20 = and i32 %19, %1
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %14
%23 = tail call i32 @connection_on_close_event(%struct.epoll_event_handler* %0)
br label %24
24: ; preds = %22, %14
ret void
}