// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
addq $0xfc, %rdi
leaq -0x4c(%rbp), %rsi
movss 0x3187b(%rip), %xmm0    # 0x72b50
callq 0x18a80
movq -0x8(%rbp), %rax
movss 0xe4(%rax), %xmm0
addss -0x4c(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movss 0xe8(%rax), %xmm0
addss -0x48(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movss 0xec(%rax), %xmm0
addss -0x44(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x27c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x280(%rax)
je 0x4136a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x8(%rbp), %rax
cvtsi2ssl 0x280(%rax), %xmm0
movq -0x8(%rbp), %rax
movl 0x280(%rax), %eax
addl $0x28, %eax
cvtsi2ss %eax, %xmm1
xorl %eax, %eax
movl %eax, %edx
movl $0x19, %ecx
callq 0x180c0
leaq -0x4c(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
movss 0x317d6(%rip), %xmm0    # 0x72b50
callq 0x18a80
movq -0x8(%rbp), %rax
movl 0x1d8(%rax), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x41399
movl $0x4b, -0x54(%rbp)
cmpl $0x64, -0x54(%rbp)
jl 0x41520
movl -0x54(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, -0x50(%rbp)
cmpl $0x8, -0x50(%rbp)
jle 0x413be
movl $0x8, -0x50(%rbp)
jmp 0x413c0
movl -0x50(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x50(%rbp)
cmpl $0x0, %eax
je 0x4151e
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
callq 0x19c80
movsd -0x70(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2ee8b(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x3001b(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x3177f(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x4c(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
callq 0x19c80
movsd -0x68(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2ee28(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x2ffb8(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x3171c(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x48(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
callq 0x19c80
movsd -0x60(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2edc5(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x2ff55(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x316b9(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x44(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rdx
leaq 0x32e18(%rip), %rsi     # 0x74324
movss 0x2e9d8(%rip), %xmm0    # 0x6feec
callq 0x18700
jmp 0x413c0
jmp 0x41520
movl -0x54(%rbp), %eax
movl $0x19, %ecx
cltd
idivl %ecx
movl %eax, -0x50(%rbp)
cmpl $0x10, -0x50(%rbp)
jle 0x4153b
movl $0x10, -0x50(%rbp)
jmp 0x4153d
movl -0x50(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x50(%rbp)
cmpl $0x0, %eax
je 0x416a1
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
callq 0x19c80
movsd -0x88(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2ed08(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x2fe98(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x315fc(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x4c(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
callq 0x19c80
movsd -0x80(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2eca5(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x2fe35(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x31599(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x48(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
callq 0x19c80
movsd -0x78(%rbp), %xmm1
andl $0x7fff, %eax           # imm = 0x7FFF
cvtsi2ss %eax, %xmm0
movss 0x2ec42(%rip), %xmm2    # 0x70288
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x2fdd2(%rip), %xmm0    # 0x71428
subsd %xmm0, %xmm2
movsd 0x31536(%rip), %xmm0    # 0x72b98
mulsd %xmm2, %xmm0
movss -0x44(%rbp), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x40(%rbp), %rdx
leaq 0x31fc6(%rip), %rsi     # 0x73655
movss 0x2e851(%rip), %xmm0    # 0x6fee8
callq 0x18700
jmp 0x4153d
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x19b50
movq 0x4180b(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x416ea
jp 0x416ea
movq -0x8(%rbp), %rax
cmpl $0x0, 0x280(%rax)
je 0x416df
movq -0x8(%rbp), %rdi
callq 0x19800
jmp 0x416e8
movq -0x8(%rbp), %rdi
callq 0x19cd0
jmp 0x41741
movq -0x8(%rbp), %rax
movl 0xc8(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0xc8(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x108(%rax)
movq -0x8(%rbp), %rax
movq 0x4156a(%rip), %rcx     # 0x82c80
movq %rcx, 0x210(%rax)
movq 0x4167c(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
addss 0x190(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x200(%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)