// File: /workspace/github_c_makefile_star2_O1/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 $0x1428, %rsp           # imm = 0x1428
movq 0x58(%rdi), %rax
xorl %ebp, %ebp
cmpl $0x0, 0xe24(%rax)
jne 0x4caeb
cmpl $0x0, 0xe2c(%rax)
jne 0x4caeb
cmpl $0x0, 0xe28(%rax)
jne 0x4caeb
cmpl $0x0, 0xf74(%rax)
jne 0x4caeb
cmpl $0x0, 0xf80(%rax)
jne 0x4caeb
cmpl $0x0, 0xe34(%rax)
je 0x4caff
movl %ebp, %eax
addq $0x1428, %rsp           # imm = 0x1428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r14
movq %rdi, %rbx
movl 0x10fc(%rax), %ecx
testl %ecx, %ecx
je 0x4cb33
movq 0x1d28a(%rip), %rdx     # 0x69da0
movl (%rdx), %edx
subl %ecx, %edx
addl 0x9128(%rax), %edx
imull $0xcccccccd, %edx, %ecx # imm = 0xCCCCCCCD
movl $0x19999998, %edx       # imm = 0x19999998
addl %edx, %ecx
rorl %ecx
cmpl %edx, %ecx
ja 0x4caeb
movq 0x1d266(%rip), %rbp     # 0x69da0
movl (%rbp), %ecx
movl %ecx, 0x10fc(%rax)
movb $0x0, 0xa0(%rsp)
movss 0xeda9(%rip), %xmm0     # 0x5b8fc
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movss (%rax), %xmm0
leaq 0x28(%rsp), %r15
movss %xmm0, (%r15)
movss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%r15)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r15)
movss 0xed76(%rip), %xmm0     # 0x5b900
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
callq 0x19510
movss (%rax), %xmm0
leaq 0x1c(%rsp), %r12
movss %xmm0, (%r12)
movss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%r12)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%r12)
movl $0xebc, %edi            # imm = 0xEBC
addq 0x58(%rbx), %rdi
leaq 0x4c(%rsp), %r13
leaq 0x40(%rsp), %rdx
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x183a0
movss 0xed23(%rip), %xmm0     # 0x5b904
movq %r13, %rdi
movq %r13, %rsi
callq 0x189d0
movss 0x4(%rbx), %xmm0
leaq 0x34(%rsp), %rsi
movss %xmm0, (%rsi)
movss 0x8(%rbx), %xmm1
movss %xmm1, 0x4(%rsi)
movss 0xc(%rbx), %xmm2
movss %xmm2, 0x8(%rsi)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm3
addss %xmm2, %xmm3
movss %xmm3, 0x8(%rsi)
addss (%r13), %xmm0
leaq 0x10(%rsp), %r8
movss %xmm0, (%r8)
addss 0x4(%r13), %xmm1
movss %xmm1, 0x4(%r8)
addss 0x8(%r13), %xmm3
movss %xmm3, 0x8(%r8)
movq 0x1c9ad(%rip), %rax     # 0x69600
movl $0x6000003, (%rsp)      # imm = 0x6000003
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %rax, %r12
movq %rbx, %r9
callq *0x60(%rax)
movq 0x40(%r13), %rax
testq %rax, %rax
je 0x4cc97
cmpq $0x0, 0x58(%rax)
je 0x4cc97
movq 0x58(%rbx), %rcx
movq %rax, 0x9130(%rcx)
movl (%rbp), %eax
movl %eax, 0xf7c(%rcx)
jmp 0x4cca6
movq 0x58(%rbx), %rax
movq $0x0, 0x9130(%rax)
movq 0x58(%rbx), %rax
movq 0x9130(%rax), %r15
testq %r15, %r15
je 0x4cd2f
movq 0x58(%r15), %rsi
testq %rsi, %rsi
je 0x4cd2f
movl $0x1, 0xf78(%rax)
testq %r14, %r14
je 0x4ccdd
addq $0x2c0, %rsi            # imm = 0x2C0
movq %r14, %rdi
callq 0x182a0
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%r15), %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x182a0
movq 0x58(%r15), %rax
movl 0x1100(%rax), %eax
movq 0x58(%rbx), %rcx
cmpl 0x1100(%rcx), %eax
leaq 0xed3f(%rip), %rax      # 0x5ba50
leaq 0xa2cf(%rip), %r9       # 0x56fe7
cmoveq %rax, %r9
movq %r14, (%rsp)
leaq 0xed9e(%rip), %rdx      # 0x5bac5
movq %r14, %rdi
jmp 0x4cdb9
xorl %eax, %eax
callq 0x18cf0
testl %eax, %eax
je 0x4cd71
movq 0x58(%rbx), %rax
movl $0x1, 0xf78(%rax)
movabsq $0x564f20484354414d, %rax # imm = 0x564F20484354414D
leaq 0xa0(%rsp), %rdi
movq %rax, (%rdi)
movl $0x215245, 0x8(%rdi)    # imm = 0x215245
movq %rdi, (%rsp)
leaq 0xecf5(%rip), %rdx      # 0x5ba64
jmp 0x4cdb2
xorl %eax, %eax
callq 0x18160
testl %eax, %eax
je 0x4cdef
movq 0x58(%rbx), %rax
movl $0x1, 0xf78(%rax)
movups 0xed09(%rip), %xmm0     # 0x5ba9a
leaq 0xa0(%rsp), %rdi
movups %xmm0, 0x9(%rdi)
movups 0xeced(%rip), %xmm0     # 0x5ba91
movaps %xmm0, (%rdi)
movq %rdi, (%rsp)
leaq 0xecf8(%rip), %rdx      # 0x5baaa
leaq 0xec97(%rip), %r9       # 0x5ba50
movl $0x1388, %esi           # imm = 0x1388
movl $0x5, %ecx
movl $0xffffffd6, %r8d       # imm = 0xFFFFFFD6
xorl %eax, %eax
callq 0x18e10
leaq 0xa0(%rsp), %rdi
callq 0x18680
movw $0x2022, 0xa0(%rsp,%rax) # imm = 0x2022
movb $0x0, 0xa2(%rsp,%rax)
movq 0x58(%rbx), %rax
movl 0xf7c(%rax), %ecx
addl $0xa, %ecx
cmpl %ecx, (%rbp)
jle 0x4ce16
movl $0x0, 0xf78(%rax)
movq $0x0, 0x9130(%rax)
movl $0x1, %ebp
cmpb $0x0, 0xa0(%rsp)
je 0x4caeb
movl $0x4, %edi
callq *0xc8(%r12)
leaq 0xa0(%rsp), %rdi
callq *0xe8(%r12)
movq %rbx, %rdi
xorl %esi, %esi
callq *0xb8(%r12)
jmp 0x4caeb