#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 */
#define LOG_ALERT 135
#define LOG_CRIT 134
#define LOG_DEBUG 133
#define LOG_EMERG 132
#define LOG_ERR 131
#define LOG_INFO 130
#define LOG_NOTICE 129
#define LOG_WARNING 128
scalar_t__ strcasecmp(char const *, char const *);
int name_to_priority(const char *name) {
  static const struct {
    const char *name;
    int code;
  } map[] = {
      {"emerg", LOG_EMERG},
      {"emergency", LOG_EMERG},
      {"alert", LOG_ALERT},
      {"crit", LOG_CRIT},
      {"critical", LOG_CRIT},
      {"err", LOG_ERR},
      {"error", LOG_ERR},
      {"warn", LOG_WARNING},
      {"warning", LOG_WARNING},
      {"notice", LOG_NOTICE},
      {"info", LOG_INFO},
      {"debug", LOG_DEBUG},
      {NULL, 0},
  };
  unsigned i = 0;
  while (map[i].name) {
    if (strcasecmp(map[i].name, name) == 0)
      return map[i].code;
    i++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<name_to_priority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2c21(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     1195 <name_to_priority+0x85>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2c04(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1187 <name_to_priority+0x77>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2bdb(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119c <name_to_priority+0x8c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <name_to_priority+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_to_priority>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1237 <name_to_priority+0x127>
lea    0xed3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     123b <name_to_priority+0x12b>
lea    0xec5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1242 <name_to_priority+0x132>
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1249 <name_to_priority+0x139>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1250 <name_to_priority+0x140>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1257 <name_to_priority+0x147>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     125e <name_to_priority+0x14e>
lea    0xe6b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1265 <name_to_priority+0x155>
lea    0xe58(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     126c <name_to_priority+0x15c>
lea    0xe48(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1273 <name_to_priority+0x163>
lea    0xe3b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     127a <name_to_priority+0x16a>
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    128e <name_to_priority+0x17e>
mov    $0xb,%eax
jmp    127f <name_to_priority+0x16f>
xor    %eax,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x1,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x2,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x3,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x4,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x5,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x6,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x7,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x8,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0x9,%eax
jmp    127f <name_to_priority+0x16f>
mov    $0xa,%eax
shl    $0x4,%rax
lea    0x2ac6(%rip),%rcx
mov    0x8(%rax,%rcx,1),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32 }
@name_to_priority.map = internal constant [13 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i32 135 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i32 129 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i32 133 }, %struct.anon zeroinitializer]
@.str = [6 x i8] c"emerg\00"
@.str.1 = [10 x i8] c"emergency\00"
@.str.2 = [6 x i8] c"alert\00"
@.str.3 = [5 x i8] c"crit\00"
@.str.4 = [9 x i8] c"critical\00"
@.str.5 = [4 x i8] c"err\00"
@.str.6 = [6 x i8] c"error\00"
@.str.7 = [5 x i8] c"warn\00"
@.str.8 = [8 x i8] c"warning\00"
@.str.9 = [7 x i8] c"notice\00"
@.str.10 = [5 x i8] c"info\00"
@.str.11 = [6 x i8] c"debug\00"
define i32 @name_to_priority(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %27, %1
%6 = load i32, i32* %4
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds [13 x %struct.anon], [13 x %struct.anon]* @name_to_priority.map, i64 0, i64 %7
%9 = getelementptr inbounds %struct.anon, %struct.anon* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %30
12: ; preds = %5
%13 = load i32, i32* %4
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [13 x %struct.anon], [13 x %struct.anon]* @name_to_priority.map, i64 0, i64 %14
%16 = getelementptr inbounds %struct.anon, %struct.anon* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = load i8*, i8** %3
%19 = call i64 @strcasecmp(i8* %17, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %12
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [13 x %struct.anon], [13 x %struct.anon]* @name_to_priority.map, i64 0, i64 %23
%25 = getelementptr inbounds %struct.anon, %struct.anon* %24, i32 0, i32 1
%26 = load i32, i32* %25
store i32 %26, i32* %2
br label %31
27: ; preds = %12
%28 = load i32, i32* %4
%29 = add i32 %28, 1
store i32 %29, i32* %4
br label %5
30: ; preds = %5
store i32 -1, i32* %2
br label %31
31: ; preds = %30, %21
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
%struct.anon = type { i8*, i32 }
@name_to_priority.map = internal unnamed_addr constant [13 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i32 135 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i32 128 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i32 129 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i32 133 }, %struct.anon zeroinitializer]
@.str = [6 x i8] c"emerg\00"
@.str.1 = [10 x i8] c"emergency\00"
@.str.2 = [6 x i8] c"alert\00"
@.str.3 = [5 x i8] c"crit\00"
@.str.4 = [9 x i8] c"critical\00"
@.str.5 = [4 x i8] c"err\00"
@.str.6 = [6 x i8] c"error\00"
@.str.7 = [5 x i8] c"warn\00"
@.str.8 = [8 x i8] c"warning\00"
@.str.9 = [7 x i8] c"notice\00"
@.str.10 = [5 x i8] c"info\00"
@.str.11 = [6 x i8] c"debug\00"
define i32 @name_to_priority(i8* nocapture %0) {
%2 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %38, %35, %32, %29, %26, %23, %20, %17, %14, %11, %8, %1
%5 = phi i64 [ 0, %1 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ 6, %23 ], [ 7, %26 ], [ 8, %29 ], [ 9, %32 ], [ 10, %35 ], [ 11, %38 ]
%6 = getelementptr inbounds [13 x %struct.anon], [13 x %struct.anon]* @name_to_priority.map, i64 0, i64 %5, i32 1
%7 = load i32, i32* %6
br label %41
8: ; preds = %1
%9 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %8
%12 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %17
%21 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %4, label %26
26: ; preds = %23
%27 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %4, label %29
29: ; preds = %26
%30 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %4, label %32
32: ; preds = %29
%33 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %4, label %35
35: ; preds = %32
%36 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* %0)
%37 = icmp eq i64 %36, 0
br i1 %37, label %4, label %38
38: ; preds = %35
%39 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %4, label %41
41: ; preds = %38, %4
%42 = phi i32 [ %7, %4 ], [ -1, %38 ]
ret i32 %42
}