#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;
};
typedef int /*<<< orphan*/ evutil_socket_t;

/* Variables and functions */
short BEV_EVENT_CONNECTED;
short BEV_EVENT_ERROR;
int /*<<< orphan*/ bufferevent_getfd(struct bufferevent *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ set_tcp_no_delay(int /*<<< orphan*/);
void eventcb(struct bufferevent *bev, short events, void *ptr) {
  if (events & BEV_EVENT_CONNECTED) {
    evutil_socket_t fd = bufferevent_getfd(bev);
    set_tcp_no_delay(fd);
  } else if (events & BEV_EVENT_ERROR) {
    printf("NOT Connected\n");
  }
}


x86 assembly (clang, -O0):
<eventcb>:
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    0x2e86(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1179 <eventcb+0x49>
mov    -0x8(%rbp),%rdi
call   1050 <bufferevent_getfd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <set_tcp_no_delay@plt>
jmp    11a3 <eventcb+0x73>
movswl -0xa(%rbp),%eax
mov    0x2e6c(%rip),%rcx
movswl (%rcx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     119e <eventcb+0x6e>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    11a3 <eventcb+0x73>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eventcb>:
push   %rax
mov    0x2ea0(%rip),%rax
test   %si,(%rax)
je     114a <eventcb+0x1a>
call   1050 <bufferevent_getfd@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <set_tcp_no_delay@plt>
mov    0x2e9f(%rip),%rax
test   %si,(%rax)
je     1163 <eventcb+0x33>
lea    0xea3(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.bufferevent = type { i32 }
@BEV_EVENT_CONNECTED = global i16 0
@BEV_EVENT_ERROR = global i16 0
@.str = [15 x i8] c"NOT Connected\0A\00"
define void @eventcb(%struct.bufferevent* %0, i16 signext %1, i8* %2) {
%4 = alloca %struct.bufferevent*
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i32
store %struct.bufferevent* %0, %struct.bufferevent** %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%8 = load i16, i16* %5
%9 = sext i16 %8 to i32
%10 = load i16, i16* @BEV_EVENT_CONNECTED
%11 = sext i16 %10 to i32
%12 = and i32 %9, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load %struct.bufferevent*, %struct.bufferevent** %4
%16 = call i32 @bufferevent_getfd(%struct.bufferevent* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = call i32 @set_tcp_no_delay(i32 %17)
br label %29
19: ; preds = %3
%20 = load i16, i16* %5
%21 = sext i16 %20 to i32
%22 = load i16, i16* @BEV_EVENT_ERROR
%23 = sext i16 %22 to i32
%24 = and i32 %21, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %19
br label %29
29: ; preds = %28, %14
ret void
}

LLVM IR (-O2):
%struct.bufferevent = type { i32 }
@BEV_EVENT_CONNECTED = global i16 0
@BEV_EVENT_ERROR = global i16 0
@str = [14 x i8] c"NOT Connected\00"
define void @eventcb(%struct.bufferevent* %0, i16 signext %1, i8* nocapture readnone %2) {
%4 = load i16, i16* @BEV_EVENT_CONNECTED
%5 = and i16 %4, %1
%6 = icmp eq i16 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @bufferevent_getfd(%struct.bufferevent* %0)
%9 = tail call i32 @set_tcp_no_delay(i32 %8)
br label %16
10: ; preds = %3
%11 = load i16, i16* @BEV_EVENT_ERROR
%12 = and i16 %11, %1
%13 = icmp eq i16 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %10, %14, %7
ret void
}