#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 /*<<< orphan*/ strcasecmp(char *, char *);
int zlog_parse_level(char *levstr) {
  char *level_list[] = {"",     "fatal", "error",   "warning", "notice",
                        "info", "debug", "verbose", 0};
  char *ptr;
  int level_i;
  for (level_i = 1, ptr = level_list[1]; (ptr = level_list[level_i], ptr);
       level_i++) {
    if (!strcasecmp(levstr, ptr)) {
      return level_i;
    }
  }
  return 5;
}


x86 assembly (clang, -O0):
<zlog_parse_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c99(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x6c(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
movslq -0x6c(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     119c <zlog_parse_level+0x7c>
mov    -0x10(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1189 <zlog_parse_level+0x69>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <zlog_parse_level+0x83>
jmp    118e <zlog_parse_level+0x6e>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1150 <zlog_parse_level+0x30>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zlog_parse_level>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11a1 <zlog_parse_level+0x91>
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11a8 <zlog_parse_level+0x98>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11af <zlog_parse_level+0x9f>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11b6 <zlog_parse_level+0xa6>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11bd <zlog_parse_level+0xad>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     11c4 <zlog_parse_level+0xb4>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,1),%eax
add    $0x5,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [6 x i8] c"fatal\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [8 x i8] c"warning\00"
@.str.4 = [7 x i8] c"notice\00"
@.str.5 = [5 x i8] c"info\00"
@.str.6 = [6 x i8] c"debug\00"
@.str.7 = [8 x i8] c"verbose\00"
@__const.zlog_parse_level.level_list = [9 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* null]
define i32 @zlog_parse_level(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [9 x i8*]
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [9 x i8*]* %4 to i8*
store i32 1, i32* %6
%8 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 1
%9 = load i8*, i8** %8
store i8* %9, i8** %5
br label %10
10: ; preds = %25, %1
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 %12
%14 = load i8*, i8** %13
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %28
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = load i8*, i8** %5
%20 = call i32 @strcasecmp(i8* %18, i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = load i32, i32* %6
store i32 %23, i32* %2
br label %29
24: ; preds = %17
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %10
28: ; preds = %10
store i32 5, i32* %2
br label %29
29: ; preds = %28, %22
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"fatal\00"
@.str.2 = [6 x i8] c"error\00"
@.str.3 = [8 x i8] c"warning\00"
@.str.4 = [7 x i8] c"notice\00"
@.str.5 = [5 x i8] c"info\00"
@.str.6 = [6 x i8] c"debug\00"
@.str.7 = [8 x i8] c"verbose\00"
define i32 @zlog_parse_level(i8* nocapture %0) {
%2 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 7, i32 5
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i32 [ 1, %1 ], [ 2, %4 ], [ 3, %7 ], [ 4, %10 ], [ 5, %13 ], [ 6, %16 ], [ %22, %19 ]
ret i32 %24
}