#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 */
char *id_to_token(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int);
void ste_error_to_str(int error, char *descr, int size) {
  char *err_txt;
  if (error < 0) {
    strcpy(descr, strerror(error));
    return;
  }
  if (error <= 30) {
    snprintf(descr, size, "'%s' expected", id_to_token(error));
    return;
  }
  switch (error) {
  case 0:
    err_txt = "No error";
    break;
  case 30 + 2:
    err_txt = "Not enough memory";
    break;
  case 30 + 3:
    err_txt = "Parse error";
    break;
  case 30 + 4:
    err_txt = "File not found";
    break;
  case 30 + 5:
    err_txt = "Can't execute";
    break;
  case 30 + 6:
    err_txt = "Invalid type";
    break;
  case 30 + 7:
    err_txt = "Invalid number";
    break;
  case 30 + 8:
    err_txt = "Invalid operation";
    break;
  case 30 + 10:
    err_txt = "Missing Qoute";
    break;
  case 30 + 11:
    err_txt = "Label not found";
    break;
  default:
    err_txt = "Unkown error";
  }
  strcpy(descr, err_txt);
}


x86 assembly (clang, -O0):
<ste_error_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    117d <ste_error_to_str+0x3d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    1295 <ste_error_to_str+0x155>
cmpl   $0x1e,-0x4(%rbp)
jg     11b8 <ste_error_to_str+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <id_to_token@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %rax,%rcx
lea    0xefa(%rip),%rdx
call   1040 <snprintf@plt>
jmp    1295 <ste_error_to_str+0x155>
mov    -0x4(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x29,%rax
ja     127d <ste_error_to_str+0x13d>
mov    -0x40(%rbp),%rax
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xecb(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xecd(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec9(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec8(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec6(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec3(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1288 <ste_error_to_str+0x148>
lea    0xec2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ste_error_to_str>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %edi,%edi
js     1170 <ste_error_to_str+0x30>
cmp    $0x1e,%edi
ja     117d <ste_error_to_str+0x3d>
mov    %edx,%ebp
call   1050 <id_to_token@plt>
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <snprintf@plt>
call   1060 <strerror@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
jmp    11a2 <ste_error_to_str+0x62>
add    $0xffffffe0,%edi
cmp    $0x9,%edi
ja     1198 <ste_error_to_str+0x58>
movslq %edi,%rax
lea    0xf15(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    119f <ste_error_to_str+0x5f>
lea    0xef6(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"'%s' expected\00"
@.str.1 = [9 x i8] c"No error\00"
@.str.2 = [18 x i8] c"Not enough memory\00"
@.str.3 = [12 x i8] c"Parse error\00"
@.str.4 = [15 x i8] c"File not found\00"
@.str.5 = [14 x i8] c"Can't execute\00"
@.str.6 = [13 x i8] c"Invalid type\00"
@.str.7 = [15 x i8] c"Invalid number\00"
@.str.8 = [18 x i8] c"Invalid operation\00"
@.str.9 = [14 x i8] c"Missing Qoute\00"
@.str.10 = [16 x i8] c"Label not found\00"
@.str.11 = [13 x i8] c"Unkown error\00"
define void @ste_error_to_str(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i32, i32* %4
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @strcpy(i8* %11, i8* %13)
br label %41
15: ; preds = %3
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 30
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = call i8* @id_to_token(i32 %21)
%23 = call i32 @snprintf(i8* %19, i32 %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %41
24: ; preds = %15
%25 = load i32, i32* %4
switch i32 %25, label %36 [
i32 0, label %26
i32 32, label %27
i32 33, label %28
i32 34, label %29
i32 35, label %30
i32 36, label %31
i32 37, label %32
i32 38, label %33
i32 40, label %34
i32 41, label %35
]
26: ; preds = %24
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %37
27: ; preds = %24
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %37
28: ; preds = %24
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %37
29: ; preds = %24
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %37
30: ; preds = %24
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %37
31: ; preds = %24
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %37
32: ; preds = %24
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %37
33: ; preds = %24
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %37
34: ; preds = %24
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %7
br label %37
35: ; preds = %24
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8** %7
br label %37
36: ; preds = %24
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8** %7
br label %37
37: ; preds = %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26
%38 = load i8*, i8** %5
%39 = load i8*, i8** %7
%40 = call i32 @strcpy(i8* %38, i8* %39)
br label %41
41: ; preds = %37, %18, %10
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"'%s' expected\00"
@.str.2 = [18 x i8] c"Not enough memory\00"
@.str.3 = [12 x i8] c"Parse error\00"
@.str.4 = [15 x i8] c"File not found\00"
@.str.5 = [14 x i8] c"Can't execute\00"
@.str.6 = [13 x i8] c"Invalid type\00"
@.str.7 = [15 x i8] c"Invalid number\00"
@.str.8 = [18 x i8] c"Invalid operation\00"
@.str.9 = [14 x i8] c"Missing Qoute\00"
@.str.10 = [16 x i8] c"Label not found\00"
@.str.11 = [13 x i8] c"Unkown error\00"
@reltable.ste_error_to_str = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.11 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.10 to i64), i64 ptrtoint ([10 x i32]* @reltable.ste_error_to_str to i64)) to i32)]
define void @ste_error_to_str(i32 %0, i8* %1, i32 %2) {
%4 = icmp slt i32 %0, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i8* @strerror(i32 %0)
%7 = tail call i32 @strcpy(i8* %1, i8* %6)
br label %23
8: ; preds = %3
%9 = icmp ult i32 %0, 31
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i8* @id_to_token(i32 %0)
%12 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %23
13: ; preds = %8
%14 = add i32 %0, -32
%15 = icmp ult i32 %14, 10
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = sext i32 %14 to i64
%18 = shl i64 %17, 2
%19 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.ste_error_to_str to i8*), i64 %18)
br label %20
20: ; preds = %13, %16
%21 = phi i8* [ %19, %16 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), %13 ]
%22 = tail call i32 @strcpy(i8* %1, i8* %21)
br label %23
23: ; preds = %20, %10, %5
ret void
}