const char *strreqerr(unsigned int req_err) {
  const char *req_err_str[] = {
      "Unknown error",      "System error",    "Connection has failed",
      "Connection timeout", "Receive timeout", "Send timeout",
  };
  if (req_err >= (sizeof(req_err_str) / sizeof((req_err_str)[0]))) {
    req_err = 0;
  }
  return req_err_str[req_err];
}


x86 assembly (clang, -O0):
<strreqerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xece(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xed1(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xede(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xee6(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeeb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
cmp    $0x6,%rax
jb     1181 <strreqerr+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x40(%rbp,%rax,8),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strreqerr>:
lea    0xef9(%rip),%rax
mov    %rax,-0x38(%rsp)
lea    0xefb(%rip),%rax
mov    %rax,-0x30(%rsp)
lea    0xefc(%rip),%rax
mov    %rax,-0x28(%rsp)
lea    0xf06(%rip),%rax
mov    %rax,-0x20(%rsp)
lea    0xf0d(%rip),%rax
mov    %rax,-0x18(%rsp)
lea    0xf11(%rip),%rax
mov    %rax,-0x10(%rsp)
xor    %eax,%eax
cmp    $0x6,%edi
cmovb  %edi,%eax
mov    -0x38(%rsp,%rax,8),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [13 x i8] c"System error\00"
@.str.2 = [22 x i8] c"Connection has failed\00"
@.str.3 = [19 x i8] c"Connection timeout\00"
@.str.4 = [16 x i8] c"Receive timeout\00"
@.str.5 = [13 x i8] c"Send timeout\00"
define i8* @strreqerr(i32 %0) {
%2 = alloca i32
%3 = alloca [6 x i8*]
store i32 %0, i32* %2
%4 = bitcast [6 x i8*]* %3 to i8*
%5 = bitcast i8* %4 to [6 x i8*]*
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i32 0, i32 0), i8** %11
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = icmp uge i64 %13, 6
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %1
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 %18
%20 = load i8*, i8** %19
ret i8* %20
}

LLVM IR (-O2):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [13 x i8] c"System error\00"
@.str.2 = [22 x i8] c"Connection has failed\00"
@.str.3 = [19 x i8] c"Connection timeout\00"
@.str.4 = [16 x i8] c"Receive timeout\00"
@.str.5 = [13 x i8] c"Send timeout\00"
define i8* @strreqerr(i32 %0) {
%2 = alloca [6 x i8*]
%3 = bitcast [6 x i8*]* %2 to i8*
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %9
%10 = icmp ugt i32 %0, 5
%11 = select i1 %10, i32 0, i32 %0
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %12
%14 = load i8*, i8** %13
ret i8* %14
}