char *Suffix(int Number) {
  static char *Ptr;
  while (Number > 1000)
    Number -= 1000;
  while (Number > 100)
    Number -= 100;
  if ((Number > 10) && (Number < 20)) {
    Ptr = "th";
    return (Ptr);
  }
  while (Number > 10)
    Number -= 10;
  switch (Number) {
  case 1:
    Ptr = "st";
    break;
  case 2:
    Ptr = "nd";
    break;
  case 3:
    Ptr = "rd";
    break;
  default:
    Ptr = "th";
    break;
  }
  return (Ptr);
}


x86 assembly (clang, -O0):
<Suffix>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jle    1124 <Suffix+0x24>
mov    -0xc(%rbp),%eax
sub    $0x3e8,%eax
mov    %eax,-0xc(%rbp)
jmp    1107 <Suffix+0x7>
jmp    1129 <Suffix+0x29>
cmpl   $0x64,-0xc(%rbp)
jle    1141 <Suffix+0x41>
mov    -0xc(%rbp),%eax
sub    $0x64,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <Suffix+0x29>
cmpl   $0xa,-0xc(%rbp)
jle    1173 <Suffix+0x73>
cmpl   $0x14,-0xc(%rbp)
jge    1173 <Suffix+0x73>
lea    0xea4(%rip),%rax
mov    %rax,0x2ec5(%rip)
mov    0x2ebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1218 <Suffix+0x118>
jmp    1178 <Suffix+0x78>
cmpl   $0xa,-0xc(%rbp)
jle    1190 <Suffix+0x90>
mov    -0xc(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <Suffix+0x78>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11c6 <Suffix+0xc6>
jmp    11a4 <Suffix+0xa4>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11d9 <Suffix+0xd9>
jmp    11b5 <Suffix+0xb5>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     11ec <Suffix+0xec>
jmp    11ff <Suffix+0xff>
lea    0xe36(%rip),%rax
mov    %rax,0x2e54(%rip)
jmp    120d <Suffix+0x10d>
lea    0xe26(%rip),%rax
mov    %rax,0x2e41(%rip)
jmp    120d <Suffix+0x10d>
lea    0xe16(%rip),%rax
mov    %rax,0x2e2e(%rip)
jmp    120d <Suffix+0x10d>
lea    0xdfa(%rip),%rax
mov    %rax,0x2e1b(%rip)
mov    0x2e14(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Suffix>:
cmp    $0x3e8,%edi
mov    $0x3e8,%eax
cmovl  %edi,%eax
neg    %eax
add    %edi,%eax
add    $0x3e7,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%ecx
mov    %edi,%eax
sub    %ecx,%eax
cmp    $0x64,%eax
mov    $0x64,%edx
cmovl  %eax,%edx
add    %ecx,%edx
neg    %edx
lea    (%rdi,%rdx,1),%eax
add    $0x63,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%r8d
lea    (%r8,%rcx,1),%esi
mov    %esi,%eax
neg    %eax
lea    (%rdi,%rax,1),%edx
add    $0xfffffff5,%edx
lea    0xe9b(%rip),%rax
cmp    $0x9,%edx
jb     11c4 <Suffix+0xc4>
mov    %edi,%edx
sub    %esi,%edx
cmp    $0xa,%edx
mov    $0xa,%esi
cmovl  %edx,%esi
add    %r8d,%esi
add    %ecx,%esi
mov    %edi,%r9d
sub    %esi,%r9d
neg    %esi
add    %edi,%esi
add    $0x9,%esi
mov    $0xcccccccd,%edx
imul   %rsi,%rdx
shr    $0x23,%rdx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%esi
add    %edi,%esi
lea    (%r8,%r9,1),%edx
add    $0x9,%edx
add    %ecx,%edx
not    %edx
add    %esi,%edx
cmp    $0x2,%edx
ja     11c4 <Suffix+0xc4>
movslq %edx,%rax
lea    0xe4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@Suffix.Ptr = internal global i8* null
@.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* @Suffix(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
br label %4
4: ; preds = %7, %1
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 1000
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1000
store i32 %9, i32* %3
br label %4
10: ; preds = %4
br label %11
11: ; preds = %14, %10
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 100
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 100
store i32 %16, i32* %3
br label %11
17: ; preds = %11
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 10
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 20
br i1 %22, label %23, label %25
23: ; preds = %20
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** @Suffix.Ptr
%24 = load i8*, i8** @Suffix.Ptr
store i8* %24, i8** %2
br label %40
25: ; preds = %20, %17
br label %26
26: ; preds = %29, %25
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 10
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 10
store i32 %31, i32* %3
br label %26
32: ; preds = %26
%33 = load i32, i32* %3
switch i32 %33, label %37 [
i32 1, label %34
i32 2, label %35
i32 3, label %36
]
34: ; preds = %32
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** @Suffix.Ptr
br label %38
35: ; preds = %32
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** @Suffix.Ptr
br label %38
36: ; preds = %32
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** @Suffix.Ptr
br label %38
37: ; preds = %32
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** @Suffix.Ptr
br label %38
38: ; preds = %37, %36, %35, %34
%39 = load i8*, i8** @Suffix.Ptr
store i8* %39, i8** %2
br label %40
40: ; preds = %38, %23
%41 = load i8*, i8** %2
ret i8* %41
}

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.Suffix = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.Suffix to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.Suffix to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.Suffix to i64)) to i32)]
define i8* @Suffix(i32 %0) {
%2 = add i32 %0, 999
%3 = call i32 @llvm.smin.i32(i32 %0, i32 1000)
%4 = sub i32 %2, %3
%5 = urem i32 %4, 1000
%6 = sub i32 %4, %5
%7 = sub i32 %0, %6
%8 = add i32 %0, 99
%9 = call i32 @llvm.smin.i32(i32 %7, i32 100)
%10 = add i32 %9, %6
%11 = sub i32 %8, %10
%12 = urem i32 %11, 100
%13 = sub i32 %11, %12
%14 = add i32 %13, %6
%15 = sub i32 %0, %14
%16 = add i32 %15, -11
%17 = icmp ult i32 %16, 9
br i1 %17, label %35, label %18
18: ; preds = %1
%19 = add i32 %0, 9
%20 = call i32 @llvm.smin.i32(i32 %15, i32 10)
%21 = add i32 %20, %13
%22 = add i32 %21, %6
%23 = sub i32 %19, %22
%24 = urem i32 %23, 10
%25 = add i32 %24, %0
%26 = add i32 %23, %13
%27 = add i32 %26, %6
%28 = xor i32 %27, -1
%29 = add i32 %25, %28
%30 = icmp ult i32 %29, 3
br i1 %30, label %31, label %35
31: ; preds = %18
%32 = sext i32 %29 to i64
%33 = shl i64 %32, 2
%34 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.Suffix to i8*), i64 %33)
br label %35
35: ; preds = %18, %31, %1
%36 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ %34, %31 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %18 ]
ret i8* %36
}