const char *getdate_strerror(int e) {
  const char *s[] = {"Invalid getdate_err value",
                     "DATEMSK environment variable null or undefined",
                     "Template file cannot be opened for reading",
                     "Failed to get file status information",
                     "Template file not a regular file",
                     "I/O error encountered while reading template file",
                     "Memory allocation failed",
                     "No line in template that matches input",
                     "Invalid input specification"};
  if (e < 1 || e > 8)
    return s[0];
  return s[e];
}


x86 assembly (clang, -O0):
<getdate_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2caa(%rip),%rsi
mov    $0x48,%edx
call   1030 <memcpy@plt>
cmpl   $0x1,-0xc(%rbp)
jl     1144 <getdate_strerror+0x34>
cmpl   $0x8,-0xc(%rbp)
jle    1151 <getdate_strerror+0x41>
mov    -0x60(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    115e <getdate_strerror+0x4e>
movslq -0xc(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getdate_strerror>:
lea    -0x9(%rdi),%eax
cmp    $0xfffffff8,%eax
movslq %edi,%rax
lea    0x2cf0(%rip),%rcx
lea    (%rcx,%rax,8),%rax
cmovb  %rcx,%rax
mov    (%rax),%rax
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Invalid getdate_err value\00"
@.str.1 = [47 x i8] c"DATEMSK environment variable null or undefined\00"
@.str.2 = [43 x i8] c"Template file cannot be opened for reading\00"
@.str.3 = [38 x i8] c"Failed to get file status information\00"
@.str.4 = [33 x i8] c"Template file not a regular file\00"
@.str.5 = [50 x i8] c"I/O error encountered while reading template file\00"
@.str.6 = [25 x i8] c"Memory allocation failed\00"
@.str.7 = [39 x i8] c"No line in template that matches input\00"
@.str.8 = [28 x i8] c"Invalid input specification\00"
@__const.getdate_strerror.s = [9 x i8*] [i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i32 0, i32 0)]
define i8* @getdate_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [9 x i8*]
store i32 %0, i32* %3
%5 = bitcast [9 x i8*]* %4 to i8*
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 8
br i1 %10, label %11, label %14
11: ; preds = %8, %1
%12 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %2
br label %19
14: ; preds = %8
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 %16
%18 = load i8*, i8** %17
store i8* %18, i8** %2
br label %19
19: ; preds = %14, %11
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
@.str = [26 x i8] c"Invalid getdate_err value\00"
@.str.1 = [47 x i8] c"DATEMSK environment variable null or undefined\00"
@.str.2 = [43 x i8] c"Template file cannot be opened for reading\00"
@.str.3 = [38 x i8] c"Failed to get file status information\00"
@.str.4 = [33 x i8] c"Template file not a regular file\00"
@.str.5 = [50 x i8] c"I/O error encountered while reading template file\00"
@.str.6 = [25 x i8] c"Memory allocation failed\00"
@.str.7 = [39 x i8] c"No line in template that matches input\00"
@.str.8 = [28 x i8] c"Invalid input specification\00"
@__const.getdate_strerror.s = [9 x i8*] [i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i32 0, i32 0)]
define i8* @getdate_strerror(i32 %0) {
%2 = add i32 %0, -9
%3 = icmp ult i32 %2, -8
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds [9 x i8*], [9 x i8*]* @__const.getdate_strerror.s, i64 0, i64 %4
%6 = select i1 %3, i8** getelementptr inbounds ([9 x i8*], [9 x i8*]* @__const.getdate_strerror.s, i64 0, i64 0), i8** %5
%7 = load i8*, i8** %6
ret i8* %7
}