const char *day_suffix(day)
int day;
{
  static const char *suffix[] = {("th"), ("st"), ("nd"), ("rd")};
  register int i = 0;
  if (day > 100)
    day %= 100;
  if (day < 11 || day > 13)
    i = day % 10;
  if (i > 3)
    i = 0;
  return ((suffix[i]));
}


x86 assembly (clang, -O0):
<day_suffix>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x4(%rbp)
jle    1126 <day_suffix+0x26>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
cmpl   $0xb,-0x4(%rbp)
jl     113a <day_suffix+0x3a>
cmpl   $0xd,-0x4(%rbp)
jle    1148 <day_suffix+0x48>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1159 <day_suffix+0x59>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rcx
lea    0x2ecc(%rip),%rax
mov    (%rax,%rcx,8),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_suffix>:
cmp    $0x65,%edi
jl     1121 <day_suffix+0x21>
movslq %edi,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edi
lea    -0xe(%rdi),%edx
xor    %eax,%eax
mov    $0x0,%ecx
cmp    $0xfffffffc,%edx
ja     1150 <day_suffix+0x50>
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edi
mov    %edi,%ecx
cmp    $0x4,%ecx
cmovl  %ecx,%eax
cltq
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@day_suffix.suffix = internal global [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 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)]
@.str = [3 x i8] c"th\00"
@.str.1 = [3 x i8] c"st\00"
@.str.2 = [3 x i8] c"nd\00"
@.str.3 = [3 x i8] c"rd\00"
define i8* @day_suffix(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 100
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %2
%8 = srem i32 %7, 100
store i32 %8, i32* %2
br label %9
9: ; preds = %6, %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 11
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 13
br i1 %14, label %15, label %18
15: ; preds = %12, %9
%16 = load i32, i32* %2
%17 = srem i32 %16, 10
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 3
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 0, i32* %3
br label %22
22: ; preds = %21, %18
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i8*], [4 x i8*]* @day_suffix.suffix, i64 0, i64 %24
%26 = load i8*, i8** %25
ret i8* %26
}

LLVM IR (-O2):
@reltable.day_suffix = internal unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.day_suffix to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.day_suffix to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.day_suffix to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.day_suffix to i64)) to i32)]
@.str = [3 x i8] c"th\00"
@.str.1 = [3 x i8] c"st\00"
@.str.2 = [3 x i8] c"nd\00"
@.str.3 = [3 x i8] c"rd\00"
define i8* @day_suffix(i32 %0) {
%2 = icmp sgt i32 %0, 100
%3 = srem i32 %0, 100
%4 = select i1 %2, i32 %3, i32 %0
%5 = add i32 %4, -14
%6 = icmp ult i32 %5, -3
%7 = srem i32 %4, 10
%8 = select i1 %6, i32 %7, i32 0
%9 = icmp sgt i32 %8, 3
%10 = select i1 %9, i32 0, i32 %8
%11 = sext i32 %10 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.day_suffix to i8*), i64 %12)
ret i8* %13
}