#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 */
unsigned short EV_READ;
unsigned short EV_WRITE;
const char *redsocks_event_str(unsigned short what) {
  return what == EV_READ                ? "R/-"
         : what == EV_WRITE             ? "-/W"
         : what == (EV_READ | EV_WRITE) ? "R/W"
         : what == 0                    ? "-/-"
                                        : "???";
}


x86 assembly (clang, -O0):
<redsocks_event_str>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
mov    0x2ed2(%rip),%rcx
movzwl (%rcx),%ecx
cmp    %ecx,%eax
jne    1131 <redsocks_event_str+0x31>
lea    0xed8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11b6 <redsocks_event_str+0xb6>
movzwl -0x2(%rbp),%eax
mov    0x2e94(%rip),%rcx
movzwl (%rcx),%ecx
cmp    %ecx,%eax
jne    1157 <redsocks_event_str+0x57>
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11ae <redsocks_event_str+0xae>
movzwl -0x2(%rbp),%eax
mov    0x2e86(%rip),%rcx
movzwl (%rcx),%ecx
mov    0x2e64(%rip),%rdx
movzwl (%rdx),%edx
or     %edx,%ecx
cmp    %ecx,%eax
jne    1189 <redsocks_event_str+0x89>
lea    0xe88(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11a6 <redsocks_event_str+0xa6>
movzwl -0x2(%rbp),%edx
lea    0xe7c(%rip),%rax
lea    0xe71(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<redsocks_event_str>:
mov    0x2ee1(%rip),%rax
movzwl (%rax),%eax
cmp    %di,%ax
jne    1117 <redsocks_event_str+0x17>
lea    0xeea(%rip),%rax
ret
mov    0x2eb2(%rip),%rcx
movzwl (%rcx),%ecx
cmp    %di,%cx
jne    112e <redsocks_event_str+0x2e>
lea    0xed7(%rip),%rax
ret
or     %eax,%ecx
cmp    %di,%cx
jne    113d <redsocks_event_str+0x3d>
lea    0xecc(%rip),%rax
ret
test   %di,%di
lea    0xec5(%rip),%rcx
lea    0xec2(%rip),%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@EV_READ = global i16 0
@.str = [4 x i8] c"R/-\00"
@EV_WRITE = global i16 0
@.str.1 = [4 x i8] c"-/W\00"
@.str.2 = [4 x i8] c"R/W\00"
@.str.3 = [4 x i8] c"-/-\00"
@.str.4 = [4 x i8] c"???\00"
define i8* @redsocks_event_str(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
%5 = load i16, i16* @EV_READ
%6 = zext i16 %5 to i32
%7 = icmp eq i32 %4, %6
br i1 %7, label %8, label %9
8: ; preds = %1
br label %36
9: ; preds = %1
%10 = load i16, i16* %2
%11 = zext i16 %10 to i32
%12 = load i16, i16* @EV_WRITE
%13 = zext i16 %12 to i32
%14 = icmp eq i32 %11, %13
br i1 %14, label %15, label %16
15: ; preds = %9
br label %34
16: ; preds = %9
%17 = load i16, i16* %2
%18 = zext i16 %17 to i32
%19 = load i16, i16* @EV_READ
%20 = zext i16 %19 to i32
%21 = load i16, i16* @EV_WRITE
%22 = zext i16 %21 to i32
%23 = or i32 %20, %22
%24 = icmp eq i32 %18, %23
br i1 %24, label %25, label %26
25: ; preds = %16
br label %32
26: ; preds = %16
%27 = load i16, i16* %2
%28 = zext i16 %27 to i32
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
br label %32
32: ; preds = %26, %25
%33 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %25 ], [ %31, %26 ]
br label %34
34: ; preds = %32, %15
%35 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %15 ], [ %33, %32 ]
br label %36
36: ; preds = %34, %8
%37 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %8 ], [ %35, %34 ]
ret i8* %37
}

LLVM IR (-O2):
@EV_READ = global i16 0
@.str = [4 x i8] c"R/-\00"
@EV_WRITE = global i16 0
@.str.1 = [4 x i8] c"-/W\00"
@.str.2 = [4 x i8] c"R/W\00"
@.str.3 = [4 x i8] c"-/-\00"
@.str.4 = [4 x i8] c"???\00"
define i8* @redsocks_event_str(i16 zeroext %0) {
%2 = load i16, i16* @EV_READ
%3 = icmp eq i16 %2, %0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = load i16, i16* @EV_WRITE
%6 = icmp eq i16 %5, %0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = or i16 %5, %2
%9 = icmp eq i16 %8, %0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = icmp eq i16 %0, 0
%12 = select i1 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
br label %13
13: ; preds = %4, %7, %10, %1
%14 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %4 ], [ %12, %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %7 ]
ret i8* %14
}