// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_combat.c
// Function: T_RadiusDamage
void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod)
{
	float	points;
	edict_t	*ent = NULL;
	vec3_t	v;
	vec3_t	dir;

#ifdef WEAP_BALANCE_OK	
	float vlength, adjuster; //surt weaponbalance
#endif

	while ((ent = findradius(ent, inflictor->s.origin, radius)) != NULL)
	{
		if (ent == ignore)
			continue;
		if (!ent->takedamage)
			continue;

		VectorAdd (ent->mins, ent->maxs, v);
		VectorMA (ent->s.origin, 0.5, v, v);
		VectorSubtract (inflictor->s.origin, v, v);

#ifdef WEAP_BALANCE_OK	
		if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		{
			vlength = VectorLength(v); //hopefully in id-units
			//'corrected' radius damage formula
			if (vlength < 1)
				vlength = 0; //no negatives
			if (radius < 1)
				radius = 1; //no divide by zero, no negatives
			adjuster = 1 - (vlength / radius);
			//as vlength approaches radius, adjuster approaches zero
			//we then multiply this value into the damage, so that
			//damage approaches zero at the radius of the explosion
			points = damage * adjuster;
			//assuming id calculated the vector length correctly, then
			//this should be a drop off of r over the radius, making
			//it worst to be very close to the center of an explosion,
			//but also allowing you to 'feel' a big explosion nearby
		}
		else //original id code
			points = damage - 0.5 * VectorLength (v);
#else
		points = damage - 0.5 * VectorLength (v);
#endif

		if (ent == attacker)
			points = points * 0.5;
		if (points > 0)
		{
			if (CanDamage (ent, inflictor))
			{
				VectorSubtract (ent->s.origin, inflictor->s.origin, dir);
				T_Damage (ent, inflictor, attacker, dir, inflictor->s.origin, vec3_origin, (int)points, (int)points, DAMAGE_RADIUS, mod);
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movss %xmm1, -0x24(%rbp)
movl %ecx, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x4, %rsi
movss -0x24(%rbp), %xmm0
callq 0x19ae0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x33434
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x3325c
jmp 0x3322c
movq -0x38(%rbp), %rax
cmpl $0x0, 0x27c(%rax)
jne 0x3326b
jmp 0x3322c
movq -0x38(%rbp), %rax
movss 0xcc(%rax), %xmm0
movq -0x38(%rbp), %rax
addss 0xd8(%rax), %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x38(%rbp), %rax
movss 0xd0(%rax), %xmm0
movq -0x38(%rbp), %rax
addss 0xdc(%rax), %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x38(%rbp), %rax
movss 0xd4(%rax), %xmm0
movq -0x38(%rbp), %rax
addss 0xe0(%rax), %xmm0
movss %xmm0, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
leaq -0x44(%rbp), %rsi
leaq -0x44(%rbp), %rdx
movss 0x3f876(%rip), %xmm0    # 0x72b50
callq 0x199c0
movq -0x8(%rbp), %rax
movss 0x4(%rax), %xmm0
subss -0x44(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x8(%rbp), %rax
movss 0x8(%rax), %xmm0
subss -0x40(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movss 0xc(%rax), %xmm0
subss -0x3c(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x194e0
movsd -0x58(%rbp), %xmm1
cvtss2sd %xmm0, %xmm0
movsd 0x3f808(%rip), %xmm2    # 0x72b48
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x33379
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3e0bc(%rip), %xmm1    # 0x71428
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x2c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3342f
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x189d0
cmpl $0x0, %eax
je 0x3342d
movq -0x38(%rbp), %rax
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, -0x50(%rbp)
movq -0x38(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movss 0xc(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0xc(%rax), %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movq -0x8(%rbp), %r8
addq $0x4, %r8
cvttss2si -0x2c(%rbp), %r11d
cvttss2si -0x2c(%rbp), %r10d
movl -0x28(%rbp), %eax
movq 0x4f355(%rip), %r9      # 0x82768
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x192c0
jmp 0x3342f
jmp 0x3322c
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)