#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void error_exit(int error_nr) {
  static char *error_msg[] = {
      "Invalid error number.\n", "Error 1: To much data.\n",
      "Error 2: Not enough memory.\n", "Error 3: No data.\n"};
  if (error_nr < 1 || error_nr > 3)
    error_nr = 0;
  fputs(error_msg[error_nr], stderr);
  exit(error_nr);
}


x86 assembly (clang, -O0):
<error_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     113f <error_exit+0x1f>
cmpl   $0x3,-0x4(%rbp)
jle    1146 <error_exit+0x26>
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2eef(%rip),%rax
mov    (%rax,%rcx,8),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    -0x4(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<error_exit>:
push   %rbx
mov    %edi,%ebx
lea    -0x4(%rbx),%eax
xor    %ecx,%ecx
cmp    $0xfffffffd,%eax
cmovb  %ecx,%ebx
lea    0xecb(%rip),%rax
movslq (%rax,%rbx,4),%rdi
add    %rax,%rdi
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    %ebx,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@error_exit.error_msg = internal global [4 x i8*] [i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0)]
@.str = [23 x i8] c"Invalid error number.\0A\00"
@.str.1 = [24 x i8] c"Error 1: To much data.\0A\00"
@.str.2 = [29 x i8] c"Error 2: Not enough memory.\0A\00"
@.str.3 = [19 x i8] c"Error 3: No data.\0A\00"
@stderr = global i32 0
define void @error_exit(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 1
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 3
br i1 %7, label %8, label %9
8: ; preds = %5, %1
store i32 0, i32* %2
br label %9
9: ; preds = %8, %5
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* @error_exit.error_msg, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* %13, i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @exit(i32 %16)
unreachable
}

LLVM IR (-O2):
@reltable.error_exit = internal unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.error_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.error_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.error_exit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.error_exit to i64)) to i32)]
@.str = [23 x i8] c"Invalid error number.\0A\00"
@.str.1 = [24 x i8] c"Error 1: To much data.\0A\00"
@.str.2 = [29 x i8] c"Error 2: Not enough memory.\0A\00"
@.str.3 = [19 x i8] c"Error 3: No data.\0A\00"
@stderr = global i32 0
define void @error_exit(i32 %0) {
%2 = add i32 %0, -4
%3 = icmp ult i32 %2, -3
%4 = select i1 %3, i32 0, i32 %0
%5 = zext i32 %4 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.error_exit to i8*), i64 %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputs(i8* %7, i32 %8)
%10 = tail call i32 @exit(i32 %4)
unreachable
}