#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 int POLLERR;
unsigned int POLLHUP;
unsigned int POLLIN;
unsigned int POLLNVAL;
unsigned int POLLOUT;
unsigned int POLLPRI;
int /*<<< orphan*/ decodeEventsMask_Sub(char **, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *decodeEventsMask(unsigned int flags) {
  static char msgBuf[900];
  char *s;
  if (flags == 0) {
    strcpy(msgBuf, "none");
    return msgBuf;
  }
  s = msgBuf;
  if (flags & POLLIN) {
    decodeEventsMask_Sub(&s, "POLLIN");
    flags = flags & (~POLLIN);
  };
  if (flags & POLLPRI) {
    decodeEventsMask_Sub(&s, "POLLPRI");
    flags = flags & (~POLLPRI);
  };
  if (flags & POLLOUT) {
    decodeEventsMask_Sub(&s, "POLLOUT");
    flags = flags & (~POLLOUT);
  };
  if (flags & POLLERR) {
    decodeEventsMask_Sub(&s, "POLLERR");
    flags = flags & (~POLLERR);
  };
  if (flags & POLLHUP) {
    decodeEventsMask_Sub(&s, "POLLHUP");
    flags = flags & (~POLLHUP);
  };
  if (flags & POLLNVAL) {
    decodeEventsMask_Sub(&s, "POLLNVAL");
    flags = flags & (~POLLNVAL);
  };
  if (flags != 0) {
    sprintf(s, "unknown bits %04X, ", flags);
    s = s + strlen(s);
  }
  *s-- = '\0';
  *s-- = '\0';
  *s-- = '\0';
  return msgBuf;
}


x86 assembly (clang, -O0):
<decodeEventsMask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1178 <decodeEventsMask+0x38>
lea    0x2ef4(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2ee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1358 <decodeEventsMask+0x218>
lea    0x2ed1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e33(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11bc <decodeEventsMask+0x7c>
lea    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2e0e(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e22(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11f5 <decodeEventsMask+0xb5>
lea    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2df9(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     122e <decodeEventsMask+0xee>
lea    -0x18(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2dd4(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2d98(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1267 <decodeEventsMask+0x127>
lea    -0x18(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2d73(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2d67(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12a0 <decodeEventsMask+0x160>
lea    -0x18(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2d42(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2d1e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12d9 <decodeEventsMask+0x199>
lea    -0x18(%rbp),%rdi
lea    0xd6c(%rip),%rsi
call   1050 <decodeEventsMask_Sub@plt>
mov    -0xc(%rbp),%eax
mov    0x2cf9(%rip),%rcx
mov    (%rcx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1317 <decodeEventsMask+0x1d7>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd44(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
lea    0x2cfc(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decodeEventsMask>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1270 <decodeEventsMask+0x130>
mov    %edi,%ebx
lea    0x2efb(%rip),%rax
mov    %rax,(%rsp)
mov    0x2e60(%rip),%r14
test   %edi,(%r14)
je     117b <decodeEventsMask+0x3b>
lea    0xe99(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    0x2e66(%rip),%r14
test   %ebx,(%r14)
je     119d <decodeEventsMask+0x5d>
lea    0xe7e(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    0x2e54(%rip),%r14
test   %ebx,(%r14)
je     11bf <decodeEventsMask+0x7f>
lea    0xe64(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    0x2e0a(%rip),%r14
test   %ebx,(%r14)
je     11e1 <decodeEventsMask+0xa1>
lea    0xe4a(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    0x2df0(%rip),%r14
test   %ebx,(%r14)
je     1203 <decodeEventsMask+0xc3>
lea    0xe30(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    0x2dbe(%rip),%r14
test   %ebx,(%r14)
je     1225 <decodeEventsMask+0xe5>
lea    0xe16(%rip),%rsi
mov    %rsp,%rdi
call   1050 <decodeEventsMask_Sub@plt>
mov    (%r14),%eax
not    %eax
and    %eax,%ebx
mov    (%rsp),%rdi
test   %ebx,%ebx
je     124d <decodeEventsMask+0x10d>
lea    0xe01(%rip),%rsi
mov    %ebx,%edx
call   1060 <sprintf@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
lea    -0x1(%rdi),%rax
mov    %rax,(%rsp)
movb   $0x0,(%rdi)
mov    (%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %rcx,(%rsp)
movb   $0x0,(%rax)
mov    (%rsp),%rax
movb   $0x0,(%rax)
jmp    1283 <decodeEventsMask+0x143>
lea    0x2dd9(%rip),%rdi
lea    0xd82(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2dc6(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@decodeEventsMask.msgBuf = internal global [900 x i8] zeroinitializer
@.str = [5 x i8] c"none\00"
@POLLIN = global i32 0
@.str.1 = [7 x i8] c"POLLIN\00"
@POLLPRI = global i32 0
@.str.2 = [8 x i8] c"POLLPRI\00"
@POLLOUT = global i32 0
@.str.3 = [8 x i8] c"POLLOUT\00"
@POLLERR = global i32 0
@.str.4 = [8 x i8] c"POLLERR\00"
@POLLHUP = global i32 0
@.str.5 = [8 x i8] c"POLLHUP\00"
@POLLNVAL = global i32 0
@.str.6 = [9 x i8] c"POLLNVAL\00"
@.str.7 = [20 x i8] c"unknown bits %04X, \00"
define i8* @decodeEventsMask(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @strcpy(i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8** %2
br label %94
9: ; preds = %1
store i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8** %4
%10 = load i32, i32* %3
%11 = load i32, i32* @POLLIN
%12 = and i32 %10, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = load i32, i32* @POLLIN
%18 = xor i32 %17, -1
%19 = and i32 %16, %18
store i32 %19, i32* %3
br label %20
20: ; preds = %14, %9
%21 = load i32, i32* %3
%22 = load i32, i32* @POLLPRI
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = load i32, i32* @POLLPRI
%29 = xor i32 %28, -1
%30 = and i32 %27, %29
store i32 %30, i32* %3
br label %31
31: ; preds = %25, %20
%32 = load i32, i32* %3
%33 = load i32, i32* @POLLOUT
%34 = and i32 %32, %33
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %31
%37 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = load i32, i32* @POLLOUT
%40 = xor i32 %39, -1
%41 = and i32 %38, %40
store i32 %41, i32* %3
br label %42
42: ; preds = %36, %31
%43 = load i32, i32* %3
%44 = load i32, i32* @POLLERR
%45 = and i32 %43, %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %42
%48 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* %3
%50 = load i32, i32* @POLLERR
%51 = xor i32 %50, -1
%52 = and i32 %49, %51
store i32 %52, i32* %3
br label %53
53: ; preds = %47, %42
%54 = load i32, i32* %3
%55 = load i32, i32* @POLLHUP
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %53
%59 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%60 = load i32, i32* %3
%61 = load i32, i32* @POLLHUP
%62 = xor i32 %61, -1
%63 = and i32 %60, %62
store i32 %63, i32* %3
br label %64
64: ; preds = %58, %53
%65 = load i32, i32* %3
%66 = load i32, i32* @POLLNVAL
%67 = and i32 %65, %66
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %75
69: ; preds = %64
%70 = call i32 @decodeEventsMask_Sub(i8** %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%71 = load i32, i32* %3
%72 = load i32, i32* @POLLNVAL
%73 = xor i32 %72, -1
%74 = and i32 %71, %73
store i32 %74, i32* %3
br label %75
75: ; preds = %69, %64
%76 = load i32, i32* %3
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %87
78: ; preds = %75
%79 = load i8*, i8** %4
%80 = load i32, i32* %3
%81 = call i32 @sprintf(i8* %79, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %80)
%82 = load i8*, i8** %4
%83 = load i8*, i8** %4
%84 = call i32 @strlen(i8* %83)
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
store i8* %86, i8** %4
br label %87
87: ; preds = %78, %75
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i32 -1
store i8* %89, i8** %4
store i8 0, i8* %88
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i32 -1
store i8* %91, i8** %4
store i8 0, i8* %90
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i32 -1
store i8* %93, i8** %4
store i8 0, i8* %92
store i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8** %2
br label %94
94: ; preds = %87, %7
%95 = load i8*, i8** %2
ret i8* %95
}

LLVM IR (-O2):
@decodeEventsMask.msgBuf = internal global [900 x i8] zeroinitializer
@.str = [5 x i8] c"none\00"
@POLLIN = global i32 0
@.str.1 = [7 x i8] c"POLLIN\00"
@POLLPRI = global i32 0
@.str.2 = [8 x i8] c"POLLPRI\00"
@POLLOUT = global i32 0
@.str.3 = [8 x i8] c"POLLOUT\00"
@POLLERR = global i32 0
@.str.4 = [8 x i8] c"POLLERR\00"
@POLLHUP = global i32 0
@.str.5 = [8 x i8] c"POLLHUP\00"
@POLLNVAL = global i32 0
@.str.6 = [9 x i8] c"POLLNVAL\00"
@.str.7 = [20 x i8] c"unknown bits %04X, \00"
define i8* @decodeEventsMask(i32 %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @strcpy(i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %82
7: ; preds = %1
store i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0), i8** %2
%8 = load i32, i32* @POLLIN
%9 = and i32 %8, %0
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @POLLIN
%14 = xor i32 %13, -1
%15 = and i32 %14, %0
br label %16
16: ; preds = %11, %7
%17 = phi i32 [ %15, %11 ], [ %0, %7 ]
%18 = load i32, i32* @POLLPRI
%19 = and i32 %18, %17
%20 = icmp eq i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @POLLPRI
%24 = xor i32 %23, -1
%25 = and i32 %17, %24
br label %26
26: ; preds = %21, %16
%27 = phi i32 [ %25, %21 ], [ %17, %16 ]
%28 = load i32, i32* @POLLOUT
%29 = and i32 %28, %27
%30 = icmp eq i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* @POLLOUT
%34 = xor i32 %33, -1
%35 = and i32 %27, %34
br label %36
36: ; preds = %31, %26
%37 = phi i32 [ %35, %31 ], [ %27, %26 ]
%38 = load i32, i32* @POLLERR
%39 = and i32 %38, %37
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%43 = load i32, i32* @POLLERR
%44 = xor i32 %43, -1
%45 = and i32 %37, %44
br label %46
46: ; preds = %41, %36
%47 = phi i32 [ %45, %41 ], [ %37, %36 ]
%48 = load i32, i32* @POLLHUP
%49 = and i32 %48, %47
%50 = icmp eq i32 %49, 0
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @POLLHUP
%54 = xor i32 %53, -1
%55 = and i32 %47, %54
br label %56
56: ; preds = %51, %46
%57 = phi i32 [ %55, %51 ], [ %47, %46 ]
%58 = load i32, i32* @POLLNVAL
%59 = and i32 %58, %57
%60 = icmp eq i32 %59, 0
br i1 %60, label %66, label %61
61: ; preds = %56
%62 = call i32 @decodeEventsMask_Sub(i8** %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%63 = load i32, i32* @POLLNVAL
%64 = xor i32 %63, -1
%65 = and i32 %57, %64
br label %66
66: ; preds = %61, %56
%67 = phi i32 [ %65, %61 ], [ %57, %56 ]
%68 = icmp eq i32 %67, 0
%69 = load i8*, i8** %2
br i1 %68, label %76, label %70
70: ; preds = %66
%71 = call i32 @sprintf(i8* dereferenceable(1) %69, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %67)
%72 = load i8*, i8** %2
%73 = call i32 @strlen(i8* %72)
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
br label %76
76: ; preds = %66, %70
%77 = phi i8* [ %75, %70 ], [ %69, %66 ]
%78 = getelementptr inbounds i8, i8* %77, i64 -1
store i8* %78, i8** %2
store i8 0, i8* %77
%79 = load i8*, i8** %2
%80 = getelementptr inbounds i8, i8* %79, i64 -1
store i8* %80, i8** %2
store i8 0, i8* %79
%81 = load i8*, i8** %2
store i8 0, i8* %81
br label %82
82: ; preds = %76, %5
ret i8* getelementptr inbounds ([900 x i8], [900 x i8]* @decodeEventsMask.msgBuf, i64 0, i64 0)
}