#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 */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
char *type_to_str(int32_t type) {
  static char buffer[10];
  switch (type) {
  case 0x1:
    memcpy(buffer, "String", 7);
    break;
  case 0x2:
    memcpy(buffer, "Integer", 8);
    break;
  case 0x3:
    memcpy(buffer, "Func", 5);
    break;
  case 0x4:
    memcpy(buffer, "Extern", 7);
    break;
  default:
    memcpy(buffer, "Unkown", 7);
    break;
  }
  return buffer;
}


x86 assembly (clang, -O0):
<type_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11b8 <type_to_str+0xa8>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x2ede(%rip),%rdi
lea    0xebe(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
jmp    11d0 <type_to_str+0xc0>
lea    0x2ec1(%rip),%rdi
lea    0xea8(%rip),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
jmp    11d0 <type_to_str+0xc0>
lea    0x2ea4(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
jmp    11d0 <type_to_str+0xc0>
lea    0x2e87(%rip),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
jmp    11d0 <type_to_str+0xc0>
lea    0x2e6a(%rip),%rdi
lea    0xe65(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
lea    0x2e52(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type_to_str>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1139 <type_to_str+0x29>
lea    0xee0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0x2ef9(%rip),%rdi
lea    0xed9(%rip),%rsi
jmp    1181 <type_to_str+0x71>
lea    0x2ee9(%rip),%rdi
lea    0xee4(%rip),%rsi
jmp    1181 <type_to_str+0x71>
lea    0x2ed9(%rip),%rdi
lea    0xec0(%rip),%rsi
mov    $0x8,%edx
jmp    1186 <type_to_str+0x76>
lea    0x2ec4(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x5,%edx
jmp    1186 <type_to_str+0x76>
lea    0x2eaf(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x7,%edx
call   1030 <memcpy@plt>
lea    0x2e97(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@type_to_str.buffer = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c"String\00"
@.str.1 = [8 x i8] c"Integer\00"
@.str.2 = [5 x i8] c"Func\00"
@.str.3 = [7 x i8] c"Extern\00"
@.str.4 = [7 x i8] c"Unkown\00"
define i8* @type_to_str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %12 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
]
4: ; preds = %1
%5 = call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
br label %14
6: ; preds = %1
%7 = call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 8)
br label %14
8: ; preds = %1
%9 = call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5)
br label %14
10: ; preds = %1
%11 = call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 7)
br label %14
12: ; preds = %1
%13 = call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 7)
br label %14
14: ; preds = %12, %10, %8, %6, %4
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@type_to_str.buffer = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c"String\00"
@.str.1 = [8 x i8] c"Integer\00"
@.str.2 = [5 x i8] c"Func\00"
@.str.3 = [7 x i8] c"Extern\00"
@.str.4 = [7 x i8] c"Unkown\00"
define i8* @type_to_str(i32 %0) {
switch i32 %0, label %10 [
i32 1, label %2
i32 2, label %4
i32 3, label %6
i32 4, label %8
]
2: ; preds = %1
%3 = tail call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
br label %12
4: ; preds = %1
%5 = tail call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 8)
br label %12
6: ; preds = %1
%7 = tail call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5)
br label %12
8: ; preds = %1
%9 = tail call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 7)
br label %12
10: ; preds = %1
%11 = tail call i32 @memcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 7)
br label %12
12: ; preds = %10, %8, %6, %4, %2
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @type_to_str.buffer, i64 0, i64 0)
}