#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
void throw_error(int error_code) {
  char message[80] = "";
  switch (error_code) {
  case 2:
    strcpy(message, "Stack overflow.");
    break;
  case 3:
    strcpy(message, "Invalid syntax, or tried to pop empty stack.");
    break;
  case 4:
    strcpy(message, "Division by 0");
    break;
  case 5:
    strcpy(message, "Invalid character was entered.");
    break;
  case 6:
    strcpy(message, "Last character can't be a number.");
    break;
  }
  fprintf(stderr, "> ERROR: %s\n\n", message);
  exit(1);
}


x86 assembly (clang, -O0):
<throw_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x20(%rbp)
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x68(%rbp)
sub    $0x4,%eax
ja     11df <throw_error+0xaf>
mov    -0x68(%rbp),%rax
lea    0xe8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x60(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11df <throw_error+0xaf>
lea    -0x60(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11df <throw_error+0xaf>
lea    -0x60(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11df <throw_error+0xaf>
lea    -0x60(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11df <throw_error+0xaf>
lea    -0x60(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rdx
lea    0xead(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<throw_error>:
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
add    $0xfffffffe,%edi
cmp    $0x4,%edi
ja     1170 <throw_error+0x40>
movslq %edi,%rax
lea    0xf3b(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xf0c(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"Stack overflow.\00"
@.str.1 = [45 x i8] c"Invalid syntax, or tried to pop empty stack.\00"
@.str.2 = [14 x i8] c"Division by 0\00"
@.str.3 = [31 x i8] c"Invalid character was entered.\00"
@.str.4 = [34 x i8] c"Last character can't be a number.\00"
@stderr = global i32 0
@.str.5 = [14 x i8] c"> ERROR: %s\0A\0A\00"
define void @throw_error(i32 %0) {
%2 = alloca i32
%3 = alloca [80 x i8]
store i32 %0, i32* %2
%4 = bitcast [80 x i8]* %3 to i8*
%5 = load i32, i32* %2
switch i32 %5, label %21 [
i32 2, label %6
i32 3, label %9
i32 4, label %12
i32 5, label %15
i32 6, label %18
]
6: ; preds = %1
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %21
12: ; preds = %1
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %21
15: ; preds = %1
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %21
18: ; preds = %1
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %1, %18, %15, %12, %9, %6
%22 = load i32, i32* @stderr
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [16 x i8] c"Stack overflow.\00"
@.str.1 = [45 x i8] c"Invalid syntax, or tried to pop empty stack.\00"
@.str.2 = [14 x i8] c"Division by 0\00"
@.str.3 = [31 x i8] c"Invalid character was entered.\00"
@.str.4 = [34 x i8] c"Last character can't be a number.\00"
@stderr = global i32 0
@.str.5 = [14 x i8] c"> ERROR: %s\0A\0A\00"
@reltable.throw_error = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([5 x i32]* @reltable.throw_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.throw_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.throw_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.throw_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.throw_error to i64)) to i32)]
define void @throw_error(i32 %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = add i32 %0, -2
%5 = icmp ult i32 %4, 5
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.throw_error to i8*), i64 %8)
%10 = call i32 @strcpy(i8* %3, i8* %9)
br label %11
11: ; preds = %1, %6
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%14 = call i32 @exit(i32 1)
unreachable
}