// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_SafePrint
void ctf_SafePrint(edict_t * ent, long print_priority, char * buf)
{
	long i;
	size_t printsize;
	char *cptr = NULL;
	char tempbuf[MAX_INFO_STRING];

	if (!ctf_validateplayer(ent, CTF_TEAM_IGNORETEAM))
		return;

	if (buf != NULL) //this is a queue request
	{
		ent->client->ctf.printready = true;
		printsize = strlen(ent->client->ctf.printdata[print_priority]);
		if ( printsize < (MAX_PRINT_BUF - 2048) )
			strncat(ent->client->ctf.printdata[print_priority], buf, 2000);
	}
	else
	{
		ent->client->ctf.printready = false;
		for (i=PRINT_LOW; i<=PRINT_CHAT; i++)
		{
			printsize = strlen(ent->client->ctf.printdata[i]);
			if (printsize <= 0)
				continue;
			else if (printsize < 50) //print it all
			{
				gi.cprintf(ent, i, "%s", ent->client->ctf.printdata[i]);
				strcpy(ent->client->ctf.printdata[i], "");
				ent->client->ctf.printready = true;
			}
			else
			{
				//just print up to the nearest return
				cptr = strchr(&ent->client->ctf.printdata[i][1], '\n');
				cptr++; //include the return
				memset(tempbuf, 0, 250);
				strncpy(tempbuf, ent->client->ctf.printdata[i], (long) (cptr - ent->client->ctf.printdata[i]) );
				strcpy(ent->client->ctf.printdata[i], cptr);
				gi.cprintf(ent, i, "%s", tempbuf);
				ent->client->ctf.printready = true;
			}
		}
	}
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbp
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x18ce0
testl %eax, %eax
je 0x226f9
movq 0x58(%rbp), %r14
testq %r12, %r12
je 0x225f8
movl $0x1, 0x911c(%r14)
shlq $0xd, %r15
leaq (%r14,%r15), %rbx
addq $0x111c, %rbx           # imm = 0x111C
movq %rbx, %rdi
callq 0x18680
cmpq $0x17ff, %rax           # imm = 0x17FF
ja 0x226f9
movl $0x7d0, %edx            # imm = 0x7D0
movq %rbx, %rdi
movq %r12, %rsi
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x188f0
movl $0x0, 0x911c(%r14)
movl $0x111d, %r15d          # imm = 0x111D
movq $-0x111b, %rbx          # imm = 0xEEE5
xorl %r12d, %r12d
movq %rbp, (%rsp)
leaq (%r14,%r15), %r13
decq %r13
movq %r13, %rdi
callq 0x18680
testq %rax, %rax
je 0x226de
cmpq $0x31, %rax
ja 0x2265e
movq %rbp, %rdi
movl %r12d, %esi
leaq 0x3036b(%rip), %rdx     # 0x529ad
movq %r13, %rcx
xorl %eax, %eax
movq 0x45fb2(%rip), %r8      # 0x68600
callq *0x10(%r8)
movq 0x58(%rbp), %rax
movb $0x0, -0x1(%rax,%r15)
jmp 0x226cf
leaq (%r14,%r15), %rdi
movl $0xa, %esi
callq 0x18730
movq %rax, %rbp
incq %rax
movq %rax, 0x8(%rsp)
movl $0xfa, %edx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x18880
subq %r14, %rbp
addq %rbx, %rbp
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq (%rsp), %rbp
callq 0x181c0
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x182a0
movq %rbp, %rdi
movl %r12d, %esi
leaq 0x302ee(%rip), %rdx     # 0x529ad
movq %r14, %rcx
xorl %eax, %eax
movq 0x45f35(%rip), %r8      # 0x68600
callq *0x10(%r8)
movq 0x58(%rbp), %r14
movl $0x1, 0x911c(%r14)
incq %r12
addq $0x2000, %r15           # imm = 0x2000
addq $-0x2000, %rbx          # imm = 0xE000
cmpq $0x4, %r12
jne 0x22617
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq