#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*/ perror(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int getLogLevel(char *levelInfo, int logLevel) {
  switch (logLevel) {
  case 1:
    strcpy(levelInfo, "DEBUG");
    break;
  case 2:
    strcpy(levelInfo, "INFO");
    break;
  case 3:
    strcpy(levelInfo, "WARN");
    break;
  case 4:
    strcpy(levelInfo, "ERROR");
    break;
  default:
    perror("error log level!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<getLogLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11ac <getLogLevel+0x8c>
mov    -0x18(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b8 <getLogLevel+0x98>
mov    -0x8(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b8 <getLogLevel+0x98>
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b8 <getLogLevel+0x98>
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b8 <getLogLevel+0x98>
lea    0xe73(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLogLevel>:
push   %rax
add    $0xffffffff,%esi
cmp    $0x3,%esi
ja     1164 <getLogLevel+0x44>
lea    0xed0(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xed0(%rip),%rsi
jmp    115b <getLogLevel+0x3b>
lea    0xecd(%rip),%rsi
jmp    115b <getLogLevel+0x3b>
lea    0xec9(%rip),%rsi
jmp    115b <getLogLevel+0x3b>
lea    0xec5(%rip),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xebb(%rip),%rdi
call   1040 <perror@plt>
jmp    1160 <getLogLevel+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"DEBUG\00"
@.str.1 = [5 x i8] c"INFO\00"
@.str.2 = [5 x i8] c"WARN\00"
@.str.3 = [6 x i8] c"ERROR\00"
@.str.4 = [17 x i8] c"error log level!\00"
define i32 @getLogLevel(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %18 [
i32 1, label %6
i32 2, label %9
i32 3, label %12
i32 4, label %15
]
6: ; preds = %2
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %20
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %20
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %20
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %12, %9, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"DEBUG\00"
@.str.1 = [5 x i8] c"INFO\00"
@.str.2 = [5 x i8] c"WARN\00"
@.str.3 = [6 x i8] c"ERROR\00"
@.str.4 = [17 x i8] c"error log level!\00"
define i32 @getLogLevel(i8* %0, i32 %1) {
switch i32 %1, label %11 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
i32 4, label %9
]
3: ; preds = %2
%4 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %2
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %13
7: ; preds = %2
%8 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %13
9: ; preds = %2
%10 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %13
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5, %3
ret i32 0
}