// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_findflagposition
edict_t * ctf_findflagposition(edict_t *whichflag)
{
	edict_t	*bestspot;
	float	bestdistance, flagdistance;
	edict_t	*spot;
	vec3_t v;


	spot = NULL;
	bestspot = NULL;
	bestdistance = 0;
	while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL)
	{
		
		VectorSubtract (whichflag->s.origin, spot->s.origin, v);
		flagdistance = VectorLength(v);

		if (flagdistance > bestdistance)
		{
			bestspot = spot;
			bestdistance = flagdistance;
		}
	}

        // MJD This should have parentheses, given that you DO want to do
	// an asignment and not a ==
	spot = G_Find (spot, FOFS(classname), "info_flag_red");
	if (spot)
	{
		
		VectorSubtract (whichflag->s.origin, spot->s.origin, v);
		flagdistance = VectorLength(v);

		if (flagdistance > bestdistance)
		{
			bestspot = spot;
			bestdistance = flagdistance;
		}
	}

        // MJD This should have parentheses, given that you DO want to do
	// an asignment and not a ==
	spot = G_Find (spot, FOFS(classname), "info_flag_blue");
	if (spot)
	{
		
		VectorSubtract (whichflag->s.origin, spot->s.origin, v);
		flagdistance = VectorLength(v);

		if (flagdistance > bestdistance)
		{
			bestspot = spot;
			bestdistance = flagdistance;
		}
	}

	if (bestspot)
	{
		return bestspot;
	}

	// if there is a player just spawned on each and every start spot
	// we have no choice to turn one into a telefrag meltdown
	spot = G_Find (NULL, FOFS(classname), "info_player_deathmatch");

	return spot;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x18(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movq -0x28(%rbp), %rdi
xorl %eax, %eax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4d689(%rip), %rdx     # 0x70522
callq 0x19660
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x22f1d
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x34(%rbp), %rdi
callq 0x194e0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
ucomiss -0x1c(%rbp), %xmm0
jbe 0x22f18
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x22e84
movq -0x28(%rbp), %rdi
xorl %eax, %eax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4d016(%rip), %rdx     # 0x6ff48
callq 0x19660
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x22fb4
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x34(%rbp), %rdi
callq 0x194e0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
ucomiss -0x1c(%rbp), %xmm0
jbe 0x22fb2
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x22fb4
movq -0x28(%rbp), %rdi
xorl %eax, %eax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4cf8d(%rip), %rdx     # 0x6ff56
callq 0x19660
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2304b
movq -0x10(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x28(%rbp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
leaq -0x34(%rbp), %rdi
callq 0x194e0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
ucomiss -0x1c(%rbp), %xmm0
jbe 0x23049
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x2304b
cmpq $0x0, -0x18(%rbp)
je 0x2305c
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x23083
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4d4b0(%rip), %rdx     # 0x70522
callq 0x19660
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)