// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_spawnflag
qboolean ctf_spawnflag(int teamnum)
{
	edict_t		*ent = NULL; // MJD Uninitialized
	edict_t         *spot;

	if (!deathmatch->value)
		return false;

	if ((int)ctfflags->value & CTF_FLAGS_NOFLAGS)
		return false;

	// Check if the flags already exist

	if (teamnum == CTF_TEAM_RED  && !redflag) // RED FLAG
	{	
		spot = G_Find (NULL, FOFS(classname), "info_flag_red");
		if (!spot)
		{
			spot = G_Find (NULL, FOFS(classname), "info_player_deathmatch");
			if (spot)
				spot = ctf_findflagposition(spot);

			if (!spot)
				spot = G_Find (NULL, FOFS(classname), "info_player_start");


			// Make the spawn point glow
			if (spot)
			{
				spot->classname = "info_flag_red";
				spot->s.effects |= EF_COLOR_SHELL;
				spot->s.renderfx |= RF_SHELL_RED;
			}
			else // No spawn location found -- we will fail
				return false;
		}
		
		ent = G_Spawn();
		ent->classname = ED_NewString ("flag");
		ED_CallSpawn(ent);
		
		// Model support for flags
		ent->model = "players/male/flag1.md2";
		// Model support for flags
		
		VectorCopy (spot->s.origin, ent->s.origin);
		VectorCopy (spot->s.origin, ent->homeposition);
		VectorCopy (spot->s.angles, ent->s.angles);
		VectorCopy (spot->s.angles, ent->homeangles);
		//ent->s.effects |= EF_COLOR_SHELL | EF_FLAG1;
		//ent->s.renderfx |= RF_SHELL_RED;
		ent->s.effects = EF_FLAG1;
		// Paril
		if (flag_init->value)
			ent->s.frame = 173;
		else
			ent->s.frame = 0;
		// Paril
		redflag = ent;
	}
	else if (teamnum == CTF_TEAM_BLUE && !blueflag) // BLUE FLAG
	{
		spot = G_Find (NULL, FOFS(classname), "info_flag_blue");
		if (!spot)
		{
			spot = G_Find (NULL, FOFS(classname), "info_player_deathmatch");
			if (spot)
			{
				spot = ctf_findflagposition(spot);
				spot = ctf_findflagposition(spot);
			}

			if (!spot)
				spot = G_Find (NULL, FOFS(classname), "target_changelevel");

			// Make the spawn point glow
			if (spot)
			{
				spot->classname = "info_flag_blue";
				spot->s.effects |= EF_COLOR_SHELL;
				spot->s.renderfx |= RF_SHELL_BLUE;
			}
			else // No spawn location found -- we will fail
				return false;
		}

		ent = G_Spawn();
		ent->classname = ED_NewString ("flag");
		ED_CallSpawn(ent);
		// Model support for flags
		ent->model = "players/male/flag2.md2";
		// Model support for flags

		
		VectorCopy (spot->s.origin, ent->s.origin);
		VectorCopy (spot->s.origin, ent->homeposition);
		VectorCopy (spot->s.angles, ent->s.angles);
		VectorCopy (spot->s.angles, ent->homeangles);
		//ent->s.effects |= EF_COLOR_SHELL | EF_FLAG2;
		//ent->s.renderfx |= RF_SHELL_BLUE;
		ent->s.effects = EF_FLAG2;
		// Paril
		if (flag_init->value)
			ent->s.frame = 173;
		else
			ent->s.frame = 0;
		// Paril
		blueflag = ent;
	}


	//ent->model = "players/male/test.md2";

	if (ent)
	{
		//common
		ent->flagteam = teamnum; // passed as parameter
		gi.setmodel (ent, ent->model);
		ent->takedamage = DAMAGE_NO; //no damage on flags
		ent->dontfree = 1;
		ctf_resetflagandplayer (ent, NULL);
		ent->solid = SOLID_TRIGGER;
		gi.linkentity(ent); //make it touchable
		ent->movetype = MOVETYPE_TOSS;
		ctf_ResetFlagProps(ent);
		ctf_deletespawnpointsnearflag(ent);
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq 0x60ca6(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x22238
jp 0x22238
movl $0x0, -0x4(%rbp)
jmp 0x227cd
movq 0x60919(%rip), %rax     # 0x82b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x2225d
movl $0x0, -0x4(%rbp)
jmp 0x227cd
cmpl $0x1, -0x8(%rbp)
jne 0x224bd
movq 0x6058a(%rip), %rax     # 0x827f8
cmpq $0x0, (%rax)
jne 0x224bd
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4dcba(%rip), %rdx     # 0x6ff48
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x22344
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4e26a(%rip), %rdx     # 0x70522
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x222d5
movq -0x18(%rbp), %rdi
callq 0x18c90
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x222fb
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4e247(%rip), %rdx     # 0x70539
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x22336
movq -0x18(%rbp), %rax
leaq 0x4dc3b(%rip), %rcx     # 0x6ff48
movq %rcx, 0x138(%rax)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, 0x40(%rax)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %ecx
orl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x44(%rax)
jmp 0x22342
movl $0x0, -0x4(%rbp)
jmp 0x227cd
jmp 0x22344
callq 0x19950
movq %rax, -0x10(%rbp)
leaq 0x557c7(%rip), %rdi     # 0x77b1b
callq 0x18280
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x10(%rbp), %rdi
callq 0x19520
movq -0x10(%rbp), %rax
leaq 0x4e1d0(%rip), %rcx     # 0x7054b
movq %rcx, 0x120(%rax)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x4(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xc(%rax)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x460(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x464(%rax)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x468(%rax)
movq -0x18(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x14(%rax)
movq -0x18(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x18(%rax)
movq -0x18(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x46c(%rax)
movq -0x18(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x470(%rax)
movq -0x18(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x474(%rax)
movq -0x10(%rbp), %rax
movl $0x40000, 0x40(%rax)    # imm = 0x40000
movq 0x603aa(%rip), %rax     # 0x82828
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x22492
jp 0x22492
jmp 0x2249f
movq -0x10(%rbp), %rax
movl $0xad, 0x38(%rax)
jmp 0x224aa
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rcx
movq 0x60343(%rip), %rax     # 0x827f8
movq %rcx, (%rax)
jmp 0x22727
cmpl $0x2, -0x8(%rbp)
jne 0x22725
movq 0x60392(%rip), %rax     # 0x82860
cmpq $0x0, (%rax)
jne 0x22725
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4da68(%rip), %rdx     # 0x6ff56
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x225b1
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4e00a(%rip), %rdx     # 0x70522
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x22542
movq -0x18(%rbp), %rdi
callq 0x18c90
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x18c90
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x22568
xorl %eax, %eax
movl %eax, %edi
movq %rdi, %rax
addq $0x138, %rax            # imm = 0x138
movl %eax, %esi
leaq 0x4e003(%rip), %rdx     # 0x70562
callq 0x19660
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x225a3
movq -0x18(%rbp), %rax
leaq 0x4d9dc(%rip), %rcx     # 0x6ff56
movq %rcx, 0x138(%rax)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
movl %ecx, 0x40(%rax)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %ecx
orl $0x1000, %ecx           # imm = 0x1000
movl %ecx, 0x44(%rax)
jmp 0x225af
movl $0x0, -0x4(%rbp)
jmp 0x227cd
jmp 0x225b1
callq 0x19950
movq %rax, -0x10(%rbp)
leaq 0x5555a(%rip), %rdi     # 0x77b1b
callq 0x18280
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x138(%rax)
movq -0x10(%rbp), %rdi
callq 0x19520
movq -0x10(%rbp), %rax
leaq 0x4df8d(%rip), %rcx     # 0x70575
movq %rcx, 0x120(%rax)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x4(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0xc(%rax)
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x460(%rax)
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x464(%rax)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x468(%rax)
movq -0x18(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x18(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x14(%rax)
movq -0x18(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x18(%rax)
movq -0x18(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x46c(%rax)
movq -0x18(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x470(%rax)
movq -0x18(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x474(%rax)
movq -0x10(%rbp), %rax
movl $0x80000, 0x40(%rax)    # imm = 0x80000
movq 0x6013d(%rip), %rax     # 0x82828
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x226ff
jp 0x226ff
jmp 0x2270c
movq -0x10(%rbp), %rax
movl $0xad, 0x38(%rax)
jmp 0x22717
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rcx
movq 0x6013e(%rip), %rax     # 0x82860
movq %rcx, (%rax)
jmp 0x22727
cmpq $0x0, -0x10(%rbp)
je 0x227c6
movl -0x8(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x47c(%rax)
movq 0x5feba(%rip), %rax     # 0x82600
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x120(%rcx), %rsi
callq *%rax
movq -0x10(%rbp), %rax
movl $0x0, 0x27c(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x49c(%rax)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x19240
movq -0x10(%rbp), %rax
movl $0x1, 0x108(%rax)
movq 0x5fe67(%rip), %rax     # 0x82600
movq 0x90(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq -0x10(%rbp), %rax
movl $0x7, 0x118(%rax)
movq -0x10(%rbp), %rdi
callq 0x185e0
movq -0x10(%rbp), %rdi
callq 0x19230
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)