#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 */
char fgaj_normalize_level(char);
char *flu_sprintf(char *, char);
char *fgaj_level_to_string(char level) {
  level = fgaj_normalize_level(level);
  if (level == 10)
    return "TRACE";
  if (level == 20)
    return "DEBUG";
  if (level == 30)
    return "INFO";
  if (level == 40)
    return "WARN";
  if (level == 50)
    return "ERROR";
  return flu_sprintf("%d", level);
}


x86 assembly (clang, -O0):
<fgaj_level_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <fgaj_normalize_level@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1157 <fgaj_level_to_string+0x37>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <fgaj_level_to_string+0xbf>
movsbl -0x9(%rbp),%eax
cmp    $0x14,%eax
jne    1174 <fgaj_level_to_string+0x54>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <fgaj_level_to_string+0xbf>
movsbl -0x9(%rbp),%eax
cmp    $0x1e,%eax
jne    1191 <fgaj_level_to_string+0x71>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <fgaj_level_to_string+0xbf>
movsbl -0x9(%rbp),%eax
cmp    $0x28,%eax
jne    11ae <fgaj_level_to_string+0x8e>
lea    0xe6c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <fgaj_level_to_string+0xbf>
movsbl -0x9(%rbp),%eax
cmp    $0x32,%eax
jne    11cb <fgaj_level_to_string+0xab>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <fgaj_level_to_string+0xbf>
lea    0xe4a(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <flu_sprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgaj_level_to_string>:
push   %rax
call   1040 <fgaj_normalize_level@plt>
mov    %eax,%ecx
lea    -0xa(%rcx),%edx
cmp    $0x28,%dl
ja     1153 <fgaj_level_to_string+0x33>
lea    0xf6d(%rip),%rax
movzbl %dl,%edx
lea    0xebf(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
lea    0xf59(%rip),%rax
pop    %rcx
ret
movsbl %cl,%esi
lea    0xf63(%rip),%rdi
pop    %rax
jmp    1030 <flu_sprintf@plt>
lea    0xf46(%rip),%rax
pop    %rcx
ret
lea    0xf42(%rip),%rax
pop    %rcx
ret
lea    0xf3e(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"TRACE\00"
@.str.1 = [6 x i8] c"DEBUG\00"
@.str.2 = [5 x i8] c"INFO\00"
@.str.3 = [5 x i8] c"WARN\00"
@.str.4 = [6 x i8] c"ERROR\00"
@.str.5 = [3 x i8] c"%d\00"
define i8* @fgaj_level_to_string(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call signext i8 @fgaj_normalize_level(i8 signext %4)
store i8 %5, i8* %3
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 10
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %33
10: ; preds = %1
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %33
15: ; preds = %10
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 30
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %33
20: ; preds = %15
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 40
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %33
25: ; preds = %20
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 50
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %33
30: ; preds = %25
%31 = load i8, i8* %3
%32 = call i8* @flu_sprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8 signext %31)
store i8* %32, i8** %2
br label %33
33: ; preds = %30, %29, %24, %19, %14, %9
%34 = load i8*, i8** %2
ret i8* %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"TRACE\00"
@.str.1 = [6 x i8] c"DEBUG\00"
@.str.2 = [5 x i8] c"INFO\00"
@.str.3 = [5 x i8] c"WARN\00"
@.str.4 = [6 x i8] c"ERROR\00"
@.str.5 = [3 x i8] c"%d\00"
define i8* @fgaj_level_to_string(i8 signext %0) {
%2 = tail call signext i8 @fgaj_normalize_level(i8 signext %0)
switch i8 %2, label %7 [
i8 10, label %9
i8 20, label %3
i8 30, label %4
i8 40, label %5
i8 50, label %6
]
3: ; preds = %1
br label %9
4: ; preds = %1
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
%8 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8 signext %2)
br label %9
9: ; preds = %1, %7, %6, %5, %4, %3
%10 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %6 ], [ %8, %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %10
}