#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 *, char *, int, char *);
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"
        "^0";
  } else if (rank == 2) {
    s = "^1"
        "2nd"
        "^0";
  } else if (rank == 3) {
    s = "^3"
        "3rd"
        "^0";
  } else if (rank == 11) {
    s = "^7"
        "11th"
        "^0";
  } else if (rank == 12) {
    s = "^7"
        "12th"
        "^0";
  } else if (rank == 13) {
    s = "^7"
        "13th"
        "^0";
  } else if (rank % 10 == 1) {
    s = va("%s%ist%s", "^7", rank, "^0");
  } else if (rank % 10 == 2) {
    s = va("%s%ind%s", "^7", rank, "^0");
  } else if (rank % 10 == 3) {
    s = va("%s%ird%s", "^7", rank, "^0");
  } else {
    s = va("%s%ith%s", "^7", rank, "^0");
  }
  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    12f5 <CG_PlaceString+0x1d5>
cmpl   $0x2,-0x4(%rbp)
jne    1196 <CG_PlaceString+0x76>
lea    0xe85(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12f0 <CG_PlaceString+0x1d0>
cmpl   $0x3,-0x4(%rbp)
jne    11b0 <CG_PlaceString+0x90>
lea    0xe73(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12eb <CG_PlaceString+0x1cb>
cmpl   $0xb,-0x4(%rbp)
jne    11ca <CG_PlaceString+0xaa>
lea    0xe61(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12e6 <CG_PlaceString+0x1c6>
cmpl   $0xc,-0x4(%rbp)
jne    11e4 <CG_PlaceString+0xc4>
lea    0xe50(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12e1 <CG_PlaceString+0x1c1>
cmpl   $0xd,-0x4(%rbp)
jne    11fe <CG_PlaceString+0xde>
lea    0xe3f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    12dc <CG_PlaceString+0x1bc>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1238 <CG_PlaceString+0x118>
mov    -0x4(%rbp),%edx
lea    0xe21(%rip),%rdi
lea    0xe23(%rip),%rsi
lea    0xded(%rip),%rcx
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    12d7 <CG_PlaceString+0x1b7>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1272 <CG_PlaceString+0x152>
mov    -0x4(%rbp),%edx
lea    0xdf3(%rip),%rdi
lea    0xde9(%rip),%rsi
lea    0xdb3(%rip),%rcx
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    12d2 <CG_PlaceString+0x1b2>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    12ac <CG_PlaceString+0x18c>
mov    -0x4(%rbp),%edx
lea    0xdc2(%rip),%rdi
lea    0xdaf(%rip),%rsi
lea    0xd79(%rip),%rcx
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    12cd <CG_PlaceString+0x1ad>
mov    -0x4(%rbp),%edx
lea    0xda5(%rip),%rdi
lea    0xd89(%rip),%rsi
lea    0xd53(%rip),%rcx
call   1040 <va@plt>
mov    %rax,-0x10(%rbp)
jmp    12d2 <CG_PlaceString+0x1b2>
jmp    12d7 <CG_PlaceString+0x1b7>
jmp    12dc <CG_PlaceString+0x1bc>
jmp    12e1 <CG_PlaceString+0x1c1>
jmp    12e6 <CG_PlaceString+0x1c6>
jmp    12eb <CG_PlaceString+0x1cb>
jmp    12f0 <CG_PlaceString+0x1d0>
jmp    12f5 <CG_PlaceString+0x1d5>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x2d3c(%rip),%rdi
mov    $0x40,%esi
lea    0xd54(%rip),%rdx
call   1030 <Com_sprintf@plt>
lea    0x2d24(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_PlaceString>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%edx
and    $0xffffbfff,%edx
lea    -0x1(%rdx),%eax
cmp    $0xd,%eax
jae    113d <CG_PlaceString+0x1d>
mov    $0x1c07,%ecx
bt     %eax,%ecx
jb     1175 <CG_PlaceString+0x55>
movslq %edx,%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    %edx,%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    0xeca(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
cltq
lea    0xeee(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
jmp    11b6 <CG_PlaceString+0x96>
lea    0xec4(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
lea    0xeb2(%rip),%rdi
jmp    11a0 <CG_PlaceString+0x80>
lea    0xebb(%rip),%rdi
lea    0xe9f(%rip),%rsi
lea    0xe69(%rip),%rcx
call   1040 <va@plt>
mov    %rax,%r8
test   $0x4000,%ebx
lea    0xe46(%rip),%rax
lea    0xe36(%rip),%rcx
cmove  %rax,%rcx
lea    0x2e6b(%rip),%rbx
lea    0xe88(%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^0\00"
@.str.3 = [8 x i8] c"^12nd^0\00"
@.str.4 = [8 x i8] c"^33rd^0\00"
@.str.5 = [9 x i8] c"^711th^0\00"
@.str.6 = [9 x i8] c"^712th^0\00"
@.str.7 = [9 x i8] c"^713th^0\00"
@.str.8 = [9 x i8] c"%s%ist%s\00"
@.str.9 = [3 x i8] c"^7\00"
@.str.10 = [3 x i8] c"^0\00"
@.str.11 = [9 x i8] c"%s%ind%s\00"
@.str.12 = [9 x i8] c"%s%ird%s\00"
@.str.13 = [9 x i8] c"%s%ith%s\00"
@.str.14 = [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 ([9 x i8], [9 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 ([9 x i8], [9 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 ([9 x i8], [9 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 ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
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 ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
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 ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i8* %56, i8** %3
br label %60
57: ; preds = %50
%58 = load i32, i32* %2
%59 = call i8* @va(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %58, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
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.14, 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^0\00"
@.str.3 = [8 x i8] c"^12nd^0\00"
@.str.4 = [8 x i8] c"^33rd^0\00"
@.str.5 = [9 x i8] c"^711th^0\00"
@.str.6 = [9 x i8] c"^712th^0\00"
@.str.7 = [9 x i8] c"^713th^0\00"
@.str.8 = [9 x i8] c"%s%ist%s\00"
@.str.9 = [3 x i8] c"^7\00"
@.str.10 = [3 x i8] c"^0\00"
@.str.11 = [9 x i8] c"%s%ind%s\00"
@.str.12 = [9 x i8] c"%s%ird%s\00"
@.str.13 = [9 x i8] c"%s%ith%s\00"
@.str.14 = [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 ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.CG_PlaceString to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 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 ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %24
9: ; preds = %5
%10 = tail call i8* @va(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %24
11: ; preds = %5
%12 = tail call i8* @va(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %24
13: ; preds = %5
%14 = tail call i8* @va(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
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.14, 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)
}