char *ord_indicator(unsigned int n) {
  int rem_h = n % 100;
  if (rem_h >= 10 && rem_h <= 20) {
    return "th";
  }
  int rem_ten = n % 10;
  switch (rem_ten) {
  case 1:
    return "st";
  case 2:
    return "nd";
  case 3:
    return "rd";
  default:
    return "th";
  }
}


x86 assembly (clang, -O0):
<ord_indicator>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jl     113a <ord_indicator+0x3a>
cmpl   $0x14,-0x10(%rbp)
jg     113a <ord_indicator+0x3a>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <ord_indicator+0xcd>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
mov    %ecx,%eax
mov    $0xcccccccd,%edx
imul   %rdx,%rcx
shr    $0x23,%rcx
mov    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1192 <ord_indicator+0x92>
jmp    1170 <ord_indicator+0x70>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     11a2 <ord_indicator+0xa2>
jmp    1181 <ord_indicator+0x81>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     11b2 <ord_indicator+0xb2>
jmp    11c2 <ord_indicator+0xc2>
lea    0xe6a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <ord_indicator+0xcd>
lea    0xe5d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <ord_indicator+0xcd>
lea    0xe50(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <ord_indicator+0xcd>
lea    0xe37(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ord_indicator>:
mov    %edi,%ecx
imul   $0x51eb851f,%rcx,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%eax
neg    %eax
lea    (%rdi,%rax,1),%edx
add    $0xfffffff6,%edx
lea    0xee1(%rip),%rax
cmp    $0xb,%edx
jb     1150 <ord_indicator+0x50>
mov    $0xcccccccd,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%ecx
not    %ecx
add    %edi,%ecx
cmp    $0x2,%ecx
ja     1150 <ord_indicator+0x50>
movslq %ecx,%rax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@.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* @ord_indicator(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = urem i32 %6, 100
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 10
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 20
br i1 %12, label %13, label %14
13: ; preds = %10
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
14: ; preds = %10, %1
%15 = load i32, i32* %3
%16 = urem i32 %15, 10
store i32 %16, i32* %5
%17 = load i32, i32* %5
switch i32 %17, label %21 [
i32 1, label %18
i32 2, label %19
i32 3, label %20
]
18: ; preds = %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %22
19: ; preds = %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %22
20: ; preds = %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %22
21: ; preds = %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %22
22: ; preds = %21, %20, %19, %18, %13
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.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"
@reltable.ord_indicator = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.ord_indicator to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.ord_indicator to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.ord_indicator to i64)) to i32)]
define i8* @ord_indicator(i32 %0) {
%2 = urem i32 %0, 100
%3 = add nsw i32 %2, -10
%4 = icmp ult i32 %3, 11
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = urem i32 %0, 10
%7 = add nsw i32 %6, -1
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.ord_indicator to i8*), i64 %11)
br label %13
13: ; preds = %5, %9, %1
%14 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ %12, %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %5 ]
ret i8* %14
}