const char *errtostr(int err) {
  static const char *errstr[] = {
      "Success",
      "SSID cannot accommodate the service set",
      "Socket error",
      "Not enough memory",
      "SSID too long",
      "Set SSID error",
      "Error in getting the next SDE packet info",
      "Error in handling an SDE packet",
      "Error in taking an SDE packet",
      "Error in removing an SDE packet",
      "Error in sending SDE metadata response",
      "Error in creating metadata packets",
      "Error in extracting metadata from service list",
      "Error in creating service description packets",
      "Error in extracting service description from service list",
      "Error in loading published service DB",
      "Error in adding a service at the front",
      "Error in saving a service list",
      "Error in counting services in a service list",
      "Invalid service position in the SSID",
      "Error in counting enabled services in a service list",
      "URI is mandatory in creating a service",
      "Error in creating a tmp service list table",
      "Cannot increment service positions",
      "Cannot decrement service positions",
      "Error in adding a service at the back",
      "Error in inserting a service",
      "Error in replacing a service",
      "Error in deleting a service",
      "Error in deleting all services",
      "Index is outside range",
      "Cannot ensure inc_dec_pos",
      "Error in retrieving a service",
      "Error in reloading service list",
      "Error in loading category list",
      "Error in parsing data",
      "Error in the DB",
      "Error in updating the category list",
      "Error in loading flat category list",
      "Invalid program state",
  };
  return errstr[err];
}


x86 assembly (clang, -O0):
<errtostr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2f1e(%rip),%rax
mov    (%rax,%rcx,8),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<errtostr>:
movslq %edi,%rax
lea    0xef6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@errtostr.errstr = internal global [40 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.32, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.33, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.34, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.35, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.36, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.37, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.38, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.39, i32 0, i32 0)]
@.str = [8 x i8] c"Success\00"
@.str.1 = [40 x i8] c"SSID cannot accommodate the service set\00"
@.str.2 = [13 x i8] c"Socket error\00"
@.str.3 = [18 x i8] c"Not enough memory\00"
@.str.4 = [14 x i8] c"SSID too long\00"
@.str.5 = [15 x i8] c"Set SSID error\00"
@.str.6 = [42 x i8] c"Error in getting the next SDE packet info\00"
@.str.7 = [32 x i8] c"Error in handling an SDE packet\00"
@.str.8 = [30 x i8] c"Error in taking an SDE packet\00"
@.str.9 = [32 x i8] c"Error in removing an SDE packet\00"
@.str.10 = [39 x i8] c"Error in sending SDE metadata response\00"
@.str.11 = [35 x i8] c"Error in creating metadata packets\00"
@.str.12 = [47 x i8] c"Error in extracting metadata from service list\00"
@.str.13 = [46 x i8] c"Error in creating service description packets\00"
@.str.14 = [58 x i8] c"Error in extracting service description from service list\00"
@.str.15 = [38 x i8] c"Error in loading published service DB\00"
@.str.16 = [39 x i8] c"Error in adding a service at the front\00"
@.str.17 = [31 x i8] c"Error in saving a service list\00"
@.str.18 = [45 x i8] c"Error in counting services in a service list\00"
@.str.19 = [37 x i8] c"Invalid service position in the SSID\00"
@.str.20 = [53 x i8] c"Error in counting enabled services in a service list\00"
@.str.21 = [39 x i8] c"URI is mandatory in creating a service\00"
@.str.22 = [43 x i8] c"Error in creating a tmp service list table\00"
@.str.23 = [35 x i8] c"Cannot increment service positions\00"
@.str.24 = [35 x i8] c"Cannot decrement service positions\00"
@.str.25 = [38 x i8] c"Error in adding a service at the back\00"
@.str.26 = [29 x i8] c"Error in inserting a service\00"
@.str.27 = [29 x i8] c"Error in replacing a service\00"
@.str.28 = [28 x i8] c"Error in deleting a service\00"
@.str.29 = [31 x i8] c"Error in deleting all services\00"
@.str.30 = [23 x i8] c"Index is outside range\00"
@.str.31 = [26 x i8] c"Cannot ensure inc_dec_pos\00"
@.str.32 = [30 x i8] c"Error in retrieving a service\00"
@.str.33 = [32 x i8] c"Error in reloading service list\00"
@.str.34 = [31 x i8] c"Error in loading category list\00"
@.str.35 = [22 x i8] c"Error in parsing data\00"
@.str.36 = [16 x i8] c"Error in the DB\00"
@.str.37 = [36 x i8] c"Error in updating the category list\00"
@.str.38 = [36 x i8] c"Error in loading flat category list\00"
@.str.39 = [22 x i8] c"Invalid program state\00"
define i8* @errtostr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [40 x i8*], [40 x i8*]* @errtostr.errstr, i64 0, i64 %4
%6 = load i8*, i8** %5
ret i8* %6
}

LLVM IR (-O2):
@reltable.errtostr = internal unnamed_addr constant [40 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.1 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.2 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.4 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([42 x i8]* @.str.6 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.7 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.8 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.9 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.10 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.11 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([47 x i8]* @.str.12 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([46 x i8]* @.str.13 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([58 x i8]* @.str.14 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.15 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.16 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.17 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.18 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([37 x i8]* @.str.19 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([53 x i8]* @.str.20 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.21 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([43 x i8]* @.str.22 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.23 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.24 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.25 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.26 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.27 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.28 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.29 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.30 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.31 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.32 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.33 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.34 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.35 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.36 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.37 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.38 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.39 to i64), i64 ptrtoint ([40 x i32]* @reltable.errtostr to i64)) to i32)]
@.str = [8 x i8] c"Success\00"
@.str.1 = [40 x i8] c"SSID cannot accommodate the service set\00"
@.str.2 = [13 x i8] c"Socket error\00"
@.str.3 = [18 x i8] c"Not enough memory\00"
@.str.4 = [14 x i8] c"SSID too long\00"
@.str.5 = [15 x i8] c"Set SSID error\00"
@.str.6 = [42 x i8] c"Error in getting the next SDE packet info\00"
@.str.7 = [32 x i8] c"Error in handling an SDE packet\00"
@.str.8 = [30 x i8] c"Error in taking an SDE packet\00"
@.str.9 = [32 x i8] c"Error in removing an SDE packet\00"
@.str.10 = [39 x i8] c"Error in sending SDE metadata response\00"
@.str.11 = [35 x i8] c"Error in creating metadata packets\00"
@.str.12 = [47 x i8] c"Error in extracting metadata from service list\00"
@.str.13 = [46 x i8] c"Error in creating service description packets\00"
@.str.14 = [58 x i8] c"Error in extracting service description from service list\00"
@.str.15 = [38 x i8] c"Error in loading published service DB\00"
@.str.16 = [39 x i8] c"Error in adding a service at the front\00"
@.str.17 = [31 x i8] c"Error in saving a service list\00"
@.str.18 = [45 x i8] c"Error in counting services in a service list\00"
@.str.19 = [37 x i8] c"Invalid service position in the SSID\00"
@.str.20 = [53 x i8] c"Error in counting enabled services in a service list\00"
@.str.21 = [39 x i8] c"URI is mandatory in creating a service\00"
@.str.22 = [43 x i8] c"Error in creating a tmp service list table\00"
@.str.23 = [35 x i8] c"Cannot increment service positions\00"
@.str.24 = [35 x i8] c"Cannot decrement service positions\00"
@.str.25 = [38 x i8] c"Error in adding a service at the back\00"
@.str.26 = [29 x i8] c"Error in inserting a service\00"
@.str.27 = [29 x i8] c"Error in replacing a service\00"
@.str.28 = [28 x i8] c"Error in deleting a service\00"
@.str.29 = [31 x i8] c"Error in deleting all services\00"
@.str.30 = [23 x i8] c"Index is outside range\00"
@.str.31 = [26 x i8] c"Cannot ensure inc_dec_pos\00"
@.str.32 = [30 x i8] c"Error in retrieving a service\00"
@.str.33 = [32 x i8] c"Error in reloading service list\00"
@.str.34 = [31 x i8] c"Error in loading category list\00"
@.str.35 = [22 x i8] c"Error in parsing data\00"
@.str.36 = [16 x i8] c"Error in the DB\00"
@.str.37 = [36 x i8] c"Error in updating the category list\00"
@.str.38 = [36 x i8] c"Error in loading flat category list\00"
@.str.39 = [22 x i8] c"Invalid program state\00"
define i8* @errtostr(i32 %0) {
%2 = sext i32 %0 to i64
%3 = shl i64 %2, 2
%4 = call i8* @llvm.load.relative.i64(i8* bitcast ([40 x i32]* @reltable.errtostr to i8*), i64 %3)
ret i8* %4
}