#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
int log_lookup_loglevel(const char *name) {
  int retval = 0;
  if (!strcmp(name, "fatal")) {
    retval = 0;
  } else if (!strcmp(name, "error")) {
    retval = 1;
  } else if (!strcmp(name, "warning")) {
    retval = 2;
  } else if (!strcmp(name, "info")) {
    retval = 3;
  } else if (!strcmp(name, "debug")) {
    retval = 4;
  } else {
    fprintf(stderr, "Loglevel not found %s\n:", name);
  }
  return retval;
}


x86 assembly (clang, -O0):
<log_lookup_loglevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1158 <log_lookup_loglevel+0x38>
movl   $0x0,-0xc(%rbp)
jmp    1219 <log_lookup_loglevel+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117d <log_lookup_loglevel+0x5d>
movl   $0x1,-0xc(%rbp)
jmp    1214 <log_lookup_loglevel+0xf4>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a2 <log_lookup_loglevel+0x82>
movl   $0x2,-0xc(%rbp)
jmp    120f <log_lookup_loglevel+0xef>
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <log_lookup_loglevel+0xa7>
movl   $0x3,-0xc(%rbp)
jmp    120a <log_lookup_loglevel+0xea>
mov    -0x8(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ec <log_lookup_loglevel+0xcc>
movl   $0x4,-0xc(%rbp)
jmp    1205 <log_lookup_loglevel+0xe5>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe1f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    120a <log_lookup_loglevel+0xea>
jmp    120f <log_lookup_loglevel+0xef>
jmp    1214 <log_lookup_loglevel+0xf4>
jmp    1219 <log_lookup_loglevel+0xf9>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_lookup_loglevel>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11bc <log_lookup_loglevel+0x9c>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a2 <log_lookup_loglevel+0x82>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a9 <log_lookup_loglevel+0x89>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b0 <log_lookup_loglevel+0x90>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b7 <log_lookup_loglevel+0x97>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
jmp    11bc <log_lookup_loglevel+0x9c>
mov    $0x1,%ebp
jmp    11bc <log_lookup_loglevel+0x9c>
mov    $0x2,%ebp
jmp    11bc <log_lookup_loglevel+0x9c>
mov    $0x3,%ebp
jmp    11bc <log_lookup_loglevel+0x9c>
mov    $0x4,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"fatal\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [8 x i8] c"warning\00"
@.str.3 = [5 x i8] c"info\00"
@.str.4 = [6 x i8] c"debug\00"
@stderr = global i32 0
@.str.5 = [24 x i8] c"Loglevel not found %s\0A:\00"
define i32 @log_lookup_loglevel(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %3
br label %36
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 1, i32* %3
br label %35
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 2, i32* %3
br label %34
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 3, i32* %3
br label %33
23: ; preds = %18
%24 = load i8*, i8** %2
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 4, i32* %3
br label %32
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %2
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %27
br label %33
33: ; preds = %32, %22
br label %34
34: ; preds = %33, %17
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35, %7
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"fatal\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [8 x i8] c"warning\00"
@.str.3 = [5 x i8] c"info\00"
@.str.4 = [6 x i8] c"debug\00"
@stderr = global i32 0
@.str.5 = [24 x i8] c"Loglevel not found %s\0A:\00"
define i32 @log_lookup_loglevel(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %13, %10, %7, %4, %1, %16
%20 = phi i32 [ 0, %16 ], [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ]
ret i32 %20
}