#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*/ printf(char *, char *);
void print_errcode(int code) {
  static char *err_list[] = {"OK",
                             "ERROR: File error",
                             "ERROR: Does not exist",
                             "ERROR: Not found",
                             "ERROR: Corrupt",
                             "ERROR: Failed",
                             "ERROR: Already loaded",
                             "ERROR: Not Implemented",
                             "ERROR: Name Clash",
                             "ERROR: Invalid Argument"};
  printf("%s\n", err_list[code]);
}


x86 assembly (clang, -O0):
<print_errcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2f0a(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xf7f(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_errcode>:
movslq %edi,%rax
lea    0xee6(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0xfb0(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@print_errcode.err_list = internal global [10 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i32 0, i32 0)]
@.str = [3 x i8] c"OK\00"
@.str.1 = [18 x i8] c"ERROR: File error\00"
@.str.2 = [22 x i8] c"ERROR: Does not exist\00"
@.str.3 = [17 x i8] c"ERROR: Not found\00"
@.str.4 = [15 x i8] c"ERROR: Corrupt\00"
@.str.5 = [14 x i8] c"ERROR: Failed\00"
@.str.6 = [22 x i8] c"ERROR: Already loaded\00"
@.str.7 = [23 x i8] c"ERROR: Not Implemented\00"
@.str.8 = [18 x i8] c"ERROR: Name Clash\00"
@.str.9 = [24 x i8] c"ERROR: Invalid Argument\00"
@.str.10 = [4 x i8] c"%s\0A\00"
define void @print_errcode(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [10 x i8*], [10 x i8*]* @print_errcode.err_list, i64 0, i64 %4
%6 = load i8*, i8** %5
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %6)
ret void
}

LLVM IR (-O2):
@reltable.print_errcode = internal unnamed_addr constant [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.print_errcode to i64)) to i32)]
@.str = [3 x i8] c"OK\00"
@.str.1 = [18 x i8] c"ERROR: File error\00"
@.str.2 = [22 x i8] c"ERROR: Does not exist\00"
@.str.3 = [17 x i8] c"ERROR: Not found\00"
@.str.4 = [15 x i8] c"ERROR: Corrupt\00"
@.str.5 = [14 x i8] c"ERROR: Failed\00"
@.str.6 = [22 x i8] c"ERROR: Already loaded\00"
@.str.7 = [23 x i8] c"ERROR: Not Implemented\00"
@.str.8 = [18 x i8] c"ERROR: Name Clash\00"
@.str.9 = [24 x i8] c"ERROR: Invalid Argument\00"
@.str.10 = [4 x i8] c"%s\0A\00"
define void @print_errcode(i32 %0) {
%2 = sext i32 %0 to i64
%3 = shl i64 %2, 2
%4 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.print_errcode to i8*), i64 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %4)
ret void
}