#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_ALERT;
int LOG_CRIT;
int LOG_DEBUG;
int LOG_EMERG;
int LOG_ERR;
int LOG_INFO;
int LOG_NOTICE;
int LOG_WARNING;
int /*<<< orphan*/ strncmp(char const *, char *, int);
int parse_level(const char *level, int *out) {
  if (!strncmp(level, "emerg", (1024))) {
    *out = LOG_EMERG;
  } else if (!strncmp(level, "alert", (1024))) {
    *out = LOG_ALERT;
  } else if (!strncmp(level, "crit", (1024))) {
    *out = LOG_CRIT;
  } else if (!strncmp(level, "err", (1024))) {
    *out = LOG_ERR;
  } else if (!strncmp(level, "warning", (1024))) {
    *out = LOG_WARNING;
  } else if (!strncmp(level, "notice", (1024))) {
    *out = LOG_NOTICE;
  } else if (!strncmp(level, "info", (1024))) {
    *out = LOG_INFO;
  } else if (!strncmp(level, "debug", (1024))) {
    *out = LOG_DEBUG;
  } else {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1152 <parse_level+0x42>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12df <parse_level+0x1cf>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1184 <parse_level+0x74>
mov    0x2e71(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12da <parse_level+0x1ca>
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b6 <parse_level+0xa6>
mov    0x2e37(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12d5 <parse_level+0x1c5>
mov    -0x10(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e8 <parse_level+0xd8>
mov    0x2dc5(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12d0 <parse_level+0x1c0>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    121a <parse_level+0x10a>
mov    0x2dc3(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12cb <parse_level+0x1bb>
mov    -0x10(%rbp),%rdi
lea    0xdf8(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    124c <parse_level+0x13c>
mov    0x2d81(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12c6 <parse_level+0x1b6>
mov    -0x10(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    127e <parse_level+0x16e>
mov    0x2d3f(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12c1 <parse_level+0x1b1>
mov    -0x10(%rbp),%rdi
lea    0xda0(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12b0 <parse_level+0x1a0>
mov    0x2d15(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12bc <parse_level+0x1ac>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e6 <parse_level+0x1d6>
jmp    12c1 <parse_level+0x1b1>
jmp    12c6 <parse_level+0x1b6>
jmp    12cb <parse_level+0x1bb>
jmp    12d0 <parse_level+0x1c0>
jmp    12d5 <parse_level+0x1c5>
jmp    12da <parse_level+0x1ca>
jmp    12df <parse_level+0x1cf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_level>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f7 <parse_level+0xe7>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1200 <parse_level+0xf0>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1209 <parse_level+0xf9>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1212 <parse_level+0x102>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121b <parse_level+0x10b>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1224 <parse_level+0x114>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     122d <parse_level+0x11d>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
mov    $0x400,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    123b <parse_level+0x12b>
mov    0x2dc3(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2dda(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2de1(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2dd0(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2d87(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2dae(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2d95(%rip),%rax
jmp    1234 <parse_level+0x124>
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"emerg\00"
@LOG_EMERG = global i32 0
@.str.1 = [6 x i8] c"alert\00"
@LOG_ALERT = global i32 0
@.str.2 = [5 x i8] c"crit\00"
@LOG_CRIT = global i32 0
@.str.3 = [4 x i8] c"err\00"
@LOG_ERR = global i32 0
@.str.4 = [8 x i8] c"warning\00"
@LOG_WARNING = global i32 0
@.str.5 = [7 x i8] c"notice\00"
@LOG_NOTICE = global i32 0
@.str.6 = [5 x i8] c"info\00"
@LOG_INFO = global i32 0
@.str.7 = [6 x i8] c"debug\00"
@LOG_DEBUG = global i32 0
define i32 @parse_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 i32 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1024)
%8 = icmp ne i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @LOG_EMERG
%11 = load i32*, i32** %5
store i32 %10, i32* %11
br label %69
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1024)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = load i32, i32* @LOG_ALERT
%18 = load i32*, i32** %5
store i32 %17, i32* %18
br label %68
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = load i32, i32* @LOG_CRIT
%25 = load i32*, i32** %5
store i32 %24, i32* %25
br label %67
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = call i32 @strncmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 1024)
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* @LOG_ERR
%32 = load i32*, i32** %5
store i32 %31, i32* %32
br label %66
33: ; preds = %26
%34 = load i8*, i8** %4
%35 = call i32 @strncmp(i8* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 1024)
%36 = icmp ne i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = load i32, i32* @LOG_WARNING
%39 = load i32*, i32** %5
store i32 %38, i32* %39
br label %65
40: ; preds = %33
%41 = load i8*, i8** %4
%42 = call i32 @strncmp(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 1024)
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %40
%45 = load i32, i32* @LOG_NOTICE
%46 = load i32*, i32** %5
store i32 %45, i32* %46
br label %64
47: ; preds = %40
%48 = load i8*, i8** %4
%49 = call i32 @strncmp(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%50 = icmp ne i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %47
%52 = load i32, i32* @LOG_INFO
%53 = load i32*, i32** %5
store i32 %52, i32* %53
br label %63
54: ; preds = %47
%55 = load i8*, i8** %4
%56 = call i32 @strncmp(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 1024)
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = load i32, i32* @LOG_DEBUG
%60 = load i32*, i32** %5
store i32 %59, i32* %60
br label %62
61: ; preds = %54
store i32 -1, i32* %3
br label %70
62: ; preds = %58
br label %63
63: ; preds = %62, %51
br label %64
64: ; preds = %63, %44
br label %65
65: ; preds = %64, %37
br label %66
66: ; preds = %65, %30
br label %67
67: ; preds = %66, %23
br label %68
68: ; preds = %67, %16
br label %69
69: ; preds = %68, %9
store i32 0, i32* %3
br label %70
70: ; preds = %69, %61
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [6 x i8] c"emerg\00"
@LOG_EMERG = global i32 0
@.str.1 = [6 x i8] c"alert\00"
@LOG_ALERT = global i32 0
@.str.2 = [5 x i8] c"crit\00"
@LOG_CRIT = global i32 0
@.str.3 = [4 x i8] c"err\00"
@LOG_ERR = global i32 0
@.str.4 = [8 x i8] c"warning\00"
@LOG_WARNING = global i32 0
@.str.5 = [7 x i8] c"notice\00"
@LOG_NOTICE = global i32 0
@.str.6 = [5 x i8] c"info\00"
@LOG_INFO = global i32 0
@.str.7 = [6 x i8] c"debug\00"
@LOG_DEBUG = global i32 0
define i32 @parse_level(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1024)
%4 = icmp eq i32 %3, 0
br i1 %4, label %26, label %5
5: ; preds = %2
%6 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1024)
%7 = icmp eq i32 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %5
%9 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%10 = icmp eq i32 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8
%12 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 1024)
%13 = icmp eq i32 %12, 0
br i1 %13, label %26, label %14
14: ; preds = %11
%15 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 1024)
%16 = icmp eq i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %14
%18 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 1024)
%19 = icmp eq i32 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 1024)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23, %20, %17, %14, %11, %8, %5, %2
%27 = phi i32* [ @LOG_EMERG, %2 ], [ @LOG_ALERT, %5 ], [ @LOG_CRIT, %8 ], [ @LOG_ERR, %11 ], [ @LOG_WARNING, %14 ], [ @LOG_NOTICE, %17 ], [ @LOG_INFO, %20 ], [ @LOG_DEBUG, %23 ]
%28 = load i32, i32* %27
store i32 %28, i32* %1
br label %29
29: ; preds = %26, %23
%30 = phi i32 [ -1, %23 ], [ 0, %26 ]
ret i32 %30
}