#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 scalar_t__ evutil_socket_t;

/* Variables and functions */
short EV_READ;
short EV_SIGNAL;
short EV_TIMEOUT;
short EV_WRITE;
int /*<<< orphan*/ printf(char *, int, char *, char *, char *, char *,
                          char const *);
void cb_func(evutil_socket_t fd, short what, void *arg) {
  const char *data = arg;
  printf("Got an event on socket %d:%s%s%s%s [%s]", (int)fd,
         (what & EV_TIMEOUT) ? " timeout" : "", (what & EV_READ) ? " read" : "",
         (what & EV_WRITE) ? " write" : "", (what & EV_SIGNAL) ? " signal" : "",
         data);
}


x86 assembly (clang, -O0):
<cb_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%esi
movswl -0xa(%rbp),%ecx
mov    0x2e98(%rip),%rax
movswl (%rax),%eax
and    %eax,%ecx
lea    0xedb(%rip),%rdx
lea    0xed5(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
movswl -0xa(%rbp),%edi
mov    0x2e83(%rip),%rax
movswl (%rax),%eax
and    %eax,%edi
lea    0xeb6(%rip),%rcx
lea    0xeb9(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
movswl -0xa(%rbp),%edi
mov    0x2e36(%rip),%rax
movswl (%rax),%eax
and    %eax,%edi
lea    0xe91(%rip),%r8
lea    0xe9a(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r8
movswl -0xa(%rbp),%edi
mov    0x2e21(%rip),%rax
movswl (%rax),%eax
and    %eax,%edi
lea    0xe6c(%rip),%r9
lea    0xe7c(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r9
mov    -0x20(%rbp),%rax
lea    0xe2c(%rip),%rdi
mov    %rax,(%rsp)
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cb_func>:
push   %rax
mov    0x2ec0(%rip),%rax
movzwl (%rax),%eax
and    %si,%ax
lea    0xf02(%rip),%r10
lea    0xefc(%rip),%r11
cmove  %r10,%r11
mov    0x2eb1(%rip),%rcx
movzwl (%rcx),%ecx
and    %si,%cx
lea    0xeed(%rip),%rcx
cmove  %r10,%rcx
mov    0x2e71(%rip),%rax
movzwl (%rax),%eax
and    %si,%ax
lea    0xedb(%rip),%r8
cmove  %r10,%r8
mov    0x2e69(%rip),%rax
and    (%rax),%si
mov    %rdi,%rsi
lea    0xeca(%rip),%r9
cmove  %r10,%r9
mov    %rdx,(%rsp)
lea    0xe7d(%rip),%rdi
mov    %r11,%rdx
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Got an event on socket %d:%s%s%s%s [%s]\00"
@EV_TIMEOUT = global i16 0
@.str.1 = [9 x i8] c" timeout\00"
@.str.2 = [1 x i8] zeroinitializer
@EV_READ = global i16 0
@.str.3 = [6 x i8] c" read\00"
@EV_WRITE = global i16 0
@.str.4 = [7 x i8] c" write\00"
@EV_SIGNAL = global i16 0
@.str.5 = [8 x i8] c" signal\00"
define void @cb_func(i64 %0, i16 signext %1, i8* %2) {
%4 = alloca i64
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i8*
store i64 %0, i64* %4
store i16 %1, i16* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
store i8* %8, i8** %7
%9 = load i64, i64* %4
%10 = trunc i64 %9 to i32
%11 = load i16, i16* %5
%12 = sext i16 %11 to i32
%13 = load i16, i16* @EV_TIMEOUT
%14 = sext i16 %13 to i32
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%19 = load i16, i16* %5
%20 = sext i16 %19 to i32
%21 = load i16, i16* @EV_READ
%22 = sext i16 %21 to i32
%23 = and i32 %20, %22
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%27 = load i16, i16* %5
%28 = sext i16 %27 to i32
%29 = load i16, i16* @EV_WRITE
%30 = sext i16 %29 to i32
%31 = and i32 %28, %30
%32 = icmp ne i32 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%35 = load i16, i16* %5
%36 = sext i16 %35 to i32
%37 = load i16, i16* @EV_SIGNAL
%38 = sext i16 %37 to i32
%39 = and i32 %36, %38
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%43 = load i8*, i8** %7
%44 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %18, i8* %26, i8* %34, i8* %42, i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Got an event on socket %d:%s%s%s%s [%s]\00"
@EV_TIMEOUT = global i16 0
@.str.1 = [9 x i8] c" timeout\00"
@.str.2 = [1 x i8] zeroinitializer
@EV_READ = global i16 0
@.str.3 = [6 x i8] c" read\00"
@EV_WRITE = global i16 0
@.str.4 = [7 x i8] c" write\00"
@EV_SIGNAL = global i16 0
@.str.5 = [8 x i8] c" signal\00"
define void @cb_func(i64 %0, i16 signext %1, i8* %2) {
%4 = trunc i64 %0 to i32
%5 = load i16, i16* @EV_TIMEOUT
%6 = and i16 %5, %1
%7 = icmp eq i16 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%9 = load i16, i16* @EV_READ
%10 = and i16 %9, %1
%11 = icmp eq i16 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%13 = load i16, i16* @EV_WRITE
%14 = and i16 %13, %1
%15 = icmp eq i16 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0)
%17 = load i16, i16* @EV_SIGNAL
%18 = and i16 %17, %1
%19 = icmp eq i16 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %4, i8* %8, i8* %12, i8* %16, i8* %20, i8* %2)
ret void
}