#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 */
scalar_t__ strlen(char const *);
int /*<<< orphan*/ strncasecmp(char const *, char *, scalar_t__);
int log_get_level_str(const char *str) {
  if (!str || strlen(str) == 0)
    return 4;
  if (!strncasecmp(str, "debug", strlen("debug")))
    return 1;
  if (!strncasecmp(str, "verbose", strlen("verbose")))
    return 2;
  if (!strncasecmp(str, "info", strlen("info")))
    return 3;
  if (!strncasecmp(str, "warn", strlen("warn")) ||
      !strncasecmp(str, "warning", strlen("warning")))
    return 4;
  if (!strncasecmp(str, "error", strlen("error")) ||
      !strncasecmp(str, "err", strlen("err")))
    return 5;
  if (!strncasecmp(str, "msg", strlen("msg")) ||
      !strncasecmp(str, "message", strlen("message")))
    return 99;
  return 4;
}


x86 assembly (clang, -O0):
<log_get_level_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114a <log_get_level_str+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1156 <log_get_level_str+0x36>
movl   $0x4,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rdx
lea    0xe88(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1192 <log_get_level_str+0x72>
movl   $0x1,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe65(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe52(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11ce <log_get_level_str+0xae>
movl   $0x2,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xe31(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xe1e(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    120a <log_get_level_str+0xea>
movl   $0x3,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xdfa(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rdx
lea    0xde7(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     126a <log_get_level_str+0x14a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xdcf(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rdx
lea    0xdbc(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1276 <log_get_level_str+0x156>
movl   $0x4,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xd9b(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xd88(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     12d6 <log_get_level_str+0x1b6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xd71(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
lea    0xd5e(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    12e2 <log_get_level_str+0x1c2>
movl   $0x5,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xd39(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xd26(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     1342 <log_get_level_str+0x222>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xd0d(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rdx
lea    0xcfa(%rip),%rsi
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    134e <log_get_level_str+0x22e>
movl   $0x63,-0x4(%rbp)
jmp    1355 <log_get_level_str+0x235>
movl   $0x4,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_get_level_str>:
push   %rbp
push   %rbx
push   %rax
mov    $0x4,%ebp
test   %rdi,%rdi
je     123e <log_get_level_str+0x12e>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     123e <log_get_level_str+0x12e>
lea    0xecc(%rip),%rsi
mov    $0x5,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     122b <log_get_level_str+0x11b>
lea    0xeb6(%rip),%rsi
mov    $0x7,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1232 <log_get_level_str+0x122>
lea    0xea2(%rip),%rsi
mov    $0x4,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1239 <log_get_level_str+0x129>
lea    0xe8b(%rip),%rsi
mov    $0x4,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     123e <log_get_level_str+0x12e>
lea    0xe74(%rip),%rsi
mov    $0x7,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     123e <log_get_level_str+0x12e>
lea    0xe60(%rip),%rsi
mov    $0x5,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
mov    $0x5,%ebp
test   %eax,%eax
je     123e <log_get_level_str+0x12e>
lea    0xe49(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     123e <log_get_level_str+0x12e>
lea    0xe35(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
je     1247 <log_get_level_str+0x137>
lea    0xe21(%rip),%rsi
mov    $0x7,%edx
mov    %rbx,%rdi
call   1030 <strncasecmp@plt>
test   %eax,%eax
mov    $0x63,%eax
mov    $0x4,%ebp
cmove  %eax,%ebp
jmp    123e <log_get_level_str+0x12e>
mov    $0x1,%ebp
jmp    123e <log_get_level_str+0x12e>
mov    $0x2,%ebp
jmp    123e <log_get_level_str+0x12e>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x63,%ebp
jmp    123e <log_get_level_str+0x12e>

LLVM IR (-O0):
@.str = [6 x i8] c"debug\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [5 x i8] c"warn\00"
@.str.4 = [8 x i8] c"warning\00"
@.str.5 = [6 x i8] c"error\00"
@.str.6 = [4 x i8] c"err\00"
@.str.7 = [4 x i8] c"msg\00"
@.str.8 = [8 x i8] c"message\00"
define i32 @log_get_level_str(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6, %1
store i32 4, i32* %2
br label %63
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = call i64 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @strncasecmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %11
store i32 1, i32* %2
br label %63
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @strncasecmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %17
store i32 2, i32* %2
br label %63
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @strncasecmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %23
store i32 3, i32* %2
br label %63
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @strncasecmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 @strncasecmp(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %34, %29
store i32 4, i32* %2
br label %63
40: ; preds = %34
%41 = load i8*, i8** %3
%42 = call i64 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 @strncasecmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %40
%46 = load i8*, i8** %3
%47 = call i64 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 @strncasecmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %45, %40
store i32 5, i32* %2
br label %63
51: ; preds = %45
%52 = load i8*, i8** %3
%53 = call i64 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 @strncasecmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %51
%57 = load i8*, i8** %3
%58 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%59 = call i32 @strncasecmp(i8* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i64 %58)
%60 = icmp ne i32 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %56, %51
store i32 99, i32* %2
br label %63
62: ; preds = %56
store i32 4, i32* %2
br label %63
63: ; preds = %62, %61, %50, %39, %28, %22, %16, %10
%64 = load i32, i32* %2
ret i32 %64
}

LLVM IR (-O2):
@.str = [6 x i8] c"debug\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [5 x i8] c"warn\00"
@.str.4 = [8 x i8] c"warning\00"
@.str.5 = [6 x i8] c"error\00"
@.str.6 = [4 x i8] c"err\00"
@.str.7 = [4 x i8] c"msg\00"
@.str.8 = [8 x i8] c"message\00"
define i32 @log_get_level_str(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %34, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %34, label %6
6: ; preds = %3
%7 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %34, label %9
9: ; preds = %6
%10 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %34, label %12
12: ; preds = %9
%13 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 4)
%14 = icmp eq i32 %13, 0
br i1 %14, label %34, label %15
15: ; preds = %12
%16 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %34, label %18
18: ; preds = %15
%19 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 7)
%20 = icmp eq i32 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %18
%22 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i64 5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %34, label %24
24: ; preds = %21
%25 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i64 3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i64 7)
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i32 99, i32 4
br label %34
34: ; preds = %30, %27, %21, %24, %15, %18, %12, %9, %6, %1, %3
%35 = phi i32 [ 4, %3 ], [ 4, %1 ], [ 1, %6 ], [ 2, %9 ], [ 3, %12 ], [ 4, %18 ], [ 4, %15 ], [ 5, %24 ], [ 5, %21 ], [ 99, %27 ], [ %33, %30 ]
ret i32 %35
}