// File: /workspace/github_c_makefile_star2_O3/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 $0xbf8, %rsp            # imm = 0xBF8
movq %rsi, %rbx
movq %rdi, %r13
xorl %r15d, %r15d
movb %r15b, 0x20(%rsp)
movb %r15b, 0x420(%rsp)
movb %r15b, 0x810(%rsp)
callq 0x18590
orb $-0x80, 0x11f(%r13)
movq 0x47236(%rip), %rax     # 0x687d8
cmpl $0x4, (%rax)
jg 0x220cd
movq %rbx, %rdi
movl $0xfffffffb, %esi       # imm = 0xFFFFFFFB
callq 0x18ce0
testl %eax, %eax
je 0x220cd
leaq 0x220(%rsp), %rdi
movb $0x0, (%rdi)
movl 0x47c(%r13), %ebp
movl %ebp, %esi
movl $0xfffffff9, %edx       # imm = 0xFFFFFFF9
callq 0x181f0
movq 0x58(%rbx), %rdx
cmpl %ebp, 0x1100(%rdx)
jne 0x21653
movq %r13, %rdi
callq 0x19420
testl %eax, %eax
je 0x21683
movq 0x58(%rbx), %r12
movq 0x330(%r13), %rax
subq 0x47834(%rip), %rax     # 0x68e40
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %rcx # imm = 0xC3C3C3C3C3C3C3C4
imulq %rax, %rcx
cmpl $0x0, 0x318(%r12,%rcx)
je 0x220cd
movl 0x1100(%r12), %eax
cmpl $0x2, %eax
je 0x2184c
cmpl $0x1, %eax
jne 0x21858
movq 0x47212(%rip), %rax     # 0x68860
jmp 0x21853
cmpl $0x2, %ebp
je 0x216a8
cmpl $0x1, %ebp
jne 0x216d2
movq 0x47334(%rip), %rax     # 0x68998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x1, %al
jne 0x220cd
movq %r13, %r14
movabsq $0x100000000100, %rax   # imm = 0x100000000100
jmp 0x216cc
movl 0x47c(%r13), %eax
cmpl $0x1, %eax
je 0x21d30
cmpl $0x2, %eax
jne 0x21d60
leaq 0x31f1c(%rip), %rdi     # 0x535bf
jmp 0x21d37
movq 0x472e9(%rip), %rax     # 0x68998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x2, %al
jne 0x220cd
movq %r13, %r14
movabsq $0x40000000100, %rax    # imm = 0x40000000100
orq %rax, 0x40(%rbx)
jmp 0x216d9
movq %r13, %r14
orb $0x1, 0x41(%rbx)
movl $0x2c0, %r13d           # imm = 0x2C0
addq %r13, %rdx
leaq 0x320a8(%rip), %rsi     # 0x53791
leaq 0x420(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x196f0
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x3209d(%rip), %rsi     # 0x537a6
leaq 0x810(%rsp), %rbp
leaq 0x220(%rsp), %rcx
movq %rbp, %rdi
xorl %eax, %eax
callq 0x196f0
movl $0x1, %edx
movq %rbx, %rdi
movl $0xc, %esi
callq 0x19330
addq 0x58(%rbx), %r13
movq 0x47660(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
movq 0x46eb4(%rip), %r15     # 0x68600
leaq 0x3206a(%rip), %rcx     # 0x537bd
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x18e90
movq %r14, %r13
movl 0x47c(%r14), %edi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x198d0
movq %r14, %rdi
callq 0x19420
testl %eax, %eax
je 0x217dc
movq 0x20(%r15), %r12
leaq 0x32034(%rip), %rdi     # 0x537c6
movq %r15, %rbp
callq *0x48(%r15)
movss 0x31cc7(%rip), %xmm0    # 0x53468
movss 0x3177f(%rip), %xmm1    # 0x52f28
xorps %xmm2, %xmm2
movss %xmm2, 0xc(%rsp)
movq %r13, %rdi
xorl %esi, %esi
movl %eax, %edx
callq *%r12
movl 0x47c(%r13), %eax
cmpl $0x1, %eax
movq 0x475d3(%rip), %r14     # 0x68da0
je 0x2183d
cmpl $0x2, %eax
movq %rbp, %r15
je 0x21831
jmp 0x22043
movq 0x475bd(%rip), %r14     # 0x68da0
movss 0x4(%r14), %xmm0
movss 0x4c833(%rip), %xmm1    # 0x6e024
addss 0x31703(%rip), %xmm1    # 0x52efc
ucomiss %xmm1, %xmm0
jbe 0x22043
movss %xmm0, 0x4c81a(%rip)    # 0x6e024
movl 0x47c(%r13), %eax
movss 0x3170f(%rip), %xmm0    # 0x52f28
movss %xmm0, 0xc(%rsp)
cmpl $0x1, %eax
je 0x22016
cmpl $0x2, %eax
jne 0x22043
leaq 0x31fae(%rip), %rdi     # 0x537e6
jmp 0x2201d
leaq 0x31f91(%rip), %rdi     # 0x537d5
movq %rbp, %r15
jmp 0x2201d
movq 0x46fa5(%rip), %rax     # 0x687f8
movq (%rax), %r14
jmp 0x2185b
xorl %r14d, %r14d
leaq 0x220(%rsp), %rbp
movb $0x0, (%rbp)
movq %r13, 0x10(%rsp)
movl 0x47c(%r13), %esi
movq %rbp, %rdi
movl $0xfffffffa, %edx       # imm = 0xFFFFFFFA
callq 0x181f0
movl $0x2c0, %r15d           # imm = 0x2C0
addq %r15, %r12
leaq 0x31d64(%rip), %rsi     # 0x535f4
leaq 0x420(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x196f0
movq 0x58(%rbx), %rdx
addq %r15, %rdx
leaq 0x31d59(%rip), %rsi     # 0x5360c
leaq 0x810(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x196f0
movq %r14, 0x18(%rsp)
movl 0x47c(%r14), %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0x198d0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %r13d
xorl %edi, %edi
xorl %esi, %esi
movl %r13d, %edx
callq 0x19170
testq %rax, %rax
je 0x21b45
movq %rax, %r12
movq 0x47497(%rip), %r14     # 0x68da0
movss 0x4(%r14), %xmm1
leaq 0x420(%rsp), %rbp
movq 0x58(%r12), %rdx
movss 0x10f4(%rdx), %xmm0
addss 0x315d8(%rip), %xmm0    # 0x52f04
ucomiss %xmm1, %xmm0
jbe 0x219c6
addq %r15, %rdx
movq %rbp, %rdi
leaq 0x31ce4(%rip), %rsi     # 0x53626
xorl %eax, %eax
callq 0x196f0
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 %r15, %rsi
movss 0x4(%r14), %xmm0
movq 0x46c5c(%rip), %rdi     # 0x68600
xorl %edx, %edx
leaq 0x31caf(%rip), %rcx     # 0x5365c
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movss 0x4(%r14), %xmm1
movq 0x58(%r12), %rdx
movss 0x10f0(%rdx), %xmm0
addss 0x3153a(%rip), %xmm0    # 0x52f10
ucomiss %xmm1, %xmm0
jbe 0x21a70
addq %r15, %rdx
movq %rbp, %rdi
leaq 0x31c7f(%rip), %rsi     # 0x5366b
xorl %eax, %eax
callq 0x196f0
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 %r15, %rsi
movss 0x4(%r14), %xmm0
movq 0x46bb2(%rip), %rdi     # 0x68600
xorl %edx, %edx
leaq 0x31c44(%rip), %rcx     # 0x5369b
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movss 0x4(%r14), %xmm1
movq 0x58(%r12), %rdx
movss 0x10ec(%rdx), %xmm0
addss 0x319ec(%rip), %xmm0    # 0x5346c
ucomiss %xmm1, %xmm0
jbe 0x21b15
addq %r15, %rdx
movq %rbp, %rdi
leaq 0x31c15(%rip), %rsi     # 0x536ab
xorl %eax, %eax
callq 0x196f0
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 %r15, %rsi
movss 0x4(%r14), %xmm0
movq 0x46b08(%rip), %rdi     # 0x68600
xorl %edx, %edx
leaq 0x31bda(%rip), %rcx     # 0x536db
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movss 0x4(%r14), %xmm1
movss %xmm1, 0xc(%rsp)
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %r13d
movq %r12, %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x19170
movss 0xc(%rsp), %xmm1
movq %rax, %r12
testq %rax, %rax
jne 0x21917
cmpl $0x2, %r13d
je 0x21b6b
cmpl $0x1, %r13d
jne 0x21b91
movq 0x46da0(%rip), %rax     # 0x688f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x31b82(%rip), %rsi     # 0x536eb
jmp 0x21b83
movq 0x46d86(%rip), %rax     # 0x688f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x31b7b(%rip), %rsi     # 0x536fe
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x196f0
jmp 0x21baf
movabsq $0x70755f656c6574, %rax # imm = 0x70755F656C6574
movq %rax, 0x25(%rsp)
movabsq $0x6c65742f6373696d, %rax # imm = 0x6C65742F6373696D
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %r12
movq 0x46a45(%rip), %r15     # 0x68600
movq 0x20(%r15), %r14
leaq 0x20(%rsp), %rdi
callq *0x48(%r15)
movss 0x31358(%rip), %xmm0    # 0x52f28
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
movl $0x5, %esi
movl %eax, %edx
callq *%r14
movl $0x3, %edi
callq *0xc8(%r15)
movl $0x14, %edi
callq *0xc8(%r15)
addq $0x4, %r12
movq %r12, %rdi
callq *0xf0(%r15)
movq %r12, %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 0x47143(%rip), %rbp     # 0x68da0
movss 0x4(%rbp), %xmm0
leaq 0x31ab6(%rip), %rcx     # 0x5371f
movq %r15, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movl $0x5, %r9d
callq 0x18e90
movq 0x46ed5(%rip), %rax     # 0x68b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0x9, %eax
jb 0x21ca6
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
movl $0xa, %r14d
jmp 0x21f7c
xorl %edi, %edi
xorl %esi, %esi
movl $0xfffffffb, %edx       # imm = 0xFFFFFFFB
callq 0x19170
movl $0x1, %r15d
testq %rax, %rax
je 0x21cf5
movl $0x1, %r12d
movq 0x58(%rax), %rcx
movl 0x1100(%rcx), %ecx
cmpl $0x2, %ecx
je 0x21cde
cmpl $0x1, %ecx
jne 0x21ce1
incq %r12
jmp 0x21ce1
incq %r15
movq %rax, %rdi
xorl %esi, %esi
movl $0xfffffffb, %edx       # imm = 0xFFFFFFFB
callq 0x19170
testq %rax, %rax
jne 0x21cc5
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
cmpl $0x2, %edx
je 0x21f68
movl $0xa, %r14d
cmpl $0x1, %edx
jne 0x21f7c
addq %r15, %r15
leaq (%r15,%r15,4), %rax
cqto
idivq %r12
movq %rax, %r14
movl $0x1, %edx
jmp 0x21f7c
leaq 0x31875(%rip), %rdi     # 0x535ac
movq 0x468c2(%rip), %rax     # 0x68600
movq 0x20(%rax), %r14
callq *0x48(%rax)
movss 0x31713(%rip), %xmm0    # 0x53460
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r13, %rdi
movl $0x5, %esi
movl %eax, %edx
callq *%r14
movq %r13, 0x10(%rsp)
movl $0x2c0, %r14d           # imm = 0x2C0
movq 0x58(%rbx), %rdx
addq %r14, %rdx
leaq 0x319bb(%rip), %rsi     # 0x53734
xorl %r15d, %r15d
leaq 0x420(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x196f0
movq 0x58(%rbx), %rdx
addq %r14, %rdx
leaq 0x319b0(%rip), %rsi     # 0x5374c
leaq 0x810(%rsp), %r13
leaq 0x220(%rsp), %rcx
movq %r13, %rdi
xorl %eax, %eax
callq 0x196f0
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 %r14, %rsi
movq 0x46fb8(%rip), %rbp     # 0x68da0
movss 0x4(%rbp), %xmm0
movq 0x4680c(%rip), %rdi     # 0x68600
leaq 0x3196b(%rip), %rcx     # 0x53766
xorl %edx, %edx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x18e90
movq 0x58(%rbx), %rax
incl 0xdf4(%rax)
movss 0x4(%rbp), %xmm0
movss %xmm0, 0x10f0(%rax)
movl 0x1100(%rax), %edi
movq %r12, %rsi
movq %r13, %rdx
callq 0x198d0
movq 0x58(%rbx), %r13
movl 0x1100(%r13), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x19170
testq %rax, %rax
je 0x21f57
movq %rax, %r12
movq 0x46f45(%rip), %rax     # 0x68da0
movss 0x4(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x420(%rsp), %rbp
movq 0x58(%r12), %rdx
movss 0x10f4(%rdx), %xmm0
addss 0x31081(%rip), %xmm0    # 0x52f04
ucomiss 0xc(%rsp), %xmm0
jbe 0x21f39
addq %r14, %rdx
addq %r14, %r13
movq %rbp, %rdi
leaq 0x318d1(%rip), %rsi     # 0x5376f
movq %r13, %rcx
leaq 0x220(%rsp), %r8
xorl %eax, %eax
callq 0x196f0
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
movq 0x46ec2(%rip), %r13     # 0x68da0
movss 0x4(%r13), %xmm0
movq 0x46715(%rip), %rdi     # 0x68600
xorl %edx, %edx
leaq 0x317a7(%rip), %rcx     # 0x5369b
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
movss 0x4(%r13), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x58(%rbx), %r13
movl 0x1100(%r13), %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19170
movq %rax, %r12
testq %rax, %rax
jne 0x21e6e
movq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x19080
jmp 0x220cd
addq %r12, %r12
leaq (%r12,%r12,4), %rax
cqto
idivq %r15
movq %rax, %r14
movl $0x2, %edx
xorl %edi, %edi
xorl %esi, %esi
callq 0x19170
testq %rax, %rax
je 0x21ff1
movq %rax, %r15
movq 0x4666c(%rip), %r12     # 0x68600
leaq 0x3178e(%rip), %r13     # 0x53729
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 0x21f9b
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x22009
movq 0x110(%rdi), %rsi
callq 0x19080
jmp 0x2200e
callq 0x18590
xorl %r15d, %r15d
jmp 0x220cd
leaq 0x317b8(%rip), %rdi     # 0x537d5
movq 0x20(%r15), %r12
callq *0x48(%r15)
movss 0x31433(%rip), %xmm0    # 0x53460
xorps %xmm2, %xmm2
movq %r13, %rdi
movl $0x5, %esi
movl %eax, %edx
movss 0xc(%rsp), %xmm1
callq *%r12
movq %rbx, 0x110(%r13)
orb $-0x80, 0x11f(%r13)
xorl %ebp, %ebp
movl %ebp, 0x108(%r13)
movq %r13, %rdi
callq *0x90(%r15)
movss 0x4(%r14), %xmm0
addss 0x3121d(%rip), %xmm0    # 0x53290
movss %xmm0, 0x200(%r13)
movq 0x4653d(%rip), %rax     # 0x685c0
movq %rax, 0x210(%r13)
movl 0x28(%r13), %eax
movq 0x110(%r13), %rcx
movl %eax, 0x30(%rcx)
movl %ebp, 0x28(%r13)
movq 0x330(%r13), %rax
subq 0x46d96(%rip), %rax     # 0x68e40
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 $0xbf8, %rsp            # imm = 0xBF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq