// File: /workspace/github_c_makefile_star2_O3/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:
movzbl 0xe3cc(%rip), %eax      # 0x131c0
testq %rax, %rax
je 0x5044
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
movl %edi, %r14d
movslq %edi, %r15
leaq 0xeb79(%rip), %r13      # 0x13990
movq (%r13,%r15,8), %rcx
xorl %ebx, %ebx
cmpw $0x63, 0xd2(%rcx,%rbx,2)
jg 0x4e36
incq %rbx
cmpq %rbx, %rax
jne 0x4e1e
jmp 0x5036
movl %r15d, %edi
movl %ebx, %esi
callq 0x4a74
movq (%r13,%r15,8), %rax
cmpw $0x64, 0xd2(%rax,%rbx,2)
jl 0x5036
leaq 0xead5(%rip), %rax      # 0x13930
movq (%rax,%r15,8), %rdx
leaq 0xe64a(%rip), %r12      # 0x134b0
leaq 0x91e2(%rip), %rsi      # 0xe04f
movq %r12, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xeb7a(%rip), %rdi      # 0x139f8
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3d76
movq (%r13,%r15,8), %rax
addw $-0x64, 0xd2(%rax,%rbx,2)
cmpb $0x0, 0xe73d(%rip)      # 0x135e2
je 0x5022
movl %ebp, (%rsp)
leaq 0xe73b(%rip), %r12      # 0x135f0
xorl %r13d, %r13d
movq (%r12), %rax
testq %rax, %rax
je 0x4ff5
cmpq %r13, %r14
je 0x4ff5
movzwl 0x4a(%rax), %ebp
testw %bp, %bp
js 0x4ff5
movl %r14d, %edi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x4(%rsp), %rcx
callq 0x4c05
testl %eax, %eax
jle 0x4ff5
cmpw $0xb, %bp
jb 0x4f2e
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x82e6(%rip), %xmm0     # 0xd1f0
movq (%r12), %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 %bp, %ecx
imull $0xcccd, %ecx, %ecx     # imm = 0xCCCD
shrl $0x13, %ecx
cmpw $0x3, %cx
ja 0x4fd2
leaq 0x839d(%rip), %rdx      # 0xd2e8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl (%rsp), %edi
movl %r13d, %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x4604
jmp 0x4fd2
leaq 0xe544(%rip), %rdi      # 0x134b0
leaq 0x9109(%rip), %rsi      # 0xe07c
jmp 0x4f83
leaq 0xe534(%rip), %rdi      # 0x134b0
leaq 0x9109(%rip), %rsi      # 0xe08c
movl %r13d, %edx
xorl %eax, %eax
callq 0x21a0
jmp 0x4fd2
movq (%r12), %rax
movswl 0x4a(%rax), %eax
imull $0x6667, %eax, %ecx     # imm = 0x6667
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x12, %ecx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movswq %ax, %rax
leaq 0xe977(%rip), %rcx      # 0x13930
movq (%rcx,%rax,8), %rdx
leaq 0xe4ec(%rip), %rdi      # 0x134b0
leaq 0x909b(%rip), %rsi      # 0xe066
xorl %eax, %eax
callq 0x21a0
cmpw $0xa, %bp
jb 0x4ff5
movq 0xea19(%rip), %rdi      # 0x139f8
leaq 0xe4ca(%rip), %rsi      # 0x134b0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3d76
incq %r13
movzbl 0xe5e3(%rip), %eax      # 0x135e2
addq $0x8, %r12
cmpq %rax, %r13
jb 0x4eb8
leaq 0xe97d(%rip), %rax      # 0x13990
movq (%rax,%r15,8), %rax
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
jmp 0x5026
xorpd %xmm0, %xmm0
movsd 0x20(%rax,%rbx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rax,%rbx,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq