#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ Com_sprintf(char *, int, char *, char *, char *);
char *va(char *, int);
const char *CG_PlaceString(int rank) {
  static char str[64];
  char *s, *t;
  if (rank & 0x4000) {
    rank &= ~0x4000;
    t = "Tied for ";
  } else {
    t = "";
  }
  if (rank == 1) {
    s = "^4"
        "1st"
        "^7";
  } else if (rank == 2) {
    s = "^1"
        "2nd"
        "^7";
  } else if (rank == 3) {
    s = "^3"
        "3rd"
        "^7";
  } else if (rank == 11) {
    s = "11th";
  } else if (rank == 12) {
    s = "12th";
  } else if (rank == 13) {
    s = "13th";
  } else if (rank % 10 == 1) {
    s = va("%ist", rank);
  } else if (rank % 10 == 2) {
    s = va("%ind", rank);
  } else if (rank % 10 == 3) {
    s = va("%ird", rank);
  } else {
    s = va("%ith", rank);
  }
  Com_sprintf(str, sizeof(str), "%s%s", t, s);
  return str;
}


x86 assembly (clang, -O0):
<CG_PlaceString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1157 <CG_PlaceString+0x37>
mov    -0x4(%rbp),%eax
and    $0xffffbfff,%eax
mov    %eax,-0x4(%rbp)
lea    0xeb2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1162 <CG_PlaceString+0x42>
lea    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    117c <CG_PlaceString+0x5c>
lea    0xe97(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12bd <CG_PlaceString+0x19d>
cmpl   $0x2,-0x4(%rbp)
jne    1196 <CG_PlaceString+0x76>
lea    0xe85(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12b8 <CG_PlaceString+0x198>
cmpl   $0x3,-0x4(%rbp)
jne    11b0 <CG_PlaceString+0x90>
lea    0xe73(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12b3 <CG_PlaceString+0x193>
cmpl   $0xb,-0x4(%rbp)
jne    11ca <CG_PlaceString+0xaa>
lea    0xe61(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12ae <CG_PlaceString+0x18e>
cmpl   $0xc,-0x4(%rbp)
jne    11e4 <CG_PlaceString+0xc4>
lea    0xe4c(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12a9 <CG_PlaceString+0x189>
cmpl   $0xd,-0x4(%rbp)
jne    11fe <CG_PlaceString+0xde>
lea    0xe37(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12a4 <CG_PlaceString+0x184>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    122a <CG_PlaceString+0x10a>
mov    -0x4(%rbp),%esi
lea    0xe15(%rip),%rdi
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    129f <CG_PlaceString+0x17f>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1256 <CG_PlaceString+0x136>
mov    -0x4(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    129a <CG_PlaceString+0x17a>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1282 <CG_PlaceString+0x162>
mov    -0x4(%rbp),%esi
lea    0xdc7(%rip),%rdi
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    1295 <CG_PlaceString+0x175>
mov    -0x4(%rbp),%esi
lea    0xdb4(%rip),%rdi
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    129a <CG_PlaceString+0x17a>
jmp    129f <CG_PlaceString+0x17f>
jmp    12a4 <CG_PlaceString+0x184>
jmp    12a9 <CG_PlaceString+0x189>
jmp    12ae <CG_PlaceString+0x18e>
jmp    12b3 <CG_PlaceString+0x193>
jmp    12b8 <CG_PlaceString+0x198>
jmp    12bd <CG_PlaceString+0x19d>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x2d74(%rip),%rdi
mov    $0x40,%esi
lea    0xd6d(%rip),%rdx
call   1030 <Com_sprintf@plt>
lea    0x2d5c(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_PlaceString>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%esi
and    $0xffffbfff,%esi
lea    -0x1(%rsi),%eax
cmp    $0xd,%eax
jae    113d <CG_PlaceString+0x1d>
mov    $0x1c07,%ecx
bt     %eax,%ecx
jb     1175 <CG_PlaceString+0x55>
movslq %esi,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%ecx
mov    %esi,%eax
sub    %ecx,%eax
cmp    $0x3,%eax
je     1187 <CG_PlaceString+0x67>
cmp    $0x2,%eax
je     1190 <CG_PlaceString+0x70>
cmp    $0x1,%eax
jne    1199 <CG_PlaceString+0x79>
lea    0xebe(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
cltq
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
jmp    11a8 <CG_PlaceString+0x88>
lea    0xead(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
lea    0xe9f(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
lea    0xea0(%rip),%rdi
call   1040 <va@plt>
mov    %rax,%r8
test   $0x4000,%ebx
lea    0xe54(%rip),%rax
lea    0xe44(%rip),%rcx
cmove  %rax,%rcx
lea    0x2e79(%rip),%rbx
lea    0xe77(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1030 <Com_sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@CG_PlaceString.str = internal global [64 x i8] zeroinitializer
@.str = [10 x i8] c"Tied for \00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [8 x i8] c"^41st^7\00"
@.str.3 = [8 x i8] c"^12nd^7\00"
@.str.4 = [8 x i8] c"^33rd^7\00"
@.str.5 = [5 x i8] c"11th\00"
@.str.6 = [5 x i8] c"12th\00"
@.str.7 = [5 x i8] c"13th\00"
@.str.8 = [5 x i8] c"%ist\00"
@.str.9 = [5 x i8] c"%ind\00"
@.str.10 = [5 x i8] c"%ird\00"
@.str.11 = [5 x i8] c"%ith\00"
@.str.12 = [5 x i8] c"%s%s\00"
define i8* @CG_PlaceString(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = and i32 %5, 16384
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %2
%10 = and i32 %9, -16385
store i32 %10, i32* %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %4
br label %12
11: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %12
12: ; preds = %11, %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %68
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %16
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %67
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %24
23: ; preds = %20
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %66
24: ; preds = %20
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 11
br i1 %26, label %27, label %28
27: ; preds = %24
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %65
28: ; preds = %24
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 12
br i1 %30, label %31, label %32
31: ; preds = %28
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %64
32: ; preds = %28
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 13
br i1 %34, label %35, label %36
35: ; preds = %32
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %63
36: ; preds = %32
%37 = load i32, i32* %2
%38 = srem i32 %37, 10
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %2
%42 = call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %41)
store i8* %42, i8** %3
br label %62
43: ; preds = %36
%44 = load i32, i32* %2
%45 = srem i32 %44, 10
%46 = icmp eq i32 %45, 2
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* %2
%49 = call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %48)
store i8* %49, i8** %3
br label %61
50: ; preds = %43
%51 = load i32, i32* %2
%52 = srem i32 %51, 10
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32, i32* %2
%56 = call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 %55)
store i8* %56, i8** %3
br label %60
57: ; preds = %50
%58 = load i32, i32* %2
%59 = call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 %58)
store i8* %59, i8** %3
br label %60
60: ; preds = %57, %54
br label %61
61: ; preds = %60, %47
br label %62
62: ; preds = %61, %40
br label %63
63: ; preds = %62, %35
br label %64
64: ; preds = %63, %31
br label %65
65: ; preds = %64, %27
br label %66
66: ; preds = %65, %23
br label %67
67: ; preds = %66, %19
br label %68
68: ; preds = %67, %15
%69 = load i8*, i8** %4
%70 = load i8*, i8** %3
%71 = call i32 @Com_sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @CG_PlaceString.str, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %69, i8* %70)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @CG_PlaceString.str, i64 0, i64 0)
}

LLVM IR (-O2):
@CG_PlaceString.str = internal global [64 x i8] zeroinitializer
@.str = [10 x i8] c"Tied for \00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [8 x i8] c"^41st^7\00"
@.str.3 = [8 x i8] c"^12nd^7\00"
@.str.4 = [8 x i8] c"^33rd^7\00"
@.str.5 = [5 x i8] c"11th\00"
@.str.6 = [5 x i8] c"12th\00"
@.str.7 = [5 x i8] c"13th\00"
@.str.8 = [5 x i8] c"%ist\00"
@.str.9 = [5 x i8] c"%ind\00"
@.str.10 = [5 x i8] c"%ird\00"
@.str.11 = [5 x i8] c"%ith\00"
@.str.12 = [5 x i8] c"%s%s\00"
@reltable.CG_PlaceString = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32)]
define i8* @CG_PlaceString(i32 %0) {
%2 = and i32 %0, -16385
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 13
br i1 %4, label %15, label %5
5: ; preds = %15, %1
%6 = srem i32 %2, 10
switch i32 %6, label %13 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
]
7: ; preds = %5
%8 = tail call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %2)
br label %24
9: ; preds = %5
%10 = tail call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %2)
br label %24
11: ; preds = %5
%12 = tail call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 %2)
br label %24
13: ; preds = %5
%14 = tail call i8* @va(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 %2)
br label %24
15: ; preds = %1
%16 = trunc i32 %3 to i16
%17 = lshr i16 7175, %16
%18 = and i16 %17, 1
%19 = icmp eq i16 %18, 0
br i1 %19, label %5, label %20
20: ; preds = %15
%21 = sext i32 %3 to i64
%22 = shl i64 %21, 2
%23 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.CG_PlaceString to i8*), i64 %22)
br label %24
24: ; preds = %20, %9, %13, %11, %7
%25 = phi i8* [ %8, %7 ], [ %10, %9 ], [ %12, %11 ], [ %14, %13 ], [ %23, %20 ]
%26 = and i32 %0, 16384
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0)
%29 = tail call i32 @Com_sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @CG_PlaceString.str, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %28, i8* %25)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @CG_PlaceString.str, i64 0, i64 0)
}