// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/p_hud.c
// Function: CTFSquadboardMessage
void CTFSquadboardMessage (edict_t *ent, edict_t* killer) // ADC
{
	char	entry[MAX_MSGLEN];
	char	string[MAX_MSGLEN];
	int		len, i, j, team, ready;
	edict_t		*cl_ent;
	int maxsize = 1000;

	gclient_t* clients [MAX_CLIENTS];
	int clientCount = 0;
	gclient_t* sortedClients [MAX_CLIENTS];
	int sortedCount = 0;

	int teamOfInterest = 0;

	char* squad = 0;
	int numCategoryLines = 0;

	char readyString [] = "string2"; // green string
	char notReadyString [] = "string"; // white string

	char statusStart [MAX_STATUS_LEN];
	int greenStatusLen = (int)strlen (GREEN_STATUS_STR);

	int widestName = 0; // in chars

	for (i = 0; i< MAX_CLIENTS; i++)
		clients [i] = sortedClients [i] = 0;

	teamOfInterest = (ent->client->ctf.teamnum == CTF_TEAM_RED) ? 0 : 1;

	for (i = 0; i< game.maxclients; i++)
	{
		cl_ent = g_edicts + 1 + i;
		if (!cl_ent->inuse)
			continue;
		if (game.clients[i].ctf.teamnum == CTF_TEAM_RED)
			team = 0;
		else if (game.clients[i].ctf.teamnum == CTF_TEAM_BLUE)
			team = 1;
		else
			continue; // unknown team?

		if (team == teamOfInterest)
		{
			len = (int)strlen(game.clients[i].pers.netname);
			clients [clientCount++] = &game.clients [i];

			if (len > widestName)
				widestName = len;
		}
	}

	// We want to put the predefined categories first
	// in the list, then any remaining ones.

	for (i = 0, ready = 1; ready; i++) // squad loop
	{
		ready = 0;

		switch (i)
		{
		case 0:	 squad = "Offense"; break;
		case 1:	 squad = "Middle";  break;
		case 2:	 squad = "Defense"; break;
		default: squad = 0;         break;
		}

		for (j = 0; j< game.maxclients; j++) // client loop
		{
			if (clients[j])
			{
				ready = 1;

				if (squad == 0)
					squad = clients[j]->pers.squad;

				if (!Q_stricmp (clients[j]->pers.squad, squad))
				{
					sortedClients [sortedCount++] = clients [j];
					clients [j] = 0;
				}
			}
		}
	}

	// print level name and exit rules
	// add the clients in sorted order
	*string = 0;
	len = 0;

	if (teamOfInterest == 0) // red
		strcpy (string, "xv 0 yv 0 picn redlion_i xv 32 yv 0 picn redtag ");
	else  // blue
		strcpy (string, "xv 0 yv 0 picn bluewolf_i xv 32 yv 0 picn bluetag ");

	strcat (string, "xv 48 yv 10 string \"Squad Board\" ");

	squad = 0;

	for (i = 0; i< 16 ; i++)
	{
		if (i >= sortedCount)
			break; // we're done

		*entry = 0;

		if (!squad || Q_stricmp (squad, sortedClients[i]->pers.squad))
		{
			squad = sortedClients[i]->pers.squad;

			sprintf(entry+(int)strlen(entry),
				"xv 0 yv %d string \"%s\" ",
				42 + i * 8 + numCategoryLines * 8,
				sortedClients[i]->pers.squad);

			numCategoryLines++;
		}

		// If the status starts with "Ready", then it should be shown
		// in green.

		strncpy (statusStart, sortedClients[i]->pers.squadStatus, 
			greenStatusLen);
		statusStart[greenStatusLen] = 0;

		ready = !Q_stricmp (statusStart, GREEN_STATUS_STR);

		// Note that the width %*s below is the widest chars
		// for a netname. We want the names padded with spaces
		// to make the status line up.

		sprintf(entry+(int)strlen(entry),
			"xv 0 yv %d %s \"   %-*s %s\" ",
			42 + i * 8 + numCategoryLines * 8,
			ready ? readyString : notReadyString,
			widestName, sortedClients[i]->pers.netname,
			sortedClients[i]->pers.squadStatus);

		if (maxsize - len > (int)strlen(entry)) {
			strcat(string, entry);
			len = (int)strlen(string);
		}
	}

	gi.WriteByte (svc_layout);
	gi.WriteString (string);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1bf0, %rsp           # imm = 0x1BF0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x3e8, -0xb34(%rbp)    # imm = 0x3E8
movl $0x0, -0x1344(%rbp)
movl $0x0, -0x1b54(%rbp)
movl $0x0, -0x1b58(%rbp)
movq $0x0, -0x1b60(%rbp)
movl $0x0, -0x1b64(%rbp)
movq 0x17a5f(%rip), %rax     # 0x77606
movq %rax, -0x1b6c(%rbp)
movl 0x133bb(%rip), %eax     # 0x72f6f
movl %eax, -0x1b73(%rbp)
movw 0x133b2(%rip), %ax      # 0x72f73
movw %ax, -0x1b6f(%rbp)
movb 0x133a7(%rip), %al      # 0x72f75
movb %al, -0x1b6d(%rbp)
movl $0x5, -0x1ba4(%rbp)
movl $0x0, -0x1ba8(%rbp)
movl $0x0, -0xb18(%rbp)
cmpl $0x100, -0xb18(%rbp)    # imm = 0x100
jge 0x5fc35
movslq -0xb18(%rbp), %rax
movq $0x0, -0x1b50(%rbp,%rax,8)
movslq -0xb18(%rbp), %rax
movq $0x0, -0x1340(%rbp,%rax,8)
movl -0xb18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb18(%rbp)
jmp 0x5fbf2
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x1, %edx
cmovel %ecx, %eax
movl %eax, -0x1b58(%rbp)
movl $0x0, -0xb18(%rbp)
movl -0xb18(%rbp), %eax
movq 0x230d3(%rip), %rcx     # 0x82d40
cmpl 0x610(%rcx), %eax
jge 0x5fdd8
movq 0x228d8(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movslq -0xb18(%rbp), %rcx
imulq $0x4a8, %rcx, %rcx      # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0xb30(%rbp)
movq -0xb30(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x5fcb3
jmp 0x5fdc4
movq 0x23086(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rax
movslq -0xb18(%rbp), %rcx
imulq $0x9140, %rcx, %rcx     # imm = 0x9140
addq %rcx, %rax
cmpl $0x1, 0x1100(%rax)
jne 0x5fce7
movl $0x0, -0xb20(%rbp)
jmp 0x5fd22
movq 0x23052(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rax
movslq -0xb18(%rbp), %rcx
imulq $0x9140, %rcx, %rcx     # imm = 0x9140
addq %rcx, %rax
cmpl $0x2, 0x1100(%rax)
jne 0x5fd1b
movl $0x1, -0xb20(%rbp)
jmp 0x5fd20
jmp 0x5fdc4
jmp 0x5fd22
movl -0xb20(%rbp), %eax
cmpl -0x1b58(%rbp), %eax
jne 0x5fdc2
movq 0x23005(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rdi
movslq -0xb18(%rbp), %rax
imulq $0x9140, %rax, %rax     # imm = 0x9140
addq %rax, %rdi
addq $0xc0, %rdi
addq $0x200, %rdi            # imm = 0x200
callq 0x186e0
movl %eax, -0xb14(%rbp)
movq 0x22fcd(%rip), %rax     # 0x82d40
movq 0x408(%rax), %rcx
movslq -0xb18(%rbp), %rax
imulq $0x9140, %rax, %rax     # imm = 0x9140
addq %rax, %rcx
movl -0x1344(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1344(%rbp)
cltq
movq %rcx, -0x1340(%rbp,%rax,8)
movl -0xb14(%rbp), %eax
cmpl -0x1ba8(%rbp), %eax
jle 0x5fdc0
movl -0xb14(%rbp), %eax
movl %eax, -0x1ba8(%rbp)
jmp 0x5fdc2
jmp 0x5fdc4
movl -0xb18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb18(%rbp)
jmp 0x5fc60
movl $0x0, -0xb18(%rbp)
movl $0x1, -0xb24(%rbp)
cmpl $0x0, -0xb24(%rbp)
je 0x5ff72
movl $0x0, -0xb24(%rbp)
movl -0xb18(%rbp), %eax
movl %eax, -0x1bac(%rbp)
testl %eax, %eax
je 0x5fe2f
jmp 0x5fe15
movl -0x1bac(%rbp), %eax
subl $0x1, %eax
je 0x5fe3f
jmp 0x5fe22
movl -0x1bac(%rbp), %eax
subl $0x2, %eax
je 0x5fe4f
jmp 0x5fe5f
leaq 0x177d8(%rip), %rax     # 0x7760e
movq %rax, -0x1b60(%rbp)
jmp 0x5fe6a
leaq 0x177d0(%rip), %rax     # 0x77616
movq %rax, -0x1b60(%rbp)
jmp 0x5fe6a
leaq 0x177c7(%rip), %rax     # 0x7761d
movq %rax, -0x1b60(%rbp)
jmp 0x5fe6a
movq $0x0, -0x1b60(%rbp)
movl $0x0, -0xb1c(%rbp)
movl -0xb1c(%rbp), %eax
movq 0x22ebf(%rip), %rcx     # 0x82d40
cmpl 0x610(%rcx), %eax
jge 0x5ff5c
movslq -0xb1c(%rbp), %rax
cmpq $0x0, -0x1340(%rbp,%rax,8)
je 0x5ff46
movl $0x1, -0xb24(%rbp)
cmpq $0x0, -0x1b60(%rbp)
jne 0x5fed9
movslq -0xb1c(%rbp), %rax
movq -0x1340(%rbp,%rax,8), %rax
addq $0xc0, %rax
addq $0x210, %rax            # imm = 0x210
movq %rax, -0x1b60(%rbp)
movslq -0xb1c(%rbp), %rax
movq -0x1340(%rbp,%rax,8), %rdi
addq $0xc0, %rdi
addq $0x210, %rdi            # imm = 0x210
movq -0x1b60(%rbp), %rsi
callq 0x186f0
cmpl $0x0, %eax
jne 0x5ff44
movslq -0xb1c(%rbp), %rax
movq -0x1340(%rbp,%rax,8), %rcx
movl -0x1b54(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1b54(%rbp)
cltq
movq %rcx, -0x1b50(%rbp,%rax,8)
movslq -0xb1c(%rbp), %rax
movq $0x0, -0x1340(%rbp,%rax,8)
jmp 0x5ff46
jmp 0x5ff48
movl -0xb1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb1c(%rbp)
jmp 0x5fe74
jmp 0x5ff5e
movl -0xb18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb18(%rbp)
jmp 0x5fdec
movb $0x0, -0xb10(%rbp)
movl $0x0, -0xb14(%rbp)
cmpl $0x0, -0x1b58(%rbp)
jne 0x5ffa1
leaq -0xb10(%rbp), %rdi
leaq 0x1768b(%rip), %rsi     # 0x77625
callq 0x182c0
jmp 0x5ffb4
leaq -0xb10(%rbp), %rdi
leaq 0x176a7(%rip), %rsi     # 0x77656
callq 0x182c0
leaq -0xb10(%rbp), %rdi
leaq 0x176c7(%rip), %rsi     # 0x77689
callq 0x19880
movq $0x0, -0x1b60(%rbp)
movl $0x0, -0xb18(%rbp)
cmpl $0x10, -0xb18(%rbp)
jge 0x6027d
movl -0xb18(%rbp), %eax
cmpl -0x1b54(%rbp), %eax
jl 0x5fffc
jmp 0x6027d
movb $0x0, -0x590(%rbp)
cmpq $0x0, -0x1b60(%rbp)
je 0x6003f
movq -0x1b60(%rbp), %rdi
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %rsi
addq $0xc0, %rsi
addq $0x210, %rsi            # imm = 0x210
callq 0x186f0
cmpl $0x0, %eax
je 0x600d8
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %rax
addq $0xc0, %rax
addq $0x210, %rax            # imm = 0x210
movq %rax, -0x1b60(%rbp)
leaq -0x590(%rbp), %rax
movq %rax, -0x1bb8(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x186e0
movq -0x1bb8(%rbp), %rdi
cltq
addq %rax, %rdi
movl -0xb18(%rbp), %edx
shll $0x3, %edx
addl $0x2a, %edx
movl -0x1b64(%rbp), %eax
shll $0x3, %eax
addl %eax, %edx
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %rcx
addq $0xc0, %rcx
addq $0x210, %rcx            # imm = 0x210
leaq 0x175e9(%rip), %rsi     # 0x776ab
movb $0x0, %al
callq 0x19940
movl -0x1b64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b64(%rbp)
leaq -0x1ba0(%rbp), %rdi
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %rsi
addq $0xc0, %rsi
addq $0x220, %rsi            # imm = 0x220
movslq -0x1ba4(%rbp), %rdx
callq 0x181e0
movslq -0x1ba4(%rbp), %rax
movb $0x0, -0x1ba0(%rbp,%rax)
leaq -0x1ba0(%rbp), %rdi
leaq 0x1759e(%rip), %rsi     # 0x776c3
callq 0x186f0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0xb24(%rbp)
leaq -0x590(%rbp), %rax
movq %rax, -0x1bd0(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x186e0
movq %rax, %rcx
movq -0x1bd0(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x1bc8(%rbp)
movl -0xb18(%rbp), %eax
shll $0x3, %eax
addl $0x2a, %eax
movl -0x1b64(%rbp), %ecx
shll $0x3, %ecx
addl %ecx, %eax
movl %eax, -0x1bbc(%rbp)
cmpl $0x0, -0xb24(%rbp)
je 0x601a4
leaq -0x1b6c(%rbp), %rax
movq %rax, -0x1bd8(%rbp)
jmp 0x601b2
leaq -0x1b73(%rbp), %rax
movq %rax, -0x1bd8(%rbp)
movl -0x1bbc(%rbp), %edx
movq -0x1bc8(%rbp), %rdi
movq -0x1bd8(%rbp), %rcx
movl -0x1ba8(%rbp), %r8d
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %r9
addq $0xc0, %r9
addq $0x200, %r9             # imm = 0x200
movslq -0xb18(%rbp), %rax
movq -0x1b50(%rbp,%rax,8), %rax
addq $0xc0, %rax
addq $0x220, %rax            # imm = 0x220
leaq 0x174bd(%rip), %rsi     # 0x776c9
movq %rax, (%rsp)
movb $0x0, %al
callq 0x19940
movl -0xb34(%rbp), %eax
subl -0xb14(%rbp), %eax
movl %eax, -0x1bdc(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x186e0
movq %rax, %rcx
movl -0x1bdc(%rbp), %eax
cmpl %ecx, %eax
jle 0x60267
leaq -0xb10(%rbp), %rdi
leaq -0x590(%rbp), %rsi
callq 0x19880
leaq -0xb10(%rbp), %rdi
callq 0x186e0
movl %eax, -0xb14(%rbp)
jmp 0x60269
movl -0xb18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb18(%rbp)
jmp 0x5ffdc
movl $0x4, %edi
movq 0x22377(%rip), %rax     # 0x82600
callq *0xc8(%rax)
movq 0x2236a(%rip), %rax     # 0x82600
movq 0xe8(%rax), %rax
leaq -0xb10(%rbp), %rdi
callq *%rax
addq $0x1bf0, %rsp           # imm = 0x1BF0
popq %rbp
retq
nop