// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_misc.c
// Function: func_explosive_explode
void func_explosive_explode (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
	vec3_t	origin;
	vec3_t	chunkorigin;
	vec3_t	size;
	int		count;
	int		mass;


	//surt, why was this commented out?????
	// bmodel origins are (0 0 0), we need to adjust that here
	VectorScale (self->size, 0.5, size);
	VectorAdd (self->absmin, size, origin);
//	VectorCopy (origin, self->s.origin);
	//surt, don't copy into the ent's origin!  the ent needs to reappear
	//this information is only calculated for the throwdebris!
	

//	VectorCopy(self->s.origin, origin); //surt FIXME put something in origin

	self->takedamage = DAMAGE_NO;

	if (self->dmg)
		T_RadiusDamage (self, attacker, self->dmg, NULL, self->dmg+40, MOD_EXPLOSIVE);
	
	//surt this is commented out because we don't want to screw with
	//self while generating the debris
//	VectorSubtract (self->s.origin, inflictor->s.origin, self->velocity);
//	VectorNormalize (self->velocity);
//	VectorScale (self->velocity, 150, self->velocity);
	
	// start chunks towards the center
	VectorScale (size, 0.5, size);

	mass = self->mass;
	if (!mass)
		mass = 75;

	// big chunks
	if (mass >= 100)
	{
		count = mass / 100;
		if (count > 8)
			count = 8;
		while(count--)
		{
			chunkorigin[0] = origin[0] + crandom() * size[0];
			chunkorigin[1] = origin[1] + crandom() * size[1];
			chunkorigin[2] = origin[2] + crandom() * size[2];
			ThrowDebris (self, "models/objects/debris1/tris.md2", 1, chunkorigin);
		}
	}

	// small chunks
	count = mass / 25;
	if (count > 16)
		count = 16;
	while(count--)
	{
		chunkorigin[0] = origin[0] + crandom() * size[0];
		chunkorigin[1] = origin[1] + crandom() * size[1];
		chunkorigin[2] = origin[2] + crandom() * size[2];
		ThrowDebris (self, "models/objects/debris2/tris.md2", 2, chunkorigin);
	}

	G_UseTargets (self, attacker);

	// LM_JORM -- Support respawning explosive walls
	if (!deathmatch->value)
	{
		if (self->dmg)
			BecomeExplosion1 (self);
		else
			G_FreeEdict (self);
	}
	else
	{
		self->svflags |= SVF_NOCLIENT;
		self->solid = SOLID_NOT;
		self->think = func_explosive_respawn;
		self->nextthink = level.time + self->speed;
	}
	// END LM_JORM

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rdi, %rbx
addq $0xfc, %rdi
movss 0x208d5(%rip), %xmm0    # 0x55404
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x189d0
movss 0xe4(%rbx), %xmm0
movss 0xe8(%rbx), %xmm1
addss (%r15), %xmm0
movss %xmm0, 0xc(%rsp)
addss 0x4(%r15), %xmm1
movss %xmm1, 0x8(%rsp)
movss 0xec(%rbx), %xmm0
addss 0x8(%r15), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x0, 0x27c(%rbx)
movl 0x280(%rbx), %eax
testl %eax, %eax
je 0x34bae
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
addl $0x28, %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x19, %ecx
callq 0x180c0
movq %r14, 0x40(%rsp)
movss 0x20849(%rip), %xmm0    # 0x55404
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
callq 0x189d0
movl 0x1d8(%rbx), %eax
testl %eax, %eax
movl $0x4b, %r13d
cmovnel %eax, %r13d
cmpl $0x64, %r13d
jl 0x34d37
movl %r13d, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
shrq $0x25, %rax
cmpl $0x8, %eax
movl $0x8, %ebp
cmovbl %eax, %ebp
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x7fff, %r14d          # imm = 0x7FFF
leaq 0x237f1(%rip), %r15     # 0x58428
leaq 0x1c(%rsp), %r12
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x1f635(%rip), %xmm1    # 0x54288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x21f4d(%rip), %xmm1    # 0x56bb0
addsd %xmm1, %xmm0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x38(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1f5e6(%rip), %xmm0    # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x21f02(%rip), %xmm0    # 0x56bb0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x14(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x30(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x20(%rsp)
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1f59f(%rip), %xmm0    # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x21ebb(%rip), %xmm0    # 0x56bb0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x28(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movss 0x1f201(%rip), %xmm0    # 0x53f28
movq %r12, %rdx
callq 0x186a0
decl %ebp
jne 0x34c3c
leal 0x18(%r13), %eax
cmpl $0x31, %eax
jb 0x34ea0
movslq %r13d, %rax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x23, %rax
addl %ecx, %eax
cmpl $0x10, %eax
movl $0x10, %ebp
cmovll %eax, %ebp
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movl $0x7fff, %r14d          # imm = 0x7FFF
leaq 0x2292d(%rip), %r15     # 0x576cd
leaq 0x1c(%rsp), %r12
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x1f4cc(%rip), %xmm1    # 0x54288
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x21de4(%rip), %xmm1    # 0x56bb0
addsd %xmm1, %xmm0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x38(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1f47d(%rip), %xmm0    # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x21d99(%rip), %xmm0    # 0x56bb0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x14(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x30(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x20(%rsp)
callq 0x19a20
andl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1f436(%rip), %xmm0    # 0x54288
cvtss2sd %xmm0, %xmm0
addsd 0x21d52(%rip), %xmm0    # 0x56bb0
addsd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x18(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd 0x28(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movss 0x1f5c8(%rip), %xmm0    # 0x54458
movq %r12, %rdx
callq 0x186a0
decl %ebp
jne 0x34da5
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x198f0
movq 0x3500c(%rip), %rax     # 0x69ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x34ec6
jnp 0x34f03
orb $0x1, 0xc8(%rbx)
movl $0x0, 0x108(%rbx)
movq 0x34da2(%rip), %rax     # 0x69c80
movq %rax, 0x210(%rbx)
movq 0x34eb4(%rip), %rax     # 0x69da0
movss 0x4(%rax), %xmm0
addss 0x190(%rbx), %xmm0
movss %xmm0, 0x200(%rbx)
jmp 0x34f1e
cmpl $0x0, 0x280(%rbx)
je 0x34f16
movq %rbx, %rdi
callq 0x195c0
jmp 0x34f1e
movq %rbx, %rdi
callq 0x19a60
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq