#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*/ LOG_CRIT;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int LOG_UPTO(int /*<<< orphan*/);
int /*<<< orphan*/ LOG_WARNING;
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int sane_log_level(char *log_level, int *syslog_level) {
  if ((strcasecmp("DEBUG", log_level) == 0)) {
    *syslog_level = LOG_UPTO(LOG_DEBUG);
  } else if ((strcasecmp("INFO", log_level) == 0)) {
    *syslog_level = LOG_UPTO(LOG_INFO);
  } else if ((strcasecmp("WARN", log_level) == 0)) {
    *syslog_level = LOG_UPTO(LOG_WARNING);
  } else if ((strcasecmp("ERROR", log_level) == 0)) {
    *syslog_level = LOG_UPTO(LOG_ERR);
  } else if ((strcasecmp("CRITICAL", log_level) == 0)) {
    *syslog_level = LOG_UPTO(LOG_CRIT);
  } else {
    syslog(LOG_ERR, "Unknown log level!");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sane_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1175 <sane_log_level+0x45>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    127e <sane_log_level+0x14e>
mov    -0x10(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11aa <sane_log_level+0x7a>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1279 <sane_log_level+0x149>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11df <sane_log_level+0xaf>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1274 <sane_log_level+0x144>
mov    -0x10(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1214 <sane_log_level+0xe4>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    126f <sane_log_level+0x13f>
mov    -0x10(%rbp),%rsi
lea    0xdf7(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1249 <sane_log_level+0x119>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    126a <sane_log_level+0x13a>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
call   1050 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1285 <sane_log_level+0x155>
jmp    126f <sane_log_level+0x13f>
jmp    1274 <sane_log_level+0x144>
jmp    1279 <sane_log_level+0x149>
jmp    127e <sane_log_level+0x14e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sane_log_level>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <sane_log_level+0x8a>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c3 <sane_log_level+0x93>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cc <sane_log_level+0x9c>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d5 <sane_log_level+0xa5>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11de <sane_log_level+0xae>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x1,%eax
jmp    11f1 <sane_log_level+0xc1>
mov    0x2e0f(%rip),%rax
jmp    11e5 <sane_log_level+0xb5>
mov    0x2dfe(%rip),%rax
jmp    11e5 <sane_log_level+0xb5>
mov    0x2e0d(%rip),%rax
jmp    11e5 <sane_log_level+0xb5>
mov    0x2ddc(%rip),%rax
jmp    11e5 <sane_log_level+0xb5>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [5 x i8] c"WARN\00"
@LOG_WARNING = global i32 0
@.str.3 = [6 x i8] c"ERROR\00"
@LOG_ERR = global i32 0
@.str.4 = [9 x i8] c"CRITICAL\00"
@LOG_CRIT = global i32 0
@.str.5 = [19 x i8] c"Unknown log level!\00"
define i32 @sane_log_level(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @LOG_DEBUG
%11 = call i32 @LOG_UPTO(i32 %10)
%12 = load i32*, i32** %5
store i32 %11, i32* %12
br label %52
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @LOG_INFO
%19 = call i32 @LOG_UPTO(i32 %18)
%20 = load i32*, i32** %5
store i32 %19, i32* %20
br label %51
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @LOG_WARNING
%27 = call i32 @LOG_UPTO(i32 %26)
%28 = load i32*, i32** %5
store i32 %27, i32* %28
br label %50
29: ; preds = %21
%30 = load i8*, i8** %4
%31 = call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @LOG_ERR
%35 = call i32 @LOG_UPTO(i32 %34)
%36 = load i32*, i32** %5
store i32 %35, i32* %36
br label %49
37: ; preds = %29
%38 = load i8*, i8** %4
%39 = call i64 @strcasecmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* @LOG_CRIT
%43 = call i32 @LOG_UPTO(i32 %42)
%44 = load i32*, i32** %5
store i32 %43, i32* %44
br label %48
45: ; preds = %37
%46 = load i32, i32* @LOG_ERR
%47 = call i32 @syslog(i32 %46, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %53
48: ; preds = %41
br label %49
49: ; preds = %48, %33
br label %50
50: ; preds = %49, %25
br label %51
51: ; preds = %50, %17
br label %52
52: ; preds = %51, %9
store i32 0, i32* %3
br label %53
53: ; preds = %52, %45
%54 = load i32, i32* %3
ret i32 %54
}

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 = [5 x i8] c"WARN\00"
@LOG_WARNING = global i32 0
@.str.3 = [6 x i8] c"ERROR\00"
@LOG_ERR = global i32 0
@.str.4 = [9 x i8] c"CRITICAL\00"
@LOG_CRIT = global i32 0
@.str.5 = [19 x i8] c"Unknown log level!\00"
define i32 @sane_log_level(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @LOG_DEBUG
%7 = tail call i32 @LOG_UPTO(i32 %6)
store i32 %7, i32* %1
br label %35
8: ; preds = %2
%9 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @LOG_INFO
%13 = tail call i32 @LOG_UPTO(i32 %12)
store i32 %13, i32* %1
br label %35
14: ; preds = %8
%15 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @LOG_WARNING
%19 = tail call i32 @LOG_UPTO(i32 %18)
store i32 %19, i32* %1
br label %35
20: ; preds = %14
%21 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @LOG_ERR
%25 = tail call i32 @LOG_UPTO(i32 %24)
store i32 %25, i32* %1
br label %35
26: ; preds = %20
%27 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @LOG_CRIT
%31 = tail call i32 @LOG_UPTO(i32 %30)
store i32 %31, i32* %1
br label %35
32: ; preds = %26
%33 = load i32, i32* @LOG_ERR
%34 = tail call i32 @syslog(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %5, %17, %29, %23, %11, %32
%36 = phi i32 [ 1, %32 ], [ 0, %11 ], [ 0, %23 ], [ 0, %29 ], [ 0, %17 ], [ 0, %5 ]
ret i32 %36
}