#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int abs(int);
char *get_english_ordinal(int n) {
  int i;
  static char *ord[] = {"th", "st", "nd", "rd"};
  n = abs(n);
  i = n % 10;
  if (i > 3 || n / 10 % 10 == 1)
    i = 0;
  return ord[i];
}


x86 assembly (clang, -O0):
<get_english_ordinal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jg     115a <get_english_ordinal+0x4a>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1161 <get_english_ordinal+0x51>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rcx
lea    0x2ec4(%rip),%rax
mov    (%rax,%rcx,8),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_english_ordinal>:
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
imul   $0xcccccccd,%ecx,%ecx
add    $0x33333333,%ecx
ror    %ecx
xor    %edx,%edx
cmp    $0x1999999a,%ecx
mov    %eax,%ecx
cmovb  %edx,%ecx
cmp    $0x4,%eax
cmovae %edx,%ecx
lea    0xebc(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
ret

LLVM IR (-O0):
@get_english_ordinal.ord = 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* @get_english_ordinal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @abs(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = srem i32 %6, 10
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 3
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 10
%13 = srem i32 %12, 10
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %10, %1
store i32 0, i32* %3
br label %16
16: ; preds = %15, %10
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* @get_english_ordinal.ord, i64 0, i64 %18
%20 = load i8*, i8** %19
ret i8* %20
}

LLVM IR (-O2):
@reltable.get_english_ordinal = 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.get_english_ordinal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_english_ordinal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_english_ordinal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.get_english_ordinal 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* @get_english_ordinal(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%3 = urem i32 %2, 10
%4 = udiv i32 %2, 10
%5 = icmp ugt i32 %3, 3
%6 = urem i32 %4, 10
%7 = icmp eq i32 %6, 1
%8 = select i1 %5, i1 true, i1 %7
%9 = select i1 %8, i32 0, i32 %3
%10 = zext i32 %9 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.get_english_ordinal to i8*), i64 %11)
ret i8* %12
}