// File: /workspace/github_c_makefile_star2_O2/hyc[P]trek73c/trekx.c
// Function: PhaserFire
void PhaserFire(I)
int I;
{
  int J, K, L, Hits, Units;

  K = (-1);
  for (J = 0; J < Phasers; J++) {
    if (Ships[I]->Pstat[J] > 99) {
      K = J;
      break;
    }
  }
  if (K < 0)
    return;
  TrakPhas(I, K);
  if (Ships[I]->Pstat[K] <= 99)
    return;
  sprintf(scrstr," <<%s Firing Phasers>>", Snams[I]);
  SEndln();
  Ships[I]->Pstat[K] -= 100;
  for (J = 0; J < ObjCount; J++) {
    if (Objects[J] != NULL) {
      L = Objects[J]->ObTyp;
      if (I != J && L >= 0) {
	Hits = PhHits(I, J, K, &Units);
	if (Hits > 0) {
	  if (L > 10) {
	    Objects[J]->Fuel -= Hits / 2.0;
	    if (Objects[J]->Fuel < 0)
	      Objects[J]->Fuel = 0.0;
	    Objects[J]->Tim_Del = 10000.0;
	  }
	  L/=10;
	  switch (L) {

	  case 0:
	    Damage(I, J, Hits, 0);
	    break;

	  case 1:
	    sprintf(scrstr,"%s's Engineering hit.",
		   Snams[(Objects[J]->ObTyp) % 10]);
	    break;

	  case 2:
	    sprintf(scrstr,"Hit on probe %d", J);
	    break;

	  case 3:
	    sprintf(scrstr,"Hit on torpedo %d", J);
	    break;
	  }
	  if (L > 0)
	    SEndln();
	}
      }
    }
  }
  Ships[I]->PChrg[K] -= Units;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebp
movzbl 0xdae8(%rip), %eax      # 0x121b0
movslq %edi, %r14
movl %r14d, %ecx
movq %rcx, 0x10(%rsp)
xorl %r15d, %r15d
leaq 0xe2a3(%rip), %rbx      # 0x12980
cmpq %r15, %rax
je 0x48b1
movq (%rbx,%r14,8), %rcx
cmpw $0x63, 0xd2(%rcx,%r15,2)
jg 0x46fb
incq %r15
jmp 0x46dd
movl %r14d, %edi
movl %r15d, %esi
callq 0x4474
movq (%rbx,%r14,8), %rax
cmpw $0x64, 0xd2(%rax,%r15,2)
jl 0x48b1
movl %ebp, 0x8(%rsp)
leaq 0xe1fb(%rip), %rax      # 0x12920
movq (%rax,%r14,8), %rdx
leaq 0xdd70(%rip), %rdi      # 0x124a0
leaq 0x78a0(%rip), %rsi      # 0xbfd7
xorl %eax, %eax
callq 0x2190
callq 0x399b
movq (%rbx,%r14,8), %rax
addw $-0x64, 0xd2(%rax,%r15,2)
leaq 0xde88(%rip), %r12      # 0x125e0
xorl %r13d, %r13d
movzbl 0xde70(%rip), %eax      # 0x125d2
cmpq %rax, %r13
jae 0x4895
movq (%r12), %rax
testq %rax, %rax
je 0x4889
cmpq %r13, 0x10(%rsp)
je 0x4889
movzwl 0x4a(%rax), %ebp
testw %bp, %bp
js 0x4889
movq 0x10(%rsp), %rdi
movl %r13d, %esi
movl %r15d, %edx
leaq 0xc(%rsp), %rcx
callq 0x456a
testl %eax, %eax
jle 0x4889
movl %eax, %ecx
cmpw $0xb, %bp
jb 0x47e5
cvtsi2sd %ecx, %xmm0
mulsd 0x68f7(%rip), %xmm0     # 0xb0b8
movq (%r12), %rax
addsd 0x20(%rax), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rax)
movabsq $0x40c3880000000000, %rdx # imm = 0x40C3880000000000
movq %rdx, 0x30(%rax)
movl %ebp, %eax
xorl %edx, %edx
movw $0xa, %si
divw %si
cmpw $0x3, %ax
ja 0x487e
movzwl %ax, %eax
leaq 0x6a6c(%rip), %rdx      # 0xb270
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl 0x8(%rsp), %edi
movl %r13d, %esi
movl %ecx, %edx
xorl %ecx, %ecx
callq 0x40d0
jmp 0x487e
leaq 0xdc7a(%rip), %rdi      # 0x124a0
leaq 0x77d7(%rip), %rsi      # 0xc004
jmp 0x483d
leaq 0xdc6a(%rip), %rdi      # 0x124a0
leaq 0x77d7(%rip), %rsi      # 0xc014
movl %r13d, %edx
xorl %eax, %eax
callq 0x2190
jmp 0x487e
movq (%r12), %rax
movzwl 0x4a(%rax), %eax
cwtd
movw $0xa, %cx
idivw %cx
movswq %dx, %rax
leaq 0xe0bb(%rip), %rcx      # 0x12920
movq (%rcx,%rax,8), %rdx
leaq 0xdc30(%rip), %rdi      # 0x124a0
leaq 0x7777(%rip), %rsi      # 0xbfee
xorl %eax, %eax
callq 0x2190
cmpw $0xa, %bp
jb 0x4889
callq 0x399b
incq %r13
addq $0x8, %r12
jmp 0x475b
cvtsi2sdl 0xc(%rsp), %xmm0
movq (%rbx,%r14,8), %rax
movsd 0x20(%rax,%r15,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rax,%r15,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq