#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_CRIT;
int LOG_DEBUG;
int LOG_EMERG;
int LOG_ERR;
int LOG_INFO;
int LOG_WARNING;
scalar_t__ strncmp(char const *, char *, int);
int sbus_translate_log_level(const char *str_log_level) {
  int level;
  if (strncmp(str_log_level, "DEBUG", 5) == 0)
    level = LOG_DEBUG;
  else if (strncmp(str_log_level, "INFO", 4) == 0)
    level = LOG_INFO;
  else if (strncmp(str_log_level, "WARNING", 7) == 0)
    level = LOG_WARNING;
  else if (strncmp(str_log_level, "CRITICAL", 8) == 0)
    level = LOG_CRIT;
  else if (strncmp(str_log_level, "OFF", 3) == 0)
    level = LOG_EMERG;
  else
    level = LOG_ERR;
  return level;
}


x86 assembly (clang, -O0):
<sbus_translate_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    114c <sbus_translate_log_level+0x3c>
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    122c <sbus_translate_log_level+0x11c>
mov    -0x8(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    117c <sbus_translate_log_level+0x6c>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    1227 <sbus_translate_log_level+0x117>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ac <sbus_translate_log_level+0x9c>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    1222 <sbus_translate_log_level+0x112>
mov    -0x8(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11dc <sbus_translate_log_level+0xcc>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    121d <sbus_translate_log_level+0x10d>
mov    -0x8(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    120c <sbus_translate_log_level+0xfc>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    1218 <sbus_translate_log_level+0x108>
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    121d <sbus_translate_log_level+0x10d>
jmp    1222 <sbus_translate_log_level+0x112>
jmp    1227 <sbus_translate_log_level+0x117>
jmp    122c <sbus_translate_log_level+0x11c>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sbus_translate_log_level>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1197 <sbus_translate_log_level+0x87>
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a0 <sbus_translate_log_level+0x90>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11a9 <sbus_translate_log_level+0x99>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b2 <sbus_translate_log_level+0xa2>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11bb <sbus_translate_log_level+0xab>
mov    0x2e4b(%rip),%rax
jmp    11c2 <sbus_translate_log_level+0xb2>
mov    0x2e2a(%rip),%rax
jmp    11c2 <sbus_translate_log_level+0xb2>
mov    0x2e19(%rip),%rax
jmp    11c2 <sbus_translate_log_level+0xb2>
mov    0x2e28(%rip),%rax
jmp    11c2 <sbus_translate_log_level+0xb2>
mov    0x2e2f(%rip),%rax
jmp    11c2 <sbus_translate_log_level+0xb2>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"DEBUG\00"
@LOG_DEBUG = global i32 0
@.str.1 = [5 x i8] c"INFO\00"
@LOG_INFO = global i32 0
@.str.2 = [8 x i8] c"WARNING\00"
@LOG_WARNING = global i32 0
@.str.3 = [9 x i8] c"CRITICAL\00"
@LOG_CRIT = global i32 0
@.str.4 = [4 x i8] c"OFF\00"
@LOG_EMERG = global i32 0
@LOG_ERR = global i32 0
define i32 @sbus_translate_log_level(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @LOG_DEBUG
store i32 %8, i32* %3
br label %39
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @LOG_INFO
store i32 %14, i32* %3
br label %38
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* @LOG_WARNING
store i32 %20, i32* %3
br label %37
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* @LOG_CRIT
store i32 %26, i32* %3
br label %36
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* @LOG_EMERG
store i32 %32, i32* %3
br label %35
33: ; preds = %27
%34 = load i32, i32* @LOG_ERR
store i32 %34, i32* %3
br label %35
35: ; preds = %33, %31
br label %36
36: ; preds = %35, %25
br label %37
37: ; preds = %36, %19
br label %38
38: ; preds = %37, %13
br label %39
39: ; preds = %38, %7
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [6 x i8] c"DEBUG\00"
@LOG_DEBUG = global i32 0
@.str.1 = [5 x i8] c"INFO\00"
@LOG_INFO = global i32 0
@.str.2 = [8 x i8] c"WARNING\00"
@LOG_WARNING = global i32 0
@.str.3 = [9 x i8] c"CRITICAL\00"
@LOG_CRIT = global i32 0
@.str.4 = [4 x i8] c"OFF\00"
@LOG_EMERG = global i32 0
@LOG_ERR = global i32 0
define i32 @sbus_translate_log_level(i8* %0) {
%2 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i64 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i32* @LOG_EMERG, i32* @LOG_ERR
br label %17
17: ; preds = %13, %10, %7, %4, %1
%18 = phi i32* [ @LOG_DEBUG, %1 ], [ @LOG_INFO, %4 ], [ @LOG_WARNING, %7 ], [ @LOG_CRIT, %10 ], [ %16, %13 ]
%19 = load i32, i32* %18
ret i32 %19
}