#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);
char *rpn_err_to_string(int errcode) {
  static char _mesg[32];
  char *_err_mesg;
  switch (errcode) {
  case (-2):
    _err_mesg = "invalid element";
    break;
  case (-1):
    _err_mesg = "error";
    break;
  case (0):
    _err_mesg = "OK";
    break;
  case (1):
    _err_mesg = "invalid stack";
    break;
  case (2):
    _err_mesg = "invalid string";
    break;
  case (3):
    _err_mesg = "invalid X";
    break;
  case (4):
    _err_mesg = "invalid Y";
    break;
  case (10):
    _err_mesg = "too big";
    break;
  case (9):
    _err_mesg = "invalid types";
    break;
  case (11):
    _err_mesg = "not enough elements";
    break;
  case (12):
    _err_mesg = "incompatible elements";
    break;
  case (6):
    _err_mesg = "invalid X type";
    break;
  case (7):
    _err_mesg = "invalid Y type";
    break;
  case (14):
    _err_mesg = "no start marker";
    break;
  case (13):
    _err_mesg = "incompatible dimensions";
    break;
  default:
    sprintf(_mesg, "UNKNOWN ERROR CODE (%d)", errcode);
    _err_mesg = _mesg;
    break;
  }
  return _err_mesg;
}


x86 assembly (clang, -O0):
<rpn_err_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x10,%eax
ja     1234 <rpn_err_to_string+0x124>
mov    -0x18(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xef9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xeef(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xee2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xee0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xedf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed3(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xec9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed3(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1255 <rpn_err_to_string+0x145>
mov    -0x4(%rbp),%edx
lea    0x2e02(%rip),%rdi
lea    0xecf(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2def(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpn_err_to_string>:
push   %rbx
mov    %edi,%edx
lea    0x2(%rdx),%eax
cmp    $0x11,%eax
jae    1125 <rpn_err_to_string+0x15>
mov    $0x1fb7f,%ecx
bt     %eax,%ecx
jb     113d <rpn_err_to_string+0x2d>
lea    0x2f14(%rip),%rbx
lea    0xf9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
jmp    114d <rpn_err_to_string+0x3d>
cltq
lea    0xfa2(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@rpn_err_to_string._mesg = internal global [32 x i8] zeroinitializer
@.str = [16 x i8] c"invalid element\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [14 x i8] c"invalid stack\00"
@.str.4 = [15 x i8] c"invalid string\00"
@.str.5 = [10 x i8] c"invalid X\00"
@.str.6 = [10 x i8] c"invalid Y\00"
@.str.7 = [8 x i8] c"too big\00"
@.str.8 = [14 x i8] c"invalid types\00"
@.str.9 = [20 x i8] c"not enough elements\00"
@.str.10 = [22 x i8] c"incompatible elements\00"
@.str.11 = [15 x i8] c"invalid X type\00"
@.str.12 = [15 x i8] c"invalid Y type\00"
@.str.13 = [16 x i8] c"no start marker\00"
@.str.14 = [24 x i8] c"incompatible dimensions\00"
@.str.15 = [24 x i8] c"UNKNOWN ERROR CODE (%d)\00"
define i8* @rpn_err_to_string(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %20 [
i32 -2, label %5
i32 -1, label %6
i32 0, label %7
i32 1, label %8
i32 2, label %9
i32 3, label %10
i32 4, label %11
i32 10, label %12
i32 9, label %13
i32 11, label %14
i32 12, label %15
i32 6, label %16
i32 7, label %17
i32 14, label %18
i32 13, label %19
]
5: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %3
br label %23
6: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %23
7: ; preds = %1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %23
8: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %23
9: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %23
10: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %23
11: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %23
12: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %23
13: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %23
14: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %23
15: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %23
16: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %23
17: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %23
18: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %23
19: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8** %3
br label %23
20: ; preds = %1
%21 = load i32, i32* %2
%22 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rpn_err_to_string._mesg, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %21)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @rpn_err_to_string._mesg, i64 0, i64 0), i8** %3
br label %23
23: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
@rpn_err_to_string._mesg = internal global [32 x i8] zeroinitializer
@.str = [16 x i8] c"invalid element\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [14 x i8] c"invalid stack\00"
@.str.4 = [15 x i8] c"invalid string\00"
@.str.5 = [10 x i8] c"invalid X\00"
@.str.6 = [10 x i8] c"invalid Y\00"
@.str.7 = [8 x i8] c"too big\00"
@.str.8 = [14 x i8] c"invalid types\00"
@.str.9 = [20 x i8] c"not enough elements\00"
@.str.10 = [22 x i8] c"incompatible elements\00"
@.str.11 = [15 x i8] c"invalid X type\00"
@.str.12 = [15 x i8] c"invalid Y type\00"
@.str.13 = [16 x i8] c"no start marker\00"
@.str.14 = [24 x i8] c"incompatible dimensions\00"
@.str.15 = [24 x i8] c"UNKNOWN ERROR CODE (%d)\00"
@reltable.rpn_err_to_string = [17 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.4 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.12 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.8 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.9 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.10 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.14 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.13 to i64), i64 ptrtoint ([17 x i32]* @reltable.rpn_err_to_string to i64)) to i32)]
define i8* @rpn_err_to_string(i32 %0) {
%2 = add i32 %0, 2
%3 = icmp ult i32 %2, 17
br i1 %3, label %6, label %4
4: ; preds = %6, %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @rpn_err_to_string._mesg, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %0)
br label %14
6: ; preds = %1
%7 = lshr i32 129919, %2
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %6
%11 = sext i32 %2 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([17 x i32]* @reltable.rpn_err_to_string to i8*), i64 %12)
br label %14
14: ; preds = %10, %4
%15 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @rpn_err_to_string._mesg, i64 0, i64 0), %4 ], [ %13, %10 ]
ret i8* %15
}