#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 */
int LOG_ALERT;
int LOG_DEBUG;
int LOG_ERR;
int LOG_INFO;
int LOG_NOTICE;
int LOG_WARNING;
int mask_to_syslog(int mask) {
  int newmask = 0;
  if (mask & (1 << (0)))
    newmask |= (1 << (LOG_ALERT));
  if (mask & (1 << (1)))
    newmask |= (1 << (LOG_ERR));
  if (mask & (1 << (2)))
    newmask |= (1 << (LOG_WARNING));
  if (mask & (1 << (3)))
    newmask |= (1 << (LOG_NOTICE));
  if (mask & (1 << (4)))
    newmask |= (1 << (LOG_INFO));
  if (mask & (1 << (5)))
    newmask |= (1 << (LOG_DEBUG));
  return newmask;
}


x86 assembly (clang, -O0):
<mask_to_syslog>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1133 <mask_to_syslog+0x33>
mov    0x2ec4(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1158 <mask_to_syslog+0x58>
mov    0x2e67(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     117d <mask_to_syslog+0x7d>
mov    0x2e72(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11a2 <mask_to_syslog+0xa2>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11c7 <mask_to_syslog+0xc7>
mov    0x2e08(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11ec <mask_to_syslog+0xec>
mov    0x2deb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mask_to_syslog>:
mov    %edi,%edx
and    $0x1,%edx
mov    0x2edc(%rip),%rax
mov    (%rax),%cl
mov    $0x1,%esi
shl    %cl,%esi
neg    %edx
mov    $0x1,%eax
and    %edx,%esi
mov    %edi,%edx
shl    $0x1e,%edx
sar    $0x1f,%edx
mov    0x2e83(%rip),%rcx
mov    (%rcx),%cl
mov    $0x1,%r8d
shl    %cl,%r8d
and    %edx,%r8d
or     %esi,%r8d
mov    %edi,%edx
shl    $0x1d,%edx
mov    0x2e96(%rip),%rcx
mov    (%rcx),%cl
mov    $0x1,%r9d
shl    %cl,%r9d
sar    $0x1f,%edx
and    %edx,%r9d
mov    %edi,%esi
mov    0x2e6c(%rip),%rcx
mov    (%rcx),%cl
mov    $0x1,%edx
shl    %cl,%edx
shl    $0x1c,%esi
sar    $0x1f,%esi
and    %esi,%edx
or     %r9d,%edx
or     %r8d,%edx
mov    %edi,%esi
shl    $0x1b,%esi
mov    0x2e39(%rip),%rcx
mov    (%rcx),%cl
mov    $0x1,%r8d
shl    %cl,%r8d
sar    $0x1f,%esi
and    %esi,%r8d
shl    $0x1a,%edi
mov    0x2e26(%rip),%rcx
mov    (%rcx),%cl
shl    %cl,%eax
sar    $0x1f,%edi
and    %edi,%eax
or     %r8d,%eax
or     %edx,%eax
ret

LLVM IR (-O0):
@LOG_ALERT = global i32 0
@LOG_ERR = global i32 0
@LOG_WARNING = global i32 0
@LOG_NOTICE = global i32 0
@LOG_INFO = global i32 0
@LOG_DEBUG = global i32 0
define i32 @mask_to_syslog(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @LOG_ALERT
%9 = shl i32 1, %8
%10 = load i32, i32* %3
%11 = or i32 %10, %9
store i32 %11, i32* %3
br label %12
12: ; preds = %7, %1
%13 = load i32, i32* %2
%14 = and i32 %13, 2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* @LOG_ERR
%18 = shl i32 1, %17
%19 = load i32, i32* %3
%20 = or i32 %19, %18
store i32 %20, i32* %3
br label %21
21: ; preds = %16, %12
%22 = load i32, i32* %2
%23 = and i32 %22, 4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i32, i32* @LOG_WARNING
%27 = shl i32 1, %26
%28 = load i32, i32* %3
%29 = or i32 %28, %27
store i32 %29, i32* %3
br label %30
30: ; preds = %25, %21
%31 = load i32, i32* %2
%32 = and i32 %31, 8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* @LOG_NOTICE
%36 = shl i32 1, %35
%37 = load i32, i32* %3
%38 = or i32 %37, %36
store i32 %38, i32* %3
br label %39
39: ; preds = %34, %30
%40 = load i32, i32* %2
%41 = and i32 %40, 16
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load i32, i32* @LOG_INFO
%45 = shl i32 1, %44
%46 = load i32, i32* %3
%47 = or i32 %46, %45
store i32 %47, i32* %3
br label %48
48: ; preds = %43, %39
%49 = load i32, i32* %2
%50 = and i32 %49, 32
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = load i32, i32* @LOG_DEBUG
%54 = shl i32 1, %53
%55 = load i32, i32* %3
%56 = or i32 %55, %54
store i32 %56, i32* %3
br label %57
57: ; preds = %52, %48
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@LOG_ALERT = global i32 0
@LOG_ERR = global i32 0
@LOG_WARNING = global i32 0
@LOG_NOTICE = global i32 0
@LOG_INFO = global i32 0
@LOG_DEBUG = global i32 0
define i32 @mask_to_syslog(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
%4 = load i32, i32* @LOG_ALERT
%5 = shl nuw i32 1, %4
%6 = select i1 %3, i32 0, i32 %5
%7 = and i32 %0, 2
%8 = icmp eq i32 %7, 0
%9 = load i32, i32* @LOG_ERR
%10 = shl nuw i32 1, %9
%11 = select i1 %8, i32 0, i32 %10
%12 = or i32 %11, %6
%13 = and i32 %0, 4
%14 = icmp eq i32 %13, 0
%15 = load i32, i32* @LOG_WARNING
%16 = shl nuw i32 1, %15
%17 = select i1 %14, i32 0, i32 %16
%18 = or i32 %12, %17
%19 = and i32 %0, 8
%20 = icmp eq i32 %19, 0
%21 = load i32, i32* @LOG_NOTICE
%22 = shl nuw i32 1, %21
%23 = select i1 %20, i32 0, i32 %22
%24 = or i32 %18, %23
%25 = and i32 %0, 16
%26 = icmp eq i32 %25, 0
%27 = load i32, i32* @LOG_INFO
%28 = shl nuw i32 1, %27
%29 = select i1 %26, i32 0, i32 %28
%30 = or i32 %24, %29
%31 = and i32 %0, 32
%32 = icmp eq i32 %31, 0
%33 = load i32, i32* @LOG_DEBUG
%34 = shl nuw i32 1, %33
%35 = select i1 %32, i32 0, i32 %34
%36 = or i32 %30, %35
ret i32 %36
}