// File: /workspace/github_c_makefile_star2_O2/hyc[P]trek73c/trekx.c
// Function: Detonate
void Detonate(I)
int I;
{
  int Hits, I0, I1, J, K, M;

  I0 = Objects[I]->ObTyp;
  M = I0 % 10;
  I0 /= 10;
  I1 = I0;
  if (I0 == 0) {
    sprintf(scrstr,"++%s++ Destruction", Snams[I]);
    for (K = 0; K < Phasers; K++)
      Objects[I]->Fuel += Ships[I]->PChrg[K];
    for (K = 0; K < Tubes; K++)
      Objects[I]->Fuel += Ships[I]->Tengy[K];
    Vessels--;
  } else if (I0 == 1)
    sprintf(scrstr,"##%s's Engineering##", Snams[M]);
  else if (I0 == 2)
    sprintf(scrstr,"** %d **", I);
  else
    sprintf(scrstr,":: %d ::", I);
  SEndln();
  for (J = 0; J < ObjCount; J++) {
    if (Objects[J] != NULL) {
      if (Objects[J]->Trgt == I+1)
	Objects[J]->Trgt = 0;
    }
    if (J != I && Objects[J] != NULL) {
      Hits = AMHits(I, J);
      I0 = Objects[J]->ObTyp;
      M = I0 % 10;
      I0 /= 10;
      if (Hits > 0) {
	if (I0 == 0)
	  Damage(I, J, Hits, 1);
	else if (I0 == 1)
	  sprintf(scrstr,"Hit on %s's jettisoned Engineering", Snams[M]);
	else if (I0 == 2)
	  sprintf(scrstr,"Hit on probe %d", J);
	if (I0 > 0) {
	  Objects[J]->Tim_Del = 9999.0;
	  if (I0 < 3)
	    SEndln();
	}
      }
    }
  }
  free(Objects[I]);
  Objects[I] = NULL;
  if (I1 != 0)
    return;
  free(Ships[I]);
  Ships[I] = NULL;
  Redo = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movslq %edi, %r15
leaq 0xd93b(%rip), %rbp      # 0x125e0
movq (%rbp,%r15,8), %rax
movswl 0x4a(%rax), %ecx
movw $0xa, %si
movl %ecx, %eax
cwtd
idivw %si
leal 0x9(%rcx), %eax
movl %r15d, %r14d
movl %eax, 0x14(%rsp)
cmpl $0x12, %eax
ja 0x4d21
leaq 0xdc51(%rip), %rax      # 0x12920
movq (%rax,%r15,8), %rdx
leaq 0xd7c6(%rip), %rdi      # 0x124a0
leaq 0x7374(%rip), %rsi      # 0xc055
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2190
movzbl 0xd4bf(%rip), %edx      # 0x121b0
leaq 0xdc88(%rip), %rax      # 0x12980
leaq 0xd8e1(%rip), %rcx      # 0x125e0
cmpq %rbx, %rdx
je 0x4d51
movq (%rax,%r15,8), %rsi
movsd 0x20(%rsi,%rbx,8), %xmm0
movq (%rcx,%r15,8), %rsi
addsd 0x20(%rsi), %xmm0
movsd %xmm0, 0x20(%rsi)
incq %rbx
jmp 0x4cff
leal -0xa(%rcx), %eax
cmpl $0x9, %eax
ja 0x4d8a
movswq %dx, %rax
movl %eax, %eax
leaq 0xdbea(%rip), %rcx      # 0x12920
movq (%rcx,%rax,8), %rdx
leaq 0xd75f(%rip), %rdi      # 0x124a0
leaq 0x7320(%rip), %rsi      # 0xc068
xorl %eax, %eax
callq 0x2190
jmp 0x4db5
movzbl 0xd459(%rip), %edx      # 0x121b1
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x4d82
movq (%rax,%r15,8), %rdi
movswl 0xc6(%rdi,%rsi,2), %edi
cvtsi2sd %edi, %xmm0
movq (%rcx,%r15,8), %rdi
addsd 0x20(%rdi), %xmm0
movsd %xmm0, 0x20(%rdi)
incq %rsi
jmp 0x4d5a
decb 0xd849(%rip)            # 0x125d1
jmp 0x4db5
addl $-0x14, %ecx
leaq 0xd70c(%rip), %rdi      # 0x124a0
cmpl $0x9, %ecx
ja 0x4da2
leaq 0x72dd(%rip), %rsi      # 0xc07d
jmp 0x4da9
leaq 0x72dd(%rip), %rsi      # 0xc086
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x2190
callq 0x399b
movq 0x8(%rsp), %rax
leal 0x1(%rax), %ebx
xorl %r13d, %r13d
movzbl 0xd806(%rip), %eax      # 0x125d2
cmpq %rax, %r13
jae 0x4ec5
movq (%rbp), %rax
testq %rax, %rax
je 0x4eb9
movswl 0x48(%rax), %ecx
cmpl %ecx, %ebx
jne 0x4def
andw $0x0, 0x48(%rax)
cmpq %r13, %r14
je 0x4eb9
movl %r14d, %edi
movl %r13d, %esi
callq 0x4c14
movl %eax, %ecx
movq (%rbp), %rax
movswl 0x4a(%rax), %r12d
movl %r12d, %eax
cwtd
movw $0xa, %si
idivw %si
testl %ecx, %ecx
jle 0x4eb9
leal 0x9(%r12), %eax
cmpl $0x12, %eax
ja 0x4e40
movq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ecx, %edx
pushq $0x1
popq %rcx
callq 0x40d0
jmp 0x4e94
leal -0xa(%r12), %eax
cmpl $0x9, %eax
ja 0x4e72
movswq %dx, %rax
movl %eax, %eax
leaq 0xdac9(%rip), %rcx      # 0x12920
movq (%rcx,%rax,8), %rdx
leaq 0xd63e(%rip), %rdi      # 0x124a0
leaq 0x7226(%rip), %rsi      # 0xc08f
xorl %eax, %eax
callq 0x2190
jmp 0x4e94
leal -0x14(%r12), %eax
cmpl $0x9, %eax
ja 0x4e94
leaq 0xd61d(%rip), %rdi      # 0x124a0
leaq 0x717a(%rip), %rsi      # 0xc004
movl %r13d, %edx
xorl %eax, %eax
callq 0x2190
cmpw $0xa, %r12w
jl 0x4eb9
movq (%rbp), %rax
movabsq $0x40c3878000000000, %rcx # imm = 0x40C3878000000000
movq %rcx, 0x30(%rax)
cmpw $0x1d, %r12w
ja 0x4eb9
callq 0x399b
incq %r13
addq $0x8, %rbp
jmp 0x4dc5
leaq 0xd714(%rip), %rbx      # 0x125e0
movq (%rbx,%r15,8), %rdi
callq 0x2120
andq $0x0, (%rbx,%r15,8)
cmpl $0x12, 0x14(%rsp)
ja 0x4efd
leaq 0xda98(%rip), %rbx      # 0x12980
movq (%rbx,%r15,8), %rdi
callq 0x2120
andq $0x0, (%rbx,%r15,8)
movb $0x1, 0xdb1f(%rip)      # 0x12a1c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq