// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rdi, %rsi
shrq $0x20, %rsi
cmpl $0x3, %r14d
leaq 0x5dcfd(%rip), %rax     # 0x6b270
leaq 0x5dd26(%rip), %rdx     # 0x6b2a0
cmovlq %rax, %rdx
callq 0x92a3
leaq 0x7d09(%rip), %rsi      # 0x15293
leaq 0x58(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5110
leaq 0x58(%rsp), %rdi
callq 0x5c6e
movq %r14, %r15
shrq $0x20, %r15
leaq 0x58(%rsp), %rdi
callq 0x5418
movl %r14d, %eax
cvtsi2ss %r15d, %xmm0
movss %xmm0, 0x30(%rsp)
imull %r14d, %eax
incl %eax
movl %eax, 0x34(%rsp)
movslq %r14d, %rdi
negl %r14d
movslq %r14d, %rdx
movq %rbx, %rsi
sarq $0x20, %rsi
movslq %ebx, %r8
imulq $0x25c, %rdx, %rax      # imm = 0x25C
imulq $0x258, %r8, %rcx       # imm = 0x258
addq %rax, %rcx
leaq (%rcx,%rsi,4), %rax
leaq 0x10d45(%rip), %rcx     # 0x1e340
addq %rax, %rcx
movq %rcx, 0x28(%rsp)
imulq $0x4b8, %rdx, %rax      # imm = 0x4B8
movq %r8, 0x38(%rsp)
imulq $0x4b0, %r8, %rcx       # imm = 0x4B0
addq %rax, %rcx
leaq (%rcx,%rsi,8), %rax
leaq 0x89e9c(%rip), %rcx     # 0x974c0
addq %rax, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x5debd(%rip), %rcx     # 0x6b4f0
addq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq %rdx, 0x40(%rsp)
movq %rdi, 0x20(%rsp)
cmpq %rdi, %rdx
jg 0xd82c
movq 0x38(%rsp), %rax
leaq (%rdx,%rax), %rbp
movq %rdx, 0x48(%rsp)
imulq %rdx, %rdx
movq %rdx, 0x50(%rsp)
xorl %r13d, %r13d
movq 0x40(%rsp), %r14
cmpq %rdi, %r14
jg 0xd807
leaq (%rsi,%r14), %rax
movl %ebp, %ecx
orl %eax, %ecx
js 0xd7fb
cmpq $0x95, %rbp
jg 0xd7fb
cmpq $0x95, %rax
jg 0xd7fb
movq %r14, %rax
imulq %r14, %rax
addq 0x50(%rsp), %rax
xorl %ebx, %ebx
cmpl %eax, 0x34(%rsp)
jb 0xd7b3
incl %eax
cvtsi2ss %eax, %xmm1
movss 0x30(%rsp), %xmm0
divss %xmm1, %xmm0
movq %rsi, %r15
callq 0x5190
movq 0x20(%rsp), %rdi
movq %r15, %rsi
cvttss2si %xmm0, %r12d
testl %r12d, %r12d
je 0xd7b3
movq 0x18(%rsp), %rax
movq (%rax,%r13,4), %rdi
testq %rdi, %rdi
je 0xd75a
addq $0x10, %rdi
leaq 0x77b9(%rip), %rsi      # 0x14eb5
callq 0x1143f
testb %al, %al
je 0xd75a
movq 0x18(%rsp), %rax
andq $0x0, (%rax,%r13,4)
movb $0x1, 0x10bfa(%rip)     # 0x1e310
movl $0xfffffe0c, %eax       # imm = 0xFFFFFE0C
movl %eax, 0x5dad3(%rip)     # 0x6b1f4
movl %eax, 0x5dad1(%rip)     # 0x6b1f8
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7b60(%rip), %rsi      # 0x15299
leaq 0xf(%rsp), %rdx
callq 0x5110
movq %rbx, %rdi
callq 0x5c6e
movq %rbx, %rdi
callq 0x5418
movb $0x1, 0x10bca(%rip)     # 0x1e324
movq 0x10(%rsp), %rax
movq (%rax,%r13,4), %rdi
testq %rdi, %rdi
je 0xd7a8
cmpb $0x1, 0x8(%rdi)
jne 0xd7a0
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7b54(%rip), %rsi      # 0x152d1
leaq 0xf(%rsp), %rdx
callq 0x5110
movq %rbx, %rdi
callq 0x5c6e
movq %rbx, %rdi
callq 0x5418
movq 0x10(%rsp), %rax
movq (%rax,%r13,4), %rdi
movl %r12d, %esi
callq 0xd52d
movl %r12d, %ebx
movq %r15, %rsi
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
movl (%rax,%r13,2), %eax
cmpl $0x1, %eax
je 0xd7eb
cmpl $0x2, %eax
je 0xd7da
cmpl $0xc, %eax
je 0xd7e1
cmpl $0x4, %eax
jne 0xd7fb
pushq $0x3
popq %rax
cmpl $0x6, %ebx
jg 0xd7f2
jmp 0xd7fb
cmpl $0xa, %ebx
jg 0xd7f0
jmp 0xd7fb
pushq $0x3
popq %rax
cmpl $0x5, %ebx
jge 0xd7f2
jmp 0xd7fb
cmpl $0x2, %ebx
jle 0xd7fb
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movl %eax, (%rcx,%r13,2)
incq %r14
addq $0x2, %r13
jmp 0xd66d
movq 0x48(%rsp), %rdx
incq %rdx
addq $0x258, 0x28(%rsp)      # imm = 0x258
movl $0x4b0, %eax            # imm = 0x4B0
addq %rax, 0x18(%rsp)
addq %rax, 0x10(%rsp)
jmp 0xd645
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0xd866
jmp 0xd859
jmp 0xd859
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0xd866
movq %rax, %rbx
jmp 0xd86b
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5418
movq %rbx, %rdi
callq 0x53c0