// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_combat.c
// Function: T_Damage
void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point, vec3_t normal, int damage, int knockback, int dflags, int mod)
{
	gclient_t	*client;
	int			take;
	int			vampdrain;
	int			save;
	int			asave;
	int			psave;
	int			te_sparks;

	if (Match_InCountdown())
		return;
	
	if (!targ->takedamage)
		return;

	// friendly fire avoidance
	// if enabled you can't hurt teammates (but you can hurt yourself)
	// knockback still occurs
	if ((targ != attacker) && (deathmatch->value || coop->value))
	{
		if (OnSameTeam (targ, attacker))
		{
			if (	
					(   ((int)(dmflags->value)) & DF_NO_FRIENDLY_FIRE   )  && 
					!(dflags & DAMAGE_NO_PROTECTION) &&
					!(mod & MOD_TELEFRAG)   
				)
			{
				damage = 0;
			}
			else
				mod |= MOD_FRIENDLY_FIRE;
		}
	}
	meansOfDeath = mod;

	// easy mode takes half damage
	if (skill->value == 0 && deathmatch->value == 0 && targ->client)
	{
		damage *= 0.5;
		if (!damage)
			damage = 1;
	}

	client = targ->client;

	if (dflags & DAMAGE_BULLET)
		te_sparks = TE_BULLET_SPARKS;
	else
		te_sparks = TE_SPARKS;

	VectorNormalize(dir);

// bonus damage for suprising a monster
	if (!(dflags & DAMAGE_RADIUS) && (targ->svflags & SVF_MONSTER) && (attacker->client) && (!targ->enemy) && (targ->health > 0))
		damage *= 2;

	if (targ->flags & FL_NO_KNOCKBACK)
		knockback = 0;

	// apply Damage rune
	damage = DamageRuneHook(targ, inflictor, attacker, damage, knockback, dflags);

// figure momentum add
	if (!(dflags & DAMAGE_NO_KNOCKBACK))
	{
		if ((knockback) && (targ->movetype != MOVETYPE_NONE) && (targ->movetype != MOVETYPE_BOUNCE) && (targ->movetype != MOVETYPE_PUSH) && (targ->movetype != MOVETYPE_STOP))
		{
			vec3_t	kvel;
			float	mass;

			if (targ->mass < 50)
				mass = 50;
			else
				mass = targ->mass;

			if (targ->client  && attacker == targ)
				VectorScale (dir, 1600.0 * (float)knockback / mass, kvel);	// the rocket jump hack...
			else
				VectorScale (dir, 500.0 * (float)knockback / mass, kvel);
			
#ifdef WEAP_BALANCE_OK	
			if ((int)ctfflags->value & CTF_WEAP_BALANCE) //a little extra umph to knockback
			{
				if (targ->client  && attacker == targ)
					VectorScale (dir, 1800.0 * (float)knockback / mass, kvel);	// the rocket jump hack...
				else
					VectorScale (dir, 800.0 * (float)knockback / mass, kvel);
			}
#endif
			if (targ->groundentity)
			{
				if (kvel[2] < 0)
					kvel[2] = 0;
			}
			VectorAdd (targ->velocity, kvel, targ->velocity);
		}
	}

	take = damage;
	save = 0;

	// check for godmode
	if ( (targ->flags & FL_GODMODE) && !(dflags & DAMAGE_NO_PROTECTION) )
	{
		take = 0;
		save = damage;
		SpawnDamage (te_sparks, point, normal, save);
	}

	// check for invincibility
	if ((client && client->invincible_framenum > level.framenum ) && !(dflags & DAMAGE_NO_PROTECTION))
	{
		if (targ->pain_debounce_time < level.time)
		{
			gi.sound(targ, CHAN_ITEM, gi.soundindex("items/protect4.wav"), 1, ATTN_NORM, 0);
			targ->pain_debounce_time = level.time + 2;
		}
		take = 0;
		save = damage;
	}

	psave = CheckPowerArmor (targ, point, normal, take, dflags);
	take -= psave;

	// apply Resist rune
	take = ResistRuneHook(targ, inflictor, attacker, take, knockback, dflags);

	// armor protect from teammates...only protect normal armor
	if (((int) ctfflags->value & CTF_TEAM_ARMOR_PROTECT) &&
	    (OnSameTeam (targ, attacker)) &&
	    (targ != attacker))
	  asave = 0;
	else
	{
	  asave = CheckArmor (targ, point, normal, take, te_sparks, dflags);
	  take -= asave;
	}

	//treat cheat/powerup savings the same as armor
	asave += save;

	// team damage avoidance
	if (!(dflags & DAMAGE_NO_PROTECTION) && CheckTeamDamage (targ, attacker))
		return;

// do the damage
	if (take)
	{
		if ((targ->svflags & SVF_MONSTER) || (client))
			SpawnDamage (TE_BLOOD, point, normal, take);
		else
			SpawnDamage (te_sparks, point, normal, take);


		targ->health = targ->health - take;

		if (attacker && attacker->client && attacker->client->rune)   //added by Vampire - if the attacker is this client
		{                                                             // and the client has a rune
			if ((attacker->client->rune->runetype == RUNE_VAMP)&&(attacker!=targ))   // if the rune is the VAMPIRE rune and the target is not himself
			{
				if (Q_stricmp(targ->classname,"player") == 0)                     // if the target is a player,
                {
					vampdrain = attacker->health + (take >> 1); // take half of the health removed from the player
					if (vampdrain < 250)
						attacker->health = vampdrain;        // and add it to the attackers health
					else
						attacker->health = 250;              // to a maximum of 250 health
					gi.sound(attacker, CHAN_ITEM, gi.soundindex("brain/brnatck3.wav"), 1, ATTN_NORM, 0); //make the vampiric sound
					//gi.bprintf(PRINT_MEDIUM,"sucking the life from %s\n",targ->classname);   //for debugging purposes
				}
				else if (Q_stricmp(targ->classname, "bodyque") == 0)      // if the target is a dead body.  NOTE: the grapple classname = 'noclass'
				{
					vampdrain = attacker->health + (take >> 2); // take quarter of the health removed from the corpse
					if (vampdrain < 250)
						attacker->health = vampdrain;        // and add it to the attackers health
					else
						attacker->health = 250;              // to a maximum of 250 health
					gi.sound(attacker, CHAN_ITEM, gi.soundindex("brain/brnatck3.wav"), 1, ATTN_NORM, 0); //make the vampiric sound
					//gi.bprintf(PRINT_MEDIUM,"sucking the life from %s\n",targ->classname);   //for debugging purposes
				}
			}
		}




		// LM_JORM -- CTF Track those who hit the flag carrier
		if ((redflag  &&  redflag->owner == targ)	||
			(blueflag && blueflag->owner == targ))
		{
			if (attacker && attacker->client)
				attacker->client->hit_carrier_time = level.time;
		}
		// END LM_JORM
			
		if (targ->health <= 0)
		{
			if ((targ->svflags & SVF_MONSTER) || (client))
				targ->flags |= FL_NO_KNOCKBACK;
			Killed (targ, inflictor, attacker, take, point);
			return;
		}
	}

	//no monsters
	//bat
#ifdef MONSTERS_OK
	if (targ->svflags & SVF_MONSTER)
	{
		M_ReactToDamage (targ, attacker);
		if (!(targ->monsterinfo.aiflags & AI_DUCKED) && (take))
		{
			targ->pain (targ, attacker, knockback, take);
			// nightmare mode monsters don't go into pain frames often
			if (skill->value == 3)
				targ->pain_debounce_time = level.time + 5;
		}
	}
	else if (client)
#else	
	if (client)
#endif
	{
		if (!(targ->flags & FL_GODMODE) && (take))
			targ->pain (targ, attacker, knockback, take);
	}
	else if (take)
	{
		if (targ->pain)
			targ->pain (targ, attacker, knockback, take);
	}

	// add to the damage inflicted on a player this frame
	// the total will be turned into screen blends and view angle kicks
	// at the end of the frame
	if (client)
	{
		client->damage_parmor += psave;
		client->damage_armor += asave;
		client->damage_blood += take;
		client->damage_knockback += knockback;
		VectorCopy (point, client->damage_from);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %rbp
movq %r8, %r13
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
xorl %eax, %eax
callq 0x19510
testl %eax, %eax
je 0x290bd
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x27c(%r15)
je 0x290ae
movq %rbp, 0x8(%rsp)
movq %rbx, 0x18(%rsp)
movl 0xc8(%rsp), %ebp
movl 0xb0(%rsp), %ebx
cmpq %r14, %r15
je 0x2915d
movq 0x3ddd5(%rip), %rax     # 0x66ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
jne 0x29113
jp 0x29113
movq 0x3de5c(%rip), %rax     # 0x66f60
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x29113
jnp 0x2915d
movq %r15, %rdi
movq %r14, %rsi
callq 0x18750
testl %eax, %eax
je 0x2915d
movq 0x3d4ef(%rip), %rax     # 0x66618
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
shrl $0x8, %eax
andl $0x1, %eax
movl 0xc0(%rsp), %ecx
andl $0x20, %ecx
movl %ebp, %edx
andl $0x15, %edx
orl %ecx, %edx
sete %cl
movl %ebp, %edx
orl $0x8000000, %edx        # imm = 0x8000000
xorl %esi, %esi
testb %al, %cl
cmovel %edx, %ebp
cmovnel %esi, %ebx
movq 0x3d9c4(%rip), %rax     # 0x66b28
movl %ebp, (%rax)
movq 0x3d5cb(%rip), %rax     # 0x66738
movq (%rax), %rax
movss 0x20(%rax), %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
movq %r15, 0x10(%rsp)
movq %r13, 0x20(%rsp)
jne 0x291bc
jp 0x291bc
movq 0x3dd30(%rip), %rax     # 0x66ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm1
ucomiss %xmm0, %xmm1
jne 0x291bc
jp 0x291bc
cmpq $0x0, 0x58(%r15)
je 0x291bc
cvtsi2sd %ebx, %xmm0
mulsd 0x28a1e(%rip), %xmm0    # 0x51bd0
cvttsd2si %xmm0, %ebx
cmpl $0x1, %ebx
adcl $0x0, %ebx
movq 0x10(%rsp), %r15
movq 0x58(%r15), %rax
movq %rax, 0x40(%rsp)
movl 0xc0(%rsp), %r13d
movl %r13d, %ebp
andl $0x10, %ebp
shrl $0x4, %ebp
movq %r12, %rdi
callq 0x183c0
testb $0x1, %r13b
jne 0x2921d
testb $0x4, 0xc8(%r15)
movq 0x20(%rsp), %r13
je 0x29224
cmpq $0x0, 0x58(%r14)
je 0x29224
movq 0x10(%rsp), %r15
cmpq $0x0, 0x2a0(%r15)
jne 0x29229
cmpl $0x0, 0x254(%r15)
setg %cl
shll %cl, %ebx
jmp 0x29229
movq 0x20(%rsp), %r13
jmp 0x29229
movq 0x10(%rsp), %r15
xorl %eax, %eax
btl $0xb, 0x11c(%r15)
movl 0xb8(%rsp), %r8d
movl $0x0, 0x34(%rsp)
cmovbl %eax, %r8d
movq %r15, %rdi
movq 0x18(%rsp), %rsi
movq %r14, 0x38(%rsp)
movq %r14, %rdx
movl %ebx, %ecx
movl %r8d, 0x10(%rsp)
movl 0xc0(%rsp), %r14d
movl %r14d, %r9d
callq 0x180a0
movl %eax, %ebx
testb $0x8, %r14b
jne 0x2929c
cmpl $0x0, 0x10(%rsp)
je 0x2929c
movl 0x118(%r15), %eax
cmpl $0x9, %eax
ja 0x295cd
movl $0x20d, %ecx            # imm = 0x20D
btl %eax, %ecx
jae 0x295cd
leal 0x9(%rbp,%rbp,4), %eax
movl %eax, 0x48(%rsp)
movl 0xc0(%rsp), %eax
testb $0x20, %al
jne 0x292e0
movl 0x11c(%r15), %eax
movl %ebx, %r12d
andl $0x10, %eax
movq 0x8(%rsp), %rbp
movq 0x38(%rsp), %r14
je 0x292ed
movl 0x48(%rsp), %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x19c30
xorl %r12d, %r12d
movl %ebx, 0x34(%rsp)
jmp 0x292ed
movl %ebx, %r12d
movq 0x8(%rsp), %rbp
movq 0x38(%rsp), %r14
cmpq $0x0, 0x40(%rsp)
je 0x2938b
movl 0xc0(%rsp), %eax
testb $0x20, %al
jne 0x2938b
movq 0x3da91(%rip), %r13     # 0x66da0
cvtsi2ssl (%r13), %xmm0
movq 0x40(%rsp), %rax
movss 0xf08(%rax), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x2938b
movss 0x4(%r13), %xmm0
xorl %r12d, %r12d
ucomiss 0x244(%r15), %xmm0
jbe 0x29383
movq 0x3d2bf(%rip), %rax     # 0x66600
movq 0x20(%rax), %rbp
leaq 0x298be(%rip), %rdi     # 0x52c0a
callq *0x48(%rax)
pushq $0x3
popq %rsi
movss 0x25bce(%rip), %xmm0    # 0x4ef28
xorps %xmm2, %xmm2
movq %r15, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%rbp
movq 0x8(%rsp), %rbp
movss 0x4(%r13), %xmm0
addss 0x260f2(%rip), %xmm0    # 0x4f46c
movss %xmm0, 0x244(%r15)
movl %ebx, 0x34(%rsp)
xorl %ebx, %ebx
jmp 0x293c4
xorl %ebx, %ebx
testl %r12d, %r12d
je 0x293c1
movq 0x58(%r15), %rbp
movl 0xc0(%rsp), %eax
andl $0x2, %eax
shrl %eax
testq %rbp, %rbp
sete %cl
orb %al, %cl
movq 0x20(%rsp), %r13
je 0x294da
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbp
jmp 0x293ce
xorl %r12d, %r12d
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rsi
subl %ebx, %r12d
movq %r15, %rdi
movq %r14, %rdx
movl %r12d, %ecx
movl 0x10(%rsp), %r8d
movl 0xc0(%rsp), %r9d
callq 0x187d0
movl %eax, %r12d
movq 0x3d762(%rip), %rax     # 0x66b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
btl $0xa, %eax
jb 0x294b7
xorl %edx, %edx
testl %r12d, %r12d
je 0x295f1
movq 0x58(%r15), %r13
testq %r13, %r13
sete %al
movl 0xc0(%rsp), %ecx
andl $0x2, %ecx
shrl %ecx
orb %al, %cl
jne 0x295f1
movq %rbx, 0x28(%rsp)
movq %r15, %rdi
callq 0x187a0
testl %eax, %eax
je 0x295ea
movl %eax, %ebx
movl %eax, %edi
callq 0x18d10
movl 0xc0(%rsp), %ecx
cvtsi2ss %r12d, %xmm0
andl $0x4, %ecx
movq 0x70(%rax), %rax
mulss 0x8(%rax,%rcx), %xmm0
callq 0x18ad0
cvttss2si %xmm0, %ebp
movslq %ebx, %rax
movl 0x318(%r13,%rax,4), %ecx
cmpl %ebp, %ecx
cmovll %ecx, %ebp
testl %ebp, %ebp
movq 0x28(%rsp), %rbx
movl $0x0, %edx
je 0x295f1
subl %ebp, %ecx
movl %ecx, 0x318(%r13,%rax,4)
movl 0x48(%rsp), %edi
movq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x19c30
movl %ebp, %edx
jmp 0x295f1
movq %r15, %rdi
movq %r14, %rsi
callq 0x18750
cmpq %r14, %r15
je 0x29408
testl %eax, %eax
je 0x29408
xorl %edx, %edx
jmp 0x295fe
movq %r15, %rdi
callq 0x18b50
testl %eax, %eax
je 0x295bc
movl %eax, %ebx
leaq 0x28728(%rip), %rdi     # 0x51c1b
callq 0x18a80
subq 0x3d941(%rip), %rax     # 0x66e40
movl $0x88, %ecx
cqto
idivq %rcx
cltq
movl 0x318(%rbp,%rax,4), %esi
testl %esi, %esi
je 0x295bc
movq %rax, 0x60(%rsp)
cmpl $0x1, %ebx
jne 0x29939
movl %esi, 0x28(%rsp)
leaq 0x10(%r15), %rdi
leaq 0x6c(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x183d0
movsd (%r13), %xmm0
movsd 0x4(%r15), %xmm1
subps %xmm1, %xmm0
leaq 0x50(%rsp), %rbx
movlps %xmm0, (%rbx)
movss 0x8(%r13), %xmm0
subss 0xc(%r15), %xmm0
movss %xmm0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x183c0
movss 0x4(%rbx), %xmm0
leaq 0x6c(%rsp), %rax
mulss 0x4(%rax), %xmm0
movss (%rbx), %xmm1
mulss (%rax), %xmm1
addss %xmm0, %xmm1
movss 0x8(%rbx), %xmm0
mulss 0x8(%rax), %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x28645(%rip), %xmm1    # 0x51be8
ucomisd %xmm0, %xmm1
jae 0x295bc
pushq $0x1
popq %r8
pushq $0xc
popq %rdi
movl %r12d, %eax
movl 0x28(%rsp), %esi
jmp 0x2995a
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbp
xorl %ebx, %ebx
jmp 0x293ce
movl 0x1d8(%r15), %eax
cmpl $0x32, %eax
jl 0x298ad
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
jmp 0x298b5
movq 0x28(%rsp), %rbx
xorl %edx, %edx
subl %edx, %r12d
movq 0x20(%rsp), %r13
movq 0x8(%rsp), %rbp
movl 0xc0(%rsp), %eax
testb $0x20, %al
jne 0x2962a
movq %r15, %rdi
movq %r13, %r14
movl %edx, %r13d
movq 0x38(%rsp), %rsi
callq 0x185f0
movl %r13d, %edx
movq %r14, %r13
testl %eax, %eax
jne 0x290ae
testl %r12d, %r12d
je 0x29764
movl %edx, 0x8(%rsp)
movq %rbx, 0x28(%rsp)
testb $0x4, 0xc8(%r15)
pushq $0x1
popq %rbx
movl 0x48(%rsp), %edi
cmovnel %ebx, %edi
cmpq $0x0, 0x40(%rsp)
cmovnel %ebx, %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x19c30
subl %r12d, 0x254(%r15)
movq 0x38(%rsp), %r14
testq %r14, %r14
je 0x29723
movq 0x58(%r14), %rax
testq %rax, %rax
je 0x29723
movq 0xf68(%rax), %rax
testq %rax, %rax
je 0x29723
cmpq %r14, %r15
je 0x29723
cmpl $0x10, 0x478(%rax)
jne 0x29723
movq 0x138(%r15), %rdi
leaq 0x26cdb(%rip), %rsi     # 0x5038f
callq 0x186d0
testl %eax, %eax
je 0x296d7
movq 0x138(%r15), %rdi
leaq 0x28548(%rip), %rsi     # 0x51c13
callq 0x186d0
testl %eax, %eax
jne 0x29723
pushq $0x2
popq %rbx
movl %r12d, %eax
movl %ebx, %ecx
sarl %cl, %eax
addl 0x254(%r14), %eax
movl $0xfa, %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
movl %eax, 0x254(%r14)
movq 0x3cf03(%rip), %rax     # 0x66600
movq 0x20(%rax), %rbx
leaq 0x284f8(%rip), %rdi     # 0x51c00
callq *0x48(%rax)
pushq $0x3
popq %rsi
movss 0x25812(%rip), %xmm0    # 0x4ef28
xorps %xmm2, %xmm2
movq %r14, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
callq *%rbx
movq 0x3d0ce(%rip), %rax     # 0x667f8
movq (%rax), %rax
testq %rax, %rax
je 0x2973b
cmpq %r15, 0x110(%rax)
je 0x29771
movq 0x3d11e(%rip), %rax     # 0x66860
movq (%rax), %rax
testq %rax, %rax
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rbx
je 0x2979d
testq %r14, %r14
je 0x2979d
cmpq %r15, 0x110(%rax)
je 0x29780
jmp 0x2979d
cmpq $0x0, 0x40(%rsp)
jne 0x297bb
jmp 0x290ae
testq %r14, %r14
movq 0x18(%rsp), %rsi
movq 0x28(%rsp), %rbx
je 0x2979d
movq 0x58(%r14), %rax
testq %rax, %rax
je 0x2979d
movq 0x3d610(%rip), %rcx     # 0x66da0
movss 0x4(%rcx), %xmm0
movss %xmm0, 0x10f8(%rax)
cmpl $0x0, 0x254(%r15)
jle 0x29853
cmpq $0x0, 0x40(%rsp)
movl 0x8(%rsp), %edx
je 0x29885
addl 0x34(%rsp), %edx
testl %r12d, %r12d
je 0x297ec
movl 0x11c(%r15), %eax
andl $0x10, %eax
jne 0x297ec
cvtsi2ssl 0x10(%rsp), %xmm0
movq %r15, %rdi
movl %edx, %ebp
movq 0x38(%rsp), %rsi
movl %r12d, %edx
callq *0x230(%r15)
movl %ebp, %edx
movq 0x40(%rsp), %rax
movdqu 0xe58(%rax), %xmm0
movd 0x10(%rsp), %xmm1
movd %r12d, %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
movd %ebx, %xmm1
movd %edx, %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
punpcklqdq %xmm2, %xmm3    # xmm3 = xmm3[0],xmm2[0]
paddd %xmm0, %xmm3
movdqu %xmm3, 0xe58(%rax)
movss (%r13), %xmm0
movss %xmm0, 0xe68(%rax)
movss 0x4(%r13), %xmm0
movss %xmm0, 0xe6c(%rax)
movss 0x8(%r13), %xmm0
movss %xmm0, 0xe70(%rax)
jmp 0x290ae
cmpq $0x0, 0x40(%rsp)
jne 0x29867
movl 0xc8(%r15), %eax
andl $0x4, %eax
je 0x2986f
orb $0x8, 0x11d(%r15)
movq %r15, %rdi
movq %r14, %rdx
movl %r12d, %ecx
movq %r13, %r8
callq 0x19850
jmp 0x290ae
movq 0x230(%r15), %rax
testq %rax, %rax
je 0x290ae
cvtsi2ssl 0x10(%rsp), %xmm0
movq %r15, %rdi
movq 0x38(%rsp), %rsi
movl %r12d, %edx
callq *%rax
jmp 0x290ae
movsd 0x28323(%rip), %xmm0    # 0x51bd8
movq 0x38(%rsp), %rdx
xorl %eax, %eax
cmpq $0x0, 0x58(%r15)
cvtsi2ssl 0x10(%rsp), %xmm1
setne %cl
cvtss2sd %xmm1, %xmm1
cmpq %rdx, %r15
je 0x298dd
movsd 0x28305(%rip), %xmm2    # 0x51be0
jmp 0x298eb
movb %cl, %al
leaq 0x282da(%rip), %rcx     # 0x51bc0
movsd (%rcx,%rax,8), %xmm2
mulsd %xmm1, %xmm2
divsd %xmm0, %xmm2
cvtsd2ss %xmm2, %xmm0
leaq 0x50(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x18a70
cmpq $0x0, 0x2b8(%r15)
movss 0x8(%r13), %xmm0
je 0x299c4
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
movq 0x20(%rsp), %r13
jbe 0x299c9
andl $0x0, 0x58(%rsp)
xorps %xmm0, %xmm0
jmp 0x299c9
movq 0x3d218(%rip), %rax     # 0x66b58
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
xorl %r8d, %r8d
btl $0xb, %eax
adcl $0x1, %r8d
leal (%r12,%r12), %eax
pushq $0xd
popq %rdi
movl %r8d, 0x4c(%rsp)
pushq $0x3
popq %rcx
cltd
idivl %ecx
imull %r8d, %esi
cmpl %eax, %esi
cmovgel %eax, %esi
movl %esi, 0x28(%rsp)
movq %r13, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x19c30
movq 0x3d417(%rip), %rax     # 0x66da0
cvtss2sd 0x4(%rax), %xmm0
addsd 0x2825a(%rip), %xmm0    # 0x51bf0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x268(%r15)
movl 0x28(%rsp), %esi
movl %esi, %eax
cltd
idivl 0x4c(%rsp)
movq 0x60(%rsp), %rcx
subl %eax, 0x318(%rbp,%rcx,4)
movq %rbx, %rbp
movl %esi, %ebx
jmp 0x293c9
movq 0x20(%rsp), %r13
movsd 0x1c0(%r15), %xmm1
movsd 0x50(%rsp), %xmm2
addps %xmm1, %xmm2
movlps %xmm2, 0x1c0(%r15)
addss 0x1c8(%r15), %xmm0
movss %xmm0, 0x1c8(%r15)
jmp 0x2929c