#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_CRIT;
int LOG_DEBUG;
int LOG_EMERG;
int LOG_ERR;
int LOG_INFO;
int LOG_NOTICE;
int LOG_WARNING;
scalar_t__ strcmp(char *, char *);
int snoopy_syslog_convert_levelToInt(char *levelStr) {
  char *levelStrAdj;
  int levelInt;
  levelStrAdj = levelStr;
  if ('_' == levelStr[3]) {
    levelStrAdj = &levelStr[4];
  }
  if (strcmp(levelStrAdj, "EMERG") == 0) {
    levelInt = LOG_EMERG;
  } else if (strcmp(levelStrAdj, "ALERT") == 0) {
    levelInt = LOG_ALERT;
  } else if (strcmp(levelStrAdj, "CRIT") == 0) {
    levelInt = LOG_CRIT;
  } else if (strcmp(levelStrAdj, "ERR") == 0) {
    levelInt = LOG_ERR;
  } else if (strcmp(levelStrAdj, "WARNING") == 0) {
    levelInt = LOG_WARNING;
  } else if (strcmp(levelStrAdj, "NOTICE") == 0) {
    levelInt = LOG_NOTICE;
  } else if (strcmp(levelStrAdj, "INFO") == 0) {
    levelInt = LOG_INFO;
  } else if (strcmp(levelStrAdj, "DEBUG") == 0) {
    levelInt = LOG_DEBUG;
  } else {
    levelInt = LOG_INFO;
  }
  return levelInt;
}


x86 assembly (clang, -O0):
<snoopy_syslog_convert_levelToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%ecx
mov    $0x5f,%eax
cmp    %ecx,%eax
jne    1145 <snoopy_syslog_convert_levelToInt+0x35>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1170 <snoopy_syslog_convert_levelToInt+0x60>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12cc <snoopy_syslog_convert_levelToInt+0x1bc>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119b <snoopy_syslog_convert_levelToInt+0x8b>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12c7 <snoopy_syslog_convert_levelToInt+0x1b7>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c6 <snoopy_syslog_convert_levelToInt+0xb6>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12c2 <snoopy_syslog_convert_levelToInt+0x1b2>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <snoopy_syslog_convert_levelToInt+0xe1>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12bd <snoopy_syslog_convert_levelToInt+0x1ad>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121c <snoopy_syslog_convert_levelToInt+0x10c>
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12b8 <snoopy_syslog_convert_levelToInt+0x1a8>
mov    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1247 <snoopy_syslog_convert_levelToInt+0x137>
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12b3 <snoopy_syslog_convert_levelToInt+0x1a3>
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1272 <snoopy_syslog_convert_levelToInt+0x162>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12ae <snoopy_syslog_convert_levelToInt+0x19e>
mov    -0x10(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    129d <snoopy_syslog_convert_levelToInt+0x18d>
mov    0x2d25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12a9 <snoopy_syslog_convert_levelToInt+0x199>
mov    0x2d0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12ae <snoopy_syslog_convert_levelToInt+0x19e>
jmp    12b3 <snoopy_syslog_convert_levelToInt+0x1a3>
jmp    12b8 <snoopy_syslog_convert_levelToInt+0x1a8>
jmp    12bd <snoopy_syslog_convert_levelToInt+0x1ad>
jmp    12c2 <snoopy_syslog_convert_levelToInt+0x1b2>
jmp    12c7 <snoopy_syslog_convert_levelToInt+0x1b7>
jmp    12cc <snoopy_syslog_convert_levelToInt+0x1bc>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snoopy_syslog_convert_levelToInt>:
push   %rbx
xor    %eax,%eax
cmpb   $0x5f,0x3(%rdi)
sete   %al
lea    (%rdi,%rax,4),%rbx
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11cf <snoopy_syslog_convert_levelToInt+0xbf>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d8 <snoopy_syslog_convert_levelToInt+0xc8>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e1 <snoopy_syslog_convert_levelToInt+0xd1>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ea <snoopy_syslog_convert_levelToInt+0xda>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f3 <snoopy_syslog_convert_levelToInt+0xe3>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1205 <snoopy_syslog_convert_levelToInt+0xf5>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fc <snoopy_syslog_convert_levelToInt+0xec>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11fc <snoopy_syslog_convert_levelToInt+0xec>
mov    0x2deb(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2e02(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2e09(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2df8(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2daf(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2dd6(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2dad(%rip),%rax
jmp    120c <snoopy_syslog_convert_levelToInt+0xfc>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"EMERG\00"
@LOG_EMERG = global i32 0
@.str.1 = [6 x i8] c"ALERT\00"
@LOG_ALERT = global i32 0
@.str.2 = [5 x i8] c"CRIT\00"
@LOG_CRIT = global i32 0
@.str.3 = [4 x i8] c"ERR\00"
@LOG_ERR = global i32 0
@.str.4 = [8 x i8] c"WARNING\00"
@LOG_WARNING = global i32 0
@.str.5 = [7 x i8] c"NOTICE\00"
@LOG_NOTICE = global i32 0
@.str.6 = [5 x i8] c"INFO\00"
@LOG_INFO = global i32 0
@.str.7 = [6 x i8] c"DEBUG\00"
@LOG_DEBUG = global i32 0
define i32 @snoopy_syslog_convert_levelToInt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 95, %9
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 4
store i8* %13, i8** %3
br label %14
14: ; preds = %11, %1
%15 = load i8*, i8** %3
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* @LOG_EMERG
store i32 %19, i32* %4
br label %71
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i32, i32* @LOG_ALERT
store i32 %25, i32* %4
br label %70
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* @LOG_CRIT
store i32 %31, i32* %4
br label %69
32: ; preds = %26
%33 = load i8*, i8** %3
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* @LOG_ERR
store i32 %37, i32* %4
br label %68
38: ; preds = %32
%39 = load i8*, i8** %3
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i32, i32* @LOG_WARNING
store i32 %43, i32* %4
br label %67
44: ; preds = %38
%45 = load i8*, i8** %3
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = load i32, i32* @LOG_NOTICE
store i32 %49, i32* %4
br label %66
50: ; preds = %44
%51 = load i8*, i8** %3
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = load i32, i32* @LOG_INFO
store i32 %55, i32* %4
br label %65
56: ; preds = %50
%57 = load i8*, i8** %3
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i32, i32* @LOG_DEBUG
store i32 %61, i32* %4
br label %64
62: ; preds = %56
%63 = load i32, i32* @LOG_INFO
store i32 %63, i32* %4
br label %64
64: ; preds = %62, %60
br label %65
65: ; preds = %64, %54
br label %66
66: ; preds = %65, %48
br label %67
67: ; preds = %66, %42
br label %68
68: ; preds = %67, %36
br label %69
69: ; preds = %68, %30
br label %70
70: ; preds = %69, %24
br label %71
71: ; preds = %70, %18
%72 = load i32, i32* %4
ret i32 %72
}

LLVM IR (-O2):
@.str = [6 x i8] c"EMERG\00"
@LOG_EMERG = global i32 0
@.str.1 = [6 x i8] c"ALERT\00"
@LOG_ALERT = global i32 0
@.str.2 = [5 x i8] c"CRIT\00"
@LOG_CRIT = global i32 0
@.str.3 = [4 x i8] c"ERR\00"
@LOG_ERR = global i32 0
@.str.4 = [8 x i8] c"WARNING\00"
@LOG_WARNING = global i32 0
@.str.5 = [7 x i8] c"NOTICE\00"
@LOG_NOTICE = global i32 0
@.str.6 = [5 x i8] c"INFO\00"
@LOG_INFO = global i32 0
@.str.7 = [6 x i8] c"DEBUG\00"
@LOG_DEBUG = global i32 0
define i32 @snoopy_syslog_convert_levelToInt(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 3
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 95
%5 = select i1 %4, i64 4, i64 0
%6 = getelementptr i8, i8* %0, i64 %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %1
%10 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %31, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %31, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i32* @LOG_DEBUG, i32* @LOG_INFO
br label %31
31: ; preds = %27, %24, %21, %18, %15, %12, %9, %1
%32 = phi i32* [ @LOG_EMERG, %1 ], [ @LOG_ALERT, %9 ], [ @LOG_CRIT, %12 ], [ @LOG_ERR, %15 ], [ @LOG_WARNING, %18 ], [ @LOG_NOTICE, %21 ], [ @LOG_INFO, %24 ], [ %30, %27 ]
%33 = load i32, i32* %32
ret i32 %33
}