#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 */
scalar_t__ g_strcasecmp(char *, char *);
int log_text2level(char *buf) {
  if (0 == g_strcasecmp(buf, "0") || 0 == g_strcasecmp(buf, "core")) {
    return 0;
  } else if (0 == g_strcasecmp(buf, "1") || 0 == g_strcasecmp(buf, "error")) {
    return 1;
  } else if (0 == g_strcasecmp(buf, "2") || 0 == g_strcasecmp(buf, "warn") ||
             0 == g_strcasecmp(buf, "warning")) {
    return 2;
  } else if (0 == g_strcasecmp(buf, "3") || 0 == g_strcasecmp(buf, "info")) {
    return 3;
  }
  return 4;
}


x86 assembly (clang, -O0):
<log_text2level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1158 <log_text2level+0x48>
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1164 <log_text2level+0x54>
movl   $0x0,-0x4(%rbp)
jmp    1270 <log_text2level+0x160>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11a0 <log_text2level+0x90>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11ac <log_text2level+0x9c>
movl   $0x1,-0x4(%rbp)
jmp    1270 <log_text2level+0x160>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1206 <log_text2level+0xf6>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1206 <log_text2level+0xf6>
mov    -0x10(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1212 <log_text2level+0x102>
movl   $0x2,-0x4(%rbp)
jmp    1270 <log_text2level+0x160>
mov    -0x10(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     124e <log_text2level+0x13e>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1030 <g_strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    125a <log_text2level+0x14a>
movl   $0x3,-0x4(%rbp)
jmp    1270 <log_text2level+0x160>
jmp    125f <log_text2level+0x14f>
jmp    1264 <log_text2level+0x154>
jmp    1269 <log_text2level+0x159>
movl   $0x4,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_text2level>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
call   1030 <g_strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11ed <log_text2level+0xdd>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
test   %rax,%rax
je     11e8 <log_text2level+0xd8>
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <g_strcasecmp@plt>
cmp    $0x1,%rax
mov    $0x4,%ebp
sbb    $0x0,%ebp
jmp    11ed <log_text2level+0xdd>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [5 x i8] c"core\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [6 x i8] c"error\00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [5 x i8] c"warn\00"
@.str.6 = [8 x i8] c"warning\00"
@.str.7 = [2 x i8] c"3\00"
@.str.8 = [5 x i8] c"info\00"
define i32 @log_text2level(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @g_strcasecmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 0, %5
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @g_strcasecmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 0, %9
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 0, i32* %2
br label %47
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @g_strcasecmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 0, %14
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i64 @g_strcasecmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 0, %18
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i32 1, i32* %2
br label %47
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i64 @g_strcasecmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 0, %23
br i1 %24, label %33, label %25
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = call i64 @g_strcasecmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 0, %27
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = call i64 @g_strcasecmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 0, %31
br i1 %32, label %33, label %34
33: ; preds = %29, %25, %21
store i32 2, i32* %2
br label %47
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = call i64 @g_strcasecmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%37 = icmp eq i64 0, %36
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = call i64 @g_strcasecmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%41 = icmp eq i64 0, %40
br i1 %41, label %42, label %43
42: ; preds = %38, %34
store i32 3, i32* %2
br label %47
43: ; preds = %38
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
store i32 4, i32* %2
br label %47
47: ; preds = %46, %42, %33, %20, %11
%48 = load i32, i32* %2
ret i32 %48
}

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