#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*/ sprintf(char *, char *, int);
const char *PMI_Err_str(int error) {
  static char str[100];
  switch (error) {
  case 0:
    return "PMI_SUCCESS";
  case -1:
    return "PMI_FAIL";
  case 3:
    return "PMI_ERR_INVALID_ARG";
  case 4:
    return "PMI_ERR_INVALID_KEY";
  case 5:
    return "PMI_ERR_INVALID_KEY_LENGTH";
  case 6:
    return "PMI_ERR_INVALID_VAL";
  case 7:
    return "PMI_ERR_INVALID_VAL_LENGTH";
  case 8:
    return "PMI_ERR_INVALID_LENGTH";
  case 1:
    return "PMI_ERR_INIT";
  case 2:
    return "PMI_ERR_NOMEM";
  }
  sprintf(str, "PMI_ERR_UNKNOWN: %d", error);
  return str;
}


x86 assembly (clang, -O0):
<PMI_Err_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     11e4 <PMI_Err_str+0xd4>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xed2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xed6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xee5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xee9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xef4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xefb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
lea    0xef8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1205 <PMI_Err_str+0xf5>
mov    -0xc(%rbp),%edx
lea    0x2e52(%rip),%rdi
lea    0xeec(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e3f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PMI_Err_str>:
push   %rbx
mov    %edi,%edx
lea    0x1(%rdx),%eax
cmp    $0xa,%eax
jae    112d <PMI_Err_str+0x1d>
cltq
lea    0xfac(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1143 <PMI_Err_str+0x33>
lea    0x2f0c(%rip),%rbx
lea    0xf7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@PMI_Err_str.str = internal global [100 x i8] zeroinitializer
@.str = [12 x i8] c"PMI_SUCCESS\00"
@.str.1 = [9 x i8] c"PMI_FAIL\00"
@.str.2 = [20 x i8] c"PMI_ERR_INVALID_ARG\00"
@.str.3 = [20 x i8] c"PMI_ERR_INVALID_KEY\00"
@.str.4 = [27 x i8] c"PMI_ERR_INVALID_KEY_LENGTH\00"
@.str.5 = [20 x i8] c"PMI_ERR_INVALID_VAL\00"
@.str.6 = [27 x i8] c"PMI_ERR_INVALID_VAL_LENGTH\00"
@.str.7 = [23 x i8] c"PMI_ERR_INVALID_LENGTH\00"
@.str.8 = [13 x i8] c"PMI_ERR_INIT\00"
@.str.9 = [14 x i8] c"PMI_ERR_NOMEM\00"
@.str.10 = [20 x i8] c"PMI_ERR_UNKNOWN: %d\00"
define i8* @PMI_Err_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 0, label %5
i32 -1, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
i32 1, label %13
i32 2, label %14
]
5: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
br label %18
6: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %18
7: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %18
8: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %18
9: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %18
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %18
11: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %18
12: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %18
13: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %18
14: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %18
15: ; preds = %1
%16 = load i32, i32* %3
%17 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @PMI_Err_str.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %16)
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @PMI_Err_str.str, i64 0, i64 0), i8** %2
br label %18
18: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@PMI_Err_str.str = internal global [100 x i8] zeroinitializer
@.str = [12 x i8] c"PMI_SUCCESS\00"
@.str.1 = [9 x i8] c"PMI_FAIL\00"
@.str.2 = [20 x i8] c"PMI_ERR_INVALID_ARG\00"
@.str.3 = [20 x i8] c"PMI_ERR_INVALID_KEY\00"
@.str.4 = [27 x i8] c"PMI_ERR_INVALID_KEY_LENGTH\00"
@.str.5 = [20 x i8] c"PMI_ERR_INVALID_VAL\00"
@.str.6 = [27 x i8] c"PMI_ERR_INVALID_VAL_LENGTH\00"
@.str.7 = [23 x i8] c"PMI_ERR_INVALID_LENGTH\00"
@.str.8 = [13 x i8] c"PMI_ERR_INIT\00"
@.str.9 = [14 x i8] c"PMI_ERR_NOMEM\00"
@.str.10 = [20 x i8] c"PMI_ERR_UNKNOWN: %d\00"
@reltable.PMI_Err_str = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.PMI_Err_str to i64)) to i32)]
define i8* @PMI_Err_str(i32 %0) {
%2 = add i32 %0, 1
%3 = icmp ult i32 %2, 10
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @PMI_Err_str.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %0)
br label %10
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.PMI_Err_str to i8*), i64 %8)
br label %10
10: ; preds = %6, %4
%11 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @PMI_Err_str.str, i64 0, i64 0), %4 ], [ %9, %6 ]
ret i8* %11
}