// File: essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: do_explosion(explosion)
void do_explosion(explosion ex)
{
	make_noise(ex.x,ex.y,&(ex.radius <3?LE_noise:HE_noise));
	add_message("BOOM!");
	int dam = 0;
	for(int i = -ex.radius; i<= ex.radius; i++)
	{
		for(int j = -ex.radius; j<= ex.radius; j++)
		{
			if(!on_map(ex.x+i,ex.y+j)) continue;
			int d = d22(0,0,i,j);
			dam = (d <= squarei(ex.radius)+1) ? (int)ceil((float)ex.centre_damage/(d+1)) : 0;
			if(dam)
			{
				if(map_items[ex.x+i][ex.y+j] != NULL)
				{
					if(map_items[ex.x+i][ex.y+j]->name == "radio transmitter")
					{
						transmitter_destroyed = true;
						map_items[ex.x+i][ex.y+j] = NULL;
						target_x = -500; target_y = -500;
						add_message("Perhaps the ship will stop pretending to be docked now!");
						destroyed_transmitter = true;

					}
				}
				if(map_occupants[ex.x+i][ex.y+j] != NULL)
				{
					if(map_occupants[ex.x+i][ex.y+j]->is_player)
					{
						add_message("You are hit by the explosion!");
					}
					hurt_actor(map_occupants[ex.x+i][ex.y+j],dam);
				}
			}
			switch(map_terrain[ex.x+i][ex.y+j])
			{
				case WALL:
					if(dam >= 7)
						map_terrain[ex.x+i][ex.y+j] = FLOOR; break;
				case BTREE:
					if(dam >= 11)
						map_terrain[ex.x+i][ex.y+j] = DIRT; break;
				case STREE:
					if(dam >= 3)
						map_terrain[ex.x+i][ex.y+j] = DIRT; break;
				case TWINDOW:
					if(dam >= 5)
						map_terrain[ex.x+i][ex.y+j] = FLOOR; break;
			}
		}
	}
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xd8(%rsp)
movq %rsi, 0xe0(%rsp)
movl 0xd8(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0xdc(%rsp), %eax
movl %eax, 0x40(%rsp)
cmpl $0x3, 0xe0(%rsp)
jge 0x18785
leaq 0x6fb62(%rip), %rax     # 0x882e0
movq %rax, 0x30(%rsp)
jmp 0x18793
leaq 0x6fb84(%rip), %rax     # 0x88310
movq %rax, 0x30(%rsp)
jmp 0x18793
movl 0x40(%rsp), %esi
movl 0x3c(%rsp), %edi
movq 0x30(%rsp), %rdx
callq 0xf520
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x5490
movq 0x28(%rsp), %rdx
leaq 0x15d6b(%rip), %rsi     # 0x2e52e
leaq 0xb8(%rsp), %rdi
callq 0x53d0
jmp 0x187d2
leaq 0xb8(%rsp), %rdi
callq 0x6670
jmp 0x187e1
leaq 0xb8(%rsp), %rdi
callq 0x54f8
leaq 0xb7(%rsp), %rdi
callq 0x5310
movl $0x0, 0xa0(%rsp)
xorl %eax, %eax
subl 0xe0(%rsp), %eax
movl %eax, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0xe0(%rsp), %eax
jg 0x18dc8
xorl %eax, %eax
subl 0xe0(%rsp), %eax
movl %eax, 0x98(%rsp)
movl 0x98(%rsp), %eax
cmpl 0xe0(%rsp), %eax
jg 0x18db0
movl 0xd8(%rsp), %edi
addl 0x9c(%rsp), %edi
movl 0xdc(%rsp), %esi
addl 0x98(%rsp), %esi
callq 0x20770
testb $0x1, %al
jne 0x188c1
jmp 0x18d9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0x188af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x54f8
leaq 0xb7(%rsp), %rdi
callq 0x5310
jmp 0x18dd0
movl 0x9c(%rsp), %edx
movl 0x98(%rsp), %ecx
xorl %esi, %esi
movl %esi, %edi
callq 0x6610
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0xe0(%rsp), %edi
callq 0x21730
movl %eax, %ecx
movl 0x24(%rsp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jg 0x1892d
cvtsi2ssl 0xe4(%rsp), %xmm0
movl 0x94(%rsp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
callq 0x200a0
cvttss2si %xmm0, %eax
movl %eax, 0x20(%rsp)
jmp 0x18935
xorl %eax, %eax
movl %eax, 0x20(%rsp)
jmp 0x18935
movl 0x20(%rsp), %eax
movl %eax, 0xa0(%rsp)
cmpl $0x0, 0xa0(%rsp)
je 0x18c1a
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x9bbca(%rip), %rax     # 0xb4530
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x18aca
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x9bb8c(%rip), %rax     # 0xb4530
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
addq $0x10, %rdi
leaq 0x15782(%rip), %rsi     # 0x2e150
callq 0x21740
testb $0x1, %al
jne 0x189dc
jmp 0x18ac8
movb $0x1, 0x2299d(%rip)     # 0x3b380
movl 0x9c(%rsp), %edx
movl 0xd8(%rsp), %eax
movl 0xdc(%rsp), %ecx
addl %edx, %eax
cltq
imulq $0x4b0, %rax, %rdx      # imm = 0x4B0
leaq 0x9bb26(%rip), %rax     # 0xb4530
addq %rdx, %rax
movl 0x98(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movq $0x0, (%rax,%rcx,8)
movl $0xfffffe0c, 0x6f839(%rip) # imm = 0xFFFFFE0C
movl $0xfffffe0c, 0x6f833(%rip) # imm = 0xFFFFFE0C
leaq 0x6f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5490
movq 0x18(%rsp), %rdx
leaq 0x15ae4(%rip), %rsi     # 0x2e534
leaq 0x70(%rsp), %rdi
callq 0x53d0
jmp 0x18a5c
leaq 0x70(%rsp), %rdi
callq 0x6670
jmp 0x18a68
leaq 0x70(%rsp), %rdi
callq 0x54f8
leaq 0x6f(%rsp), %rdi
callq 0x5310
movb $0x1, 0x22911(%rip)     # 0x3b394
jmp 0x18ac8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0x18ab9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x54f8
leaq 0x6f(%rsp), %rdi
callq 0x5310
jmp 0x18dd0
jmp 0x18aca
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x6fa7e(%rip), %rax     # 0x88560
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x18c18
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x6fa40(%rip), %rax     # 0x88560
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
testb $0x1, 0x8(%rax)
je 0x18bd5
leaq 0x47(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x5490
movq 0x10(%rsp), %rdx
leaq 0x15a08(%rip), %rsi     # 0x2e56c
leaq 0x48(%rsp), %rdi
callq 0x53d0
jmp 0x18b70
leaq 0x48(%rsp), %rdi
callq 0x6670
jmp 0x18b7c
leaq 0x48(%rsp), %rdi
callq 0x54f8
leaq 0x47(%rsp), %rdi
callq 0x5310
jmp 0x18bd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
jmp 0x18bc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x54f8
leaq 0x47(%rsp), %rdi
callq 0x5310
jmp 0x18dd0
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x6f973(%rip), %rax     # 0x88560
imulq $0x4b0, %rcx, %rcx      # imm = 0x4B0
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
movl 0xa0(%rsp), %esi
callq 0x186e0
jmp 0x18c1a
movl 0x9c(%rsp), %edx
movl 0xd8(%rsp), %eax
movl 0xdc(%rsp), %ecx
addl %edx, %eax
cltq
imulq $0x258, %rax, %rdx      # imm = 0x258
leaq 0x2276f(%rip), %rax     # 0x3b3b0
addq %rdx, %rax
movl 0x98(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0xb, %eax
ja 0x18d98
movq 0x8(%rsp), %rax
leaq 0x144a7(%rip), %rcx     # 0x2d118
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x7, 0xa0(%rsp)
jl 0x18cbe
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x22714(%rip), %rax     # 0x3b3b0
imulq $0x258, %rcx, %rcx      # imm = 0x258
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movl $0x3, (%rax,%rcx,4)
jmp 0x18d98
cmpl $0xb, 0xa0(%rsp)
jl 0x18d07
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x226cb(%rip), %rax     # 0x3b3b0
imulq $0x258, %rcx, %rcx      # imm = 0x258
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x18d98
cmpl $0x3, 0xa0(%rsp)
jl 0x18d50
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x22682(%rip), %rax     # 0x3b3b0
imulq $0x258, %rcx, %rcx      # imm = 0x258
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x18d98
cmpl $0x5, 0xa0(%rsp)
jl 0x18d96
movl 0xd8(%rsp), %eax
addl 0x9c(%rsp), %eax
movslq %eax, %rcx
leaq 0x2263c(%rip), %rax     # 0x3b3b0
imulq $0x258, %rcx, %rcx      # imm = 0x258
addq %rcx, %rax
movl 0xdc(%rsp), %ecx
addl 0x98(%rsp), %ecx
movslq %ecx, %rcx
movl $0x3, (%rax,%rcx,4)
jmp 0x18d98
jmp 0x18d9a
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x1883a
jmp 0x18db2
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x18816
addq $0xe8, %rsp
retq
movq 0xa8(%rsp), %rdi
callq 0x5480
nopl (%rax)