#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
const char *region_name(int region_type) {
  static const char *regions[5] = {"Flash Descriptor", "BIOS", "Intel ME",
                                   "GbE", "Platform Data"};
  if (region_type < 0 || region_type > 4) {
    fprintf(stderr, "Invalid region type.\n");
    exit(EXIT_FAILURE);
  }
  return regions[region_type];
}


x86 assembly (clang, -O0):
<region_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     113f <region_name+0x1f>
cmpl   $0x4,-0x4(%rbp)
jle    1162 <region_name+0x42>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xee2(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
movslq -0x4(%rbp),%rcx
lea    0x2ed3(%rip),%rax
mov    (%rax,%rcx,8),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<region_name>:
push   %rax
cmp    $0x5,%edi
jae    1138 <region_name+0x18>
mov    %edi,%eax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xefd(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@region_name.regions = internal global [5 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0)]
@.str = [17 x i8] c"Flash Descriptor\00"
@.str.1 = [5 x i8] c"BIOS\00"
@.str.2 = [9 x i8] c"Intel ME\00"
@.str.3 = [4 x i8] c"GbE\00"
@.str.4 = [14 x i8] c"Platform Data\00"
@stderr = global i32 0
@.str.5 = [22 x i8] c"Invalid region type.\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @region_name(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 4
br i1 %7, label %8, label %13
8: ; preds = %5, %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %5
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* @region_name.regions, i64 0, i64 %15
%17 = load i8*, i8** %16
ret i8* %17
}

LLVM IR (-O2):
@reltable.region_name = internal unnamed_addr constant [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str to i64), i64 ptrtoint ([5 x i32]* @reltable.region_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.region_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.region_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.region_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.region_name to i64)) to i32)]
@.str = [17 x i8] c"Flash Descriptor\00"
@.str.1 = [5 x i8] c"BIOS\00"
@.str.2 = [9 x i8] c"Intel ME\00"
@.str.3 = [4 x i8] c"GbE\00"
@.str.4 = [14 x i8] c"Platform Data\00"
@stderr = global i32 0
@.str.5 = [22 x i8] c"Invalid region type.\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @region_name(i32 %0) {
%2 = icmp ugt i32 %0, 4
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
%9 = zext i32 %0 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.region_name to i8*), i64 %10)
ret i8* %11
}