#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 */
typedef int /*<<< orphan*/ levels;

/* Variables and functions */
scalar_t__ g_strcasecmp(char const *, char const *);
unsigned int get_log_level(const char *level_str, unsigned int default_level) {
  static const char *levels[] = {"LOG_LEVEL_ALWAYS", "LOG_LEVEL_ERROR",
                                 "LOG_LEVEL_WARNING", "LOG_LEVEL_INFO",
                                 "LOG_LEVEL_DEBUG"};
  unsigned int i;
  if (level_str == 0 || level_str[0] == 0) {
    return default_level;
  }
  for (i = 0; i < (sizeof(levels) / sizeof(*(levels))); ++i) {
    if (g_strcasecmp(levels[i], level_str) == 0) {
      return i;
    }
  }
  return default_level;
}


x86 assembly (clang, -O0):
<get_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113a <get_log_level+0x2a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1145 <get_log_level+0x35>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <get_log_level+0x90>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    $0x5,%rax
jae    119a <get_log_level+0x8a>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
lea    0x2ecb(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <g_strcasecmp@plt>
cmp    $0x0,%rax
jne    1187 <get_log_level+0x77>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a0 <get_log_level+0x90>
jmp    118c <get_log_level+0x7c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <get_log_level+0x3c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_log_level>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
test   %rdi,%rdi
je     11ad <get_log_level+0x9d>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11ad <get_log_level+0x9d>
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     1196 <get_log_level+0x86>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     119a <get_log_level+0x8a>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11a1 <get_log_level+0x91>
lea    0xec6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11a8 <get_log_level+0x98>
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
mov    $0x4,%eax
cmove  %eax,%ebp
jmp    11ad <get_log_level+0x9d>
xor    %ebp,%ebp
jmp    11ad <get_log_level+0x9d>
mov    $0x1,%ebp
jmp    11ad <get_log_level+0x9d>
mov    $0x2,%ebp
jmp    11ad <get_log_level+0x9d>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@get_log_level.levels = internal global [5 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0)]
@.str = [17 x i8] c"LOG_LEVEL_ALWAYS\00"
@.str.1 = [16 x i8] c"LOG_LEVEL_ERROR\00"
@.str.2 = [18 x i8] c"LOG_LEVEL_WARNING\00"
@.str.3 = [15 x i8] c"LOG_LEVEL_INFO\00"
@.str.4 = [16 x i8] c"LOG_LEVEL_DEBUG\00"
define i32 @get_log_level(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9, %2
%16 = load i32, i32* %5
store i32 %16, i32* %3
br label %38
17: ; preds = %9
store i32 0, i32* %6
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %6
%20 = zext i32 %19 to i64
%21 = icmp ult i64 %20, 5
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* @get_log_level.levels, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = load i8*, i8** %4
%28 = call i64 @g_strcasecmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = load i32, i32* %6
store i32 %31, i32* %3
br label %38
32: ; preds = %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
%35 = add i32 %34, 1
store i32 %35, i32* %6
br label %18
36: ; preds = %18
%37 = load i32, i32* %5
store i32 %37, i32* %3
br label %38
38: ; preds = %36, %30, %15
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"LOG_LEVEL_ALWAYS\00"
@.str.1 = [16 x i8] c"LOG_LEVEL_ERROR\00"
@.str.2 = [18 x i8] c"LOG_LEVEL_WARNING\00"
@.str.3 = [15 x i8] c"LOG_LEVEL_INFO\00"
@.str.4 = [16 x i8] c"LOG_LEVEL_DEBUG\00"
define i32 @get_log_level(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = tail call i64 @g_strcasecmp(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %7
%11 = tail call i64 @g_strcasecmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %10
%14 = tail call i64 @g_strcasecmp(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = tail call i64 @g_strcasecmp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = tail call i64 @g_strcasecmp(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i32 4, i32 %1
br label %23
23: ; preds = %19, %7, %10, %13, %16, %2, %4
%24 = phi i32 [ %1, %4 ], [ %1, %2 ], [ 0, %7 ], [ 1, %10 ], [ 2, %13 ], [ 3, %16 ], [ %22, %19 ]
ret i32 %24
}