#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_AUTH 145
#define LOG_CRON 144
#define LOG_DAEMON 143
#define LOG_FTP 142
#define LOG_KERN 141
#define LOG_LOCAL0 140
#define LOG_LOCAL1 139
#define LOG_LOCAL2 138
#define LOG_LOCAL3 137
#define LOG_LOCAL4 136
#define LOG_LOCAL5 135
#define LOG_LOCAL6 134
#define LOG_LOCAL7 133
#define LOG_LPR 132
#define LOG_MAIL 131
#define LOG_NEWS 130
#define LOG_USER 129
#define LOG_UUCP 128
scalar_t__ strcasecmp(char const *, char const *);
int name_to_facility(const char *name) {
  static const struct {
    const char *name;
    int code;
  } map[] = {
      {"auth", LOG_AUTH},     {"cron", LOG_CRON},
      {"daemon", LOG_DAEMON}, {"ftp", LOG_FTP},
      {"kern", LOG_KERN},     {"kernel", LOG_KERN},
      {"local0", LOG_LOCAL0}, {"local1", LOG_LOCAL1},
      {"local2", LOG_LOCAL2}, {"local3", LOG_LOCAL3},
      {"local4", LOG_LOCAL4}, {"local5", LOG_LOCAL5},
      {"local6", LOG_LOCAL6}, {"local7", LOG_LOCAL7},
      {"lpr", LOG_LPR},       {"print", LOG_LPR},
      {"printer", LOG_LPR},   {"mail", LOG_MAIL},
      {"news", LOG_NEWS},     {"user", LOG_USER},
      {"uucp", LOG_UUCP},     {NULL, 0},
  };
  unsigned i = 0;
  while (map[i].name) {
    if (strcasecmp(name, map[i].name) == 0)
      return map[i].code;
    i++;
  }
  return -1;
}


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

x86 assembly (clang, -O2):
<name_to_facility>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x8,%ebx
lea    0x2b9c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x8(%rbx,%r15,1),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1156 <name_to_facility+0x46>
add    $0x10,%rbx
cmp    $0x158,%rbx
jne    1130 <name_to_facility+0x20>
mov    $0xffffffff,%eax
jmp    115a <name_to_facility+0x4a>
mov    (%rbx,%r15,1),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32 }
@name_to_facility.map = internal constant [22 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 145 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 144 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i32 143 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 142 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i32 141 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i32 141 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i32 140 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i32 139 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i32 138 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i32 137 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0), i32 136 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i32 135 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i32 0, i32 0), i32 133 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i32 0, i32 0), i32 129 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i32 0, i32 0), i32 128 }, %struct.anon zeroinitializer]
@.str = [5 x i8] c"auth\00"
@.str.1 = [5 x i8] c"cron\00"
@.str.2 = [7 x i8] c"daemon\00"
@.str.3 = [4 x i8] c"ftp\00"
@.str.4 = [5 x i8] c"kern\00"
@.str.5 = [7 x i8] c"kernel\00"
@.str.6 = [7 x i8] c"local0\00"
@.str.7 = [7 x i8] c"local1\00"
@.str.8 = [7 x i8] c"local2\00"
@.str.9 = [7 x i8] c"local3\00"
@.str.10 = [7 x i8] c"local4\00"
@.str.11 = [7 x i8] c"local5\00"
@.str.12 = [7 x i8] c"local6\00"
@.str.13 = [7 x i8] c"local7\00"
@.str.14 = [4 x i8] c"lpr\00"
@.str.15 = [6 x i8] c"print\00"
@.str.16 = [8 x i8] c"printer\00"
@.str.17 = [5 x i8] c"mail\00"
@.str.18 = [5 x i8] c"news\00"
@.str.19 = [5 x i8] c"user\00"
@.str.20 = [5 x i8] c"uucp\00"
define i32 @name_to_facility(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 [22 x %struct.anon], [22 x %struct.anon]* @name_to_facility.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 i8*, i8** %3
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [22 x %struct.anon], [22 x %struct.anon]* @name_to_facility.map, i64 0, i64 %15
%17 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i64 @strcasecmp(i8* %13, 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 [22 x %struct.anon], [22 x %struct.anon]* @name_to_facility.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_facility.map = internal unnamed_addr constant [22 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i32 145 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 144 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i32 143 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 142 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i32 141 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i32 141 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i32 140 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i32 139 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i32 138 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i32 137 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0), i32 136 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i32 135 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i32 0, i32 0), i32 134 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i32 0, i32 0), i32 133 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i32 0, i32 0), i32 132 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i32 131 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i32 0, i32 0), i32 130 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i32 0, i32 0), i32 129 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i32 0, i32 0), i32 128 }, %struct.anon zeroinitializer]
@.str = [5 x i8] c"auth\00"
@.str.1 = [5 x i8] c"cron\00"
@.str.2 = [7 x i8] c"daemon\00"
@.str.3 = [4 x i8] c"ftp\00"
@.str.4 = [5 x i8] c"kern\00"
@.str.5 = [7 x i8] c"kernel\00"
@.str.6 = [7 x i8] c"local0\00"
@.str.7 = [7 x i8] c"local1\00"
@.str.8 = [7 x i8] c"local2\00"
@.str.9 = [7 x i8] c"local3\00"
@.str.10 = [7 x i8] c"local4\00"
@.str.11 = [7 x i8] c"local5\00"
@.str.12 = [7 x i8] c"local6\00"
@.str.13 = [7 x i8] c"local7\00"
@.str.14 = [4 x i8] c"lpr\00"
@.str.15 = [6 x i8] c"print\00"
@.str.16 = [8 x i8] c"printer\00"
@.str.17 = [5 x i8] c"mail\00"
@.str.18 = [5 x i8] c"news\00"
@.str.19 = [5 x i8] c"user\00"
@.str.20 = [5 x i8] c"uucp\00"
define i32 @name_to_facility(i8* nocapture %0) {
br label %2
2: ; preds = %1, %12
%3 = phi i64 [ 0, %1 ], [ %13, %12 ]
%4 = getelementptr inbounds [22 x %struct.anon], [22 x %struct.anon]* @name_to_facility.map, i64 0, i64 %3, i32 0
%5 = load i8*, i8** %4
%6 = tail call i64 @strcasecmp(i8* %0, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = and i64 %3, 4294967295
%10 = getelementptr inbounds [22 x %struct.anon], [22 x %struct.anon]* @name_to_facility.map, i64 0, i64 %9, i32 1
%11 = load i32, i32* %10
br label %15
12: ; preds = %2
%13 = add nuw nsw i64 %3, 1
%14 = icmp eq i64 %13, 21
br i1 %14, label %15, label %2
15: ; preds = %12, %8
%16 = phi i32 [ %11, %8 ], [ -1, %12 ]
ret i32 %16
}