// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_flagtouch
qboolean ctf_flagtouch (edict_t *ent, edict_t *other)
{
	char flagcolor[MAX_INFO_STRING];
	edict_t *otherflag;       //stmt, fixed anyway.
	edict_t	*teammate;
	edict_t *assister = NULL; //surt
	char	sound[MAX_INFO_STRING];
//	int		i;
	static float last_flagtktime = 0;
	long redcount, bluecount, scorebonus;

	char message[1000], elsemessage[1000];
	sound[0] = 0;
	message[0] = 0;
	elsemessage[0] = 0;

	
	ctf_validateflags(); //make sure nothing is wierd

	// Make sure it will respawn
	ent->flags |= FL_RESPAWN;

	if(matchstate >= MATCH_RAILGUN_COUNTDOWN)
		return false;


	if (!ctf_validateplayer(other, CTF_TEAM_ANYTEAM))
		return false; //only active players may touch flag

	strcpy(flagcolor,"");
	ctf_teamstring(flagcolor, ent->flagteam, CTF_TEAM_MATCHING);

	// If it is your flag...
	if (other->client->ctf.teamnum == ent->flagteam)
	{
		// Check to see if the flag is home
//		if (FlagCompare (ent->homeposition, ent->s.origin))
		if (ctf_flagathome(ent))
		{
			// Do we have the enemy flag?
			if (other->client->pers.inventory[ITEM_INDEX(ent->item)])
			{
				//MULTIFLAG: while loop here
				// return OTHER flag to origin
				otherflag = ctf_getteamflag(other->client->ctf.teamnum,CTF_TEAM_OPPOSING);
		
				strcpy(flagcolor, "");
				ctf_teamstring(flagcolor, ent->flagteam, CTF_TEAM_OPPOSING);
				
				// Tell everyone about it
				sprintf(message, "%s captured your flag!\n",
					other->client->pers.netname);
				sprintf(elsemessage, "%s captured the %s flag.\n",
					other->client->pers.netname,
					flagcolor);

				Team_cprint(otherflag->flagteam, message, elsemessage);

				// Award Assists for captures
				assister = ctf_findplayer(NULL, NULL, other->client->ctf.teamnum);  // LM_Hati NULL second argument allows assisting yourself
				while (assister)
				{
					if (level.time < assister->client->kill_carrier_time + 6) //surt was 60 ... (this is seconds, not tenths)
					{
						sprintf(message, "%s assisted the capture by killing the flag carrier.\n",
							assister->client->pers.netname);
						ctf_BSafePrint(PRINT_HIGH, message);

						stats_add(assister, STATS_SCORE, 1);
						assister->client->resp.score += 1;
						assister->client->kill_carrier_time = 0;

						stats_add(assister, STATS_ASSISTS, 1); // STATS - LM_Hati

						// STDLog Flag Capture Frag Carrier - Surt
						sl_LogScore( &gi,
							assister->client->pers.netname,
							NULL,
							"FC Frag Assist",
							NULL,
							1, //FIXME symbolic surt
							level.time );
						
					}
					if (level.time < assister->client->return_flag_time + 3) //surt
					{
						sprintf(message, "%s assisted the capture by returning the flag.\n",
							assister->client->pers.netname);
						ctf_BSafePrint(PRINT_HIGH, message);
						stats_add(assister, STATS_SCORE, 1);
						assister->client->resp.score += 1;
						assister->client->return_flag_time = 0;

						stats_add(assister, STATS_ASSISTS, 1); // STATS - LM_Hati

						// STDLog Flag Capture Return Bonus - Surt
						sl_LogScore( &gi,
							assister->client->pers.netname,
							NULL,
							"F Return Assist",
							NULL,
							1, //bonus frags, should be symbolic, fixme surt
							level.time );

					}
					if	(level.time < assister->client->defend_flag_time + 2) //surt
					{
						sprintf(message, "%s assisted the capture by defending the flag.\n",
							assister->client->pers.netname);
						ctf_BSafePrint(PRINT_HIGH, message);
						stats_add(assister, STATS_SCORE, 1);
						assister->client->resp.score += 1;
						assister->client->defend_flag_time = 0;

						stats_add(assister, STATS_ASSISTS, 1); // STATS - LM_Hati

						// STDLog Flag Capture Defend Bonus - Surt
						sl_LogScore( &gi,
							assister->client->pers.netname,
							NULL,
							"F Defend Assist",
							NULL,
							1, //bonus frags, should be symbolic, fixme surt
							level.time );

					}

					assister = ctf_findplayer(assister, NULL, other->client->ctf.teamnum);
				}


				//gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/tele_up.wav"), 1, ATTN_NORM, 0);	//FIXME capture sound
				
				if (other->client->ctf.teamnum == CTF_TEAM_RED) // Red team
					sprintf(sound, "ctf/redscore%d.wav", (int)(skinset->value)+1);
				else if (other->client->ctf.teamnum == CTF_TEAM_BLUE) // Blue team
					sprintf(sound, "ctf/bluescore%d.wav", (int)(skinset->value)+1);
				else
					strcpy(sound, "misc/tele_up");
					
				gi.sound(ent, CHAN_CTF, gi.soundindex(sound), 1, ATTN_NONE, 0);

				gi.WriteByte (svc_temp_entity);
				gi.WriteByte (TE_BFG_EXPLOSION);
				gi.WritePosition (ent->s.origin);
				gi.multicast (ent->s.origin, MULTICAST_PVS);


				//  Add score to team
				stats_add(other, STATS_SCORE, CTF_CAPTURE_BONUS_CARRIER);
				other->client->resp.score += CTF_CAPTURE_BONUS_CARRIER; //5 for being the actual capturer
				stats_add(other, STATS_CAPTURES, 1);
				// STDLog Flag Capture - Surt
				sl_LogScore( &gi,
					other->client->pers.netname,
					NULL,
					"F Capture",
					NULL,
					CTF_CAPTURE_BONUS_CARRIER,
					level.time );
			
				scorebonus = CTF_CAPTURE_BONUS_TEAM;
				//surt code to give a scoring bonus for a small team capturing vs a large team

				if ( ((int)ctfflags->value) & CTF_SCORE_BALANCE)
				{
					teammate = ctf_findplayer(NULL, NULL, CTF_TEAM_ANYTEAM);
					redcount = bluecount = 1;
					while (teammate != NULL)
					{
						if (teammate->client->ctf.teamnum == CTF_TEAM_RED)
							redcount++;
						else if (teammate->client->ctf.teamnum == CTF_TEAM_BLUE)
							bluecount++;
						teammate = ctf_findplayer(teammate, NULL, CTF_TEAM_ANYTEAM);
					}
					if (other->client->ctf.teamnum == CTF_TEAM_RED)
					{
						scorebonus *= bluecount;
						scorebonus /= redcount;
					}
					else if (other->client->ctf.teamnum == CTF_TEAM_BLUE)
					{
						scorebonus *= redcount;
						scorebonus /= bluecount;
					}
				}



				//surt
				teammate = NULL;
				// MJD Parens are suggested here, but is this
				// correct?
				//surt cleaned up structure
				teammate = ctf_findplayer(NULL, NULL, other->client->ctf.teamnum);
				while (teammate)
				{
					stats_add(teammate, STATS_SCORE, scorebonus);
					teammate->client->resp.score += scorebonus;
					// STDLog Flag Capture Team Score - Surt
					sl_LogScore( &gi,
						teammate->client->pers.netname,
						NULL,
						"Team Score",
						NULL,
						scorebonus,
						level.time );

					teammate = ctf_findplayer(teammate, NULL, other->client->ctf.teamnum);
					
				}

				if (!otherflag)
				{
					ctf_validateflags();
				}
				else
				{
					ctf_resetflagandplayer(otherflag,otherflag->owner);
				}
			}
			return false; // Can't pickup your own flag
		}
		else
		{
			// Return flag to origin
			switch (ent->flagteam)
			{
			case CTF_TEAM_RED:
				gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/r_returned.wav"), 0.8f, ATTN_NONE, 0);	
				break;
			case CTF_TEAM_BLUE: 
				gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/b_returned.wav"), 0.8f, ATTN_NONE, 0);	
				break;
			}

			sprintf(message, "%s returned your flag!\n",
				other->client->pers.netname);
			sprintf(elsemessage, "%s returned the %s flag.\n",
				other->client->pers.netname,
				flagcolor);

			stats_add(other, STATS_RETURNS, 1); // STATS - LM_Hati

			stats_add(other, STATS_SCORE, 1);

        // STDLog Flag Recover - Surt
        sl_LogScore( &gi,
                     other->client->pers.netname,
                     NULL,
                     "F Return",
                     NULL,
                     1, //fixme surt symbolic
                     level.time );

			other->client->resp.score += 1;
			other->client->return_flag_time = level.time;
			
			Team_cprint(other->client->ctf.teamnum, message, elsemessage);

			// Award Assists for returns
			assister = ctf_findplayer(NULL, other, other->client->ctf.teamnum);
			while (assister)
			{
				if (level.time < assister->client->kill_carrier_time + 6) //surt was 60 ... (this is seconds, not tenths)
				{
					sprintf(message, "%s helped %s return the %s flag.\n",
						assister->client->pers.netname, other->client->pers.netname, flagcolor);
					ctf_BSafePrint(PRINT_HIGH, message);
					stats_add(assister, STATS_SCORE, 1);

					// Log Flag Recover - MarkDavies
					sl_LogScore( &gi,
						assister->client->pers.netname,
						NULL,
						"F Return Assist",
						NULL,
						1,
						level.time );

					assister->client->resp.score += 1;
					assister->client->kill_carrier_time = 0;
					
					stats_add(assister, STATS_ASSISTS, 1); // STATS - LM_Hati
				}
				assister = ctf_findplayer(assister, other, other->client->ctf.teamnum);
			}

			ctf_resetflagandplayer(ent,NULL);
			return false;
		}
	}
	else // Enemy flag
	{
		// Can't pick up the flag if it is frozen
//		if (ent->entprops & CTF_PROPS_FROZEN)
//			return false;
		if (ent->flagteam == CTF_TEAM_RED && ((int)refset->value & CTF_RED_FLAG_FROZEN) )
			return false;
		else if (ent->flagteam == CTF_TEAM_BLUE && ((int)refset->value & CTF_BLUE_FLAG_FROZEN) )
			return false;
	
		// Give us a glowing shell
		other->s.effects |= EF_COLOR_SHELL;
		if (ent->flagteam == CTF_TEAM_BLUE)
			other->s.renderfx |= RF_SHELL_RED;
		else if (ent->flagteam == CTF_TEAM_RED)
			other->s.renderfx |= RF_SHELL_BLUE;


		sprintf(message, "%s stole your flag!\n",
			other->client->pers.netname);
		sprintf(elsemessage, "%s stole the %s flag.\n",
			other->client->pers.netname,
			flagcolor);

		stats_add(other, STATS_OFFENSE_FLAG, 1); // STATS - LM_Hati
		// Log Flag Pickup - MarkDavies
		sl_LogScore( &gi,
			other->client->pers.netname,
			NULL,
			"F Pickup",
			NULL,
			0, //surt fixme symbolic
			level.time );
		
		Team_cprint(ent->flagteam, message, elsemessage);
		
		//gi.sound(ent, CHAN_AUTO, gi.soundindex("world/klaxon2.wav"), 1, ATTN_NONE, 0);	//FIXME powering up sound
//		if (FlagCompare (ent->homeposition, ent->s.origin))
		if (ctf_flagathome(ent))
		{
			gi.sound(ent, CHAN_AUTO, gi.soundindex("ctf/flagtk.wav"), 0.7f, ATTN_NORM, 0);	
			switch (ent->flagteam)
			{
			case CTF_TEAM_RED:
				gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/r_stolen.wav"), 0.8f, ATTN_NONE, 0);	
				break;
			case CTF_TEAM_BLUE: 
				gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/b_stolen.wav"), 0.8f, ATTN_NONE, 0);	
				break;
			default:
				break;
			}
		}

		//surt volume was slightly too loud at 1.0
		//so always plays when stolen from home base
		//surt also irritating if dropped/stolen repeatedly
		else
		{
			//only plays every 5 seconds if not at home base
			if (level.time > (last_flagtktime + 8) )
			{
				last_flagtktime = level.time;
				switch (ent->flagteam)
				{
				case CTF_TEAM_RED:
					gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/r_stolen.wav"), 0.8f, ATTN_NORM, 0);	
					break;
				case CTF_TEAM_BLUE: 
					gi.sound(ent, CHAN_CTF, gi.soundindex("ctf/b_stolen.wav"), 0.8f, ATTN_NORM, 0);	
					break;
				default:
					break;
				}
			}
		}

		
		ent->owner = other;
		ent->flags |= FL_RESPAWN;
		//ent->svflags |= SVF_NOCLIENT;
		ent->solid = SOLID_NOT;
		gi.linkentity(ent); //make it touchable

		ent->nextthink = level.time + FRAMETIME;	
		ent->think = ctf_flagwave;

		ent->owner->s.modelindex3 = ent->s.modelindex; // Move mode to player
		ent->s.modelindex = 0; // Turn off model
		
		
		other->client->pers.inventory[ITEM_INDEX(ent->item)]++;
	}

	return true;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xbe8, %rsp            # imm = 0xBE8
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movb %r15b, 0x10(%rsp)
movb %r15b, 0x410(%rsp)
movb %r15b, 0x800(%rsp)
callq 0x18590
orb $-0x80, 0x11f(%r14)
movq 0x48120(%rip), %rax     # 0x697d8
cmpl $0x4, (%rax)
jg 0x2218d
movq %rbx, %rdi
movl $0xfffffffb, %esi       # imm = 0xFFFFFFFB
callq 0x18ce0
testl %eax, %eax
je 0x2218d
leaq 0x210(%rsp), %rdi
movb $0x0, (%rdi)
movl 0x47c(%r14), %ebp
movl %ebp, %esi
movl $0xfffffff9, %edx       # imm = 0xFFFFFFF9
callq 0x181f0
movq 0x58(%rbx), %rdx
cmpl %ebp, 0x1100(%rdx)
jne 0x21769
movq %r14, %rdi
callq 0x19420
testl %eax, %eax
je 0x217bb
movq 0x58(%rbx), %r12
movq 0x330(%r14), %rax
subq 0x4871e(%rip), %rax     # 0x69e40
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %rcx # imm = 0xC3C3C3C3C3C3C3C4
imulq %rax, %rcx
cmpl $0x0, 0x318(%r12,%rcx)
je 0x2218d
movl 0x1100(%r12), %eax
cmpl $0x2, %eax
je 0x21947
cmpl $0x1, %eax
jne 0x21962
movq 0x480fc(%rip), %rax     # 0x69860
jmp 0x2194e
cmpl $0x2, %ebp
je 0x2178f
cmpl $0x1, %ebp
jne 0x217a6
movq 0x4821e(%rip), %rax     # 0x69998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x1, %al
jne 0x2218d
cmpl $0x2, %ebp
jne 0x217a6
movq 0x48202(%rip), %rax     # 0x69998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x2, %al
jne 0x2218d
orb $0x1, 0x41(%rbx)
cmpl $0x2, %ebp
je 0x217e0
cmpl $0x1, %ebp
jne 0x217e8
movl $0x1000, %eax           # imm = 0x1000
jmp 0x217e5
movl 0x47c(%r14), %eax
cmpl $0x1, %eax
je 0x21e06
cmpl $0x2, %eax
jne 0x21e36
leaq 0x32db4(%rip), %rdi     # 0x5458f
jmp 0x21e0d
movl $0x400, %eax            # imm = 0x400
orl %eax, 0x44(%rbx)
movl $0x2c0, %r13d           # imm = 0x2C0
addq %r13, %rdx
leaq 0x32f69(%rip), %rsi     # 0x54761
leaq 0x410(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x19700
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x32f5e(%rip), %rsi     # 0x54776
leaq 0x800(%rsp), %rbp
leaq 0x210(%rsp), %rcx
movq %rbp, %rdi
xorl %eax, %eax
callq 0x19700
movl $0x1, %edx
movq %rbx, %rdi
movl $0xc, %esi
callq 0x19330
addq 0x58(%rbx), %r13
movq 0x48551(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
movq 0x47da5(%rip), %r15     # 0x69600
leaq 0x32f2b(%rip), %rcx     # 0x5478d
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x18e90
movl 0x47c(%r14), %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x198e0
movq %r14, %rdi
callq 0x19420
testl %eax, %eax
je 0x218e7
movq 0x20(%r15), %r12
leaq 0x32ef8(%rip), %rdi     # 0x54796
movq %r15, %rbp
callq *0x48(%r15)
movss 0x32ba7(%rip), %xmm0    # 0x54454
movss 0x32673(%rip), %xmm1    # 0x53f28
xorps %xmm2, %xmm2
movss %xmm2, (%rsp)
movq %r14, %rdi
xorl %esi, %esi
movl %eax, %edx
callq *%r12
movl 0x47c(%r14), %eax
cmpl $0x1, %eax
movq 0x484c8(%rip), %r13     # 0x69da0
je 0x21953
cmpl $0x2, %eax
movq %rbp, %r15
je 0x2193b
jmp 0x22103
movq 0x484b2(%rip), %r13     # 0x69da0
movss 0x4(%r13), %xmm0
movss 0x4d728(%rip), %xmm1    # 0x6f024
addss 0x325f4(%rip), %xmm1    # 0x53ef8
ucomiss %xmm1, %xmm0
jbe 0x22103
movss %xmm0, 0x4d70f(%rip)    # 0x6f024
movl 0x47c(%r14), %eax
movss 0x32604(%rip), %xmm0    # 0x53f28
movss %xmm0, (%rsp)
cmpl $0x1, %eax
je 0x220d7
cmpl $0x2, %eax
jne 0x22103
leaq 0x32e74(%rip), %rdi     # 0x547b6
jmp 0x220de
movq 0x47eaa(%rip), %rax     # 0x697f8
movq (%rax), %rbp
jmp 0x21964
leaq 0x32e4b(%rip), %rdi     # 0x547a5
movq %rbp, %r15
jmp 0x220de
xorl %ebp, %ebp
leaq 0x210(%rsp), %r15
movb $0x0, (%r15)
movq %r14, (%rsp)
movl 0x47c(%r14), %esi
movq %r15, %rdi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x181f0
movl $0x2c0, %r13d           # imm = 0x2C0
addq %r13, %r12
leaq 0x32c2c(%rip), %rsi     # 0x545c4
leaq 0x410(%rsp), %r14
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x19700
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x32c21(%rip), %rsi     # 0x545dc
leaq 0x800(%rsp), %r12
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x19700
movq %rbp, 0x8(%rsp)
movl 0x47c(%rbp), %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x198e0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
xorl %edi, %edi
xorl %esi, %esi
callq 0x19170
testq %rax, %rax
je 0x21c26
movq %rax, %r12
movq 0x48394(%rip), %r15     # 0x69da0
leaq 0x410(%rsp), %rbp
movq 0x58(%r12), %rdx
movss 0x10f4(%rdx), %xmm0
addss 0x324d7(%rip), %xmm0    # 0x53f00
ucomiss 0x4(%r15), %xmm0
jbe 0x21aba
addq %r13, %rdx
movq %rbp, %rdi
leaq 0x32bb5(%rip), %rsi     # 0x545f6
xorl %eax, %eax
callq 0x19700
movl $0x2, %edi
movq %rbp, %rsi
callq 0x19270
movl $0x1, %edx
movq %r12, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%r12), %rax
incl 0xdf4(%rax)
movl $0x0, 0x10f4(%rax)
movl $0x1, %edx
movq %r12, %rdi
movl $0xa, %esi
callq 0x19330
movq 0x58(%r12), %rsi
addq %r13, %rsi
movss 0x4(%r15), %xmm0
movq 0x47b5d(%rip), %rdi     # 0x69600
xorl %edx, %edx
leaq 0x32b80(%rip), %rcx     # 0x5462c
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%r12), %rdx
movss 0x10f0(%rdx), %xmm0
addss 0x3243d(%rip), %xmm0    # 0x53f0c
ucomiss 0x4(%r15), %xmm0
jbe 0x21b60
addq %r13, %rdx
movq %rbp, %rdi
leaq 0x32b54(%rip), %rsi     # 0x5463b
xorl %eax, %eax
callq 0x19700
movl $0x2, %edi
movq %rbp, %rsi
callq 0x19270
movl $0x1, %edx
movq %r12, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%r12), %rax
incl 0xdf4(%rax)
movl $0x0, 0x10f0(%rax)
movl $0x1, %edx
movq %r12, %rdi
movl $0xa, %esi
callq 0x19330
movq 0x58(%r12), %rsi
addq %r13, %rsi
movss 0x4(%r15), %xmm0
movq 0x47ab7(%rip), %rdi     # 0x69600
xorl %edx, %edx
leaq 0x32b19(%rip), %rcx     # 0x5466b
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%r12), %rdx
movss 0x10ec(%rdx), %xmm0
addss 0x328e3(%rip), %xmm0    # 0x54458
ucomiss 0x4(%r15), %xmm0
jbe 0x21c06
addq %r13, %rdx
movq %rbp, %rdi
leaq 0x32aee(%rip), %rsi     # 0x5467b
xorl %eax, %eax
callq 0x19700
movl $0x2, %edi
movq %rbp, %rsi
callq 0x19270
movl $0x1, %edx
movq %r12, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%r12), %rax
incl 0xdf4(%rax)
movl $0x0, 0x10ec(%rax)
movl $0x1, %edx
movq %r12, %rdi
movl $0xa, %esi
callq 0x19330
movq 0x58(%r12), %rsi
addq %r13, %rsi
movss 0x4(%r15), %xmm0
movq 0x47a11(%rip), %rdi     # 0x69600
xorl %edx, %edx
leaq 0x32ab3(%rip), %rcx     # 0x546ab
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x19170
movq %rax, %r12
testq %rax, %rax
jne 0x21a14
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %eax
cmpl $0x2, %eax
je 0x21c64
cmpl $0x1, %eax
movq (%rsp), %r14
jne 0x21c8e
movq 0x47cb3(%rip), %rax     # 0x698f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x32a65(%rip), %rsi     # 0x546bb
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x19700
jmp 0x21cac
movq 0x47c8d(%rip), %rax     # 0x698f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x32a52(%rip), %rsi     # 0x546ce
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x19700
movq (%rsp), %r14
jmp 0x21cac
movabsq $0x70755f656c6574, %rax # imm = 0x70755F656C6574
movq %rax, 0x15(%rsp)
movabsq $0x6c65742f6373696d, %rax # imm = 0x6C65742F6373696D
movq %rax, 0x10(%rsp)
movq 0x4794d(%rip), %r15     # 0x69600
movq 0x20(%r15), %r12
leaq 0x10(%rsp), %rdi
callq *0x48(%r15)
movss 0x32260(%rip), %xmm0    # 0x53f28
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
movl $0x5, %esi
movl %eax, %edx
callq *%r12
movl $0x3, %edi
callq *0xc8(%r15)
movl $0x14, %edi
callq *0xc8(%r15)
addq $0x4, %r14
movq %r14, %rdi
callq *0xf0(%r15)
movq %r14, %rdi
movl $0x2, %esi
callq *0xb0(%r15)
movl $0x5, %edx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%rbx), %rax
addl $0x5, 0xdf4(%rax)
movl $0x1, %r12d
movl $0x1, %edx
movq %rbx, %rdi
movl $0x4, %esi
callq 0x19330
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%rbx), %rsi
movq 0x4804b(%rip), %rbp     # 0x69da0
movss 0x4(%rbp), %xmm0
leaq 0x3298e(%rip), %rcx     # 0x546ef
movq %r15, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movl $0x5, %r9d
callq 0x18e90
movq 0x47ddd(%rip), %rax     # 0x69b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movl $0xa, %r14d
btl $0x9, %eax
jae 0x22033
xorl %edi, %edi
xorl %esi, %esi
movl $0xfffffffb, %edx       # imm = 0xFFFFFFFB
callq 0x19170
movl $0x1, %r15d
testq %rax, %rax
je 0x21de2
movl $0x1, %r12d
movq 0x58(%rax), %rcx
movl 0x1100(%rcx), %ecx
cmpl $0x2, %ecx
je 0x21dcb
cmpl $0x1, %ecx
jne 0x21dce
incq %r12
jmp 0x21dce
incq %r15
movq %rax, %rdi
xorl %esi, %esi
movl $0xfffffffb, %edx       # imm = 0xFFFFFFFB
callq 0x19170
testq %rax, %rax
jne 0x21db2
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %eax
cmpl $0x1, %eax
je 0x2201e
cmpl $0x2, %eax
jne 0x22033
movq %r12, %rax
jmp 0x22024
leaq 0x3276f(%rip), %rdi     # 0x5457c
movq 0x477ec(%rip), %rax     # 0x69600
movq 0x20(%rax), %r15
callq *0x48(%rax)
movss 0x3262d(%rip), %xmm0    # 0x54450
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
movl $0x5, %esi
movl %eax, %edx
callq *%r15
movq %r14, (%rsp)
movl $0x2c0, %r13d           # imm = 0x2C0
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x328b6(%rip), %rsi     # 0x54704
xorl %r15d, %r15d
leaq 0x410(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x19700
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x328ab(%rip), %rsi     # 0x5471c
leaq 0x800(%rsp), %rbp
leaq 0x210(%rsp), %rcx
movq %rbp, %rdi
xorl %eax, %eax
callq 0x19700
movl $0x1, %edx
movq %rbx, %rdi
movl $0xb, %esi
callq 0x19330
movl $0x1, %edx
movq %rbx, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%rbx), %rsi
addq %r13, %rsi
movq 0x47ee3(%rip), %r13     # 0x69da0
movss 0x4(%r13), %xmm0
movq 0x47736(%rip), %rdi     # 0x69600
leaq 0x32865(%rip), %rcx     # 0x54736
xorl %edx, %edx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%rbx), %rax
incl 0xdf4(%rax)
movss 0x4(%r13), %xmm0
movss %xmm0, 0x10f0(%rax)
movl 0x1100(%rax), %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x198e0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x19170
testq %rax, %rax
je 0x2200e
movq %rax, %r12
leaq 0x410(%rsp), %rbp
movl $0x2c0, %r14d           # imm = 0x2C0
movq 0x58(%r12), %rdx
movss 0x10f4(%rdx), %xmm0
addss 0x31fb3(%rip), %xmm0    # 0x53f00
ucomiss 0x4(%r13), %xmm0
jbe 0x21fed
addq %r14, %rdx
movq 0x58(%rbx), %rcx
addq %r14, %rcx
movq %rbp, %rdi
leaq 0x327d3(%rip), %rsi     # 0x5473f
leaq 0x210(%rsp), %r8
xorl %eax, %eax
callq 0x19700
movl $0x2, %edi
movq %rbp, %rsi
callq 0x19270
movl $0x1, %edx
movq %r12, %rdi
movl $0x3, %esi
callq 0x19330
movq 0x58(%r12), %rsi
addq %r14, %rsi
movss 0x4(%r13), %xmm0
movq 0x47651(%rip), %rdi     # 0x69600
xorl %edx, %edx
leaq 0x326b3(%rip), %rcx     # 0x5466b
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%r12), %rax
incl 0xdf4(%rax)
movl $0x0, 0x10f4(%rax)
movl $0x1, %edx
movq %r12, %rdi
movl $0xa, %esi
callq 0x19330
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19170
movq %rax, %r12
testq %rax, %rax
jne 0x21f38
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x19080
jmp 0x2218d
movq %r15, %rax
movq %r12, %r15
addq %rax, %rax
leaq (%rax,%rax,4), %rax
cqto
idivq %r15
movq %rax, %r14
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
xorl %edi, %edi
xorl %esi, %esi
callq 0x19170
testq %rax, %rax
je 0x220b2
movq %rax, %r15
movq 0x475ab(%rip), %r12     # 0x69600
leaq 0x3269d(%rip), %r13     # 0x546f9
movq %r15, %rdi
movl $0x3, %esi
movq %r14, %rdx
callq 0x19330
movq 0x58(%r15), %rsi
addl %r14d, 0xdf4(%rsi)
addq $0x2c0, %rsi            # imm = 0x2C0
movss 0x4(%rbp), %xmm0
movq %r12, %rdi
xorl %edx, %edx
movq %r13, %rcx
xorl %r8d, %r8d
movl %r14d, %r9d
callq 0x18e90
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x19170
movq %rax, %r15
testq %rax, %rax
jne 0x2205c
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x220ca
movq 0x110(%rdi), %rsi
callq 0x19080
jmp 0x220cf
callq 0x18590
xorl %r15d, %r15d
jmp 0x2218d
leaq 0x326c7(%rip), %rdi     # 0x547a5
movq 0x20(%r15), %r12
callq *0x48(%r15)
movss 0x32362(%rip), %xmm0    # 0x54450
xorps %xmm2, %xmm2
movq %r14, %rdi
movl $0x5, %esi
movl %eax, %edx
movss (%rsp), %xmm1
callq *%r12
movq %rbx, 0x110(%r14)
orb $-0x80, 0x11f(%r14)
xorl %ebp, %ebp
movl %ebp, 0x108(%r14)
movq %r14, %rdi
callq *0x90(%r15)
movss 0x4(%r13), %xmm0
addss 0x3215d(%rip), %xmm0    # 0x54290
movss %xmm0, 0x200(%r14)
movq 0x4747d(%rip), %rax     # 0x695c0
movq %rax, 0x210(%r14)
movl 0x28(%r14), %eax
movq 0x110(%r14), %rcx
movl %eax, 0x30(%rcx)
movl %ebp, 0x28(%r14)
movq 0x330(%r14), %rax
subq 0x47cd6(%rip), %rax     # 0x69e40
movq 0x58(%rbx), %rcx
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %rdx # imm = 0xC3C3C3C3C3C3C3C4
imulq %rax, %rdx
incl 0x318(%rcx,%rdx)
movl $0x1, %r15d
movl %r15d, %eax
addq $0xbe8, %rsp            # imm = 0xBE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq