const char *short_day_name(day) const int day;
{
  static const char *name[] = {("invalid day"), ("Mo"), ("Tu"), ("We"),
                               ("Th"),          ("Fr"), ("Sa"), ("Su")};
  return (((day < 1) || (day > 7)) ? (name[0]) : (name[day]));
}


x86 assembly (clang, -O0):
<short_day_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     111b <short_day_name+0x1b>
cmpl   $0x7,-0x4(%rbp)
jle    112b <short_day_name+0x2b>
mov    0x2f0e(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    113e <short_day_name+0x3e>
movslq -0x4(%rbp),%rcx
lea    0x2efa(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<short_day_name>:
lea    -0x8(%rdi),%eax
cmp    $0xfffffff9,%eax
jae    1110 <short_day_name+0x10>
lea    0xf11(%rip),%rax
ret
mov    %edi,%eax
lea    0xee7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@short_day_name.name = internal global [8 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0)]
@.str = [12 x i8] c"invalid day\00"
@.str.1 = [3 x i8] c"Mo\00"
@.str.2 = [3 x i8] c"Tu\00"
@.str.3 = [3 x i8] c"We\00"
@.str.4 = [3 x i8] c"Th\00"
@.str.5 = [3 x i8] c"Fr\00"
@.str.6 = [3 x i8] c"Sa\00"
@.str.7 = [3 x i8] c"Su\00"
define i8* @short_day_name(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, 7
br i1 %7, label %8, label %10
8: ; preds = %5, %1
%9 = load i8*, i8** getelementptr inbounds ([8 x i8*], [8 x i8*]* @short_day_name.name, i64 0, i64 0)
br label %15
10: ; preds = %5
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x i8*], [8 x i8*]* @short_day_name.name, i64 0, i64 %12
%14 = load i8*, i8** %13
br label %15
15: ; preds = %10, %8
%16 = phi i8* [ %9, %8 ], [ %14, %10 ]
ret i8* %16
}

LLVM IR (-O2):
@reltable.short_day_name = internal unnamed_addr constant [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.short_day_name to i64)) to i32)]
@.str = [12 x i8] c"invalid day\00"
@.str.1 = [3 x i8] c"Mo\00"
@.str.2 = [3 x i8] c"Tu\00"
@.str.3 = [3 x i8] c"We\00"
@.str.4 = [3 x i8] c"Th\00"
@.str.5 = [3 x i8] c"Fr\00"
@.str.6 = [3 x i8] c"Sa\00"
@.str.7 = [3 x i8] c"Su\00"
define i8* @short_day_name(i32 %0) {
%2 = add i32 %0, -8
%3 = icmp ult i32 %2, -7
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = zext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.short_day_name to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}