// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_cmds.c
// Function: Cmd_InfoEnt_f
void Cmd_InfoEnt_f (edict_t *ent)
{
	edict_t	*banner;
	FILE	*fp;
	char	*p;
	char	name[MAX_INFO_STRING];
	char	entities[MAX_INFO_STRING];
	double f1, f2, f3, a1, a2, a3;
	int	red = 0;
	vec3_t	forward, right, start, offset, mins, maxs, end;
	trace_t	tr;
	float	*v;
	char	enttype[100] = { 0 };
	char	entcolor[100] = { 0 };

	v = tv(-8,-8,-2);
	VectorCopy (v, mins);
	v = tv(8,8,2);
	VectorCopy (v, maxs);

	// Set out ending point to our starting point
	AngleVectors (ent->client->v_angle, forward, right, NULL);
	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);


	p = gi.args();

	if (sscanf(p, "%s %[^\n]", enttype, entcolor))
	{
		if (!Q_stricmp(entcolor, "red"))
			red = 1;
		else
			red = 0;
		p = entcolor;
		if (*p == '"')
		{
			p++;
			p[strlen(p)-1] = 0;
			strcpy(name, p);
			strcpy(entcolor, name);
		}
	}
	else if (p)
		strcpy(p, enttype);
	else
		return;


	// MISC_CTF_BANNER

	if (!strcmp(enttype, "misc_ctf_banner"))
	{
		if (tr.ent)
		{
			vectoangles(tr.plane.normal, end);
			a1 = end[0] = 0;
			a2 = end[1];
			a3 = end[2] = 0;
		}
		else
		{
			return;
		}


		tr.endpos[2] -= 248;

		f1 = tr.endpos[0];
		f2 = tr.endpos[1];
		f3 = tr.endpos[2];


		banner = G_Spawn();
		banner->classname = ED_NewString ("misc_ctf_banner");
		if (red)
			banner->spawnflags = 0;
		else
			banner->spawnflags = 1;
		VectorCopy(tr.endpos, banner->s.origin);
		VectorCopy(end, banner->s.angles);
		ED_CallSpawn(banner);

		v = tv(-8,-8,0);
		VectorCopy (v, mins);
		v = tv(8,8,248);
		VectorCopy (v, maxs);
		tr = gi.trace (banner->s.origin, mins, maxs, banner->s.origin, banner, MASK_SOLID);
		if (tr.startsolid)
		{
			G_FreeEdict(banner);
			gi.centerprintf(ent, "Banner Failed. Deleting Entity\n");
			return;
		}

		if (red)
		{
			sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
				"\"angles\" \"%.0f %.0f %.0f\"\n"
				"\"classname\" \"misc_ctf_banner\"\n"
				"}\n",
				f1, f2, f3, a1, a2, a3);
		}
		else
		{
			sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
				"\"angles\" \"%.0f %.0f %.0f\"\n"
				"\"classname\" \"misc_ctf_banner\"\n"
				"\"spawnflags\" \"1\"\n"
				"}\n",
				f1, f2, f3, a1, a2, a3);
		}
	}

	// MISC_CTF_SMALL_BANNER

	else if (!strcmp(enttype, "misc_ctf_small_banner"))
	{
		if (tr.ent)
		{
			tr.plane.normal[2] = 0;
			vectoangles(tr.plane.normal, end);
			a1 = end[0] = 0;
			a2 = end[1];
			a3 = end[2] = 0;
		}
		else
		{
			return;
		}


		tr.endpos[2] -= 124;

		f1 = tr.endpos[0];
		f2 = tr.endpos[1];
		f3 = tr.endpos[2];


		banner = G_Spawn();
		banner->classname = ED_NewString ("misc_ctf_small_banner");
		if (red)
			banner->spawnflags = 0;
		else
			banner->spawnflags = 1;
		VectorCopy(tr.endpos, banner->s.origin);
		VectorCopy(end, banner->s.angles);
		ED_CallSpawn(banner);

		v = tv(-8,-8,0);
		VectorCopy (v, mins);
		v = tv(8,8,124);
		VectorCopy (v, maxs);
		tr = gi.trace (banner->s.origin, mins, maxs, banner->s.origin, banner, MASK_SOLID);
		if (tr.startsolid)
		{
			G_FreeEdict(banner);
			gi.centerprintf(ent, "Small Banner Failed. Deleting Entity\n");
			return;
		}

		if (red)
		{
			sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
				"\"angles\" \"%.0f %.0f %.0f\"\n"
				"\"classname\" \"misc_ctf_small_banner\"\n"
				"}\n",
				f1, f2, f3, a1, a2, a3);
		}
		else
		{
			sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
				"\"angles\" \"%.0f %.0f %.0f\"\n"
				"\"classname\" \"misc_ctf_small_banner\"\n"
				"\"spawnflags\" \"1\"\n"
				"}\n",
				f1, f2, f3, a1, a2, a3);
		}
	}
	// INFO_POSITION

	else if (!strcmp(enttype, "info_position"))
	{
		f1 = ent->s.origin[0];
		f2 = ent->s.origin[1];
		f3 = ent->s.origin[2];

		sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
			"\"classname\" \"info_position\"\n"
			"\"message\" \"%s\"\n}\n",
			f1, f2, f3, entcolor);

		banner = G_Spawn();
		banner->classname = ED_NewString (enttype);
		banner->message = ED_NewString (entcolor);
		VectorCopy(ent->s.origin, banner->s.origin);
		ED_CallSpawn(banner);

	}
		// INFO_FLAG_RED

	else if (!strcmp(enttype, "info_flag_red") ||
			 !strcmp(enttype, "info_flag_blue") ||
			 !strcmp(enttype, "info_player_red") ||
			 !strcmp(enttype, "info_player_blue"))
	{
		f1 = ent->s.origin[0];
		f2 = ent->s.origin[1];
		f3 = ent->s.origin[2];

		a1 = ent->s.angles[0];  // Filled out this so the
		a2 = ent->s.angles[1];  // sprintf below has enough
		a3 = ent->s.angles[2];  // fodder


		sprintf(entities, "{\n\"origin\" \"%.0f %.0f %.0f\"\n"
			"\"classname\" \"%s\"\n"
			"\"angle\" \"%.0f %.0f %.0f\"\n}\n",
			f1, f2, f3, enttype, a1,a2,a3);
			// Added a1,a2,a3 to fill out format

		banner = G_Spawn();
		banner->classname = ED_NewString (enttype);
		VectorCopy(ent->s.origin, banner->s.origin);
		VectorCopy(ent->s.angles, banner->s.angles);
		ED_CallSpawn(banner);
	}

	else
		return;


	strcpy (name, gamedir->string);
	strcat (name, "/info/");
	strcat (name, level.mapname);
	strcat (name, ".ent");

	fp = fopen (name, "a");
	fwrite(entities, 1, strlen(entities), fp);
	fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5c8, %rsp            # imm = 0x5C8
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rax
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
andl $0x0, 0x60(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x150(%rsp), %r15
movaps %xmm0, 0x50(%r15)
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
andl $0x0, 0x60(%r15)
movss 0x29dc1(%rip), %xmm0    # 0x5040c
movss 0x29dbd(%rip), %xmm2    # 0x50410
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x48(%rsp), %rcx
movsd %xmm0, (%rcx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rcx)
movss 0x2887e(%rip), %xmm0    # 0x4eef8
movss 0x28dea(%rip), %xmm2    # 0x4f46c
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x38(%rsp), %rcx
movsd %xmm0, (%rcx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rcx)
movl $0xebc, %edi            # imm = 0xEBC
addq 0x58(%rbx), %rdi
leaq 0x144(%rsp), %rbp
leaq 0x64(%rsp), %r14
movq %rbp, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x183d0
movss 0x2882c(%rip), %xmm0    # 0x4eef8
leaq 0x128(%rsp), %r12
movlps %xmm0, (%r12)
movl 0x278(%rbx), %eax
addl $-0x8, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x8(%r12)
leaq 0x4(%rbx), %rdi
leaq 0x138(%rsp), %r13
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
movq %r13, %r8
callq 0x190d0
movd 0x29cf6(%rip), %xmm0    # 0x50408
movq %xmm0, (%r12)
andl $0x0, 0x8(%r12)
leaq 0x58(%rsp), %r14
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
leaq 0x64(%rsp), %rcx
movq %r14, %r8
callq 0x190d0
movq 0x3fec0(%rip), %rbp     # 0x66600
movl $0x6000003, (%rsp)      # imm = 0x6000003
leaq 0xe0(%rsp), %rdi
movq %r13, %rsi
leaq 0x48(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %r14, %r8
movq %rbx, 0x18(%rsp)
movq %rbx, %r9
callq *0x60(%rbp)
callq *0x148(%rbp)
movq %rax, %rbx
leaq 0x2a5ec(%rip), %rsi     # 0x50d66
movq %rax, %rdi
leaq 0x70(%rsp), %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x19110
testl %eax, %eax
je 0x267ef
leaq 0x28d40(%rip), %rsi     # 0x4f4d7
leaq 0x150(%rsp), %rbx
movq %rbx, %rdi
callq 0x186d0
testl %eax, %eax
sete %r15b
cmpb $0x22, (%rbx)
jne 0x26808
leaq 0x151(%rsp), %rbx
movq %rbx, %rdi
callq 0x186c0
movb $0x0, 0x150(%rsp,%rax)
leaq 0x3c0(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x182c0
leaq 0x150(%rsp), %rdi
movq %r14, %rsi
callq 0x182c0
jmp 0x26808
testq %rbx, %rbx
je 0x26e45
leaq 0x70(%rsp), %rsi
movq %rbx, %rdi
callq 0x182c0
xorl %r15d, %r15d
movdqa 0x70(%rsp), %xmm0
pcmpeqb 0x29c3a(%rip), %xmm0    # 0x50450
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x2696d
leaq 0x2a612(%rip), %rsi     # 0x50e3e
leaq 0x70(%rsp), %rdi
pushq $0x16
popq %rdx
callq 0x191e0
testl %eax, %eax
je 0x26afd
leaq 0x2872a(%rip), %rsi     # 0x4ef72
leaq 0x70(%rsp), %rdi
pushq $0xe
popq %rdx
callq 0x191e0
testl %eax, %eax
je 0x26c9d
leaq 0x286ec(%rip), %rsi     # 0x4ef50
leaq 0x70(%rsp), %rdi
pushq $0xe
popq %rdx
callq 0x191e0
testl %eax, %eax
je 0x268c2
leaq 0x286e2(%rip), %rsi     # 0x4ef5e
leaq 0x70(%rsp), %rdi
pushq $0xf
popq %rdx
callq 0x191e0
testl %eax, %eax
je 0x268c2
movdqa 0x70(%rsp), %xmm0
pcmpeqb 0x29bc5(%rip), %xmm0    # 0x50460
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x268c2
leaq 0x2a6f2(%rip), %rsi     # 0x50f9f
leaq 0x70(%rsp), %rdi
pushq $0x11
popq %rdx
callq 0x191e0
testl %eax, %eax
jne 0x26e45
movq 0x18(%rsp), %r15
cvtss2sd 0x4(%r15), %xmm0
cvtss2sd 0x8(%r15), %xmm1
cvtss2sd 0xc(%r15), %xmm2
cvtss2sd 0x10(%r15), %xmm3
cvtss2sd 0x14(%r15), %xmm4
cvtss2sd 0x18(%r15), %xmm5
leaq 0x2a6be(%rip), %rsi     # 0x50fb0
leaq 0x1c0(%rsp), %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rdx
movb $0x6, %al
callq 0x198c0
callq 0x198d0
movq %rax, %r14
movq %rbx, %rdi
callq 0x18280
movq %rax, 0x138(%r14)
movss 0x4(%r15), %xmm0
movss %xmm0, 0x4(%r14)
movss 0x8(%r15), %xmm0
movss %xmm0, 0x8(%r14)
movss 0xc(%r15), %xmm0
movss %xmm0, 0xc(%r14)
movss 0x10(%r15), %xmm0
movss %xmm0, 0x10(%r14)
movss 0x14(%r15), %xmm0
movss %xmm0, 0x14(%r14)
movd 0x18(%r15), %xmm0
movd %xmm0, 0x18(%r14)
jmp 0x26d21
cmpq $0x0, 0x120(%rsp)
je 0x26e45
leaq 0xf8(%rsp), %r12
leaq 0x58(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x19240
andl $0x0, (%r13)
cvtss2sd 0x4(%r13), %xmm0
movsd %xmm0, 0x30(%rsp)
andl $0x0, 0x8(%r13)
movss -0x4(%r12), %xmm0
addss 0x29a63(%rip), %xmm0    # 0x5041c
movss %xmm0, 0x10(%rsp)
movss %xmm0, -0x4(%r12)
cvtss2sd -0xc(%r12), %xmm0
movsd %xmm0, 0x28(%rsp)
cvtss2sd -0x8(%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x198d0
movq %rax, %r14
leaq 0x2a380(%rip), %rdi     # 0x50d6f
callq 0x18280
movq %rax, 0x138(%r14)
movl %r15d, %eax
xorb $0x1, %al
movzbl %al, %eax
movl %eax, 0x140(%r14)
movss -0xc(%r12), %xmm0
movl %r15d, 0x14(%rsp)
leaq 0x4(%r14), %r15
movss %xmm0, 0x4(%r14)
movss -0x8(%r12), %xmm0
movss %xmm0, 0x8(%r14)
movsd 0x4(%r13), %xmm0
movss (%r13), %xmm1
movhps -0x4(%r12), %xmm1       # xmm1 = xmm1[0,1],mem[0,1]
shufps $0x42, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[0,1]
movups %xmm1, 0xc(%r14)
movq %r14, %rdi
callq 0x194a0
movss 0x299b4(%rip), %xmm0    # 0x5040c
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x48(%rsp), %rbx
movsd %xmm0, (%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rbx)
movss 0x28476(%rip), %xmm0    # 0x4eef8
movss 0x29996(%rip), %xmm2    # 0x50420
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x38(%rsp), %rcx
movsd %xmm0, (%rcx)
movd 0x8(%rax), %xmm0
movd %xmm0, 0x8(%rcx)
movl $0x3, (%rsp)
leaq 0x1c0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r15, %r8
movq %r14, %r9
callq *0x60(%rbp)
pushq $0x9
popq %rcx
leaq 0xe0(%rsp), %rax
movq %rax, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
xorl %ecx, %ecx
cmpl %ecx, 0x4(%rax)
je 0x26d2b
movq %r14, %rdi
callq 0x19c50
leaq 0x2a362(%rip), %rsi     # 0x50e5a
jmp 0x26c8e
cmpq $0x0, 0x120(%rsp)
je 0x26e45
leaq 0xf8(%rsp), %r12
andl $0x0, 0x8(%r12)
leaq 0x58(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x19240
andl $0x0, (%r13)
cvtss2sd 0x4(%r13), %xmm0
movsd %xmm0, 0x30(%rsp)
andl $0x0, 0x8(%r13)
movss -0x4(%r12), %xmm0
addss 0x298c5(%rip), %xmm0    # 0x50414
movss %xmm0, 0x10(%rsp)
movss %xmm0, -0x4(%r12)
cvtss2sd -0xc(%r12), %xmm0
movsd %xmm0, 0x28(%rsp)
cvtss2sd -0x8(%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x198d0
movq %rax, %r14
leaq 0x2a2b9(%rip), %rdi     # 0x50e3e
callq 0x18280
movq %rax, 0x138(%r14)
movl %r15d, %eax
xorb $0x1, %al
movzbl %al, %eax
movl %eax, 0x140(%r14)
movss -0xc(%r12), %xmm0
movl %r15d, 0x14(%rsp)
leaq 0x4(%r14), %r15
movss %xmm0, 0x4(%r14)
movss -0x8(%r12), %xmm0
movss %xmm0, 0x8(%r14)
movsd 0x4(%r13), %xmm0
movss (%r13), %xmm1
movhps -0x4(%r12), %xmm1       # xmm1 = xmm1[0,1],mem[0,1]
shufps $0x42, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[0,1]
movups %xmm1, 0xc(%r14)
movq %r14, %rdi
callq 0x194a0
movss 0x2981e(%rip), %xmm0    # 0x5040c
xorps %xmm2, %xmm2
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x48(%rsp), %rbx
movsd %xmm0, (%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rbx)
movss 0x282e0(%rip), %xmm0    # 0x4eef8
movss 0x297f8(%rip), %xmm2    # 0x50418
movaps %xmm0, %xmm1
callq 0x196c0
movsd (%rax), %xmm0
leaq 0x38(%rsp), %rcx
movsd %xmm0, (%rcx)
movd 0x8(%rax), %xmm0
movd %xmm0, 0x8(%rcx)
movl $0x3, (%rsp)
leaq 0x1c0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r15, %r8
movq %r14, %r9
callq *0x60(%rbp)
pushq $0x9
popq %rcx
leaq 0xe0(%rsp), %rax
movq %rax, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
xorl %ecx, %ecx
cmpl %ecx, 0x4(%rax)
je 0x26d53
movq %r14, %rdi
callq 0x19c50
leaq 0x2a1c6(%rip), %rsi     # 0x50e54
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq *0x18(%rbp)
jmp 0x26e45
movq 0x18(%rsp), %r15
cvtss2sd 0x4(%r15), %xmm0
cvtss2sd 0x8(%r15), %xmm1
cvtss2sd 0xc(%r15), %xmm2
leaq 0x2a28a(%rip), %rsi     # 0x50f45
leaq 0x1c0(%rsp), %rdi
leaq 0x150(%rsp), %rbx
movq %rbx, %rdx
movb $0x3, %al
callq 0x198c0
callq 0x198d0
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x18280
movq %rax, 0x138(%r14)
movq %rbx, %rdi
callq 0x18280
movq %rax, 0x130(%r14)
movss 0x4(%r15), %xmm0
movss %xmm0, 0x4(%r14)
movss 0x8(%r15), %xmm0
movss %xmm0, 0x8(%r14)
movd 0xc(%r15), %xmm0
movd %xmm0, 0xc(%r14)
movq %r14, %rdi
callq 0x194a0
jmp 0x26da0
movq 0x28(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm4
cvtss2sd 0x10(%rsp), %xmm2
cmpb $0x0, 0x14(%rsp)
je 0x26d7b
leaq 0x2a02e(%rip), %rsi     # 0x50d7f
jmp 0x26d8b
movq 0x28(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm4
cvtss2sd 0x10(%rsp), %xmm2
cmpb $0x0, 0x14(%rsp)
je 0x26d84
leaq 0x2a101(%rip), %rsi     # 0x50e7a
jmp 0x26d8b
leaq 0x2a054(%rip), %rsi     # 0x50dd6
jmp 0x26d8b
leaq 0x2a14c(%rip), %rsi     # 0x50ed7
leaq 0x1c0(%rsp), %rdi
xorps %xmm3, %xmm3
xorps %xmm5, %xmm5
movb $0x6, %al
callq 0x198c0
movq 0x40109(%rip), %rax     # 0x66eb0
movq (%rax), %rax
movq 0x8(%rax), %rsi
leaq 0x3c0(%rsp), %rbx
movq %rbx, %rdi
callq 0x182c0
movq %rbx, %rdi
callq 0x186c0
movl $0x666e692f, 0x3c0(%rsp,%rax) # imm = 0x666E692F
movl $0x2f6f66, 0x3c3(%rsp,%rax) # imm = 0x2F6F66
movq 0x3ffbd(%rip), %rsi     # 0x66da0
addq $0x48, %rsi
movq %rbx, %rdi
callq 0x19800
movq %rbx, %rdi
callq 0x186c0
movl $0x746e652e, 0x3c0(%rsp,%rax) # imm = 0x746E652E
movb $0x0, 0x3c4(%rsp,%rax)
leaq 0x278b7(%rip), %rsi     # 0x4e6c8
movq %rbx, %rdi
callq 0x19620
movq %rax, %rbx
leaq 0x1c0(%rsp), %r14
movq %r14, %rdi
callq 0x186c0
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x198e0
movq %rbx, %rdi
callq 0x185e0
addq $0x5c8, %rsp            # imm = 0x5C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq