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

/* Variables and functions */
short BEV_EVENT_EOF;
short BEV_EVENT_ERROR;
int /*<<< orphan*/ bufferevent_free(struct bufferevent *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void srv_event_cb(struct bufferevent *bev, short events, void *ctx) {
  if (events & (BEV_EVENT_ERROR | BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
    bufferevent_free(bev);
    fprintf(stderr, "Connection closed\n");
  }
}


x86 assembly (clang, -O0):
<srv_event_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
movswl -0xa(%rbp),%eax
mov    0x2eae(%rip),%rcx
movswl (%rcx),%ecx
mov    0x2e94(%rip),%rdx
movswl (%rdx),%edx
or     %edx,%ecx
mov    0x2e98(%rip),%rdx
movswl (%rdx),%edx
or     %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1186 <srv_event_cb+0x66>
mov    -0x8(%rbp),%rdi
call   1040 <bufferevent_free@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srv_event_cb>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    0x2eb1(%rip),%rcx
movzwl (%rcx),%ecx
or     (%rax),%cx
test   %si,%cx
je     1155 <srv_event_cb+0x35>
call   1040 <bufferevent_free@plt>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xeb1(%rip),%rsi
pop    %rax
jmp    1030 <fprintf@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
@BEV_EVENT_ERROR = global i16 0
@BEV_EVENT_EOF = global i16 0
@stderr = global i32 0
@.str = [19 x i8] c"Connection closed\0A\00"
define void @srv_event_cb(%struct.bufferevent* %0, i16 signext %1, i8* %2) {
%4 = alloca %struct.bufferevent*
%5 = alloca i16
%6 = alloca i8*
store %struct.bufferevent* %0, %struct.bufferevent** %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%7 = load i16, i16* %5
%8 = sext i16 %7 to i32
%9 = load i16, i16* @BEV_EVENT_ERROR
%10 = sext i16 %9 to i32
%11 = load i16, i16* @BEV_EVENT_EOF
%12 = sext i16 %11 to i32
%13 = or i32 %10, %12
%14 = load i16, i16* @BEV_EVENT_ERROR
%15 = sext i16 %14 to i32
%16 = or i32 %13, %15
%17 = and i32 %8, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %3
%20 = load %struct.bufferevent*, %struct.bufferevent** %4
%21 = call i32 @bufferevent_free(%struct.bufferevent* %20)
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %19, %3
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
@BEV_EVENT_ERROR = global i16 0
@BEV_EVENT_EOF = global i16 0
@stderr = global i32 0
@.str = [19 x i8] c"Connection closed\0A\00"
define void @srv_event_cb(%struct.bufferevent* %0, i16 signext %1, i8* nocapture readnone %2) {
%4 = load i16, i16* @BEV_EVENT_ERROR
%5 = load i16, i16* @BEV_EVENT_EOF
%6 = or i16 %5, %4
%7 = and i16 %6, %1
%8 = icmp eq i16 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = tail call i32 @bufferevent_free(%struct.bufferevent* %0)
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %9, %3
ret void
}