// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_view.c
// Function: ClientShowID
int ClientShowID(edict_t *ent, char * buf)
{
	char	string[5000];
#ifdef OLDOBSERVERCODE
	char	string2[5000];
#endif
	char	*color;
	vec3_t	forward, right, start, mins, maxs, end;
	trace_t	tr;
	float	*v;
	edict_t *popup_ent;

	if (ent->client->showscores || ent->client->showhelp ||
		ent->client->showinventory || ent->client->showmod ||
		ent->client->showmenu
		|| ent->client->showsquadboard) // ADC
		return 0;

	// only update every second for each player
	// hopefuly this will distribute the load on the server
	// for the tracing needed for this function as well as
	// reduce the number of packets
	if (ent->client->last_popup_frame &&
		((level.framenum - ent->client->last_popup_frame + ent->client->ctf.original_enterframe) % 10))
		return 0;

	ent->client->last_popup_frame = level.framenum;

	strcpy(string, "");

	// Always show who we are chasing.
#ifdef OLDOBSERVERCODE
	if (ent->client->camera_target)
	{
		ent->client->ctf.popup_ent = ent->client->camera_target;
		ent->client->awayframe = level.framenum;
		sprintf(string2, ":%d", stats_get(ent->client->camera_target, STATS_SCORE));
	}
	else
#endif
	{
		v = tv(-16,-16,-16);
		VectorCopy (v, mins);
		v = tv(16,16,16);
		VectorCopy (v, maxs);
		
		// Set out ending point to our starting point
		AngleVectors (ent->client->v_angle, forward, right, NULL);
		
		VectorScale(forward, 5000, forward);
		VectorCopy(ent->s.origin, start);
		start[2] += ent->viewheight-8;
		
		VectorAdd(start, forward, end);
		/*
		VectorSet(offset, 8, 0, ent->viewheight-8);
		G_ProjectSource (ent->s.origin, offset, forward, right, start);
		
		  VectorSet(offset, 10000, 0, 0);
		  G_ProjectSource (start, offset, forward, right, end);
		*/
		
		tr = gi.trace (start, mins, maxs, end, ent, MASK_SHOT);
		
		if (tr.ent && tr.ent->client)
		{
			ent->client->ctf.popup_ent = tr.ent;
			ent->client->awayframe = level.framenum;
		}
		else
		{
			ent->client->ctf.popup_ent = NULL;
		}
	}

	popup_ent = ent->client->ctf.popup_ent;
	if (popup_ent && popup_ent->client)
	{
		ent->client->showctfhud = true;
		color = "string2";

		if (buf != NULL)
			strcpy(buf, popup_ent->client->pers.netname); //surt, for autotext

		strcpy(string, popup_ent->client->pers.netname);
#ifdef OLDOBSERVERCODE
		if (ent->client->camera_target)
			strcat(string, string2);
#endif
		if (popup_ent->client->ctf.teamnum != ent->client->ctf.teamnum)
			color = "string";

		Com_sprintf(string, sizeof(string),
			"xl %i yb %i %s \""
			"%s",
			5,-42,
			color,
			string);
		strcat(string, "\" ");
	}
	else if (Match_Over())
	{
		ent->client->showctfhud = true;
		color = "string2";
		strcpy(string, "MATCH OVER!");

		Com_sprintf(string, sizeof(string),
			"xv 32 yv 8 picn matchover "
			"xl %i yb %i %s \""
			"%s",
			5,-42,
			color,
			string);
		strcat(string, "\" ");
	}
	else if (GamePaused())
	{
		ent->client->showctfhud = true;
		color = "string2";
		strcpy(string, "GAME PAUSED (NO MOVING)!");

		Com_sprintf(string, sizeof(string),
			"xv 32 yv 8 picn gamepaused "
			"xl %i yb %i %s \""
			"%s",
			5,-42,
			color,
			string);
		strcat(string, "\" ");
	}

	// show popup for 1 more second after looking away
	if (level.framenum > ent->client->awayframe + 10)
	{
		ent->client->showctfhud = false;
		ent->client->ctf.popup_ent = NULL;
	}

	if (strlen(string) > 0)
	{
		gi.WriteByte (svc_layout);
		gi.WriteString (string);
		gi.unicast (ent, false);
	}
	
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1438, %rsp           # imm = 0x1438
movq 0x58(%rdi), %rcx
xorl %ebp, %ebp
cmpl $0x0, 0xe24(%rcx)
jne 0x47ce0
cmpl $0x0, 0xe2c(%rcx)
jne 0x47ce0
cmpl $0x0, 0xe28(%rcx)
jne 0x47ce0
cmpl $0x0, 0xf74(%rcx)
jne 0x47ce0
cmpl $0x0, 0xf80(%rcx)
jne 0x47ce0
cmpl $0x0, 0xe34(%rcx)
je 0x47cf4
movl %ebp, %eax
addq $0x1438, %rsp           # imm = 0x1438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %rbx
movl 0x10fc(%rcx), %edx
movq 0x1f099(%rip), %rax     # 0x66da0
movl (%rax), %esi
testl %edx, %edx
je 0x47d21
movl %esi, %eax
subl %edx, %eax
addl 0x9128(%rcx), %eax
pushq $0xa
popq %rdi
cltd
idivl %edi
testl %edx, %edx
jne 0x47ce0
movl %esi, 0x10fc(%rcx)
movb $0x0, 0xb0(%rsp)
movss 0xeeb5(%rip), %xmm0     # 0x56bec
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x30(%rsp), %r15
movsd %xmm0, (%r15)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r15)
movss 0xee8d(%rip), %xmm0     # 0x56bf0
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x20(%rsp), %r12
movsd %xmm0, (%r12)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r12)
movl $0xebc, %edi            # imm = 0xEBC
addq 0x58(%rbx), %rdi
leaq 0x50(%rsp), %r13
leaq 0x5c(%rsp), %rdx
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x183d0
movss 0xee46(%rip), %xmm0     # 0x56bf4
movq %r13, %rdi
movq %r13, %rsi
callq 0x18a70
movsd 0x4(%rbx), %xmm0
leaq 0x40(%rsp), %rsi
movsd %xmm0, (%rsi)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm1
addss 0xc(%rbx), %xmm1
movss %xmm1, 0x8(%rsi)
movsd (%r13), %xmm2
addps %xmm0, %xmm2
leaq 0x10(%rsp), %r8
movlps %xmm2, (%r8)
addss 0x8(%r13), %xmm1
movss %xmm1, 0x8(%r8)
movq 0x1e7fd(%rip), %rax     # 0x66600
movl $0x6000003, (%rsp)      # imm = 0x6000003
leaq 0x68(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r9
callq *0x60(%rax)
movq 0x40(%r13), %r13
testq %r13, %r13
je 0x47ede
cmpq $0x0, 0x58(%r13)
je 0x47ede
movq 0x58(%rbx), %r12
movq %r13, 0x9130(%r12)
movq 0x1ef57(%rip), %rbp     # 0x66da0
movl (%rbp), %eax
movl %eax, 0xf7c(%r12)
movq 0x58(%r13), %r15
testq %r15, %r15
je 0x47ef1
movl $0x1, 0xf78(%r12)
testq %r14, %r14
je 0x47e8c
addq $0x2c0, %r15            # imm = 0x2C0
movq %r14, %rdi
movq %r15, %rsi
callq 0x182c0
movq 0x58(%r13), %r15
movq 0x58(%rbx), %r12
leaq 0x2c0(%r15), %rsi
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x182c0
movl 0x1100(%r15), %eax
cmpl 0x1100(%r12), %eax
leaq 0xee87(%rip), %rax      # 0x56d40
leaq 0xa1fb(%rip), %r9       # 0x520bb
cmoveq %rax, %r9
movq %r14, (%rsp)
leaq 0xeee6(%rip), %rdx      # 0x56db5
pushq $0x5
popq %rcx
pushq $-0x2a
popq %r8
movq %r14, %rdi
jmp 0x47f82
movq 0x58(%rbx), %rax
andq $0x0, 0x9130(%rax)
movq 0x1eeaf(%rip), %rbp     # 0x66da0
xorl %eax, %eax
callq 0x18df0
testl %eax, %eax
je 0x47f33
movq 0x58(%rbx), %rax
movl $0x1, 0xf78(%rax)
movabsq $0x564f20484354414d, %rax # imm = 0x564F20484354414D
leaq 0xb0(%rsp), %rdi
movq %rax, (%rdi)
movl $0x215245, 0x8(%rdi)    # imm = 0x215245
movq %rdi, (%rsp)
leaq 0xee23(%rip), %rdx      # 0x56d54
jmp 0x47f74
xorl %eax, %eax
callq 0x18160
testl %eax, %eax
je 0x47fad
movq 0x58(%rbx), %rax
movl $0x1, 0xf78(%rax)
movups 0xee37(%rip), %xmm0     # 0x56d8a
leaq 0xb0(%rsp), %rdi
movups %xmm0, 0x9(%rdi)
movups 0xee1b(%rip), %xmm0     # 0x56d81
movaps %xmm0, (%rdi)
movq %rdi, (%rsp)
leaq 0xee26(%rip), %rdx      # 0x56d9a
leaq 0xedc5(%rip), %r9       # 0x56d40
pushq $0x5
popq %rcx
pushq $-0x2a
popq %r8
movl $0x1388, %esi           # imm = 0x1388
xorl %eax, %eax
callq 0x18f30
leaq 0xb0(%rsp), %rdi
callq 0x186c0
movw $0x2022, 0xb0(%rsp,%rax) # imm = 0x2022
movb $0x0, 0xb2(%rsp,%rax)
movq 0x58(%rbx), %rax
movl 0xf7c(%rax), %ecx
addl $0xa, %ecx
cmpl %ecx, (%rbp)
jle 0x47fce
andl $0x0, 0xf78(%rax)
andq $0x0, 0x9130(%rax)
pushq $0x1
popq %rbp
cmpb $0x0, 0xb0(%rsp)
je 0x47ce0
pushq $0x4
popq %rdi
movq 0x1e617(%rip), %r14     # 0x66600
callq *0xc8(%r14)
leaq 0xb0(%rsp), %rdi
callq *0xe8(%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq *0xb8(%r14)
jmp 0x47ce0