// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_faceEnemyFlag
char *
ctf_faceEnemyFlag(edict_t *ent)
{
	int angle;
	edict_t *flag;
	vec3_t distvector, angles;

	if (ent->client->ctf.teamnum == CTF_TEAM_RED)
		flag = blueflag;
	else if (ent->client->ctf.teamnum == CTF_TEAM_BLUE)
		flag = redflag;
	else return "north";

	if (!flag) //surt no flags mode always points north.
		return "north";

	if (flag->owner)
		flag = flag->owner;

	if (flag == ent)
	{
		if (ent->client->ctf.teamnum == CTF_TEAM_RED)
			return "blueflaggone";		
		else if (ent->client->ctf.teamnum == CTF_TEAM_BLUE)
			return "redflaggone";
	}

	VectorSubtract(flag->s.origin, ent->s.origin, distvector);

	/*
	if (abs(distvector[0]) > abs(distvector[1]) &&		// 0 Biggest
		abs(distvector[0]) > abs(distvector[2]))
	{
		if (distvector[0] > 0)
			strcpy(temp, "north of ");
		else
			strcpy(temp, "south of ");
	}
	else if (abs(distvector[1]) > abs(distvector[2]))	// 1 biggest
	{
		if (distvector[1] > 0)
			strcpy(temp, "west of ");
		else
			strcpy(temp, "east of ");
	}
	*/
	vectoangles(distvector, angles);
	//angle = angles[1];
	angle = (int)ent->client->v_angle[1] - angles[1];

	// Turn the angle positive
	angle = (angle + 720) % 360;

	if (angle < 22 || angle >= 338)
		return "north";
	else if (angle < 67)
		return "northeast";
	else if (angle < 112)
		return "east";
	else if (angle < 157)
		return "southeast";
	else if (angle < 202)
		return "south";
	else if (angle < 247)
		return "southwest";
	else if (angle < 292)
		return "west";
	else // MJD See Previous Error - Requires Default
		return "northwest";
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %r14
movq 0x58(%rdi), %rax
movl 0x1100(%rax), %eax
leaq 0x3241f(%rip), %rbx     # 0x547f6
cmpl $0x1, %eax
je 0x223ee
cmpl $0x2, %eax
jne 0x22539
movq 0x4740c(%rip), %rcx     # 0x697f8
jmp 0x223f5
movq 0x4746b(%rip), %rcx     # 0x69860
movq (%rcx), %rdx
testq %rdx, %rdx
je 0x22539
movq 0x110(%rdx), %rcx
testq %rcx, %rcx
cmoveq %rdx, %rcx
cmpq %r14, %rcx
je 0x224c4
movss 0x4(%rcx), %xmm0
subss 0x4(%r14), %xmm0
leaq 0x14(%rsp), %rdi
movss %xmm0, (%rdi)
movss 0x8(%rcx), %xmm0
subss 0x8(%r14), %xmm0
movss %xmm0, 0x4(%rdi)
movss 0xc(%rcx), %xmm0
subss 0xc(%r14), %xmm0
movss %xmm0, 0x8(%rdi)
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x190d0
movq 0x58(%r14), %rax
movss 0xec0(%rax), %xmm0
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
subss 0x4(%r15), %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, %eax
addl $0x2d0, %eax            # imm = 0x2D0
cltq
imulq $-0x49f49f49, %rax, %rdx # imm = 0xB60B60B7
shrq $0x20, %rdx
addl %edx, %ecx
addl $0x2d0, %ecx            # imm = 0x2D0
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x8, %ecx
addl %edx, %ecx
imull $0x168, %ecx, %ecx      # imm = 0x168
subl %ecx, %eax
leal -0x152(%rax), %ecx
cmpl $0xfffffec4, %ecx       # imm = 0xFFFFFEC4
jb 0x22539
cmpl $0x43, %eax
jge 0x224db
leaq 0x3233a(%rip), %rbx     # 0x547fc
jmp 0x22539
cmpl $0x1, %eax
je 0x224e9
cmpl $0x2, %eax
jne 0x22418
leaq 0x32344(%rip), %rbx     # 0x5481d
jmp 0x22539
cmpl $0x70, %eax
jge 0x224f2
leaq 0x3231a(%rip), %rbx     # 0x54801
jmp 0x22539
leaq 0x32320(%rip), %rbx     # 0x54810
jmp 0x22539
cmpl $0x9d, %eax
jge 0x22502
leaq 0x32306(%rip), %rbx     # 0x54806
jmp 0x22539
cmpl $0xca, %eax
jge 0x22512
leaq 0x322cc(%rip), %rbx     # 0x547dc
jmp 0x22539
cmpl $0xf7, %eax
jge 0x22522
leaq 0x322c2(%rip), %rbx     # 0x547e2
jmp 0x22539
cmpl $0x124, %eax            # imm = 0x124
leaq 0x322c3(%rip), %rax     # 0x547f1
leaq 0x322b7(%rip), %rbx     # 0x547ec
cmovlq %rax, %rbx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq