#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 */
typedef int /*<<< orphan*/ error_msg;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void error_exit(unsigned int error_n) {
  char *error_msg[] = {"Unknown error code.\n", "Insufficient memory.\n",
                       "Illegal memory access.\n"};
  unsigned int arr_len = sizeof(error_msg) / sizeof(char *);
  if (error_n >= arr_len)
    error_n = 0;
  fputs(error_msg[error_n], stderr);
  exit(1);
}


x86 assembly (clang, -O0):
<error_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2ccb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cc8(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x24(%rbp),%eax
jb     1166 <error_exit+0x46>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x20(%rbp,%rax,8),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<error_exit>:
push   %rax
xor    %eax,%eax
cmp    $0x3,%edi
cmovb  %edi,%eax
lea    0xf14(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Unknown error code.\0A\00"
@.str.1 = [22 x i8] c"Insufficient memory.\0A\00"
@.str.2 = [24 x i8] c"Illegal memory access.\0A\00"
@__const.error_exit.error_msg = [3 x i8*] [i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i32 0, i32 0)]
@stderr = global i32 0
define void @error_exit(i32 %0) {
%2 = alloca i32
%3 = alloca [3 x i8*]
%4 = alloca i32
store i32 %0, i32* %2
%5 = bitcast [3 x i8*]* %3 to i8*
store i32 3, i32* %4
%6 = load i32, i32* %2
%7 = load i32, i32* %4
%8 = icmp uge i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %10
10: ; preds = %9, %1
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* %14, i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [21 x i8] c"Unknown error code.\0A\00"
@.str.1 = [22 x i8] c"Insufficient memory.\0A\00"
@.str.2 = [24 x i8] c"Illegal memory access.\0A\00"
@reltable.error_exit = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.error_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.error_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.error_exit to i64)) to i32)]
@stderr = global i32 0
define void @error_exit(i32 %0) {
%2 = icmp ugt i32 %0, 2
%3 = select i1 %2, i32 0, i32 %0
%4 = zext i32 %3 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.error_exit to i8*), i64 %5)
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* %6, i32 %7)
%9 = tail call i32 @exit(i32 1)
unreachable
}