// File: /workspace/github_c_makefile_star2_O3/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), %rax
xorl %ebp, %ebp
cmpl $0x0, 0xe24(%rax)
jne 0x4be04
cmpl $0x0, 0xe2c(%rax)
jne 0x4be04
cmpl $0x0, 0xe28(%rax)
jne 0x4be04
cmpl $0x0, 0xf74(%rax)
jne 0x4be04
cmpl $0x0, 0xf80(%rax)
jne 0x4be04
cmpl $0x0, 0xe34(%rax)
je 0x4be18
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(%rax), %edx
movq 0x1cf75(%rip), %rcx     # 0x68da0
movl (%rcx), %ecx
testl %edx, %edx
je 0x4be4e
movl %ecx, %esi
subl %edx, %esi
addl 0x9128(%rax), %esi
imull $0xcccccccd, %esi, %edx # imm = 0xCCCCCCCD
movl $0x19999998, %esi       # imm = 0x19999998
addl %esi, %edx
rorl %edx
cmpl %esi, %edx
ja 0x4be04
movl %ecx, 0x10fc(%rax)
movb $0x0, 0xb0(%rsp)
movss 0xedc8(%rip), %xmm0     # 0x5ac2c
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movsd (%rax), %xmm0
leaq 0x30(%rsp), %r15
movsd %xmm0, (%r15)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r15)
movss 0xeda0(%rip), %xmm0     # 0x5ac30
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
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 0x183a0
movss 0xed59(%rip), %xmm0     # 0x5ac34
movq %r13, %rdi
movq %r13, %rsi
callq 0x189d0
movsd 0x4(%rbx), %xmm0
leaq 0x40(%rsp), %rsi
movsd %xmm0, (%rsi)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
xorps %xmm1, %xmm1
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 0x1c6cd(%rip), %rax     # 0x68600
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 0x4c007
cmpq $0x0, 0x58(%r13)
je 0x4c007
movq 0x58(%rbx), %r12
movq %r13, 0x9130(%r12)
movq 0x1ce27(%rip), %rbp     # 0x68da0
movl (%rbp), %eax
movl %eax, 0xf7c(%r12)
movq 0x58(%r13), %r15
testq %r15, %r15
je 0x4c01d
movl $0x1, 0xf78(%r12)
testq %r14, %r14
je 0x4bfbc
addq $0x2c0, %r15            # imm = 0x2C0
movq %r14, %rdi
movq %r15, %rsi
callq 0x182a0
movq 0x58(%r13), %r15
movq 0x58(%rbx), %r12
leaq 0x2c0(%r15), %rsi
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x182a0
movl 0x1100(%r15), %eax
cmpl 0x1100(%r12), %eax
leaq 0xed97(%rip), %rax      # 0x5ad80
leaq 0xa0eb(%rip), %r9       # 0x560db
cmoveq %rax, %r9
movq %r14, (%rsp)
leaq 0xedf6(%rip), %rdx      # 0x5adf5
movq %r14, %rdi
jmp 0x4c0a7
movq 0x58(%rbx), %rax
movq $0x0, 0x9130(%rax)
movq 0x1cd83(%rip), %rbp     # 0x68da0
xorl %eax, %eax
callq 0x18cf0
testl %eax, %eax
je 0x4c05f
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 0xed37(%rip), %rdx      # 0x5ad94
jmp 0x4c0a0
xorl %eax, %eax
callq 0x18160
testl %eax, %eax
je 0x4c0dd
movq 0x58(%rbx), %rax
movl $0x1, 0xf78(%rax)
movups 0xed4b(%rip), %xmm0     # 0x5adca
leaq 0xb0(%rsp), %rdi
movups %xmm0, 0x9(%rdi)
movups 0xed2f(%rip), %xmm0     # 0x5adc1
movaps %xmm0, (%rdi)
movq %rdi, (%rsp)
leaq 0xed3a(%rip), %rdx      # 0x5adda
leaq 0xecd9(%rip), %r9       # 0x5ad80
movl $0x1388, %esi           # imm = 0x1388
movl $0x5, %ecx
movl $0xffffffd6, %r8d       # imm = 0xFFFFFFD6
xorl %eax, %eax
callq 0x18e10
leaq 0xb0(%rsp), %rdi
callq 0x18680
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 0x4c104
movl $0x0, 0xf78(%rax)
movq $0x0, 0x9130(%rax)
movl $0x1, %ebp
cmpb $0x0, 0xb0(%rsp)
je 0x4be04
movl $0x4, %edi
movq 0x1c4dd(%rip), %r14     # 0x68600
callq *0xc8(%r14)
leaq 0xb0(%rsp), %rdi
callq *0xe8(%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq *0xb8(%r14)
jmp 0x4be04