#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 prio_to_syslog(int prio) {
  switch (prio) {
  case 0:
    return LOG_ALERT;
  case 1:
    return LOG_ERR;
  case 2:
    return LOG_WARNING;
  case 3:
    return LOG_NOTICE;
  case 4:
    return LOG_INFO;
  case 5:
    return LOG_DEBUG;
  }
  return -1;
}


x86 assembly (clang, -O0):
<prio_to_syslog>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     1192 <prio_to_syslog+0x92>
mov    -0x10(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <prio_to_syslog+0x99>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<prio_to_syslog>:
cmp    $0x5,%edi
ja     1121 <prio_to_syslog+0x21>
mov    %edi,%eax
lea    0xef2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2eca(%rip),%rax
mov    (%rax),%eax
ret
mov    $0xffffffff,%eax
ret
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e72(%rip),%rax
mov    (%rax),%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 @prio_to_syslog(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
5: ; preds = %1
%6 = load i32, i32* @LOG_ALERT
store i32 %6, i32* %2
br label %18
7: ; preds = %1
%8 = load i32, i32* @LOG_ERR
store i32 %8, i32* %2
br label %18
9: ; preds = %1
%10 = load i32, i32* @LOG_WARNING
store i32 %10, i32* %2
br label %18
11: ; preds = %1
%12 = load i32, i32* @LOG_NOTICE
store i32 %12, i32* %2
br label %18
13: ; preds = %1
%14 = load i32, i32* @LOG_INFO
store i32 %14, i32* %2
br label %18
15: ; preds = %1
%16 = load i32, i32* @LOG_DEBUG
store i32 %16, i32* %2
br label %18
17: ; preds = %1
store i32 -1, i32* %2
br label %18
18: ; preds = %17, %15, %13, %11, %9, %7, %5
%19 = load i32, i32* %2
ret i32 %19
}

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 @prio_to_syslog(i32 %0) {
switch i32 %0, label %14 [
i32 0, label %2
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
]
2: ; preds = %1
%3 = load i32, i32* @LOG_ALERT
br label %14
4: ; preds = %1
%5 = load i32, i32* @LOG_ERR
br label %14
6: ; preds = %1
%7 = load i32, i32* @LOG_WARNING
br label %14
8: ; preds = %1
%9 = load i32, i32* @LOG_NOTICE
br label %14
10: ; preds = %1
%11 = load i32, i32* @LOG_INFO
br label %14
12: ; preds = %1
%13 = load i32, i32* @LOG_DEBUG
br label %14
14: ; preds = %1, %12, %10, %8, %6, %4, %2
%15 = phi i32 [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ], [ -1, %1 ]
ret i32 %15
}