// File: /workspace/github_c_makefile_star2_O2/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, %r15
xorl %r14d, %r14d
movb %r14b, 0x10(%rsp)
movb %r14b, 0x410(%rsp)
movb %r14b, 0x800(%rsp)
callq 0x185d0
orb $-0x80, 0x11f(%r15)
movq 0x46b98(%rip), %rax     # 0x667d8
cmpl $0x4, (%rax)
jg 0x20650
pushq $-0x5
popq %rsi
movq %rbx, %rdi
callq 0x18de0
testl %eax, %eax
je 0x20650
leaq 0x210(%rsp), %rdi
movb $0x0, (%rdi)
movl 0x47c(%r15), %ebp
pushq $-0x7
popq %rdx
movl %ebp, %esi
callq 0x18210
movq 0x58(%rbx), %rdx
cmpl %ebp, 0x1100(%rdx)
jne 0x1fce1
movq %r15, %rdi
callq 0x195d0
testl %eax, %eax
je 0x1fd0e
movq 0x330(%r15), %rax
subq 0x471a2(%rip), %rax     # 0x66e40
movq 0x58(%rbx), %r12
movl $0x88, %ecx
cqto
idivq %rcx
cmpl $0x0, 0x318(%r12,%rax,4)
je 0x20650
movl 0x1100(%r12), %eax
cmpl $0x2, %eax
je 0x1ff57
cmpl $0x1, %eax
jne 0x1ff63
movq 0x46b84(%rip), %rax     # 0x66860
jmp 0x1ff5e
cmpl $0x2, %ebp
je 0x1fd33
cmpl $0x1, %ebp
jne 0x1fd5a
movq 0x46ca6(%rip), %rax     # 0x66998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x1, %al
jne 0x20650
movabsq $0x100000000100, %rax   # imm = 0x100000000100
jmp 0x1fd54
movl 0x47c(%r15), %eax
cmpl $0x1, %eax
je 0x20467
cmpl $0x2, %eax
jne 0x20495
leaq 0x2f891(%rip), %rdi     # 0x4f5bf
jmp 0x2046e
movq 0x46c5e(%rip), %rax     # 0x66998
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
testb $0x2, %al
jne 0x20650
movabsq $0x40000000100, %rax    # imm = 0x40000000100
orq %rax, 0x40(%rbx)
jmp 0x1fd5e
orb $0x1, 0x41(%rbx)
movl $0x2c0, %r12d           # imm = 0x2C0
addq %r12, %rdx
leaq 0x2fa23(%rip), %rsi     # 0x4f791
leaq 0x410(%rsp), %rbp
movq %rbp, %rdi
xorl %eax, %eax
callq 0x198c0
movq 0x58(%rbx), %rdx
addq %r12, %rdx
leaq 0x2fa18(%rip), %rsi     # 0x4f7a6
leaq 0x800(%rsp), %r13
leaq 0x210(%rsp), %rcx
movq %r13, %rdi
xorl %eax, %eax
callq 0x198c0
pushq $0xc
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x194d0
addq 0x58(%rbx), %r12
movq 0x46fdf(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
movq 0x46833(%rip), %r14     # 0x66600
leaq 0x2f9e9(%rip), %rcx     # 0x4f7bd
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x18fb0
movl 0x47c(%r15), %edi
movq %rbp, %rsi
movq %r13, %rdx
movq %r15, %r12
callq 0x19ab0
movq %r15, %rdi
callq 0x195d0
testl %eax, %eax
je 0x1fe5b
movq 0x20(%r14), %r15
leaq 0x2f9b3(%rip), %rdi     # 0x4f7c6
callq *0x48(%r14)
movss 0x2f649(%rip), %xmm0    # 0x4f468
movss 0x2f101(%rip), %xmm1    # 0x4ef28
xorps %xmm2, %xmm2
movss %xmm2, (%rsp)
movq %r12, %rdi
xorl %esi, %esi
movl %eax, %edx
callq *%r15
movl 0x47c(%r12), %eax
cmpl $0x1, %eax
movq 0x46f55(%rip), %r13     # 0x66da0
je 0x1fe9f
cmpl $0x2, %eax
jne 0x1fec9
leaq 0x2f98d(%rip), %rdi     # 0x4f7e6
jmp 0x1fea6
movq 0x46f3e(%rip), %r13     # 0x66da0
movss 0x4(%r13), %xmm0
movss 0x4c2b4(%rip), %xmm1    # 0x6c124
addss 0x2f080(%rip), %xmm1    # 0x4eef8
ucomiss %xmm1, %xmm0
jbe 0x1fec9
movss %xmm0, 0x4c29f(%rip)    # 0x6c124
movl 0x47c(%r12), %eax
movss 0x2f093(%rip), %xmm0    # 0x4ef28
movss %xmm0, (%rsp)
cmpl $0x1, %eax
jne 0x1fe4d
leaq 0x2f92f(%rip), %rdi     # 0x4f7d5
movq 0x20(%r14), %r15
callq *0x48(%r14)
pushq $0x5
popq %rsi
movss 0x2f5a7(%rip), %xmm0    # 0x4f460
xorps %xmm2, %xmm2
movq %r12, %rdi
movl %eax, %edx
movss (%rsp), %xmm1
callq *%r15
movq %rbx, 0x110(%r12)
orb $-0x80, 0x11f(%r12)
andl $0x0, 0x108(%r12)
movq %r12, %rdi
callq *0x90(%r14)
movss 0x4(%r13), %xmm0
addss 0x2f395(%rip), %xmm0    # 0x4f290
movss %xmm0, 0x200(%r12)
movq 0x466b4(%rip), %rax     # 0x665c0
movq %rax, 0x210(%r12)
movl 0x28(%r12), %eax
movq 0x110(%r12), %rcx
movl %eax, 0x30(%rcx)
andl $0x0, 0x28(%r12)
movq 0x58(%rbx), %rcx
movq 0x330(%r12), %rax
subq 0x46f03(%rip), %rax     # 0x66e40
movl $0x88, %esi
cqto
idivq %rsi
incl 0x318(%rcx,%rax,4)
pushq $0x1
popq %r14
jmp 0x20650
movq 0x4689a(%rip), %rax     # 0x667f8
movq (%rax), %rbp
jmp 0x1ff65
xorl %ebp, %ebp
leaq 0x210(%rsp), %r14
movb $0x0, (%r14)
movq %r15, (%rsp)
movl 0x47c(%r15), %esi
pushq $-0x6
popq %rdx
movq %r14, %rdi
callq 0x18210
movl $0x2c0, %r15d           # imm = 0x2C0
addq %r15, %r12
leaq 0x2f65d(%rip), %rsi     # 0x4f5f4
leaq 0x410(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x198c0
movq 0x58(%rbx), %rdx
addq %r15, %rdx
leaq 0x2f652(%rip), %rsi     # 0x4f60c
leaq 0x800(%rsp), %r12
movq %r12, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x198c0
movq %rbp, 0x8(%rsp)
movl 0x47c(%rbp), %edi
movq %r13, %rsi
movq %r12, %rdx
callq 0x19ab0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %r12d
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
callq 0x192e0
movq %rax, %rbp
pushq $0x1
popq %r14
testq %rbp, %rbp
je 0x201fd
movq 0x46d8d(%rip), %r12     # 0x66da0
movss 0x4(%r12), %xmm0
movq 0x58(%rbp), %rdx
movss 0x10f4(%rdx), %xmm1
addss 0x2eed2(%rip), %xmm1    # 0x4ef00
ucomiss %xmm0, %xmm1
jbe 0x200b8
addq %r15, %rdx
movq %r13, %rdi
leaq 0x2f5e2(%rip), %rsi     # 0x4f626
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
movq %r13, %rsi
callq 0x193f0
movq %rbp, %rdi
pushq $0x3
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rax
incl 0xdf4(%rax)
andl $0x0, 0x10f4(%rax)
movq %rbp, %rdi
pushq $0xa
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rsi
addq %r15, %rsi
movss 0x4(%r12), %xmm0
movq 0x46568(%rip), %rdi     # 0x66600
xorl %edx, %edx
leaq 0x2f5bb(%rip), %rcx     # 0x4f65c
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x18fb0
movss 0x4(%r12), %xmm0
movq 0x58(%rbp), %rdx
movss 0x10f0(%rdx), %xmm1
addss 0x2ee44(%rip), %xmm1    # 0x4ef0c
ucomiss %xmm0, %xmm1
jbe 0x20152
addq %r15, %rdx
movq %r13, %rdi
leaq 0x2f58d(%rip), %rsi     # 0x4f66b
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
movq %r13, %rsi
callq 0x193f0
movq %rbp, %rdi
pushq $0x3
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rax
incl 0xdf4(%rax)
andl $0x0, 0x10f0(%rax)
movq %rbp, %rdi
pushq $0xa
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rsi
addq %r15, %rsi
movss 0x4(%r12), %xmm0
movq 0x464ce(%rip), %rdi     # 0x66600
xorl %edx, %edx
leaq 0x2f560(%rip), %rcx     # 0x4f69b
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x18fb0
movss 0x4(%r12), %xmm0
movq 0x58(%rbp), %rdx
movss 0x10ec(%rdx), %xmm1
addss 0x2f30a(%rip), %xmm1    # 0x4f46c
ucomiss %xmm0, %xmm1
jbe 0x201dd
addq %r15, %rdx
movq %r13, %rdi
leaq 0x2f537(%rip), %rsi     # 0x4f6ab
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
movq %r13, %rsi
callq 0x193f0
movq %rbp, %rdi
pushq $0x3
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rax
incl 0xdf4(%rax)
andl $0x0, 0x10ec(%rax)
movq %rbp, %rdi
pushq $0xa
popq %rsi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbp), %rsi
addq %r15, %rsi
movss 0x4(%r12), %xmm0
movq 0x46438(%rip), %rdi     # 0x66600
xorl %edx, %edx
leaq 0x2f50a(%rip), %rcx     # 0x4f6db
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x18fb0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %r12d
movq %rbp, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x192e0
movq %rax, %rbp
jmp 0x20003
cmpl $0x2, %r12d
je 0x20233
cmpl $0x1, %r12d
movq (%rsp), %r12
jne 0x2025d
movq 0x466e4(%rip), %rax     # 0x668f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x2f4c6(%rip), %rsi     # 0x4f6eb
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x198c0
jmp 0x2027b
movq 0x466be(%rip), %rax     # 0x668f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
incl %edx
leaq 0x2f4b3(%rip), %rsi     # 0x4f6fe
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x198c0
movq (%rsp), %r12
jmp 0x2027b
movabsq $0x70755f656c6574, %rax # imm = 0x70755F656C6574
movq %rax, 0x15(%rsp)
movabsq $0x6c65742f6373696d, %rax # imm = 0x6C65742F6373696D
movq %rax, 0x10(%rsp)
movq 0x4637e(%rip), %r13     # 0x66600
movq 0x20(%r13), %r14
leaq 0x10(%rsp), %rdi
callq *0x48(%r13)
pushq $0x5
popq %r15
movss 0x2ec8d(%rip), %xmm0    # 0x4ef28
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
movl %r15d, %esi
movl %eax, %edx
callq *%r14
pushq $0x3
popq %r14
movl %r14d, %edi
callq *0xc8(%r13)
pushq $0x14
popq %rdi
callq *0xc8(%r13)
addq $0x4, %r12
movq %r12, %rdi
callq *0xf0(%r13)
pushq $0x2
popq %rbp
movq %r12, %rdi
movl %ebp, %esi
callq *0xb0(%r13)
pushq $0x5
popq %rdx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x194d0
movq 0x58(%rbx), %rax
addl $0x5, 0xdf4(%rax)
pushq $0x4
popq %rsi
pushq $0x1
popq %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x194d0
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%rbx), %rsi
movq 0x46a84(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
leaq 0x2f3f7(%rip), %rcx     # 0x4f71f
movq %r13, %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movl %r15d, %r9d
callq 0x18fb0
movq 0x46819(%rip), %rax     # 0x66b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0x9, %eax
jb 0x20359
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
jmp 0x203c5
pushq $-0x5
popq %r15
xorl %edi, %edi
xorl %esi, %esi
movl %r15d, %edx
callq 0x192e0
movq %r14, %r12
testq %rax, %rax
je 0x2039c
movq 0x58(%rax), %rcx
movl 0x1100(%rcx), %ecx
cmpl $0x2, %ecx
je 0x2038a
cmpl $0x1, %ecx
jne 0x2038d
incq %r14
jmp 0x2038d
incq %r12
movq %rax, %rdi
xorl %esi, %esi
movl %r15d, %edx
callq 0x192e0
jmp 0x2036c
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
cmpl $0x2, %edx
je 0x20665
cmpl $0x1, %edx
jne 0x203c5
imulq $0xa, %r12, %rax
cqto
idivq %r14
movq %rax, %r14
pushq $0x1
popq %rdx
jmp 0x203c9
pushq $0xa
popq %r14
xorl %edi, %edi
xorl %esi, %esi
callq 0x192e0
movq %rax, %r13
pushq $0x3
popq %rbp
movq 0x46221(%rip), %r15     # 0x66600
leaq 0x2f343(%rip), %r12     # 0x4f729
testq %r13, %r13
je 0x20442
movq %r13, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%r13), %rsi
addl %r14d, 0xdf4(%rsi)
addq $0x2c0, %rsi            # imm = 0x2C0
movq 0x4698f(%rip), %rax     # 0x66da0
movss 0x4(%rax), %xmm0
movq %r15, %rdi
xorl %edx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
movl %r14d, %r9d
callq 0x18fb0
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x192e0
movq %rax, %r13
jmp 0x203e6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2045a
movq 0x110(%rdi), %rsi
callq 0x191d0
jmp 0x2045f
callq 0x185d0
xorl %r14d, %r14d
jmp 0x20650
leaq 0x2f13e(%rip), %rdi     # 0x4f5ac
movq 0x4618b(%rip), %rax     # 0x66600
movq 0x20(%rax), %r14
callq *0x48(%rax)
pushq $0x5
popq %rsi
movss 0x2efd9(%rip), %xmm0    # 0x4f460
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rdi
movl %eax, %edx
callq *%r14
movq %r15, (%rsp)
movl $0x2c0, %r13d           # imm = 0x2C0
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x2f287(%rip), %rsi     # 0x4f734
leaq 0x410(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x198c0
movq 0x58(%rbx), %rdx
addq %r13, %rdx
leaq 0x2f27f(%rip), %rsi     # 0x4f74c
leaq 0x800(%rsp), %r15
leaq 0x210(%rsp), %rcx
movq %r15, %rdi
xorl %eax, %eax
callq 0x198c0
pushq $0xb
popq %rsi
pushq $0x1
popq %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x194d0
pushq $0x3
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x194d0
movq 0x58(%rbx), %rsi
addq %r13, %rsi
movq 0x4688b(%rip), %r14     # 0x66da0
movss 0x4(%r14), %xmm0
movq 0x460de(%rip), %rdi     # 0x66600
leaq 0x2f23d(%rip), %rcx     # 0x4f766
pushq $0x1
popq %r9
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x18fb0
movq 0x58(%rbx), %rax
incl 0xdf4(%rax)
movss 0x4(%r14), %xmm0
movss %xmm0, 0x10f0(%rax)
movl 0x1100(%rax), %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x19ab0
movq 0x58(%rbx), %r15
movl 0x1100(%r15), %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x192e0
movq %rax, %rbp
testq %rax, %rax
je 0x20642
movq 0x58(%rbp), %rdx
movss 0x10f4(%rdx), %xmm0
addss 0x2e96b(%rip), %xmm0    # 0x4ef00
ucomiss 0x4(%r14), %xmm0
jbe 0x20633
addq %r13, %rdx
addq %r13, %r15
leaq 0x410(%rsp), %r12
movq %r12, %rdi
leaq 0x2f1b7(%rip), %rsi     # 0x4f76f
movq %r15, %rcx
leaq 0x210(%rsp), %r8
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
movq %r12, %rsi
callq 0x193f0
movq %rbp, %rdi
pushq $0x3
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
callq 0x194d0
movq 0x58(%rbp), %rsi
addq %r13, %rsi
movss 0x4(%r14), %xmm0
movq 0x46005(%rip), %rdi     # 0x66600
xorl %edx, %edx
leaq 0x2f097(%rip), %rcx     # 0x4f69b
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x18fb0
movq 0x58(%rbp), %rax
incl 0xdf4(%rax)
andl $0x0, 0x10f4(%rax)
movq %rbp, %rdi
pushq $0xa
popq %rsi
movq %r15, %rdx
callq 0x194d0
movq 0x58(%rbx), %r15
movl 0x1100(%r15), %edx
movq %rbp, %rdi
jmp 0x2056d
xorl %r14d, %r14d
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x191d0
movl %r14d, %eax
addq $0xbe8, %rsp            # imm = 0xBE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
imulq $0xa, %r14, %rax
cqto
idivq %r12
movq %rax, %r14
movl %ebp, %edx
jmp 0x203c9