#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 uint8_t;

/* Variables and functions */
const char *flash_name(uint8_t flash_type) {
  switch (flash_type) {
  case 4:
    return "MB90F497G";
  case 12:
    return "LPC_IAP";
  case 14:
    return "M32C87_1MB";
  case 16:
    return "LPC23xx_256k";
  case 20:
    return "USB_PRO_FD_Flash";
  case 21:
    return "USB_FD_Flash";
  case 22:
    return "LPC407X_8X";
  case 40:
    return "FLASH_ROUTER_FD";
  default:
    return "unkown";
  }
}


x86 assembly (clang, -O0):
<flash_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x24,%eax
ja     11b0 <flash_name+0xb0>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf5d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf57(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf48(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <flash_name+0xbb>
lea    0xf40(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<flash_name>:
add    $0xfffffffc,%edi
cmp    $0x24,%edi
ja     1127 <flash_name+0x27>
lea    0xf85(%rip),%rax
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf78(%rip),%rax
ret
lea    0xfc9(%rip),%rax
ret
lea    0xf70(%rip),%rax
ret
lea    0xf73(%rip),%rax
ret
lea    0xf78(%rip),%rax
ret
lea    0xf81(%rip),%rax
ret
lea    0xf86(%rip),%rax
ret
lea    0xf89(%rip),%rax
ret

LLVM IR (-O0):
@.str = [10 x i8] c"MB90F497G\00"
@.str.1 = [8 x i8] c"LPC_IAP\00"
@.str.2 = [11 x i8] c"M32C87_1MB\00"
@.str.3 = [13 x i8] c"LPC23xx_256k\00"
@.str.4 = [17 x i8] c"USB_PRO_FD_Flash\00"
@.str.5 = [13 x i8] c"USB_FD_Flash\00"
@.str.6 = [11 x i8] c"LPC407X_8X\00"
@.str.7 = [16 x i8] c"FLASH_ROUTER_FD\00"
@.str.8 = [7 x i8] c"unkown\00"
define i8* @flash_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %13 [
i32 4, label %5
i32 12, label %6
i32 14, label %7
i32 16, label %8
i32 20, label %9
i32 21, label %10
i32 22, label %11
i32 40, label %12
]
5: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %14
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %14
7: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %14
8: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %14
12: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %14
13: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %14
14: ; preds = %13, %12, %11, %10, %9, %8, %7, %6, %5
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@.str = [10 x i8] c"MB90F497G\00"
@.str.1 = [8 x i8] c"LPC_IAP\00"
@.str.2 = [11 x i8] c"M32C87_1MB\00"
@.str.3 = [13 x i8] c"LPC23xx_256k\00"
@.str.4 = [17 x i8] c"USB_PRO_FD_Flash\00"
@.str.5 = [13 x i8] c"USB_FD_Flash\00"
@.str.6 = [11 x i8] c"LPC407X_8X\00"
@.str.7 = [16 x i8] c"FLASH_ROUTER_FD\00"
@.str.8 = [7 x i8] c"unkown\00"
define i8* @flash_name(i32 %0) {
switch i32 %0, label %9 [
i32 4, label %10
i32 12, label %2
i32 14, label %3
i32 16, label %4
i32 20, label %5
i32 21, label %6
i32 22, label %7
i32 40, label %8
]
2: ; preds = %1
br label %10
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %7, %6, %5, %4, %3, %2
%11 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %11
}