// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movzbl 0xe4ad(%rip), %eax      # 0x131c0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movslq %edi, %r12
testq %rax, %rax
je 0x4d44
leaq 0xec69(%rip), %rcx      # 0x13990
movq (%rcx,%r12,8), %rdx
xorl %ecx, %ecx
cmpw $0x63, 0xd2(%rdx,%rcx,2)
jg 0x4d42
incq %rcx
cmpq %rcx, %rax
jne 0x4d2d
jmp 0x4d44
movl %ecx, %ebp
testl %ebp, %ebp
js 0x4f62
movl %ebx, %edi
movl %ebp, %esi
callq 0x4977
leaq 0xec34(%rip), %r13      # 0x13990
movq (%r13,%r12,8), %rax
movl %ebp, %r15d
cmpw $0x64, 0xd2(%rax,%r15,2)
jl 0x4f62
movl %ebx, 0x8(%rsp)
leaq 0xebb1(%rip), %rax      # 0x13930
movq (%rax,%r12,8), %rdx
leaq 0xe726(%rip), %r14      # 0x134b0
leaq 0x9206(%rip), %rsi      # 0xdf97
movq %r14, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xec56(%rip), %rdi      # 0x139f8
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3c58
movq (%r13,%r12,8), %rax
movq %r15, 0x10(%rsp)
addw $-0x64, 0xd2(%rax,%r15,2)
cmpb $0x0, 0xe813(%rip)      # 0x135e2
je 0x4f39
movl 0x8(%rsp), %r14d
leaq 0xe80f(%rip), %r15      # 0x135f0
xorl %r13d, %r13d
movq (%r15), %rax
testq %rax, %rax
je 0x4f22
cmpq %r13, %r14
je 0x4f22
movzwl 0x4a(%rax), %ebx
testw %bx, %bx
js 0x4f22
movl %r14d, %edi
movl %r13d, %esi
movl %ebp, %edx
leaq 0xc(%rsp), %rcx
callq 0x4b04
testl %eax, %eax
jle 0x4f22
cmpw $0xb, %bx
jl 0x4e58
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x827b(%rip), %xmm0     # 0xd0b0
movq (%r15), %rcx
addsd 0x20(%rcx), %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rcx)
movabsq $0x40c3880000000000, %rdx # imm = 0x40C3880000000000
movq %rdx, 0x30(%rcx)
movzwl %bx, %ecx
imull $0xcccd, %ecx, %ecx     # imm = 0xCCCD
shrl $0x13, %ecx
cmpw $0x3, %cx
ja 0x4eff
leaq 0x83bb(%rip), %rdx      # 0xd230
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x8(%rsp), %edi
movl %r13d, %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x44f7
jmp 0x4eff
leaq 0xe619(%rip), %rdi      # 0x134b0
leaq 0x9126(%rip), %rsi      # 0xdfc4
jmp 0x4eae
leaq 0xe609(%rip), %rdi      # 0x134b0
leaq 0x9126(%rip), %rsi      # 0xdfd4
movl %r13d, %edx
xorl %eax, %eax
callq 0x21a0
jmp 0x4eff
movq (%r15), %rax
movswq 0x4a(%rax), %rax
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cltq
leaq 0xea4a(%rip), %rcx      # 0x13930
movq (%rcx,%rax,8), %rdx
leaq 0xe5bf(%rip), %rdi      # 0x134b0
leaq 0x90b6(%rip), %rsi      # 0xdfae
xorl %eax, %eax
callq 0x21a0
cmpw $0xa, %bx
jb 0x4f22
movq 0xeaec(%rip), %rdi      # 0x139f8
leaq 0xe59d(%rip), %rsi      # 0x134b0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3c58
incq %r13
movzbl 0xe6b6(%rip), %eax      # 0x135e2
addq $0x8, %r15
cmpq %rax, %r13
jb 0x4de4
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
leaq 0xea47(%rip), %rax      # 0x13990
movq (%rax,%r12,8), %rax
movq 0x10(%rsp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rax,%rcx,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq