#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 */
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char *, unsigned char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *translateErrorCodeToMessage(unsigned char errorCode) {
  char *errorMessage = NULL;
  switch (errorCode) {
  case 0x00:
    errorMessage = "Can only test for equality with strings";
    break;
  case 0x01:
    errorMessage = "Can only test for equality with none";
    break;
  case 0x02:
    errorMessage = "Can only perform addition with strings";
    break;
  case 0x03:
    errorMessage = "Too many array indexes in expression";
    break;
  case 0x04:
    errorMessage = "Not allowed negative array indexes";
    break;
  case 0x05:
    errorMessage =
        "Array index in expression exceeds array size in that dimension";
    break;
  case 0x06:
    errorMessage = "Can only display strings with input statement";
    break;
  case 0x07:
    errorMessage = "Out of shared heap memory for data";
    break;
  case 0x08:
    errorMessage = "Out of core and shared heap memory for data";
    break;
  case 0x09:
    errorMessage = "Out of shared stack memory for data";
    break;
  case 0x0A:
    errorMessage = "Out of core and shared stack memory for data";
    break;
  case 0x0B:
    errorMessage = "Can only send integers and reals between cores";
    break;
  case 0x0C:
    errorMessage = "Attempting to send to non-existent or inactive process";
    break;
  case 0x0D:
    errorMessage = "Attempting to send to inactive core";
    break;
  case 0x0E:
    errorMessage =
        "Attempting to receive from non-existent or inactive process";
    break;
  case 0x0F:
    errorMessage = "Attempting to receive from inactive core";
    break;
  case 0x10:
    errorMessage =
        "Attempting to sendrecv with non-existent or inactive process";
    break;
  case 0x11:
    errorMessage = "Attempting to free non allocated heap memory";
    break;
  case 0x12:
    errorMessage =
        "Incorrect number of parameters provided to native function call";
    break;
  case 0x13:
    errorMessage = "Unknown native command supplied to runtime library";
    break;
  case 0x14:
    errorMessage = "Function called via a variable but this variable is not "
                   "pointing to any function";
    break;
  case 0x15:
    errorMessage = "Message probe and non-blocking send test and wait not "
                   "supported for communications with virtual cores";
    break;
  case 0x16:
    errorMessage = "Non-blocking sends between device and virtual cores on the "
                   "host are not yet supported";
    break;
  }
  if (errorMessage != NULL) {
    char *msgToRet = (char *)malloc(strlen(errorMessage) + 1);
    strcpy(msgToRet, errorMessage);
    return msgToRet;
  } else {
    errorMessage = "Unknown error code of";
    char *msgToRet = (char *)malloc(strlen(errorMessage) + 10);
    sprintf(msgToRet, "%s 0x%x", errorMessage, errorCode);
    return msgToRet;
  }
}


x86 assembly (clang, -O0):
<translateErrorCodeToMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movq   $0x0,-0x18(%rbp)
movzbl -0x9(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x16,%rax
ja     12e7 <translateErrorCodeToMessage+0x1a7>
mov    -0x30(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xef1(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf06(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf1d(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf32(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf45(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf74(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xf92(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xfa5(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xfc1(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xfd5(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0xff2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x1011(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x1038(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x104c(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x1078(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x1091(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x10be(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x10db(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x110b(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x112e(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x116f(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12e7 <translateErrorCodeToMessage+0x1a7>
lea    0x11c5(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1325 <translateErrorCodeToMessage+0x1e5>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1369 <translateErrorCodeToMessage+0x229>
lea    0x11d2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0xa,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0x11bc(%rip),%rsi
movzbl -0x9(%rbp),%ecx
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translateErrorCodeToMessage>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x16,%bpl
ja     117b <translateErrorCodeToMessage+0x3b>
movsbq %bpl,%rax
lea    0x2c12(%rip),%rcx
mov    (%rcx,%rax,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
jmp    11a2 <translateErrorCodeToMessage+0x62>
mov    $0x1f,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movzbl %bpl,%ecx
lea    0x1325(%rip),%rsi
lea    0x1308(%rip),%rdx
mov    %rax,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Can only test for equality with strings\00"
@.str.1 = [37 x i8] c"Can only test for equality with none\00"
@.str.2 = [39 x i8] c"Can only perform addition with strings\00"
@.str.3 = [37 x i8] c"Too many array indexes in expression\00"
@.str.4 = [35 x i8] c"Not allowed negative array indexes\00"
@.str.5 = [63 x i8] c"Array index in expression exceeds array size in that dimension\00"
@.str.6 = [46 x i8] c"Can only display strings with input statement\00"
@.str.7 = [35 x i8] c"Out of shared heap memory for data\00"
@.str.8 = [44 x i8] c"Out of core and shared heap memory for data\00"
@.str.9 = [36 x i8] c"Out of shared stack memory for data\00"
@.str.10 = [45 x i8] c"Out of core and shared stack memory for data\00"
@.str.11 = [47 x i8] c"Can only send integers and reals between cores\00"
@.str.12 = [55 x i8] c"Attempting to send to non-existent or inactive process\00"
@.str.13 = [36 x i8] c"Attempting to send to inactive core\00"
@.str.14 = [60 x i8] c"Attempting to receive from non-existent or inactive process\00"
@.str.15 = [41 x i8] c"Attempting to receive from inactive core\00"
@.str.16 = [61 x i8] c"Attempting to sendrecv with non-existent or inactive process\00"
@.str.17 = [45 x i8] c"Attempting to free non allocated heap memory\00"
@.str.18 = [64 x i8] c"Incorrect number of parameters provided to native function call\00"
@.str.19 = [51 x i8] c"Unknown native command supplied to runtime library\00"
@.str.20 = [81 x i8] c"Function called via a variable but this variable is not pointing to any function\00"
@.str.21 = [102 x i8] c"Message probe and non-blocking send test and wait not supported for communications with virtual cores\00"
@.str.22 = [86 x i8] c"Non-blocking sends between device and virtual cores on the host are not yet supported\00"
@.str.23 = [22 x i8] c"Unknown error code of\00"
@.str.24 = [8 x i8] c"%s 0x%x\00"
define i8* @translateErrorCodeToMessage(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8 %0, i8* %3
store i8* null, i8** %4
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
switch i32 %8, label %32 [
i32 0, label %9
i32 1, label %10
i32 2, label %11
i32 3, label %12
i32 4, label %13
i32 5, label %14
i32 6, label %15
i32 7, label %16
i32 8, label %17
i32 9, label %18
i32 10, label %19
i32 11, label %20
i32 12, label %21
i32 13, label %22
i32 14, label %23
i32 15, label %24
i32 16, label %25
i32 17, label %26
i32 18, label %27
i32 19, label %28
i32 20, label %29
i32 21, label %30
i32 22, label %31
]
9: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8** %4
br label %32
10: ; preds = %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %32
11: ; preds = %1
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %32
12: ; preds = %1
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %32
13: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %32
14: ; preds = %1
store i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i8** %4
br label %32
15: ; preds = %1
store i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8** %4
br label %32
16: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8** %4
br label %32
17: ; preds = %1
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8** %4
br label %32
18: ; preds = %1
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i8** %4
br label %32
19: ; preds = %1
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i8** %4
br label %32
20: ; preds = %1
store i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i8** %4
br label %32
21: ; preds = %1
store i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i8** %4
br label %32
22: ; preds = %1
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8** %4
br label %32
23: ; preds = %1
store i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.14, i64 0, i64 0), i8** %4
br label %32
24: ; preds = %1
store i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i8** %4
br label %32
25: ; preds = %1
store i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.16, i64 0, i64 0), i8** %4
br label %32
26: ; preds = %1
store i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.17, i64 0, i64 0), i8** %4
br label %32
27: ; preds = %1
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.18, i64 0, i64 0), i8** %4
br label %32
28: ; preds = %1
store i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.19, i64 0, i64 0), i8** %4
br label %32
29: ; preds = %1
store i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.20, i64 0, i64 0), i8** %4
br label %32
30: ; preds = %1
store i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.21, i64 0, i64 0), i8** %4
br label %32
31: ; preds = %1
store i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.22, i64 0, i64 0), i8** %4
br label %32
32: ; preds = %1, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9
%33 = load i8*, i8** %4
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i8*, i8** %4
%37 = call i64 @strlen(i8* %36)
%38 = add nsw i64 %37, 1
%39 = call i64 @malloc(i64 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %5
%41 = load i8*, i8** %5
%42 = load i8*, i8** %4
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i8*, i8** %5
store i8* %44, i8** %2
br label %56
45: ; preds = %32
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.23, i64 0, i64 0), i8** %4
%46 = load i8*, i8** %4
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 10
%49 = call i64 @malloc(i64 %48)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %6
%51 = load i8*, i8** %6
%52 = load i8*, i8** %4
%53 = load i8, i8* %3
%54 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0), i8* %52, i8 zeroext %53)
%55 = load i8*, i8** %6
store i8* %55, i8** %2
br label %56
56: ; preds = %45, %35
%57 = load i8*, i8** %2
ret i8* %57
}

LLVM IR (-O2):
@.str = [40 x i8] c"Can only test for equality with strings\00"
@.str.1 = [37 x i8] c"Can only test for equality with none\00"
@.str.2 = [39 x i8] c"Can only perform addition with strings\00"
@.str.3 = [37 x i8] c"Too many array indexes in expression\00"
@.str.4 = [35 x i8] c"Not allowed negative array indexes\00"
@.str.5 = [63 x i8] c"Array index in expression exceeds array size in that dimension\00"
@.str.6 = [46 x i8] c"Can only display strings with input statement\00"
@.str.7 = [35 x i8] c"Out of shared heap memory for data\00"
@.str.8 = [44 x i8] c"Out of core and shared heap memory for data\00"
@.str.9 = [36 x i8] c"Out of shared stack memory for data\00"
@.str.10 = [45 x i8] c"Out of core and shared stack memory for data\00"
@.str.11 = [47 x i8] c"Can only send integers and reals between cores\00"
@.str.12 = [55 x i8] c"Attempting to send to non-existent or inactive process\00"
@.str.13 = [36 x i8] c"Attempting to send to inactive core\00"
@.str.14 = [60 x i8] c"Attempting to receive from non-existent or inactive process\00"
@.str.15 = [41 x i8] c"Attempting to receive from inactive core\00"
@.str.16 = [61 x i8] c"Attempting to sendrecv with non-existent or inactive process\00"
@.str.17 = [45 x i8] c"Attempting to free non allocated heap memory\00"
@.str.18 = [64 x i8] c"Incorrect number of parameters provided to native function call\00"
@.str.19 = [51 x i8] c"Unknown native command supplied to runtime library\00"
@.str.20 = [81 x i8] c"Function called via a variable but this variable is not pointing to any function\00"
@.str.21 = [102 x i8] c"Message probe and non-blocking send test and wait not supported for communications with virtual cores\00"
@.str.22 = [86 x i8] c"Non-blocking sends between device and virtual cores on the host are not yet supported\00"
@.str.23 = [22 x i8] c"Unknown error code of\00"
@.str.24 = [8 x i8] c"%s 0x%x\00"
@switch.table.translateErrorCodeToMessage = [23 x i8*] [i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.22, i64 0, i64 0)]
define i8* @translateErrorCodeToMessage(i8 zeroext %0) {
%2 = icmp ult i8 %0, 23
br i1 %2, label %3, label %12
3: ; preds = %1
%4 = sext i8 %0 to i64
%5 = getelementptr inbounds [23 x i8*], [23 x i8*]* @switch.table.translateErrorCodeToMessage, i64 0, i64 %4
%6 = load i8*, i8** %5
%7 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%8 = add nsw i64 %7, 1
%9 = tail call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @strcpy(i8* %10, i8* %6)
br label %16
12: ; preds = %1
%13 = tail call i64 @malloc(i64 31)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.24, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.23, i64 0, i64 0), i8 zeroext %0)
br label %16
16: ; preds = %12, %3
%17 = phi i8* [ %10, %3 ], [ %14, %12 ]
ret i8* %17
}