// File: /workspace/github_c_makefile_star2_O3/hyc[P]trek73c/trekx.c
// Function: Execute
void Execute()
{
  int I, I0, J, N1, N2;
  boolean Ok;
  double Rn;
  int FORLIM;
  Srec *WITH;

  FORLIM = (long)(SimTim / Iter);
  for (I = 0; I < FORLIM; I++) {
    for (J = 0; J < ObjCount; J++) {
      if (Objects[J] != NULL) {
	I0 = Objects[J]->ObTyp;
	if (I0 < 10) {
	  if (Ships[J]->Crew > 0) {
	    if (I < Phasers)
	      PhaserFire(J);
	    if (I < Tubes)
	      Torpfire(J);
	  }
	}
	Antimatter(J);
	if (Objects[J] != NULL)
	  Movem(J);
      }
    }
  }
  for (I = 0; I <= Enemies; I++) {
    if (Ships[I] != NULL) {
      Distrib(I, 2.0);
      for (J = 0; J < Phasers; J++) {
	if (Ships[I]->Pstat[J] >= 0)
	  TrakPhas(I, J);
      }
      for (J = 0; J < Tubes; J++) {
	if (Ships[I]->Tstat[J] >= 0)
	  TrakTorp(I, J);
      }
    }
  }
  TCount = (-1);
  if (Ships[0] != NULL) {
    I0 = (long)floor((10000 - Objects[0]->Tim_Del) * Iter + 0.5);
    if (I0 != 0 && I0 <= 15) {
      sprintf(scrstr,"Computer: %d seconds to self-destruct.\n", I0);
      SEndln();
    }
  }
  /*
   * Fuses, bluffs, surrenders
   */
  for (I = 0; I <= 3; I++) {
    if (Ct[I] != 0)
      Ct[I]++;
  }
  N1 = 0;
  N2 = 0;
  Win = 0;
  /*
   * Federation disposition
   */
  if ((Ships[0] == NULL) || (Ships[0]->Crew == 0))
    Win = 1;
  else {
    WITH = Ships[0];
    Ok = false;
    if ((WITH->Regen > 1) ||
       ((!WITH->Dmge[(int)Warp] || !WITH->Dmge[(int)Prob]) &&
	Objects[0]->Fuel > 10)) {
      Ok = true;
    } else {
      for (I = 0; I < Phasers; I++) {
        if (WITH->PChrg[I] > 0) {
	  Ok = true; break;
        }
      }
      for (I = 0; (I < Tubes) && !Ok; I++) {
        if (WITH->Tengy[I] > 0) {
	  Ok = true; break;
        }
      }
    }
    if (!Ok)
      Win = 1;
  }
  /*
   * Enemy disposition
   */
  for (I = 1; I <= Enemies; I++) {
    if ((Ships[I] == NULL) || (Ships[I]->Crew == 0)) {
      N1++;
      continue;
    }
    Rn = Range(I, 0);
    if (((Rn > 3500) && Ships[I]->Dmge[(long)Warp]) ||
	((Rn > 20000) && (Objects[0]->Tim_Del > 100))) {
      N2++;
      continue;
    }
    if (Objects[I]->Fuel > 10)
      continue;
    Ok = false;
    for (J = 0; J < Phasers; J++) {
      if (Ships[I]->PChrg[J] > 0) {
	    Ok = true;
	    break;
      }
    }
    if (Ok)
      continue;
    for (J = 0; J < Tubes; J++) {
      if (Ships[I]->Tengy[J] > 0) {
	    Ok = true;
	    break;
      }
    }
    if (!Ok)
      N1++;
  }

  /* Don't quit on all disabled... */
  if (cheat)
    N2 = 0;

  switch (Win) {

  case 0:
    if (N1 == Enemies)
      Win = 2;
    else if (N1 + N2 == Enemies)
      Win = 3;
    break;

  case 1:
    if (N1 == Enemies)
      Win = 6;		/* Nobody won */
/*    else if (N1 + N2 < Enemies)
      Win = 5;		/* No special case needed */
    break;
  }
  if (Win > 0)
    Ender();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movsd 0xcc3f(%rip), %xmm0     # 0x131b8
divsd 0xcc2f(%rip), %xmm0     # 0x131b0
cvttsd2si %xmm0, %r14
leaq 0xd063(%rip), %r15      # 0x135f0
leaq 0xd3fc(%rip), %r12      # 0x13990
testl %r14d, %r14d
jle 0x6626
xorl %r13d, %r13d
movb 0xd03c(%rip), %al       # 0x135e2
testb %al, %al
je 0x661c
xorl %ebp, %ebp
xorl %ebx, %ebx
movq (%rbp,%r15), %rax
testq %rax, %rax
je 0x6607
cmpw $0x9, 0x4a(%rax)
jg 0x65f1
movq (%rbp,%r12), %rax
cmpw $0x0, 0x1a(%rax)
jle 0x65f1
movzbl 0xcbee(%rip), %eax      # 0x131c0
cmpl %eax, %r13d
jae 0x65de
movl %ebx, %edi
callq 0x4ded
movzbl 0xcbdc(%rip), %eax      # 0x131c1
cmpl %eax, %r13d
jae 0x65f1
movl %ebx, %edi
callq 0x526b
movl %ebx, %edi
callq 0x5884
cmpq $0x0, (%rbp,%r15)
je 0x6607
movl %ebx, %edi
callq 0x598b
incq %rbx
movzbl 0xcfd1(%rip), %eax      # 0x135e2
addq $0x8, %rbp
cmpq %rax, %rbx
jb 0x65ae
jmp 0x661e
xorl %eax, %eax
incl %r13d
cmpl %r14d, %r13d
jne 0x65a6
xorl %ebx, %ebx
cmpq $0x0, (%r12,%rbx,8)
je 0x66ae
movl %ebx, %edi
movsd 0x6be7(%rip), %xmm0     # 0xd220
callq 0x443f
movb 0xcb7c(%rip), %al       # 0x131c0
testb %al, %al
je 0x6676
xorl %r14d, %r14d
movq (%r12,%rbx,8), %rcx
cmpw $0x0, 0xd2(%rcx,%r14,2)
js 0x666b
movl %ebx, %edi
movl %r14d, %esi
callq 0x4a74
movb 0xcb55(%rip), %al       # 0x131c0
incq %r14
movzbl %al, %ecx
cmpq %rcx, %r14
jb 0x664b
movb 0xcb45(%rip), %al       # 0x131c1
testb %al, %al
je 0x66ae
xorl %r14d, %r14d
movq (%r12,%rbx,8), %rcx
cmpw $0x0, 0x110(%rcx,%r14,2)
js 0x66a3
movl %ebx, %edi
movl %r14d, %esi
callq 0x50eb
movb 0xcb1e(%rip), %al       # 0x131c1
incq %r14
movzbl %al, %ecx
cmpq %rcx, %r14
jb 0x6683
leaq 0x1(%rbx), %rax
movzbl 0xcf27(%rip), %ecx      # 0x135e0
cmpq %rcx, %rbx
movq %rax, %rbx
jb 0x6628
movl $0xffffffff, 0xd369(%rip) # imm = 0xFFFFFFFF
cmpq $0x0, 0xd2b9(%rip)      # 0x13990
je 0x6747
movq 0xcf10(%rip), %rax      # 0x135f0
movsd 0x6b20(%rip), %xmm0     # 0xd208
subsd 0x30(%rax), %xmm0
mulsd 0xcabb(%rip), %xmm0     # 0x131b0
addsd 0x6a7b(%rip), %xmm0     # 0xd178
callq 0x22d0
cvttsd2si %xmm0, %rdx
testl %edx, %edx
sete %al
cmpl $0x10, %edx
setge %cl
orb %al, %cl
jne 0x6747
leaq 0xcd93(%rip), %rbx      # 0x134b0
leaq 0x7f02(%rip), %rsi      # 0xe626
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21a0
movq 0xd2c3(%rip), %rdi      # 0x139f8
movq %rbx, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2210
callq 0x3d76
movd 0xce95(%rip), %xmm0     # 0x135e4
pxor %xmm1, %xmm1
movdqa %xmm0, %xmm2
pcmpeqb %xmm1, %xmm2
movd %xmm2, %ecx
notb %cl
movd %xmm0, %eax
testb $0x1, %cl
je 0x6773
leal 0x1(%rax), %ecx
movb %cl, 0xce71(%rip)       # 0x135e4
movdqa %xmm0, %xmm2
pslld $0x8, %xmm2
pcmpeqb %xmm1, %xmm2
pcmpeqd %xmm1, %xmm1
pxor %xmm1, %xmm2
pextrw $0x1, %xmm2, %ecx
testb $0x1, %cl
je 0x679f
movl %eax, %ecx
shrl $0x8, %ecx
incb %cl
movb %cl, 0xce46(%rip)       # 0x135e5
pshuflw $0x55, %xmm0, %xmm3     # xmm3 = xmm0[1,1,1,1,4,5,6,7]
pxor %xmm2, %xmm2
pcmpeqb %xmm2, %xmm3
pxor %xmm1, %xmm3
pextrw $0x2, %xmm3, %ecx
testb $0x1, %cl
je 0x67c7
movl %eax, %ecx
shrl $0x10, %ecx
incb %cl
movb %cl, 0xce1f(%rip)       # 0x135e6
psllq $0x18, %xmm0
pcmpeqb %xmm2, %xmm0
pxor %xmm0, %xmm1
pextrw $0x3, %xmm1, %ecx
testb $0x1, %cl
je 0x67e9
shrl $0x18, %eax
incb %al
movb %al, 0xcdfe(%rip)       # 0x135e7
movb $0x0, 0xcdf8(%rip)      # 0x135e8
movq 0xd199(%rip), %rcx      # 0x13990
testq %rcx, %rcx
je 0x68cf
cmpw $0x0, 0x1a(%rcx)
je 0x68cf
movsd (%rcx), %xmm0
movb $0x1, %sil
ucomisd 0x691e(%rip), %xmm0     # 0xd138
ja 0x68d8
cmpb $0x0, 0xc3(%rcx)
je 0x6832
cmpb $0x0, 0xc2(%rcx)
jne 0x684c
movq 0xcdb7(%rip), %rax      # 0x135f0
movsd 0x20(%rax), %xmm0
ucomisd 0x68ea(%rip), %xmm0     # 0xd130
ja 0x68d8
movzbl 0xc96d(%rip), %eax      # 0x131c0
testq %rax, %rax
je 0x686b
movsd 0x20(%rcx), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x686f
xorl %edx, %edx
jmp 0x6896
movb $0x1, %dl
jmp 0x6896
leaq -0x1(%rax), %rdx
xorl %edi, %edi
movq %rdi, %rsi
cmpq %rdi, %rdx
je 0x688d
movsd 0x28(%rcx,%rsi,8), %xmm1
leaq 0x1(%rsi), %rdi
ucomisd %xmm0, %xmm1
jbe 0x6875
incq %rsi
cmpq %rax, %rsi
setae %dl
movzbl 0xc924(%rip), %eax      # 0x131c1
testq %rax, %rax
sete %sil
movl %edx, %edi
xorb $0x1, %dil
orb %sil, %dil
jne 0x68c8
xorl %esi, %esi
cmpw $0x0, 0xc6(%rcx,%rsi,2)
jg 0x6a7d
incq %rsi
cmpq %rax, %rsi
jb 0x68b1
movb $0x1, %sil
testb %dl, %dl
je 0x68d8
movb $0x1, 0xcd12(%rip)      # 0x135e8
xorl %esi, %esi
movl %esi, 0x4(%rsp)
movzbl 0xccfd(%rip), %ecx      # 0x135e0
xorl %edx, %edx
movl $0x0, %esi
movl $0x0, %edi
testl %ecx, %ecx
je 0x6a30
movq 0xccf2(%rip), %r8       # 0x135f0
movzbl 0xc8ba(%rip), %r9d      # 0x131c0
movzbl 0xc8b3(%rip), %r10d     # 0x131c1
leaq 0x1(%rcx), %r11
leaq -0x1(%r10), %rbx
xorl %edi, %edi
movl $0x1, %r14d
movsd 0x6842(%rip), %xmm0     # 0xd168
movsd 0x6902(%rip), %xmm1     # 0xd230
movsd 0x6872(%rip), %xmm2     # 0xd1a8
movsd 0x67f2(%rip), %xmm3     # 0xd130
xorpd %xmm4, %xmm4
movsd 0x68de(%rip), %xmm5     # 0xd228
xorl %esi, %esi
movq (%r12,%r14,8), %r13
testq %r13, %r13
je 0x69b6
cmpw $0x0, 0x1a(%r13)
je 0x69b6
movapd %xmm0, %xmm6
testq %r8, %r8
je 0x6996
movsd 0x38(%r8), %xmm6
movq (%r15,%r14,8), %rax
subsd 0x38(%rax), %xmm6
movsd 0x40(%rax), %xmm7
subsd 0x40(%r8), %xmm7
mulsd %xmm7, %xmm7
mulsd %xmm6, %xmm6
addsd %xmm7, %xmm6
sqrtsd %xmm6, %xmm6
ucomisd %xmm5, %xmm6
jbe 0x69a0
cmpb $0x0, 0xc3(%r13)
jne 0x69b2
ucomisd %xmm1, %xmm6
jbe 0x69c2
movsd 0x30(%r8), %xmm6
ucomisd %xmm2, %xmm6
jbe 0x69c2
incl %edi
jmp 0x69b8
incl %esi
incq %r14
cmpq %r11, %r14
jne 0x694c
jmp 0x6a30
movq (%r15,%r14,8), %rax
movsd 0x20(%rax), %xmm6
ucomisd %xmm3, %xmm6
ja 0x69b8
testq %r9, %r9
je 0x69ed
xorl %eax, %eax
movsd 0x20(%r13,%rax,8), %xmm6
ucomisd %xmm4, %xmm6
ja 0x69b8
incq %rax
cmpq %rax, %r9
jne 0x69d8
testq %r10, %r10
je 0x6a27
xorl %ebp, %ebp
cmpw $0x0, 0xc6(%r13)
jg 0x6a2c
xorl %ebp, %ebp
movq %rbp, %rax
cmpq %rbp, %rbx
je 0x6a19
leaq 0x1(%rax), %rbp
cmpw $0x0, 0xc8(%r13,%rax,2)
jle 0x6a01
incq %rax
xorl %ebp, %ebp
cmpq %r10, %rax
setae %bpl
jmp 0x6a2c
movl $0x1, %ebp
addl %ebp, %esi
jmp 0x69b8
cmpb $0x0, 0xcb99(%rip)      # 0x135d0
cmovel %edi, %edx
cmpb $0x0, 0x4(%rsp)
je 0x6a5e
movb $0x2, %al
cmpl %ecx, %esi
je 0x6a64
addl %esi, %edx
movb $0x3, %al
cmpl %ecx, %edx
je 0x6a64
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x6, %al
cmpl %ecx, %esi
jne 0x6a6a
movb %al, 0xcb7e(%rip)       # 0x135e8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f4b
movb $0x1, %sil
jmp 0x68d8